@tangle-network/agent-eval 1.0.13 → 1.0.15

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/analyst/index.js +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/contract/index.js +1 -1
  5. package/dist/{default-registry-eCkZFfuF.js → default-registry-BB9_jzyH.js} +2 -2
  6. package/dist/{default-registry-eCkZFfuF.js.map → default-registry-BB9_jzyH.js.map} +1 -1
  7. package/dist/diagnosis/index.d.ts.map +1 -1
  8. package/dist/diagnosis/index.js +19 -13
  9. package/dist/diagnosis/index.js.map +1 -1
  10. package/dist/{exporters-ByLcILYU.js → exporters-BKZLt1Px.js} +2 -2
  11. package/dist/{exporters-ByLcILYU.js.map → exporters-BKZLt1Px.js.map} +1 -1
  12. package/dist/{hf-dataset-DPVQXW5n.js → hf-dataset-Bv114tzB.js} +11 -11
  13. package/dist/{hf-dataset-DPVQXW5n.js.map → hf-dataset-Bv114tzB.js.map} +1 -1
  14. package/dist/index-f09MX_H_.d.ts.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +6 -9
  17. package/dist/index.js.map +1 -1
  18. package/dist/{integrity-Vx5xgn3s.js → integrity-BHM4voOx.js} +3 -3
  19. package/dist/{integrity-Vx5xgn3s.js.map → integrity-BHM4voOx.js.map} +1 -1
  20. package/dist/{mint-BH_3Ak2x.js → mint-yF51iBgY.js} +2 -2
  21. package/dist/{mint-BH_3Ak2x.js.map → mint-yF51iBgY.js.map} +1 -1
  22. package/dist/multishot/golden/index.d.ts.map +1 -1
  23. package/dist/multishot/golden/index.js +3 -5
  24. package/dist/multishot/golden/index.js.map +1 -1
  25. package/dist/openapi.json +1 -1
  26. package/dist/{render-BVPfP7dc.js → render-CsHLoMUl.js} +70 -47
  27. package/dist/render-CsHLoMUl.js.map +1 -0
  28. package/dist/rl.js +3 -3
  29. package/dist/rollout/index.js +5 -5
  30. package/dist/{rollout-CbOGxuHl.js → rollout-Cu7kHGIe.js} +5 -5
  31. package/dist/{rollout-CbOGxuHl.js.map → rollout-Cu7kHGIe.js.map} +1 -1
  32. package/dist/{rollout-nodes-DKZ3vAYY.js → rollout-nodes-DhSPJ2X7.js} +4 -4
  33. package/dist/rollout-nodes-DhSPJ2X7.js.map +1 -0
  34. package/dist/{schema-YUIXT8iW.js → schema-ChIZfnqY.js} +37 -5
  35. package/dist/schema-ChIZfnqY.js.map +1 -0
  36. package/dist/supervisor-run/index.d.ts +1 -0
  37. package/dist/supervisor-run/index.d.ts.map +1 -1
  38. package/dist/supervisor-run/index.js +3 -3
  39. package/dist/trace-repair/index.d.ts.map +1 -1
  40. package/dist/trace-repair/index.js +2 -5
  41. package/dist/trace-repair/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/render-BVPfP7dc.js.map +0 -1
  44. package/dist/rollout-nodes-DKZ3vAYY.js.map +0 -1
  45. package/dist/schema-YUIXT8iW.js.map +0 -1
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "@tangle-network/agent-eval — wire protocol",
5
- "version": "1.0.13",
5
+ "version": "1.0.15",
6
6
  "description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.1.0. Bumps on breaking changes to request/response schemas.",
7
7
  "contact": {
8
8
  "name": "Tangle Network",
@@ -2,8 +2,8 @@ import { a as hashCanonical } from "./canonical-CicJlINA.js";
2
2
  import { l as unscreenedRewardFields, o as screenedRewardFields } from "./reward-DqMfaEax.js";
3
3
  import { c as summarizeNumberSeries } from "./descriptive-B3Eb7tX0.js";
4
4
  import { t as roundDecimal } from "./round-decimal-ZmjAQPo1.js";
5
- import { S as licenseClassOfName } from "./schema-YUIXT8iW.js";
6
- import { _ as showMeasured, a as readTerminalRecord, c as parseJsonRecord, d as recordOrNull, f as workerSourceKey, g as isUnavailable, h as SUPERVISOR_RUN_SCHEMA, l as parseJsonl, n as supervisorRunRolloutLinesFromFacts, o as asRecord, p as NO_SOURCE_LIMITS, s as nonEmptyString, u as parseSupervisorTree, v as unavailable, y as expandJournalEventGroup } from "./rollout-nodes-DKZ3vAYY.js";
5
+ import { S as licenseClassOfName } from "./schema-ChIZfnqY.js";
6
+ import { _ as showMeasured, a as readTerminalRecord, c as parseJsonRecord, d as recordOrNull, f as workerSourceKey, g as isUnavailable, h as SUPERVISOR_RUN_SCHEMA, l as parseJsonl, n as supervisorRunRolloutLinesFromFacts, o as asRecord, p as NO_SOURCE_LIMITS, s as nonEmptyString, u as parseSupervisorTree, v as unavailable, y as expandJournalEventGroup } from "./rollout-nodes-DhSPJ2X7.js";
7
7
  import { basename, join } from "node:path";
8
8
  import { execFile } from "node:child_process";
9
9
  import { readFile, readdir, stat } from "node:fs/promises";
@@ -1379,9 +1379,10 @@ async function isFile(path) {
1379
1379
  * - Producer: each node's `materialized` receipt names the model it ran on
1380
1380
  * (`opencode/zai-coding-plan/glm-5.3` → harness, provider, model), and the
1381
1381
  * root's `root-segment` names the root's. The license class follows.
1382
- * - Episode: the node's task prompt (its `taskDigest` blob) and its settled
1383
- * result (its `outRef` blob, `{content, events}`), read as a Sandbox session
1384
- * with every tool call. A result without events stays a lossy projection.
1382
+ * - Episode: each execution's input (`execution-input.taskRef`) and result
1383
+ * (`execution-result.outRef`, a `{content, events}` blob), read as Sandbox
1384
+ * sessions in order, so a node steered twice keeps both turns and every tool
1385
+ * call. A node with no event stream stays a lossy projection.
1385
1386
  * - A node respawned under the same id (a reopened run) is one row.
1386
1387
  * - Reward: the run's newest known play-check verdict on the root row
1387
1388
  * (`solved` → 1, a staged `SCORE` → stages passed / stages), and each
@@ -1424,7 +1425,6 @@ function wholeEpisode({ lossy_projection: _, gap, ...kept }) {
1424
1425
  gap: workspace
1425
1426
  };
1426
1427
  }
1427
- const record = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
1428
1428
  const text = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
1429
1429
  async function journalFacts(runDir) {
1430
1430
  const facts = /* @__PURE__ */ new Map();
@@ -1438,15 +1438,15 @@ async function journalFacts(runDir) {
1438
1438
  const expanded = expandJournalEventGroup(row);
1439
1439
  if (!expanded.succeeded) continue;
1440
1440
  for (const entry of expanded.value) {
1441
- const event = record(entry.event);
1441
+ const event = recordOrNull(entry.event);
1442
1442
  const id = text(event?.id);
1443
1443
  if (event === null || id === void 0) continue;
1444
- if (event.kind === "spawned") node(id).taskRef ??= text(record(event.identity)?.taskDigest);
1444
+ if (event.kind === "spawned") node(id).taskRef ??= text(recordOrNull(event.identity)?.taskDigest);
1445
1445
  else if (event.kind === "materialized") {
1446
- const model = record(record(event.receipt)?.model);
1446
+ const model = recordOrNull(recordOrNull(event.receipt)?.model);
1447
1447
  if (model?.status === "known" && text(model.id)) node(id).model = text(model.id);
1448
1448
  } else if (event.kind === "root-segment") {
1449
- const to = record(event.to);
1449
+ const to = recordOrNull(event.to);
1450
1450
  const model = text(to?.model);
1451
1451
  if (model) node(id).model = [
1452
1452
  text(to?.harness),
@@ -1454,21 +1454,54 @@ async function journalFacts(runDir) {
1454
1454
  model
1455
1455
  ].join("/");
1456
1456
  } else if (event.kind === "settled" && text(event.outRef)) node(id).outRef = text(event.outRef);
1457
+ else if (event.kind === "execution-input") {
1458
+ const fact = node(id);
1459
+ fact.inputRef = text(event.taskRef);
1460
+ fact.unansweredSince ??= text(event.at);
1461
+ } else if (event.kind === "execution-result" && text(event.outRef)) {
1462
+ const fact = node(id);
1463
+ fact.unansweredSince = void 0;
1464
+ const taskRef = fact.inputRef ?? fact.taskRef;
1465
+ (fact.executions ??= []).push({
1466
+ taskRef,
1467
+ outRef: event.outRef
1468
+ });
1469
+ }
1457
1470
  }
1458
1471
  }
1459
1472
  return facts;
1460
1473
  }
1474
+ const readJson = (path) => readFile(path, "utf8").then(JSON.parse).catch(() => void 0);
1461
1475
  async function blobValue(runDir, ref) {
1462
1476
  if (ref === void 0 || !/^sha256:[0-9a-f]{64}$/u.test(ref)) return void 0;
1463
- const raw = await readFile(join(runDir, "blobs", `${ref.replace(":", "-")}.json`), "utf8").catch(() => void 0);
1464
- if (raw === void 0) return void 0;
1465
- try {
1466
- return JSON.parse(raw);
1467
- } catch {
1468
- return;
1469
- }
1477
+ return readJson(join(runDir, "blobs", `${ref.replace(":", "-")}.json`));
1470
1478
  }
1471
1479
  const jsonlRows = async (path) => parseJsonl(await readFile(path, "utf8").catch(() => null));
1480
+ /** One Sandbox session per execution, oldest first; older runs keep only the settled result. */
1481
+ async function nodeSessions(runDir, harness, id, fact) {
1482
+ const executions = fact.executions ?? [{
1483
+ taskRef: fact.taskRef,
1484
+ outRef: fact.outRef
1485
+ }];
1486
+ const sessions = [];
1487
+ for (const [index, { taskRef, outRef }] of executions.entries()) {
1488
+ const [input, result] = await Promise.all([blobValue(runDir, taskRef), blobValue(runDir, outRef)]);
1489
+ const task = text(input) ?? text(recordOrNull(input)?.prompt) ?? text(recordOrNull(input)?.instruction);
1490
+ const answer = text(result) ?? text(recordOrNull(result)?.content);
1491
+ const stream = recordOrNull(result)?.events;
1492
+ const events = Array.isArray(stream) ? stream : [];
1493
+ if (task === void 0 || answer === void 0 && events.length === 0) continue;
1494
+ const nativeSessionId = `${id}:${index}`;
1495
+ sessions.push(sandboxEventsSession({
1496
+ harness,
1497
+ nativeSessionId,
1498
+ task,
1499
+ answer: answer ?? "",
1500
+ events
1501
+ }));
1502
+ }
1503
+ return sessions;
1504
+ }
1472
1505
  /**
1473
1506
  * The newest play-check row whose verdict is known. A staged check
1474
1507
  * (`SCORE {"reached": r, "of": n}`) that is not solved failed at stage r, so it
@@ -1477,38 +1510,34 @@ const jsonlRows = async (path) => parseJsonl(await readFile(path, "utf8").catch(
1477
1510
  */
1478
1511
  async function discoveryPlayCheckReward(runDir) {
1479
1512
  const rows = await jsonlRows(join(runDir, "play-checks.jsonl"));
1480
- if (rows.length === 0) {
1481
- const single = await readFile(join(runDir, "play-check.json"), "utf8").catch(() => null);
1482
- try {
1483
- const row = single === null ? null : record(JSON.parse(single));
1484
- if (row) rows.push(row);
1485
- } catch {}
1486
- }
1513
+ const single = rows.length === 0 ? recordOrNull(await readJson(join(runDir, "play-check.json"))) : null;
1514
+ if (single) rows.push(single);
1487
1515
  const last = rows.filter((row) => row.known !== false && typeof row.solved === "boolean").sort((a, b) => String(a.at ?? "").localeCompare(String(b.at ?? ""))).at(-1);
1488
1516
  if (last === void 0) return null;
1489
1517
  const detail = typeof last.detail === "string" ? last.detail : "";
1490
1518
  let reward = last.solved === true ? 1 : 0;
1491
1519
  const score = detail.split("\n").find((line) => line.startsWith("SCORE {"));
1492
1520
  if (reward === 0 && score !== void 0) try {
1493
- const staged = record(JSON.parse(score.slice(6)));
1494
- const reached = staged?.reached;
1495
- const of = staged?.of;
1521
+ const { reached, of } = JSON.parse(score.slice(6));
1496
1522
  if (Number.isSafeInteger(reached) && Number.isSafeInteger(of) && 1 <= reached && reached <= of) reward = (reached - 1) / of;
1497
1523
  } catch {}
1498
1524
  const key = last.contentHash ?? last.commit ?? last.at;
1499
1525
  const ruling = (await jsonlRows(join(runDir, "goal-audits.jsonl"))).filter((a) => a.key === key && a.verdict !== "unavailable").at(-1);
1500
- const receipt = await readFile(join(runDir, "RECEIPT.json"), "utf8").then(JSON.parse, () => null);
1501
- const calibration = record(record(record(receipt)?.check)?.calibration);
1502
- const stages = Object.values(record(calibration?.stages) ?? {});
1526
+ const receipt = recordOrNull(await readJson(join(runDir, "RECEIPT.json")));
1527
+ const calibration = recordOrNull(recordOrNull(receipt?.check)?.calibration);
1528
+ const stages = Object.values(recordOrNull(calibration?.stages) ?? {});
1503
1529
  return {
1504
1530
  reward,
1505
1531
  calibrated: stages.length > 0 && stages.every((state) => state === "calibrated"),
1506
- contradicted: (ruling?.verdict ?? record(last.goalAudit)?.verdict) === "contradiction",
1532
+ contradicted: (ruling?.verdict ?? recordOrNull(last.goalAudit)?.verdict) === "contradiction",
1507
1533
  at: String(last.at ?? ""),
1534
+ taggedAt: text(receipt?.taggedAt),
1508
1535
  commit: typeof last.commit === "string" ? last.commit : null,
1509
1536
  detail: detail.slice(0, 500)
1510
1537
  };
1511
1538
  }
1539
+ /** A solved run is stopped, so it reads `cancelled`; it is whole if no turn was open at the tag. */
1540
+ const holdsTheSolve = (check, unansweredSince) => check.reward === 1 && !check.contradicted && (!unansweredSince || Date.parse(check.taggedAt ?? "") <= Date.parse(unansweredSince));
1512
1541
  /** Commits each `workers/<label>` branch holds beyond the commit every worker started from. */
1513
1542
  async function deliverableCommits(runDir) {
1514
1543
  const git = (args) => run("git", [
@@ -1570,23 +1599,17 @@ async function discoveryRunRolloutLines(runDir, options = {}) {
1570
1599
  const fact = facts.get(node.rollout_id) ?? {};
1571
1600
  const producer = fact.model === void 0 ? null : producerOf(fact.model);
1572
1601
  const license = licenseClassOfName(producer?.model) ?? licenseClassOfName(producer?.harness);
1573
- const [taskBlob, result] = await Promise.all([blobValue(runDir, fact.taskRef), blobValue(runDir, fact.outRef)]);
1574
- const task = text(taskBlob);
1575
- const answer = text(result) ?? text(record(result)?.content);
1576
- const events = record(result)?.events;
1577
- const stream = Array.isArray(events) ? events : [];
1578
- const session = task === void 0 || answer === void 0 ? null : sandboxEventsSession({
1579
- harness: producer?.harness ?? node.policy.harness ?? "sandbox",
1580
- nativeSessionId: node.rollout_id,
1581
- task,
1582
- answer,
1583
- events: stream
1584
- });
1602
+ const sessions = await nodeSessions(runDir, producer?.harness ?? node.policy.harness ?? "sandbox", node.rollout_id, fact);
1603
+ const messages = sessions.flatMap((session) => toChatMessages(session));
1585
1604
  const label = typeof node.outcome.metrics.label === "string" ? node.outcome.metrics.label : null;
1586
1605
  const isRoot = node.parent_rollout_id === null;
1587
1606
  const outcome = isRoot && check !== null ? {
1588
1607
  ...node.outcome,
1589
1608
  ...check.calibrated || check.contradicted ? screenedRewardFields(check.reward, check.contradicted) : unscreenedRewardFields(check.reward),
1609
+ ...holdsTheSolve(check, fact.unansweredSince) ? {
1610
+ is_completed: true,
1611
+ error: null
1612
+ } : {},
1590
1613
  reward_source: "discovery/play-check",
1591
1614
  verdict: {
1592
1615
  at: check.at,
@@ -1594,7 +1617,7 @@ async function discoveryRunRolloutLines(runDir, options = {}) {
1594
1617
  detail: check.detail
1595
1618
  }
1596
1619
  } : node.outcome;
1597
- const spans = session === null ? [] : toOtlpSpans(session);
1620
+ const spans = sessions.map((session) => toOtlpSpans(session)).filter((s) => s.length > 1).flat();
1598
1621
  otlp.set(node.rollout_id, spans.map((span) => `${JSON.stringify(span)}\n`).join(""));
1599
1622
  lines.push({
1600
1623
  ...node,
@@ -1607,8 +1630,8 @@ async function discoveryRunRolloutLines(runDir, options = {}) {
1607
1630
  },
1608
1631
  ...license === null ? {} : { license_class: license }
1609
1632
  },
1610
- messages: session === null ? node.messages : toChatMessages(session),
1611
- provenance: stream.length === 0 ? node.provenance : wholeEpisode(node.provenance),
1633
+ messages: sessions.length === 0 ? node.messages : messages,
1634
+ provenance: messages.some((m) => m.role === "tool") ? wholeEpisode(node.provenance) : node.provenance,
1612
1635
  outcome: {
1613
1636
  ...outcome,
1614
1637
  metrics: {
@@ -1882,4 +1905,4 @@ function renderSupervisorRollupMarkdown(rollup, title = "Round rollup") {
1882
1905
  }
1883
1906
  export { findSupervisorRunDirs as a, discoveryRunRolloutLines as c, analyzeSupervisorRunSources as d, parsePatch as f, analyzeSupervisorRun as i, isRuntimeSupervisorRunDir as l, renderSupervisorRunHeadline as n, discoveryPlayCheckReward as o, renderSupervisorRunMarkdown as r, discoveryPursuitOf as s, renderSupervisorRollupMarkdown as t, readRuntimeSupervisorRun as u };
1884
1907
 
1885
- //# sourceMappingURL=render-BVPfP7dc.js.map
1908
+ //# sourceMappingURL=render-CsHLoMUl.js.map