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.

fix(cli): honor if-present for unsupported hosts

Kshitij Jhunjhunwala20273ea66e30
diff --git a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
index 9f08751c8..f32ce36da 100644
--- a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+++ b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
@@ -53,6 +53,11 @@ export PATH=/tmp/bin:$PATH
composio setup --target auto --yes
`;
+const legacyCodexIfPresentFixture = legacyCodexFixture.replace(
+ 'composio setup --target auto --yes',
+ 'composio setup --target auto --yes --if-present'
+);
+
const legacyClaudeFixture = `
set -eu
mkdir -p /tmp/bin /tmp/host-state
@@ -119,6 +124,7 @@ e2e(import.meta.url, {
let skippedUnavailableUninstall: E2ETestResult;
let legacyClaude: E2ETestResult;
let legacyCodex: E2ETestResult;
+ let legacyCodexIfPresent: E2ETestResult;
let claudeWithLegacyCodex: E2ETestResult;
let codexWithLegacyClaude: E2ETestResult;
let failedClaudeInspection: E2ETestResult;
@@ -141,6 +147,7 @@ e2e(import.meta.url, {
);
legacyClaude = await runCmd(legacyClaudeFixture);
legacyCodex = await runCmd(legacyCodexFixture);
+ legacyCodexIfPresent = await runCmd(legacyCodexIfPresentFixture);
claudeWithLegacyCodex = await runCmd(claudeWithLegacyCodexFixture);
codexWithLegacyClaude = await runCmd(codexWithLegacyClaudeFixture);
failedClaudeInspection = await runCmd(failedClaudeInspectionFixture);
@@ -238,6 +245,12 @@ e2e(import.meta.url, {
expect(legacyCodex.stderr).not.toContain("unexpected argument '--json'");
});
+ it('skips an unsupported-only host when invoked by an installer', () => {
+ expect(legacyCodexIfPresent.exitCode).toBe(0);
+ expect(legacyCodexIfPresent.stdout).toBe('');
+ expect(legacyCodexIfPresent.stderr).toBe('');
+ });
+
it('continues with Claude when Codex is unsupported', () => {
expect(claudeWithLegacyCodex.exitCode).toBe(0);
expect(claudeWithLegacyCodex.stdout).toBe('');
diff --git a/ts/packages/cli/src/commands/setup.cmd.ts b/ts/packages/cli/src/commands/setup.cmd.ts
index dd36adc4c..4210e07ba 100644
--- a/ts/packages/cli/src/commands/setup.cmd.ts
+++ b/ts/packages/cli/src/commands/setup.cmd.ts
@@ -82,12 +82,21 @@ const setupBaseCmd = Command.make(
.map(result => result.unsupportedReason)
.filter((message): message is string => Boolean(message))
.join(' ');
- if (target !== 'auto' || supported.length === 0) {
+ if (target !== 'auto') {
return yield* Effect.fail(new Error(reason));
}
yield* ui.log.warn(
`${formatTargets(unsupported.map(result => result.target))} plugin setup skipped. ${reason}`
);
+ if (supported.length === 0) {
+ if (ifPresent) {
+ yield* ui.outro(
+ `No supported agent host detected; plugin ${uninstall ? 'uninstall' : 'setup'} skipped.`
+ );
+ return;
+ }
+ return yield* Effect.fail(new Error(reason));
+ }
}
if (detected.length === 0) {
if (target === 'claude' || target === 'codex') {
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 2f9db37a7..284f05de2 100644
--- a/ts/packages/cli/test/src/commands/setup.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
@@ -1003,6 +1003,20 @@ describe('CLI: composio setup', () => {
})
);
+ it.scoped('skips cleanly for installer integration when no supported host remains', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(
+ cli(['setup', '--target', 'auto', '--yes', '--if-present'])
+ );
+
+ expect(Exit.isSuccess(exit)).toBe(true);
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('Codex plugin setup skipped.');
+ expect(output).toContain('No supported agent host detected; plugin setup skipped.');
+ expect(legacyCodex.commands.some(parts => parts.includes('--json'))).toBe(false);
+ })
+ );
+
it.scoped('fails with an actionable upgrade message before running setup mutations', () =>
Effect.gen(function* () {
const exit = yield* Effect.exit(cli(['setup', '--target', 'codex', '--yes']));