@tangle-network/traces 0.17.0 → 0.18.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/dist/{chunk-4QY4U4XW.js → chunk-TCTZ7DUY.js} +146 -53
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/docs/trace-analysts.md +41 -0
- package/package.json +2 -2
|
@@ -1025,8 +1025,8 @@ var OTLP_WRITE_CHUNK_CHARS = 4 * 1024 * 1024;
|
|
|
1025
1025
|
async function writeOtlpFile(spans, outPath) {
|
|
1026
1026
|
const { mkdtemp: mkdtemp8, open: open2 } = await import("fs/promises");
|
|
1027
1027
|
const { tmpdir: tmpdir8 } = await import("os");
|
|
1028
|
-
const { join:
|
|
1029
|
-
const path = outPath ??
|
|
1028
|
+
const { join: join36 } = await import("path");
|
|
1029
|
+
const path = outPath ?? join36(await mkdtemp8(join36(tmpdir8(), "traces-")), "spans.otlp.jsonl");
|
|
1030
1030
|
const handle = await open2(path, "w");
|
|
1031
1031
|
try {
|
|
1032
1032
|
let chunk = "";
|
|
@@ -2448,7 +2448,10 @@ function distinctClaudeEvent(event, seen, sourcePath, fallbackUid) {
|
|
|
2448
2448
|
if (previous.fingerprint !== fingerprint) {
|
|
2449
2449
|
throw new ClaudeEventConflictError(sourcePath, uid);
|
|
2450
2450
|
}
|
|
2451
|
-
if (previous.originKind === null && originKind !== null)
|
|
2451
|
+
if (previous.originKind === null && originKind !== null) {
|
|
2452
|
+
seen.set(uid, { fingerprint, originKind });
|
|
2453
|
+
return { originEnrichment: originKind, uid };
|
|
2454
|
+
}
|
|
2452
2455
|
if (previous.originKind !== null && originKind !== null && previous.originKind !== originKind) {
|
|
2453
2456
|
throw new ClaudeEventConflictError(sourcePath, uid);
|
|
2454
2457
|
}
|
|
@@ -3982,9 +3985,9 @@ function itemCountsJson(counts) {
|
|
|
3982
3985
|
}
|
|
3983
3986
|
function placeInnerSpans(pending, windows) {
|
|
3984
3987
|
return pending.map((entry) => {
|
|
3985
|
-
const { parent, join:
|
|
3988
|
+
const { parent, join: join36 } = joinItem(windows, entry.startMs, entry.endMs);
|
|
3986
3989
|
if (parent) entry.span.parent_span_id = parent.span_id;
|
|
3987
|
-
entry.span.attributes["traces.codex.item_join"] =
|
|
3990
|
+
entry.span.attributes["traces.codex.item_join"] = join36;
|
|
3988
3991
|
return entry.span;
|
|
3989
3992
|
});
|
|
3990
3993
|
}
|
|
@@ -15308,6 +15311,7 @@ function assertPositiveInteger(name, value) {
|
|
|
15308
15311
|
import { createHash as createHash14 } from "crypto";
|
|
15309
15312
|
import { request as httpRequest } from "http";
|
|
15310
15313
|
import { request as httpsRequest } from "https";
|
|
15314
|
+
import { join as join25 } from "path";
|
|
15311
15315
|
var DEFAULT_BRIDGE_URL = "http://localhost:4181";
|
|
15312
15316
|
var DEFAULT_MODEL = "prime/zai/glm-5.2";
|
|
15313
15317
|
var DEFAULT_TIMEOUT_MS = 12e5;
|
|
@@ -15323,9 +15327,9 @@ async function fileDelivery(otlpPath, perAttributeCharCap, signal) {
|
|
|
15323
15327
|
signal?.throwIfAborted();
|
|
15324
15328
|
const { copyFile: copyFile2, mkdtemp: mkdtemp8, stat: stat19 } = await import("fs/promises");
|
|
15325
15329
|
const { tmpdir: tmpdir8 } = await import("os");
|
|
15326
|
-
const { join:
|
|
15327
|
-
const cwd = await mkdtemp8(
|
|
15328
|
-
await copyFile2(otlpPath,
|
|
15330
|
+
const { join: join36 } = await import("path");
|
|
15331
|
+
const cwd = await mkdtemp8(join36(tmpdir8(), "traces-prime-"));
|
|
15332
|
+
await copyFile2(otlpPath, join36(cwd, TRAJECTORY_FILE_NAME));
|
|
15329
15333
|
const artifactBytes = (await stat19(otlpPath)).size;
|
|
15330
15334
|
return { mode: "file-cwd", perAttributeCharCap, renderedChars: artifactBytes, cwd, fileName: TRAJECTORY_FILE_NAME };
|
|
15331
15335
|
}
|
|
@@ -15478,7 +15482,16 @@ var FILE_DELIVERY_CONTRACT_LINES = [
|
|
|
15478
15482
|
' "confidence": number 0..1}',
|
|
15479
15483
|
"Do NOT include a rationale field. Keep every string SHORT \u2014 long strings get corrupted in transport and void your work.",
|
|
15480
15484
|
`Report at most ${MAX_FINDINGS} findings; a finding cites 1..${MAX_SPAN_IDS_PER_FINDING} span_ids, each copied VERBATIM from a span in ${TRAJECTORY_FILE_NAME}.`,
|
|
15481
|
-
'"findings" is [] only for a clean trajectory.'
|
|
15485
|
+
'"findings" is [] only for a clean trajectory.',
|
|
15486
|
+
`PAYLOAD CHANNEL \u2014 do this BEFORE your final message: WRITE the complete JSON object (same schema as`,
|
|
15487
|
+
"the reply contract) to a file named findings.json in your working directory, using your tools (python",
|
|
15488
|
+
"or shell). One assistant message has an output-token cap and a cut reply is discarded unread;",
|
|
15489
|
+
"findings.json is the durable channel a large result must travel on. Write it first, incrementally if",
|
|
15490
|
+
"it is long, THEN send your final message: the fenced ```json block when it is short enough to fit,",
|
|
15491
|
+
"otherwise ONE line only \u2014 `findings written to findings.json`.",
|
|
15492
|
+
"FINAL MESSAGE RULE: after your REPL work is done, send ONE last message that contains NOTHING BUT the",
|
|
15493
|
+
"fenced ```json block (or the one-line pointer above) \u2014 no preamble, no summary, no code identifiers",
|
|
15494
|
+
"around it. A reply whose last message is prose or a partial block is discarded unread."
|
|
15482
15495
|
];
|
|
15483
15496
|
function buildPrompt(question, projection) {
|
|
15484
15497
|
if (projection.delivery.mode === "file-cwd") {
|
|
@@ -15499,16 +15512,23 @@ function buildPrompt(question, projection) {
|
|
|
15499
15512
|
projection.rendered
|
|
15500
15513
|
].join("\n");
|
|
15501
15514
|
}
|
|
15502
|
-
function
|
|
15515
|
+
function replyWasTruncated(previousReply, finishReason) {
|
|
15516
|
+
if (finishReason === "length") return true;
|
|
15517
|
+
if (finishReason !== null) return false;
|
|
15518
|
+
return extractJsonObject(previousReply) === null;
|
|
15519
|
+
}
|
|
15520
|
+
function buildRepairPrompt(parseDefect, previousReply, finishReason) {
|
|
15521
|
+
const truncated = replyWasTruncated(previousReply, finishReason);
|
|
15503
15522
|
return [
|
|
15504
15523
|
"Your previous reply to a trace-analysis task was structurally malformed and could not be parsed",
|
|
15505
|
-
`(${parseDefect}). Below is your previous reply verbatim
|
|
15506
|
-
"fenced ```json block, no other text, no tools. The JSON object has exactly two fields:",
|
|
15524
|
+
`(${parseDefect}${truncated ? "; it was cut off by the output limit" : ""}). Below is your previous reply verbatim.`,
|
|
15525
|
+
"Re-emit ONLY the corrected JSON \u2014 one fenced ```json block, no other text, no tools. The JSON object has exactly two fields:",
|
|
15507
15526
|
' "answer": string (ONE short sentence, max 300 chars)',
|
|
15508
15527
|
' "findings": array (possibly empty) of {"span_ids": [string, ...],',
|
|
15509
15528
|
' "severity": "critical"|"high"|"medium"|"low"|"info", "area": string (max 40 chars),',
|
|
15510
15529
|
' "claim": string (max 200 chars), "action": string (optional, max 200 chars), "confidence": number 0..1}',
|
|
15511
|
-
"No rationale field. Keep every string SHORT.
|
|
15530
|
+
"No rationale field. Keep every string SHORT.",
|
|
15531
|
+
truncated ? "Your previous reply was cut off by the output limit. Write the corrected JSON to a file named findings.json in your working directory with your tools (at most 3 findings \u2014 your strongest \u2014 with terse strings, claim and action under 120 chars each), then reply with ONE line: findings written to findings.json." : "Preserve the span ids and verdicts of your previous reply exactly; shorten prose freely.",
|
|
15512
15532
|
"",
|
|
15513
15533
|
"PREVIOUS REPLY:",
|
|
15514
15534
|
previousReply
|
|
@@ -15543,6 +15563,59 @@ function parseDefectOf(parsed) {
|
|
|
15543
15563
|
if (!Array.isArray(parsed.findings)) return 'JSON has no "findings" array';
|
|
15544
15564
|
return null;
|
|
15545
15565
|
}
|
|
15566
|
+
var FINDINGS_FILE_MAX_BYTES = 256 * 1024;
|
|
15567
|
+
var FINDINGS_FILE_NAME = "findings.json";
|
|
15568
|
+
async function readFindingsFile2(cwd, signal) {
|
|
15569
|
+
signal?.throwIfAborted();
|
|
15570
|
+
const path = join25(cwd, FINDINGS_FILE_NAME);
|
|
15571
|
+
let raw;
|
|
15572
|
+
const { readFile: readFile20, stat: stat19 } = await import("fs/promises");
|
|
15573
|
+
try {
|
|
15574
|
+
const size = (await stat19(path)).size;
|
|
15575
|
+
if (size > FINDINGS_FILE_MAX_BYTES) {
|
|
15576
|
+
return { parsed: null, receipt: `${FINDINGS_FILE_NAME} is ${size} bytes (cap ${FINDINGS_FILE_MAX_BYTES}); refused` };
|
|
15577
|
+
}
|
|
15578
|
+
raw = await readFile20(path, "utf8");
|
|
15579
|
+
} catch {
|
|
15580
|
+
return void 0;
|
|
15581
|
+
}
|
|
15582
|
+
const direct = extractJsonObject(raw);
|
|
15583
|
+
if (direct !== null && parseDefectOf(direct) === null) {
|
|
15584
|
+
return { parsed: direct, receipt: `${FINDINGS_FILE_NAME} read (${raw.length} chars)` };
|
|
15585
|
+
}
|
|
15586
|
+
const rows = [];
|
|
15587
|
+
let droppedLines = 0;
|
|
15588
|
+
let answer = null;
|
|
15589
|
+
for (const [index, line] of raw.split("\n").entries()) {
|
|
15590
|
+
const trimmed = line.trim();
|
|
15591
|
+
if (trimmed.length === 0) continue;
|
|
15592
|
+
const row = extractJsonObject(trimmed);
|
|
15593
|
+
if (row === null) {
|
|
15594
|
+
droppedLines += 1;
|
|
15595
|
+
continue;
|
|
15596
|
+
}
|
|
15597
|
+
if (typeof row.answer === "string" && !Array.isArray(row.findings)) {
|
|
15598
|
+
if (answer === null) answer = row.answer;
|
|
15599
|
+
continue;
|
|
15600
|
+
}
|
|
15601
|
+
if (Array.isArray(row.findings)) {
|
|
15602
|
+
rows.push(...row.findings);
|
|
15603
|
+
if (answer === null && typeof row.answer === "string") answer = row.answer;
|
|
15604
|
+
continue;
|
|
15605
|
+
}
|
|
15606
|
+
rows.push(row);
|
|
15607
|
+
}
|
|
15608
|
+
if (rows.length === 0) {
|
|
15609
|
+
return {
|
|
15610
|
+
parsed: null,
|
|
15611
|
+
receipt: `${FINDINGS_FILE_NAME} unreadable (no parseable object${droppedLines > 0 ? `, ${droppedLines} malformed line(s) dropped` : ""})`
|
|
15612
|
+
};
|
|
15613
|
+
}
|
|
15614
|
+
return {
|
|
15615
|
+
parsed: { ...answer !== null ? { answer } : {}, findings: rows },
|
|
15616
|
+
receipt: `${FINDINGS_FILE_NAME} read as JSONL (${rows.length} row(s)${droppedLines > 0 ? `, ${droppedLines} malformed line(s) dropped` : ""})`
|
|
15617
|
+
};
|
|
15618
|
+
}
|
|
15546
15619
|
function findingRowDefect(row, spanTraces) {
|
|
15547
15620
|
if (!row || typeof row !== "object" || Array.isArray(row)) return "row is not an object";
|
|
15548
15621
|
const record2 = row;
|
|
@@ -15675,7 +15748,12 @@ async function callBridge(transport, url, model, content, timeoutMs, callerSigna
|
|
|
15675
15748
|
if (typeof replyContent !== "string" || replyContent.length === 0) {
|
|
15676
15749
|
throw new PrimeBridgeError(`${turn}bridge reply carries no message content`);
|
|
15677
15750
|
}
|
|
15678
|
-
|
|
15751
|
+
const finishReason = record2.choices?.[0]?.finish_reason;
|
|
15752
|
+
return {
|
|
15753
|
+
content: replyContent,
|
|
15754
|
+
usage: normalizeUsage(record2.usage),
|
|
15755
|
+
finishReason: typeof finishReason === "string" && finishReason.length > 0 ? finishReason : null
|
|
15756
|
+
};
|
|
15679
15757
|
}
|
|
15680
15758
|
function failure(output, error) {
|
|
15681
15759
|
return { analyzer: ANALYST_ID, kind: "report", ok: false, output, error };
|
|
@@ -15748,7 +15826,7 @@ function primeAnalyzer(opts = {}) {
|
|
|
15748
15826
|
transport,
|
|
15749
15827
|
url,
|
|
15750
15828
|
model,
|
|
15751
|
-
buildRepairPrompt(parseDefect, reply.content),
|
|
15829
|
+
buildRepairPrompt(parseDefect, reply.content, reply.finishReason),
|
|
15752
15830
|
timeoutMs,
|
|
15753
15831
|
analyzeOpts.signal,
|
|
15754
15832
|
"repair-turn "
|
|
@@ -15761,11 +15839,25 @@ function primeAnalyzer(opts = {}) {
|
|
|
15761
15839
|
parsed = extractJsonObject(repairReply.content);
|
|
15762
15840
|
parseDefect = parseDefectOf(parsed);
|
|
15763
15841
|
}
|
|
15842
|
+
let channel = "reply";
|
|
15843
|
+
let channelReceipt = "";
|
|
15764
15844
|
if (parseDefect !== null) {
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15845
|
+
const deliveryCwd2 = projection.delivery.mode === "file-cwd" ? projection.delivery.cwd : void 0;
|
|
15846
|
+
const file = deliveryCwd2 !== void 0 ? await readFindingsFile2(deliveryCwd2, analyzeOpts.signal).catch(() => void 0) : void 0;
|
|
15847
|
+
if (file?.parsed !== null && file !== void 0) {
|
|
15848
|
+
parsed = file.parsed;
|
|
15849
|
+
parseDefect = parseDefectOf(parsed);
|
|
15850
|
+
if (parseDefect === null) {
|
|
15851
|
+
channel = FINDINGS_FILE_NAME;
|
|
15852
|
+
channelReceipt = file.receipt;
|
|
15853
|
+
}
|
|
15854
|
+
}
|
|
15855
|
+
if (parseDefect !== null) {
|
|
15856
|
+
return failure(
|
|
15857
|
+
reply.content,
|
|
15858
|
+
`${parseDefect} in prime reply${repairAttempted ? " even after the bounded repair turn" : ""}` + (file === void 0 ? "; no findings.json in the run directory" : `; ${file.receipt}`) + `; ${renderUsage(usage)}`
|
|
15859
|
+
);
|
|
15860
|
+
}
|
|
15769
15861
|
}
|
|
15770
15862
|
const rows = parsed.findings.slice(0, MAX_FINDINGS);
|
|
15771
15863
|
const overflow = parsed.findings.length - rows.length;
|
|
@@ -15786,6 +15878,7 @@ function primeAnalyzer(opts = {}) {
|
|
|
15786
15878
|
`findings: ${findings.length} mapped, ${rejected.length} rejected` + (overflow > 0 ? `, ${overflow} over the ${MAX_FINDINGS}-finding cap dropped` : ""),
|
|
15787
15879
|
...rejected,
|
|
15788
15880
|
deliveryLine,
|
|
15881
|
+
...channel !== "reply" ? [`reply channel: ${channel} \u2014 ${channelReceipt}; the chat reply was unparseable, the payload file carried the result`] : [],
|
|
15789
15882
|
`repair: ${repairAttempted ? "attempted (succeeded)" : "not needed"}`,
|
|
15790
15883
|
renderUsage(usage),
|
|
15791
15884
|
...findings.length === 0 ? ["zero findings \u2014 an honest null, not a failure"] : []
|
|
@@ -15890,7 +15983,7 @@ async function applyRedactor(spans, redactor) {
|
|
|
15890
15983
|
import { createHash as createHash15 } from "crypto";
|
|
15891
15984
|
import { mkdtemp as mkdtemp6, readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
|
|
15892
15985
|
import { tmpdir as tmpdir6 } from "os";
|
|
15893
|
-
import { join as
|
|
15986
|
+
import { join as join26 } from "path";
|
|
15894
15987
|
import {
|
|
15895
15988
|
firstNumberAttr as firstNumberAttr2,
|
|
15896
15989
|
LLM_CACHED_TOKEN_ATTR_KEYS,
|
|
@@ -16561,7 +16654,7 @@ async function exportTraceEvidenceFile(inputPath, opts = {}) {
|
|
|
16561
16654
|
}
|
|
16562
16655
|
async function writeTraceEvidenceExportFile(inputPath, outPath, opts = {}) {
|
|
16563
16656
|
const result = await exportTraceEvidenceFile(inputPath, opts);
|
|
16564
|
-
const path = outPath ??
|
|
16657
|
+
const path = outPath ?? join26(await mkdtemp6(join26(tmpdir6(), "traces-export-")), "spans.openinference.jsonl");
|
|
16565
16658
|
await writeFile8(path, serializeSpans(result.spans), "utf8");
|
|
16566
16659
|
return { ...result, path };
|
|
16567
16660
|
}
|
|
@@ -16569,7 +16662,7 @@ async function writeTraceEvidenceExportFile(inputPath, outPath, opts = {}) {
|
|
|
16569
16662
|
// src/inspect.ts
|
|
16570
16663
|
import { mkdtemp as mkdtemp7, readFile as readFile13, writeFile as writeFile9 } from "fs/promises";
|
|
16571
16664
|
import { tmpdir as tmpdir7 } from "os";
|
|
16572
|
-
import { basename as basename14, join as
|
|
16665
|
+
import { basename as basename14, join as join27 } from "path";
|
|
16573
16666
|
var severityRank2 = {
|
|
16574
16667
|
high: 0,
|
|
16575
16668
|
medium: 1,
|
|
@@ -16858,7 +16951,7 @@ async function readSessionIndexFile(path) {
|
|
|
16858
16951
|
return parsed;
|
|
16859
16952
|
}
|
|
16860
16953
|
async function writeInspectionReportFile(report, outPath) {
|
|
16861
|
-
const path = outPath ??
|
|
16954
|
+
const path = outPath ?? join27(await mkdtemp7(join27(tmpdir7(), "traces-inspect-")), "inspection-report.md");
|
|
16862
16955
|
await writeFile9(path, renderInspectionReport(report), "utf8");
|
|
16863
16956
|
return path;
|
|
16864
16957
|
}
|
|
@@ -17292,7 +17385,7 @@ async function streamSessions(opts) {
|
|
|
17292
17385
|
|
|
17293
17386
|
// src/supervisor-run-context.ts
|
|
17294
17387
|
import { readFile as readFile14, stat as stat16 } from "fs/promises";
|
|
17295
|
-
import { basename as basename15, join as
|
|
17388
|
+
import { basename as basename15, join as join28 } from "path";
|
|
17296
17389
|
import { materializeTreeView } from "@tangle-network/agent-runtime/kernel";
|
|
17297
17390
|
import {
|
|
17298
17391
|
readRuntimeSupervisorRun
|
|
@@ -17454,14 +17547,14 @@ function parseInstant(v) {
|
|
|
17454
17547
|
}
|
|
17455
17548
|
async function readFileRunContext(runDir, opts = {}) {
|
|
17456
17549
|
const sources = await readRuntimeSupervisorRun(runDir);
|
|
17457
|
-
const coordination = readCoordinationLog(await readMaybe(
|
|
17550
|
+
const coordination = readCoordinationLog(await readMaybe(join28(runDir, COORDINATION_LOG_FILE)));
|
|
17458
17551
|
return {
|
|
17459
17552
|
...sources,
|
|
17460
17553
|
instanceId: opts.instanceId !== void 0 ? opts.instanceId : sources.instanceId,
|
|
17461
17554
|
arm: opts.arm !== void 0 ? opts.arm : basename15(runDir),
|
|
17462
17555
|
workers: sources.workers !== null && coordination.present ? workerSources(sources.workers, coordination) : sources.workers,
|
|
17463
17556
|
...sources.journal !== null ? {
|
|
17464
|
-
rootTranscriptRef:
|
|
17557
|
+
rootTranscriptRef: join28(runDir, SPAWN_JOURNAL_FILE),
|
|
17465
17558
|
traceCommand: `traces watch ${runDir}`
|
|
17466
17559
|
} : {}
|
|
17467
17560
|
};
|
|
@@ -17470,7 +17563,7 @@ function fileRunContextSupervisorRunReader(runDir, opts = {}) {
|
|
|
17470
17563
|
return { runRef: runDir, read: () => readFileRunContext(runDir, opts) };
|
|
17471
17564
|
}
|
|
17472
17565
|
async function isFileRunContextDir(runDir) {
|
|
17473
|
-
return stat16(
|
|
17566
|
+
return stat16(join28(runDir, SPAWN_JOURNAL_FILE)).then((s) => s.isFile()).catch(() => false);
|
|
17474
17567
|
}
|
|
17475
17568
|
function parseJsonObject(text2) {
|
|
17476
17569
|
if (text2 === null) return null;
|
|
@@ -17536,9 +17629,9 @@ function mergeRolls(a, b) {
|
|
|
17536
17629
|
};
|
|
17537
17630
|
}
|
|
17538
17631
|
async function readRunContextSnapshot(runDir) {
|
|
17539
|
-
const journal = readRunContextJournal(await readMaybe(
|
|
17540
|
-
const coordination = readCoordinationLog(await readMaybe(
|
|
17541
|
-
const resultText = await readMaybe(
|
|
17632
|
+
const journal = readRunContextJournal(await readMaybe(join28(runDir, SPAWN_JOURNAL_FILE)));
|
|
17633
|
+
const coordination = readCoordinationLog(await readMaybe(join28(runDir, COORDINATION_LOG_FILE)));
|
|
17634
|
+
const resultText = await readMaybe(join28(runDir, RESULT_FILE));
|
|
17542
17635
|
const result = parseResult(resultText);
|
|
17543
17636
|
const view = safeTreeView(journal.events);
|
|
17544
17637
|
const nodes = view === null ? [] : orderNodes(view, journal);
|
|
@@ -17721,7 +17814,7 @@ function wrap(text2, indent) {
|
|
|
17721
17814
|
|
|
17722
17815
|
// src/run-span-tree.ts
|
|
17723
17816
|
import { readdir as readdir18 } from "fs/promises";
|
|
17724
|
-
import { join as
|
|
17817
|
+
import { join as join29 } from "path";
|
|
17725
17818
|
import {
|
|
17726
17819
|
firstNumberAttr as firstNumberAttr3,
|
|
17727
17820
|
LLM_COST_ATTR_KEYS as LLM_COST_ATTR_KEYS2,
|
|
@@ -17996,7 +18089,7 @@ async function findSpanSourceFiles(dir) {
|
|
|
17996
18089
|
const found = [];
|
|
17997
18090
|
const entries = await readdir18(dir, { withFileTypes: true }).catch(() => []);
|
|
17998
18091
|
for (const entry of entries) {
|
|
17999
|
-
const child =
|
|
18092
|
+
const child = join29(dir, entry.name);
|
|
18000
18093
|
if (entry.isFile()) {
|
|
18001
18094
|
if (SPAN_FILE_PATTERN.test(entry.name)) found.push(child);
|
|
18002
18095
|
continue;
|
|
@@ -18004,7 +18097,7 @@ async function findSpanSourceFiles(dir) {
|
|
|
18004
18097
|
if (!entry.isDirectory()) continue;
|
|
18005
18098
|
const nested = await readdir18(child, { withFileTypes: true }).catch(() => []);
|
|
18006
18099
|
for (const inner of nested) {
|
|
18007
|
-
if (inner.isFile() && SPAN_FILE_PATTERN.test(inner.name)) found.push(
|
|
18100
|
+
if (inner.isFile() && SPAN_FILE_PATTERN.test(inner.name)) found.push(join29(child, inner.name));
|
|
18008
18101
|
}
|
|
18009
18102
|
}
|
|
18010
18103
|
return found.sort();
|
|
@@ -18012,7 +18105,7 @@ async function findSpanSourceFiles(dir) {
|
|
|
18012
18105
|
|
|
18013
18106
|
// src/supervisor-run-watch.ts
|
|
18014
18107
|
import { readdir as readdir19 } from "fs/promises";
|
|
18015
|
-
import { join as
|
|
18108
|
+
import { join as join30 } from "path";
|
|
18016
18109
|
function budget(node) {
|
|
18017
18110
|
const parts = [`${int(node.budget.maxIterations)}it`, `${int(node.budget.maxTokens)}tok`];
|
|
18018
18111
|
if (node.budget.maxUsd !== void 0) parts.push(`$${node.budget.maxUsd.toFixed(2)}`);
|
|
@@ -18156,7 +18249,7 @@ async function resolveRunContextDir(dir) {
|
|
|
18156
18249
|
const candidates = [];
|
|
18157
18250
|
for (const entry of entries) {
|
|
18158
18251
|
if (!entry.isDirectory()) continue;
|
|
18159
|
-
const child =
|
|
18252
|
+
const child = join30(dir, entry.name);
|
|
18160
18253
|
if (await isFileRunContextDir(child)) candidates.push(child);
|
|
18161
18254
|
}
|
|
18162
18255
|
if (candidates.length === 1) return candidates[0];
|
|
@@ -18492,7 +18585,7 @@ function parseJsonAnswer(text2) {
|
|
|
18492
18585
|
|
|
18493
18586
|
// src/ask.ts
|
|
18494
18587
|
import { mkdir as mkdir6, readFile as readFile15, writeFile as writeFile10 } from "fs/promises";
|
|
18495
|
-
import { join as
|
|
18588
|
+
import { join as join31, resolve as resolve11 } from "path";
|
|
18496
18589
|
import { performance } from "perf_hooks";
|
|
18497
18590
|
import { CostCeilingReachedError, CostLedger } from "@tangle-network/agent-eval";
|
|
18498
18591
|
import {
|
|
@@ -19047,8 +19140,8 @@ async function writeTraceQuestionsArtifacts(result, outDir) {
|
|
|
19047
19140
|
await mkdir6(directory, { recursive: true });
|
|
19048
19141
|
const paths = {
|
|
19049
19142
|
directory,
|
|
19050
|
-
result:
|
|
19051
|
-
report:
|
|
19143
|
+
result: join31(directory, "answers.json"),
|
|
19144
|
+
report: join31(directory, "report.md"),
|
|
19052
19145
|
traces: result.otlpPath
|
|
19053
19146
|
};
|
|
19054
19147
|
const { report, ...machine } = result;
|
|
@@ -19112,7 +19205,7 @@ async function watchSessions(opts) {
|
|
|
19112
19205
|
// src/bundle-view.ts
|
|
19113
19206
|
import { createHash as createHash17 } from "crypto";
|
|
19114
19207
|
import { mkdir as mkdir7, readdir as readdir20, readFile as readFile16, writeFile as writeFile11 } from "fs/promises";
|
|
19115
|
-
import { dirname as dirname11, join as
|
|
19208
|
+
import { dirname as dirname11, join as join32, resolve as resolve12 } from "path";
|
|
19116
19209
|
var EVIDENCE_ONLY_ALLOW_LIST = [
|
|
19117
19210
|
{
|
|
19118
19211
|
path: "derived/session-index.json",
|
|
@@ -19236,7 +19329,7 @@ async function findSessionTextLeaks(opts) {
|
|
|
19236
19329
|
const index = /* @__PURE__ */ new Map();
|
|
19237
19330
|
const carried = [];
|
|
19238
19331
|
for (const path of opts.carriedPaths) {
|
|
19239
|
-
const signatures = sessionTextSignatures(await readFile16(
|
|
19332
|
+
const signatures = sessionTextSignatures(await readFile16(join32(opts.viewDir, path), "utf8"));
|
|
19240
19333
|
carried.push({ path, signatures: signatures.size });
|
|
19241
19334
|
for (const signature of signatures) if (!index.has(signature)) index.set(signature, path);
|
|
19242
19335
|
}
|
|
@@ -19244,7 +19337,7 @@ async function findSessionTextLeaks(opts) {
|
|
|
19244
19337
|
const comparedSources = [];
|
|
19245
19338
|
let sourceSignatures = 0;
|
|
19246
19339
|
for (const sourcePath of opts.excludedPaths) {
|
|
19247
|
-
const signatures = sessionTextSignatures(await readFile16(
|
|
19340
|
+
const signatures = sessionTextSignatures(await readFile16(join32(opts.sourceDir, sourcePath), "utf8"));
|
|
19248
19341
|
comparedSources.push(sourcePath);
|
|
19249
19342
|
sourceSignatures += signatures.size;
|
|
19250
19343
|
for (const signature of signatures) {
|
|
@@ -19303,17 +19396,17 @@ async function projectSessionBundle(opts) {
|
|
|
19303
19396
|
const candidates = [];
|
|
19304
19397
|
for (const path of await listSessionBundleFiles(sourceDir)) {
|
|
19305
19398
|
if (path === "manifest.json") continue;
|
|
19306
|
-
const bytes2 = await readFile16(
|
|
19399
|
+
const bytes2 = await readFile16(join32(sourceDir, path));
|
|
19307
19400
|
const sha2562 = createHash17("sha256").update(bytes2).digest("hex");
|
|
19308
19401
|
const recorded = sourceHashes.get(path);
|
|
19309
19402
|
if (!recorded) {
|
|
19310
19403
|
throw new Error(
|
|
19311
|
-
`${
|
|
19404
|
+
`${join32(sourceDir, path)} is not listed in the bundle manifest \u2014 the bundle changed after assembly and cannot be projected; re-run \`traces bundle\``
|
|
19312
19405
|
);
|
|
19313
19406
|
}
|
|
19314
19407
|
if (recorded.sha256 !== sha2562) {
|
|
19315
19408
|
throw new Error(
|
|
19316
|
-
`${
|
|
19409
|
+
`${join32(sourceDir, path)} does not match its manifest hash (${recorded.sha256} recorded, ${sha2562} on disk) \u2014 the bundle changed after assembly and cannot be projected; re-run \`traces bundle\``
|
|
19317
19410
|
);
|
|
19318
19411
|
}
|
|
19319
19412
|
const verdict = classifyEvidenceOnlyPath(path);
|
|
@@ -19349,7 +19442,7 @@ async function projectSessionBundle(opts) {
|
|
|
19349
19442
|
});
|
|
19350
19443
|
continue;
|
|
19351
19444
|
}
|
|
19352
|
-
const target =
|
|
19445
|
+
const target = join32(outDir, candidate.path);
|
|
19353
19446
|
await mkdir7(dirname11(target), { recursive: true });
|
|
19354
19447
|
await writeFile11(target, candidate.bytes);
|
|
19355
19448
|
carriedPaths.push(candidate.path);
|
|
@@ -19366,7 +19459,7 @@ async function projectSessionBundle(opts) {
|
|
|
19366
19459
|
})),
|
|
19367
19460
|
matches: 0
|
|
19368
19461
|
};
|
|
19369
|
-
const sourceManifestBytes = await readFile16(
|
|
19462
|
+
const sourceManifestBytes = await readFile16(join32(sourceDir, "manifest.json"));
|
|
19370
19463
|
const manifest = {
|
|
19371
19464
|
schemaVersion: 2,
|
|
19372
19465
|
kind: "traces.session_bundle",
|
|
@@ -19554,11 +19647,11 @@ function renderRunDiff(report) {
|
|
|
19554
19647
|
// src/upload-state.ts
|
|
19555
19648
|
import { mkdir as mkdir8, readFile as readFile17, writeFile as writeFile12 } from "fs/promises";
|
|
19556
19649
|
import { homedir as homedir12 } from "os";
|
|
19557
|
-
import { dirname as dirname12, join as
|
|
19650
|
+
import { dirname as dirname12, join as join33 } from "path";
|
|
19558
19651
|
import { contentHash } from "@tangle-network/agent-eval";
|
|
19559
19652
|
function stateFile() {
|
|
19560
|
-
const base = process.env.XDG_STATE_HOME ??
|
|
19561
|
-
return
|
|
19653
|
+
const base = process.env.XDG_STATE_HOME ?? join33(homedir12(), ".local", "state");
|
|
19654
|
+
return join33(base, "tangle-traces", "uploaded.json");
|
|
19562
19655
|
}
|
|
19563
19656
|
function uploadKey(harness, sessionId) {
|
|
19564
19657
|
return `${harness}:${sessionId}`;
|
|
@@ -19590,7 +19683,7 @@ function alreadyUploaded(state, harness, sessionId, hash2) {
|
|
|
19590
19683
|
import { readFile as readFile18 } from "fs/promises";
|
|
19591
19684
|
import { createRequire as createRequire2 } from "module";
|
|
19592
19685
|
import { hostname as hostname2 } from "os";
|
|
19593
|
-
import { basename as basename16, join as
|
|
19686
|
+
import { basename as basename16, join as join34 } from "path";
|
|
19594
19687
|
import { hostedClientFromEnv } from "@tangle-network/agent-eval/hosted";
|
|
19595
19688
|
import { assessShareSafety as assessShareSafety2, REDACTION_VERSION, redact as redact2, shareAllowed } from "@tangle-network/agent-eval/traces";
|
|
19596
19689
|
var require2 = createRequire2(import.meta.url);
|
|
@@ -19614,7 +19707,7 @@ async function planUpload(opts = {}) {
|
|
|
19614
19707
|
async function gitBranch(cwd) {
|
|
19615
19708
|
if (!cwd) return void 0;
|
|
19616
19709
|
try {
|
|
19617
|
-
const head = await readFile18(
|
|
19710
|
+
const head = await readFile18(join34(cwd, ".git", "HEAD"), "utf8");
|
|
19618
19711
|
const m = head.match(/^ref:\s*refs\/heads\/(.+)$/m);
|
|
19619
19712
|
return m?.[1]?.trim();
|
|
19620
19713
|
} catch {
|
|
@@ -19790,7 +19883,7 @@ async function executeUpload(plan, opts = {}) {
|
|
|
19790
19883
|
|
|
19791
19884
|
// src/verify-safe.ts
|
|
19792
19885
|
import { lstat as lstat4, readdir as readdir21, readFile as readFile19 } from "fs/promises";
|
|
19793
|
-
import { basename as basename17, extname, join as
|
|
19886
|
+
import { basename as basename17, extname, join as join35, relative as relative7 } from "path";
|
|
19794
19887
|
import {
|
|
19795
19888
|
assessShareSafety as assessShareSafety3,
|
|
19796
19889
|
combineVerdicts as combineVerdicts2
|
|
@@ -19851,7 +19944,7 @@ async function listFiles(target, unreadable) {
|
|
|
19851
19944
|
const out = [];
|
|
19852
19945
|
const walk = async (dir) => {
|
|
19853
19946
|
for (const entry of (await readdir21(dir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
19854
|
-
const path =
|
|
19947
|
+
const path = join35(dir, entry.name);
|
|
19855
19948
|
if (entry.isDirectory()) await walk(path);
|
|
19856
19949
|
else if (entry.isFile()) out.push(path);
|
|
19857
19950
|
else unreadable.push(`${relative7(target, path)}: not a regular file`);
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4139,6 +4139,12 @@ interface PrimeAnalyzerOptions {
|
|
|
4139
4139
|
repair?: boolean;
|
|
4140
4140
|
transport?: PrimeTransport;
|
|
4141
4141
|
}
|
|
4142
|
+
interface FindingsFileOutcome {
|
|
4143
|
+
parsed: Record<string, unknown> | null;
|
|
4144
|
+
/** Human-readable receipt for the output: what the file was and what
|
|
4145
|
+
* happened to it. Present whenever a file was found. */
|
|
4146
|
+
receipt: string;
|
|
4147
|
+
}
|
|
4142
4148
|
/** Default transport: plain node:http/https, NOT fetch — undici's fixed 300s
|
|
4143
4149
|
* headers timeout kills prime calls that legitimately run longer; the
|
|
4144
4150
|
* analyzer's AbortSignal is the only deadline. */
|
|
@@ -4934,4 +4940,4 @@ interface ExecuteOptions {
|
|
|
4934
4940
|
/** Send the final, new outbound items (or write their dry-run OTLP). */
|
|
4935
4941
|
declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
|
|
4936
4942
|
|
|
4937
|
-
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalysisEngineFromEnvOptions, type AnalyzeOptions, type AnalyzeResult, type AnswerSchema, type AssembleSessionBundleOptions, BLOBS_DIR, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CHANGED_FILE_LIST_CAP, CITATION_NORMALIZATION_VERSION, CONTENT_CAP, COORDINATION_LOG_FILE, CORRECTIVE_REACTIONS, type ChangedFileFact, type ChatTrajectory, type ChatTrajectoryMessage, type ChatTrajectoryOptions, ClaudeAdapter, type CodeTraceBenchFileRef, type CodeTraceBenchImportOptions, type CodeTraceBenchImportReceipt, type CodeTraceBenchImportResult, type CodeTraceBenchImportedTrace, type CodeTraceBenchStep, CodexAdapter, CodexExecAdapter, CodexExecStreamError, CodexTaskScopeError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, type CollectSessionSelectionOptions, type CollectSessionWorkflowOptions, type CompactionMeasurement, type ConformanceRenderOptions, type ContentFootprint, type CoordinationLog, type CoordinationQuestion, type CoordinationSteer, CopilotAdapter, type CorruptionMode, type CoveredMeasurement, DEFAULT_ANALYST_MODEL, DEFAULT_ASK_CONCURRENCY, DEFAULT_HARNESS, DEFAULT_SANDBOX_BASE_URL, EMPTY_SPAN_RUN_SNAPSHOT, EXPORT_RULE, EmptySessionError, type EvidenceOnlyVerdict, type ExcludedTurnFact, type ExecuteOptions, type ExportRule, type ExternalAnalysisKind, type ExternalAnalysisPayload, type ExternalAnalysisResult, type ExternalAnalyzer, type ExternalAnalyzerOptions, type ExternalDiscoveryCandidate, FACT_LIST_CAP, FACT_TEXT_CAP, FactoryAdapter, type FailureFollowUp, type FailureFollowUpReport, type FileRunContextReaderOptions, type FinalMessageFact, type FindSessionTextLeaksOptions, type FindingRejectionCounts, type FindingRejectionReasons, type FindingRejectionTally, type FollowUpKind, ForgeAdapter, GeminiAdapter, type HaloAnalyzerOptions, type HaloReasoningEffort, type HarnessTraceAdapter, type HodoscopeAnalyzerOptions, type HodoscopeInput, type HodoscopeMessage, type HodoscopeSourceMapEntry, type HodoscopeTrajectory, INGEST_SOURCE_CLI, INHERITED_SOURCE_ATTR, INHERITED_SPANS_OMITTED_ATTR, INHERITED_SPAN_ATTR, INHERITED_SPAN_COUNT_ATTR, type InheritedSpanSource, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type LoopConvergence, type LoopConvergenceReport, type LoopIteration, type LoopTrend, type LoopTrendBasis, MAX_SHELL_DEPTH, MAX_TRACE_QUESTION_CHARS, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpIngestIssue, type OtlpIngestIssueKind, type OtlpInput, type OtlpInputFile, type OtlpRowConversion, type OtlpSpan, type OtlpSpanKind, type OtlpSpanLink, type OtlpStatusCode, POLICY_EVIDENCE_NOTE, PREPARED_CONTEXT_BYTE_CEILING, type ParentTaskResolution, type ParseOptions, PartialUploadError, PiAdapter, type PiAdapterOptions, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, type PrimeAnalyzerOptions, type PrimeTransport, type PrimeTransportRequest, type PrimeTransportResponse, type ProjectSessionBundleOptions, type ProjectSessionBundleResult, type PullRequestFact, type PullRequestFacts, type PullRequestReading, QwenAdapter, REACTIONS, RESULT_FILE, RULE, type Reaction, type ReactionReport, type ReactionSessionReport, type RedactSpansOptions, type Redactor, type RefusedSession, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type ResolvedOtlpInput, type RunContextJournal, type RunContextNode, type RunContextResult, type RunContextSnapshot, type RunDiffOptions, type RunDiffReport, type RunDiffSide, type RunResult, type RunWatchSnapshot, type RunWatchTarget, type RuntimeTrace, SESSION_FACTS_MEASUREMENT_VERSION, SESSION_FACTS_VERSION_SUFFIX, SESSION_TOKEN_TOTAL_ATTR, SOURCE_ATTRIBUTE_PREFIX, SPAN_SYNTHESIZED_ATTR, SPAWN_JOURNAL_FILE, STATUS_MARK, SYNTHESIZED_SOURCE_ATTR, SYNTHESIZED_SPAN_ATTR, type SandboxReplayBackendOptions, type ScanOptions, type ScannedSession, type SessionBatch, type SessionBundleAbsence, type SessionBundleCarriedSignatures, type SessionBundleExclusion, type SessionBundleExclusionRule, type SessionBundleFile, type SessionBundleIssue, type SessionBundleIssueKind, type SessionBundleLeakCheck, type SessionBundleLedgerSlice, type SessionBundleManifest, type SessionBundleProjection, type SessionBundleResult, type SessionBundleSliceRule, type SessionBundleVerification, type SessionBundleView, type SessionCorruptionReceipt, type SessionEnvironment, type SessionFact, type SessionFacts, type SessionFactsOptions, type SessionFactsReport, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionMeasurements, type SessionRef, type SessionRelationship, type SessionRole, type SessionSeedGroup, type SessionSelection, type SessionSelectionRow, type SessionSourceFile, type SessionTextLeak, type SessionTextLeakReport, type SessionTurnFact, type SessionWorkflow, SessionWorkflowError, type SessionWorkflowErrorCode, type SessionWorkflowIssue, type SessionWorkflowSession, type SessionWorkflowSummary, type SkippedAnalysis, type SkippedInputFile, type SourceRecordReference, type SpanInput, type SpanNodeStatus, type SpanRedaction, type SpanRunNode, type SpanRunSnapshot, type SpanStructure, type SpawnedChildResolution, type SpendRoll, type SteeringChainReport, type SteeringEdge, type SubagentSpawnFact, TRACE_QUESTION_PREVIEW_HEAD_CHARS, type ToolMeasurement, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceQuestion, type TraceQuestionAnswer, type TraceQuestionCitation, type TraceQuestionFailureKind, type TraceQuestionTrace, type TraceQuestionsArtifacts, type TraceQuestionsOptions, type TraceQuestionsResult, type TraceQuestionsTotals, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type TurnActorCount, type UnavailableCapabilities, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, type VerifySafeOptions, type VerifySafeResult, type WatchRunTargetOptions, ZERO_ROLL, type ZaiChatCallerOptions, addSpend, alreadyUploaded, analysisEngineFromEnv, analyzeAdoption, analyzeLiveBatch, analyzeLoopConvergence, analyzeReactions, analyzeSpans, analyzeSteeringChain, answerSchemaErrors, applyRedactor, assembleSessionBundle, assertAnswerSchema, assertSandboxReachable, assessSpans, buildPolicyEvidenceRecord, buildSessionFactsReport, buildSessionIndex, buildSessionIndexFromRows, buildSpanRunTree, buildTraceFindingPacket, capText, chatTrajectoryToSpans, classifyEvidenceOnlyPath, classifyFailureFollowUps, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessionSelection, collectSessionWorkflow, collectSessions, commandAnalyzer, commandRedactor, commandTextFromInput, computeAdoption, computeSessionFacts, conformanceOfSpans, connectors, countSkillRunsJsonl, createBundleSourceReader, createFindingRejectionTally, cwdMatchesSelection, cwdMatchesSelectionResolved, defaultTraceLiveAnalysts, describeSessionRelationship, diffRuns, engineCallReservationFloorUsd, environmentAttributes, environmentFromSpanAttributes, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, externalFailureMessage, fileRunContextSupervisorRunReader, fileSha256, findContextRoot, findSessionTextLeaks, findSpanSourceFiles, findingRejection, findingRejectionDetail, forEachTreeNode, formatFindingRejections, formatVerdict, haloAnalyzer, hashSessionBundleFiles, hodoscopeAnalyzer, httpJsonTransport, importCodeTraceBench, incompleteInputsNote, indexSessionIdsByTrace, inferRole, inferSpanKind, inspectSessionIndex, int, isBridgeMismatchError, isChatTrajectory, isChatTrajectoryMessage, isFileRunContextDir, isInheritedSpan, isSynthesizedSpan, iterSerializedSpans, knownHarnesses, listAdapters, listSessionBundleFiles, loadState, loadTraceQuestionsFile, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeRolls, mergeTracesConfig, ms, normalizeAnalystCitations, normalizeRemote, normalizeTraceQuestions, otlpRowToSpan, outboundHash, parseIsoToEpochMs, parseJsonAnswer, parseSession, parseSince, planTraceAgenticRoute, planUpload, primeAnalyzer, projectSessionBundle, readCoordinationLog, readFileRunContext, readJsonFile, readJsonl, readOtlpInput, readPullRequests, readRunContextJournal, readRunContextSnapshot, readRunSide, readRunWatchSnapshot, readSessionBundleManifest, readSessionIndexFile, readSpanRunSnapshot, recordSessionCorruption, redactSpans, renderConformance, renderInspectionReport, renderRunContextSnapshot, renderRunDiff, renderRunWatchSnapshot, renderSessionFacts, renderSessionFactsContext, renderSpanRunSnapshot, renderTraceQuestionInstructions, renderTraceQuestionPrompt, renderTraceQuestionsReport, renderValidation, resolveAdapter, resolveOtlpInputFiles, resolveRepoAttrs, resolveRunContextDir, resolveRunWatchTarget, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTotals, runTraceImprovement, runTraceInvestigation, runTraceQuestions, runTraceStoreInvestigation, sandboxReplayBackend, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionFactsContext, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, sessionTextSignatures, shellCommands, skippedAnalyses, span, spanRunTotals, stampEnvironmentAttrs, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, summarizeSpanStructure, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, tokens, totalAgenticFailureMessage, totalFindingRejections, traceAgenticKinds, traceCitationsInText, traceStreamEventsFromSpans, unavailableCapabilities, uploadKey, usd, userPromptSpan, validateOtlpSpans, validationExitCode, verdictExitCode, verifyFindingsInSandbox, verifySafe, verifySessionBundle, watchRunTarget, watchSessions, withSessionFactsContext, wrap, writeHodoscopeInput, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionBundleManifest, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts, writeTraceQuestionsArtifacts, zaiChatCaller, zeroPricedCost };
|
|
4943
|
+
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalysisEngineFromEnvOptions, type AnalyzeOptions, type AnalyzeResult, type AnswerSchema, type AssembleSessionBundleOptions, BLOBS_DIR, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CHANGED_FILE_LIST_CAP, CITATION_NORMALIZATION_VERSION, CONTENT_CAP, COORDINATION_LOG_FILE, CORRECTIVE_REACTIONS, type ChangedFileFact, type ChatTrajectory, type ChatTrajectoryMessage, type ChatTrajectoryOptions, ClaudeAdapter, type CodeTraceBenchFileRef, type CodeTraceBenchImportOptions, type CodeTraceBenchImportReceipt, type CodeTraceBenchImportResult, type CodeTraceBenchImportedTrace, type CodeTraceBenchStep, CodexAdapter, CodexExecAdapter, CodexExecStreamError, CodexTaskScopeError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, type CollectSessionSelectionOptions, type CollectSessionWorkflowOptions, type CompactionMeasurement, type ConformanceRenderOptions, type ContentFootprint, type CoordinationLog, type CoordinationQuestion, type CoordinationSteer, CopilotAdapter, type CorruptionMode, type CoveredMeasurement, DEFAULT_ANALYST_MODEL, DEFAULT_ASK_CONCURRENCY, DEFAULT_HARNESS, DEFAULT_SANDBOX_BASE_URL, EMPTY_SPAN_RUN_SNAPSHOT, EXPORT_RULE, EmptySessionError, type EvidenceOnlyVerdict, type ExcludedTurnFact, type ExecuteOptions, type ExportRule, type ExternalAnalysisKind, type ExternalAnalysisPayload, type ExternalAnalysisResult, type ExternalAnalyzer, type ExternalAnalyzerOptions, type ExternalDiscoveryCandidate, FACT_LIST_CAP, FACT_TEXT_CAP, FactoryAdapter, type FailureFollowUp, type FailureFollowUpReport, type FileRunContextReaderOptions, type FinalMessageFact, type FindSessionTextLeaksOptions, type FindingRejectionCounts, type FindingRejectionReasons, type FindingRejectionTally, type FindingsFileOutcome, type FollowUpKind, ForgeAdapter, GeminiAdapter, type HaloAnalyzerOptions, type HaloReasoningEffort, type HarnessTraceAdapter, type HodoscopeAnalyzerOptions, type HodoscopeInput, type HodoscopeMessage, type HodoscopeSourceMapEntry, type HodoscopeTrajectory, INGEST_SOURCE_CLI, INHERITED_SOURCE_ATTR, INHERITED_SPANS_OMITTED_ATTR, INHERITED_SPAN_ATTR, INHERITED_SPAN_COUNT_ATTR, type InheritedSpanSource, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type LoopConvergence, type LoopConvergenceReport, type LoopIteration, type LoopTrend, type LoopTrendBasis, MAX_SHELL_DEPTH, MAX_TRACE_QUESTION_CHARS, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpIngestIssue, type OtlpIngestIssueKind, type OtlpInput, type OtlpInputFile, type OtlpRowConversion, type OtlpSpan, type OtlpSpanKind, type OtlpSpanLink, type OtlpStatusCode, POLICY_EVIDENCE_NOTE, PREPARED_CONTEXT_BYTE_CEILING, type ParentTaskResolution, type ParseOptions, PartialUploadError, PiAdapter, type PiAdapterOptions, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, type PrimeAnalyzerOptions, type PrimeTransport, type PrimeTransportRequest, type PrimeTransportResponse, type ProjectSessionBundleOptions, type ProjectSessionBundleResult, type PullRequestFact, type PullRequestFacts, type PullRequestReading, QwenAdapter, REACTIONS, RESULT_FILE, RULE, type Reaction, type ReactionReport, type ReactionSessionReport, type RedactSpansOptions, type Redactor, type RefusedSession, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type ResolvedOtlpInput, type RunContextJournal, type RunContextNode, type RunContextResult, type RunContextSnapshot, type RunDiffOptions, type RunDiffReport, type RunDiffSide, type RunResult, type RunWatchSnapshot, type RunWatchTarget, type RuntimeTrace, SESSION_FACTS_MEASUREMENT_VERSION, SESSION_FACTS_VERSION_SUFFIX, SESSION_TOKEN_TOTAL_ATTR, SOURCE_ATTRIBUTE_PREFIX, SPAN_SYNTHESIZED_ATTR, SPAWN_JOURNAL_FILE, STATUS_MARK, SYNTHESIZED_SOURCE_ATTR, SYNTHESIZED_SPAN_ATTR, type SandboxReplayBackendOptions, type ScanOptions, type ScannedSession, type SessionBatch, type SessionBundleAbsence, type SessionBundleCarriedSignatures, type SessionBundleExclusion, type SessionBundleExclusionRule, type SessionBundleFile, type SessionBundleIssue, type SessionBundleIssueKind, type SessionBundleLeakCheck, type SessionBundleLedgerSlice, type SessionBundleManifest, type SessionBundleProjection, type SessionBundleResult, type SessionBundleSliceRule, type SessionBundleVerification, type SessionBundleView, type SessionCorruptionReceipt, type SessionEnvironment, type SessionFact, type SessionFacts, type SessionFactsOptions, type SessionFactsReport, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionMeasurements, type SessionRef, type SessionRelationship, type SessionRole, type SessionSeedGroup, type SessionSelection, type SessionSelectionRow, type SessionSourceFile, type SessionTextLeak, type SessionTextLeakReport, type SessionTurnFact, type SessionWorkflow, SessionWorkflowError, type SessionWorkflowErrorCode, type SessionWorkflowIssue, type SessionWorkflowSession, type SessionWorkflowSummary, type SkippedAnalysis, type SkippedInputFile, type SourceRecordReference, type SpanInput, type SpanNodeStatus, type SpanRedaction, type SpanRunNode, type SpanRunSnapshot, type SpanStructure, type SpawnedChildResolution, type SpendRoll, type SteeringChainReport, type SteeringEdge, type SubagentSpawnFact, TRACE_QUESTION_PREVIEW_HEAD_CHARS, type ToolMeasurement, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceQuestion, type TraceQuestionAnswer, type TraceQuestionCitation, type TraceQuestionFailureKind, type TraceQuestionTrace, type TraceQuestionsArtifacts, type TraceQuestionsOptions, type TraceQuestionsResult, type TraceQuestionsTotals, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type TurnActorCount, type UnavailableCapabilities, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, type VerifySafeOptions, type VerifySafeResult, type WatchRunTargetOptions, ZERO_ROLL, type ZaiChatCallerOptions, addSpend, alreadyUploaded, analysisEngineFromEnv, analyzeAdoption, analyzeLiveBatch, analyzeLoopConvergence, analyzeReactions, analyzeSpans, analyzeSteeringChain, answerSchemaErrors, applyRedactor, assembleSessionBundle, assertAnswerSchema, assertSandboxReachable, assessSpans, buildPolicyEvidenceRecord, buildSessionFactsReport, buildSessionIndex, buildSessionIndexFromRows, buildSpanRunTree, buildTraceFindingPacket, capText, chatTrajectoryToSpans, classifyEvidenceOnlyPath, classifyFailureFollowUps, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessionSelection, collectSessionWorkflow, collectSessions, commandAnalyzer, commandRedactor, commandTextFromInput, computeAdoption, computeSessionFacts, conformanceOfSpans, connectors, countSkillRunsJsonl, createBundleSourceReader, createFindingRejectionTally, cwdMatchesSelection, cwdMatchesSelectionResolved, defaultTraceLiveAnalysts, describeSessionRelationship, diffRuns, engineCallReservationFloorUsd, environmentAttributes, environmentFromSpanAttributes, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, externalFailureMessage, fileRunContextSupervisorRunReader, fileSha256, findContextRoot, findSessionTextLeaks, findSpanSourceFiles, findingRejection, findingRejectionDetail, forEachTreeNode, formatFindingRejections, formatVerdict, haloAnalyzer, hashSessionBundleFiles, hodoscopeAnalyzer, httpJsonTransport, importCodeTraceBench, incompleteInputsNote, indexSessionIdsByTrace, inferRole, inferSpanKind, inspectSessionIndex, int, isBridgeMismatchError, isChatTrajectory, isChatTrajectoryMessage, isFileRunContextDir, isInheritedSpan, isSynthesizedSpan, iterSerializedSpans, knownHarnesses, listAdapters, listSessionBundleFiles, loadState, loadTraceQuestionsFile, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeRolls, mergeTracesConfig, ms, normalizeAnalystCitations, normalizeRemote, normalizeTraceQuestions, otlpRowToSpan, outboundHash, parseIsoToEpochMs, parseJsonAnswer, parseSession, parseSince, planTraceAgenticRoute, planUpload, primeAnalyzer, projectSessionBundle, readCoordinationLog, readFileRunContext, readJsonFile, readJsonl, readOtlpInput, readPullRequests, readRunContextJournal, readRunContextSnapshot, readRunSide, readRunWatchSnapshot, readSessionBundleManifest, readSessionIndexFile, readSpanRunSnapshot, recordSessionCorruption, redactSpans, renderConformance, renderInspectionReport, renderRunContextSnapshot, renderRunDiff, renderRunWatchSnapshot, renderSessionFacts, renderSessionFactsContext, renderSpanRunSnapshot, renderTraceQuestionInstructions, renderTraceQuestionPrompt, renderTraceQuestionsReport, renderValidation, resolveAdapter, resolveOtlpInputFiles, resolveRepoAttrs, resolveRunContextDir, resolveRunWatchTarget, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTotals, runTraceImprovement, runTraceInvestigation, runTraceQuestions, runTraceStoreInvestigation, sandboxReplayBackend, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionFactsContext, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, sessionTextSignatures, shellCommands, skippedAnalyses, span, spanRunTotals, stampEnvironmentAttrs, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, summarizeSpanStructure, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, tokens, totalAgenticFailureMessage, totalFindingRejections, traceAgenticKinds, traceCitationsInText, traceStreamEventsFromSpans, unavailableCapabilities, uploadKey, usd, userPromptSpan, validateOtlpSpans, validationExitCode, verdictExitCode, verifyFindingsInSandbox, verifySafe, verifySessionBundle, watchRunTarget, watchSessions, withSessionFactsContext, wrap, writeHodoscopeInput, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionBundleManifest, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts, writeTraceQuestionsArtifacts, zaiChatCaller, zeroPricedCost };
|
package/dist/index.js
CHANGED
package/docs/trace-analysts.md
CHANGED
|
@@ -389,6 +389,47 @@ Output expectations:
|
|
|
389
389
|
|
|
390
390
|
The scored prime-vs-dspy comparison — same trajectories, same scoring — lives in `@tangle-network/agent-eval`'s analyst benchmark (`runAnalystBenchmark`); this engine is the capture-side entry point, not the scoreboard.
|
|
391
391
|
|
|
392
|
+
### Verifying against a real prime
|
|
393
|
+
|
|
394
|
+
The suite above runs against a scripted bridge over real HTTP. A full real run — real
|
|
395
|
+
prime-agent, real model, real REPL — is a manual, credentials-on-the-host affair:
|
|
396
|
+
|
|
397
|
+
1. **Install prime-agent the way cli-bridge pins it.** It is a hard fork of pi that reuses
|
|
398
|
+
pi's npm name, so `npm i` gives you the WRONG agent: clone
|
|
399
|
+
`PrimeIntellect-ai/prime-agent`, `git checkout <the commit src/backends/prime.ts names>`
|
|
400
|
+
(be9e2fa0 at the time of writing), build, and expose the bundle as `prime-agent`
|
|
401
|
+
(cli-bridge's `pnpm install:harness prime` does exactly this).
|
|
402
|
+
2. **Start cli-bridge with the prime backend**: `BRIDGE_BACKENDS=prime
|
|
403
|
+
PRIME_MODELS_JSON=<operator models.json> BRIDGE_PORT=4181 pnpm start`. The
|
|
404
|
+
models.json names an `apiKey` as an exported ENV VAR (not a literal — prime
|
|
405
|
+
resolves env-var-first, so an unforwarded name becomes the literal key), and the
|
|
406
|
+
bridge forwards exactly the names the file names into prime's neutral child env.
|
|
407
|
+
Mind which endpoint a key is funded on: a coding-plan GLM key only works on the
|
|
408
|
+
coding endpoint, and the same key 402s on the general one.
|
|
409
|
+
3. **Give the kernel a persistent interpreter.** Prime's Python kernel bootstraps a
|
|
410
|
+
venv under its HOME, and the bridge gives every run an isolated one — a
|
|
411
|
+
uv-managed interpreter installed inside an ephemeral HOME dies with it. Pre-provision
|
|
412
|
+
a venv (ipykernel + the default rlm extras + an editable
|
|
413
|
+
`prime-agent-runtime`) from a system Python and export
|
|
414
|
+
`PRIME_AGENT_KERNEL_PYTHON=<that venv's python>` to the bridge; prime skips
|
|
415
|
+
auto-bootstrap when the named interpreter already passes its checks.
|
|
416
|
+
4. Run with `TRACES_PRIME_BRIDGE_URL=http://localhost:4181 TRACES_PRIME_MODEL=prime/<provider>/<model>`.
|
|
417
|
+
The opt-in suite (`TRACES_PRIME_REAL_E2E=1` in `tests/analyst-engine-prime.test.ts`)
|
|
418
|
+
exercises the same path from vitest.
|
|
419
|
+
|
|
420
|
+
What real runs have shown (GLM-5.3 via a coding-plan endpoint, fork at the pinned commit):
|
|
421
|
+
|
|
422
|
+
- **Inline, small session:** clean single-call success — one fenced JSON block, five findings,
|
|
423
|
+
all grounded, exit 0.
|
|
424
|
+
- **File, ~121 spans / 788 KB artifact:** the RLM loads and pages the file (14 calls, ~156k input
|
|
425
|
+
tokens); its first reply gets cut by the endpoint's output limit mid-JSON, and the
|
|
426
|
+
truncation-aware repair turn (re-emit at most 3 findings, terse strings) recovers it — ok:true,
|
|
427
|
+
findings grounded, exit 0.
|
|
428
|
+
- **File, ~794 spans / 2.1 MB artifact:** ~2.2M input tokens of genuine REPL inspection, but the
|
|
429
|
+
reply never survives the endpoint's output cap even after repair — the run fails honestly
|
|
430
|
+
(exit 1, raw reply preserved, no findings invented). At that trajectory size, a model with a
|
|
431
|
+
larger output budget — or a paged finalization — is the next step, not silence about it.
|
|
432
|
+
|
|
392
433
|
## Write one analyst
|
|
393
434
|
|
|
394
435
|
An analyst receives a paged trace store and returns typed findings.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/traces",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi,
|
|
3
|
+
"version": "0.18.0",
|
|
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",
|
|
7
7
|
"repository": {
|