@tangle-network/agent-runtime 10.0.2 → 10.0.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 (98) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/{activation-D0Sp7wMc.d.ts → activation-DbSxPRUW.d.ts} +2 -2
  3. package/dist/{activation-B0DHGRtB.js → activation-kitznAHo.js} +2 -2
  4. package/dist/{activation-B0DHGRtB.js.map → activation-kitznAHo.js.map} +1 -1
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{continuation-CZaeHEzQ.js → continuation-BDeKJgV3.js} +3 -3
  8. package/dist/{continuation-CZaeHEzQ.js.map → continuation-BDeKJgV3.js.map} +1 -1
  9. package/dist/{delegate-Co5iUyS0.js → delegate-D8yX_2K7.js} +2 -2
  10. package/dist/{delegate-Co5iUyS0.js.map → delegate-D8yX_2K7.js.map} +1 -1
  11. package/dist/{driver-control-acknowledgers-B1Qx2JUz.js → driver-control-acknowledgers-BTSr3Znq.js} +7 -5
  12. package/dist/{driver-control-acknowledgers-B1Qx2JUz.js.map → driver-control-acknowledgers-BTSr3Znq.js.map} +1 -1
  13. package/dist/durable-file-DUcTDWJD.js +498 -0
  14. package/dist/durable-file-DUcTDWJD.js.map +1 -0
  15. package/dist/durable-file-XqOyDf7q.js +1 -0
  16. package/dist/durable-writer-thread.d.ts +1 -0
  17. package/dist/durable-writer-thread.js +86 -0
  18. package/dist/durable-writer-thread.js.map +1 -0
  19. package/dist/durable.d.ts +1 -1
  20. package/dist/durable.js +15 -128
  21. package/dist/durable.js.map +1 -1
  22. package/dist/{graph-uc4eT1wR.js → graph-4ep9laIH.js} +7 -7
  23. package/dist/{graph-uc4eT1wR.js.map → graph-4ep9laIH.js.map} +1 -1
  24. package/dist/{graph-registry-DxhlgHdA.js → graph-registry-B-EGvJ-3.js} +1 -1
  25. package/dist/{graph-registry-j9t9J0KT.js → graph-registry-BxEBeihr.js} +4 -4
  26. package/dist/{graph-registry-j9t9J0KT.js.map → graph-registry-BxEBeihr.js.map} +1 -1
  27. package/dist/{improve-BM0HlzMi.js → improve-CJf87tBs.js} +7 -7
  28. package/dist/{improve-BM0HlzMi.js.map → improve-CJf87tBs.js.map} +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +9 -9
  31. package/dist/intelligence.d.ts +2 -2
  32. package/dist/intelligence.js +4 -4
  33. package/dist/{jsonl-file-BhuxeejY.js → jsonl-file-CVAWegN-.js} +53 -11
  34. package/dist/jsonl-file-CVAWegN-.js.map +1 -0
  35. package/dist/kernel.d.ts +1 -1
  36. package/dist/kernel.js +17 -15
  37. package/dist/{loop-runner-npLkvCU5.d.ts → loop-runner-CayC8e9K.d.ts} +2 -2
  38. package/dist/{loop-runner-CRC-RE4D.js → loop-runner-Ckj-Zz3-.js} +2 -2
  39. package/dist/{loop-runner-CRC-RE4D.js.map → loop-runner-Ckj-Zz3-.js.map} +1 -1
  40. package/dist/loop-runner-bin.d.ts +1 -1
  41. package/dist/loop-runner-bin.js +1 -1
  42. package/dist/mcp/bin.js +3 -3
  43. package/dist/mcp/index.d.ts +1 -1
  44. package/dist/mcp/index.js +5 -5
  45. package/dist/profiles.d.ts +1 -1
  46. package/dist/{provision-supervisor-CJrMGyZW.js → provision-supervisor-NjROV7AQ.js} +6 -6
  47. package/dist/{provision-supervisor-CJrMGyZW.js.map → provision-supervisor-NjROV7AQ.js.map} +1 -1
  48. package/dist/result-blob-store-BR-BVZrg.js +76 -0
  49. package/dist/result-blob-store-BR-BVZrg.js.map +1 -0
  50. package/dist/{run-cancellation-CBP3Bmad.js → run-cancellation-C9V1lYhq.js} +5 -209
  51. package/dist/run-cancellation-C9V1lYhq.js.map +1 -0
  52. package/dist/run-lock-Y3u9kwM0.js +193 -0
  53. package/dist/run-lock-Y3u9kwM0.js.map +1 -0
  54. package/dist/run-reopen-CHYTHk7x.js +134 -0
  55. package/dist/run-reopen-CHYTHk7x.js.map +1 -0
  56. package/dist/run-state-DgKo8_tO.js +180 -0
  57. package/dist/run-state-DgKo8_tO.js.map +1 -0
  58. package/dist/{runtime-BqSaWTEY.js → runtime-CdthBQUs.js} +21 -19
  59. package/dist/{runtime-BqSaWTEY.js.map → runtime-CdthBQUs.js.map} +1 -1
  60. package/dist/{search-executor-C9TN-KgI.js → search-executor-Bb0WuI_Z.js} +3 -3
  61. package/dist/{search-executor-C9TN-KgI.js.map → search-executor-Bb0WuI_Z.js.map} +1 -1
  62. package/dist/{server-CcMa8Lt9.js → server-BCtyL7jH.js} +3 -3
  63. package/dist/{server-CcMa8Lt9.js.map → server-BCtyL7jH.js.map} +1 -1
  64. package/dist/{settle-record-BtjYZabI.js → settle-record-Beh-sXBW.js} +5 -4
  65. package/dist/settle-record-Beh-sXBW.js.map +1 -0
  66. package/dist/{structural-rollout-2oRJjwyM.js → structural-rollout-BRfSDPkv.js} +4 -4
  67. package/dist/{structural-rollout-2oRJjwyM.js.map → structural-rollout-BRfSDPkv.js.map} +1 -1
  68. package/dist/{supervise-BrgtzJf3.js → supervise-DTUYxnoJ.js} +9 -8
  69. package/dist/{supervise-BrgtzJf3.js.map → supervise-DTUYxnoJ.js.map} +1 -1
  70. package/dist/supervise-identity-eMF-h1uP.js +210 -0
  71. package/dist/supervise-identity-eMF-h1uP.js.map +1 -0
  72. package/dist/{supervision-discovery-DLMm3UOr.js → supervision-discovery-CAUsSDno.js} +3 -3
  73. package/dist/{supervision-discovery-DLMm3UOr.js.map → supervision-discovery-CAUsSDno.js.map} +1 -1
  74. package/dist/{supervisor-ACffs_W4.js → supervisor-BtRRFbgF.js} +13 -176
  75. package/dist/supervisor-BtRRFbgF.js.map +1 -0
  76. package/dist/{supervisor-accounting-BlJqoP3k.js → supervisor-accounting-Cuehs4te.js} +59 -112
  77. package/dist/supervisor-accounting-Cuehs4te.js.map +1 -0
  78. package/dist/supervisor-root-contract-CmFKzPps.js +165 -0
  79. package/dist/supervisor-root-contract-CmFKzPps.js.map +1 -0
  80. package/dist/testing.d.ts +1 -1
  81. package/dist/testing.js +11 -11
  82. package/dist/{top-web-PYyzBMsK.js → top-web-D-wuEVdM.js} +7 -6
  83. package/dist/{top-web-PYyzBMsK.js.map → top-web-D-wuEVdM.js.map} +1 -1
  84. package/dist/tui/bin.js +3 -3
  85. package/dist/tui/index.d.ts +1 -1
  86. package/dist/tui/index.js +2 -2
  87. package/dist/{types-DX1OGeHE.d.ts → types-PBoTtcbX.d.ts} +2 -2
  88. package/package.json +1 -1
  89. package/dist/durable-file-CksURHlH.js +0 -1
  90. package/dist/durable-file-DstVeHcj.js +0 -228
  91. package/dist/durable-file-DstVeHcj.js.map +0 -1
  92. package/dist/jsonl-file-BhuxeejY.js.map +0 -1
  93. package/dist/run-cancellation-CBP3Bmad.js.map +0 -1
  94. package/dist/run-state-BnhCVbTY.js +0 -357
  95. package/dist/run-state-BnhCVbTY.js.map +0 -1
  96. package/dist/settle-record-BtjYZabI.js.map +0 -1
  97. package/dist/supervisor-ACffs_W4.js.map +0 -1
  98. package/dist/supervisor-accounting-BlJqoP3k.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { $r as executableAgentSpecSnapshot, $t as owners, Br as recordRuntimeOwnedProviderDispatchNotStarted, Cn as reconnectRetainedRun, Dr as attestRuntimeOwnedExecutor, Er as attestRuntimeOwnedDeferredExecutor, Fr as knownMaterializationReceipt, G as appendSpawnEvents, Gr as runtimeOwnedExecutorMaterialization, Hr as recordRuntimeOwnedProviderModel, In as environmentGone, Ir as newExecutionAttemptId, J as reenteredWorkers, Jr as runtimeOwnedScopeOwnerControl, L as nestedScopeSeamKey, Ln as WORKER_TRACE_PROPAGATION, M as prepareScopeResume, Mr as finalizeRuntimeOwnedPendingExecutor, Nr as inheritRuntimeOwnedExecutorAttestation, Or as attestRuntimeOwnedPendingExecutor, Pr as knownExecutionBindingReceipt, Qr as executableAgentProfileSnapshot, Qt as bindScopeRetainedOwnerProvider, Rn as workerTraceEnv, Sn as mintRetainedIdentity, Tn as startRetainedRun, Tr as subscriptionUsageLimitSignal, Vn as mergeTraceEnv, Vr as recordRuntimeOwnedProviderIdentityConflict, Wr as runtimeOwnedExecutorExecutionBinding, Wt as scopeRetainedOwnerSettled, X as assertRecursiveReservationPolicy, Xr as unknownExecutionBindingReceipt, Xt as scopeRetainedOwnerCheckpointing, Yr as runtimeOwnedScopeOwnerRuntime, Zr as unknownMaterializationReceipt, _n as describeRetainedNativeStops, _t as unconfirmedTeardowns, ai as assertEventBinding, ar as harnessTranscriptFromLines, bn as RetainedMaterializationTimeoutError, ci as freezeControlRef, cn as nestedDriverTreeRoot, dn as SpawnEventIndex, dt as registerNestedTeardownScope, en as scopeOwnerLiabilities, fi as promptOptionsFromAgentTurnInput, ft as releaseHeldEnvironments, gr as describeToolArgs, gt as startScopeRecoveries, hn as observeModelRequest, hr as createActivityLog, ht as settleManagerWork, ii as RetainedRunProviderContractError, in as ownedTreeRootSpawn, it as hasRetriableTeardowns, j as resolveWorkerSlots, jt as finalizeScopeOwnerMaterialization, li as retainedSessionReplaced, mt as retryUnconfirmedTeardowns, n as terminalAccounting, nt as closeRetainedSlots, oi as awaitAbortable, on as attestNestedDriverTreeOwner, or as harnessTranscriptUnavailable, pn as executorObservation, pt as releaseRetainedEnvironments, q as appendTeardownConfirmation, r as createScope, rn as loadSpawnForest, rr as captureHarnessTranscript, rt as closeScopeAdmission, si as exactSession, sn as driverRuntime, t as isNonEmptySpend, tr as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, tt as boundRetainedReleases, ui as sameControlCoordinates, un as encodeResultBlob, vn as stopRetainedNativeExecution, vr as isLiveNodeStatus, vt as waitForScopeChildren, wn as recoverRetainedRun, wt as RELEASE_DESTROY_MS, xn as assertRetainedRunReplayMaterial, yn as verifyWorkspaceMarker, zn as workerTraceHeaders, zr as recordRuntimeOwnedProviderAttemptStart } from "./supervisor-accounting-BlJqoP3k.js";
1
+ import { Ar as attestRuntimeOwnedPendingExecutor, Bn as workerTraceEnv, Cn as assertRetainedRunReplayMaterial, Dn as startRetainedRun, Dr as subscriptionUsageLimitSignal, En as recoverRetainedRun, F as resolveWorkerSlots, Fr as inheritRuntimeOwnedExecutorAttestation, Ft as finalizeScopeOwnerMaterialization, Hr as recordRuntimeOwnedProviderDispatchNotStarted, I as prepareScopeResume, Jt as scopeRetainedOwnerSettled, Kr as runtimeOwnedExecutorExecutionBinding, Or as attestRuntimeOwnedDeferredExecutor, Ot as RELEASE_DESTROY_MS, Pr as finalizeRuntimeOwnedPendingExecutor, Rn as environmentGone, Rr as newExecutionAttemptId, Sn as RetainedMaterializationTimeoutError, St as waitForScopeChildren, Tn as reconnectRetainedRun, Un as mergeTraceEnv, Ur as recordRuntimeOwnedProviderIdentityConflict, V as nestedScopeSeamKey, Vn as workerTraceHeaders, Vr as recordRuntimeOwnedProviderAttemptStart, Wr as recordRuntimeOwnedProviderModel, Xr as runtimeOwnedScopeOwnerControl, Y as appendSpawnEvents, Z as appendTeardownConfirmation, Zr as runtimeOwnedScopeOwnerRuntime, _n as observeModelRequest, _r as createActivityLog, _t as releaseRetainedEnvironments, ar as captureHarnessTranscript, at as boundRetainedReleases, bn as stopRetainedNativeExecution, br as isLiveNodeStatus, bt as startScopeRecoveries, ci as awaitAbortable, cn as ownedTreeRootSpawn, cr as harnessTranscriptUnavailable, ct as hasRetriableTeardowns, di as retainedSessionReplaced, dn as driverRuntime, ei as executableAgentProfileSnapshot, en as scopeRetainedOwnerCheckpointing, et as assertRecursiveReservationPolicy, fi as sameControlCoordinates, fn as nestedDriverTreeRoot, gt as releaseHeldEnvironments, hn as executorObservation, ht as registerNestedTeardownScope, in as scopeOwnerLiabilities, kr as attestRuntimeOwnedExecutor, li as exactSession, mi as promptOptionsFromAgentTurnInput, n as terminalAccounting, nn as bindScopeRetainedOwnerProvider, oi as RetainedRunProviderContractError, ot as closeRetainedSlots, pn as SpawnEventIndex, qr as runtimeOwnedExecutorMaterialization, r as createScope, rn as owners, rr as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, si as assertEventBinding, sn as loadSpawnForest, sr as harnessTranscriptFromLines, st as closeScopeAdmission, t as isNonEmptySpend, ti as executableAgentSpecSnapshot, ui as freezeControlRef, un as attestNestedDriverTreeOwner, vr as describeToolArgs, vt as retryUnconfirmedTeardowns, wn as mintRetainedIdentity, xn as verifyWorkspaceMarker, xt as unconfirmedTeardowns, yn as describeRetainedNativeStops, yt as settleManagerWork, zn as WORKER_TRACE_PROPAGATION } from "./supervisor-accounting-Cuehs4te.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-DG8yufqX.js";
3
- import { d as abortReason, l as sha256, m as runAbortable, p as linkAbort, u as RunCancellationReason } from "./jsonl-file-BhuxeejY.js";
3
+ import { _ as runAbortable, f as sha256, g as linkAbort, m as abortReason, p as RunCancellationReason } from "./jsonl-file-CVAWegN-.js";
4
4
  import { a as ROOT_DEADLINE_REASON, f as teardownSurfaces, l as isDeadlineAbortReason, o as armDeadlineTimer, t as ACCEPTED_RESULT_GRACE_MS } from "./deadline-CySmJ_0S.js";
5
5
  import { C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, S as unmeteredSpend, T as zeroSpend, _ as roundBoxMinutes, b as throwAbort, c as errorMessage, d as isAbortError, f as isAsyncIterable, g as randomUuid, h as randomSuffix, m as promptCacheTokenClasses, n as addSpend, o as cloneTokenUsage, p as mapWithConcurrency, r as addTokenUsage, s as deleteBoxSafe, v as sleep, w as withTimeout, x as throwIfAborted, y as stringifySafe } from "./util-qsH5cC9S.js";
6
6
  import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
@@ -9,17 +9,19 @@ import { a as errMessage, i as causeChain, l as errorText, n as detachedSnapshot
9
9
  import { _ as reportedServedModel, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy, v as agentHarness } from "./model-policy-DZnL8Yj9.js";
10
10
  import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-l-SLQnGb.js";
11
11
  import { x as hasControlCharacter } from "./workspace-streams-C7PGLAUd.js";
12
- import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-CZaeHEzQ.js";
13
- import { a as writeAtomicDurableFile, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
12
+ import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-BDeKJgV3.js";
13
+ import { r as appendRunLines, u as writeAtomicDurableFile } from "./durable-file-DUcTDWJD.js";
14
14
  import { t as PROTOCOL_VERSION } from "./tool-server-DQCdu3am.js";
15
15
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
16
- import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentFileOutputPolicySchema, AgentRetainedFilePublicationSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sameAgentRunControlRef, sha256DigestSchema, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
16
+ import { n as encodeResultBlob } from "./result-blob-store-BR-BVZrg.js";
17
+ import { a as recordRootReentered, c as rootMaterializationReceipt, i as changesRootProfile, l as rootStartedAtMs, o as recordRootSegment, r as assertRootIdentity, s as rootExecutionBindingReceipt, t as assertResumeContract } from "./supervisor-root-contract-CmFKzPps.js";
18
+ import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentFileOutputPolicySchema, AgentRetainedFilePublicationSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sameAgentRunControlRef, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
17
19
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
18
20
  import { SDKError, generateIdempotencyKey, isRecord, withRetry } from "@tangle-network/agent-core";
19
21
  import { collectAgentFinalMessageText, collectAgentResponseText, isToolBearingEvent } from "@tangle-network/sandbox";
20
22
  import { z } from "zod";
21
23
  import { createHash, randomBytes, randomUUID } from "node:crypto";
22
- import { appendFileSync, closeSync, constants, createReadStream, existsSync, openSync } from "node:fs";
24
+ import { constants, createReadStream, existsSync } from "node:fs";
23
25
  import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
24
26
  import { spawn } from "node:child_process";
25
27
  import { access, chmod, copyFile, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, rmdir, stat, symlink, writeFile } from "node:fs/promises";
@@ -6422,15 +6424,7 @@ function recordLaunch(env, ids, options) {
6422
6424
  dst: ids.TANGLE_RUN_ID,
6423
6425
  attrs: {}
6424
6426
  });
6425
- fenceRunWrite(() => {
6426
- const fd = openSync(join(dir, `${host}.jsonl`), "a", 384);
6427
- try {
6428
- appendFileSync(fd, node);
6429
- appendFileSync(fd, edge);
6430
- } finally {
6431
- closeSync(fd);
6432
- }
6433
- });
6427
+ appendRunLines(join(dir, `${host}.jsonl`), [node, edge], { mode: 384 });
6434
6428
  } catch {}
6435
6429
  }
6436
6430
  // src/runtime/supervise/bridge-executor.ts
@@ -15850,164 +15844,6 @@ function deadlinePassed(pool, opts) {
15850
15844
  const deadlineMs = pool.readout().deadlineMs;
15851
15845
  return deadlineMs > 0 && (opts.now ?? Date.now)() >= deadlineMs;
15852
15846
  }
15853
- // src/runtime/supervise/supervisor-root-contract.ts
15854
- /** A resumed process may continue only the exact root contract first recorded for this run id. Its
15855
- * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */
15856
- function assertResumeContract(events, opts) {
15857
- const recorded = assertResumeLimits(events, opts);
15858
- if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) throw new RuntimeRunStateError(`supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`);
15859
- const receipts = events.filter((event) => event.kind === "materialized" && event.id === opts.runId);
15860
- const expectedReceipt = rootMaterializationReceipt(opts);
15861
- if (expectedReceipt === void 0) {
15862
- if (receipts.length > 1) throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`);
15863
- } else if (receipts.length !== 1 || contentAddress(receipts[0]?.receipt) !== contentAddress(expectedReceipt)) throw new RuntimeRunStateError(`supervisor: resume materialization mismatch for run '${opts.runId}'; backend, model, execution identity, and plan must match`);
15864
- return recorded;
15865
- }
15866
- /**
15867
- * The limits half of the resume contract: one root identity event, the recorded budget and the
15868
- * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);
15869
- * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.
15870
- */
15871
- function assertResumeLimits(events, opts, reopenBudget) {
15872
- const roots = events.filter((event) => event.kind === "spawned" && event.parent === void 0);
15873
- if (roots.length !== 1 || roots[0]?.id !== opts.runId) throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`);
15874
- const recorded = roots[0];
15875
- const reopenedBudget = reopenBudget ?? events.filter((event) => event.kind === "reopened" && event.id === opts.runId && event.budget !== void 0).at(-1)?.budget;
15876
- if (contentAddress(reopenedBudget ?? recorded.budget) !== contentAddress(opts.budget)) throw new RuntimeRunStateError(`supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`);
15877
- const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : void 0;
15878
- if (contentAddress(recorded.recursiveAdmission ?? null) !== contentAddress(expectedAdmission ?? null)) throw new RuntimeRunStateError(`supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`);
15879
- return recorded;
15880
- }
15881
- /** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no
15882
- * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */
15883
- function rootMaterializationReceipt(opts) {
15884
- const declaration = opts.rootMaterialization;
15885
- if (declaration === void 0) return unknownMaterializationReceipt({
15886
- ...opts.rootIdentity?.profileDigest === void 0 ? {} : { authoredProfileDigest: opts.rootIdentity.profileDigest },
15887
- runtime: "inline",
15888
- reason: "root-agent-did-not-report"
15889
- });
15890
- if (declaration.declaration === "deferred") return void 0;
15891
- if (opts.rootIdentity?.profileDigest === void 0) throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`);
15892
- try {
15893
- return knownMaterializationReceipt({
15894
- authoredProfileDigest: opts.rootIdentity.profileDigest,
15895
- runtime: declaration.runtime,
15896
- declaration: declaration.declaration
15897
- });
15898
- } catch (error) {
15899
- throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' has invalid root materialization evidence`, { cause: error });
15900
- }
15901
- }
15902
- function rootExecutionBindingReceipt(opts, materialization, attemptId) {
15903
- const root = opts.rootMaterialization;
15904
- if (root?.declaration === "deferred") return void 0;
15905
- if (root === void 0) return unknownExecutionBindingReceipt(materialization, attemptId, "root-agent-did-not-report");
15906
- try {
15907
- return knownExecutionBindingReceipt(materialization, {
15908
- attemptId,
15909
- ...root.binding
15910
- });
15911
- } catch (error) {
15912
- throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' has invalid root execution binding`, { cause: error });
15913
- }
15914
- }
15915
- /** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */
15916
- function changesRootProfile(entry) {
15917
- const { stack: _stack, ...current } = entry.current;
15918
- return contentAddress(current) !== contentAddress(entry.registered);
15919
- }
15920
- /**
15921
- * Append one `root-segment` record when the root enters a segment that differs from the one it
15922
- * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its
15923
- * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends
15924
- * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.
15925
- */
15926
- async function recordRootSegment(opts, events, at, fresh) {
15927
- const entry = opts.rootSegment;
15928
- if (entry === void 0) return;
15929
- const records = events.filter((event) => event.kind === "root-segment" && event.id === opts.runId);
15930
- const last = records.at(-1)?.to ?? (fresh ? void 0 : entry.registered);
15931
- if (last !== void 0 && contentAddress(last) === contentAddress(entry.current)) return;
15932
- await opts.journal.appendEvent(opts.runId, {
15933
- kind: "root-segment",
15934
- id: opts.runId,
15935
- ...last === void 0 ? {} : { from: last },
15936
- to: entry.current,
15937
- reason: entry.reason,
15938
- seq: records.length,
15939
- at
15940
- });
15941
- }
15942
- /**
15943
- * Append one `root-reentered` record: this process is supervising a run an earlier process drove.
15944
- * After a host reboot the re-entered root ran two
15945
- * barren continuations and the run settled `no-result-selected`, with three workers still open in
15946
- * the journal and no record that a restart had happened.
15947
- */
15948
- async function recordRootReentered(opts, resumeFrom, at) {
15949
- await opts.journal.appendEvent(opts.runId, {
15950
- kind: "root-reentered",
15951
- id: opts.runId,
15952
- ...reenteredWorkers(resumeFrom, opts.runId),
15953
- seq: resumeFrom.events.filter((event) => event.kind === "root-reentered").length,
15954
- at
15955
- });
15956
- }
15957
- function sameOptionalIdentity(recorded, requested) {
15958
- if (recorded === void 0 || requested === void 0) return recorded === requested;
15959
- return contentAddress(recorded) === contentAddress(requested);
15960
- }
15961
- /**
15962
- * Name the identity fields that actually differ, with both values.
15963
- *
15964
- * The identity is compared as one content address, so a mismatch is a single boolean and the
15965
- * message could only list every field that MIGHT have caused it. A caller then has to diff four
15966
- * digests by hand to learn which one moved, and the common cause — a task file regenerated with
15967
- * one character different — is indistinguishable from a genuinely different profile.
15968
- *
15969
- * Digests are truncated because the prefix identifies them and the full 64 characters push the
15970
- * real content off the end of a terminal line.
15971
- */
15972
- function describeIdentityMismatch(recorded, requested) {
15973
- if (recorded === void 0) return "the recorded root carried no identity but this resume supplies one";
15974
- if (requested === void 0) return "the recorded root carried an identity but this resume supplies none";
15975
- const short = (value) => {
15976
- if (value === void 0) return "(absent)";
15977
- const text = typeof value === "string" ? value : JSON.stringify(value);
15978
- return text.length > 20 ? `${text.slice(0, 20)}…` : text;
15979
- };
15980
- const differing = [
15981
- "profileDigest",
15982
- "taskDigest",
15983
- "candidateDigest",
15984
- "correlation"
15985
- ].filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field])).map((field) => `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`);
15986
- if (differing.length === 0) return "the identity objects differ in shape while every known field matches";
15987
- 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)`;
15988
- }
15989
- /** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,
15990
- * but once supplied it is trusted durable evidence and therefore must be complete and canonical;
15991
- * resumed runs always require it so the prior root can be matched exactly. */
15992
- function assertRootIdentity(opts) {
15993
- const identity = opts.rootIdentity;
15994
- if (identity === void 0) {
15995
- if (opts.resume !== true) return;
15996
- throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`);
15997
- }
15998
- const unknownFields = Object.keys(identity).filter((key) => key !== "profileDigest" && key !== "taskDigest" && key !== "candidateDigest" && key !== "correlation");
15999
- const correlation = identity.correlation;
16000
- const validCorrelation = correlation === void 0 || typeof correlation === "object" && correlation !== null && !Array.isArray(correlation) && Object.entries(correlation).every(([key, value]) => key.length > 0 && typeof value === "string" && value.length > 0);
16001
- if (unknownFields.length > 0 || !sha256DigestSchema.safeParse(identity.profileDigest).success || !sha256DigestSchema.safeParse(identity.taskDigest).success || identity.candidateDigest !== void 0 && !sha256DigestSchema.safeParse(identity.candidateDigest).success || !validCorrelation) throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' requires an exact rootIdentity with valid profileDigest, taskDigest, candidateDigest, and correlation`);
16002
- }
16003
- /** The instant the run's root was journaled — the anchor for both the absolute deadline and the
16004
- * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this
16005
- * process's. */
16006
- function rootStartedAtMs(root) {
16007
- const startedAt = Date.parse(root.at);
16008
- if (!Number.isFinite(startedAt)) throw new RuntimeRunStateError(`supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`);
16009
- return startedAt;
16010
- }
16011
15847
  // src/runtime/supervise/run-persistence.ts
16012
15848
  /** One failed store operation revokes this controller's writes, never its retained executions. */
16013
15849
  function guardRunPersistence(journal, blobs, interrupt) {
@@ -16294,7 +16130,8 @@ async function openRunTree(opts, now) {
16294
16130
  return opened;
16295
16131
  }
16296
16132
  async function resumeRunTree(opts, prior, now, runStartedAt, rootAttemptId) {
16297
- const runEpochMs = rootStartedAtMs(assertResumeContract(prior, opts));
16133
+ const rootEvent = assertResumeContract(prior, opts);
16134
+ const runEpochMs = rootStartedAtMs(rootEvent);
16298
16135
  const cancelledAtEntry = opts.signal?.aborted === true && opts.signal.reason instanceof RunCancellationReason;
16299
16136
  const { resumeFrom, poolRestore } = await prepareScopeResume(opts, prior, opts.signal ?? new AbortController().signal, now, opts.runId, cancelledAtEntry);
16300
16137
  const events = [...resumeFrom.events];
@@ -16668,6 +16505,6 @@ async function noWinner(settled, rejection) {
16668
16505
  reason: "no-result-selected"
16669
16506
  };
16670
16507
  }
16671
- export { failPendingAfter as $, worktreeCliProfileMaterialization as $t, readPromptOptions as A, readCodexRolloutSession as At, toolResultText as B, terminateProcessTreeAndConfirm as Bt, captureReusableExecutorConfig as C, bridgeAdmissionRefusal as Ct, createSteerableSandboxSession as D, addHarnessUsage as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, ROUTER_PRICE_SOURCE as Et, defaultSelectWinner as F, defaultRunCommand as Ft, providerAsExecutor as G, fullProfileMaterialization as Gt, routerBrain as H, assertProfileMaterializes as Ht, codeModeArguments as I, runSettledCommand as It, providerAsSandboxClient as J, promptModelProfileMaterialization as Jt, providerOutputOptions as K, profileMaterializationAxes$1 as Kt, codeModeModelOutput as L, runWorktreeHarness as Lt, createSandboxLineage as M, bridgeRuntimeAttachmentsKey as Mt, acquireSandbox as N, bridgeRuntimeEnvKey as Nt, runAgentRounds as O, createCodexRolloutStoreReader as Ot, TERMINAL_DECISIONS as P, bridgeStopSignalKey as Pt, createInbox as Q, unsupportedProfileDimensions as Qt, createCodeModeTools as R, LOCAL_HARNESSES as Rt, bindReusableExecutorExecutionId as S, verdictFromJudgeScore as St, snapshotExecutorConfig as T, priceTokens as Tt, createAgentEnvironmentProviderRegistry as U, controlProfileMaterialization as Ut, createRouterTranscript as V, assertProfileMaterialization as Vt, resolveAgentEnvironmentProvider as W, defineProfileMaterializationContract as Wt, createInPlaceCliExecutor as X, sandboxActProfileMaterialization as Xt, createWorktreeCliExecutor as Y, renderUnsupported as Yt, INBOX_RECEIPT_KEY as Z, sandboxProfileMaterialization as Zt, isDriverSpec as _, preflightPublicCoordination as _t, assertRunParking as a, isPeerMailEnvelope as at, InMemorySpawnJournal as b, gateOnDeliverable as bt, readRunParking as c, taskToPrompt$1 as ct, bestDelivered as d, abandonablePending as dt, projectSandboxOutcome as en, AUTHORITY_MARKERS as et, runFinalizer as f, classifyDriverFailure as ft, driverExecutorFactory as g, upstreamUnavailableSignal as gt, driverChild as h, undispatchedCredentialExit as ht, RunParkedError as i, createPeerMailbox as it, createSandboxForSpec as j, createPushTraceSource as jt, assertBoxlessPromptOptions as k, harnessUsageIsEmpty as kt, sleepScopeWait as l, DriverAttemptsExhaustedError as lt, createRootHandle as m, transientFailureKind as mt, createSupervisor as n, PEER_MAIL_WIRE_KEY as nt, bindScopeParkingDrain as o, peerMailTools as ot, runTree as p, summarizeDriverAttempts as pt, LEAF_CONTINUATION_TASK as q, promptControlProfileMaterialization as qt, assertResumeLimits as r, claimsAuthority as rt, isRunParked as s, peerMailVerbNames as st, DEFAULT_MAX_DEPTH as t, readSandboxOutcome as tn, DEFAULT_PEER_MAIL_LIMITS as tt, withRunParking as u, HarnessTurnFailedError as ut, withDriverExecutor as v, CheckUnavailableError as vt, createExecutor as w, bridgeModelRouteRefusal as wt, createExecutorRegistry as x, mapExecutorResult as xt, InMemoryResultBlobStore as y, gateFactoryOnDeliverable as yt, runCodeMode as z, harnessInvocation as zt };
16508
+ export { AUTHORITY_MARKERS as $, projectSandboxOutcome as $t, createSandboxForSpec as A, createPushTraceSource as At, createRouterTranscript as B, assertProfileMaterialization as Bt, createExecutor as C, bridgeModelRouteRefusal as Ct, runAgentRounds as D, createCodexRolloutStoreReader as Dt, createSteerableSandboxSession as E, addHarnessUsage as Et, codeModeArguments as F, runSettledCommand as Ft, providerOutputOptions as G, profileMaterializationAxes$1 as Gt, createAgentEnvironmentProviderRegistry as H, controlProfileMaterialization as Ht, codeModeModelOutput as I, runWorktreeHarness as It, createWorktreeCliExecutor as J, renderUnsupported as Jt, LEAF_CONTINUATION_TASK as K, promptControlProfileMaterialization as Kt, createCodeModeTools as L, LOCAL_HARNESSES as Lt, acquireSandbox as M, bridgeRuntimeEnvKey as Mt, TERMINAL_DECISIONS as N, bridgeStopSignalKey as Nt, assertBoxlessPromptOptions as O, harnessUsageIsEmpty as Ot, defaultSelectWinner as P, defaultRunCommand as Pt, failPendingAfter as Q, worktreeCliProfileMaterialization as Qt, runCodeMode as R, harnessInvocation as Rt, captureReusableExecutorConfig as S, bridgeAdmissionRefusal as St, DEFAULT_SANDBOX_STEERING_MAX_TURNS as T, ROUTER_PRICE_SOURCE as Tt, resolveAgentEnvironmentProvider as U, defineProfileMaterializationContract as Ut, routerBrain as V, assertProfileMaterializes as Vt, providerAsExecutor as W, fullProfileMaterialization as Wt, INBOX_RECEIPT_KEY as X, sandboxProfileMaterialization as Xt, createInPlaceCliExecutor as Y, sandboxActProfileMaterialization as Yt, createInbox as Z, unsupportedProfileDimensions as Zt, withDriverExecutor as _, CheckUnavailableError as _t, bindScopeParkingDrain as a, peerMailTools as at, createExecutorRegistry as b, mapExecutorResult as bt, sleepScopeWait as c, DriverAttemptsExhaustedError as ct, runFinalizer as d, classifyDriverFailure as dt, readSandboxOutcome as en, DEFAULT_PEER_MAIL_LIMITS as et, runTree as f, summarizeDriverAttempts as ft, isDriverSpec as g, preflightPublicCoordination as gt, driverExecutorFactory as h, upstreamUnavailableSignal as ht, assertRunParking as i, isPeerMailEnvelope as it, createSandboxLineage as j, bridgeRuntimeAttachmentsKey as jt, readPromptOptions as k, readCodexRolloutSession as kt, withRunParking as l, HarnessTurnFailedError as lt, driverChild as m, undispatchedCredentialExit as mt, createSupervisor as n, claimsAuthority as nt, isRunParked as o, peerMailVerbNames as ot, createRootHandle as p, transientFailureKind as pt, providerAsSandboxClient as q, promptModelProfileMaterialization as qt, RunParkedError as r, createPeerMailbox as rt, readRunParking as s, taskToPrompt$1 as st, DEFAULT_MAX_DEPTH as t, PEER_MAIL_WIRE_KEY as tt, bestDelivered as u, abandonablePending as ut, InMemoryResultBlobStore as v, gateFactoryOnDeliverable as vt, snapshotExecutorConfig as w, priceTokens as wt, bindReusableExecutorExecutionId as x, verdictFromJudgeScore as xt, InMemorySpawnJournal as y, gateOnDeliverable as yt, toolResultText as z, terminateProcessTreeAndConfirm as zt };
16672
16509
 
16673
- //# sourceMappingURL=supervisor-ACffs_W4.js.map
16510
+ //# sourceMappingURL=supervisor-BtRRFbgF.js.map