Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
feat(cli): add install-only POSIX installer
jkomyno committed
Jul 31, 2026 at 19:15 UTC
d9998571708194403a65b49bb287571cdab8d9f7
10 files changed
+1337
-773
.github/CODEOWNERS
+2
@@ -2,3 +2,5 @@ docs/ @shawnesquivel @Sushmithamallesh
2
ts/packages/cli/ @CryogenicPlanet
3
ts/ @jkomyno
4
python/ @jkomyno
5
+/install.sh @CryogenicPlanet
6
+/install/ @CryogenicPlanet
.github/workflows/cli.install-health-check.yml
+22
-6
@@ -35,19 +35,21 @@ jobs:
35
echo "Latest published release: ${tag}"
36
37
# Install the PINNED newest tag. This is the path that 404s when a release ships without
38
- # assets. The no-arg `curl | bash` below is asset-aware and silently falls back to the
38
+ # assets. The no-arg `curl | sh` below is asset-aware and silently falls back to the
39
# previous good release, so it would stay green even when the newest release is broken —
40
# which is exactly why the previous canary never caught the recurring outage.
41
- name: Install newest stable (pinned — fails on a release with missing assets)
42
run: |
43
set -euo pipefail
44
- curl -fsSL https://composio.dev/install | bash -s -- "${{ steps.resolve.outputs.tag }}"
45
- echo "$HOME/.composio" >> "$GITHUB_PATH"
44
+ curl -fsSL https://composio.dev/install | sh -s -- "${{ steps.resolve.outputs.tag }}"
45
+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"
46
47
- name: Verify pinned installation
48
run: |
49
set -euo pipefail
50
ls -la "$HOME/.composio" || true
51
+ test -x "$HOME/.composio/composio"
52
+ test -L "$HOME/.local/bin/composio"
53
which composio
54
composio --version
55
@@ -56,9 +58,23 @@ jobs:
58
- name: Install via default no-arg flow
59
run: |
60
set -euo pipefail
59
- rm -rf "$HOME/.composio"
60
- curl -fsSL https://composio.dev/install | bash
61
- "$HOME/.composio/composio" --version
61
+ rm -f \
62
+ "$HOME/.local/bin/composio" \
63
+ "$HOME/.composio/composio" \
64
+ "$HOME/.composio/release-tag.txt" \
65
+ "$HOME/.composio/run-helpers-runtime.mjs" \
66
+ "$HOME/.composio/run-subagent-shared.mjs" \
67
+ "$HOME/.composio/run-subagent-acp.mjs" \
68
+ "$HOME/.composio/run-subagent-legacy.mjs" \
69
+ "$HOME/.composio/run-subagent-output-mcp.mjs"
70
+ rm -rf \
71
+ "$HOME/.composio/services" \
72
+ "$HOME/.composio/acp-adapters" \
73
+ "$HOME/.composio/local-tools-binaries"
74
+ curl -fsSL https://composio.dev/install | sh
75
+ test -x "$HOME/.composio/composio"
76
+ test -L "$HOME/.local/bin/composio"
77
+ "$HOME/.local/bin/composio" --version
78
79
- name: Send Slack Notification (Failure)
80
if: failure()
.github/workflows/cli.test-installation.yml
+38
-34
@@ -33,6 +33,9 @@ jobs:
33
- name: Test release resolution fallback
34
run: bash test/install-sh-release-resolution.test.sh
35
36
+ - name: Lint POSIX install scripts
37
+ run: shellcheck -s sh install.sh install/*.sh
38
+
39
test-install-script:
40
name: Test Install Script
41
needs: install-script-unit-tests
@@ -160,23 +163,22 @@ jobs:
163
echo "Testing installation with auto-detected latest CLI version..."
164
165
# Test the install script without version (it will auto-detect latest CLI release)
163
- bash install.sh
166
+ sh install.sh
167
168
# Verify installation
166
- source ~/.bashrc 2>/dev/null || source ~/.zshrc 2>/dev/null || true
167
- export PATH="$HOME/.composio:$PATH"
169
+ export PATH="$HOME/.local/bin:$PATH"
170
169
- # Check if binary exists
170
- if [[ -f "$HOME/.composio/composio" ]]; then
171
- echo "✅ Binary installed successfully"
172
- ls -la "$HOME/.composio/composio"
171
+ # Check the bundle and entry point
172
+ if [[ -x "$HOME/.composio/composio" && -L "$HOME/.local/bin/composio" ]]; then
173
+ echo "✅ Bundle and entry point installed successfully"
174
+ ls -la "$HOME/.composio/composio" "$HOME/.local/bin/composio"
175
else
174
- echo "❌ Binary not found"
176
+ echo "❌ Bundle or entry point not found"
177
exit 1
178
fi
179
180
# Test binary execution
179
- if "$HOME/.composio/composio" --version; then
181
+ if "$HOME/.local/bin/composio" --version; then
182
echo "✅ Binary executes successfully"
183
else
184
echo "❌ Binary execution failed"
@@ -192,23 +194,22 @@ jobs:
194
echo "Testing installation with version: ${RELEASE_TAG}"
195
196
# Test the install script with specific version
195
- bash install.sh "${RELEASE_TAG}"
197
+ sh install.sh "${RELEASE_TAG}"
198
199
# Verify installation
198
- source ~/.bashrc 2>/dev/null || source ~/.zshrc 2>/dev/null || true
199
- export PATH="$HOME/.composio:$PATH"
200
+ export PATH="$HOME/.local/bin:$PATH"
201
201
- # Check if binary exists
202
- if [[ -f "$HOME/.composio/composio" ]]; then
203
- echo "✅ Binary installed successfully"
204
- ls -la "$HOME/.composio/composio"
202
+ # Check the bundle and entry point
203
+ if [[ -x "$HOME/.composio/composio" && -L "$HOME/.local/bin/composio" ]]; then
204
+ echo "✅ Bundle and entry point installed successfully"
205
+ ls -la "$HOME/.composio/composio" "$HOME/.local/bin/composio"
206
else
206
- echo "❌ Binary not found"
207
+ echo "❌ Bundle or entry point not found"
208
exit 1
209
fi
210
211
# Test binary execution
211
- if "$HOME/.composio/composio" --version; then
212
+ if "$HOME/.local/bin/composio" --version; then
213
echo "✅ Binary executes successfully"
214
else
215
echo "❌ Binary execution failed"
@@ -220,6 +221,8 @@ jobs:
221
run: |
222
echo "Testing PATH integration with ${{ matrix.shell }}..."
223
224
+ COMPOSIO_BIN_DIR="$HOME/.local/bin" "$HOME/.composio/composio" install --shell "${{ matrix.shell }}"
225
+
226
# Debug: Check what files exist and their contents
227
echo "=== DEBUGGING ==="
228
echo "Checking shell config files:"
@@ -352,7 +355,7 @@ jobs:
355
exit 1
356
fi
357
355
- if grep -Fqx 'export PATH="$HOME/.composio:$PATH"' "$config_file"; then
358
+ if grep -Fqx 'export PATH="$HOME/.local/bin:$PATH"' "$config_file"; then
359
echo "✅ $config_file updated with the installed binary directory"
360
else
361
echo "❌ $config_file PATH not updated"
@@ -377,27 +380,28 @@ jobs:
380
echo "Testing custom install directory..."
381
382
# Clean up previous installation
380
- rm -rf ~/.composio
383
+ rm -rf ~/.composio /tmp/custom-composio /tmp/custom-composio-bin
384
385
# Test with custom directory using the same version as the workflow
386
export COMPOSIO_INSTALL_DIR="/tmp/custom-composio"
387
+ export COMPOSIO_BIN_DIR="/tmp/custom-composio-bin"
388
if [[ "$USE_LATEST" == "true" ]]; then
385
- bash install.sh
389
+ sh install.sh
390
else
387
- bash install.sh "${RELEASE_TAG}"
391
+ sh install.sh "${RELEASE_TAG}"
392
fi
393
394
# Verify custom installation
391
- if [[ -f "/tmp/custom-composio/composio" ]]; then
395
+ if [[ -x "/tmp/custom-composio/composio" && -L "/tmp/custom-composio-bin/composio" ]]; then
396
echo "✅ Custom directory installation successful"
393
- ls -la "/tmp/custom-composio/composio"
397
+ ls -la "/tmp/custom-composio/composio" "/tmp/custom-composio-bin/composio"
398
else
399
echo "❌ Custom directory installation failed"
400
exit 1
401
fi
402
403
# Test execution
400
- if "/tmp/custom-composio/composio" --version; then
404
+ if "/tmp/custom-composio-bin/composio" --version; then
405
echo "✅ Custom installation executes successfully"
406
else
407
echo "❌ Custom installation execution failed"
@@ -409,11 +413,12 @@ jobs:
413
echo "Testing uninstallation..."
414
415
# Remove binary
412
- rm -rf ~/.composio /tmp/custom-composio
416
+ rm -f ~/.local/bin/composio /tmp/custom-composio-bin/composio
417
+ rm -rf ~/.composio /tmp/custom-composio /tmp/custom-composio-bin
418
419
# Check if binary is gone
415
- if [[ ! -f "$HOME/.composio/composio" ]]; then
416
- echo "✅ Binary removed successfully"
420
+ if [[ ! -e "$HOME/.composio/composio" && ! -e "$HOME/.local/bin/composio" ]]; then
421
+ echo "✅ Bundle and entry point removed successfully"
422
else
423
echo "❌ Binary removal failed"
424
exit 1
@@ -425,12 +430,11 @@ jobs:
430
echo "Testing error handling..."
431
432
# Test with invalid version
428
- if bash install.sh v999.999.999 2>&1 | grep -q "Failed"; then
429
- echo "✅ Error handling works for invalid version"
430
- else
431
- echo "❌ Error handling failed"
432
- # Don't exit 1 here as this is expected to fail
433
+ if sh install.sh v999.999.999; then
434
+ echo "❌ Invalid version unexpectedly succeeded"
435
+ exit 1
436
fi
437
+ echo "✅ Error handling works for invalid versions"
438
439
test-architecture-detection:
440
name: Test Architecture Detection
@@ -530,7 +534,7 @@ jobs:
534
# Create a version of the script that will fail prerequisite check
535
sed 's/command -v curl/command -v nonexistent-tool/' install.sh > test-install.sh
536
533
- if bash test-install.sh 2>&1 | grep -q "required to install"; then
537
+ if sh test-install.sh 2>&1 | grep -q "required to install"; then
538
echo "✅ Prerequisites check works"
539
else
540
echo "❌ Prerequisites check failed"
install.sh
+370
-357
@@ -1,445 +1,458 @@
1
-#!/usr/bin/env bash
2
-set -euo pipefail
1
+#!/bin/sh
2
+set -eu
3
4
-COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-"ComposioHQ"}
5
-COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-"composio"}
6
-COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-"https://github.com"}
7
-COMPOSIO_GITHUB_API_BASE_URL=${COMPOSIO_GITHUB_API_BASE_URL:-}
8
-COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-$HOME/.composio}
9
-
10
-# --- Input validation ---
11
-
12
-# Only allow HTTPS URLs for the download source.
13
-if [[ ! "$COMPOSIO_GITHUB_URL" =~ ^https:// ]]; then
14
- echo "error: COMPOSIO_GITHUB_URL must start with https:// (got \"$COMPOSIO_GITHUB_URL\")" >&2
4
+error() {
5
+ printf 'error: %s\n' "$*" >&2
6
exit 1
16
-fi
7
+}
8
18
-# Owner and repo must be safe identifiers (alphanumeric, hyphens, underscores, dots).
19
-if [[ ! "$COMPOSIO_GITHUB_OWNER" =~ ^[a-zA-Z0-9._-]+$ ]]; then
20
- echo "error: COMPOSIO_GITHUB_OWNER contains invalid characters (got \"$COMPOSIO_GITHUB_OWNER\")" >&2
21
- exit 1
22
-fi
23
-if [[ ! "$COMPOSIO_GITHUB_REPO" =~ ^[a-zA-Z0-9._-]+$ ]]; then
24
- echo "error: COMPOSIO_GITHUB_REPO contains invalid characters (got \"$COMPOSIO_GITHUB_REPO\")" >&2
25
- exit 1
26
-fi
9
+warn() {
10
+ printf 'warning: %s\n' "$*" >&2
11
+}
12
28
-if [[ -n "$COMPOSIO_GITHUB_API_BASE_URL" && ! "$COMPOSIO_GITHUB_API_BASE_URL" =~ ^https:// ]]; then
29
- echo "error: COMPOSIO_GITHUB_API_BASE_URL must start with https:// (got \"$COMPOSIO_GITHUB_API_BASE_URL\")" >&2
30
- exit 1
31
-fi
13
+is_true() {
14
+ case ${1:-} in
15
+ 1 | true) return 0 ;;
16
+ *) return 1 ;;
17
+ esac
18
+}
19
33
-github_repo="$COMPOSIO_GITHUB_URL/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"
20
+info() {
21
+ if ! is_true "${COMPOSIO_QUIET:-}"; then
22
+ printf '%s\n' "$*"
23
+ fi
24
+}
25
35
-if [[ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]]; then
36
- github_api_base="${COMPOSIO_GITHUB_API_BASE_URL%/}"
37
-elif [[ "$COMPOSIO_GITHUB_URL" = "https://github.com" ]]; then
38
- github_api_base="https://api.github.com"
39
-else
40
- github_api_base="${COMPOSIO_GITHUB_URL%/}/api/v3"
41
-fi
26
+debug() {
27
+ if is_true "${COMPOSIO_DEBUG:-}"; then
28
+ printf '+ %s\n' "$*" >&2
29
+ fi
30
+}
31
43
-github_api_repo="$github_api_base/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"
32
+tildify() {
33
+ case $1 in
34
+ "$HOME"/*) printf '%s/%s\n' '~' "${1#"$HOME"/}" ;;
35
+ *) printf '%s\n' "$1" ;;
36
+ esac
37
+}
38
45
-# --- Colors (only when interactive) ---
39
+print_usage() {
40
+ printf '%s\n' \
41
+ 'Usage: install.sh [--agent] [--no-plugins] [version-tag]' \
42
+ '' \
43
+ 'Options:' \
44
+ ' --agent Sign up or log in as a Composio agent after installation.' \
45
+ ' --no-plugins Skip agent plugin installation (the default).' \
46
+ ' -h, --help Show this help.' \
47
+ '' \
48
+ 'Version tags may be stable or beta, for example 0.3.1 or @composio/cli@0.3.1-beta.2.'
49
+}
50
47
-Color_Off='' Red='' Green='' Dim='' Bold_White='' Bold_Green=''
51
+validate_identifier() {
52
+ printf '%s\n' "$2" | grep -Eq '^[A-Za-z0-9._-]+$' ||
53
+ error "$1 contains invalid characters (got \"$2\")"
54
+}
55
49
-if [[ -t 1 ]]; then
50
- Color_Off='\033[0m'
51
- Red='\033[0;31m'
52
- Green='\033[0;32m'
53
- Dim='\033[0;2m'
54
- Bold_Green='\033[1;32m'
55
- Bold_White='\033[1m'
56
-fi
56
+url_authority() {
57
+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'
58
+}
59
58
-error() { echo -e "${Red}error${Color_Off}:" "$@" >&2; exit 1; }
59
-warn() { echo -e "${Red}warning${Color_Off}:" "$@" >&2; }
60
-info() { echo -e "${Dim}$*${Color_Off}"; }
61
-info_bold() { echo -e "${Bold_White}$*${Color_Off}"; }
62
-success() { echo -e "${Green}$*${Color_Off}"; }
60
+is_allowed_http_authority() {
61
+ case $1 in
62
+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;
63
+ esac
64
64
-tildify() {
65
- if [[ $1 = $HOME/* ]]; then
66
- echo "~/${1#$HOME/}"
67
- else
68
- echo "$1"
65
+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then
66
+ case $1 in
67
+ "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;;
68
+ esac
69
fi
70
-}
70
72
-install_agent=false
73
-install_plugins=true
74
-version_arg=""
71
+ return 1
72
+}
73
76
-case "${COMPOSIO_INSTALL_PLUGINS:-1}" in
77
-1) ;;
78
-0) install_plugins=false ;;
79
-*) error 'COMPOSIO_INSTALL_PLUGINS must be 1 or 0' ;;
80
-esac
74
+validate_url() {
75
+ validate_url_value=$1
76
+ case $validate_url_value in
77
+ *[![:print:]]* | *[[:space:]]*) return 1 ;;
78
+ esac
79
82
-while [[ $# -gt 0 ]]; do
83
- case "$1" in
84
- --agent)
85
- install_agent=true
86
- shift
87
- ;;
88
- --no-plugins)
89
- install_plugins=false
90
- shift
91
- ;;
92
- -h|--help)
93
- echo 'Usage: install.sh [--agent] [--no-plugins] [version-tag] (e.g. "@composio/cli@0.1.32")'
94
- echo ' --agent After installing, sign up/log in as a Composio agent.'
95
- echo ' --no-plugins Skip installing plugins for detected agent hosts.'
96
- echo ' Set COMPOSIO_INSTALL_PLUGINS=0 to skip plugin installation in automation.'
97
- exit 0
98
- ;;
99
- --*)
100
- error "Unknown option: $1"
101
- ;;
102
- *)
103
- if [[ -n "$version_arg" ]]; then
104
- error 'Too many arguments. Usage: install.sh [--agent] [--no-plugins] [version-tag] (e.g. "@composio/cli@0.1.32")'
105
- fi
106
- version_arg=$1
107
- shift
108
- ;;
80
+ validate_url_authority=$(url_authority "$validate_url_value")
81
+ [ -n "$validate_url_authority" ] || return 1
82
+ case $validate_url_authority in
83
+ *@*) return 1 ;;
84
esac
110
-done
85
112
-# --- Platform detection ---
86
+ case $validate_url_value in
87
+ https://*) return 0 ;;
88
+ http://*) is_allowed_http_authority "$validate_url_authority" ;;
89
+ *) return 1 ;;
90
+ esac
91
+}
92
114
-platform=$(uname -ms)
93
+curl_fetch() {
94
+ curl_fetch_url=$1
95
+ validate_url "$curl_fetch_url" || error "Refusing unsafe URL \"$curl_fetch_url\""
96
+ debug "curl GET $curl_fetch_url"
97
+ case $curl_fetch_url in
98
+ https://*)
99
+ curl --fail --silent --location --proto '=https' --proto-redir '=https' "$curl_fetch_url"
100
+ ;;
101
+ http://*)
102
+ curl --fail --silent --location --proto '=http,https' --proto-redir '=https' "$curl_fetch_url"
103
+ ;;
104
+ esac
105
+}
106
116
-case $platform in
117
-'MINGW64'* | 'MSYS'* | 'CYGWIN'*)
118
- error 'Windows is not supported. Please use WSL (https://learn.microsoft.com/windows/wsl/install) and run this script inside your WSL distribution.'
119
- ;;
120
-esac
107
+curl_download() {
108
+ curl_download_url=$1
109
+ curl_download_output=$2
110
+ curl_download_quiet=${3:-0}
111
+ validate_url "$curl_download_url" || error "Refusing unsafe URL \"$curl_download_url\""
112
+ debug "curl GET $curl_download_url -> $curl_download_output"
113
122
-# --- Prerequisites ---
114
+ if [ "$curl_download_quiet" = 1 ] || is_true "${COMPOSIO_QUIET:-}"; then
115
+ curl_download_ui=--silent
116
+ else
117
+ curl_download_ui=--progress-bar
118
+ fi
119
124
-command -v curl >/dev/null || error 'curl is required to install Composio CLI'
125
-command -v unzip >/dev/null || error 'unzip is required to install Composio CLI'
120
+ case $curl_download_url in
121
+ https://*)
122
+ curl --fail --location "$curl_download_ui" --proto '=https' --proto-redir '=https' \
123
+ --output "$curl_download_output" "$curl_download_url"
124
+ ;;
125
+ http://*)
126
+ curl --fail --location "$curl_download_ui" --proto '=http,https' --proto-redir '=https' \
127
+ --output "$curl_download_output" "$curl_download_url"
128
+ ;;
129
+ esac
130
+}
131
127
-case $platform in
128
-'Darwin x86_64') target=darwin-x64 ;;
129
-'Darwin arm64') target=darwin-aarch64 ;;
130
-'Linux aarch64' | 'Linux arm64')
131
- target=linux-aarch64 ;;
132
-'Linux x86_64') target=linux-x64 ;;
133
-*) error "Unsupported platform: $platform" ;;
134
-esac
132
+normalize_version() {
133
+ normalize_version_value=$1
134
+ case $normalize_version_value in
135
+ @composio/cli@*) normalize_version_bare=${normalize_version_value#@composio/cli@} ;;
136
+ *) normalize_version_bare=$normalize_version_value ;;
137
+ esac
138
136
-# Rosetta 2 detection on macOS
137
-if [[ $target = darwin-x64 ]]; then
138
- if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then
139
- target=darwin-aarch64
140
- info "Your shell is running in Rosetta 2. Downloading for $target instead"
141
- fi
142
-fi
139
+ printf '%s\n' "$normalize_version_bare" |
140
+ grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$' ||
141
+ error "Invalid Composio CLI version \"$normalize_version_value\". Expected X.Y.Z or X.Y.Z-beta.N."
142
144
-archive_name="composio-$target.zip"
143
+ printf '@composio/cli@%s\n' "$normalize_version_bare"
144
+}
145
146
resolve_latest_cli_release() {
147
- local page release_json release_line
148
-
149
- for page in 1 2 3 4 5; do
150
- release_json=$(curl --fail --silent --location "$github_api_repo/releases?per_page=100&page=$page") || return 1
151
-
152
- release_line=$(printf '%s\n' "$release_json" \
153
- | sed 's/"tag_name"/\
147
+ resolve_page=1
148
+ while [ "$resolve_page" -le 5 ]; do
149
+ resolve_url="$github_api_repo/releases?per_page=100&page=$resolve_page"
150
+ resolve_json=$(curl_fetch "$resolve_url") || return 1
151
+ resolve_release=$(printf '%s\n' "$resolve_json" |
152
+ sed 's/"tag_name"/\
153
"tag_name"/g; s/"browser_download_url"/\
155
-"browser_download_url"/g' \
156
- | awk -v asset_name="$archive_name" '
154
+"browser_download_url"/g' |
155
+ awk -v asset_name="$archive_name" '
156
BEGIN {
157
tag = ""
159
- stable_cli_release = "^@composio/cli@[0-9]+\\.[0-9]+\\.[0-9]+$"
158
+ stable = "^@composio/cli@[0-9]+\\.[0-9]+\\.[0-9]+$"
159
}
160
/"tag_name":[[:space:]]*"/ {
161
tag = $0
162
sub(/^.*"tag_name":[[:space:]]*"/, "", tag)
163
sub(/".*$/, "", tag)
165
- if (tag !~ stable_cli_release) {
166
- tag = ""
167
- }
164
+ if (tag !~ stable) tag = ""
165
}
166
tag != "" && /"browser_download_url":[[:space:]]*"/ && index($0, "/" asset_name "\"") > 0 {
167
url = $0
168
sub(/^.*"browser_download_url":[[:space:]]*"/, "", url)
169
sub(/".*$/, "", url)
173
- print tag "\t" url
170
+ print tag
171
+ print url
172
exit
173
}
174
')
175
178
- if [[ -n "$release_line" ]]; then
179
- printf '%s\n' "$release_line"
176
+ if [ -n "$resolve_release" ]; then
177
+ printf '%s\n' "$resolve_release"
178
return 0
179
fi
180
183
- if ! printf '%s\n' "$release_json" | grep -q '"tag_name"'; then
184
- break
185
- fi
181
+ printf '%s\n' "$resolve_json" | grep -q '"tag_name"' || break
182
+ resolve_page=$((resolve_page + 1))
183
done
184
185
return 1
186
}
187
191
-# --- Version resolution ---
188
+detect_target() {
189
+ platform=$(uname -ms)
190
+ case $platform in
191
+ 'MINGW64'* | 'MSYS'* | 'CYGWIN'*)
192
+ error 'Windows is not supported. Use WSL (https://learn.microsoft.com/windows/wsl/install) and run this script inside your WSL distribution.'
193
+ ;;
194
+ 'Darwin x86_64') target=darwin-x64 ;;
195
+ 'Darwin arm64') target=darwin-aarch64 ;;
196
+ 'Linux aarch64' | 'Linux arm64') target=linux-aarch64 ;;
197
+ 'Linux x86_64') target=linux-x64 ;;
198
+ *) error "Unsupported platform: $platform" ;;
199
+ esac
200
193
-if [[ -z "$version_arg" ]]; then
194
- info "Finding latest CLI release..."
201
+ if [ "$target" = darwin-x64 ]; then
202
+ translated=$(sysctl -n sysctl.proc_translated 2>/dev/null || printf '0')
203
+ if [ "$translated" = 1 ]; then
204
+ target=darwin-aarch64
205
+ info "Your shell is running in Rosetta 2. Downloading for $target instead"
206
+ fi
207
+ fi
208
+}
209
196
- latest_release=$(resolve_latest_cli_release) ||
197
- error "Failed to determine the latest CLI release with a $archive_name asset. Please specify a version manually."
210
+verify_checksum() {
211
+ checksum_archive=$1
212
+ checksum_manifest=$2
213
+ checksum_name=$3
214
+ checksum_expected=$(awk -v name="$checksum_name" '$2 == name || $2 == "*" name { print $1; exit }' "$checksum_manifest")
215
199
- version=${latest_release%%$'\t'*}
200
- archive_url=${latest_release#*$'\t'}
216
+ if [ -z "$checksum_expected" ]; then
217
+ warn "No checksum entry found for $checksum_name; continuing without verification"
218
+ return 0
219
+ fi
220
+ printf '%s\n' "$checksum_expected" | grep -Eq '^[0-9a-fA-F]{64}$' ||
221
+ error "Malformed checksum for $checksum_name"
222
202
- info "Found latest version: $version"
203
-else
204
- version=$version_arg
205
- archive_url="$github_repo/releases/download/$version/$archive_name"
206
-fi
223
+ if command -v sha256sum >/dev/null 2>&1; then
224
+ checksum_actual=$(sha256sum "$checksum_archive" | awk '{ print $1 }')
225
+ elif command -v shasum >/dev/null 2>&1; then
226
+ checksum_actual=$(shasum -a 256 "$checksum_archive" | awk '{ print $1 }')
227
+ else
228
+ warn 'No SHA-256 utility found; continuing without verification'
229
+ return 0
230
+ fi
231
208
-# --- Download into temp directory ---
232
+ [ "$checksum_expected" = "$checksum_actual" ] ||
233
+ error "Checksum mismatch for $checksum_name (expected $checksum_expected, got $checksum_actual)"
234
+ info 'Checksum verified'
235
+}
236
210
-tmpdir="$(mktemp -d)"
211
-trap 'rm -rf "$tmpdir"' EXIT
237
+resolve_directory() {
238
+ resolve_directory_value=$1
239
+ mkdir -p "$resolve_directory_value" || error "Failed to create directory \"$resolve_directory_value\""
240
+ (cd "$resolve_directory_value" && pwd -P)
241
+}
242
213
-checksums_url="$github_repo/releases/download/$version/checksums.txt"
243
+install_bundle() {
244
+ install_bundle_root=$1
245
+ install_bundle_dir=$install_bundle_root/composio-$target
246
215
-info "Installing Composio CLI $version for $target"
247
+ if [ ! -f "$install_bundle_dir/composio" ]; then
248
+ rm -f "$install_bundle_root/$archive_name" "$install_bundle_root/checksums.txt"
249
+ install_bundle_dir=$install_bundle_root
250
+ fi
251
+ [ -f "$install_bundle_dir/composio" ] || error 'Binary not found in extracted archive'
252
217
-info "Downloading..."
218
-curl --fail --location --progress-bar --output "$tmpdir/$archive_name" "$archive_url" ||
219
- error "Failed to download from \"$archive_url\""
253
+ if ! find "$install_bundle_dir" -mindepth 1 ! -name composio -print -quit | grep -q .; then
254
+ warn 'This release archive has no bundled support files. Some CLI features may be unavailable.'
255
+ fi
256
221
-# --- Checksum verification ---
257
+ cp -Rp "$install_bundle_dir"/. "$resolved_install_dir/" ||
258
+ error "Failed to install the CLI bundle to \"$resolved_install_dir\""
259
+ chmod +x "$resolved_install_dir/composio" || error 'Failed to set permissions on executable'
260
+ printf '%s\n' "$version" >"$resolved_install_dir/release-tag.txt" ||
261
+ error "Failed to write install metadata to \"$resolved_install_dir/release-tag.txt\""
262
+}
263
223
-if curl --fail --silent --location --output "$tmpdir/checksums.txt" "$checksums_url" 2>/dev/null; then
224
- expected=$(grep "$archive_name" "$tmpdir/checksums.txt" | awk '{print $1}')
264
+install_entry_point() {
265
+ entry_point=$resolved_bin_dir/composio
266
+ if [ "$resolved_bin_dir" = "$resolved_install_dir" ]; then
267
+ return 0
268
+ fi
269
+ if [ -d "$entry_point" ]; then
270
+ error "Cannot replace entry point \"$entry_point\" because it is a directory"
271
+ fi
272
+ ln -sf "$resolved_install_dir/composio" "$entry_point" ||
273
+ error "Failed to create entry point \"$entry_point\""
274
+}
275
226
- if [[ -n "$expected" ]]; then
227
- if command -v sha256sum &>/dev/null; then
228
- actual=$(sha256sum "$tmpdir/$archive_name" | awk '{print $1}')
229
- elif command -v shasum &>/dev/null; then
230
- actual=$(shasum -a 256 "$tmpdir/$archive_name" | awk '{print $1}')
231
- else
232
- actual=""
233
- warn "No SHA-256 utility found — skipping verification"
234
- fi
276
+path_contains_bin_dir() {
277
+ case :${PATH:-}: in
278
+ *:"$resolved_bin_dir":*) return 0 ;;
279
+ *) return 1 ;;
280
+ esac
281
+}
282
236
- if [[ -n "$actual" && "$expected" != "$actual" ]]; then
237
- error "Checksum mismatch for $archive_name\n Expected: $expected\n Actual: $actual"
238
- fi
283
+print_post_install_help() {
284
+ [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0
285
+ is_true "${COMPOSIO_QUIET:-}" && return 0
286
+
287
+ shell_name=${SHELL##*/}
288
+ shell_route=
289
+ shell_config=
290
+ case $shell_name in
291
+ zsh)
292
+ shell_route=zsh
293
+ shell_config=~/.zshrc
294
+ ;;
295
+ bash)
296
+ shell_route=bash
297
+ shell_config=~/.bashrc
298
+ ;;
299
+ fish)
300
+ shell_route=fish
301
+ shell_config=~/.config/fish/config.fish
302
+ ;;
303
+ esac
304
+
305
+ guidance_required=0
306
+ path_contains_bin_dir || guidance_required=1
307
+ if [ "$shell_name" = bash ] && { [ -f "$HOME/.bash_profile" ] || [ -f "$HOME/.bash_login" ]; }; then
308
+ guidance_required=1
309
+ fi
310
240
- if [[ -n "$actual" ]]; then
241
- info "Checksum verified"
311
+ printf '\n'
312
+ if [ -n "$shell_route" ]; then
313
+ if [ "$guidance_required" = 1 ]; then
314
+ printf 'Required next step for %s:\n\n' "$shell_name"
315
+ else
316
+ printf 'Optional shell setup for completions and future PATH changes:\n\n'
317
fi
318
+ printf ' curl -fsSL https://composio.dev/install/%s | sh\n' "$shell_route"
319
+ printf '\nThis configures %s.\n' "$shell_config"
320
+ elif path_contains_bin_dir; then
321
+ printf 'The composio command is available on PATH.\n'
322
else
244
- warn "No checksum entry found for $archive_name — skipping verification"
323
+ printf 'Add %s to PATH, then start a new shell.\n' "$(tildify "$resolved_bin_dir")"
324
fi
246
-else
247
- info "No checksums.txt in release — skipping verification"
248
-fi
249
-
250
-# --- Extract and install ---
325
+ printf "\nRun \`composio --help\` to get started.\n"
326
+}
327
252
-info "Extracting..."
253
-unzip -oqd "$tmpdir" "$tmpdir/$archive_name" ||
254
- error 'Failed to extract archive'
328
+cleanup() {
329
+ if [ -n "${tmpdir:-}" ] && [ -d "$tmpdir" ]; then
330
+ rm -rf "$tmpdir"
331
+ fi
332
+}
333
256
-mkdir -p "$COMPOSIO_INSTALL_DIR" ||
257
- error "Failed to create install directory \"$COMPOSIO_INSTALL_DIR\""
334
+main() {
335
+ install_agent=0
336
+ install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}
337
+ version_arg=
338
259
-exe="$COMPOSIO_INSTALL_DIR/composio"
260
-release_tag_file="$COMPOSIO_INSTALL_DIR/release-tag.txt"
339
+ case $install_plugins in
340
+ 0 | 1) ;;
341
+ *) error 'COMPOSIO_INSTALL_PLUGINS must be 1 or 0' ;;
342
+ esac
343
262
-install_bundle_support_files() {
263
- local source_dir="$1"
264
- local installed_count=0
344
+ while [ "$#" -gt 0 ]; do
345
+ case $1 in
346
+ --agent) install_agent=1 ;;
347
+ --no-plugins) install_plugins=0 ;;
348
+ -h | --help)
349
+ print_usage
350
+ return 0
351
+ ;;
352
+ --*) error "Unknown option: $1" ;;
353
+ *)
354
+ [ -z "$version_arg" ] || error 'Too many arguments. Expected at most one version tag.'
355
+ version_arg=$1
356
+ ;;
357
+ esac
358
+ shift
359
+ done
360
266
- while IFS= read -r -d '' source_path; do
267
- local relative_path=${source_path#"$source_dir"/}
268
- local target_path="$COMPOSIO_INSTALL_DIR/$relative_path"
361
+ COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-ComposioHQ}
362
+ COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-composio}
363
+ COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-https://github.com}
364
+ COMPOSIO_GITHUB_API_BASE_URL=${COMPOSIO_GITHUB_API_BASE_URL:-}
365
+ COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
366
+ COMPOSIO_BIN_DIR=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
367
+
368
+ validate_identifier COMPOSIO_GITHUB_OWNER "$COMPOSIO_GITHUB_OWNER"
369
+ validate_identifier COMPOSIO_GITHUB_REPO "$COMPOSIO_GITHUB_REPO"
370
+ validate_url "$COMPOSIO_GITHUB_URL" ||
371
+ error "COMPOSIO_GITHUB_URL must use https or an explicitly allowed test host (got \"$COMPOSIO_GITHUB_URL\")"
372
+ if [ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]; then
373
+ validate_url "$COMPOSIO_GITHUB_API_BASE_URL" ||
374
+ error "COMPOSIO_GITHUB_API_BASE_URL must use https or an explicitly allowed test host (got \"$COMPOSIO_GITHUB_API_BASE_URL\")"
375
+ fi
376
270
- mkdir -p "$(dirname "$target_path")" ||
271
- error "Failed to create support file directory \"$(dirname "$target_path")\""
377
+ detect_target
378
+ command -v curl >/dev/null 2>&1 || error 'curl is required to install Composio CLI'
379
+ command -v unzip >/dev/null 2>&1 || error 'unzip is required to install Composio CLI'
380
273
- mv "$source_path" "$target_path" ||
274
- error "Failed to install support file \"$relative_path\""
381
+ github_repo=${COMPOSIO_GITHUB_URL%/}/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO
382
+ if [ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]; then
383
+ github_api_base=${COMPOSIO_GITHUB_API_BASE_URL%/}
384
+ elif [ "$COMPOSIO_GITHUB_URL" = https://github.com ]; then
385
+ github_api_base=https://api.github.com
386
+ else
387
+ github_api_base=${COMPOSIO_GITHUB_URL%/}/api/v3
388
+ fi
389
+ github_api_repo=$github_api_base/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO
390
+ archive_name=composio-$target.zip
391
276
- installed_count=$((installed_count + 1))
277
- done < <(find "$source_dir" -mindepth 1 -type f ! -path "$source_dir/composio" -print0)
392
+ requested_version=$version_arg
393
+ if [ -z "$requested_version" ]; then
394
+ requested_version=${COMPOSIO_INSTALL_VERSION:-}
395
+ fi
396
279
- if (( installed_count == 0 )); then
280
- warn "This release archive does not include any bundled support files beyond the main binary. Some CLI features may be unavailable in this version."
397
+ if [ -n "$requested_version" ]; then
398
+ version=$(normalize_version "$requested_version")
399
+ archive_url=$github_repo/releases/download/$version/$archive_name
400
+ else
401
+ info 'Finding latest stable CLI release...'
402
+ latest_release=$(resolve_latest_cli_release) ||
403
+ error "Failed to determine the latest CLI release with a $archive_name asset. Specify a version manually."
404
+ version=$(printf '%s\n' "$latest_release" | sed -n '1p')
405
+ archive_url=$(printf '%s\n' "$latest_release" | sed -n '2p')
406
+ [ -n "$version" ] && [ -n "$archive_url" ] || error 'The release API returned an incomplete CLI release'
407
+ info "Found latest version: $version"
408
fi
282
-}
409
+ validate_url "$archive_url" || error "Release API returned an unsafe archive URL \"$archive_url\""
410
+
411
+ checksums_url=$github_repo/releases/download/$version/checksums.txt
412
+ validate_url "$checksums_url" || error "Refusing unsafe checksum URL \"$checksums_url\""
413
284
-# Handle nested directory structure (composio-<target>/composio)
285
-if [[ -f "$tmpdir/composio-$target/composio" ]]; then
286
- mv "$tmpdir/composio-$target/composio" "$exe"
287
- install_bundle_support_files "$tmpdir/composio-$target"
288
-elif [[ -f "$tmpdir/composio" ]]; then
289
- mv "$tmpdir/composio" "$exe"
290
- install_bundle_support_files "$tmpdir"
291
-else
292
- error 'Binary not found in extracted archive'
293
-fi
294
-
295
-chmod +x "$exe" ||
296
- error 'Failed to set permissions on executable'
297
-
298
-printf '%s\n' "$version" > "$release_tag_file" ||
299
- error "Failed to write install metadata to \"$release_tag_file\""
300
-
301
-success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")"
302
-
303
-# --- Shell integration (PATH + completions) ---
304
-
305
-# Delegate to the CLI's own install command, which handles:
306
-# - Idempotent PATH setup in the correct rc file
307
-# - Shell completions installation
308
-# If the binary can't run (e.g. missing runtime), fall back to inline setup.
309
-#
310
-# Run it with stderr left on the terminal. `composio install` reports which rc
311
-# file it changed and how to reload the shell, and it treats a redirected stderr
312
-# as "nobody is watching" — capturing that stream, even to replay it later, is
313
-# what makes the PATH guidance disappear. The version probe keeps a binary that
314
-# cannot run at all from spilling loader errors before the fallback takes over.
315
-
316
-echo
317
-
318
-if "$exe" --version >/dev/null 2>&1 &&
319
- COMPOSIO_INSTALL_DIR="$COMPOSIO_INSTALL_DIR" COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" install; then
320
- : # the CLI printed its own shell-integration guidance
321
-else
322
- info "Setting up shell integration..."
323
-
324
- refresh_command=''
325
- quoted_install_dir=\"${COMPOSIO_INSTALL_DIR//\"/\\\"}\"
326
-
327
- if [[ $quoted_install_dir = \"$HOME/* ]]; then
328
- quoted_install_dir=${COMPOSIO_INSTALL_DIR/$HOME\//\$HOME/}
414
+ tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'
415
+ trap cleanup 0 1 2 3 15
416
+ debug "temporary directory: $tmpdir"
417
+
418
+ info "Installing Composio CLI $version for $target"
419
+ curl_download "$archive_url" "$tmpdir/$archive_name" 0 ||
420
+ error "Failed to download from \"$archive_url\""
421
+
422
+ if curl_download "$checksums_url" "$tmpdir/checksums.txt" 1; then
423
+ verify_checksum "$tmpdir/$archive_name" "$tmpdir/checksums.txt" "$archive_name"
424
+ else
425
+ warn 'No checksums.txt in this release; continuing without verification'
426
fi
427
331
- shell_name=$(basename "${SHELL:-}")
332
- marker='# Composio CLI'
428
+ info 'Extracting bundle...'
429
+ unzip -oqd "$tmpdir" "$tmpdir/$archive_name" || error 'Failed to extract archive'
430
334
- case $shell_name in
335
- fish)
336
- commands=(
337
- "set --export COMPOSIO_INSTALL_DIR \"$COMPOSIO_INSTALL_DIR\""
338
- "set --export PATH \$COMPOSIO_INSTALL_DIR \$PATH"
339
- )
340
- fish_config=$HOME/.config/fish/config.fish
341
- if [[ -w $fish_config ]] || [[ -w $(dirname "$fish_config") ]]; then
342
- mkdir -p "$(dirname "$fish_config")"
343
- if ! grep -qxF "$marker" "$fish_config" 2>/dev/null; then
344
- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$fish_config"
345
- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$fish_config")\""
346
- else
347
- info "PATH already configured in \"$(tildify "$fish_config")\""
348
- fi
349
- refresh_command="source $(tildify "$fish_config")"
350
- else
351
- echo "Manually add the directory to $(tildify "$fish_config") (or similar):"
352
- for cmd in "${commands[@]}"; do info_bold " $cmd"; done
353
- fi
354
- ;;
355
- zsh)
356
- commands=(
357
- "export COMPOSIO_INSTALL_DIR=\"$COMPOSIO_INSTALL_DIR\""
358
- "export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""
359
- )
360
- zsh_config=$HOME/.zshrc
361
- if [[ ! -f $zsh_config && -w $(dirname "$zsh_config") ]]; then touch "$zsh_config"; fi
362
- if [[ -w $zsh_config ]]; then
363
- if ! grep -qxF "$marker" "$zsh_config" 2>/dev/null; then
364
- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$zsh_config"
365
- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$zsh_config")\""
366
- else
367
- info "PATH already configured in \"$(tildify "$zsh_config")\""
368
- fi
369
- refresh_command="source $(tildify "$zsh_config")"
370
- else
371
- echo "Manually add the directory to $(tildify "$zsh_config") (or similar):"
372
- for cmd in "${commands[@]}"; do info_bold " $cmd"; done
373
- fi
374
- ;;
375
- bash)
376
- commands=(
377
- "export COMPOSIO_INSTALL_DIR=$quoted_install_dir"
378
- "export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""
379
- )
380
- bash_configs=("$HOME/.bashrc" "$HOME/.bash_profile")
381
- if [[ ${XDG_CONFIG_HOME:-} ]]; then
382
- bash_configs+=("$XDG_CONFIG_HOME/.bash_profile" "$XDG_CONFIG_HOME/.bashrc" "$XDG_CONFIG_HOME/bash_profile" "$XDG_CONFIG_HOME/bashrc")
383
- fi
384
- set_manually=true
385
- for bash_config in "${bash_configs[@]}"; do
386
- if [[ -w $bash_config ]]; then
387
- if ! grep -qxF "$marker" "$bash_config" 2>/dev/null; then
388
- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$bash_config"
389
- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$bash_config")\""
390
- else
391
- info "PATH already configured in \"$(tildify "$bash_config")\""
392
- fi
393
- refresh_command="source $bash_config"
394
- set_manually=false
395
- break
396
- fi
397
- done
398
- if [[ $set_manually = true ]]; then
399
- echo "Manually add the directory to ~/.bashrc (or similar):"
400
- for cmd in "${commands[@]}"; do info_bold " $cmd"; done
401
- fi
402
- ;;
403
- *)
404
- echo 'Manually add the directory to ~/.bashrc (or similar):'
405
- info_bold " export COMPOSIO_INSTALL_DIR=$quoted_install_dir"
406
- info_bold " export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""
407
- ;;
408
- esac
431
+ resolved_install_dir=$(resolve_directory "$COMPOSIO_INSTALL_DIR")
432
+ resolved_bin_dir=$(resolve_directory "$COMPOSIO_BIN_DIR")
433
+ install_bundle "$tmpdir"
434
+ install_entry_point
435
410
-fi
436
+ exe=$resolved_install_dir/composio
437
+ "$exe" --version >/dev/null 2>&1 || error 'The installed Composio CLI failed its version check'
438
+ info "Composio CLI was installed to $(tildify "$exe")"
439
+ if [ "$resolved_bin_dir" != "$resolved_install_dir" ]; then
440
+ info "The composio entry point is $(tildify "$resolved_bin_dir/composio")"
441
+ fi
442
412
-if [[ $install_plugins = true ]]; then
413
- echo
414
- info "Checking for supported agent hosts..."
415
- if ! COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present; then
416
- error 'Composio CLI was installed, but agent plugin setup failed. Retry with `composio setup --target auto --yes`.'
443
+ if [ "$install_plugins" = 1 ]; then
444
+ info 'Installing plugins for detected agent hosts...'
445
+ COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present ||
446
+ error "Composio CLI was installed, but agent plugin setup failed. Retry with \`composio setup --target auto --yes\`."
447
fi
418
-fi
448
420
-if [[ $install_agent = true ]]; then
421
- echo
422
- info "Setting up Composio agent login..."
423
- if ! COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" login --agent --no-skill-install; then
424
- error 'Failed to sign up/log in as a Composio agent. If this CLI is already signed in as a regular user, run `composio logout` and then `composio signup` or `composio agent login <composio_agent_key>`.'
449
+ if [ "$install_agent" = 1 ]; then
450
+ info 'Setting up Composio agent login...'
451
+ COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" login --agent --no-skill-install ||
452
+ error 'Failed to sign up or log in as a Composio agent.'
453
fi
426
-fi
427
-
428
-echo
429
-# No PATH claim here: whichever branch ran above already reported what it did to
430
-# which file, and whether a reload is needed. Restating it unconditionally would
431
-# promise a configured PATH even on the branches that only printed manual
432
-# instructions.
433
-info "To get started, run:"
434
-echo
435
-
436
-if [[ ${refresh_command:-} ]]; then
437
- info_bold " $refresh_command"
438
-fi
439
-
440
-info_bold " composio --help"
441
-if [[ $install_agent = true ]]; then
442
- info_bold " composio agent whoami"
443
-else
444
- info_bold " composio login"
445
-fi
454
+
455
+ print_post_install_help
456
+}
457
+
458
+main "$@"
install/bash.sh
new
+141
@@ -0,0 +1,141 @@
1
+#!/bin/sh
2
+set -eu
3
+
4
+requested_shell() { printf '%s\n' bash; }
5
+
6
+error() {
7
+ printf 'error: %s\n' "$*" >&2
8
+ exit 1
9
+}
10
+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11
+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
12
+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
13
+
14
+url_authority() {
15
+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'
16
+}
17
+
18
+is_allowed_http_authority() {
19
+ case $1 in
20
+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;
21
+ esac
22
+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then
23
+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac
24
+ fi
25
+ return 1
26
+}
27
+
28
+validate_url() {
29
+ variant_url=$1
30
+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac
31
+ variant_authority=$(url_authority "$variant_url")
32
+ [ -n "$variant_authority" ] || return 1
33
+ case $variant_authority in *@*) return 1 ;; esac
34
+ case $variant_url in
35
+ https://*) return 0 ;;
36
+ http://*) is_allowed_http_authority "$variant_authority" ;;
37
+ *) return 1 ;;
38
+ esac
39
+}
40
+
41
+download_installer() {
42
+ variant_url=$1
43
+ variant_output=$2
44
+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""
45
+ debug "curl GET $variant_url -> $variant_output"
46
+ case $variant_url in
47
+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
48
+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
49
+ esac
50
+}
51
+
52
+is_unsafe_path() {
53
+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54
+ variant_cr=$(printf '\r')
55
+ case $1 in *"$variant_cr"* | *'
56
+'*) return 0 ;; esac
57
+ return 1
58
+}
59
+
60
+render_bin_dir() {
61
+ variant_render=$1
62
+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63
+ printf '%s\n' "$variant_render"
64
+}
65
+
66
+append_path_block() {
67
+ variant_file=$1
68
+ variant_shell=$2
69
+ variant_bin=$3
70
+ mkdir -p "$(dirname "$variant_file")"
71
+ touch "$variant_file"
72
+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73
+ case $variant_shell in
74
+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75
+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76
+ esac
77
+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78
+}
79
+
80
+inline_shell_setup() {
81
+ variant_shell=$1
82
+ variant_bin_dir=$2
83
+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84
+ variant_rendered=$(render_bin_dir "$variant_bin_dir")
85
+ case $variant_shell in
86
+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87
+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88
+ bash)
89
+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90
+ if [ -f "$HOME/.bash_profile" ]; then
91
+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92
+ elif [ -f "$HOME/.bash_login" ]; then
93
+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94
+ fi
95
+ ;;
96
+ esac
97
+}
98
+
99
+cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
100
+
101
+main() {
102
+ variant_shell=$(requested_shell)
103
+ # Internal test override. User-facing docs intentionally omit this variable.
104
+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}
105
+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'
106
+ debug "temporary directory: $variant_tmpdir"
107
+ trap cleanup 0 1 2 3 15
108
+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
109
+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
110
+
111
+ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
112
+
113
+ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
114
+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
115
+ variant_exe=$variant_install_dir/composio
116
+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
117
+
118
+ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
119
+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"
120
+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
121
+ variant_configured=cli
122
+ else
123
+ debug "falling back to inline $variant_shell shell setup"
124
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
125
+ variant_configured=fallback
126
+ fi
127
+ else
128
+ debug "falling back to inline $variant_shell shell setup"
129
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
130
+ variant_configured=fallback
131
+ fi
132
+
133
+ info "Configured $variant_shell shell setup ($variant_configured)."
134
+ case $variant_shell in
135
+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
136
+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
137
+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
138
+ esac
139
+}
140
+
141
+main "$@"
install/fish.sh
new
+141
@@ -0,0 +1,141 @@
1
+#!/bin/sh
2
+set -eu
3
+
4
+requested_shell() { printf '%s\n' fish; }
5
+
6
+error() {
7
+ printf 'error: %s\n' "$*" >&2
8
+ exit 1
9
+}
10
+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11
+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
12
+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
13
+
14
+url_authority() {
15
+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'
16
+}
17
+
18
+is_allowed_http_authority() {
19
+ case $1 in
20
+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;
21
+ esac
22
+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then
23
+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac
24
+ fi
25
+ return 1
26
+}
27
+
28
+validate_url() {
29
+ variant_url=$1
30
+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac
31
+ variant_authority=$(url_authority "$variant_url")
32
+ [ -n "$variant_authority" ] || return 1
33
+ case $variant_authority in *@*) return 1 ;; esac
34
+ case $variant_url in
35
+ https://*) return 0 ;;
36
+ http://*) is_allowed_http_authority "$variant_authority" ;;
37
+ *) return 1 ;;
38
+ esac
39
+}
40
+
41
+download_installer() {
42
+ variant_url=$1
43
+ variant_output=$2
44
+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""
45
+ debug "curl GET $variant_url -> $variant_output"
46
+ case $variant_url in
47
+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
48
+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
49
+ esac
50
+}
51
+
52
+is_unsafe_path() {
53
+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54
+ variant_cr=$(printf '\r')
55
+ case $1 in *"$variant_cr"* | *'
56
+'*) return 0 ;; esac
57
+ return 1
58
+}
59
+
60
+render_bin_dir() {
61
+ variant_render=$1
62
+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63
+ printf '%s\n' "$variant_render"
64
+}
65
+
66
+append_path_block() {
67
+ variant_file=$1
68
+ variant_shell=$2
69
+ variant_bin=$3
70
+ mkdir -p "$(dirname "$variant_file")"
71
+ touch "$variant_file"
72
+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73
+ case $variant_shell in
74
+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75
+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76
+ esac
77
+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78
+}
79
+
80
+inline_shell_setup() {
81
+ variant_shell=$1
82
+ variant_bin_dir=$2
83
+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84
+ variant_rendered=$(render_bin_dir "$variant_bin_dir")
85
+ case $variant_shell in
86
+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87
+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88
+ bash)
89
+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90
+ if [ -f "$HOME/.bash_profile" ]; then
91
+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92
+ elif [ -f "$HOME/.bash_login" ]; then
93
+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94
+ fi
95
+ ;;
96
+ esac
97
+}
98
+
99
+cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
100
+
101
+main() {
102
+ variant_shell=$(requested_shell)
103
+ # Internal test override. User-facing docs intentionally omit this variable.
104
+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}
105
+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'
106
+ debug "temporary directory: $variant_tmpdir"
107
+ trap cleanup 0 1 2 3 15
108
+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
109
+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
110
+
111
+ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
112
+
113
+ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
114
+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
115
+ variant_exe=$variant_install_dir/composio
116
+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
117
+
118
+ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
119
+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"
120
+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
121
+ variant_configured=cli
122
+ else
123
+ debug "falling back to inline $variant_shell shell setup"
124
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
125
+ variant_configured=fallback
126
+ fi
127
+ else
128
+ debug "falling back to inline $variant_shell shell setup"
129
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
130
+ variant_configured=fallback
131
+ fi
132
+
133
+ info "Configured $variant_shell shell setup ($variant_configured)."
134
+ case $variant_shell in
135
+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
136
+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
137
+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
138
+ esac
139
+}
140
+
141
+main "$@"
install/zsh.sh
new
+141
@@ -0,0 +1,141 @@
1
+#!/bin/sh
2
+set -eu
3
+
4
+requested_shell() { printf '%s\n' zsh; }
5
+
6
+error() {
7
+ printf 'error: %s\n' "$*" >&2
8
+ exit 1
9
+}
10
+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }
11
+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }
12
+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }
13
+
14
+url_authority() {
15
+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'
16
+}
17
+
18
+is_allowed_http_authority() {
19
+ case $1 in
20
+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;
21
+ esac
22
+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then
23
+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac
24
+ fi
25
+ return 1
26
+}
27
+
28
+validate_url() {
29
+ variant_url=$1
30
+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac
31
+ variant_authority=$(url_authority "$variant_url")
32
+ [ -n "$variant_authority" ] || return 1
33
+ case $variant_authority in *@*) return 1 ;; esac
34
+ case $variant_url in
35
+ https://*) return 0 ;;
36
+ http://*) is_allowed_http_authority "$variant_authority" ;;
37
+ *) return 1 ;;
38
+ esac
39
+}
40
+
41
+download_installer() {
42
+ variant_url=$1
43
+ variant_output=$2
44
+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""
45
+ debug "curl GET $variant_url -> $variant_output"
46
+ case $variant_url in
47
+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
48
+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;
49
+ esac
50
+}
51
+
52
+is_unsafe_path() {
53
+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac
54
+ variant_cr=$(printf '\r')
55
+ case $1 in *"$variant_cr"* | *'
56
+'*) return 0 ;; esac
57
+ return 1
58
+}
59
+
60
+render_bin_dir() {
61
+ variant_render=$1
62
+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac
63
+ printf '%s\n' "$variant_render"
64
+}
65
+
66
+append_path_block() {
67
+ variant_file=$1
68
+ variant_shell=$2
69
+ variant_bin=$3
70
+ mkdir -p "$(dirname "$variant_file")"
71
+ touch "$variant_file"
72
+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0
73
+ case $variant_shell in
74
+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;
75
+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;
76
+ esac
77
+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"
78
+}
79
+
80
+inline_shell_setup() {
81
+ variant_shell=$1
82
+ variant_bin_dir=$2
83
+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"
84
+ variant_rendered=$(render_bin_dir "$variant_bin_dir")
85
+ case $variant_shell in
86
+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;
87
+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;
88
+ bash)
89
+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"
90
+ if [ -f "$HOME/.bash_profile" ]; then
91
+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"
92
+ elif [ -f "$HOME/.bash_login" ]; then
93
+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"
94
+ fi
95
+ ;;
96
+ esac
97
+}
98
+
99
+cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }
100
+
101
+main() {
102
+ variant_shell=$(requested_shell)
103
+ # Internal test override. User-facing docs intentionally omit this variable.
104
+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}
105
+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'
106
+ debug "temporary directory: $variant_tmpdir"
107
+ trap cleanup 0 1 2 3 15
108
+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'
109
+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'
110
+
111
+ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"
112
+
113
+ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}
114
+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}
115
+ variant_exe=$variant_install_dir/composio
116
+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""
117
+
118
+ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then
119
+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"
120
+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then
121
+ variant_configured=cli
122
+ else
123
+ debug "falling back to inline $variant_shell shell setup"
124
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
125
+ variant_configured=fallback
126
+ fi
127
+ else
128
+ debug "falling back to inline $variant_shell shell setup"
129
+ inline_shell_setup "$variant_shell" "$variant_bin_dir"
130
+ variant_configured=fallback
131
+ fi
132
+
133
+ info "Configured $variant_shell shell setup ($variant_configured)."
134
+ case $variant_shell in
135
+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;
136
+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;
137
+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;
138
+ esac
139
+}
140
+
141
+main "$@"
test/install-sh-release-resolution.test.sh
+459
-372
@@ -2,421 +2,508 @@
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
6
-tmpdir="$(mktemp -d)"
7
-trap 'rm -rf "$tmpdir"' EXIT
8
-
9
-bin_dir="$tmpdir/bin"
10
-home_dir="$tmpdir/home"
11
-install_dir="$tmpdir/install"
12
-mkdir -p "$bin_dir" "$home_dir" "$install_dir"
13
-
14
-windows_bin_dir="$tmpdir/windows-bin"
15
-mkdir -p "$windows_bin_dir"
16
-cat > "$windows_bin_dir/uname" <<'EOF'
17
-#!/bin/sh
18
-printf '%s\n' 'MINGW64_NT-10.0 x86_64'
19
-EOF
20
-chmod +x "$windows_bin_dir/uname"
21
-
22
-bash_bin=$(command -v bash)
23
-run_windows_installer() {
24
- env PATH="$windows_bin_dir" HOME="$home_dir" "$bash_bin" "$repo_root/install.sh" "$@"
8
+fail() {
9
+ printf 'FAIL: %s\n' "$*" >&2
10
+ exit 1
11
}
12
27
-if ! windows_help_output=$(run_windows_installer --help 2>&1); then
28
- echo 'Expected install.sh --help to succeed before platform and prerequisite checks.' >&2
29
- printf '%s\n' "$windows_help_output" >&2
30
- exit 1
31
-fi
32
-if ! grep -q '^Usage: install.sh' <<<"$windows_help_output"; then
33
- echo 'Expected install.sh --help to print usage on Windows-like platforms.' >&2
34
- printf '%s\n' "$windows_help_output" >&2
35
- exit 1
36
-fi
13
+assert_contains() {
14
+ local haystack=$1
15
+ local needle=$2
16
+ local label=$3
17
+ grep -Fq -- "$needle" <<<"$haystack" || fail "$label (missing: $needle)"
18
+}
19
38
-if invalid_option_output=$(run_windows_installer --invalid-option 2>&1); then
39
- echo 'Expected install.sh to reject an unknown option before platform checks.' >&2
40
- exit 1
41
-fi
42
-if ! grep -q 'Unknown option: --invalid-option' <<<"$invalid_option_output"; then
43
- echo 'Expected the unknown-option error on Windows-like platforms.' >&2
44
- printf '%s\n' "$invalid_option_output" >&2
45
- exit 1
46
-fi
47
-if grep -Eq 'Windows is not supported|(curl|unzip) is required to install Composio CLI' <<<"$invalid_option_output"; then
48
- echo 'Expected argument validation to take precedence over platform and prerequisite errors.' >&2
49
- printf '%s\n' "$invalid_option_output" >&2
50
- exit 1
51
-fi
20
+assert_not_contains() {
21
+ local haystack=$1
22
+ local needle=$2
23
+ local label=$3
24
+ if grep -Fq -- "$needle" <<<"$haystack"; then
25
+ fail "$label (unexpected: $needle)"
26
+ fi
27
+}
28
53
-if excess_arguments_output=$(run_windows_installer first-version second-version 2>&1); then
54
- echo 'Expected install.sh to reject excess positional arguments before platform checks.' >&2
55
- exit 1
56
-fi
57
-if ! grep -q 'Too many arguments' <<<"$excess_arguments_output"; then
58
- echo 'Expected the excess-arguments error on Windows-like platforms.' >&2
59
- printf '%s\n' "$excess_arguments_output" >&2
60
- exit 1
61
-fi
62
-if grep -Eq 'Windows is not supported|(curl|unzip) is required to install Composio CLI' <<<"$excess_arguments_output"; then
63
- echo 'Expected argument validation to take precedence over platform and prerequisite errors.' >&2
64
- printf '%s\n' "$excess_arguments_output" >&2
65
- exit 1
66
-fi
29
+for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do
30
+ [[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\""
31
+ [[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point"
32
+ if rg -n '(^|[[:space:]])\[\[[[:space:]]|set -[^[:space:]]*o[[:space:]]+pipefail|<\(|<<<|echo -e|(^|[[:space:]])local[[:space:]]' "$script"; then
33
+ fail "$script contains a non-POSIX shell construct"
34
+ fi
35
+done
36
68
-if windows_output=$(run_windows_installer 2>&1); then
69
- echo 'Expected install.sh to reject Windows-like platforms.' >&2
70
- exit 1
71
-fi
72
-if ! grep -q 'Windows is not supported. Please use WSL' <<<"$windows_output"; then
73
- echo 'Expected Windows-to-WSL guidance when installer prerequisites are missing.' >&2
74
- printf '%s\n' "$windows_output" >&2
75
- exit 1
76
-fi
77
-if grep -Eq '(curl|unzip) is required to install Composio CLI' <<<"$windows_output"; then
78
- echo 'Expected Windows-to-WSL guidance to take precedence over prerequisite errors.' >&2
79
- printf '%s\n' "$windows_output" >&2
80
- exit 1
81
-fi
37
+windows_bin="$suite_tmp/windows-bin"
38
+windows_home="$suite_tmp/windows-home"
39
+mkdir -p "$windows_bin" "$windows_home"
40
+cat >"$windows_bin/uname" <<'EOF'
41
+#!/bin/sh
42
+printf '%s\n' 'MINGW64_NT-10.0 x86_64'
43
+EOF
44
+chmod +x "$windows_bin/uname"
45
+
46
+for interpreter in "$(command -v sh)"; do
47
+ help_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --help 2>&1) ||
48
+ fail '--help must succeed before platform checks'
49
+ assert_contains "$help_output" 'Usage: install.sh' '--help output'
50
+
51
+ if invalid_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --invalid 2>&1); then
52
+ fail 'unknown options must fail'
53
+ fi
54
+ assert_contains "$invalid_output" 'Unknown option: --invalid' 'argument validation order'
55
+ assert_not_contains "$invalid_output" 'Windows is not supported' 'argument validation must precede platform checks'
56
+
57
+ if windows_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" 2>&1); then
58
+ fail 'Windows-like platforms must fail'
59
+ fi
60
+ assert_contains "$windows_output" 'Windows is not supported. Use WSL' 'Windows guidance'
61
+done
62
63
platform=$(uname -ms)
64
case $platform in
85
-'Darwin x86_64') target=darwin-x64 ;;
86
-'Darwin arm64') target=darwin-aarch64 ;;
87
-'Linux aarch64' | 'Linux arm64')
88
- target=linux-aarch64 ;;
89
-'Linux x86_64') target=linux-x64 ;;
90
-*) echo "Unsupported test platform: $platform" >&2; exit 1 ;;
65
+'Darwin x86_64') target=darwin-x64 ;;
66
+'Darwin arm64') target=darwin-aarch64 ;;
67
+'Linux aarch64'|'Linux arm64') target=linux-aarch64 ;;
68
+'Linux x86_64') target=linux-x64 ;;
69
+*) fail "unsupported test platform: $platform" ;;
70
esac
71
72
archive_name="composio-$target.zip"
94
-valid_tag='@composio/cli@98.0.0'
73
+stable_tag='@composio/cli@98.0.0'
74
+beta_tag='@composio/cli@98.0.0-beta.123'
75
missing_asset_tag='@composio/cli@99.0.0'
96
-tag_without_release='@composio/cli@100.0.0'
76
api_base='https://api.example.test'
98
-archive_url="https://downloads.example.test/$valid_tag/$archive_name"
99
-curl_log="$tmpdir/curl.log"
100
-git_log="$tmpdir/git.log"
101
-composio_log="$tmpdir/composio.log"
77
+github_url='https://github.example.test'
78
+archive_url="https://downloads.example.test/$stable_tag/$archive_name"
79
+script_url='https://installer.example.test/install.sh'
80
103
-cat > "$bin_dir/curl" <<'EOF'
81
+interpreters=("$(command -v sh)")
82
+if command -v dash >/dev/null 2>&1 && [[ $(command -v dash) != "${interpreters[0]}" ]]; then
83
+ interpreters+=("$(command -v dash)")
84
+fi
85
+
86
+for interpreter in "${interpreters[@]}"; do
87
+ interpreter_name=$(basename "$interpreter")
88
+ case_root="$suite_tmp/$interpreter_name"
89
+ fake_bin="$case_root/bin"
90
+ curl_log="$case_root/curl.log"
91
+ composio_log="$case_root/composio.log"
92
+ mkdir -p "$fake_bin"
93
+ : >"$curl_log"
94
+ : >"$composio_log"
95
+
96
+ cat >"$fake_bin/curl" <<'EOF'
97
#!/usr/bin/env bash
98
set -euo pipefail
99
107
-output=""
108
-url=""
109
-while [[ $# -gt 0 ]]; do
110
- case "$1" in
111
- --output|-o)
112
- output="$2"
113
- shift 2
114
- ;;
115
- --*)
116
- shift
117
- ;;
118
- *)
119
- url="$1"
120
- shift
121
- ;;
122
- esac
100
+printf '%s\n' "$*" >>"$TEST_CURL_LOG"
101
+all_args=$*
102
+output=
103
+url=
104
+while (($# > 0)); do
105
+ case $1 in
106
+ --output|-o)
107
+ output=$2
108
+ shift 2
109
+ ;;
110
+ --proto|--proto-redir)
111
+ shift 2
112
+ ;;
113
+ --fail|--silent|--show-error|--location|--progress-bar)
114
+ shift
115
+ ;;
116
+ --*)
117
+ shift
118
+ ;;
119
+ *)
120
+ url=$1
121
+ shift
122
+ ;;
123
+ esac
124
done
125
125
-printf '%s\n' "$url" >> "$TEST_CURL_LOG"
126
+case $url in
127
+https://*)
128
+ [[ $all_args == *"--proto =https"* && $all_args == *"--proto-redir =https"* ]] || exit 91
129
+ ;;
130
+http://*)
131
+ [[ $all_args == *"--proto =http,https"* && $all_args == *"--proto-redir =https"* ]] || exit 92
132
+ ;;
133
+esac
134
+
135
+if [[ $url == "$TEST_SCRIPT_URL" ]]; then
136
+ case ${TEST_BASE_MODE:-ok} in
137
+ fail) exit 22 ;;
138
+ empty) : >"$output" ;;
139
+ ok) cp "$TEST_REPO_ROOT/install.sh" "$output" ;;
140
+ esac
141
+ exit 0
142
+fi
143
127
-case "$url" in
144
+case $url in
145
"$TEST_API_BASE/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO/releases?per_page=100&page=1")
129
- cat <<JSON
146
+ asset_url=${TEST_API_ASSET_URL:-$TEST_ARCHIVE_URL}
147
+ cat <<JSON
148
[
131
- {
132
- "tag_name": "$TEST_MISSING_ASSET_TAG",
133
- "prerelease": false,
134
- "draft": false,
135
- "assets": []
136
- },
137
- {
138
- "tag_name": "@composio/cli@99.0.0-beta.1",
139
- "prerelease": true,
140
- "draft": false,
141
- "assets": [
142
- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "https://downloads.example.test/@composio/cli@99.0.0-beta.1/$TEST_ARCHIVE_NAME" }
143
- ]
144
- },
145
- {
146
- "tag_name": "@composio/openai@100.0.0",
147
- "prerelease": false,
148
- "draft": false,
149
- "assets": [
150
- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "https://downloads.example.test/@composio/openai@100.0.0/$TEST_ARCHIVE_NAME" }
151
- ]
152
- },
153
- {
154
- "tag_name": "$TEST_VALID_TAG",
155
- "prerelease": false,
156
- "draft": false,
157
- "assets": [
158
- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "$TEST_ARCHIVE_URL" }
159
- ]
160
- }
149
+ {"tag_name":"$TEST_MISSING_ASSET_TAG","assets":[]},
150
+ {"tag_name":"@composio/cli@99.0.0-beta.1","assets":[{"browser_download_url":"https://downloads.example.test/beta/$TEST_ARCHIVE_NAME"}]},
151
+ {"tag_name":"$TEST_STABLE_TAG","assets":[{"browser_download_url":"$asset_url"}]}
152
]
153
JSON
163
- ;;
164
-"$TEST_ARCHIVE_URL")
165
- if [[ -z "$output" ]]; then
166
- echo 'archive download did not pass --output' >&2
167
- exit 1
168
- fi
169
- printf 'fake archive for %s\n' "$TEST_VALID_TAG" > "$output"
170
- ;;
171
-*checksums.txt)
172
- exit 22
173
- ;;
154
+ ;;
155
+"$TEST_ARCHIVE_URL"|*"/releases/download/"*"/$TEST_ARCHIVE_NAME")
156
+ [[ -n $output ]] || exit 93
157
+ if [[ ${TEST_REDIRECT_DOWNGRADE:-0} == 1 ]]; then
158
+ exit 47
159
+ fi
160
+ printf 'fake archive\n' >"$output"
161
+ ;;
162
+*"/releases/download/"*"/checksums.txt")
163
+ case ${TEST_CHECKSUM_MODE:-missing} in
164
+ missing) exit 22 ;;
165
+ valid) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'a' >"$output" ;;
166
+ mismatch) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'b' >"$output" ;;
167
+ malformed) printf 'not-a-hash %s\n' "$TEST_ARCHIVE_NAME" >"$output" ;;
168
+ esac
169
+ ;;
170
*)
175
- echo "unexpected curl URL: $url" >&2
176
- exit 1
177
- ;;
171
+ printf 'unexpected curl URL: %s\n' "$url" >&2
172
+ exit 94
173
+ ;;
174
esac
175
EOF
180
-chmod +x "$bin_dir/curl"
176
+ chmod +x "$fake_bin/curl"
177
182
-cat > "$bin_dir/unzip" <<'EOF'
183
-#!/usr/bin/env bash
184
-set -euo pipefail
185
-
186
-dest=""
187
-while [[ $# -gt 0 ]]; do
188
- case "$1" in
189
- -d)
190
- dest="$2"
191
- shift 2
192
- ;;
193
- -*)
194
- # install.sh currently calls unzip with -oqd <dest>, so support the
195
- # compact flag by treating the next argument as the destination.
196
- if [[ "$1" == *d ]]; then
197
- dest="$2"
198
- shift 2
199
- else
200
- shift
201
- fi
202
- ;;
203
- *)
204
- shift
205
- ;;
206
- esac
207
-done
208
-
209
-if [[ -z "$dest" ]]; then
210
- echo 'fake unzip did not receive a destination' >&2
211
- exit 1
212
-fi
178
+ cat >"$fake_bin/sha256sum" <<'EOF'
179
+#!/bin/sh
180
+printf '%s %s\n' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' "$1"
181
+EOF
182
+ chmod +x "$fake_bin/sha256sum"
183
214
-mkdir -p "$dest"
215
-cat > "$dest/composio" <<'BIN'
184
+ cat >"$fake_bin/unzip" <<'EOF'
185
#!/usr/bin/env bash
186
set -euo pipefail
218
-
219
-printf '%s\n' "$*" >> "$TEST_COMPOSIO_LOG"
220
-
221
-case "${1:-}" in
222
-install)
223
- if [[ -n "${TEST_INSTALL_STDERR:-}" ]]; then
224
- printf '%s\n' "$TEST_INSTALL_STDERR" >&2
225
- fi
226
- exit 0
187
+dest=
188
+while (($# > 0)); do
189
+ case $1 in
190
+ -d)
191
+ dest=$2
192
+ shift 2
193
;;
228
-setup)
229
- if [[ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" != 'installer' ]]; then
230
- echo 'Expected automatic plugin setup telemetry origin to be installer.' >&2
231
- exit 97
232
- fi
233
- exit "${TEST_SETUP_EXIT:-0}"
194
+ -*d)
195
+ dest=$2
196
+ shift 2
197
;;
198
+ *) shift ;;
199
+ esac
200
+done
201
+[[ -n $dest ]] || exit 95
202
+bundle="$dest/composio-$TEST_TARGET"
203
+mkdir -p "$bundle/services" "$bundle/local-tools-binaries"
204
+cat >"$bundle/composio" <<'BIN'
205
+#!/bin/sh
206
+printf '%s|%s|%s|%s\n' "${COMPOSIO_INSTALL_HELP:-}" "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" "${COMPOSIO_BIN_DIR:-}" "$*" >>"$TEST_COMPOSIO_LOG"
207
+case ${1:-} in
208
--version|version)
236
- if [[ -n "${TEST_VERSION_STDERR:-}" ]]; then
237
- printf '%s\n' "$TEST_VERSION_STDERR" >&2
209
+ printf '%s\n' 'composio fake 98.0.0'
210
+ exit "${TEST_VERSION_EXIT:-0}"
211
+ ;;
212
+setup)
213
+ [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 96
214
+ exit "${TEST_SETUP_EXIT:-0}"
215
+ ;;
216
+login)
217
+ [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 97
218
+ exit 0
219
+ ;;
220
+install)
221
+ if [ "${2:-}" = --help ]; then
222
+ if [ "${TEST_SHELL_CAPABILITY:-supported}" = supported ]; then
223
+ printf '%s\n' 'Usage: composio install [--shell zsh|bash|fish]'
224
+ else
225
+ printf '%s\n' 'Usage: composio install'
226
fi
239
- echo 'composio fake 98.0.0'
240
- exit "${TEST_VERSION_EXIT:-0}"
241
- ;;
242
-*)
227
exit 0
244
- ;;
228
+ fi
229
+ if [ "${2:-}" = --shell ]; then
230
+ exit "${TEST_INSTALL_EXIT:-0}"
231
+ fi
232
+ exit 98
233
+ ;;
234
+*) exit 0 ;;
235
esac
236
BIN
247
-chmod +x "$dest/composio"
248
-EOF
249
-chmod +x "$bin_dir/unzip"
250
-
251
-cat > "$bin_dir/git" <<'EOF'
252
-#!/usr/bin/env bash
253
-set -euo pipefail
254
-printf 'git should not be used for install.sh release resolution; fake tag was %s\n' "$TEST_TAG_WITHOUT_RELEASE" >> "$TEST_GIT_LOG"
255
-echo "0000000000000000000000000000000000000000 refs/tags/$TEST_TAG_WITHOUT_RELEASE"
256
-exit 0
237
+ chmod +x "$bundle/composio"
238
+ printf '%s\n' 'support' >"$bundle/run-bun.mjs"
239
+ printf '%s\n' 'service' >"$bundle/services/example.txt"
240
EOF
258
-chmod +x "$bin_dir/git"
259
-
260
-export TEST_CURL_LOG="$curl_log"
261
-export TEST_GIT_LOG="$git_log"
262
-export TEST_COMPOSIO_LOG="$composio_log"
263
-export TEST_API_BASE="$api_base"
264
-export TEST_ARCHIVE_NAME="$archive_name"
265
-export TEST_ARCHIVE_URL="$archive_url"
266
-export TEST_VALID_TAG="$valid_tag"
267
-export TEST_MISSING_ASSET_TAG="$missing_asset_tag"
268
-export TEST_TAG_WITHOUT_RELEASE="$tag_without_release"
269
-
270
-run_installer() {
271
- local test_home="$1"
272
- local test_install_dir="$2"
273
- shift 2
241
+ chmod +x "$fake_bin/unzip"
242
+
243
+ export TEST_REPO_ROOT="$repo_root"
244
+ export TEST_TARGET="$target"
245
+ export TEST_ARCHIVE_NAME="$archive_name"
246
+ export TEST_STABLE_TAG="$stable_tag"
247
+ export TEST_MISSING_ASSET_TAG="$missing_asset_tag"
248
+ export TEST_ARCHIVE_URL="$archive_url"
249
+ export TEST_API_BASE="$api_base"
250
+ export TEST_SCRIPT_URL="$script_url"
251
+ export TEST_CURL_LOG="$curl_log"
252
+ export TEST_COMPOSIO_LOG="$composio_log"
253
+
254
+ reset_case() {
255
+ unset CASE_GITHUB_URL CASE_API_BASE CASE_INSTALL_VERSION CASE_PLUGINS CASE_QUIET CASE_DEBUG CASE_HELP
256
+ unset CASE_ALLOW_HTTP_HOST CASE_CHECKSUM_MODE CASE_API_ASSET_URL CASE_BASE_MODE CASE_REDIRECT_DOWNGRADE
257
+ unset CASE_SHELL_CAPABILITY CASE_INSTALL_EXIT CASE_SETUP_EXIT CASE_VERSION_EXIT CASE_PATH_PREFIX
258
+ : >"$curl_log"
259
+ : >"$composio_log"
260
+ }
261
262
+ run_installer() {
263
+ local home=$1
264
+ local install_dir=$2
265
+ local bin_dir=$3
266
+ shift 3
267
+ mkdir -p "$home" "$install_dir" "$bin_dir"
268
env \
276
- PATH="$bin_dir:$PATH" \
277
- HOME="$test_home" \
278
- SHELL="/bin/bash" \
279
- COMPOSIO_INSTALL_DIR="$test_install_dir" \
280
- COMPOSIO_INSTALL_PLUGINS="${COMPOSIO_INSTALL_PLUGINS:-1}" \
281
- COMPOSIO_GITHUB_URL='https://github.example.test' \
282
- COMPOSIO_GITHUB_API_BASE_URL="$api_base" \
283
- COMPOSIO_GITHUB_OWNER='FakeOwner' \
284
- COMPOSIO_GITHUB_REPO='fake-repo' \
285
- TEST_INSTALL_STDERR="${TEST_INSTALL_STDERR:-}" \
286
- TEST_SETUP_EXIT="${TEST_SETUP_EXIT:-0}" \
287
- TEST_VERSION_EXIT="${TEST_VERSION_EXIT:-0}" \
288
- TEST_VERSION_STDERR="${TEST_VERSION_STDERR:-}" \
289
- bash "$repo_root/install.sh" "$@"
290
-}
291
-
292
-install_guidance='shell integration guidance from composio install'
293
-output=$(TEST_INSTALL_STDERR="$install_guidance" run_installer "$home_dir" "$install_dir" 2>&1)
294
-
295
-printf '%s\n' "$output"
296
-
297
-if [[ -s "$git_log" ]]; then
298
- echo 'Expected install.sh not to call git while resolving latest release.' >&2
299
- cat "$git_log" >&2
300
- exit 1
301
-fi
302
-
303
-if [[ ! -f "$install_dir/release-tag.txt" ]]; then
304
- echo 'Expected install.sh to write release-tag.txt.' >&2
305
- exit 1
306
-fi
307
-
308
-installed_tag=$(<"$install_dir/release-tag.txt")
309
-if [[ "$installed_tag" != "$valid_tag" ]]; then
310
- echo "Expected fallback to $valid_tag, got $installed_tag" >&2
311
- exit 1
312
-fi
313
-
314
-if ! grep -q "Found latest version: $valid_tag" <<<"$output"; then
315
- echo "Expected installer output to select $valid_tag." >&2
316
- exit 1
317
-fi
318
-
319
-if grep -q "Installing Composio CLI $missing_asset_tag" <<<"$output"; then
320
- echo "Installer attempted to install release without $archive_name." >&2
321
- exit 1
322
-fi
323
-
324
-if grep -q "$tag_without_release" "$curl_log"; then
325
- echo 'Installer attempted to use a tag that was not present in releases.' >&2
326
- exit 1
327
-fi
328
-
329
-if ! grep -qxF -- '--version' "$composio_log"; then
330
- echo 'Expected installer to probe the downloaded CLI with --version.' >&2
331
- cat "$composio_log" >&2
332
- exit 1
333
-fi
334
-
335
-if ! grep -qxF 'install' "$composio_log"; then
336
- echo 'Expected installer to delegate shell integration to composio install.' >&2
337
- cat "$composio_log" >&2
338
- exit 1
339
-fi
340
-
341
-if ! grep -qF "$install_guidance" <<<"$output"; then
342
- echo 'Expected composio install stderr guidance to remain visible.' >&2
343
- printf '%s\n' "$output" >&2
344
- exit 1
345
-fi
346
-
347
-expected_setup='setup --target auto --yes --if-present'
348
-if ! grep -qxF "$expected_setup" "$composio_log"; then
349
- echo "Expected installer to invoke: composio $expected_setup" >&2
350
- cat "$composio_log" >&2
351
- exit 1
352
-fi
353
-
354
-failed_probe_home="$tmpdir/home-failed-probe"
355
-failed_probe_install="$tmpdir/install-failed-probe"
356
-mkdir -p "$failed_probe_home" "$failed_probe_install"
357
-: > "$failed_probe_home/.bashrc"
358
-: > "$composio_log"
359
-loader_error='loader error from an unusable composio binary'
360
-failed_probe_output=$(
361
- TEST_VERSION_EXIT=126 \
362
- TEST_VERSION_STDERR="$loader_error" \
363
- run_installer "$failed_probe_home" "$failed_probe_install" --no-plugins 2>&1
364
-)
365
-if grep -qF "$loader_error" <<<"$failed_probe_output"; then
366
- echo 'Expected the failed binary probe to suppress loader errors.' >&2
367
- printf '%s\n' "$failed_probe_output" >&2
368
- exit 1
369
-fi
370
-if grep -qxF 'install' "$composio_log"; then
371
- echo 'Expected a failed binary probe to skip composio install.' >&2
372
- cat "$composio_log" >&2
373
- exit 1
374
-fi
375
-if ! grep -qF 'Setting up shell integration...' <<<"$failed_probe_output"; then
376
- echo 'Expected a failed binary probe to select inline shell integration.' >&2
377
- printf '%s\n' "$failed_probe_output" >&2
378
- exit 1
379
-fi
380
-if ! grep -qxF '# Composio CLI' "$failed_probe_home/.bashrc"; then
381
- echo 'Expected inline shell integration to update .bashrc.' >&2
382
- cat "$failed_probe_home/.bashrc" >&2
383
- exit 1
384
-fi
269
+ PATH="${CASE_PATH_PREFIX:-}$fake_bin:$PATH" \
270
+ HOME="$home" \
271
+ SHELL=/bin/bash \
272
+ COMPOSIO_INSTALL_DIR="$install_dir" \
273
+ COMPOSIO_BIN_DIR="$bin_dir" \
274
+ COMPOSIO_INSTALL_VERSION="${CASE_INSTALL_VERSION:-}" \
275
+ COMPOSIO_INSTALL_PLUGINS="${CASE_PLUGINS:-0}" \
276
+ COMPOSIO_QUIET="${CASE_QUIET:-0}" \
277
+ COMPOSIO_DEBUG="${CASE_DEBUG:-0}" \
278
+ COMPOSIO_INSTALL_HELP="${CASE_HELP:-1}" \
279
+ COMPOSIO_INSTALL_ALLOW_HTTP_HOST="${CASE_ALLOW_HTTP_HOST:-}" \
280
+ COMPOSIO_GITHUB_URL="${CASE_GITHUB_URL:-$github_url}" \
281
+ COMPOSIO_GITHUB_API_BASE_URL="${CASE_API_BASE:-$api_base}" \
282
+ COMPOSIO_GITHUB_OWNER=FakeOwner \
283
+ COMPOSIO_GITHUB_REPO=fake-repo \
284
+ TEST_CHECKSUM_MODE="${CASE_CHECKSUM_MODE:-missing}" \
285
+ TEST_API_ASSET_URL="${CASE_API_ASSET_URL:-}" \
286
+ TEST_REDIRECT_DOWNGRADE="${CASE_REDIRECT_DOWNGRADE:-0}" \
287
+ TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \
288
+ TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \
289
+ TEST_SETUP_EXIT="${CASE_SETUP_EXIT:-0}" \
290
+ TEST_VERSION_EXIT="${CASE_VERSION_EXIT:-0}" \
291
+ "$interpreter" "$repo_root/install.sh" "$@"
292
+ }
293
386
-no_plugins_home="$tmpdir/home-no-plugins"
387
-no_plugins_install="$tmpdir/install-no-plugins"
388
-mkdir -p "$no_plugins_home" "$no_plugins_install"
389
-: > "$composio_log"
390
-run_installer "$no_plugins_home" "$no_plugins_install" --no-plugins >/dev/null 2>&1
391
-if grep -q '^setup ' "$composio_log"; then
392
- echo 'Expected --no-plugins to skip agent plugin setup.' >&2
393
- cat "$composio_log" >&2
394
- exit 1
395
-fi
294
+ run_variant() {
295
+ local shell_name=$1
296
+ local home=$2
297
+ local install_dir=$3
298
+ local bin_dir=$4
299
+ shift 4
300
+ mkdir -p "$home" "$install_dir" "$bin_dir"
301
+ env \
302
+ PATH="$fake_bin:$PATH" \
303
+ HOME="$home" \
304
+ SHELL="/bin/$shell_name" \
305
+ COMPOSIO_INSTALL_DIR="$install_dir" \
306
+ COMPOSIO_BIN_DIR="$bin_dir" \
307
+ COMPOSIO_INSTALL_SCRIPT_URL="$script_url" \
308
+ COMPOSIO_INSTALL_PLUGINS=0 \
309
+ COMPOSIO_GITHUB_URL="$github_url" \
310
+ COMPOSIO_GITHUB_API_BASE_URL="$api_base" \
311
+ COMPOSIO_GITHUB_OWNER=FakeOwner \
312
+ COMPOSIO_GITHUB_REPO=fake-repo \
313
+ TEST_BASE_MODE="${CASE_BASE_MODE:-ok}" \
314
+ TEST_CHECKSUM_MODE=missing \
315
+ TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \
316
+ TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \
317
+ "$interpreter" "$repo_root/install/$shell_name.sh" "$@"
318
+ }
319
397
-env_opt_out_home="$tmpdir/home-env-opt-out"
398
-env_opt_out_install="$tmpdir/install-env-opt-out"
399
-mkdir -p "$env_opt_out_home" "$env_opt_out_install"
400
-: > "$composio_log"
401
-COMPOSIO_INSTALL_PLUGINS=0 run_installer "$env_opt_out_home" "$env_opt_out_install" >/dev/null 2>&1
402
-if grep -q '^setup ' "$composio_log"; then
403
- echo 'Expected COMPOSIO_INSTALL_PLUGINS=0 to skip agent plugin setup.' >&2
404
- cat "$composio_log" >&2
405
- exit 1
406
-fi
320
+ reset_case
321
+ home="$case_root/default-home"
322
+ install_dir="$case_root/default-install"
323
+ bin_dir="$case_root/default-bin"
324
+ output=$(run_installer "$home" "$install_dir" "$bin_dir" 2>&1)
325
+ [[ $(<"$install_dir/release-tag.txt") == "$stable_tag" ]] || fail "$interpreter_name latest stable resolution"
326
+ [[ -x "$install_dir/composio" && -f "$install_dir/run-bun.mjs" ]] || fail "$interpreter_name bundle installation"
327
+ [[ -L "$bin_dir/composio" ]] || fail "$interpreter_name entry-point symlink"
328
+ expected_install_dir=$(cd "$install_dir" && pwd -P)
329
+ [[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"
330
+ assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"
331
+ assert_contains "$output" 'Required next step for bash:' "$interpreter_name required PATH guidance"
332
+ [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name default flow must not write rc files"
333
+ [[ $(wc -l <"$composio_log") -eq 1 ]] || fail "$interpreter_name default flow invoked extra CLI commands"
334
+ grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"
335
+ [[ ! -s "$case_root/git.log" ]] || fail "$interpreter_name must not use git"
336
+
337
+ reset_case
338
+ equal_dir="$case_root/equal-layout"
339
+ run_installer "$case_root/equal-home" "$equal_dir" "$equal_dir" "$beta_tag" >/dev/null 2>&1
340
+ [[ -x "$equal_dir/composio" && ! -L "$equal_dir/composio" ]] || fail "$interpreter_name equal-dir layout"
341
+ [[ $(<"$equal_dir/release-tag.txt") == "$beta_tag" ]] || fail "$interpreter_name explicit beta tag"
342
+
343
+ reset_case
344
+ legacy_home="$case_root/legacy-home"
345
+ mkdir -p "$legacy_home"
346
+ printf '%s\n' 'export COMPOSIO_INSTALL_DIR="$HOME/.composio"' >"$legacy_home/.bashrc"
347
+ run_installer "$legacy_home" "$case_root/legacy-install" "$case_root/legacy-bin" "$stable_tag" >/dev/null 2>&1
348
+ [[ -L "$case_root/legacy-bin/composio" ]] || fail "$interpreter_name legacy migration symlink"
349
+ grep -Fq 'COMPOSIO_INSTALL_DIR' "$legacy_home/.bashrc" || fail "$interpreter_name must preserve legacy rc content"
350
+
351
+ reset_case
352
+ replacement_bin="$case_root/replacement-bin"
353
+ mkdir -p "$replacement_bin"
354
+ printf '%s\n' old >"$replacement_bin/composio"
355
+ run_installer "$case_root/replacement-home" "$case_root/replacement-install" "$replacement_bin" "$stable_tag" >/dev/null 2>&1
356
+ [[ -L "$replacement_bin/composio" ]] || fail "$interpreter_name regular entry point replacement"
357
+
358
+ reset_case
359
+ directory_bin="$case_root/directory-bin"
360
+ mkdir -p "$directory_bin/composio"
361
+ if directory_output=$(run_installer "$case_root/directory-home" "$case_root/directory-install" "$directory_bin" "$stable_tag" 2>&1); then
362
+ fail "$interpreter_name directory entry point must fail"
363
+ fi
364
+ assert_contains "$directory_output" 'because it is a directory' "$interpreter_name directory error"
365
+
366
+ reset_case
367
+ CASE_INSTALL_VERSION=97.0.0
368
+ precedence_install="$case_root/precedence-install"
369
+ run_installer "$case_root/precedence-home" "$precedence_install" "$case_root/precedence-bin" 96.0.0 >/dev/null 2>&1
370
+ [[ $(<"$precedence_install/release-tag.txt") == '@composio/cli@96.0.0' ]] || fail "$interpreter_name version precedence"
371
+
372
+ reset_case
373
+ CASE_INSTALL_VERSION=95.0.0-beta.7
374
+ env_version_install="$case_root/env-version-install"
375
+ run_installer "$case_root/env-version-home" "$env_version_install" "$case_root/env-version-bin" >/dev/null 2>&1
376
+ [[ $(<"$env_version_install/release-tag.txt") == '@composio/cli@95.0.0-beta.7' ]] || fail "$interpreter_name env beta normalization"
377
+
378
+ reset_case
379
+ 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
380
+ fail "$interpreter_name malformed prerelease must fail"
381
+ fi
382
+ assert_contains "$malformed_output" 'Invalid Composio CLI version' "$interpreter_name malformed version"
383
+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name malformed version must fail before network"
384
+
385
+ reset_case
386
+ CASE_CHECKSUM_MODE=valid
387
+ run_installer "$case_root/checksum-home" "$case_root/checksum-install" "$case_root/checksum-bin" "$stable_tag" >/dev/null 2>&1
388
+
389
+ for checksum_mode in mismatch malformed; do
390
+ reset_case
391
+ CASE_CHECKSUM_MODE=$checksum_mode
392
+ 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
393
+ fail "$interpreter_name $checksum_mode checksum must fail"
394
+ fi
395
+ grep -qi 'checksum' <<<"$checksum_output" || fail "$interpreter_name $checksum_mode checksum error"
396
+ done
397
+
398
+ reset_case
399
+ CASE_PLUGINS=1
400
+ run_installer "$case_root/plugins-home" "$case_root/plugins-install" "$case_root/plugins-bin" "$stable_tag" >/dev/null 2>&1
401
+ grep -Eq '\|installer\|[^|]*\|setup --target auto --yes --if-present$' "$composio_log" || fail "$interpreter_name plugin opt-in"
402
+
403
+ reset_case
404
+ CASE_QUIET=1
405
+ quiet_output=$(run_installer "$case_root/quiet-home" "$case_root/quiet-install" "$case_root/quiet-bin" "$stable_tag" 2>&1)
406
+ assert_not_contains "$quiet_output" 'Installing Composio CLI' "$interpreter_name quiet output"
407
+
408
+ reset_case
409
+ CASE_DEBUG=1
410
+ debug_output=$(run_installer "$case_root/debug-home" "$case_root/debug-install" "$case_root/debug-bin" "$stable_tag" 2>&1)
411
+ assert_contains "$debug_output" '+ curl GET' "$interpreter_name debug traces"
412
+
413
+ reset_case
414
+ CASE_HELP=0
415
+ help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)
416
+ assert_not_contains "$help_suppressed" 'next step' "$interpreter_name help suppression"
417
+
418
+ reset_case
419
+ CASE_GITHUB_URL='http://127.0.0.1:8929'
420
+ CASE_API_BASE='http://127.0.0.1:8929/api'
421
+ run_installer "$case_root/loopback-home" "$case_root/loopback-install" "$case_root/loopback-bin" "$stable_tag" >/dev/null 2>&1
422
+ grep -Fq -- '--proto =http,https --proto-redir =https' "$curl_log" || fail "$interpreter_name loopback protocol flags"
423
+
424
+ for unsafe_url in 'http://evil.example' 'http://user@127.0.0.1:8929' 'http://127.0.0.1.evil.example'; do
425
+ reset_case
426
+ CASE_GITHUB_URL=$unsafe_url
427
+ 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
428
+ fail "$interpreter_name unsafe configured URL accepted: $unsafe_url"
429
+ fi
430
+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name unsafe configured URL reached curl"
431
+ done
432
+
433
+ reset_case
434
+ CASE_GITHUB_URL='http://host.docker.internal:8080'
435
+ CASE_API_BASE='http://host.docker.internal:8080/api'
436
+ 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
437
+ fail "$interpreter_name host.docker.internal must require opt-in"
438
+ fi
439
+ CASE_ALLOW_HTTP_HOST=host.docker.internal
440
+ run_installer "$case_root/docker-home" "$case_root/docker-install" "$case_root/docker-bin" "$stable_tag" >/dev/null 2>&1
441
+
442
+ reset_case
443
+ CASE_API_ASSET_URL="http://evil.example/$archive_name"
444
+ if api_unsafe_output=$(run_installer "$case_root/api-unsafe-home" "$case_root/api-unsafe-install" "$case_root/api-unsafe-bin" 2>&1); then
445
+ fail "$interpreter_name unsafe API asset URL accepted"
446
+ fi
447
+ assert_contains "$api_unsafe_output" 'unsafe archive URL' "$interpreter_name unsafe API URL"
448
+
449
+ reset_case
450
+ CASE_REDIRECT_DOWNGRADE=1
451
+ if run_installer "$case_root/downgrade-home" "$case_root/downgrade-install" "$case_root/downgrade-bin" "$stable_tag" >/dev/null 2>&1; then
452
+ fail "$interpreter_name redirect downgrade simulation must fail"
453
+ fi
454
+ [[ ! -e "$case_root/downgrade-bin/composio" ]] || fail "$interpreter_name failed download must not install"
455
+
456
+ for shell_name in zsh bash fish; do
457
+ reset_case
458
+ variant_home="$case_root/variant-$shell_name-home"
459
+ variant_install="$case_root/variant-$shell_name-install"
460
+ variant_bin="$case_root/variant-$shell_name-bin"
461
+ run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins >/dev/null 2>&1
462
+ grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||
463
+ fail "$interpreter_name $shell_name variant delegation"
464
+ grep -Eq '^0\|\|[^|]+\|--version$' "$composio_log" || fail "$interpreter_name $shell_name nested help suppression"
465
+ done
466
+
467
+ reset_case
468
+ CASE_SHELL_CAPABILITY=unsupported
469
+ fallback_home="$case_root/fallback-home"
470
+ run_variant zsh "$fallback_home" "$case_root/fallback-install" "$case_root/fallback-bin" "$stable_tag" >/dev/null 2>&1
471
+ grep -Fqx '# Composio CLI' "$fallback_home/.zshrc" || fail "$interpreter_name unsupported CLI fallback"
472
+
473
+ reset_case
474
+ CASE_INSTALL_EXIT=23
475
+ failed_install_home="$case_root/failed-install-home"
476
+ run_variant zsh "$failed_install_home" "$case_root/failed-install-dir" "$case_root/failed-install-bin" "$stable_tag" >/dev/null 2>&1
477
+ grep -Fqx '# Composio CLI' "$failed_install_home/.zshrc" || fail "$interpreter_name failed --shell fallback"
478
+
479
+ reset_case
480
+ CASE_SHELL_CAPABILITY=unsupported
481
+ bash_fallback_home="$case_root/bash-fallback-home"
482
+ mkdir -p "$bash_fallback_home"
483
+ : >"$bash_fallback_home/.bash_profile"
484
+ run_variant bash "$bash_fallback_home" "$case_root/bash-fallback-install" "$case_root/bash-fallback-bin" "$stable_tag" >/dev/null 2>&1
485
+ grep -Fqx '# Composio CLI' "$bash_fallback_home/.bashrc" || fail "$interpreter_name bash fallback bashrc"
486
+ grep -Fqx '# Composio CLI' "$bash_fallback_home/.bash_profile" || fail "$interpreter_name bash fallback login override"
487
+
488
+ reset_case
489
+ CASE_SHELL_CAPABILITY=unsupported
490
+ unsafe_home="$case_root/unsafe-variant-home"
491
+ if run_variant zsh "$unsafe_home" "$case_root/unsafe-variant-install" "$case_root/unsafe;variant-bin" "$stable_tag" >/dev/null 2>&1; then
492
+ fail "$interpreter_name unsafe variant bin dir must fail"
493
+ fi
494
+ [[ ! -e "$unsafe_home/.zshrc" ]] || fail "$interpreter_name unsafe variant must not write rc file"
495
+
496
+ for base_mode in fail empty; do
497
+ reset_case
498
+ CASE_BASE_MODE=$base_mode
499
+ base_failure_home="$case_root/base-$base_mode-home"
500
+ 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
501
+ fail "$interpreter_name $base_mode base installer download must fail"
502
+ fi
503
+ [[ ! -e "$base_failure_home/.zshrc" ]] || fail "$interpreter_name $base_mode download must not write rc"
504
+ done
505
408
-failed_setup_home="$tmpdir/home-failed-setup"
409
-failed_setup_install="$tmpdir/install-failed-setup"
410
-mkdir -p "$failed_setup_home" "$failed_setup_install"
411
-: > "$composio_log"
412
-if failed_output=$(TEST_SETUP_EXIT=23 run_installer "$failed_setup_home" "$failed_setup_install" 2>&1); then
413
- echo 'Expected installer to fail when detected agent plugin setup fails.' >&2
414
- exit 1
415
-fi
416
-if ! grep -q 'Composio CLI was installed, but agent plugin setup failed' <<<"$failed_output"; then
417
- echo 'Expected installer to explain how to retry failed plugin setup.' >&2
418
- printf '%s\n' "$failed_output" >&2
419
- exit 1
420
-fi
506
+ printf 'install scripts passed under %s\n' "$interpreter_name"
507
+done
508
422
-printf 'install.sh release fallback, shell integration, and plugin setup tests passed\n'
509
+printf 'install.sh release resolution, layout, security, and shell-variant tests passed\n'
test/release-workflow.test.ts
+10
-1
@@ -697,9 +697,18 @@ if (!installHealthCheck.includes("| sed -n '1p'")) {
697
'cli.install-health-check.yml must convert no matching release into empty output'
698
);
699
}
700
-if (!installHealthCheck.includes('bash -s -- "${{ steps.resolve.outputs.tag }}"')) {
700
+if (!installHealthCheck.includes('sh -s -- "${{ steps.resolve.outputs.tag }}"')) {
701
throw new Error('cli.install-health-check.yml must install the resolved tag via the pinned path');
702
}
703
+if (!installHealthCheck.includes('echo "$HOME/.local/bin" >> "$GITHUB_PATH"')) {
704
+ throw new Error('cli.install-health-check.yml must expose the installer entry-point directory');
705
+}
706
+if (!installHealthCheck.includes('test -L "$HOME/.local/bin/composio"')) {
707
+ throw new Error('cli.install-health-check.yml must verify the installer entry-point symlink');
708
+}
709
+if (installHealthCheck.includes('rm -rf "$HOME/.composio"')) {
710
+ throw new Error('cli.install-health-check.yml must preserve CLI user state between install legs');
711
+}
712
713
const fakeBin = mkdtempSync(join(tmpdir(), 'composio-release-test-'));
714
try {
ts/packages/cli/test/src/analytics.events.test.ts
+13
-3
@@ -481,13 +481,23 @@ describe('CLI analytics journey taxonomy', () => {
481
});
482
});
483
484
- it('marks the install.sh shell-integration run as installer-origin', () => {
484
+ it('keeps the base installer install-only and marks shell-variant delegation as installer-origin', () => {
485
const installScript = readFileSync(
486
new URL('../../../../../install.sh', import.meta.url),
487
'utf8'
488
);
489
- const installLine = installScript.split('\n').find(line => line.includes('"$exe" install'));
489
+ expect(installScript).not.toContain('"$exe" install');
490
491
- expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
491
+ for (const shell of ['zsh', 'bash', 'fish']) {
492
+ const variantScript = readFileSync(
493
+ new URL(`../../../../../install/${shell}.sh`, import.meta.url),
494
+ 'utf8'
495
+ );
496
+ const installLine = variantScript
497
+ .split('\n')
498
+ .find(line => line.includes('"$variant_exe" install --shell'));
499
+
500
+ expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');
501
+ }
502
});
503
});