claw-insights 0.1.3 → 0.1.5

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 CHANGED
@@ -1,20 +1,22 @@
1
1
  <div align="center">
2
2
  <img src="packages/web/public/logo/icon-dark.svg" width="80" alt="Claw Insights" />
3
3
  <h1>Claw Insights</h1>
4
- <p><strong>Replay, metrics, logs &amp; shareable snapshots for <a href="https://github.com/openclaw/openclaw">OpenClaw</a> agents</strong></p>
4
+ <p><strong>Open-source agent observability — replay, metrics, logs & shareable snapshots</strong></p>
5
+ <p><sub>Built for <a href="https://github.com/openclaw/openclaw">OpenClaw</a> · Adapter architecture — extend to any agent runtime</sub></p>
5
6
  <p>
6
7
  <img src="https://img.shields.io/badge/%F0%9F%94%8C_Zero_Intrusion-read--only_sidecar-10b981" alt="Zero Intrusion" />
7
8
  <img src="https://img.shields.io/badge/%F0%9F%94%8D_Full_Replay-session_transcripts-6366f1" alt="Full Replay" />
8
9
  <img src="https://img.shields.io/badge/%F0%9F%93%B8_Shareable_Snapshots-PNG_%7C_SVG-f59e0b" alt="Shareable Snapshots" />
9
10
  </p>
10
11
  <p>
12
+ <a href="https://github.com/LucaL6/claw-insights/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/LucaL6/claw-insights/ci.yml?branch=main&label=CI" alt="CI" /></a>
11
13
  <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
12
14
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node.js-%E2%89%A522.5-green" alt="Node.js" /></a>
13
15
  <img src="https://img.shields.io/badge/macOS-supported-blue" alt="macOS" />
14
16
  <img src="https://img.shields.io/badge/Linux-supported-blue" alt="Linux" />
15
17
  </p>
16
18
  <br />
17
- <img src="docs/assets/hero-montage.png" width="100%" alt="Dashboard, Session Transcript, and Snapshot API" />
19
+ <img src="docs/assets/hero-montage.png" width="100%" alt="Claw Insights dashboard — agent observability with session replay, token analytics, and shareable snapshots" />
18
20
  </div>
19
21
 
20
22
  ---
@@ -26,25 +28,25 @@
26
28
 
27
29
  ## Features
28
30
 
29
- - **Zero Intrusion** — Pure read-only sidecar; no code changes, no cloud calls, data never leaves your machine
30
- - **Session Replay** — Full transcript timeline with role separation, tool calls, and per-turn token tracking
31
- - **Shareable Snapshots** — Generate PNG/SVG status cards via REST API with themes, languages, and detail levels
32
- - **Metrics Dashboard** — Per-model token breakdown, error rates, and uptime over 30m / 1h / 6h / 12h / 24h
33
- - **Event Logs** — Structured viewer with density heatmap, filtering, and search
31
+ - **Zero Intrusion** — Self-hosted, local-first observability sidecar; no SDK, no code changes, no cloud calls, data never leaves your machine
32
+ - **Session Replay** — Full transcript timeline with role separation, tool calls, thinking steps, and per-turn token tracking
33
+ - **Shareable Snapshots** — Generate PNG/SVG status cards via REST API or CLI with themes, languages, and detail levels
34
+ - **Metrics Dashboard** — Per-model token analytics, error rates, and uptime over 30m / 1h / 6h / 12h / 24h
35
+ - **Event Logs** — Structured log viewer with density heatmap, filtering, and search for AI agent debugging
34
36
  - **One Command Setup** — Auto-discovers your running gateway, lightweight SQLite storage
35
37
  - **Dark / Light · EN / 中文** — Full theming and i18n with runtime toggle
36
38
 
37
39
  ## Quick Start
38
40
 
39
41
  ```bash
40
- # Install
42
+ # Install globally
41
43
  npm install -g claw-insights
42
44
 
43
- # Start (auto-connects to your running OpenClaw gateway)
45
+ # Start auto-connects to your running OpenClaw gateway
44
46
  claw-insights start
45
47
  ```
46
48
 
47
- On launch you'll see an access URL:
49
+ On launch you'll see:
48
50
 
49
51
  ```
50
52
  ✅ Claw Insights v0.1.0 ready in 1.2s
@@ -57,22 +59,111 @@ PID 12345 · daemon · Port 41041
57
59
 
58
60
  Open the URL — token is exchanged for a session cookie, and you're in.
59
61
 
62
+ ## Usage
63
+
64
+ ### 🔌 Zero Intrusion — start & connect
65
+
66
+ ```bash
67
+ claw-insights start # Auto-discovers running OpenClaw gateway
68
+ claw-insights start --gateway <url> # Connect to specific gateway
69
+ claw-insights start --no-auth # Disable token authentication
70
+ claw-insights start --open # Start and open browser automatically
71
+ claw-insights status # Show access URL & connection info
72
+ claw-insights status --json # Machine-readable status (includes auth.accessUrl)
73
+ claw-insights logs -n 50 # Tail daemon logs
74
+ claw-insights restart # Restart daemon
75
+ claw-insights stop # Stop daemon
76
+ ```
77
+
78
+ ### 🔍 Full Replay — sessions & transcripts
79
+
80
+ Browse all sessions in the dashboard. Click any session to see the full transcript timeline — with role separation, tool call detail, and per-turn token / latency tracking.
81
+
82
+ ### 📸 Shareable Snapshots — capture & share
83
+
60
84
  ```bash
61
- claw-insights status # Show current access URL
62
- claw-insights stop # Stop daemon
63
- claw-insights start --no-auth # Disable authentication
85
+ claw-insights snapshot # Default: PNG, dark theme, 6h range
86
+ claw-insights snapshot --format svg --theme light # SVG light theme
87
+ claw-insights snapshot --range 24h --detail full # 24h detailed snapshot
88
+ claw-insights snapshot --lang zh --quick # Quick Chinese compact card
64
89
  ```
65
90
 
66
- Full install options, snapshot API, and troubleshooting: [docs/configuration.md](docs/configuration.md)
91
+ REST API for programmatic access:
92
+
93
+ ```bash
94
+ curl -X POST http://localhost:41041/api/snapshot \
95
+ -H "Authorization: Bearer $TOKEN" \
96
+ -d '{"format":"svg","theme":"light","detail":"full","range":"24h"}'
97
+ ```
98
+
99
+ ## How It Works
100
+
101
+ Claw Insights runs as a **read-only sidecar** for LLM & agent observability alongside your AI agent runtime.
102
+ It tails log files and CLI output — no SDK, no code changes, no network calls.
103
+
104
+ ```
105
+ Agent Runtime (OpenClaw / Claude Code / ...)
106
+
107
+ ├─ log files ──→ claw-insights daemon
108
+ │ │
109
+ ├─ CLI probe ──→ ├─→ SQLite (local-only storage)
110
+ │ ├─→ GraphQL API + SSE subscriptions
111
+ │ └─→ Satori renderer (PNG/SVG)
112
+ │ │
113
+ └─────────────────────────→ React dashboard (real-time)
114
+ ```
115
+
116
+ **Tech stack:** Express · GraphQL Yoga · SQLite · Satori · React 19 · Vite · ECharts
117
+
118
+ → Full configuration and install options: [docs/configuration.md](docs/configuration.md)
67
119
 
68
120
  ## 🤖 AI Agent Friendly
69
121
 
70
- Ships with structured resources for AI agents — see **[AGENTS.md](AGENTS.md)** for the full index:
122
+ Claw Insights ships with structured skills for AI agents —
123
+ your agent can install, operate, and capture snapshots autonomously.
124
+
125
+ See **[AGENTS.md](AGENTS.md)** for the full index.
71
126
 
72
- | Skill | Use case |
73
- | ----------------------------------------- | ------------------------------------------------- |
74
- | [install](docs/skills/install/SKILL.md) | Install, configure, and launch |
75
- | [snapshot](docs/skills/snapshot/SKILL.md) | Capture dashboard as PNG/SVG/JSON via REST or CLI |
127
+ ### Install Skill
128
+
129
+ Help AI agents set up Claw Insights from scratch — install, configure, launch, and verify.
130
+
131
+ ```bash
132
+ # Agent reads the skill, then executes:
133
+ npm install -g claw-insights
134
+ claw-insights start
135
+ claw-insights status # Verify: running + gateway connected
136
+ ```
137
+
138
+ → Full skill: [docs/skills/install/SKILL.md](docs/skills/install/SKILL.md)
139
+
140
+ ### Snapshot Skill
141
+
142
+ Teach agents to capture dashboard state as PNG/SVG/JSON and share to chat channels.
143
+
144
+ ```bash
145
+ # Capture a dark-theme Chinese snapshot for the last 6 hours
146
+ claw-insights snapshot --theme dark --lang zh --range 6h -o status.png
147
+
148
+ # REST API — programmatic access from any agent
149
+ curl -X POST http://localhost:41041/api/snapshot \
150
+ -H "Authorization: Bearer $TOKEN" \
151
+ -d '{"format":"svg","theme":"light","detail":"full"}'
152
+ ```
153
+
154
+ → Full skill: [docs/skills/snapshot/SKILL.md](docs/skills/snapshot/SKILL.md)
155
+
156
+ ## Roadmap
157
+
158
+ ✅ Shipped · 🔧 In Progress · 📋 Planned
159
+
160
+ - ✅ Session replay & transcript timeline
161
+ - ✅ Metrics dashboard (token analytics, error rates, uptime)
162
+ - ✅ Shareable snapshots (PNG / SVG / JSON)
163
+ - 🔧 Thinking / reasoning step visualization — *in progress*
164
+ - 🔧 Agent tool call observability — *in progress*
165
+ - 📋 Multiple data source adapters (Claude Code, Codex, ...)
166
+ - 📋 Multi-agent topology view
76
167
 
77
168
  ## Architecture
78
169
 
@@ -86,18 +177,16 @@ claw-insights/
86
177
  └── codegen.ts GraphQL codegen config (3 targets)
87
178
  ```
88
179
 
89
- **Data flow:** OpenClaw gateway → log tailing + CLI → SQLite → GraphQL (SSE subscriptions) → React
90
-
91
180
  → Full architecture, dev setup, and codegen: [docs/architecture.md](docs/architecture.md)
92
181
 
93
182
  ## Documentation
94
183
 
95
- | Document | Description |
96
- | -------------------------------------- | ------------------------------------- |
97
- | [Configuration](docs/configuration.md) | All env vars, config file, auth model |
98
- | [Architecture](docs/architecture.md) | System design, dev setup, testing |
99
- | [API Reference](docs/api-reference.md) | GraphQL + REST endpoint signatures |
100
- | [AGENTS.md](AGENTS.md) | AI agent skill index |
184
+ | Document | Description |
185
+ | -------------------------------------- | -------------------------------------------------- |
186
+ | [Configuration](docs/configuration.md) | All env vars, config file, auth model |
187
+ | [Architecture](docs/architecture.md) | System design, dev setup, testing |
188
+ | [API Reference](docs/api-reference.md) | GraphQL + REST endpoint signatures |
189
+ | [AGENTS.md](AGENTS.md) | AI agent skill index |
101
190
 
102
191
  ## Contributing
103
192
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claw-insights",
3
- "version": "0.1.3",
4
- "description": "Real-time monitoring dashboard for OpenClaw gateway",
3
+ "version": "0.1.5",
4
+ "description": "Open-source agent observability replay, metrics, logs & shareable snapshots",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "claw-insights": "./bin/claw-insights"
@@ -29,6 +29,7 @@ interface StatusJsonPayload {
29
29
  auth: {
30
30
  mode: string;
31
31
  tokenUrlPresent: boolean;
32
+ accessUrl: string | null;
32
33
  };
33
34
  health: {
34
35
  ok: boolean;
@@ -519,7 +519,11 @@ async function daemonStatus(options = {}) {
519
519
  version,
520
520
  server: { state: "stopped", pid: null, port, url: `http://127.0.0.1:${port}` },
521
521
  web: { enabled: !serverOnly, port: webPort, url: `http://127.0.0.1:${webPort}` },
522
- auth: { mode: noAuth ? "none" : "token-cookie", tokenUrlPresent: false },
522
+ auth: {
523
+ mode: noAuth ? "none" : "token-cookie",
524
+ tokenUrlPresent: false,
525
+ accessUrl: noAuth ? `http://127.0.0.1:${port}/` : null
526
+ },
523
527
  health: { ok: false, ready: false, gateway: "unknown", db: "unknown" }
524
528
  });
525
529
  console.log(JSON.stringify(payload));
@@ -542,12 +546,25 @@ async function daemonStatus(options = {}) {
542
546
  const version = resolveCliVersion(process.env);
543
547
  const isOk = healthResponseOk && healthData?.status === "ok";
544
548
  const state = healthResponseOk ? isOk ? "running" : "degraded" : "degraded";
545
- const tokenUrlPresent = existsSync2(join(paths.dataDir, "auth-token"));
549
+ const tokenFile = join(paths.dataDir, "auth-token");
550
+ let token = null;
551
+ if (!noAuth) {
552
+ try {
553
+ const rawToken = readFileSync2(tokenFile, "utf-8").trim();
554
+ if (rawToken) {
555
+ token = rawToken;
556
+ }
557
+ } catch {
558
+ token = null;
559
+ }
560
+ }
561
+ const tokenUrlPresent = token !== null;
562
+ const accessUrl = noAuth ? `http://127.0.0.1:${port}/` : token ? `http://127.0.0.1:${port}/?token=${token}` : null;
546
563
  const payload = buildStatusJson({
547
564
  version,
548
565
  server: { state, pid, port, url: `http://127.0.0.1:${port}` },
549
566
  web: { enabled: !serverOnly, port: webPort, url: `http://127.0.0.1:${webPort}` },
550
- auth: { mode: noAuth ? "none" : "token-cookie", tokenUrlPresent },
567
+ auth: { mode: noAuth ? "none" : "token-cookie", tokenUrlPresent, accessUrl },
551
568
  health: {
552
569
  ok: isOk,
553
570
  ready: isOk,
package/server/index.js CHANGED
@@ -3566,9 +3566,14 @@ function createGatewayClient(platform, options) {
3566
3566
  if (json.trim() === "") {
3567
3567
  return { ok: false, reason: "empty" };
3568
3568
  }
3569
+ const jsonStartIdx = json.indexOf("{");
3570
+ if (jsonStartIdx === -1) {
3571
+ return { ok: false, reason: "invalid-json" };
3572
+ }
3573
+ const cleanedJson = json.substring(jsonStartIdx);
3569
3574
  let d;
3570
3575
  try {
3571
- d = JSON.parse(json);
3576
+ d = JSON.parse(cleanedJson);
3572
3577
  } catch {
3573
3578
  return { ok: false, reason: "invalid-json" };
3574
3579
  }