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): install detected agent plugins

Kshitij Jhunjhunwalafb5e97749d6e
diff --git a/install.sh b/install.sh
index 77ccf01ce..4ac559085 100755
--- a/install.sh
+++ b/install.sh
@@ -75,17 +75,30 @@ 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'
install_agent=false
+install_plugins=true
version_arg=""
+case "${COMPOSIO_INSTALL_PLUGINS:-1}" in
+1) ;;
+0) install_plugins=false ;;
+*) error 'COMPOSIO_INSTALL_PLUGINS must be 1 or 0' ;;
+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] [version-tag] (e.g. "@composio/[email protected]")'
- echo ' --agent After installing, sign up/log in as a Composio agent.'
+ 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
;;
--*)
@@ -93,7 +106,7 @@ while [[ $# -gt 0 ]]; do
;;
*)
if [[ -n "$version_arg" ]]; then
- error 'Too many arguments. Usage: install.sh [--agent] [version-tag] (e.g. "@composio/[email protected]")'
+ error 'Too many arguments. Usage: install.sh [--agent] [--no-plugins] [version-tag] (e.g. "@composio/[email protected]")'
fi
version_arg=$1
shift
@@ -391,6 +404,14 @@ else
fi
rm -f "$install_err"
+if [[ $install_plugins = true ]]; then
+ echo
+ info "Checking for supported agent hosts..."
+ if ! "$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`.'
+ fi
+fi
+
if [[ $install_agent = true ]]; then
echo
info "Setting up Composio agent login..."
diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.sh
index 752c52906..f492e4a5c 100755
--- a/test/install-sh-release-resolution.test.sh
+++ b/test/install-sh-release-resolution.test.sh
@@ -29,6 +29,7 @@ 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"
cat > "$bin_dir/curl" <<'EOF'
#!/usr/bin/env bash
@@ -144,10 +145,17 @@ fi
mkdir -p "$dest"
cat > "$dest/composio" <<'BIN'
#!/usr/bin/env bash
+set -euo pipefail
+
+printf '%s\n' "$*" >> "$TEST_COMPOSIO_LOG"
+
case "${1:-}" in
install)
exit 0
;;
+setup)
+ exit "${TEST_SETUP_EXIT:-0}"
+ ;;
--version|version)
echo 'composio fake 98.0.0'
exit 0
@@ -172,6 +180,7 @@ 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"
@@ -179,16 +188,26 @@ export TEST_VALID_TAG="$valid_tag"
export TEST_MISSING_ASSET_TAG="$missing_asset_tag"
export TEST_TAG_WITHOUT_RELEASE="$tag_without_release"
-output=$(env \
- PATH="$bin_dir:$PATH" \
- HOME="$home_dir" \
- SHELL="/bin/bash" \
- COMPOSIO_INSTALL_DIR="$install_dir" \
- COMPOSIO_GITHUB_URL='https://github.example.test' \
- COMPOSIO_GITHUB_API_BASE_URL="$api_base" \
- COMPOSIO_GITHUB_OWNER='FakeOwner' \
- COMPOSIO_GITHUB_REPO='fake-repo' \
- bash "$repo_root/install.sh" 2>&1)
+run_installer() {
+ local test_home="$1"
+ local test_install_dir="$2"
+ shift 2
+
+ 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_SETUP_EXIT="${TEST_SETUP_EXIT:-0}" \
+ bash "$repo_root/install.sh" "$@"
+}
+
+output=$(run_installer "$home_dir" "$install_dir" 2>&1)
printf '%s\n' "$output"
@@ -224,4 +243,47 @@ if grep -q "$tag_without_release" "$curl_log"; then
exit 1
fi
-printf 'install.sh release fallback test passed\n'
+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
+
+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
+
+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
+
+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.sh release fallback and plugin setup tests passed\n'
diff --git a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
index 0389705f6..70611c623 100644
--- a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+++ b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
@@ -48,6 +48,7 @@ e2e(import.meta.url, {
let claude: E2ETestResultWithFiles<'first-run.log' | 'second-run.log'>;
let codex: E2ETestResultWithFiles<'first-run.log' | 'second-run.log'>;
let unavailable: E2ETestResult;
+ let skippedUnavailable: E2ETestResult;
beforeAll(async () => {
// The shared E2E runner derives container names from Date.now(), so keep
@@ -61,6 +62,7 @@ e2e(import.meta.url, {
files: ['first-run.log', 'second-run.log'],
});
unavailable = await runCmd('composio setup --target auto --yes');
+ skippedUnavailable = await runCmd('composio setup --target auto --yes --if-present');
}, TIMEOUTS.FIXTURE);
describe.each([
@@ -116,6 +118,12 @@ e2e(import.meta.url, {
expect(unavailable.stdout).toBe('');
expect(unavailable.stderr).toContain('No supported agent host was detected');
});
+
+ it('can skip cleanly when invoked by an installer', () => {
+ expect(skippedUnavailable.exitCode).toBe(0);
+ expect(skippedUnavailable.stdout).toBe('');
+ expect(skippedUnavailable.stderr).toBe('');
+ });
});
},
});
diff --git a/ts/packages/cli/src/commands/root-help.ts b/ts/packages/cli/src/commands/root-help.ts
index c4b0750fc..e6958d763 100644
--- a/ts/packages/cli/src/commands/root-help.ts
+++ b/ts/packages/cli/src/commands/root-help.ts
@@ -874,7 +874,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
description: 'Display your account information.',
},
setup: {
- usage: 'composio setup [--target auto|claude|codex|all] [--yes]',
+ usage: 'composio setup [--target auto|claude|codex|all] [--yes] [--if-present]',
description: 'Install plugins for supported agent hosts.',
examples: [
'composio setup',
@@ -884,6 +884,10 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
options: [
{ name: '--target <target>', description: 'auto, claude, codex, or all' },
{ name: '-y, --yes', description: 'Accept setup changes without prompting' },
+ {
+ name: '--if-present',
+ description: 'Exit successfully when automatic detection finds no supported host',
+ },
],
},
version: {
diff --git a/ts/packages/cli/src/commands/setup.cmd.ts b/ts/packages/cli/src/commands/setup.cmd.ts
index 90def390e..0cccb202b 100644
--- a/ts/packages/cli/src/commands/setup.cmd.ts
+++ b/ts/packages/cli/src/commands/setup.cmd.ts
@@ -20,47 +20,59 @@ const yes = Options.boolean('yes').pipe(
Options.withDescription('Accept setup changes without prompting')
);
-const setupBaseCmd = Command.make('setup', { target, yes }, ({ target, yes }) =>
- Effect.gen(function* () {
- const ui = yield* TerminalUI;
- yield* ui.intro('composio setup');
+const ifPresent = Options.boolean('if-present').pipe(
+ Options.withDefault(false),
+ Options.withDescription('Exit successfully when automatic detection finds no supported host')
+);
- if (!yes && !isInteractiveTerminal()) {
- return yield* Effect.fail(
- new Error('Non-interactive setup requires `--yes` to approve local changes.')
- );
- }
+const setupBaseCmd = Command.make(
+ 'setup',
+ { target, yes, ifPresent },
+ ({ target, yes, ifPresent }) =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.intro('composio setup');
- const targets = yield* resolveSetupTargets(target);
- if (!yes) {
- const confirmed = yield* ui.confirm(`Install Composio for ${targets.join(' and ')}?`, {
- defaultValue: true,
- });
- if (!confirmed) {
- yield* ui.outro('Setup cancelled.');
- return;
+ if (!yes && !isInteractiveTerminal()) {
+ return yield* Effect.fail(
+ new Error('Non-interactive setup requires `--yes` to approve local changes.')
+ );
}
- }
- const results = yield* installSetupTargets(targets);
- for (const result of results) {
- let pluginMessage = `The Composio plugin for ${result.target} is already installed and enabled.`;
- if (result.plugin_changed) {
- pluginMessage = `Configured and enabled the Composio plugin for ${result.target}.`;
+ const targets = yield* resolveSetupTargets(target, { allowEmpty: ifPresent });
+ if (targets.length === 0) {
+ yield* ui.outro('No supported agent host detected; plugin setup skipped.');
+ return;
}
- yield* ui.log.success(pluginMessage);
-
- if (result.target === 'codex') {
- yield* ui.log.success('The Codex plugin includes the composio-cli skill.');
- continue;
+ if (!yes) {
+ const confirmed = yield* ui.confirm(`Install Composio for ${targets.join(' and ')}?`, {
+ defaultValue: true,
+ });
+ if (!confirmed) {
+ yield* ui.outro('Setup cancelled.');
+ return;
+ }
}
- if (!result.skill_changed) {
- yield* ui.log.success('The composio-cli skill for Claude Code is already installed.');
+
+ const results = yield* installSetupTargets(targets);
+ for (const result of results) {
+ let pluginMessage = `The Composio plugin for ${result.target} is already installed and enabled.`;
+ if (result.plugin_changed) {
+ pluginMessage = `Configured and enabled the Composio plugin for ${result.target}.`;
+ }
+ yield* ui.log.success(pluginMessage);
+
+ if (result.target === 'codex') {
+ yield* ui.log.success('The Codex plugin includes the composio-cli skill.');
+ continue;
+ }
+ if (!result.skill_changed) {
+ yield* ui.log.success('The composio-cli skill for Claude Code is already installed.');
+ }
}
- }
- yield* ui.outro('Composio setup complete.');
- })
+ yield* ui.outro('Composio setup complete.');
+ })
);
export const setupCmd = setupBaseCmd.pipe(
diff --git a/ts/packages/cli/src/services/setup.ts b/ts/packages/cli/src/services/setup.ts
index cd22b2683..ecd65468c 100644
--- a/ts/packages/cli/src/services/setup.ts
+++ b/ts/packages/cli/src/services/setup.ts
@@ -420,7 +420,10 @@ const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHos
all: ['claude', 'codex'],
};
-export const resolveSetupTargets = (target: SetupTarget) =>
+export const resolveSetupTargets = (
+ target: SetupTarget,
+ options: { readonly allowEmpty?: boolean } = {}
+) =>
Effect.gen(function* () {
const fixedTargets = FIXED_TARGETS[target];
if (fixedTargets) return fixedTargets;
@@ -434,6 +437,7 @@ export const resolveSetupTargets = (target: SetupTarget) =>
);
const detected = statuses.filter(status => status.available).map(status => status.target);
if (detected.length === 0) {
+ if (options.allowEmpty) return detected;
return yield* Effect.fail(
new Error(
'No supported agent host was detected. Install Claude Code or Codex, or pass `--target claude|codex` after installing it.'
diff --git a/ts/packages/cli/test/src/commands/setup.cmd.test.ts b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
index 05aa379b8..5e6e22301 100644
--- a/ts/packages/cli/test/src/commands/setup.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
@@ -422,6 +422,15 @@ describe('CLI: composio setup', () => {
expect(Exit.isFailure(exit)).toBe(true);
})
);
+
+ it.scoped('can skip automatic setup for installer integration', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(
+ cli(['setup', '--target', 'auto', '--yes', '--if-present'])
+ );
+ expect(Exit.isSuccess(exit)).toBe(true);
+ })
+ );
});
const conflict = makeFakeHosts({