mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
2.7 KiB
2.7 KiB
Codex App-Server Integration Plan (Rust Learning Track)
Goals
- Practice Rust fundamentals through a concrete, asynchronous systems project.
- Understand the Codex JSON-RPC contract (
codex-rs/protocol/src/mcp_protocol.rsandprotocol/src/protocol.rs). - Build confidence with tooling (
tokio,serde,clap,tracing,ratatui).
Project Ideas
-
Minimal MCP Client
- Spawn
codex-app-serverwithtokio::process::Commandand manage stdio streams. - Implement JSON-RPC handshake (
initialize,newConversation). - Send
addConversationListenerto receivecodex/event/*notifications.
- Spawn
-
Protocol Bindings Crate
- Re-export the schema types from Codex or mirror them in a new crate.
- Derive
serdetraits and optionally generate TypeScript definitions withts_rs. - Provide helper builders for common requests.
-
Event Reactor
- Write an async dispatcher that matches notification
methodvalues. - Map
params.msg.typeto enums and forward them to handlers. - Demonstrate logging of plan updates, approvals, and tool call progress.
- Write an async dispatcher that matches notification
-
CLI Wrapper
- Build a
clap-based CLI:new,send,interrupt,status. - Manage Request IDs, handle JSON-RPC errors, serialize inputs with
serde_json. - Support piping stdin into user messages.
- Build a
-
Tracing & Diagnostics
- Instrument the client with
tracingspans around requests and responses. - Emit structured logs for event handling and error paths.
- Optionally integrate with
tracing-subscriberfor pretty output or JSON logs.
- Instrument the client with
-
TUI Conversation Viewer
- Use
ratatuito render conversation history, plan updates, and approvals. - Represent
PlanUpdateevents as checklists and reasoning deltas as streaming text. - Explore async UI patterns using
tokio+crossterm.
- Use
-
Diff & Approval UX
- Parse
applyPatchApprovalpayloads and render diffs with crates likedissimilarorsimilar. - Provide approve/deny keybindings and feed decisions back via JSON-RPC.
- Parse
-
Custom MCP Tool Prototype
- Implement a Rust tool service that Codex can call (mirroring the plan tool pattern).
- Showcase serde-based argument parsing and structured responses.
Learning Outcomes
- Async process management, buffered IO, and JSON serialization in Rust.
- Familiarity with Codex’s turn lifecycle, event taxonomy, and approval flows.
- Experience building CLI/TUI applications and instrumenting them for observability.
Next Steps
- Set up a dedicated Rust workspace with integration tests that launch
codex-app-serverin-process. - Prioritize Project 1 to establish the transport loop, then layer on additional ideas as separate modules or binaries.