@devries-cameron20 / composio-1 / commits / 460f804dd
Fork 0

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 Jhunjhunwala committed Jul 14, 2026 at 19:06 UTC 460f804dd145587a376257734d1284dbb6206e92
4 files changed +180 -23
ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+28 -2
@@ -50,7 +50,25 @@ chmod +x /tmp/bin/codex
50 touch /tmp/host-state/codex-without-json
51 export HOST_STATE_DIR=/tmp/host-state
52 export PATH=/tmp/bin:$PATH
53 -composio setup --target codex --yes
53 +composio setup --target auto --yes
54 +`;
55 +
56 +const claudeWithLegacyCodexFixture = `
57 +set -eu
58 +mkdir -p /tmp/bin /tmp/host-state
59 +cp fixtures/fake-agent-host.sh /tmp/bin/claude
60 +cp fixtures/fake-agent-host.sh /tmp/bin/codex
61 +chmod +x /tmp/bin/claude /tmp/bin/codex
62 +touch /tmp/host-state/codex-without-json
63 +mkdir -p /tmp/.claude/skills /tmp/.agents/skills/composio-cli
64 +printf '%s\n' '# composio-cli' > /tmp/.agents/skills/composio-cli/SKILL.md
65 +printf '@composio/cli@%s\n' "$(composio --version)" > /tmp/.agents/skills/composio-cli/.composio-release-tag
66 +ln -s ../../.agents/skills/composio-cli /tmp/.claude/skills/composio-cli
67 +export HOST_STATE_DIR=/tmp/host-state
68 +export PATH=/tmp/bin:$PATH
69 +composio setup --target auto --yes
70 +test -f /tmp/host-state/claude-plugin
71 +test ! -f /tmp/host-state/codex-plugin
72 `;
73
74 e2e(import.meta.url, {
@@ -64,6 +82,7 @@ e2e(import.meta.url, {
82 let skippedUnavailable: E2ETestResult;
83 let skippedUnavailableUninstall: E2ETestResult;
84 let legacyCodex: E2ETestResult;
85 + let claudeWithLegacyCodex: E2ETestResult;
86
87 beforeAll(async () => {
88 // The shared E2E runner derives container names from Date.now(), so keep
@@ -82,6 +101,7 @@ e2e(import.meta.url, {
101 'composio setup --uninstall --target auto --yes --if-present'
102 );
103 legacyCodex = await runCmd(legacyCodexFixture);
104 + claudeWithLegacyCodex = await runCmd(claudeWithLegacyCodexFixture);
105 }, TIMEOUTS.FIXTURE);
106
107 describe.each([
@@ -161,13 +181,19 @@ e2e(import.meta.url, {
181 });
182
183 describe('Codex compatibility', () => {
164 - it('explains how to upgrade when JSON plugin inspection is unavailable', () => {
184 + it('exits with upgrade instructions when no supported host remains', () => {
185 expect(legacyCodex.exitCode).not.toBe(0);
186 expect(legacyCodex.stdout).toBe('');
187 expect(legacyCodex.stderr).toContain('requires Codex 0.139.0 or newer');
188 expect(legacyCodex.stderr).toContain('codex update');
189 expect(legacyCodex.stderr).not.toContain("unexpected argument '--json'");
190 });
191 +
192 + it('continues with Claude when Codex is unsupported', () => {
193 + expect(claudeWithLegacyCodex.exitCode).toBe(0);
194 + expect(claudeWithLegacyCodex.stdout).toBe('');
195 + expect(claudeWithLegacyCodex.stderr).toBe('');
196 + });
197 });
198 },
199 });
ts/packages/cli/src/commands/setup.cmd.ts
+14
@@ -54,6 +54,8 @@ const setupBaseCmd = Command.make(
54
55 const detections = yield* detectSetupTargets(target);
56 const detected = detections.filter(result => result.available).map(result => result.target);
57 + const supported = detections.filter(result => result.available && result.supported);
58 + const unsupported = detections.filter(result => result.available && !result.supported);
59 const notDetected = detections
60 .filter(result => !result.available)
61 .map(result => result.target);
@@ -71,6 +73,18 @@ const setupBaseCmd = Command.make(
73 )
74 );
75 }
76 + if (unsupported.length > 0) {
77 + const reason = unsupported
78 + .map(result => result.unsupportedReason)
79 + .filter((message): message is string => Boolean(message))
80 + .join(' ');
81 + if (target !== 'auto' || supported.length === 0) {
82 + return yield* Effect.fail(new Error(reason));
83 + }
84 + yield* ui.log.warn(
85 + `${formatTargets(unsupported.map(result => result.target))} plugin setup skipped. ${reason}`
86 + );
87 + }
88 if (detected.length === 0) {
89 if (target === 'claude' || target === 'codex') {
90 return yield* Effect.fail(
ts/packages/cli/src/services/setup.ts
+39 -21
@@ -240,33 +240,43 @@ const capture = (executable: string, args: ReadonlyArray<string>) =>
240 );
241 });
242
243 -const detectAdapter = (adapter: SetupTargetAdapter) =>
244 - Effect.gen(function* () {
245 - const result = yield* capture(adapter.executable, ['--version']);
246 - const available = result !== undefined && result.exitCode === 0;
247 - const version = available ? result.stdout.trim() || result.stderr.trim() : '';
248 - return version ? { available, version } : { available };
249 - });
250 -
251 -const unsupportedCodexInspectionError = () =>
252 - new Error(
253 - `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.`
254 - );
243 +const unsupportedCodexInspectionMessage = () =>
244 + `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.`;
245
256 -const requireInspectionSupport = (adapter: SetupTargetAdapter, versionOutput?: string) =>
246 +const supportsInspection = (adapter: SetupTargetAdapter, versionOutput?: string) =>
247 Effect.gen(function* () {
258 - if (adapter.target !== 'codex') return;
248 + if (adapter.target !== 'codex') return true;
249
250 const version = versionOutput?.match(/\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/)?.[0];
251 if (!version || !semver.valid(version) || semver.lt(version, MINIMUM_CODEX_SETUP_VERSION)) {
262 - return yield* Effect.fail(unsupportedCodexInspectionError());
252 + return false;
253 }
254
255 const result = yield* capture(adapter.executable, ['plugin', 'marketplace', 'list', '--help']);
256 const help = result ? `${result.stdout}\n${result.stderr}` : '';
267 - if (result?.exitCode === 0 && /^\s*--json\b/m.test(help)) return;
257 + return result?.exitCode === 0 && /^\s*--json\b/m.test(help);
258 + });
259
269 - return yield* Effect.fail(unsupportedCodexInspectionError());
260 +const detectAdapter = (adapter: SetupTargetAdapter) =>
261 + Effect.gen(function* () {
262 + const result = yield* capture(adapter.executable, ['--version']);
263 + const available = result !== undefined && result.exitCode === 0;
264 + if (!available) return { available, supported: false };
265 +
266 + const version = result.stdout.trim() || result.stderr.trim();
267 + const supported = yield* supportsInspection(adapter, version);
268 + return version
269 + ? {
270 + available,
271 + supported,
272 + version,
273 + ...(supported ? {} : { unsupportedReason: unsupportedCodexInspectionMessage() }),
274 + }
275 + : {
276 + available,
277 + supported,
278 + ...(supported ? {} : { unsupportedReason: unsupportedCodexInspectionMessage() }),
279 + };
280 });
281
282 const commandFailureSuffix = (result: CommandResult): string => {
@@ -303,7 +313,11 @@ const requireInspection = <T>(
313
314 const inspectAdapter = (
315 adapter: SetupTargetAdapter,
306 - knownDetection?: { readonly available: boolean; readonly version?: string }
316 + knownDetection?: {
317 + readonly available: boolean;
318 + readonly supported: boolean;
319 + readonly version?: string;
320 + }
321 ) =>
322 Effect.gen(function* () {
323 const skillInstaller = yield* SetupSkillInstaller;
@@ -320,7 +334,9 @@ const inspectAdapter = (
334 } satisfies InspectedSetupTarget;
335 }
336
323 - yield* requireInspectionSupport(adapter, detection.version);
337 + if (!detection.supported) {
338 + return yield* Effect.fail(new Error(unsupportedCodexInspectionMessage()));
339 + }
340
341 const [marketplaces, plugins] = yield* Effect.all([
342 capture(adapter.executable, adapter.marketplaceListArgs),
@@ -506,7 +522,9 @@ const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHos
522 export interface SetupTargetDetection {
523 readonly target: AgentHost;
524 readonly available: boolean;
525 + readonly supported: boolean;
526 readonly version?: string;
527 + readonly unsupportedReason?: string;
528 }
529
530 export const detectSetupTargets = (target: SetupTarget) =>
@@ -515,7 +533,7 @@ export const detectSetupTargets = (target: SetupTarget) =>
533 return yield* Effect.all(
534 targets.map(target =>
535 detectAdapter(ADAPTERS[target]).pipe(
518 - Effect.map(detection => ({ target, ...detection }) satisfies SetupTargetDetection)
536 + Effect.map((detection): SetupTargetDetection => ({ target, ...detection }))
537 )
538 )
539 );
@@ -527,7 +545,7 @@ export const inspectSetupTargets = (
545 ) =>
546 Effect.gen(function* () {
547 const inspected = yield* Effect.forEach(
530 - detections.filter(detection => detection.available),
548 + detections.filter(detection => detection.available && detection.supported),
549 detection => inspectAdapter(ADAPTERS[detection.target], detection)
550 );
551 if (!options.allowMarketplaceConflict) {
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+99
@@ -394,6 +394,26 @@ describe('CLI: composio setup', () => {
394 );
395 });
396
397 + const autoCodex = makeFakeHosts({ codex: { available: true } });
398 + layer(TestLive({ commandRunner: autoCodex.runner }))(
399 + 'automatic setup with only supported Codex',
400 + it => {
401 + it.scoped('installs Codex when Claude is not detected', () =>
402 + Effect.gen(function* () {
403 + yield* cli(['setup', '--target', 'auto', '--yes']);
404 +
405 + expect(autoCodex.state.codex).toMatchObject({
406 + marketplace: 'canonical',
407 + plugin: 'enabled',
408 + });
409 + const output = (yield* MockConsole.getLines()).join('\n');
410 + expect(output).toContain('Codex detected.');
411 + expect(output).toContain('Claude Code not detected.');
412 + })
413 + );
414 + }
415 + );
416 +
417 const autoBoth = makeFakeHosts({
418 claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
419 codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
@@ -422,6 +442,48 @@ describe('CLI: composio setup', () => {
442 );
443 });
444
445 + const autoClaudeWithLegacyCodex = makeFakeHosts(
446 + {
447 + claude: { available: true },
448 + codex: { available: true },
449 + },
450 + { codexJsonInspection: false, codexVersion: 'codex-cli 0.137.0' }
451 + );
452 + layer(
453 + TestLive({
454 + commandRunner: autoClaudeWithLegacyCodex.runner,
455 + setupSkillInstaller: makeSkillInstaller(),
456 + })
457 + )('automatic setup with Claude and unsupported Codex', it => {
458 + it.scoped('installs Claude and reports that Codex was skipped', () =>
459 + Effect.gen(function* () {
460 + yield* cli(['setup', '--target', 'auto', '--yes']);
461 +
462 + expect(autoClaudeWithLegacyCodex.state.claude).toMatchObject({
463 + marketplace: 'canonical',
464 + plugin: 'enabled',
465 + });
466 + expect(autoClaudeWithLegacyCodex.state.codex).toMatchObject({
467 + marketplace: 'missing',
468 + plugin: 'missing',
469 + });
470 + expect(
471 + autoClaudeWithLegacyCodex.commands.some(
472 + parts => parts[0] === 'codex' && parts.includes('--json')
473 + )
474 + ).toBe(false);
475 +
476 + const output = (yield* MockConsole.getLines()).join('\n');
477 + expect(output).toContain('Claude Code and Codex detected.');
478 + expect(output).toContain('Codex plugin setup skipped.');
479 + expect(output).toContain('requires Codex 0.139.0 or newer');
480 + expect(output).toContain(
481 + 'Successfully installed and enabled the Composio plugin for Claude Code.'
482 + );
483 + })
484 + );
485 + });
486 +
487 const allTargets = makeFakeHosts({
488 claude: { available: true },
489 codex: { available: true },
@@ -471,6 +533,32 @@ describe('CLI: composio setup', () => {
533 }
534 );
535
536 + const allWithLegacyCodex = makeFakeHosts(
537 + {
538 + claude: { available: true },
539 + codex: { available: true },
540 + },
541 + { codexJsonInspection: false, codexVersion: 'codex-cli 0.137.0' }
542 + );
543 + layer(
544 + TestLive({
545 + commandRunner: allWithLegacyCodex.runner,
546 + setupSkillInstaller: makeSkillInstaller(),
547 + })
548 + )('explicit all-host setup with unsupported Codex', it => {
549 + it.scoped('fails before mutating Claude', () =>
550 + Effect.gen(function* () {
551 + const exit = yield* Effect.exit(cli(['setup', '--target', 'all', '--yes']));
552 +
553 + expect(Exit.isFailure(exit)).toBe(true);
554 + expect(allWithLegacyCodex.state.claude).toMatchObject({
555 + marketplace: 'missing',
556 + plugin: 'missing',
557 + });
558 + })
559 + );
560 + });
561 +
562 const uninstallBoth = makeFakeHosts({
563 claude: { available: true, marketplace: 'canonical', plugin: 'enabled' },
564 codex: { available: true, marketplace: 'canonical', plugin: 'enabled' },
@@ -829,6 +917,17 @@ describe('CLI: composio setup', () => {
917 layer(TestLive({ commandRunner: legacyCodex.runner }))(
918 'Codex without JSON marketplace inspection',
919 it => {
920 + it.scoped('fails automatic setup when no supported host remains', () =>
921 + Effect.gen(function* () {
922 + const exit = yield* Effect.exit(cli(['setup', '--target', 'auto', '--yes']));
923 +
924 + expect(Exit.isFailure(exit)).toBe(true);
925 + if (Exit.isFailure(exit)) {
926 + expect(Cause.pretty(exit.cause)).toContain('requires Codex 0.139.0 or newer');
927 + }
928 + })
929 + );
930 +
931 it.scoped('fails with an actionable upgrade message before running setup mutations', () =>
932 Effect.gen(function* () {
933 const exit = yield* Effect.exit(cli(['setup', '--target', 'codex', '--yes']));