@tangle-network/traces 0.8.16 → 0.8.18

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
@@ -17,6 +17,7 @@ It reads the transcripts your harness leaves on disk, reconstructs the run as sp
17
17
  - [What it finds](#what-it-finds)
18
18
  - [Supported harnesses](#supported-harnesses)
19
19
  - [CLI reference](#cli-reference)
20
+ - [Live stream](#live-stream)
20
21
  - [Improvement engine](#improvement-engine)
21
22
  - [Session index](#session-index)
22
23
  - [Policy-mining evidence](#policy-mining-evidence)
@@ -44,6 +45,8 @@ Requires Node ≥ 22.
44
45
  ```bash
45
46
  traces analyze --harness claude-code --last 1
46
47
  traces improve --harness claude-code --last 5 --dir .traces/improvement
48
+ traces watch --all
49
+ traces stream --all --no-spans
47
50
  ```
48
51
 
49
52
  That's the command in the demo above. The **deterministic pass** — stuck loops, token growth, output decay, missing self-verification, tool monoculture — needs no API key and costs nothing.
@@ -100,7 +103,9 @@ traces index --all --since 24h --out session-index.json
100
103
  traces inspect session-index.json --out inspection-report.md
101
104
  traces evidence --harness codex --last 20 --out policy-evidence.jsonl
102
105
  traces export policy-evidence.jsonl --out spans.openinference.jsonl
103
- traces watch --all # live observer; notify on stuck loops
106
+ traces watch --all # live observer; loops + semantic findings
107
+ traces stream --all --no-spans # live JSONL events for dashboards/visualizers
108
+ traces stream spans.openinference.jsonl --format openinference --no-spans
104
109
  traces upload --since 1h --dry-run # redact + dedup + preview, no network
105
110
  traces upload --since 24h # upload last day to the Intelligence Platform
106
111
  ```
@@ -116,14 +121,34 @@ traces upload --since 24h # upload last day to the Inte
116
121
  | `--out <path>` | Write the report to a file |
117
122
  | `--dir <path>` | `improve`: write the full artifact pack to this directory |
118
123
  | `--otlp <path>` | OTLP artifact path (also evidence provenance / dry-run upload preview) |
119
- | `--format <kind>` | `export`: `auto`, `policy-evidence`, `sandbox-events`, or `openinference` |
124
+ | `--format <kind>` | `export` / file `stream`: `auto`, `policy-evidence`, `sandbox-events`, or `openinference` |
120
125
  | `--llm` / `--budget <usd>` | Enable agentic analysts (needs `OPENAI_API_KEY`) / cap their spend |
121
126
  | `--config <path>` | `investigate` / `improve`: load BYO analysts, external analyzers, and proposal adapters |
122
- | `--interval <s>` / `--window <m>` | `watch`: poll seconds (default 5) / active-session window minutes (default 30) |
127
+ | `--interval <s>` / `--window <m>` | `watch` / live `stream`: poll seconds (default 5) / active-session window minutes (default 30) |
123
128
  | `--min-loop <n>` | Identical repeated calls before flagging a loop (default 3) |
129
+ | `--replay` / `--once` | `stream`: scan once, then exit |
130
+ | `--no-spans` / `--no-findings` | `stream`: suppress raw span rows / finding rows |
124
131
  | `--no-content` | `upload`: send metadata only — strip all prompt/response text |
125
132
  | `--dry-run` / `--yes` | `upload`: preview without sending / skip the confirm prompt |
126
133
 
134
+ ## Live stream
135
+
136
+ `traces watch` is the human terminal view.
137
+ It prints repeated-tool loops and semantic findings while a coding agent is still running.
138
+
139
+ `traces stream` is the machine feed.
140
+ It emits newline-delimited JSON events that a dashboard, art visualizer, local watcher, or hosted product can consume without scraping terminal prose.
141
+
142
+ ```bash
143
+ traces stream --all
144
+ traces stream --all --no-spans
145
+ traces stream spans.openinference.jsonl --format openinference --no-spans
146
+ ```
147
+
148
+ The stream emits `session`, `span`, `analysis_batch`, `finding`, and `tick` events.
149
+ The semantic findings currently cover repeated failing commands, verification churn without code/config changes, completion claims without later verification, and high tool-error rates.
150
+ Use `--no-spans` when you want the low-volume meaning layer; keep spans on for real-time visualizers that need motion, timing, and tool-call texture.
151
+
127
152
  ## Improvement engine
128
153
 
129
154
  `traces improve` turns observed sessions into a portable improvement packet:
@@ -289,6 +314,9 @@ The CLI is a thin consumer of these exports.
289
314
  | `runTraceStoreInvestigation` | `({ traceStore }) → TraceStoreInvestigationResult` | run the same packet layer over a hosted/custom `TraceAnalysisStore` |
290
315
  | `loadTracesConfig` | `(path?) → TracesConfig \| undefined` | load BYO analysts, external analyzers, and proposal adapters |
291
316
  | `watchSessions` | `(ObserverOptions) → Promise<void>` | live observer; `onLoop` / `onReport` / `signal` / `adapters` |
317
+ | `streamSessions` | `(TraceStreamOptions) → Promise<void>` | live JSONL-ready event stream over active sessions |
318
+ | `traceStreamEventsFromSpans` | `(spans, opts?) → TraceStreamEvent[]` | replay an existing span list as stream events |
319
+ | `analyzeLiveBatch` | `(spans, opts?) → TraceLiveBatch` | compute semantic online findings for one batch |
292
320
  | `collectSessionIndex` | `(ScanOptions) → TraceSessionIndex` | scan sessions and return a reusable JSON-ready catalog |
293
321
  | `inspectSessionIndex` | `(TraceSessionIndex) → TraceInspectionReport` | rank improvement findings from an index without rescanning sessions |
294
322
  | `buildPolicyEvidenceRecord` | `(ref, spans, opts?) → PolicyEvidenceRecord` | summarize one session for downstream policy mining |
@@ -303,12 +331,15 @@ The CLI is a thin consumer of these exports.
303
331
  | `ExternalAnalyzer` / `Redactor` | `haloAnalyzer` / `commandAnalyzer` / `commandRedactor` | drive engines/models you install (not bundled) |
304
332
 
305
333
  ```ts
306
- import { watchSessions, analyzeSpans, AnalystRegistry, makeFinding } from '@tangle-network/traces'
334
+ import { watchSessions, streamSessions, analyzeSpans, AnalystRegistry, makeFinding } from '@tangle-network/traces'
307
335
 
308
336
  // Observe live sessions, feed findings anywhere (read-only, cancellable):
309
337
  const c = new AbortController()
310
338
  await watchSessions({ all: true, signal: c.signal, onLoop: (l) => alert(l.toolName, l.occurrences) })
311
339
 
340
+ // Feed a visualizer or dashboard:
341
+ await streamSessions({ all: true, signal: c.signal, includeSpans: false, onEvent: (event) => console.log(event) })
342
+
312
343
  // Run your own analyst instead of the built-ins:
313
344
  const registry = new AnalystRegistry()
314
345
  registry.register({