feat: add codex_sdk package for Codex CLI integration#73
Merged
Norbert515 merged 3 commits intomainfrom Feb 19, 2026
Merged
Conversation
b23b14d to
0c4b412
Compare
Adds codex_sdk as a standalone package that wraps OpenAI's Codex CLI (codex exec --json) and maps its JSONL events to ClaudeResponse types, allowing the existing downstream pipeline to work unchanged. Key components: - CodexClient: process lifecycle, multi-turn resume via stdin - CodexEventParser/Mapper: JSONL parsing and response mapping - CodexConfig: CLI flag generation with correct ordering - CodexMcpRegistry: .codex/config.toml for MCP server discovery
… tests - Fix resume mode: prompt passed as positional arg, not stdin - Fix stale process callbacks via turn ID scoping - Add _isClosed guard to prevent post-close stream errors - Remove dead approvalPolicy/fullAuto fields (exec mode ignores them) - Always pass --full-auto (exec mode hardcodes approval_policy: never) - Add 85 unit tests (config, event parser, event mapper, MCP registry) - Add 7 e2e tests including multi-turn resume verification
Replace process-per-turn architecture with persistent JSON-RPC subprocess. This enables interactive approval handling, streaming text deltas, and persistent sessions without per-turn overhead. - Add CodexTransport for persistent subprocess management and JSON-RPC I/O - Add JSON-RPC message types (notification, request, response) - Add approval types (CodexApprovalRequest, CodexApprovalDecision) - Rewrite CodexEvent as sealed class built from JSON-RPC notifications - Rewrite CodexClient with initialize handshake, thread/turn lifecycle - Replace toCliArgs() with toThreadStartParams(), add approvalPolicy - Handle list-based content blocks in reasoning summary fields - Update all unit and e2e tests
23d36ac to
f9af320
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codex_sdkpackage wrapping OpenAI Codex CLI's headless mode (codex exec --json)ClaudeResponsetypes so the downstream pipeline works unchanged.codex/config.tomlgenerationAgentClientabstraction is introducedWhat's in the package
CodexClientImpl— spawnscodex execprocesses, handles multi-turn via thread resumeCodexEventParser— parses JSONL output from Codex CLICodexEventMapper— maps Codex events (agent_message, command_execution, file_change, mcp_tool_call, reasoning) to ClaudeResponse objectsCodexConfig— configuration and CLI arg generationCodexMcpRegistry— writes.codex/config.tomlfor MCP server discoveryTest plan
dart analyze— zero issues in core packagesdart test— 302/302 tests passaggregated_output,server/tool)