deepline 0.3.552 → 0.3.554

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 (323) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +107 -12
  2. package/dist/bundling-sources/sdk/src/compat.ts +239 -87
  3. package/dist/bundling-sources/sdk/src/config.ts +113 -2
  4. package/dist/bundling-sources/sdk/src/errors.ts +2 -0
  5. package/dist/bundling-sources/sdk/src/http-core.ts +118 -8
  6. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  7. package/dist/bundling-sources/sdk/src/integrations.ts +6 -4
  8. package/dist/bundling-sources/sdk/src/play.ts +3 -0
  9. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
  10. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +8 -1
  12. package/dist/bundling-sources/sdk/src/tool-calls.ts +2 -1
  13. package/dist/bundling-sources/sdk/src/tool-failure-hint.ts +104 -0
  14. package/dist/bundling-sources/sdk/src/types.ts +9 -1
  15. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/integration-contracts/billing-plan-skus.ts +25 -0
  17. package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +2 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +58 -4
  19. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +8 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +11 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +13 -0
  22. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +103 -5
  23. package/dist/bundling-sources/shared_libs/monitors/fleets/converge-admission.ts +133 -0
  24. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-attention.ts +165 -0
  25. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-release.ts +726 -0
  26. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-walk.ts +274 -0
  27. package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +28 -0
  29. package/dist/bundling-sources/shared_libs/monitors/fleets/provider-bulk-wait.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/monitors/fleets/shared-payload.ts +189 -0
  31. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +28 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +4 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-counter-errors.ts +25 -0
  34. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +65 -0
  35. package/dist/bundling-sources/shared_libs/monitors/package.json +9 -0
  36. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +152 -1
  37. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +6 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +390 -10
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +34 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +66 -30
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +30 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
  43. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  45. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  46. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  47. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  49. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  50. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  51. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  52. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  53. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  54. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +168 -41
  55. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  56. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  57. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  58. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  60. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +444 -39
  61. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  64. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  65. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  67. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +72 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  71. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  73. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  74. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  78. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  79. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +254 -44
  82. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  83. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  86. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +259 -52
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +30 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  108. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  109. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  113. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  114. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  116. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  117. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  118. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  119. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  120. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  121. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  122. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  123. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  124. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  125. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  126. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  127. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  128. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  129. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  130. package/dist/cli/{auth-KVSBJZOX.mjs → auth-HJUNW7T2.mjs} +8 -7
  131. package/dist/cli/auth-SP6SKZJZ.js +44 -0
  132. package/dist/cli/{billing-FQREA7UA.js → billing-4TSA5HEC.js} +297 -161
  133. package/dist/cli/{billing-54RHFEBI.mjs → billing-SJYRJAQ2.mjs} +197 -61
  134. package/dist/cli/{chunk-4MK42735.js → chunk-2HMN5H54.js} +215 -130
  135. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  136. package/dist/cli/{chunk-EOPEYCY7.mjs → chunk-2ORPFQUA.mjs} +18 -18
  137. package/dist/cli/{chunk-RQZQVFCJ.js → chunk-2OVHNHCF.js} +2 -2
  138. package/dist/cli/{chunk-QX7LFGJR.mjs → chunk-33WRQSQ2.mjs} +1874 -91
  139. package/dist/cli/{chunk-UPMRIVZB.js → chunk-3IKGZ4CG.js} +74 -13
  140. package/dist/cli/{chunk-EUPVF4SU.mjs → chunk-3Z4VFCXO.mjs} +8 -8
  141. package/dist/cli/{chunk-GKYAYLRI.js → chunk-4DOFGIEJ.js} +27 -31
  142. package/dist/cli/{chunk-4TALT2M3.mjs → chunk-52Q5KETX.mjs} +69 -3
  143. package/dist/cli/{chunk-RBEUVDZF.js → chunk-5CYZHOKI.js} +249 -107
  144. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  145. package/dist/cli/{chunk-IYSTRCLX.mjs → chunk-62AUAWQV.mjs} +4 -4
  146. package/dist/cli/{chunk-ZIAXDBXX.mjs → chunk-62HWJXST.mjs} +17 -21
  147. package/dist/cli/{chunk-QY3ZNU6Z.mjs → chunk-6EXOAT6T.mjs} +2 -2
  148. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  149. package/dist/cli/{chunk-ADRC5I3R.js → chunk-7OWI736E.js} +30 -30
  150. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  151. package/dist/cli/{chunk-PTVD2GVQ.mjs → chunk-B6HO2XWH.mjs} +13 -13
  152. package/dist/cli/{chunk-YJHE3O5M.mjs → chunk-BOZAP2EM.mjs} +141 -56
  153. package/dist/cli/chunk-BVXIGOBZ.js +32 -0
  154. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  155. package/dist/cli/{chunk-WE5HES3H.mjs → chunk-D6Z6POKE.mjs} +151 -43
  156. package/dist/cli/{chunk-AZQ264ID.mjs → chunk-DSKSFFK2.mjs} +1 -1
  157. package/dist/cli/{chunk-SHLFOPD6.js → chunk-DUBXUAAO.js} +5 -5
  158. package/dist/cli/{chunk-V436Z54K.js → chunk-E2G2DNAB.js} +3 -1
  159. package/dist/cli/{chunk-HO3XK3R7.js → chunk-E74KGKFZ.js} +8 -8
  160. package/dist/cli/{chunk-77AAAGVB.js → chunk-ECHKAC7M.js} +2 -2
  161. package/dist/cli/{chunk-KWSH5T7K.js → chunk-EN5NHCCQ.js} +21 -21
  162. package/dist/cli/{chunk-6RZOWL2V.mjs → chunk-F7CMRKSK.mjs} +1 -1
  163. package/dist/cli/{chunk-JWUAX6OP.js → chunk-FBAFX43W.js} +11 -11
  164. package/dist/cli/{chunk-AQWQ2BFX.mjs → chunk-FXQ3JKE3.mjs} +1 -1
  165. package/dist/cli/{chunk-QPKH23EC.mjs → chunk-GA2M3G3Y.mjs} +5 -5
  166. package/dist/cli/{chunk-G4O75EXF.js → chunk-GHT2NDL7.js} +18 -18
  167. package/dist/cli/{chunk-MF2GHZDO.js → chunk-GRZENGNE.js} +2 -2
  168. package/dist/cli/{chunk-4UUR4TCH.js → chunk-IVZKMJUK.js} +1875 -92
  169. package/dist/cli/{chunk-FTJLJCE5.mjs → chunk-KVBQY4ST.mjs} +3 -3
  170. package/dist/cli/{chunk-S5S355UY.mjs → chunk-KZHBDMGF.mjs} +12 -12
  171. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  172. package/dist/cli/{chunk-6ZORHRKB.mjs → chunk-LRZGS6RZ.mjs} +2 -0
  173. package/dist/cli/{chunk-2WFPHBR4.js → chunk-LY5MMXFF.js} +47 -29
  174. package/dist/cli/{chunk-BAIST2BR.js → chunk-M7STM3MZ.js} +36 -36
  175. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  176. package/dist/cli/{chunk-45PVGZST.js → chunk-OPTV7D2V.js} +508 -361
  177. package/dist/cli/{chunk-PFO3ISXA.js → chunk-OVEYWO4H.js} +174 -129
  178. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-PC2FTUCP.mjs} +4 -4
  179. package/dist/cli/{chunk-WLN3SUIA.js → chunk-PQQMPUCZ.js} +3 -3
  180. package/dist/cli/{chunk-HYC4MKGK.mjs → chunk-Q7ACILL2.mjs} +5 -5
  181. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  182. package/dist/cli/{chunk-57VZVF5D.mjs → chunk-RBBTCYQB.mjs} +3 -3
  183. package/dist/cli/{chunk-F2LH7TGF.js → chunk-RTHMGSZX.js} +21 -21
  184. package/dist/cli/{chunk-YLTMXJFC.mjs → chunk-S6W6SJ6E.mjs} +158 -16
  185. package/dist/cli/chunk-STXDSVQZ.mjs +32 -0
  186. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-TGUQET3O.mjs} +67 -6
  187. package/dist/cli/{chunk-IHRKLXZN.js → chunk-TJ6HLN56.js} +5 -5
  188. package/dist/cli/{chunk-3FD5EQ62.js → chunk-TOO3YM5N.js} +6 -7
  189. package/dist/cli/{chunk-QILKGXYF.mjs → chunk-UBBYHB2B.mjs} +2 -2
  190. package/dist/cli/{chunk-6PRW5UBA.mjs → chunk-UC4BDZKI.mjs} +299 -69
  191. package/dist/cli/{chunk-634ZDA3F.js → chunk-UNNOZKRT.js} +1 -1
  192. package/dist/cli/{chunk-IDVVIXPJ.js → chunk-UOT7HPBH.js} +41 -41
  193. package/dist/cli/{chunk-6YCA5NKJ.js → chunk-UYCZFQYQ.js} +12 -12
  194. package/dist/cli/{chunk-7IKQKKNX.js → chunk-VIUUTEHY.js} +90 -24
  195. package/dist/cli/{chunk-Z5TSLLOW.mjs → chunk-VLO5NFH2.mjs} +63 -18
  196. package/dist/cli/{chunk-U7QRMBIY.mjs → chunk-VQ75KX7G.mjs} +5 -5
  197. package/dist/cli/{chunk-4NQF6KJ3.js → chunk-VV4XGZ24.js} +13 -13
  198. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  199. package/dist/cli/{chunk-S46HWQKO.js → chunk-W6CZDTIR.js} +69 -69
  200. package/dist/cli/{chunk-XVB7V4N7.js → chunk-WL7P32PI.js} +161 -53
  201. package/dist/cli/{chunk-DJ2JDK4O.mjs → chunk-XD3MFTHA.mjs} +1 -1
  202. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-XFZX6FNM.mjs} +40 -22
  203. package/dist/cli/{chunk-AWJPDPMA.mjs → chunk-XU6QNM4D.mjs} +1 -1
  204. package/dist/cli/{chunk-QAORXEY3.mjs → chunk-YCOGPOUX.mjs} +6 -7
  205. package/dist/cli/{chunk-VQALXEXO.js → chunk-YQKCH4R7.js} +348 -118
  206. package/dist/cli/{chunk-6O5HOODW.mjs → chunk-YY55NYAH.mjs} +207 -60
  207. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  208. package/dist/cli/command-docs.js +3 -3
  209. package/dist/cli/command-docs.mjs +2 -2
  210. package/dist/cli/{concurrent-runs-help-Q4KPAUJX.mjs → concurrent-runs-help-O3Q5IPLF.mjs} +9 -8
  211. package/dist/cli/concurrent-runs-help-ZFRZWX5V.js +22 -0
  212. package/dist/cli/{csv-F5VAGX4K.js → csv-4ZQ2RATI.js} +16 -15
  213. package/dist/cli/{csv-2PTVDNO6.mjs → csv-Y3BFPEM6.mjs} +7 -6
  214. package/dist/cli/{db-IEDXAUF7.mjs → db-3JYY4JNN.mjs} +17 -17
  215. package/dist/cli/{db-Z3OIUFMM.js → db-VEIFS4M7.js} +45 -45
  216. package/dist/cli/describe-EVJ4MFVU.mjs +50 -0
  217. package/dist/cli/describe-FG625QPF.js +50 -0
  218. package/dist/cli/describe-core.d.mts +3 -3
  219. package/dist/cli/describe-core.d.ts +3 -3
  220. package/dist/cli/describe-core.js +7 -7
  221. package/dist/cli/describe-core.mjs +6 -6
  222. package/dist/cli/{executions-H6H5655J.js → executions-HPZXOOVX.js} +12 -12
  223. package/dist/cli/{executions-R3LP74QN.mjs → executions-PCXZKEHM.mjs} +10 -10
  224. package/dist/cli/{feedback-WL3MRVT5.mjs → feedback-Y6VKZNY6.mjs} +9 -8
  225. package/dist/cli/{feedback-VFOUR66B.js → feedback-ZKFHFVL6.js} +17 -16
  226. package/dist/cli/git-RUBMALLH.js +26 -0
  227. package/dist/cli/{git-YX2J4GCI.mjs → git-UMPR2QYC.mjs} +8 -7
  228. package/dist/cli/index.js +170 -158
  229. package/dist/cli/index.mjs +60 -48
  230. package/dist/cli/{integrations-E2JZYKHS.js → integrations-3GQCTRTF.js} +23 -27
  231. package/dist/cli/{integrations-5ZK5KLVP.mjs → integrations-V3TM6XAB.mjs} +15 -19
  232. package/dist/cli/{legacy-noops-SMN3GSXY.mjs → legacy-noops-JZBUD7ZE.mjs} +9 -8
  233. package/dist/cli/{legacy-noops-3VW4IJTH.js → legacy-noops-VYCO7NGW.js} +12 -11
  234. package/dist/cli/{mcp-UQV2K4EW.js → mcp-4OIWTCE6.js} +121 -48
  235. package/dist/cli/{mcp-V6MGCYAG.mjs → mcp-PH4KZ76P.mjs} +100 -27
  236. package/dist/cli/{monitors-R3BBDCRC.js → monitors-E2A6VPBY.js} +221 -186
  237. package/dist/cli/{monitors-GGKS5W6M.mjs → monitors-SSMGIDGX.mjs} +58 -23
  238. package/dist/cli/org-SFDKSK5D.mjs +2289 -0
  239. package/dist/cli/org-WUDZGWBT.js +2289 -0
  240. package/dist/cli/outcomes-QT7LQBPK.mjs +2865 -0
  241. package/dist/cli/outcomes-Y7SZTLSL.js +2865 -0
  242. package/dist/cli/{play-MDWPR4XG.mjs → play-EK7KSFPL.mjs} +376 -106
  243. package/dist/cli/{play-2MVO27VO.js → play-GDNHCRRR.js} +1150 -880
  244. package/dist/cli/{providers-AKDYFZJZ.mjs → providers-FVZLRXAU.mjs} +10 -10
  245. package/dist/cli/{providers-2AACRUZH.js → providers-ZKOSECLV.js} +13 -13
  246. package/dist/cli/{quickstart-H6IV3PV3.js → quickstart-KSDKIXYD.js} +9 -8
  247. package/dist/cli/{quickstart-QDGRJFZY.mjs → quickstart-UJZ6PIQV.mjs} +7 -6
  248. package/dist/cli/{run-RTSQNGRD.mjs → run-E7MZ7P35.mjs} +35 -33
  249. package/dist/cli/{run-2634REDK.js → run-PD2BBG6S.js} +55 -53
  250. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  251. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  252. package/dist/cli/search-TKSPTPHA.js +32 -0
  253. package/dist/cli/{search-6AOJ4XPP.mjs → search-VTFUFTOY.mjs} +11 -11
  254. package/dist/cli/{search-output-S5ODBL5E.js → search-output-G2AGDCOY.js} +13 -12
  255. package/dist/cli/{search-output-6ADMTOU5.mjs → search-output-PFVXQCWA.mjs} +10 -9
  256. package/dist/cli/{secrets-TFIFBFB3.mjs → secrets-7CIMEMX7.mjs} +11 -11
  257. package/dist/cli/{secrets-LHCIIHMT.js → secrets-BCOQ4U7U.js} +20 -20
  258. package/dist/cli/sessions-4CO556VD.js +23 -0
  259. package/dist/cli/{sessions-WHBVUHVW.mjs → sessions-IUCQZEF7.mjs} +9 -8
  260. package/dist/cli/{settings-EBONWL5C.mjs → settings-KZN62UQK.mjs} +16 -16
  261. package/dist/cli/{settings-CP4FVK2W.js → settings-REL4736M.js} +89 -89
  262. package/dist/cli/{setup-I5AZE3IU.mjs → setup-2P7OG3OU.mjs} +22 -24
  263. package/dist/cli/{setup-LFGHTNLQ.js → setup-2XIVBBCS.js} +62 -64
  264. package/dist/cli/skills-JYT5DEY6.js +37 -0
  265. package/dist/cli/{skills-W76AO5XE.mjs → skills-VIGNDJKI.mjs} +10 -9
  266. package/dist/cli/tools-NTVUQ2TG.js +57 -0
  267. package/dist/cli/{tools-7IJHGF6W.mjs → tools-W3QT5EJY.mjs} +24 -24
  268. package/dist/cli/{update-GFOPZTHY.mjs → update-GZVBVMY3.mjs} +14 -11
  269. package/dist/cli/update-TWJZPUZM.js +37 -0
  270. package/dist/cli/{views-D4NX4SBG.mjs → views-BOGEH424.mjs} +47 -49
  271. package/dist/cli/{views-BPL2TQJ4.js → views-TOLJNLSV.js} +62 -64
  272. package/dist/cli/{workflow-ZYNAUCKC.js → workflow-ENWFRK5M.js} +23 -23
  273. package/dist/cli/{workflow-YXP42FUI.mjs → workflow-VDG2FDQV.mjs} +13 -13
  274. package/dist/{client-CyXGrO4D.d.mts → client-B8f7RNF8.d.mts} +1 -1
  275. package/dist/{client-Bf3IpUKN.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  276. package/dist/{client-core-BxsLnXlm.d.mts → client-core-SLLGBTht.d.mts} +268 -23
  277. package/dist/{client-core-BWd0lX0Z.d.ts → client-core-p0sOxnkl.d.ts} +268 -23
  278. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  279. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  280. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  281. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  282. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  283. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  284. package/dist/index.d.mts +7 -7
  285. package/dist/index.d.ts +7 -7
  286. package/dist/index.js +66 -55
  287. package/dist/index.mjs +25 -14
  288. package/dist/install-integrity.json +163 -144
  289. package/dist/plays/bundle-play-file.d.mts +3 -3
  290. package/dist/plays/bundle-play-file.d.ts +3 -3
  291. package/dist/plays/bundle-play-file.mjs +23 -4
  292. package/dist/plays/csv-data-input.js +3 -3
  293. package/dist/plays/csv-data-input.mjs +2 -2
  294. package/dist/plays/play-description.d.mts +2 -2
  295. package/dist/plays/play-description.d.ts +2 -2
  296. package/dist/plays/run-request.d.mts +2 -2
  297. package/dist/plays/run-request.d.ts +2 -2
  298. package/dist/plays/run-request.js +4 -4
  299. package/dist/plays/run-request.mjs +3 -3
  300. package/dist/release.d.mts +1 -1
  301. package/dist/release.d.ts +1 -1
  302. package/dist/release.js +2 -2
  303. package/dist/release.mjs +1 -1
  304. package/dist/server.d.mts +4 -4
  305. package/dist/server.d.ts +4 -4
  306. package/dist/server.js +15 -13
  307. package/dist/server.mjs +9 -7
  308. package/package.json +1 -1
  309. package/dist/cli/auth-MMNVWATX.js +0 -43
  310. package/dist/cli/chunk-AID3OYVJ.js +0 -8
  311. package/dist/cli/chunk-OVDNJAJN.mjs +0 -8
  312. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +0 -21
  313. package/dist/cli/describe-QDANCTS3.mjs +0 -50
  314. package/dist/cli/describe-VUTT5ZKU.js +0 -50
  315. package/dist/cli/git-ETB3GH3K.js +0 -25
  316. package/dist/cli/org-GRYVMNSW.js +0 -1282
  317. package/dist/cli/org-Z37NGJV4.mjs +0 -1282
  318. package/dist/cli/run-identity-G257GQED.js +0 -25
  319. package/dist/cli/search-VTW2YNBS.js +0 -32
  320. package/dist/cli/sessions-CJ4FJ2WB.js +0 -22
  321. package/dist/cli/skills-R7EBXREW.js +0 -36
  322. package/dist/cli/tools-V7U2BDXM.js +0 -57
  323. package/dist/cli/update-4COPZETK.js +0 -34
@@ -132,7 +132,10 @@ import {
132
132
  resolveLaunchRuntimeSandboxPlacementPolicy,
133
133
  selectRuntimeSandboxCanary,
134
134
  } from '../runtime-sandbox-placement-policy';
135
- import { shouldUseRuntimeSchedulerDirectNotify } from '../runtime-scheduler-topology';
135
+ import {
136
+ resolvePreviewWorkerListenerElection,
137
+ shouldUseRuntimeSchedulerDirectNotify,
138
+ } from '../runtime-scheduler-topology';
136
139
  import {
137
140
  createPlayRunnerBackendSandboxExecutionAdapter,
138
141
  createSandboxExecutionJob,
@@ -151,8 +154,18 @@ import { createFleetSandboxSweep } from '../fleet-sandbox-sweep';
151
154
  import {
152
155
  earlySandboxFleetSweepAdapter,
153
156
  earlySandboxSweepAdapters,
157
+ wireEarlySandboxListenerHost,
154
158
  type EarlySandboxWorkerCapacity,
155
159
  } from './early-sandbox-lane';
160
+ import {
161
+ composeAbsurdSchedulerQueryObservers,
162
+ createAbsurdWorkerSlotLedger,
163
+ type AbsurdWorkerSlotLedger,
164
+ } from './absurd-worker-slot-ledger';
165
+ import {
166
+ createEarlySandboxListenerLeadership,
167
+ type EarlySandboxListenerHintDesk,
168
+ } from './early-sandbox-listener-hint';
156
169
  import {
157
170
  resolveDetachedRunnerRuntimeLimitSeconds,
158
171
  type DetachedRunnerSuspension,
@@ -626,6 +639,17 @@ const RUNTIME_CLAIM_LEASE_SECONDS =
626
639
  RUNTIME_RELIABILITY_POLICY.worker.claimLeaseSeconds;
627
640
  const HEARTBEAT_CLAIM_TIMEOUT_SECONDS = RUNTIME_CLAIM_LEASE_SECONDS;
628
641
 
642
+ /**
643
+ * Switch SR (static default off; a run gets it through a per-run override or
644
+ * a runtime speed profile): the runner fetches its park-fence startup reads
645
+ * (every named tool's metadata and auth-scope) in one GET instead of two per
646
+ * tool. A run that calls one of several declared tools then makes one startup
647
+ * request instead of two per declared tool. It does nothing while
648
+ * `DURABLE_RUNS_ROLLOUT.runnerStartupReadPrefetch` is off. An app or gateway
649
+ * that cannot serve the batch gets the per-tool GETs instead.
650
+ */
651
+ export const STARTUP_READS_IN_ONE_REQUEST = false;
652
+
629
653
  /** `startupReadToolIds` for the runner context, from the launch's contract plan; empty when it names none. */
630
654
  export function startupReadToolIdsContext(contractSnapshot: unknown): {
631
655
  startupReadToolIds?: string[];
@@ -5214,6 +5238,14 @@ async function executeAssignedAbsurdAttempt(input: {
5214
5238
  ...(DURABLE_RUNS_ROLLOUT.workerStartupReadToolIds
5215
5239
  ? startupReadToolIdsContext(launch.contractSnapshot)
5216
5240
  : {}),
5241
+ // Switch SR: the runner's startup reads in one request.
5242
+ ...(resolveExperimentSwitch(
5243
+ 'SR',
5244
+ launch.experimentSwitchOverrides,
5245
+ STARTUP_READS_IN_ONE_REQUEST,
5246
+ )
5247
+ ? { startupReadBatch: true }
5248
+ : {}),
5217
5249
  // Push execution: the Daytona sandbox runner keeps the Absurd run claim
5218
5250
  // alive itself by heartbeating the receipt gateway. The local-process
5219
5251
  // backend stays worker-babysat, so it gets no push config.
@@ -7973,7 +8005,17 @@ export function createAbsurdRuntimeTasks(
7973
8005
  queue: string = ABSURD_RUNS_QUEUE,
7974
8006
  /** Logs task setup and handler end for each play run. */
7975
8007
  claimLoopTiming?: AbsurdClaimLoopTiming,
8008
+ /**
8009
+ * LH: counts every task handler of this queue in the host's slot ledger,
8010
+ * and is told each play run's start (its authoritative claim).
8011
+ */
8012
+ slots?: {
8013
+ ledger: AbsurdWorkerSlotLedger;
8014
+ onPlayRunStarted?: (runId: string) => void;
8015
+ },
7976
8016
  ): void {
8017
+ const counted = <T>(ctx: { taskID: string }, handler: () => Promise<T>) =>
8018
+ slots ? slots.ledger.runTask(ctx.taskID, handler) : handler();
7977
8019
  const resolved: AbsurdRuntimeWorkerDeps = {
7978
8020
  ...buildDefaultDeps(absurd),
7979
8021
  ...deps,
@@ -7988,12 +8030,15 @@ export function createAbsurdRuntimeTasks(
7988
8030
  }
7989
8031
  absurd.registerTask({ name: ABSURD_PLAY_RUN_TASK, queue }, (params, ctx) => {
7990
8032
  const execute = () =>
7991
- executeAbsurdRuntimeLaunch(
7992
- params as AbsurdPlayRunTaskParams,
7993
- ctx,
7994
- resolved,
7995
- queue,
7996
- );
8033
+ counted(ctx, () => {
8034
+ slots?.onPlayRunStarted?.((params as AbsurdPlayRunTaskParams).runId);
8035
+ return executeAbsurdRuntimeLaunch(
8036
+ params as AbsurdPlayRunTaskParams,
8037
+ ctx,
8038
+ resolved,
8039
+ queue,
8040
+ );
8041
+ });
7997
8042
  return claimLoopTiming
7998
8043
  ? claimLoopTiming.playRunHandler(
7999
8044
  {
@@ -8008,64 +8053,67 @@ export function createAbsurdRuntimeTasks(
8008
8053
  // The task may sleep for days, but its handler schedules children on the
8009
8054
  // current release through `resolved.currentReleaseId` after waking.
8010
8055
  absurd.registerTask({ name: ABSURD_CRON_FIRE_TASK, queue }, (params, ctx) =>
8011
- executeAbsurdCronFire(params as AbsurdCronFireTaskParams, ctx, resolved),
8056
+ counted(ctx, () =>
8057
+ executeAbsurdCronFire(params as AbsurdCronFireTaskParams, ctx, resolved),
8058
+ ),
8012
8059
  );
8013
8060
  absurd.registerTask(
8014
8061
  { name: ABSURD_DAYTONA_SANDBOX_CLEANUP_TASK, queue },
8015
- async (params) => {
8016
- const cleanup = params as AbsurdDaytonaSandboxCleanupTaskParams & {
8017
- runtimeSandboxRef?: RuntimeSandboxRef;
8018
- };
8019
- const runId = cleanup.runId?.trim();
8020
- const sandboxId = cleanup.sandboxId?.trim();
8021
- if (!runId || !sandboxId) {
8022
- throw new Error(
8023
- 'runtime sandbox cleanup requires runId and sandboxId.',
8024
- );
8025
- }
8026
- const runtimeSandboxRef: RuntimeSandboxRef = cleanup.runtimeSandboxRef
8027
- ? readPersistedRuntimeSandboxRef({
8028
- raw: cleanup.runtimeSandboxRef,
8029
- expectedSandboxId: sandboxId,
8030
- })
8031
- : {
8032
- schemaVersion: 1,
8033
- provider: 'daytona',
8034
- resourceId: sandboxId,
8035
- routingDomain: null,
8036
- };
8037
- const configuredBackend = resolved.configuredRuntimeBackend;
8038
- if (
8039
- !runtimeSandboxProviderCapabilities(configuredBackend).includes(
8040
- runtimeSandboxRef.provider,
8041
- )
8042
- ) {
8043
- throw new DeferTask(
8044
- `Runtime lane ${configuredBackend} cannot clean up ${runtimeSandboxRef.provider} sandbox ${sandboxId}.`,
8045
- 30,
8046
- );
8047
- }
8048
- const deleteResult = resolved.deleteRuntimeSandboxRef
8049
- ? await resolved.deleteRuntimeSandboxRef(runtimeSandboxRef)
8050
- : runtimeSandboxRef.provider === 'daytona'
8051
- ? await resolved.deleteRuntimeSandbox(sandboxId)
8052
- : false;
8053
- const deleted =
8054
- typeof deleteResult === 'boolean'
8055
- ? deleteResult
8056
- : runtimeSandboxDeleteSucceeded(deleteResult);
8057
- if (!deleted) {
8058
- throw new Error(
8059
- `${runtimeSandboxRef.provider} sandbox cleanup did not delete ${sandboxId} for ${runId}.`,
8060
- );
8061
- }
8062
- return {
8063
- ok: true,
8064
- runId,
8065
- sandboxId,
8066
- provider: runtimeSandboxRef.provider,
8067
- };
8068
- },
8062
+ (params, ctx) =>
8063
+ counted(ctx, async () => {
8064
+ const cleanup = params as AbsurdDaytonaSandboxCleanupTaskParams & {
8065
+ runtimeSandboxRef?: RuntimeSandboxRef;
8066
+ };
8067
+ const runId = cleanup.runId?.trim();
8068
+ const sandboxId = cleanup.sandboxId?.trim();
8069
+ if (!runId || !sandboxId) {
8070
+ throw new Error(
8071
+ 'runtime sandbox cleanup requires runId and sandboxId.',
8072
+ );
8073
+ }
8074
+ const runtimeSandboxRef: RuntimeSandboxRef = cleanup.runtimeSandboxRef
8075
+ ? readPersistedRuntimeSandboxRef({
8076
+ raw: cleanup.runtimeSandboxRef,
8077
+ expectedSandboxId: sandboxId,
8078
+ })
8079
+ : {
8080
+ schemaVersion: 1,
8081
+ provider: 'daytona',
8082
+ resourceId: sandboxId,
8083
+ routingDomain: null,
8084
+ };
8085
+ const configuredBackend = resolved.configuredRuntimeBackend;
8086
+ if (
8087
+ !runtimeSandboxProviderCapabilities(configuredBackend).includes(
8088
+ runtimeSandboxRef.provider,
8089
+ )
8090
+ ) {
8091
+ throw new DeferTask(
8092
+ `Runtime lane ${configuredBackend} cannot clean up ${runtimeSandboxRef.provider} sandbox ${sandboxId}.`,
8093
+ 30,
8094
+ );
8095
+ }
8096
+ const deleteResult = resolved.deleteRuntimeSandboxRef
8097
+ ? await resolved.deleteRuntimeSandboxRef(runtimeSandboxRef)
8098
+ : runtimeSandboxRef.provider === 'daytona'
8099
+ ? await resolved.deleteRuntimeSandbox(sandboxId)
8100
+ : false;
8101
+ const deleted =
8102
+ typeof deleteResult === 'boolean'
8103
+ ? deleteResult
8104
+ : runtimeSandboxDeleteSucceeded(deleteResult);
8105
+ if (!deleted) {
8106
+ throw new Error(
8107
+ `${runtimeSandboxRef.provider} sandbox cleanup did not delete ${sandboxId} for ${runId}.`,
8108
+ );
8109
+ }
8110
+ return {
8111
+ ok: true,
8112
+ runId,
8113
+ sandboxId,
8114
+ provider: runtimeSandboxRef.provider,
8115
+ };
8116
+ }),
8069
8117
  );
8070
8118
  }
8071
8119
 
@@ -11603,6 +11651,11 @@ export function createAbsurdWorkerWakeHook(input: {
11603
11651
  useDirectNotify?: boolean;
11604
11652
  /** Accept local wake hints without allocating a direct database session. */
11605
11653
  enableWakeHints?: boolean;
11654
+ /**
11655
+ * LH: called on every change of this process's listener election
11656
+ * (`isListening`), including the loss on release or close.
11657
+ */
11658
+ onListeningChange?: (listening: boolean) => void;
11606
11659
  acquireNotifyHub?: (input: {
11607
11660
  url: string;
11608
11661
  channel: string;
@@ -11653,6 +11706,7 @@ export function createAbsurdWorkerWakeHook(input: {
11653
11706
  const unsubscribeState = lease.hub.subscribeState((state) => {
11654
11707
  const wasListening = listening;
11655
11708
  listening = state === 'listening';
11709
+ if (listening !== wasListening) input.onListeningChange?.(listening);
11656
11710
  if (listening || wasListening) wake();
11657
11711
  });
11658
11712
  let released = false;
@@ -11661,6 +11715,9 @@ export function createAbsurdWorkerWakeHook(input: {
11661
11715
  released = true;
11662
11716
  unsubscribeNotify();
11663
11717
  unsubscribeState();
11718
+ // The election ends with this subscription; `isListening` keeps its
11719
+ // last value as before (close resets it).
11720
+ if (listening) input.onListeningChange?.(false);
11664
11721
  wakeHandlers.delete(wake);
11665
11722
  lease.release();
11666
11723
  subscriptions.delete(release);
@@ -11684,6 +11741,7 @@ export function createAbsurdWorkerWakeHook(input: {
11684
11741
  : ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS;
11685
11742
  hook.close = () => {
11686
11743
  closed = true;
11744
+ if (listening) input.onListeningChange?.(false);
11687
11745
  listening = false;
11688
11746
  for (const release of subscriptions) release();
11689
11747
  wakeHandlers.clear();
@@ -11804,6 +11862,11 @@ export type RuntimeWorkerHost = {
11804
11862
  * no idle claim slot refuses the hint.
11805
11863
  */
11806
11864
  earlySandboxCapacity?: EarlySandboxWorkerCapacity;
11865
+ /**
11866
+ * LH: this worker's listener-hint desk (status, admission, reservations).
11867
+ * Present on every host with a wake hook; used only by LH hints.
11868
+ */
11869
+ earlySandboxListenerDesk?: EarlySandboxListenerHintDesk;
11807
11870
  };
11808
11871
 
11809
11872
  /** Own shutdown ordering across the primary queue, listener and maintenance.
@@ -11815,6 +11878,7 @@ export function createAbsurdRuntimeWorkerHostLifecycle(input: {
11815
11878
  wake?: () => boolean;
11816
11879
  earlySandboxClaimOwner?: RuntimeWorkerHost['earlySandboxClaimOwner'];
11817
11880
  earlySandboxCapacity?: RuntimeWorkerHost['earlySandboxCapacity'];
11881
+ earlySandboxListenerDesk?: EarlySandboxListenerHintDesk;
11818
11882
  stopControllers: () => void;
11819
11883
  controllers: readonly (Promise<unknown> | null)[];
11820
11884
  }): RuntimeWorkerHost {
@@ -11826,6 +11890,9 @@ export function createAbsurdRuntimeWorkerHostLifecycle(input: {
11826
11890
  ...(input.earlySandboxClaimOwner
11827
11891
  ? { earlySandboxClaimOwner: input.earlySandboxClaimOwner }
11828
11892
  : {}),
11893
+ ...(input.earlySandboxListenerDesk
11894
+ ? { earlySandboxListenerDesk: input.earlySandboxListenerDesk }
11895
+ : {}),
11829
11896
  // A closing host claims nothing more, so it reports itself draining.
11830
11897
  ...(capacity
11831
11898
  ? {
@@ -11910,6 +11977,16 @@ export async function startRuntimeWorkerHost(
11910
11977
  'gateway (apps/runtime-receipt-gateway/index.ts), never the Vercel app.',
11911
11978
  );
11912
11979
  }
11980
+ // An isolated Preview lane's typed config may join the election (one
11981
+ // direct session per worker from the Preview budget); unset everywhere
11982
+ // else. Checked before any database work, so a misconfiguration fails boot
11983
+ // without side effects.
11984
+ const previewListenerElection = resolvePreviewWorkerListenerElection(
11985
+ process.env,
11986
+ normalizeAbsurdSchedulerOptions({
11987
+ schema: options.schedulerSchema ?? null,
11988
+ }).schema,
11989
+ );
11913
11990
  const poolOptions = resolveAbsurdPoolOptions();
11914
11991
  // Wait for the scheduler database beside the gateway check, before the pool
11915
11992
  // makes its first connections: their 5 s timeouts and breaker are for a
@@ -11949,6 +12026,7 @@ export async function startRuntimeWorkerHost(
11949
12026
  normalizeAbsurdSchedulerOptions({
11950
12027
  schema: options.schedulerSchema ?? null,
11951
12028
  });
12029
+
11952
12030
  // Active work is lane-pinned to the queue derived from this worker's baked
11953
12031
  // release id. Every worker serves exactly this queue; durable top-level
11954
12032
  // sleeps and event waits resume on their owning release lane.
@@ -11978,16 +12056,30 @@ export async function startRuntimeWorkerHost(
11978
12056
  wake: () => claimAffinityWake?.() ?? false,
11979
12057
  })
11980
12058
  : undefined;
12059
+ // LH: live slot use, from claimed task ids and running handlers; the
12060
+ // engine's saturation reading is bound below once the claim loop exists.
12061
+ let claimLoopHasIdleSlot: () => boolean = () => false;
12062
+ const slotLedger = createAbsurdWorkerSlotLedger({
12063
+ concurrency: slots,
12064
+ hasIdleSlot: () => claimLoopHasIdleSlot(),
12065
+ });
12066
+ let onPlayRunStarted: ((runId: string) => void) | null = null;
11981
12067
  const absurdClient = createAbsurdRuntimeClient(
11982
12068
  poolOptions,
11983
12069
  queue,
11984
- claimLoopTiming.observer,
12070
+ composeAbsurdSchedulerQueryObservers(
12071
+ claimLoopTiming.observer,
12072
+ slotLedger.observer,
12073
+ ),
11985
12074
  claimAffinityGate,
11986
12075
  );
11987
12076
  const workerDeps: AbsurdRuntimeWorkerDeps = {
11988
12077
  ...buildDefaultDeps(absurdClient),
11989
12078
  };
11990
- createAbsurdRuntimeTasks(absurdClient, workerDeps, queue, claimLoopTiming);
12079
+ createAbsurdRuntimeTasks(absurdClient, workerDeps, queue, claimLoopTiming, {
12080
+ ledger: slotLedger,
12081
+ onPlayRunStarted: (runId) => onPlayRunStarted?.(runId),
12082
+ });
11991
12083
  // Must happen before `startWorker()` can call `claim_task()`: an expired
11992
12084
  // engine claim otherwise retries a task whose signed completed runner
11993
12085
  // terminal has already been durably persisted.
@@ -12009,12 +12101,16 @@ export async function startRuntimeWorkerHost(
12009
12101
  }
12010
12102
  const useDirectNotify =
12011
12103
  PREVIEW_WORKER_DIRECT_NOTIFY_WAKE ||
12104
+ previewListenerElection === 'direct_listen' ||
12012
12105
  shouldUseRuntimeSchedulerDirectNotify(schedulerOptions.schema);
12013
12106
  console.info('[absurd-runtime.worker] wake_config', {
12014
12107
  queue,
12015
12108
  useDirectNotify,
12016
12109
  previewDirectNotifyWake: PREVIEW_WORKER_DIRECT_NOTIFY_WAKE,
12110
+ previewListenerElection,
12017
12111
  });
12112
+ // LH: this process's listener generations for its queue (in memory).
12113
+ const listenerLeadership = createEarlySandboxListenerLeadership({ queue });
12018
12114
  const onWake = createAbsurdWorkerWakeHook({
12019
12115
  poolOptions,
12020
12116
  queue,
@@ -12023,6 +12119,16 @@ export async function startRuntimeWorkerHost(
12023
12119
  draining: drainExit,
12024
12120
  useDirectNotify,
12025
12121
  enableWakeHints: true,
12122
+ onListeningChange: (listening) => {
12123
+ const ended = listenerLeadership.generation();
12124
+ listenerLeadership.onListening(listening);
12125
+ // One line per election transition, so LH routing is explainable.
12126
+ console.info('[runtime.listener_hint]', {
12127
+ event: listening ? 'election_won' : 'election_lost',
12128
+ queue,
12129
+ generation: listening ? listenerLeadership.generation() : ended,
12130
+ });
12131
+ },
12026
12132
  });
12027
12133
  claimAffinityWake = onWake ? () => onWake.wake() : null;
12028
12134
  let ownerProbeStopped = false;
@@ -12102,6 +12208,7 @@ export async function startRuntimeWorkerHost(
12102
12208
  // scheduler/outbox.
12103
12209
  saturatedMaintenance: sweepAndReconcileCancellations,
12104
12210
  });
12211
+ claimLoopHasIdleSlot = claimLoop.hasIdleSlot;
12105
12212
  const worker = await absurdClient.startWorker({
12106
12213
  workerId: `${workerBase}:${queue}`,
12107
12214
  concurrency: slots,
@@ -12366,9 +12473,22 @@ export async function startRuntimeWorkerHost(
12366
12473
  workerName: workerBase,
12367
12474
  });
12368
12475
 
12476
+ // LH: the listener desk, bound to this host's leadership, live free slots
12477
+ // and early-sandbox registries (`wireEarlySandboxListenerHost`).
12478
+ const listenerHost = onWake
12479
+ ? wireEarlySandboxListenerHost({
12480
+ leadership: listenerLeadership,
12481
+ draining: drainExit,
12482
+ freeSlots: slotLedger.freeSlots,
12483
+ })
12484
+ : null;
12485
+ const earlySandboxListenerDesk = listenerHost?.desk ?? null;
12486
+ onPlayRunStarted = (runId) => listenerHost?.onPlayRunStarted(runId);
12487
+
12369
12488
  return createAbsurdRuntimeWorkerHostLifecycle({
12370
12489
  worker,
12371
12490
  ...(onWake ? { wake: () => onWake.wake() } : {}),
12491
+ ...(earlySandboxListenerDesk ? { earlySandboxListenerDesk } : {}),
12372
12492
  ...(earlySandboxClaimOwner ? { earlySandboxClaimOwner } : {}),
12373
12493
  earlySandboxCapacity: {
12374
12494
  draining: drainExit,
@@ -12378,6 +12498,7 @@ export async function startRuntimeWorkerHost(
12378
12498
  // its listener without exhausting primary scheduler sessions.
12379
12499
  closeWake: () => onWake?.close(),
12380
12500
  stopControllers: () => {
12501
+ listenerHost?.stop();
12381
12502
  standbyProbeStopped = true;
12382
12503
  ownerProbeStopped = true;
12383
12504
  drainStopped = true;
@@ -0,0 +1,157 @@
1
+ import { CancelledTask, FailedTask, SuspendTask } from '@deepline/absurd/sdk';
2
+ import type { AbsurdSchedulerQueryObserver } from './absurd-pool';
3
+
4
+ /**
5
+ * This host's live count of claim slots in use, for decisions that must not
6
+ * over-promise a slot (LH listener hints). The engine's own count
7
+ * (`executing.size - lentSlots` in the vendored worker loop) is private, so
8
+ * this counts from the two points the host owns:
9
+ * - every task id a claim query returned (`onClaimTask`), until its handler
10
+ * starts or `CLAIMED_TASK_RETENTION_MS` passes (a task whose handler never
11
+ * starts, e.g. cancelled during setup, cannot pin a slot);
12
+ * - every running task handler, of every task name, and then, exactly as the
13
+ * engine's `executeTask` does, its finalization: a handler that returned or
14
+ * threw an ordinary error stays counted until the engine's run-terminal
15
+ * write for that run (`complete_run`, `fail_run`, `schedule_run`) settles
16
+ * (`onRunWrite`). A handler that parks, is cancelled or fails through
17
+ * `FailedTask` writes nothing, so its slot frees at once.
18
+ *
19
+ * A task that lends its slot while its handler runs still counts. Every
20
+ * pending entry (claimed, finalizing) expires after
21
+ * `CLAIMED_TASK_RETENTION_MS`, so a write the observer never sees cannot pin a
22
+ * slot forever; past that the ledger may count a slot free that a stalled
23
+ * write still holds. While the engine reports its loop saturated it reports
24
+ * none free.
25
+ *
26
+ * Counting only: no claim, lease, log or durable state changes.
27
+ */
28
+ export type AbsurdWorkerSlotLedger = {
29
+ /** Compose into the scheduler query observer. */
30
+ observer: AbsurdSchedulerQueryObserver;
31
+ /** Wrap one task handler invocation of any task name. */
32
+ runTask<T>(taskId: string, handler: () => Promise<T>): Promise<T>;
33
+ /** Slots free right now (0 while saturated). */
34
+ freeSlots(): number;
35
+ /** In-use counts, for tests and status. */
36
+ snapshot(): {
37
+ claimedNotStarted: number;
38
+ running: number;
39
+ finalizing: number;
40
+ };
41
+ };
42
+
43
+ /** Same retention as the claim-loop timing's unstarted claims. */
44
+ export const CLAIMED_TASK_RETENTION_MS = 60_000;
45
+
46
+ export function createAbsurdWorkerSlotLedger(input: {
47
+ concurrency: number;
48
+ /** The engine's saturation reading (`trackAbsurdClaimLoopCapacity`). */
49
+ hasIdleSlot: () => boolean;
50
+ now?: () => number;
51
+ }): AbsurdWorkerSlotLedger {
52
+ const now = input.now ?? Date.now;
53
+ // Multisets: a task id reclaimed while its old handler still runs here
54
+ // holds two engine slots.
55
+ const claimed = new Map<string, number[]>();
56
+ const running = new Map<string, number>();
57
+ const finalizing = new Map<string, number[]>();
58
+ // The run each claimed task id is on (the engine's terminal writes name
59
+ // the run); the latest claim of an id wins.
60
+ const runOf = new Map<string, { runId: string; at: number }>();
61
+ const expire = () => {
62
+ const cutoff = now() - CLAIMED_TASK_RETENTION_MS;
63
+ for (const entries of [claimed, finalizing]) {
64
+ for (const [id, times] of entries) {
65
+ const kept = times.filter((at) => at > cutoff);
66
+ if (kept.length > 0) entries.set(id, kept);
67
+ else entries.delete(id);
68
+ }
69
+ }
70
+ };
71
+ const add = (entries: Map<string, number[]>, id: string) =>
72
+ entries.set(id, [...(entries.get(id) ?? []), now()]);
73
+ const takeOne = (entries: Map<string, number[]>, id: string) => {
74
+ const times = entries.get(id);
75
+ if (!times) return;
76
+ if (times.length > 1) entries.set(id, times.slice(1));
77
+ else entries.delete(id);
78
+ };
79
+ const size = (entries: Map<string, number[] | number>) => {
80
+ let total = 0;
81
+ for (const value of entries.values())
82
+ total += typeof value === 'number' ? value : value.length;
83
+ return total;
84
+ };
85
+ return {
86
+ observer: {
87
+ onClaimTask(timing) {
88
+ expire();
89
+ for (const taskId of timing.taskIds) {
90
+ add(claimed, taskId);
91
+ const runId = timing.runIdsByTaskId?.[taskId];
92
+ if (runId) runOf.set(taskId, { runId, at: now() });
93
+ }
94
+ const cutoff = now() - CLAIMED_TASK_RETENTION_MS;
95
+ for (const [taskId, entry] of runOf) {
96
+ if (entry.at <= cutoff && !running.has(taskId)) runOf.delete(taskId);
97
+ }
98
+ },
99
+ onRunWrite(runId) {
100
+ takeOne(finalizing, runId);
101
+ },
102
+ },
103
+ async runTask(taskId, handler) {
104
+ takeOne(claimed, taskId);
105
+ running.set(taskId, (running.get(taskId) ?? 0) + 1);
106
+ const runId = runOf.get(taskId)?.runId ?? null;
107
+ let writesNothing = false;
108
+ try {
109
+ return await handler();
110
+ } catch (error) {
111
+ writesNothing =
112
+ error instanceof SuspendTask ||
113
+ error instanceof CancelledTask ||
114
+ error instanceof FailedTask;
115
+ throw error;
116
+ } finally {
117
+ const left = (running.get(taskId) ?? 1) - 1;
118
+ if (left > 0) running.set(taskId, left);
119
+ else running.delete(taskId);
120
+ // Without a known run the write cannot be matched; the retention
121
+ // bound still applies through the task id.
122
+ if (!writesNothing) add(finalizing, runId ?? `task:${taskId}`);
123
+ }
124
+ },
125
+ freeSlots() {
126
+ if (!input.hasIdleSlot()) return 0;
127
+ expire();
128
+ const inUse = size(claimed) + size(running) + size(finalizing);
129
+ return Math.max(0, Math.floor(input.concurrency) - inUse);
130
+ },
131
+ snapshot() {
132
+ expire();
133
+ return {
134
+ claimedNotStarted: size(claimed),
135
+ running: size(running),
136
+ finalizing: size(finalizing),
137
+ };
138
+ },
139
+ };
140
+ }
141
+
142
+ /** Both observers see every claim query. */
143
+ export function composeAbsurdSchedulerQueryObservers(
144
+ ...observers: (AbsurdSchedulerQueryObserver | undefined)[]
145
+ ): AbsurdSchedulerQueryObserver {
146
+ const present = observers.filter(
147
+ (observer): observer is AbsurdSchedulerQueryObserver => Boolean(observer),
148
+ );
149
+ return {
150
+ onClaimTask(timing) {
151
+ for (const observer of present) observer.onClaimTask(timing);
152
+ },
153
+ onRunWrite(runId) {
154
+ for (const observer of present) observer.onRunWrite?.(runId);
155
+ },
156
+ };
157
+ }