@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 +35 -4
- package/dist/{chunk-EOQY2RIK.js → chunk-G3OBZSWY.js} +553 -83
- package/dist/cli.js +153 -14
- package/dist/index.d.ts +115 -2
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -33,18 +33,22 @@ import {
|
|
|
33
33
|
serializePolicyEvidence,
|
|
34
34
|
serializeSessionIndex,
|
|
35
35
|
serializeSpans,
|
|
36
|
+
serializeTraceStreamEvent,
|
|
37
|
+
streamSessions,
|
|
36
38
|
summarizeDeterministicSignals,
|
|
39
|
+
traceStreamEventsFromSpans,
|
|
37
40
|
watchSessions,
|
|
38
41
|
writeInspectionReportFile,
|
|
39
42
|
writeOtlpFile,
|
|
40
43
|
writePolicyEvidenceFile,
|
|
41
44
|
writeSessionIndexFile,
|
|
42
45
|
writeTraceEvidenceExportFile
|
|
43
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-G3OBZSWY.js";
|
|
44
47
|
|
|
45
48
|
// src/cli.ts
|
|
46
49
|
import { readFileSync } from "fs";
|
|
47
50
|
import { readFile, stat, writeFile } from "fs/promises";
|
|
51
|
+
import { basename, resolve } from "path";
|
|
48
52
|
function packageVersion() {
|
|
49
53
|
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
50
54
|
if (typeof pkg.version !== "string" || !pkg.version) throw new Error("package.json is missing version");
|
|
@@ -66,6 +70,9 @@ function parseArgs(argv) {
|
|
|
66
70
|
yes: false,
|
|
67
71
|
noContent: false,
|
|
68
72
|
analyzers: [],
|
|
73
|
+
replay: false,
|
|
74
|
+
noSpans: false,
|
|
75
|
+
noFindings: false,
|
|
69
76
|
attrs: []
|
|
70
77
|
};
|
|
71
78
|
for (let i = 1; i < argv.length; i++) {
|
|
@@ -135,6 +142,16 @@ function parseArgs(argv) {
|
|
|
135
142
|
case "--no-content":
|
|
136
143
|
a.noContent = true;
|
|
137
144
|
break;
|
|
145
|
+
case "--replay":
|
|
146
|
+
case "--once":
|
|
147
|
+
a.replay = true;
|
|
148
|
+
break;
|
|
149
|
+
case "--no-spans":
|
|
150
|
+
a.noSpans = true;
|
|
151
|
+
break;
|
|
152
|
+
case "--no-findings":
|
|
153
|
+
a.noFindings = true;
|
|
154
|
+
break;
|
|
138
155
|
case "--analyzer": {
|
|
139
156
|
const v = next();
|
|
140
157
|
if (v) a.analyzers.push(v);
|
|
@@ -326,10 +343,7 @@ async function cmdInspect(args) {
|
|
|
326
343
|
}
|
|
327
344
|
async function cmdExport(args) {
|
|
328
345
|
if (!args.input) throw new Error("export needs an input file; run `traces export --help` for examples");
|
|
329
|
-
const format = args.format
|
|
330
|
-
if (format !== "auto" && format !== "policy-evidence" && format !== "sandbox-events" && format !== "openinference") {
|
|
331
|
-
throw new Error("--format must be auto, policy-evidence, sandbox-events, or openinference");
|
|
332
|
-
}
|
|
346
|
+
const format = traceEvidenceFormat(args.format);
|
|
333
347
|
const attributes = await loadExportAttributes(args);
|
|
334
348
|
const outPath = args.out ?? args.otlp;
|
|
335
349
|
if (outPath) {
|
|
@@ -342,6 +356,13 @@ async function cmdExport(args) {
|
|
|
342
356
|
const result = await exportTraceEvidenceFile(args.input, { format, attributes });
|
|
343
357
|
process.stdout.write(serializeSpans(result.spans));
|
|
344
358
|
}
|
|
359
|
+
function traceEvidenceFormat(raw) {
|
|
360
|
+
const format = raw ?? "auto";
|
|
361
|
+
if (format !== "auto" && format !== "policy-evidence" && format !== "sandbox-events" && format !== "openinference" && format !== "intelligence-spans") {
|
|
362
|
+
throw new Error("--format must be auto, policy-evidence, sandbox-events, openinference, or intelligence-spans");
|
|
363
|
+
}
|
|
364
|
+
return format;
|
|
365
|
+
}
|
|
345
366
|
function parseAttributeValue(raw) {
|
|
346
367
|
if (raw === "true") return true;
|
|
347
368
|
if (raw === "false") return false;
|
|
@@ -368,7 +389,7 @@ async function loadExportAttributes(args) {
|
|
|
368
389
|
return attributes;
|
|
369
390
|
}
|
|
370
391
|
async function cmdAnalyze(args) {
|
|
371
|
-
const { spans, harness, sessionCount, cwds } = await collectSpans(args);
|
|
392
|
+
const { spans, harness, sessionCount, cwds } = args.input ? await collectImportedSpans(args) : await collectSpans(args);
|
|
372
393
|
if (spans.length === 0) throw new Error("no spans found for the given selection");
|
|
373
394
|
const ai = args.llm ? await buildAxService() : void 0;
|
|
374
395
|
const { otlpPath, result } = await analyzeSpans(spans, {
|
|
@@ -405,6 +426,21 @@ ${r.ok ? r.output || "(no output)" : `failed: ${r.error}`}`;
|
|
|
405
426
|
console.log(report);
|
|
406
427
|
}
|
|
407
428
|
}
|
|
429
|
+
async function collectImportedSpans(args) {
|
|
430
|
+
if (!args.input) throw new Error("analyze input missing");
|
|
431
|
+
const attributes = await loadExportAttributes(args);
|
|
432
|
+
const result = await exportTraceEvidenceFile(args.input, {
|
|
433
|
+
format: traceEvidenceFormat(args.format),
|
|
434
|
+
attributes
|
|
435
|
+
});
|
|
436
|
+
const traceIds = new Set(result.spans.map((s) => s.trace_id).filter(Boolean));
|
|
437
|
+
return {
|
|
438
|
+
spans: result.spans,
|
|
439
|
+
harness: result.format,
|
|
440
|
+
sessionCount: traceIds.size || 1,
|
|
441
|
+
cwds: []
|
|
442
|
+
};
|
|
443
|
+
}
|
|
408
444
|
function externalAnalyzersFromArgs(args) {
|
|
409
445
|
return args.analyzers.map(
|
|
410
446
|
(spec) => spec === "halo" ? haloAnalyzer({ defaultPrompt: args.analyzerPrompt, model: args.model }) : commandAnalyzer({ name: spec, command: spec, args: (p, prompt) => prompt ? [p, prompt] : [p] })
|
|
@@ -467,12 +503,102 @@ async function cmdImprove(args) {
|
|
|
467
503
|
`improvement artifacts \u2192 ${dir} (${result.findings.length} findings, ${result.recommendations.length} recommendations, ${result.proposals.length} proposal(s), OTLP: ${result.otlpPath})`
|
|
468
504
|
);
|
|
469
505
|
}
|
|
506
|
+
function summarizeFindingEvidence(finding) {
|
|
507
|
+
const first = finding.evidence[0];
|
|
508
|
+
if (!first) return "no evidence";
|
|
509
|
+
return `${first.label}: ${first.value}`;
|
|
510
|
+
}
|
|
511
|
+
function formatLiveFinding(finding) {
|
|
512
|
+
const ts = new Date(finding.observedAt).toISOString().slice(11, 19);
|
|
513
|
+
const where = `[${finding.session.harness}] ${finding.session.sessionId.slice(0, 8)}`;
|
|
514
|
+
const cwd = finding.session.cwd ? ` \xB7 ${finding.session.cwd}` : "";
|
|
515
|
+
return [
|
|
516
|
+
`${ts} ${finding.severity.toUpperCase()} ${where} \u2014 ${finding.title}${cwd}`,
|
|
517
|
+
` evidence: ${summarizeFindingEvidence(finding)}`,
|
|
518
|
+
` action: ${finding.action}`,
|
|
519
|
+
` check: ${finding.check}`
|
|
520
|
+
].join("\n");
|
|
521
|
+
}
|
|
522
|
+
async function streamExplicitSession(args) {
|
|
523
|
+
if (!args.session) throw new Error("streamExplicitSession needs --session");
|
|
524
|
+
const adapter = resolveAdapter(args.harness);
|
|
525
|
+
if (!adapter) throw new Error(`unknown harness "${args.harness}"`);
|
|
526
|
+
const st = await stat(args.session);
|
|
527
|
+
const ref = {
|
|
528
|
+
harness: adapter.harness,
|
|
529
|
+
sessionId: basename(args.session),
|
|
530
|
+
path: resolve(args.session),
|
|
531
|
+
cwd: args.cwd ?? null,
|
|
532
|
+
mtimeMs: st.mtimeMs
|
|
533
|
+
};
|
|
534
|
+
const spans = await parseSession(adapter, ref);
|
|
535
|
+
for (const event of traceStreamEventsFromSpans(spans, {
|
|
536
|
+
ref,
|
|
537
|
+
includeSpans: !args.noSpans,
|
|
538
|
+
includeFindings: !args.noFindings
|
|
539
|
+
})) {
|
|
540
|
+
process.stdout.write(serializeTraceStreamEvent(event));
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
async function cmdStream(args) {
|
|
544
|
+
if (args.input) {
|
|
545
|
+
const { spans, harness } = await collectImportedSpans(args);
|
|
546
|
+
const ref = {
|
|
547
|
+
harness,
|
|
548
|
+
sessionId: basename(args.input),
|
|
549
|
+
path: resolve(args.input),
|
|
550
|
+
cwd: args.cwd ?? null,
|
|
551
|
+
mtimeMs: Date.now()
|
|
552
|
+
};
|
|
553
|
+
for (const event of traceStreamEventsFromSpans(spans, {
|
|
554
|
+
ref,
|
|
555
|
+
includeSpans: !args.noSpans,
|
|
556
|
+
includeFindings: !args.noFindings
|
|
557
|
+
})) {
|
|
558
|
+
process.stdout.write(serializeTraceStreamEvent(event));
|
|
559
|
+
}
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (args.session) {
|
|
563
|
+
await streamExplicitSession(args);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const all = args.all || !args.harnessExplicit && !args.cwd;
|
|
567
|
+
const controller = new AbortController();
|
|
568
|
+
process.once("SIGINT", () => controller.abort());
|
|
569
|
+
if (!args.replay) {
|
|
570
|
+
process.stderr.write(
|
|
571
|
+
`traces stream \u2014 JSONL live feed for ${all ? "all harnesses" : args.harness}, last ${args.window}m, every ${args.interval}s. Ctrl-C to stop.
|
|
572
|
+
`
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
await streamSessions({
|
|
576
|
+
all,
|
|
577
|
+
harnesses: all ? void 0 : [args.harness],
|
|
578
|
+
cwd: args.cwd,
|
|
579
|
+
last: args.last > 0 ? args.last : args.replay ? 1 : void 0,
|
|
580
|
+
windowMs: args.window * 6e4,
|
|
581
|
+
intervalMs: args.interval * 1e3,
|
|
582
|
+
once: args.replay,
|
|
583
|
+
includeSpans: !args.noSpans,
|
|
584
|
+
includeFindings: !args.noFindings,
|
|
585
|
+
signal: controller.signal,
|
|
586
|
+
onEvent: (event) => {
|
|
587
|
+
process.stdout.write(serializeTraceStreamEvent(event));
|
|
588
|
+
},
|
|
589
|
+
onError: (err, ref) => {
|
|
590
|
+
const where = ref ? ` [${ref.harness}] ${ref.sessionId}` : "";
|
|
591
|
+
process.stderr.write(`stream error${where}: ${err instanceof Error ? err.message : String(err)}
|
|
592
|
+
`);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
470
596
|
async function cmdWatch(args) {
|
|
471
597
|
const all = args.all || !args.harnessExplicit && !args.cwd;
|
|
472
598
|
const controller = new AbortController();
|
|
473
599
|
process.once("SIGINT", () => controller.abort());
|
|
474
600
|
process.stderr.write(
|
|
475
|
-
`traces watch \u2014 observing ${all ? "all harnesses" : args.harness}, sessions active in the last ${args.window}m, every ${args.interval}s.
|
|
601
|
+
`traces watch \u2014 observing ${all ? "all harnesses" : args.harness}, sessions active in the last ${args.window}m, every ${args.interval}s. Loop + semantic live findings; read-only; Ctrl-C to stop.
|
|
476
602
|
`
|
|
477
603
|
);
|
|
478
604
|
await watchSessions({
|
|
@@ -486,9 +612,13 @@ async function cmdWatch(args) {
|
|
|
486
612
|
onLoop: (l) => {
|
|
487
613
|
const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 19);
|
|
488
614
|
process.stdout.write(
|
|
489
|
-
|
|
615
|
+
`${ts} LOOP [${l.harness}] ${l.sessionId.slice(0, 8)} \u2014 \`${l.toolName}\` repeated \xD7${l.occurrences} with identical args (${(l.windowMs / 1e3).toFixed(0)}s)${l.cwd ? ` \xB7 ${l.cwd}` : ""}
|
|
490
616
|
`
|
|
491
617
|
);
|
|
618
|
+
},
|
|
619
|
+
onFinding: (finding) => {
|
|
620
|
+
process.stdout.write(`${formatLiveFinding(finding)}
|
|
621
|
+
`);
|
|
492
622
|
}
|
|
493
623
|
});
|
|
494
624
|
}
|
|
@@ -560,12 +690,14 @@ Input formats:
|
|
|
560
690
|
policy-evidence Compact JSONL rows from \`traces evidence --out policy-evidence.jsonl\`
|
|
561
691
|
sandbox-events Sandbox/OpenCode event arrays with start/raw/result/done/error events
|
|
562
692
|
openinference Existing OpenInference JSONL; rewrites through traces redaction
|
|
693
|
+
intelligence-spans JSONL rows exported from Tangle Intelligence trace spans
|
|
563
694
|
auto Detect the format from the file contents (default)
|
|
564
695
|
|
|
565
696
|
Examples:
|
|
566
697
|
traces evidence --all --since 24h --out policy-evidence.jsonl
|
|
567
698
|
traces export policy-evidence.jsonl --out spans.openinference.jsonl
|
|
568
699
|
traces export sandbox-events.json --format sandbox-events --out spans.openinference.jsonl
|
|
700
|
+
traces export intelligence-spans.jsonl --out spans.openinference.jsonl
|
|
569
701
|
traces export sandbox-events.json --attr task.id=aec-001 --attr outcome.score=1 --out spans.openinference.jsonl
|
|
570
702
|
halo spans.openinference.jsonl --prompt "Analyze this trace slice" --max-turns 1
|
|
571
703
|
|
|
@@ -578,7 +710,7 @@ function usage() {
|
|
|
578
710
|
|
|
579
711
|
Commands:
|
|
580
712
|
list List discovered sessions
|
|
581
|
-
analyze Run analyst suite + loop/waste pipelines
|
|
713
|
+
analyze Run analyst suite + loop/waste pipelines over sessions or an input file
|
|
582
714
|
investigate Run typed investigation flow, including BYO config + recommendations
|
|
583
715
|
improve Write a full improvement artifact directory for review/apply/rerun
|
|
584
716
|
convert Emit OTLP-JSONL only (HALO: use analyze --analyzer halo)
|
|
@@ -586,22 +718,26 @@ Commands:
|
|
|
586
718
|
inspect Read a session index and print ranked improvement findings
|
|
587
719
|
export Convert evidence/events files to OpenInference JSONL for HALO
|
|
588
720
|
evidence Emit compact session-evidence JSONL for downstream policy miners
|
|
589
|
-
|
|
721
|
+
stream Emit JSONL trace stream events for live visualizers or replay
|
|
722
|
+
watch Online observer: tail active sessions, notify on loops + semantic findings
|
|
590
723
|
upload Redact + upload sessions in a time window to the Tangle Intelligence Platform
|
|
591
724
|
|
|
592
725
|
Options:
|
|
593
726
|
--harness <id> Harness or alias (default: claude-code). Known: ${knownHarnesses().join(", ")}
|
|
594
727
|
--all Sweep every known harness
|
|
595
728
|
--last <n> Most-recent N sessions
|
|
596
|
-
--session <path> Analyze one explicit session file
|
|
729
|
+
--session <path> Analyze/stream one explicit harness session file
|
|
597
730
|
--cwd <dir> Filter sessions by working directory
|
|
598
731
|
--since <t> upload: window \u2014 30m / 2h / 7d or an ISO date (default 24h); analyze: ISO cutoff
|
|
599
732
|
--out <path> Write report to a file
|
|
600
733
|
--dir <path> improve: write artifacts to this directory
|
|
601
734
|
--otlp <path> OTLP artifact path (also evidence provenance / dry-run upload preview)
|
|
602
|
-
--format <kind> export: auto | policy-evidence | sandbox-events | openinference
|
|
603
|
-
--metadata <json> export: attach JSON object fields as span attributes
|
|
604
|
-
--attr <k=v> export: attach one span attribute (repeatable)
|
|
735
|
+
--format <kind> analyze/export file: auto | policy-evidence | sandbox-events | openinference | intelligence-spans
|
|
736
|
+
--metadata <json> analyze/export file: attach JSON object fields as span attributes
|
|
737
|
+
--attr <k=v> analyze/export file: attach one span attribute (repeatable)
|
|
738
|
+
--replay, --once stream: scan once and exit (default for positional input / --session)
|
|
739
|
+
--no-spans stream: omit per-span pulse events
|
|
740
|
+
--no-findings stream: omit semantic live-finding events
|
|
605
741
|
--llm Enable agentic RLM analysts (needs OPENAI_API_KEY / OPENAI_BASE_URL)
|
|
606
742
|
--model <id> --llm model id (e.g. a router model like glm-5.2); default is agent-eval's
|
|
607
743
|
--config <path> investigate/improve: JS config with analysts, external analyzers, or proposal adapter
|
|
@@ -664,6 +800,9 @@ async function main() {
|
|
|
664
800
|
case "evidence":
|
|
665
801
|
await cmdEvidence(args);
|
|
666
802
|
break;
|
|
803
|
+
case "stream":
|
|
804
|
+
await cmdStream(args);
|
|
805
|
+
break;
|
|
667
806
|
case "watch":
|
|
668
807
|
await cmdWatch(args);
|
|
669
808
|
break;
|
package/dist/index.d.ts
CHANGED
|
@@ -998,7 +998,7 @@ declare function readSessionIndexFile(path: string): Promise<TraceSessionIndex>;
|
|
|
998
998
|
declare function writeInspectionReportFile(report: TraceInspectionReport, outPath?: string): Promise<string>;
|
|
999
999
|
|
|
1000
1000
|
type JsonObject = Record<string, unknown>;
|
|
1001
|
-
type TraceEvidenceInputFormat = 'policy-evidence' | 'sandbox-events' | 'openinference';
|
|
1001
|
+
type TraceEvidenceInputFormat = 'policy-evidence' | 'sandbox-events' | 'openinference' | 'intelligence-spans';
|
|
1002
1002
|
type TraceEvidenceFormatOption = TraceEvidenceInputFormat | 'auto';
|
|
1003
1003
|
interface TraceEvidenceExportOptions {
|
|
1004
1004
|
readonly format?: TraceEvidenceFormatOption;
|
|
@@ -1276,6 +1276,115 @@ declare function writeTraceImprovementArtifacts(result: Pick<TraceImprovementRes
|
|
|
1276
1276
|
declare function runTraceImprovementLoop(opts: TraceImprovementOptions): Promise<TraceImprovementResult>;
|
|
1277
1277
|
declare function saveReport(path: string, report: string): Promise<void>;
|
|
1278
1278
|
|
|
1279
|
+
type TraceLiveSeverity = 'info' | 'low' | 'medium' | 'high';
|
|
1280
|
+
interface TraceLiveEvidence {
|
|
1281
|
+
readonly kind: 'metric' | 'span' | 'pattern';
|
|
1282
|
+
readonly label: string;
|
|
1283
|
+
readonly value: string;
|
|
1284
|
+
readonly spanIds?: readonly string[];
|
|
1285
|
+
}
|
|
1286
|
+
interface TraceLiveFinding {
|
|
1287
|
+
readonly schemaVersion: 1;
|
|
1288
|
+
readonly kind: 'traces.live_finding';
|
|
1289
|
+
readonly id: string;
|
|
1290
|
+
readonly ruleId: string;
|
|
1291
|
+
readonly fingerprint: string;
|
|
1292
|
+
readonly severity: TraceLiveSeverity;
|
|
1293
|
+
readonly title: string;
|
|
1294
|
+
readonly claim: string;
|
|
1295
|
+
readonly action: string;
|
|
1296
|
+
readonly check: string;
|
|
1297
|
+
readonly evidence: readonly TraceLiveEvidence[];
|
|
1298
|
+
readonly session: TraceStreamSession;
|
|
1299
|
+
readonly observedAt: string;
|
|
1300
|
+
}
|
|
1301
|
+
interface TraceStreamSession {
|
|
1302
|
+
readonly harness: string;
|
|
1303
|
+
readonly sessionId: string;
|
|
1304
|
+
readonly cwd: string | null;
|
|
1305
|
+
readonly path?: string;
|
|
1306
|
+
}
|
|
1307
|
+
interface TraceLiveBatch {
|
|
1308
|
+
readonly schemaVersion: 1;
|
|
1309
|
+
readonly kind: 'traces.live_batch';
|
|
1310
|
+
readonly generatedAt: string;
|
|
1311
|
+
readonly session: TraceStreamSession;
|
|
1312
|
+
readonly spanCount: number;
|
|
1313
|
+
readonly newSpanCount: number;
|
|
1314
|
+
readonly toolCallCount: number;
|
|
1315
|
+
readonly erroredToolCallCount: number;
|
|
1316
|
+
readonly verificationCallCount: number;
|
|
1317
|
+
readonly changeCallCount: number;
|
|
1318
|
+
readonly findingCount: number;
|
|
1319
|
+
readonly findings: readonly TraceLiveFinding[];
|
|
1320
|
+
}
|
|
1321
|
+
type TraceStreamEvent = {
|
|
1322
|
+
readonly schemaVersion: 1;
|
|
1323
|
+
readonly kind: 'traces.stream.session';
|
|
1324
|
+
readonly event: 'session';
|
|
1325
|
+
readonly generatedAt: string;
|
|
1326
|
+
readonly session: TraceStreamSession;
|
|
1327
|
+
readonly spanCount: number;
|
|
1328
|
+
readonly startedAt: string | null;
|
|
1329
|
+
readonly endedAt: string | null;
|
|
1330
|
+
} | {
|
|
1331
|
+
readonly schemaVersion: 1;
|
|
1332
|
+
readonly kind: 'traces.stream.span';
|
|
1333
|
+
readonly event: 'span';
|
|
1334
|
+
readonly generatedAt: string;
|
|
1335
|
+
readonly session: TraceStreamSession;
|
|
1336
|
+
readonly span: OtlpSpan;
|
|
1337
|
+
} | {
|
|
1338
|
+
readonly schemaVersion: 1;
|
|
1339
|
+
readonly kind: 'traces.stream.batch';
|
|
1340
|
+
readonly event: 'analysis_batch';
|
|
1341
|
+
readonly generatedAt: string;
|
|
1342
|
+
readonly batch: TraceLiveBatch;
|
|
1343
|
+
} | {
|
|
1344
|
+
readonly schemaVersion: 1;
|
|
1345
|
+
readonly kind: 'traces.stream.finding';
|
|
1346
|
+
readonly event: 'finding';
|
|
1347
|
+
readonly generatedAt: string;
|
|
1348
|
+
readonly finding: TraceLiveFinding;
|
|
1349
|
+
} | {
|
|
1350
|
+
readonly schemaVersion: 1;
|
|
1351
|
+
readonly kind: 'traces.stream.tick';
|
|
1352
|
+
readonly event: 'tick';
|
|
1353
|
+
readonly generatedAt: string;
|
|
1354
|
+
readonly sessions: number;
|
|
1355
|
+
readonly newSpans: number;
|
|
1356
|
+
readonly findings: number;
|
|
1357
|
+
};
|
|
1358
|
+
interface LiveBatchOptions {
|
|
1359
|
+
readonly generatedAt?: string;
|
|
1360
|
+
readonly session?: Partial<TraceStreamSession>;
|
|
1361
|
+
readonly newSpanCount?: number;
|
|
1362
|
+
}
|
|
1363
|
+
interface TraceStreamReplayOptions extends LiveBatchOptions {
|
|
1364
|
+
readonly ref?: SessionRef;
|
|
1365
|
+
readonly includeSpans?: boolean;
|
|
1366
|
+
readonly includeFindings?: boolean;
|
|
1367
|
+
}
|
|
1368
|
+
interface TraceStreamOptions extends ScanOptions {
|
|
1369
|
+
/** Observe sessions active within this window. Default 30 min. */
|
|
1370
|
+
readonly windowMs?: number;
|
|
1371
|
+
/** Poll interval. Default 5s. */
|
|
1372
|
+
readonly intervalMs?: number;
|
|
1373
|
+
/** Stop after one scan, useful for replay or tests. */
|
|
1374
|
+
readonly once?: boolean;
|
|
1375
|
+
/** Emit one JSON event per new span. Default true. */
|
|
1376
|
+
readonly includeSpans?: boolean;
|
|
1377
|
+
/** Emit live semantic findings. Default true. */
|
|
1378
|
+
readonly includeFindings?: boolean;
|
|
1379
|
+
/** Emit session and analysis-batch events. Default true. */
|
|
1380
|
+
readonly includeBatches?: boolean;
|
|
1381
|
+
readonly onEvent: (event: TraceStreamEvent) => void | Promise<void>;
|
|
1382
|
+
}
|
|
1383
|
+
declare function analyzeLiveBatch(spans: readonly OtlpSpan[], opts?: LiveBatchOptions): TraceLiveBatch;
|
|
1384
|
+
declare function traceStreamEventsFromSpans(spans: readonly OtlpSpan[], opts?: TraceStreamReplayOptions): TraceStreamEvent[];
|
|
1385
|
+
declare function serializeTraceStreamEvent(event: TraceStreamEvent): string;
|
|
1386
|
+
declare function streamSessions(opts: TraceStreamOptions): Promise<void>;
|
|
1387
|
+
|
|
1279
1388
|
/**
|
|
1280
1389
|
* Live trace observer — the reusable, event-driven core behind `traces watch`.
|
|
1281
1390
|
*
|
|
@@ -1323,6 +1432,10 @@ interface ObserverOptions {
|
|
|
1323
1432
|
/** Fired for every observed session each tick, with its full pipeline report
|
|
1324
1433
|
* (stuck loops + tool-use metrics) — react to anything, not just loops. */
|
|
1325
1434
|
onReport?: (ref: SessionRef, report: PipelineReport) => void | Promise<void>;
|
|
1435
|
+
/** Fired for every observed session each tick, after semantic live analysis. */
|
|
1436
|
+
onBatch?: (ref: SessionRef, batch: TraceLiveBatch) => void | Promise<void>;
|
|
1437
|
+
/** Fired once for each newly-observed live semantic finding. */
|
|
1438
|
+
onFinding?: (finding: TraceLiveFinding) => void | Promise<void>;
|
|
1326
1439
|
/** Per-session parse/pipeline error (the observer keeps going). */
|
|
1327
1440
|
onError?: (error: unknown, ref?: SessionRef) => void;
|
|
1328
1441
|
/** Fired after each poll cycle. */
|
|
@@ -1489,4 +1602,4 @@ interface ExecuteOptions {
|
|
|
1489
1602
|
/** Send the NEW items (or, on dryRun, write the redacted OTLP that would send). */
|
|
1490
1603
|
declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
|
|
1491
1604
|
|
|
1492
|
-
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, ClaudeAdapter, CodexAdapter, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, type FindingStore, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type ImprovementAdapter, type ImprovementAdapterInput, type ImprovementProposal, type InspectSessionIndexOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type RecommendationWriter, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceClaim, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceRecommendation, type TraceReplayProof, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TracesConfig, type TriggerPair, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, parseIsoToEpochMs, parseSession, parseSince, planUpload, readSessionIndexFile, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovementLoop, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, sessionHash, span, stampRepoAttrs, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
|
|
1605
|
+
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, ClaudeAdapter, CodexAdapter, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, type FindingStore, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type ImprovementAdapter, type ImprovementAdapterInput, type ImprovementProposal, type InspectSessionIndexOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type RecommendationWriter, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceClaim, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveSeverity, type TraceRecommendation, type TraceReplayProof, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeLiveBatch, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, parseIsoToEpochMs, parseSession, parseSince, planUpload, readSessionIndexFile, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovementLoop, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, span, stampRepoAttrs, streamSessions, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
TRACES_REDACTION_RULES,
|
|
21
21
|
alreadyUploaded,
|
|
22
22
|
analyzeAdoption,
|
|
23
|
+
analyzeLiveBatch,
|
|
23
24
|
analyzeReactions,
|
|
24
25
|
analyzeSpans,
|
|
25
26
|
applyRedactor,
|
|
@@ -73,13 +74,16 @@ import {
|
|
|
73
74
|
serializePolicyEvidence,
|
|
74
75
|
serializeSessionIndex,
|
|
75
76
|
serializeSpans,
|
|
77
|
+
serializeTraceStreamEvent,
|
|
76
78
|
sessionHash,
|
|
77
79
|
span,
|
|
78
80
|
stampRepoAttrs,
|
|
81
|
+
streamSessions,
|
|
79
82
|
textIsSynthetic,
|
|
80
83
|
toOpenInferenceSpan,
|
|
81
84
|
toRuntimeStore,
|
|
82
85
|
toTraceSpanEvents,
|
|
86
|
+
traceStreamEventsFromSpans,
|
|
83
87
|
uploadKey,
|
|
84
88
|
userPromptSpan,
|
|
85
89
|
watchSessions,
|
|
@@ -89,7 +93,7 @@ import {
|
|
|
89
93
|
writeSessionIndexFile,
|
|
90
94
|
writeTraceEvidenceExportFile,
|
|
91
95
|
writeTraceImprovementArtifacts
|
|
92
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-G3OBZSWY.js";
|
|
93
97
|
|
|
94
98
|
// src/collect.ts
|
|
95
99
|
async function collectSessions(opts = {}) {
|
|
@@ -137,6 +141,7 @@ export {
|
|
|
137
141
|
TRACES_REDACTION_RULES,
|
|
138
142
|
alreadyUploaded,
|
|
139
143
|
analyzeAdoption,
|
|
144
|
+
analyzeLiveBatch,
|
|
140
145
|
analyzeReactions,
|
|
141
146
|
analyzeSpans,
|
|
142
147
|
applyRedactor,
|
|
@@ -197,13 +202,16 @@ export {
|
|
|
197
202
|
serializePolicyEvidence,
|
|
198
203
|
serializeSessionIndex,
|
|
199
204
|
serializeSpans,
|
|
205
|
+
serializeTraceStreamEvent,
|
|
200
206
|
sessionHash,
|
|
201
207
|
span,
|
|
202
208
|
stampRepoAttrs,
|
|
209
|
+
streamSessions,
|
|
203
210
|
textIsSynthetic,
|
|
204
211
|
toOpenInferenceSpan,
|
|
205
212
|
toRuntimeStore,
|
|
206
213
|
toTraceSpanEvents,
|
|
214
|
+
traceStreamEventsFromSpans,
|
|
207
215
|
uploadKey,
|
|
208
216
|
userPromptSpan,
|
|
209
217
|
watchSessions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/traces",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.18",
|
|
4
4
|
"description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi, …) and get failure-mode + efficiency findings. CLI + SDK over the @tangle-network/agent-eval analyst suite — observe live sessions, run your own analysts, redact, and upload to the Tangle Intelligence Platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|