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): continue setup with supported hosts

Kshitij Jhunjhunwala460f804dd145
diff --git a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
index 4bde9dd87..ff03fabc6 100644
--- a/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+++ b/ts/e2e-tests/cli/setup-plugins/e2e.test.ts
@@ -50,7 +50,25 @@ chmod +x /tmp/bin/codex
touch /tmp/host-state/codex-without-json
export HOST_STATE_DIR=/tmp/host-state
export PATH=/tmp/bin:$PATH
-composio setup --target codex --yes
+composio setup --target auto --yes
+`;
+
+const claudeWithLegacyCodexFixture = `
+set -eu
+mkdir -p /tmp/bin /tmp/host-state
+cp fixtures/fake-agent-host.sh /tmp/bin/claude
+cp fixtures/fake-agent-host.sh /tmp/bin/codex
+chmod +x /tmp/bin/claude /tmp/bin/codex
+touch /tmp/host-state/codex-without-json
+mkdir -p /tmp/.claude/skills /tmp/.agents/skills/composio-cli
+printf '%s\n' '# composio-cli' > /tmp/.agents/skills/composio-cli/SKILL.md
+printf '@composio/cli@%s\n' "$(composio --version)" > /tmp/.agents/skills/composio-cli/.composio-release-tag
+ln -s ../../.agents/skills/composio-cli /tmp/.claude/skills/composio-cli
+export HOST_STATE_DIR=/tmp/host-state
+export PATH=/tmp/bin:$PATH
+composio setup --target auto --yes
+test -f /tmp/host-state/claude-plugin
+test ! -f /tmp/host-state/codex-plugin
`;
e2e(import.meta.url, {
@@ -64,6 +82,7 @@ e2e(import.meta.url, {
let skippedUnavailable: E2ETestResult;
let skippedUnavailableUninstall: E2ETestResult;
let legacyCodex: E2ETestResult;
+ let claudeWithLegacyCodex: E2ETestResult;
beforeAll(async () => {
// The shared E2E runner derives container names from Date.now(), so keep
@@ -82,6 +101,7 @@ e2e(import.meta.url, {
'composio setup --uninstall --target auto --yes --if-present'
);
legacyCodex = await runCmd(legacyCodexFixture);
+ claudeWithLegacyCodex = await runCmd(claudeWithLegacyCodexFixture);
}, TIMEOUTS.FIXTURE);
describe.each([
@@ -161,13 +181,19 @@ e2e(import.meta.url, {
});
describe('Codex compatibility', () => {
- it('explains how to upgrade when JSON plugin inspection is unavailable', () => {
+ it('exits with upgrade instructions when no supported host remains', () => {
expect(legacyCodex.exitCode).not.toBe(0);
expect(legacyCodex.stdout).toBe('');
expect(legacyCodex.stderr).toContain('requires Codex 0.139.0 or newer');
expect(legacyCodex.stderr).toContain('codex update');
expect(legacyCodex.stderr).not.toContain("unexpected argument '--json'");
});
+
+ it('continues with Claude when Codex is unsupported', () => {
+ expect(claudeWithLegacyCodex.exitCode).toBe(0);
+ expect(claudeWithLegacyCodex.stdout).toBe('');
+ expect(claudeWithLegacyCodex.stderr).toBe('');
+ });
});
},
});
diff --git a/ts/packages/cli/src/commands/setup.cmd.ts b/ts/packages/cli/src/commands/setup.cmd.ts
index 6d9f898ec..05a36eb36 100644
--- a/ts/packages/cli/src/commands/setup.cmd.ts
+++ b/ts/packages/cli/src/commands/setup.cmd.ts
@@ -54,6 +54,8 @@ const setupBaseCmd = Command.make(
const detections = yield* detectSetupTargets(target);
const detected = detections.filter(result => result.available).map(result => result.target);
+ const supported = detections.filter(result => result.available && result.supported);
+ const unsupported = detections.filter(result => result.available && !result.supported);
const notDetected = detections
.filter(result => !result.available)
.map(result => result.target);
@@ -71,6 +73,18 @@ const setupBaseCmd = Command.make(
)
);
}
+ if (unsupported.length > 0) {
+ const reason = unsupported
+ .map(result => result.unsupportedReason)
+ .filter((message): message is string => Boolean(message))
+ .join(' ');
+ if (target !== 'auto' || supported.length === 0) {
+ return yield* Effect.fail(new Error(reason));
+ }
+ yield* ui.log.warn(
+ `${formatTargets(unsupported.map(result => result.target))} plugin setup skipped. ${reason}`
+ );
+ }
if (detected.length === 0) {
if (target === 'claude' || target === 'codex') {
return yield* Effect.fail(
diff --git a/ts/packages/cli/src/services/setup.ts b/ts/packages/cli/src/services/setup.ts
index b6a902535..908027d43 100644
--- a/ts/packages/cli/src/services/setup.ts
+++ b/ts/packages/cli/src/services/setup.ts
@@ -240,33 +240,43 @@ const capture = (executable: string, args: ReadonlyArray<string>) =>
);
});
-const detectAdapter = (adapter: SetupTargetAdapter) =>
- Effect.gen(function* () {
- const result = yield* capture(adapter.executable, ['--version']);
- const available = result !== undefined && result.exitCode === 0;
- const version = available ? result.stdout.trim() || result.stderr.trim() : '';
- return version ? { available, version } : { available };
- });
-
-const unsupportedCodexInspectionError = () =>
- new Error(
- `This Codex installation does not support safe automatic plugin inspection. Composio setup requires Codex ${MINIMUM_CODEX_SETUP_VERSION} or newer with JSON plugin inspection. Run \`codex update\`, then rerun this command.`
- );
+const unsupportedCodexInspectionMessage = () =>
+ `This Codex installation does not support safe automatic plugin inspection. Composio setup requires Codex ${MINIMUM_CODEX_SETUP_VERSION} or newer with JSON plugin inspection. Run \`codex update\`, then rerun this command.`;
-const requireInspectionSupport = (adapter: SetupTargetAdapter, versionOutput?: string) =>
+const supportsInspection = (adapter: SetupTargetAdapter, versionOutput?: string) =>
Effect.gen(function* () {
- if (adapter.target !== 'codex') return;
+ if (adapter.target !== 'codex') return true;
const version = versionOutput?.match(/\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/)?.[0];
if (!version || !semver.valid(version) || semver.lt(version, MINIMUM_CODEX_SETUP_VERSION)) {
- return yield* Effect.fail(unsupportedCodexInspectionError());
+ return false;
}
const result = yield* capture(adapter.executable, ['plugin', 'marketplace', 'list', '--help']);
const help = result ? `${result.stdout}\n${result.stderr}` : '';
- if (result?.exitCode === 0 && /^\s*--json\b/m.test(help)) return;
+ return result?.exitCode === 0 && /^\s*--json\b/m.test(help);
+ });
- return yield* Effect.fail(unsupportedCodexInspectionError());
+const detectAdapter = (adapter: SetupTargetAdapter) =>
+ Effect.gen(function* () {
+ const result = yield* capture(adapter.executable, ['--version']);
+ const available = result !== undefined && result.exitCode === 0;
+ if (!available) return { available, supported: false };
+
+ const version = result.stdout.trim() || result.stderr.trim();
+ const supported = yield* supportsInspection(adapter, version);
+ return version
+ ? {
+ available,
+ supported,
+ version,
+ ...(supported ? {} : { unsupportedReason: unsupportedCodexInspectionMessage() }),
+ }
+ : {
+ available,
+ supported,
+ ...(supported ? {} : { unsupportedReason: unsupportedCodexInspectionMessage() }),
+ };
});
const commandFailureSuffix = (result: CommandResult): string => {
@@ -303,7 +313,11 @@ const requireInspection = <T>(
const inspectAdapter = (
adapter: SetupTargetAdapter,
- knownDetection?: { readonly available: boolean; readonly version?: string }
+ knownDetection?: {
+ readonly available: boolean;
+ readonly supported: boolean;
+ readonly version?: string;
+ }
) =>
Effect.gen(function* () {
const skillInstaller = yield* SetupSkillInstaller;
@@ -320,7 +334,9 @@ const inspectAdapter = (
} satisfies InspectedSetupTarget;
}
- yield* requireInspectionSupport(adapter, detection.version);
+ if (!detection.supported) {
+ return yield* Effect.fail(new Error(unsupportedCodexInspectionMessage()));
+ }
const [marketplaces, plugins] = yield* Effect.all([
capture(adapter.executable, adapter.marketplaceListArgs),
@@ -506,7 +522,9 @@ const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHos
export interface SetupTargetDetection {
readonly target: AgentHost;
readonly available: boolean;
+ readonly supported: boolean;
readonly version?: string;
+ readonly unsupportedReason?: string;
}
export const detectSetupTargets = (target: SetupTarget) =>
@@ -515,7 +533,7 @@ export const detectSetupTargets = (target: SetupTarget) =>
return yield* Effect.all(
targets.map(target =>
detectAdapter(ADAPTERS[target]).pipe(
- Effect.map(detection => ({ target, ...detection }) satisfies SetupTargetDetection)
+ Effect.map((detection): SetupTargetDetection => ({ target, ...detection }))
)
)
);
@@ -527,7 +545,7 @@ export const inspectSetupTargets = (
) =>
Effect.gen(function* () {
const inspected = yield* Effect.forEach(
- detections.filter(detection => detection.available),
+ detections.filter(detection => detection.available && detection.supported),
detection => inspectAdapter(ADAPTERS[detection.target], detection)
);
if (!options.allowMarketplaceConflict) {
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 31b8a628d..5519f0d0c 100644
--- a/ts/packages/cli/test/src/commands/setup.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/setup.cmd.test.ts
@@ -394,6 +394,26 @@ describe('CLI: composio setup', () => {
);
});
+ const autoCodex = makeFakeHosts({ codex: { available: true } });
+ layer(TestLive({ commandRunner: autoCodex.runner }))(
+ 'automatic setup with only supported Codex',
+ it => {
+ it.scoped('installs Codex when Claude is not detected', () =>
+ Effect.gen(function* () {
+ yield* cli(['setup', '--target', 'auto', '--yes']);
+
+ expect(autoCodex.state.codex).toMatchObject({
+ marketplace: 'canonical',
+ plugin: 'enabled',
+ });
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('Codex detected.');
+ expect(output).toContain('Claude Code not detected.');
+ })
+ );
+ }
+ );
+
const autoBoth = makeFakeHosts({
claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
@@ -422,6 +442,48 @@ describe('CLI: composio setup', () => {
);
});
+ const autoClaudeWithLegacyCodex = makeFakeHosts(
+ {
+ claude: { available: true },
+ codex: { available: true },
+ },
+ { codexJsonInspection: false, codexVersion: 'codex-cli 0.137.0' }
+ );
+ layer(
+ TestLive({
+ commandRunner: autoClaudeWithLegacyCodex.runner,
+ setupSkillInstaller: makeSkillInstaller(),
+ })
+ )('automatic setup with Claude and unsupported Codex', it => {
+ it.scoped('installs Claude and reports that Codex was skipped', () =>
+ Effect.gen(function* () {
+ yield* cli(['setup', '--target', 'auto', '--yes']);
+
+ expect(autoClaudeWithLegacyCodex.state.claude).toMatchObject({
+ marketplace: 'canonical',
+ plugin: 'enabled',
+ });
+ expect(autoClaudeWithLegacyCodex.state.codex).toMatchObject({
+ marketplace: 'missing',
+ plugin: 'missing',
+ });
+ expect(
+ autoClaudeWithLegacyCodex.commands.some(
+ parts => parts[0] === 'codex' && parts.includes('--json')
+ )
+ ).toBe(false);
+
+ const output = (yield* MockConsole.getLines()).join('\n');
+ expect(output).toContain('Claude Code and Codex detected.');
+ expect(output).toContain('Codex plugin setup skipped.');
+ expect(output).toContain('requires Codex 0.139.0 or newer');
+ expect(output).toContain(
+ 'Successfully installed and enabled the Composio plugin for Claude Code.'
+ );
+ })
+ );
+ });
+
const allTargets = makeFakeHosts({
claude: { available: true },
codex: { available: true },
@@ -471,6 +533,32 @@ describe('CLI: composio setup', () => {
}
);
+ const allWithLegacyCodex = makeFakeHosts(
+ {
+ claude: { available: true },
+ codex: { available: true },
+ },
+ { codexJsonInspection: false, codexVersion: 'codex-cli 0.137.0' }
+ );
+ layer(
+ TestLive({
+ commandRunner: allWithLegacyCodex.runner,
+ setupSkillInstaller: makeSkillInstaller(),
+ })
+ )('explicit all-host setup with unsupported Codex', it => {
+ it.scoped('fails before mutating Claude', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(cli(['setup', '--target', 'all', '--yes']));
+
+ expect(Exit.isFailure(exit)).toBe(true);
+ expect(allWithLegacyCodex.state.claude).toMatchObject({
+ marketplace: 'missing',
+ plugin: 'missing',
+ });
+ })
+ );
+ });
+
const uninstallBoth = makeFakeHosts({
claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
@@ -829,6 +917,17 @@ describe('CLI: composio setup', () => {
layer(TestLive({ commandRunner: legacyCodex.runner }))(
'Codex without JSON marketplace inspection',
it => {
+ it.scoped('fails automatic setup when no supported host remains', () =>
+ Effect.gen(function* () {
+ const exit = yield* Effect.exit(cli(['setup', '--target', 'auto', '--yes']));
+
+ expect(Exit.isFailure(exit)).toBe(true);
+ if (Exit.isFailure(exit)) {
+ expect(Cause.pretty(exit.cause)).toContain('requires Codex 0.139.0 or newer');
+ }
+ })
+ );
+
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']));