Repository navigation
Description
The hand-maintained sdk/typescript/src/items.ts (header: "based on item types from codex-rs/exec/src/exec_events.rs") has drifted from what codex exec --experimental-json actually emits. All four gaps below were verified against current main Rust sources and with tsc — the SDK rejects each shape.
collab_tool_callmissing fromThreadItem— the wire format emits it for subagent activity (ThreadItemDetails::CollabToolCallinexec_events.rs, mapped inevent_processor_with_jsonl_output.rs), but TS consumers must cast toanyto handle official SDK events. Same root cause as @openai/codex-sdk: ThreadItem type missing collab_tool_call #28318 (no fixing PR exists).CommandExecutionStatusmissing"declined"—event_processor_with_jsonl_output.rsmapsCommandExecutionStatus::Declinedinto the JSONL output.PatchApplyStatusmissing"in_progress"—event_processor_with_jsonl_output.rsmapsPatchApplyStatus::InProgressinto the JSONL output.WebSearchItemmissingactionandresults— added to the wire format by Preserve web search actions and results in exec JSON output #46319 (WebSearchAction+results: Option<Vec<JsonValue>>inexec_events.rs); the SDK was never synced.
I have a ready fix on branch codex-sdk-wire-type-sync in nosmile99/codex (commit c2ce059; compares cleanly against main, no conflicts) that:
- adds exported
CollabToolCallItem,CollabToolCallStatus,CollabTool,CollabAgentStatus,CollabAgentStateand putsCollabToolCallItemin theThreadItemunion; - adds
"declined"toCommandExecutionStatusand"in_progress"toPatchApplyStatus; - adds
action: WebSearchActionandresults?: unknown[]toWebSearchItem, withWebSearchActionmirroring the Rust serde shape (search/open_page/find_in_page/other,snake_casetag); - adds
tests/wireTypeSync.test.ts: wire-shaped fixtures (including the runtime example from @openai/codex-sdk: ThreadItem type missing collab_tool_call #28318) that fail to compile via ts-jest diagnostics if the types drift again.
Verified: new suite 5/5 green, pre-existing tests/exec.test.ts 14/14 green, eslint + prettier clean; the new suite fails against the pre-fix types (negative control). I could not open a PR because this repo restricts PR creation to collaborators — happy for a maintainer to pull the branch, or I can re-submit it as a PR if the restriction is lifted.
Activity
argszero commentedon Oct 11, 2026
Verified all four against
main@cc7ba33601, and swept the rest of the mirror for the same class of gap. All four are real, and the fix scope is exactly these two files.Claim-by-claim
collab_tool_call—ThreadItemDetailshas 9 variants (exec_events.rs:107-133), the TS union has 8 (items.ts:120-128). Emission site:event_processor_with_jsonl_output.rs:246. Confirmed.declined—CommandExecutionStatusis 4 variants (exec_events.rs:151-157),items.ts:6lists 3. Confirmed.in_progress—PatchApplyStatusis 3 (exec_events.rs:178-182),items.ts:32lists 2. Confirmed.action/results—WebSearchItemis{id, query, action, results}(exec_events.rs:298-306),items.ts:90-94has neither. Confirmed, and your proposed shape is right on the subtle part:action: WebSearchActionis required (not anOption, noskip_serializing_if, so always emitted) whileresultscarriesskip_serializing_if/#[ts(optional)]and is the only genuinely optional field. YourWebSearchActionalso matches the source:models.rs:2066-2092is#[serde(tag = "type", rename_all = "snake_case")]withSearch { query?, queries? }/OpenPage { url? }/FindInPage { url?, pattern? }/Other(#[serde(other)]) — notesearchcarries bothqueryandqueries.What else I checked (the four are complete — nothing else in
items.tsdrifted)Field-by-field against the Rust structs:
PatchChangeKind,McpToolCallStatus,CollabTool/CollabToolCallStatus/CollabAgentStatus/CollabAgentState,McpToolCallItem's fields,TodoItem/TodoListItem,ErrorItem,AgentMessageItem,ReasoningItem— all in sync. Andevents.tsis fully in sync: all 8ThreadEventarms and all 5Usagefields includingcache_write_input_tokens(exec_events.rs:61-73). So the surface to fix isitems.tsonly, which should keep the patch small.One divergence the four don't cover, and the proposed patch keeps
exit_codeisnull, not absent.exec_events.rs:164declarespub exit_code: Option<i32>with noskip_serializing_ifand no#[ts(optional)], and the emit path is plainserde_json::to_string(&event)(event_processor_with_jsonl_output.rs:108) — so while a command is running the wire carries"exit_code": null, an always-present key.items.ts:17types itexit_code?: numberwith the doc "omitted while still running", soitem.exit_code !== undefinedis wrong against the wire whileitem.exit_code != nullis right. Same asymmetry forMcpToolCallItem.resultand.error(exec_events.rs:291-292vsitems.ts:61,67: both serialize asnull, both typed?). Fixture-based type tests won't catch this class, because theundefinedcheck still compiles.The structural point
exec_events.rsderivests_rs::TSon every type in the file, andcodex-rs/exec/Cargo.toml:61depends onts-rsv11 — ts-rs renders that field asexit_code: number | null, so the hand-written mirror already disagrees with a generator wired to the source.execjust never got an export step, which is whyitems.tscarries the hand-copy header.The repo does have a complete pattern for this, in
app-server-protocol:export.rs:123generate_ts_with_options/:132-140export_all_to, with#[ts(export_to = "v2/")]markers on the types;precomputed_exports.rs— a precomputed snapshot (GENERATED_TS_HEADER = "// GENERATED CODE! DO NOT MODIFY BY HAND!", served fromschema/precomputed/*.json.zst) so the check needs no Rust run;schema_fixtures_tests.rs:19-37typescript_schema_fixtures_match_generated— a drift guard that reads the committed fixture tree and diffs it against freshly generated output (assert_schema_trees_match), wired into nextest atcodex-rs/.config/nextest.toml:67.That is the shape that would end this class of bug for
exec, rather than a third hand-sync. Flagging it as the follow-up rather than something to bundle here.History of this exact surface
collab_tool_callgap, same file.collab_tool_call"spawn_agent" item missing fromexec --experimental-jsonstream; "wait" item'sreceiver_thread_idsstays empty despite a real, successful delegation underneath #34919 (2026-07-23, open) —spawn_agentitem missing from the stream andwait'sreceiver_thread_idsempty; that one is about emission, not the types, so it is adjacent rather than duplicate.Nuance worth putting in the type once you add it
The collab mapping is conditional in a way the type can't express:
CollabAgentTool::SendMessage,FollowupTask,InterruptAgent,ListAgentsand statusInterruptedallreturn None, i.e. no item is emitted at all (event_processor_with_jsonl_output.rs:248-251,:299), andCollabAgentTool::ResumeAgentis folded intoCollabTool::Wait(:254) — so the wire only ever carriesspawn_agent/send_input/wait/close_agentwithin_progress/completed/failed, matching your proposed enum. A short comment there is worth it, sincewaitis two source tools and the absent cases are invisible from the types alone.I hit the same wall on PR creation, so I can't submit this either. If it helps, I can re-run this comparison against a newer
mainonce the branch is rebased, or check whether the export/snapshot shape fromapp-server-protocoltransfers cleanly toexec.nosmile99 commentedon Oct 11, 2026
Thanks for the thorough verification — your claims-by-claim check is even deeper than the issue.
I folded the extra divergence you found into the fix branch:
exit_code: number | null— always present on the wire,nullwhile running (never omitted); same forMcpToolCallItem.result/.error(always present,nulluntil settled). The type doc now says to check== null, not=== undefined.SendMessage/FollowupTask/InterruptAgent/ListAgents/Interruptednever emitted;ResumeAgentfolded intowait).wireTypeSyncfixtures extended: declined/running command item withexit_code: null, plus a dedicated always-present-null test. 6/6 green, lint clean.On the structural point I agree: the
app-server-protocolexport/snapshot + drift-guard shape is the right end-state forexec, and that belongs as a follow-up rather than bundled here.The branch is updated at
nosmile99/codex@codex-sdk-wire-type-sync(now56421a3) if you want to pull it — happy to rebase it or run the comparison against a newermainwhenever that helps.