@tangle-network/agent-runtime 10.0.3 → 10.0.4

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 (86) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/{activation-kitznAHo.js → activation-38MolXIP.js} +2 -2
  3. package/dist/{activation-kitznAHo.js.map → activation-38MolXIP.js.map} +1 -1
  4. package/dist/{activation-DbSxPRUW.d.ts → activation-Ckx0yHjT.d.ts} +2 -2
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{continuation-BDeKJgV3.js → continuation-CL4B1Y4M.js} +3 -3
  8. package/dist/{continuation-BDeKJgV3.js.map → continuation-CL4B1Y4M.js.map} +1 -1
  9. package/dist/{delegate-D8yX_2K7.js → delegate-dhNeiaH_.js} +2 -2
  10. package/dist/{delegate-D8yX_2K7.js.map → delegate-dhNeiaH_.js.map} +1 -1
  11. package/dist/{driver-control-acknowledgers-BTSr3Znq.js → driver-control-acknowledgers-C6GaGBf_.js} +98 -57
  12. package/dist/{driver-control-acknowledgers-BTSr3Znq.js.map → driver-control-acknowledgers-C6GaGBf_.js.map} +1 -1
  13. package/dist/durable-file-DJ3JsA4B.js +1 -0
  14. package/dist/{durable-file-DUcTDWJD.js → durable-file-lXnojyij.js} +15 -4
  15. package/dist/{durable-file-DUcTDWJD.js.map → durable-file-lXnojyij.js.map} +1 -1
  16. package/dist/durable-writer-thread.js +5 -5
  17. package/dist/durable.d.ts +1 -1
  18. package/dist/durable.js +13 -13
  19. package/dist/{graph-4ep9laIH.js → graph-CwLg3LGC.js} +7 -7
  20. package/dist/{graph-4ep9laIH.js.map → graph-CwLg3LGC.js.map} +1 -1
  21. package/dist/{graph-registry-B-EGvJ-3.js → graph-registry-Bs6mGKou.js} +1 -1
  22. package/dist/{graph-registry-BxEBeihr.js → graph-registry-DtGd03zk.js} +4 -4
  23. package/dist/{graph-registry-BxEBeihr.js.map → graph-registry-DtGd03zk.js.map} +1 -1
  24. package/dist/{improve-CJf87tBs.js → improve-C_LKfgH9.js} +7 -7
  25. package/dist/{improve-CJf87tBs.js.map → improve-C_LKfgH9.js.map} +1 -1
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +9 -9
  28. package/dist/intelligence.d.ts +2 -2
  29. package/dist/intelligence.js +4 -4
  30. package/dist/{jsonl-file-CVAWegN-.js → jsonl-file-DyzefaZ6.js} +3 -3
  31. package/dist/{jsonl-file-CVAWegN-.js.map → jsonl-file-DyzefaZ6.js.map} +1 -1
  32. package/dist/kernel.d.ts +2 -2
  33. package/dist/kernel.js +18 -18
  34. package/dist/{loop-runner-Ckj-Zz3-.js → loop-runner-BS3ru-yj.js} +2 -2
  35. package/dist/{loop-runner-Ckj-Zz3-.js.map → loop-runner-BS3ru-yj.js.map} +1 -1
  36. package/dist/{loop-runner-CayC8e9K.d.ts → loop-runner-LWqWf8FD.d.ts} +2 -2
  37. package/dist/loop-runner-bin.d.ts +1 -1
  38. package/dist/loop-runner-bin.js +1 -1
  39. package/dist/mcp/bin.js +3 -3
  40. package/dist/mcp/index.d.ts +1 -1
  41. package/dist/mcp/index.js +5 -5
  42. package/dist/profiles.d.ts +1 -1
  43. package/dist/{provision-supervisor-NjROV7AQ.js → provision-supervisor-D8N0l2DM.js} +6 -6
  44. package/dist/{provision-supervisor-NjROV7AQ.js.map → provision-supervisor-D8N0l2DM.js.map} +1 -1
  45. package/dist/{result-blob-store-BR-BVZrg.js → result-blob-store-DfTcyQ05.js} +3 -3
  46. package/dist/{result-blob-store-BR-BVZrg.js.map → result-blob-store-DfTcyQ05.js.map} +1 -1
  47. package/dist/{run-cancellation-C9V1lYhq.js → run-cancellation-D3qc9wAD.js} +3 -3
  48. package/dist/{run-cancellation-C9V1lYhq.js.map → run-cancellation-D3qc9wAD.js.map} +1 -1
  49. package/dist/{run-lock-Y3u9kwM0.js → run-lock-D1xnb9ve.js} +3 -3
  50. package/dist/{run-lock-Y3u9kwM0.js.map → run-lock-D1xnb9ve.js.map} +1 -1
  51. package/dist/{run-reopen-CHYTHk7x.js → run-reopen-DVM5AEKV.js} +6 -6
  52. package/dist/{run-reopen-CHYTHk7x.js.map → run-reopen-DVM5AEKV.js.map} +1 -1
  53. package/dist/{run-state-DgKo8_tO.js → run-state-tgQ-S9Ln.js} +7 -7
  54. package/dist/{run-state-DgKo8_tO.js.map → run-state-tgQ-S9Ln.js.map} +1 -1
  55. package/dist/{runtime-CdthBQUs.js → runtime-BTECV05R.js} +20 -20
  56. package/dist/{runtime-CdthBQUs.js.map → runtime-BTECV05R.js.map} +1 -1
  57. package/dist/{search-executor-Bb0WuI_Z.js → search-executor-Uco2_KTB.js} +3 -3
  58. package/dist/{search-executor-Bb0WuI_Z.js.map → search-executor-Uco2_KTB.js.map} +1 -1
  59. package/dist/{server-BCtyL7jH.js → server-BMp24-xn.js} +3 -3
  60. package/dist/{server-BCtyL7jH.js.map → server-BMp24-xn.js.map} +1 -1
  61. package/dist/{settle-record-Beh-sXBW.js → settle-record-au3w7bQG.js} +4 -4
  62. package/dist/{settle-record-Beh-sXBW.js.map → settle-record-au3w7bQG.js.map} +1 -1
  63. package/dist/{structural-rollout-BRfSDPkv.js → structural-rollout-D8wufVJI.js} +3 -3
  64. package/dist/{structural-rollout-BRfSDPkv.js.map → structural-rollout-D8wufVJI.js.map} +1 -1
  65. package/dist/{supervise-DTUYxnoJ.js → supervise-DtVdvZpr.js} +9 -9
  66. package/dist/{supervise-DTUYxnoJ.js.map → supervise-DtVdvZpr.js.map} +1 -1
  67. package/dist/{supervise-identity-eMF-h1uP.js → supervise-identity-S5XwgaF3.js} +4 -4
  68. package/dist/{supervise-identity-eMF-h1uP.js.map → supervise-identity-S5XwgaF3.js.map} +1 -1
  69. package/dist/{supervision-discovery-CAUsSDno.js → supervision-discovery-Cqu4NxPV.js} +3 -3
  70. package/dist/{supervision-discovery-CAUsSDno.js.map → supervision-discovery-Cqu4NxPV.js.map} +1 -1
  71. package/dist/{supervisor-BtRRFbgF.js → supervisor-CHgCAMjm.js} +7 -7
  72. package/dist/{supervisor-BtRRFbgF.js.map → supervisor-CHgCAMjm.js.map} +1 -1
  73. package/dist/{supervisor-accounting-Cuehs4te.js → supervisor-accounting-CZ7i4cd5.js} +117 -46
  74. package/dist/{supervisor-accounting-Cuehs4te.js.map → supervisor-accounting-CZ7i4cd5.js.map} +1 -1
  75. package/dist/{supervisor-root-contract-CmFKzPps.js → supervisor-root-contract-D70KTGXF.js} +2 -2
  76. package/dist/{supervisor-root-contract-CmFKzPps.js.map → supervisor-root-contract-D70KTGXF.js.map} +1 -1
  77. package/dist/testing.d.ts +1 -1
  78. package/dist/testing.js +11 -11
  79. package/dist/{top-web-D-wuEVdM.js → top-web-COrMqTRC.js} +7 -7
  80. package/dist/{top-web-D-wuEVdM.js.map → top-web-COrMqTRC.js.map} +1 -1
  81. package/dist/tui/bin.js +3 -3
  82. package/dist/tui/index.d.ts +1 -1
  83. package/dist/tui/index.js +2 -2
  84. package/dist/{types-PBoTtcbX.d.ts → types-9xsn2GGY.d.ts} +9 -2
  85. package/package.json +1 -1
  86. package/dist/durable-file-XqOyDf7q.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { M as contentAddress } from "./failure-cause-DoCCGLDH.js";
2
2
  import { f as RuntimeRunStateError } from "./errors-DG8yufqX.js";
3
- import { $r as unknownMaterializationReceipt, Ir as knownExecutionBindingReceipt, Lr as knownMaterializationReceipt, Q as reenteredWorkers, Qr as unknownExecutionBindingReceipt } from "./supervisor-accounting-Cuehs4te.js";
3
+ import { $ as reenteredWorkers, $r as unknownExecutionBindingReceipt, Lr as knownExecutionBindingReceipt, Rr as knownMaterializationReceipt, ei as unknownMaterializationReceipt } from "./supervisor-accounting-CZ7i4cd5.js";
4
4
  import { sha256DigestSchema } from "@tangle-network/agent-interface";
5
5
  // src/runtime/supervise/supervisor-root-contract.ts
6
6
  /** A resumed process may continue only the exact root contract first recorded for this run id. Its
@@ -162,4 +162,4 @@ function rootStartedAtMs(root) {
162
162
  }
163
163
  export { recordRootReentered as a, rootMaterializationReceipt as c, changesRootProfile as i, rootStartedAtMs as l, assertResumeLimits as n, recordRootSegment as o, assertRootIdentity as r, rootExecutionBindingReceipt as s, assertResumeContract as t };
164
164
 
165
- //# sourceMappingURL=supervisor-root-contract-CmFKzPps.js.map
165
+ //# sourceMappingURL=supervisor-root-contract-D70KTGXF.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-root-contract-CmFKzPps.js","names":[],"sources":["../src/runtime/supervise/supervisor-root-contract.ts"],"sourcesContent":["import { sha256DigestSchema } from '@tangle-network/agent-interface'\nimport { contentAddress } from '../../durable/content-address'\nimport { RuntimeRunStateError } from '../../errors'\nimport {\n knownExecutionBindingReceipt,\n knownMaterializationReceipt,\n unknownExecutionBindingReceipt,\n unknownMaterializationReceipt,\n} from './materialization'\nimport type { ScopeResumeState } from './recover-executors'\nimport { reenteredWorkers } from './scope'\nimport type {\n ExecutionBindingReceipt,\n ProfileMaterializationReceipt,\n RootSegmentEntry,\n SpawnEvent,\n SupervisorOpts,\n} from './types'\n\nexport type SpawnedEvent = Extract<SpawnEvent, { kind: 'spawned' }>\n\n/** A resumed process may continue only the exact root contract first recorded for this run id. Its\n * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */\nexport function assertResumeContract(events: SpawnEvent[], opts: SupervisorOpts): SpawnedEvent {\n const recorded = assertResumeLimits(events, opts)\n if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) {\n throw new RuntimeRunStateError(\n `supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`,\n )\n }\n const receipts = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'materialized' }> =>\n event.kind === 'materialized' && event.id === opts.runId,\n )\n const expectedReceipt = rootMaterializationReceipt(opts)\n if (expectedReceipt === undefined) {\n if (receipts.length > 1) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`,\n )\n }\n } else if (\n receipts.length !== 1 ||\n contentAddress(receipts[0]?.receipt) !== contentAddress(expectedReceipt)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume materialization mismatch for run '${opts.runId}'; backend, model, execution identity, and plan must match`,\n )\n }\n return recorded\n}\n\n/**\n * The limits half of the resume contract: one root identity event, the recorded budget and the\n * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);\n * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.\n */\nexport function assertResumeLimits(\n events: readonly SpawnEvent[],\n opts: Pick<SupervisorOpts, 'runId' | 'budget' | 'reservationPolicy'>,\n reopenBudget?: SupervisorOpts['budget'],\n): SpawnedEvent {\n const roots = events.filter(\n (event): event is SpawnedEvent => event.kind === 'spawned' && event.parent === undefined,\n )\n if (roots.length !== 1 || roots[0]?.id !== opts.runId) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`,\n )\n }\n const recorded = roots[0]!\n // A reopen may carry a new budget; the last one that did is the budget this run is held to.\n const reopenedBudget =\n reopenBudget ??\n events\n .filter(\n (event): event is Extract<SpawnEvent, { kind: 'reopened' }> =>\n event.kind === 'reopened' && event.id === opts.runId && event.budget !== undefined,\n )\n .at(-1)?.budget\n if (contentAddress(reopenedBudget ?? recorded.budget) !== contentAddress(opts.budget)) {\n throw new RuntimeRunStateError(\n `supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`,\n )\n }\n const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : undefined\n if (\n contentAddress(recorded.recursiveAdmission ?? null) !==\n contentAddress(expectedAdmission ?? null)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`,\n )\n }\n return recorded\n}\n\n/** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no\n * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */\nexport function rootMaterializationReceipt(\n opts: SupervisorOpts,\n): ProfileMaterializationReceipt | undefined {\n const declaration = opts.rootMaterialization\n if (declaration === undefined) {\n return unknownMaterializationReceipt({\n ...(opts.rootIdentity?.profileDigest === undefined\n ? {}\n : { authoredProfileDigest: opts.rootIdentity.profileDigest }),\n runtime: 'inline',\n reason: 'root-agent-did-not-report',\n })\n }\n if (declaration.declaration === 'deferred') return undefined\n if (opts.rootIdentity?.profileDigest === undefined) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`,\n )\n }\n try {\n return knownMaterializationReceipt({\n authoredProfileDigest: opts.rootIdentity.profileDigest,\n runtime: declaration.runtime,\n declaration: declaration.declaration,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root materialization evidence`,\n { cause: error },\n )\n }\n}\n\nexport function rootExecutionBindingReceipt(\n opts: SupervisorOpts,\n materialization: ProfileMaterializationReceipt,\n attemptId: string,\n): ExecutionBindingReceipt | undefined {\n const root = opts.rootMaterialization\n if (root?.declaration === 'deferred') return undefined\n if (root === undefined) {\n return unknownExecutionBindingReceipt(materialization, attemptId, 'root-agent-did-not-report')\n }\n try {\n return knownExecutionBindingReceipt(materialization, {\n attemptId,\n ...root.binding,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root execution binding`,\n { cause: error },\n )\n }\n}\n\n/** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */\nexport function changesRootProfile(entry: RootSegmentEntry): boolean {\n const { stack: _stack, ...current } = entry.current\n return contentAddress(current) !== contentAddress(entry.registered)\n}\n\n/**\n * Append one `root-segment` record when the root enters a segment that differs from the one it\n * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its\n * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends\n * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.\n */\nexport async function recordRootSegment(\n opts: SupervisorOpts,\n events: readonly SpawnEvent[],\n at: string,\n fresh: boolean,\n): Promise<void> {\n const entry = opts.rootSegment\n if (entry === undefined) return\n const records = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'root-segment' }> =>\n event.kind === 'root-segment' && event.id === opts.runId,\n )\n const last = records.at(-1)?.to ?? (fresh ? undefined : entry.registered)\n if (last !== undefined && contentAddress(last) === contentAddress(entry.current)) return\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-segment',\n id: opts.runId,\n ...(last === undefined ? {} : { from: last }),\n to: entry.current,\n reason: entry.reason,\n seq: records.length,\n at,\n })\n}\n\n/**\n * Append one `root-reentered` record: this process is supervising a run an earlier process drove.\n * After a host reboot the re-entered root ran two\n * barren continuations and the run settled `no-result-selected`, with three workers still open in\n * the journal and no record that a restart had happened.\n */\nexport async function recordRootReentered(\n opts: SupervisorOpts,\n resumeFrom: ScopeResumeState,\n at: string,\n): Promise<void> {\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-reentered',\n id: opts.runId,\n ...reenteredWorkers(resumeFrom, opts.runId),\n seq: resumeFrom.events.filter((event) => event.kind === 'root-reentered').length,\n at,\n })\n}\n\nfunction sameOptionalIdentity(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): boolean {\n if (recorded === undefined || requested === undefined) return recorded === requested\n return contentAddress(recorded) === contentAddress(requested)\n}\n\n/**\n * Name the identity fields that actually differ, with both values.\n *\n * The identity is compared as one content address, so a mismatch is a single boolean and the\n * message could only list every field that MIGHT have caused it. A caller then has to diff four\n * digests by hand to learn which one moved, and the common cause — a task file regenerated with\n * one character different — is indistinguishable from a genuinely different profile.\n *\n * Digests are truncated because the prefix identifies them and the full 64 characters push the\n * real content off the end of a terminal line.\n */\nfunction describeIdentityMismatch(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): string {\n if (recorded === undefined)\n return 'the recorded root carried no identity but this resume supplies one'\n if (requested === undefined)\n return 'the recorded root carried an identity but this resume supplies none'\n const short = (value: unknown): string => {\n if (value === undefined) return '(absent)'\n const text = typeof value === 'string' ? value : JSON.stringify(value)\n return text.length > 20 ? `${text.slice(0, 20)}…` : text\n }\n const differing = (['profileDigest', 'taskDigest', 'candidateDigest', 'correlation'] as const)\n .filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field]))\n .map(\n (field) =>\n `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`,\n )\n // A differing content address with no differing field means the shape itself changed (an extra\n // key, a different key order the address is sensitive to). Say that rather than nothing.\n if (differing.length === 0)\n return 'the identity objects differ in shape while every known field matches'\n return `${differing.join('; ')} — a different task or root profile is a new run; a resume may change the root's model, reasoning effort and harness as a new segment of this run (segment)`\n}\n\n/** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,\n * but once supplied it is trusted durable evidence and therefore must be complete and canonical;\n * resumed runs always require it so the prior root can be matched exactly. */\nexport function assertRootIdentity(opts: SupervisorOpts): void {\n const identity = opts.rootIdentity\n if (identity === undefined) {\n if (opts.resume !== true) return\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`,\n )\n }\n const unknownFields = Object.keys(identity).filter(\n (key) =>\n key !== 'profileDigest' &&\n key !== 'taskDigest' &&\n key !== 'candidateDigest' &&\n key !== 'correlation',\n )\n const correlation = identity.correlation\n const validCorrelation =\n correlation === undefined ||\n (typeof correlation === 'object' &&\n correlation !== null &&\n !Array.isArray(correlation) &&\n Object.entries(correlation).every(\n ([key, value]) => key.length > 0 && typeof value === 'string' && value.length > 0,\n ))\n if (\n unknownFields.length > 0 ||\n !sha256DigestSchema.safeParse(identity.profileDigest).success ||\n !sha256DigestSchema.safeParse(identity.taskDigest).success ||\n (identity.candidateDigest !== undefined &&\n !sha256DigestSchema.safeParse(identity.candidateDigest).success) ||\n !validCorrelation\n ) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' requires an exact rootIdentity with valid profileDigest, taskDigest, candidateDigest, and correlation`,\n )\n }\n}\n\n/** The instant the run's root was journaled — the anchor for both the absolute deadline and the\n * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this\n * process's. */\nexport function rootStartedAtMs(root: SpawnedEvent): number {\n const startedAt = Date.parse(root.at)\n if (!Number.isFinite(startedAt)) {\n throw new RuntimeRunStateError(\n `supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`,\n )\n }\n return startedAt\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,qBAAqB,QAAsB,MAAoC;CAC7F,MAAM,WAAW,mBAAmB,QAAQ,IAAI;CAChD,IAAI,CAAC,qBAAqB,SAAS,UAAU,KAAK,YAAY,GAC5D,MAAM,IAAI,qBACR,iDAAiD,KAAK,MAAM,KAAK,yBAAyB,SAAS,UAAU,KAAK,YAAY,GAChI;CAEF,MAAM,WAAW,OAAO,QACrB,UACC,MAAM,SAAS,kBAAkB,MAAM,OAAO,KAAK,KACvD;CACA,MAAM,kBAAkB,2BAA2B,IAAI;CACvD,IAAI,oBAAoB,KAAA,GAClB;MAAA,SAAS,SAAS,GACpB,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,mDACzC;CAAA,OAEG,IACL,SAAS,WAAW,KACpB,eAAe,SAAS,EAAE,EAAE,OAAO,MAAM,eAAe,eAAe,GAEvE,MAAM,IAAI,qBACR,wDAAwD,KAAK,MAAM,2DACrE;CAEF,OAAO;AACT;;;;;;AAOA,SAAgB,mBACd,QACA,MACA,cACc;CACd,MAAM,QAAQ,OAAO,QAClB,UAAiC,MAAM,SAAS,aAAa,MAAM,WAAW,KAAA,CACjF;CACA,IAAI,MAAM,WAAW,KAAK,MAAM,EAAE,EAAE,OAAO,KAAK,OAC9C,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,wDAAwD,MAAM,QACvG;CAEF,MAAM,WAAW,MAAM;CAEvB,MAAM,iBACJ,gBACA,OACG,QACE,UACC,MAAM,SAAS,cAAc,MAAM,OAAO,KAAK,SAAS,MAAM,WAAW,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D,CAAC,kBAED,MAAM,IAAI,qBACR,oBAAoB,KAAK,MAAM,wGACjC;AAEJ;;;;AAKA,SAAgB,gBAAgB,MAA4B;CAC1D,MAAM,YAAY,KAAK,MAAM,KAAK,EAAE;CACpC,IAAI,CAAC,OAAO,SAAS,SAAS,GAC5B,MAAM,IAAI,qBACR,+BAA+B,KAAK,GAAG,8BAA8B,KAAK,GAAG,EAC/E;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"supervisor-root-contract-D70KTGXF.js","names":[],"sources":["../src/runtime/supervise/supervisor-root-contract.ts"],"sourcesContent":["import { sha256DigestSchema } from '@tangle-network/agent-interface'\nimport { contentAddress } from '../../durable/content-address'\nimport { RuntimeRunStateError } from '../../errors'\nimport {\n knownExecutionBindingReceipt,\n knownMaterializationReceipt,\n unknownExecutionBindingReceipt,\n unknownMaterializationReceipt,\n} from './materialization'\nimport type { ScopeResumeState } from './recover-executors'\nimport { reenteredWorkers } from './scope'\nimport type {\n ExecutionBindingReceipt,\n ProfileMaterializationReceipt,\n RootSegmentEntry,\n SpawnEvent,\n SupervisorOpts,\n} from './types'\n\nexport type SpawnedEvent = Extract<SpawnEvent, { kind: 'spawned' }>\n\n/** A resumed process may continue only the exact root contract first recorded for this run id. Its\n * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */\nexport function assertResumeContract(events: SpawnEvent[], opts: SupervisorOpts): SpawnedEvent {\n const recorded = assertResumeLimits(events, opts)\n if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) {\n throw new RuntimeRunStateError(\n `supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`,\n )\n }\n const receipts = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'materialized' }> =>\n event.kind === 'materialized' && event.id === opts.runId,\n )\n const expectedReceipt = rootMaterializationReceipt(opts)\n if (expectedReceipt === undefined) {\n if (receipts.length > 1) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`,\n )\n }\n } else if (\n receipts.length !== 1 ||\n contentAddress(receipts[0]?.receipt) !== contentAddress(expectedReceipt)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume materialization mismatch for run '${opts.runId}'; backend, model, execution identity, and plan must match`,\n )\n }\n return recorded\n}\n\n/**\n * The limits half of the resume contract: one root identity event, the recorded budget and the\n * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);\n * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.\n */\nexport function assertResumeLimits(\n events: readonly SpawnEvent[],\n opts: Pick<SupervisorOpts, 'runId' | 'budget' | 'reservationPolicy'>,\n reopenBudget?: SupervisorOpts['budget'],\n): SpawnedEvent {\n const roots = events.filter(\n (event): event is SpawnedEvent => event.kind === 'spawned' && event.parent === undefined,\n )\n if (roots.length !== 1 || roots[0]?.id !== opts.runId) {\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`,\n )\n }\n const recorded = roots[0]!\n // A reopen may carry a new budget; the last one that did is the budget this run is held to.\n const reopenedBudget =\n reopenBudget ??\n events\n .filter(\n (event): event is Extract<SpawnEvent, { kind: 'reopened' }> =>\n event.kind === 'reopened' && event.id === opts.runId && event.budget !== undefined,\n )\n .at(-1)?.budget\n if (contentAddress(reopenedBudget ?? recorded.budget) !== contentAddress(opts.budget)) {\n throw new RuntimeRunStateError(\n `supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`,\n )\n }\n const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : undefined\n if (\n contentAddress(recorded.recursiveAdmission ?? null) !==\n contentAddress(expectedAdmission ?? null)\n ) {\n throw new RuntimeRunStateError(\n `supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`,\n )\n }\n return recorded\n}\n\n/** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no\n * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */\nexport function rootMaterializationReceipt(\n opts: SupervisorOpts,\n): ProfileMaterializationReceipt | undefined {\n const declaration = opts.rootMaterialization\n if (declaration === undefined) {\n return unknownMaterializationReceipt({\n ...(opts.rootIdentity?.profileDigest === undefined\n ? {}\n : { authoredProfileDigest: opts.rootIdentity.profileDigest }),\n runtime: 'inline',\n reason: 'root-agent-did-not-report',\n })\n }\n if (declaration.declaration === 'deferred') return undefined\n if (opts.rootIdentity?.profileDigest === undefined) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`,\n )\n }\n try {\n return knownMaterializationReceipt({\n authoredProfileDigest: opts.rootIdentity.profileDigest,\n runtime: declaration.runtime,\n declaration: declaration.declaration,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root materialization evidence`,\n { cause: error },\n )\n }\n}\n\nexport function rootExecutionBindingReceipt(\n opts: SupervisorOpts,\n materialization: ProfileMaterializationReceipt,\n attemptId: string,\n): ExecutionBindingReceipt | undefined {\n const root = opts.rootMaterialization\n if (root?.declaration === 'deferred') return undefined\n if (root === undefined) {\n return unknownExecutionBindingReceipt(materialization, attemptId, 'root-agent-did-not-report')\n }\n try {\n return knownExecutionBindingReceipt(materialization, {\n attemptId,\n ...root.binding,\n })\n } catch (error) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' has invalid root execution binding`,\n { cause: error },\n )\n }\n}\n\n/** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */\nexport function changesRootProfile(entry: RootSegmentEntry): boolean {\n const { stack: _stack, ...current } = entry.current\n return contentAddress(current) !== contentAddress(entry.registered)\n}\n\n/**\n * Append one `root-segment` record when the root enters a segment that differs from the one it\n * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its\n * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends\n * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.\n */\nexport async function recordRootSegment(\n opts: SupervisorOpts,\n events: readonly SpawnEvent[],\n at: string,\n fresh: boolean,\n): Promise<void> {\n const entry = opts.rootSegment\n if (entry === undefined) return\n const records = events.filter(\n (event): event is Extract<SpawnEvent, { kind: 'root-segment' }> =>\n event.kind === 'root-segment' && event.id === opts.runId,\n )\n const last = records.at(-1)?.to ?? (fresh ? undefined : entry.registered)\n if (last !== undefined && contentAddress(last) === contentAddress(entry.current)) return\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-segment',\n id: opts.runId,\n ...(last === undefined ? {} : { from: last }),\n to: entry.current,\n reason: entry.reason,\n seq: records.length,\n at,\n })\n}\n\n/**\n * Append one `root-reentered` record: this process is supervising a run an earlier process drove.\n * After a host reboot the re-entered root ran two\n * barren continuations and the run settled `no-result-selected`, with three workers still open in\n * the journal and no record that a restart had happened.\n */\nexport async function recordRootReentered(\n opts: SupervisorOpts,\n resumeFrom: ScopeResumeState,\n at: string,\n): Promise<void> {\n await opts.journal.appendEvent(opts.runId, {\n kind: 'root-reentered',\n id: opts.runId,\n ...reenteredWorkers(resumeFrom, opts.runId),\n seq: resumeFrom.events.filter((event) => event.kind === 'root-reentered').length,\n at,\n })\n}\n\nfunction sameOptionalIdentity(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): boolean {\n if (recorded === undefined || requested === undefined) return recorded === requested\n return contentAddress(recorded) === contentAddress(requested)\n}\n\n/**\n * Name the identity fields that actually differ, with both values.\n *\n * The identity is compared as one content address, so a mismatch is a single boolean and the\n * message could only list every field that MIGHT have caused it. A caller then has to diff four\n * digests by hand to learn which one moved, and the common cause — a task file regenerated with\n * one character different — is indistinguishable from a genuinely different profile.\n *\n * Digests are truncated because the prefix identifies them and the full 64 characters push the\n * real content off the end of a terminal line.\n */\nfunction describeIdentityMismatch(\n recorded: SpawnedEvent['identity'],\n requested: SpawnedEvent['identity'],\n): string {\n if (recorded === undefined)\n return 'the recorded root carried no identity but this resume supplies one'\n if (requested === undefined)\n return 'the recorded root carried an identity but this resume supplies none'\n const short = (value: unknown): string => {\n if (value === undefined) return '(absent)'\n const text = typeof value === 'string' ? value : JSON.stringify(value)\n return text.length > 20 ? `${text.slice(0, 20)}…` : text\n }\n const differing = (['profileDigest', 'taskDigest', 'candidateDigest', 'correlation'] as const)\n .filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field]))\n .map(\n (field) =>\n `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`,\n )\n // A differing content address with no differing field means the shape itself changed (an extra\n // key, a different key order the address is sensitive to). Say that rather than nothing.\n if (differing.length === 0)\n return 'the identity objects differ in shape while every known field matches'\n return `${differing.join('; ')} — a different task or root profile is a new run; a resume may change the root's model, reasoning effort and harness as a new segment of this run (segment)`\n}\n\n/** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,\n * but once supplied it is trusted durable evidence and therefore must be complete and canonical;\n * resumed runs always require it so the prior root can be matched exactly. */\nexport function assertRootIdentity(opts: SupervisorOpts): void {\n const identity = opts.rootIdentity\n if (identity === undefined) {\n if (opts.resume !== true) return\n throw new RuntimeRunStateError(\n `supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`,\n )\n }\n const unknownFields = Object.keys(identity).filter(\n (key) =>\n key !== 'profileDigest' &&\n key !== 'taskDigest' &&\n key !== 'candidateDigest' &&\n key !== 'correlation',\n )\n const correlation = identity.correlation\n const validCorrelation =\n correlation === undefined ||\n (typeof correlation === 'object' &&\n correlation !== null &&\n !Array.isArray(correlation) &&\n Object.entries(correlation).every(\n ([key, value]) => key.length > 0 && typeof value === 'string' && value.length > 0,\n ))\n if (\n unknownFields.length > 0 ||\n !sha256DigestSchema.safeParse(identity.profileDigest).success ||\n !sha256DigestSchema.safeParse(identity.taskDigest).success ||\n (identity.candidateDigest !== undefined &&\n !sha256DigestSchema.safeParse(identity.candidateDigest).success) ||\n !validCorrelation\n ) {\n throw new RuntimeRunStateError(\n `supervisor: run '${opts.runId}' requires an exact rootIdentity with valid profileDigest, taskDigest, candidateDigest, and correlation`,\n )\n }\n}\n\n/** The instant the run's root was journaled — the anchor for both the absolute deadline and the\n * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this\n * process's. */\nexport function rootStartedAtMs(root: SpawnedEvent): number {\n const startedAt = Date.parse(root.at)\n if (!Number.isFinite(startedAt)) {\n throw new RuntimeRunStateError(\n `supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`,\n )\n }\n return startedAt\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,qBAAqB,QAAsB,MAAoC;CAC7F,MAAM,WAAW,mBAAmB,QAAQ,IAAI;CAChD,IAAI,CAAC,qBAAqB,SAAS,UAAU,KAAK,YAAY,GAC5D,MAAM,IAAI,qBACR,iDAAiD,KAAK,MAAM,KAAK,yBAAyB,SAAS,UAAU,KAAK,YAAY,GAChI;CAEF,MAAM,WAAW,OAAO,QACrB,UACC,MAAM,SAAS,kBAAkB,MAAM,OAAO,KAAK,KACvD;CACA,MAAM,kBAAkB,2BAA2B,IAAI;CACvD,IAAI,oBAAoB,KAAA,GAClB;MAAA,SAAS,SAAS,GACpB,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,mDACzC;CAAA,OAEG,IACL,SAAS,WAAW,KACpB,eAAe,SAAS,EAAE,EAAE,OAAO,MAAM,eAAe,eAAe,GAEvE,MAAM,IAAI,qBACR,wDAAwD,KAAK,MAAM,2DACrE;CAEF,OAAO;AACT;;;;;;AAOA,SAAgB,mBACd,QACA,MACA,cACc;CACd,MAAM,QAAQ,OAAO,QAClB,UAAiC,MAAM,SAAS,aAAa,MAAM,WAAW,KAAA,CACjF;CACA,IAAI,MAAM,WAAW,KAAK,MAAM,EAAE,EAAE,OAAO,KAAK,OAC9C,MAAM,IAAI,qBACR,4BAA4B,KAAK,MAAM,wDAAwD,MAAM,QACvG;CAEF,MAAM,WAAW,MAAM;CAEvB,MAAM,iBACJ,gBACA,OACG,QACE,UACC,MAAM,SAAS,cAAc,MAAM,OAAO,KAAK,SAAS,MAA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AC,WAC1D,CAAC,kBAED,MAAM,IAAI,qBACR,oBAAoB,KAAK,MAAM,wGACjC;AAEJ;;;;AAKA,SAAgB,gBAAgB,MAA4B;CAC1D,MAAM,YAAY,KAAK,MAAM,KAAK,EAAE;CACpC,IAAI,CAAC,OAAO,SAAS,SAAS,GAC5B,MAAM,IAAI,qBACR,+BAA+B,KAAK,GAAG,8BAA8B,KAAK,GAAG,EAC/E;CAEF,OAAO;AACT"}
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $m as CoordinationDeliveryEvidence, Am as StopRule, Bf as runGraphWithTestBrain, Cm as ManagerWakePolicy, E as Budget, Eb as EscalateQuestion, Hm as SupervisorFinalizer, Ix as AnalystRegistry, Jb as MapOnSettleRoute, Lf as RunGraphTestOptions, Ov as DeliverableSpec, Qg as RouterResponseReceipt, Qh as Inbox, Rb as AuthorizeDownMessage, Rx as AnalyzeOnSettleRoute, Tb as ChildQuestionInbox, Vb as ContinuityMode, _S as RunCancelRequest, _f as SuperviseTestOptions, _x as McpToolDescriptor, a_ as ToolLoopCompactionOptions, at as MakeWorkerAgent, bb as RouteFlow, bx as BusRecord, ct as SpawnPreflight, ff as superviseWithTestBrain, ft as SuperviseProfileEntry, gb as DecideGate, hb as WorkerWatchOptions, ia as ResultBlobStore, it as GraphSubtasks, ka as Agent, lb as CoordinationEvent, lm as supervisorAgentWithTestBrain, lt as SpawnPreflightContext, n_ as ToolLoopCallContext, nh as PriorCoordination, o_ as ToolLoopMessageRecord, ot as PeerAuditAccess, r_ as ToolLoopChat, rt as GraphSubtaskPreparation, s_ as ToolLoopToolCall, tt as CoordinationTools, uC as HarnessTranscriptCapture, ut as SpawnRefusal, vm as SupervisorAgentTestDeps, xh as SpawnResourceReader } from "./types-PBoTtcbX.js";
1
+ import { $g as RouterResponseReceipt, $h as Inbox, Aa as Agent, Db as EscalateQuestion, E as Budget, Eb as ChildQuestionInbox, Hb as ContinuityMode, Lx as AnalystRegistry, Rf as RunGraphTestOptions, Sh as SpawnResourceReader, Um as SupervisorFinalizer, Vf as runGraphWithTestBrain, Yb as MapOnSettleRoute, _b as DecideGate, aa as ResultBlobStore, at as MakeWorkerAgent, c_ as ToolLoopToolCall, ct as SpawnPreflight, dC as HarnessTranscriptCapture, eh as CoordinationDeliveryEvidence, ft as SuperviseProfileEntry, gb as WorkerWatchOptions, i_ as ToolLoopChat, it as GraphSubtasks, jm as StopRule, kv as DeliverableSpec, lt as SpawnPreflightContext, o_ as ToolLoopCompactionOptions, ot as PeerAuditAccess, pf as superviseWithTestBrain, r_ as ToolLoopCallContext, rh as PriorCoordination, rt as GraphSubtaskPreparation, s_ as ToolLoopMessageRecord, tt as CoordinationTools, ub as CoordinationEvent, um as supervisorAgentWithTestBrain, ut as SpawnRefusal, vS as RunCancelRequest, vf as SuperviseTestOptions, vx as McpToolDescriptor, wm as ManagerWakePolicy, xb as RouteFlow, xx as BusRecord, ym as SupervisorAgentTestDeps, zb as AuthorizeDownMessage, zx as AnalyzeOnSettleRoute } from "./types-9xsn2GGY.js";
2
2
  import { AgentImprovementProposal, AgentProfile, AgentProfileImprovementMeasuredComparison, SandboxSizePreset } from "@tangle-network/agent-interface";
3
3
  /** What the brain returned for one turn, as the recorder keeps it. */
4
4
  interface RouterTranscriptReply {
package/dist/testing.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { m as canonicalCandidateDigest$1, v as immutableCandidateValue } from "./output-artifacts-AqkZ8lO2.js";
2
2
  import { a as applyExactAgentProfileDiff, v as parseExactAgentProfile } from "./profile-Cxl_Ajl2.js";
3
- import { c as verifyAgentImprovementProposal } from "./activation-kitznAHo.js";
4
- import { o as supervisorAgentWithTestBrain, p as driverAgent, r as superviseWithTestBrain } from "./supervise-DTUYxnoJ.js";
5
- import { r as runGraphWithTestBrain } from "./graph-4ep9laIH.js";
3
+ import { c as verifyAgentImprovementProposal } from "./activation-38MolXIP.js";
4
+ import { o as supervisorAgentWithTestBrain, p as driverAgent, r as superviseWithTestBrain } from "./supervise-DtVdvZpr.js";
5
+ import { r as runGraphWithTestBrain } from "./graph-CwLg3LGC.js";
6
6
  import { SANDBOX_SIZE_PRESET_NAMES, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
7
7
  // src/testing/fixtures/agent-improvement-proposal.json
8
8
  var agent_improvement_proposal_default = {
9
9
  changedSurfaces: ["prompt"],
10
- digest: "sha256:6be0c7ab30b881707ff2d65319fa8b1f9fa2cc16804ee69d0dd1dda5c9f473a8",
10
+ digest: "sha256:5af2a98c6f8102c1c0cc767d404c697da9e6a2ea64e706275c0d9c3a4afb81b1",
11
11
  evaluation: {
12
12
  "decision": {
13
13
  "contributingChecks": [
@@ -4578,7 +4578,7 @@ var agent_improvement_proposal_default = {
4578
4578
  ],
4579
4579
  "metadata": {
4580
4580
  "fixture": "agent-improvement-proposal",
4581
- "runtimeVersion": "10.0.3"
4581
+ "runtimeVersion": "10.0.4"
4582
4582
  },
4583
4583
  "objectives": [
4584
4584
  {
@@ -4689,8 +4689,8 @@ var agent_improvement_proposal_default = {
4689
4689
  "baselineContentHash": "sha256:5c21ee53e513fc604cb09754e21c392b24a424da0ef37dbf8f1ee4a8a0b08f09",
4690
4690
  "candidateContentHash": "sha256:60fcbb1c728194bd51d7d19cb732d1c3f1881dce7e0a6266b41c8b98cfd65693",
4691
4691
  "kind": "agent-eval-loop",
4692
- "recordDigest": "sha256:c9ed218d74af9f90cd23ef90ac872f007631915ed2a9edfe3d16371042b0a2cd",
4693
- "runId": "agent-runtime-10.0.3-proposal-fixture",
4692
+ "recordDigest": "sha256:d6c70b9c54c9a70f46d958b1574cecfcac82ca037cbbcde2b1916f1aec18ed34",
4693
+ "runId": "agent-runtime-10.0.4-proposal-fixture",
4694
4694
  "schema": "agent-candidate-experiment"
4695
4695
  }
4696
4696
  },
@@ -4713,12 +4713,12 @@ var agent_improvement_proposal_default = {
4713
4713
  }],
4714
4714
  kind: "agent-improvement-proposal",
4715
4715
  proposedAt: "2026-07-10T01:00:00.000Z",
4716
- runId: "agent-runtime-10.0.3-proposal-fixture"
4716
+ runId: "agent-runtime-10.0.4-proposal-fixture"
4717
4717
  };
4718
4718
  // src/testing/fixtures/agent-profile-improvement-proposal.json
4719
4719
  var agent_profile_improvement_proposal_default = {
4720
4720
  changedSurfaces: ["prompt", "skills"],
4721
- digest: "sha256:8c610a6c15d0e0b8de1c515b9d5d09430b0ecd2ae17228664d7e1a4dea5467fb",
4721
+ digest: "sha256:ff5dfe93204f1831aac2878f7640e13206b97fd0c5ee632f4c6c700bb9d6692b",
4722
4722
  evaluation: {
4723
4723
  "decision": {
4724
4724
  "contributingChecks": [
@@ -6352,7 +6352,7 @@ var agent_profile_improvement_proposal_default = {
6352
6352
  ],
6353
6353
  "metadata": {
6354
6354
  "fixture": "agent-profile-improvement-proposal",
6355
- "runtimeVersion": "10.0.3"
6355
+ "runtimeVersion": "10.0.4"
6356
6356
  },
6357
6357
  "objectives": [
6358
6358
  {
@@ -6463,7 +6463,7 @@ var agent_profile_improvement_proposal_default = {
6463
6463
  "baselineContentHash": "sha256:21c495a37c418c10bde64fbaa188beddeed31f1f051ea60a6a6582a9ee0db704",
6464
6464
  "candidateContentHash": "sha256:103f77bc8481601eef1ad5fe6ba84a40dffabc3a44f421f8c8559121edab84e9",
6465
6465
  "kind": "agent-eval-loop",
6466
- "recordDigest": "sha256:754bfbe30ada3fcfacbe73f2e3b92d8ba49f1ed1f051419a1435061e403cd026",
6466
+ "recordDigest": "sha256:f3697ffcc15a3c59112554318b8e0c3c5d6ea1336b210818477665569fa46d2e",
6467
6467
  "runId": "profile-improvement-1",
6468
6468
  "schema": "agent-profile-improvement-experiment"
6469
6469
  }
@@ -1,10 +1,10 @@
1
- import { C as safeWorkerFile, J as FileSpawnJournal, Nn as FileObserverJournal, T as supervisorRunsRoot, X as spawnJournalRecordEvents, i as ROOT_STREAM_FILE, or as harnessTranscriptArtifact, s as nodeStreamFile, v as legacySupervisorRunsRoot } from "./supervisor-accounting-Cuehs4te.js";
2
- import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-CAUsSDno.js";
3
- import { a as readFailureRecord, o as readSettleRecord } from "./settle-record-Beh-sXBW.js";
4
- import { s as rootCoordinationOwner, u as FileCoordinationLog } from "./supervise-identity-eMF-h1uP.js";
5
- import { t as FileResultBlobStore } from "./result-blob-store-BR-BVZrg.js";
1
+ import { C as safeWorkerFile, Pn as FileObserverJournal, T as supervisorRunsRoot, Y as FileSpawnJournal, Z as spawnJournalRecordEvents, i as ROOT_STREAM_FILE, s as nodeStreamFile, sr as harnessTranscriptArtifact, v as legacySupervisorRunsRoot } from "./supervisor-accounting-CZ7i4cd5.js";
2
+ import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-Cqu4NxPV.js";
3
+ import { a as readFailureRecord, o as readSettleRecord } from "./settle-record-au3w7bQG.js";
4
+ import { s as rootCoordinationOwner, u as FileCoordinationLog } from "./supervise-identity-S5XwgaF3.js";
5
+ import { t as FileResultBlobStore } from "./result-blob-store-DfTcyQ05.js";
6
6
  import { Ot as recordValue } from "./failure-cause-DoCCGLDH.js";
7
- import { _ as runAbortable, g as linkAbort, n as parseCommittedJsonLines } from "./jsonl-file-CVAWegN-.js";
7
+ import { _ as runAbortable, g as linkAbort, n as parseCommittedJsonLines } from "./jsonl-file-DyzefaZ6.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { isRecord } from "@tangle-network/agent-core";
10
10
  import { createHash } from "node:crypto";
@@ -1674,4 +1674,4 @@ async function loadRunsRoot(root) {
1674
1674
  }
1675
1675
  export { topAgentMetadata as _, buildSupervisorView as a, numberValue as c, topSnapshot as d, totalSpend as f, readTopAgentInspection as g, readTopAgentHistory as h, aggregateSnapshot as i, parseSpend as l, harnessSessionRows as m, runTopWeb as n, isSpawnEvent as o, createTopAgentStream as p, serveTopWeb as r, loadTopSnapshot as s, TOP_SNAPSHOT_RECONCILE_MS as t, parseTime as u, topAgentWorker as v };
1676
1676
 
1677
- //# sourceMappingURL=top-web-D-wuEVdM.js.map
1677
+ //# sourceMappingURL=top-web-COrMqTRC.js.map