@tangle-network/traces 0.7.0 → 0.8.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 +57 -3
- package/dist/{chunk-Q56AP2EY.js → chunk-D5OMTM4S.js} +1224 -315
- package/dist/cli.js +260 -12
- package/dist/index.d.ts +330 -28
- package/dist/index.js +51 -5
- package/package.json +12 -13
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
|
+
- [Policy-mining evidence](#policy-mining-evidence)
|
|
20
21
|
- [Upload to the Intelligence Platform](#upload-to-the-intelligence-platform)
|
|
21
22
|
- [External engines (bring your own)](#external-engines-bring-your-own)
|
|
22
23
|
- [Library (SDK)](#library-sdk)
|
|
@@ -43,7 +44,7 @@ That's the command in the demo above. The **deterministic pass** — stuck loops
|
|
|
43
44
|
|
|
44
45
|
Add `--llm` for the **agentic analysts** (failure-mode / knowledge-gap / knowledge-poisoning / improvement); they call OpenAI and respect `--budget <usd>`.
|
|
45
46
|
|
|
46
|
-
Every run also writes
|
|
47
|
+
Every run also writes a **canonical OpenInference JSONL artifact**, so you can run external engines like [HALO](https://github.com/context-labs/halo) over it directly with `--analyzer halo` — see [External engines](#external-engines-bring-your-own). Analysis is never locked to one engine.
|
|
47
48
|
|
|
48
49
|
## What it finds
|
|
49
50
|
|
|
@@ -85,6 +86,8 @@ traces list --harness claude-code --last 20 # discover sessions
|
|
|
85
86
|
traces analyze --harness codex --last 1 # $0 deterministic report
|
|
86
87
|
traces analyze --all --since 2026-06-18 --out report.md
|
|
87
88
|
traces convert --harness claude-code --last 1 --otlp spans.jsonl # OTLP only
|
|
89
|
+
traces evidence --harness codex --last 20 --out policy-evidence.jsonl
|
|
90
|
+
traces export policy-evidence.jsonl --out spans.openinference.jsonl
|
|
88
91
|
traces watch --all # live observer; notify on stuck loops
|
|
89
92
|
traces upload --since 1h --dry-run # redact + dedup + preview, no network
|
|
90
93
|
traces upload --since 24h # upload last day to the Intelligence Platform
|
|
@@ -99,13 +102,50 @@ traces upload --since 24h # upload last day to the Inte
|
|
|
99
102
|
| `--cwd <dir>` | Filter by working directory |
|
|
100
103
|
| `--since <t>` | `upload`: window — `30m`/`2h`/`7d` or ISO (default 24h); `analyze`: ISO cutoff |
|
|
101
104
|
| `--out <path>` | Write the report to a file |
|
|
102
|
-
| `--otlp <path>` | OTLP artifact path (also
|
|
105
|
+
| `--otlp <path>` | OTLP artifact path (also evidence provenance / dry-run upload preview) |
|
|
106
|
+
| `--format <kind>` | `export`: `auto`, `policy-evidence`, `sandbox-events`, or `openinference` |
|
|
103
107
|
| `--llm` / `--budget <usd>` | Enable agentic analysts (needs `OPENAI_API_KEY`) / cap their spend |
|
|
104
108
|
| `--interval <s>` / `--window <m>` | `watch`: poll seconds (default 5) / active-session window minutes (default 30) |
|
|
105
109
|
| `--min-loop <n>` | Identical repeated calls before flagging a loop (default 3) |
|
|
106
110
|
| `--no-content` | `upload`: send metadata only — strip all prompt/response text |
|
|
107
111
|
| `--dry-run` / `--yes` | `upload`: preview without sending / skip the confirm prompt |
|
|
108
112
|
|
|
113
|
+
## Policy-mining evidence
|
|
114
|
+
|
|
115
|
+
`traces` does **not** emit benchmark campaign cells. It emits normalized coding-agent session evidence that another system can mine.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
traces evidence --all --since 24h --out policy-evidence.jsonl --otlp spans.otlp.jsonl
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Each JSONL row is one session:
|
|
122
|
+
|
|
123
|
+
- session provenance: harness, session id, cwd, path, mtime
|
|
124
|
+
- repo labels: `tangle.subject.key`, `git.repository`, branch, commit
|
|
125
|
+
- behavior metrics: span counts, LLM turns, tool calls, errored tool calls, tokens, models, tool histogram
|
|
126
|
+
- mining signals: stuck loops and tool error rate
|
|
127
|
+
- provenance marker: `notCampaignCell: true`
|
|
128
|
+
|
|
129
|
+
That boundary matters. `agent-lab` campaign `cells.jsonl` says "arm X beat arm Y on task Z." `traces evidence` says "this real agent session had this repo/model/tool/failure shape." A downstream policy compiler can cluster these rows, propose candidate policies, then validate those policies in a separate eval campaign.
|
|
130
|
+
|
|
131
|
+
### Export existing evidence/events to OpenInference
|
|
132
|
+
|
|
133
|
+
If you already have compact evidence or Sandbox/OpenCode event captures on disk, convert them to the same OpenInference JSONL shape that `traces analyze --analyzer halo` uses:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
traces export policy-evidence.jsonl --out spans.openinference.jsonl
|
|
137
|
+
traces export sandbox-events.json --format sandbox-events --out spans.openinference.jsonl
|
|
138
|
+
halo spans.openinference.jsonl --prompt "Analyze this trace slice" --max-turns 1
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`traces export` accepts:
|
|
142
|
+
|
|
143
|
+
- compact `traces.policy_evidence.session` JSONL from `traces evidence`
|
|
144
|
+
- Sandbox/OpenCode JSON arrays with `start`, `raw`, `result`, `done`, and `error` events
|
|
145
|
+
- existing OpenInference JSONL, rewritten through the local redaction path
|
|
146
|
+
|
|
147
|
+
Run `traces export --help` for the full command reference.
|
|
148
|
+
|
|
109
149
|
## Upload to the Intelligence Platform
|
|
110
150
|
|
|
111
151
|
`upload` **redacts locally before anything leaves the machine**, dedups against already-uploaded sessions, and tags each with metadata (harness, cwd, git branch, host).
|
|
@@ -142,7 +182,7 @@ traces analyze --last 1 --analyzer halo --analyzer-prompt "find token waste"
|
|
|
142
182
|
traces analyze --last 1 --analyzer halo --analyzer my-engine # repeatable
|
|
143
183
|
```
|
|
144
184
|
|
|
145
|
-
|
|
185
|
+
Our OTLP artifact is **canonical OpenInference** (top-level `kind`, `resource`, `scope`), so HALO reads it directly — no conversion. HALO runs its *own* LLM (OpenAI client — set `OPENAI_BASE_URL` / `OPENAI_API_KEY`, or use HALO's provider); `--model` is forwarded to it. traces supplies the trace and drives the CLI; it doesn't pay for or configure HALO's model.
|
|
146
186
|
|
|
147
187
|
**Redactors** scrub prompt/response prose with an external PII model (catching names/addresses the regex pass can't), running *after* the built-in redaction:
|
|
148
188
|
|
|
@@ -155,6 +195,17 @@ In the SDK these are the `ExternalAnalyzer` and `Redactor` interfaces (`haloAnal
|
|
|
155
195
|
|
|
156
196
|
> For the built-in agentic analysts (`--llm`), set `OPENAI_API_KEY` — or point at any OpenAI-compatible gateway with `OPENAI_BASE_URL` (e.g. an internal router) to use a non-OpenAI key.
|
|
157
197
|
|
|
198
|
+
## Release automation
|
|
199
|
+
|
|
200
|
+
Merging to `main` publishes a patch release automatically:
|
|
201
|
+
|
|
202
|
+
1. The Publish workflow bumps `package.json` from `X.Y.Z` to `X.Y.(Z+1)`.
|
|
203
|
+
2. It commits `chore(release): vX.Y.(Z+1) [skip release]` back to `main`.
|
|
204
|
+
3. It pushes the matching `vX.Y.(Z+1)` tag.
|
|
205
|
+
4. The same workflow verifies the tag, builds, publishes to npm, and creates a GitHub release.
|
|
206
|
+
|
|
207
|
+
Minor releases are manual. Run the Publish workflow from GitHub Actions and choose `minor`; it publishes `X.(Y+1).0`. Use manual `patch` only when you need a patch release without merging a new code change.
|
|
208
|
+
|
|
158
209
|
## Library (SDK)
|
|
159
210
|
|
|
160
211
|
The CLI is a thin consumer of these exports.
|
|
@@ -163,6 +214,9 @@ The CLI is a thin consumer of these exports.
|
|
|
163
214
|
|---|---|---|
|
|
164
215
|
| `analyzeSpans` | `(spans, { registry?, ai?, budgetUsd? }) → AnalyzeResult` | run analysts — built-in, or **your own** via `registry` |
|
|
165
216
|
| `watchSessions` | `(ObserverOptions) → Promise<void>` | live observer; `onLoop` / `onReport` / `signal` / `adapters` |
|
|
217
|
+
| `buildPolicyEvidenceRecord` | `(ref, spans, opts?) → PolicyEvidenceRecord` | summarize one session for downstream policy mining |
|
|
218
|
+
| `collectPolicyEvidence` | `(ScanOptions) → PolicyEvidenceRecord[]` | scan harness sessions and emit policy-evidence rows |
|
|
219
|
+
| `exportTraceEvidenceFile` | `(path, opts?) → { format, spans, redactionCount }` | convert compact evidence/events/OpenInference files to redacted OpenInference spans |
|
|
166
220
|
| `scanSessions` | `(ScanOptions) → AsyncIterable<ScannedSession>` | the shared locate→parse iterator |
|
|
167
221
|
| `collectSessions` | `(CollectOptions) → SessionBatch[]` | redacted per-session batches for your own pipeline |
|
|
168
222
|
| `redactSpans` | `(spans, rules?) → { spans, report }` | PII/secret redaction (`TRACES_REDACTION_RULES`) |
|