Parent roadmap: #15 ## What 在 Tauri Rust 后端新增长驻 `CodexAppServerManager`,通过本地 `stdio` 与 `codex app-server` 建立 JSON-RPC 连接,为后续 Thread、Turn、审批和结构化事件能力提供统一传输层。 ## Why 当前每个请求都启动一次 `codex exec --json`,stdin 写入 Prompt 后立即关闭,无法承载运行中 steering、双向审批和完整 App Server 生命周期。事件解析还需要兼容多套内部格式,维护成本较高。 ## Implementation - 复用现有 Codex binary resolver 和 Node.js preflight。 - 启动一个受管理的 `codex app-server --listen stdio://` 子进程。 - 实现 `initialize` / `initialized` 握手、递增请求 ID、pending request map 和 notification dispatcher。 - 增加 `CodexCapabilities`,记录 CLI 版本、稳定 API 能力及可选实验能力;首版不启用 `experimentalApi`。 - 根据当前 Codex CLI 生成的 JSON Schema 建立受版本控制的协议类型;未知字段保持向前兼容。 - 实现进程退出检测、失败状态、指数退避重启和应用退出清理。 - App Server 不可用、版本不支持或初始化失败时,回退现有 `codex exec --json` 路径。 - 通过 Tauri event 暴露连接状态和可诊断错误,不记录凭据或完整敏感 Prompt。 ## Acceptance criteria - Flowix 启动后可以建立并复用一个本地 App Server 连接。 - 并发 JSON-RPC 请求能按 ID 正确完成或超时。 - Notifications 不会阻塞请求响应处理。 - App Server 异常退出后 UI 获得明确状态,并能按退避策略恢复。 - 不支持 App Server 的 Codex CLI 仍可通过现有 runtime 工作。 - 未知 notification 或额外字段不会导致连接崩溃。 - 包含 transport、握手、请求关联、重启和 fallback 的单元/集成测试。 ## Dependencies 无。本 Issue 是其他 Codex App Server 子 Issue 的基础。 ## Non-goals - 不迁移现有 Thread/Turn 业务逻辑。 - 不实现审批 UI、账户配置 UI 或 Flowix MCP Server。 - 不支持 Unix socket、WebSocket 或远程连接。
Activity