Skip to content

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 checksums, cross-compilation, and simplified install

jkomyno5b8e7abdf3fc
diff --git a/.github/workflows/build-cli-binaries.yml b/.github/workflows/build-cli-binaries.yml
index caa0f16fc..1322abf07 100644
--- a/.github/workflows/build-cli-binaries.yml
+++ b/.github/workflows/build-cli-binaries.yml
@@ -13,24 +13,20 @@ permissions:
contents: write
jobs:
- build-binaries:
- name: Build CLI Binaries
+ build:
+ name: Build ${{ matrix.artifact }}
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, '@composio/cli@') || startsWith(github.event.release.tag_name, 'v')
- runs-on: ${{ matrix.runner }}
+ runs-on: ubuntu-latest
strategy:
matrix:
include:
- - runner: ubuntu-latest
- platform: linux-x64
+ - target: bun-linux-x64
artifact: composio-linux-x64
- - runner: depot-ubuntu-24.04-arm
- platform: linux-aarch64
+ - target: bun-linux-arm64
artifact: composio-linux-aarch64
- - runner: macos-15-intel # Intel Mac
- platform: darwin-x64
+ - target: bun-darwin-x64
artifact: composio-darwin-x64
- - runner: macos-15 # Apple Silicon Mac
- platform: darwin-aarch64
+ - target: bun-darwin-arm64
artifact: composio-darwin-aarch64
steps:
@@ -56,15 +52,9 @@ jobs:
- name: Build packages
run: pnpm build:packages
- - name: Build CLI binary
+ - name: Cross-compile CLI binary
working-directory: ts/packages/cli
- run: |
- # Use the existing build:binary script which builds for current platform
- pnpm build:binary
-
- # Create binaries directory and copy/rename the binary
- mkdir -p dist/binaries
- cp dist/composio dist/binaries/${{ matrix.artifact }}
+ run: pnpm build:binary:cross --target ${{ matrix.target }}
- name: Verify binary
working-directory: ts/packages/cli
@@ -73,6 +63,7 @@ jobs:
file dist/binaries/${{ matrix.artifact }}
- name: Test binary
+ if: startsWith(matrix.target, 'bun-linux')
working-directory: ts/packages/cli
env:
COMPOSIO_USER_API_KEY: test-dummy-api-key-for-ci
@@ -83,33 +74,46 @@ jobs:
- name: Create archive
working-directory: ts/packages/cli/dist/binaries
run: |
- # Create subdirectory structure expected by install script
- # Use a temp directory name to avoid name collision with the binary file
temp_dir="archive-${{ matrix.artifact }}"
rm -rf "$temp_dir"
mkdir -p "$temp_dir/${{ matrix.artifact }}"
cp "${{ matrix.artifact }}" "$temp_dir/${{ matrix.artifact }}/composio"
cd "$temp_dir" && zip -r "../${{ matrix.artifact }}.zip" "${{ matrix.artifact }}"
cd .. && rm -r "$temp_dir"
- ls -la
- - name: Upload binary artifact
+ - name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact }}
- path: |
- ts/packages/cli/dist/binaries/${{ matrix.artifact }}
- ts/packages/cli/dist/binaries/${{ matrix.artifact }}.zip
+ path: ts/packages/cli/dist/binaries/${{ matrix.artifact }}.zip
retention-days: 7
- - name: Create Release
- if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
+ release:
+ name: Create Release
+ needs: build
+ runs-on: ubuntu-latest
+ if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
+
+ steps:
+ - name: Download all artifacts
+ uses: actions/download-artifact@v6
+ with:
+ merge-multiple: true
+
+ - name: Generate checksums
+ run: sha256sum *.zip > checksums.txt
+
+ - name: Display checksums
+ run: cat checksums.txt
+
+ - name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}
name: ${{ github.event_name == 'workflow_dispatch' && format('CLI @composio/cli@{0} (Manual Build)', inputs.version) || github.event.release.tag_name }}
files: |
- ts/packages/cli/dist/binaries/${{ matrix.artifact }}.zip
+ *.zip
+ checksums.txt
draft: false
prerelease: ${{ github.event_name == 'workflow_dispatch' || github.event.release.prerelease || contains(github.event.release.tag_name, 'alpha') || contains(github.event.release.tag_name, 'beta') || contains(github.event.release.tag_name, 'rc') }}
generate_release_notes: true
@@ -119,17 +123,17 @@ jobs:
test-installation:
name: Test Installation
- needs: build-binaries
- if: always() && !cancelled() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
+ needs: release
+ if: always() && !cancelled() && needs.release.result == 'success'
uses: ./.github/workflows/cli.test-installation.yml
with:
version: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}
create-install-instructions:
name: Create Install Instructions
- needs: build-binaries
+ needs: release
runs-on: ubuntu-latest
- if: always() && !cancelled() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
+ if: always() && !cancelled() && needs.release.result == 'success'
steps:
- name: Checkout
@@ -179,7 +183,7 @@ jobs:
## Supported Platforms
- Linux x64
- - Linux ARM64
+ - Linux ARM64
- macOS x64 (Intel)
- macOS ARM64 (Apple Silicon)
diff --git a/install.sh b/install.sh
index 45a521da5..fbe46a8da 100644
--- a/install.sh
+++ b/install.sh
@@ -1,241 +1,191 @@
#!/usr/bin/env bash
set -euo pipefail
-platform=$(uname -ms)
-
-# Check for unsupported platforms
-case $platform in
-'MINGW64'* | 'MSYS'* | 'CYGWIN'*)
- echo "Windows installation is not supported yet. Please use WSL or install via npm:"
- echo " npm install -g @composio/cli"
- exit 1
- ;;
-esac
+COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-"ComposioHQ"}
+COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-"composio"}
+COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-"https://github.com"}
+COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-$HOME/.composio}
-# Reset
-Color_Off=''
+github_repo="$COMPOSIO_GITHUB_URL/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"
-# Regular Colors
-Red=''
-Green=''
-Dim='' # White
+# --- Colors (only when interactive) ---
-# Bold
-Bold_White=''
-Bold_Green=''
+Color_Off='' Red='' Green='' Dim='' Bold_White='' Bold_Green=''
if [[ -t 1 ]]; then
- # Reset
- Color_Off='\033[0m' # Text Reset
-
- # Regular Colors
- Red='\033[0;31m' # Red
- Green='\033[0;32m' # Green
- Dim='\033[0;2m' # White
-
- # Bold
- Bold_Green='\033[1;32m' # Bold Green
- Bold_White='\033[1m' # Bold White
+ 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
-error() {
- echo -e "${Red}error${Color_Off}:" "$@" >&2
- exit 1
-}
-
-info() {
- echo -e "${Dim}$@ ${Color_Off}"
-}
+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}"; }
-info_bold() {
- echo -e "${Bold_White}$@ ${Color_Off}"
-}
-
-success() {
- echo -e "${Green}$@ ${Color_Off}"
+tildify() {
+ if [[ $1 = $HOME/* ]]; then
+ echo "~/${1#$HOME/}"
+ else
+ echo "$1"
+ fi
}
-# Check for required tools
-command -v unzip >/dev/null ||
- error 'unzip is required to install Composio CLI'
+# --- Prerequisites ---
-command -v curl >/dev/null ||
- error 'curl is required to install Composio CLI'
+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'
+command -v git >/dev/null || error 'git is required to install Composio CLI'
if [[ $# -gt 1 ]]; then
- error 'Too many arguments, only 1 is allowed. You can specify a specific release tag to install. (e.g. "@composio/[email protected]")'
+ error 'Too many arguments. Usage: install.sh [version-tag] (e.g. "@composio/[email protected]")'
fi
-# Determine platform and architecture
+# --- Platform detection ---
+
+platform=$(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
+'MINGW64'* | 'MSYS'* | 'CYGWIN'*)
+ error 'Windows is not supported. Please use WSL or install via npm: npm install -g @composio/cli'
;;
esac
-# Check for musl on Linux
-case "$target" in
-'linux'*)
- if [ -f /etc/alpine-release ]; then
- target="$target-musl"
- fi
- ;;
+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
-# Special handling for Rosetta on macOS
+# Rosetta 2 detection on macOS
if [[ $target = darwin-x64 ]]; then
- # Is this process running in Rosetta?
- # redirect stderr to devnull to avoid error message when not running in Rosetta
if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then
target=darwin-aarch64
- info "Your shell is running in Rosetta 2. Downloading Composio CLI for $target instead"
+ info "Your shell is running in Rosetta 2. Downloading for $target instead"
fi
fi
-COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-"ComposioHQ"}
-COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-"composio"}
-COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-"https://github.com"}
-github_repo="$COMPOSIO_GITHUB_URL/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"
-
-exe_name=composio
+# --- Version resolution ---
-# Determine version to install
if [[ $# = 0 ]]; then
info "Finding latest CLI release..."
-
- # Get the latest version tag using OS-specific grep patterns
- case $platform in
- 'Darwin'*)
- # BSD/MacOS: Use extended regex with -E
- version=$(git ls-remote --tags "$github_repo" \
- | awk '{print $2}' \
- | sed 's#^refs/tags/##' \
- | sed 's#\^{}$##' \
- | grep -E "^@composio/cli@\d+\.\d+\.\d+.*" \
- | sort -V \
- | tail -n1)
- ;;
- *)
- # Unix/Linux: Use Perl-compatible regex with -P
- version=$(git ls-remote --tags "$github_repo" \
- | awk '{print $2}' \
- | sed 's#^refs/tags/##' \
- | sed 's#\^{}$##' \
- | grep -P "^@composio/cli@\d+\.\d+\.\d+.*" \
- | sort -V \
- | tail -n1)
- ;;
- esac
-
+
+ version=$(git ls-remote --tags "$github_repo" "@composio/cli@*" \
+ | awk '{print $2}' \
+ | sed 's#^refs/tags/##; s#\^{}$##' \
+ | sort -V \
+ | tail -1)
+
if [[ -z "$version" ]]; then
error "Failed to determine the latest version. Please specify a version manually."
fi
-
+
info "Found latest version: $version"
-
- composio_uri="$github_repo/releases/download/$version/composio-$target.zip"
else
version=$1
- composio_uri="$github_repo/releases/download/$version/composio-$target.zip"
fi
+# --- Download into temp directory ---
+
+tmpdir="$(mktemp -d)"
+trap 'rm -rf "$tmpdir"' EXIT
+
+archive_name="composio-$target.zip"
+archive_url="$github_repo/releases/download/$version/$archive_name"
+checksums_url="$github_repo/releases/download/$version/checksums.txt"
+
info "Installing Composio CLI $version for $target"
-COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-$HOME/.composio}
-exe=$COMPOSIO_INSTALL_DIR/composio
+info "Downloading..."
+curl --fail --location --progress-bar --output "$tmpdir/$archive_name" "$archive_url" ||
+ error "Failed to download from \"$archive_url\""
+
+# --- Checksum verification ---
+
+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}')
-if [[ ! -d $COMPOSIO_INSTALL_DIR ]]; then
- mkdir -p "$COMPOSIO_INSTALL_DIR" ||
- error "Failed to create install directory \"$COMPOSIO_INSTALL_DIR\""
+ 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
+
+ if [[ -n "$actual" && "$expected" != "$actual" ]]; then
+ error "Checksum mismatch for $archive_name\n Expected: $expected\n Actual: $actual"
+ fi
+
+ if [[ -n "$actual" ]]; then
+ info "Checksum verified"
+ fi
+ else
+ warn "No checksum entry found for $archive_name — skipping verification"
+ fi
+else
+ info "No checksums.txt in release — skipping verification"
fi
-# Download
-info "Downloading Composio CLI..."
-curl --fail --location --progress-bar --output "$exe.zip" "$composio_uri" ||
- error "Failed to download Composio CLI from \"$composio_uri\""
-
-# Extract
-info "Extracting Composio CLI..."
-unzip -oqd "$COMPOSIO_INSTALL_DIR" "$exe.zip" ||
- error 'Failed to extract Composio CLI'
-
-# Move binary to final location
-if [[ -f "$COMPOSIO_INSTALL_DIR/composio-$target/$exe_name" ]]; then
- mv "$COMPOSIO_INSTALL_DIR/composio-$target/$exe_name" "$exe" ||
- error 'Failed to move extracted binary to destination'
- rm -r "$COMPOSIO_INSTALL_DIR/composio-$target"
-elif [[ -f "$COMPOSIO_INSTALL_DIR/$exe_name" ]]; then
- mv "$COMPOSIO_INSTALL_DIR/$exe_name" "$exe" ||
- error 'Failed to move extracted binary to destination'
+# --- Extract and install ---
+
+info "Extracting..."
+unzip -oqd "$tmpdir" "$tmpdir/$archive_name" ||
+ error 'Failed to extract archive'
+
+mkdir -p "$COMPOSIO_INSTALL_DIR" ||
+ error "Failed to create install directory \"$COMPOSIO_INSTALL_DIR\""
+
+exe="$COMPOSIO_INSTALL_DIR/composio"
+
+# Handle nested directory structure (composio-<target>/composio)
+if [[ -f "$tmpdir/composio-$target/composio" ]]; then
+ mv "$tmpdir/composio-$target/composio" "$exe"
+elif [[ -f "$tmpdir/composio" ]]; then
+ mv "$tmpdir/composio" "$exe"
else
error 'Binary not found in extracted archive'
fi
chmod +x "$exe" ||
- error 'Failed to set permissions on Composio CLI executable'
+ error 'Failed to set permissions on executable'
-rm "$exe.zip"
+success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")"
-tildify() {
- if [[ $1 = $HOME/* ]]; then
- local replacement=\~/
- echo "${1/$HOME\//$replacement}"
- else
- echo "$1"
- fi
-}
+# --- Shell configuration ---
-success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")"
+echo
refresh_command=''
-
-tilde_bin_dir=$(tildify "$COMPOSIO_INSTALL_DIR")
quoted_install_dir=\"${COMPOSIO_INSTALL_DIR//\"/\\\"}\"
if [[ $quoted_install_dir = \"$HOME/* ]]; then
quoted_install_dir=${COMPOSIO_INSTALL_DIR/$HOME\//\$HOME/}
fi
-echo
-
-# Add to shell configuration
case $(basename "$SHELL") 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
- tilde_fish_config=$(tildify "$fish_config")
-
if [[ -w $fish_config ]]; then
- {
- echo -e '\n# Composio CLI'
-
- for command in "${commands[@]}"; do
- echo "$command"
- done
- } >>"$fish_config"
-
- info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_fish_config\""
-
- refresh_command="source $tilde_fish_config"
+ { echo -e '\n# Composio CLI'; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$fish_config"
+ info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$fish_config")\""
+ refresh_command="source $(tildify "$fish_config")"
else
- echo "Manually add the directory to $tilde_fish_config (or similar):"
-
- for command in "${commands[@]}"; do
- info_bold " $command"
- done
+ echo "Manually add the directory to $(tildify "$fish_config") (or similar):"
+ for cmd in "${commands[@]}"; do info_bold " $cmd"; done
fi
;;
zsh)
@@ -243,33 +193,15 @@ zsh)
"export COMPOSIO_INSTALL_DIR=$COMPOSIO_INSTALL_DIR"
"export PATH=\"$COMPOSIO_INSTALL_DIR:\$PATH\""
)
-
zsh_config=$HOME/.zshrc
- tilde_zsh_config=$(tildify "$zsh_config")
-
- # Create .zshrc if it doesn't exist and directory is writable
- if [[ ! -f $zsh_config && -w $(dirname "$zsh_config") ]]; then
- touch "$zsh_config"
- fi
-
+ if [[ ! -f $zsh_config && -w $(dirname "$zsh_config") ]]; then touch "$zsh_config"; fi
if [[ -w $zsh_config ]]; then
- {
- echo -e '\n# Composio CLI'
-
- for command in "${commands[@]}"; do
- echo "$command"
- done
- } >>"$zsh_config"
-
- info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_zsh_config\""
-
+ { echo -e '\n# Composio CLI'; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$zsh_config"
+ info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$zsh_config")\""
refresh_command="exec $SHELL"
else
- echo "Manually add the directory to $tilde_zsh_config (or similar):"
-
- for command in "${commands[@]}"; do
- info_bold " $command"
- done
+ echo "Manually add the directory to $(tildify "$zsh_config") (or similar):"
+ for cmd in "${commands[@]}"; do info_bold " $cmd"; done
fi
;;
bash)
@@ -277,51 +209,25 @@ bash)
"export COMPOSIO_INSTALL_DIR=$quoted_install_dir"
"export PATH=\"\$COMPOSIO_INSTALL_DIR:\$PATH\""
)
-
- bash_configs=(
- "$HOME/.bashrc"
- "$HOME/.bash_profile"
- )
-
+ 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"
- )
+ 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
- tilde_bash_config=$(tildify "$bash_config")
-
if [[ -w $bash_config ]]; then
- {
- echo -e '\n# Composio CLI'
-
- for command in "${commands[@]}"; do
- echo "$command"
- done
- } >>"$bash_config"
-
- info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\""
-
+ { echo -e '\n# Composio CLI'; for cmd in "${commands[@]}"; do echo "$cmd"; done; } >>"$bash_config"
+ info "Added \"$(tildify "$COMPOSIO_INSTALL_DIR")\" to \$PATH in \"$(tildify "$bash_config")\""
refresh_command="source $bash_config"
set_manually=false
break
fi
done
-
if [[ $set_manually = true ]]; then
- echo "Manually add the directory to $tilde_bash_config (or similar):"
-
- for command in "${commands[@]}"; do
- info_bold " $command"
- done
+ 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"
diff --git a/package.json b/package.json
index 5c30e97a8..b1aa98af7 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,8 @@
"scripts": {
"build": "turbo build",
"build:binary": "turbo build:binary --filter=./ts/packages/cli",
+ "build:binary:all": "turbo build:binary:all --filter=./ts/packages/cli",
+ "build:binary:checksums": "turbo build:binary:checksums --filter=./ts/packages/cli",
"install:binary": "turbo install:binary --filter=./ts/packages/cli",
"build:packages": "turbo build --filter=./ts/packages/**",
"cli:record": "turbo run record --filter=./ts/packages/cli",
diff --git a/ts/packages/cli/package.json b/ts/packages/cli/package.json
index 6e87ea292..9c6d50a76 100644
--- a/ts/packages/cli/package.json
+++ b/ts/packages/cli/package.json
@@ -27,6 +27,10 @@
"clean": "git clean -xdf node_modules",
"cli": "bun run src/bin.ts",
"build:binary": "bun run ./scripts/build-binary.ts",
+ "build:binary:cross": "bun run ./scripts/build-binary-cross.ts",
+ "build:binary:all": "bun run ./scripts/build-all-binaries.ts",
+ "build:binary:package": "bun run ./scripts/package-binaries.ts",
+ "build:binary:checksums": "bun run ./scripts/generate-checksums.ts",
"install:binary": "bun run ./scripts/install-binary.ts ./dist/composio",
"table:metrics": "bun run ./scripts/optimize-metrics-table.ts",
"mock": "bun run ./scripts/copy-mocks-from-cache.ts",
diff --git a/ts/packages/cli/scripts/build-all-binaries.ts b/ts/packages/cli/scripts/build-all-binaries.ts
new file mode 100644
index 000000000..fd35b82f8
--- /dev/null
+++ b/ts/packages/cli/scripts/build-all-binaries.ts
@@ -0,0 +1,120 @@
+import process from 'node:process';
+import {
+ Cause,
+ Config,
+ ConfigProvider,
+ Console,
+ Effect,
+ Exit,
+ Stream,
+ Logger,
+ Layer,
+ LogLevel,
+} from 'effect';
+import { Command } from '@effect/platform';
+import { BunContext, BunRuntime } from '@effect/platform-bun';
+import type { Teardown } from '@effect/platform/Runtime';
+
+/**
+ * All cross-compilation targets and their artifact names.
+ */
+const TARGETS = [
+ { target: 'bun-darwin-arm64', artifact: 'composio-darwin-aarch64' },
+ { target: 'bun-darwin-x64', artifact: 'composio-darwin-x64' },
+ { target: 'bun-linux-x64', artifact: 'composio-linux-x64' },
+ { target: 'bun-linux-arm64', artifact: 'composio-linux-aarch64' },
+] as const;
+
+function runBunBuild(target: string, outfile: string) {
+ return Effect.gen(function* () {
+ const args = [
+ 'bun',
+ 'build',
+ './src/bin.ts',
+ '--env',
+ 'DEBUG_OVERRIDE_*',
+ '--compile',
+ '--production',
+ '--target',
+ target,
+ '--outfile',
+ outfile,
+ ] as const satisfies ReadonlyArray<string>;
+
+ const cmd = Command.make(...args);
+
+ const { exitCode } = yield* cmd.pipe(
+ Command.start,
+ Effect.flatMap(process =>
+ Effect.all(
+ {
+ exitCode: process.exitCode,
+ output: Stream.merge(
+ Stream.decodeText(process.stdout, 'utf-8'),
+ Stream.decodeText(process.stderr, 'utf-8'),
+ { haltStrategy: 'left' }
+ ).pipe(
+ Stream.tap(chunk => Console.log(chunk)),
+ Stream.runDrain
+ ),
+ },
+ {
+ concurrency: 'unbounded',
+ }
+ )
+ )
+ );
+
+ if (exitCode !== 0) {
+ return yield* Effect.fail(new Error(`Failed to build binary for ${target}`));
+ }
+ });
+}
+
+/**
+ * Build all platform binaries via cross-compilation.
+ *
+ * Usage: `bun scripts/build-all-binaries.ts`
+ * Output: `dist/binaries/composio-{darwin-aarch64,darwin-x64,linux-x64,linux-aarch64}`
+ */
+export function buildAllBinaries() {
+ return Effect.gen(function* () {
+ yield* Console.log(`Building ${TARGETS.length} platform binaries...`);
+
+ for (const { target, artifact } of TARGETS) {
+ const outfile = `./dist/binaries/${artifact}`;
+ yield* Console.log(`\nBuilding ${artifact} (${target})...`);
+ yield* runBunBuild(target, outfile);
+ yield* Console.log(`Built: ${outfile}`);
+ }
+
+ yield* Console.log(`\nAll ${TARGETS.length} binaries built successfully.`);
+ });
+}
+
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
+
+const ConfigLive = Effect.gen(function* () {
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
+ Config.withDefault(LogLevel.Info)
+ );
+
+ return Logger.minimumLogLevel(logLevel);
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
+
+if (require.main === module) {
+ buildAllBinaries().pipe(
+ Effect.provide(ConfigLive),
+ Effect.provide(Logger.pretty),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.map(() => ({ message: 'Process completed successfully.' })),
+ BunRuntime.runMain({
+ teardown,
+ })
+ );
+}
diff --git a/ts/packages/cli/scripts/build-binary-cross.ts b/ts/packages/cli/scripts/build-binary-cross.ts
new file mode 100644
index 000000000..a40cea37b
--- /dev/null
+++ b/ts/packages/cli/scripts/build-binary-cross.ts
@@ -0,0 +1,139 @@
+import process from 'node:process';
+import {
+ Cause,
+ Config,
+ ConfigProvider,
+ Console,
+ Effect,
+ Exit,
+ Stream,
+ Logger,
+ Layer,
+ LogLevel,
+} from 'effect';
+import { Command } from '@effect/platform';
+import { BunContext, BunRuntime } from '@effect/platform-bun';
+import type { Teardown } from '@effect/platform/Runtime';
+
+/**
+ * Maps Bun cross-compilation targets to Composio artifact names.
+ */
+const TARGET_MAP: Record<string, string> = {
+ 'bun-darwin-arm64': 'composio-darwin-aarch64',
+ 'bun-darwin-x64': 'composio-darwin-x64',
+ 'bun-linux-x64': 'composio-linux-x64',
+ 'bun-linux-arm64': 'composio-linux-aarch64',
+};
+
+const VALID_TARGETS = Object.keys(TARGET_MAP);
+
+function parseTarget(): { target: string; artifact: string } {
+ const targetIdx = process.argv.indexOf('--target');
+ if (targetIdx === -1 || !process.argv[targetIdx + 1]) {
+ process.stderr.write(`Usage: bun scripts/build-binary-cross.ts --target <target>\n`);
+ process.stderr.write(`Valid targets: ${VALID_TARGETS.join(', ')}\n`);
+ process.exit(1);
+ }
+
+ const target = process.argv[targetIdx + 1];
+ const artifact = TARGET_MAP[target];
+ if (!artifact) {
+ process.stderr.write(`Invalid target: ${target}\n`);
+ process.stderr.write(`Valid targets: ${VALID_TARGETS.join(', ')}\n`);
+ process.exit(1);
+ }
+
+ return { target, artifact };
+}
+
+/**
+ * Cross-compile a CLI binary for a specific Bun target.
+ *
+ * Usage: `bun scripts/build-binary-cross.ts --target bun-darwin-arm64`
+ * Output: `dist/binaries/composio-darwin-aarch64`
+ */
+export function buildBinaryCross() {
+ const { target, artifact } = parseTarget();
+
+ return Effect.gen(function* () {
+ const cwd = process.cwd();
+ yield* Effect.logDebug(`Cross-compiling binary in ${cwd} for target ${target}`);
+
+ const outfile = `./dist/binaries/${artifact}`;
+
+ const args = [
+ 'bun',
+ 'build',
+ './src/bin.ts',
+ '--env',
+ 'DEBUG_OVERRIDE_*',
+ '--compile',
+ '--production',
+ '--target',
+ target,
+ '--outfile',
+ outfile,
+ ] as const satisfies ReadonlyArray<string>;
+
+ const cmd = Command.make(...args);
+
+ yield* Effect.logDebug('Running build command with', args.join(' '), '');
+
+ const { exitCode } = yield* cmd.pipe(
+ Command.start,
+ Effect.flatMap(process =>
+ Effect.all(
+ {
+ exitCode: process.exitCode,
+ output: Stream.merge(
+ Stream.decodeText(process.stdout, 'utf-8'),
+ Stream.decodeText(process.stderr, 'utf-8'),
+ { haltStrategy: 'left' }
+ ).pipe(
+ Stream.tap(chunk => Console.log(chunk)),
+ Stream.runDrain
+ ),
+ },
+ {
+ concurrency: 'unbounded',
+ }
+ )
+ )
+ );
+
+ process.exitCode = exitCode;
+
+ if (exitCode !== 0) {
+ return yield* Effect.logInfo(`Failed to cross-compile binary for ${target}`);
+ }
+
+ yield* Console.log(`Binary cross-compiled: ${outfile}`);
+ });
+}
+
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
+
+const ConfigLive = Effect.gen(function* () {
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
+ Config.withDefault(LogLevel.Info)
+ );
+
+ return Logger.minimumLogLevel(logLevel);
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
+
+if (require.main === module) {
+ buildBinaryCross().pipe(
+ Effect.provide(ConfigLive),
+ Effect.provide(Logger.pretty),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.map(() => ({ message: 'Process completed successfully.' })),
+ BunRuntime.runMain({
+ teardown,
+ })
+ );
+}
diff --git a/ts/packages/cli/scripts/generate-checksums.ts b/ts/packages/cli/scripts/generate-checksums.ts
new file mode 100644
index 000000000..9326d9a3e
--- /dev/null
+++ b/ts/packages/cli/scripts/generate-checksums.ts
@@ -0,0 +1,88 @@
+import process from 'node:process';
+import {
+ Cause,
+ Config,
+ ConfigProvider,
+ Console,
+ Effect,
+ Exit,
+ Logger,
+ Layer,
+ LogLevel,
+} from 'effect';
+import { BunContext, BunRuntime } from '@effect/platform-bun';
+import type { Teardown } from '@effect/platform/Runtime';
+import { readdir, readFile, writeFile } from 'node:fs/promises';
+import path from 'node:path';
+
+const BINARIES_DIR = './dist/binaries';
+
+/**
+ * Generate checksums.txt from all .zip files in dist/binaries/.
+ *
+ * Output format (sha256sum compatible):
+ * <sha256hex> <filename>
+ *
+ * Usage: `bun scripts/generate-checksums.ts`
+ */
+export function generateChecksums() {
+ return Effect.gen(function* () {
+ const entries = yield* Effect.tryPromise(() => readdir(BINARIES_DIR));
+ const zipFiles = entries.filter(entry => entry.endsWith('.zip')).sort();
+
+ if (zipFiles.length === 0) {
+ yield* Console.error(
+ 'No .zip files found in dist/binaries/. Run build:binary:package first.'
+ );
+ process.exitCode = 1;
+ return;
+ }
+
+ yield* Console.log(`Generating checksums for ${zipFiles.length} archives...`);
+
+ const lines: string[] = [];
+
+ for (const zipFile of zipFiles) {
+ const filePath = path.join(BINARIES_DIR, zipFile);
+ const data = yield* Effect.tryPromise(() => readFile(filePath));
+ const hashBuffer = yield* Effect.tryPromise(() => crypto.subtle.digest('SHA-256', data));
+ const hash = Array.from(new Uint8Array(hashBuffer))
+ .map(b => b.toString(16).padStart(2, '0'))
+ .join('');
+ lines.push(`${hash} ${zipFile}`);
+ yield* Console.log(` ${hash} ${zipFile}`);
+ }
+
+ const checksumsPath = path.join(BINARIES_DIR, 'checksums.txt');
+ yield* Effect.tryPromise(() => writeFile(checksumsPath, lines.join('\n') + '\n'));
+
+ yield* Console.log(`\nWritten: ${checksumsPath}`);
+ });
+}
+
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
+
+const ConfigLive = Effect.gen(function* () {
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
+ Config.withDefault(LogLevel.Info)
+ );
+
+ return Logger.minimumLogLevel(logLevel);
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
+
+if (require.main === module) {
+ generateChecksums().pipe(
+ Effect.provide(ConfigLive),
+ Effect.provide(Logger.pretty),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.map(() => ({ message: 'Process completed successfully.' })),
+ BunRuntime.runMain({
+ teardown,
+ })
+ );
+}
diff --git a/ts/packages/cli/scripts/package-binaries.ts b/ts/packages/cli/scripts/package-binaries.ts
new file mode 100644
index 000000000..ad7e9df20
--- /dev/null
+++ b/ts/packages/cli/scripts/package-binaries.ts
@@ -0,0 +1,104 @@
+import process from 'node:process';
+import {
+ Cause,
+ Config,
+ ConfigProvider,
+ Console,
+ Effect,
+ Exit,
+ Logger,
+ Layer,
+ LogLevel,
+} from 'effect';
+import { BunContext, BunRuntime } from '@effect/platform-bun';
+import type { Teardown } from '@effect/platform/Runtime';
+import { $ } from 'bun';
+import { readdir, stat } from 'node:fs/promises';
+import path from 'node:path';
+
+const BINARIES_DIR = './dist/binaries';
+
+/**
+ * Known binary artifact names (without extension).
+ */
+const ARTIFACT_NAMES = [
+ 'composio-darwin-aarch64',
+ 'composio-darwin-x64',
+ 'composio-linux-x64',
+ 'composio-linux-aarch64',
+];
+
+/**
+ * Package each raw binary in dist/binaries/ into a .zip archive.
+ *
+ * Creates a nested directory structure inside the zip:
+ * composio-<target>/composio
+ *
+ * This matches the structure expected by install.sh.
+ *
+ * Usage: `bun scripts/package-binaries.ts`
+ */
+export function packageBinaries() {
+ return Effect.gen(function* () {
+ const entries = yield* Effect.tryPromise(() => readdir(BINARIES_DIR));
+
+ const binaries = entries.filter(entry => ARTIFACT_NAMES.includes(entry));
+
+ if (binaries.length === 0) {
+ yield* Console.error('No binaries found in dist/binaries/. Run build:binary:all first.');
+ process.exitCode = 1;
+ return;
+ }
+
+ yield* Console.log(`Packaging ${binaries.length} binaries...`);
+
+ for (const binary of binaries) {
+ const binaryPath = path.join(BINARIES_DIR, binary);
+ const zipPath = path.join(BINARIES_DIR, `${binary}.zip`);
+
+ // Create nested directory structure: <artifact>/<binary-name>
+ const tempDir = path.join(BINARIES_DIR, `_pkg_${binary}`);
+ const nestedDir = path.join(tempDir, binary);
+
+ yield* Effect.tryPromise(async () => {
+ await $`mkdir -p ${nestedDir}`.quiet();
+ await $`cp ${binaryPath} ${nestedDir}/composio`.quiet();
+ await $`cd ${tempDir} && zip -r ${path.resolve(zipPath)} ${binary}`.quiet();
+ await $`rm -rf ${tempDir}`.quiet();
+ });
+
+ const zipStat = yield* Effect.tryPromise(() => stat(zipPath));
+ const sizeMB = (zipStat.size / (1024 * 1024)).toFixed(1);
+ yield* Console.log(` ${binary}.zip (${sizeMB} MB)`);
+ }
+
+ yield* Console.log(`\nAll ${binaries.length} archives created.`);
+ });
+}
+
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
+
+const ConfigLive = Effect.gen(function* () {
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
+ Config.withDefault(LogLevel.Info)
+ );
+
+ return Logger.minimumLogLevel(logLevel);
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
+
+if (require.main === module) {
+ packageBinaries().pipe(
+ Effect.provide(ConfigLive),
+ Effect.provide(Logger.pretty),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.map(() => ({ message: 'Process completed successfully.' })),
+ BunRuntime.runMain({
+ teardown,
+ })
+ );
+}
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index 2826357c4..6ca7d8d9b 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -259,6 +259,86 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
};
});
+ /**
+ * Fetch checksums.txt from a release, if available.
+ * Returns the parsed map of filename -> expected SHA-256 hash, or None if not found.
+ */
+ const fetchChecksums = (
+ release: GitHubRelease
+ ): Effect.Effect<Option.Option<Map<string, string>>, never, never> =>
+ Effect.gen(function* () {
+ const checksumsAsset = release.assets.find(a => a.name === 'checksums.txt');
+ if (!checksumsAsset) {
+ yield* Effect.logDebug('No checksums.txt found in release assets');
+ return Option.none();
+ }
+
+ const response = yield* httpClient
+ .get(checksumsAsset.browser_download_url)
+ .pipe(Effect.catchAll(() => Effect.succeed(null)));
+
+ if (!response || response.status < 200 || response.status >= 300) {
+ yield* Effect.logDebug('Failed to download checksums.txt');
+ return Option.none();
+ }
+
+ const text = yield* response.text.pipe(Effect.catchAll(() => Effect.succeed('')));
+ if (!text) {
+ return Option.none();
+ }
+
+ const checksums = new Map<string, string>();
+ for (const line of text.split('\n')) {
+ const trimmed = line.trim();
+ if (!trimmed) continue;
+ // Format: "<hash> <filename>" (two spaces, sha256sum compatible)
+ const parts = trimmed.split(/\s+/);
+ if (parts.length >= 2) {
+ checksums.set(parts[1], parts[0]);
+ }
+ }
+
+ return Option.some(checksums);
+ });
+
+ /**
+ * Verify SHA-256 checksum of downloaded data against expected hash.
+ */
+ const verifyChecksum = (
+ data: Uint8Array,
+ expectedHash: string,
+ fileName: string
+ ): Effect.Effect<void, UpgradeBinaryError> =>
+ Effect.gen(function* () {
+ const hashBuffer = yield* Effect.tryPromise({
+ try: () => {
+ // Copy into a fresh ArrayBuffer to avoid SharedArrayBuffer type incompatibility
+ const buf = new ArrayBuffer(data.byteLength);
+ new Uint8Array(buf).set(data);
+ return crypto.subtle.digest('SHA-256', buf);
+ },
+ catch: error =>
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to compute SHA-256 checksum',
+ }),
+ });
+
+ const actual = Array.from(new Uint8Array(hashBuffer))
+ .map(b => b.toString(16).padStart(2, '0'))
+ .join('');
+
+ if (actual !== expectedHash) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ message: `Checksum mismatch for ${fileName}\n Expected: ${expectedHash}\n Actual: ${actual}`,
+ })
+ );
+ }
+
+ yield* Effect.logDebug(`Checksum verified for ${fileName}`);
+ });
+
/**
* Extract binary from zip archive using FileSystem
*/
@@ -421,6 +501,20 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
const platformArch = yield* detectPlatform;
const { name, data } = yield* downloadBinary(release, platformArch);
+ yield* spinner.message('Verifying checksum...');
+
+ const checksums = yield* fetchChecksums(release);
+ if (Option.isSome(checksums)) {
+ const expectedHash = checksums.value.get(name);
+ if (expectedHash) {
+ yield* verifyChecksum(data, expectedHash, name);
+ } else {
+ yield* Effect.logDebug(
+ `No checksum entry found for ${name} — skipping verification`
+ );
+ }
+ }
+
yield* spinner.message('Extracting...');
// The temporary directory is automatically cleaned up
diff --git a/ts/packages/cli/turbo.json b/ts/packages/cli/turbo.json
index cecb90e9a..e77de002f 100644
--- a/ts/packages/cli/turbo.json
+++ b/ts/packages/cli/turbo.json
@@ -11,6 +11,24 @@
"inputs": ["$TURBO_DEFAULT$", "!test/**", "!vitest.config.ts"],
"outputs": ["dist/composio"]
},
+ "build:binary:all": {
+ "dependsOn": ["build"],
+ "inputs": ["$TURBO_DEFAULT$", "!test/**", "!vitest.config.ts"],
+ "outputs": [
+ "dist/binaries/composio-darwin-aarch64",
+ "dist/binaries/composio-darwin-x64",
+ "dist/binaries/composio-linux-x64",
+ "dist/binaries/composio-linux-aarch64"
+ ]
+ },
+ "build:binary:package": {
+ "dependsOn": ["build:binary:all"],
+ "outputs": ["dist/binaries/*.zip"]
+ },
+ "build:binary:checksums": {
+ "dependsOn": ["build:binary:package"],
+ "outputs": ["dist/binaries/checksums.txt"]
+ },
"install:binary": {
"dependsOn": ["build:binary"],
"cache": false