Fix codex-mcp command exit codes
This commit is contained in:
@@ -1055,20 +1055,29 @@ class CodexMcpAgentSession implements AgentSession {
|
|||||||
const exitCodeRaw = (event as { exit_code?: unknown; exitCode?: unknown }).exit_code ??
|
const exitCodeRaw = (event as { exit_code?: unknown; exitCode?: unknown }).exit_code ??
|
||||||
(event as { exitCode?: unknown }).exitCode;
|
(event as { exitCode?: unknown }).exitCode;
|
||||||
const exitCode = typeof exitCodeRaw === "number" ? exitCodeRaw : undefined;
|
const exitCode = typeof exitCodeRaw === "number" ? exitCodeRaw : undefined;
|
||||||
const output = (event as { output?: string; stdout?: string }).output ??
|
const output = (event as { output?: unknown; stdout?: unknown }).output ??
|
||||||
(event as { stdout?: string }).stdout ??
|
(event as { stdout?: unknown }).stdout ??
|
||||||
(event as { stderr?: string }).stderr ??
|
(event as { stderr?: unknown }).stderr;
|
||||||
"";
|
const outputRecord =
|
||||||
const structuredOutput =
|
output && typeof output === "object" ? (output as Record<string, unknown>) : undefined;
|
||||||
|
const outputText =
|
||||||
typeof output === "string"
|
typeof output === "string"
|
||||||
|
? output
|
||||||
|
: typeof outputRecord?.stdout === "string"
|
||||||
|
? outputRecord.stdout
|
||||||
|
: typeof outputRecord?.stderr === "string"
|
||||||
|
? outputRecord.stderr
|
||||||
|
: undefined;
|
||||||
|
const structuredOutput =
|
||||||
|
outputText !== undefined || typeof exitCode === "number"
|
||||||
? {
|
? {
|
||||||
type: "command" as const,
|
type: "command" as const,
|
||||||
command: extractCommandText(command) ?? "command",
|
command: extractCommandText(command) ?? "command",
|
||||||
output,
|
output: outputText ?? "",
|
||||||
exitCode,
|
exitCode,
|
||||||
cwd,
|
cwd,
|
||||||
}
|
}
|
||||||
: undefined;
|
: outputRecord;
|
||||||
const emitEvent = () => {
|
const emitEvent = () => {
|
||||||
if (typeof exitCode === "number" && exitCode !== 0) {
|
if (typeof exitCode === "number" && exitCode !== 0) {
|
||||||
this.turnState && (this.turnState.sawError = true);
|
this.turnState && (this.turnState.sawError = true);
|
||||||
@@ -1249,12 +1258,13 @@ class CodexMcpAgentSession implements AgentSession {
|
|||||||
? (commandValue as string[]).join(" ")
|
? (commandValue as string[]).join(" ")
|
||||||
: "command";
|
: "command";
|
||||||
|
|
||||||
|
const outputText = typeof aggregatedOutput === "string" ? aggregatedOutput : undefined;
|
||||||
const structuredOutput =
|
const structuredOutput =
|
||||||
typeof aggregatedOutput === "string"
|
outputText !== undefined || typeof exitCode === "number"
|
||||||
? {
|
? {
|
||||||
type: "command" as const,
|
type: "command" as const,
|
||||||
command,
|
command,
|
||||||
output: aggregatedOutput,
|
output: outputText ?? "",
|
||||||
exitCode: typeof exitCode === "number" ? exitCode : undefined,
|
exitCode: typeof exitCode === "number" ? exitCode : undefined,
|
||||||
cwd,
|
cwd,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ Build a new Codex MCP provider side‑by‑side with the existing Codex SDK prov
|
|||||||
- [x] **Test (E2E)**: Run tests and verify fixes work.
|
- [x] **Test (E2E)**: Run tests and verify fixes work.
|
||||||
- **Done (2025-12-24 19:32)**: Ran `npm run test --workspace=@paseo/server`; 9 failures (1 in `codex-agent.test.ts` missing persisted shell_command entry, 8 in `codex-mcp-agent.test.ts` for exit code, thread/item events, error timeline, persistence metadata, and permission requests).
|
- **Done (2025-12-24 19:32)**: Ran `npm run test --workspace=@paseo/server`; 9 failures (1 in `codex-agent.test.ts` missing persisted shell_command entry, 8 in `codex-mcp-agent.test.ts` for exit code, thread/item events, error timeline, persistence metadata, and permission requests).
|
||||||
|
|
||||||
- [ ] **Fix**: Codex MCP command output should include exit codes for command tool calls.
|
- [x] **Fix**: Codex MCP command output should include exit codes for command tool calls.
|
||||||
|
- **Done (2025-12-24 19:36)**: Ensured command tool outputs include exit codes even when output text is missing.
|
||||||
|
|
||||||
- [ ] **Fix**: Codex MCP thread/item event mapping should capture file_change, mcp_tool_call, web_search, and todo_list.
|
- [ ] **Fix**: Codex MCP thread/item event mapping should capture file_change, mcp_tool_call, web_search, and todo_list.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user