Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(cli): add install-only POSIX installer
jkomynod99985717081
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex eb1a1deb2..225cc35ae 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -2,3 +2,5 @@ docs/ @shawnesquivel @Sushmithamalleshts/packages/cli/ @CryogenicPlanetts/ @jkomynopython/ @jkomyno+/install.sh @CryogenicPlanet+/install/ @CryogenicPlanetdiff --git a/.github/workflows/cli.install-health-check.yml b/.github/workflows/cli.install-health-check.ymlindex 830c933a1..24f8d77e3 100644--- a/.github/workflows/cli.install-health-check.yml+++ b/.github/workflows/cli.install-health-check.yml@@ -35,19 +35,21 @@ jobs:echo "Latest published release: ${tag}"# Install the PINNED newest tag. This is the path that 404s when a release ships without- # assets. The no-arg `curl | bash` below is asset-aware and silently falls back to the+ # assets. The no-arg `curl | sh` below is asset-aware and silently falls back to the# previous good release, so it would stay green even when the newest release is broken —# which is exactly why the previous canary never caught the recurring outage.- name: Install newest stable (pinned — fails on a release with missing assets)run: |set -euo pipefail- curl -fsSL https://composio.dev/install | bash -s -- "${{ steps.resolve.outputs.tag }}"- echo "$HOME/.composio" >> "$GITHUB_PATH"+ curl -fsSL https://composio.dev/install | sh -s -- "${{ steps.resolve.outputs.tag }}"+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"- name: Verify pinned installationrun: |set -euo pipefaills -la "$HOME/.composio" || true+ test -x "$HOME/.composio/composio"+ test -L "$HOME/.local/bin/composio"which composiocomposio --version@@ -56,9 +58,23 @@ jobs:- name: Install via default no-arg flowrun: |set -euo pipefail- rm -rf "$HOME/.composio"- curl -fsSL https://composio.dev/install | bash- "$HOME/.composio/composio" --version+ rm -f \+ "$HOME/.local/bin/composio" \+ "$HOME/.composio/composio" \+ "$HOME/.composio/release-tag.txt" \+ "$HOME/.composio/run-helpers-runtime.mjs" \+ "$HOME/.composio/run-subagent-shared.mjs" \+ "$HOME/.composio/run-subagent-acp.mjs" \+ "$HOME/.composio/run-subagent-legacy.mjs" \+ "$HOME/.composio/run-subagent-output-mcp.mjs"+ rm -rf \+ "$HOME/.composio/services" \+ "$HOME/.composio/acp-adapters" \+ "$HOME/.composio/local-tools-binaries"+ curl -fsSL https://composio.dev/install | sh+ test -x "$HOME/.composio/composio"+ test -L "$HOME/.local/bin/composio"+ "$HOME/.local/bin/composio" --version- name: Send Slack Notification (Failure)if: failure()diff --git a/.github/workflows/cli.test-installation.yml b/.github/workflows/cli.test-installation.ymlindex 1b6c24cff..2dffd63ab 100644--- a/.github/workflows/cli.test-installation.yml+++ b/.github/workflows/cli.test-installation.yml@@ -33,6 +33,9 @@ jobs:- name: Test release resolution fallbackrun: bash test/install-sh-release-resolution.test.sh+ - name: Lint POSIX install scripts+ run: shellcheck -s sh install.sh install/*.sh+test-install-script:name: Test Install Scriptneeds: install-script-unit-tests@@ -160,23 +163,22 @@ jobs:echo "Testing installation with auto-detected latest CLI version..."# Test the install script without version (it will auto-detect latest CLI release)- bash install.sh+ sh install.sh# Verify installation- source ~/.bashrc 2>/dev/null || source ~/.zshrc 2>/dev/null || true- export PATH="$HOME/.composio:$PATH"+ export PATH="$HOME/.local/bin:$PATH"- # Check if binary exists- if [[ -f "$HOME/.composio/composio" ]]; then- echo "✅ Binary installed successfully"- ls -la "$HOME/.composio/composio"+ # Check the bundle and entry point+ if [[ -x "$HOME/.composio/composio" && -L "$HOME/.local/bin/composio" ]]; then+ echo "✅ Bundle and entry point installed successfully"+ ls -la "$HOME/.composio/composio" "$HOME/.local/bin/composio"else- echo "❌ Binary not found"+ echo "❌ Bundle or entry point not found"exit 1fi# Test binary execution- if "$HOME/.composio/composio" --version; then+ if "$HOME/.local/bin/composio" --version; thenecho "✅ Binary executes successfully"elseecho "❌ Binary execution failed"@@ -192,23 +194,22 @@ jobs:echo "Testing installation with version: ${RELEASE_TAG}"# Test the install script with specific version- bash install.sh "${RELEASE_TAG}"+ sh install.sh "${RELEASE_TAG}"# Verify installation- source ~/.bashrc 2>/dev/null || source ~/.zshrc 2>/dev/null || true- export PATH="$HOME/.composio:$PATH"+ export PATH="$HOME/.local/bin:$PATH"- # Check if binary exists- if [[ -f "$HOME/.composio/composio" ]]; then- echo "✅ Binary installed successfully"- ls -la "$HOME/.composio/composio"+ # Check the bundle and entry point+ if [[ -x "$HOME/.composio/composio" && -L "$HOME/.local/bin/composio" ]]; then+ echo "✅ Bundle and entry point installed successfully"+ ls -la "$HOME/.composio/composio" "$HOME/.local/bin/composio"else- echo "❌ Binary not found"+ echo "❌ Bundle or entry point not found"exit 1fi# Test binary execution- if "$HOME/.composio/composio" --version; then+ if "$HOME/.local/bin/composio" --version; thenecho "✅ Binary executes successfully"elseecho "❌ Binary execution failed"@@ -220,6 +221,8 @@ jobs:run: |echo "Testing PATH integration with ${{ matrix.shell }}..."+ COMPOSIO_BIN_DIR="$HOME/.local/bin" "$HOME/.composio/composio" install --shell "${{ matrix.shell }}"+# Debug: Check what files exist and their contentsecho "=== DEBUGGING ==="echo "Checking shell config files:"@@ -352,7 +355,7 @@ jobs:exit 1fi- if grep -Fqx 'export PATH="$HOME/.composio:$PATH"' "$config_file"; then+ if grep -Fqx 'export PATH="$HOME/.local/bin:$PATH"' "$config_file"; thenecho "✅ $config_file updated with the installed binary directory"elseecho "❌ $config_file PATH not updated"@@ -377,27 +380,28 @@ jobs:echo "Testing custom install directory..."# Clean up previous installation- rm -rf ~/.composio+ rm -rf ~/.composio /tmp/custom-composio /tmp/custom-composio-bin# Test with custom directory using the same version as the workflowexport COMPOSIO_INSTALL_DIR="/tmp/custom-composio"+ export COMPOSIO_BIN_DIR="/tmp/custom-composio-bin"if [[ "$USE_LATEST" == "true" ]]; then- bash install.sh+ sh install.shelse- bash install.sh "${RELEASE_TAG}"+ sh install.sh "${RELEASE_TAG}"fi# Verify custom installation- if [[ -f "/tmp/custom-composio/composio" ]]; then+ if [[ -x "/tmp/custom-composio/composio" && -L "/tmp/custom-composio-bin/composio" ]]; thenecho "✅ Custom directory installation successful"- ls -la "/tmp/custom-composio/composio"+ ls -la "/tmp/custom-composio/composio" "/tmp/custom-composio-bin/composio"elseecho "❌ Custom directory installation failed"exit 1fi# Test execution- if "/tmp/custom-composio/composio" --version; then+ if "/tmp/custom-composio-bin/composio" --version; thenecho "✅ Custom installation executes successfully"elseecho "❌ Custom installation execution failed"@@ -409,11 +413,12 @@ jobs:echo "Testing uninstallation..."# Remove binary- rm -rf ~/.composio /tmp/custom-composio+ rm -f ~/.local/bin/composio /tmp/custom-composio-bin/composio+ rm -rf ~/.composio /tmp/custom-composio /tmp/custom-composio-bin# Check if binary is gone- if [[ ! -f "$HOME/.composio/composio" ]]; then- echo "✅ Binary removed successfully"+ if [[ ! -e "$HOME/.composio/composio" && ! -e "$HOME/.local/bin/composio" ]]; then+ echo "✅ Bundle and entry point removed successfully"elseecho "❌ Binary removal failed"exit 1@@ -425,12 +430,11 @@ jobs:echo "Testing error handling..."# Test with invalid version- if bash install.sh v999.999.999 2>&1 | grep -q "Failed"; then- echo "✅ Error handling works for invalid version"- else- echo "❌ Error handling failed"- # Don't exit 1 here as this is expected to fail+ if sh install.sh v999.999.999; then+ echo "❌ Invalid version unexpectedly succeeded"+ exit 1fi+ echo "✅ Error handling works for invalid versions"test-architecture-detection:name: Test Architecture Detection@@ -530,7 +534,7 @@ jobs:# Create a version of the script that will fail prerequisite checksed 's/command -v curl/command -v nonexistent-tool/' install.sh > test-install.sh- if bash test-install.sh 2>&1 | grep -q "required to install"; then+ if sh test-install.sh 2>&1 | grep -q "required to install"; thenecho "✅ Prerequisites check works"elseecho "❌ Prerequisites check failed"diff --git a/install.sh b/install.shindex d6d4cd7b3..2c0345505 100755--- a/install.sh+++ b/install.sh@@ -1,445 +1,458 @@-#!/usr/bin/env bash-set -euo pipefail+#!/bin/sh+set -eu-COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-"ComposioHQ"}-COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-"composio"}-COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-"https://github.com"}-COMPOSIO_GITHUB_API_BASE_URL=${COMPOSIO_GITHUB_API_BASE_URL:-}-COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-$HOME/.composio}--# --- Input validation -----# Only allow HTTPS URLs for the download source.-if [[ ! "$COMPOSIO_GITHUB_URL" =~ ^https:// ]]; then- echo "error: COMPOSIO_GITHUB_URL must start with https:// (got \"$COMPOSIO_GITHUB_URL\")" >&2+error() {+ printf 'error: %s\n' "$*" >&2exit 1-fi+}-# Owner and repo must be safe identifiers (alphanumeric, hyphens, underscores, dots).-if [[ ! "$COMPOSIO_GITHUB_OWNER" =~ ^[a-zA-Z0-9._-]+$ ]]; then- echo "error: COMPOSIO_GITHUB_OWNER contains invalid characters (got \"$COMPOSIO_GITHUB_OWNER\")" >&2- exit 1-fi-if [[ ! "$COMPOSIO_GITHUB_REPO" =~ ^[a-zA-Z0-9._-]+$ ]]; then- echo "error: COMPOSIO_GITHUB_REPO contains invalid characters (got \"$COMPOSIO_GITHUB_REPO\")" >&2- exit 1-fi+warn() {+ printf 'warning: %s\n' "$*" >&2+}-if [[ -n "$COMPOSIO_GITHUB_API_BASE_URL" && ! "$COMPOSIO_GITHUB_API_BASE_URL" =~ ^https:// ]]; then- echo "error: COMPOSIO_GITHUB_API_BASE_URL must start with https:// (got \"$COMPOSIO_GITHUB_API_BASE_URL\")" >&2- exit 1-fi+is_true() {+ case ${1:-} in+ 1 | true) return 0 ;;+ *) return 1 ;;+ esac+}-github_repo="$COMPOSIO_GITHUB_URL/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"+info() {+ if ! is_true "${COMPOSIO_QUIET:-}"; then+ printf '%s\n' "$*"+ fi+}-if [[ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]]; then- github_api_base="${COMPOSIO_GITHUB_API_BASE_URL%/}"-elif [[ "$COMPOSIO_GITHUB_URL" = "https://github.com" ]]; then- github_api_base="https://api.github.com"-else- github_api_base="${COMPOSIO_GITHUB_URL%/}/api/v3"-fi+debug() {+ if is_true "${COMPOSIO_DEBUG:-}"; then+ printf '+ %s\n' "$*" >&2+ fi+}-github_api_repo="$github_api_base/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"+tildify() {+ case $1 in+ "$HOME"/*) printf '%s/%s\n' '~' "${1#"$HOME"/}" ;;+ *) printf '%s\n' "$1" ;;+ esac+}-# --- Colors (only when interactive) ---+print_usage() {+ printf '%s\n' \+ 'Usage: install.sh [--agent] [--no-plugins] [version-tag]' \+ '' \+ 'Options:' \+ ' --agent Sign up or log in as a Composio agent after installation.' \+ ' --no-plugins Skip agent plugin installation (the default).' \+ ' -h, --help Show this help.' \+ '' \+ 'Version tags may be stable or beta, for example 0.3.1 or @composio/[email protected].'+}-Color_Off='' Red='' Green='' Dim='' Bold_White='' Bold_Green=''+validate_identifier() {+ printf '%s\n' "$2" | grep -Eq '^[A-Za-z0-9._-]+$' ||+ error "$1 contains invalid characters (got \"$2\")"+}-if [[ -t 1 ]]; then- Color_Off='\033[0m'- Red='\033[0;31m'- Green='\033[0;32m'- Dim='\033[0;2m'- Bold_Green='\033[1;32m'- Bold_White='\033[1m'-fi+url_authority() {+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'+}-error() { echo -e "${Red}error${Color_Off}:" "$@" >&2; exit 1; }-warn() { echo -e "${Red}warning${Color_Off}:" "$@" >&2; }-info() { echo -e "${Dim}$*${Color_Off}"; }-info_bold() { echo -e "${Bold_White}$*${Color_Off}"; }-success() { echo -e "${Green}$*${Color_Off}"; }+is_allowed_http_authority() {+ case $1 in+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;+ esac-tildify() {- if [[ $1 = $HOME/* ]]; then- echo "~/${1#$HOME/}"- else- echo "$1"+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then+ case $1 in+ "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;;+ esacfi-}-install_agent=false-install_plugins=true-version_arg=""+ return 1+}-case "${COMPOSIO_INSTALL_PLUGINS:-1}" in-1) ;;-0) install_plugins=false ;;-*) error 'COMPOSIO_INSTALL_PLUGINS must be 1 or 0' ;;-esac+validate_url() {+ validate_url_value=$1+ case $validate_url_value in+ *[![:print:]]* | *[[:space:]]*) return 1 ;;+ esac-while [[ $# -gt 0 ]]; do- case "$1" in- --agent)- install_agent=true- shift- ;;- --no-plugins)- install_plugins=false- shift- ;;- -h|--help)- echo 'Usage: install.sh [--agent] [--no-plugins] [version-tag] (e.g. "@composio/[email protected]")'- echo ' --agent After installing, sign up/log in as a Composio agent.'- echo ' --no-plugins Skip installing plugins for detected agent hosts.'- echo ' Set COMPOSIO_INSTALL_PLUGINS=0 to skip plugin installation in automation.'- exit 0- ;;- --*)- error "Unknown option: $1"- ;;- *)- if [[ -n "$version_arg" ]]; then- error 'Too many arguments. Usage: install.sh [--agent] [--no-plugins] [version-tag] (e.g. "@composio/[email protected]")'- fi- version_arg=$1- shift- ;;+ validate_url_authority=$(url_authority "$validate_url_value")+ [ -n "$validate_url_authority" ] || return 1+ case $validate_url_authority in+ *@*) return 1 ;;esac-done-# --- Platform detection ---+ case $validate_url_value in+ https://*) return 0 ;;+ http://*) is_allowed_http_authority "$validate_url_authority" ;;+ *) return 1 ;;+ esac+}-platform=$(uname -ms)+curl_fetch() {+ curl_fetch_url=$1+ validate_url "$curl_fetch_url" || error "Refusing unsafe URL \"$curl_fetch_url\""+ debug "curl GET $curl_fetch_url"+ case $curl_fetch_url in+ https://*)+ curl --fail --silent --location --proto '=https' --proto-redir '=https' "$curl_fetch_url"+ ;;+ http://*)+ curl --fail --silent --location --proto '=http,https' --proto-redir '=https' "$curl_fetch_url"+ ;;+ esac+}-case $platform in-'MINGW64'* | 'MSYS'* | 'CYGWIN'*)- error 'Windows is not supported. Please use WSL (https://learn.microsoft.com/windows/wsl/install) and run this script inside your WSL distribution.'- ;;-esac+curl_download() {+ curl_download_url=$1+ curl_download_output=$2+ curl_download_quiet=${3:-0}+ validate_url "$curl_download_url" || error "Refusing unsafe URL \"$curl_download_url\""+ debug "curl GET $curl_download_url -> $curl_download_output"-# --- Prerequisites ---+ if [ "$curl_download_quiet" = 1 ] || is_true "${COMPOSIO_QUIET:-}"; then+ curl_download_ui=--silent+ else+ curl_download_ui=--progress-bar+ fi-command -v curl >/dev/null || error 'curl is required to install Composio CLI'-command -v unzip >/dev/null || error 'unzip is required to install Composio CLI'+ case $curl_download_url in+ https://*)+ curl --fail --location "$curl_download_ui" --proto '=https' --proto-redir '=https' \+ --output "$curl_download_output" "$curl_download_url"+ ;;+ http://*)+ curl --fail --location "$curl_download_ui" --proto '=http,https' --proto-redir '=https' \+ --output "$curl_download_output" "$curl_download_url"+ ;;+ esac+}-case $platform in-'Darwin x86_64') target=darwin-x64 ;;-'Darwin arm64') target=darwin-aarch64 ;;-'Linux aarch64' | 'Linux arm64')- target=linux-aarch64 ;;-'Linux x86_64') target=linux-x64 ;;-*) error "Unsupported platform: $platform" ;;-esac+normalize_version() {+ normalize_version_value=$1+ case $normalize_version_value in+ @composio/cli@*) normalize_version_bare=${normalize_version_value#@composio/cli@} ;;+ *) normalize_version_bare=$normalize_version_value ;;+ esac-# Rosetta 2 detection on macOS-if [[ $target = darwin-x64 ]]; then- if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then- target=darwin-aarch64- info "Your shell is running in Rosetta 2. Downloading for $target instead"- fi-fi+ printf '%s\n' "$normalize_version_bare" |+ grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$' ||+ error "Invalid Composio CLI version \"$normalize_version_value\". Expected X.Y.Z or X.Y.Z-beta.N."-archive_name="composio-$target.zip"+ printf '@composio/cli@%s\n' "$normalize_version_bare"+}resolve_latest_cli_release() {- local page release_json release_line-- for page in 1 2 3 4 5; do- release_json=$(curl --fail --silent --location "$github_api_repo/releases?per_page=100&page=$page") || return 1-- release_line=$(printf '%s\n' "$release_json" \- | sed 's/"tag_name"/\+ resolve_page=1+ while [ "$resolve_page" -le 5 ]; do+ resolve_url="$github_api_repo/releases?per_page=100&page=$resolve_page"+ resolve_json=$(curl_fetch "$resolve_url") || return 1+ resolve_release=$(printf '%s\n' "$resolve_json" |+ sed 's/"tag_name"/\"tag_name"/g; s/"browser_download_url"/\-"browser_download_url"/g' \- | awk -v asset_name="$archive_name" '+"browser_download_url"/g' |+ awk -v asset_name="$archive_name" 'BEGIN {tag = ""- stable_cli_release = "^@composio/cli@[0-9]+\\.[0-9]+\\.[0-9]+$"+ stable = "^@composio/cli@[0-9]+\\.[0-9]+\\.[0-9]+$"}/"tag_name":[[:space:]]*"/ {tag = $0sub(/^.*"tag_name":[[:space:]]*"/, "", tag)sub(/".*$/, "", tag)- if (tag !~ stable_cli_release) {- tag = ""- }+ if (tag !~ stable) tag = ""}tag != "" && /"browser_download_url":[[:space:]]*"/ && index($0, "/" asset_name "\"") > 0 {url = $0sub(/^.*"browser_download_url":[[:space:]]*"/, "", url)sub(/".*$/, "", url)- print tag "\t" url+ print tag+ print urlexit}')- if [[ -n "$release_line" ]]; then- printf '%s\n' "$release_line"+ if [ -n "$resolve_release" ]; then+ printf '%s\n' "$resolve_release"return 0fi- if ! printf '%s\n' "$release_json" | grep -q '"tag_name"'; then- break- fi+ printf '%s\n' "$resolve_json" | grep -q '"tag_name"' || break+ resolve_page=$((resolve_page + 1))donereturn 1}-# --- Version resolution ---+detect_target() {+ platform=$(uname -ms)+ case $platform in+ 'MINGW64'* | 'MSYS'* | 'CYGWIN'*)+ error 'Windows is not supported. Use WSL (https://learn.microsoft.com/windows/wsl/install) and run this script inside your WSL distribution.'+ ;;+ 'Darwin x86_64') target=darwin-x64 ;;+ 'Darwin arm64') target=darwin-aarch64 ;;+ 'Linux aarch64' | 'Linux arm64') target=linux-aarch64 ;;+ 'Linux x86_64') target=linux-x64 ;;+ *) error "Unsupported platform: $platform" ;;+ esac-if [[ -z "$version_arg" ]]; then- info "Finding latest CLI release..."+ if [ "$target" = darwin-x64 ]; then+ translated=$(sysctl -n sysctl.proc_translated 2>/dev/null || printf '0')+ if [ "$translated" = 1 ]; then+ target=darwin-aarch64+ info "Your shell is running in Rosetta 2. Downloading for $target instead"+ fi+ fi+}- latest_release=$(resolve_latest_cli_release) ||- error "Failed to determine the latest CLI release with a $archive_name asset. Please specify a version manually."+verify_checksum() {+ checksum_archive=$1+ checksum_manifest=$2+ checksum_name=$3+ checksum_expected=$(awk -v name="$checksum_name" '$2 == name || $2 == "*" name { print $1; exit }' "$checksum_manifest")- version=${latest_release%%$'\t'*}- archive_url=${latest_release#*$'\t'}+ if [ -z "$checksum_expected" ]; then+ warn "No checksum entry found for $checksum_name; continuing without verification"+ return 0+ fi+ printf '%s\n' "$checksum_expected" | grep -Eq '^[0-9a-fA-F]{64}$' ||+ error "Malformed checksum for $checksum_name"- info "Found latest version: $version"-else- version=$version_arg- archive_url="$github_repo/releases/download/$version/$archive_name"-fi+ if command -v sha256sum >/dev/null 2>&1; then+ checksum_actual=$(sha256sum "$checksum_archive" | awk '{ print $1 }')+ elif command -v shasum >/dev/null 2>&1; then+ checksum_actual=$(shasum -a 256 "$checksum_archive" | awk '{ print $1 }')+ else+ warn 'No SHA-256 utility found; continuing without verification'+ return 0+ fi-# --- Download into temp directory ---+ [ "$checksum_expected" = "$checksum_actual" ] ||+ error "Checksum mismatch for $checksum_name (expected $checksum_expected, got $checksum_actual)"+ info 'Checksum verified'+}-tmpdir="$(mktemp -d)"-trap 'rm -rf "$tmpdir"' EXIT+resolve_directory() {+ resolve_directory_value=$1+ mkdir -p "$resolve_directory_value" || error "Failed to create directory \"$resolve_directory_value\""+ (cd "$resolve_directory_value" && pwd -P)+}-checksums_url="$github_repo/releases/download/$version/checksums.txt"+install_bundle() {+ install_bundle_root=$1+ install_bundle_dir=$install_bundle_root/composio-$target-info "Installing Composio CLI $version for $target"+ if [ ! -f "$install_bundle_dir/composio" ]; then+ rm -f "$install_bundle_root/$archive_name" "$install_bundle_root/checksums.txt"+ install_bundle_dir=$install_bundle_root+ fi+ [ -f "$install_bundle_dir/composio" ] || error 'Binary not found in extracted archive'-info "Downloading..."-curl --fail --location --progress-bar --output "$tmpdir/$archive_name" "$archive_url" ||- error "Failed to download from \"$archive_url\""+ if ! find "$install_bundle_dir" -mindepth 1 ! -name composio -print -quit | grep -q .; then+ warn 'This release archive has no bundled support files. Some CLI features may be unavailable.'+ fi-# --- Checksum verification ---+ cp -Rp "$install_bundle_dir"/. "$resolved_install_dir/" ||+ error "Failed to install the CLI bundle to \"$resolved_install_dir\""+ chmod +x "$resolved_install_dir/composio" || error 'Failed to set permissions on executable'+ printf '%s\n' "$version" >"$resolved_install_dir/release-tag.txt" ||+ error "Failed to write install metadata to \"$resolved_install_dir/release-tag.txt\""+}-if curl --fail --silent --location --output "$tmpdir/checksums.txt" "$checksums_url" 2>/dev/null; then- expected=$(grep "$archive_name" "$tmpdir/checksums.txt" | awk '{print $1}')+install_entry_point() {+ entry_point=$resolved_bin_dir/composio+ if [ "$resolved_bin_dir" = "$resolved_install_dir" ]; then+ return 0+ fi+ if [ -d "$entry_point" ]; then+ error "Cannot replace entry point \"$entry_point\" because it is a directory"+ fi+ ln -sf "$resolved_install_dir/composio" "$entry_point" ||+ error "Failed to create entry point \"$entry_point\""+}- if [[ -n "$expected" ]]; then- if command -v sha256sum &>/dev/null; then- actual=$(sha256sum "$tmpdir/$archive_name" | awk '{print $1}')- elif command -v shasum &>/dev/null; then- actual=$(shasum -a 256 "$tmpdir/$archive_name" | awk '{print $1}')- else- actual=""- warn "No SHA-256 utility found — skipping verification"- fi+path_contains_bin_dir() {+ case :${PATH:-}: in+ *:"$resolved_bin_dir":*) return 0 ;;+ *) return 1 ;;+ esac+}- if [[ -n "$actual" && "$expected" != "$actual" ]]; then- error "Checksum mismatch for $archive_name\n Expected: $expected\n Actual: $actual"- fi+print_post_install_help() {+ [ "${COMPOSIO_INSTALL_HELP:-1}" != 0 ] || return 0+ is_true "${COMPOSIO_QUIET:-}" && return 0++ shell_name=${SHELL##*/}+ shell_route=+ shell_config=+ case $shell_name in+ zsh)+ shell_route=zsh+ shell_config=~/.zshrc+ ;;+ bash)+ shell_route=bash+ shell_config=~/.bashrc+ ;;+ fish)+ shell_route=fish+ shell_config=~/.config/fish/config.fish+ ;;+ esac++ guidance_required=0+ path_contains_bin_dir || guidance_required=1+ if [ "$shell_name" = bash ] && { [ -f "$HOME/.bash_profile" ] || [ -f "$HOME/.bash_login" ]; }; then+ guidance_required=1+ fi- if [[ -n "$actual" ]]; then- info "Checksum verified"+ printf '\n'+ if [ -n "$shell_route" ]; then+ if [ "$guidance_required" = 1 ]; then+ printf 'Required next step for %s:\n\n' "$shell_name"+ else+ printf 'Optional shell setup for completions and future PATH changes:\n\n'fi+ printf ' curl -fsSL https://composio.dev/install/%s | sh\n' "$shell_route"+ printf '\nThis configures %s.\n' "$shell_config"+ elif path_contains_bin_dir; then+ printf 'The composio command is available on PATH.\n'else- warn "No checksum entry found for $archive_name — skipping verification"+ printf 'Add %s to PATH, then start a new shell.\n' "$(tildify "$resolved_bin_dir")"fi-else- info "No checksums.txt in release — skipping verification"-fi--# --- Extract and install ---+ printf "\nRun \`composio --help\` to get started.\n"+}-info "Extracting..."-unzip -oqd "$tmpdir" "$tmpdir/$archive_name" ||- error 'Failed to extract archive'+cleanup() {+ if [ -n "${tmpdir:-}" ] && [ -d "$tmpdir" ]; then+ rm -rf "$tmpdir"+ fi+}-mkdir -p "$COMPOSIO_INSTALL_DIR" ||- error "Failed to create install directory \"$COMPOSIO_INSTALL_DIR\""+main() {+ install_agent=0+ install_plugins=${COMPOSIO_INSTALL_PLUGINS:-0}+ version_arg=-exe="$COMPOSIO_INSTALL_DIR/composio"-release_tag_file="$COMPOSIO_INSTALL_DIR/release-tag.txt"+ case $install_plugins in+ 0 | 1) ;;+ *) error 'COMPOSIO_INSTALL_PLUGINS must be 1 or 0' ;;+ esac-install_bundle_support_files() {- local source_dir="$1"- local installed_count=0+ while [ "$#" -gt 0 ]; do+ case $1 in+ --agent) install_agent=1 ;;+ --no-plugins) install_plugins=0 ;;+ -h | --help)+ print_usage+ return 0+ ;;+ --*) error "Unknown option: $1" ;;+ *)+ [ -z "$version_arg" ] || error 'Too many arguments. Expected at most one version tag.'+ version_arg=$1+ ;;+ esac+ shift+ done- while IFS= read -r -d '' source_path; do- local relative_path=${source_path#"$source_dir"/}- local target_path="$COMPOSIO_INSTALL_DIR/$relative_path"+ COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-ComposioHQ}+ COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-composio}+ COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-https://github.com}+ COMPOSIO_GITHUB_API_BASE_URL=${COMPOSIO_GITHUB_API_BASE_URL:-}+ COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}+ COMPOSIO_BIN_DIR=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}++ validate_identifier COMPOSIO_GITHUB_OWNER "$COMPOSIO_GITHUB_OWNER"+ validate_identifier COMPOSIO_GITHUB_REPO "$COMPOSIO_GITHUB_REPO"+ validate_url "$COMPOSIO_GITHUB_URL" ||+ error "COMPOSIO_GITHUB_URL must use https or an explicitly allowed test host (got \"$COMPOSIO_GITHUB_URL\")"+ if [ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]; then+ validate_url "$COMPOSIO_GITHUB_API_BASE_URL" ||+ error "COMPOSIO_GITHUB_API_BASE_URL must use https or an explicitly allowed test host (got \"$COMPOSIO_GITHUB_API_BASE_URL\")"+ fi- mkdir -p "$(dirname "$target_path")" ||- error "Failed to create support file directory \"$(dirname "$target_path")\""+ detect_target+ command -v curl >/dev/null 2>&1 || error 'curl is required to install Composio CLI'+ command -v unzip >/dev/null 2>&1 || error 'unzip is required to install Composio CLI'- mv "$source_path" "$target_path" ||- error "Failed to install support file \"$relative_path\""+ github_repo=${COMPOSIO_GITHUB_URL%/}/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO+ if [ -n "$COMPOSIO_GITHUB_API_BASE_URL" ]; then+ github_api_base=${COMPOSIO_GITHUB_API_BASE_URL%/}+ elif [ "$COMPOSIO_GITHUB_URL" = https://github.com ]; then+ github_api_base=https://api.github.com+ else+ github_api_base=${COMPOSIO_GITHUB_URL%/}/api/v3+ fi+ github_api_repo=$github_api_base/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO+ archive_name=composio-$target.zip- installed_count=$((installed_count + 1))- done < <(find "$source_dir" -mindepth 1 -type f ! -path "$source_dir/composio" -print0)+ requested_version=$version_arg+ if [ -z "$requested_version" ]; then+ requested_version=${COMPOSIO_INSTALL_VERSION:-}+ fi- if (( installed_count == 0 )); then- warn "This release archive does not include any bundled support files beyond the main binary. Some CLI features may be unavailable in this version."+ if [ -n "$requested_version" ]; then+ version=$(normalize_version "$requested_version")+ archive_url=$github_repo/releases/download/$version/$archive_name+ else+ info 'Finding latest stable CLI release...'+ latest_release=$(resolve_latest_cli_release) ||+ error "Failed to determine the latest CLI release with a $archive_name asset. Specify a version manually."+ version=$(printf '%s\n' "$latest_release" | sed -n '1p')+ archive_url=$(printf '%s\n' "$latest_release" | sed -n '2p')+ [ -n "$version" ] && [ -n "$archive_url" ] || error 'The release API returned an incomplete CLI release'+ info "Found latest version: $version"fi-}+ validate_url "$archive_url" || error "Release API returned an unsafe archive URL \"$archive_url\""++ checksums_url=$github_repo/releases/download/$version/checksums.txt+ validate_url "$checksums_url" || error "Refusing unsafe checksum URL \"$checksums_url\""-# Handle nested directory structure (composio-<target>/composio)-if [[ -f "$tmpdir/composio-$target/composio" ]]; then- mv "$tmpdir/composio-$target/composio" "$exe"- install_bundle_support_files "$tmpdir/composio-$target"-elif [[ -f "$tmpdir/composio" ]]; then- mv "$tmpdir/composio" "$exe"- install_bundle_support_files "$tmpdir"-else- error 'Binary not found in extracted archive'-fi--chmod +x "$exe" ||- error 'Failed to set permissions on executable'--printf '%s\n' "$version" > "$release_tag_file" ||- error "Failed to write install metadata to \"$release_tag_file\""--success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")"--# --- Shell integration (PATH + completions) -----# Delegate to the CLI's own install command, which handles:-# - Idempotent PATH setup in the correct rc file-# - Shell completions installation-# If the binary can't run (e.g. missing runtime), fall back to inline setup.-#-# Run it with stderr left on the terminal. `composio install` reports which rc-# file it changed and how to reload the shell, and it treats a redirected stderr-# as "nobody is watching" — capturing that stream, even to replay it later, is-# what makes the PATH guidance disappear. The version probe keeps a binary that-# cannot run at all from spilling loader errors before the fallback takes over.--echo--if "$exe" --version >/dev/null 2>&1 &&- COMPOSIO_INSTALL_DIR="$COMPOSIO_INSTALL_DIR" COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" install; then- : # the CLI printed its own shell-integration guidance-else- info "Setting up shell integration..."-- refresh_command=''- quoted_install_dir=\"${COMPOSIO_INSTALL_DIR//\"/\\\"}\"-- if [[ $quoted_install_dir = \"$HOME/* ]]; then- quoted_install_dir=${COMPOSIO_INSTALL_DIR/$HOME\//\$HOME/}+ tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'+ trap cleanup 0 1 2 3 15+ debug "temporary directory: $tmpdir"++ info "Installing Composio CLI $version for $target"+ curl_download "$archive_url" "$tmpdir/$archive_name" 0 ||+ error "Failed to download from \"$archive_url\""++ if curl_download "$checksums_url" "$tmpdir/checksums.txt" 1; then+ verify_checksum "$tmpdir/$archive_name" "$tmpdir/checksums.txt" "$archive_name"+ else+ warn 'No checksums.txt in this release; continuing without verification'fi- shell_name=$(basename "${SHELL:-}")- marker='# Composio CLI'+ info 'Extracting bundle...'+ unzip -oqd "$tmpdir" "$tmpdir/$archive_name" || error 'Failed to extract archive'- case $shell_name in- fish)- commands=(- "set --export COMPOSIO_INSTALL_DIR \"$COMPOSIO_INSTALL_DIR\""- "set --export PATH \$COMPOSIO_INSTALL_DIR \$PATH"- )- fish_config=$HOME/.config/fish/config.fish- if [[ -w $fish_config ]] || [[ -w $(dirname "$fish_config") ]]; then- mkdir -p "$(dirname "$fish_config")"- if ! grep -qxF "$marker" "$fish_config" 2>/dev/null; then- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$fish_config"- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$fish_config")\""- else- info "PATH already configured in \"$(tildify "$fish_config")\""- fi- refresh_command="source $(tildify "$fish_config")"- else- echo "Manually add the directory to $(tildify "$fish_config") (or similar):"- for cmd in "${commands[@]}"; do info_bold " $cmd"; done- fi- ;;- zsh)- commands=(- "export COMPOSIO_INSTALL_DIR=\"$COMPOSIO_INSTALL_DIR\""- "export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""- )- zsh_config=$HOME/.zshrc- if [[ ! -f $zsh_config && -w $(dirname "$zsh_config") ]]; then touch "$zsh_config"; fi- if [[ -w $zsh_config ]]; then- if ! grep -qxF "$marker" "$zsh_config" 2>/dev/null; then- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$zsh_config"- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$zsh_config")\""- else- info "PATH already configured in \"$(tildify "$zsh_config")\""- fi- refresh_command="source $(tildify "$zsh_config")"- else- echo "Manually add the directory to $(tildify "$zsh_config") (or similar):"- for cmd in "${commands[@]}"; do info_bold " $cmd"; done- fi- ;;- bash)- commands=(- "export COMPOSIO_INSTALL_DIR=$quoted_install_dir"- "export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""- )- bash_configs=("$HOME/.bashrc" "$HOME/.bash_profile")- if [[ ${XDG_CONFIG_HOME:-} ]]; then- bash_configs+=("$XDG_CONFIG_HOME/.bash_profile" "$XDG_CONFIG_HOME/.bashrc" "$XDG_CONFIG_HOME/bash_profile" "$XDG_CONFIG_HOME/bashrc")- fi- set_manually=true- for bash_config in "${bash_configs[@]}"; do- if [[ -w $bash_config ]]; then- if ! grep -qxF "$marker" "$bash_config" 2>/dev/null; then- { echo -e "\n$marker"; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$bash_config"- info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$bash_config")\""- else- info "PATH already configured in \"$(tildify "$bash_config")\""- fi- refresh_command="source $bash_config"- set_manually=false- break- fi- done- if [[ $set_manually = true ]]; then- echo "Manually add the directory to ~/.bashrc (or similar):"- for cmd in "${commands[@]}"; do info_bold " $cmd"; done- fi- ;;- *)- echo 'Manually add the directory to ~/.bashrc (or similar):'- info_bold " export COMPOSIO_INSTALL_DIR=$quoted_install_dir"- info_bold " export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""- ;;- esac+ resolved_install_dir=$(resolve_directory "$COMPOSIO_INSTALL_DIR")+ resolved_bin_dir=$(resolve_directory "$COMPOSIO_BIN_DIR")+ install_bundle "$tmpdir"+ install_entry_point-fi+ exe=$resolved_install_dir/composio+ "$exe" --version >/dev/null 2>&1 || error 'The installed Composio CLI failed its version check'+ info "Composio CLI was installed to $(tildify "$exe")"+ if [ "$resolved_bin_dir" != "$resolved_install_dir" ]; then+ info "The composio entry point is $(tildify "$resolved_bin_dir/composio")"+ fi-if [[ $install_plugins = true ]]; then- echo- info "Checking for supported agent hosts..."- if ! COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present; then- error 'Composio CLI was installed, but agent plugin setup failed. Retry with `composio setup --target auto --yes`.'+ if [ "$install_plugins" = 1 ]; then+ info 'Installing plugins for detected agent hosts...'+ COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present ||+ error "Composio CLI was installed, but agent plugin setup failed. Retry with \`composio setup --target auto --yes\`."fi-fi-if [[ $install_agent = true ]]; then- echo- info "Setting up Composio agent login..."- if ! COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" login --agent --no-skill-install; then- 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>`.'+ if [ "$install_agent" = 1 ]; then+ info 'Setting up Composio agent login...'+ COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" login --agent --no-skill-install ||+ error 'Failed to sign up or log in as a Composio agent.'fi-fi--echo-# No PATH claim here: whichever branch ran above already reported what it did to-# which file, and whether a reload is needed. Restating it unconditionally would-# promise a configured PATH even on the branches that only printed manual-# instructions.-info "To get started, run:"-echo--if [[ ${refresh_command:-} ]]; then- info_bold " $refresh_command"-fi--info_bold " composio --help"-if [[ $install_agent = true ]]; then- info_bold " composio agent whoami"-else- info_bold " composio login"-fi++ print_post_install_help+}++main "$@"diff --git a/install/bash.sh b/install/bash.shnew file mode 100755index 000000000..6430cb8f2--- /dev/null+++ b/install/bash.sh@@ -0,0 +1,141 @@+#!/bin/sh+set -eu++requested_shell() { printf '%s\n' bash; }++error() {+ printf 'error: %s\n' "$*" >&2+ exit 1+}+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }++url_authority() {+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'+}++is_allowed_http_authority() {+ case $1 in+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;+ esac+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac+ fi+ return 1+}++validate_url() {+ variant_url=$1+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac+ variant_authority=$(url_authority "$variant_url")+ [ -n "$variant_authority" ] || return 1+ case $variant_authority in *@*) return 1 ;; esac+ case $variant_url in+ https://*) return 0 ;;+ http://*) is_allowed_http_authority "$variant_authority" ;;+ *) return 1 ;;+ esac+}++download_installer() {+ variant_url=$1+ variant_output=$2+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""+ debug "curl GET $variant_url -> $variant_output"+ case $variant_url in+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ esac+}++is_unsafe_path() {+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac+ variant_cr=$(printf '\r')+ case $1 in *"$variant_cr"* | *'+'*) return 0 ;; esac+ return 1+}++render_bin_dir() {+ variant_render=$1+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac+ printf '%s\n' "$variant_render"+}++append_path_block() {+ variant_file=$1+ variant_shell=$2+ variant_bin=$3+ mkdir -p "$(dirname "$variant_file")"+ touch "$variant_file"+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0+ case $variant_shell in+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;+ esac+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"+}++inline_shell_setup() {+ variant_shell=$1+ variant_bin_dir=$2+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"+ variant_rendered=$(render_bin_dir "$variant_bin_dir")+ case $variant_shell in+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;+ bash)+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"+ if [ -f "$HOME/.bash_profile" ]; then+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"+ elif [ -f "$HOME/.bash_login" ]; then+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"+ fi+ ;;+ esac+}++cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }++main() {+ variant_shell=$(requested_shell)+ # Internal test override. User-facing docs intentionally omit this variable.+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'+ debug "temporary directory: $variant_tmpdir"+ trap cleanup 0 1 2 3 15+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'++ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"++ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}+ variant_exe=$variant_install_dir/composio+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""++ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then+ variant_configured=cli+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi++ info "Configured $variant_shell shell setup ($variant_configured)."+ case $variant_shell in+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;+ esac+}++main "$@"diff --git a/install/fish.sh b/install/fish.shnew file mode 100755index 000000000..fbad0f853--- /dev/null+++ b/install/fish.sh@@ -0,0 +1,141 @@+#!/bin/sh+set -eu++requested_shell() { printf '%s\n' fish; }++error() {+ printf 'error: %s\n' "$*" >&2+ exit 1+}+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }++url_authority() {+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'+}++is_allowed_http_authority() {+ case $1 in+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;+ esac+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac+ fi+ return 1+}++validate_url() {+ variant_url=$1+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac+ variant_authority=$(url_authority "$variant_url")+ [ -n "$variant_authority" ] || return 1+ case $variant_authority in *@*) return 1 ;; esac+ case $variant_url in+ https://*) return 0 ;;+ http://*) is_allowed_http_authority "$variant_authority" ;;+ *) return 1 ;;+ esac+}++download_installer() {+ variant_url=$1+ variant_output=$2+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""+ debug "curl GET $variant_url -> $variant_output"+ case $variant_url in+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ esac+}++is_unsafe_path() {+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac+ variant_cr=$(printf '\r')+ case $1 in *"$variant_cr"* | *'+'*) return 0 ;; esac+ return 1+}++render_bin_dir() {+ variant_render=$1+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac+ printf '%s\n' "$variant_render"+}++append_path_block() {+ variant_file=$1+ variant_shell=$2+ variant_bin=$3+ mkdir -p "$(dirname "$variant_file")"+ touch "$variant_file"+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0+ case $variant_shell in+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;+ esac+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"+}++inline_shell_setup() {+ variant_shell=$1+ variant_bin_dir=$2+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"+ variant_rendered=$(render_bin_dir "$variant_bin_dir")+ case $variant_shell in+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;+ bash)+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"+ if [ -f "$HOME/.bash_profile" ]; then+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"+ elif [ -f "$HOME/.bash_login" ]; then+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"+ fi+ ;;+ esac+}++cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }++main() {+ variant_shell=$(requested_shell)+ # Internal test override. User-facing docs intentionally omit this variable.+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'+ debug "temporary directory: $variant_tmpdir"+ trap cleanup 0 1 2 3 15+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'++ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"++ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}+ variant_exe=$variant_install_dir/composio+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""++ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then+ variant_configured=cli+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi++ info "Configured $variant_shell shell setup ($variant_configured)."+ case $variant_shell in+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;+ esac+}++main "$@"diff --git a/install/zsh.sh b/install/zsh.shnew file mode 100755index 000000000..0a0b98cb9--- /dev/null+++ b/install/zsh.sh@@ -0,0 +1,141 @@+#!/bin/sh+set -eu++requested_shell() { printf '%s\n' zsh; }++error() {+ printf 'error: %s\n' "$*" >&2+ exit 1+}+is_true() { case ${1:-} in 1 | true) return 0 ;; *) return 1 ;; esac }+info() { is_true "${COMPOSIO_QUIET:-}" || printf '%s\n' "$*"; }+debug() { is_true "${COMPOSIO_DEBUG:-}" && printf '+ %s\n' "$*" >&2 || :; }++url_authority() {+ printf '%s\n' "$1" | sed -e 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##' -e 's#[/?#].*$##'+}++is_allowed_http_authority() {+ case $1 in+ localhost | localhost:* | 127.0.0.1 | 127.0.0.1:* | '[::1]' | '[::1]':*) return 0 ;;+ esac+ if [ -n "${COMPOSIO_INSTALL_ALLOW_HTTP_HOST:-}" ]; then+ case $1 in "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST" | "$COMPOSIO_INSTALL_ALLOW_HTTP_HOST":*) return 0 ;; esac+ fi+ return 1+}++validate_url() {+ variant_url=$1+ case $variant_url in *[![:print:]]* | *[[:space:]]*) return 1 ;; esac+ variant_authority=$(url_authority "$variant_url")+ [ -n "$variant_authority" ] || return 1+ case $variant_authority in *@*) return 1 ;; esac+ case $variant_url in+ https://*) return 0 ;;+ http://*) is_allowed_http_authority "$variant_authority" ;;+ *) return 1 ;;+ esac+}++download_installer() {+ variant_url=$1+ variant_output=$2+ validate_url "$variant_url" || error "Refusing unsafe installer URL \"$variant_url\""+ debug "curl GET $variant_url -> $variant_output"+ case $variant_url in+ https://*) curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ http://*) curl --fail --silent --show-error --location --proto '=http,https' --proto-redir '=https' --output "$variant_output" "$variant_url" ;;+ esac+}++is_unsafe_path() {+ case $1 in *';'* | *'`'* | *'$'* | *'|'* | *'&'* | *'"'* | *"'"* | *'('* | *')'* | *\\*) return 0 ;; esac+ variant_cr=$(printf '\r')+ case $1 in *"$variant_cr"* | *'+'*) return 0 ;; esac+ return 1+}++render_bin_dir() {+ variant_render=$1+ case $variant_render in "$HOME"/*) variant_render=\$HOME/${variant_render#"$HOME"/} ;; esac+ printf '%s\n' "$variant_render"+}++append_path_block() {+ variant_file=$1+ variant_shell=$2+ variant_bin=$3+ mkdir -p "$(dirname "$variant_file")"+ touch "$variant_file"+ grep -Fqx '# Composio CLI' "$variant_file" 2>/dev/null && return 0+ case $variant_shell in+ fish) variant_line="set --export PATH \"$variant_bin\" \$PATH" ;;+ *) variant_line="export PATH=\"$variant_bin:\$PATH\"" ;;+ esac+ printf '\n# Composio CLI\n%s\n' "$variant_line" >>"$variant_file"+}++inline_shell_setup() {+ variant_shell=$1+ variant_bin_dir=$2+ is_unsafe_path "$variant_bin_dir" && error "COMPOSIO_BIN_DIR contains unsafe characters"+ variant_rendered=$(render_bin_dir "$variant_bin_dir")+ case $variant_shell in+ zsh) append_path_block "$HOME/.zshrc" zsh "$variant_rendered" ;;+ fish) append_path_block "$HOME/.config/fish/config.fish" fish "$variant_rendered" ;;+ bash)+ append_path_block "$HOME/.bashrc" bash "$variant_rendered"+ if [ -f "$HOME/.bash_profile" ]; then+ append_path_block "$HOME/.bash_profile" bash "$variant_rendered"+ elif [ -f "$HOME/.bash_login" ]; then+ append_path_block "$HOME/.bash_login" bash "$variant_rendered"+ fi+ ;;+ esac+}++cleanup() { [ -z "${variant_tmpdir:-}" ] || [ ! -d "$variant_tmpdir" ] || rm -rf "$variant_tmpdir"; }++main() {+ variant_shell=$(requested_shell)+ # Internal test override. User-facing docs intentionally omit this variable.+ variant_script_url=${COMPOSIO_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/ComposioHQ/composio/refs/heads/next/install.sh}+ variant_tmpdir=$(mktemp -d) || error 'Failed to create a temporary directory'+ debug "temporary directory: $variant_tmpdir"+ trap cleanup 0 1 2 3 15+ download_installer "$variant_script_url" "$variant_tmpdir/install.sh" || error 'Failed to download the base installer'+ [ -s "$variant_tmpdir/install.sh" ] || error 'Downloaded base installer is empty'++ COMPOSIO_INSTALL_HELP=0 sh "$variant_tmpdir/install.sh" "$@"++ variant_install_dir=${COMPOSIO_INSTALL_DIR:-"$HOME/.composio"}+ variant_bin_dir=${COMPOSIO_BIN_DIR:-"$HOME/.local/bin"}+ variant_exe=$variant_install_dir/composio+ [ -x "$variant_exe" ] || error "Installed executable not found at \"$variant_exe\""++ if "$variant_exe" install --help 2>&1 | grep -q -- '--shell'; then+ debug "delegating shell setup to $variant_exe install --shell $variant_shell"+ if COMPOSIO_CLI_INVOCATION_ORIGIN=installer COMPOSIO_BIN_DIR="$variant_bin_dir" "$variant_exe" install --shell "$variant_shell"; then+ variant_configured=cli+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi+ else+ debug "falling back to inline $variant_shell shell setup"+ inline_shell_setup "$variant_shell" "$variant_bin_dir"+ variant_configured=fallback+ fi++ info "Configured $variant_shell shell setup ($variant_configured)."+ case $variant_shell in+ zsh) info "Restart your shell or run \`source ~/.zshrc\`." ;;+ bash) info "Restart your shell or run \`source ~/.bashrc\`." ;;+ fish) info "Restart your shell or run \`source ~/.config/fish/config.fish\`." ;;+ esac+}++main "$@"diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.shindex ffec6f81e..93dbb7c5e 100755--- a/test/install-sh-release-resolution.test.sh+++ b/test/install-sh-release-resolution.test.sh@@ -2,421 +2,508 @@set -euo pipefailrepo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+suite_tmp="$(mktemp -d)"+trap 'rm -rf "$suite_tmp"' EXIT-tmpdir="$(mktemp -d)"-trap 'rm -rf "$tmpdir"' EXIT--bin_dir="$tmpdir/bin"-home_dir="$tmpdir/home"-install_dir="$tmpdir/install"-mkdir -p "$bin_dir" "$home_dir" "$install_dir"--windows_bin_dir="$tmpdir/windows-bin"-mkdir -p "$windows_bin_dir"-cat > "$windows_bin_dir/uname" <<'EOF'-#!/bin/sh-printf '%s\n' 'MINGW64_NT-10.0 x86_64'-EOF-chmod +x "$windows_bin_dir/uname"--bash_bin=$(command -v bash)-run_windows_installer() {- env PATH="$windows_bin_dir" HOME="$home_dir" "$bash_bin" "$repo_root/install.sh" "$@"+fail() {+ printf 'FAIL: %s\n' "$*" >&2+ exit 1}-if ! windows_help_output=$(run_windows_installer --help 2>&1); then- echo 'Expected install.sh --help to succeed before platform and prerequisite checks.' >&2- printf '%s\n' "$windows_help_output" >&2- exit 1-fi-if ! grep -q '^Usage: install.sh' <<<"$windows_help_output"; then- echo 'Expected install.sh --help to print usage on Windows-like platforms.' >&2- printf '%s\n' "$windows_help_output" >&2- exit 1-fi+assert_contains() {+ local haystack=$1+ local needle=$2+ local label=$3+ grep -Fq -- "$needle" <<<"$haystack" || fail "$label (missing: $needle)"+}-if invalid_option_output=$(run_windows_installer --invalid-option 2>&1); then- echo 'Expected install.sh to reject an unknown option before platform checks.' >&2- exit 1-fi-if ! grep -q 'Unknown option: --invalid-option' <<<"$invalid_option_output"; then- echo 'Expected the unknown-option error on Windows-like platforms.' >&2- printf '%s\n' "$invalid_option_output" >&2- exit 1-fi-if grep -Eq 'Windows is not supported|(curl|unzip) is required to install Composio CLI' <<<"$invalid_option_output"; then- echo 'Expected argument validation to take precedence over platform and prerequisite errors.' >&2- printf '%s\n' "$invalid_option_output" >&2- exit 1-fi+assert_not_contains() {+ local haystack=$1+ local needle=$2+ local label=$3+ if grep -Fq -- "$needle" <<<"$haystack"; then+ fail "$label (unexpected: $needle)"+ fi+}-if excess_arguments_output=$(run_windows_installer first-version second-version 2>&1); then- echo 'Expected install.sh to reject excess positional arguments before platform checks.' >&2- exit 1-fi-if ! grep -q 'Too many arguments' <<<"$excess_arguments_output"; then- echo 'Expected the excess-arguments error on Windows-like platforms.' >&2- printf '%s\n' "$excess_arguments_output" >&2- exit 1-fi-if grep -Eq 'Windows is not supported|(curl|unzip) is required to install Composio CLI' <<<"$excess_arguments_output"; then- echo 'Expected argument validation to take precedence over platform and prerequisite errors.' >&2- printf '%s\n' "$excess_arguments_output" >&2- exit 1-fi+for script in "$repo_root/install.sh" "$repo_root"/install/*.sh; do+ [[ $(tail -n 1 "$script") == 'main "$@"' ]] || fail "$script must end with main \"\$@\""+ [[ $(grep -c '^main "\$@"$' "$script") -eq 1 ]] || fail "$script must contain one main entry point"+ if rg -n '(^|[[:space:]])\[\[[[:space:]]|set -[^[:space:]]*o[[:space:]]+pipefail|<\(|<<<|echo -e|(^|[[:space:]])local[[:space:]]' "$script"; then+ fail "$script contains a non-POSIX shell construct"+ fi+done-if windows_output=$(run_windows_installer 2>&1); then- echo 'Expected install.sh to reject Windows-like platforms.' >&2- exit 1-fi-if ! grep -q 'Windows is not supported. Please use WSL' <<<"$windows_output"; then- echo 'Expected Windows-to-WSL guidance when installer prerequisites are missing.' >&2- printf '%s\n' "$windows_output" >&2- exit 1-fi-if grep -Eq '(curl|unzip) is required to install Composio CLI' <<<"$windows_output"; then- echo 'Expected Windows-to-WSL guidance to take precedence over prerequisite errors.' >&2- printf '%s\n' "$windows_output" >&2- exit 1-fi+windows_bin="$suite_tmp/windows-bin"+windows_home="$suite_tmp/windows-home"+mkdir -p "$windows_bin" "$windows_home"+cat >"$windows_bin/uname" <<'EOF'+#!/bin/sh+printf '%s\n' 'MINGW64_NT-10.0 x86_64'+EOF+chmod +x "$windows_bin/uname"++for interpreter in "$(command -v sh)"; do+ help_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --help 2>&1) ||+ fail '--help must succeed before platform checks'+ assert_contains "$help_output" 'Usage: install.sh' '--help output'++ if invalid_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" --invalid 2>&1); then+ fail 'unknown options must fail'+ fi+ assert_contains "$invalid_output" 'Unknown option: --invalid' 'argument validation order'+ assert_not_contains "$invalid_output" 'Windows is not supported' 'argument validation must precede platform checks'++ if windows_output=$(env PATH="$windows_bin:$PATH" HOME="$windows_home" "$interpreter" "$repo_root/install.sh" 2>&1); then+ fail 'Windows-like platforms must fail'+ fi+ assert_contains "$windows_output" 'Windows is not supported. Use WSL' 'Windows guidance'+doneplatform=$(uname -ms)case $platform in-'Darwin x86_64') target=darwin-x64 ;;-'Darwin arm64') target=darwin-aarch64 ;;-'Linux aarch64' | 'Linux arm64')- target=linux-aarch64 ;;-'Linux x86_64') target=linux-x64 ;;-*) echo "Unsupported test platform: $platform" >&2; exit 1 ;;+'Darwin x86_64') target=darwin-x64 ;;+'Darwin arm64') target=darwin-aarch64 ;;+'Linux aarch64'|'Linux arm64') target=linux-aarch64 ;;+'Linux x86_64') target=linux-x64 ;;+*) fail "unsupported test platform: $platform" ;;esacarchive_name="composio-$target.zip"-valid_tag='@composio/[email protected]'+stable_tag='@composio/[email protected]'+beta_tag='@composio/[email protected]'missing_asset_tag='@composio/[email protected]'-tag_without_release='@composio/[email protected]'api_base='https://api.example.test'-archive_url="https://downloads.example.test/$valid_tag/$archive_name"-curl_log="$tmpdir/curl.log"-git_log="$tmpdir/git.log"-composio_log="$tmpdir/composio.log"+github_url='https://github.example.test'+archive_url="https://downloads.example.test/$stable_tag/$archive_name"+script_url='https://installer.example.test/install.sh'-cat > "$bin_dir/curl" <<'EOF'+interpreters=("$(command -v sh)")+if command -v dash >/dev/null 2>&1 && [[ $(command -v dash) != "${interpreters[0]}" ]]; then+ interpreters+=("$(command -v dash)")+fi++for interpreter in "${interpreters[@]}"; do+ interpreter_name=$(basename "$interpreter")+ case_root="$suite_tmp/$interpreter_name"+ fake_bin="$case_root/bin"+ curl_log="$case_root/curl.log"+ composio_log="$case_root/composio.log"+ mkdir -p "$fake_bin"+ : >"$curl_log"+ : >"$composio_log"++ cat >"$fake_bin/curl" <<'EOF'#!/usr/bin/env bashset -euo pipefail-output=""-url=""-while [[ $# -gt 0 ]]; do- case "$1" in- --output|-o)- output="$2"- shift 2- ;;- --*)- shift- ;;- *)- url="$1"- shift- ;;- esac+printf '%s\n' "$*" >>"$TEST_CURL_LOG"+all_args=$*+output=+url=+while (($# > 0)); do+ case $1 in+ --output|-o)+ output=$2+ shift 2+ ;;+ --proto|--proto-redir)+ shift 2+ ;;+ --fail|--silent|--show-error|--location|--progress-bar)+ shift+ ;;+ --*)+ shift+ ;;+ *)+ url=$1+ shift+ ;;+ esacdone-printf '%s\n' "$url" >> "$TEST_CURL_LOG"+case $url in+https://*)+ [[ $all_args == *"--proto =https"* && $all_args == *"--proto-redir =https"* ]] || exit 91+ ;;+http://*)+ [[ $all_args == *"--proto =http,https"* && $all_args == *"--proto-redir =https"* ]] || exit 92+ ;;+esac++if [[ $url == "$TEST_SCRIPT_URL" ]]; then+ case ${TEST_BASE_MODE:-ok} in+ fail) exit 22 ;;+ empty) : >"$output" ;;+ ok) cp "$TEST_REPO_ROOT/install.sh" "$output" ;;+ esac+ exit 0+fi-case "$url" in+case $url in"$TEST_API_BASE/repos/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO/releases?per_page=100&page=1")- cat <<JSON+ asset_url=${TEST_API_ASSET_URL:-$TEST_ARCHIVE_URL}+ cat <<JSON[- {- "tag_name": "$TEST_MISSING_ASSET_TAG",- "prerelease": false,- "draft": false,- "assets": []- },- {- "tag_name": "@composio/[email protected]",- "prerelease": true,- "draft": false,- "assets": [- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "https://downloads.example.test/@composio/[email protected]/$TEST_ARCHIVE_NAME" }- ]- },- {- "tag_name": "@composio/[email protected]",- "prerelease": false,- "draft": false,- "assets": [- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "https://downloads.example.test/@composio/[email protected]/$TEST_ARCHIVE_NAME" }- ]- },- {- "tag_name": "$TEST_VALID_TAG",- "prerelease": false,- "draft": false,- "assets": [- { "name": "$TEST_ARCHIVE_NAME", "browser_download_url": "$TEST_ARCHIVE_URL" }- ]- }+ {"tag_name":"$TEST_MISSING_ASSET_TAG","assets":[]},+ {"tag_name":"@composio/[email protected]","assets":[{"browser_download_url":"https://downloads.example.test/beta/$TEST_ARCHIVE_NAME"}]},+ {"tag_name":"$TEST_STABLE_TAG","assets":[{"browser_download_url":"$asset_url"}]}]JSON- ;;-"$TEST_ARCHIVE_URL")- if [[ -z "$output" ]]; then- echo 'archive download did not pass --output' >&2- exit 1- fi- printf 'fake archive for %s\n' "$TEST_VALID_TAG" > "$output"- ;;-*checksums.txt)- exit 22- ;;+ ;;+"$TEST_ARCHIVE_URL"|*"/releases/download/"*"/$TEST_ARCHIVE_NAME")+ [[ -n $output ]] || exit 93+ if [[ ${TEST_REDIRECT_DOWNGRADE:-0} == 1 ]]; then+ exit 47+ fi+ printf 'fake archive\n' >"$output"+ ;;+*"/releases/download/"*"/checksums.txt")+ case ${TEST_CHECKSUM_MODE:-missing} in+ missing) exit 22 ;;+ valid) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'a' >"$output" ;;+ mismatch) printf '%064d %s\n' 0 "$TEST_ARCHIVE_NAME" | tr '0' 'b' >"$output" ;;+ malformed) printf 'not-a-hash %s\n' "$TEST_ARCHIVE_NAME" >"$output" ;;+ esac+ ;;*)- echo "unexpected curl URL: $url" >&2- exit 1- ;;+ printf 'unexpected curl URL: %s\n' "$url" >&2+ exit 94+ ;;esacEOF-chmod +x "$bin_dir/curl"+ chmod +x "$fake_bin/curl"-cat > "$bin_dir/unzip" <<'EOF'-#!/usr/bin/env bash-set -euo pipefail--dest=""-while [[ $# -gt 0 ]]; do- case "$1" in- -d)- dest="$2"- shift 2- ;;- -*)- # install.sh currently calls unzip with -oqd <dest>, so support the- # compact flag by treating the next argument as the destination.- if [[ "$1" == *d ]]; then- dest="$2"- shift 2- else- shift- fi- ;;- *)- shift- ;;- esac-done--if [[ -z "$dest" ]]; then- echo 'fake unzip did not receive a destination' >&2- exit 1-fi+ cat >"$fake_bin/sha256sum" <<'EOF'+#!/bin/sh+printf '%s %s\n' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' "$1"+EOF+ chmod +x "$fake_bin/sha256sum"-mkdir -p "$dest"-cat > "$dest/composio" <<'BIN'+ cat >"$fake_bin/unzip" <<'EOF'#!/usr/bin/env bashset -euo pipefail--printf '%s\n' "$*" >> "$TEST_COMPOSIO_LOG"--case "${1:-}" in-install)- if [[ -n "${TEST_INSTALL_STDERR:-}" ]]; then- printf '%s\n' "$TEST_INSTALL_STDERR" >&2- fi- exit 0+dest=+while (($# > 0)); do+ case $1 in+ -d)+ dest=$2+ shift 2;;-setup)- if [[ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" != 'installer' ]]; then- echo 'Expected automatic plugin setup telemetry origin to be installer.' >&2- exit 97- fi- exit "${TEST_SETUP_EXIT:-0}"+ -*d)+ dest=$2+ shift 2;;+ *) shift ;;+ esac+done+[[ -n $dest ]] || exit 95+bundle="$dest/composio-$TEST_TARGET"+mkdir -p "$bundle/services" "$bundle/local-tools-binaries"+cat >"$bundle/composio" <<'BIN'+#!/bin/sh+printf '%s|%s|%s|%s\n' "${COMPOSIO_INSTALL_HELP:-}" "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" "${COMPOSIO_BIN_DIR:-}" "$*" >>"$TEST_COMPOSIO_LOG"+case ${1:-} in--version|version)- if [[ -n "${TEST_VERSION_STDERR:-}" ]]; then- printf '%s\n' "$TEST_VERSION_STDERR" >&2+ printf '%s\n' 'composio fake 98.0.0'+ exit "${TEST_VERSION_EXIT:-0}"+ ;;+setup)+ [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 96+ exit "${TEST_SETUP_EXIT:-0}"+ ;;+login)+ [ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" = installer ] || exit 97+ exit 0+ ;;+install)+ if [ "${2:-}" = --help ]; then+ if [ "${TEST_SHELL_CAPABILITY:-supported}" = supported ]; then+ printf '%s\n' 'Usage: composio install [--shell zsh|bash|fish]'+ else+ printf '%s\n' 'Usage: composio install'fi- echo 'composio fake 98.0.0'- exit "${TEST_VERSION_EXIT:-0}"- ;;-*)exit 0- ;;+ fi+ if [ "${2:-}" = --shell ]; then+ exit "${TEST_INSTALL_EXIT:-0}"+ fi+ exit 98+ ;;+*) exit 0 ;;esacBIN-chmod +x "$dest/composio"-EOF-chmod +x "$bin_dir/unzip"--cat > "$bin_dir/git" <<'EOF'-#!/usr/bin/env bash-set -euo pipefail-printf 'git should not be used for install.sh release resolution; fake tag was %s\n' "$TEST_TAG_WITHOUT_RELEASE" >> "$TEST_GIT_LOG"-echo "0000000000000000000000000000000000000000 refs/tags/$TEST_TAG_WITHOUT_RELEASE"-exit 0+ chmod +x "$bundle/composio"+ printf '%s\n' 'support' >"$bundle/run-bun.mjs"+ printf '%s\n' 'service' >"$bundle/services/example.txt"EOF-chmod +x "$bin_dir/git"--export TEST_CURL_LOG="$curl_log"-export TEST_GIT_LOG="$git_log"-export TEST_COMPOSIO_LOG="$composio_log"-export TEST_API_BASE="$api_base"-export TEST_ARCHIVE_NAME="$archive_name"-export TEST_ARCHIVE_URL="$archive_url"-export TEST_VALID_TAG="$valid_tag"-export TEST_MISSING_ASSET_TAG="$missing_asset_tag"-export TEST_TAG_WITHOUT_RELEASE="$tag_without_release"--run_installer() {- local test_home="$1"- local test_install_dir="$2"- shift 2+ chmod +x "$fake_bin/unzip"++ export TEST_REPO_ROOT="$repo_root"+ export TEST_TARGET="$target"+ export TEST_ARCHIVE_NAME="$archive_name"+ export TEST_STABLE_TAG="$stable_tag"+ export TEST_MISSING_ASSET_TAG="$missing_asset_tag"+ export TEST_ARCHIVE_URL="$archive_url"+ export TEST_API_BASE="$api_base"+ export TEST_SCRIPT_URL="$script_url"+ export TEST_CURL_LOG="$curl_log"+ export TEST_COMPOSIO_LOG="$composio_log"++ reset_case() {+ unset CASE_GITHUB_URL CASE_API_BASE CASE_INSTALL_VERSION CASE_PLUGINS CASE_QUIET CASE_DEBUG CASE_HELP+ unset CASE_ALLOW_HTTP_HOST CASE_CHECKSUM_MODE CASE_API_ASSET_URL CASE_BASE_MODE CASE_REDIRECT_DOWNGRADE+ unset CASE_SHELL_CAPABILITY CASE_INSTALL_EXIT CASE_SETUP_EXIT CASE_VERSION_EXIT CASE_PATH_PREFIX+ : >"$curl_log"+ : >"$composio_log"+ }+ run_installer() {+ local home=$1+ local install_dir=$2+ local bin_dir=$3+ shift 3+ mkdir -p "$home" "$install_dir" "$bin_dir"env \- PATH="$bin_dir:$PATH" \- HOME="$test_home" \- SHELL="/bin/bash" \- COMPOSIO_INSTALL_DIR="$test_install_dir" \- COMPOSIO_INSTALL_PLUGINS="${COMPOSIO_INSTALL_PLUGINS:-1}" \- COMPOSIO_GITHUB_URL='https://github.example.test' \- COMPOSIO_GITHUB_API_BASE_URL="$api_base" \- COMPOSIO_GITHUB_OWNER='FakeOwner' \- COMPOSIO_GITHUB_REPO='fake-repo' \- TEST_INSTALL_STDERR="${TEST_INSTALL_STDERR:-}" \- TEST_SETUP_EXIT="${TEST_SETUP_EXIT:-0}" \- TEST_VERSION_EXIT="${TEST_VERSION_EXIT:-0}" \- TEST_VERSION_STDERR="${TEST_VERSION_STDERR:-}" \- bash "$repo_root/install.sh" "$@"-}--install_guidance='shell integration guidance from composio install'-output=$(TEST_INSTALL_STDERR="$install_guidance" run_installer "$home_dir" "$install_dir" 2>&1)--printf '%s\n' "$output"--if [[ -s "$git_log" ]]; then- echo 'Expected install.sh not to call git while resolving latest release.' >&2- cat "$git_log" >&2- exit 1-fi--if [[ ! -f "$install_dir/release-tag.txt" ]]; then- echo 'Expected install.sh to write release-tag.txt.' >&2- exit 1-fi--installed_tag=$(<"$install_dir/release-tag.txt")-if [[ "$installed_tag" != "$valid_tag" ]]; then- echo "Expected fallback to $valid_tag, got $installed_tag" >&2- exit 1-fi--if ! grep -q "Found latest version: $valid_tag" <<<"$output"; then- echo "Expected installer output to select $valid_tag." >&2- exit 1-fi--if grep -q "Installing Composio CLI $missing_asset_tag" <<<"$output"; then- echo "Installer attempted to install release without $archive_name." >&2- exit 1-fi--if grep -q "$tag_without_release" "$curl_log"; then- echo 'Installer attempted to use a tag that was not present in releases.' >&2- exit 1-fi--if ! grep -qxF -- '--version' "$composio_log"; then- echo 'Expected installer to probe the downloaded CLI with --version.' >&2- cat "$composio_log" >&2- exit 1-fi--if ! grep -qxF 'install' "$composio_log"; then- echo 'Expected installer to delegate shell integration to composio install.' >&2- cat "$composio_log" >&2- exit 1-fi--if ! grep -qF "$install_guidance" <<<"$output"; then- echo 'Expected composio install stderr guidance to remain visible.' >&2- printf '%s\n' "$output" >&2- exit 1-fi--expected_setup='setup --target auto --yes --if-present'-if ! grep -qxF "$expected_setup" "$composio_log"; then- echo "Expected installer to invoke: composio $expected_setup" >&2- cat "$composio_log" >&2- exit 1-fi--failed_probe_home="$tmpdir/home-failed-probe"-failed_probe_install="$tmpdir/install-failed-probe"-mkdir -p "$failed_probe_home" "$failed_probe_install"-: > "$failed_probe_home/.bashrc"-: > "$composio_log"-loader_error='loader error from an unusable composio binary'-failed_probe_output=$(- TEST_VERSION_EXIT=126 \- TEST_VERSION_STDERR="$loader_error" \- run_installer "$failed_probe_home" "$failed_probe_install" --no-plugins 2>&1-)-if grep -qF "$loader_error" <<<"$failed_probe_output"; then- echo 'Expected the failed binary probe to suppress loader errors.' >&2- printf '%s\n' "$failed_probe_output" >&2- exit 1-fi-if grep -qxF 'install' "$composio_log"; then- echo 'Expected a failed binary probe to skip composio install.' >&2- cat "$composio_log" >&2- exit 1-fi-if ! grep -qF 'Setting up shell integration...' <<<"$failed_probe_output"; then- echo 'Expected a failed binary probe to select inline shell integration.' >&2- printf '%s\n' "$failed_probe_output" >&2- exit 1-fi-if ! grep -qxF '# Composio CLI' "$failed_probe_home/.bashrc"; then- echo 'Expected inline shell integration to update .bashrc.' >&2- cat "$failed_probe_home/.bashrc" >&2- exit 1-fi+ PATH="${CASE_PATH_PREFIX:-}$fake_bin:$PATH" \+ HOME="$home" \+ SHELL=/bin/bash \+ COMPOSIO_INSTALL_DIR="$install_dir" \+ COMPOSIO_BIN_DIR="$bin_dir" \+ COMPOSIO_INSTALL_VERSION="${CASE_INSTALL_VERSION:-}" \+ COMPOSIO_INSTALL_PLUGINS="${CASE_PLUGINS:-0}" \+ COMPOSIO_QUIET="${CASE_QUIET:-0}" \+ COMPOSIO_DEBUG="${CASE_DEBUG:-0}" \+ COMPOSIO_INSTALL_HELP="${CASE_HELP:-1}" \+ COMPOSIO_INSTALL_ALLOW_HTTP_HOST="${CASE_ALLOW_HTTP_HOST:-}" \+ COMPOSIO_GITHUB_URL="${CASE_GITHUB_URL:-$github_url}" \+ COMPOSIO_GITHUB_API_BASE_URL="${CASE_API_BASE:-$api_base}" \+ COMPOSIO_GITHUB_OWNER=FakeOwner \+ COMPOSIO_GITHUB_REPO=fake-repo \+ TEST_CHECKSUM_MODE="${CASE_CHECKSUM_MODE:-missing}" \+ TEST_API_ASSET_URL="${CASE_API_ASSET_URL:-}" \+ TEST_REDIRECT_DOWNGRADE="${CASE_REDIRECT_DOWNGRADE:-0}" \+ TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \+ TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \+ TEST_SETUP_EXIT="${CASE_SETUP_EXIT:-0}" \+ TEST_VERSION_EXIT="${CASE_VERSION_EXIT:-0}" \+ "$interpreter" "$repo_root/install.sh" "$@"+ }-no_plugins_home="$tmpdir/home-no-plugins"-no_plugins_install="$tmpdir/install-no-plugins"-mkdir -p "$no_plugins_home" "$no_plugins_install"-: > "$composio_log"-run_installer "$no_plugins_home" "$no_plugins_install" --no-plugins >/dev/null 2>&1-if grep -q '^setup ' "$composio_log"; then- echo 'Expected --no-plugins to skip agent plugin setup.' >&2- cat "$composio_log" >&2- exit 1-fi+ run_variant() {+ local shell_name=$1+ local home=$2+ local install_dir=$3+ local bin_dir=$4+ shift 4+ mkdir -p "$home" "$install_dir" "$bin_dir"+ env \+ PATH="$fake_bin:$PATH" \+ HOME="$home" \+ SHELL="/bin/$shell_name" \+ COMPOSIO_INSTALL_DIR="$install_dir" \+ COMPOSIO_BIN_DIR="$bin_dir" \+ COMPOSIO_INSTALL_SCRIPT_URL="$script_url" \+ COMPOSIO_INSTALL_PLUGINS=0 \+ COMPOSIO_GITHUB_URL="$github_url" \+ COMPOSIO_GITHUB_API_BASE_URL="$api_base" \+ COMPOSIO_GITHUB_OWNER=FakeOwner \+ COMPOSIO_GITHUB_REPO=fake-repo \+ TEST_BASE_MODE="${CASE_BASE_MODE:-ok}" \+ TEST_CHECKSUM_MODE=missing \+ TEST_SHELL_CAPABILITY="${CASE_SHELL_CAPABILITY:-supported}" \+ TEST_INSTALL_EXIT="${CASE_INSTALL_EXIT:-0}" \+ "$interpreter" "$repo_root/install/$shell_name.sh" "$@"+ }-env_opt_out_home="$tmpdir/home-env-opt-out"-env_opt_out_install="$tmpdir/install-env-opt-out"-mkdir -p "$env_opt_out_home" "$env_opt_out_install"-: > "$composio_log"-COMPOSIO_INSTALL_PLUGINS=0 run_installer "$env_opt_out_home" "$env_opt_out_install" >/dev/null 2>&1-if grep -q '^setup ' "$composio_log"; then- echo 'Expected COMPOSIO_INSTALL_PLUGINS=0 to skip agent plugin setup.' >&2- cat "$composio_log" >&2- exit 1-fi+ reset_case+ home="$case_root/default-home"+ install_dir="$case_root/default-install"+ bin_dir="$case_root/default-bin"+ output=$(run_installer "$home" "$install_dir" "$bin_dir" 2>&1)+ [[ $(<"$install_dir/release-tag.txt") == "$stable_tag" ]] || fail "$interpreter_name latest stable resolution"+ [[ -x "$install_dir/composio" && -f "$install_dir/run-bun.mjs" ]] || fail "$interpreter_name bundle installation"+ [[ -L "$bin_dir/composio" ]] || fail "$interpreter_name entry-point symlink"+ expected_install_dir=$(cd "$install_dir" && pwd -P)+ [[ $(readlink "$bin_dir/composio") == "$expected_install_dir/composio" ]] || fail "$interpreter_name symlink target"+ assert_contains "$output" "Found latest version: $stable_tag" "$interpreter_name stable discovery"+ assert_contains "$output" 'Required next step for bash:' "$interpreter_name required PATH guidance"+ [[ ! -e "$home/.bashrc" ]] || fail "$interpreter_name default flow must not write rc files"+ [[ $(wc -l <"$composio_log") -eq 1 ]] || fail "$interpreter_name default flow invoked extra CLI commands"+ grep -Fq '|--version' "$composio_log" || fail "$interpreter_name version probe"+ [[ ! -s "$case_root/git.log" ]] || fail "$interpreter_name must not use git"++ reset_case+ equal_dir="$case_root/equal-layout"+ run_installer "$case_root/equal-home" "$equal_dir" "$equal_dir" "$beta_tag" >/dev/null 2>&1+ [[ -x "$equal_dir/composio" && ! -L "$equal_dir/composio" ]] || fail "$interpreter_name equal-dir layout"+ [[ $(<"$equal_dir/release-tag.txt") == "$beta_tag" ]] || fail "$interpreter_name explicit beta tag"++ reset_case+ legacy_home="$case_root/legacy-home"+ mkdir -p "$legacy_home"+ printf '%s\n' 'export COMPOSIO_INSTALL_DIR="$HOME/.composio"' >"$legacy_home/.bashrc"+ run_installer "$legacy_home" "$case_root/legacy-install" "$case_root/legacy-bin" "$stable_tag" >/dev/null 2>&1+ [[ -L "$case_root/legacy-bin/composio" ]] || fail "$interpreter_name legacy migration symlink"+ grep -Fq 'COMPOSIO_INSTALL_DIR' "$legacy_home/.bashrc" || fail "$interpreter_name must preserve legacy rc content"++ reset_case+ replacement_bin="$case_root/replacement-bin"+ mkdir -p "$replacement_bin"+ printf '%s\n' old >"$replacement_bin/composio"+ run_installer "$case_root/replacement-home" "$case_root/replacement-install" "$replacement_bin" "$stable_tag" >/dev/null 2>&1+ [[ -L "$replacement_bin/composio" ]] || fail "$interpreter_name regular entry point replacement"++ reset_case+ directory_bin="$case_root/directory-bin"+ mkdir -p "$directory_bin/composio"+ if directory_output=$(run_installer "$case_root/directory-home" "$case_root/directory-install" "$directory_bin" "$stable_tag" 2>&1); then+ fail "$interpreter_name directory entry point must fail"+ fi+ assert_contains "$directory_output" 'because it is a directory' "$interpreter_name directory error"++ reset_case+ CASE_INSTALL_VERSION=97.0.0+ precedence_install="$case_root/precedence-install"+ run_installer "$case_root/precedence-home" "$precedence_install" "$case_root/precedence-bin" 96.0.0 >/dev/null 2>&1+ [[ $(<"$precedence_install/release-tag.txt") == '@composio/[email protected]' ]] || fail "$interpreter_name version precedence"++ reset_case+ CASE_INSTALL_VERSION=95.0.0-beta.7+ env_version_install="$case_root/env-version-install"+ run_installer "$case_root/env-version-home" "$env_version_install" "$case_root/env-version-bin" >/dev/null 2>&1+ [[ $(<"$env_version_install/release-tag.txt") == '@composio/[email protected]' ]] || fail "$interpreter_name env beta normalization"++ reset_case+ 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+ fail "$interpreter_name malformed prerelease must fail"+ fi+ assert_contains "$malformed_output" 'Invalid Composio CLI version' "$interpreter_name malformed version"+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name malformed version must fail before network"++ reset_case+ CASE_CHECKSUM_MODE=valid+ run_installer "$case_root/checksum-home" "$case_root/checksum-install" "$case_root/checksum-bin" "$stable_tag" >/dev/null 2>&1++ for checksum_mode in mismatch malformed; do+ reset_case+ CASE_CHECKSUM_MODE=$checksum_mode+ 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+ fail "$interpreter_name $checksum_mode checksum must fail"+ fi+ grep -qi 'checksum' <<<"$checksum_output" || fail "$interpreter_name $checksum_mode checksum error"+ done++ reset_case+ CASE_PLUGINS=1+ run_installer "$case_root/plugins-home" "$case_root/plugins-install" "$case_root/plugins-bin" "$stable_tag" >/dev/null 2>&1+ grep -Eq '\|installer\|[^|]*\|setup --target auto --yes --if-present$' "$composio_log" || fail "$interpreter_name plugin opt-in"++ reset_case+ CASE_QUIET=1+ quiet_output=$(run_installer "$case_root/quiet-home" "$case_root/quiet-install" "$case_root/quiet-bin" "$stable_tag" 2>&1)+ assert_not_contains "$quiet_output" 'Installing Composio CLI' "$interpreter_name quiet output"++ reset_case+ CASE_DEBUG=1+ debug_output=$(run_installer "$case_root/debug-home" "$case_root/debug-install" "$case_root/debug-bin" "$stable_tag" 2>&1)+ assert_contains "$debug_output" '+ curl GET' "$interpreter_name debug traces"++ reset_case+ CASE_HELP=0+ help_suppressed=$(run_installer "$case_root/help-home" "$case_root/help-install" "$case_root/help-bin" "$stable_tag" 2>&1)+ assert_not_contains "$help_suppressed" 'next step' "$interpreter_name help suppression"++ reset_case+ CASE_GITHUB_URL='http://127.0.0.1:8929'+ CASE_API_BASE='http://127.0.0.1:8929/api'+ run_installer "$case_root/loopback-home" "$case_root/loopback-install" "$case_root/loopback-bin" "$stable_tag" >/dev/null 2>&1+ grep -Fq -- '--proto =http,https --proto-redir =https' "$curl_log" || fail "$interpreter_name loopback protocol flags"++ for unsafe_url in 'http://evil.example' 'http://[email protected]:8929' 'http://127.0.0.1.evil.example'; do+ reset_case+ CASE_GITHUB_URL=$unsafe_url+ 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+ fail "$interpreter_name unsafe configured URL accepted: $unsafe_url"+ fi+ [[ ! -s "$curl_log" ]] || fail "$interpreter_name unsafe configured URL reached curl"+ done++ reset_case+ CASE_GITHUB_URL='http://host.docker.internal:8080'+ CASE_API_BASE='http://host.docker.internal:8080/api'+ 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+ fail "$interpreter_name host.docker.internal must require opt-in"+ fi+ CASE_ALLOW_HTTP_HOST=host.docker.internal+ run_installer "$case_root/docker-home" "$case_root/docker-install" "$case_root/docker-bin" "$stable_tag" >/dev/null 2>&1++ reset_case+ CASE_API_ASSET_URL="http://evil.example/$archive_name"+ if api_unsafe_output=$(run_installer "$case_root/api-unsafe-home" "$case_root/api-unsafe-install" "$case_root/api-unsafe-bin" 2>&1); then+ fail "$interpreter_name unsafe API asset URL accepted"+ fi+ assert_contains "$api_unsafe_output" 'unsafe archive URL' "$interpreter_name unsafe API URL"++ reset_case+ CASE_REDIRECT_DOWNGRADE=1+ if run_installer "$case_root/downgrade-home" "$case_root/downgrade-install" "$case_root/downgrade-bin" "$stable_tag" >/dev/null 2>&1; then+ fail "$interpreter_name redirect downgrade simulation must fail"+ fi+ [[ ! -e "$case_root/downgrade-bin/composio" ]] || fail "$interpreter_name failed download must not install"++ for shell_name in zsh bash fish; do+ reset_case+ variant_home="$case_root/variant-$shell_name-home"+ variant_install="$case_root/variant-$shell_name-install"+ variant_bin="$case_root/variant-$shell_name-bin"+ run_variant "$shell_name" "$variant_home" "$variant_install" "$variant_bin" "$stable_tag" --no-plugins >/dev/null 2>&1+ grep -Fq "|installer|$variant_bin|install --shell $shell_name" "$composio_log" ||+ fail "$interpreter_name $shell_name variant delegation"+ grep -Eq '^0\|\|[^|]+\|--version$' "$composio_log" || fail "$interpreter_name $shell_name nested help suppression"+ done++ reset_case+ CASE_SHELL_CAPABILITY=unsupported+ fallback_home="$case_root/fallback-home"+ run_variant zsh "$fallback_home" "$case_root/fallback-install" "$case_root/fallback-bin" "$stable_tag" >/dev/null 2>&1+ grep -Fqx '# Composio CLI' "$fallback_home/.zshrc" || fail "$interpreter_name unsupported CLI fallback"++ reset_case+ CASE_INSTALL_EXIT=23+ failed_install_home="$case_root/failed-install-home"+ run_variant zsh "$failed_install_home" "$case_root/failed-install-dir" "$case_root/failed-install-bin" "$stable_tag" >/dev/null 2>&1+ grep -Fqx '# Composio CLI' "$failed_install_home/.zshrc" || fail "$interpreter_name failed --shell fallback"++ reset_case+ CASE_SHELL_CAPABILITY=unsupported+ bash_fallback_home="$case_root/bash-fallback-home"+ mkdir -p "$bash_fallback_home"+ : >"$bash_fallback_home/.bash_profile"+ run_variant bash "$bash_fallback_home" "$case_root/bash-fallback-install" "$case_root/bash-fallback-bin" "$stable_tag" >/dev/null 2>&1+ grep -Fqx '# Composio CLI' "$bash_fallback_home/.bashrc" || fail "$interpreter_name bash fallback bashrc"+ grep -Fqx '# Composio CLI' "$bash_fallback_home/.bash_profile" || fail "$interpreter_name bash fallback login override"++ reset_case+ CASE_SHELL_CAPABILITY=unsupported+ unsafe_home="$case_root/unsafe-variant-home"+ if run_variant zsh "$unsafe_home" "$case_root/unsafe-variant-install" "$case_root/unsafe;variant-bin" "$stable_tag" >/dev/null 2>&1; then+ fail "$interpreter_name unsafe variant bin dir must fail"+ fi+ [[ ! -e "$unsafe_home/.zshrc" ]] || fail "$interpreter_name unsafe variant must not write rc file"++ for base_mode in fail empty; do+ reset_case+ CASE_BASE_MODE=$base_mode+ base_failure_home="$case_root/base-$base_mode-home"+ 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+ fail "$interpreter_name $base_mode base installer download must fail"+ fi+ [[ ! -e "$base_failure_home/.zshrc" ]] || fail "$interpreter_name $base_mode download must not write rc"+ done-failed_setup_home="$tmpdir/home-failed-setup"-failed_setup_install="$tmpdir/install-failed-setup"-mkdir -p "$failed_setup_home" "$failed_setup_install"-: > "$composio_log"-if failed_output=$(TEST_SETUP_EXIT=23 run_installer "$failed_setup_home" "$failed_setup_install" 2>&1); then- echo 'Expected installer to fail when detected agent plugin setup fails.' >&2- exit 1-fi-if ! grep -q 'Composio CLI was installed, but agent plugin setup failed' <<<"$failed_output"; then- echo 'Expected installer to explain how to retry failed plugin setup.' >&2- printf '%s\n' "$failed_output" >&2- exit 1-fi+ printf 'install scripts passed under %s\n' "$interpreter_name"+done-printf 'install.sh release fallback, shell integration, and plugin setup tests passed\n'+printf 'install.sh release resolution, layout, security, and shell-variant tests passed\n'diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.tsindex 699f1d247..52c7ecd5a 100644--- a/test/release-workflow.test.ts+++ b/test/release-workflow.test.ts@@ -697,9 +697,18 @@ if (!installHealthCheck.includes("| sed -n '1p'")) {'cli.install-health-check.yml must convert no matching release into empty output');}-if (!installHealthCheck.includes('bash -s -- "${{ steps.resolve.outputs.tag }}"')) {+if (!installHealthCheck.includes('sh -s -- "${{ steps.resolve.outputs.tag }}"')) {throw new Error('cli.install-health-check.yml must install the resolved tag via the pinned path');}+if (!installHealthCheck.includes('echo "$HOME/.local/bin" >> "$GITHUB_PATH"')) {+ throw new Error('cli.install-health-check.yml must expose the installer entry-point directory');+}+if (!installHealthCheck.includes('test -L "$HOME/.local/bin/composio"')) {+ throw new Error('cli.install-health-check.yml must verify the installer entry-point symlink');+}+if (installHealthCheck.includes('rm -rf "$HOME/.composio"')) {+ throw new Error('cli.install-health-check.yml must preserve CLI user state between install legs');+}const fakeBin = mkdtempSync(join(tmpdir(), 'composio-release-test-'));try {diff --git a/ts/packages/cli/test/src/analytics.events.test.ts b/ts/packages/cli/test/src/analytics.events.test.tsindex bc4ae477b..87d4dd10d 100644--- a/ts/packages/cli/test/src/analytics.events.test.ts+++ b/ts/packages/cli/test/src/analytics.events.test.ts@@ -481,13 +481,23 @@ describe('CLI analytics journey taxonomy', () => {});});- it('marks the install.sh shell-integration run as installer-origin', () => {+ it('keeps the base installer install-only and marks shell-variant delegation as installer-origin', () => {const installScript = readFileSync(new URL('../../../../../install.sh', import.meta.url),'utf8');- const installLine = installScript.split('\n').find(line => line.includes('"$exe" install'));+ expect(installScript).not.toContain('"$exe" install');- expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');+ for (const shell of ['zsh', 'bash', 'fish']) {+ const variantScript = readFileSync(+ new URL(`../../../../../install/${shell}.sh`, import.meta.url),+ 'utf8'+ );+ const installLine = variantScript+ .split('\n')+ .find(line => line.includes('"$variant_exe" install --shell'));++ expect(installLine).toContain('COMPOSIO_CLI_INVOCATION_ORIGIN=installer');+ }});});