@tangle-network/traces 0.1.0 → 0.2.0
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 +64 -3
- package/dist/chunk-HPBKRTTP.js +1924 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +128 -1639
- package/dist/index.d.ts +657 -0
- package/dist/index.js +126 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -45,6 +45,9 @@ traces analyze --harness codex --last 1 # $0 deterministic report
|
|
|
45
45
|
traces analyze --all --since 2026-06-18 --out report.md
|
|
46
46
|
traces convert --harness claude-code --last 1 --otlp spans.jsonl # OTLP only → HALO
|
|
47
47
|
traces analyze --harness claude-code --last 1 --llm # +agentic (needs OPENAI_API_KEY)
|
|
48
|
+
traces watch --all # live observer: notify on stuck loops (read-only)
|
|
49
|
+
traces upload --since 1h --dry-run # redact + dedup + preview, no network
|
|
50
|
+
traces upload --since 24h # upload last day to the Intelligence Platform
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
### Options
|
|
@@ -56,11 +59,69 @@ traces analyze --harness claude-code --last 1 --llm # +agentic (needs OPENAI_A
|
|
|
56
59
|
| `--last <n>` | Most-recent N sessions |
|
|
57
60
|
| `--session <path>` | Analyze one explicit session file |
|
|
58
61
|
| `--cwd <dir>` | Filter sessions by working directory |
|
|
59
|
-
| `--since <
|
|
62
|
+
| `--since <t>` | `upload`: window — `30m`/`2h`/`7d` or ISO (default 24h); `analyze`: ISO cutoff |
|
|
60
63
|
| `--out <path>` | Write report to a file |
|
|
61
|
-
| `--otlp <path>` | OTLP artifact path |
|
|
64
|
+
| `--otlp <path>` | OTLP artifact path (also the dry-run upload preview) |
|
|
62
65
|
| `--llm` | Enable agentic RLM analysts (needs `OPENAI_API_KEY`) |
|
|
63
66
|
| `--budget <usd>` | USD cap for agentic analysts |
|
|
67
|
+
| `--dry-run` | `upload`: redact + dedup + preview, do not send |
|
|
68
|
+
| `--yes`, `-y` | `upload`: skip the confirmation prompt |
|
|
69
|
+
| `--interval <s>` / `--window <m>` | `watch`: poll interval / active-session window |
|
|
70
|
+
| `--min-loop <n>` | Identical repeated calls before flagging a loop (default 3) |
|
|
71
|
+
|
|
72
|
+
**Upload** redacts PII/secrets *before anything leaves the machine*, dedups against already-uploaded sessions, and tags each session with metadata (harness, cwd, git branch, host). It needs the platform env: `TANGLE_INGEST_URL` (or `TANGLE_ORCHESTRATOR_URL`), `TANGLE_INGEST_API_KEY` (or `TANGLE_API_KEY`), `TANGLE_TENANT_ID`. Without them, `--dry-run` still works fully.
|
|
73
|
+
|
|
74
|
+
## Use as a library
|
|
75
|
+
|
|
76
|
+
The CLI is a thin layer over an exported SDK — build your own tooling on top:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import {
|
|
80
|
+
watchSessions, collectSessions, analyzeSpans, executeUpload,
|
|
81
|
+
AnalystRegistry, makeFinding, listAdapters,
|
|
82
|
+
} from '@tangle-network/traces'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Observe live sessions** and feed findings into your own system (read-only, cancellable):
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const controller = new AbortController()
|
|
89
|
+
await watchSessions({
|
|
90
|
+
all: true,
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
onLoop: (loop) => alertSlack(`stuck loop: ${loop.toolName} ×${loop.occurrences} in ${loop.sessionId}`),
|
|
93
|
+
onReport: (ref, report) => metrics.record(ref.harness, report.toolUse),
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Run your OWN analysts** (any agent/detector) instead of the built-ins — register against the
|
|
98
|
+
[`@tangle-network/agent-eval`](https://www.npmjs.com/package/@tangle-network/agent-eval) `AnalystRegistry`:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const registry = new AnalystRegistry()
|
|
102
|
+
registry.register({
|
|
103
|
+
id: 'my-detector', description: '…', inputKind: 'trace-store',
|
|
104
|
+
cost: { kind: 'deterministic' }, version: '1.0.0',
|
|
105
|
+
async analyze(store, ctx) { /* your logic */ return [makeFinding({ /* … */ })] },
|
|
106
|
+
})
|
|
107
|
+
const { result } = await analyzeSpans(spans, { registry })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Collect redacted batches** to feed a vector store / fine-tune corpus / another pipeline:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const batches = await collectSessions({ all: true, sinceMs: Date.now() - 3_600_000 })
|
|
114
|
+
// → [{ ref, spans /* redacted */, redaction }]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Upload to your own backend** (anything implementing `ingestTraces`), not just Tangle:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
await executeUpload(plan, { backend: { async ingestTraces(spans, key) { /* POST anywhere */ return { accepted: spans.length } } } })
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Register a new harness** — implement `HarnessTraceAdapter` (`locate` + `parse`) and pass it via
|
|
124
|
+
`adapters: [...]` to `watchSessions`/`collectSessions`, or drop a file in `src/adapters/`.
|
|
64
125
|
|
|
65
126
|
## Develop
|
|
66
127
|
|
|
@@ -69,5 +130,5 @@ pnpm install
|
|
|
69
130
|
pnpm dev analyze --harness claude-code --last 1 # run from source via tsx
|
|
70
131
|
pnpm test
|
|
71
132
|
pnpm typecheck
|
|
72
|
-
pnpm build # → dist/
|
|
133
|
+
pnpm build # → dist/index.js (SDK) + dist/cli.js (bin) + .d.ts
|
|
73
134
|
```
|