@opencode-trace/viewer 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @opencode-trace/viewer
2
+
3
+ opencode-trace Web viewer for visualizing AI session trace data.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@opencode-trace/viewer)](https://www.npmjs.com/package/@opencode-trace/viewer)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Global install
11
+ npm install -g @opencode-trace/viewer
12
+
13
+ # Or use npx (no installation required)
14
+ npx @opencode-trace/viewer
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ # Start Viewer
21
+ npx @opencode-trace/viewer
22
+
23
+ # Or (if globally installed)
24
+ opencode-trace-viewer
25
+
26
+ # Or (via CLI)
27
+ opencode-trace viewer
28
+ ```
29
+
30
+ After starting, browser automatically opens (default http://localhost:3000).
31
+
32
+ ### Options
33
+
34
+ | Option | Description |
35
+ |--------|-------------|
36
+ | `--port <num>` | Specify port (default 3000) |
37
+ | `--no-open` | Don't auto-open browser |
38
+
39
+ ## Features
40
+
41
+ ### Session Management
42
+
43
+ - Session list (supports tree view)
44
+ - Session search and filtering
45
+ - Session export/import (ZIP format)
46
+ - Session deletion (cascade delete sub-sessions)
47
+
48
+ ### Timeline View
49
+
50
+ - Request sequence visualization
51
+ - Change comparison (added/deleted messages and Blocks)
52
+ - Token usage statistics (per request)
53
+ - Latency metrics (TTFT, TPOT)
54
+
55
+ ### Record Details
56
+
57
+ - Complete request/response content
58
+ - Block classification (text, thinking, tool_call, image, etc.)
59
+ - SSE stream data display
60
+ - Error information display
61
+
62
+ ### Trace Control
63
+
64
+ - Global trace switch
65
+ - Session-level trace switch
66
+ - Real-time status display
67
+
68
+ ## API Endpoints
69
+
70
+ Viewer provides RESTful API:
71
+
72
+ | Endpoint | Description |
73
+ |----------|-------------|
74
+ | `GET /api/sessions` | List sessions |
75
+ | `GET /api/sessions/tree` | Session tree |
76
+ | `GET /api/sessions/:id/timeline` | Timeline data |
77
+ | `GET /api/sessions/:id/metadata` | Session metadata |
78
+ | `GET /api/sessions/:id/records/:rid` | Record details |
79
+ | `POST /api/sessions/import` | Import ZIP |
80
+ | `GET /api/sessions/:id/export` | Export ZIP |
81
+ | `DELETE /api/sessions/:id` | Delete session |
82
+ | `POST /api/trace/enable` | Enable tracing |
83
+ | `POST /api/trace/disable` | Disable tracing |
84
+ | `GET /api/trace/status` | Trace status |
85
+
86
+ ## Data Source
87
+
88
+ Viewer reads from `~/.opencode-trace/` directory by default.
89
+
90
+ Can specify custom directory via environment variable `OPENCODE_TRACE_DIR`.
91
+
92
+ ## License
93
+
94
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import { createViewer } from "./server.js";
3
+ const args = process.argv.slice(2);
4
+ const openBrowser = !args.includes("--no-open");
5
+ const portArg = args.find((a) => !a.startsWith("--"));
6
+ const port = portArg ? parseInt(portArg, 10) : 3210;
7
+ if (isNaN(port)) {
8
+ console.error("Usage: opencode-trace-viewer [port] [--no-open]");
9
+ console.error("Default port: 3210");
10
+ console.error(" --no-open Don't open browser automatically");
11
+ process.exit(1);
12
+ }
13
+ createViewer({ port, open: openBrowser }).then((instance) => {
14
+ console.log(`opencode-trace viewer running at ${instance.url}`);
15
+ console.log("Press Ctrl+C to stop");
16
+ process.on("SIGINT", () => {
17
+ instance.close();
18
+ process.exit(0);
19
+ });
20
+ });
21
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings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ingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createViewer } from "./server.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,53 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120">
2
+ <defs>
3
+ <linearGradient id="brandGrad" x1="0%" y1="100%" x2="100%" y2="0%">
4
+ <stop offset="0%" stop-color="#FF512F"/>
5
+ <stop offset="100%" stop-color="#F09819"/>
6
+ </linearGradient>
7
+
8
+ <style>
9
+ .path-anim {
10
+ stroke-dasharray: 440;
11
+ stroke-dashoffset: 440;
12
+ animation: draw 2.5s ease-in-out infinite alternate;
13
+ }
14
+ .pulse-anim {
15
+ animation: pulse 1.5s ease-in-out infinite alternate;
16
+ }
17
+ @keyframes draw {
18
+ 0% { stroke-dashoffset: 440; }
19
+ 100% { stroke-dashoffset: 0; }
20
+ }
21
+ @keyframes pulse {
22
+ 0% { r: 8px; opacity: 1; }
23
+ 100% { r: 20px; opacity: 0; }
24
+ }
25
+ </style>
26
+ </defs>
27
+
28
+ <rect width="120" height="120" rx="28" fill="#ffffff" stroke="#e2e8f0" stroke-width="1.5"/>
29
+
30
+ <!-- 底层灰白轨道(更粗) -->
31
+ <polyline points="22,89 39,51 55,74 71,27 87,60 102,40"
32
+ fill="none" stroke="#F1F5F9" stroke-width="9"
33
+ stroke-linecap="round" stroke-linejoin="round"/>
34
+
35
+ <!-- 动态生长的 Agent 轨迹线(更粗) -->
36
+ <polyline class="path-anim"
37
+ points="22,89 39,51 55,74 71,27 87,60 102,40"
38
+ fill="none" stroke="url(#brandGrad)" stroke-width="8"
39
+ stroke-linecap="round" stroke-linejoin="round"/>
40
+
41
+ <!-- 静态中间节点(半径更大) -->
42
+ <circle cx="39" cy="51" r="8" fill="#ffffff" stroke="#F97316" stroke-width="3"/>
43
+ <circle cx="55" cy="74" r="8" fill="#ffffff" stroke="#F97316" stroke-width="3"/>
44
+ <circle cx="71" cy="27" r="8" fill="#ffffff" stroke="#F59E0B" stroke-width="3"/>
45
+ <circle cx="87" cy="60" r="8" fill="#ffffff" stroke="#F59E0B" stroke-width="3"/>
46
+
47
+ <!-- 起始节点(半径更大) -->
48
+ <circle cx="22" cy="89" r="9" fill="#FF512F"/>
49
+
50
+ <!-- 终点(脉冲范围进一步内收) -->
51
+ <circle class="pulse-anim" cx="102" cy="40" r="8" fill="none" stroke="#F09819" stroke-width="3.5"/>
52
+ <circle cx="102" cy="40" r="8.5" fill="#F09819"/>
53
+ </svg>