@tangle-network/agent-runtime 3.0.43 → 5.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 (80) hide show
  1. package/CHANGELOG.md +5263 -0
  2. package/dist/{activation-CiUbW1QE.d.ts → activation-CtLdCiH3.d.ts} +2 -2
  3. package/dist/{activation-1YUy4GWu.js → activation-DGLWxFJu.js} +2 -2
  4. package/dist/{activation-1YUy4GWu.js.map → activation-DGLWxFJu.js.map} +1 -1
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +4 -4
  7. package/dist/candidate-execution/index.d.ts +1 -1
  8. package/dist/{coordination-manager-DXOwLu9T.js → coordination-manager-D74AZg7m.js} +7 -7
  9. package/dist/{coordination-manager-DXOwLu9T.js.map → coordination-manager-D74AZg7m.js.map} +1 -1
  10. package/dist/{coordination-map-routing-2_hUlTnz.js → coordination-map-routing-DVjW5Gx0.js} +2 -2
  11. package/dist/{coordination-map-routing-2_hUlTnz.js.map → coordination-map-routing-DVjW5Gx0.js.map} +1 -1
  12. package/dist/{delegate-CAvTMCk0.js → delegate-BVyFJ9AX.js} +2 -2
  13. package/dist/{delegate-CAvTMCk0.js.map → delegate-BVyFJ9AX.js.map} +1 -1
  14. package/dist/durable.d.ts +4 -2
  15. package/dist/durable.js +12 -184
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{graph-C7Xthj-4.js → graph-r8zcRxbi.js} +6 -8
  18. package/dist/{graph-C7Xthj-4.js.map → graph-r8zcRxbi.js.map} +1 -1
  19. package/dist/{graph-registry-BoaUV5g8.js → graph-registry-B25FxBZN.js} +5 -5
  20. package/dist/graph-registry-B25FxBZN.js.map +1 -0
  21. package/dist/{graph-registry-EGeo_moB.js → graph-registry-C-hjRx2t.js} +1 -1
  22. package/dist/{improve-BZpoezFh.js → improve-D12GulmK.js} +7 -7
  23. package/dist/{improve-BZpoezFh.js.map → improve-D12GulmK.js.map} +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +9 -9
  26. package/dist/intelligence.d.ts +3 -3
  27. package/dist/intelligence.js +5 -5
  28. package/dist/{jsonl-file-CbxMVnUj.js → jsonl-file-CeVYTIQJ.js} +45 -33
  29. package/dist/jsonl-file-CeVYTIQJ.js.map +1 -0
  30. package/dist/kernel.d.ts +2 -2
  31. package/dist/kernel.js +14 -13
  32. package/dist/{loop-runner-Dmjf2IY6.d.ts → loop-runner-BHBabRIw.d.ts} +2 -2
  33. package/dist/{loop-runner-BchibTTn.js → loop-runner-CYcN11I4.js} +2 -2
  34. package/dist/{loop-runner-BchibTTn.js.map → loop-runner-CYcN11I4.js.map} +1 -1
  35. package/dist/loop-runner-bin.d.ts +1 -1
  36. package/dist/loop-runner-bin.js +1 -1
  37. package/dist/mcp/bin.js +3 -3
  38. package/dist/mcp/index.d.ts +1 -1
  39. package/dist/mcp/index.js +5 -5
  40. package/dist/profiles.d.ts +1 -1
  41. package/dist/{provision-supervisor-BtDnk11d.js → provision-supervisor-BiqHJ-d4.js} +5 -5
  42. package/dist/{provision-supervisor-BtDnk11d.js.map → provision-supervisor-BiqHJ-d4.js.map} +1 -1
  43. package/dist/{run-cancellation-DEW04dun.js → run-cancellation-D5R-7UQt.js} +3 -3
  44. package/dist/{run-cancellation-DEW04dun.js.map → run-cancellation-D5R-7UQt.js.map} +1 -1
  45. package/dist/run-state-DRh8BOFi.js +350 -0
  46. package/dist/run-state-DRh8BOFi.js.map +1 -0
  47. package/dist/{runtime-CKoChP6L.js → runtime-BX_9-DJB.js} +18 -17
  48. package/dist/runtime-BX_9-DJB.js.map +1 -0
  49. package/dist/{scope-Bg1uCsPR.js → scope-JcCkUy_z.js} +268 -165
  50. package/dist/scope-JcCkUy_z.js.map +1 -0
  51. package/dist/{search-executor-CJ5y2-b8.js → search-executor-CdmaS5r4.js} +3 -3
  52. package/dist/{search-executor-CJ5y2-b8.js.map → search-executor-CdmaS5r4.js.map} +1 -1
  53. package/dist/{server-zdmmyP7r.js → server-BY6OluUf.js} +3 -3
  54. package/dist/{server-zdmmyP7r.js.map → server-BY6OluUf.js.map} +1 -1
  55. package/dist/settle-record-BSDDf9Z4.js +130 -0
  56. package/dist/settle-record-BSDDf9Z4.js.map +1 -0
  57. package/dist/{structural-rollout-CH9b7K9B.js → structural-rollout-BjMUUXLn.js} +3 -3
  58. package/dist/{structural-rollout-CH9b7K9B.js.map → structural-rollout-BjMUUXLn.js.map} +1 -1
  59. package/dist/{supervise-472pyfgQ.js → supervise-rYEsVVcn.js} +254 -414
  60. package/dist/supervise-rYEsVVcn.js.map +1 -0
  61. package/dist/{supervision-discovery-CD350Iar.js → supervision-discovery-D95Ack4J.js} +4 -129
  62. package/dist/supervision-discovery-D95Ack4J.js.map +1 -0
  63. package/dist/{supervisor-BDOWzyCC.js → supervisor-B-bX69uL.js} +185 -120
  64. package/dist/supervisor-B-bX69uL.js.map +1 -0
  65. package/dist/testing.d.ts +1 -1
  66. package/dist/testing.js +11 -11
  67. package/dist/{top-web-CNTJBqFy.js → top-web-D-wH9ipn.js} +13 -9
  68. package/dist/{top-web-CNTJBqFy.js.map → top-web-D-wH9ipn.js.map} +1 -1
  69. package/dist/tui/bin.js +3 -3
  70. package/dist/tui/index.d.ts +1 -1
  71. package/dist/tui/index.js +2 -2
  72. package/dist/{types-tG_tps7N.d.ts → types-DblV14Oe.d.ts} +204 -224
  73. package/package.json +7 -8
  74. package/dist/graph-registry-BoaUV5g8.js.map +0 -1
  75. package/dist/jsonl-file-CbxMVnUj.js.map +0 -1
  76. package/dist/runtime-CKoChP6L.js.map +0 -1
  77. package/dist/scope-Bg1uCsPR.js.map +0 -1
  78. package/dist/supervise-472pyfgQ.js.map +0 -1
  79. package/dist/supervision-discovery-CD350Iar.js.map +0 -1
  80. package/dist/supervisor-BDOWzyCC.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, l as RetainedInteractiveBindingError, m as ValidationError, r as BackendTransportError, u as RetainedRunAdmissionError } from "./errors-AzSuGI23.js";
1
+ import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, l as RetainedInteractiveBindingError, m as ValidationError, r as BackendTransportError, t as AgentEvalError$1, u as RetainedRunAdmissionError } from "./errors-AzSuGI23.js";
2
2
  import { $ as isAsyncIterable, Ct as boundedChildDeadlineAt, Dt as teardownExecutor, Et as singleFlightTeardown, F as deepFreezeCandidate, G as chargedTokens, H as abortError, K as cloneSpend, St as armDeadlineTimer, U as addSpend, W as addTokenUsage, X as fnv1a32Hex, Y as errorMessage, Z as hasCompleteCacheBreakdown, a as verifyAgentCandidateWorkspaceArtifacts, at as sleep, dt as zeroSpend, ft as zeroTokenUsage, g as workspaceLimits, gt as withBudgetResources, h as verifyAgentCandidateWorkspaceArchive, ht as resourceTelemetry, i as readAgentCandidateWorkspaceArtifactFiles, j as verifiedArtifactChunks, k as verifyWorkspaceSnapshotArtifacts, m as safeArchivePath, mt as assertResources, o as verifyAgentCandidateWorkspaceTree, pt as addResourceSpend, q as cloneTokenUsage, tt as promptCacheTokenClasses, vt as CHILD_DEADLINE_REASON, wt as checkInIdleMs, z as sha256Bytes$1 } from "./workspace-streams-8ALHaZzx.js";
3
- import { _ as errorText, a as readCommittedJsonLines, b as resolveRedactor, c as appendCommittedJsonLine, d as detachedSnapshot, f as shareParsedStrings, g as errorProperty, l as sha256, m as errMessage, p as causeChain, r as prepareJsonlAppend, s as withJsonlFileLock, t as isNoEntError, v as defaultRedactor } from "./jsonl-file-CbxMVnUj.js";
3
+ import { _ as errorText, a as readCommittedJsonLines, b as resolveRedactor, c as appendCommittedJsonLine, d as detachedSnapshot, f as shareParsedStrings, g as errorProperty, l as sha256, m as errMessage, p as causeChain, r as prepareJsonlAppend, s as withJsonlFileLock, t as isNoEntError, v as defaultRedactor } from "./jsonl-file-CeVYTIQJ.js";
4
4
  import { t as assertExecutableAgentProfile } from "./model-policy-JOcg3NRs.js";
5
5
  import { a as writeAtomicDurableFile, n as assertNoSymlinkDescendant, o as captureRunWriteContext, r as publishExclusiveDurableFile, s as fenceRunWrite, t as appendDurableFile } from "./durable-file-DstVeHcj.js";
6
6
  import { a as withPursuitContext, i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
@@ -12,6 +12,7 @@ import { isRecord } from "@tangle-network/agent-core";
12
12
  import { collectAgentFinalMessageText, collectAgentResponseText } from "@tangle-network/sandbox";
13
13
  import { z } from "zod";
14
14
  import { redact } from "@tangle-network/agent-eval/traces";
15
+ import { AgentTurnFailureSchema } from "@tangle-network/agent-interface/environment-provider";
15
16
  import { createHash, randomUUID } from "node:crypto";
16
17
  import { setImmediate as setImmediate$1 } from "node:timers/promises";
17
18
  import { LedgerCanonicalizationError, canonicalString, jsonDocument, merkleLeafHash, merkleRoot, merkleSalt } from "@tangle-network/agent-eval/ledger-core";
@@ -1725,8 +1726,8 @@ function assertValidBudget(budget, label = "budget") {
1725
1726
  if (!Number.isFinite(value) || value < 0) throw new Error(`${label}.${field} must be a non-negative finite number`);
1726
1727
  };
1727
1728
  assertResources(budget.resources, "limit", `${label}.resources`);
1728
- safeInteger(budget.maxIterations, "maxIterations");
1729
- safeInteger(budget.maxTokens, "maxTokens");
1729
+ if (budget.maxIterations !== void 0) safeInteger(budget.maxIterations, "maxIterations");
1730
+ if (budget.maxTokens !== void 0) safeInteger(budget.maxTokens, "maxTokens");
1730
1731
  if (budget.maxUsd !== void 0) finiteNonNegative(budget.maxUsd, "maxUsd");
1731
1732
  if (budget.deadlineMs !== void 0) finiteNonNegative(budget.deadlineMs, "deadlineMs");
1732
1733
  }
@@ -1767,6 +1768,8 @@ function assertValidSpend(spend, label) {
1767
1768
  */
1768
1769
  function openBudgetLedger(root, runStartedAtMs) {
1769
1770
  return {
1771
+ tokensCapped: root.maxTokens !== void 0,
1772
+ iterationsCapped: root.maxIterations !== void 0,
1770
1773
  usdCapped: root.maxUsd !== void 0,
1771
1774
  absoluteDeadlineMs: root.deadlineMs === void 0 ? 0 : runStartedAtMs + root.deadlineMs,
1772
1775
  resources: new Map(Object.entries(root.resources ?? {}).map(([name, value]) => [name, {
@@ -1776,7 +1779,7 @@ function openBudgetLedger(root, runStartedAtMs) {
1776
1779
  committed: 0,
1777
1780
  known: true
1778
1781
  }])),
1779
- freeTokens: root.maxTokens,
1782
+ freeTokens: root.maxTokens ?? 0,
1780
1783
  reservedTokens: 0,
1781
1784
  committedTokens: 0,
1782
1785
  tokensTainted: false,
@@ -1786,7 +1789,7 @@ function openBudgetLedger(root, runStartedAtMs) {
1786
1789
  committedUsd: 0,
1787
1790
  usdTainted: false,
1788
1791
  usdMeasured: true,
1789
- freeIterations: root.maxIterations,
1792
+ freeIterations: root.maxIterations ?? 0,
1790
1793
  reservedIterations: 0,
1791
1794
  committedIterations: 0,
1792
1795
  ownerSpent: {
@@ -1853,9 +1856,9 @@ function ledgerCommitResources(l, spend, allocations, requireAll = true) {
1853
1856
  }
1854
1857
  /** Every channel `b` does not fit, measured against the free balance less `keep`. */
1855
1858
  function ledgerShortfalls(l, b, keep) {
1856
- const wantTokens = b.maxTokens;
1859
+ const wantTokens = b.maxTokens ?? 0;
1857
1860
  const wantUsd = b.maxUsd ?? 0;
1858
- const wantIterations = b.maxIterations;
1861
+ const wantIterations = b.maxIterations ?? 0;
1859
1862
  const shortfalls = [];
1860
1863
  const short = (channel, requested, free, held, closedByUnknownSpend = false) => {
1861
1864
  shortfalls.push({
@@ -1875,8 +1878,8 @@ function ledgerShortfalls(l, b, keep) {
1875
1878
  const kept = (share = 0, spent) => Math.max(0, share - spent);
1876
1879
  const tokensFree = l.freeTokens - kept(keep?.tokens, chargedTokens(l.ownerSpent.tokens));
1877
1880
  const iterationsFree = l.freeIterations - kept(keep?.iterations, l.ownerSpent.iterations);
1878
- if (wantTokens > tokensFree) short("tokens", wantTokens, tokensFree, l.reservedTokens);
1879
- if (wantIterations > iterationsFree) short("iterations", wantIterations, iterationsFree, l.reservedIterations);
1881
+ if (l.tokensCapped && wantTokens > tokensFree) short("tokens", wantTokens, tokensFree, l.reservedTokens);
1882
+ if (l.iterationsCapped && wantIterations > iterationsFree) short("iterations", wantIterations, iterationsFree, l.reservedIterations);
1880
1883
  const usdFree = l.freeUsd - kept(keep?.usd, l.ownerSpent.usd);
1881
1884
  if (l.usdCapped && !l.usdTainted && wantUsd > usdFree) short("usd", wantUsd, usdFree, l.reservedUsd);
1882
1885
  return shortfalls;
@@ -1888,10 +1891,14 @@ function ledgerTake(l, b) {
1888
1891
  state.remaining -= amount;
1889
1892
  state.reserved += amount;
1890
1893
  }
1891
- l.freeTokens -= b.maxTokens;
1892
- l.reservedTokens += b.maxTokens;
1893
- l.freeIterations -= b.maxIterations;
1894
- l.reservedIterations += b.maxIterations;
1894
+ if (l.tokensCapped) {
1895
+ l.freeTokens -= b.maxTokens ?? 0;
1896
+ l.reservedTokens += b.maxTokens ?? 0;
1897
+ }
1898
+ if (l.iterationsCapped) {
1899
+ l.freeIterations -= b.maxIterations ?? 0;
1900
+ l.reservedIterations += b.maxIterations ?? 0;
1901
+ }
1895
1902
  l.freeUsd -= b.maxUsd ?? 0;
1896
1903
  l.reservedUsd += b.maxUsd ?? 0;
1897
1904
  }
@@ -1902,18 +1909,20 @@ function ledgerTake(l, b) {
1902
1909
  * dollar ceiling: without `maxUsd` it reserved NO dollars, so under a capped root its dollars are
1903
1910
  * OBSERVED spend, committed and debited from `free` like `observe`d inference.
1904
1911
  */
1905
- function ledgerClassifyOverspend(l, held, usdBudgeted, spent) {
1912
+ function ledgerClassifyOverspend(l, held, usdBudgeted, spent, limits) {
1906
1913
  const unknownUnderCap = l.usdCapped && spent.usdKnown === false;
1907
1914
  const spentTokens = chargedTokens(spent.tokens);
1908
1915
  const overspent = [];
1909
- if (spentTokens > held.tokens) overspent.push({
1916
+ const tokens = limits === void 0 ? held.tokens : limits.maxTokens;
1917
+ const iterations = limits === void 0 ? held.iterations : limits.maxIterations;
1918
+ if (tokens !== void 0 && spentTokens > tokens) overspent.push({
1910
1919
  channel: "tokens",
1911
- reserved: held.tokens,
1920
+ reserved: tokens,
1912
1921
  spent: spentTokens
1913
1922
  });
1914
- if (spent.iterations > held.iterations) overspent.push({
1923
+ if (iterations !== void 0 && spent.iterations > iterations) overspent.push({
1915
1924
  channel: "iterations",
1916
- reserved: held.iterations,
1925
+ reserved: iterations,
1917
1926
  spent: spent.iterations
1918
1927
  });
1919
1928
  if (!unknownUnderCap && l.usdCapped && usdBudgeted && spent.usd > held.usd) overspent.push({
@@ -1933,12 +1942,16 @@ function ledgerClassifyOverspend(l, held, usdBudgeted, spent) {
1933
1942
  function ledgerSettle(l, held, spent, unknownUnderCap) {
1934
1943
  noteUnknowns(l, spent);
1935
1944
  const spentTokens = chargedTokens(spent.tokens);
1936
- l.reservedTokens -= held.tokens;
1937
1945
  l.committedTokens += spentTokens;
1938
- l.freeTokens += held.tokens - spentTokens;
1939
- l.reservedIterations -= held.iterations;
1946
+ if (l.tokensCapped) {
1947
+ l.reservedTokens -= held.tokens;
1948
+ l.freeTokens += held.tokens - spentTokens;
1949
+ }
1940
1950
  l.committedIterations += spent.iterations;
1941
- l.freeIterations += held.iterations - spent.iterations;
1951
+ if (l.iterationsCapped) {
1952
+ l.reservedIterations -= held.iterations;
1953
+ l.freeIterations += held.iterations - spent.iterations;
1954
+ }
1942
1955
  if (l.usdCapped) {
1943
1956
  l.reservedUsd -= held.usd;
1944
1957
  l.committedUsd += spent.usd;
@@ -1965,9 +1978,9 @@ function ledgerObserve(l, spend, unknownUnderCap, requireAllResources) {
1965
1978
  function debit(l, spend) {
1966
1979
  noteUnknowns(l, spend);
1967
1980
  const tokens = chargedTokens(spend.tokens);
1968
- l.freeTokens -= tokens;
1981
+ if (l.tokensCapped) l.freeTokens -= tokens;
1969
1982
  l.committedTokens += tokens;
1970
- l.freeIterations -= spend.iterations;
1983
+ if (l.iterationsCapped) l.freeIterations -= spend.iterations;
1971
1984
  l.committedIterations += spend.iterations;
1972
1985
  l.committedUsd += spend.usd;
1973
1986
  if (l.usdCapped) l.freeUsd -= spend.usd;
@@ -2002,14 +2015,16 @@ function ledgerRestore(l, root, restore) {
2002
2015
  }, root));
2003
2016
  l.tokensTainted = true;
2004
2017
  l.usdMeasured = false;
2005
- l.freeTokens -= uncertain.maxTokens;
2006
- l.committedTokens += uncertain.maxTokens;
2007
- l.freeIterations -= uncertain.maxIterations;
2008
- l.committedIterations += uncertain.maxIterations;
2018
+ const tokens = uncertain.maxTokens ?? (l.tokensCapped ? Math.max(0, l.freeTokens) : 0);
2019
+ const iterations = uncertain.maxIterations ?? (l.iterationsCapped ? Math.max(0, l.freeIterations) : 0);
2020
+ l.committedTokens += tokens;
2021
+ l.committedIterations += iterations;
2022
+ if (l.tokensCapped) l.freeTokens -= tokens;
2023
+ if (l.iterationsCapped) l.freeIterations -= iterations;
2009
2024
  if (!l.usdCapped) continue;
2010
2025
  if (uncertain.maxUsd === void 0) {
2011
2026
  l.usdTainted = true;
2012
- l.committedUsd += l.freeUsd > 0 ? l.freeUsd : 0;
2027
+ l.committedUsd += Math.max(0, l.freeUsd);
2013
2028
  l.freeUsd = 0;
2014
2029
  } else {
2015
2030
  l.freeUsd -= uncertain.maxUsd;
@@ -2141,7 +2156,7 @@ async function foldUsage(events) {
2141
2156
  * overspend of a $0 ceiling. Unknowable dollar cost under a dollar limit closes the known
2142
2157
  * token/iteration work, marks the dollar channel unusable and refuses later reservations. An
2143
2158
  * unknowable TOKEN count records the work, debits what is known, and marks
2144
- * `readout().tokensKnown` false (a ceiling, not a measurement); tokens are always capped, so one
2159
+ * `readout().tokensKnown` false (a ceiling, not a measurement); one
2145
2160
  * unreported turn must not end the run.
2146
2161
  *
2147
2162
  * A reservation the free balance cannot cover now can WAIT (`reserve(b, holder, { wait: true })`)
@@ -2217,7 +2232,7 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
2217
2232
  function admitToWait(b, holder, keep) {
2218
2233
  const id = nextTicketId++;
2219
2234
  open.set(id, holder);
2220
- const ticket = ticketFor(id, b);
2235
+ const ticket = ticketFor(id, b, ledger);
2221
2236
  let grant;
2222
2237
  let refuse;
2223
2238
  const granted = new Promise((resolve, reject) => {
@@ -2256,7 +2271,7 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
2256
2271
  open.set(id, holder);
2257
2272
  return {
2258
2273
  ok: true,
2259
- ticket: ticketFor(id, b)
2274
+ ticket: ticketFor(id, b, ledger)
2260
2275
  };
2261
2276
  }
2262
2277
  if (options.wait !== true || !fitsAfterRefunds(shortfalls)) return {
@@ -2290,7 +2305,10 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
2290
2305
  resources: void 0
2291
2306
  } : ticket.reserved;
2292
2307
  const usdBudgeted = ticket.reserved.usdBudgeted !== false;
2293
- const { overspent, unknownUnderCap } = ledgerClassifyOverspend(ledger, held, usdBudgeted, spent);
2308
+ const { overspent, unknownUnderCap } = ledgerClassifyOverspend(ledger, held, usdBudgeted, spent, heldNothing ? {
2309
+ maxTokens: 0,
2310
+ maxIterations: 0
2311
+ } : ticket.limits);
2294
2312
  let fault = unknownUnderCap ? `ticket ${ticket.id} reported unknown dollar cost under a dollar-capped budget` : void 0;
2295
2313
  open.delete(ticket.id);
2296
2314
  const resourceSettlement = ledgerSettle(ledger, held, spent, unknownUnderCap);
@@ -2314,12 +2332,15 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
2314
2332
  return {
2315
2333
  ...ledger.resources.size ? { resources: Object.fromEntries([...ledger.resources].map(([name, value]) => [name, { ...value }])) } : {},
2316
2334
  tokensLeft: ledger.freeTokens,
2335
+ tokensCapped: ledger.tokensCapped,
2336
+ committedTokens: ledger.committedTokens,
2317
2337
  tokensKnown: !ledger.tokensTainted,
2318
2338
  cacheBreakdownKnown: !ledger.cacheBreakdownTainted,
2319
2339
  usdLeft: ledger.usdCapped ? ledger.usdTainted ? 0 : ledger.freeUsd : 0,
2320
2340
  usdCapped: ledger.usdCapped,
2321
2341
  usdKnown: ledger.usdMeasured && !ledger.usdTainted,
2322
2342
  iterationsLeft: ledger.freeIterations,
2343
+ iterationsCapped: ledger.iterationsCapped,
2323
2344
  deadlineMs: ledger.absoluteDeadlineMs,
2324
2345
  reservedTokens: ledger.reservedTokens
2325
2346
  };
@@ -2358,14 +2379,18 @@ function assertResourceDeclarations(ledger, b) {
2358
2379
  function fitsAfterRefunds(shortfalls) {
2359
2380
  return shortfalls.every((shortfall) => shortfall.closedByUnknownSpend !== true && shortfall.requested <= shortfall.free + (shortfall.held ?? 0));
2360
2381
  }
2361
- function ticketFor(id, b) {
2382
+ function ticketFor(id, b, ledger) {
2362
2383
  return {
2363
2384
  id,
2385
+ limits: {
2386
+ ...b.maxTokens === void 0 ? {} : { maxTokens: b.maxTokens },
2387
+ ...b.maxIterations === void 0 ? {} : { maxIterations: b.maxIterations }
2388
+ },
2364
2389
  reserved: {
2365
2390
  ...b.resources === void 0 ? {} : { resources: Object.fromEntries(Object.entries(b.resources).map(([name, value]) => [name, { ...value }])) },
2366
- tokens: b.maxTokens,
2391
+ tokens: ledger.tokensCapped ? b.maxTokens ?? 0 : 0,
2367
2392
  usd: b.maxUsd ?? 0,
2368
- iterations: b.maxIterations,
2393
+ iterations: ledger.iterationsCapped ? b.maxIterations ?? 0 : 0,
2369
2394
  usdBudgeted: b.maxUsd !== void 0
2370
2395
  }
2371
2396
  };
@@ -2440,7 +2465,8 @@ function jsonContentText(value) {
2440
2465
  // src/runtime/supervise/executor-outcome.ts
2441
2466
  const outcomeSchema = AgentTurnResultSchema.pick({
2442
2467
  success: true,
2443
- error: true
2468
+ error: true,
2469
+ failure: true
2444
2470
  }).extend({
2445
2471
  errorCode: AgentTurnResultSchema.shape.error,
2446
2472
  statusCode: z.number().int().min(400).max(599).optional()
@@ -2452,6 +2478,7 @@ function executorFailure(result) {
2452
2478
  if (outcome.success) return void 0;
2453
2479
  return {
2454
2480
  error: outcome.error ?? "Agent execution failed",
2481
+ ...outcome.failure === void 0 ? {} : { failure: outcome.failure },
2455
2482
  ...outcome.errorCode === void 0 ? {} : { errorCode: outcome.errorCode },
2456
2483
  ...outcome.statusCode === void 0 ? {} : { statusCode: outcome.statusCode }
2457
2484
  };
@@ -2460,19 +2487,51 @@ function executorFailure(result) {
2460
2487
  function executorFailureReason(result) {
2461
2488
  return executorFailure(result)?.error;
2462
2489
  }
2463
- /**
2464
- * The platform's own failure vocabulary: machine codes and lifecycle messages that the sandbox
2465
- * runtime, the router, or the egress path put in an executor envelope when the platform, not
2466
- * the agent's work, ended the execution. Each entry names its evidence: the count is how many
2467
- * down children carried it on the 2026-09-20 fleet corpus (277 down settlements across 691
2468
- * runs), every one of them stamped `infra: false` by the hard-coded call site this table
2469
- * replaced. The table is deliberately the platform's fixed strings, not the agent's prose.
2470
- */
2490
+ /** Canonical producer classifications take precedence over the legacy code/message vocabulary. */
2491
+ const TURN_FAILURE_POLICY = {
2492
+ capacity: {
2493
+ classification: "unavailable",
2494
+ failureKind: "infra",
2495
+ infra: true,
2496
+ code: "upstream-unavailable",
2497
+ owner: "platform"
2498
+ },
2499
+ caller: {
2500
+ classification: "terminal",
2501
+ failureKind: "deterministic",
2502
+ infra: void 0,
2503
+ code: "request-rejected",
2504
+ owner: "caller"
2505
+ },
2506
+ infra: {
2507
+ classification: "transient",
2508
+ failureKind: "infra",
2509
+ infra: true,
2510
+ code: "transport",
2511
+ owner: "platform"
2512
+ },
2513
+ work: {
2514
+ classification: "transient",
2515
+ failureKind: "deterministic",
2516
+ infra: void 0,
2517
+ code: "work-failed",
2518
+ owner: "work"
2519
+ }
2520
+ };
2521
+ const turnFailurePolicy = (failure) => TURN_FAILURE_POLICY[failure.kind];
2522
+ /** Validate the shared contract on an envelope or any wrapped cause; malformed legacy data falls back. */
2523
+ function turnFailureOf(value) {
2524
+ for (const link of causeChain(value)) try {
2525
+ const parsed = AgentTurnFailureSchema.safeParse(Reflect.get(link, "failure"));
2526
+ if (parsed.success) return parsed.data;
2527
+ } catch {}
2528
+ }
2471
2529
  const PLATFORM_FAILURE_CODES = new Set([
2472
2530
  "QUOTA_EXCEEDED",
2473
2531
  "provider_quota_exceeded",
2474
2532
  "provider_quota_exhausted",
2475
2533
  "buffer.overflow",
2534
+ "EXECUTION_INTERRUPTED",
2476
2535
  "TIMEOUT",
2477
2536
  "ECONNRESET",
2478
2537
  "ECONNREFUSED",
@@ -2483,7 +2542,6 @@ const PLATFORM_FAILURE_CODES = new Set([
2483
2542
  const PLATFORM_FAILURE_MESSAGES = [
2484
2543
  /^terminated$/u,
2485
2544
  /Execution exceeded its time limit/u,
2486
- /Execution interrupted: the agent runtime restarted/u,
2487
2545
  /Platform key[- ]verification/u,
2488
2546
  /Platform key delegation failed/u,
2489
2547
  /Bad Gateway/iu,
@@ -2501,18 +2559,9 @@ const PLATFORM_FAILURE_MESSAGES = [
2501
2559
  /OpenCode exited while a model step was still in progress/u,
2502
2560
  /the agent runtime restarted/u
2503
2561
  ];
2504
- /**
2505
- * Whether an executor envelope's failure was the platform's, as far as the envelope can say.
2506
- *
2507
- * `true` when the code or the message is in the platform's own vocabulary above. `undefined`
2508
- * otherwise: the harness reported a failure and nothing in the envelope attributes it, so the
2509
- * settlement carries no `infra` claim at all rather than a false one. This path never answers
2510
- * `false`, because an executor envelope cannot prove the agent's work was at fault; the throw
2511
- * path in `scope.ts` still answers `false` for an ordinary thrown result, where the runtime does
2512
- * know. Until this function existed both envelope sites stamped `infra: false` unconditionally,
2513
- * and the flag caught 1 of the 78 platform losses it was checked against on the fleet corpus.
2514
- */
2562
+ /** Producer-owned classification first; legacy platform codes/messages otherwise leave attribution unknown. */
2515
2563
  function executorFailureInfra(failure) {
2564
+ if (failure.failure) return turnFailurePolicy(failure.failure).infra;
2516
2565
  const code = failure.errorCode?.toLowerCase();
2517
2566
  if (code !== void 0 && PLATFORM_FAILURE_CODES.has(code)) return true;
2518
2567
  return PLATFORM_FAILURE_MESSAGES.some((pattern) => pattern.test(failure.error)) ? true : void 0;
@@ -2717,24 +2766,8 @@ function storedText(event) {
2717
2766
  return JSON.stringify(event) ?? "null";
2718
2767
  }
2719
2768
  // src/runtime/supervise/upstream-unavailable.ts
2720
- /**
2721
- * An upstream that cannot serve NOW: how Runtime recognizes one, and how long an agent waits for it.
2722
- *
2723
- * A model provider's exhausted quota, a rate limit, an overload, or the router's own refused
2724
- * credential is not a fault in the agent: the same request succeeds when capacity returns. A
2725
- * driver that meets one re-enters after a pause (`runDriverWithRetry`), and a leaf continues in
2726
- * its environment after the same pause (`providerAsExecutor`). Both read the refusal and the pause
2727
- * from here, so an outage costs a director and its workers the same number of turns.
2728
- *
2729
- * This module imports nothing, so the provider executor can read it without the error classes of
2730
- * `../../errors`.
2731
- */
2732
- /**
2733
- * Machine codes that say the upstream cannot serve now rather than that the request is wrong.
2734
- * Each is a code an upstream publishes, not prose: the router's
2735
- * (`lib/model-substitution.ts`, `lib/upstream-error-triage.ts`) and the OpenAI- and Anthropic-shaped
2736
- * error types a relayed body carries.
2737
- */
2769
+ /** Shared capacity recognition and pause policy for drivers and retained leaves. */
2770
+ /** Legacy capacity codes for producers without the canonical failure contract. */
2738
2771
  const UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
2739
2772
  "provider_quota_exhausted",
2740
2773
  "provider_quota_exceeded",
@@ -2754,12 +2787,7 @@ const UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([
2754
2787
  503,
2755
2788
  529
2756
2789
  ]);
2757
- /**
2758
- * A harness that flattens the router's JSON body into its own failure text leaves the router's
2759
- * code in that text: `opencode execution failed: No provider served model "..."
2760
- * (provider_quota_exhausted)`. The code is matched as a whole token, and a status only in the
2761
- * `status code <n>` framing a harness prints, so prose that merely mentions a quota does not match.
2762
- */
2790
+ /** Legacy text fallback reads whole code tokens and explicitly framed HTTP statuses. */
2763
2791
  function unavailableSignalInText(text) {
2764
2792
  for (const token of text.toLowerCase().matchAll(/[a-z_]+/gu)) if (UNAVAILABLE_CODES.has(token[0])) return token[0];
2765
2793
  const status = printedStatus(text);
@@ -2770,13 +2798,7 @@ const printedStatus = (text) => {
2770
2798
  const status = text.match(/\bstatus code (\d{3})\b/u)?.[1];
2771
2799
  return status === void 0 ? void 0 : Number(status);
2772
2800
  };
2773
- /**
2774
- * Sandbox's 409 `NO_HOST_FITS_SHAPE` for a shape that fits its host's ceiling: no exceeded
2775
- * dimension, only `its room is held placeable on <sku>`. It is sent by mistake for "no room now"
2776
- * while new hosts cannot be planned, and the create lands within one autoscaler purchase. Four
2777
- * nodes of Discovery run magnetar-rust-sandbox-20261101a went down on it. A shape over the ceiling
2778
- * names the dimension it exceeds instead, and stays refused.
2779
- */
2801
+ /** Held room for an otherwise placeable shape is temporary capacity; oversized shapes stay refused. */
2780
2802
  const HELD_ROOM_REFUSAL = /\bits room is held placeable\b/u;
2781
2803
  /**
2782
2804
  * The code or status that marks a failed turn outcome as an upstream capacity refusal, or
@@ -2785,6 +2807,8 @@ const HELD_ROOM_REFUSAL = /\bits room is held placeable\b/u;
2785
2807
  * report the router's refusal as text.
2786
2808
  */
2787
2809
  function unavailableSignalOfFailure(failure) {
2810
+ const typed = turnFailureOf(failure);
2811
+ if (typed) return turnFailurePolicy(typed).classification === "unavailable" ? typed.code : void 0;
2788
2812
  const code = failure.errorCode?.toLowerCase();
2789
2813
  if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
2790
2814
  if (code === "no_host_fits_shape" && HELD_ROOM_REFUSAL.test(failure.error)) return "host-room-held";
@@ -2810,26 +2834,29 @@ function cappedDoublingMs(consecutive, first, ceiling) {
2810
2834
  const MAX_RESET_HOLD_MS = 216e5;
2811
2835
  /** How often a refusal whose reset is beyond {@link MAX_RESET_HOLD_MS} is probed again. */
2812
2836
  const FAR_RESET_PROBE_MS = 36e5;
2837
+ /** Read canonical reset/retry-after before legacy structured reset fields; never parse text. */
2838
+ function reportedResetAt(error, nowMs = Date.now()) {
2839
+ const typed = turnFailureOf(error);
2840
+ if (typed) return typed.resetAt !== void 0 ? Date.parse(typed.resetAt) : typed.retryAfterMs !== void 0 ? nowMs + typed.retryAfterMs : void 0;
2841
+ for (const cause of causeChain(error)) {
2842
+ let value;
2843
+ try {
2844
+ value = Reflect.get(cause, "resetAt");
2845
+ } catch {
2846
+ continue;
2847
+ }
2848
+ const at = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : NaN;
2849
+ if (Number.isFinite(at)) return at;
2850
+ }
2851
+ }
2813
2852
  /**
2814
- * When a refusal says its quota resets, as epoch ms, or `undefined` when it names no usable time.
2815
- * The Z.ai Coding Plan's opencode refusal names one in Beijing time with no zone:
2816
- * `Usage limit reached for 5 hour. Your limit will reset at 2026-10-18 15:17:33`. On Discovery run
2817
- * magnetar-rust-20261018b, 219 of 324 driver attempts ended on it between 06:04Z and 22:18Z, and
2818
- * the last refusal came at 22:18Z against `reset at 2026-10-19 06:18:14`, which is 22:18:14Z at
2819
- * +08:00. A time with its own zone is read as written. A time in the past is no reset time: the
2820
- * caller keeps its doubling pause. A time more than MAX_RESET_HOLD_MS ahead is held for only
2821
- * FAR_RESET_PROBE_MS at a time, so a misread zone cannot hold a seat for a day, yet the spent seat
2822
- * is not asked again every 5 minutes: on magnetar-rust-20261019c a reset beyond 6 h drew about 12
2823
- * attempts an hour against the refusing seat.
2853
+ * Until when a reported reset holds a pause, or `undefined` for none (absent or past: the caller
2854
+ * keeps its doubling pause). A reset more than MAX_RESET_HOLD_MS ahead is held FAR_RESET_PROBE_MS
2855
+ * at a time; on magnetar-rust-20261019c a far reset drew about 12 attempts an hour.
2824
2856
  */
2825
- function unavailableResumeAt(text, nowMs) {
2826
- const match = text.match(/\breset at (\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})(?:\.\d+)?(Z|[+-]\d{2}:?\d{2})?/u);
2827
- if (match === null) return void 0;
2828
- const zone = match[3] ?? (/Usage limit reached for \d+ hour/u.test(text) ? "+08:00" : void 0);
2829
- if (zone === void 0) return void 0;
2830
- const at = Date.parse(`${match[1]}T${match[2]}${zone.length === 5 ? `${zone.slice(0, 3)}:${zone.slice(3)}` : zone}`);
2831
- if (!Number.isFinite(at) || at <= nowMs) return void 0;
2832
- return at - nowMs > MAX_RESET_HOLD_MS ? nowMs + FAR_RESET_PROBE_MS : at;
2857
+ function unavailableResumeAt(resetAt, nowMs) {
2858
+ if (resetAt === void 0 || resetAt <= nowMs) return void 0;
2859
+ return resetAt - nowMs > MAX_RESET_HOLD_MS ? nowMs + FAR_RESET_PROBE_MS : resetAt;
2833
2860
  }
2834
2861
  /**
2835
2862
  * Spread a wait over `[ms / 2, ms]`. Every driver a Platform restart cut off fails within the same
@@ -3220,6 +3247,8 @@ function runtimeProviderCode(value) {
3220
3247
  return typeof value === "string" && MACHINE_CODE_PATTERN.test(value) ? value : void 0;
3221
3248
  }
3222
3249
  function upstreamMachineCode(links) {
3250
+ const typed = links.map(turnFailureOf).find((value) => value !== void 0);
3251
+ if (typed) return runtimeProviderCode(typed.code);
3223
3252
  return [
3224
3253
  "upstreamCode",
3225
3254
  "errorCode",
@@ -3228,6 +3257,8 @@ function upstreamMachineCode(links) {
3228
3257
  }
3229
3258
  /** The typed HTTP status and retry-after of the link carrying the provider's code. */
3230
3259
  function upstreamResponse(links, providerCode) {
3260
+ const typed = links.map(turnFailureOf).find((value) => value !== void 0);
3261
+ if (typed?.retryAfterMs !== void 0) return { retryAfterMs: typed.retryAfterMs };
3231
3262
  const link = links.find((each) => [
3232
3263
  "upstreamCode",
3233
3264
  "errorCode",
@@ -3266,6 +3297,12 @@ function runtimeFailureCause(error, context = {}) {
3266
3297
  code: caller,
3267
3298
  owner: "caller"
3268
3299
  });
3300
+ for (const link of links) {
3301
+ if (link instanceof RetainedExecutionPendingError && link.pendingCause === "provider-contract") return failure(retainedFailures["provider-contract"]);
3302
+ if (read(link, "name") === "RetainedRunProviderContractError") return failure(retainedFailures[classifyRetainedPendingCause(link)]);
3303
+ }
3304
+ const typed = error instanceof AgentEvalError$1 && !(error instanceof BackendTransportError) ? void 0 : turnFailureOf(error);
3305
+ if (typed) return failure(turnFailurePolicy(typed));
3269
3306
  if (context.signal === void 0 && links.some((link) => read(link, "name") === "AbortError")) return failure({
3270
3307
  code: "aborted",
3271
3308
  owner: "caller"
@@ -3303,7 +3340,8 @@ function runtimeFailureCause(error, context = {}) {
3303
3340
  function reportedFailureCause(outcome) {
3304
3341
  return runtimeFailureCause(Object.assign(new Error(outcome.error ?? "execution reported a failure"), {
3305
3342
  errorCode: outcome.errorCode,
3306
- statusCode: outcome.statusCode
3343
+ statusCode: outcome.statusCode,
3344
+ failure: outcome.failure
3307
3345
  }));
3308
3346
  }
3309
3347
  /**
@@ -3500,14 +3538,21 @@ function runtimeOwnedDeferredExecutorRuntime(executor) {
3500
3538
  return attestation?.kind === "deferred" ? attestation.runtime : void 0;
3501
3539
  }
3502
3540
  /** Propagate trust from a built-in driver adapter to the Agent and recursive executor it owns. */
3503
- function attestRuntimeOwnedScopeOwner(owner, runtime) {
3504
- runtimeOwnedScopeOwners.set(owner, runtime);
3541
+ function attestRuntimeOwnedScopeOwner(owner, runtime, control) {
3542
+ runtimeOwnedScopeOwners.set(owner, {
3543
+ runtime,
3544
+ ...control === void 0 ? {} : { control }
3545
+ });
3505
3546
  return owner;
3506
3547
  }
3548
+ /** A trusted owner's existing provider control remains available before any execution turn. */
3549
+ function runtimeOwnedScopeOwnerControl(owner) {
3550
+ return runtimeOwnedScopeOwners.get(owner)?.control;
3551
+ }
3507
3552
  /** Return a built-in scope owner's expected concrete leaf runtime; caller-owned functions/Agents
3508
3553
  * deliberately have no entry even if they add lookalike fields. */
3509
3554
  function runtimeOwnedScopeOwnerRuntime(owner) {
3510
- return runtimeOwnedScopeOwners.get(owner);
3555
+ return runtimeOwnedScopeOwners.get(owner)?.runtime;
3511
3556
  }
3512
3557
  /** Mark one provider inference attempt on a Runtime-owned executor. */
3513
3558
  function recordRuntimeOwnedProviderAttemptStart(executor) {
@@ -3774,12 +3819,17 @@ function providerAttemptEvidence(model) {
3774
3819
  });
3775
3820
  }
3776
3821
  // src/runtime/supervise/seat-chain.ts
3777
- var SeatChainExhaustedError = class extends Error {
3822
+ /** How often a pause with no known reset asks again, the account cache's cadence. */
3823
+ const SEAT_RECHECK_MS = 12e4;
3824
+ /** No seat can start before `resumeAt`: the chain is exhausted, or `detail` says why not. */
3825
+ var SeatPauseError = class extends Error {
3778
3826
  resumeAt;
3779
- constructor(resumeAt) {
3780
- super(`authored subscription seat chain exhausted; resume at ${resumeAt}`);
3781
- this.name = "SeatChainExhaustedError";
3827
+ detail;
3828
+ constructor(resumeAt, detail) {
3829
+ super(`${detail ?? "authored subscription seat chain exhausted"}; resume at ${resumeAt}`);
3830
+ this.name = "SeatPauseError";
3782
3831
  this.resumeAt = resumeAt;
3832
+ this.detail = detail;
3783
3833
  }
3784
3834
  };
3785
3835
  /** One logical node's durable chain. The spawn journal is the sole transition authority. */
@@ -3895,8 +3945,8 @@ var SeatChain = class {
3895
3945
  }
3896
3946
  return active;
3897
3947
  }
3898
- const recheckAt = Math.max(earliestReset ?? 0, this.now() + 12e4);
3899
- throw new SeatChainExhaustedError(new Date(recheckAt).toISOString());
3948
+ const recheckAt = Math.max(earliestReset ?? 0, this.now() + SEAT_RECHECK_MS);
3949
+ throw new SeatPauseError(new Date(recheckAt).toISOString());
3900
3950
  }
3901
3951
  async close(reason) {
3902
3952
  const events = (await this.journal.loadTree(this.rootId) ?? []).filter((event) => event.kind === "seat-segment" && event.id === this.nodeId);
@@ -8602,6 +8652,7 @@ const outsideKinds = /* @__PURE__ */ new Set([
8602
8652
  "environment-teardown",
8603
8653
  "environment-terminal",
8604
8654
  "workspace-checkpoint-requested",
8655
+ "workspace-checkpoint-refused",
8605
8656
  "workspace-checkpoint",
8606
8657
  "workspace-checkpoint-fork-requested",
8607
8658
  "workspace-checkpoint-fork-ready",
@@ -9062,16 +9113,17 @@ function pendingCheckpoints(events, state) {
9062
9113
  // src/runtime/supervise/retained-owner-checkpoint-capture.ts
9063
9114
  /**
9064
9115
  * Delete checkpoints, each only after its files are captured into the run's content-addressed
9065
- * store; a checkpoint no capture holds is kept, and the cleanup record says why. Only the
9116
+ * store; a checkpoint no capture holds is kept, and the cleanup record says why. `uncapturable`
9117
+ * deletes one anyway when no capture port exists: the record then names no digest. Only the
9066
9118
  * source-scoped handle can fork a checkpoint and attest its deletion, including after its source
9067
9119
  * is lost. `parent` cancels the captures (the owner's scope during rotation); each provider
9068
9120
  * operation also has its own bound.
9069
9121
  */
9070
- async function cleanCheckpoints(state, branching, checkpoints, events, parent) {
9122
+ async function cleanCheckpoints(state, branching, checkpoints, events, parent, uncapturable = false) {
9071
9123
  const unconfirmed = [];
9072
9124
  const refused = [];
9073
9125
  for (const event of checkpoints) {
9074
- const captured = await captureBeforeCleanup(state, branching, event, events, parent);
9126
+ const captured = await captureBeforeCleanup(state, branching, event, events, parent, uncapturable);
9075
9127
  if ("reason" in captured) {
9076
9128
  state.captureRefused ??= /* @__PURE__ */ new Set();
9077
9129
  state.captureRefused.add(event.checkpoint.checkpointId);
@@ -9115,7 +9167,7 @@ async function cleanCheckpoints(state, branching, checkpoints, events, parent) {
9115
9167
  environmentId: event.environmentId,
9116
9168
  checkpointId: event.checkpoint.checkpointId,
9117
9169
  confirmed,
9118
- capturedDigest: captured.digest,
9170
+ ...captured.digest === void 0 ? {} : { capturedDigest: captured.digest },
9119
9171
  seq: state.nextSequence(),
9120
9172
  at: new Date(state.args.now()).toISOString()
9121
9173
  });
@@ -9133,7 +9185,7 @@ async function cleanCheckpoints(state, branching, checkpoints, events, parent) {
9133
9185
  * destroyed once the capture is journaled, so neither a failure nor a crash leaves it running
9134
9186
  * unrecorded.
9135
9187
  */
9136
- async function captureBeforeCleanup(state, branching, event, events, parent) {
9188
+ async function captureBeforeCleanup(state, branching, event, events, parent, uncapturable = false) {
9137
9189
  const { args } = state;
9138
9190
  const checkpointId = event.checkpoint.checkpointId;
9139
9191
  const recorded = events.find((prior) => prior.kind === "workspace-checkpoint-capture" && prior.id === args.nodeId && prior.provider === event.provider && prior.environmentId === event.environmentId && prior.checkpointId === checkpointId);
@@ -9144,7 +9196,7 @@ async function captureBeforeCleanup(state, branching, event, events, parent) {
9144
9196
  needsSource
9145
9197
  });
9146
9198
  const capture = state.checkpointCapture;
9147
- if (capture?.port.captureCheckpoint === void 0) return refuse("no checkpoint capture: the owner backend has no captureCheckpoint", false);
9199
+ if (capture?.port.captureCheckpoint === void 0) return uncapturable ? {} : refuse("no checkpoint capture: the owner backend has no captureCheckpoint", false);
9148
9200
  const provider = state.provider;
9149
9201
  if (provider?.get === void 0) return refuse("the provider cannot reconstruct a fork of the checkpoint", false);
9150
9202
  const get = provider.get.bind(provider);
@@ -9339,8 +9391,8 @@ function scopeRetainedOwnerJournalRoot(scope) {
9339
9391
  }
9340
9392
  /**
9341
9393
  * Bind cleanup before replay can return an already accepted owner result. `checkpointCapture` is
9342
- * where each checkpoint's files are stored before the checkpoint is deleted; without it, no
9343
- * checkpoint of this owner is deleted.
9394
+ * where each checkpoint's files are stored before the checkpoint is deleted; without it, a
9395
+ * checkpoint of this owner is deleted only when a provider refuses a newer one.
9344
9396
  */
9345
9397
  function bindScopeRetainedOwnerProvider(scope, provider, checkpointCapture) {
9346
9398
  const state = owners.get(scope);
@@ -9413,6 +9465,23 @@ async function checkpointOwnerWorkspace(scope, state) {
9413
9465
  state.checkpointsUnavailable = `environment ${environment.id} offers no durable checkpoint`;
9414
9466
  return;
9415
9467
  }
9468
+ const requestOne = () => requestCheckpoint(scope, state, provider.name, environment, branching, source, signal);
9469
+ if (!await requestOne() && (!await deleteOldestUncapturable(state, branching, environment.id, signal) || !await requestOne())) return;
9470
+ const events = await args.journal.loadTree(args.rootId) ?? [];
9471
+ const owned = pendingCheckpoints(events, state).filter((event) => event.environmentId === environment.id && state.captureRefused?.has(event.checkpoint.checkpointId) !== true);
9472
+ const rotation = new AbortController();
9473
+ state.rotationCaptures = rotation;
9474
+ const timer = setTimeout(() => rotation.abort(/* @__PURE__ */ new Error(`the rotation's ${WORKSPACE_CHECKPOINT_ROTATION_CAPTURES_MS} ms for checkpoint captures ran out; checkpoint kept`)), WORKSPACE_CHECKPOINT_ROTATION_CAPTURES_MS);
9475
+ try {
9476
+ await cleanCheckpoints(state, branching, owned.slice(0, -2), events, AbortSignal.any([scope.signal, rotation.signal]));
9477
+ } finally {
9478
+ clearTimeout(timer);
9479
+ if (state.rotationCaptures === rotation) delete state.rotationCaptures;
9480
+ }
9481
+ }
9482
+ /** Ask for one checkpoint and journal the answer. True when the journal holds the checkpoint. */
9483
+ async function requestCheckpoint(scope, state, providerName, environment, branching, source, signal) {
9484
+ const { args } = state;
9416
9485
  const seq = state.nextSequence();
9417
9486
  const at = new Date(args.now()).toISOString();
9418
9487
  const name = `owner-checkpoint-${seq}`;
@@ -9439,7 +9508,7 @@ async function checkpointOwnerWorkspace(scope, state) {
9439
9508
  await args.journal.appendEvent(args.rootId, {
9440
9509
  kind: "workspace-checkpoint-requested",
9441
9510
  id: args.nodeId,
9442
- provider: provider.name,
9511
+ provider: providerName,
9443
9512
  environmentId: environment.id,
9444
9513
  request,
9445
9514
  ...marked ? { marker } : {},
@@ -9447,30 +9516,46 @@ async function checkpointOwnerWorkspace(scope, state) {
9447
9516
  at
9448
9517
  });
9449
9518
  const result = await runAbortable(() => branching.checkpoint(request, { signal }), signal, "retained owner checkpoint timed out");
9450
- if (result.status !== "created" && result.status !== "replayed") return;
9451
- if (!workspaceCheckpointResultMatchesRequest(request, result)) return;
9519
+ if (result.status !== "created" && result.status !== "replayed") {
9520
+ await args.journal.appendEvent(args.rootId, {
9521
+ kind: "workspace-checkpoint-refused",
9522
+ id: args.nodeId,
9523
+ provider: providerName,
9524
+ environmentId: environment.id,
9525
+ idempotencyKey: request.idempotencyKey,
9526
+ message: errorText("message" in result ? result.message : result.status),
9527
+ seq: state.nextSequence(),
9528
+ at
9529
+ });
9530
+ return false;
9531
+ }
9532
+ if (!workspaceCheckpointResultMatchesRequest(request, result)) return false;
9452
9533
  scope.signal.throwIfAborted();
9453
9534
  await args.journal.appendEvent(args.rootId, {
9454
9535
  kind: "workspace-checkpoint",
9455
9536
  id: args.nodeId,
9456
- provider: provider.name,
9537
+ provider: providerName,
9457
9538
  environmentId: environment.id,
9458
9539
  checkpoint: result.checkpoint,
9459
9540
  ...marked ? { marker } : {},
9460
9541
  seq: state.nextSequence(),
9461
9542
  at
9462
9543
  });
9463
- const events = await args.journal.loadTree(args.rootId) ?? [];
9464
- const owned = pendingCheckpoints(events, state).filter((event) => event.environmentId === environment.id && state.captureRefused?.has(event.checkpoint.checkpointId) !== true);
9465
- const rotation = new AbortController();
9466
- state.rotationCaptures = rotation;
9467
- const timer = setTimeout(() => rotation.abort(/* @__PURE__ */ new Error(`the rotation's ${WORKSPACE_CHECKPOINT_ROTATION_CAPTURES_MS} ms for checkpoint captures ran out; checkpoint kept`)), WORKSPACE_CHECKPOINT_ROTATION_CAPTURES_MS);
9468
- try {
9469
- await cleanCheckpoints(state, branching, owned.slice(0, -2), events, AbortSignal.any([scope.signal, rotation.signal]));
9470
- } finally {
9471
- clearTimeout(timer);
9472
- if (state.rotationCaptures === rotation) delete state.rotationCaptures;
9473
- }
9544
+ return true;
9545
+ }
9546
+ /**
9547
+ * Delete this environment's oldest checkpoint beyond {@link WORKSPACE_CHECKPOINTS_KEPT} when no
9548
+ * capture could ever hold its files, to make room for a newer one. Keeping them all stopped the
9549
+ * restore point instead: zro-game-20261104b's box stored 25 of its 61 requests, its plan's limit,
9550
+ * and its last restore point was 7 h old. A backend that captures deletes through its rotation.
9551
+ */
9552
+ async function deleteOldestUncapturable(state, branching, environmentId, signal) {
9553
+ if (state.checkpointCapture?.port.captureCheckpoint !== void 0) return false;
9554
+ const events = await state.args.journal.loadTree(state.args.rootId) ?? [];
9555
+ const oldest = pendingCheckpoints(events, state).filter((event) => event.environmentId === environmentId).slice(0, -2).slice(0, 1);
9556
+ if (oldest.length === 0) return false;
9557
+ const { unconfirmed } = await cleanCheckpoints(state, branching, oldest, events, signal, true);
9558
+ return unconfirmed.length === 0;
9474
9559
  }
9475
9560
  /**
9476
9561
  * The owner's workspace-capture journal writers. A turn's capture starting cuts short the
@@ -10955,27 +11040,28 @@ function scopeRetainedOwnerResourceReader(scope) {
10955
11040
  }
10956
11041
  // src/runtime/supervise/retained-owner-seat-switch.ts
10957
11042
  /** A committed turn is the seat boundary. Keep its native home for a same-harness provider
10958
- * continuation; only a provider/harness change needs a new environment. */
11043
+ * continuation; only a provider/harness change needs a new environment, and a checkpoint of the
11044
+ * old one, whose time it returns. */
10959
11045
  async function prepareScopeRetainedOwnerSeatSwitch(scope, mode) {
10960
11046
  const state = owners.get(scope);
10961
11047
  if (!state?.acceptedRef || !state.acceptedConsumed) throw new ValidationError("seat switch requires a committed owner turn");
10962
11048
  const accepted = state.acceptedRef;
10963
11049
  const owned = await checkpointOwner(scope, state);
11050
+ if (mode === "same-environment") return void 0;
10964
11051
  const acceptedIndex = owned.findIndex((event) => event.kind === "execution-result" && event.seq === accepted.seq && event.outRef === accepted.outRef);
10965
11052
  if (acceptedIndex < 0) throw new ValidationError("seat switch has no committed result in its journal");
10966
11053
  const source = owned.slice(0, acceptedIndex).reverse().find((event) => event.kind === "execution-admitted" && event.admission.phase === "environment");
10967
11054
  const sourceEnvironmentId = source?.kind === "execution-admitted" && source.admission.phase === "environment" ? source.admission.environmentId : void 0;
10968
- const checkpoint = owned.slice(acceptedIndex + 1).reverse().find((event) => event.kind === "workspace-checkpoint" && event.environmentId === sourceEnvironmentId);
10969
- if (checkpoint?.kind !== "workspace-checkpoint") throw new ValidationError("seat switch requires a checkpoint of its committed source");
10970
- if (mode === "replace-environment") {
10971
- await retireCheckpointed(scope, state, owned, checkpoint, "seat changed");
10972
- state.forceNewSession = true;
11055
+ const since = owned.slice(acceptedIndex + 1).reverse();
11056
+ const checkpoint = since.find((event) => event.kind === "workspace-checkpoint" && event.environmentId === sourceEnvironmentId);
11057
+ if (checkpoint?.kind !== "workspace-checkpoint") {
11058
+ const refusal = since.find((event) => event.kind === "workspace-checkpoint-refused");
11059
+ const why = state.checkpointsUnavailable ?? (refusal?.kind === "workspace-checkpoint-refused" ? refusal.message : "none was taken");
11060
+ throw new ValidationError(`no checkpoint of its committed source: ${why}`);
10973
11061
  }
10974
- return {
10975
- checkpointAt: checkpoint.at,
10976
- checkpointId: checkpoint.checkpoint.checkpointId,
10977
- sourceEnvironmentId: checkpoint.environmentId
10978
- };
11062
+ await retireCheckpointed(scope, state, owned, checkpoint, "seat changed");
11063
+ state.forceNewSession = true;
11064
+ return checkpoint.at;
10979
11065
  }
10980
11066
  /** An exhausted seat chain pauses its manager until `resumeAt` with no turn to run: on
10981
11067
  * magnetar-rust-sandbox-20261031b (Runtime 3.0.5) a resume paused four managers until 11-04 with
@@ -12741,7 +12827,7 @@ function createChildRetention({ args, controller, id, ordinal, identity, recover
12741
12827
  }
12742
12828
  /** Whether a settled spend exceeds the budget it was given, by the channels the pool reconciles. */
12743
12829
  function overBudget(budget, spent) {
12744
- return chargedTokens(spent.tokens) > budget.maxTokens || spent.iterations > budget.maxIterations || budget.maxUsd !== void 0 && spent.usdKnown !== false && spent.usd > budget.maxUsd;
12830
+ return budget.maxTokens !== void 0 && chargedTokens(spent.tokens) > budget.maxTokens || budget.maxIterations !== void 0 && spent.iterations > budget.maxIterations || budget.maxUsd !== void 0 && spent.usdKnown !== false && spent.usd > budget.maxUsd;
12745
12831
  }
12746
12832
  // src/durable/spawn-journal/record-events.ts
12747
12833
  /** Decode the file journal's historical single-event and atomic-group envelopes. @internal */
@@ -14692,12 +14778,18 @@ function reservedCursorFloor(events) {
14692
14778
  function sumSpendFromEvents(events) {
14693
14779
  const totals = sumMeasuredSpendFromEvents(events);
14694
14780
  const rootBudget = events.find((event) => event.kind === "spawned" && event.parent === void 0)?.budget;
14781
+ let remainingRootTokens = Math.max(0, (rootBudget?.maxTokens ?? 0) - chargedTokens(totals.childWork.tokens) - chargedTokens(totals.driverInference.tokens));
14782
+ let remainingRootIterations = Math.max(0, (rootBudget?.maxIterations ?? 0) - totals.childWork.iterations - totals.driverInference.iterations);
14695
14783
  let remainingRootUsd = Math.max(0, (rootBudget?.maxUsd ?? 0) - totals.childWork.usd - totals.driverInference.usd);
14696
14784
  for (const budget of uncertainSpawnBudgets(events)) {
14697
14785
  const unknown = withBudgetResources(zeroSpend(), budget);
14698
14786
  Object.assign(totals.childWork, addResourceSpend(totals.childWork.resources, unknown.resources));
14699
- totals.childWork.iterations += budget.maxIterations;
14700
- totals.childWork.tokens.input += budget.maxTokens;
14787
+ const iterationCharge = budget.maxIterations ?? remainingRootIterations;
14788
+ totals.childWork.iterations += iterationCharge;
14789
+ remainingRootIterations = Math.max(0, remainingRootIterations - iterationCharge);
14790
+ const tokenCharge = budget.maxTokens ?? remainingRootTokens;
14791
+ totals.childWork.tokens.input += tokenCharge;
14792
+ remainingRootTokens = Math.max(0, remainingRootTokens - tokenCharge);
14701
14793
  totals.childWork.tokensKnown = false;
14702
14794
  const usdCharge = budget.maxUsd ?? (rootBudget?.maxUsd !== void 0 ? remainingRootUsd : 0);
14703
14795
  totals.childWork.usd += usdCharge;
@@ -16146,7 +16238,7 @@ var ScopeSpawner = class {
16146
16238
  const { recovery, opts } = request;
16147
16239
  const child = this.admit(request, reuse, ticket);
16148
16240
  const { id, continuing } = child;
16149
- const controller = this.armChildAbort(child, cleanup);
16241
+ const controller = this.armChildAbort(child, cleanup, permit);
16150
16242
  const deferredOwner = {};
16151
16243
  const workerTrace = args.workerTrace?.(args.parentId);
16152
16244
  const { recoveryReady, markRecoveryReady } = recoveryReadyGate(recovery, budgetGranted);
@@ -16267,20 +16359,24 @@ var ScopeSpawner = class {
16267
16359
  }
16268
16360
  /**
16269
16361
  * The child's abort chains off this scope's signal AND its own handle.abort() or bounded
16270
- * deadline; aborting mid-acquire cascades into acquireSandbox's find-by-name reap.
16362
+ * deadline; aborting mid-acquire cascades into acquireSandbox's find-by-name reap. A live child's
16363
+ * time box counts from its grant, not its spawn: queue time is not its time (zro-game-20261104a
16364
+ * s15-s20 expired queued, execution-did-not-start). A recovered child keeps its journaled grant.
16271
16365
  */
16272
- armChildAbort(child, cleanup) {
16366
+ armChildAbort(child, cleanup, permit) {
16273
16367
  const { args, now } = this.deps;
16274
16368
  const { id, childDeadlineAtMs } = child;
16275
16369
  const controller = new AbortController();
16276
16370
  cleanup.cascadeAbort = () => controller.abort(args.signal.reason);
16277
16371
  if (args.signal.aborted) controller.abort(args.signal.reason);
16278
16372
  else args.signal.addEventListener("abort", cleanup.cascadeAbort, { once: true });
16279
- if (childDeadlineAtMs !== void 0) {
16280
- const runDeadlineAtMs = args.depth === 0 ? args.pool.readout().deadlineMs : 0;
16281
- const timeBox = !(runDeadlineAtMs > 0 && childDeadlineAtMs >= runDeadlineAtMs);
16373
+ const runDeadlineAtMs = args.depth === 0 ? args.pool.readout().deadlineMs : 0;
16374
+ let cleared = false;
16375
+ const arm = (deadlineAtMs) => {
16376
+ if (deadlineAtMs === void 0 || cleared) return;
16377
+ const timeBox = !(runDeadlineAtMs > 0 && deadlineAtMs >= runDeadlineAtMs);
16282
16378
  let clearCheckIn;
16283
- const clearTimer = armDeadlineTimer(Math.max(0, childDeadlineAtMs - now()), () => {
16379
+ const clearTimer = armDeadlineTimer(Math.max(0, deadlineAtMs - now()), () => {
16284
16380
  clearCheckIn = timeBox ? this.deps.checkInAtTimeBox(id, controller) : void 0;
16285
16381
  if (clearCheckIn === void 0) controller.abort(CHILD_DEADLINE_REASON);
16286
16382
  });
@@ -16288,6 +16384,13 @@ var ScopeSpawner = class {
16288
16384
  clearTimer();
16289
16385
  clearCheckIn?.();
16290
16386
  };
16387
+ };
16388
+ if (child.recovery !== void 0 || child.opts.budget.deadlineMs === void 0) arm(childDeadlineAtMs);
16389
+ else {
16390
+ cleanup.clearChildDeadline = () => {
16391
+ cleared = true;
16392
+ };
16393
+ permit.ready.then(() => arm(boundedChildDeadlineAt(args.pool.readout().deadlineMs, child.opts.budget.deadlineMs, now())), () => void 0);
16291
16394
  }
16292
16395
  return controller;
16293
16396
  }
@@ -16715,8 +16818,8 @@ function reservationOwnerFloor(args) {
16715
16818
  if (reservationPolicy && !args.ownerBudget) throw new ValidationError("reservationPolicy requires the owning scope budget");
16716
16819
  const ownerBudget = args.ownerBudget;
16717
16820
  return reservationPolicy && ownerBudget ? {
16718
- tokens: Math.ceil(ownerBudget.maxTokens * reservationPolicy.ownerShare),
16719
- iterations: Math.ceil(ownerBudget.maxIterations * reservationPolicy.ownerShare),
16821
+ tokens: Math.ceil((ownerBudget.maxTokens ?? 0) * reservationPolicy.ownerShare),
16822
+ iterations: Math.ceil((ownerBudget.maxIterations ?? 0) * reservationPolicy.ownerShare),
16720
16823
  ...ownerBudget.maxUsd === void 0 ? {} : { usd: ownerBudget.maxUsd * reservationPolicy.ownerShare }
16721
16824
  } : void 0;
16722
16825
  }
@@ -16795,6 +16898,6 @@ async function recoverRetainedChildren(args, children, spawn, next) {
16795
16898
  throw error;
16796
16899
  }
16797
16900
  }
16798
- export { deriveNodeExecutionIdentity as $, assertEventBinding as $i, persistHarnessTranscript as $n, DISPATCH_NOT_ADMITTED_CODE as $r, insideCursorNamespace as $t, nestedScopeSeamKey as A, mapSandboxEvent as Ai, workerTraceEnv as An, recordRuntimeOwnedProviderDispatchNotStarted as Ar, beginScopeRetainedOwnerDrive as At, beginScopeOwnerAttempt as B, createSandboxTurnEventCollector as Bi, flatOtelSpan as Bn, unknownMaterializationReceipt as Br, retainedOwnerWorkspaceRetentionSeamKey as Bt, writeWorkerSteerAcknowledgement as C, createBudgetPool as Ci, nativeCopyDelayMs as Cn, inheritRuntimeOwnedExecutorAttestation as Cr, environmentReader as Ct, isTraceAnalysisStore as D, spendFromUsageTotals as Di, openSlotGroup as Dn, providerAttemptEvidence as Dr, prepareScopeRetainedOwnerTask as Dt, replaySpawnTree as E, spendFromUsageEvents as Ei, createWorkerSlots as En, newExecutionAttemptId as Er, consumeScopeRetainedOwnerResult as Et, recoverRetainedInteractiveRun as F, terminalTextFromSandboxEvent as Fi, buildLoopOtelSpans as Fn, runtimeOwnedExecutorMaterialization as Fr, scopeRetainedOwnerRestorePoint as Ft, scopeOwnerExecutorNodeContext as G, sameModelId as Gi, sanitizeKnowledgeReadinessReport as Gn, runtimeFlowBrain as Gr, materializeTreeView as Gt, noteScopeOwnerPlannedExecution as H, extractLlmCallEvent as Hi, loopEventToOtelSpan as Hn, executableAgentSpecSnapshot as Hr, scopeRetainedOwnerJournalRoot as Ht, startRetainedInteractiveRun as I, canonicalStreamEventFromSandboxEvent as Ii, buildLoopSpanNodes as In, runtimeOwnedExecutorProviderEvidence as Ir, noteScopeRetainedOwnerCoordination as It, providerVisibleProfile as J, sumSandboxUsage as Ji, captureBoundHarnessTranscript as Jn, runtimeFailureCauseSchema as Jr, nestedDriverTreeRoot as Jt, coordinationMcpAlias as K, sandboxEventServedBackend as Ki, sanitizeRuntimeStreamEvent as Kn, reportedFailureCause as Kr, attestNestedDriverTreeOwner as Kt, FileSpawnJournal as L, extractTransportEventIdentity as Li, buildRuntimeEventOtelSpans as Ln, runtimeOwnedPendingExecutorMaterialization as Lr, scopeRetainedOwnerCheckpointing as Lt, attachWorker as M, sandboxLeafOutputFromEvents as Mi, createPropagatingTraceEmitter as Mn, recordRuntimeOwnedProviderModel as Mr, scopeRetainedOwnerTurnEnded as Mt, readWorkerInteractiveBinding as N, sandboxOutputMarker as Ni, mergeTraceEnv as Nn, runtimeOwnedDriveHarnessProviderEvidence as Nr, assertRetainedOwnerCoordinationRekey as Nt, parseWorkerToolTraceArtifact as O, assertValidBudget as Oi, resolveWorkerSlots as On, recordRuntimeOwnedDriveHarnessProviderEvidence as Or, scopeRetainedOwnerPriorSpend as Ot, reconnectRetainedInteractiveRun as P, sandboxProgressEvents as Pi, readTraceContextFromEnv as Pn, runtimeOwnedExecutorExecutionBinding as Pr, reconcileScopeRetainedOwnerEnvironment as Pt, assertRecursiveReservationPolicy as Q, RetainedRunProviderContractError as Qi, harnessTranscriptUnavailable as Qn, DISPATCH_EXECUTION_CHANGED_CODE as Qr, closesCursorSlot as Qt, appendSpawnEvents as R, assertSandboxServedModel as Ri, createOpenInferenceFileExporter as Rn, runtimeOwnedScopeOwnerRuntime as Rr, bindScopeRetainedOwnerEnvironmentId as Rt, writeWorkerSteer as S, isCredentialRefusal as Si, captureProviderWorkspaceSnapshot as Sn, finalizeRuntimeOwnedPendingExecutor as Sr, scopeRetainedOwnerResourceReader as St, sumSpendFromEvents as T, newUsageTotals as Ti, workspaceCaptureReceipt as Tn, knownMaterializationReceipt as Tr, abandonScopeRetainedOwnerInvocation as Tt, recordScopeOwnerMaterialization as U, isSandboxTerminalEvent as Ui, createRuntimeEventCollector as Un, isRuntimeFlowBrain as Ur, loadSpawnForest as Ut, finalizeScopeOwnerMaterialization as V, createSandboxUsageLedger as Vi, generateSpanId as Vn, executableAgentProfileSnapshot as Vr, scopeRetainedOwnerContext as Vt, restoreScopeOwnerAcceptedExecution as W, notifySandboxEventObserver as Wi, createRuntimeStreamEventCollector as Wn, runtimeFlowAgent as Wr, ownedTreeRootSpawn as Wt, reenteredWorkers as X, parseCodexUsageRecord as Xi, harnessTranscriptArtifact as Xn, runtimeProviderCode as Xr, encodeResultBlob as Xt, runtimeGraphMetadataKey as Y, decodeHarnessUsage as Yi, captureHarnessTranscript as Yn, runtimeFailureRemediationSchema as Yr, FileResultBlobStore as Yt, settledToIteration as Z, recordValue as Zi, harnessTranscriptFromLines as Zn, settlementFailureCause as Zr, SpawnEventIndex as Zt, supervisorRunDir as _, contentAddress as _i, destroyInteractiveEnvironment as _n, attestRuntimeOwnedExecutor as _r, startScopeRecoveries as _t, readRootStream as a, RunCancellationReason as aa, retainedExecutorContext as ai, reconnectRetainedRun as an, DEFAULT_STALL_AFTER_MS as ar, hasRetriableTeardowns as at, workerInboxFileFromEventDir as b, hashJson as bi, assertProviderWorkspaceRetentionPort as bn, authoredAgentIdentity as br, prepareScopeRetainedOwnerSeatSwitch as bt, cancelWorker as c, runAbortable as ca, UNAVAILABLE_STATUSES as ci, startRetainedRunInEnvironment as cn, readWorkerProgress as cr, recordScopeOwnerBarrenPause as ct, legacySupervisorRunsRoot as d, promptOptionsFromAgentTurnInput as da, printedStatus as di, offerInteractiveControl as dn, SeatChain as dr, registerNestedTeardownScope as dt, awaitAbortable$1 as ea, RetainedExecutionPendingError as ei, verifyWorkspaceMarker as en, readHarnessTranscript as er, freeSlots as et, readWorkerCancelRequests as f, providerMessageText as fa, unavailablePauseMs as fi, prepareInteractiveDelegation as fn, SeatChainExhaustedError as fr, releaseHeldEnvironments as ft, safeWorkerFile as g, TRACE_SUMMARY_SCHEMA as gi, verifyObserverRecords as gn, attestRuntimeOwnedDeferredExecutor as gr, settleManagerWork as gt, readWorkerSteerRequests as h, TRACE_ROOT_SCHEMA as hi, observerRecordDigest as hn, subscriptionUsageLimitSignal as hr, retryUnconfirmedTeardowns as ht, nodeStreamFile as i, sameControlCoordinates as ia, registerRetainedExecutorPreparation as ii, mintRetainedIdentity as in, retainHarnessTranscript as ir, closeScopeAdmission as it, interactiveAdmissionSeamKey as j, mapSandboxToolEvent as ji, workerTraceHeaders as jn, recordRuntimeOwnedProviderIdentityConflict as jr, scopeRetainedOwnerSettled as jt, workerTraceAnalysisStore as k, createSandboxToolPartState as ki, WORKER_TRACE_PROPAGATION as kn, recordRuntimeOwnedProviderAttemptStart as kr, scopeRetainedOwnerResult as kt, claimWorkerSteerDelivery as l, signalAbortError as la, cappedDoublingMs as li, retainedCreateMaterial as ln, isLiveNodeStatus as lr, recordScopeOwnerDriverAttempt as lt, readWorkerSteerAcknowledgement as m, unavailableSignalOfFailure as mi, createFileObserverHooks as mn, seatExecutionProfile as mr, releaseRetainedEnvironments as mt, ROOT_STREAM_FILE as n, freezeControlRef as na, isProvisioningRefusal as ni, stopRetainedNativeExecution as nn, readBoundHarnessSessions as nr, rollingDispatch as nt, readRootStreamReceipt as o, abortReason as oa, retainedExecutorSeamKey as oi, recoverRetainedRun as on, createActivityLog as or, meterRuntimeOwnedAccounting as ot, readWorkerCancellation as p, unavailableResumeAt as pi, FileObserverJournal as pn, authoredSeatStages as pr, releaseManagerEnvironment as pt, coordinationProfileToolPrefix as q, sandboxTerminalUsageField as qi, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as qn, runtimeFailureCause as qr, driverRuntime as qt, createRootStreamSink as r, isTerminalSessionStatus as ra, isSchemaRejection as ri, assertRetainedRunReplayMaterial as rn, resolveHarnessTranscriptCapture as rr, closeRetainedSlots as rt, appendWorkerControlEvent as s, linkAbort as sa, UNAVAILABLE_CODES as si, startRetainedRun as sn, describeToolArgs as sr, meterRuntimeOwnedProviderAttempt as st, createScope as t, exactSession as ta, TRANSPORT_ERROR_CODES as ti, describeRetainedNativeStops as tn, HARNESS_TRANSCRIPT_READ_LIMITS as tr, queueOf as tt, legacySupervisorRunDir as u, promptFromAgentTurnInput as ua, jitteredMs as ui, acceptedInteractiveControl as un, isTerminalNodeStatus as ur, recordScopeOwnerPause as ut, supervisorRunsRoot as v, contentRef as vi, environmentGone as vn, attestRuntimeOwnedPendingExecutor as vr, unconfirmedTeardowns as vt, prepareScopeResume as w, meterUsageEvent as wi, openNativeMirror as wn, knownExecutionBindingReceipt as wr, resolveSpawnResourcePaths as wt, writeWorkerCancellation as x, credentialCommandExit as xi, captureProviderLiveWorkspace as xn, authoredProfileDigest as xr, releaseScopeRetainedOwnerForSeatPause as xt, workerCancellationsDir as y, executorFailure as yi, DEFAULT_NATIVE_CAPTURE_INTERVAL_MS as yn, attestRuntimeOwnedScopeOwner as yr, waitForScopeChildren as yt, spawnJournalRecordEvents as z, canonicalSandboxUsageMode as zi, createOtelExporter as zn, unknownExecutionBindingReceipt as zr, bindScopeRetainedOwnerProvider as zt };
16901
+ export { deriveNodeExecutionIdentity as $, sandboxEventServedBackend as $i, harnessTranscriptUnavailable as $n, runtimeProviderCode as $r, closesCursorSlot as $t, nestedScopeSeamKey as A, createBudgetPool as Ai, WORKER_TRACE_PROPAGATION as An, recordRuntimeOwnedDriveHarnessProviderEvidence as Ar, beginScopeRetainedOwnerDrive as At, beginScopeOwnerAttempt as B, sandboxOutputMarker as Bi, createOtelExporter as Bn, runtimeOwnedScopeOwnerControl as Br, bindScopeRetainedOwnerWorkspaceRetention as Bt, writeWorkerSteerAcknowledgement as C, executorFailure as Ci, captureProviderWorkspaceSnapshot as Cn, authoredProfileDigest as Cr, environmentReader as Ct, isTraceAnalysisStore as D, hashJson as Di, createWorkerSlots as Dn, knownMaterializationReceipt as Dr, prepareScopeRetainedOwnerTask as Dt, replaySpawnTree as E, turnFailurePolicy as Ei, workspaceCaptureReceipt as En, knownExecutionBindingReceipt as Er, consumeScopeRetainedOwnerResult as Et, recoverRetainedInteractiveRun as F, assertValidBudget as Fi, readTraceContextFromEnv as Fn, runtimeOwnedDriveHarnessProviderEvidence as Fr, scopeRetainedOwnerRestorePoint as Ft, scopeOwnerExecutorNodeContext as G, assertSandboxServedModel as Gi, createRuntimeStreamEventCollector as Gn, executableAgentSpecSnapshot as Gr, ownedTreeRootSpawn as Gt, noteScopeOwnerPlannedExecution as H, terminalTextFromSandboxEvent as Hi, generateSpanId as Hn, unknownExecutionBindingReceipt as Hr, scopeRetainedOwnerContext as Ht, startRetainedInteractiveRun as I, createSandboxToolPartState as Ii, buildLoopOtelSpans as In, runtimeOwnedExecutorExecutionBinding as Ir, noteScopeRetainedOwnerCoordination as It, providerVisibleProfile as J, createSandboxUsageLedger as Ji, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as Jn, runtimeFlowBrain as Jr, driverRuntime as Jt, coordinationMcpAlias as K, canonicalSandboxUsageMode as Ki, sanitizeKnowledgeReadinessReport as Kn, isRuntimeFlowBrain as Kr, materializeTreeView as Kt, FileSpawnJournal as L, mapSandboxEvent as Li, buildLoopSpanNodes as Ln, runtimeOwnedExecutorMaterialization as Lr, scopeRetainedOwnerCheckpointing as Lt, attachWorker as M, newUsageTotals as Mi, workerTraceHeaders as Mn, recordRuntimeOwnedProviderDispatchNotStarted as Mr, scopeRetainedOwnerTurnEnded as Mt, readWorkerInteractiveBinding as N, spendFromUsageEvents as Ni, createPropagatingTraceEmitter as Nn, recordRuntimeOwnedProviderIdentityConflict as Nr, assertRetainedOwnerCoordinationRekey as Nt, parseWorkerToolTraceArtifact as O, credentialCommandExit as Oi, openSlotGroup as On, newExecutionAttemptId as Or, scopeRetainedOwnerPriorSpend as Ot, reconnectRetainedInteractiveRun as P, spendFromUsageTotals as Pi, mergeTraceEnv as Pn, recordRuntimeOwnedProviderModel as Pr, reconcileScopeRetainedOwnerEnvironment as Pt, assertRecursiveReservationPolicy as Q, sameModelId as Qi, harnessTranscriptFromLines as Qn, runtimeFailureRemediationSchema as Qr, SpawnEventIndex as Qt, appendSpawnEvents as R, mapSandboxToolEvent as Ri, buildRuntimeEventOtelSpans as Rn, runtimeOwnedExecutorProviderEvidence as Rr, bindScopeRetainedOwnerEnvironmentId as Rt, writeWorkerSteer as S, contentRef as Si, captureProviderLiveWorkspace as Sn, authoredAgentIdentity as Sr, scopeRetainedOwnerResourceReader as St, sumSpendFromEvents as T, turnFailureOf as Ti, openNativeMirror as Tn, inheritRuntimeOwnedExecutorAttestation as Tr, abandonScopeRetainedOwnerInvocation as Tt, recordScopeOwnerMaterialization as U, canonicalStreamEventFromSandboxEvent as Ui, loopEventToOtelSpan as Un, unknownMaterializationReceipt as Ur, scopeRetainedOwnerJournalRoot as Ut, finalizeScopeOwnerMaterialization as V, sandboxProgressEvents as Vi, flatOtelSpan as Vn, runtimeOwnedScopeOwnerRuntime as Vr, retainedOwnerWorkspaceRetentionSeamKey as Vt, restoreScopeOwnerAcceptedExecution as W, extractTransportEventIdentity as Wi, createRuntimeEventCollector as Wn, executableAgentProfileSnapshot as Wr, loadSpawnForest as Wt, reenteredWorkers as X, isSandboxTerminalEvent as Xi, captureHarnessTranscript as Xn, runtimeFailureCause as Xr, FileResultBlobStore as Xt, runtimeGraphMetadataKey as Y, extractLlmCallEvent as Yi, captureBoundHarnessTranscript as Yn, reportedFailureCause as Yr, nestedDriverTreeRoot as Yt, settledToIteration as Z, notifySandboxEventObserver as Zi, harnessTranscriptArtifact as Zn, runtimeFailureCauseSchema as Zr, encodeResultBlob as Zt, supervisorRunDir as _, promptFromAgentTurnInput as _a, unavailableResumeAt as _i, verifyObserverRecords as _n, subscriptionUsageLimitSignal as _r, startScopeRecoveries as _t, readRootStream as a, RetainedRunProviderContractError as aa, isProvisioningRefusal as ai, mintRetainedIdentity as an, retainHarnessTranscript as ar, hasRetriableTeardowns as at, workerInboxFileFromEventDir as b, TRACE_SUMMARY_SCHEMA as bi, DEFAULT_NATIVE_CAPTURE_INTERVAL_MS as bn, attestRuntimeOwnedPendingExecutor as br, prepareScopeRetainedOwnerSeatSwitch as bt, cancelWorker as c, exactSession as ca, retainedExecutorContext as ci, startRetainedRun as cn, describeToolArgs as cr, recordScopeOwnerBarrenPause as ct, legacySupervisorRunsRoot as d, sameControlCoordinates as da, UNAVAILABLE_STATUSES as di, acceptedInteractiveControl as dn, isTerminalNodeStatus as dr, registerNestedTeardownScope as dt, sandboxTerminalUsageField as ea, settlementFailureCause as ei, insideCursorNamespace as en, persistHarnessTranscript as er, freeSlots as et, readWorkerCancelRequests as f, RunCancellationReason as fa, cappedDoublingMs as fi, offerInteractiveControl as fn, SEAT_RECHECK_MS as fr, releaseHeldEnvironments as ft, safeWorkerFile as g, signalAbortError as ga, unavailablePauseMs as gi, observerRecordDigest as gn, seatExecutionProfile as gr, settleManagerWork as gt, readWorkerSteerRequests as h, runAbortable as ha, reportedResetAt as hi, createFileObserverHooks as hn, authoredSeatStages as hr, retryUnconfirmedTeardowns as ht, nodeStreamFile as i, recordValue as ia, TRANSPORT_ERROR_CODES as ii, assertRetainedRunReplayMaterial as in, resolveHarnessTranscriptCapture as ir, closeScopeAdmission as it, interactiveAdmissionSeamKey as j, meterUsageEvent as ji, workerTraceEnv as jn, recordRuntimeOwnedProviderAttemptStart as jr, scopeRetainedOwnerSettled as jt, workerTraceAnalysisStore as k, isCredentialRefusal as ki, resolveWorkerSlots as kn, providerAttemptEvidence as kr, scopeRetainedOwnerResult as kt, claimWorkerSteerDelivery as l, freezeControlRef as la, retainedExecutorSeamKey as li, startRetainedRunInEnvironment as ln, readWorkerProgress as lr, recordScopeOwnerDriverAttempt as lt, readWorkerSteerAcknowledgement as m, linkAbort as ma, printedStatus as mi, FileObserverJournal as mn, SeatPauseError as mr, releaseRetainedEnvironments as mt, ROOT_STREAM_FILE as n, decodeHarnessUsage as na, DISPATCH_NOT_ADMITTED_CODE as ni, describeRetainedNativeStops as nn, HARNESS_TRANSCRIPT_READ_LIMITS as nr, rollingDispatch as nt, readRootStreamReceipt as o, assertEventBinding as oa, isSchemaRejection as oi, reconnectRetainedRun as on, DEFAULT_STALL_AFTER_MS as or, meterRuntimeOwnedAccounting as ot, readWorkerCancellation as p, abortReason as pa, jitteredMs as pi, prepareInteractiveDelegation as pn, SeatChain as pr, releaseManagerEnvironment as pt, coordinationProfileToolPrefix as q, createSandboxTurnEventCollector as qi, sanitizeRuntimeStreamEvent as qn, runtimeFlowAgent as qr, attestNestedDriverTreeOwner as qt, createRootStreamSink as r, parseCodexUsageRecord as ra, RetainedExecutionPendingError as ri, stopRetainedNativeExecution as rn, readBoundHarnessSessions as rr, closeRetainedSlots as rt, appendWorkerControlEvent as s, awaitAbortable$1 as sa, registerRetainedExecutorPreparation as si, recoverRetainedRun as sn, createActivityLog as sr, meterRuntimeOwnedProviderAttempt as st, createScope as t, sumSandboxUsage as ta, DISPATCH_EXECUTION_CHANGED_CODE as ti, verifyWorkspaceMarker as tn, readHarnessTranscript as tr, queueOf as tt, legacySupervisorRunDir as u, isTerminalSessionStatus as ua, UNAVAILABLE_CODES as ui, retainedCreateMaterial as un, isLiveNodeStatus as ur, recordScopeOwnerPause as ut, supervisorRunsRoot as v, promptOptionsFromAgentTurnInput as va, unavailableSignalOfFailure as vi, destroyInteractiveEnvironment as vn, attestRuntimeOwnedDeferredExecutor as vr, unconfirmedTeardowns as vt, prepareScopeResume as w, executorFailureInfra as wi, nativeCopyDelayMs as wn, finalizeRuntimeOwnedPendingExecutor as wr, resolveSpawnResourcePaths as wt, writeWorkerCancellation as x, contentAddress as xi, assertProviderWorkspaceRetentionPort as xn, attestRuntimeOwnedScopeOwner as xr, releaseScopeRetainedOwnerForSeatPause as xt, workerCancellationsDir as y, providerMessageText as ya, TRACE_ROOT_SCHEMA as yi, environmentGone as yn, attestRuntimeOwnedExecutor as yr, waitForScopeChildren as yt, spawnJournalRecordEvents as z, sandboxLeafOutputFromEvents as zi, createOpenInferenceFileExporter as zn, runtimeOwnedPendingExecutorMaterialization as zr, bindScopeRetainedOwnerProvider as zt };
16799
16902
 
16800
- //# sourceMappingURL=scope-Bg1uCsPR.js.map
16903
+ //# sourceMappingURL=scope-JcCkUy_z.js.map