feat(sessions): integrate structured Codex tool calls - #482
Conversation
[P1] [P2] [P2] |
Show runtime results beneath their exec parent with explicit AST provenance, retain safely resolved literal arguments, and persist Code Mode relationships in both session apps. Write V2 trace span parent links in a second phase so large sessions remain indexable across batch boundaries.
Persist the Code Mode collector state in both session stores so incremental scans retain parent relationships and replace static evidence with runtime results. Reindex existing Codex sessions once when the new storage is introduced.
Exercise two production-style index passes through the SQLite and PostgreSQL stores and assert that later runtime evidence replaces the earlier AST-only child call.
Remove the duplicate cross-filesystem Electron staging change and its regression test from this branch so PR zszz3#477 remains the single owner. Keep this branch release note focused on structured Code Mode calls.
|
[P1] [P2] [P2] |
[P1] [P2] [P2] [P2] [P2] |

关联 Issue
Closes #441
变更概述
在现有 Codex ToolCall phase 1 基础上,完成 V1/V2 的统一工具调用语义层接入。Codex Legacy、Paginated 和 Code Mode Session 中分散的请求记录、完成记录、执行 metadata 与 JavaScript 调用,现在会先归一为同一种
StructuredToolCall,再供 Session Trace、Skill Usage 和 V2 Eval 消费。用户可见结果:
exec会继续保留,同时展示其内部识别出的exec_command、skills.read、web.run、MCP 或插件工具。EXDEV、导致应用无法启动的问题。问题根因
同一次调用存在多种持久化形态
Codex 的一次逻辑工具调用可能同时记录为:
原有模块分别直接理解一部分 JSONL 结构,容易产生以下差异:
exec;skills__read、web__run和 MCP namespace 在不同功能中规范化不一致;旧正则只能提供展示名称
现有
extractCodexExecToolNames()能从exec源码中提取工具名,并生成:但它不能表达 call ID、父调用、Turn、参数、运行状态、cwd、耗时和证据来源,也无法可靠关联 Paginated 完成事件。因此本次保留旧字段以兼容现有标题展示,同时由统一中间层负责完整工具语义。
Electron runtime 暂存目录位于不同设备
Electron 修复脚本原先把暂存和备份目录创建在系统
/tmp,再使用rename()替换工作区中的node_modules/electron/dist。当工作区和系统临时目录属于不同文件系统时,跨设备 rename 会稳定报错EXDEV。实现说明
统一数据流
ToolCallObservation保存某一条原始记录提供的事实;StructuredToolCall表示完成关联后的单次逻辑调用。后者统一包含:canonicalNamecallId/parentCallId/turnIdinput/cwdstatusexecutionEvidencepluginId/scriptPathdurationMs/timestamp输入 Adapter
function_call、custom_tool_call、local_shell_call、tool_search_callCommandExecution、DynamicToolCall、McpToolCallexecuted_tool_callscustom_tool_call(name=exec)中的 JavaScripttools.*(...)调用和可静态求值的参数AST 使用
@babel/parser,不会通过eval、Function或其他方式执行 Session 中的 JavaScript。对象、数组和基础字面量会被静态还原;动态表达式无法安全求值时保留未知参数。名称规范化
统一层保留 namespace,并生成稳定名称:
外层
exec仍作为 Code Mode 容器保留,不与任意一个内层工具调用混为同一实体。证据优先级和去重
parentCallId + ordinal生成稳定临时 ID。最终执行证据分为:
runtime-confirmedrecorded-requeststatic-only增量扫描与回滚
thread_rolled_back删除 Turn 时同步丢弃相关 call ID 和内层 observation。下游接入
Session Trace
nestedTools和exec · ...标题继续兼容。Skill Usage
SKILL.md、运行 Skill 脚本、顶层或 Code Modeskills.read都消费统一调用。skills.read结合 Session 中的 Skill catalog 将 package/resource 映射到 Skill 名称。V2 Eval
PostgreSQL Skill Eval 查询从 trace attributes 读取:
Eval 与解析器使用相同的名称和证据语义,不再单独推断 Code Mode 调用。
Electron runtime 修复
下载、校验和解压流程保持不变;只将暂存 runtime 和 previous runtime 放到
node_modules/electron所在文件系统,确保安装与回滚所需的 rename 都是同盘原子操作。修改前后
execstatic-onlyexec_commandStructuredToolCall兼容性与风险控制
nestedTools字段和标题展示,避免现有 UI 回退。数据更新与已知限制
更新说明检查
.release-notes/<branch-slug>.mdrelease-target: both,覆盖 V1/V2 的 Session 与 Skill 结果npm run release-note:check验证
npm --prefix apps/main-2.0 run predev完成 runtime 修复,随后再次运行无需下载并立即通过。npm run release-note:check通过。git diff --check通过。更新说明
本分支包含
.release-notes/structured-tool-call.md: