@tangle-network/agent-runtime 10.0.1 → 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 (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{activation-s6dGGify.d.ts → activation-DbSxPRUW.d.ts} +2 -2
  3. package/dist/{activation-C_BenzIu.js → activation-kitznAHo.js} +2 -2
  4. package/dist/{activation-C_BenzIu.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-BOren4c7.js → delegate-D8yX_2K7.js} +2 -2
  10. package/dist/{delegate-BOren4c7.js.map → delegate-D8yX_2K7.js.map} +1 -1
  11. package/dist/{driver-control-acknowledgers-ByKwAgCI.js → driver-control-acknowledgers-BTSr3Znq.js} +50 -12
  12. package/dist/driver-control-acknowledgers-BTSr3Znq.js.map +1 -0
  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-BXONYT1o.js → graph-4ep9laIH.js} +8 -8
  23. package/dist/{graph-BXONYT1o.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-CS2GIF5O.js → improve-CJf87tBs.js} +8 -8
  28. package/dist/{improve-CS2GIF5O.js.map → improve-CJf87tBs.js.map} +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +10 -10
  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 +2 -2
  36. package/dist/kernel.js +19 -17
  37. package/dist/{loop-runner-C0B3PexH.d.ts → loop-runner-CayC8e9K.d.ts} +2 -2
  38. package/dist/{loop-runner-ftyZP4st.js → loop-runner-Ckj-Zz3-.js} +2 -2
  39. package/dist/{loop-runner-ftyZP4st.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 +6 -6
  45. package/dist/{model-policy-CqDuBTq-.js → model-policy-DZnL8Yj9.js} +13 -2
  46. package/dist/{model-policy-CqDuBTq-.js.map → model-policy-DZnL8Yj9.js.map} +1 -1
  47. package/dist/profiles.d.ts +1 -1
  48. package/dist/profiles.js +1 -1
  49. package/dist/{provision-supervisor-CauovUHn.js → provision-supervisor-NjROV7AQ.js} +7 -7
  50. package/dist/{provision-supervisor-CauovUHn.js.map → provision-supervisor-NjROV7AQ.js.map} +1 -1
  51. package/dist/result-blob-store-BR-BVZrg.js +76 -0
  52. package/dist/result-blob-store-BR-BVZrg.js.map +1 -0
  53. package/dist/{run-cancellation-NMNVuYiO.js → run-cancellation-C9V1lYhq.js} +5 -209
  54. package/dist/run-cancellation-C9V1lYhq.js.map +1 -0
  55. package/dist/run-lock-Y3u9kwM0.js +193 -0
  56. package/dist/run-lock-Y3u9kwM0.js.map +1 -0
  57. package/dist/run-reopen-CHYTHk7x.js +134 -0
  58. package/dist/run-reopen-CHYTHk7x.js.map +1 -0
  59. package/dist/run-state-DgKo8_tO.js +180 -0
  60. package/dist/run-state-DgKo8_tO.js.map +1 -0
  61. package/dist/{runtime-DYaRDLKn.js → runtime-CdthBQUs.js} +22 -20
  62. package/dist/{runtime-DYaRDLKn.js.map → runtime-CdthBQUs.js.map} +1 -1
  63. package/dist/{search-executor-Drd_N9YO.js → search-executor-Bb0WuI_Z.js} +4 -4
  64. package/dist/{search-executor-Drd_N9YO.js.map → search-executor-Bb0WuI_Z.js.map} +1 -1
  65. package/dist/{server-Dk9B1WFf.js → server-BCtyL7jH.js} +3 -3
  66. package/dist/{server-Dk9B1WFf.js.map → server-BCtyL7jH.js.map} +1 -1
  67. package/dist/{settle-record-YdkkHzqw.js → settle-record-Beh-sXBW.js} +5 -4
  68. package/dist/settle-record-Beh-sXBW.js.map +1 -0
  69. package/dist/{structural-rollout-DbZAkHTq.js → structural-rollout-BRfSDPkv.js} +5 -5
  70. package/dist/{structural-rollout-DbZAkHTq.js.map → structural-rollout-BRfSDPkv.js.map} +1 -1
  71. package/dist/{supervise-B5hb0my3.js → supervise-DTUYxnoJ.js} +10 -9
  72. package/dist/{supervise-B5hb0my3.js.map → supervise-DTUYxnoJ.js.map} +1 -1
  73. package/dist/supervise-identity-eMF-h1uP.js +210 -0
  74. package/dist/supervise-identity-eMF-h1uP.js.map +1 -0
  75. package/dist/{supervision-discovery-ChkTxilL.js → supervision-discovery-CAUsSDno.js} +3 -3
  76. package/dist/{supervision-discovery-ChkTxilL.js.map → supervision-discovery-CAUsSDno.js.map} +1 -1
  77. package/dist/{supervisor-DpwcTrTh.js → supervisor-BtRRFbgF.js} +32 -187
  78. package/dist/supervisor-BtRRFbgF.js.map +1 -0
  79. package/dist/{supervisor-accounting-QiXnF-EW.js → supervisor-accounting-Cuehs4te.js} +60 -113
  80. package/dist/supervisor-accounting-Cuehs4te.js.map +1 -0
  81. package/dist/supervisor-root-contract-CmFKzPps.js +165 -0
  82. package/dist/supervisor-root-contract-CmFKzPps.js.map +1 -0
  83. package/dist/testing.d.ts +1 -1
  84. package/dist/testing.js +11 -11
  85. package/dist/{top-web-E85Fk8pH.js → top-web-D-wuEVdM.js} +7 -6
  86. package/dist/{top-web-E85Fk8pH.js.map → top-web-D-wuEVdM.js.map} +1 -1
  87. package/dist/tui/bin.js +3 -3
  88. package/dist/tui/index.d.ts +1 -1
  89. package/dist/tui/index.js +2 -2
  90. package/dist/{types-dv295cpm.d.ts → types-PBoTtcbX.d.ts} +15 -2
  91. package/package.json +1 -1
  92. package/dist/driver-control-acknowledgers-ByKwAgCI.js.map +0 -1
  93. package/dist/durable-file-CksURHlH.js +0 -1
  94. package/dist/durable-file-DstVeHcj.js +0 -228
  95. package/dist/durable-file-DstVeHcj.js.map +0 -1
  96. package/dist/jsonl-file-BhuxeejY.js.map +0 -1
  97. package/dist/run-cancellation-NMNVuYiO.js.map +0 -1
  98. package/dist/run-state-COyIVOVb.js +0 -357
  99. package/dist/run-state-COyIVOVb.js.map +0 -1
  100. package/dist/settle-record-YdkkHzqw.js.map +0 -1
  101. package/dist/supervisor-DpwcTrTh.js.map +0 -1
  102. package/dist/supervisor-accounting-QiXnF-EW.js.map +0 -1
@@ -1,25 +1,27 @@
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-QiXnF-EW.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";
7
7
  import { B as turnFailurePolicy, Ct as sandboxEventServedBackend, D as unavailableResumeAt, Dt as parseCodexUsageRecord, E as unavailablePauseMs, F as executorFailureInfra, H as hashJson, M as contentAddress, N as contentRef, O as unavailableSignalOfFailure, Ot as recordValue, R as runtimeFailureRemediationSchema, S as cappedDoublingMs, St as sandboxEventProviderModels, T as reportedResetAt, U as credentialCommandExit, V as turnRemediationOf, W as isCredentialRefusal, X as createBudgetPool, _ as retainedExecutorContext, _t as createSandboxUsageLedger, b as UNAVAILABLE_CODES, bt as notifySandboxEventObserver, c as DISPATCH_NOT_ADMITTED_CODE, ct as sandboxOutputMarker, f as isProvisioningRefusal, ft as extractTransportEventIdentity, gt as createSandboxTurnEventCollector, ht as canonicalSandboxUsageMode, i as runtimeProviderCode, it as createSandboxToolPartState, l as RetainedExecutionPendingError, lt as sandboxProgressEvents, mt as assertSandboxServedModel, n as runtimeFailureCause, p as isSchemaRejection, s as DISPATCH_EXECUTION_CHANGED_CODE, st as sandboxLeafOutputFromEvents, t as reportedFailureCause, u as TRANSPORT_ERROR_CODES, v as retainedExecutorSeamKey, w as printedStatus, wt as sandboxTerminalUsageField, x as UNAVAILABLE_STATUSES, xt as sameModelId, yt as isSandboxTerminalEvent, z as turnFailureOf } from "./failure-cause-DoCCGLDH.js";
8
8
  import { a as errMessage, i as causeChain, l as errorText, n as detachedSnapshot, o as errorHttpStatus, s as errorProperty, t as detachedFrozen, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
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-CqDuBTq-.js";
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";
@@ -4010,7 +4012,7 @@ function newTurnTally() {
4010
4012
  usdKnown: true,
4011
4013
  knownCostSubtotal: 0,
4012
4014
  costProvenance: void 0,
4013
- estimatedCostSubtotal: 0,
4015
+ estimatedCostSubtotal: void 0,
4014
4016
  inputTokens: 0,
4015
4017
  outputTokens: 0
4016
4018
  };
@@ -4141,9 +4143,10 @@ var BridgeSessionLedger = class {
4141
4143
  }
4142
4144
  }
4143
4145
  if (typeof chunk.estimatedCost === "number") {
4144
- const increment = chunk.costScope === "total" ? chunk.estimatedCost - turn.estimatedCostSubtotal : chunk.estimatedCost;
4146
+ const subtotal = turn.estimatedCostSubtotal ?? 0;
4147
+ const increment = chunk.costScope === "total" ? chunk.estimatedCost - subtotal : chunk.estimatedCost;
4145
4148
  if (increment < 0) throw new ValidationError$1("bridgeExecutor: total estimated cost decreased within a turn");
4146
- turn.estimatedCostSubtotal += increment;
4149
+ turn.estimatedCostSubtotal = subtotal + increment;
4147
4150
  this.estimatedUsd += increment;
4148
4151
  this.sawEstimatedUsd = true;
4149
4152
  }
@@ -4192,7 +4195,14 @@ var BridgeSessionLedger = class {
4192
4195
  }
4193
4196
  priceUnreceiptedTurn(providerModel, credentialSource) {
4194
4197
  const { turn } = this;
4195
- const priced = turn.knownCostSubtotal === 0 ? priceUnreceiptedWork({
4198
+ const estimate = credentialSource === "subscription" ? void 0 : turn.estimatedCostSubtotal;
4199
+ const priced = estimate !== void 0 ? {
4200
+ kind: "cost",
4201
+ usd: estimate,
4202
+ usdKnown: false,
4203
+ usdEstimated: estimate,
4204
+ provenance: "catalog-estimate"
4205
+ } : turn.knownCostSubtotal === 0 ? priceUnreceiptedWork({
4196
4206
  inputTokens: turn.inputTokens,
4197
4207
  outputTokens: turn.outputTokens,
4198
4208
  model: this.observedModel ?? providerModel,
@@ -6414,15 +6424,7 @@ function recordLaunch(env, ids, options) {
6414
6424
  dst: ids.TANGLE_RUN_ID,
6415
6425
  attrs: {}
6416
6426
  });
6417
- fenceRunWrite(() => {
6418
- const fd = openSync(join(dir, `${host}.jsonl`), "a", 384);
6419
- try {
6420
- appendFileSync(fd, node);
6421
- appendFileSync(fd, edge);
6422
- } finally {
6423
- closeSync(fd);
6424
- }
6425
- });
6427
+ appendRunLines(join(dir, `${host}.jsonl`), [node, edge], { mode: 384 });
6426
6428
  } catch {}
6427
6429
  }
6428
6430
  // src/runtime/supervise/bridge-executor.ts
@@ -8258,12 +8260,12 @@ var RetainedObservation = class {
8258
8260
  const identity = extractTransportEventIdentity(event);
8259
8261
  const eventId = identity.eventId ?? identity.cursor;
8260
8262
  if (eventId !== void 0) {
8261
- const digest = canonicalCandidateDigest({
8262
- type: event.type,
8263
- data: event.data,
8264
- ...event.usage === void 0 ? {} : { usage: event.usage },
8265
- ...event.normalized === void 0 ? {} : { normalized: event.normalized }
8266
- });
8263
+ const digest = sha256(JSON.stringify([
8264
+ event.type,
8265
+ event.data,
8266
+ event.usage ?? null,
8267
+ event.normalized ?? null
8268
+ ]));
8267
8269
  const prior = this.seenEvents.get(eventId);
8268
8270
  if (prior !== void 0) {
8269
8271
  if (prior !== digest) throw new RetainedRunProviderContractError(`provider replay changed retained event ${eventId}`, { code: "RETAINED_EVENT_DUPLICATE_CHANGED" });
@@ -15842,164 +15844,6 @@ function deadlinePassed(pool, opts) {
15842
15844
  const deadlineMs = pool.readout().deadlineMs;
15843
15845
  return deadlineMs > 0 && (opts.now ?? Date.now)() >= deadlineMs;
15844
15846
  }
15845
- // src/runtime/supervise/supervisor-root-contract.ts
15846
- /** A resumed process may continue only the exact root contract first recorded for this run id. Its
15847
- * budget is the root's, or the one the run's last budget-carrying `reopened` row recorded. */
15848
- function assertResumeContract(events, opts) {
15849
- const recorded = assertResumeLimits(events, opts);
15850
- if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) throw new RuntimeRunStateError(`supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`);
15851
- const receipts = events.filter((event) => event.kind === "materialized" && event.id === opts.runId);
15852
- const expectedReceipt = rootMaterializationReceipt(opts);
15853
- if (expectedReceipt === void 0) {
15854
- if (receipts.length > 1) throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' contains duplicate root materialization evidence`);
15855
- } 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`);
15856
- return recorded;
15857
- }
15858
- /**
15859
- * The limits half of the resume contract: one root identity event, the recorded budget and the
15860
- * reservation policy. A reopen checks them before it archives anything (`durable/run-reopen.ts`);
15861
- * `reopenBudget` is the budget that reopen is about to record, which then replaces the recorded one.
15862
- */
15863
- function assertResumeLimits(events, opts, reopenBudget) {
15864
- const roots = events.filter((event) => event.kind === "spawned" && event.parent === void 0);
15865
- 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}`);
15866
- const recorded = roots[0];
15867
- const reopenedBudget = reopenBudget ?? events.filter((event) => event.kind === "reopened" && event.id === opts.runId && event.budget !== void 0).at(-1)?.budget;
15868
- 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`);
15869
- const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : void 0;
15870
- if (contentAddress(recorded.recursiveAdmission ?? null) !== contentAddress(expectedAdmission ?? null)) throw new RuntimeRunStateError(`supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`);
15871
- return recorded;
15872
- }
15873
- /** Mint root evidence at the trusted composition boundary. A generic in-process Agent root has no
15874
- * executor declaration and remains explicitly unknown rather than inheriting fabricated details. */
15875
- function rootMaterializationReceipt(opts) {
15876
- const declaration = opts.rootMaterialization;
15877
- if (declaration === void 0) return unknownMaterializationReceipt({
15878
- ...opts.rootIdentity?.profileDigest === void 0 ? {} : { authoredProfileDigest: opts.rootIdentity.profileDigest },
15879
- runtime: "inline",
15880
- reason: "root-agent-did-not-report"
15881
- });
15882
- if (declaration.declaration === "deferred") return void 0;
15883
- if (opts.rootIdentity?.profileDigest === void 0) throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' cannot record known root materialization without an exact profileDigest`);
15884
- try {
15885
- return knownMaterializationReceipt({
15886
- authoredProfileDigest: opts.rootIdentity.profileDigest,
15887
- runtime: declaration.runtime,
15888
- declaration: declaration.declaration
15889
- });
15890
- } catch (error) {
15891
- throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' has invalid root materialization evidence`, { cause: error });
15892
- }
15893
- }
15894
- function rootExecutionBindingReceipt(opts, materialization, attemptId) {
15895
- const root = opts.rootMaterialization;
15896
- if (root?.declaration === "deferred") return void 0;
15897
- if (root === void 0) return unknownExecutionBindingReceipt(materialization, attemptId, "root-agent-did-not-report");
15898
- try {
15899
- return knownExecutionBindingReceipt(materialization, {
15900
- attemptId,
15901
- ...root.binding
15902
- });
15903
- } catch (error) {
15904
- throw new RuntimeRunStateError(`supervisor: run '${opts.runId}' has invalid root execution binding`, { cause: error });
15905
- }
15906
- }
15907
- /** Whether a segment changes what the recorded profile runs, apart from the caller's stack. */
15908
- function changesRootProfile(entry) {
15909
- const { stack: _stack, ...current } = entry.current;
15910
- return contentAddress(current) !== contentAddress(entry.registered);
15911
- }
15912
- /**
15913
- * Append one `root-segment` record when the root enters a segment that differs from the one it
15914
- * last ran. The last record's `to` is what it last ran; a resumed run with no record last ran its
15915
- * recorded profile, and a fresh run ran nothing. Every later entry on the same segment appends
15916
- * nothing, so a resume after a dead supervisor or a lost stream is a boundary, not a segment.
15917
- */
15918
- async function recordRootSegment(opts, events, at, fresh) {
15919
- const entry = opts.rootSegment;
15920
- if (entry === void 0) return;
15921
- const records = events.filter((event) => event.kind === "root-segment" && event.id === opts.runId);
15922
- const last = records.at(-1)?.to ?? (fresh ? void 0 : entry.registered);
15923
- if (last !== void 0 && contentAddress(last) === contentAddress(entry.current)) return;
15924
- await opts.journal.appendEvent(opts.runId, {
15925
- kind: "root-segment",
15926
- id: opts.runId,
15927
- ...last === void 0 ? {} : { from: last },
15928
- to: entry.current,
15929
- reason: entry.reason,
15930
- seq: records.length,
15931
- at
15932
- });
15933
- }
15934
- /**
15935
- * Append one `root-reentered` record: this process is supervising a run an earlier process drove.
15936
- * After a host reboot the re-entered root ran two
15937
- * barren continuations and the run settled `no-result-selected`, with three workers still open in
15938
- * the journal and no record that a restart had happened.
15939
- */
15940
- async function recordRootReentered(opts, resumeFrom, at) {
15941
- await opts.journal.appendEvent(opts.runId, {
15942
- kind: "root-reentered",
15943
- id: opts.runId,
15944
- ...reenteredWorkers(resumeFrom, opts.runId),
15945
- seq: resumeFrom.events.filter((event) => event.kind === "root-reentered").length,
15946
- at
15947
- });
15948
- }
15949
- function sameOptionalIdentity(recorded, requested) {
15950
- if (recorded === void 0 || requested === void 0) return recorded === requested;
15951
- return contentAddress(recorded) === contentAddress(requested);
15952
- }
15953
- /**
15954
- * Name the identity fields that actually differ, with both values.
15955
- *
15956
- * The identity is compared as one content address, so a mismatch is a single boolean and the
15957
- * message could only list every field that MIGHT have caused it. A caller then has to diff four
15958
- * digests by hand to learn which one moved, and the common cause — a task file regenerated with
15959
- * one character different — is indistinguishable from a genuinely different profile.
15960
- *
15961
- * Digests are truncated because the prefix identifies them and the full 64 characters push the
15962
- * real content off the end of a terminal line.
15963
- */
15964
- function describeIdentityMismatch(recorded, requested) {
15965
- if (recorded === void 0) return "the recorded root carried no identity but this resume supplies one";
15966
- if (requested === void 0) return "the recorded root carried an identity but this resume supplies none";
15967
- const short = (value) => {
15968
- if (value === void 0) return "(absent)";
15969
- const text = typeof value === "string" ? value : JSON.stringify(value);
15970
- return text.length > 20 ? `${text.slice(0, 20)}…` : text;
15971
- };
15972
- const differing = [
15973
- "profileDigest",
15974
- "taskDigest",
15975
- "candidateDigest",
15976
- "correlation"
15977
- ].filter((field) => contentAddress(recorded[field]) !== contentAddress(requested[field])).map((field) => `${field} recorded ${short(recorded[field])} but resumed with ${short(requested[field])}`);
15978
- if (differing.length === 0) return "the identity objects differ in shape while every known field matches";
15979
- 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)`;
15980
- }
15981
- /** Validate caller-supplied root identity before any journal access. Fresh runs may omit identity,
15982
- * but once supplied it is trusted durable evidence and therefore must be complete and canonical;
15983
- * resumed runs always require it so the prior root can be matched exactly. */
15984
- function assertRootIdentity(opts) {
15985
- const identity = opts.rootIdentity;
15986
- if (identity === void 0) {
15987
- if (opts.resume !== true) return;
15988
- throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' requires an exact rootIdentity with profileDigest and taskDigest`);
15989
- }
15990
- const unknownFields = Object.keys(identity).filter((key) => key !== "profileDigest" && key !== "taskDigest" && key !== "candidateDigest" && key !== "correlation");
15991
- const correlation = identity.correlation;
15992
- 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);
15993
- 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`);
15994
- }
15995
- /** The instant the run's root was journaled — the anchor for both the absolute deadline and the
15996
- * terminal wall-clock `ms`, so a resumed run measures from its ORIGINAL start, not this
15997
- * process's. */
15998
- function rootStartedAtMs(root) {
15999
- const startedAt = Date.parse(root.at);
16000
- if (!Number.isFinite(startedAt)) throw new RuntimeRunStateError(`supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`);
16001
- return startedAt;
16002
- }
16003
15847
  // src/runtime/supervise/run-persistence.ts
16004
15848
  /** One failed store operation revokes this controller's writes, never its retained executions. */
16005
15849
  function guardRunPersistence(journal, blobs, interrupt) {
@@ -16286,7 +16130,8 @@ async function openRunTree(opts, now) {
16286
16130
  return opened;
16287
16131
  }
16288
16132
  async function resumeRunTree(opts, prior, now, runStartedAt, rootAttemptId) {
16289
- const runEpochMs = rootStartedAtMs(assertResumeContract(prior, opts));
16133
+ const rootEvent = assertResumeContract(prior, opts);
16134
+ const runEpochMs = rootStartedAtMs(rootEvent);
16290
16135
  const cancelledAtEntry = opts.signal?.aborted === true && opts.signal.reason instanceof RunCancellationReason;
16291
16136
  const { resumeFrom, poolRestore } = await prepareScopeResume(opts, prior, opts.signal ?? new AbortController().signal, now, opts.runId, cancelledAtEntry);
16292
16137
  const events = [...resumeFrom.events];
@@ -16660,6 +16505,6 @@ async function noWinner(settled, rejection) {
16660
16505
  reason: "no-result-selected"
16661
16506
  };
16662
16507
  }
16663
- 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 };
16664
16509
 
16665
- //# sourceMappingURL=supervisor-DpwcTrTh.js.map
16510
+ //# sourceMappingURL=supervisor-BtRRFbgF.js.map