Crate 目录
codex-rs/Cargo.toml 当前 workspace 有大量 crate。理解它们时,可以先按功能域分组,而不是按字母顺序硬读。
Core Runtime
| Crate |
说明 |
core |
agent loop、session/thread、工具、上下文、压缩、MCP 接入 |
protocol |
core 与客户端之间的事件/请求协议 |
core-api、codex-api |
API-facing 类型与客户端辅助 |
codex-client、backend-client |
后端或 Codex 服务客户端 |
prompts |
内置 prompt、summary prompt、review prompt |
model-provider、model-provider-info、models-manager |
provider、模型元数据、模型列表缓存和默认选择 |
用户入口
| Crate |
说明 |
cli |
codex 主 CLI,包括 app、mcp、plugin、doctor 等命令 |
tui |
终端 UI |
exec |
headless codex exec |
app-server、app-server-protocol、app-server-client |
桌面/IDE JSON-RPC 服务与客户端 |
app-server-daemon、app-server-transport |
app-server 后台和传输 |
工具与执行
| Crate |
说明 |
tools |
通用工具 spec、tool name、Responses API tool 类型 |
exec-server |
local/remote environment、process、filesystem、exec protocol |
execpolicy、execpolicy-legacy |
命令前缀策略和兼容逻辑 |
apply-patch |
patch grammar 和应用逻辑 |
shell-command、shell-escalation |
shell 命令表示和升级执行 |
file-system、file-search、file-watcher |
文件系统抽象、搜索、监听 |
linux-sandbox、sandboxing、windows-sandbox-rs、bwrap |
平台沙箱 |
扩展系统
| Crate |
说明 |
ext/extension-api |
extension contributor traits |
ext/goal |
/goal 持久化目标系统 |
ext/mcp |
MCP server contribution |
ext/skills |
skills extension |
ext/memories |
memories extension |
ext/web-search |
web search extension |
ext/image-generation |
image generation extension |
ext/guardian |
Guardian review extension |
memories/read、memories/write |
memories 读路径、写路径和后台合并流水线 |
core-plugins、plugin |
plugin manifest、loader、manager、marketplace |
core-skills、skills |
skill model、loader、render、系统 skills |
connectors |
apps/connectors 合并和访问策略 |
状态与持久化
| Crate |
说明 |
rollout、rollout-trace |
JSONL 历史、压缩、trace |
thread-store |
local/in-memory thread store |
state |
SQLite state runtime、migrations、goals、memories、logs |
agent-graph-store |
agent graph 状态 |
message-history |
message history 辅助 |
Multi-Agent 与外部 agent
| Crate |
说明 |
agent-identity |
agent identity |
external-agent-sessions |
外部 agent session |
external-agent-migration |
外部 agent 迁移 |
thread-manager-sample |
thread manager 示例 |
code-mode、code-mode-protocol、code-mode-host |
code mode runtime/protocol/host |
Provider 与本地模型
| Crate |
说明 |
ollama、lmstudio |
OSS/local provider 适配 |
aws-auth |
AWS auth |
cloud-config、cloud-tasks* |
cloud 配置和 cloud task 客户端/模拟 |
chatgpt、login、keyring-store、secrets |
ChatGPT/API auth、keyring、secret 处理 |
平台与工具库
| Crate |
说明 |
analytics、otel、feedback |
事件、指标和反馈 |
config |
config.toml、requirements、profiles、hooks、MCP config |
features |
feature gate 和实验配置 |
realtime-webrtc |
realtime WebRTC;核心会话编排在 core/src/realtime_conversation.rs |
responses-api-proxy |
Responses API proxy |
rmcp-client、mcp-server、codex-mcp |
MCP client/server/compat |
network-proxy |
managed network proxy |
process-hardening |
进程加固 |
terminal-detection、ansi-escape、arg0 |
终端和进程启动辅助 |
utils/* |
路径、缓存、模板、stream parser、pty、image、output truncation 等工具库 |
这个目录不是源码详解的替代品,但能帮助你快速定位某个设计点属于哪个功能域。