deepline 0.3.537 → 0.3.538

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 (204) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +22 -5
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
  6. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
  7. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +330 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
  11. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
  16. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
  17. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
  20. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -3
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2390 -110
  35. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
  54. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
  55. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
  57. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
  59. package/dist/cli/auth-4WEVLYK4.js +43 -0
  60. package/dist/cli/{auth-4SUPGDIM.mjs → auth-KYH7N7RQ.mjs} +5 -5
  61. package/dist/cli/{billing-SQU726P7.js → billing-4KTUVZ4S.js} +114 -90
  62. package/dist/cli/{billing-5JUA3ZM3.mjs → billing-WK346KAI.mjs} +31 -7
  63. package/dist/cli/{chunk-KULT6O5K.js → chunk-25RGHJQL.js} +15 -15
  64. package/dist/cli/{chunk-PJ4ZGZAN.js → chunk-34PLG5OE.js} +13 -13
  65. package/dist/cli/{chunk-37AZHCTP.mjs → chunk-35OCRH5C.mjs} +5 -5
  66. package/dist/cli/{chunk-JMHYDDBQ.js → chunk-3I5TU5XE.js} +292 -279
  67. package/dist/cli/{chunk-Y6AMMXWS.mjs → chunk-4KZF6OYY.mjs} +3 -3
  68. package/dist/cli/{chunk-BRRCWUOW.mjs → chunk-4NEOGPKD.mjs} +1 -1
  69. package/dist/cli/{chunk-NU7B5X6J.mjs → chunk-4WQR4DG4.mjs} +1 -1
  70. package/dist/cli/{chunk-AVQET3NR.js → chunk-5VSPRRTI.js} +7 -7
  71. package/dist/cli/{chunk-EEFSUCYP.mjs → chunk-6JG3MRTM.mjs} +2 -2
  72. package/dist/cli/{chunk-D77W6Q67.js → chunk-6SLQLWWL.js} +26 -26
  73. package/dist/cli/{chunk-ZUAMXZXC.mjs → chunk-7XDJKIM2.mjs} +4 -4
  74. package/dist/cli/{chunk-C37VELBR.mjs → chunk-A6E7TCK2.mjs} +5 -5
  75. package/dist/cli/{chunk-JS2SBCWD.js → chunk-ADLDU2QG.js} +6 -6
  76. package/dist/cli/{chunk-VP2K5B3R.mjs → chunk-ALARRSMZ.mjs} +3 -3
  77. package/dist/cli/{chunk-CHIGEDAE.js → chunk-B2BTBHX2.js} +3 -3
  78. package/dist/cli/{chunk-CFND2ACL.js → chunk-BBS2BLPV.js} +16 -16
  79. package/dist/cli/{chunk-QDBGPRR2.mjs → chunk-CLO562KG.mjs} +3 -1
  80. package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
  81. package/dist/cli/{chunk-UGA5KI4A.js → chunk-ESX3H7Q7.js} +22 -22
  82. package/dist/cli/{chunk-BFHR7IC2.mjs → chunk-FJ5KPGCS.mjs} +10 -10
  83. package/dist/cli/{chunk-R7JYG6XO.mjs → chunk-FWE37N2P.mjs} +1 -1
  84. package/dist/cli/{chunk-K4WJ4BYO.mjs → chunk-ICTA5ICE.mjs} +1 -1
  85. package/dist/cli/{chunk-PU42VOBI.js → chunk-IMLFB66A.js} +3 -3
  86. package/dist/cli/{chunk-GI3V4D7K.mjs → chunk-IP3XJTWA.mjs} +2 -2
  87. package/dist/cli/{chunk-WBFOV5HT.js → chunk-JCLRSMUP.js} +5 -5
  88. package/dist/cli/{chunk-L3JVGNAT.mjs → chunk-JPEBKN3K.mjs} +2 -2
  89. package/dist/cli/{chunk-Z2PPB3IO.mjs → chunk-JTOV5RUA.mjs} +1 -1
  90. package/dist/cli/{chunk-WBTYWJLN.js → chunk-KCUQNH4K.js} +2 -2
  91. package/dist/cli/{chunk-C3XD2WHM.mjs → chunk-KNIYEZVV.mjs} +2 -2
  92. package/dist/cli/{chunk-3PMCQ3LK.js → chunk-LPTBHNGB.js} +7 -5
  93. package/dist/cli/{chunk-KH27B2HJ.mjs → chunk-M3NCXGNN.mjs} +2 -2
  94. package/dist/cli/{chunk-XDS26J7Z.js → chunk-MNBIGX6O.js} +10 -10
  95. package/dist/cli/{chunk-L6QAIZNZ.js → chunk-MYSPQUAO.js} +44 -44
  96. package/dist/cli/{chunk-W3J3LT22.mjs → chunk-N2BCPZVR.mjs} +5 -5
  97. package/dist/cli/{chunk-ZFSB7GXF.js → chunk-N5HSG4OV.js} +5 -5
  98. package/dist/cli/{chunk-2Q7VXTMS.js → chunk-O765M4LT.js} +2 -2
  99. package/dist/cli/{chunk-QPDLG7DQ.js → chunk-OOLBE6FR.js} +53 -53
  100. package/dist/cli/{chunk-IQOIT6E3.js → chunk-P3DP56HB.js} +41 -41
  101. package/dist/cli/{chunk-BGXEMTIG.js → chunk-PQKD5DMT.js} +19 -19
  102. package/dist/cli/{chunk-V5IIBG2E.mjs → chunk-T6GPTJ5F.mjs} +1 -1
  103. package/dist/cli/{chunk-GPMS6OPX.mjs → chunk-TWWYCJJW.mjs} +5 -5
  104. package/dist/cli/{chunk-ZHPSJ3LJ.mjs → chunk-UE7JHAZ2.mjs} +29 -16
  105. package/dist/cli/{chunk-VRYX2BR4.js → chunk-UEZNIPFO.js} +107 -107
  106. package/dist/cli/{chunk-AX2OAXDL.mjs → chunk-VCHV4LS3.mjs} +1 -1
  107. package/dist/cli/{chunk-NXGLJGPB.js → chunk-VIFLWQXS.js} +2 -2
  108. package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
  109. package/dist/cli/{chunk-5EOEJKSV.js → chunk-YQURGSRB.js} +1 -1
  110. package/dist/cli/{chunk-ALHKB3AE.js → chunk-YZ2ZPHWR.js} +9 -9
  111. package/dist/cli/{chunk-CGDW2CRR.mjs → chunk-ZDLDCXY3.mjs} +2 -2
  112. package/dist/cli/{chunk-RMVZTBI5.mjs → chunk-ZU6JBRV5.mjs} +4 -4
  113. package/dist/cli/command-docs.js +2 -2
  114. package/dist/cli/command-docs.mjs +1 -1
  115. package/dist/cli/{csv-HZP6QMG7.mjs → csv-2YKLUKDR.mjs} +4 -4
  116. package/dist/cli/{csv-JITYN27L.js → csv-LM7FBECI.js} +13 -13
  117. package/dist/cli/{db-QRIRTOMM.mjs → db-234UBWJH.mjs} +6 -6
  118. package/dist/cli/{db-FYSRB7O4.js → db-5PMA4IVW.js} +27 -27
  119. package/dist/cli/describe-C7GOSGYB.js +49 -0
  120. package/dist/cli/{describe-REXJVJC3.mjs → describe-W26LW5O7.mjs} +17 -17
  121. package/dist/cli/describe-core.d.mts +3 -3
  122. package/dist/cli/describe-core.d.ts +3 -3
  123. package/dist/cli/{executions-BSTF4DDS.js → executions-3S736GXX.js} +8 -8
  124. package/dist/cli/{executions-53KJAFOW.mjs → executions-GD7GXTJM.mjs} +6 -6
  125. package/dist/cli/{feedback-6MW3QOXX.js → feedback-BUWTDY4R.js} +14 -14
  126. package/dist/cli/{feedback-CWUJJF3J.mjs → feedback-GBV5HJJZ.mjs} +6 -6
  127. package/dist/cli/git-YG36MROC.js +25 -0
  128. package/dist/cli/{git-CKVZTJFS.mjs → git-YXJGTDQL.mjs} +5 -5
  129. package/dist/cli/index.js +143 -143
  130. package/dist/cli/index.mjs +42 -42
  131. package/dist/cli/{legacy-noops-USTBRFRX.mjs → legacy-noops-UJM6GBNP.mjs} +6 -6
  132. package/dist/cli/{legacy-noops-QBL4PNGB.js → legacy-noops-ZSF64V2U.js} +9 -9
  133. package/dist/cli/{monitors-6UCG5D7W.mjs → monitors-UERUQ6CT.mjs} +7 -7
  134. package/dist/cli/{monitors-VCR6SUZD.js → monitors-XQ2GNH6D.js} +100 -100
  135. package/dist/cli/{org-GSRBOJVO.mjs → org-CP4VLH6M.mjs} +6 -6
  136. package/dist/cli/{org-HPILTEG4.js → org-IF6MPVNR.js} +86 -86
  137. package/dist/cli/{play-TK7WOP5H.js → play-2NHQO5MO.js} +317 -317
  138. package/dist/cli/{play-QRTYQNG4.mjs → play-ZWDYYVPI.mjs} +17 -17
  139. package/dist/cli/{providers-OAQJWVBS.mjs → providers-2CVIATU4.mjs} +6 -6
  140. package/dist/cli/{providers-HEXNJ5QC.js → providers-LOPXQN56.js} +9 -9
  141. package/dist/cli/{quickstart-FFVHTPSP.mjs → quickstart-KVCFXLID.mjs} +4 -4
  142. package/dist/cli/{quickstart-PYZTFXZX.js → quickstart-N4WDEQZY.js} +6 -6
  143. package/dist/cli/{run-4DWJXJRO.js → run-BDT5LK3I.js} +42 -42
  144. package/dist/cli/{run-HLN6YYZH.mjs → run-RUXHYWLF.mjs} +22 -22
  145. package/dist/cli/search-ATDDVADT.js +32 -0
  146. package/dist/cli/{search-ZHRCXGEL.mjs → search-BFUTNPA5.mjs} +7 -7
  147. package/dist/cli/{search-output-2KY6PFDH.js → search-output-CTXI2QZU.js} +6 -6
  148. package/dist/cli/{search-output-N7QXACVK.mjs → search-output-WUGH4PZA.mjs} +4 -4
  149. package/dist/cli/{secrets-WXQ7XO5C.js → secrets-BZJZYFOU.js} +15 -15
  150. package/dist/cli/{secrets-FKMWBLHU.mjs → secrets-Z4XQVTC6.mjs} +6 -6
  151. package/dist/cli/sessions-HNU35AFM.js +22 -0
  152. package/dist/cli/{sessions-3YDTEDA5.mjs → sessions-VZXR3MQZ.mjs} +6 -6
  153. package/dist/cli/{settings-JTPASUZN.mjs → settings-VYEZFR4L.mjs} +12 -12
  154. package/dist/cli/{settings-67TWLQ6E.js → settings-WBYA4JMM.js} +85 -85
  155. package/dist/cli/{setup-KUERQJUX.js → setup-FS2RMSS2.js} +49 -49
  156. package/dist/cli/{setup-VYNGXUJ6.mjs → setup-H7KCI4SO.mjs} +9 -9
  157. package/dist/cli/skills-VPIURCAZ.js +36 -0
  158. package/dist/cli/{skills-KI4KYHH6.mjs → skills-YQNSJUUG.mjs} +7 -7
  159. package/dist/cli/tools-273GS5HU.js +56 -0
  160. package/dist/cli/{tools-UQDJS2RS.mjs → tools-ZF6SVEGW.mjs} +16 -16
  161. package/dist/cli/{update-7FQQUBOD.mjs → update-RKQNNJM4.mjs} +9 -9
  162. package/dist/cli/update-TOD3XY55.js +34 -0
  163. package/dist/cli/{views-JAM4MNNV.mjs → views-JHHOTWDU.mjs} +6 -6
  164. package/dist/cli/{views-MJK7JGZG.js → views-KN7FEDGT.js} +21 -21
  165. package/dist/cli/{workflow-AQPRIWQX.js → workflow-2WHSKTTV.js} +17 -17
  166. package/dist/cli/{workflow-TQRV5FGO.mjs → workflow-AAYLCLWA.mjs} +7 -7
  167. package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
  168. package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
  169. package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
  170. package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
  171. package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
  172. package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
  173. package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
  174. package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
  175. package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
  176. package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +1 -1
  177. package/dist/index.d.mts +7 -7
  178. package/dist/index.d.ts +7 -7
  179. package/dist/index.js +9 -9
  180. package/dist/index.mjs +6 -6
  181. package/dist/install-integrity.json +120 -112
  182. package/dist/plays/bundle-play-file.d.mts +3 -3
  183. package/dist/plays/bundle-play-file.d.ts +3 -3
  184. package/dist/plays/play-description.d.mts +2 -2
  185. package/dist/plays/play-description.d.ts +2 -2
  186. package/dist/plays/run-request.d.mts +2 -2
  187. package/dist/plays/run-request.d.ts +2 -2
  188. package/dist/release.d.mts +1 -1
  189. package/dist/release.d.ts +1 -1
  190. package/dist/release.js +2 -2
  191. package/dist/release.mjs +1 -1
  192. package/dist/server.d.mts +4 -4
  193. package/dist/server.d.ts +4 -4
  194. package/dist/server.js +5 -5
  195. package/dist/server.mjs +3 -3
  196. package/package.json +1 -1
  197. package/dist/cli/auth-Y2K2ZYYA.js +0 -43
  198. package/dist/cli/describe-LSOHOLFI.js +0 -49
  199. package/dist/cli/git-S7SWUZ3T.js +0 -25
  200. package/dist/cli/search-WERQBC6V.js +0 -32
  201. package/dist/cli/sessions-LXQ4Q6BS.js +0 -22
  202. package/dist/cli/skills-EFRLHY3F.js +0 -36
  203. package/dist/cli/tools-C3EIGFFP.js +0 -56
  204. package/dist/cli/update-KCY72RXH.js +0 -34
@@ -138,6 +138,14 @@ export function defaultPacingForTool(
138
138
  };
139
139
  }
140
140
 
141
+ /** A tool-call budget unit taken for work that may turn out not to run. */
142
+ export type SpeculativeBudgetCharge = {
143
+ /** The work never dispatched: counters end exactly as before the charge. */
144
+ refund(): void;
145
+ /** The work ran: the charge stands, exactly as an ordinary charge. */
146
+ commit(): void;
147
+ };
148
+
141
149
  export interface PlayExecutionGovernor {
142
150
  readonly adapter: AdapterId;
143
151
  readonly policy: ResolvedExecutionPolicy;
@@ -234,6 +242,19 @@ export interface PlayExecutionGovernor {
234
242
  /** Increment a monotonic budget counter; throws GovernorBudgetError on breach. */
235
243
  chargeBudget(kind: BudgetKind, amount?: number): Promise<void>;
236
244
 
245
+ /**
246
+ * Charge only from budget already reserved in this process, without
247
+ * waiting. Null when that is not possible (the ordinary `chargeBudget`
248
+ * path then decides, including a breach). `refund` returns an undispatched
249
+ * charge so counters and the reserved block end exactly as before it;
250
+ * `commit` keeps it. Until one of them, an ordinary charge that breaches
251
+ * only because of this charge waits for it instead of failing.
252
+ */
253
+ tryChargeBudget?(
254
+ kind: BudgetKind,
255
+ amount?: number,
256
+ ): SpeculativeBudgetCharge | null;
257
+
237
258
  /**
238
259
  * Fork an inline child view. The child gets its own recursion lineage while
239
260
  * sharing the parent's row/tool semaphores, adaptive admission, and budgets.
@@ -678,17 +699,86 @@ export function createPlayExecutionGovernor(
678
699
  }
679
700
  }
680
701
 
702
+ /**
703
+ * Budget held by speculative charges (`tryChargeBudget`) that have neither
704
+ * refunded nor committed. Without speculation that budget would be unspent,
705
+ * so an ordinary charge never fails because of it: it waits until those
706
+ * charges settle and then decides exactly as it would have.
707
+ */
708
+ const speculativeBudget = new Map<BudgetKind, number>();
709
+ let speculativeBudgetWaiters: Array<() => void> = [];
710
+ const releaseSpeculativeBudget = (kind: BudgetKind, amount: number) => {
711
+ const held = (speculativeBudget.get(kind) ?? 0) - amount;
712
+ if (held > 0) speculativeBudget.set(kind, held);
713
+ else speculativeBudget.delete(kind);
714
+ const waiters = speculativeBudgetWaiters;
715
+ speculativeBudgetWaiters = [];
716
+ for (const wake of waiters) wake();
717
+ };
718
+ const speculativeBudgetSettled = () =>
719
+ new Promise<void>((resolve) => {
720
+ speculativeBudgetWaiters.push(resolve);
721
+ });
722
+
681
723
  async function chargeBudget(kind: BudgetKind, amount = 1): Promise<void> {
682
- const current =
683
- kind === 'toolCall'
684
- ? state.toolCallCount
685
- : kind === 'retry'
686
- ? state.retryCount
687
- : state.waterfallStepExecutions;
688
- if (current + amount > budgetLimit(kind)) {
689
- throw new GovernorBudgetError(kind, current + amount, budgetLimit(kind));
724
+ while (true) {
725
+ const current =
726
+ kind === 'toolCall'
727
+ ? state.toolCallCount
728
+ : kind === 'retry'
729
+ ? state.retryCount
730
+ : state.waterfallStepExecutions;
731
+ const speculative = speculativeBudget.get(kind) ?? 0;
732
+ if (current + amount > budgetLimit(kind)) {
733
+ if (
734
+ speculative > 0 &&
735
+ current - speculative + amount <= budgetLimit(kind)
736
+ ) {
737
+ await speculativeBudgetSettled();
738
+ continue;
739
+ }
740
+ throw new GovernorBudgetError(
741
+ kind,
742
+ current + amount,
743
+ budgetLimit(kind),
744
+ );
745
+ }
746
+ try {
747
+ await reserveBudgets([{ kind, amount }]);
748
+ } catch (error) {
749
+ // The durable store refused a new reservation while speculative
750
+ // charges hold reserved budget this charge would otherwise have
751
+ // drawn. Each one that refunds puts its unit back in the block; wait
752
+ // through every held charge before deciding, not just the first.
753
+ if (!(error instanceof GovernorBudgetError)) throw error;
754
+ const charges = [{ key: kind, amount, limit: budgetLimit(kind) }];
755
+ let drawn = false;
756
+ while (!drawn && (speculativeBudget.get(kind) ?? 0) > 0) {
757
+ await speculativeBudgetSettled();
758
+ drawn =
759
+ budgetState.tryCharge?.call(budgetState, {
760
+ rootRunId: state.rootRunId,
761
+ charges,
762
+ }) === true;
763
+ }
764
+ if (!drawn) throw error;
765
+ }
766
+ break;
767
+ }
768
+ switch (kind) {
769
+ case 'toolCall':
770
+ state.toolCallCount += amount;
771
+ return;
772
+ case 'retry':
773
+ state.retryCount += amount;
774
+ return;
775
+ case 'waterfallStep':
776
+ state.waterfallStepExecutions += amount;
777
+ return;
690
778
  }
691
- await reserveBudgets([{ kind, amount }]);
779
+ }
780
+
781
+ function adjustBudgetCounter(kind: BudgetKind, amount: number): void {
692
782
  switch (kind) {
693
783
  case 'toolCall':
694
784
  state.toolCallCount += amount;
@@ -702,6 +792,45 @@ export function createPlayExecutionGovernor(
702
792
  }
703
793
  }
704
794
 
795
+ function tryChargeBudget(
796
+ kind: BudgetKind,
797
+ amount = 1,
798
+ ): SpeculativeBudgetCharge | null {
799
+ const tryCharge = budgetState.tryCharge;
800
+ const refundUndispatched = budgetState.refundUndispatched;
801
+ if (!tryCharge || !refundUndispatched) return null;
802
+ const current =
803
+ kind === 'toolCall'
804
+ ? state.toolCallCount
805
+ : kind === 'retry'
806
+ ? state.retryCount
807
+ : state.waterfallStepExecutions;
808
+ if (current + amount > budgetLimit(kind)) return null;
809
+ const charges = [{ key: kind, amount, limit: budgetLimit(kind) }];
810
+ if (!tryCharge.call(budgetState, { rootRunId: state.rootRunId, charges }))
811
+ return null;
812
+ adjustBudgetCounter(kind, amount);
813
+ speculativeBudget.set(kind, (speculativeBudget.get(kind) ?? 0) + amount);
814
+ let settled = false;
815
+ return {
816
+ refund() {
817
+ if (settled) return;
818
+ settled = true;
819
+ adjustBudgetCounter(kind, -amount);
820
+ refundUndispatched.call(budgetState, {
821
+ rootRunId: state.rootRunId,
822
+ charges,
823
+ });
824
+ releaseSpeculativeBudget(kind, amount);
825
+ },
826
+ commit() {
827
+ if (settled) return;
828
+ settled = true;
829
+ releaseSpeculativeBudget(kind, amount);
830
+ },
831
+ };
832
+ }
833
+
705
834
  const governor: PlayExecutionGovernor = {
706
835
  adapter: input.adapter,
707
836
  policy,
@@ -870,6 +999,7 @@ export function createPlayExecutionGovernor(
870
999
  },
871
1000
 
872
1001
  chargeBudget,
1002
+ tryChargeBudget,
873
1003
 
874
1004
  async forkInlineChild(childInput) {
875
1005
  return createInlineChildGovernor(
@@ -1025,6 +1155,8 @@ function createInlineChildGovernor(
1025
1155
  suggestedDirectToolParallelism: (toolId, fallback) =>
1026
1156
  root.suggestedDirectToolParallelism(toolId, fallback),
1027
1157
  chargeBudget: (kind, amount) => root.chargeBudget(kind, amount),
1158
+ tryChargeBudget: (kind, amount) =>
1159
+ root.tryChargeBudget?.(kind, amount) ?? null,
1028
1160
  resolveRowConcurrency: (requested) => root.resolveRowConcurrency(requested),
1029
1161
  reportProviderBackpressure: async (input) =>
1030
1162
  await root.reportProviderBackpressure(input),
@@ -96,6 +96,8 @@ export const PLAY_LAUNCH_ENVELOPE_FIELD_ROLES: {
96
96
  preferredReceiptGatewayMachineId: 'detail',
97
97
  runtimeTestFaultHeader: 'detail',
98
98
  testPolicyOverrides: 'detail',
99
+ experimentSwitchOverrides: 'detail',
100
+ earlySandboxClaimOwner: 'detail',
99
101
  submittedAtMs: 'detail',
100
102
  concurrentRunsLimit: 'detail',
101
103
  schedulerBackend: 'detail',
@@ -59,6 +59,11 @@ export type ModalRequiredConfig = {
59
59
  client: ModalClient;
60
60
  appName: string;
61
61
  image: string;
62
+ /**
63
+ * True when DEEPLINE_MODAL_RUNNER_IMAGE chose `image`. An explicit image
64
+ * takes precedence over the published baked runner image.
65
+ */
66
+ imageExplicit?: boolean;
62
67
  workdir: string;
63
68
  outboundCidrAllowlist: string[] | null;
64
69
  limits: PlaySandboxRuntimeLimits;
@@ -213,6 +218,7 @@ export async function loadModalClientConfig(
213
218
  appName:
214
219
  env.DEEPLINE_MODAL_RUNNER_APP_NAME?.trim() || MODAL_RUNNER_APP_NAME,
215
220
  image: env.DEEPLINE_MODAL_RUNNER_IMAGE?.trim() || MODAL_RUNNER_IMAGE,
221
+ imageExplicit: Boolean(env.DEEPLINE_MODAL_RUNNER_IMAGE?.trim()),
216
222
  workdir: env.DEEPLINE_MODAL_RUNNER_WORKDIR?.trim() || MODAL_RUNNER_WORKDIR,
217
223
  };
218
224
  }