feat(server,web): import and export Trace files in the trace viewer (#73)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,10 @@ On Session creation, `modelId` and `provider` are both-or-neither: send the comp
|
||||
| GET | /agents/:agentId/traces | Date → Session drill-down structure of Trace files |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index | Read Trace events (`offset` / `limit` pagination) |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index/analysis | Trace performance analysis |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index/download | Download the raw Trace file (JSONL attachment) |
|
||||
| POST | /agents/:agentId/traces/import | Import a Trace file: `{dataBase64}` → `{sessionId, index, date}` |
|
||||
|
||||
Trace download is available to any member; import is owner-only (like the Agent snapshot import, capped at 14MB). An imported file must be valid Trace JSONL whose first record is a `session_meta` with a filename-safe `session_id`; a session id the Agent already has is rejected (409 `trace_session_exists`), so an imported file always becomes index 001 of a new Session, landing in the local date directory of its first record's timestamp.
|
||||
|
||||
### Session-Level Endpoints
|
||||
|
||||
|
||||
@@ -134,6 +134,10 @@ Schedule 写操作仅限 Owner。新建 Session 模式的任务,`modelId` 与
|
||||
| GET | /agents/:agentId/traces | Trace 文件的日期 → Session 下钻结构 |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index | 读取 Trace 事件(`offset` / `limit` 分页) |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index/analysis | Trace 性能分析结果 |
|
||||
| GET | /agents/:agentId/traces/:sessionId/:index/download | 下载 Trace 原始文件(JSONL 附件) |
|
||||
| POST | /agents/:agentId/traces/import | 导入 Trace 文件:`{dataBase64}` → `{sessionId, index, date}` |
|
||||
|
||||
Trace 下载对任意成员开放;导入仅限 owner(同 Agent 快照导入,上限 14MB)。导入文件必须是合法的 Trace JSONL,且首条记录为携带文件名安全 `session_id` 的 `session_meta`;若该 Agent 已存在同名 Session,导入将被拒绝(409 `trace_session_exists`),因此导入文件总是成为一个新 Session 的 001 号文件,并按首条记录时间戳的本地日期落入对应日期目录。
|
||||
|
||||
### Session 级接口
|
||||
|
||||
|
||||
@@ -89,4 +89,4 @@ Each content message's opaque provider `fidelity` payload (thinking signatures,
|
||||
|
||||
## Observability
|
||||
|
||||
Every approval decision (`approval_decision`), abort (`abort`), compaction (`compaction_begin` / `compaction_end`), and `token_usage` lands in the Trace as an event. The Web Trace view and the usage/cost statistics are both derived from this same data — there is no second source of truth; see the [Web App Guide](/web-app). The approval mechanism itself is covered in [Tools & Approval](/tools).
|
||||
Every approval decision (`approval_decision`), abort (`abort`), compaction (`compaction_begin` / `compaction_end`), and `token_usage` lands in the Trace as an event. The Web Trace view and the usage/cost statistics are both derived from this same data — there is no second source of truth; see the [Web App Guide](/web-app). The approval mechanism itself is covered in [Tools & Approval](/tools). Trace files can also be moved across deployments from the Web Traces page: any file can be exported (downloaded verbatim as JSONL) and imported back under an Agent — an import whose session id already exists under that Agent is rejected, so an imported file always becomes index 001 of a new Session.
|
||||
|
||||
@@ -89,4 +89,4 @@ Web 的 `/model` 命令按 @ handoff 的方式换模型:用普通的会话创
|
||||
|
||||
## 可观测性
|
||||
|
||||
每一次审批决策(`approval_decision`)、中断(`abort`)、压缩(`compaction_begin` / `compaction_end`)与 `token_usage` 都作为事件落入 Trace。Web 的 Trace 视图与用量、成本统计均由这同一份数据派生,不存在第二事实来源;见 [Web App 指南](/web-app)。审批机制本身见[工具与审批](/tools)。
|
||||
每一次审批决策(`approval_decision`)、中断(`abort`)、压缩(`compaction_begin` / `compaction_end`)与 `token_usage` 都作为事件落入 Trace。Web 的 Trace 视图与用量、成本统计均由这同一份数据派生,不存在第二事实来源;见 [Web App 指南](/web-app)。审批机制本身见[工具与审批](/tools)。Trace 文件还可以在部署之间迁移:在 Web 轨迹观测页可将任意文件导出(按原样下载为 JSONL),也可导入到某个 Agent 下——若该 Agent 已存在同名 Session 则导入被拒绝,因此导入文件总是成为一个新 Session 的 001 号文件。
|
||||
|
||||
Reference in New Issue
Block a user