@tangle-network/agent-runtime 0.266.0 → 0.273.3

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 (76) hide show
  1. package/dist/{activation-BERiJjx5.js → activation-Cx2dKA_l.js} +2 -2
  2. package/dist/{activation-BERiJjx5.js.map → activation-Cx2dKA_l.js.map} +1 -1
  3. package/dist/{activation-VpxSbDKJ.d.ts → activation-IfDlhR3J.d.ts} +4 -4
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/candidate-execution/index.js +2 -2
  7. package/dist/{coordination-driver-DdZ-nh_4.js → coordination-driver-CkcW4dxU.js} +173 -92
  8. package/dist/coordination-driver-CkcW4dxU.js.map +1 -0
  9. package/dist/{delegate-Ajx_PVyu.js → delegate-Dvb1-mE-.js} +2 -2
  10. package/dist/{delegate-Ajx_PVyu.js.map → delegate-Dvb1-mE-.js.map} +1 -1
  11. package/dist/durable.d.ts +3 -571
  12. package/dist/durable.js +93 -19
  13. package/dist/durable.js.map +1 -1
  14. package/dist/{graph-CK50N9vG.js → graph-C69Uxtzt.js} +17 -8
  15. package/dist/graph-C69Uxtzt.js.map +1 -0
  16. package/dist/{improvement-cycle-GRPoHLm1.js → improvement-cycle-CO2HRCQq.js} +10 -10
  17. package/dist/improvement-cycle-CO2HRCQq.js.map +1 -0
  18. package/dist/{index-CU2mlMfc.d.ts → index-D2ipSqkP.d.ts} +4335 -3055
  19. package/dist/index.d.ts +7 -451
  20. package/dist/index.js +14 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/intelligence.d.ts +9 -3
  23. package/dist/intelligence.js +13 -7
  24. package/dist/intelligence.js.map +1 -1
  25. package/dist/kernel.d.ts +4 -4
  26. package/dist/kernel.js +9 -9
  27. package/dist/{loop-runner-bin-cC16EPUq.js → loop-runner-bin-B9MIq9O7.js} +3 -3
  28. package/dist/{loop-runner-bin-cC16EPUq.js.map → loop-runner-bin-B9MIq9O7.js.map} +1 -1
  29. package/dist/{loop-runner-bin-XKZXM08Q.d.ts → loop-runner-bin-ThlwVkvo.d.ts} +3 -3
  30. package/dist/loop-runner-bin.d.ts +1 -1
  31. package/dist/loop-runner-bin.js +1 -1
  32. package/dist/mcp/bin.js +3 -3
  33. package/dist/mcp/index.d.ts +12 -6
  34. package/dist/mcp/index.js +7 -7
  35. package/dist/mcp/memory-bin.js +1 -1
  36. package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
  37. package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
  38. package/dist/{openai-tools-D3ajI_D2.d.ts → openai-tools-Bb0mAr5z.d.ts} +2 -2
  39. package/dist/{prepare-oHUQdC5-.js → prepare-DVlvGP7V.js} +2 -2
  40. package/dist/{prepare-oHUQdC5-.js.map → prepare-DVlvGP7V.js.map} +1 -1
  41. package/dist/profiles.d.ts +2 -2
  42. package/dist/{protected-model-port-DqF0qDU6.js → protected-model-port-BrWgsCnl.js} +2 -2
  43. package/dist/{protected-model-port-DqF0qDU6.js.map → protected-model-port-BrWgsCnl.js.map} +1 -1
  44. package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-DylCC_ot.js} +14 -20
  45. package/dist/protected-redaction-DylCC_ot.js.map +1 -0
  46. package/dist/{provision-supervisor-Bf_bPaCv.js → provision-supervisor-BKAvsDtP.js} +3 -3
  47. package/dist/{provision-supervisor-Bf_bPaCv.js.map → provision-supervisor-BKAvsDtP.js.map} +1 -1
  48. package/dist/{runtime-hOLlAc1i.js → runtime-CHxXrUeZ.js} +1714 -854
  49. package/dist/runtime-CHxXrUeZ.js.map +1 -0
  50. package/dist/{server-DOb67ohd.js → server-2OeFrEVG.js} +4 -4
  51. package/dist/{server-DOb67ohd.js.map → server-2OeFrEVG.js.map} +1 -1
  52. package/dist/{stream-agent-turn-Gw9hLpBn.d.ts → stream-agent-turn-ewm3BZAp.d.ts} +34 -17
  53. package/dist/{structural-rollout-DV9YoQF6.js → structural-rollout-DCUprNpH.js} +2 -2
  54. package/dist/{structural-rollout-DV9YoQF6.js.map → structural-rollout-DCUprNpH.js.map} +1 -1
  55. package/dist/{substrate-CLt9S9ym.d.ts → substrate-VKjmrksz.d.ts} +2 -2
  56. package/dist/{supervise--njTtSL3.js → supervise-Dej5aSDa.js} +220 -52
  57. package/dist/supervise-Dej5aSDa.js.map +1 -0
  58. package/dist/{supervisor-B8UMAXya.js → supervisor-DdKPGluv.js} +1233 -303
  59. package/dist/supervisor-DdKPGluv.js.map +1 -0
  60. package/dist/testing.d.ts +2 -2
  61. package/dist/testing.js +62 -62
  62. package/dist/testing.js.map +1 -1
  63. package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
  64. package/dist/tool-server-Dqer2M4_.js.map +1 -0
  65. package/dist/tui/index.d.ts +1 -1
  66. package/dist/tui/index.js +1 -1
  67. package/dist/{types-CrnwLVYQ.d.ts → types-DMRc3jru.d.ts} +463 -105
  68. package/package.json +6 -5
  69. package/dist/coordination-driver-DdZ-nh_4.js.map +0 -1
  70. package/dist/graph-CK50N9vG.js.map +0 -1
  71. package/dist/improvement-cycle-GRPoHLm1.js.map +0 -1
  72. package/dist/protected-redaction--F3v1oo8.js.map +0 -1
  73. package/dist/runtime-hOLlAc1i.js.map +0 -1
  74. package/dist/supervise--njTtSL3.js.map +0 -1
  75. package/dist/supervisor-B8UMAXya.js.map +0 -1
  76. package/dist/tool-server-x9NEhvHZ.js.map +0 -1
package/dist/durable.js CHANGED
@@ -1,9 +1,9 @@
1
- import { $i as cloneSpend, Ii as detachedSnapshot, Ot as loadSpawnForest, Zi as addSpend, _i as authoredProfileDigest, da as zeroSpend, di as parseCommittedJsonLines, fi as prepareJsonlAppend, fr as contentAddress, mi as writeAllBytes, pi as readCommittedJsonLines, ui as isNoEntError, wt as FileSpawnJournal } from "./supervisor-B8UMAXya.js";
2
- import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
1
+ import { $i as detachedSnapshot, Ai as readCommittedJsonLines, Di as isNoEntError, E as failedItems, Lt as FileSpawnJournal, Oa as zeroSpend, Oi as parseCommittedJsonLines, Pi as authoredProfileDigest, Wt as loadSpawnForest, ga as cloneSpend, ji as writeAllBytes, ki as prepareJsonlAppend, kr as contentAddress, ma as addSpend } from "./supervisor-DdKPGluv.js";
2
+ import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
4
4
  import { a as writeAtomicDurableFile, r as publishExclusiveDurableFile } from "./durable-file-DWQA4ooo.js";
5
5
  import { i as applyExactAgentProfileDiff } from "./profile-D3eXNBQV.js";
6
- import { _ as readRootStream, g as ROOT_STREAM_FILE, i as superviseRootProfile, r as supervise, v as readRootStreamReceipt } from "./supervise--njTtSL3.js";
6
+ import { _ as readRootStream, g as ROOT_STREAM_FILE, i as superviseRootProfile, r as supervise, v as readRootStreamReceipt } from "./supervise-Dej5aSDa.js";
7
7
  import { h as supervisorRunDir } from "./run-layout-vwd4SwX_.js";
8
8
  import { canonicalCandidateDigest, canonicalCandidateJson, sha256Bytes } from "@tangle-network/agent-interface";
9
9
  import { createHash } from "node:crypto";
@@ -551,7 +551,7 @@ function projectNodeActivity(nodes, record) {
551
551
  const infra = booleanField(payload, "infra");
552
552
  if (infra !== void 0) node.infra = infra;
553
553
  const retained = stringField(payload, "retainedExecution");
554
- if (retained === "pending" || retained === "released") node.retainedExecution = retained;
554
+ if (retained === "pending" || retained === "released" || retained === "release-unconfirmed") node.retainedExecution = retained;
555
555
  const cause = stringField(payload, "retainedPendingCause");
556
556
  if (cause === "unobservable" || cause === "provider-contract" || cause === "request-rejected" || cause === "transport" || cause === "nested-recovery") node.retainedPendingCause = cause;
557
557
  const releasedAt = numberField(payload, "releasedAt");
@@ -1279,11 +1279,9 @@ function assertPursuitVersions(versions) {
1279
1279
  };
1280
1280
  if (typeof versions !== "object" || versions === null) fail("must be an object");
1281
1281
  const { judge, next, stop, run } = versions;
1282
- if (typeof judge === "string") {
1283
- if (judge.trim().length === 0) fail("judge must name a registry entry");
1284
- } else if (typeof judge !== "object" || judge === null || typeof judge.judge !== "function") fail("judge must be a VersionJudge or a registry name");
1282
+ if (typeof judge !== "object" || judge === null || typeof judge.judge !== "function") fail("judge must be a VersionJudge, such as declaredCheckJudge(check)");
1285
1283
  else if (!isSha256(judge.digest)) fail("judge.digest must be a sha256 digest (sha256:<64 hex>)");
1286
- if (typeof next === "string" ? next.trim().length === 0 : typeof next !== "function") fail("next must be a function or a registry name");
1284
+ if (next !== "review-of-best" && typeof next !== "function") fail("next must be a function or 'review-of-best'");
1287
1285
  if (run !== void 0 && typeof run !== "function") fail("run must be a function when set");
1288
1286
  const { usd } = versions;
1289
1287
  if (usd !== void 0 && typeof usd !== "function") fail("usd must be a function when set");
@@ -1312,10 +1310,9 @@ async function runPursuitVersions(profile, task, opts, runOne) {
1312
1310
  "rootHandle",
1313
1311
  "steerDir"
1314
1312
  ]) if (rest[key] !== void 0) throw new ValidationError(`supervisePursuit versions: ${key} names one run, and a version chain has one per version; omit it`);
1315
- const registry = rest.registry;
1316
- const judge = resolveNamed("judge", "versionJudges", versions.judge, registry?.versionJudges);
1317
- if (!isSha256(judge.digest)) throw new ValidationError("supervisePursuit versions: judge.digest must be a sha256 digest");
1318
- const next = resolveNamed("next", "nextVersions", versions.next, registry?.nextVersions);
1313
+ const judge = versions.judge;
1314
+ if (versions.next === "review-of-best" && rest.continuation?.profile.review === void 0) throw new ValidationError("supervisePursuit versions: next 'review-of-best' needs continuation.profile.review, the words the next version reads about its review");
1315
+ const next = versions.next === "review-of-best" ? reviewOfBest(rest.runId ?? "supervise", rest.continuation?.profile.review ?? "") : versions.next;
1319
1316
  const stop = versions.stop;
1320
1317
  const minImprovement = stop.minImprovement ?? 0;
1321
1318
  const now = rest.now ?? Date.now;
@@ -1525,8 +1522,16 @@ async function runPursuitVersions(profile, task, opts, runOne) {
1525
1522
  change: spec.change,
1526
1523
  acceptUncertain: true
1527
1524
  };
1525
+ const bar = base.continuation !== void 0 && parent.verdict.check !== void 0 ? { continuation: {
1526
+ ...base.continuation,
1527
+ best: {
1528
+ label: `v${parent.version}`,
1529
+ verdict: parent.verdict.check
1530
+ }
1531
+ } } : {};
1528
1532
  const options = {
1529
1533
  ...base,
1534
+ ...bar,
1530
1535
  runId: spec.runId,
1531
1536
  runDir: spec.runDir,
1532
1537
  fork,
@@ -1636,12 +1641,81 @@ function canonicalStop(stop) {
1636
1641
  ...stop.minImprovement === void 0 ? {} : { minImprovement: stop.minImprovement }
1637
1642
  };
1638
1643
  }
1639
- function resolveNamed(option, table, value, registry) {
1640
- if (typeof value !== "string") return value;
1641
- if (registry === void 0) throw new ConfigError(`supervisePursuit versions: ${option} = ${JSON.stringify(value)} names a registry entry, but no registry.${table} was provided`);
1642
- const entry = registry.resolve(value);
1643
- if (entry === void 0) throw new ConfigError(`supervisePursuit versions: ${option} = ${JSON.stringify(value)} is not in registry.${table}`);
1644
- return entry;
1644
+ /** Where `'review-of-best'` mounts a review: `inputs/review/version-<n>.md`. One review lives in
1645
+ * a profile at a time. */
1646
+ const REVIEW_DIR = "inputs/review/";
1647
+ /**
1648
+ * `'review-of-best'`: fork from the best version with its check's verdict mounted under
1649
+ * {@link REVIEW_DIR} and the profile's review words as one instruction. The previous review's
1650
+ * mount and instruction are removed, so a profile carries one review. This is what the Lab's
1651
+ * `continue-best` changes did in Lab code, now written once from the check's own verdict.
1652
+ */
1653
+ function reviewOfBest(runId, words) {
1654
+ return ({ best, versions }) => {
1655
+ const n = versions.length + 1;
1656
+ const verdict = best.verdict.check;
1657
+ const path = `${REVIEW_DIR}version-${best.version}.md`;
1658
+ const instruction = words.replaceAll("{version}", String(best.version)).replaceAll("{path}", path).replaceAll("{score}", best.verdict.score === null ? "none" : String(best.verdict.score)).trim();
1659
+ const page = reviewPage(best.version, best.verdict.score, verdict);
1660
+ const earlierInstructions = best.change?.set?.prompt?.instructions ?? [];
1661
+ const earlierMounts = (best.profile.resources?.files ?? []).map((file) => file.path).filter((mounted) => mounted.startsWith("inputs/review/") && mounted !== path);
1662
+ return {
1663
+ kind: "agent-profile-diff",
1664
+ id: `${runId}-v${n}-review-of-v${best.version}`,
1665
+ title: `Version ${n}: review of version ${best.version}`,
1666
+ source: {
1667
+ kind: "optimizer",
1668
+ notes: [`review-of-best: version ${best.version}`, `judge ${best.verdict.judgeDigest}`]
1669
+ },
1670
+ set: {
1671
+ prompt: { instructions: [instruction] },
1672
+ resources: { files: [{
1673
+ path,
1674
+ resource: {
1675
+ kind: "inline",
1676
+ name: path,
1677
+ content: page
1678
+ }
1679
+ }] }
1680
+ },
1681
+ ...earlierInstructions.length > 0 || earlierMounts.length > 0 ? { remove: {
1682
+ ...earlierInstructions.length > 0 ? { prompt: { instructions: [...earlierInstructions] } } : {},
1683
+ ...earlierMounts.length > 0 ? { resources: { files: earlierMounts } } : {}
1684
+ } } : {}
1685
+ };
1686
+ };
1687
+ }
1688
+ /** The review page: facts only, in the check's own lines. */
1689
+ function reviewPage(version, score, verdict) {
1690
+ if (verdict === void 0) return [
1691
+ `# Version ${version}`,
1692
+ "",
1693
+ `Score: ${score ?? "none"}. The judge reported no per-item verdict.`,
1694
+ ""
1695
+ ].join("\n");
1696
+ const failing = failedItems(verdict);
1697
+ return [
1698
+ `# Version ${version}`,
1699
+ "",
1700
+ `Score: ${score ?? "none"}.${verdict.threshold === void 0 ? "" : ` The check passes at ${verdict.threshold}.`}`,
1701
+ "",
1702
+ "## Items",
1703
+ "",
1704
+ ...Object.entries(verdict.items ?? {}).map(([item, value]) => `- ${item}: ${value >= 1 ? "passes" : `fails (${value})`}`),
1705
+ "",
1706
+ ...failing.length === 0 ? [] : [
1707
+ "## Failures",
1708
+ "",
1709
+ ...verdict.failures ?? [],
1710
+ ""
1711
+ ],
1712
+ ...verdict.review === void 0 ? [] : [
1713
+ "## The check's review",
1714
+ "",
1715
+ verdict.review,
1716
+ ""
1717
+ ]
1718
+ ].join("\n");
1645
1719
  }
1646
1720
  async function readLedger(path) {
1647
1721
  let text;
@@ -1872,6 +1946,6 @@ function compareText(left, right) {
1872
1946
  return left < right ? -1 : left > right ? 1 : 0;
1873
1947
  }
1874
1948
  //#endregion
1875
- export { FAILURE_RECORD_FILE, FORK_PARENT_UNCERTAIN_NODES_KEY, FileObserverJournal, PURSUIT_VERSIONS_FILE, ROOT_STREAM_FILE, RUN_DIRECTORY_LOCK_FILE, RUN_FORK_CORRELATION_KEYS, RunDirectoryLockedError, SETTLE_RECORD_FILE, SettledRunDirectoryError, SupervisePursuitError, acquireRunDirectoryLock, assertPursuitVersions, createFileObserverHooks, deriveExecutionId, discoverDurableSupervisionRun, handleChatTurn, observerRecordDigest, projectPursuit, pursuitVersionRun, readFailureRecord, readRootStream, readRootStreamReceipt, readRunDirectoryLock, readSettleRecord, runDirectoryHolderIsLive, settleRecordJson, supervisePursuit, verifyObserverRecords };
1949
+ export { FAILURE_RECORD_FILE, FORK_PARENT_UNCERTAIN_NODES_KEY, FileObserverJournal, PURSUIT_VERSIONS_FILE, REVIEW_DIR, ROOT_STREAM_FILE, RUN_DIRECTORY_LOCK_FILE, RUN_FORK_CORRELATION_KEYS, RunDirectoryLockedError, SETTLE_RECORD_FILE, SettledRunDirectoryError, SupervisePursuitError, acquireRunDirectoryLock, assertPursuitVersions, createFileObserverHooks, deriveExecutionId, discoverDurableSupervisionRun, handleChatTurn, observerRecordDigest, projectPursuit, pursuitVersionRun, readFailureRecord, readRootStream, readRootStreamReceipt, readRunDirectoryLock, readSettleRecord, runDirectoryHolderIsLive, settleRecordJson, supervisePursuit, verifyObserverRecords };
1876
1950
 
1877
1951
  //# sourceMappingURL=durable.js.map