(list: readonly TraceEntry[] = entries)
| 399 | /** Download the captured trace as a JSONL file. Reusable so the debug panel and |
| 400 | any "Export log" UI action share one implementation. */ |
| 401 | export function downloadTraceLog(list: readonly TraceEntry[] = entries): void { |
| 402 | if (typeof document === 'undefined') return; |
| 403 | const blob = new Blob([traceToJsonl(list)], { type: 'application/x-ndjson' }); |
| 404 | const url = URL.createObjectURL(blob); |
| 405 | const a = document.createElement('a'); |
| 406 | a.href = url; |
| 407 | a.download = `kimi-web-log-${new Date().toISOString().replace(/[:.]/g, '-')}.jsonl`; |
| 408 | document.body.appendChild(a); |
| 409 | a.click(); |
| 410 | a.remove(); |
| 411 | URL.revokeObjectURL(url); |
| 412 | } |
| 413 | |
| 414 | /** Serialize the given entries (default: all) as JSONL for download. */ |
| 415 | export function traceToJsonl(list: readonly TraceEntry[] = entries): string { |
nothing calls this directly
no test coverage detected