Skip to content

Comments

feat: add codex_sdk package for Codex CLI integration#73

Merged
Norbert515 merged 3 commits intomainfrom
explore/codex-cli-integration
Feb 19, 2026
Merged

feat: add codex_sdk package for Codex CLI integration#73
Norbert515 merged 3 commits intomainfrom
explore/codex-cli-integration

Conversation

@Norbert515
Copy link
Owner

Summary

  • Adds standalone codex_sdk package wrapping OpenAI Codex CLI's headless mode (codex exec --json)
  • Parses JSONL event stream and maps Codex events to ClaudeResponse types so the downstream pipeline works unchanged
  • Includes MCP server registration via .codex/config.toml generation
  • Not yet integrated into core — excluded from analyzer until AgentClient abstraction is introduced

What's in the package

  • CodexClientImpl — spawns codex exec processes, handles multi-turn via thread resume
  • CodexEventParser — parses JSONL output from Codex CLI
  • CodexEventMapper — maps Codex events (agent_message, command_execution, file_change, mcp_tool_call, reasoning) to ClaudeResponse objects
  • CodexConfig — configuration and CLI arg generation
  • CodexMcpRegistry — writes .codex/config.toml for MCP server discovery

Test plan

  • dart analyze — zero issues in core packages
  • dart test — 302/302 tests pass
  • Verified field names match actual Codex CLI API docs (aggregated_output, server/tool)
  • Core packages have zero diff against main (no accidental changes)

@Norbert515 Norbert515 force-pushed the explore/codex-cli-integration branch 4 times, most recently from b23b14d to 0c4b412 Compare February 14, 2026 21:02
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
@Norbert515 Norbert515 force-pushed the explore/codex-cli-integration branch from 23d36ac to f9af320 Compare February 15, 2026 16:26
@Norbert515 Norbert515 merged commit dfbcc18 into main Feb 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant