Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 5 | suite_tmp="$(mktemp -d)" |
| 6 | trap 'rm -rf "$suite_tmp"' EXIT |
| 7 | # Case A and recovery-path assertions compare resolved physical paths, so the |
| 8 | # suite root itself must be physical (macOS mktemp returns /var -> /private/var). |
| 9 | suite_tmp="$(cd "$suite_tmp" && pwd -P)" |
| 10 | |
| 11 | fail() { |
| 12 | printf 'FAIL: %s\n' "$*" >&2 |
| 13 | exit 1 |
| 14 | } |
| 15 | |
| 16 | assert_contains() { |
| 17 | local haystack=$1 |
| 18 | local needle=$2 |
| 19 | local label=$3 |
| 20 | grep -Fq -- "$needle" <<<"$haystack" || fail "$label (missing: $needle)" |
| 21 | } |
| 22 | |
| 23 | assert_not_contains() { |
| 24 | local haystack=$1 |
| 25 | local needle=$2 |
| 26 | local label=$3 |
| 27 | if grep -Fq -- "$needle" <<<"$haystack"; then |
| 28 | fail "$label (unexpected: $needle)" |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | # Asserts the exact final N lines of an output capture, proving nothing prints |
| 33 | # after the final action block: the ending is the instruction users copy, so |
| 34 | # the last block must win. |
| 35 | assert_tail() { |
| 36 | local haystack=$1 |
| 37 | local expected=$2 |
| 38 | local label=$3 |
| 39 | local lines actual |
| 40 | lines=$(printf '%s\n' "$expected" | wc -l | tr -d '[:space:]') |
| 41 | actual=$(printf '%s\n' "$haystack" | tail -n "$lines") |
| 42 | if [[ $actual != "$expected" ]]; then |
| 43 | printf 'FAIL: %s\nexpected tail:\n%s\nactual tail:\n%s\n' "$label" "$expected" "$actual" >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | } |
| 47 | |
| 48 | wait_for_file() { |
| 49 | local file=$1 |
| 50 | local label=$2 |
| 51 | for _ in {1..100}; do |
| 52 | [[ -f $file ]] && return 0 |
| 53 | sleep 0.05 |
| 54 | done |
| 55 | fail "$label" |
| 56 | } |
| 57 | |
| 58 | # The single confirmation both setup paths print: it names the startup files |
| 59 | # that now carry the managed block and never leaks internal vocabulary. |
| 60 | configured_line() { |
| 61 | case $1 in |
| 62 | zsh) printf 'Configured zsh shell setup in ~/.zshrc.\n' ;; |
| 63 | bash) printf 'Configured bash shell setup in ~/.bashrc and ~/.bash_profile.\n' ;; |
| 64 | fish) printf 'Configured fish shell setup in ~/.config/fish/config.fish.\n' ;; |
| 65 | *) fail "configured_line: unknown shell $1" ;; |
| 66 | esac |
| 67 | } |
| 68 | |
| 69 | # The recovery ending both failure-adjacent flows close with: an absolute, |
| 70 | # copy-paste-safe login command. "now" is the install-only success variant |
| 71 | # (setup skipped or unavailable, PATH untouched); "later" is the setup-failure |
| 72 | # variant printed on stderr after the failure warning. |
| 73 | recovery_tail() { |
| 74 | case $1 in |
| 75 | now) printf 'To get started now, run:\n\n %s login' "$2" ;; |
| 76 | later) printf 'To get started, run:\n\n %s login' "$2" ;; |
| 77 | *) fail "recovery_tail: unknown mode $1" ;; |
| 78 | esac |
| 79 | } |
| 80 | |
| 81 | # macOS Terminal.app starts bash as a login shell, which reads only the first |
| 82 | # existing of ~/.bash_profile, ~/.bash_login, ~/.profile and never ~/.bashrc. |
| 83 | # Probe a real login bash over the sandboxed HOME to prove the PATH entry |
| 84 | # actually lands somewhere it reads. |
| 85 | assert_login_bash_path() { |
| 86 | local home=$1 |
| 87 | local bin=$2 |
| 88 | local label=$3 |
| 89 | local login_path |
| 90 | login_path=$(env -i HOME="$home" PATH=/usr/bin:/bin bash -lc 'printf %s "$PATH"') || |
| 91 | fail "$label (login bash probe failed)" |
| 92 | case ":$login_path:" in |
| 93 | *":$bin:"*) ;; |
| 94 | *) fail "$label (login bash PATH lacks $bin: $login_path)" ;; |
| 95 | esac |
| 96 | } |
| 97 | |
| 98 | for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do |
| 99 | [[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\"" |
| 100 | [[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point" |
| 101 | if grep -En '(^|[[:space:]])\[\[[[:space:]]|set -[^[:space:]]*o[[:space:]]+pipefail|<\(|<<<|echo -e|(^|[[:space:]])local[[:space:]]' "$script"; then |
| 102 | fail "$script contains a non-POSIX shell construct" |
| 103 | fi |
| 104 | done |
| 105 | |
| 106 | # Concurrent installer runs must not share one rc rewrite tmp file, so the |
| 107 | # tmp suffix embeds the process id. |
| 108 | grep -Fq '.composio.tmp.$$' "$repo_root/install.sh" || |
| 109 | fail 'install.sh rc rewrites must use a per-process tmp suffix' |
| 110 | |
| 111 | # The shell variants are served as standalone scripts, so their shared logic |
| 112 | # (including the URL-validation security checks) is intentionally copied. |
| 113 | # Enforce that they stay byte-identical except for the shell each hardcodes in |
| 114 | # requested_shell(), so a fix applied to one cannot silently miss the others. |
| 115 | for variant in bash zsh fish; do |
| 116 | variant_script="$repo_root/install/$variant.sh" |
| 117 | grep -Fqx "requested_shell() { printf '%s\\n' $variant; }" "$variant_script" || |
| 118 | fail "install/$variant.sh must hardcode requested_shell() for $variant" |
| 119 | # The diff below masks every requested_shell() line, so a second overriding |
| 120 | # definition would slip through it; require exactly one such line per variant. |
| 121 | [[ $(grep -Fc 'requested_shell()' "$variant_script") -eq 1 ]] || |
| 122 | fail "install/$variant.sh must mention requested_shell() exactly once" |
| 123 | diff <(grep -Fv 'requested_shell()' "$repo_root/install/bash.sh") \ |
| 124 | <(grep -Fv 'requested_shell()' "$variant_script") >/dev/null || |
| 125 | fail "install/$variant.sh drifted from install/bash.sh outside requested_shell()" |
| 126 | done |
| 127 | |
| 128 | windows_bin="$suite_tmp/windows-bin" |
| 129 | windows_home="$suite_tmp/windows-home" |
| 130 | mkdir -p "$windows_bin" "$windows_home" |
| 131 | cat >"$windows_bin/uname" <<'EOF' |
| 132 | #!/bin/sh |
| 133 | printf '%s\n' 'MINGW64_NT-10.0 x86_64' |
| 134 | EOF |
| 135 | chmod +x "$windows_bin/uname" |
| 136 | |
| 137 | for interpreter in "$(command -v sh)"; do |
| 138 | help_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --help 2>&1) || |
| 139 | fail '--help must succeed before platform checks' |
| 140 | assert_contains "$help_output" 'Usage: install.sh' '--help output' |
| 141 | |
| 142 | if invalid_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --invalid 2>&1); then |
| 143 | fail 'unknown options must fail' |
| 144 | fi |
| 145 | assert_contains "$invalid_output" 'Unknown option: --invalid' 'argument validation order' |
| 146 | assert_not_contains "$invalid_output" 'Windows is not supported' 'argument validation must precede platform checks' |
| 147 | |
| 148 | if windows_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" 2>&1); then |
| 149 | fail 'Windows-like platforms must fail' |
| 150 | fi |
| 151 | assert_contains "$windows_output" 'Run this installer inside WSL' 'Windows guidance' |
| 152 | done |
| 153 | |
| 154 | platform=$(uname -ms) |
| 155 | case $platform in |
| 156 | 'Darwin x86_64') target=darwin-x64 ;; |
| 157 | 'Darwin arm64') target=darwin-aarch64 ;; |
| 158 | 'Linux aarch64'|'Linux arm64') target=linux-aarch64 ;; |
| 159 | 'Linux x86_64') target=linux-x64 ;; |
| 160 | *) fail "unsupported test platform: $platform" ;; |
| 161 | esac |
| 162 | |
| 163 | archive_name="composio-$target.zip" |
| 164 | stable_tag='@composio/cli@98.0.0' |
| 165 | beta_tag='@composio/cli@98.0.0-beta.123' |
| 166 | missing_asset_tag='@composio/cli@99.0.0' |
| 167 | api_base='https://api.example.test' |
| 168 | github_url='https://github.example.test' |
| 169 | archive_url="https://downloads.example.test/$stable_tag/$archive_name" |
| 170 | script_url='https://installer.example.test/install.sh' |
| 171 | |
| 172 | # Exact endings the installer must close with: plain indented lines, no box |
| 173 | # drawing, nothing after them, so the final instruction stays copy-paste safe. |
| 174 | case_a_tail=$'composio is ready.\n\n composio login' |
| 175 | case_b_tail=$'Open a new terminal, then run:\n\n composio login' |
| 176 | |
| 177 | interpreters=("$(command -v sh)") |
| 178 | if command -v dash >/dev/null 2>&1 && [[ $(command -v dash) != "${interpreters[0]}" ]]; then |
| 179 | interpreters+=("$(command -v dash)") |
| 180 | fi |
| 181 | |
| 182 | # The installer's final block depends on what the inherited PATH resolves, so |
| 183 | # strip any real composio installation from the ambient PATH to keep the |
| 184 | # resolution cases deterministic on developer machines and CI runners. |
| 185 | sanitize_path() { |
| 186 | local entry result= |
| 187 | local IFS=':' |
| 188 | for entry in $1; do |
| 189 | if [[ -n $entry && ! -x $entry/composio ]]; then |
| 190 | result+="${result:+:}$entry" |
| 191 | fi |
| 192 | done |
| 193 | printf '%s\n' "$result" |
| 194 | } |
| 195 | ambient_path=$(sanitize_path "$PATH") |
| 196 | |
| 197 | # TS/sh managed-block contract conformance: the fixtures under |
| 198 | # test/managed-block-fixtures also drive the CLI's reconciler |
| 199 | # (ts/packages/cli/test/src/install-managed-block-conformance.test.ts), so an |
| 200 | # edit to either implementation fails one of the two suites until the other |
| 201 | # side produces byte-identical output again. |
| 202 | conformance_fixtures="$repo_root/test/managed-block-fixtures" |
| 203 | conformance_functions="$suite_tmp/install-sh-functions.sh" |
| 204 | # The entry-point guard above pins install.sh to end with exactly one |
| 205 | # `main "$@"` line, so dropping the final line leaves only definitions. |
| 206 | sed '$d' "$repo_root/install.sh" >"$conformance_functions" |
| 207 | conformance_driver="$suite_tmp/conformance-driver.sh" |
| 208 | cat >"$conformance_driver" <<'EOF' |
| 209 | #!/bin/sh |
| 210 | set -eu |
| 211 | functions_file=$1 |
| 212 | rc_file=$2 |
| 213 | shell_name=$3 |
| 214 | bin_dir=$4 |
| 215 | . "$functions_file" |
| 216 | rendered=$(render_bin_dir "$bin_dir") |
| 217 | write_path_block "$rc_file" "$shell_name" "$rendered" |
| 218 | EOF |
| 219 | [[ -d $conformance_fixtures ]] || fail 'managed-block fixtures directory is missing' |
| 220 | for interpreter in "${interpreters[@]}"; do |
| 221 | interpreter_name=$(basename "$interpreter") |
| 222 | for fixture_dir in "$conformance_fixtures"/*/; do |
| 223 | fixture_name=$(basename "$fixture_dir") |
| 224 | fixture_home="$suite_tmp/conformance-$interpreter_name/$fixture_name" |
| 225 | mkdir -p "$fixture_home" |
| 226 | cp "$fixture_dir/before" "$fixture_home/rcfile" |
| 227 | fixture_bin_dir=$(sed "s|__HOME__|$fixture_home|" "$fixture_dir/bin-dir") |
| 228 | fixture_shell=$(<"$fixture_dir/shell") |
| 229 | env HOME="$fixture_home" COMPOSIO_QUIET=1 \ |
| 230 | "$interpreter" "$conformance_driver" "$conformance_functions" \ |
| 231 | "$fixture_home/rcfile" "$fixture_shell" "$fixture_bin_dir" || |
| 232 | fail "$interpreter_name managed-block conformance: $fixture_name (driver failed)" |
| 233 | cmp -s "$fixture_dir/after" "$fixture_home/rcfile" || { |
| 234 | diff -u "$fixture_dir/after" "$fixture_home/rcfile" >&2 || : |
| 235 | fail "$interpreter_name managed-block conformance: $fixture_name (output drifted)" |
| 236 | } |
| 237 | done |
| 238 | done |
| 239 | |
| 240 | for interpreter in "${interpreters[@]}"; do |
| 241 | interpreter_name=$(basename "$interpreter") |
| 242 | case_root="$suite_tmp/$interpreter_name" |
| 243 | fake_bin="$case_root/bin" |
| 244 | curl_log="$case_root/curl.log" |
| 245 | composio_log="$case_root/composio.log" |
| 246 | mkdir -p "$fake_bin" |
| 247 | : >"$curl_log" |
| 248 | : >"$composio_log" |
| 249 | |
| 250 | cat >"$fake_bin/curl" <<'EOF' |
| 251 | #!/usr/bin/env bash |
| 252 | set -euo pipefail |
| 253 | |
| 254 | printf '%s\n' "$*" >>"$TEST_CURL_LOG" |
| 255 | all_args=$* |
| 256 | output= |
| 257 | url= |
| 258 | while (($# > 0)); do |
| 259 | case $1 in |
| 260 | --output|-o) |
| 261 | output=$2 |
| 262 | shift 2 |
| 263 | ;; |
| 264 | --proto|--proto-redir) |
| 265 | shift 2 |
| 266 | ;; |
| 267 | --fail|--silent|--show-error|--location|--progress-bar) |
| 268 | shift |
| 269 | ;; |
| 270 | --*) |
| 271 | shift |
| 272 | ;; |
| 273 | *) |
| 274 | url=$1 |
| 275 | shift |
| 276 | ;; |
| 277 | esac |
| 278 | done |
| 279 | |
| 280 | case $url in |
| 281 | https://*) |
| 282 | [[ $all_args == *"--proto =https"* && $all_args == *"--proto-redir =https"* ]] || exit 91 |
| 283 | ;; |
| 284 | http://*) |
| 285 | [[ $all_args == *"--proto =http,https"* && $all_args == *"--proto-redir =https"* ]] || exit 92 |
| 286 | ;; |
| 287 | esac |
| 288 | |
| 289 | if [[ -n ${TEST_CURL_DELAY_URL:-} && $url == "$TEST_CURL_DELAY_URL" ]]; then |
| 290 | printf '%s\n' "$PPID" >"$TEST_CURL_PARENT_PID_FILE" |
| 291 | sleep "${TEST_CURL_DELAY_SECONDS:-1}" |
| 292 | fi |
| 293 | |
| 294 | if [[ $url == "$TEST_SCRIPT_URL" ]]; then |
| 295 | case ${TEST_BASE_MODE:-ok} in |
| 296 | fail) exit 22 ;; |
| 297 | empty) : >"$output" ;; |
| 298 | ok) cp "$TEST_REPO_ROOT/install.sh" "$output" ;; |
| 299 | esac |
| 300 | exit 0 |
| 301 | fi |
| 302 | |
| 303 | case $url in |
| 304 | "$TEST_API_BASE/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO/releases?per_page=100&page=1") |
| 305 | asset_url=${TEST_API_ASSET_URL:-$TEST_ARCHIVE_URL} |
| 306 | cat <<JSON |
| 307 | [ |
| 308 | {"tag_name":"$TEST_MISSING_ASSET_TAG","assets":[]}, |
| 309 | {"tag_name":"@composio/cli@99.0.0-beta.1","assets":[{"browser_download_url":"https://downloads.example.test/beta/$TEST_ARCHIVE_NAME"}]}, |
| 310 | {"tag_name":"$TEST_STABLE_TAG","assets":[{"browser_download_url":"$asset_url"}]} |
| 311 | ] |
| 312 | JSON |
| 313 | ;; |
| 314 | "$TEST_ARCHIVE_URL"|*"/releases/download/"*"/$TEST_ARCHIVE_NAME") |
| 315 | [[ -n $output ]] || exit 93 |
| 316 | if [[ ${TEST_REDIRECT_DOWNGRADE:-0} == 1 ]]; then |
| 317 | exit 47 |
| 318 | fi |
| 319 | printf 'fake archive\n' >"$output" |
| 320 | ;; |
| 321 | *"/releases/download/"*"/checksums.txt") |
| 322 | case ${TEST_CHECKSUM_MODE:-missing} in |
| 323 | missing) exit 22 ;; |
| 324 | valid) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'a' >"$output" ;; |
| 325 | mismatch) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'b' >"$output" ;; |
| 326 | malformed) printf 'not-a-hash %s\n' "$TEST_ARCHIVE_NAME" >"$output" ;; |
| 327 | absent-entry) printf '%064d %s\n' 0 'some-other-asset.zip' | tr '0' 'a' >"$output" ;; |
| 328 | esac |
| 329 | ;; |
| 330 | *) |
| 331 | printf 'unexpected curl URL: %s\n' "$url" >&2 |
| 332 | exit 94 |
| 333 | ;; |
| 334 | esac |
| 335 | EOF |
| 336 | chmod +x "$fake_bin/curl" |
| 337 | |
| 338 | cat >"$fake_bin/sha256sum" <<'EOF' |
| 339 | #!/bin/sh |
| 340 | printf '%s %s\n' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' "$1" |
| 341 | EOF |
| 342 | chmod +x "$fake_bin/sha256sum" |
| 343 | |
| 344 | cat >"$fake_bin/unzip" <<'EOF' |
| 345 | #!/usr/bin/env bash |
| 346 | set -euo pipefail |
| 347 | dest= |
| 348 | while (($# > 0)); do |
| 349 | case $1 in |
| 350 | -d) |
| 351 | dest=$2 |
| 352 | shift 2 |
| 353 | ;; |
| 354 | -*d) |
| 355 | dest=$2 |
| 356 | shift 2 |
| 357 | ;; |
| 358 | *) shift ;; |
| 359 | esac |
| 360 | done |
| 361 | [[ -n $dest ]] || exit 95 |
| 362 | bundle="$dest/composio-$TEST_TARGET" |
| 363 | mkdir -p "$bundle/services" "$bundle/acp-adapters" |
| 364 | cat >"$bundle/composio" <<'BIN' |
| 365 | #!/bin/sh |
| 366 | printf '%s|%s|%s|%s\n' "${COMPOSIO_INSTALL_HELP:-}" "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" "${COMPOSIO_BIN_DIR:-}" "$*" >>"$TEST_COMPOSIO_LOG" |
| 367 | case ${1:-} in |
| 368 | --version|version) |
| 369 | printf '%s\n' 'composio fake 98.0.0' |
| 370 | exit "${TEST_VERSION_EXIT:-0}" |
| 371 | ;; |
| 372 | setup) |
| 373 | [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 96 |
| 374 | exit "${TEST_SETUP_EXIT:-0}" |
| 375 | ;; |
| 376 | login) |
| 377 | [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 97 |
| 378 | exit 0 |
| 379 | ;; |
| 380 | install) |
| 381 | if [ "${2:-}" = --help ]; then |
| 382 | if [ "${TEST_SHELL_CAPABILITY:-supported}" = supported ]; then |
| 383 | printf '%s\n' 'Usage: composio install [--shell zsh|bash|fish]' |
| 384 | else |
| 385 | printf '%s\n' 'Usage: composio install' |
| 386 | fi |
| 387 | exit 0 |
| 388 | fi |
| 389 | if [ "${2:-}" = --shell ]; then |
| 390 | if [ "${TEST_INSTALL_HINT:-0}" = 1 ]; then |
| 391 | printf '%s\n' '│ Restart your shell so composio is on PATH │' |
| 392 | fi |
| 393 | # Mirror the reconciling CLI: write the managed block to the same startup |
| 394 | # files the installer verifies. TEST_INSTALL_RECONCILE=0 models stable |
| 395 | # CLIs that exit 0 without reconciling (they skip marker-bearing files). |
| 396 | if [ "${TEST_INSTALL_EXIT:-0}" = 0 ] && [ "${TEST_INSTALL_RECONCILE:-1}" = 1 ]; then |
| 397 | write_block() { |
| 398 | if [ -f "$1" ] && grep -Fq "$2" "$1"; then |
| 399 | return 0 |
| 400 | fi |
| 401 | printf '\n# Composio CLI\n%s\n' "$2" >>"$1" |
| 402 | } |
| 403 | case ${3:-} in |
| 404 | zsh) write_block "$HOME/.zshrc" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\"" ;; |
| 405 | fish) |
| 406 | mkdir -p "$HOME/.config/fish" |
| 407 | write_block "$HOME/.config/fish/config.fish" "set --export PATH \"$COMPOSIO_BIN_DIR\" \$PATH" |
| 408 | ;; |
| 409 | bash) |
| 410 | # Login bash never reads .bashrc, so the CLI also configures a |
| 411 | # login-mode file, creating ~/.bash_profile when no override exists. |
| 412 | # (The real CLI additionally seeds a ~/.profile passthrough into a file |
| 413 | # it creates; that belongs to the CLI and is covered by its unit tests.) |
| 414 | write_block "$HOME/.bashrc" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\"" |
| 415 | if [ ! -f "$HOME/.bash_profile" ] && [ -f "$HOME/.bash_login" ]; then |
| 416 | write_block "$HOME/.bash_login" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\"" |
| 417 | else |
| 418 | write_block "$HOME/.bash_profile" "export PATH=\"$COMPOSIO_BIN_DIR:\$PATH\"" |
| 419 | fi |
| 420 | ;; |
| 421 | esac |
| 422 | fi |
| 423 | exit "${TEST_INSTALL_EXIT:-0}" |
| 424 | fi |
| 425 | exit 98 |
| 426 | ;; |
| 427 | *) exit 0 ;; |
| 428 | esac |
| 429 | BIN |
| 430 | chmod +x "$bundle/composio" |
| 431 | printf '%s\n' 'support' >"$bundle/run-bun.mjs" |
| 432 | printf '%s\n' 'service' >"$bundle/services/example.txt" |
| 433 | EOF |
| 434 | chmod +x "$fake_bin/unzip" |
| 435 | |
| 436 | export TEST_REPO_ROOT="$repo_root" |
| 437 | export TEST_TARGET="$target" |
| 438 | export TEST_ARCHIVE_NAME="$archive_name" |
| 439 | export TEST_STABLE_TAG="$stable_tag" |
| 440 | export TEST_MISSING_ASSET_TAG="$missing_asset_tag" |
| 441 | export TEST_ARCHIVE_URL="$archive_url" |
| 442 | export TEST_API_BASE="$api_base" |
| 443 | export TEST_SCRIPT_URL="$script_url" |
| 444 | export TEST_CURL_LOG="$curl_log" |
| 445 | export TEST_COMPOSIO_LOG="$composio_log" |
| 446 | |
| 447 | reset_case() { |
| 448 | unset CASE_UNSET_PLUGINS CASE_GITHUB_URL CASE_GITHUB_OWNER CASE_GITHUB_REPO CASE_API_BASE CASE_INSTALL_VERSION CASE_INSTALL_SHELL CASE_PLUGINS CASE_QUIET CASE_DEBUG CASE_HELP |
| 449 | unset CASE_ALLOW_HTTP_HOST CASE_CHECKSUM_MODE CASE_API_ASSET_URL CASE_BASE_MODE CASE_REDIRECT_DOWNGRADE |
| 450 | unset CASE_SHELL_CAPABILITY CASE_INSTALL_EXIT CASE_SETUP_EXIT CASE_VERSION_EXIT CASE_PATH_PREFIX CASE_UNSET_SHELL |
| 451 | unset CASE_CURL_DELAY_URL CASE_CURL_DELAY_SECONDS CASE_SHELL_VALUE CASE_INSTALL_HINT CASE_INSTALL_RECONCILE |
| 452 | rm -f "$case_root/curl-parent.pid" |
| 453 | : >"$curl_log" |
| 454 | : >"$composio_log" |
| 455 | } |
| 456 | |
| 457 | # Env assignments shared by run_installer and run_variant. Emitted into |
| 458 | # common_env_args; each runner appends its own entry-point-specific overrides. |
| 459 | common_env() { |
| 460 | local home=$1 |
| 461 | local install_dir=$2 |
| 462 | local bin_dir=$3 |
| 463 | common_env_args=( |
| 464 | HOME="$home" |
| 465 | COMPOSIO_INSTALL_DIR="$install_dir" |
| 466 | COMPOSIO_BIN_DIR="$bin_dir" |
| 467 | COMPOSIO_GITHUB_URL="${CASE_GITHUB_URL:-$github_url}" |
| 468 | # CASE_API_BASE set-but-empty passes an empty API base through, which the |
| 469 | # installer treats as "no override" (official-source cases need this). |
| 470 | COMPOSIO_GITHUB_API_BASE_URL="${CASE_API_BASE-$api_base}" |
| 471 | COMPOSIO_GITHUB_OWNER="${CASE_GITHUB_OWNER:-FakeOwner}" |
| 472 | COMPOSIO_GITHUB_REPO="${CASE_GITHUB_REPO:-fake-repo}" |
| 473 | TEST_CHECKSUM_MODE="${CASE_CHECKSUM_MODE:-missing}" |
| 474 | TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" |
| 475 | TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" |
| 476 | TEST_CURL_DELAY_URL="${CASE_CURL_DELAY_URL:-}" |
| 477 | TEST_CURL_DELAY_SECONDS="${CASE_CURL_DELAY_SECONDS:-1}" |
| 478 | TEST_CURL_PARENT_PID_FILE="$case_root/curl-parent.pid" |
| 479 | ) |
| 480 | if [[ ${CASE_UNSET_PLUGINS:-0} != 1 ]]; then |
| 481 | common_env_args+=(COMPOSIO_INSTALL_PLUGINS="${CASE_PLUGINS:-0}") |
| 482 | fi |
| 483 | } |
| 484 | |
| 485 | run_installer() { |
| 486 | local home=$1 |
| 487 | local install_dir=$2 |
| 488 | local bin_dir=$3 |
| 489 | shift 3 |
| 490 | mkdir -p "$home" "$install_dir" "$bin_dir" |
| 491 | local -a installer_command=("$interpreter" "$repo_root/install.sh") |
| 492 | if [[ ${CASE_UNSET_SHELL:-0} == 1 ]]; then |
| 493 | installer_command=("$interpreter" -c 'unset SHELL; script=$1; shift; . "$script"' unset-shell "$repo_root/install.sh") |
| 494 | fi |
| 495 | common_env "$home" "$install_dir" "$bin_dir" |
| 496 | env -u COMPOSIO_INSTALL_PLUGINS \ |
| 497 | PATH="${CASE_PATH_PREFIX:-}$fake_bin:$ambient_path" \ |
| 498 | SHELL="${CASE_SHELL_VALUE:-/bin/bash}" \ |
| 499 | "${common_env_args[@]}" \ |
| 500 | COMPOSIO_INSTALL_VERSION="${CASE_INSTALL_VERSION:-}" \ |
| 501 | COMPOSIO_INSTALL_SHELL="${CASE_INSTALL_SHELL:-}" \ |
| 502 | COMPOSIO_QUIET="${CASE_QUIET:-0}" \ |
| 503 | COMPOSIO_DEBUG="${CASE_DEBUG:-0}" \ |
| 504 | COMPOSIO_INSTALL_HELP="${CASE_HELP:-1}" \ |
| 505 | COMPOSIO_INSTALL_ALLOW_HTTP_HOST="${CASE_ALLOW_HTTP_HOST:-}" \ |
| 506 | TEST_API_ASSET_URL="${CASE_API_ASSET_URL:-}" \ |
| 507 | TEST_REDIRECT_DOWNGRADE="${CASE_REDIRECT_DOWNGRADE:-0}" \ |
| 508 | TEST_INSTALL_HINT="${CASE_INSTALL_HINT:-0}" \ |
| 509 | TEST_INSTALL_RECONCILE="${CASE_INSTALL_RECONCILE:-1}" \ |
| 510 | TEST_SETUP_EXIT="${CASE_SETUP_EXIT:-0}" \ |
| 511 | TEST_VERSION_EXIT="${CASE_VERSION_EXIT:-0}" \ |
| 512 | "${installer_command[@]}" "$@" |
| 513 | } |
| 514 | |
| 515 | run_variant() { |
| 516 | local shell_name=$1 |
| 517 | local home=$2 |
| 518 | local install_dir=$3 |
| 519 | local bin_dir=$4 |
| 520 | shift 4 |
| 521 | mkdir -p "$home" "$install_dir" "$bin_dir" |
| 522 | common_env "$home" "$install_dir" "$bin_dir" |
| 523 | env -u COMPOSIO_INSTALL_PLUGINS \ |
| 524 | PATH="$fake_bin:$ambient_path" \ |
| 525 | SHELL="/bin/$shell_name" \ |
| 526 | "${common_env_args[@]}" \ |
| 527 | COMPOSIO_INSTALL_SCRIPT_URL="$script_url" \ |
| 528 | TEST_BASE_MODE="${CASE_BASE_MODE:-ok}" \ |
| 529 | TEST_INSTALL_RECONCILE="${CASE_INSTALL_RECONCILE:-1}" \ |
| 530 | "$interpreter" "$repo_root/install/$shell_name.sh" "$@" |
| 531 | } |
| 532 | |
| 533 | reset_case |
| 534 | home="$case_root/default-home" |
| 535 | install_dir="$case_root/default-install" |
| 536 | bin_dir="$case_root/default-bin" |
| 537 | output=$(run_installer "$home" "$install_dir" "$bin_dir" 2>&1) |
| 538 | [[ $(<"$install_dir/release-tag.txt") == "$stable_tag" ]] || fail "$interpreter_name latest stable resolution" |
| 539 | [[ -x "$install_dir/composio" && -f "$install_dir/run-bun.mjs" ]] || fail "$interpreter_name bundle installation" |
| 540 | [[ -L "$bin_dir/composio" ]] || fail "$interpreter_name entry-point symlink" |
| 541 | expected_install_dir=$(cd "$install_dir" && pwd -P) |
| 542 | [[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target" |
| 543 | assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery" |
| 544 | grep -Fq "|installer|$bin_dir|install --shell bash" "$composio_log" || fail "$interpreter_name default auto delegation" |
| 545 | assert_contains "$output" "$(configured_line bash)" "$interpreter_name default auto confirmation" |
| 546 | assert_not_contains "$output" '(cli)' "$interpreter_name confirmation must not leak internal labels" |
| 547 | assert_not_contains "$output" '(fallback)' "$interpreter_name confirmation must not leak internal labels" |
| 548 | # Inherited-PATH contract: the installer prepends the bin dir to its own PATH |
| 549 | # for delegated CLI calls, but the ending must reflect only the PATH the |
| 550 | # invoking terminal inherited, which does not contain the bin dir here. |
| 551 | assert_tail "$output" "$case_b_tail" "$interpreter_name default auto Case B tail" |
| 552 | grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bashrc" || fail "$interpreter_name delegated default flow rc written by the CLI" |
| 553 | # A login bash reads none of ~/.bashrc, so the delegated path must reach a |
| 554 | # login-mode startup file as well. |
| 555 | grep -Fq "export PATH=\"$bin_dir:\$PATH\"" "$home/.bash_profile" || |
| 556 | fail "$interpreter_name delegated default flow login file written by the CLI" |
| 557 | assert_login_bash_path "$home" "$bin_dir" "$interpreter_name delegated default flow login shell" |
| 558 | assert_not_contains "$output" 'Updated ~/.bashrc' "$interpreter_name delegated default flow must not rewrite rc files inline" |
| 559 | [[ $(wc -l <"$composio_log") -eq 3 ]] || fail "$interpreter_name default flow invoked extra CLI commands" |
| 560 | grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe" |
| 561 | [[ ! -s "$case_root/git.log" ]] || fail "$interpreter_name must not use git" |
| 562 | |
| 563 | reset_case |
| 564 | equal_dir="$case_root/equal-layout" |
| 565 | run_installer "$case_root/equal-home" "$equal_dir" "$equal_dir" "$beta_tag" >/dev/null 2>&1 |
| 566 | [[ -x "$equal_dir/composio" && ! -L "$equal_dir/composio" ]] || fail "$interpreter_name equal-dir layout" |
| 567 | [[ $(<"$equal_dir/release-tag.txt") == "$beta_tag" ]] || fail "$interpreter_name explicit beta tag" |
| 568 | |
| 569 | reset_case |
| 570 | upgrade_home="$case_root/upgrade-home" |
| 571 | upgrade_install="$case_root/upgrade-install" |
| 572 | upgrade_bin="$case_root/upgrade-bin" |
| 573 | mkdir -p "$upgrade_install/services" |
| 574 | printf '%s\n' stale >"$upgrade_install/services/stale.txt" |
| 575 | printf '%s\n' old-binary >"$upgrade_install/composio" |
| 576 | run_installer "$upgrade_home" "$upgrade_install" "$upgrade_bin" "$stable_tag" >/dev/null 2>&1 |
| 577 | [[ -x "$upgrade_install/composio" ]] || fail "$interpreter_name upgrade must replace the existing binary" |
| 578 | [[ $(<"$upgrade_install/services/example.txt") == service ]] || fail "$interpreter_name upgrade must install new support files" |
| 579 | [[ ! -e "$upgrade_install/services/stale.txt" ]] || fail "$interpreter_name upgrade must replace bundle directories wholesale" |
| 580 | [[ -z $(find "$upgrade_install" -maxdepth 1 -name '.composio-install-staging.*' -print -quit) ]] || |
| 581 | fail "$interpreter_name upgrade must clean up the staging directory" |
| 582 | |
| 583 | reset_case |
| 584 | legacy_home="$case_root/legacy-home" |
| 585 | mkdir -p "$legacy_home" |
| 586 | printf '%s\n' 'export COMPOSIO_INSTALL_DIR="$HOME/.composio"' >"$legacy_home/.bashrc" |
| 587 | run_installer "$legacy_home" "$case_root/legacy-install" "$case_root/legacy-bin" "$stable_tag" >/dev/null 2>&1 |
| 588 | [[ -L "$case_root/legacy-bin/composio" ]] || fail "$interpreter_name legacy migration symlink" |
| 589 | grep -Fq 'COMPOSIO_INSTALL_DIR' "$legacy_home/.bashrc" || fail "$interpreter_name must preserve legacy rc content" |
| 590 | |
| 591 | reset_case |
| 592 | replacement_bin="$case_root/replacement-bin" |
| 593 | mkdir -p "$replacement_bin" |
| 594 | printf '%s\n' old >"$replacement_bin/composio" |
| 595 | run_installer "$case_root/replacement-home" "$case_root/replacement-install" "$replacement_bin" "$stable_tag" >/dev/null 2>&1 |
| 596 | [[ -L "$replacement_bin/composio" ]] || fail "$interpreter_name regular entry point replacement" |
| 597 | |
| 598 | reset_case |
| 599 | directory_bin="$case_root/directory-bin" |
| 600 | mkdir -p "$directory_bin/composio" |
| 601 | if directory_output=$(run_installer "$case_root/directory-home" "$case_root/directory-install" "$directory_bin" "$stable_tag" 2>&1); then |
| 602 | fail "$interpreter_name directory entry point must fail" |
| 603 | fi |
| 604 | assert_contains "$directory_output" 'because it is a directory' "$interpreter_name directory error" |
| 605 | |
| 606 | reset_case |
| 607 | CASE_INSTALL_VERSION=97.0.0 |
| 608 | precedence_install="$case_root/precedence-install" |
| 609 | run_installer "$case_root/precedence-home" "$precedence_install" "$case_root/precedence-bin" 96.0.0 >/dev/null 2>&1 |
| 610 | [[ $(<"$precedence_install/release-tag.txt") == '@composio/cli@96.0.0' ]] || fail "$interpreter_name version precedence" |
| 611 | |
| 612 | reset_case |
| 613 | CASE_INSTALL_VERSION=95.0.0-beta.7 |
| 614 | env_version_install="$case_root/env-version-install" |
| 615 | run_installer "$case_root/env-version-home" "$env_version_install" "$case_root/env-version-bin" >/dev/null 2>&1 |
| 616 | [[ $(<"$env_version_install/release-tag.txt") == '@composio/cli@95.0.0-beta.7' ]] || fail "$interpreter_name env beta normalization" |
| 617 | |
| 618 | reset_case |
| 619 | if malformed_output=$(run_installer "$case_root/malformed-home" "$case_root/malformed-install" "$case_root/malformed-bin" 1.2.3-rc.1 2>&1); then |
| 620 | fail "$interpreter_name malformed prerelease must fail" |
| 621 | fi |
| 622 | assert_contains "$malformed_output" 'Invalid Composio CLI version' "$interpreter_name malformed version" |
| 623 | [[ ! -s "$curl_log" ]] || fail "$interpreter_name malformed version must fail before network" |
| 624 | |
| 625 | reset_case |
| 626 | CASE_CHECKSUM_MODE=valid |
| 627 | run_installer "$case_root/checksum-home" "$case_root/checksum-install" "$case_root/checksum-bin" "$stable_tag" >/dev/null 2>&1 |
| 628 | |
| 629 | for checksum_mode in mismatch malformed; do |
| 630 | reset_case |
| 631 | CASE_CHECKSUM_MODE=$checksum_mode |
| 632 | if checksum_output=$(run_installer "$case_root/$checksum_mode-home" "$case_root/$checksum_mode-install" "$case_root/$checksum_mode-bin" "$stable_tag" 2>&1); then |
| 633 | fail "$interpreter_name $checksum_mode checksum must fail" |
| 634 | fi |
| 635 | grep -qi 'checksum' <<<"$checksum_output" || fail "$interpreter_name $checksum_mode checksum error" |
| 636 | done |
| 637 | |
| 638 | # Overridden sources (mirrors, test hosts) keep the lenient behavior: a |
| 639 | # missing checksums.txt or a manifest without an entry for the archive warns |
| 640 | # and the install proceeds. |
| 641 | reset_case |
| 642 | CASE_CHECKSUM_MODE=missing |
| 643 | lenient_output=$(run_installer "$case_root/lenient-home" "$case_root/lenient-install" "$case_root/lenient-bin" "$stable_tag" 2>&1) || |
| 644 | fail "$interpreter_name overridden source with missing checksums.txt must proceed" |
| 645 | assert_contains "$lenient_output" 'No checksums.txt in this release; continuing without verification' \ |
| 646 | "$interpreter_name overridden-source missing manifest warning" |
| 647 | [[ -x "$case_root/lenient-install/composio" ]] || fail "$interpreter_name overridden-source missing manifest must still install" |
| 648 | |
| 649 | reset_case |
| 650 | CASE_CHECKSUM_MODE=absent-entry |
| 651 | entry_lenient_output=$(run_installer "$case_root/entry-lenient-home" "$case_root/entry-lenient-install" "$case_root/entry-lenient-bin" "$stable_tag" 2>&1) || |
| 652 | fail "$interpreter_name overridden source with no checksum entry must proceed" |
| 653 | assert_contains "$entry_lenient_output" 'No checksum entry found' "$interpreter_name overridden-source absent entry warning" |
| 654 | |
| 655 | # The official ComposioHQ source always publishes complete checksums, so the |
| 656 | # installer must hard-fail there when the manifest or the entry is missing. |
| 657 | # The env triple below matches the installer defaults exactly; the pinned |
| 658 | # version tag keeps the release API (and its overridden base) out of play. |
| 659 | official_env() { |
| 660 | CASE_GITHUB_URL=https://github.com |
| 661 | CASE_GITHUB_OWNER=ComposioHQ |
| 662 | CASE_GITHUB_REPO=composio |
| 663 | CASE_API_BASE= |
| 664 | } |
| 665 | |
| 666 | reset_case |
| 667 | official_env |
| 668 | CASE_CHECKSUM_MODE=valid |
| 669 | run_installer "$case_root/official-valid-home" "$case_root/official-valid-install" "$case_root/official-valid-bin" "$stable_tag" >/dev/null 2>&1 || |
| 670 | fail "$interpreter_name official source with a valid checksum must install" |
| 671 | [[ -x "$case_root/official-valid-install/composio" ]] || fail "$interpreter_name official-source valid checksum install" |
| 672 | |
| 673 | reset_case |
| 674 | official_env |
| 675 | CASE_CHECKSUM_MODE=missing |
| 676 | if official_missing_output=$(run_installer "$case_root/official-missing-home" "$case_root/official-missing-install" "$case_root/official-missing-bin" "$stable_tag" 2>&1); then |
| 677 | fail "$interpreter_name official source with a missing checksums.txt must fail" |
| 678 | fi |
| 679 | assert_contains "$official_missing_output" 'Failed to download checksums.txt' "$interpreter_name official missing manifest error" |
| 680 | [[ ! -e "$case_root/official-missing-install/composio" ]] || fail "$interpreter_name official missing manifest must not install" |
| 681 | |
| 682 | reset_case |
| 683 | official_env |
| 684 | CASE_CHECKSUM_MODE=absent-entry |
| 685 | if official_entry_output=$(run_installer "$case_root/official-entry-home" "$case_root/official-entry-install" "$case_root/official-entry-bin" "$stable_tag" 2>&1); then |
| 686 | fail "$interpreter_name official source with no checksum entry must fail" |
| 687 | fi |
| 688 | assert_contains "$official_entry_output" 'checksums.txt has no entry for' "$interpreter_name official absent entry error" |
| 689 | [[ ! -e "$case_root/official-entry-install/composio" ]] || fail "$interpreter_name official absent entry must not install" |
| 690 | |
| 691 | reset_case |
| 692 | CASE_UNSET_PLUGINS=1 |
| 693 | run_installer "$case_root/default-plugins-home" "$case_root/default-plugins-install" "$case_root/default-plugins-bin" "$stable_tag" >/dev/null 2>&1 |
| 694 | grep -Eq '\|installer\|[^|]*\|setup --target auto --yes --if-present$' "$composio_log" || fail "$interpreter_name plugin setup enabled by default" |
| 695 | |
| 696 | for plugin_mode in env-zero flag flag-overrides-env; do |
| 697 | reset_case |
| 698 | plugin_args=("$stable_tag") |
| 699 | case "$plugin_mode" in |
| 700 | env-zero) CASE_PLUGINS=0 ;; |
| 701 | flag) CASE_UNSET_PLUGINS=1; plugin_args=(--no-plugins "$stable_tag") ;; |
| 702 | flag-overrides-env) CASE_PLUGINS=1; plugin_args=(--no-plugins "$stable_tag") ;; |
| 703 | esac |
| 704 | run_installer "$case_root/$plugin_mode-home" "$case_root/$plugin_mode-install" "$case_root/$plugin_mode-bin" "${plugin_args[@]}" >/dev/null 2>&1 |
| 705 | if grep -q 'setup --target' "$composio_log"; then |
| 706 | fail "$interpreter_name plugin opt-out $plugin_mode" |
| 707 | fi |
| 708 | done |
| 709 | |
| 710 | reset_case |
| 711 | CASE_UNSET_PLUGINS=1 |
| 712 | CASE_SETUP_EXIT=1 |
| 713 | if plugin_failure_output=$(run_installer "$case_root/plugin-failure-home" "$case_root/plugin-failure-install" "$case_root/plugin-failure-bin" "$stable_tag" 2>&1); then |
| 714 | fail "$interpreter_name plugin setup failure must fail installation" |
| 715 | fi |
| 716 | [[ -x "$case_root/plugin-failure-install/composio" ]] || fail "$interpreter_name plugin failure preserves CLI binary" |
| 717 | assert_contains "$plugin_failure_output" 'agent plugin setup failed' "$interpreter_name plugin failure reported" |
| 718 | assert_contains "$plugin_failure_output" 'composio setup --target auto --yes' "$interpreter_name plugin recovery command" |
| 719 | |
| 720 | reset_case |
| 721 | CASE_PLUGINS=1 |
| 722 | run_installer "$case_root/plugins-home" "$case_root/plugins-install" "$case_root/plugins-bin" "$stable_tag" >/dev/null 2>&1 |
| 723 | grep -Eq '\|installer\|[^|]*\|setup --target auto --yes --if-present$' "$composio_log" || fail "$interpreter_name plugin opt-in" |
| 724 | |
| 725 | reset_case |
| 726 | CASE_QUIET=1 |
| 727 | quiet_output=$(run_installer "$case_root/quiet-home" "$case_root/quiet-install" "$case_root/quiet-bin" "$stable_tag" 2>&1) |
| 728 | assert_not_contains "$quiet_output" 'Installing Composio CLI' "$interpreter_name quiet output" |
| 729 | assert_not_contains "$quiet_output" 'composio login' "$interpreter_name quiet suppresses the normal-success final block" |
| 730 | assert_not_contains "$quiet_output" 'composio is ready' "$interpreter_name quiet suppresses the normal-success final block" |
| 731 | assert_not_contains "$quiet_output" 'Open a new terminal' "$interpreter_name quiet suppresses the normal-success final block" |
| 732 | |
| 733 | reset_case |
| 734 | CASE_DEBUG=1 |
| 735 | debug_output=$(run_installer "$case_root/debug-home" "$case_root/debug-install" "$case_root/debug-bin" "$stable_tag" 2>&1) |
| 736 | assert_contains "$debug_output" '+ curl GET' "$interpreter_name debug traces" |
| 737 | |
| 738 | reset_case |
| 739 | CASE_HELP=0 |
| 740 | help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1) |
| 741 | assert_contains "$help_suppressed" "$(configured_line bash)" "$interpreter_name help suppression keeps setup status" |
| 742 | assert_not_contains "$help_suppressed" 'composio login' "$interpreter_name help suppression removes the final block" |
| 743 | assert_not_contains "$help_suppressed" 'Open a new terminal' "$interpreter_name help suppression removes the final block" |
| 744 | |
| 745 | reset_case |
| 746 | CASE_UNSET_SHELL=1 |
| 747 | unset_shell_install="$case_root/unset-shell-install" |
| 748 | unset_shell_output=$(run_installer "$case_root/unset-shell-home" "$unset_shell_install" "$case_root/unset-shell-bin" "$stable_tag" 2>&1) || |
| 749 | fail "$interpreter_name unset SHELL must not fail after installation" |
| 750 | if grep -Fq 'install --shell' "$composio_log"; then |
| 751 | fail "$interpreter_name unset SHELL must not run shell setup" |
| 752 | fi |
| 753 | assert_tail "$unset_shell_output" "$(recovery_tail now "$unset_shell_install/composio")" "$interpreter_name unset SHELL install-only tail" |
| 754 | |
| 755 | # Runs the given command in the background, SIGTERMs it once the delayed |
| 756 | # download is reached, and asserts the process exits with 128+15. |
| 757 | assert_sigterm_143() { |
| 758 | local label=$1 |
| 759 | local output_file=$2 |
| 760 | shift 2 |
| 761 | "$@" >"$output_file" 2>&1 & |
| 762 | local signal_job=$! |
| 763 | wait_for_file "$case_root/curl-parent.pid" "$interpreter_name $label did not reach delayed download" |
| 764 | local signal_pid |
| 765 | signal_pid=$(<"$case_root/curl-parent.pid") |
| 766 | kill -TERM "$signal_pid" |
| 767 | local signal_status=0 |
| 768 | if wait "$signal_job"; then |
| 769 | fail "$interpreter_name $label must terminate after SIGTERM" |
| 770 | else |
| 771 | signal_status=$? |
| 772 | fi |
| 773 | [[ $signal_status -eq 143 ]] || fail "$interpreter_name $label SIGTERM status (got $signal_status)" |
| 774 | } |
| 775 | |
| 776 | reset_case |
| 777 | CASE_CURL_DELAY_URL="$github_url/FakeOwner/fake-repo/releases/download/$stable_tag/$archive_name" |
| 778 | assert_sigterm_143 'installer' "$case_root/signal-installer.log" \ |
| 779 | run_installer "$case_root/signal-home" "$case_root/signal-install" "$case_root/signal-bin" "$stable_tag" |
| 780 | |
| 781 | reset_case |
| 782 | CASE_CURL_DELAY_URL=$script_url |
| 783 | assert_sigterm_143 'shell variant' "$case_root/signal-variant.log" \ |
| 784 | run_variant zsh "$case_root/signal-variant-home" "$case_root/signal-variant-install" "$case_root/signal-variant-bin" "$stable_tag" |
| 785 | |
| 786 | reset_case |
| 787 | CASE_GITHUB_URL='http://127.0.0.1:8929' |
| 788 | CASE_API_BASE='http://127.0.0.1:8929/api' |
| 789 | run_installer "$case_root/loopback-home" "$case_root/loopback-install" "$case_root/loopback-bin" "$stable_tag" >/dev/null 2>&1 |
| 790 | grep -Fq -- '--proto =http,https --proto-redir =https' "$curl_log" || fail "$interpreter_name loopback protocol flags" |
| 791 | |
| 792 | for unsafe_url in 'http://evil.example' 'http://user@127.0.0.1:8929' 'http://127.0.0.1.evil.example'; do |
| 793 | reset_case |
| 794 | CASE_GITHUB_URL=$unsafe_url |
| 795 | if run_installer "$case_root/unsafe-home-${RANDOM}" "$case_root/unsafe-install-${RANDOM}" "$case_root/unsafe-bin-${RANDOM}" "$stable_tag" >/dev/null 2>&1; then |
| 796 | fail "$interpreter_name unsafe configured URL accepted: $unsafe_url" |
| 797 | fi |
| 798 | [[ ! -s "$curl_log" ]] || fail "$interpreter_name unsafe configured URL reached curl" |
| 799 | done |
| 800 | |
| 801 | reset_case |
| 802 | CASE_GITHUB_URL='http://host.docker.internal:8080' |
| 803 | CASE_API_BASE='http://host.docker.internal:8080/api' |
| 804 | if run_installer "$case_root/docker-denied-home" "$case_root/docker-denied-install" "$case_root/docker-denied-bin" "$stable_tag" >/dev/null 2>&1; then |
| 805 | fail "$interpreter_name host.docker.internal must require opt-in" |
| 806 | fi |
| 807 | CASE_ALLOW_HTTP_HOST=host.docker.internal |
| 808 | run_installer "$case_root/docker-home" "$case_root/docker-install" "$case_root/docker-bin" "$stable_tag" >/dev/null 2>&1 |
| 809 | |
| 810 | reset_case |
| 811 | CASE_API_ASSET_URL="http://evil.example/$archive_name" |
| 812 | if api_unsafe_output=$(run_installer "$case_root/api-unsafe-home" "$case_root/api-unsafe-install" "$case_root/api-unsafe-bin" 2>&1); then |
| 813 | fail "$interpreter_name unsafe API asset URL accepted" |
| 814 | fi |
| 815 | assert_contains "$api_unsafe_output" 'unsafe archive URL' "$interpreter_name unsafe API URL" |
| 816 | |
| 817 | reset_case |
| 818 | CASE_REDIRECT_DOWNGRADE=1 |
| 819 | if run_installer "$case_root/downgrade-home" "$case_root/downgrade-install" "$case_root/downgrade-bin" "$stable_tag" >/dev/null 2>&1; then |
| 820 | fail "$interpreter_name redirect downgrade simulation must fail" |
| 821 | fi |
| 822 | [[ ! -e "$case_root/downgrade-bin/composio" ]] || fail "$interpreter_name failed download must not install" |
| 823 | |
| 824 | for shell_name in zsh bash fish; do |
| 825 | reset_case |
| 826 | variant_home="$case_root/variant-$shell_name-home" |
| 827 | variant_install="$case_root/variant-$shell_name-install" |
| 828 | variant_bin="$case_root/variant-$shell_name-bin" |
| 829 | variant_output=$(run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins 2>&1) |
| 830 | expected_variant_bin=$(cd "$variant_bin" && pwd -P) |
| 831 | grep -Fq "|installer|$expected_variant_bin|install --shell $shell_name" "$composio_log" || |
| 832 | fail "$interpreter_name $shell_name variant delegation" |
| 833 | assert_contains "$variant_output" "$(configured_line "$shell_name")" "$interpreter_name $shell_name variant confirmation" |
| 834 | assert_not_contains "$variant_output" 'Required next step' "$interpreter_name $shell_name variant must not print setup guidance" |
| 835 | assert_not_contains "$variant_output" 'Optional shell setup' "$interpreter_name $shell_name variant must not print setup guidance" |
| 836 | done |
| 837 | |
| 838 | reset_case |
| 839 | CASE_INSTALL_SHELL=zsh |
| 840 | direct_home="$case_root/direct-shell-home" |
| 841 | direct_bin="$case_root/direct-shell-bin" |
| 842 | direct_output=$(run_installer "$direct_home" "$case_root/direct-shell-install" "$direct_bin" "$stable_tag" 2>&1) |
| 843 | expected_direct_bin=$(cd "$direct_bin" && pwd -P) |
| 844 | grep -Fq "|installer|$expected_direct_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL delegation" |
| 845 | assert_contains "$direct_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL confirmation" |
| 846 | assert_not_contains "$direct_output" 'Required next step' "$interpreter_name COMPOSIO_INSTALL_SHELL must not print setup guidance" |
| 847 | assert_tail "$direct_output" "$case_b_tail" "$interpreter_name COMPOSIO_INSTALL_SHELL Case B tail" |
| 848 | grep -Fq "export PATH=\"$direct_bin:\$PATH\"" "$direct_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL CLI-written block" |
| 849 | assert_not_contains "$direct_output" 'Updated ~/.zshrc' "$interpreter_name COMPOSIO_INSTALL_SHELL CLI path must not rewrite rc files inline" |
| 850 | |
| 851 | reset_case |
| 852 | CASE_INSTALL_SHELL=zsh |
| 853 | relative_work="$case_root/relative-shell-work" |
| 854 | relative_home="$case_root/relative-shell-home" |
| 855 | relative_install="$case_root/relative-shell-install" |
| 856 | mkdir -p "$relative_work" |
| 857 | (cd "$relative_work" && run_installer "$relative_home" "$relative_install" relative-bin "$stable_tag" >/dev/null 2>&1) |
| 858 | expected_relative_bin=$(cd "$relative_work/relative-bin" && pwd -P) |
| 859 | grep -Fq "|installer|$expected_relative_bin|install --shell zsh" "$composio_log" || |
| 860 | fail "$interpreter_name relative COMPOSIO_BIN_DIR delegation must receive the resolved absolute path" |
| 861 | |
| 862 | reset_case |
| 863 | CASE_INSTALL_SHELL=zsh |
| 864 | CASE_SHELL_CAPABILITY=unsupported |
| 865 | relative_fallback_work="$case_root/relative-fallback-work" |
| 866 | relative_fallback_home="$case_root/relative-fallback-home" |
| 867 | relative_fallback_install="$case_root/relative-fallback-install" |
| 868 | mkdir -p "$relative_fallback_work" |
| 869 | (cd "$relative_fallback_work" && run_installer "$relative_fallback_home" "$relative_fallback_install" relative-bin "$stable_tag" >/dev/null 2>&1) |
| 870 | expected_relative_fallback_bin=$(cd "$relative_fallback_work/relative-bin" && pwd -P) |
| 871 | grep -Fq "export PATH=\"$expected_relative_fallback_bin:\$PATH\"" "$relative_fallback_home/.zshrc" || |
| 872 | fail "$interpreter_name relative COMPOSIO_BIN_DIR fallback must persist the resolved absolute path" |
| 873 | |
| 874 | reset_case |
| 875 | CASE_INSTALL_SHELL=zsh |
| 876 | CASE_SHELL_CAPABILITY=unsupported |
| 877 | direct_fallback_home="$case_root/direct-fallback-home" |
| 878 | direct_fallback_output=$(run_installer "$direct_fallback_home" "$case_root/direct-fallback-install" "$case_root/direct-fallback-bin" "$stable_tag" 2>&1) |
| 879 | grep -Fqx '# Composio CLI' "$direct_fallback_home/.zshrc" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL unsupported CLI fallback" |
| 880 | assert_contains "$direct_fallback_output" "$(configured_line zsh)" "$interpreter_name COMPOSIO_INSTALL_SHELL fallback confirmation" |
| 881 | |
| 882 | reset_case |
| 883 | CASE_INSTALL_SHELL=fish |
| 884 | CASE_INSTALL_EXIT=23 |
| 885 | direct_failed_home="$case_root/direct-failed-home" |
| 886 | run_installer "$direct_failed_home" "$case_root/direct-failed-install" "$case_root/direct-failed-bin" "$stable_tag" >/dev/null 2>&1 |
| 887 | grep -Fqx '# Composio CLI' "$direct_failed_home/.config/fish/config.fish" || fail "$interpreter_name COMPOSIO_INSTALL_SHELL failed delegation fallback" |
| 888 | |
| 889 | reset_case |
| 890 | CASE_INSTALL_SHELL=tcsh |
| 891 | if invalid_shell_output=$(run_installer "$case_root/invalid-shell-home" "$case_root/invalid-shell-install" "$case_root/invalid-shell-bin" 2>&1); then |
| 892 | fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail" |
| 893 | fi |
| 894 | assert_contains "$invalid_shell_output" 'COMPOSIO_INSTALL_SHELL must be auto, zsh, bash, fish, or none' "$interpreter_name invalid COMPOSIO_INSTALL_SHELL message" |
| 895 | [[ ! -s "$curl_log" ]] || fail "$interpreter_name invalid COMPOSIO_INSTALL_SHELL must fail before network" |
| 896 | |
| 897 | reset_case |
| 898 | CASE_SHELL_CAPABILITY=unsupported |
| 899 | fallback_home="$case_root/fallback-home" |
| 900 | run_variant zsh "$fallback_home" "$case_root/fallback-install" "$case_root/fallback-bin" "$stable_tag" >/dev/null 2>&1 |
| 901 | grep -Fqx '# Composio CLI' "$fallback_home/.zshrc" || fail "$interpreter_name unsupported CLI fallback" |
| 902 | |
| 903 | reset_case |
| 904 | CASE_INSTALL_EXIT=23 |
| 905 | failed_install_home="$case_root/failed-install-home" |
| 906 | run_variant zsh "$failed_install_home" "$case_root/failed-install-dir" "$case_root/failed-install-bin" "$stable_tag" >/dev/null 2>&1 |
| 907 | grep -Fqx '# Composio CLI' "$failed_install_home/.zshrc" || fail "$interpreter_name failed --shell fallback" |
| 908 | |
| 909 | reset_case |
| 910 | CASE_SHELL_CAPABILITY=unsupported |
| 911 | bash_fallback_home="$case_root/bash-fallback-home" |
| 912 | mkdir -p "$bash_fallback_home" |
| 913 | : >"$bash_fallback_home/.bash_profile" |
| 914 | run_variant bash "$bash_fallback_home" "$case_root/bash-fallback-install" "$case_root/bash-fallback-bin" "$stable_tag" >/dev/null 2>&1 |
| 915 | grep -Fqx '# Composio CLI' "$bash_fallback_home/.bashrc" || fail "$interpreter_name bash fallback bashrc" |
| 916 | grep -Fqx '# Composio CLI' "$bash_fallback_home/.bash_profile" || fail "$interpreter_name bash fallback login override" |
| 917 | |
| 918 | # The inline fallback embeds the resolved bin dir in an rc line, so a dir |
| 919 | # holding a character double quotes still expand -- `$`, a backtick, `"`, `\` |
| 920 | # -- or a structural `:` is refused outright, on the same set |
| 921 | # `composio install` refuses. A dir the CLI rejects must not slip into an rc |
| 922 | # file just because the CLI could not run. |
| 923 | injection_marker="$case_root/injection-marker" |
| 924 | unsafe_case=0 |
| 925 | for unsafe_bin in "inject-\$(touch $injection_marker)" 'inject-`id`' 'inject-"quote"' 'inject\backslash' 'inject:colon'; do |
| 926 | reset_case |
| 927 | CASE_SHELL_CAPABILITY=unsupported |
| 928 | unsafe_case=$((unsafe_case + 1)) |
| 929 | unsafe_home="$case_root/unsafe-$unsafe_case-variant-home" |
| 930 | unsafe_install="$case_root/unsafe-$unsafe_case-variant-install" |
| 931 | unsafe_bin_dir="$case_root/$unsafe_bin" |
| 932 | unsafe_variant_output=$(run_variant zsh "$unsafe_home" "$unsafe_install" "$unsafe_bin_dir" "$stable_tag" 2>&1) || |
| 933 | fail "$interpreter_name unsafe variant bin dir must keep the install successful: $unsafe_bin" |
| 934 | [[ ! -e "$unsafe_home/.zshrc" ]] || fail "$interpreter_name unsafe variant must not write rc file: $unsafe_bin" |
| 935 | [[ -x "$unsafe_install/composio" ]] || fail "$interpreter_name unsafe variant must retain the binary: $unsafe_bin" |
| 936 | assert_contains "$unsafe_variant_output" 'warning:' "$interpreter_name unsafe variant warning: $unsafe_bin" |
| 937 | assert_contains "$unsafe_variant_output" "$unsafe_bin_dir" "$interpreter_name unsafe variant warning names the rejected path: $unsafe_bin" |
| 938 | assert_tail "$unsafe_variant_output" "$(recovery_tail later "$unsafe_install/composio")" "$interpreter_name unsafe variant recovery tail: $unsafe_bin" |
| 939 | done |
| 940 | [[ ! -e "$injection_marker" ]] || fail "$interpreter_name command substitution in the bin dir must never run" |
| 941 | |
| 942 | # The denylist stops at what double quotes actually expand: characters that |
| 943 | # are literal there stay legal and are written verbatim. |
| 944 | reset_case |
| 945 | CASE_SHELL_CAPABILITY=unsupported |
| 946 | literal_home="$case_root/literal-variant-home" |
| 947 | literal_bin="$case_root/o'brien;bin" |
| 948 | run_variant zsh "$literal_home" "$case_root/literal-variant-install" "$literal_bin" "$stable_tag" >/dev/null 2>&1 |
| 949 | expected_literal_bin=$(cd "$literal_bin" && pwd -P) |
| 950 | grep -Fq "export PATH=\"$expected_literal_bin:\$PATH\"" "$literal_home/.zshrc" || |
| 951 | fail "$interpreter_name apostrophe bin dir must be written verbatim" |
| 952 | |
| 953 | for base_mode in fail empty; do |
| 954 | reset_case |
| 955 | CASE_BASE_MODE=$base_mode |
| 956 | base_failure_home="$case_root/base-$base_mode-home" |
| 957 | if run_variant zsh "$base_failure_home" "$case_root/base-$base_mode-install" "$case_root/base-$base_mode-bin" "$stable_tag" >/dev/null 2>&1; then |
| 958 | fail "$interpreter_name $base_mode base installer download must fail" |
| 959 | fi |
| 960 | [[ ! -e "$base_failure_home/.zshrc" ]] || fail "$interpreter_name $base_mode download must not write rc" |
| 961 | done |
| 962 | |
| 963 | # --- Auto shell setup default: $SHELL picks the shell, setup delegates to the CLI --- |
| 964 | |
| 965 | # Every recognized default-flow shell delegates through the setup chain. |
| 966 | for auto_shell in zsh bash fish; do |
| 967 | reset_case |
| 968 | CASE_SHELL_VALUE="/bin/$auto_shell" |
| 969 | auto_home="$case_root/auto-$auto_shell-home" |
| 970 | auto_install="$case_root/auto-$auto_shell-install" |
| 971 | auto_bin="$case_root/auto-$auto_shell-bin" |
| 972 | auto_output=$(run_installer "$auto_home" "$auto_install" "$auto_bin" "$stable_tag" 2>&1) |
| 973 | grep -Fq "|installer|$auto_bin|install --shell $auto_shell" "$composio_log" || |
| 974 | fail "$interpreter_name auto $auto_shell delegation" |
| 975 | assert_contains "$auto_output" "$(configured_line "$auto_shell")" "$interpreter_name auto $auto_shell confirmation" |
| 976 | assert_tail "$auto_output" "$case_b_tail" "$interpreter_name auto $auto_shell Case B tail" |
| 977 | done |
| 978 | |
| 979 | # Repeated default-flow installs keep taking the idempotent setup chain. |
| 980 | reset_case |
| 981 | idempotent_home="$case_root/idempotent-home" |
| 982 | idempotent_install="$case_root/idempotent-install" |
| 983 | idempotent_bin="$case_root/idempotent-bin" |
| 984 | run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1 |
| 985 | run_installer "$idempotent_home" "$idempotent_install" "$idempotent_bin" "$stable_tag" >/dev/null 2>&1 |
| 986 | [[ $(grep -c 'install --shell bash' "$composio_log") -eq 2 ]] || |
| 987 | fail "$interpreter_name repeated auto installs must re-run idempotent setup" |
| 988 | |
| 989 | # COMPOSIO_INSTALL_SHELL=none preserves install-only behavior. |
| 990 | reset_case |
| 991 | CASE_INSTALL_SHELL=none |
| 992 | none_home="$case_root/none-home" |
| 993 | none_install="$case_root/none-install" |
| 994 | none_output=$(run_installer "$none_home" "$none_install" "$case_root/none-bin" "$stable_tag" 2>&1) |
| 995 | if grep -Fq 'install --shell' "$composio_log"; then |
| 996 | fail "$interpreter_name none must not run shell setup" |
| 997 | fi |
| 998 | [[ ! -e "$none_home/.bashrc" && ! -e "$none_home/.bash_profile" ]] || fail "$interpreter_name none must not write rc files" |
| 999 | assert_contains "$none_output" 'COMPOSIO_INSTALL_SHELL=none' "$interpreter_name none skip disclosure" |
| 1000 | assert_tail "$none_output" "$(recovery_tail now "$none_install/composio")" "$interpreter_name none install-only tail" |
| 1001 | |
| 1002 | # none + already-resolving installed command uses the bare Case A ending. |
| 1003 | reset_case |
| 1004 | CASE_INSTALL_SHELL=none |
| 1005 | none_ready_bin="$case_root/none-ready-bin" |
| 1006 | CASE_PATH_PREFIX="$none_ready_bin:" |
| 1007 | none_ready_output=$(run_installer "$case_root/none-ready-home" "$case_root/none-ready-install" "$none_ready_bin" "$stable_tag" 2>&1) |
| 1008 | assert_tail "$none_ready_output" "$case_a_tail" "$interpreter_name none Case A tail" |
| 1009 | |
| 1010 | # Case A: recognized shell, setup succeeds, and the inherited PATH already |
| 1011 | # resolves the installed entry point. Setup still runs (idempotent). |
| 1012 | reset_case |
| 1013 | ready_bin="$case_root/ready-bin" |
| 1014 | CASE_PATH_PREFIX="$ready_bin:" |
| 1015 | ready_output=$(run_installer "$case_root/ready-home" "$case_root/ready-install" "$ready_bin" "$stable_tag" 2>&1) |
| 1016 | grep -Fq 'install --shell bash' "$composio_log" || fail "$interpreter_name Case A still runs idempotent setup" |
| 1017 | assert_tail "$ready_output" "$case_a_tail" "$interpreter_name Case A tail" |
| 1018 | |
| 1019 | # Explicit shell + resolving command also ends in Case A. |
| 1020 | reset_case |
| 1021 | CASE_INSTALL_SHELL=zsh |
| 1022 | explicit_ready_bin="$case_root/explicit-ready-bin" |
| 1023 | CASE_PATH_PREFIX="$explicit_ready_bin:" |
| 1024 | explicit_ready_output=$(run_installer "$case_root/explicit-ready-home" "$case_root/explicit-ready-install" "$explicit_ready_bin" "$stable_tag" 2>&1) |
| 1025 | assert_tail "$explicit_ready_output" "$case_a_tail" "$interpreter_name explicit shell Case A tail" |
| 1026 | |
| 1027 | # Physical-path identity: a pre-existing symlink on PATH that resolves to the |
| 1028 | # installed executable still counts as Case A. |
| 1029 | reset_case |
| 1030 | alias_dir="$case_root/alias-dir" |
| 1031 | alias_install="$case_root/alias-install" |
| 1032 | mkdir -p "$alias_dir" "$alias_install" |
| 1033 | ln -sf "$alias_install/composio" "$alias_dir/composio" |
| 1034 | CASE_PATH_PREFIX="$alias_dir:" |
| 1035 | alias_output=$(run_installer "$case_root/alias-home" "$alias_install" "$case_root/alias-bin" "$stable_tag" 2>&1) |
| 1036 | assert_tail "$alias_output" "$case_a_tail" "$interpreter_name symlink-alias Case A tail" |
| 1037 | |
| 1038 | # Unknown $SHELL degrades to install-only guidance plus the trusted absolute command. |
| 1039 | reset_case |
| 1040 | CASE_SHELL_VALUE=/bin/tcsh |
| 1041 | unknown_home="$case_root/unknown-shell-home" |
| 1042 | unknown_install="$case_root/unknown-shell-install" |
| 1043 | unknown_output=$(run_installer "$unknown_home" "$unknown_install" "$case_root/unknown-shell-bin" "$stable_tag" 2>&1) |
| 1044 | if grep -Fq 'install --shell' "$composio_log"; then |
| 1045 | fail "$interpreter_name unknown shell must not run shell setup" |
| 1046 | fi |
| 1047 | [[ ! -e "$unknown_home/.bashrc" ]] || fail "$interpreter_name unknown shell must not write rc files" |
| 1048 | assert_tail "$unknown_output" "$(recovery_tail now "$unknown_install/composio")" "$interpreter_name unknown shell install-only tail" |
| 1049 | |
| 1050 | # Shadowing: bin dir on the inherited PATH, but another composio resolves |
| 1051 | # first. The ending must never run the shadowed bare command. |
| 1052 | reset_case |
| 1053 | shadow_dir="$case_root/shadow-dir" |
| 1054 | mkdir -p "$shadow_dir" |
| 1055 | printf '#!/bin/sh\nexit 0\n' >"$shadow_dir/composio" |
| 1056 | chmod +x "$shadow_dir/composio" |
| 1057 | shadow_bin="$case_root/shadow-bin" |
| 1058 | shadow_install="$case_root/shadow-install" |
| 1059 | CASE_PATH_PREFIX="$shadow_dir:$shadow_bin:" |
| 1060 | shadow_output=$(run_installer "$case_root/shadow-home" "$shadow_install" "$shadow_bin" "$stable_tag" 2>&1) |
| 1061 | assert_contains "$shadow_output" "$shadow_dir/composio" "$interpreter_name shadow ending names the shadowing command" |
| 1062 | assert_tail "$shadow_output" $'To use the newly installed CLI, run:\n\n '"$shadow_install/composio login" "$interpreter_name shadow tail avoids the shadowed bare command" |
| 1063 | |
| 1064 | # Pinned old CLI: supports --shell but ignores the invocation-origin hint, |
| 1065 | # prints its own boxed restart hint, and exits 0 without reconciling. A |
| 1066 | # relative COMPOSIO_BIN_DIR must never reach setup raw; the installer must |
| 1067 | # detect the unreconciled startup file and repair it inline. The delegated |
| 1068 | # command's own presentation never reaches the user: the installer owns its |
| 1069 | # output and its plain final block is the only ending. |
| 1070 | reset_case |
| 1071 | CASE_INSTALL_HINT=1 |
| 1072 | CASE_INSTALL_RECONCILE=0 |
| 1073 | oldcli_home="$case_root/oldcli-home" |
| 1074 | oldcli_work="$case_root/oldcli-work" |
| 1075 | oldcli_install="$case_root/oldcli-install" |
| 1076 | mkdir -p "$oldcli_work" |
| 1077 | oldcli_output=$(cd "$oldcli_work" && run_installer "$oldcli_home" "$oldcli_install" "rel-bin" "$stable_tag" 2>&1) |
| 1078 | grep -Fq "|installer|$oldcli_work/rel-bin|install --shell bash" "$composio_log" || |
| 1079 | fail "$interpreter_name old-CLI setup must receive the resolved absolute bin dir" |
| 1080 | grep -Fq "export PATH=\"$oldcli_work/rel-bin:\$PATH\"" "$oldcli_home/.bashrc" || |
| 1081 | fail "$interpreter_name old-CLI delegation must be reconciled inline with the absolute bin dir" |
| 1082 | assert_contains "$oldcli_output" "$(configured_line bash)" "$interpreter_name old-CLI reconciliation disclosure" |
| 1083 | assert_not_contains "$oldcli_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name delegated CLI output must not leak" |
| 1084 | assert_tail "$oldcli_output" "$case_b_tail" "$interpreter_name old-CLI hint superseded by the installer tail" |
| 1085 | |
| 1086 | # The suppressed delegated output stays available for troubleshooting. |
| 1087 | reset_case |
| 1088 | CASE_INSTALL_HINT=1 |
| 1089 | CASE_DEBUG=1 |
| 1090 | delegated_debug_output=$(run_installer "$case_root/delegated-debug-home" "$case_root/delegated-debug-install" "$case_root/delegated-debug-bin" "$stable_tag" 2>&1) |
| 1091 | assert_contains "$delegated_debug_output" 'delegated shell setup exited 0' "$interpreter_name debug reports the delegated exit status" |
| 1092 | assert_contains "$delegated_debug_output" '│ Restart your shell so composio is on PATH │' "$interpreter_name debug replays the captured delegated output" |
| 1093 | assert_contains "$delegated_debug_output" '+ shell setup source: cli' "$interpreter_name debug keeps the setup-source distinction" |
| 1094 | |
| 1095 | # --- Login-shell reachability for bash (macOS Terminal.app) --- |
| 1096 | |
| 1097 | # Inline path, virgin home: ~/.bashrc alone is unreachable from a login bash, |
| 1098 | # so the installer must also create a login-mode startup file. |
| 1099 | reset_case |
| 1100 | CASE_SHELL_CAPABILITY=unsupported |
| 1101 | CASE_SHELL_VALUE=/bin/bash |
| 1102 | bash_login_home="$case_root/bash-login-home" |
| 1103 | bash_login_bin="$case_root/bash-login-bin" |
| 1104 | bash_login_output=$(run_installer "$bash_login_home" "$case_root/bash-login-install" "$bash_login_bin" "$stable_tag" 2>&1) |
| 1105 | grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bashrc" || |
| 1106 | fail "$interpreter_name inline bash setup must configure .bashrc" |
| 1107 | grep -Fq "export PATH=\"$bash_login_bin:\$PATH\"" "$bash_login_home/.bash_profile" || |
| 1108 | fail "$interpreter_name inline bash setup must configure a login-mode startup file" |
| 1109 | assert_login_bash_path "$bash_login_home" "$bash_login_bin" "$interpreter_name inline bash login shell" |
| 1110 | assert_contains "$bash_login_output" "$(configured_line bash)" "$interpreter_name inline bash names both startup files" |
| 1111 | [[ ! -e "$bash_login_home/.profile" ]] || fail "$interpreter_name inline bash setup must not create ~/.profile" |
| 1112 | |
| 1113 | # A created ~/.bash_profile shadows an existing ~/.profile, so it must keep |
| 1114 | # sourcing it — and must never rewrite ~/.profile itself. |
| 1115 | reset_case |
| 1116 | CASE_SHELL_CAPABILITY=unsupported |
| 1117 | CASE_SHELL_VALUE=/bin/bash |
| 1118 | bash_profile_home="$case_root/bash-profile-home" |
| 1119 | bash_profile_bin="$case_root/bash-profile-bin" |
| 1120 | mkdir -p "$bash_profile_home" |
| 1121 | printf '%s\n' 'export DISTRO_PROFILE=1' >"$bash_profile_home/.profile" |
| 1122 | run_installer "$bash_profile_home" "$case_root/bash-profile-install" "$bash_profile_bin" "$stable_tag" >/dev/null 2>&1 |
| 1123 | grep -Fq '. "$HOME/.profile"' "$bash_profile_home/.bash_profile" || |
| 1124 | fail "$interpreter_name a created .bash_profile must keep sourcing ~/.profile" |
| 1125 | [[ $(<"$bash_profile_home/.profile") == 'export DISTRO_PROFILE=1' ]] || |
| 1126 | fail "$interpreter_name ~/.profile must not be modified" |
| 1127 | assert_login_bash_path "$bash_profile_home" "$bash_profile_bin" "$interpreter_name shadowed profile login shell" |
| 1128 | shadowed_profile_value=$(env -i HOME="$bash_profile_home" PATH=/usr/bin:/bin bash -lc 'printf %s "${DISTRO_PROFILE:-}"') |
| 1129 | [[ $shadowed_profile_value == 1 ]] || |
| 1130 | fail "$interpreter_name a created .bash_profile must not shadow ~/.profile content" |
| 1131 | |
| 1132 | # An existing ~/.bash_login is the login file bash reads, so it is reused and |
| 1133 | # no ~/.bash_profile is invented in front of it. |
| 1134 | reset_case |
| 1135 | CASE_SHELL_CAPABILITY=unsupported |
| 1136 | CASE_SHELL_VALUE=/bin/bash |
| 1137 | bash_login_only_home="$case_root/bash-login-only-home" |
| 1138 | bash_login_only_bin="$case_root/bash-login-only-bin" |
| 1139 | mkdir -p "$bash_login_only_home" |
| 1140 | printf '%s\n' 'export LOGIN_OVERRIDE=1' >"$bash_login_only_home/.bash_login" |
| 1141 | bash_login_only_output=$(run_installer "$bash_login_only_home" "$case_root/bash-login-only-install" "$bash_login_only_bin" "$stable_tag" 2>&1) |
| 1142 | grep -Fq "export PATH=\"$bash_login_only_bin:\$PATH\"" "$bash_login_only_home/.bash_login" || |
| 1143 | fail "$interpreter_name existing .bash_login must receive the managed block" |
| 1144 | [[ ! -e "$bash_login_only_home/.bash_profile" ]] || |
| 1145 | fail "$interpreter_name an existing .bash_login must not be shadowed by a new .bash_profile" |
| 1146 | assert_contains "$bash_login_only_output" 'Configured bash shell setup in ~/.bashrc and ~/.bash_login.' "$interpreter_name .bash_login disclosure" |
| 1147 | assert_login_bash_path "$bash_login_only_home" "$bash_login_only_bin" "$interpreter_name .bash_login login shell" |
| 1148 | |
| 1149 | # --- Setup write failures stay non-fatal: the binary stays installed and the ending stays truthful --- |
| 1150 | |
| 1151 | # Delegated path: CLI --shell fails, inline fallback also fails. |
| 1152 | reset_case |
| 1153 | CASE_SHELL_VALUE=/bin/zsh |
| 1154 | CASE_INSTALL_EXIT=23 |
| 1155 | wf_delegated_home="$case_root/write-failure-delegated-home" |
| 1156 | wf_delegated_install="$case_root/write-failure-delegated-install" |
| 1157 | mkdir -p "$wf_delegated_home/.zshrc" |
| 1158 | wf_delegated_output=$(run_installer "$wf_delegated_home" "$wf_delegated_install" "$case_root/write-failure-delegated-bin" "$stable_tag" 2>&1) || |
| 1159 | fail "$interpreter_name delegated setup failure must keep the install successful" |
| 1160 | [[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary" |
| 1161 | assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning" |
| 1162 | assert_contains "$wf_delegated_output" 'COMPOSIO_DEBUG=1' "$interpreter_name delegated setup failure points at the captured output" |
| 1163 | assert_tail "$wf_delegated_output" "$(recovery_tail later "$wf_delegated_install/composio")" "$interpreter_name delegated setup failure recovery tail" |
| 1164 | |
| 1165 | # Inline path: helper failure inside a conditional must propagate explicitly. |
| 1166 | # COMPOSIO_QUIET=1 and COMPOSIO_INSTALL_HELP=0 are set on purpose: both only |
| 1167 | # gate the normal-success final block, so this one case also proves they are |
| 1168 | # no-ops on the setup-failure path — the warning and the recovery tail reach |
| 1169 | # the user even with all optional output suppressed. |
| 1170 | reset_case |
| 1171 | CASE_SHELL_CAPABILITY=unsupported |
| 1172 | CASE_QUIET=1 |
| 1173 | CASE_HELP=0 |
| 1174 | wf_inline_home="$case_root/write-failure-inline-home" |
| 1175 | wf_inline_install="$case_root/write-failure-inline-install" |
| 1176 | mkdir -p "$wf_inline_home/.bashrc" |
| 1177 | wf_inline_output=$(run_installer "$wf_inline_home" "$wf_inline_install" "$case_root/write-failure-inline-bin" "$stable_tag" 2>&1) || |
| 1178 | fail "$interpreter_name inline setup failure must keep the install successful" |
| 1179 | [[ -x "$wf_inline_install/composio" ]] || fail "$interpreter_name inline setup failure must retain the binary" |
| 1180 | assert_contains "$wf_inline_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name inline setup failure warning" |
| 1181 | assert_tail "$wf_inline_output" "$(recovery_tail later "$wf_inline_install/composio")" "$interpreter_name inline setup failure recovery tail" |
| 1182 | |
| 1183 | # --- Managed-block reconciliation: a rerun replaces stale blocks instead of stacking duplicates --- |
| 1184 | |
| 1185 | reset_case |
| 1186 | CASE_SHELL_CAPABILITY=unsupported |
| 1187 | CASE_SHELL_VALUE=/bin/zsh |
| 1188 | reconcile_home="$case_root/reconcile-home" |
| 1189 | reconcile_install="$case_root/reconcile-install" |
| 1190 | reconcile_bin_a="$case_root/reconcile-bin-a" |
| 1191 | reconcile_bin_b="$case_root/reconcile-bin-b" |
| 1192 | mkdir -p "$reconcile_home" |
| 1193 | printf '%s\n' 'alias reconcile-before=1' >"$reconcile_home/.zshrc" |
| 1194 | reconcile_first=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1) |
| 1195 | assert_contains "$reconcile_first" 'Updated ~/.zshrc' "$interpreter_name inline setup update disclosure" |
| 1196 | grep -Fq "export PATH=\"$reconcile_bin_a:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name first managed block" |
| 1197 | printf '%s\n' 'alias reconcile-after=1' >>"$reconcile_home/.zshrc" |
| 1198 | reconcile_second=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_a" "$stable_tag" 2>&1) |
| 1199 | assert_contains "$reconcile_second" 'already' "$interpreter_name inline setup already-current disclosure" |
| 1200 | [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name idempotent rerun keeps one marker block" |
| 1201 | reconcile_third=$(run_installer "$reconcile_home" "$reconcile_install" "$reconcile_bin_b" "$stable_tag" 2>&1) |
| 1202 | assert_contains "$reconcile_third" 'Updated ~/.zshrc' "$interpreter_name reconcile update disclosure" |
| 1203 | [[ $(grep -Fc '# Composio CLI' "$reconcile_home/.zshrc") -eq 1 ]] || fail "$interpreter_name reconcile keeps exactly one marker block" |
| 1204 | grep -Fq "export PATH=\"$reconcile_bin_b:\$PATH\"" "$reconcile_home/.zshrc" || fail "$interpreter_name reconciled managed block" |
| 1205 | if grep -Fq "$reconcile_bin_a" "$reconcile_home/.zshrc"; then |
| 1206 | fail "$interpreter_name stale managed path must be replaced" |
| 1207 | fi |
| 1208 | grep -Fq 'alias reconcile-before=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (before block)" |
| 1209 | grep -Fq 'alias reconcile-after=1' "$reconcile_home/.zshrc" || fail "$interpreter_name unmanaged content preserved (after block)" |
| 1210 | |
| 1211 | # A marker followed by unmanaged content is malformed. Remove only the |
| 1212 | # marker, preserve every following line, and append the current managed block |
| 1213 | # after the orphaned stale assignment so the new bin dir wins PATH order. |
| 1214 | reset_case |
| 1215 | CASE_SHELL_CAPABILITY=unsupported |
| 1216 | CASE_SHELL_VALUE=/bin/zsh |
| 1217 | malformed_home="$case_root/malformed-block-home" |
| 1218 | malformed_bin="$case_root/malformed-block-bin" |
| 1219 | mkdir -p "$malformed_home" |
| 1220 | printf '%s\n' \ |
| 1221 | 'alias malformed-before=1' \ |
| 1222 | '# Composio CLI' \ |
| 1223 | '# keep this dotfile-manager annotation' \ |
| 1224 | '' \ |
| 1225 | 'export PATH="/stale/malformed-bin:$PATH"' \ |
| 1226 | 'alias malformed-after=1' >"$malformed_home/.zshrc" |
| 1227 | malformed_output=$(run_installer "$malformed_home" "$case_root/malformed-block-install" "$malformed_bin" "$stable_tag" 2>&1) |
| 1228 | assert_contains "$malformed_output" 'Updated ~/.zshrc' "$interpreter_name malformed block update disclosure" |
| 1229 | grep -Fq '# keep this dotfile-manager annotation' "$malformed_home/.zshrc" || fail "$interpreter_name malformed block preserves the line after its marker" |
| 1230 | grep -Fq 'export PATH="/stale/malformed-bin:$PATH"' "$malformed_home/.zshrc" || fail "$interpreter_name malformed block preserves an orphaned stale assignment" |
| 1231 | grep -Fq 'alias malformed-before=1' "$malformed_home/.zshrc" || fail "$interpreter_name malformed block preserves content before its marker" |
| 1232 | grep -Fq 'alias malformed-after=1' "$malformed_home/.zshrc" || fail "$interpreter_name malformed block preserves content after its marker" |
| 1233 | [[ $(grep -Fc '# Composio CLI' "$malformed_home/.zshrc") -eq 1 ]] || fail "$interpreter_name malformed block leaves one fresh marker" |
| 1234 | malformed_tail=$(tail -n 2 "$malformed_home/.zshrc") |
| 1235 | [[ $malformed_tail == "# Composio CLI |
| 1236 | export PATH=\"$malformed_bin:\$PATH\"" ]] || fail "$interpreter_name malformed block appends the current assignment last" |
| 1237 | |
| 1238 | # --- Symlinked startup files and mode preservation (managed dotfiles) --- |
| 1239 | |
| 1240 | # Inline setup must write through a symlinked rc file: the symlink survives |
| 1241 | # and its target receives the managed block (mirrors the CLI unit test |
| 1242 | # 'preserves a symlinked .zshrc'). |
| 1243 | reset_case |
| 1244 | CASE_SHELL_CAPABILITY=unsupported |
| 1245 | CASE_SHELL_VALUE=/bin/zsh |
| 1246 | symlink_home="$case_root/symlink-home" |
| 1247 | symlink_store="$case_root/symlink-store" |
| 1248 | symlink_bin="$case_root/symlink-bin" |
| 1249 | mkdir -p "$symlink_home" "$symlink_store" |
| 1250 | printf '%s\n' 'alias dotfiles-managed=1' >"$symlink_store/zshrc" |
| 1251 | ln -s "$symlink_store/zshrc" "$symlink_home/.zshrc" |
| 1252 | symlink_output=$(run_installer "$symlink_home" "$case_root/symlink-install" "$symlink_bin" "$stable_tag" 2>&1) |
| 1253 | assert_contains "$symlink_output" 'Updated ~/.zshrc' "$interpreter_name symlinked rc update disclosure" |
| 1254 | [[ -L "$symlink_home/.zshrc" ]] || fail "$interpreter_name symlinked rc must stay a symlink" |
| 1255 | [[ $(readlink "$symlink_home/.zshrc") == "$symlink_store/zshrc" ]] || fail "$interpreter_name symlinked rc target must not change" |
| 1256 | [[ $(grep -Fc '# Composio CLI' "$symlink_store/zshrc") -eq 1 ]] || fail "$interpreter_name symlink target must hold one managed block" |
| 1257 | grep -Fq "export PATH=\"$symlink_bin:\$PATH\"" "$symlink_store/zshrc" || fail "$interpreter_name symlink target managed line" |
| 1258 | grep -Fq 'alias dotfiles-managed=1' "$symlink_store/zshrc" || fail "$interpreter_name symlink target unmanaged content preserved" |
| 1259 | |
| 1260 | # The inline rewrite must preserve the startup file's permission bits. |
| 1261 | reset_case |
| 1262 | CASE_SHELL_CAPABILITY=unsupported |
| 1263 | CASE_SHELL_VALUE=/bin/zsh |
| 1264 | mode_home="$case_root/mode-home" |
| 1265 | mkdir -p "$mode_home" |
| 1266 | printf '%s\n' 'alias mode-check=1' >"$mode_home/.zshrc" |
| 1267 | chmod 600 "$mode_home/.zshrc" |
| 1268 | run_installer "$mode_home" "$case_root/mode-install" "$case_root/mode-bin" "$stable_tag" >/dev/null 2>&1 |
| 1269 | grep -Fq '# Composio CLI' "$mode_home/.zshrc" || fail "$interpreter_name mode-preservation run must write the block" |
| 1270 | case $(uname) in |
| 1271 | Darwin) mode_actual=$(stat -f '%Lp' "$mode_home/.zshrc") ;; |
| 1272 | *) mode_actual=$(stat -c '%a' "$mode_home/.zshrc") ;; |
| 1273 | esac |
| 1274 | [[ $mode_actual == 600 ]] || fail "$interpreter_name inline rewrite must preserve the file mode (got $mode_actual)" |
| 1275 | |
| 1276 | # --- Delegated setup verification (stale managed blocks) --- |
| 1277 | |
| 1278 | # A delegated CLI that exits 0 without reconciling a pre-seeded stale block |
| 1279 | # must not be trusted: the installer verifies the startup file, reconciles |
| 1280 | # inline, and reports the fallback disclosure with the Case B ending. |
| 1281 | reset_case |
| 1282 | CASE_INSTALL_SHELL=zsh |
| 1283 | CASE_INSTALL_RECONCILE=0 |
| 1284 | stale_home="$case_root/stale-delegated-home" |
| 1285 | stale_bin="$case_root/stale-delegated-bin" |
| 1286 | mkdir -p "$stale_home" |
| 1287 | printf '%s\n' 'alias stale-guard=1' '' '# Composio CLI' 'export PATH="/stale/old-bin:$PATH"' >"$stale_home/.zshrc" |
| 1288 | stale_output=$(run_installer "$stale_home" "$case_root/stale-delegated-install" "$stale_bin" "$stable_tag" 2>&1) |
| 1289 | grep -Fq "|installer|$stale_bin|install --shell zsh" "$composio_log" || fail "$interpreter_name stale delegation still delegates first" |
| 1290 | assert_contains "$stale_output" "$(configured_line zsh)" "$interpreter_name stale delegation reconciles inline" |
| 1291 | [[ $(grep -Fc '# Composio CLI' "$stale_home/.zshrc") -eq 1 ]] || fail "$interpreter_name stale reconcile keeps one marker block" |
| 1292 | grep -Fq "export PATH=\"$stale_bin:\$PATH\"" "$stale_home/.zshrc" || fail "$interpreter_name stale reconcile names the current bin dir" |
| 1293 | if grep -Fq '/stale/old-bin' "$stale_home/.zshrc"; then |
| 1294 | fail "$interpreter_name stale managed path must be replaced after delegation" |
| 1295 | fi |
| 1296 | grep -Fq 'alias stale-guard=1' "$stale_home/.zshrc" || fail "$interpreter_name stale reconcile preserves unmanaged content" |
| 1297 | assert_tail "$stale_output" "$case_b_tail" "$interpreter_name stale delegation Case B tail" |
| 1298 | |
| 1299 | # --- Unsafe resolved bin dirs under the default flow: shell metacharacters never reach rc files --- |
| 1300 | |
| 1301 | # Only characters double quotes still expand are rejected: `;` is literal |
| 1302 | # inside them and stays legal, so it is deliberately not probed here. |
| 1303 | unsafe_auto_index=0 |
| 1304 | for unsafe_character in '$' '`'; do |
| 1305 | unsafe_auto_index=$((unsafe_auto_index + 1)) |
| 1306 | reset_case |
| 1307 | unsafe_auto_home="$case_root/unsafe-auto-$unsafe_auto_index-home" |
| 1308 | unsafe_auto_install="$case_root/unsafe-auto-$unsafe_auto_index-install" |
| 1309 | unsafe_auto_bin="$case_root/unsafe-auto${unsafe_character}$unsafe_auto_index-bin" |
| 1310 | unsafe_auto_output=$(run_installer "$unsafe_auto_home" "$unsafe_auto_install" "$unsafe_auto_bin" "$stable_tag" 2>&1) || |
| 1311 | fail "$interpreter_name unsafe auto bin dir with $unsafe_character must keep the install successful" |
| 1312 | if grep -Fq 'install --shell' "$composio_log"; then |
| 1313 | fail "$interpreter_name unsafe auto bin dir must be rejected before delegation" |
| 1314 | fi |
| 1315 | [[ ! -e "$unsafe_auto_home/.bashrc" && ! -e "$unsafe_auto_home/.bash_profile" ]] || |
| 1316 | fail "$interpreter_name unsafe auto bin dir must not write startup files" |
| 1317 | [[ -x "$unsafe_auto_install/composio" ]] || fail "$interpreter_name unsafe auto bin dir must retain the binary" |
| 1318 | assert_contains "$unsafe_auto_output" "$unsafe_auto_bin" "$interpreter_name unsafe auto warning names the rejected path" |
| 1319 | assert_tail "$unsafe_auto_output" "$(recovery_tail later "$unsafe_auto_install/composio")" "$interpreter_name unsafe auto recovery tail" |
| 1320 | done |
| 1321 | |
| 1322 | # A valid absolute install dir containing spaces stays copy-paste safe in |
| 1323 | # recovery output: the printed command executes the installed binary as-is. |
| 1324 | reset_case |
| 1325 | CASE_SHELL_CAPABILITY=unsupported |
| 1326 | space_home="$case_root/space-home" |
| 1327 | space_install="$case_root/space install/dir" |
| 1328 | mkdir -p "$space_home/.bashrc" |
| 1329 | space_output=$(run_installer "$space_home" "$space_install" "$case_root/space-bin" "$stable_tag" 2>&1) || |
| 1330 | fail "$interpreter_name spaced install dir setup failure must keep the install successful" |
| 1331 | assert_tail "$space_output" "$(recovery_tail later "'$space_install/composio'")" "$interpreter_name spaced recovery tail" |
| 1332 | space_recovery_line=$(printf '%s\n' "$space_output" | tail -n 1) |
| 1333 | space_recovery_command=${space_recovery_line# } |
| 1334 | space_recovery_command=${space_recovery_command% login} |
| 1335 | space_paste_output=$(env TEST_COMPOSIO_LOG="$composio_log" "$interpreter" -c "$space_recovery_command --version") || |
| 1336 | fail "$interpreter_name spaced recovery command must execute when pasted" |
| 1337 | [[ $space_paste_output == 'composio fake 98.0.0' ]] || fail "$interpreter_name spaced recovery command output" |
| 1338 | |
| 1339 | # --- Final-block contract combinations: exactly one truthful ending, always last --- |
| 1340 | |
| 1341 | # Plugin output completes before the final block. |
| 1342 | reset_case |
| 1343 | CASE_PLUGINS=1 |
| 1344 | plugin_order_output=$(run_installer "$case_root/plugin-order-home" "$case_root/plugin-order-install" "$case_root/plugin-order-bin" "$stable_tag" 2>&1) |
| 1345 | assert_contains "$plugin_order_output" 'Installing plugins for detected agent hosts...' "$interpreter_name plugin status printed" |
| 1346 | assert_tail "$plugin_order_output" "$case_b_tail" "$interpreter_name plugin output precedes the final block" |
| 1347 | |
| 1348 | # --agent, setup succeeds, command not yet resolvable: completed state plus |
| 1349 | # only the new-terminal notice; never a second login command. |
| 1350 | reset_case |
| 1351 | agent_home="$case_root/agent-home" |
| 1352 | agent_output=$(run_installer "$agent_home" "$case_root/agent-install" "$case_root/agent-bin" "$stable_tag" --agent 2>&1) |
| 1353 | grep -Fq 'login --agent --no-skill-install' "$composio_log" || fail "$interpreter_name agent login invocation" |
| 1354 | assert_not_contains "$agent_output" 'composio login' "$interpreter_name agent flow must not print a generic login command" |
| 1355 | assert_tail "$agent_output" $'Composio agent login complete.\nOpen a new terminal to use the composio command.' "$interpreter_name agent Case B tail" |
| 1356 | |
| 1357 | # --agent with the installed command already resolvable: completed state only. |
| 1358 | reset_case |
| 1359 | agent_ready_bin="$case_root/agent-ready-bin" |
| 1360 | CASE_PATH_PREFIX="$agent_ready_bin:" |
| 1361 | agent_ready_output=$(run_installer "$case_root/agent-ready-home" "$case_root/agent-ready-install" "$agent_ready_bin" "$stable_tag" --agent 2>&1) |
| 1362 | assert_not_contains "$agent_ready_output" 'Open a new terminal' "$interpreter_name agent ready flow needs no terminal notice" |
| 1363 | assert_tail "$agent_ready_output" 'Composio agent login complete.' "$interpreter_name agent Case A tail" |
| 1364 | |
| 1365 | # --agent with setup failure: completed state plus warning and trusted |
| 1366 | # installed-path guidance; still no generic login command. |
| 1367 | reset_case |
| 1368 | CASE_SHELL_CAPABILITY=unsupported |
| 1369 | agent_fail_home="$case_root/agent-fail-home" |
| 1370 | agent_fail_install="$case_root/agent-fail-install" |
| 1371 | mkdir -p "$agent_fail_home/.bashrc" |
| 1372 | agent_fail_output=$(run_installer "$agent_fail_home" "$agent_fail_install" "$case_root/agent-fail-bin" "$stable_tag" --agent 2>&1) || |
| 1373 | fail "$interpreter_name agent setup failure must keep the install successful" |
| 1374 | assert_contains "$agent_fail_output" 'Composio agent login complete.' "$interpreter_name agent completion survives setup failure" |
| 1375 | assert_contains "$agent_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name agent setup failure warning" |
| 1376 | assert_not_contains "$agent_fail_output" 'composio login' "$interpreter_name agent setup failure must not print a login command" |
| 1377 | assert_tail "$agent_fail_output" $'Run composio from its installed location:\n\n '"$agent_fail_install/composio --help" "$interpreter_name agent setup failure recovery tail" |
| 1378 | |
| 1379 | # --agent with setup skipped (none): completed state plus installed-path guidance. |
| 1380 | reset_case |
| 1381 | CASE_INSTALL_SHELL=none |
| 1382 | agent_none_install="$case_root/agent-none-install" |
| 1383 | agent_none_output=$(run_installer "$case_root/agent-none-home" "$agent_none_install" "$case_root/agent-none-bin" "$stable_tag" --agent 2>&1) |
| 1384 | assert_not_contains "$agent_none_output" 'composio login' "$interpreter_name agent none flow must not print a login command" |
| 1385 | assert_tail "$agent_none_output" $'Composio agent login complete.\nRun composio from its installed location:\n\n '"$agent_none_install/composio --help" "$interpreter_name agent none tail" |
| 1386 | |
| 1387 | printf 'install scripts passed under %s\n' "$interpreter_name" |
| 1388 | done |
| 1389 | |
| 1390 | printf 'install.sh release resolution, layout, security, and shell-variant tests passed\n' |