@tangle-network/agent-runtime 6.0.8 → 7.0.0

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 (78) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +23 -9
  3. package/dist/{activation-Cwy3_Qn_.js → activation-Ba9IAgQ3.js} +2 -2
  4. package/dist/{activation-Cwy3_Qn_.js.map → activation-Ba9IAgQ3.js.map} +1 -1
  5. package/dist/{activation-CWx7I1PU.d.ts → activation-DIkTEBWF.d.ts} +2 -2
  6. package/dist/agent.d.ts +1 -1
  7. package/dist/agent.js +3 -3
  8. package/dist/{coordination-manager-D9z7To7p.js → coordination-manager-DQZ2u6L-.js} +58 -6
  9. package/dist/coordination-manager-DQZ2u6L-.js.map +1 -0
  10. package/dist/{delegate-ws-KBA2H.js → delegate-DFLSVjFG.js} +2 -2
  11. package/dist/{delegate-ws-KBA2H.js.map → delegate-DFLSVjFG.js.map} +1 -1
  12. package/dist/durable.d.ts +71 -4
  13. package/dist/durable.js +158 -10
  14. package/dist/durable.js.map +1 -1
  15. package/dist/{failure-cause-BzjUUsRz.js → failure-cause-rJTm_Tx8.js} +6 -9
  16. package/dist/failure-cause-rJTm_Tx8.js.map +1 -0
  17. package/dist/{graph-2_nX4ib4.js → graph-BjQF2syl.js} +6 -6
  18. package/dist/{graph-2_nX4ib4.js.map → graph-BjQF2syl.js.map} +1 -1
  19. package/dist/{improve-BxfqTsZy.js → improve-BolbYegO.js} +6 -6
  20. package/dist/{improve-BxfqTsZy.js.map → improve-BolbYegO.js.map} +1 -1
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +10 -10
  23. package/dist/intelligence.d.ts +2 -2
  24. package/dist/intelligence.js +4 -4
  25. package/dist/kernel.d.ts +2 -2
  26. package/dist/kernel.js +13 -13
  27. package/dist/{loop-runner-BmGZ4y1W.js → loop-runner-C9W3T_3T.js} +2 -2
  28. package/dist/{loop-runner-BmGZ4y1W.js.map → loop-runner-C9W3T_3T.js.map} +1 -1
  29. package/dist/{loop-runner-CUMypgRw.d.ts → loop-runner-Cs9IJ6Nk.d.ts} +2 -2
  30. package/dist/loop-runner-bin.d.ts +1 -1
  31. package/dist/loop-runner-bin.js +1 -1
  32. package/dist/mcp/bin.js +3 -3
  33. package/dist/mcp/index.d.ts +1 -1
  34. package/dist/mcp/index.js +6 -6
  35. package/dist/mcp/memory-bin.js +1 -1
  36. package/dist/profiles.d.ts +1 -1
  37. package/dist/{provision-supervisor-CeQTPHRr.js → provision-supervisor-BQFHjCtN.js} +5 -5
  38. package/dist/{provision-supervisor-CeQTPHRr.js.map → provision-supervisor-BQFHjCtN.js.map} +1 -1
  39. package/dist/{run-cancellation-D_4vJ522.js → run-cancellation-B84X8ZAP.js} +2 -2
  40. package/dist/{run-cancellation-D_4vJ522.js.map → run-cancellation-B84X8ZAP.js.map} +1 -1
  41. package/dist/{run-state-CTZVngI_.js → run-state-Dh1bGERI.js} +6 -6
  42. package/dist/{run-state-CTZVngI_.js.map → run-state-Dh1bGERI.js.map} +1 -1
  43. package/dist/{runtime-COm9uBBx.js → runtime-C9F1PG2A.js} +13 -13
  44. package/dist/{runtime-COm9uBBx.js.map → runtime-C9F1PG2A.js.map} +1 -1
  45. package/dist/{search-executor-DTEIl58w.js → search-executor-CKR9_6NR.js} +4 -4
  46. package/dist/{search-executor-DTEIl58w.js.map → search-executor-CKR9_6NR.js.map} +1 -1
  47. package/dist/{server-zO9Nz9Nk.js → server-Dh3SQGQT.js} +4 -4
  48. package/dist/{server-zO9Nz9Nk.js.map → server-Dh3SQGQT.js.map} +1 -1
  49. package/dist/{settle-record-U7fkQEZa.js → settle-record-C6LdVvok.js} +12 -4
  50. package/dist/settle-record-C6LdVvok.js.map +1 -0
  51. package/dist/{structural-rollout-BwTwTUXF.js → structural-rollout-Dapf2aZY.js} +25 -7
  52. package/dist/structural-rollout-Dapf2aZY.js.map +1 -0
  53. package/dist/{supervise-tmqDU6YT.js → supervise-xwl2D6q3.js} +9 -7
  54. package/dist/{supervise-tmqDU6YT.js.map → supervise-xwl2D6q3.js.map} +1 -1
  55. package/dist/{supervision-discovery-CGbXayGv.js → supervision-discovery-B47U8TH5.js} +3 -3
  56. package/dist/{supervision-discovery-CGbXayGv.js.map → supervision-discovery-B47U8TH5.js.map} +1 -1
  57. package/dist/{scope-gIYQ5ZiL.js → supervisor-accounting-DxLQ_TQe.js} +330 -44
  58. package/dist/supervisor-accounting-DxLQ_TQe.js.map +1 -0
  59. package/dist/{supervisor-1A27fE6k.js → supervisor-gC-u_PRk.js} +11 -314
  60. package/dist/supervisor-gC-u_PRk.js.map +1 -0
  61. package/dist/testing.d.ts +1 -1
  62. package/dist/testing.js +11 -11
  63. package/dist/{tool-server-B9q2dtnW.js → tool-server-Dg350Bgz.js} +2 -2
  64. package/dist/{tool-server-B9q2dtnW.js.map → tool-server-Dg350Bgz.js.map} +1 -1
  65. package/dist/{top-web-CS4PD4ck.js → top-web-BJLnFQdr.js} +6 -6
  66. package/dist/{top-web-CS4PD4ck.js.map → top-web-BJLnFQdr.js.map} +1 -1
  67. package/dist/tui/bin.js +6 -6
  68. package/dist/tui/bin.js.map +1 -1
  69. package/dist/tui/index.d.ts +1 -1
  70. package/dist/tui/index.js +2 -2
  71. package/dist/{types-w3Oo1uRJ.d.ts → types-Jg274chm.d.ts} +153 -309
  72. package/package.json +1 -1
  73. package/dist/coordination-manager-D9z7To7p.js.map +0 -1
  74. package/dist/failure-cause-BzjUUsRz.js.map +0 -1
  75. package/dist/scope-gIYQ5ZiL.js.map +0 -1
  76. package/dist/settle-record-U7fkQEZa.js.map +0 -1
  77. package/dist/structural-rollout-BwTwTUXF.js.map +0 -1
  78. package/dist/supervisor-1A27fE6k.js.map +0 -1
@@ -1,15 +1,15 @@
1
- import { $ as hasRetriableTeardowns, $r as linkAbort, An as mergeTraceEnv, Ar as recordRuntimeOwnedProviderModel, Br as executableAgentProfileSnapshot, Cr as knownMaterializationReceipt, D as prepareScopeResume, Dn as workerTraceEnv, Dr as recordRuntimeOwnedProviderAttemptStart, E as resolveWorkerSlots, En as WORKER_TRACE_PROPAGATION, Gr as RetainedRunProviderContractError, Ht as scopeRetainedOwnerCheckpointing, Ir as runtimeOwnedScopeOwnerControl, It as scopeRetainedOwnerSettled, Jn as harnessTranscriptFromLines, Jr as exactSession, Jt as ownedTreeRootSpawn, K as assertRecursiveReservationPolicy, Kn as captureHarnessTranscript, Kr as assertEventBinding, Lr as runtimeOwnedScopeOwnerRuntime, Mr as runtimeOwnedExecutorExecutionBinding, N as nestedScopeSeamKey, Nr as runtimeOwnedExecutorMaterialization, O as sumSpendFromEvents, On as workerTraceHeaders, Or as recordRuntimeOwnedProviderDispatchNotStarted, Q as closeScopeAdmission, Qr as abortReason, Qt as nestedDriverTreeRoot, Rr as unknownExecutionBindingReceipt, Sr as knownExecutionBindingReceipt, Tn as environmentGone, Tt as finalizeScopeOwnerMaterialization, U as appendTeardownConfirmation, V as appendSpawnEvents, Vr as executableAgentSpecSnapshot, W as reenteredWorkers, Wn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, Wt as bindScopeRetainedOwnerProvider, Xr as sameControlCoordinates, Xt as attestNestedDriverTreeOwner, Yn as harnessTranscriptUnavailable, Yr as freezeControlRef, Z as closeRetainedSlots, Zr as RunCancellationReason, Zt as driverRuntime, br as finalizeRuntimeOwnedPendingExecutor, cn as stopRetainedNativeExecution, ct as releaseRetainedEnvironments, dn as mintRetainedIdentity, dt as startScopeRecoveries, ei as runAbortable, en as encodeResultBlob, fn as reconnectRetainedRun, ft as unconfirmedTeardowns, gr as attestRuntimeOwnedPendingExecutor, hr as attestRuntimeOwnedExecutor, in as executorObservation, ir as describeToolArgs, kr as recordRuntimeOwnedProviderIdentityConflict, ln as verifyWorkspaceMarker, lt as retryUnconfirmedTeardowns, mn as startRetainedRun, mr as attestRuntimeOwnedDeferredExecutor, nn as closesCursorSlot, on as observeModelRequest, or as isLiveNodeStatus, ot as registerNestedTeardownScope, pn as recoverRetainedRun, pr as subscriptionUsageLimitSignal, pt as waitForScopeChildren, qr as awaitAbortable, qt as loadSpawnForest, ri as promptOptionsFromAgentTurnInput, rr as createActivityLog, sn as describeRetainedNativeStops, st as releaseHeldEnvironments, t as createScope, tn as SpawnEventIndex, un as assertRetainedRunReplayMaterial, ut as settleManagerWork, wr as newExecutionAttemptId, xr as inheritRuntimeOwnedExecutorAttestation, zr as unknownMaterializationReceipt } from "./scope-gIYQ5ZiL.js";
1
+ import { $ as closeScopeAdmission, $r as linkAbort, $t as nestedDriverTreeRoot, An as mergeTraceEnv, Ar as recordRuntimeOwnedProviderModel, Br as executableAgentProfileSnapshot, Cr as knownMaterializationReceipt, Dn as workerTraceEnv, Dr as recordRuntimeOwnedProviderAttemptStart, En as WORKER_TRACE_PROPAGATION, Et as finalizeScopeOwnerMaterialization, G as reenteredWorkers, Gr as RetainedRunProviderContractError, Gt as bindScopeRetainedOwnerProvider, H as appendSpawnEvents, Ir as runtimeOwnedScopeOwnerControl, Jn as harnessTranscriptFromLines, Jr as exactSession, Jt as loadSpawnForest, Kn as captureHarnessTranscript, Kr as assertEventBinding, Lr as runtimeOwnedScopeOwnerRuntime, Lt as scopeRetainedOwnerSettled, Mr as runtimeOwnedExecutorExecutionBinding, Nr as runtimeOwnedExecutorMaterialization, O as resolveWorkerSlots, On as workerTraceHeaders, Or as recordRuntimeOwnedProviderDispatchNotStarted, P as nestedScopeSeamKey, Q as closeRetainedSlots, Qr as abortReason, Qt as driverRuntime, Rr as unknownExecutionBindingReceipt, Sr as knownExecutionBindingReceipt, Tn as environmentGone, Ut as scopeRetainedOwnerCheckpointing, Vr as executableAgentSpecSnapshot, W as appendTeardownConfirmation, Wn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, Xr as sameControlCoordinates, Yn as harnessTranscriptUnavailable, Yr as freezeControlRef, Yt as ownedTreeRootSpawn, Zr as RunCancellationReason, Zt as attestNestedDriverTreeOwner, br as finalizeRuntimeOwnedPendingExecutor, cn as stopRetainedNativeExecution, ct as releaseHeldEnvironments, dn as mintRetainedIdentity, dt as settleManagerWork, ei as runAbortable, et as hasRetriableTeardowns, fn as reconnectRetainedRun, ft as startScopeRecoveries, gr as attestRuntimeOwnedPendingExecutor, hr as attestRuntimeOwnedExecutor, in as executorObservation, ir as describeToolArgs, k as prepareScopeResume, kr as recordRuntimeOwnedProviderIdentityConflict, ln as verifyWorkspaceMarker, lt as releaseRetainedEnvironments, mn as startRetainedRun, mr as attestRuntimeOwnedDeferredExecutor, mt as waitForScopeChildren, n as terminalAccounting, nn as SpawnEventIndex, on as observeModelRequest, or as isLiveNodeStatus, pn as recoverRetainedRun, pr as subscriptionUsageLimitSignal, pt as unconfirmedTeardowns, q as assertRecursiveReservationPolicy, qr as awaitAbortable, r as createScope, ri as promptOptionsFromAgentTurnInput, rr as createActivityLog, sn as describeRetainedNativeStops, st as registerNestedTeardownScope, t as isNonEmptySpend, tn as encodeResultBlob, un as assertRetainedRunReplayMaterial, ut as retryUnconfirmedTeardowns, wr as newExecutionAttemptId, xr as inheritRuntimeOwnedExecutorAttestation, zr as unknownMaterializationReceipt } from "./supervisor-accounting-DxLQ_TQe.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-AzSuGI23.js";
3
- import { A as withBudgetResources, C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, F as ROOT_DEADLINE_REASON, H as teardownSurfaces, I as armDeadlineTimer, 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, j as ACCEPTED_RESULT_GRACE_MS, 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, z as isDeadlineAbortReason } from "./util-C_cdPNC4.js";
3
+ import { C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, F as ROOT_DEADLINE_REASON, H as teardownSurfaces, I as armDeadlineTimer, 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, j as ACCEPTED_RESULT_GRACE_MS, 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, z as isDeadlineAbortReason } from "./util-C_cdPNC4.js";
4
4
  import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
5
- import { B as credentialCommandExit, Ct as parseCodexUsageRecord, D as unavailableResumeAt, E as unavailablePauseMs, F as executorFailureInfra, L as turnFailureOf, M as contentAddress, N as contentRef, O as unavailableSignalOfFailure, R as turnFailurePolicy, T as reportedResetAt, V as isCredentialRefusal, _t as notifySandboxEventObserver, a as runtimeProviderCode, at as sandboxOutputMarker, b as UNAVAILABLE_CODES, bt as sandboxTerminalUsageField, c as DISPATCH_EXECUTION_CHANGED_CODE, d as TRANSPORT_ERROR_CODES, dt as assertSandboxServedModel, ft as canonicalSandboxUsageMode, gt as isSandboxTerminalEvent, i as runtimeFailureRemediationSchema, it as sandboxLeafOutputFromEvents, l as DISPATCH_NOT_ADMITTED_CODE, lt as extractTransportEventIdentity, m as isSchemaRejection, mt as createSandboxUsageLedger, n as runtimeFailureCause, ot as sandboxProgressEvents, p as isProvisioningRefusal, pt as createSandboxTurnEventCollector, q as createBudgetPool, t as reportedFailureCause, tt as createSandboxToolPartState, u as RetainedExecutionPendingError, v as retainedExecutorContext, vt as sameModelId, w as printedStatus, wt as recordValue, x as UNAVAILABLE_STATUSES, y as retainedExecutorSeamKey, yt as sandboxEventServedBackend, z as hashJson } from "./failure-cause-BzjUUsRz.js";
5
+ import { B as credentialCommandExit, Ct as parseCodexUsageRecord, D as unavailableResumeAt, E as unavailablePauseMs, F as executorFailureInfra, L as turnFailureOf, M as contentAddress, N as contentRef, O as unavailableSignalOfFailure, R as turnFailurePolicy, T as reportedResetAt, V as isCredentialRefusal, _t as notifySandboxEventObserver, a as runtimeProviderCode, at as sandboxOutputMarker, b as UNAVAILABLE_CODES, bt as sandboxTerminalUsageField, c as DISPATCH_EXECUTION_CHANGED_CODE, d as TRANSPORT_ERROR_CODES, dt as assertSandboxServedModel, ft as canonicalSandboxUsageMode, gt as isSandboxTerminalEvent, i as runtimeFailureRemediationSchema, it as sandboxLeafOutputFromEvents, l as DISPATCH_NOT_ADMITTED_CODE, lt as extractTransportEventIdentity, m as isSchemaRejection, mt as createSandboxUsageLedger, n as runtimeFailureCause, ot as sandboxProgressEvents, p as isProvisioningRefusal, pt as createSandboxTurnEventCollector, q as createBudgetPool, t as reportedFailureCause, tt as createSandboxToolPartState, u as RetainedExecutionPendingError, v as retainedExecutorContext, vt as sameModelId, w as printedStatus, wt as recordValue, x as UNAVAILABLE_STATUSES, y as retainedExecutorSeamKey, yt as sandboxEventServedBackend, z as hashJson } from "./failure-cause-rJTm_Tx8.js";
6
6
  import { a as errMessage, c as errorText, i as causeChain, l as defaultRedactor, n as detachedSnapshot, o as errorHttpStatus, s as errorProperty } from "./snapshot-Cgj2Wzi6.js";
7
7
  import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, h as observedModelHasSnapshot, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy } from "./model-policy-JOcg3NRs.js";
8
8
  import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-oFGWESLn.js";
9
9
  import { l as sha256 } from "./jsonl-file-DsxVI0E_.js";
10
10
  import { V as hasControlCharacter } from "./workspace-streams-B7yNMahl.js";
11
11
  import { a as writeAtomicDurableFile, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
12
- import { t as PROTOCOL_VERSION } from "./tool-server-B9q2dtnW.js";
12
+ import { t as PROTOCOL_VERSION } from "./tool-server-Dg350Bgz.js";
13
13
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
14
14
  import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema } from "@tangle-network/agent-interface";
15
15
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
@@ -15583,312 +15583,6 @@ function parkingRecordOf(record) {
15583
15583
  wakeAt: record.wakeAt
15584
15584
  };
15585
15585
  }
15586
- // src/durable/spawn-journal/provider-model-evidence.ts
15587
- /**
15588
- * Aggregate provider-served model evidence across one recursively owned journal forest.
15589
- *
15590
- * The parent tree records an owned driver's terminal summary, while that driver's own inference
15591
- * and descendants live in its owned tree. This reducer follows the forest reader's explicit tree
15592
- * edges and consumes each tree's metered attempts plus terminal leaf settlements exactly once.
15593
- * A summary node is skipped because its owned tree supplies the source records. Plan materialization
15594
- * is intentionally not read: it proves only what Runtime requested, not what a provider served.
15595
- *
15596
- * Missing legacy evidence, an unfinished node, an unopened owned tree, an identity conflict, and a
15597
- * paid attempt without a qualified served snapshot all return unknown. An explicit
15598
- * `providerDispatch: "not_started"` arm and Runtime accounting-only metered records are ignored
15599
- * for served-model identity, while absent or malformed legacy data remains unknown here.
15600
- */
15601
- function aggregateProviderModelEvidence(forest) {
15602
- const attempts = [];
15603
- const observedModels = /* @__PURE__ */ new Set();
15604
- const canonicalModels = /* @__PURE__ */ new Set();
15605
- const nodes = /* @__PURE__ */ new Map();
15606
- let reason;
15607
- let sawProviderEvidence = false;
15608
- for (const node of forest.nodes) nodes.set(forestNodeKey(node.treeRoot, node.id), node);
15609
- if (forest.missingTrees.length > 0 || forest.inDoubt.length > 0) reason = "provider-model-missing";
15610
- const markMissing = () => {
15611
- reason ??= "provider-model-missing";
15612
- };
15613
- const markConflict = () => {
15614
- reason = "provider-model-conflict";
15615
- };
15616
- const append = (raw) => {
15617
- sawProviderEvidence = true;
15618
- if (!isProviderEvidenceObject(raw)) {
15619
- markMissing();
15620
- return;
15621
- }
15622
- if (raw.status === "unknown") {
15623
- if (raw.reason === "provider-model-conflict") markConflict();
15624
- else if (!hasOnlyNotStartedAttempts(raw)) markMissing();
15625
- } else if (raw.status !== "known") {
15626
- markMissing();
15627
- return;
15628
- }
15629
- if (!Array.isArray(raw.attempts) || !Array.isArray(raw.models)) {
15630
- markMissing();
15631
- return;
15632
- }
15633
- const declared = /* @__PURE__ */ new Set();
15634
- for (const model of raw.models) if (typeof model !== "string" || model.length === 0) markMissing();
15635
- else declared.add(model);
15636
- const observedInRecord = /* @__PURE__ */ new Set();
15637
- for (const rawAttempt of raw.attempts) {
15638
- if (!isProviderAttemptEvidence(rawAttempt)) {
15639
- markMissing();
15640
- continue;
15641
- }
15642
- if (rawAttempt.identityConflict === true) markConflict();
15643
- const observations = [...rawAttempt.observations];
15644
- if (rawAttempt.providerDispatch === "not_started") {
15645
- if (observations.length > 0) markMissing();
15646
- attempts.push(Object.freeze({
15647
- observations: Object.freeze([]),
15648
- providerDispatch: "not_started",
15649
- ...rawAttempt.identityConflict === true ? { identityConflict: true } : {}
15650
- }));
15651
- continue;
15652
- }
15653
- if (observations.length === 0) {
15654
- markMissing();
15655
- attempts.push(Object.freeze({
15656
- observations: Object.freeze([]),
15657
- ...rawAttempt.identityConflict === true ? { identityConflict: true } : {}
15658
- }));
15659
- continue;
15660
- }
15661
- let base;
15662
- let snapshot;
15663
- for (const model of observations) {
15664
- if (typeof model !== "string" || model.length === 0) {
15665
- markMissing();
15666
- continue;
15667
- }
15668
- observedInRecord.add(model);
15669
- observedModels.add(model);
15670
- const identity = servedIdentityParts(model);
15671
- if (identity === void 0) {
15672
- markMissing();
15673
- continue;
15674
- }
15675
- if (base !== void 0 && base !== identity.base) markConflict();
15676
- if (snapshot !== void 0 && identity.snapshot !== void 0 && snapshot !== identity.snapshot) markConflict();
15677
- base = identity.base;
15678
- snapshot ??= identity.snapshot;
15679
- if (identity.snapshot !== void 0) {
15680
- canonicalModels.add(`${identity.base}@${identity.snapshot}`);
15681
- if (canonicalModels.size > 1) markConflict();
15682
- }
15683
- }
15684
- if (base === void 0 || snapshot === void 0) markMissing();
15685
- attempts.push(Object.freeze({
15686
- observations: Object.freeze(observations),
15687
- ...rawAttempt.identityConflict === true ? { identityConflict: true } : {}
15688
- }));
15689
- }
15690
- if (declared.size !== observedInRecord.size || [...declared].some((model) => !observedInRecord.has(model))) markMissing();
15691
- };
15692
- const terminal = (treeRoot, event) => {
15693
- const node = nodes.get(forestNodeKey(treeRoot, event.id));
15694
- if (node === void 0) {
15695
- markMissing();
15696
- return;
15697
- }
15698
- if (node.ownedTreeRoot !== void 0) return;
15699
- if (event.kind === "cancelled" && event.providerModel === void 0) {
15700
- markMissing();
15701
- return;
15702
- }
15703
- append(event.providerModel ?? node.providerModel);
15704
- };
15705
- for (const tree of forest.trees) for (const event of tree.events) if (event.kind === "metered") {
15706
- if (event.accountingOnly === true) {
15707
- if (event.providerModel !== void 0) markMissing();
15708
- continue;
15709
- }
15710
- if (nodes.get(forestNodeKey(tree.root, event.id))?.ownedTreeRoot !== void 0) continue;
15711
- const evidence = event.providerModel;
15712
- if (evidence === void 0) markMissing();
15713
- else append(evidence);
15714
- } else if (event.kind === "settled" || event.kind === "cancelled") terminal(tree.root, event);
15715
- if (!sawProviderEvidence || attempts.length === 0 || observedModels.size === 0) reason ??= "provider-model-missing";
15716
- const models = Object.freeze([...observedModels]);
15717
- const frozenAttempts = Object.freeze(attempts);
15718
- return Object.freeze(reason === void 0 ? {
15719
- status: "known",
15720
- attempts: frozenAttempts,
15721
- models
15722
- } : {
15723
- status: "unknown",
15724
- attempts: frozenAttempts,
15725
- models,
15726
- reason
15727
- });
15728
- }
15729
- function forestNodeKey(treeRoot, nodeId) {
15730
- return `${treeRoot}\u0000${nodeId}`;
15731
- }
15732
- function isProviderEvidenceObject(value) {
15733
- return typeof value === "object" && value !== null && !Array.isArray(value) && "status" in value;
15734
- }
15735
- function hasOnlyNotStartedAttempts(evidence) {
15736
- return Array.isArray(evidence.attempts) && evidence.attempts.length > 0 && evidence.attempts.every((attempt) => isProviderAttemptEvidence(attempt) && attempt.providerDispatch === "not_started" && attempt.observations.length === 0 && attempt.identityConflict !== true);
15737
- }
15738
- function isProviderAttemptEvidence(value) {
15739
- return typeof value === "object" && value !== null && !Array.isArray(value) && Array.isArray(value.observations) && (value.providerDispatch === void 0 || value.providerDispatch === "not_started");
15740
- }
15741
- function servedIdentityParts(model) {
15742
- const at = model.lastIndexOf("@");
15743
- const rawBase = at < 0 ? model : model.slice(0, at);
15744
- const base = rawBase.slice(rawBase.lastIndexOf("/") + 1);
15745
- if (base.length === 0) return void 0;
15746
- const snapshot = at < 0 ? void 0 : model.slice(at + 1);
15747
- if (snapshot !== void 0 && snapshot.length === 0) return void 0;
15748
- return snapshot === void 0 ? { base } : {
15749
- base,
15750
- snapshot
15751
- };
15752
- }
15753
- // src/runtime/supervise/supervisor-accounting.ts
15754
- /**
15755
- * The run's terminal accounting, read off the one journal ledger — the honest per-channel
15756
- * sums (input/output/usd/iterations all preserved), the named usage gaps, and the wall-clock
15757
- * duration stamped onto `spentTotal.ms`. Computed AFTER the join barrier so every child's
15758
- * settlement is recorded. Fails loud if the tree was never journaled (the supervisor always
15759
- * `beginTree`s, so a missing tree is a corrupted journal, not a normal path).
15760
- *
15761
- * `spentTotal.ms` is `elapsedMs`, never the per-event sum: executors under-report their own
15762
- * `ms` (most stamp 0) and parallel children overlap, so the sum cannot state the run's real
15763
- * duration. The breakdown keeps the executor-reported sums.
15764
- *
15765
- * `tokensKnown`/`usdKnown` are stamped explicitly on the terminal total: `true` is a checked
15766
- * claim (every spawn reached a terminal record AND every settled/metered record carried a
15767
- * complete receipt on that channel), never the absence of bad news. The conjunction with the
15768
- * summed flags is deliberately redundant — a future divergence between the sum and the gap
15769
- * scan can only make the claim more conservative, never falsely `true`.
15770
- */
15771
- async function terminalAccounting(journal, root, elapsedMs) {
15772
- const events = await journal.loadTree(root);
15773
- if (events === void 0) throw new RuntimeRunStateError(`supervisor: spawn tree '${root}' is missing from the journal after run (corrupted log)`);
15774
- const { childWork, driverInference } = sumSpendFromEvents(events);
15775
- const gaps = spendGapsFromEvents(events);
15776
- const forest = await loadSpawnForest(journal, root);
15777
- const providerModel = aggregateProviderModelEvidence(forest);
15778
- const fleetYield = fleetYieldFromForest(forest);
15779
- const summed = addSpend(childWork, driverInference);
15780
- return {
15781
- spentTotal: {
15782
- ...summed,
15783
- ms: Math.max(0, elapsedMs),
15784
- tokensKnown: summed.tokensKnown !== false && !gaps.some((gap) => gap.channels.includes("tokens")),
15785
- usdKnown: summed.usdKnown !== false && !gaps.some((gap) => gap.channels.includes("usd"))
15786
- },
15787
- childWork,
15788
- driverInference,
15789
- gaps,
15790
- providerModel,
15791
- fleetYield
15792
- };
15793
- }
15794
- /** How the run's spawned children ended, by node id across every tree of the forest. Read after
15795
- * the join barrier and the release sweep, so the terminal records the sweep wrote are in it.
15796
- * Spawned records without a parent are exempt: the run root, and the re-rooted owner copy a
15797
- * nested driver writes as its tree's first record (`ownedTreeRootSpawn` strips the parent), so
15798
- * a manager is counted once, in its parent's tree. Buckets are id sets rather than record counts
15799
- * because the journal guards seq uniqueness, not one-terminal-per-node, and the invariant
15800
- * `spawned === done + down + cancelled + neverSettled` must not rest on scope discipline alone;
15801
- * it is asserted here so a future root-id terminal record cannot silently break the tally. */
15802
- function fleetYieldFromForest(forest) {
15803
- const spawned = /* @__PURE__ */ new Set();
15804
- const terminal = /* @__PURE__ */ new Map();
15805
- const released = /* @__PURE__ */ new Set();
15806
- const unconfirmed = /* @__PURE__ */ new Set();
15807
- for (const { event } of forest.events) if (event.kind === "spawned") {
15808
- if (event.parent !== void 0) spawned.add(event.id);
15809
- } else if (event.kind === "settled" || event.kind === "cancelled") {
15810
- const bucket = event.kind === "cancelled" ? "cancelled" : event.status;
15811
- terminal.set(event.id, bucket);
15812
- released.delete(event.id);
15813
- unconfirmed.delete(event.id);
15814
- if (bucket !== "done" && event.retainedExecution === "released") released.add(event.id);
15815
- if (bucket !== "done" && event.retainedExecution === "release-unconfirmed") unconfirmed.add(event.id);
15816
- }
15817
- const count = (bucket) => [...terminal.values()].filter((value) => value === bucket).length;
15818
- const fleetYield = {
15819
- spawned: spawned.size,
15820
- done: count("done"),
15821
- down: count("down"),
15822
- cancelled: count("cancelled"),
15823
- neverSettled: forest.inDoubt.length,
15824
- releasedUnrecovered: released.size,
15825
- releaseUnconfirmed: unconfirmed.size
15826
- };
15827
- if (fleetYield.done + fleetYield.down + fleetYield.cancelled + fleetYield.neverSettled !== fleetYield.spawned) throw new RuntimeRunStateError(`supervisor: fleet yield does not partition the spawned children of '${forest.root}' (${JSON.stringify(fleetYield)})`);
15828
- if (fleetYield.releasedUnrecovered + fleetYield.releaseUnconfirmed > fleetYield.down + fleetYield.cancelled) throw new RuntimeRunStateError(`supervisor: released children exceed down + cancelled for '${forest.root}' (${JSON.stringify(fleetYield)})`);
15829
- return fleetYield;
15830
- }
15831
- /** The journaled nodes whose usage accounting is incomplete — one `SpendGap` per node+kind,
15832
- * channels merged. A spawn with no terminal record (`settled`/`cancelled`/`woken`) is
15833
- * unaccounted on every channel; a settled or metered record that flags a channel unknown is
15834
- * a floor on that channel. The root's own spawned event is exempt: its terminal state is the
15835
- * result this list rides on. */
15836
- function spendGapsFromEvents(events) {
15837
- const labels = /* @__PURE__ */ new Map();
15838
- const budgets = /* @__PURE__ */ new Map();
15839
- const terminal = /* @__PURE__ */ new Set();
15840
- for (const ev of events) if (ev.kind === "spawned") {
15841
- labels.set(ev.id, ev.label);
15842
- budgets.set(ev.id, ev.budget);
15843
- } else if (closesCursorSlot(ev)) terminal.add(ev.id);
15844
- const gaps = /* @__PURE__ */ new Map();
15845
- const record = (id, kind, channels) => {
15846
- if (channels.length === 0) return;
15847
- const key = `${kind}:${id}`;
15848
- const existing = gaps.get(key);
15849
- if (existing !== void 0) for (const channel of channels) existing.channels.add(channel);
15850
- else gaps.set(key, {
15851
- id,
15852
- kind,
15853
- channels: new Set(channels)
15854
- });
15855
- };
15856
- for (const ev of events) if (ev.kind === "spawned" && ev.parent !== void 0 && !terminal.has(ev.id)) record(ev.id, "never-settled", [
15857
- "tokens",
15858
- "usd",
15859
- ...Object.keys(ev.budget.resources ?? {}).map((name) => `resource:${name}`)
15860
- ]);
15861
- else if (ev.kind === "cancelled" && ev.spent === void 0) record(ev.id, "unreported", [
15862
- "tokens",
15863
- "usd",
15864
- ...Object.keys(budgets.get(ev.id)?.resources ?? {}).map((name) => `resource:${name}`)
15865
- ]);
15866
- else if (ev.kind === "settled" || ev.kind === "cancelled" && ev.spent !== void 0) record(ev.id, "unreported", unknownChannels(withBudgetResources(ev.spent, budgets.get(ev.id) ?? {})));
15867
- else if (ev.kind === "metered") record(ev.id, "unreported", unknownChannels(ev.spend));
15868
- return [...gaps.values()].map((gap) => {
15869
- const label = labels.get(gap.id);
15870
- return {
15871
- id: gap.id,
15872
- ...label !== void 0 ? { label } : {},
15873
- kind: gap.kind,
15874
- channels: [...gap.channels]
15875
- };
15876
- });
15877
- }
15878
- /** The channels a single spend record explicitly marks incomplete. */
15879
- function unknownChannels(spend) {
15880
- const channels = [];
15881
- if (spend.tokensKnown === false) channels.push("tokens");
15882
- if (spend.usdKnown === false) channels.push("usd");
15883
- for (const [name, resource] of Object.entries(spend.resources ?? {})) if (!resource.known) channels.push(`resource:${name}`);
15884
- return channels;
15885
- }
15886
- /** True when any driver metered inference this run (so the winner carries a `spentBreakdown`).
15887
- * Checks every channel `addSpend` sums — including `ms` — so the gate stays consistent with the
15888
- * total even though the coordination driver currently stamps `ms: 0`. */
15889
- function isNonEmptySpend(s) {
15890
- return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
15891
- }
15892
15586
  // src/runtime/supervise/supervisor-child-join.ts
15893
15587
  /**
15894
15588
  * Drain the root scope's live set so every still-running/acquiring child is torn down
@@ -16324,13 +16018,14 @@ function guardRunPersistence(journal, blobs, interrupt) {
16324
16018
  /** Read every caller-owned field once, then detach and freeze all decision data before the first
16325
16019
  * await; stateful collaborators stay live by reference, but later opts mutation cannot redirect the run. */
16326
16020
  function admitSupervisorRun(task, opts) {
16327
- const { budget, rootIdentity, rootSegment, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, maxDepth, workerSlots, reservationPolicy, deadlineCheckIn, budgetStopHoldMs, maxRestarts, withinMs, childSettleGraceMs, teardownConfirmMs, resume, retainedAtSettlement: requestedRetainedAtSettlement, now: suppliedNow, signal, hooks, workerTrace, workerTraceUnpropagated, interactiveBindingDir } = opts;
16021
+ const { budget, rootIdentity, requestedProfile, rootSegment, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, maxDepth, workerSlots, reservationPolicy, deadlineCheckIn, budgetStopHoldMs, maxRestarts, withinMs, childSettleGraceMs, teardownConfirmMs, resume, retainedAtSettlement: requestedRetainedAtSettlement, now: suppliedNow, signal, hooks, workerTrace, workerTraceUnpropagated, interactiveBindingDir } = opts;
16328
16022
  const input = detachedSnapshot({
16329
16023
  task,
16330
16024
  options: {
16331
16025
  budget,
16332
16026
  runId,
16333
16027
  ...rootIdentity === void 0 ? {} : { rootIdentity },
16028
+ ...requestedProfile === void 0 ? {} : { requestedProfile },
16334
16029
  ...rootSegment === void 0 ? {} : { rootSegment },
16335
16030
  ...rootMaterialization === void 0 ? {} : { rootMaterialization },
16336
16031
  ...maxDepth === void 0 ? {} : { maxDepth },
@@ -16860,13 +16555,14 @@ async function settleRootResult(settled) {
16860
16555
  pool.assertNoOpenTickets();
16861
16556
  const outRef = contentAddress(out);
16862
16557
  await settled.opts.blobs.put(outRef, out);
16863
- const { spentTotal, childWork, driverInference, gaps, providerModel, fleetYield } = await terminalAccounting(settled.journal, settled.opts.runId, settled.now() - settled.runEpochMs);
16558
+ const { spentTotal, childWork, driverInference, gaps, providerModel, fleetYield, usage } = await terminalAccounting(settled.journal, settled.opts.runId, settled.now() - settled.runEpochMs, settled.opts.requestedProfile);
16864
16559
  return {
16865
16560
  kind: "winner",
16866
16561
  out,
16867
16562
  outRef,
16868
16563
  tree: settled.tree,
16869
16564
  spentTotal,
16565
+ usage,
16870
16566
  providerModel,
16871
16567
  ...teardownUnconfirmed.length > 0 ? { teardownUnconfirmed } : {},
16872
16568
  ...gaps.length > 0 ? { spendGaps: gaps } : {},
@@ -16884,12 +16580,13 @@ async function settleRootResult(settled) {
16884
16580
  /** A no-winner still carries `spentTotal`, summed off the SAME journal the winner path reads. */
16885
16581
  async function noWinner(settled, rejection) {
16886
16582
  const { controller, teardownUnconfirmed, leakedReservations } = settled;
16887
- const { spentTotal, gaps, providerModel, fleetYield } = await terminalAccounting(settled.journal, settled.opts.runId, settled.now() - settled.runEpochMs);
16583
+ const { spentTotal, gaps, providerModel, fleetYield, usage } = await terminalAccounting(settled.journal, settled.opts.runId, settled.now() - settled.runEpochMs, settled.opts.requestedProfile);
16888
16584
  const common = {
16889
16585
  kind: "no-winner",
16890
16586
  tree: settled.tree,
16891
16587
  downCount: settled.breaker.downCount(),
16892
16588
  spentTotal,
16589
+ usage,
16893
16590
  providerModel,
16894
16591
  ...teardownUnconfirmed.length > 0 ? { teardownUnconfirmed } : {},
16895
16592
  ...leakedReservations.length > 0 ? { leakedReservations } : {},
@@ -16928,4 +16625,4 @@ async function noWinner(settled, rejection) {
16928
16625
  }
16929
16626
  export { DEFAULT_PEER_MAIL_LIMITS as $, renderUnsupported as $t, createSandboxForSpec as A, priceTokens as At, createRouterTranscript as B, runSettledCommand as Bt, createExecutor as C, bestComposite as Ct, runAgentRounds as D, isFiniteNumber as Dt, createSteerableSandboxSession as E, failedItems as Et, codeModeArguments as F, readCodexRolloutSession as Ft, LEAF_CONTINUATION_TASK as G, assertProfileMaterialization as Gt, createAgentEnvironmentProviderRegistry as H, LOCAL_HARNESSES as Ht, codeModeModelOutput as I, createPushTraceSource as It, createInPlaceCliExecutor as J, defineProfileMaterializationContract as Jt, providerAsSandboxClient as K, assertProfileMaterializes as Kt, createCodeModeTools as L, bridgeRuntimeAttachmentsKey as Lt, acquireSandbox as M, addHarnessUsage as Mt, TERMINAL_DECISIONS as N, createCodexRolloutStoreReader as Nt, assertBoxlessPromptOptions as O, bridgeAdmissionRefusal as Ot, defaultSelectWinner as P, harnessUsageIsEmpty as Pt, AUTHORITY_MARKERS as Q, promptModelProfileMaterialization as Qt, runCodeMode as R, bridgeStopSignalKey as Rt, captureReusableExecutorConfig as S, admitContinuationPolicy as St, DEFAULT_SANDBOX_STEERING_MAX_TURNS as T, createContinuationKeeper as Tt, resolveAgentEnvironmentProvider as U, harnessInvocation as Ut, routerBrain as V, runWorktreeHarness as Vt, providerAsExecutor as W, terminateProcessTreeAndConfirm as Wt, createInbox as X, profileMaterializationAxes$1 as Xt, INBOX_RECEIPT_KEY as Y, fullProfileMaterialization as Yt, failPendingAfter as Z, promptControlProfileMaterialization as Zt, withDriverExecutor as _, gateFactoryOnDeliverable as _t, assertRunParking as a, readSandboxOutcome as an, peerMailVerbNames as at, createExecutorRegistry as b, verdictFromJudgeScore as bt, sleepScopeWait as c, HarnessTurnFailedError as ct, runFinalizer as d, summarizeDriverAttempts as dt, sandboxActProfileMaterialization as en, PEER_MAIL_WIRE_KEY as et, runTree as f, transientFailureKind as ft, isDriverSpec as g, CheckUnavailableError as gt, driverExecutorFactory as h, preflightPublicCoordination as ht, RunParkedError as i, projectSandboxOutcome as in, peerMailTools as it, createSandboxLineage as j, ROUTER_PRICE_SOURCE as jt, readPromptOptions as k, bridgeModelRouteRefusal as kt, withRunParking as l, abandonablePending as lt, driverChild as m, upstreamUnavailableSignal as mt, createSupervisor as n, unsupportedProfileDimensions as nn, createPeerMailbox as nt, bindScopeParkingDrain as o, taskToPrompt$1 as ot, createRootHandle as p, undispatchedCredentialExit as pt, createWorktreeCliExecutor as q, controlProfileMaterialization as qt, assertResumeLimits as r, worktreeCliProfileMaterialization as rn, isPeerMailEnvelope as rt, readRunParking as s, DriverAttemptsExhaustedError as st, DEFAULT_MAX_DEPTH as t, sandboxProfileMaterialization as tn, claimsAuthority as tt, bestDelivered as u, classifyDriverFailure as ut, InMemoryResultBlobStore as v, gateOnDeliverable as vt, snapshotExecutorConfig as w, checkVerdictOf as wt, bindReusableExecutorExecutionId as x, CONTINUATIONS_DIR as xt, InMemorySpawnJournal as y, mapExecutorResult as yt, toolResultText as z, defaultRunCommand as zt };
16930
16627
 
16931
- //# sourceMappingURL=supervisor-1A27fE6k.js.map
16628
+ //# sourceMappingURL=supervisor-gC-u_PRk.js.map