Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 18:30 UTC
fix(cli): handle incompatible Codex plugin commands
Kshitij Jhunjhunwala committed
Jul 14, 2026 at 18:59 UTC
d004b2a309abdd5ded9bc814ef57f8d5ada5eacd
4 files changed
+120
-11
ts/e2e-tests/cli/setup-plugins/e2e.test.ts
+23
@@ -42,6 +42,17 @@ test ! -e /tmp/.agents/skills/composio-cli`
42
cp /tmp/host-state/commands.log second-run.log
43
`;
44
45
+const legacyCodexFixture = `
46
+set -eu
47
+mkdir -p /tmp/bin /tmp/host-state
48
+cp fixtures/fake-agent-host.sh /tmp/bin/codex
49
+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
54
+`;
55
+
56
e2e(import.meta.url, {
57
versions: {
58
cli: ['current'],
@@ -52,6 +63,7 @@ e2e(import.meta.url, {
63
let unavailable: E2ETestResult;
64
let skippedUnavailable: E2ETestResult;
65
let skippedUnavailableUninstall: E2ETestResult;
66
+ let legacyCodex: E2ETestResult;
67
68
beforeAll(async () => {
69
// The shared E2E runner derives container names from Date.now(), so keep
@@ -69,6 +81,7 @@ e2e(import.meta.url, {
81
skippedUnavailableUninstall = await runCmd(
82
'composio setup --uninstall --target auto --yes --if-present'
83
);
84
+ legacyCodex = await runCmd(legacyCodexFixture);
85
}, TIMEOUTS.FIXTURE);
86
87
describe.each([
@@ -146,5 +159,15 @@ e2e(import.meta.url, {
159
expect(skippedUnavailableUninstall.stderr).toBe('');
160
});
161
});
162
+
163
+ describe('Codex compatibility', () => {
164
+ it('explains how to upgrade when JSON plugin inspection is unavailable', () => {
165
+ expect(legacyCodex.exitCode).not.toBe(0);
166
+ expect(legacyCodex.stdout).toBe('');
167
+ expect(legacyCodex.stderr).toContain('requires Codex 0.139.0 or newer');
168
+ expect(legacyCodex.stderr).toContain('codex update');
169
+ expect(legacyCodex.stderr).not.toContain("unexpected argument '--json'");
170
+ });
171
+ });
172
},
173
});
ts/e2e-tests/cli/setup-plugins/fixtures/fake-agent-host.sh
+11
-1
@@ -39,7 +39,17 @@ case "$host:$command" in
39
rm -f "$state_dir/claude-plugin"
40
;;
41
"codex:--version")
42
- printf '%s\n' 'codex-cli 0.144.1'
42
+ if [ -f "$state_dir/codex-without-json" ]; then
43
+ printf '%s\n' 'codex-cli 0.137.0'
44
+ else
45
+ printf '%s\n' 'codex-cli 0.144.1'
46
+ fi
47
+ ;;
48
+ "codex:plugin marketplace list --help")
49
+ printf '%s\n' 'Usage: codex plugin marketplace list [OPTIONS]'
50
+ if [ ! -f "$state_dir/codex-without-json" ]; then
51
+ printf '%s\n' ' --json'
52
+ fi
53
;;
54
"codex:plugin marketplace list --json")
55
if [ -f "$state_dir/codex-marketplace" ]; then
ts/packages/cli/src/services/setup.ts
+41
-9
@@ -1,5 +1,6 @@
1
import { Command } from '@effect/platform';
2
import { Effect } from 'effect';
3
+import semver from 'semver';
4
import { CommandRunner, type CommandResult } from './command-runner';
5
import { SetupSkillInstaller } from './setup-skill-installer';
6
@@ -105,6 +106,7 @@ const ADAPTERS: Readonly<Record<AgentHost, SetupTargetAdapter>> = {
106
107
const ADAPTER_LIST = Object.values(ADAPTERS);
108
const SETUP_COMMAND_TIMEOUT = '2 minutes';
109
+const MINIMUM_CODEX_SETUP_VERSION = '0.139.0';
110
111
const asRecord = (value: unknown): Record<string, unknown> | undefined => {
112
if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;
@@ -238,11 +240,35 @@ const capture = (executable: string, args: ReadonlyArray<string>) =>
240
);
241
});
242
241
-const isAdapterAvailable = (adapter: SetupTargetAdapter) =>
242
- capture(adapter.executable, ['--version']).pipe(
243
- Effect.map(result => result !== undefined && result.exitCode === 0)
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
);
255
256
+const requireInspectionSupport = (adapter: SetupTargetAdapter, versionOutput?: string) =>
257
+ Effect.gen(function* () {
258
+ if (adapter.target !== 'codex') return;
259
+
260
+ const version = versionOutput?.match(/\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/)?.[0];
261
+ if (!version || !semver.valid(version) || semver.lt(version, MINIMUM_CODEX_SETUP_VERSION)) {
262
+ return yield* Effect.fail(unsupportedCodexInspectionError());
263
+ }
264
+
265
+ const result = yield* capture(adapter.executable, ['plugin', 'marketplace', 'list', '--help']);
266
+ const help = result ? `${result.stdout}\n${result.stderr}` : '';
267
+ if (result?.exitCode === 0 && /^\s*--json\b/m.test(help)) return;
268
+
269
+ return yield* Effect.fail(unsupportedCodexInspectionError());
270
+ });
271
+
272
const commandFailureSuffix = (result: CommandResult): string => {
273
const detail = result.stderr.trim() || result.stdout.trim();
274
if (detail) return `: ${detail}`;
@@ -275,11 +301,14 @@ const requireInspection = <T>(
301
return Effect.succeed(inspected);
302
};
303
278
-const inspectAdapter = (adapter: SetupTargetAdapter, knownAvailable?: boolean) =>
304
+const inspectAdapter = (
305
+ adapter: SetupTargetAdapter,
306
+ knownDetection?: { readonly available: boolean; readonly version?: string }
307
+) =>
308
Effect.gen(function* () {
309
const skillInstaller = yield* SetupSkillInstaller;
281
- const available = knownAvailable ?? (yield* isAdapterAvailable(adapter));
282
- if (!available) {
310
+ const detection = knownDetection ?? (yield* detectAdapter(adapter));
311
+ if (!detection.available) {
312
return {
313
target: adapter.target,
314
available: false,
@@ -291,6 +320,8 @@ const inspectAdapter = (adapter: SetupTargetAdapter, knownAvailable?: boolean) =
320
} satisfies InspectedSetupTarget;
321
}
322
323
+ yield* requireInspectionSupport(adapter, detection.version);
324
+
325
const [marketplaces, plugins] = yield* Effect.all([
326
capture(adapter.executable, adapter.marketplaceListArgs),
327
capture(adapter.executable, adapter.pluginListArgs),
@@ -475,6 +506,7 @@ const FIXED_TARGETS: Readonly<Partial<Record<SetupTarget, ReadonlyArray<AgentHos
506
export interface SetupTargetDetection {
507
readonly target: AgentHost;
508
readonly available: boolean;
509
+ readonly version?: string;
510
}
511
512
export const detectSetupTargets = (target: SetupTarget) =>
@@ -482,8 +514,8 @@ export const detectSetupTargets = (target: SetupTarget) =>
514
const targets = FIXED_TARGETS[target] ?? ADAPTER_LIST.map(adapter => adapter.target);
515
return yield* Effect.all(
516
targets.map(target =>
485
- isAdapterAvailable(ADAPTERS[target]).pipe(
486
- Effect.map(available => ({ target, available }) satisfies SetupTargetDetection)
517
+ detectAdapter(ADAPTERS[target]).pipe(
518
+ Effect.map(detection => ({ target, ...detection }) satisfies SetupTargetDetection)
519
)
520
)
521
);
@@ -496,7 +528,7 @@ export const inspectSetupTargets = (
528
Effect.gen(function* () {
529
const inspected = yield* Effect.forEach(
530
detections.filter(detection => detection.available),
499
- detection => inspectAdapter(ADAPTERS[detection.target], true)
531
+ detection => inspectAdapter(ADAPTERS[detection.target], detection)
532
);
533
if (!options.allowMarketplaceConflict) {
534
yield* Effect.forEach(inspected, status =>
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+45
-1
@@ -122,6 +122,8 @@ const makeFakeHosts = (
122
readonly noOp?: boolean;
123
readonly failOn?: string;
124
readonly malformedOn?: string;
125
+ readonly codexJsonInspection?: boolean;
126
+ readonly codexVersion?: string;
127
readonly marketplaceSource?: Partial<Record<AgentHost, string>>;
128
} = {}
129
) => {
@@ -155,7 +157,20 @@ const makeFakeHosts = (
157
const command = parts.join(' ');
158
if (parts[1] === '--version') {
159
if (!state[host].available) return { exitCode: 127, stderr: 'not found' };
158
- return { stdout: HOST_OUTPUT_FORMATTERS[host].version };
160
+ return {
161
+ stdout:
162
+ host === 'codex' && options.codexVersion
163
+ ? options.codexVersion
164
+ : HOST_OUTPUT_FORMATTERS[host].version,
165
+ };
166
+ }
167
+ if (command === 'codex plugin marketplace list --help') {
168
+ return {
169
+ stdout:
170
+ options.codexJsonInspection === false
171
+ ? 'Usage: codex plugin marketplace list [OPTIONS]'
172
+ : 'Usage: codex plugin marketplace list [OPTIONS]\n\n --json',
173
+ };
174
}
175
if (options.failOn && command.includes(options.failOn)) {
176
return { exitCode: 2, stderr: 'native operation failed' };
@@ -806,6 +821,35 @@ describe('CLI: composio setup', () => {
821
{ codex: { available: true } },
822
{ malformedOn: 'plugin marketplace list --json' }
823
);
824
+
825
+ const legacyCodex = makeFakeHosts(
826
+ { codex: { available: true } },
827
+ { codexJsonInspection: false, codexVersion: 'codex-cli 0.137.0' }
828
+ );
829
+ layer(TestLive({ commandRunner: legacyCodex.runner }))(
830
+ 'Codex without JSON marketplace inspection',
831
+ it => {
832
+ it.scoped('fails with an actionable upgrade message before running setup mutations', () =>
833
+ Effect.gen(function* () {
834
+ const exit = yield* Effect.exit(cli(['setup', '--target', 'codex', '--yes']));
835
+
836
+ expect(Exit.isFailure(exit)).toBe(true);
837
+ if (Exit.isFailure(exit)) {
838
+ const renderedCause = Cause.pretty(exit.cause);
839
+ expect(renderedCause).toContain('requires Codex 0.139.0 or newer');
840
+ expect(renderedCause).toContain('codex update');
841
+ expect(renderedCause).not.toContain("unexpected argument '--json'");
842
+ }
843
+ expect(legacyCodex.commands.some(parts => parts.includes('--json'))).toBe(false);
844
+ expect(
845
+ legacyCodex.commands.some(parts =>
846
+ ['add', 'install', 'enable', 'remove'].some(operation => parts.includes(operation))
847
+ )
848
+ ).toBe(false);
849
+ })
850
+ );
851
+ }
852
+ );
853
layer(TestLive({ commandRunner: malformedInspection.runner }))(
854
'malformed native inspection',
855
it => {