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:
Yaowei Zheng
2026-07-27 22:54:57 +08:00
committed by GitHub
parent d29d2ba7f3
commit f192db338e
13 changed files with 592 additions and 8 deletions
+19
View File
@@ -57,6 +57,8 @@ import type {
TaskCreateResponse,
TraceAnalysisResponse,
TraceEventsResponse,
TraceImportRequest,
TraceImportResponse,
UiPrefs,
UsageGroupBy,
UsageResponse,
@@ -332,6 +334,23 @@ export const getAgentTraceAnalysis = (
`/traces/${encodeURIComponent(sessionId)}/${index}/analysis`,
);
/** Trace file download URL: the server sets Content-Disposition attachment, usable directly in <a download>. */
export const agentTraceDownloadUrl = (
projectId: string,
agentId: string,
sessionId: string,
index: number,
): string =>
`/api/projects/${encodeURIComponent(projectId)}/agents/${encodeURIComponent(agentId)}` +
`/traces/${encodeURIComponent(sessionId)}/${index}/download`;
/** Imports a Trace JSONL file (owner only); the response says where the file landed (sessionId / index / date). */
export const importAgentTrace = (projectId: string, agentId: string, body: TraceImportRequest) =>
apiFetch<TraceImportResponse>(
`/api/projects/${encodeURIComponent(projectId)}/agents/${encodeURIComponent(agentId)}/traces/import`,
{ method: "POST", body },
);
// Usage statistics ----------------------------------------------------------------------
export const getUsage = (