@tangle-network/agent-runtime 0.246.0 → 0.247.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 (61) hide show
  1. package/dist/{activation-C6d-NTWk.js → activation-DYqnl8zq.js} +2 -2
  2. package/dist/{activation-C6d-NTWk.js.map → activation-DYqnl8zq.js.map} +1 -1
  3. package/dist/{activation-Df-ae5Uq.d.ts → activation-DizpINK3.d.ts} +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-De8pyM57.js → coordination-driver-BV4AAUns.js} +20 -7
  7. package/dist/{coordination-driver-De8pyM57.js.map → coordination-driver-BV4AAUns.js.map} +1 -1
  8. package/dist/{delegate-DE6hNhbD.js → delegate-DQAzB5Xv.js} +2 -2
  9. package/dist/{delegate-DE6hNhbD.js.map → delegate-DQAzB5Xv.js.map} +1 -1
  10. package/dist/durable.d.ts +2 -2
  11. package/dist/durable.js +2 -2
  12. package/dist/{graph-s57f-VCR.js → graph-DcBmMLIp.js} +3 -3
  13. package/dist/{graph-s57f-VCR.js.map → graph-DcBmMLIp.js.map} +1 -1
  14. package/dist/{improvement-cycle-BE3gIJwL.js → improvement-cycle-B049YmQ8.js} +3 -3
  15. package/dist/{improvement-cycle-BE3gIJwL.js.map → improvement-cycle-B049YmQ8.js.map} +1 -1
  16. package/dist/{index-CAG31NtK.d.ts → index-DLzlXwr6.d.ts} +11 -6
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +7 -7
  19. package/dist/intelligence.d.ts +7 -5
  20. package/dist/intelligence.js +9 -8
  21. package/dist/intelligence.js.map +1 -1
  22. package/dist/kernel.d.ts +3 -3
  23. package/dist/kernel.js +9 -9
  24. package/dist/{loop-runner-bin-B_oSVrE7.d.ts → loop-runner-bin-HbMECmxT.d.ts} +3 -3
  25. package/dist/{loop-runner-bin-Bp8Mih20.js → loop-runner-bin-iqq1azfy.js} +3 -3
  26. package/dist/{loop-runner-bin-Bp8Mih20.js.map → loop-runner-bin-iqq1azfy.js.map} +1 -1
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +3 -3
  30. package/dist/mcp/index.d.ts +5 -5
  31. package/dist/mcp/index.js +4 -4
  32. package/dist/{openai-tools-B1GMKDjW.d.ts → openai-tools-DvLk_Ddg.d.ts} +2 -2
  33. package/dist/profiles.d.ts +2 -2
  34. package/dist/{provision-supervisor-D0X9KUv-.js → provision-supervisor-BgQx2Avp.js} +4 -4
  35. package/dist/{provision-supervisor-D0X9KUv-.js.map → provision-supervisor-BgQx2Avp.js.map} +1 -1
  36. package/dist/{run-layout-B8-Gqhpg.js → run-layout-hKAJGF4g.js} +6 -1
  37. package/dist/run-layout-hKAJGF4g.js.map +1 -0
  38. package/dist/{runtime-CHbVv5UI.js → runtime-HpTXhB3g.js} +9 -9
  39. package/dist/{runtime-CHbVv5UI.js.map → runtime-HpTXhB3g.js.map} +1 -1
  40. package/dist/{server-DwsC_FyV.js → server-OOE7mXrN.js} +3 -3
  41. package/dist/{server-DwsC_FyV.js.map → server-OOE7mXrN.js.map} +1 -1
  42. package/dist/{stream-agent-turn-DQ-W8mHf.d.ts → stream-agent-turn-CcumM0Bu.d.ts} +2 -2
  43. package/dist/{structural-rollout-DasmuuUp.js → structural-rollout-z1A0okaB.js} +2 -2
  44. package/dist/{structural-rollout-DasmuuUp.js.map → structural-rollout-z1A0okaB.js.map} +1 -1
  45. package/dist/{substrate-DJOnuoa_.d.ts → substrate-CQ0hfewn.d.ts} +2 -2
  46. package/dist/{supervise-o6CzD2Rt.js → supervise-DZEOpzRw.js} +11 -5
  47. package/dist/supervise-DZEOpzRw.js.map +1 -0
  48. package/dist/{supervisor-tGq-TPIv.js → supervisor-BIBWUFUr.js} +165 -48
  49. package/dist/supervisor-BIBWUFUr.js.map +1 -0
  50. package/dist/testing.d.ts +2 -2
  51. package/dist/testing.js +12 -12
  52. package/dist/{top-app-DL-sjv7K.js → top-app-d-bmwO7O.js} +2 -2
  53. package/dist/{top-app-DL-sjv7K.js.map → top-app-d-bmwO7O.js.map} +1 -1
  54. package/dist/tui/bin.js +1 -1
  55. package/dist/tui/index.d.ts +1 -1
  56. package/dist/tui/index.js +2 -2
  57. package/dist/{types-BoEzH8V6.d.ts → types-BUhz284C.d.ts} +23 -10
  58. package/package.json +1 -1
  59. package/dist/run-layout-B8-Gqhpg.js.map +0 -1
  60. package/dist/supervise-o6CzD2Rt.js.map +0 -1
  61. package/dist/supervisor-tGq-TPIv.js.map +0 -1
@@ -8117,13 +8117,12 @@ async function* streamProviderExecutor(args) {
8117
8117
  let usd = 0;
8118
8118
  let text = "";
8119
8119
  let terminal = false;
8120
- let explicitFailure = false;
8121
8120
  let settled;
8122
8121
  let failure;
8123
8122
  let failed = false;
8124
8123
  try {
8125
8124
  const toolParts = createSandboxToolPartState();
8126
- const outcomeTracker = createAgentRunOutcomeTracker();
8125
+ const failures = createProviderFailureLedger();
8127
8126
  for await (const event of source.events) {
8128
8127
  archive.append(event);
8129
8128
  text += textFromEnvironmentEvent(event);
@@ -8137,11 +8136,7 @@ async function* streamProviderExecutor(args) {
8137
8136
  args.trace.record(step);
8138
8137
  }
8139
8138
  }
8140
- const failureEvent = providerFailureEvent(event, sandboxEvent);
8141
- if (failureEvent) {
8142
- explicitFailure = true;
8143
- outcomeTracker.observe(failureEvent);
8144
- }
8139
+ failures.observe(event, sandboxEvent);
8145
8140
  for (const progress of sandboxProgressEvents(sandboxEvent, toolParts)) yield {
8146
8141
  kind: "progress",
8147
8142
  progress
@@ -8173,10 +8168,11 @@ async function* streamProviderExecutor(args) {
8173
8168
  yield { kind: "iteration" };
8174
8169
  const harnessTranscript = await captureHarnessTranscript(environment, args.profile.harness, linked);
8175
8170
  args.onHarnessTranscript(harnessTranscript);
8171
+ const outcome = failures.finish();
8176
8172
  const result = {
8177
8173
  ...resultFromEvents(archive.events(), text),
8178
8174
  ...archive.superseded > 0 ? { supersededPartUpdates: archive.superseded } : {},
8179
- ...explicitFailure ? { outcome: outcomeTracker.finish() } : {}
8175
+ ...outcome ? { outcome } : {}
8180
8176
  };
8181
8177
  const spent = {
8182
8178
  iterations: 1,
@@ -8644,21 +8640,16 @@ function environmentAsSandboxInstance(environment, options) {
8644
8640
  let text = "";
8645
8641
  let usage;
8646
8642
  let terminal = false;
8647
- const outcomeTracker = createAgentRunOutcomeTracker();
8648
- let explicitFailure = false;
8643
+ const failures = createProviderFailureLedger();
8649
8644
  for await (const event of environment.stream(turnInputFromPrompt(message, promptOptions))) {
8650
8645
  events.push(event);
8651
8646
  if (isTerminalEnvironmentEvent(event)) terminal = true;
8652
- const failureEvent = providerFailureEvent(event, sandboxEventFromEnvironmentEvent(event));
8653
- if (failureEvent) {
8654
- explicitFailure = true;
8655
- outcomeTracker.observe(failureEvent);
8656
- }
8647
+ failures.observe(event, sandboxEventFromEnvironmentEvent(event));
8657
8648
  text += textFromEnvironmentEvent(event);
8658
8649
  usage = mergeTokenUsage(usage, event.usage);
8659
8650
  }
8660
8651
  if (options.requireTerminalEvent && !terminal) throw new ValidationError(`providerAsSandboxClient(${environment.provider}): prompt ended without a terminal result/done/status event`);
8661
- const outcome = explicitFailure ? outcomeTracker.finish() : void 0;
8652
+ const outcome = failures.finish();
8662
8653
  return {
8663
8654
  response: resultFromEvents(events, text).content,
8664
8655
  success: outcome?.success ?? true,
@@ -8994,6 +8985,79 @@ function providerFailureEvent(event, sandboxEvent) {
8994
8985
  }
8995
8986
  };
8996
8987
  }
8988
+ /** The statuses the sandbox outcome tracker itself reads as success, so a frame that would settle
8989
+ * `success: true` there is the same frame that supersedes a transient error here. */
8990
+ const TERMINAL_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
8991
+ "completed",
8992
+ "done",
8993
+ "ok",
8994
+ "success"
8995
+ ]);
8996
+ /**
8997
+ * Whether a frame says, explicitly, that the run succeeded: a raw or normalized
8998
+ * `status: completed` (the same form `isTerminalEnvironmentEvent` reads as terminal), or a
8999
+ * terminal `done`/`result` with `success: true` or a success status on the frame, its outcome,
9000
+ * or its nested result. An empty `done` says nothing and supersedes nothing — the stream that
9001
+ * ends `status: failed` then `done: {}` stays failed.
9002
+ */
9003
+ function providerTerminalSuccess(event, sandboxEvent) {
9004
+ if (event.type === "status" && event.data.status === "completed") return true;
9005
+ if (event.normalized?.type === "status" && event.normalized.status === "completed") return true;
9006
+ if (sandboxEvent.type !== "done" && sandboxEvent.type !== "result") return false;
9007
+ const data = sandboxEvent.data;
9008
+ if (data.success === true) return true;
9009
+ if (data.success === false) return false;
9010
+ const outcome = recordValue(data.outcome);
9011
+ const result = recordValue(data.result);
9012
+ return [
9013
+ data.status,
9014
+ outcome?.type,
9015
+ outcome?.status,
9016
+ result?.status
9017
+ ].some((status) => typeof status === "string" && TERMINAL_SUCCESS_STATUSES.has(status));
9018
+ }
9019
+ /**
9020
+ * Holds a stream's failure frames until it ends, so the terminal frame decides the outcome.
9021
+ *
9022
+ * The sandbox outcome tracker latches the first `error` frame as the run's error and settles
9023
+ * `failed` on it whatever the terminal frame says; and until this ledger existed the runtime
9024
+ * only ever showed the tracker its failure frames, so a terminal `success: true` was never in
9025
+ * evidence at all. A transport error that the harness recovered from — a stream break the
9026
+ * sidecar re-attached, a tool backend that failed once — therefore settled the whole child
9027
+ * `down` with the transient error as its reason, and the artifact the child had banked was
9028
+ * discarded. On the 2026-09-20 fleet corpus, 25 children that finished their work settled that
9029
+ * way.
9030
+ *
9031
+ * The rule: `error` frames are forgiven when the stream reports success and carries no verdict;
9032
+ * a failed status or a failed terminal frame is the provider's own verdict on the run, and once
9033
+ * one exists every failure frame is evidence again, in order, so the tracker names the first
9034
+ * `error` as it always did. The existing contracts hold unchanged: `status: failed` then
9035
+ * `done: {}` is failed, and the retained Claude tail `completed → failed → error → done` is
9036
+ * failed with the error frame's message. The forgiven frames stay in the event archive the trace
9037
+ * reads; only the outcome stops claiming them.
9038
+ */
9039
+ function createProviderFailureLedger() {
9040
+ const failures = [];
9041
+ let verdicts = 0;
9042
+ let succeeded = false;
9043
+ return {
9044
+ observe(event, sandboxEvent) {
9045
+ const failureEvent = providerFailureEvent(event, sandboxEvent);
9046
+ if (failureEvent) {
9047
+ failures.push(failureEvent);
9048
+ if (failureEvent.type !== "error") verdicts += 1;
9049
+ return;
9050
+ }
9051
+ if (providerTerminalSuccess(event, sandboxEvent)) succeeded = true;
9052
+ },
9053
+ finish() {
9054
+ if (failures.length === 0 || verdicts === 0 && succeeded) return void 0;
9055
+ const tracker = createAgentRunOutcomeTracker();
9056
+ for (const frame of failures) tracker.observe(frame);
9057
+ return tracker.finish();
9058
+ }
9059
+ };
9060
+ }
8997
9061
  function recordValue(value) {
8998
9062
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
8999
9063
  }
@@ -13410,6 +13474,62 @@ function executorFailure(result) {
13410
13474
  function executorFailureReason(result) {
13411
13475
  return executorFailure(result)?.error;
13412
13476
  }
13477
+ /**
13478
+ * The platform's own failure vocabulary: machine codes and lifecycle messages that the sandbox
13479
+ * runtime, the router, or the egress path put in an executor envelope when the platform, not
13480
+ * the agent's work, ended the execution. Each entry names its evidence: the count is how many
13481
+ * down children carried it on the 2026-09-20 fleet corpus (277 down settlements across 691
13482
+ * runs), every one of them stamped `infra: false` by the hard-coded call site this table
13483
+ * replaced. The table is deliberately the platform's fixed strings, not the agent's prose.
13484
+ */
13485
+ const PLATFORM_FAILURE_CODES = new Set([
13486
+ "QUOTA_EXCEEDED",
13487
+ "provider_quota_exceeded",
13488
+ "buffer.overflow",
13489
+ "TIMEOUT",
13490
+ "ECONNRESET",
13491
+ "ECONNREFUSED",
13492
+ "ETIMEDOUT",
13493
+ "EPIPE",
13494
+ "EADDRINUSE"
13495
+ ].map((code) => code.toLowerCase()));
13496
+ const PLATFORM_FAILURE_MESSAGES = [
13497
+ /^terminated$/u,
13498
+ /Execution exceeded its time limit/u,
13499
+ /Execution interrupted: the agent runtime restarted/u,
13500
+ /Platform key[- ]verification/u,
13501
+ /Platform key delegation failed/u,
13502
+ /Bad Gateway/iu,
13503
+ /Cannot connect to API/u,
13504
+ /Failed to connect to Sandbox API/u,
13505
+ /fetch failed/u,
13506
+ /A sandbox lifecycle operation is already in progress/u,
13507
+ /exceeded its string bound/u,
13508
+ /exceeds its JSON bound/u,
13509
+ /No provider served model/u,
13510
+ /Invalid API key/u,
13511
+ /provider_quota_exceeded|QUOTA_EXCEEDED|rate limit/iu,
13512
+ /is at its box cap/u,
13513
+ /could not materialize the seat credential/u,
13514
+ /OpenCode exited while a model step was still in progress/u,
13515
+ /the agent runtime restarted/u
13516
+ ];
13517
+ /**
13518
+ * Whether an executor envelope's failure was the platform's, as far as the envelope can say.
13519
+ *
13520
+ * `true` when the code or the message is in the platform's own vocabulary above. `undefined`
13521
+ * otherwise: the harness reported a failure and nothing in the envelope attributes it, so the
13522
+ * settlement carries no `infra` claim at all rather than a false one. This path never answers
13523
+ * `false`, because an executor envelope cannot prove the agent's work was at fault; the throw
13524
+ * path in `scope.ts` still answers `false` for an ordinary thrown result, where the runtime does
13525
+ * know. Until this function existed both envelope sites stamped `infra: false` unconditionally,
13526
+ * and the flag caught 1 of the 78 platform losses it was checked against on the fleet corpus.
13527
+ */
13528
+ function executorFailureInfra(failure) {
13529
+ const code = failure.errorCode?.toLowerCase();
13530
+ if (code !== void 0 && PLATFORM_FAILURE_CODES.has(code)) return true;
13531
+ return PLATFORM_FAILURE_MESSAGES.some((pattern) => pattern.test(failure.error)) ? true : void 0;
13532
+ }
13413
13533
  /** Preserve deterministic result pointers across built-in executors and replay.
13414
13534
  * FNV-1a is an identity convention here, not a cryptographic integrity check. */
13415
13535
  function contentRef(prefix, value) {
@@ -16294,7 +16414,7 @@ async function replaySpawnTree(journal, blobs, root) {
16294
16414
  handle: handleFor(ev.id, "cancelled"),
16295
16415
  reason: ev.reason,
16296
16416
  ...ev.outRef === void 0 ? {} : { outRef: ev.outRef },
16297
- infra: ev.infra === true,
16417
+ ...ev.infra === void 0 ? {} : { infra: ev.infra },
16298
16418
  ...ev.providerModel === void 0 ? {} : { providerModel: copyProviderModelEvidence(ev.providerModel) },
16299
16419
  ...budgetViolationOf(ev),
16300
16420
  trace: ev.trace ?? {
@@ -16317,7 +16437,7 @@ async function replaySpawnTree(journal, blobs, root) {
16317
16437
  handle: handleFor(ev.id, "failed"),
16318
16438
  reason: ev.reason ?? ev.verdict?.notes ?? "child down",
16319
16439
  ...ev.outRef === void 0 ? {} : { outRef: ev.outRef },
16320
- infra: ev.infra === true,
16440
+ ...ev.infra === void 0 ? {} : { infra: ev.infra },
16321
16441
  ...ev.providerModel === void 0 ? {} : { providerModel: copyProviderModelEvidence(ev.providerModel) },
16322
16442
  ...budgetViolationOf(ev),
16323
16443
  trace,
@@ -20089,7 +20209,7 @@ function stableText(value, label) {
20089
20209
  function settlementFields(subject, settlement) {
20090
20210
  return {
20091
20211
  spent: subject.spent,
20092
- infra: settlement.infra,
20212
+ ...settlement.infra === void 0 ? {} : { infra: settlement.infra },
20093
20213
  reason: settlement.reason,
20094
20214
  ...settlement.retainedPendingCause === void 0 ? {} : { retainedPendingCause: settlement.retainedPendingCause },
20095
20215
  ...settlement.outRef ? { outRef: settlement.outRef } : {},
@@ -20151,7 +20271,7 @@ function releasedChildPayload(subject, settlement, settledAt, releasedAt) {
20151
20271
  releasedAt,
20152
20272
  ...settlement.outRef === void 0 ? {} : { outRef: settlement.outRef },
20153
20273
  reason: settlement.reason,
20154
- infra: settlement.infra,
20274
+ ...settlement.infra === void 0 ? {} : { infra: settlement.infra },
20155
20275
  spent: subject.spent,
20156
20276
  ...settledNodeEvidence(subject, {
20157
20277
  ...settlement,
@@ -20179,8 +20299,9 @@ function journaledEnvironmentId(owned) {
20179
20299
  *
20180
20300
  * The gate is fail-closed, every clause required, because the heal cannot re-ask the executor
20181
20301
  * to confirm teardown the way the sweep does:
20182
- * - the latest `reconciled` record carries `settledSeq`, `reason`, `infra` and `trace` (a record
20183
- * written before those fields existed names no cursor position and is not healed);
20302
+ * - the latest `reconciled` record carries `settledSeq`, `reason` and `trace` (a record written
20303
+ * before those fields existed names no cursor position and is not healed; `infra` is carried
20304
+ * when present and never required, since an unattributable envelope failure has none);
20184
20305
  * - at least one receipt sits after that record and every such receipt reads `destroyed: true`
20185
20306
  * (an empty set must not close the slot vacuously, and a receipt from an earlier process
20186
20307
  * belongs to an earlier settlement);
@@ -20206,7 +20327,7 @@ async function healReleasedSlots(opts, signal, now) {
20206
20327
  if (closed.has(spawned.id) || recorded.has(spawned.id)) continue;
20207
20328
  const owned = events.filter((event) => event.id === spawned.id);
20208
20329
  const floor = owned.reduce((latest, event) => event.kind === "reconciled" && (latest === void 0 || event.seq > latest.seq) ? event : latest, void 0);
20209
- if (floor?.settledSeq === void 0 || floor.reason === void 0 || floor.infra === void 0 || floor.trace === void 0) continue;
20330
+ if (floor?.settledSeq === void 0 || floor.reason === void 0 || floor.trace === void 0) continue;
20210
20331
  const receipts = owned.slice(owned.indexOf(floor) + 1).filter((event) => event.kind === "environment-teardown");
20211
20332
  if (receipts.length === 0 || !receipts.every((receipt) => receipt.destroyed)) continue;
20212
20333
  const held = journaledEnvironmentId(owned);
@@ -20222,7 +20343,7 @@ async function healReleasedSlots(opts, signal, now) {
20222
20343
  const settlement = {
20223
20344
  kind: "down",
20224
20345
  reason: floor.reason,
20225
- infra: floor.infra,
20346
+ ...floor.infra === void 0 ? {} : { infra: floor.infra },
20226
20347
  trace: floor.trace,
20227
20348
  ...floor.outRef ? { outRef: floor.outRef } : {},
20228
20349
  ...floor.providerModel ? { providerModel: floor.providerModel } : {},
@@ -20329,17 +20450,16 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
20329
20450
  let seq = reservedCursorFloor(events) + 1;
20330
20451
  for (const { result, fault, budgetViolation } of accepted) {
20331
20452
  signal.throwIfAborted();
20332
- const failureReason = executorFailureReason(result);
20333
- const reason = fault ?? failureReason;
20453
+ const failure = executorFailure(result);
20454
+ const reason = fault ?? failure?.error;
20455
+ const infra = fault !== void 0 ? true : failure === void 0 ? void 0 : executorFailureInfra(failure);
20334
20456
  await opts.journal.appendEvent(opts.runId, {
20335
20457
  kind: "settled",
20336
20458
  id: result.id,
20337
20459
  status: reason === void 0 ? "done" : "down",
20338
20460
  outRef: result.outRef,
20339
- ...reason === void 0 ? {} : {
20340
- infra: fault !== void 0,
20341
- reason
20342
- },
20461
+ ...reason === void 0 ? {} : { reason },
20462
+ ...infra === void 0 ? {} : { infra },
20343
20463
  spent: result.spent,
20344
20464
  ...budgetViolation === void 0 ? {} : { budgetViolation },
20345
20465
  ...result.verdict ? { verdict: result.verdict } : {},
@@ -22767,7 +22887,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
22767
22887
  status: "down",
22768
22888
  ...settlement.outRef === void 0 ? {} : { outRef: settlement.outRef },
22769
22889
  reason: settlement.reason,
22770
- infra: settlement.infra,
22890
+ ...settlement.infra === void 0 ? {} : { infra: settlement.infra },
22771
22891
  ...retainedExecution,
22772
22892
  spent: child.spent,
22773
22893
  ...settledNodeEvidence(child, settlement, settledAt)
@@ -22777,7 +22897,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
22777
22897
  kind: "down",
22778
22898
  handle,
22779
22899
  reason: settlement.reason,
22780
- infra: settlement.infra,
22900
+ ...settlement.infra === void 0 ? {} : { infra: settlement.infra },
22781
22901
  ...retainedExecution,
22782
22902
  ...settlement.outRef === void 0 ? {} : { outRef: settlement.outRef },
22783
22903
  ...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
@@ -22860,7 +22980,7 @@ async function finalizeWait(child, settlement, seq, args, now, handle) {
22860
22980
  kind: "down",
22861
22981
  handle,
22862
22982
  reason: settlement.reason,
22863
- infra: settlement.infra,
22983
+ ...settlement.infra === void 0 ? {} : { infra: settlement.infra },
22864
22984
  trace: settlement.trace,
22865
22985
  settledAt,
22866
22986
  seq
@@ -23044,11 +23164,11 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
23044
23164
  return downRecord("aborted before settle", true, trace, ownMetered, runtimeOwnedExecutorProviderEvidence(executor), retainedOutputRef, childHarnessTranscript);
23045
23165
  }
23046
23166
  const outRef = artifact.outRef;
23047
- const failureReason = executorFailureReason(artifact);
23048
- if (failureReason !== void 0) {
23167
+ const failure = executorFailure(artifact);
23168
+ if (failure !== void 0) {
23049
23169
  await teardownOnce(opts.shutdown ?? 5e3).catch(() => void 0);
23050
23170
  return {
23051
- ...downRecord(failureReason, false, trace, ownMetered, runtimeOwnedExecutorProviderEvidence(executor), void 0, childHarnessTranscript),
23171
+ ...downRecord(failure.error, executorFailureInfra(failure), trace, ownMetered, runtimeOwnedExecutorProviderEvidence(executor), void 0, childHarnessTranscript),
23052
23172
  outRef
23053
23173
  };
23054
23174
  }
@@ -23078,9 +23198,9 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
23078
23198
  const trace = await captureTraceOnce();
23079
23199
  await teardownOnce(opts.shutdown ?? 5e3).catch(() => void 0);
23080
23200
  const metered = executor.metered?.();
23081
- const failureReason = executorFailureReason(accepted);
23082
- if (failureReason !== void 0) return {
23083
- ...downRecord(failureReason, false, trace, metered, runtimeOwnedExecutorProviderEvidence(executor), void 0, await persistTranscriptOnce()),
23201
+ const failure = executorFailure(accepted);
23202
+ if (failure !== void 0) return {
23203
+ ...downRecord(failure.error, executorFailureInfra(failure), trace, metered, runtimeOwnedExecutorProviderEvidence(executor), void 0, await persistTranscriptOnce()),
23084
23204
  outRef: accepted.outRef
23085
23205
  };
23086
23206
  return {
@@ -23387,7 +23507,7 @@ function downRecord(reason, infra, trace, metered, providerModel, outRef, harnes
23387
23507
  return {
23388
23508
  kind: "down",
23389
23509
  reason,
23390
- infra,
23510
+ ...infra === void 0 ? {} : { infra },
23391
23511
  trace,
23392
23512
  ...harnessTranscript ? { harnessTranscript } : {},
23393
23513
  ...providerModel ? { providerModel } : {},
@@ -24641,7 +24761,6 @@ function createSupervisor() {
24641
24761
  let teardownSeq = 0;
24642
24762
  let executionAborted = controller.signal.aborted;
24643
24763
  let allChildrenDownAtSettle = false;
24644
- let downCountAtSettle = 0;
24645
24764
  try {
24646
24765
  await startScopeRecoveries(openScope);
24647
24766
  actOutcome = {
@@ -24657,7 +24776,6 @@ function createSupervisor() {
24657
24776
  closeScopeAdmission(openScope);
24658
24777
  executionAborted = controller.signal.aborted;
24659
24778
  allChildrenDownAtSettle = allSpawnedChildrenDown(runTree(openScope));
24660
- downCountAtSettle = breaker.downCount();
24661
24779
  if (!controller.signal.aborted && rootDeadlineAtMs > 0 && now() >= rootDeadlineAtMs) deadlineExceeded = true;
24662
24780
  clearRootDeadline?.();
24663
24781
  const settleGraceMs = !controller.signal.aborted ? boundedSettleGrace(opts.childSettleGraceMs, rootDeadlineAtMs, now) : 0;
@@ -24734,7 +24852,7 @@ function createSupervisor() {
24734
24852
  ...gaps.length > 0 ? { spendGaps: gaps } : {},
24735
24853
  fleetYield
24736
24854
  };
24737
- const lifecycle = classifyNoWinner(executionAborted, pool, opts, breaker, deadlineExceeded, allChildrenDownAtSettle, downCountAtSettle);
24855
+ const lifecycle = classifyNoWinner(executionAborted, pool, opts, breaker, deadlineExceeded, allChildrenDownAtSettle);
24738
24856
  if (controller.signal.reason instanceof RunCancellationReason) {
24739
24857
  const cancellation = controller.signal.reason;
24740
24858
  return {
@@ -24760,7 +24878,7 @@ function createSupervisor() {
24760
24878
  };
24761
24879
  return {
24762
24880
  ...common,
24763
- reason: "all-children-down"
24881
+ reason: "no-result-selected"
24764
24882
  };
24765
24883
  }
24766
24884
  } finally {
@@ -24950,17 +25068,16 @@ async function drainCursor(scope) {
24950
25068
  * the caller decide between the `driver-failed` arm (a rejection was captured) and the residual
24951
25069
  * bucket — and it is why `driver-failed` cannot be produced without an `error` to attach.
24952
25070
  */
24953
- function classifyNoWinner(abortedAtSettle, pool, opts, breaker, deadlineExceeded, allChildrenDownAtSettle, downCountAtSettle) {
25071
+ function classifyNoWinner(abortedAtSettle, pool, opts, breaker, deadlineExceeded, allChildrenDownAtSettle) {
24954
25072
  if (breaker.tripped()) return "all-children-down";
24955
25073
  if (deadlineExceeded) return "budget-exhausted";
24956
25074
  if (abortedAtSettle) return "aborted";
24957
25075
  if (allChildrenDownAtSettle) return "all-children-down";
24958
25076
  if (poolExhausted(pool, opts)) return "budget-exhausted";
24959
- if (downCountAtSettle > 0) return "all-children-down";
24960
25077
  }
24961
25078
  function allSpawnedChildrenDown(tree) {
24962
25079
  const children = tree.nodes.filter((node) => node.id !== tree.root);
24963
- return children.length > 0 && children.every((node) => node.status === "failed");
25080
+ return children.length > 0 && children.every((node) => node.status === "failed" || node.settlementPending?.kind === "down");
24964
25081
  }
24965
25082
  function poolExhausted(pool, opts) {
24966
25083
  const r = pool.readout();
@@ -25107,4 +25224,4 @@ function isNonEmptySpend(s) {
25107
25224
  //#endregion
25108
25225
  export { startRetainedInteractiveRun as $, withBudgetResources as $i, contentAddress as $n, writeAllBytes as $r, isPeerMailEnvelope as $t, validateWaitSpec as A, mapSandboxEvent as Ai, providerAsSandboxClient as An, localHarnessExecutable as Ar, workerTraceAnalysisStore as At, SPAWN_RESOURCE_PATH_MAX_BYTES as B, hasCompleteCacheBreakdown as Bi, linkAbort as Bn, promptControlProfileMaterialization as Br, workerTraceEnv as Bt, restoreScopeOwnerAcceptedExecution as C, readSandboxOutcome as Ci, routerBrain as Cn, runWorktreeHarness as Cr, materializeTreeView as Ct, isWaitOutcome as D, createSandboxUsageLedger as Di, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as Dn, DEFAULT_LOCAL_HARNESS as Dr, captureWorkerTraceEvidence as Dt, createWaitProbes as E, createSandboxToolPartState as Ei, observedModelMatchesDeclared as En, removeWorktree as Er, WORKER_TOOL_TRACE_SCHEMA_VERSION as Et, prepareScopeRetainedOwnerTask as F, sumSandboxUsage as Fi, sandboxSessionTraceSource as Fn, assertProfileMaterialization as Fr, newUsageTotals as Ft, readWorkerInteractiveAdmissions as G, stringifySafe as Gi, startRetainedRunInEnvironment as Gn, renderUnsupported as Gr, createActivityLog as Gt, hostDirectoryReader as H, promptCacheTokenClasses as Hi, reconnectRetainedRun as Hn, promptOnlyProfileMaterialization as Hr, workerTraceSeamKey as Ht, scopeRetainedOwnerContext as I, addSpend as Ii, registerRetainedExecutorPreparation as In, controlProfileMaterialization as Ir, spendFromUsageEvents as It, readWorkerInteractiveBinding as J, unmeteredSpend as Ji, defaultRedactorIdentityMaterial as Jn, validateProfileMaterialization as Jr, AUTHORITY_MARKERS as Jt, workerInteractiveAdmissionFile as K, throwAbort as Ki, retainedCreateMaterial as Kn, sandboxActProfileMaterialization as Kr, readWorkerProgress as Kt, scopeRetainedOwnerPriorSpend as L, chargedTokens as Li, retainedExecutorSeamKey as Ln, defineProfileMaterializationContract as Lr, spendFromUsageTotals as Lt, bindScopeRetainedOwnerEnvironmentId as M, notifySandboxEventObserver as Mi, sandboxClientAsProvider as Mn, CodexExecutionDiagnosticError as Mr, assertValidBudget as Mt, bindScopeRetainedOwnerProvider as N, sandboxEventServedBackend as Ni, createPushTraceSource as Nn, terminateProcessTreeAndConfirm as Nr, createBudgetPool as Nt, pollFor as O, extractLlmCallEvent as Oi, createAgentEnvironmentProviderRegistry as On, LOCAL_HARNESSES as Or, isTraceAnalysisStore as Ot, consumeScopeRetainedOwnerResult as P, sandboxProgressEvents as Pi, decodeToolPart as Pn, AGENT_PROFILE_MATERIALIZATION_AXES as Pr, meterUsageEvent as Pt, recoverRetainedInteractiveRun as Q, resourceTelemetry as Qi, persistHarnessTranscript as Qn, readCommittedJsonLines as Qr, createPeerMailbox as Qt, scopeRetainedOwnerResourceReader as R, cloneSpend as Ri, RunCancellationReason as Rn, fullProfileMaterialization as Rr, WORKER_TRACE_PROPAGATION as Rt, recordScopeOwnerMaterialization as S, projectSandboxOutcome as Si, readPromptOptions as Sn, runSettledCommand as Sr, loadSpawnForest as St, settledToIteration as T, canonicalStreamEventFromSandboxEvent as Ti, canonicalObservedModelParts as Tn, createWorktree as Tr, replaySpawnTree as Tt, resolveSpawnResourcePaths as U, randomSuffix as Ui, recoverRetainedRun as Un, promptResourceProfileMaterialization as Ur, taskToPrompt as Ut, environmentReader as V, isAbortError$2 as Vi, runAbortable as Vn, promptModelProfileMaterialization as Vr, workerTraceHeaders as Vt, interactiveAdmissionSeamKey as W, sleep as Wi, startRetainedRun as Wn, renderProfileMaterializationIssues as Wr, DEFAULT_STALL_AFTER_MS as Wt, workerInteractiveBindingsDir as X, zeroSpend as Xi, captureHarnessTranscript as Xn, isNoEntError as Xr, PEER_MAIL_WIRE_KEY as Xt, workerInteractiveBindingFile as Y, withTimeout as Yi, resolveRedactor as Yn, worktreeCliProfileMaterialization as Yr, DEFAULT_PEER_MAIL_LIMITS as Yt, reconnectRetainedInteractiveRun as Z, addResourceSpend as Zi, harnessTranscriptArtifact as Zn, prepareJsonlAppend as Zr, claimsAuthority as Zt, beginScopeOwnerAttempt as _, unknownMaterializationReceipt as _i, runAgentRounds as _n, createRuntimeEventCollector as _r, FileResultBlobStore as _t, pickBestDelivered as a, teardownExecutor as aa, knownExecutionBindingReceipt as ai, bridgeAdmissionRefusal as an, buildLoopOtelSpans as ar, rollingDispatch as at, meterRuntimeOwnedAccounting as b, detachedFrozen as bi, acquireSandbox as bn, sanitizeKnowledgeReadinessReport as br, InMemorySpawnJournal as bt, DriverAttemptsExhaustedError as c, providerMessageText as ca, providerAttemptEvidence as ci, createCodexRolloutStoreReader as cn, createOpenInferenceFileExporter as cr, cliInPlaceExecutor as ct, defaultUnmetContractSteer as d, runtimeOwnedExecutorExecutionBinding as di, bridgeRuntimeAttachmentsKey as dn, flatOtelSpan as dr, createExecutorRegistry as dt, decodeHarnessUsage as ea, attestRuntimeOwnedPendingExecutor as ei, peerMailTools as en, createPropagatingTraceEmitter as er, destroyInteractiveEnvironment as et, runDriverWithRetry as f, runtimeOwnedExecutorMaterialization as fi, bridgeStopSignalKey as fn, generateSpanId as fr, snapshotExecutorConfig as ft, withDriverExecutor as g, unknownExecutionBindingReceipt as gi, isTerminalDecision as gn, toOtelAttributes as gr, createInPlaceCliExecutor as gt, isDriverSpec as h, runtimeOwnedScopeOwnerRuntime as hi, defaultSelectWinner as hn, padTraceId as hr, createSteerableSandboxSession as ht, collectDelivered as i, armDeadlineTimer as ia, inheritRuntimeOwnedExecutorAttestation as ii, executorFailure as in, INTELLIGENCE_WIRE_VERSION as ir, queueOf as it, waitUntil as j, mapSandboxToolEvent as ji, resolveAgentEnvironmentProvider as jn, parseCodexTokenUsage as jr, BudgetReconcileFault as jt, timerAt as k, isSandboxTerminalEvent as ki, providerAsExecutor as kn, harnessSupportsReasoningEffort as kr, parseWorkerToolTraceArtifact as kt, HarnessTurnFailedError as l, recordRuntimeOwnedDriveHarnessProviderEvidence as li, harnessUsageIsEmpty as ln, createOtelExporter as lr, cliWorktreeExecutor as lt, driverExecutorFactory as m, runtimeOwnedPendingExecutorMaterialization as mi, createSandboxForSpec as mn, padSpanId as mr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as mt, createSupervisor as n, awaitAbortable$1 as na, authoredProfileDigest as ni, isLiveNodeStatus as nn, readTraceContextFromEnv as nr, effectiveConcurrency as nt, runFinalizer as o, promptFromAgentTurnInput as oa, knownMaterializationReceipt as oi, bridgeModelRouteRefusal as on, buildLoopSpanNodes as or, bindReusableExecutorExecutionId as ot, driverChild as p, runtimeOwnedExecutorProviderEvidence as pi, TERMINAL_DECISIONS as pn, loopEventToOtelSpan as pr, createWorktreeCliExecutor as pt, attachWorker as q, throwIfAborted as qi, defaultRedactor as qn, unsupportedProfileDimensions as qr, createInbox as qt, bestDelivered as r, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as ra, finalizeRuntimeOwnedPendingExecutor as ri, isTerminalNodeStatus as rn, traceContextToEnv as rr, freeSlots as rt, runTree as s, promptOptionsFromAgentTurnInput as sa, newExecutionAttemptId as si, addHarnessUsage as sn, buildRuntimeEventOtelSpans as sr, captureReusableExecutorConfig as st, createRootHandle as t, abortError$2 as ta, attestRuntimeOwnedScopeOwner as ti, peerMailVerbNames as tn, mergeTraceEnv as tr, errMessage as tt, classifyDriverFailure as u, runtimeOwnedDriveHarnessProviderEvidence as ui, readCodexRolloutSession as un, exportEvalRuns as ur, createExecutor as ut, createScope as v, executableAgentProfileSnapshot as vi, createSandboxLineage as vn, createRuntimeStreamEventCollector as vr, FileSpawnJournal as vt, scopeOwnerExecutorNodeContext as w, assertSandboxServedModel as wi, runBrainLoop as wn, captureWorktreeDiff as wr, pendingWaits as wt, meterRuntimeOwnedProviderAttempt as x, detachedSnapshot as xi, assertBoxlessPromptOptions as xn, sanitizeRuntimeStreamEvent as xr, insideCursorNamespace as xt, deriveNodeExecutionIdentity as y, executableAgentSpecSnapshot as yi, probeSandboxCapabilities as yn, sanitizeAgentRuntimeEvent as yr, InMemoryResultBlobStore as yt, scopeRetainedOwnerResult as z, deleteBoxSafe as zi, abortError as zn, profileMaterializationAxes$1 as zr, readWorkerTraceContext as zt };
25109
25226
 
25110
- //# sourceMappingURL=supervisor-tGq-TPIv.js.map
25227
+ //# sourceMappingURL=supervisor-BIBWUFUr.js.map