Skip to content

Commit b04f1e5

Browse files
committed
refactor(agents): remove retired Codex CLI parser
1 parent dc80799 commit b04f1e5

12 files changed

Lines changed: 25 additions & 297 deletions

‎src/agents/cli-output.ts‎

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ function isGeminiCliProvider(providerId: string): boolean {
156156
return normalizeLowercaseStringOrEmpty(providerId) === "google-gemini-cli";
157157
}
158158

159-
function isCodexExecJsonlProvider(providerId: string): boolean {
160-
const normalized = normalizeLowercaseStringOrEmpty(providerId);
161-
return normalized === "codex" || normalized === "codex-cli";
162-
}
163-
164159
function isGeminiStreamJsonDialect(params: {
165160
backend: CliBackendConfig;
166161
providerId: string;
@@ -1174,128 +1169,6 @@ function dispatchGeminiCliStreamingToolEvent(params: {
11741169
}
11751170
}
11761171

1177-
type CodexToolEvent = {
1178-
toolCallId: string;
1179-
name: string;
1180-
kind: CliToolUseStartDelta["kind"];
1181-
args: Record<string, unknown>;
1182-
result?: unknown;
1183-
isError: boolean;
1184-
};
1185-
1186-
function readCodexToolEvent(item: Record<string, unknown>): CodexToolEvent | null {
1187-
const toolCallId = typeof item.id === "string" ? item.id.trim() : "";
1188-
if (!toolCallId) {
1189-
return null;
1190-
}
1191-
const type = normalizeLowercaseStringOrEmpty(item.type);
1192-
if (type === "command_execution") {
1193-
return {
1194-
toolCallId,
1195-
name: "bash",
1196-
kind: "tool_use",
1197-
args: typeof item.command === "string" ? { command: item.command } : {},
1198-
result: item.aggregated_output,
1199-
isError: item.status === "failed" || item.status === "declined",
1200-
};
1201-
}
1202-
if (type === "file_change") {
1203-
return {
1204-
toolCallId,
1205-
name: "apply_patch",
1206-
kind: "tool_use",
1207-
args: Array.isArray(item.changes) ? { changes: item.changes } : {},
1208-
result: item.changes,
1209-
isError: item.status === "failed",
1210-
};
1211-
}
1212-
if (type === "web_search") {
1213-
return {
1214-
toolCallId,
1215-
name: "web_search",
1216-
kind: "server_tool_use",
1217-
args: typeof item.query === "string" ? { query: item.query } : {},
1218-
result: item.query,
1219-
isError: false,
1220-
};
1221-
}
1222-
if (type !== "mcp_tool_call") {
1223-
if (type !== "collab_tool_call") {
1224-
return null;
1225-
}
1226-
const tool = typeof item.tool === "string" ? item.tool.trim() : "";
1227-
if (!tool) {
1228-
return null;
1229-
}
1230-
return {
1231-
toolCallId,
1232-
name: `collab.${tool}`,
1233-
kind: "server_tool_use",
1234-
args: {
1235-
...(typeof item.sender_thread_id === "string"
1236-
? { sender_thread_id: item.sender_thread_id }
1237-
: {}),
1238-
...(Array.isArray(item.receiver_thread_ids)
1239-
? { receiver_thread_ids: item.receiver_thread_ids }
1240-
: {}),
1241-
...(typeof item.prompt === "string" ? { prompt: item.prompt } : {}),
1242-
},
1243-
result: item.agents_states,
1244-
isError: item.status === "failed",
1245-
};
1246-
}
1247-
const server = typeof item.server === "string" ? item.server.trim() : "";
1248-
const tool = typeof item.tool === "string" ? item.tool.trim() : "";
1249-
if (!tool) {
1250-
return null;
1251-
}
1252-
return {
1253-
toolCallId,
1254-
name: server ? `${server}.${tool}` : tool,
1255-
kind: "mcp_tool_use",
1256-
args: isRecord(item.arguments) ? item.arguments : {},
1257-
result: item.status === "failed" ? item.error : item.result,
1258-
isError: item.status === "failed",
1259-
};
1260-
}
1261-
1262-
function dispatchCodexCliStreamingToolEvent(params: {
1263-
providerId: string;
1264-
parsed: Record<string, unknown>;
1265-
tracker: ToolUseTracker;
1266-
onToolUseStart?: (delta: CliToolUseStartDelta) => void;
1267-
onToolResult?: (delta: CliToolResultDelta) => void;
1268-
}): void {
1269-
if (
1270-
!isCodexExecJsonlProvider(params.providerId) ||
1271-
(params.parsed.type !== "item.started" && params.parsed.type !== "item.completed") ||
1272-
!isRecord(params.parsed.item)
1273-
) {
1274-
return;
1275-
}
1276-
const event = readCodexToolEvent(params.parsed.item);
1277-
if (!event) {
1278-
return;
1279-
}
1280-
emitToolStartOnce(
1281-
params.tracker,
1282-
event.toolCallId,
1283-
event.name,
1284-
event.kind,
1285-
event.args,
1286-
params.onToolUseStart,
1287-
);
1288-
if (params.parsed.type === "item.completed") {
1289-
emitToolResultOnce(
1290-
params.tracker,
1291-
event.toolCallId,
1292-
event.isError,
1293-
event.result,
1294-
params.onToolResult,
1295-
);
1296-
}
1297-
}
1298-
12991172
const GEMINI_CLI_ERROR_EVENT_FALLBACK = "Gemini CLI emitted an error event.";
13001173
const GEMINI_CLI_RESULT_ERROR_FALLBACK = "Gemini CLI result status was error.";
13011174

@@ -1527,13 +1400,6 @@ export function createCliJsonlStreamingParser(params: {
15271400
}
15281401

15291402
if (params.onToolUseStart || params.onToolResult) {
1530-
dispatchCodexCliStreamingToolEvent({
1531-
providerId: params.providerId,
1532-
parsed,
1533-
tracker: toolTracker,
1534-
onToolUseStart: params.onToolUseStart,
1535-
onToolResult: params.onToolResult,
1536-
});
15371403
dispatchGeminiCliStreamingToolEvent({
15381404
backend: params.backend,
15391405
providerId: params.providerId,

‎src/agents/cli-runner.codex-tool-summary.test.ts‎

Lines changed: 0 additions & 108 deletions
This file was deleted.

‎src/agents/cli-runner/execute.supervisor-capture.test.ts‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ describe("executePreparedCliRun supervisor output capture", () => {
690690

691691
expect(spawnInput.captureOutput).toBe(false);
692692
expect(result.text).toBe("Hello world");
693+
expect(result.toolSummary).toEqual({ calls: 0, tools: [], failures: 0 });
693694
expect(agentEvents).toEqual([
694695
{ text: "Hello", delta: "Hello" },
695696
{ text: "Hello world", delta: " world" },
@@ -753,7 +754,12 @@ describe("executePreparedCliRun supervisor output capture", () => {
753754
context.params.agentId = "coder";
754755

755756
try {
756-
await executePreparedCliRun(context);
757+
const result = await executePreparedCliRun(context);
758+
expect(result.toolSummary).toEqual({
759+
calls: 1,
760+
tools: ["mcp__team__lookup"],
761+
failures: 0,
762+
});
757763
} finally {
758764
stop();
759765
}
@@ -859,7 +865,12 @@ describe("executePreparedCliRun supervisor output capture", () => {
859865
context.mcpDeliveryCapture = true;
860866

861867
try {
862-
await executePreparedCliRun(context);
868+
const result = await executePreparedCliRun(context);
869+
expect(result.toolSummary).toEqual({
870+
calls: 1,
871+
tools: ["mcp__openclaw__message"],
872+
failures: 1,
873+
});
863874
} finally {
864875
stop();
865876
}
@@ -938,7 +949,12 @@ describe("executePreparedCliRun supervisor output capture", () => {
938949
context.mcpDeliveryCapture = true;
939950

940951
try {
941-
await executePreparedCliRun(context);
952+
const result = await executePreparedCliRun(context);
953+
expect(result.toolSummary).toEqual({
954+
calls: 1,
955+
tools: ["mcp__openclaw__message"],
956+
failures: 1,
957+
});
942958
} finally {
943959
stop();
944960
}
@@ -1021,7 +1037,12 @@ describe("executePreparedCliRun supervisor output capture", () => {
10211037
context.mcpDeliveryCapture = true;
10221038

10231039
try {
1024-
await executePreparedCliRun(context);
1040+
const result = await executePreparedCliRun(context);
1041+
expect(result.toolSummary).toEqual({
1042+
calls: 2,
1043+
tools: ["mcp__openclaw__message"],
1044+
failures: 1,
1045+
});
10251046
} finally {
10261047
stop();
10271048
}

‎test/fixtures/cli/codex-tool-summary-collab-close-agent.jsonl‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-collab-failed.jsonl‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-collab-paired.jsonl‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-collab-terminal-only.jsonl‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-declined-command.jsonl‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-failed-mcp.jsonl‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎test/fixtures/cli/codex-tool-summary-paired-mcp.jsonl‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)