@tangle-network/agent-runtime 5.0.0 → 6.0.1

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 (83) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{activation-DGLWxFJu.js → activation-BRfZOfwb.js} +4 -4
  3. package/dist/{activation-DGLWxFJu.js.map → activation-BRfZOfwb.js.map} +1 -1
  4. package/dist/{activation-CtLdCiH3.d.ts → activation-DEKw9CDD.d.ts} +2 -2
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{bundle-CV4Ts0cS.js → bundle-vFFiCigS.js} +2 -2
  8. package/dist/{bundle-CV4Ts0cS.js.map → bundle-vFFiCigS.js.map} +1 -1
  9. package/dist/candidate-execution/index.d.ts +70 -3
  10. package/dist/candidate-execution/index.js +4 -4
  11. package/dist/{coordination-manager-D74AZg7m.js → coordination-manager-RSJg5GmY.js} +10 -9
  12. package/dist/coordination-manager-RSJg5GmY.js.map +1 -0
  13. package/dist/coordination-map-routing-DVjW5Gx0.js.map +1 -1
  14. package/dist/{delegate-BVyFJ9AX.js → delegate-C0cprMUN.js} +2 -2
  15. package/dist/{delegate-BVyFJ9AX.js.map → delegate-C0cprMUN.js.map} +1 -1
  16. package/dist/durable.d.ts +2 -2
  17. package/dist/durable.js +9 -9
  18. package/dist/{graph-r8zcRxbi.js → graph-cEg-gquv.js} +5 -5
  19. package/dist/{graph-r8zcRxbi.js.map → graph-cEg-gquv.js.map} +1 -1
  20. package/dist/{improve-D12GulmK.js → improve-DNl4_6lP.js} +7 -7
  21. package/dist/{improve-D12GulmK.js.map → improve-DNl4_6lP.js.map} +1 -1
  22. package/dist/index.d.ts +6 -6
  23. package/dist/index.js +10 -10
  24. package/dist/intelligence.d.ts +4 -4
  25. package/dist/intelligence.js +7 -7
  26. package/dist/kernel.d.ts +3 -3
  27. package/dist/kernel.js +12 -12
  28. package/dist/{loop-runner-BHBabRIw.d.ts → loop-runner-CDad0CCY.d.ts} +2 -2
  29. package/dist/{loop-runner-CYcN11I4.js → loop-runner-DQJjowz0.js} +2 -2
  30. package/dist/{loop-runner-CYcN11I4.js.map → loop-runner-DQJjowz0.js.map} +1 -1
  31. package/dist/loop-runner-bin.d.ts +1 -1
  32. package/dist/loop-runner-bin.js +1 -1
  33. package/dist/mcp/bin.js +3 -3
  34. package/dist/mcp/index.d.ts +1 -1
  35. package/dist/mcp/index.js +6 -6
  36. package/dist/{prepare-DutbxpWr.js → prepare-B6SQA12v.js} +3 -3
  37. package/dist/{prepare-DutbxpWr.js.map → prepare-B6SQA12v.js.map} +1 -1
  38. package/dist/{profile-ClvuI8aY.js → profile-DN8Dw2Kp.js} +2 -2
  39. package/dist/{profile-ClvuI8aY.js.map → profile-DN8Dw2Kp.js.map} +1 -1
  40. package/dist/profiles.d.ts +1 -1
  41. package/dist/{protected-model-port-DEsNIYi1.d.ts → protected-model-port-uN4M48vT.d.ts} +2 -2
  42. package/dist/{provision-supervisor-BiqHJ-d4.js → provision-supervisor-CtAaJCUa.js} +5 -5
  43. package/dist/{provision-supervisor-BiqHJ-d4.js.map → provision-supervisor-CtAaJCUa.js.map} +1 -1
  44. package/dist/{run-cancellation-D5R-7UQt.js → run-cancellation-BCuu6khW.js} +2 -2
  45. package/dist/{run-cancellation-D5R-7UQt.js.map → run-cancellation-BCuu6khW.js.map} +1 -1
  46. package/dist/{run-state-DRh8BOFi.js → run-state-ByHiAjUs.js} +6 -5
  47. package/dist/{run-state-DRh8BOFi.js.map → run-state-ByHiAjUs.js.map} +1 -1
  48. package/dist/{runtime-BX_9-DJB.js → runtime-9EYvBcHG.js} +13 -13
  49. package/dist/{runtime-BX_9-DJB.js.map → runtime-9EYvBcHG.js.map} +1 -1
  50. package/dist/runtime-hooks-CsW2pfFk.js.map +1 -1
  51. package/dist/{runtime-hooks-ZQqPw-0g.d.ts → runtime-hooks-DPghSHV7.d.ts} +11 -16
  52. package/dist/{scope-JcCkUy_z.js → scope-DzhBJrRN.js} +3510 -3451
  53. package/dist/scope-DzhBJrRN.js.map +1 -0
  54. package/dist/{search-executor-CdmaS5r4.js → search-executor-BJRNavck.js} +4 -4
  55. package/dist/{search-executor-CdmaS5r4.js.map → search-executor-BJRNavck.js.map} +1 -1
  56. package/dist/{server-BY6OluUf.js → server-DH0P6OY_.js} +4 -4
  57. package/dist/{server-BY6OluUf.js.map → server-DH0P6OY_.js.map} +1 -1
  58. package/dist/{structural-rollout-BjMUUXLn.js → structural-rollout-DgvJLTO0.js} +4 -4
  59. package/dist/{structural-rollout-BjMUUXLn.js.map → structural-rollout-DgvJLTO0.js.map} +1 -1
  60. package/dist/{supervise-rYEsVVcn.js → supervise-Cqhkb2Oj.js} +244 -80
  61. package/dist/supervise-Cqhkb2Oj.js.map +1 -0
  62. package/dist/{supervision-discovery-D95Ack4J.js → supervision-discovery-DI5GIFBJ.js} +3 -3
  63. package/dist/{supervision-discovery-D95Ack4J.js.map → supervision-discovery-DI5GIFBJ.js.map} +1 -1
  64. package/dist/{supervisor-B-bX69uL.js → supervisor-B6sl14OR.js} +243 -962
  65. package/dist/supervisor-B6sl14OR.js.map +1 -0
  66. package/dist/testing.d.ts +1 -1
  67. package/dist/testing.js +13 -13
  68. package/dist/tool-loop.d.ts +1 -1
  69. package/dist/{top-web-D-wH9ipn.js → top-web-DGoXGxH8.js} +4 -4
  70. package/dist/{top-web-D-wH9ipn.js.map → top-web-DGoXGxH8.js.map} +1 -1
  71. package/dist/tui/bin.js +3 -3
  72. package/dist/tui/index.d.ts +2 -2
  73. package/dist/tui/index.js +2 -2
  74. package/dist/{types-DblV14Oe.d.ts → types-niKnm6ux.d.ts} +86 -242
  75. package/dist/{workspace-streams-DbKiDOWA.d.ts → workspace-archive-DS9E9tUr.d.ts} +2 -69
  76. package/dist/{workspace-streams-8ALHaZzx.js → workspace-streams-BqNM06y4.js} +34 -9
  77. package/dist/workspace-streams-BqNM06y4.js.map +1 -0
  78. package/package.json +5 -5
  79. package/dist/coordination-manager-D74AZg7m.js.map +0 -1
  80. package/dist/scope-JcCkUy_z.js.map +0 -1
  81. package/dist/supervise-rYEsVVcn.js.map +0 -1
  82. package/dist/supervisor-B-bX69uL.js.map +0 -1
  83. package/dist/workspace-streams-8ALHaZzx.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { An as WORKER_TRACE_PROPAGATION, Ar as recordRuntimeOwnedDriveHarnessProviderEvidence, At as beginScopeRetainedOwnerDrive, B as beginScopeOwnerAttempt, Bn as createOtelExporter, Ci as executorFailure, Dt as prepareScopeRetainedOwnerTask, Et as consumeScopeRetainedOwnerResult, Fi as assertValidBudget, Fr as runtimeOwnedDriveHarnessProviderEvidence, Ft as scopeRetainedOwnerRestorePoint, G as scopeOwnerExecutorNodeContext, H as noteScopeOwnerPlannedExecution, Hn as generateSpanId, Ht as scopeRetainedOwnerContext, Ir as runtimeOwnedExecutorExecutionBinding, It as noteScopeRetainedOwnerCoordination, J as providerVisibleProfile, Jr as runtimeFlowBrain, K as coordinationMcpAlias, Kr as isRuntimeFlowBrain, Lr as runtimeOwnedExecutorMaterialization, Mi as newUsageTotals, Mt as scopeRetainedOwnerTurnEnded, Nt as assertRetainedOwnerCoordinationRekey, O as parseWorkerToolTraceArtifact, Ot as scopeRetainedOwnerPriorSpend, Pi as spendFromUsageTotals, Pt as reconcileScopeRetainedOwnerEnvironment, Q as assertRecursiveReservationPolicy, Rr as runtimeOwnedExecutorProviderEvidence, Rt as bindScopeRetainedOwnerEnvironmentId, Sr as authoredAgentIdentity, St as scopeRetainedOwnerResourceReader, Tt as abandonScopeRetainedOwnerInvocation, U as recordScopeOwnerMaterialization, Ut as scopeRetainedOwnerJournalRoot, Vr as runtimeOwnedScopeOwnerRuntime, W as restoreScopeOwnerAcceptedExecution, Y as runtimeGraphMetadataKey, _i as unavailableResumeAt, a as readRootStream, bt as prepareScopeRetainedOwnerSeatSwitch, ct as recordScopeOwnerBarrenPause, dr as isTerminalNodeStatus, er as persistHarnessTranscript, fa as RunCancellationReason, fi as cappedDoublingMs, fr as SEAT_RECHECK_MS, gi as unavailablePauseMs, gr as seatExecutionProfile, ha as runAbortable, hi as reportedResetAt, hr as authoredSeatStages, ia as recordValue, ji as meterUsageEvent, kr as providerAttemptEvidence, kt as scopeRetainedOwnerResult, li as retainedExecutorSeamKey, lt as recordScopeOwnerDriverAttempt, ma as linkAbort, mr as SeatPauseError, n as ROOT_STREAM_FILE, ot as meterRuntimeOwnedAccounting, pi as jitteredMs, pr as SeatChain, q as coordinationProfileToolPrefix, qr as runtimeFlowAgent, r as createRootStreamSink, ri as RetainedExecutionPendingError, si as registerRetainedExecutorPreparation, sr as createActivityLog, st as meterRuntimeOwnedProviderAttempt, tr as readHarnessTranscript, ur as isLiveNodeStatus, ut as recordScopeOwnerPause, xi as contentAddress, xr as attestRuntimeOwnedScopeOwner, xt as releaseScopeRetainedOwnerForSeatPause, zr as runtimeOwnedPendingExecutorMaterialization, zt as bindScopeRetainedOwnerProvider } from "./scope-JcCkUy_z.js";
1
+ import { $r as RetainedExecutionPendingError, Ai as spendFromUsageTotals, At as scopeOwnerExecutorNodeContext, Bt as scopeRetainedOwnerRestorePoint, Ct as scopeRetainedOwnerResult, Di as meterUsageEvent, Dt as recordScopeOwnerMaterialization, En as WORKER_TRACE_PROPAGATION, Er as recordRuntimeOwnedDriveHarnessProviderEvidence, Et as noteScopeOwnerPlannedExecution, Fr as runtimeOwnedPendingExecutorMaterialization, Ft as beginScopeRetainedOwnerDrive, Gt as scopeRetainedOwnerContext, Hr as isRuntimeFlowBrain, In as createOtelExporter, K as assertRecursiveReservationPolicy, Kt as scopeRetainedOwnerJournalRoot, Lr as runtimeOwnedScopeOwnerRuntime, Lt as scopeRetainedOwnerTurnEnded, Mr as runtimeOwnedExecutorExecutionBinding, Mt as coordinationProfileToolPrefix, Nr as runtimeOwnedExecutorMaterialization, Nt as providerVisibleProfile, Oi as newUsageTotals, Ot as restoreScopeOwnerAcceptedExecution, Pr as runtimeOwnedExecutorProviderEvidence, Pt as runtimeGraphMetadataKey, Rn as generateSpanId, Rt as assertRetainedOwnerCoordinationRekey, Si as turnFailurePolicy, St as scopeRetainedOwnerPriorSpend, Tr as providerAttemptEvidence, Ur as runtimeFlowAgent, Ut as bindScopeRetainedOwnerEnvironmentId, Vt as noteScopeRetainedOwnerCoordination, Wr as runtimeFlowBrain, Wt as bindScopeRetainedOwnerProvider, Xn as persistHarnessTranscript, Zn as readHarnessTranscript, _i as contentAddress, _r as attestRuntimeOwnedScopeOwner, a as readRootStream, ai as retainedExecutorSeamKey, an as executorObservationSeamKey, at as recordScopeOwnerPause, bt as consumeScopeRetainedOwnerResult, ci as cappedDoublingMs, cr as SEAT_RECHECK_MS, di as reportedResetAt, dr as authoredSeatStages, ea as recordValue, et as meterRuntimeOwnedAccounting, fi as unavailablePauseMs, fr as seatExecutionProfile, gt as scopeRetainedOwnerResourceReader, ht as releaseScopeRetainedOwnerForSeatPause, it as recordScopeOwnerDriverAttempt, j as parseWorkerToolTraceArtifact, ji as assertValidBudget, jr as runtimeOwnedDriveHarnessProviderEvidence, jt as coordinationMcpAlias, kt as scopeOwnerExecutionObservation, la as linkAbort, li as jitteredMs, lr as SeatChain, mt as prepareScopeRetainedOwnerSeatSwitch, n as ROOT_STREAM_FILE, nt as pauseScopeSeatAdmission, or as isLiveNodeStatus, pi as unavailableResumeAt, r as createRootStreamSink, ri as registerRetainedExecutorPreparation, rr as createActivityLog, rt as recordScopeOwnerBarrenPause, sa as RunCancellationReason, sr as isTerminalNodeStatus, tt as meterRuntimeOwnedProviderAttempt, ua as runAbortable, ur as SeatPauseError, vr as authoredAgentIdentity, wt as beginScopeOwnerAttempt, xi as turnFailureOf, xt as prepareScopeRetainedOwnerTask, yi as executorFailure, yt as abandonScopeRetainedOwnerInvocation, zt as reconcileScopeRetainedOwnerEnvironment } from "./scope-DzhBJrRN.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-AzSuGI23.js";
3
- import { $ as isAsyncIterable, Dt as teardownExecutor, G as chargedTokens, St as armDeadlineTimer, Tt as isDeadlineAbortReason, U as addSpend, Y as errorMessage, at as sleep, bt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, dt as zeroSpend, gt as withBudgetResources, ht as resourceTelemetry, lt as unmeteredSpend, pt as addResourceSpend, tt as promptCacheTokenClasses, ut as withTimeout } from "./workspace-streams-8ALHaZzx.js";
4
- import { _ as errorText, d as detachedSnapshot, h as errorHttpStatus, m as errMessage, p as causeChain } from "./jsonl-file-CeVYTIQJ.js";
5
- import { $t as promptModelProfileMaterialization, At as bridgeModelRouteRefusal, B as createRouterTranscript, C as createExecutor, Ct as admitContinuationPolicy, Et as createContinuationKeeper, F as codeModeArguments, I as codeModeModelOutput, Jt as controlProfileMaterialization, Kt as assertProfileMaterialization, L as createCodeModeTools, Qt as promptControlProfileMaterialization, Rt as bridgeRuntimeAttachmentsKey, S as captureReusableExecutorConfig, St as CONTINUATIONS_DIR, Tt as checkVerdictOf, U as resolveAgentEnvironmentProvider, V as routerBrain, X as createInbox, Xt as fullProfileMaterialization, Y as INBOX_RECEIPT_KEY, Yt as defineProfileMaterializationContract, Zt as profileMaterializationAxes$1, _t as CheckUnavailableError, a as assertRunParking, c as sleepScopeWait, ct as HarnessTurnFailedError, d as runFinalizer, dt as isContentFilterRefusal, en as renderUnsupported, et as PEER_MAIL_WIRE_KEY, f as runTree, ft as summarizeDriverAttempts, g as isDriverSpec, gt as preflightPublicCoordination, h as driverExecutorFactory, ht as upstreamUnavailableSignal, i as RunParkedError, in as worktreeCliProfileMaterialization, kt as bridgeAdmissionRefusal, l as withRunParking, lt as abandonablePending, m as driverChild, mt as undispatchedCredentialExit, n as createSupervisor, nn as sandboxProfileMaterialization, o as bindScopeParkingDrain, p as createRootHandle, pt as transientFailureKind, rn as unsupportedProfileDimensions, rt as isPeerMailEnvelope, st as DriverAttemptsExhaustedError, u as bestDelivered, ut as classifyDriverFailure, vt as gateFactoryOnDeliverable, w as snapshotExecutorConfig, wt as bestComposite, x as bindReusableExecutorExecutionId, z as toolResultText, zt as bridgeStopSignalKey } from "./supervisor-B-bX69uL.js";
3
+ import { Dt as teardownExecutor, H as addSpend, J as errorMessage, Q as isAsyncIterable, St as armDeadlineTimer, Tt as isDeadlineAbortReason, W as chargedTokens, bt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, ct as unmeteredSpend, dt as zeroSpend, et as promptCacheTokenClasses, gt as withBudgetResources, ht as resourceTelemetry, it as sleep, pt as addResourceSpend, ut as withTimeout } from "./workspace-streams-BqNM06y4.js";
4
+ import { _ as errorText, d as detachedSnapshot, h as errorHttpStatus, m as errMessage, p as causeChain, v as defaultRedactor } from "./jsonl-file-CeVYTIQJ.js";
5
+ import { $t as promptModelProfileMaterialization, At as bridgeModelRouteRefusal, B as createRouterTranscript, C as createExecutor, Ct as admitContinuationPolicy, Et as createContinuationKeeper, F as codeModeArguments, I as codeModeModelOutput, Jt as controlProfileMaterialization, Kt as assertProfileMaterialization, L as createCodeModeTools, Qt as promptControlProfileMaterialization, Rt as bridgeRuntimeAttachmentsKey, S as captureReusableExecutorConfig, St as CONTINUATIONS_DIR, Tt as checkVerdictOf, U as resolveAgentEnvironmentProvider, V as routerBrain, X as createInbox, Xt as fullProfileMaterialization, Y as INBOX_RECEIPT_KEY, Yt as defineProfileMaterializationContract, Zt as profileMaterializationAxes$1, _t as CheckUnavailableError, a as assertRunParking, c as sleepScopeWait, ct as HarnessTurnFailedError, d as runFinalizer, dt as isContentFilterRefusal, en as renderUnsupported, et as PEER_MAIL_WIRE_KEY, f as runTree, ft as summarizeDriverAttempts, g as isDriverSpec, gt as preflightPublicCoordination, h as driverExecutorFactory, ht as upstreamUnavailableSignal, i as RunParkedError, in as worktreeCliProfileMaterialization, kt as bridgeAdmissionRefusal, l as withRunParking, lt as abandonablePending, m as driverChild, mt as undispatchedCredentialExit, n as createSupervisor, nn as sandboxProfileMaterialization, o as bindScopeParkingDrain, p as createRootHandle, pt as transientFailureKind, rn as unsupportedProfileDimensions, rt as isPeerMailEnvelope, st as DriverAttemptsExhaustedError, u as bestDelivered, ut as classifyDriverFailure, vt as gateFactoryOnDeliverable, w as snapshotExecutorConfig, wt as bestComposite, x as bindReusableExecutorExecutionId, z as toolResultText, zt as bridgeStopSignalKey } from "./supervisor-B6sl14OR.js";
6
6
  import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-JOcg3NRs.js";
7
7
  import { n as createStdioToolServer } from "./tool-server-CZWd_Opp.js";
8
8
  import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
9
- import { _ as workerAssignmentNamespace, c as writeRunCancellation, d as coordinationEventId, f as externalExecutionId, g as supervisionRunNamespace, h as rootCoordinationOwner, i as readRunCancellation, l as canonicalExecution, m as freezeDetachedProfile, p as freezeDetached, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation, u as childCoordinationOwner } from "./run-cancellation-D5R-7UQt.js";
10
- import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-D74AZg7m.js";
9
+ import { _ as workerAssignmentNamespace, c as writeRunCancellation, d as coordinationEventId, f as externalExecutionId, g as supervisionRunNamespace, h as rootCoordinationOwner, i as readRunCancellation, l as canonicalExecution, m as freezeDetachedProfile, p as freezeDetached, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation, u as childCoordinationOwner } from "./run-cancellation-BCuu6khW.js";
10
+ import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-RSJg5GmY.js";
11
11
  import { o as safeJsonText } from "./coordination-map-routing-DVjW5Gx0.js";
12
12
  import { a as graphRegistry, c as loadGraph } from "./graph-registry-B25FxBZN.js";
13
- import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
13
+ import { ATTR, LINK_KIND_ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
14
14
  import { ProxySecretScopeSchema, ProxySecretsSchema, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, mergeProxySecretBindings, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
15
15
  import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
16
16
  import { isRecord } from "@tangle-network/agent-core";
@@ -275,30 +275,7 @@ function captureSuperviseOptions(opts, mode = "execution") {
275
275
  });
276
276
  }
277
277
  // src/runtime/supervise/otel-spans.ts
278
- /**
279
- * Supervisor tree → OTLP spans. OPT-IN, off by default.
280
- *
281
- * WHY. A supervised tree is legible only by parsing this package's own spawn journal; a span
282
- * carrying `parent_span_id` IS a tree, so emitting spans makes the supervisor readable by the same
283
- * viewer as every other multi-agent shape, with no per-system reader.
284
- *
285
- * NOT the record of truth. The spawn journal remains the sole durable ledger for replay/resume and
286
- * cost; nothing here is read back, and a run whose export fails is unaffected.
287
- *
288
- * HOW. A pure `RuntimeHooks` observer over events `Scope` ALREADY emits — `agent.spawn` (node
289
- * opened), `agent.child` (node settled), `agent.turn` (driver turn metered). It adds no event,
290
- * mutates no journal, changes no result. `Scope` re-seeds the hooks into every nested scope
291
- * (`makeNestedScopeSeam`), so one observer sees the WHOLE recursion.
292
- *
293
- * SHAPE. One span per node, opened at spawn, closed at settle, parented to its parent node's
294
- * span; the run root is the trace. Driver inference rides as an `LLM` child span under the node
295
- * that metered it. Attributes reuse the stack's vocabulary (`openinference.span.kind`,
296
- * `agent.name`, `llm.token_count.*`, `llm.cost_usd`, `tangle.cost.usd`), consumed by
297
- * `@tangle-network/agent-eval`'s `src/trace/attribute-vocabulary.ts`.
298
- *
299
- * UNKNOWN IS NEVER ZERO. `tokensKnown === false` / `usdKnown === false` spans OMIT the token/cost
300
- * attribute and set `tangle.supervise.tokens_known` / `cost_known` to `false`.
301
- */
278
+ /** Best-effort supervisor spans; the spawn journal owns replay and accounting. */
302
279
  /** OTEL status codes (`UNSET` / `OK` / `ERROR`) — the numeric wire values `OtelSpan.status` carries. */
303
280
  const STATUS_UNSET = 0;
304
281
  const STATUS_OK = 1;
@@ -315,6 +292,7 @@ function otelSpan(traceId, spec) {
315
292
  startTimeUnixNano: msToUnixNano(spec.startMs),
316
293
  endTimeUnixNano: msToUnixNano(Math.max(spec.startMs, spec.endMs)),
317
294
  attributes: toOtlpAttributes(spec.attrs),
295
+ ...spec.links ? { links: spec.links } : {},
318
296
  status: {
319
297
  code: spec.status,
320
298
  ...spec.message ? { message: spec.message } : {}
@@ -365,9 +343,9 @@ function settleNode(t, event) {
365
343
  name: node.name,
366
344
  startMs: node.startMs,
367
345
  endMs: event.timestamp,
368
- attrs: settledAttributes(node.attrs, event),
346
+ attrs: settledAttributes(node.attrs, event, t.telemetry),
369
347
  status: down ? STATUS_ERROR : STATUS_OK,
370
- message: down ? str(p.reason) ?? "child down" : void 0
348
+ message: down ? t.telemetry.includeEvalDetails ? truncate(str(p.reason) ?? "child down") : "child down" : void 0
371
349
  });
372
350
  }
373
351
  function turnSpan(t, event) {
@@ -386,18 +364,134 @@ function turnSpan(t, event) {
386
364
  };
387
365
  if (parentId) attrs["tangle.supervise.node.id"] = parentId;
388
366
  const p = record(event.payload);
389
- assignTurnDetail(attrs, p);
367
+ assignTurnDetail(attrs, p, t.telemetry);
390
368
  const spend = assignSpend(attrs, p.spend);
391
369
  return otelSpan(t.traceId, {
392
370
  spanId: generateSpanId(),
393
371
  parentSpanId: parent.spanId,
394
372
  name: "gen_ai.client.inference",
395
- startMs: event.timestamp,
396
- endMs: event.timestamp + (spend?.ms ?? 0),
373
+ startMs: event.timestamp - (spend?.ms ?? 0),
374
+ endMs: event.timestamp,
397
375
  attrs,
398
376
  status: STATUS_OK
399
377
  });
400
378
  }
379
+ /** Runtime-owned metadata only: prompts, arguments, results and error messages stay private. */
380
+ function observationSpan(t, event) {
381
+ const p = record(event.payload);
382
+ const nodeId = event.target === "agent.steer" ? str(p.nodeId) ?? t.runId : event.parentId ?? t.runId;
383
+ const parent = parentSpan(t, nodeId);
384
+ const attrs = {
385
+ ...t.base,
386
+ ...t.identityOf.get(nodeId) ?? {},
387
+ [ATTR.parentConfidence]: parent.confidence,
388
+ "tangle.supervise.node.id": nodeId
389
+ };
390
+ const attempt = str(p.attemptId);
391
+ if (attempt) attrs[ATTR.attemptId] = attempt;
392
+ let name = event.target;
393
+ let links;
394
+ if (event.target === "agent.model") {
395
+ attrs[ATTR.spanKind] = "LLM";
396
+ name = "gen_ai.client.inference";
397
+ if (attempt) t.modeledAttempts.add(`${nodeId}:${attempt}`);
398
+ const model = str(p.model);
399
+ if (model) attrs[ATTR.model] = model;
400
+ for (const [field, key] of [
401
+ ["tokensIn", ATTR.inputTokens],
402
+ ["tokensOut", ATTR.outputTokens],
403
+ ["costUsd", ATTR.costUsd]
404
+ ]) if (typeof p[field] === "number" && Number.isFinite(p[field])) attrs[key] = p[field];
405
+ } else if (event.target === "agent.tool_call") {
406
+ attrs[ATTR.spanKind] = "TOOL";
407
+ const tool = str(p.toolName);
408
+ if (tool) attrs[ATTR.toolName] = tool;
409
+ const call = str(p.toolCallId);
410
+ if (call) attrs["tool.call_id"] = call;
411
+ if (typeof p.durationKnown === "boolean") attrs["tangle.tool.duration_known"] = p.durationKnown;
412
+ } else {
413
+ attrs[ATTR.spanKind] = "CHAIN";
414
+ if (event.target === "agent.steer") {
415
+ const target = str(p.nodeId);
416
+ if (target) attrs["tangle.supervise.steer.node_id"] = target;
417
+ const senderSpan = event.parentId === void 0 ? void 0 : t.spanIdOf.get(event.parentId);
418
+ if (senderSpan) links = [{
419
+ traceId: t.traceId,
420
+ spanId: senderSpan,
421
+ attributes: toOtlpAttributes({ [LINK_KIND_ATTR]: "steered_by" })
422
+ }];
423
+ } else {
424
+ const control = record(p.controlRef);
425
+ for (const key of [
426
+ "provider",
427
+ "environmentId",
428
+ "executionId",
429
+ "sessionId"
430
+ ]) {
431
+ const value = str(control[key]);
432
+ if (value) attrs[`tangle.execution.${key}`] = value;
433
+ }
434
+ attrs["tangle.execution.phase"] = "dispatched";
435
+ }
436
+ }
437
+ const failed = p.status === "error";
438
+ if (typeof p.status === "string") attrs["tangle.observation.status"] = p.status;
439
+ const errorType = str(record(p.error).type);
440
+ if (errorType) attrs["error.type"] = truncate(errorType);
441
+ return otelSpan(t.traceId, {
442
+ spanId: generateSpanId(),
443
+ parentSpanId: parent.spanId,
444
+ name,
445
+ startMs: typeof p.startedAt === "number" ? p.startedAt : event.timestamp,
446
+ endMs: typeof p.endedAt === "number" ? p.endedAt : event.timestamp,
447
+ attrs,
448
+ status: failed ? STATUS_ERROR : p.status === "ok" ? STATUS_OK : STATUS_UNSET,
449
+ ...links ? { links } : {}
450
+ });
451
+ }
452
+ /** One acknowledged driver outcome is execution evidence, never another model call. */
453
+ function attemptSpan(t, event) {
454
+ const p = record(event.payload), attempt = record(p.record);
455
+ const duration = attempt.durationMs;
456
+ if (!Number.isSafeInteger(attempt.attempt) || Number(attempt.attempt) < 1 || typeof duration !== "number" || !Number.isFinite(duration) || duration < 0 || !Number.isFinite(event.timestamp)) return void 0;
457
+ const nodeId = str(p.nodeId) ?? event.parentId ?? t.runId;
458
+ const parent = parentSpan(t, nodeId);
459
+ const failure = turnFailureOf(attempt);
460
+ const failed = failure !== void 0 || typeof attempt.error === "string";
461
+ const attrs = {
462
+ ...t.base,
463
+ ...t.identityOf.get(nodeId) ?? {},
464
+ [ATTR.spanKind]: "CHAIN",
465
+ [ATTR.parentConfidence]: parent.confidence,
466
+ [ATTR.outcome]: failed ? "error" : "ok",
467
+ "tangle.supervise.node.id": nodeId
468
+ };
469
+ const id = str(p.attemptId);
470
+ if (id) attrs[ATTR.attemptId] = id;
471
+ if (typeof attempt.attempt === "number") attrs["tangle.driver.attempt"] = attempt.attempt;
472
+ for (const key of [
473
+ "classification",
474
+ "failureKind",
475
+ "stop"
476
+ ]) {
477
+ const value = str(attempt[key]);
478
+ if (value) attrs[`tangle.driver.${key}`] = value;
479
+ }
480
+ if (failure) assignFailure(attrs, {
481
+ ...turnFailurePolicy(failure),
482
+ providerCode: failure.code
483
+ });
484
+ if (failed) attrs["error.type"] = failure?.kind ?? "driver-attempt";
485
+ return otelSpan(t.traceId, {
486
+ spanId: generateSpanId(),
487
+ parentSpanId: parent.spanId,
488
+ name: "agent.execution",
489
+ startMs: event.timestamp - duration,
490
+ endMs: event.timestamp,
491
+ attrs,
492
+ status: failed ? STATUS_ERROR : STATUS_OK
493
+ });
494
+ }
401
495
  /** The spans that close a run, yielded one at a time. A node still open never settled: its span is
402
496
  * closed UNSET and explicitly marked, never dropped or reported as clean. */
403
497
  function* closingSpans(t, opts, endMs, outcome) {
@@ -423,12 +517,12 @@ function* closingSpans(t, opts, endMs, outcome) {
423
517
  startMs: t.rootStartMs,
424
518
  endMs,
425
519
  attrs: {
426
- ...rootAttrs(t.base, opts.agentName ?? "supervisor", outcome),
520
+ ...rootAttrs(t.base, opts.agentName ?? "supervisor", outcome, opts),
427
521
  ...t.rootIdentity,
428
522
  ...opts.parentSpanId ? { [ATTR.parentConfidence]: "explicit" } : {}
429
523
  },
430
524
  status: rootStatus(outcome),
431
- message: rootMessage(outcome)
525
+ message: rootMessage(outcome, opts)
432
526
  });
433
527
  }
434
528
  /** Build the span recorder for one run, or `undefined` when no exporter resolves (off by default; "configured but unreachable" also costs nothing). */
@@ -442,6 +536,7 @@ function createSupervisorSpanRecorder(opts) {
442
536
  const rootStartMs = now();
443
537
  const rootIdentity = agentIdentityAttributes(opts.agentIdentity);
444
538
  const trace = {
539
+ telemetry: opts,
445
540
  runId: opts.runId,
446
541
  traceId,
447
542
  rootSpanId,
@@ -452,6 +547,7 @@ function createSupervisorSpanRecorder(opts) {
452
547
  ...opts.attributes ?? {}
453
548
  },
454
549
  rootIdentity,
550
+ modeledAttempts: /* @__PURE__ */ new Set(),
455
551
  identityOf: /* @__PURE__ */ new Map([[opts.runId, rootIdentity]]),
456
552
  open: /* @__PURE__ */ new Map(),
457
553
  spanIdOf: /* @__PURE__ */ new Map([[opts.runId, rootSpanId]])
@@ -467,12 +563,20 @@ function createSupervisorSpanRecorder(opts) {
467
563
  hooks: { onEvent(event) {
468
564
  if (finished) return;
469
565
  try {
566
+ if (event.target === "agent.execution" && event.phase === "event") {
567
+ const span = attemptSpan(trace, event);
568
+ if (span) emit(span);
569
+ return;
570
+ }
470
571
  if (event.phase !== "after") return;
471
572
  if (event.target === "agent.spawn") openNode(trace, event);
472
573
  else if (event.target === "agent.child") {
473
574
  const settled = settleNode(trace, event);
474
575
  if (settled) emit(settled);
475
- } else if (event.target === "agent.turn") emit(turnSpan(trace, event));
576
+ } else if (event.target === "agent.turn") {
577
+ const attempt = str(record(event.payload).attemptId);
578
+ if (!attempt || !trace.modeledAttempts.has(`${event.parentId}:${attempt}`)) emit(turnSpan(trace, event));
579
+ } else if (event.target === "agent.model" || event.target === "agent.tool_call" || event.target === "agent.execution" || event.target === "agent.steer") emit(observationSpan(trace, event));
476
580
  } catch {}
477
581
  } },
478
582
  traceId,
@@ -532,13 +636,14 @@ function spawnAttributes(base, event, identity) {
532
636
  return attrs;
533
637
  }
534
638
  /** A node span's attributes at `agent.child`: the spawn-time ones plus how it settled. */
535
- function settledAttributes(opened, event) {
639
+ function settledAttributes(opened, event, telemetry) {
536
640
  const p = record(event.payload);
537
641
  const status = str(p.status);
538
642
  const attrs = {
539
643
  ...opened,
540
644
  "tangle.supervise.node.status": status ?? "done"
541
645
  };
646
+ assignFailure(attrs, p.failure);
542
647
  if (typeof event.stepIndex === "number") attrs["tangle.supervise.node.seq"] = event.stepIndex;
543
648
  if (typeof p.outRef === "string") attrs["tangle.supervise.node.out_ref"] = p.outRef;
544
649
  if (typeof p.valid === "boolean") attrs["tangle.supervise.verdict.valid"] = p.valid;
@@ -546,7 +651,7 @@ function settledAttributes(opened, event) {
546
651
  if (status === "down") {
547
652
  attrs["error.type"] = p.infra === true ? "infra" : "child-down";
548
653
  const reason = str(p.reason);
549
- if (reason) attrs["error.message"] = truncate(reason);
654
+ if (reason && telemetry.includeEvalDetails) attrs["error.message"] = truncate(reason);
550
655
  if (typeof p.infra === "boolean") attrs["tangle.supervise.node.infra"] = p.infra;
551
656
  }
552
657
  const wokeBy = str(record(p.wait).settled);
@@ -556,7 +661,7 @@ function settledAttributes(opened, event) {
556
661
  }
557
662
  /** Free-form `Scope.meter` detail: named keys get the canonical attribute, the rest ride
558
663
  * namespaced and bounded so a caller's extra context survives without unbounded span growth. */
559
- function assignTurnDetail(attrs, payload) {
664
+ function assignTurnDetail(attrs, payload, telemetry) {
560
665
  for (const [key, value] of Object.entries(payload)) {
561
666
  if (key === "spend") continue;
562
667
  if (key === "driver" && typeof value === "string") {
@@ -568,6 +673,7 @@ function assignTurnDetail(attrs, payload) {
568
673
  attrs["llm.model_name"] = value;
569
674
  continue;
570
675
  }
676
+ if (!telemetry.includeMetadata) continue;
571
677
  if (Array.isArray(value)) {
572
678
  const scalars = value.filter((v) => typeof v === "string" || typeof v === "number");
573
679
  if (scalars.length > 0) attrs[`tangle.supervise.turn.${key}`] = truncate(scalars.join(","));
@@ -577,7 +683,18 @@ function assignTurnDetail(attrs, payload) {
577
683
  else if (typeof value === "number" || typeof value === "boolean") attrs[`tangle.supervise.turn.${key}`] = value;
578
684
  }
579
685
  }
580
- function rootAttrs(base, agentName, outcome) {
686
+ function assignFailure(attrs, value) {
687
+ const failure = record(value);
688
+ for (const key of [
689
+ "owner",
690
+ "code",
691
+ "providerCode"
692
+ ]) {
693
+ const field = str(failure[key]);
694
+ if (field) attrs[`tangle.failure.${key}`] = field;
695
+ }
696
+ }
697
+ function rootAttrs(base, agentName, outcome, telemetry) {
581
698
  const attrs = {
582
699
  ...base,
583
700
  [ATTR.spanKind]: "AGENT",
@@ -594,7 +711,8 @@ function rootAttrs(base, agentName, outcome) {
594
711
  attrs["tangle.supervise.down_count"] = result.downCount;
595
712
  if (result.reason === "driver-failed") {
596
713
  attrs["error.type"] = result.error.name;
597
- attrs["error.message"] = truncate(result.error.message);
714
+ assignFailure(attrs, result.error.failure);
715
+ if (telemetry.includeEvalDetails) attrs["error.message"] = truncate(result.error.message);
598
716
  }
599
717
  }
600
718
  assignSpend(attrs, result.spentTotal);
@@ -603,7 +721,7 @@ function rootAttrs(base, agentName, outcome) {
603
721
  attrs["tangle.supervise.result"] = "error";
604
722
  const err = outcome.error;
605
723
  attrs["error.type"] = err instanceof Error ? err.name : typeof err;
606
- attrs["error.message"] = truncate(err instanceof Error ? err.message : String(err));
724
+ if (telemetry.includeEvalDetails) attrs["error.message"] = truncate(err instanceof Error ? err.message : String(err));
607
725
  }
608
726
  return attrs;
609
727
  }
@@ -612,8 +730,8 @@ function rootStatus(outcome) {
612
730
  if (!outcome?.result) return STATUS_UNSET;
613
731
  return outcome.result.kind === "winner" ? STATUS_OK : STATUS_ERROR;
614
732
  }
615
- function rootMessage(outcome) {
616
- if (outcome?.error !== void 0) return truncate(outcome.error instanceof Error ? outcome.error.message : String(outcome.error));
733
+ function rootMessage(outcome, telemetry) {
734
+ if (outcome?.error !== void 0 && telemetry.includeEvalDetails) return truncate(outcome.error instanceof Error ? outcome.error.message : String(outcome.error));
617
735
  const result = outcome?.result;
618
736
  return result && result.kind === "no-winner" ? result.reason : void 0;
619
737
  }
@@ -647,8 +765,16 @@ function assignBudget(attrs, value) {
647
765
  if (!isRecord(value)) return;
648
766
  const budget = value;
649
767
  if (typeof budget.maxTokens === "number") attrs["tangle.supervise.budget.max_tokens"] = budget.maxTokens;
650
- if (typeof budget.maxIterations === "number") attrs["tangle.supervise.budget.max_iterations"] = budget.maxIterations;
768
+ if (typeof budget.maxIterations === "number") {
769
+ attrs["tangle.supervise.budget.max_iterations"] = budget.maxIterations;
770
+ attrs[ATTR.maxIterations] = budget.maxIterations;
771
+ }
651
772
  if (typeof budget.maxUsd === "number") attrs["tangle.supervise.budget.max_usd"] = budget.maxUsd;
773
+ if (typeof budget.deadlineMs === "number") attrs["tangle.supervise.budget.deadline_ms"] = budget.deadlineMs;
774
+ for (const [name, cap] of Object.entries(budget.resources ?? {})) {
775
+ attrs[`tangle.supervise.budget.resource.${name}.limit`] = cap.limit;
776
+ attrs[`tangle.supervise.budget.resource.${name}.unit`] = cap.unit;
777
+ }
652
778
  }
653
779
  /** A trace id is 32 hex chars: a valid caller-supplied one is used verbatim, anything else (and the
654
780
  * default) is DERIVED by content address from namespace and run id, so a resumed run rejoins its trace. */
@@ -664,6 +790,7 @@ function str(value) {
664
790
  return typeof value === "string" && value.length > 0 ? value : void 0;
665
791
  }
666
792
  function truncate(value) {
793
+ value = String(defaultRedactor(value));
667
794
  return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
668
795
  }
669
796
  // src/runtime/anytime.ts
@@ -4960,7 +5087,7 @@ function driverRetryLimits(run) {
4960
5087
  function extend(streak, error, at) {
4961
5088
  const chain = causeChain(error);
4962
5089
  const root = chain.find((cause) => !(cause instanceof RetainedExecutionPendingError)) ?? error;
4963
- const code = chain.find((cause) => cause instanceof HarnessTurnFailedError)?.errorCode;
5090
+ const code = turnFailureOf(error)?.code ?? chain.find((cause) => cause instanceof HarnessTurnFailedError)?.errorCode;
4964
5091
  const text = (code ? errMessage(root).replace(` (${code})`, "") : errMessage(root)).replace(/\d{4}-\d\d-\d\dT[\d:.]+Z?/gu, "<time>").replace(/\b(?=[\da-f-]*\d)[\da-f]{8,}(?:-[\da-f]{4,})*\b/giu, "<id>").replace(/\d{6,}/gu, "<n>");
4965
5092
  if (streak?.error !== text || (streak.code ?? code) !== (code ?? streak.code)) return {
4966
5093
  error: text,
@@ -5114,10 +5241,12 @@ var DriverRetryLoop = class {
5114
5241
  };
5115
5242
  }
5116
5243
  failureRecord(failure) {
5244
+ const producerFailure = turnFailureOf(failure.error);
5117
5245
  return {
5118
5246
  attempt: failure.attempt,
5119
5247
  durationMs: failure.durationMs,
5120
5248
  error: errMessage(failure.error),
5249
+ ...producerFailure === void 0 ? {} : { failure: producerFailure },
5121
5250
  classification: failure.classification,
5122
5251
  ...failure.classification === "transient" ? { failureKind: transientFailureKind(failure.error) } : {},
5123
5252
  madeProgress: failure.progressed
@@ -5359,10 +5488,10 @@ var DriverRetryLoop = class {
5359
5488
  this.refusals = 0;
5360
5489
  this.abandonments = 0;
5361
5490
  const durationMs = this.limits.now() - startedAt;
5362
- const after = run.progress();
5491
+ let after = run.progress();
5363
5492
  const progressed = madeProgress(before, after);
5364
- const contract = contractOf(after);
5365
- const completed = {
5493
+ let contract = contractOf(after);
5494
+ let completed = {
5366
5495
  attempt,
5367
5496
  durationMs,
5368
5497
  madeProgress: progressed,
@@ -5373,7 +5502,18 @@ var DriverRetryLoop = class {
5373
5502
  this.stopPauses = 0;
5374
5503
  this.lastProgressAt = this.limits.now();
5375
5504
  } else if (!this.beforeModelEvent && this.reentry !== void 0 && this.reentry.reason !== "wake" && contract === "unmet") this.barrenReentries += 1;
5376
- if (run.wait !== void 0 && contract !== "met" && await this.wake(attempt, completed)) return true;
5505
+ if (run.wait !== void 0 && contract !== "met") {
5506
+ const waited = await this.wake(attempt, completed, after);
5507
+ if (waited.reentered) return true;
5508
+ after = waited.progress;
5509
+ contract = contractOf(after);
5510
+ completed = {
5511
+ attempt,
5512
+ durationMs,
5513
+ madeProgress: madeProgress(before, after),
5514
+ ...contract === "none" ? {} : { contract }
5515
+ };
5516
+ }
5377
5517
  if (contract === "unmet" && continuation !== void 0) {
5378
5518
  let decision = await this.decideContinuation(continuation, attempt, after);
5379
5519
  while ("refusedBy" in decision && decision.refusedBy === "budget-exhausted") {
@@ -5414,17 +5554,36 @@ var DriverRetryLoop = class {
5414
5554
  });
5415
5555
  return false;
5416
5556
  }
5417
- async wake(attempt, completed, held) {
5557
+ async wake(attempt, completed, beforeWait, held) {
5418
5558
  const { run } = this;
5419
5559
  const wait = run.wait;
5420
- if (wait === void 0 || (run.continuation?.closed() ?? false) || run.signal.aborted || !wait.open()) return false;
5560
+ if (wait === void 0 || (run.continuation?.closed() ?? false) || run.signal.aborted || !wait.open()) return {
5561
+ reentered: false,
5562
+ progress: beforeWait
5563
+ };
5421
5564
  const stop = budgetStop(run.budget(), this.limits.now());
5422
- if (stop === "deadline" || stop !== void 0 && this.pausesStop(stop)) return false;
5565
+ if (stop === "deadline" || stop !== void 0 && this.pausesStop(stop)) return {
5566
+ reentered: false,
5567
+ progress: beforeWait
5568
+ };
5423
5569
  const woken = await wait.wake(attempt + 1);
5424
- if (woken === void 0 || run.signal.aborted) return false;
5570
+ const afterWait = run.progress();
5571
+ if (madeProgress(beforeWait, afterWait)) {
5572
+ completed = {
5573
+ ...completed,
5574
+ madeProgress: true
5575
+ };
5576
+ this.barrenReentries = 0;
5577
+ this.stopPauses = 0;
5578
+ this.lastProgressAt = this.limits.now();
5579
+ }
5580
+ if (woken === void 0 || run.signal.aborted) return {
5581
+ reentered: false,
5582
+ progress: afterWait
5583
+ };
5425
5584
  const input = held ? `${held.input}\n\n${woken.input}` : woken.input;
5426
5585
  const idleMs = woken.idleMs + (held?.idleMs ?? 0);
5427
- if (budgetStop(run.budget(), this.limits.now()) !== void 0) return this.wake(attempt, completed, {
5586
+ if (budgetStop(run.budget(), this.limits.now()) !== void 0) return this.wake(attempt, completed, afterWait, {
5428
5587
  input,
5429
5588
  idleMs
5430
5589
  });
@@ -5439,7 +5598,10 @@ var DriverRetryLoop = class {
5439
5598
  input,
5440
5599
  wake: this.wakes
5441
5600
  };
5442
- return true;
5601
+ return {
5602
+ reentered: true,
5603
+ progress: afterWait
5604
+ };
5443
5605
  }
5444
5606
  };
5445
5607
  // src/runtime/supervise/driver-retry.ts
@@ -7815,8 +7977,7 @@ var DriverExecutionAttempt = class {
7815
7977
  sink.state.driveTurns += 1;
7816
7978
  if (turnStop !== void 0 && turns >= sink.turnCap && !turnStop.signal.aborted) turnStop.abort(`supervise: maxTurns ${sink.turnCap} reached`);
7817
7979
  } else if (event.kind === "progress") {
7818
- sink.rootStream?.append(event.progress);
7819
- sink.noteDriveProgress(event.progress);
7980
+ sink.observeProgress(event.progress);
7820
7981
  sink.onModelEvent?.();
7821
7982
  } else this.pendingUsage.push(event);
7822
7983
  await this.meterPending();
@@ -8088,13 +8249,18 @@ var ManagerDriveSession = class {
8088
8249
  const paused = [...await seatSelection.journal.loadTree(seatJournalRoot) ?? []].reverse().find((event) => event.id === scope.view.root && (event.kind === "seat-paused" || event.kind === "seat-segment" && event.phase === "started"));
8089
8250
  let pausedUntil = paused?.kind === "seat-paused" ? paused.resumeAt : void 0;
8090
8251
  let afterRecheck = pausedUntil !== void 0 && Date.parse(pausedUntil) <= now();
8252
+ let resumeAdmission;
8091
8253
  for (;;) try {
8092
8254
  const seat = await seatChain.next(usageLimit && !afterRecheck, afterRecheck);
8255
+ await resumeAdmission?.();
8093
8256
  this.activeSeat = seat;
8094
8257
  if (afterRecheck) await seatSelection.onPause(scope.view.root, "", "resumed");
8095
8258
  return seat;
8096
8259
  } catch (error) {
8097
8260
  if (!(error instanceof SeatPauseError)) throw error;
8261
+ resumeAdmission = await pauseScopeSeatAdmission(scope, error.resumeAt);
8262
+ await releaseScopeRetainedOwnerForSeatPause(scope, error.resumeAt).catch(() => void 0);
8263
+ resumeAdmission = await pauseScopeSeatAdmission(scope, error.resumeAt);
8098
8264
  if (error.resumeAt !== pausedUntil) {
8099
8265
  pausedUntil = error.resumeAt;
8100
8266
  await seatSelection.journal.appendEvent(seatJournalRoot, {
@@ -8107,7 +8273,6 @@ var ManagerDriveSession = class {
8107
8273
  });
8108
8274
  await seatSelection.onPause(scope.view.root, error.resumeAt, "paused");
8109
8275
  }
8110
- await releaseScopeRetainedOwnerForSeatPause(scope, error.resumeAt).catch(() => void 0);
8111
8276
  const wakeAt = Date.now() + Math.max(0, Date.parse(error.resumeAt) - now());
8112
8277
  while (Date.now() < wakeAt) {
8113
8278
  scope.signal.throwIfAborted();
@@ -8143,10 +8308,16 @@ async function executeDriverAttempt(input) {
8143
8308
  ...input.coordinationMcpHeaders ? { headers: input.coordinationMcpHeaders } : {},
8144
8309
  metadata: { toolTimeoutMs: COORDINATION_CLIENT_TOOL_TIMEOUT_MS }
8145
8310
  };
8146
- const executor = (reusedAttemptFactory(input) ?? await providerAttemptFactory(input, identity.providerProfile.harness))(spec, {
8311
+ const factory = reusedAttemptFactory(input) ?? await providerAttemptFactory(input, identity.providerProfile.harness);
8312
+ const observation = scopeOwnerExecutionObservation(scope, (event) => {
8313
+ input.rootStream?.append(event);
8314
+ input.noteDriveProgress(event);
8315
+ });
8316
+ const executor = factory(spec, {
8147
8317
  signal: scope.signal,
8148
8318
  node: scopeOwnerExecutorNodeContext(scope),
8149
8319
  seams: {
8320
+ [executorObservationSeamKey]: observation,
8150
8321
  ...retainedOwner ? { [retainedExecutorSeamKey]: {
8151
8322
  ...retainedOwner,
8152
8323
  onResult: async (result) => attempt.commitOwnerResult(result)
@@ -8174,7 +8345,10 @@ async function executeDriverAttempt(input) {
8174
8345
  if (retainedOwner?.admissions.length && !executor.recover) throw new ValidationError("retained owner executor does not support recovery");
8175
8346
  await input.rootStream?.beginAttempt();
8176
8347
  const run = retainedOwner?.admissions.length ? executor.recover(input.originalTask, scope.signal) : executor.execute(input.originalTask, scope.signal);
8177
- if (isAsyncIterable(run)) await attempt.drainStream(run, input);
8348
+ if (isAsyncIterable(run)) await attempt.drainStream(run, {
8349
+ ...input,
8350
+ observeProgress: observation.progress
8351
+ });
8178
8352
  else await attempt.settleReturned(await run);
8179
8353
  await attempt.publishAcknowledgement(pending);
8180
8354
  attempt.completed = true;
@@ -8372,14 +8546,11 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
8372
8546
  };
8373
8547
  return attestRuntimeOwnedScopeOwner(Object.assign(drive, seatSelection ? { seatChain: true } : {}), manager.ownerRuntime);
8374
8548
  }
8375
- async function bindDriveRetainedOwner(manager, { scope, profile, authoredProfile }) {
8376
- const { state, activeSeat } = manager;
8549
+ async function bindDriveRetainedOwner(manager, { scope }) {
8550
+ const { state } = manager;
8377
8551
  const retainedOwner = state.boundBackend.backend === "provider" ? scopeRetainedOwnerContext(scope) : void 0;
8378
8552
  if (retainedOwner && state.boundBackend.backend === "provider") {
8379
- bindScopeRetainedOwnerProvider(scope, resolveAgentEnvironmentProvider(state.boundBackend.provider, state.boundBackend.registry), state.boundBackend.workspaceRetention === void 0 ? void 0 : {
8380
- port: state.boundBackend.workspaceRetention,
8381
- profile: activeSeat ? seatProviderProfile(authoredProfile, activeSeat) : profile
8382
- });
8553
+ bindScopeRetainedOwnerProvider(scope, resolveAgentEnvironmentProvider(state.boundBackend.provider, state.boundBackend.registry));
8383
8554
  bindScopeRetainedOwnerEnvironmentId(scope, () => {
8384
8555
  if (state.activeExecutor === void 0) return void 0;
8385
8556
  const execution = runtimeOwnedExecutorMaterialization(state.activeExecutor)?.execution;
@@ -8995,13 +9166,7 @@ function pendingCancellationRun(profile, task, opts) {
8995
9166
  if (backend?.backend === "provider" && !options.driveHarness && !options.resolveDriveHarness) {
8996
9167
  const provider = typeof backend.provider === "string" ? backend.registry?.get(backend.provider) : backend.provider;
8997
9168
  const priorProviders = new Set((prior ?? []).flatMap((event) => event.id === runId && event.kind === "execution-admitted" ? [event.admission.phase === "dispatched" ? event.admission.controlRef.provider : event.admission.provider] : []));
8998
- if (provider !== void 0 && priorProviders.size === 1 && priorProviders.has(provider.name)) attestRuntimeOwnedScopeOwner(rootAgent, root?.kind === "spawned" ? root.runtime : provider.name, {
8999
- provider,
9000
- ...backend.workspaceRetention === void 0 ? {} : { checkpointCapture: {
9001
- port: backend.workspaceRetention,
9002
- profile: providerVisibleProfile(canonicalProfile)
9003
- } }
9004
- });
9169
+ if (provider !== void 0 && priorProviders.size === 1 && priorProviders.has(provider.name)) attestRuntimeOwnedScopeOwner(rootAgent, root?.kind === "spawned" ? root.runtime : provider.name, { provider });
9005
9170
  }
9006
9171
  const result = await createSupervisor().run(rootAgent, canonicalTask, {
9007
9172
  budget,
@@ -9181,7 +9346,7 @@ function runHooks(options, recorder, workers) {
9181
9346
  }
9182
9347
  function rootRunOptions(run, runDir, hooks, recorder) {
9183
9348
  const { setup, workers } = run;
9184
- const { options, ctx, registeredProfile, managerBackend, rootOwnerRuntime } = setup;
9349
+ const { options, ctx, registeredProfile, rootOwnerRuntime } = setup;
9185
9350
  const recoverExecutor = options.recoverExecutor ?? workers.recoveryFactories.get(workers.workerFactory);
9186
9351
  return {
9187
9352
  budget: options.budget,
@@ -9208,7 +9373,6 @@ function rootRunOptions(run, runDir, hooks, recorder) {
9208
9373
  ...options.childSettleGraceMs !== void 0 ? { childSettleGraceMs: options.childSettleGraceMs } : {},
9209
9374
  ...options.teardownConfirmMs !== void 0 ? { teardownConfirmMs: options.teardownConfirmMs } : {},
9210
9375
  ...options.retainedAtSettlement !== void 0 ? { retainedAtSettlement: options.retainedAtSettlement } : {},
9211
- ownerWorkspaceRetention: managerBackend?.backend === "provider" && managerBackend.workspaceRetention !== void 0,
9212
9376
  ...options.workerSlots !== void 0 ? { workerSlots: options.workerSlots } : {},
9213
9377
  ...options.reservationPolicy ? { reservationPolicy: options.reservationPolicy } : {},
9214
9378
  ...options.deadlineCheckIn === void 0 ? {} : { deadlineCheckIn: options.deadlineCheckIn },
@@ -9282,4 +9446,4 @@ function superviseWithContext(profile, task, opts, brain) {
9282
9446
  }
9283
9447
  export { dumbContinuationPassPrompt as A, areaUnderCurve as B, defaultEdgeTraversalCap as C, createPromptRegistry as D, analyzesFindingsReportPrompt as E, allWorkersStalled as F, plateauLength as H, anyOf as I, noProgressFor as L, kernelPromptRegistry as M, naiveContinuationPrompt as N, delegatesWorkerBriefPrompt as O, promptHandle as P, plateau as R, validateFlowGraph as S, validateGraphTopology as T, renderAnytimeTable as U, bestSoFar as V, createSupervisorSpanRecorder as W, GraphRouteError as _, superviseRootProfile as a, journaledGateDecider as b, supervisorAgentWithTestBrain as c, composeReentryTask as d, serveCoordinationMcp as f, createGraphOverlay as g, runBrainLoop as h, profileGuidanceComposer as i, formatPromptHandle as j, dumbContinuationFailPrompt as k, runToolSpans as l, driverAgent as m, superviseFleetCapabilities as n, workerFromBackend as o, coordinationControlToolNames as p, superviseWithTestBrain as r, supervisorAgent as s, supervise as t, UNPROVEN_CONTINUITY as u, createFlowRun as v, graphRootProfile as w, routeFlowOf as x, flowRootProfile as y, anytimeReport as z };
9284
9448
 
9285
- //# sourceMappingURL=supervise-rYEsVVcn.js.map
9449
+ //# sourceMappingURL=supervise-Cqhkb2Oj.js.map