deepline 0.3.551 → 0.3.553

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 (324) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +130 -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 +124 -10
  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 +66 -30
  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 +11 -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-monitor-upstream-identity.ts +80 -13
  43. package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  45. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  46. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  47. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tamradar-countries.ts +285 -0
  49. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  50. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  51. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  52. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  53. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  54. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  55. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  56. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +312 -41
  57. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  58. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  59. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  60. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  62. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +568 -26
  63. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  67. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +14 -2
  68. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  69. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  70. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  71. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +92 -16
  72. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  73. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  74. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  76. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  77. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  79. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  81. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  82. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  83. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +300 -57
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  86. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  87. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  88. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +298 -46
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +39 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  95. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +32 -10
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  108. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  109. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  110. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  112. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  113. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  117. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  118. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +37 -7
  119. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  120. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  121. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  122. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  123. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  124. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  125. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  126. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  127. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  128. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  129. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  130. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  131. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  132. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  133. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  134. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  135. package/dist/cli/{auth-E7BH4GMJ.mjs → auth-I3QAU4RV.mjs} +8 -7
  136. package/dist/cli/auth-MQCN7WGZ.js +44 -0
  137. package/dist/cli/{billing-OXKU462W.mjs → billing-3IC54OQQ.mjs} +202 -59
  138. package/dist/cli/{billing-DNQAZGX7.js → billing-YGFFVAIC.js} +302 -159
  139. package/dist/cli/{chunk-COGREZAO.js → chunk-2B5B5KAW.js} +210 -128
  140. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  141. package/dist/cli/{chunk-T2B5BVZE.js → chunk-3NTP2OSG.js} +13 -13
  142. package/dist/cli/{chunk-FOTGUFVK.mjs → chunk-45OAVGU6.mjs} +5 -5
  143. package/dist/cli/{chunk-54EEYLTF.js → chunk-4747TPLV.js} +3 -3
  144. package/dist/cli/{chunk-CLRAANWH.mjs → chunk-4BFTDNHU.mjs} +1 -1
  145. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-4HYNMXXF.mjs} +4 -4
  146. package/dist/cli/{chunk-5S6PHKRV.mjs → chunk-4SMCFQ23.mjs} +1 -1
  147. package/dist/cli/{chunk-VWLHRZFG.mjs → chunk-55F6HNOY.mjs} +5 -5
  148. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  149. package/dist/cli/{chunk-VTGG2RT3.js → chunk-6NE3RRRY.js} +1 -1
  150. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  151. package/dist/cli/{chunk-MNSTCJMX.mjs → chunk-72V4PDH5.mjs} +18 -18
  152. package/dist/cli/{chunk-ZCDKE4UH.js → chunk-74RES4DS.js} +5 -5
  153. package/dist/cli/{chunk-WKBHUB6R.js → chunk-7GEMELKI.js} +366 -320
  154. package/dist/cli/{chunk-C4CUZH57.js → chunk-7O6J6A7P.js} +1871 -92
  155. package/dist/cli/{chunk-7RSIFA72.js → chunk-7SERLBNR.js} +161 -53
  156. package/dist/cli/{chunk-3G6QZACZ.js → chunk-7YRJ5UC4.js} +21 -21
  157. package/dist/cli/{chunk-I4VKGNAQ.mjs → chunk-A7DLBE5K.mjs} +136 -54
  158. package/dist/cli/{chunk-GGB3JYCW.mjs → chunk-AGICYWGN.mjs} +299 -69
  159. package/dist/cli/{chunk-44KSACJW.mjs → chunk-AGIQDA2T.mjs} +12 -12
  160. package/dist/cli/{chunk-PACD5DGC.js → chunk-AGLR6QVN.js} +255 -109
  161. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  162. package/dist/cli/{chunk-4OMAGJ6U.js → chunk-BVDKFS2T.js} +2 -2
  163. package/dist/cli/{chunk-LPJPCGT3.js → chunk-CACFJODG.js} +190 -134
  164. package/dist/cli/{chunk-GVYLCCKN.mjs → chunk-CAEBJOYU.mjs} +1 -1
  165. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  166. package/dist/cli/{chunk-POLUE7D5.js → chunk-DP2VH7CO.js} +12 -12
  167. package/dist/cli/{chunk-D6M5HFBB.mjs → chunk-DP64MD6U.mjs} +1 -1
  168. package/dist/cli/{chunk-W425ERWN.mjs → chunk-DZA7RFGL.mjs} +5 -5
  169. package/dist/cli/{chunk-R7J7CJPZ.js → chunk-E2G2DNAB.js} +4 -1
  170. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-E7WZOX2A.mjs} +22 -18
  171. package/dist/cli/{chunk-44I675YK.js → chunk-FM7LPUPA.js} +41 -41
  172. package/dist/cli/{chunk-2UXDHFSF.mjs → chunk-GAVZ4EOD.mjs} +1 -1
  173. package/dist/cli/{chunk-Z2FIOG3V.js → chunk-HEBO3XNZ.js} +27 -31
  174. package/dist/cli/{chunk-6PWJKMFQ.mjs → chunk-HSJ6X2AQ.mjs} +4 -4
  175. package/dist/cli/{chunk-UPMRIVZB.js → chunk-HVI55MTK.js} +61 -10
  176. package/dist/cli/{chunk-KWSH5T7K.js → chunk-IH6GDNKW.js} +21 -21
  177. package/dist/cli/{chunk-3KYBDAR3.js → chunk-IMX7J4DU.js} +8 -8
  178. package/dist/cli/{chunk-HEHVGEZV.mjs → chunk-INEMTYMT.mjs} +8 -8
  179. package/dist/cli/{chunk-5VVSEU67.js → chunk-IUOGII7D.js} +6 -7
  180. package/dist/cli/{chunk-MXGA6JFI.mjs → chunk-JJGWHITQ.mjs} +5 -5
  181. package/dist/cli/{chunk-QM6Y6S4E.js → chunk-JLGP5XAJ.js} +5 -5
  182. package/dist/cli/{chunk-V6SCP4B7.mjs → chunk-LFOERUQY.mjs} +69 -3
  183. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  184. package/dist/cli/{chunk-ZMNGZ6XS.mjs → chunk-LH5PZKER.mjs} +80 -24
  185. package/dist/cli/{chunk-MR5LTVHD.js → chunk-LRDHPOZW.js} +69 -69
  186. package/dist/cli/{chunk-5LUF4LAR.mjs → chunk-LRZGS6RZ.mjs} +3 -0
  187. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  188. package/dist/cli/{chunk-UDXULACQ.js → chunk-MLABYI4M.js} +90 -24
  189. package/dist/cli/{chunk-S7IZWGUA.mjs → chunk-NDNHYONK.mjs} +17 -21
  190. package/dist/cli/{chunk-4D3WIZST.mjs → chunk-OTV2UUKW.mjs} +164 -18
  191. package/dist/cli/{chunk-XYE5XPGF.js → chunk-Q6Z6N3A7.js} +18 -18
  192. package/dist/cli/{chunk-7WQNWJQW.mjs → chunk-QG6JIWUL.mjs} +151 -43
  193. package/dist/cli/{chunk-3T65J5RG.mjs → chunk-QI5S5HWB.mjs} +2 -2
  194. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  195. package/dist/cli/{chunk-PM7MO62Y.mjs → chunk-RMNOZKRI.mjs} +3 -3
  196. package/dist/cli/{chunk-NMWGZD6Y.js → chunk-RTV4RF7N.js} +36 -36
  197. package/dist/cli/{chunk-CQ6JYQSW.js → chunk-SBH4CKPN.js} +11 -11
  198. package/dist/cli/{chunk-BIIJATTX.mjs → chunk-SG3LUONJ.mjs} +3 -3
  199. package/dist/cli/{chunk-2WFPHBR4.js → chunk-TFEXSHPM.js} +22 -18
  200. package/dist/cli/{chunk-5IL7SC45.mjs → chunk-TN4TY6TT.mjs} +6 -7
  201. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-UEVKMZLR.mjs} +54 -3
  202. package/dist/cli/{chunk-RE5MJBEV.mjs → chunk-UVQJYV76.mjs} +2 -2
  203. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  204. package/dist/cli/{chunk-W2ZWQUHT.js → chunk-WOCHZCUJ.js} +2 -2
  205. package/dist/cli/{chunk-ZDQFBJPO.js → chunk-XLIHTJVM.js} +348 -118
  206. package/dist/cli/{chunk-2ZYRBMQM.js → chunk-Y6SP3JMI.js} +22 -22
  207. package/dist/cli/{chunk-PPSDCN6C.js → chunk-YUA6HA6D.js} +2 -2
  208. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  209. package/dist/cli/{chunk-E64HFB4L.mjs → chunk-Z6XPSHKM.mjs} +87 -41
  210. package/dist/cli/{chunk-7DOQ3OEX.mjs → chunk-Z7AOIHFE.mjs} +1870 -91
  211. package/dist/cli/command-docs.js +3 -3
  212. package/dist/cli/command-docs.mjs +2 -2
  213. package/dist/cli/concurrent-runs-help-CFJH4KXV.js +22 -0
  214. package/dist/cli/{concurrent-runs-help-C6L6I5OR.mjs → concurrent-runs-help-DNV2X5AZ.mjs} +9 -8
  215. package/dist/cli/{csv-QMF4FWE7.js → csv-SA6ELJY6.js} +16 -15
  216. package/dist/cli/{csv-SYSDXFEM.mjs → csv-ZXZGHWOM.mjs} +7 -6
  217. package/dist/cli/{db-Q7HURWRZ.mjs → db-A54SP6AD.mjs} +16 -16
  218. package/dist/cli/{db-YSHPPA4H.js → db-JHFEIQBU.js} +43 -43
  219. package/dist/cli/describe-PHQ33AGS.mjs +50 -0
  220. package/dist/cli/describe-RHJ4XRFI.js +50 -0
  221. package/dist/cli/describe-core.d.mts +3 -3
  222. package/dist/cli/describe-core.d.ts +3 -3
  223. package/dist/cli/describe-core.js +6 -6
  224. package/dist/cli/describe-core.mjs +5 -5
  225. package/dist/cli/{executions-G7U3VUXN.mjs → executions-HL2M2DFU.mjs} +10 -10
  226. package/dist/cli/{executions-MWBC5TAW.js → executions-TLFZRHBJ.js} +12 -12
  227. package/dist/cli/{feedback-SD55OY6H.js → feedback-5UEX5UZK.js} +17 -16
  228. package/dist/cli/{feedback-GMHIFLBJ.mjs → feedback-QMBTNXVG.mjs} +9 -8
  229. package/dist/cli/git-4JWOOHBG.js +26 -0
  230. package/dist/cli/{git-HPE45OPD.mjs → git-LKGXVIVC.mjs} +8 -7
  231. package/dist/cli/index.js +170 -158
  232. package/dist/cli/index.mjs +60 -48
  233. package/dist/cli/{integrations-HFKVBY6G.js → integrations-6RUTLMN7.js} +23 -27
  234. package/dist/cli/{integrations-2W4MGIQR.mjs → integrations-FGGRVUJ7.mjs} +15 -19
  235. package/dist/cli/{legacy-noops-SXVNDEXN.js → legacy-noops-J3Z7QRWZ.js} +12 -11
  236. package/dist/cli/{legacy-noops-GZYKNU2Z.mjs → legacy-noops-YIPRMVXZ.mjs} +9 -8
  237. package/dist/cli/{mcp-PJRHQHHU.js → mcp-6LWFP7RW.js} +121 -48
  238. package/dist/cli/{mcp-BWA6KULG.mjs → mcp-CHDYFO7F.mjs} +100 -27
  239. package/dist/cli/{monitors-K2WSI6CR.js → monitors-STM6A7OU.js} +221 -186
  240. package/dist/cli/{monitors-SYQKCATO.mjs → monitors-UGRY2BXI.mjs} +58 -23
  241. package/dist/cli/org-3SYOUQCX.mjs +2289 -0
  242. package/dist/cli/org-ZOBSNSIB.js +2289 -0
  243. package/dist/cli/outcomes-H4YYAT5X.js +2865 -0
  244. package/dist/cli/outcomes-Z3P2JE67.mjs +2865 -0
  245. package/dist/cli/{play-SZXY2F2S.js → play-SM4CW2GS.js} +1116 -846
  246. package/dist/cli/{play-TTMABJEI.mjs → play-SN5YWLS7.mjs} +375 -105
  247. package/dist/cli/{providers-GQIOMRQO.mjs → providers-WZ4YBR5Y.mjs} +10 -10
  248. package/dist/cli/{providers-YDHCTZAF.js → providers-WZARYMCF.js} +13 -13
  249. package/dist/cli/{quickstart-PHSSMKCA.mjs → quickstart-2575BNKA.mjs} +7 -6
  250. package/dist/cli/{quickstart-BNYOXQXG.js → quickstart-PS4YHQJ6.js} +9 -8
  251. package/dist/cli/{run-GFIAZXVL.js → run-FLZ6OTM7.js} +51 -51
  252. package/dist/cli/{run-74C3C75C.mjs → run-ZUHCZOJS.mjs} +31 -31
  253. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  254. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  255. package/dist/cli/{search-3SWUB7KX.mjs → search-HLPPKQEO.mjs} +11 -11
  256. package/dist/cli/search-JJWVHR3N.js +32 -0
  257. package/dist/cli/{search-output-K2SWHVHQ.mjs → search-output-PDAXNOGP.mjs} +9 -8
  258. package/dist/cli/{search-output-6JF3S4TP.js → search-output-RXJLU36B.js} +12 -11
  259. package/dist/cli/{secrets-2M4XWEKE.mjs → secrets-CGELYQ3H.mjs} +11 -11
  260. package/dist/cli/{secrets-2SAKLH2H.js → secrets-QJNG7G2Y.js} +20 -20
  261. package/dist/cli/sessions-DHTBT2GN.js +23 -0
  262. package/dist/cli/{sessions-A64BCXTO.mjs → sessions-ELMWVR4M.mjs} +9 -8
  263. package/dist/cli/{settings-HV64WIJF.js → settings-44I44P5F.js} +89 -89
  264. package/dist/cli/{settings-SVGEC3FI.mjs → settings-RR3LZXL7.mjs} +16 -16
  265. package/dist/cli/{setup-EDC3NEJ3.mjs → setup-KGWRWH4B.mjs} +20 -19
  266. package/dist/cli/{setup-FHXOLQGQ.js → setup-KTEYOCJO.js} +60 -59
  267. package/dist/cli/skills-EPZPEXI2.js +37 -0
  268. package/dist/cli/{skills-3HGHZMXB.mjs → skills-FPRID2I5.mjs} +10 -9
  269. package/dist/cli/tools-IGQQ5TML.js +57 -0
  270. package/dist/cli/{tools-P2QS6A6Q.mjs → tools-PI4WMDLY.mjs} +23 -23
  271. package/dist/cli/update-4RNCVYGE.js +37 -0
  272. package/dist/cli/{update-552BYQM4.mjs → update-VJOJAZ7B.mjs} +14 -11
  273. package/dist/cli/{views-PA25NAE3.js → views-NTUOLNQU.js} +62 -64
  274. package/dist/cli/{views-LD5HXJYY.mjs → views-OVPSINZO.mjs} +47 -49
  275. package/dist/cli/{workflow-FIDBUQV6.js → workflow-2UDYDM6F.js} +23 -23
  276. package/dist/cli/{workflow-LDYFGBYP.mjs → workflow-7OEFNXZC.mjs} +13 -13
  277. package/dist/{client-DuDFiJDU.d.mts → client-B8f7RNF8.d.mts} +1 -1
  278. package/dist/{client-t9HZAkFD.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  279. package/dist/{client-core-DydMQOft.d.mts → client-core-SLLGBTht.d.mts} +285 -23
  280. package/dist/{client-core-CJRzLanv.d.ts → client-core-p0sOxnkl.d.ts} +285 -23
  281. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  282. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  283. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  284. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  285. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  286. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  287. package/dist/index.d.mts +7 -7
  288. package/dist/index.d.ts +7 -7
  289. package/dist/index.js +66 -55
  290. package/dist/index.mjs +25 -14
  291. package/dist/install-integrity.json +162 -142
  292. package/dist/plays/bundle-play-file.d.mts +3 -3
  293. package/dist/plays/bundle-play-file.d.ts +3 -3
  294. package/dist/plays/bundle-play-file.mjs +23 -4
  295. package/dist/plays/csv-data-input.js +3 -3
  296. package/dist/plays/csv-data-input.mjs +2 -2
  297. package/dist/plays/play-description.d.mts +2 -2
  298. package/dist/plays/play-description.d.ts +2 -2
  299. package/dist/plays/run-request.d.mts +2 -2
  300. package/dist/plays/run-request.d.ts +2 -2
  301. package/dist/plays/run-request.js +4 -4
  302. package/dist/plays/run-request.mjs +3 -3
  303. package/dist/release.d.mts +1 -1
  304. package/dist/release.d.ts +1 -1
  305. package/dist/release.js +2 -2
  306. package/dist/release.mjs +1 -1
  307. package/dist/server.d.mts +4 -4
  308. package/dist/server.d.ts +4 -4
  309. package/dist/server.js +15 -13
  310. package/dist/server.mjs +9 -7
  311. package/package.json +1 -1
  312. package/dist/cli/auth-B4PI7GVY.js +0 -43
  313. package/dist/cli/concurrent-runs-help-JEFQZTJI.js +0 -21
  314. package/dist/cli/describe-PXTSBJTL.js +0 -50
  315. package/dist/cli/describe-YGMQBV44.mjs +0 -50
  316. package/dist/cli/git-I3JV7IGH.js +0 -25
  317. package/dist/cli/org-5KD7X7IA.mjs +0 -1282
  318. package/dist/cli/org-YQ2CR32B.js +0 -1282
  319. package/dist/cli/run-identity-G257GQED.js +0 -25
  320. package/dist/cli/search-2RRRF4LW.js +0 -32
  321. package/dist/cli/sessions-SBH27JNW.js +0 -22
  322. package/dist/cli/skills-Y3SRLOYD.js +0 -36
  323. package/dist/cli/tools-OFYPUPUV.js +0 -57
  324. package/dist/cli/update-SOUSCLB7.js +0 -34
@@ -3,9 +3,18 @@ import dns from 'node:dns';
3
3
  import type { IncomingMessage, ServerResponse } from 'node:http';
4
4
  import {
5
5
  readCarriedExperimentSwitchOverrides,
6
+ resolveExperimentSwitch,
6
7
  type ExperimentSwitchOverrides,
7
8
  } from '../experiment-switches';
8
9
  import { parseEarlySandboxClaimOwner } from './early-sandbox-claim-affinity';
10
+ import {
11
+ EARLY_SANDBOX_LISTENER_HINT,
12
+ parseEarlySandboxListenerGeneration,
13
+ parseEarlySandboxListenerQueue,
14
+ parseEarlySandboxListenerStatus,
15
+ selectEarlySandboxListener,
16
+ type EarlySandboxListenerStatus,
17
+ } from './early-sandbox-listener-hint';
9
18
 
10
19
  export const RUNTIME_WORKER_WAKE_PATH = '/internal/runtime-worker/wake';
11
20
 
@@ -72,6 +81,22 @@ export function runtimeWorkerWakeTargetFromEnv(
72
81
  return url && token ? { url, token } : null;
73
82
  }
74
83
 
84
+ /**
85
+ * Deployment-owned target for the early-sandbox hint relay only. Its own
86
+ * setting (`DEEPLINE_RUNTIME_WORKER_EARLY_SANDBOX_URL`) lets a deployment
87
+ * relay hints without also turning on terminal and generic worker wakes,
88
+ * which read `DEEPLINE_RUNTIME_WORKER_WAKE_URL`. Absent: the wake target, so
89
+ * a Preview lane that sets only the wake URL relays hints as before.
90
+ */
91
+ export function runtimeWorkerEarlySandboxTargetFromEnv(
92
+ env: Record<string, string | undefined> = process.env,
93
+ ): RuntimeWorkerWakeTarget | null {
94
+ const url = env.DEEPLINE_RUNTIME_WORKER_EARLY_SANDBOX_URL?.trim();
95
+ const token = env.DEEPLINE_INTERNAL_TOKEN?.trim();
96
+ if (url) return token ? { url, token } : null;
97
+ return runtimeWorkerWakeTargetFromEnv(env);
98
+ }
99
+
75
100
  /** A bounded hint, never a retry, admission, or correctness dependency. */
76
101
  export async function requestRuntimeWorkerWake(
77
102
  target: RuntimeWorkerWakeTarget,
@@ -202,6 +227,13 @@ export type RuntimeWorkerEarlySandboxHint = {
202
227
  * gateway drops it, and its hint takes the absent path.
203
228
  */
204
229
  sandboxPlacementPolicyId?: string;
230
+ /**
231
+ * LH: the run's release queue (`absurdQueueNameForLaunch`). The gateway
232
+ * picks that queue's listener; the worker refuses any other queue.
233
+ */
234
+ queue?: string;
235
+ /** LH: set by the gateway only, the chosen listener's generation. */
236
+ listenerGeneration?: string;
205
237
  };
206
238
 
207
239
  /** Longest placement policy id a hint may carry (catalog ids are ~25). */
@@ -236,11 +268,31 @@ export function parseEarlySandboxHint(
236
268
  return null;
237
269
  sandboxPlacementPolicyId = trimmed;
238
270
  }
271
+ // LH fields: present but malformed is a malformed hint, as above.
272
+ let queue: string | undefined;
273
+ if (value.queue !== undefined && value.queue !== null) {
274
+ const parsed = parseEarlySandboxListenerQueue(value.queue);
275
+ if (!parsed) return null;
276
+ queue = parsed;
277
+ }
278
+ let listenerGeneration: string | undefined;
279
+ if (
280
+ value.listenerGeneration !== undefined &&
281
+ value.listenerGeneration !== null
282
+ ) {
283
+ const parsed = parseEarlySandboxListenerGeneration(
284
+ value.listenerGeneration,
285
+ );
286
+ if (!parsed) return null;
287
+ listenerGeneration = parsed;
288
+ }
239
289
  return {
240
290
  workflowId,
241
291
  orgId,
242
292
  ...(experimentSwitchOverrides ? { experimentSwitchOverrides } : {}),
243
293
  ...(sandboxPlacementPolicyId ? { sandboxPlacementPolicyId } : {}),
294
+ ...(queue ? { queue } : {}),
295
+ ...(listenerGeneration ? { listenerGeneration } : {}),
244
296
  };
245
297
  } catch {
246
298
  return null;
@@ -319,9 +371,11 @@ export async function requestRuntimeWorkerEarlySandboxWithOwner(
319
371
  url: string,
320
372
  token: string,
321
373
  hint: RuntimeWorkerEarlySandboxHint,
374
+ /** Defaults to the hint's 1 s bound; the LH relay passes what remains. */
375
+ timeoutMs: number = EARLY_SANDBOX_HINT_REQUEST_TIMEOUT_MS,
322
376
  ): Promise<{ status: number | null; owner: string | null }> {
323
377
  const controller = new AbortController();
324
- const timeout = setTimeout(() => controller.abort(), 1_000);
378
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
325
379
  try {
326
380
  const target = new URL(url);
327
381
  if (target.protocol === 'http:' && target.hostname.endsWith('.internal')) {
@@ -366,12 +420,309 @@ export async function requestRuntimeWorkerEarlySandboxWithOwner(
366
420
  }
367
421
  }
368
422
 
423
+ /** LH: a worker's in-memory listener status (no database read). */
424
+ export const RUNTIME_WORKER_EARLY_SANDBOX_LISTENER_PATH =
425
+ '/internal/runtime-worker/early-sandbox-listener';
426
+
427
+ /** Most worker addresses the gateway asks for listener status. */
428
+ export const EARLY_SANDBOX_LISTENER_MAX_TARGETS = 32;
429
+ /** Every hint request's bound (app -> gateway, gateway -> worker). */
430
+ export const EARLY_SANDBOX_HINT_REQUEST_TIMEOUT_MS = 1_000;
431
+ /**
432
+ * The gateway's whole LH budget (status reads plus the relay to the chosen
433
+ * worker), inside the app's own hint request bound so the app never gives up
434
+ * on a gateway that is still working.
435
+ */
436
+ export const EARLY_SANDBOX_LISTENER_HINT_BUDGET_MS = 900;
437
+ /**
438
+ * One deadline for the lookup and every status read; a slow worker counts as
439
+ * no status. 300 ms refused every Production hint on the target org
440
+ * (2026-11-23 12:00Z: `outcomes: {timeout: 2}` while the elected listener
441
+ * claimed the run). 700 ms leaves the relay at least 200 ms of the LH budget.
442
+ * A miss still only means the launch creates its own sandbox.
443
+ */
444
+ export const EARLY_SANDBOX_LISTENER_STATUS_TIMEOUT_MS = 700;
445
+ /** The least the relay is given after the status reads. */
446
+ export const EARLY_SANDBOX_LISTENER_RELAY_MIN_MS = 100;
447
+
448
+ /**
449
+ * The worker's listener status source: its desk while ready, or none (the
450
+ * read answers 503). The Preview listener-status fixture
451
+ * (`resolvePreviewWorkerListenerStatusFault`) also yields none.
452
+ */
453
+ export function workerEarlySandboxListenerStatusSource(input: {
454
+ ready: boolean;
455
+ desk: { status: () => EarlySandboxListenerStatus | null } | null;
456
+ fault: string | null;
457
+ }): (() => EarlySandboxListenerStatus | null) | null {
458
+ const { desk } = input;
459
+ return input.ready && desk && !input.fault ? () => desk.status() : null;
460
+ }
461
+
462
+ /** Worker side of the listener status read (node:http). */
463
+ export function handleRuntimeWorkerEarlySandboxListener(
464
+ req: IncomingMessage,
465
+ res: ServerResponse,
466
+ input: {
467
+ expectedToken: string | undefined;
468
+ status: (() => EarlySandboxListenerStatus | null) | null;
469
+ },
470
+ ): boolean {
471
+ if (
472
+ new URL(req.url ?? '/', 'http://worker.local').pathname !==
473
+ RUNTIME_WORKER_EARLY_SANDBOX_LISTENER_PATH
474
+ )
475
+ return false;
476
+ const respond = (status: number, body: string) => {
477
+ res.writeHead(status, {
478
+ 'content-type': 'application/json',
479
+ 'cache-control': 'no-store',
480
+ });
481
+ res.end(body);
482
+ };
483
+ if (req.method !== 'POST') {
484
+ respond(405, '{"error":"Use POST."}');
485
+ return true;
486
+ }
487
+ if (
488
+ !internalBearerTokenMatches(req.headers.authorization, input.expectedToken)
489
+ ) {
490
+ respond(401, '{"error":"Unauthorized."}');
491
+ return true;
492
+ }
493
+ const status = input.status?.() ?? null;
494
+ if (!status) {
495
+ respond(503, '{"error":"No listener status."}');
496
+ return true;
497
+ }
498
+ respond(200, JSON.stringify(status));
499
+ return true;
500
+ }
501
+
502
+ /** Every private address behind a `.internal` worker URL; the URL otherwise. */
503
+ async function resolveWorkerTargets(
504
+ url: URL,
505
+ lookupAll: (hostname: string) => Promise<string[]>,
506
+ signal: AbortSignal,
507
+ ): Promise<URL[]> {
508
+ if (!(url.protocol === 'http:' && url.hostname.endsWith('.internal')))
509
+ return [url];
510
+ const addresses = await new Promise<string[]>((resolve, reject) => {
511
+ signal.addEventListener(
512
+ 'abort',
513
+ () => reject(new Error('listener lookup timed out')),
514
+ { once: true },
515
+ );
516
+ lookupAll(url.hostname).then(resolve, reject);
517
+ });
518
+ return addresses
519
+ .slice(0, EARLY_SANDBOX_LISTENER_MAX_TARGETS)
520
+ .map((address) => {
521
+ const target = new URL(url);
522
+ target.hostname = `[${address}]`;
523
+ return target;
524
+ });
525
+ }
526
+
527
+ const defaultLookupAll = (hostname: string) =>
528
+ new Promise<string[]>((resolve, reject) => {
529
+ dns.lookup(hostname, { family: 6, all: true }, (error, resolved) =>
530
+ error ? reject(error) : resolve(resolved.map((entry) => entry.address)),
531
+ );
532
+ });
533
+
534
+ /**
535
+ * LH: the one worker address listening for `queue`, with its generation, or
536
+ * why none was chosen. Reads only each worker's in-memory status.
537
+ */
538
+ export async function findEarlySandboxListener(input: {
539
+ url: string;
540
+ token: string;
541
+ queue: string;
542
+ lookupAll?: (hostname: string) => Promise<string[]>;
543
+ timeoutMs?: number;
544
+ /**
545
+ * The deadline owner: arms `abort` after `ms` and returns its cancel.
546
+ * Defaults to a timer; tests inject one they fire explicitly.
547
+ */
548
+ scheduleDeadline?: (abort: () => void, ms: number) => () => void;
549
+ /** The caller's cancellation (e.g. the hint request ending). */
550
+ signal?: AbortSignal;
551
+ /** Close each connection after its read (the path warmer: no pooled socket). */
552
+ closeConnections?: boolean;
553
+ }): Promise<
554
+ | {
555
+ target: URL;
556
+ generation: string;
557
+ asked: number;
558
+ outcomes: EarlySandboxListenerStatusOutcomes;
559
+ }
560
+ | {
561
+ refused: string;
562
+ asked: number;
563
+ outcomes: EarlySandboxListenerStatusOutcomes;
564
+ }
565
+ > {
566
+ const controller = new AbortController();
567
+ const scheduleDeadline =
568
+ input.scheduleDeadline ??
569
+ ((abort: () => void, ms: number) => {
570
+ const timer = setTimeout(abort, ms);
571
+ return () => clearTimeout(timer);
572
+ });
573
+ const cancelDeadline = scheduleDeadline(
574
+ () => controller.abort(),
575
+ input.timeoutMs ?? EARLY_SANDBOX_LISTENER_STATUS_TIMEOUT_MS,
576
+ );
577
+ const onParentAbort = () => controller.abort();
578
+ if (input.signal?.aborted) controller.abort();
579
+ else input.signal?.addEventListener('abort', onParentAbort, { once: true });
580
+ const outcomes: EarlySandboxListenerStatusOutcomes = {
581
+ counts: {},
582
+ otherQueues: [],
583
+ lookupMs: null,
584
+ slowestReadMs: null,
585
+ };
586
+ const startedAt = performance.now();
587
+ const elapsed = (from: number) => Math.round(performance.now() - from);
588
+ const note = (outcome: string) => {
589
+ outcomes.counts[outcome] = (outcomes.counts[outcome] ?? 0) + 1;
590
+ };
591
+ try {
592
+ const base = new URL(input.url);
593
+ base.pathname = RUNTIME_WORKER_EARLY_SANDBOX_LISTENER_PATH;
594
+ let targets: URL[];
595
+ try {
596
+ targets = await resolveWorkerTargets(
597
+ base,
598
+ input.lookupAll ?? defaultLookupAll,
599
+ controller.signal,
600
+ );
601
+ } catch {
602
+ outcomes.lookupMs = elapsed(startedAt);
603
+ note('lookup_failed');
604
+ return { refused: 'lookup_failed', asked: 0, outcomes };
605
+ }
606
+ outcomes.lookupMs = elapsed(startedAt);
607
+ const readsStartedAt = performance.now();
608
+ const ended = () => {
609
+ const ms = elapsed(readsStartedAt);
610
+ outcomes.slowestReadMs = Math.max(outcomes.slowestReadMs ?? 0, ms);
611
+ };
612
+ const statuses = await Promise.all(
613
+ targets.map(async (target) => {
614
+ try {
615
+ const response = await fetch(target, {
616
+ method: 'POST',
617
+ headers: {
618
+ authorization: `Bearer ${input.token}`,
619
+ ...(input.closeConnections ? { connection: 'close' } : {}),
620
+ },
621
+ redirect: 'error',
622
+ signal: controller.signal,
623
+ });
624
+ if (response.status !== 200) {
625
+ await response.body?.cancel();
626
+ // The status code only; the body and headers are never read.
627
+ note(
628
+ Number.isInteger(response.status) &&
629
+ response.status >= 100 &&
630
+ response.status <= 599
631
+ ? `http_${response.status}`
632
+ : 'http_invalid',
633
+ );
634
+ return null;
635
+ }
636
+ let status: EarlySandboxListenerStatus | null = null;
637
+ try {
638
+ status = parseEarlySandboxListenerStatus(
639
+ JSON.parse((await response.text()).slice(0, 1024)),
640
+ );
641
+ } catch {
642
+ status = null;
643
+ }
644
+ if (!status) note('malformed');
645
+ else if (status.queue !== input.queue) {
646
+ note('other_queue');
647
+ if (
648
+ outcomes.otherQueues.length < 2 &&
649
+ !outcomes.otherQueues.includes(status.queue)
650
+ )
651
+ outcomes.otherQueues.push(status.queue);
652
+ } else if (status.generation === null) note('not_listening');
653
+ else if (status.draining) note('listening_draining');
654
+ else if (status.unreservedSlots < 1) note('listening_no_slot');
655
+ else note('listening');
656
+ return status;
657
+ } catch (error) {
658
+ note(
659
+ controller.signal.aborted
660
+ ? 'timeout'
661
+ : `error_${errorCode(error) ?? 'unknown'}`,
662
+ );
663
+ return null;
664
+ } finally {
665
+ ended();
666
+ }
667
+ }),
668
+ );
669
+ const selection = selectEarlySandboxListener({
670
+ queue: input.queue,
671
+ statuses,
672
+ });
673
+ if ('refused' in selection)
674
+ return { refused: selection.refused, asked: targets.length, outcomes };
675
+ const target = new URL(targets[selection.target]!);
676
+ target.pathname = RUNTIME_WORKER_EARLY_SANDBOX_PATH;
677
+ return {
678
+ target,
679
+ generation: selection.generation,
680
+ asked: targets.length,
681
+ outcomes,
682
+ };
683
+ } finally {
684
+ cancelDeadline();
685
+ input.signal?.removeEventListener('abort', onParentAbort);
686
+ }
687
+ }
688
+
689
+ /**
690
+ * LH: what each worker's status read returned, for the gateway decision line:
691
+ * `listening`, `listening_draining`, `listening_no_slot`, `not_listening`,
692
+ * `other_queue` (with up to 2 sample queue names), `malformed`,
693
+ * `http_<status>`, `timeout`, `error_<code>` or `lookup_failed`.
694
+ */
695
+ export type EarlySandboxListenerStatusOutcomes = {
696
+ counts: Record<string, number>;
697
+ otherQueues: string[];
698
+ /** Milliseconds spent resolving worker addresses (null: not reached). */
699
+ lookupMs: number | null;
700
+ /** The slowest status read that ended, ok or not (null: none ended). */
701
+ slowestReadMs: number | null;
702
+ };
703
+
704
+ /**
705
+ * A bounded, allowlisted error class (e.g. `ECONNREFUSED`, `UND_ERR_SOCKET`),
706
+ * never a message, URL or provider body: anything else is `unknown`.
707
+ */
708
+ const ERROR_CODE_PATTERN = /^[A-Z][A-Z0-9_]{1,31}$/;
709
+ function errorCode(error: unknown): string | null {
710
+ const direct = (error as { code?: unknown } | null)?.code;
711
+ const cause = (error as { cause?: { code?: unknown } } | null)?.cause?.code;
712
+ for (const code of [direct, cause]) {
713
+ if (typeof code === 'string' && ERROR_CODE_PATTERN.test(code)) return code;
714
+ }
715
+ return null;
716
+ }
717
+
369
718
  /** Gateway relay of the early-sandbox hint to its fixed private worker. */
370
719
  export async function handleRuntimeGatewayEarlySandbox(
371
720
  req: Request,
372
721
  input: {
373
722
  expectedToken: string | undefined;
374
723
  target: RuntimeWorkerWakeTarget | null;
724
+ /** Test seam; `findEarlySandboxListener` otherwise. */
725
+ findListener?: typeof findEarlySandboxListener;
375
726
  },
376
727
  ): Promise<Response | null> {
377
728
  if (new URL(req.url).pathname !== RUNTIME_WORKER_EARLY_SANDBOX_PATH)
@@ -395,9 +746,98 @@ export async function handleRuntimeGatewayEarlySandbox(
395
746
  }
396
747
  const hint = parseEarlySandboxHint(await req.text());
397
748
  if (!hint) return respond(400, '{"error":"Invalid hint."}');
398
- if (!input.target) return respond(503, '{"error":"No worker target."}');
749
+ if (!input.target) {
750
+ // Loud: a gateway released without the hint target refuses every hint.
751
+ console.warn('[runtime.worker_early_sandbox]', {
752
+ event: 'no_target',
753
+ workflowId: hint.workflowId,
754
+ });
755
+ return respond(503, '{"error":"No worker target."}');
756
+ }
757
+ // The generation is the gateway's to choose; a caller's is never relayed.
758
+ delete hint.listenerGeneration;
399
759
  const workerUrl = new URL(input.target.url);
400
760
  workerUrl.pathname = RUNTIME_WORKER_EARLY_SANDBOX_PATH;
761
+ if (
762
+ resolveExperimentSwitch(
763
+ 'LH',
764
+ hint.experimentSwitchOverrides,
765
+ EARLY_SANDBOX_LISTENER_HINT,
766
+ )
767
+ ) {
768
+ // LH: only the one listener for the run's queue gets the hint. No queue,
769
+ // no listener, or more than one: no hint, and the launch creates its own.
770
+ // One decision line per LH hint, joinable by workflow id.
771
+ const decided = (fields: Record<string, unknown>) =>
772
+ console.info('[runtime.listener_hint]', {
773
+ workflowId: hint.workflowId,
774
+ ...fields,
775
+ });
776
+ if (!hint.queue) {
777
+ decided({ event: 'refused', reason: 'no_queue', asked: 0 });
778
+ return respond(503, '{"ok":false,"refused":"no_queue"}');
779
+ }
780
+ const lhStartedAt = performance.now();
781
+ const found = await (input.findListener ?? findEarlySandboxListener)({
782
+ url: workerUrl.toString(),
783
+ token: input.target.token,
784
+ queue: hint.queue,
785
+ });
786
+ if ('refused' in found) {
787
+ decided({
788
+ event: 'refused',
789
+ reason: found.refused,
790
+ asked: found.asked,
791
+ outcomes: found.outcomes.counts,
792
+ lookupMs: found.outcomes.lookupMs,
793
+ slowestReadMs: found.outcomes.slowestReadMs,
794
+ ...(found.outcomes.otherQueues.length
795
+ ? { otherQueues: found.outcomes.otherQueues, queue: hint.queue }
796
+ : {}),
797
+ });
798
+ return respond(
799
+ 503,
800
+ JSON.stringify({ ok: false, refused: found.refused }),
801
+ );
802
+ }
803
+ const relayBudgetMs = Math.max(
804
+ EARLY_SANDBOX_LISTENER_RELAY_MIN_MS,
805
+ Math.round(
806
+ EARLY_SANDBOX_LISTENER_HINT_BUDGET_MS -
807
+ (performance.now() - lhStartedAt),
808
+ ),
809
+ );
810
+ const { status } = await requestRuntimeWorkerEarlySandboxWithOwner(
811
+ found.target.toString(),
812
+ input.target.token,
813
+ { ...hint, listenerGeneration: found.generation },
814
+ relayBudgetMs,
815
+ );
816
+ // A refusing worker (handover since the status read, slot taken) means
817
+ // no early sandbox; the launch creates its own.
818
+ decided(
819
+ status === 202
820
+ ? {
821
+ event: 'accepted',
822
+ generation: found.generation,
823
+ asked: found.asked,
824
+ lookupMs: found.outcomes.lookupMs,
825
+ slowestReadMs: found.outcomes.slowestReadMs,
826
+ }
827
+ : {
828
+ event: 'refused',
829
+ reason: 'listener_refused',
830
+ workerStatus: status,
831
+ asked: found.asked,
832
+ },
833
+ );
834
+ return respond(
835
+ status ?? 503,
836
+ status === 202
837
+ ? '{"ok":true}'
838
+ : JSON.stringify({ ok: false, refused: 'listener_refused' }),
839
+ );
840
+ }
401
841
  const { status, owner } = await requestRuntimeWorkerEarlySandboxWithOwner(
402
842
  workerUrl.toString(),
403
843
  input.target.token,
@@ -412,3 +852,160 @@ export async function handleRuntimeGatewayEarlySandbox(
412
852
  : '{"ok":false}',
413
853
  );
414
854
  }
855
+
856
+ /**
857
+ * Keeps the gateway's private paths to every worker warm for LH. Measured in
858
+ * Production (2026-11-24 05:3xZ, from both receipt gateways): the first TCP
859
+ * connection from a gateway to a worker's :8787 takes ~2 s (2007-2055 ms on
860
+ * every cold pair), then any new connection to that worker takes 1-17 ms for
861
+ * minutes. The delay is the path, not the worker: a closed port on a cold
862
+ * host takes the same ~2 s to refuse, and the kernel counts two SYN
863
+ * retransmits (the first two SYNs are dropped; Linux resends at 1 s and 2 s).
864
+ * Hints are rare, so the hint-time status read always met a cold path and
865
+ * timed out (`outcomes: {timeout: 6}`). A periodic status read keeps every
866
+ * started worker's path warm and reaches a newly started worker within one
867
+ * interval; the hint still reads fresh status itself, so nothing is selected
868
+ * from this pass.
869
+ */
870
+ export const EARLY_SANDBOX_LISTENER_WARM_INTERVAL_MS = 5_000;
871
+ /** Long enough for a cold connection (~2 s) to open, so the path warms. */
872
+ export const EARLY_SANDBOX_LISTENER_WARM_TIMEOUT_MS = 4_000;
873
+ /** No release queue is named this; every status reads as another queue. */
874
+ const WARM_PASS_QUEUE = 'listener-path-warm';
875
+
876
+ export type EarlySandboxListenerPathWarmer = {
877
+ /** One pass now (single-flight); resolves when it ends. */
878
+ warmNow: () => Promise<void>;
879
+ /** Clears the timer and aborts a pass in flight. */
880
+ stop: () => void;
881
+ };
882
+
883
+ /**
884
+ * Only for a deployment that names the early-sandbox URL explicitly (today the
885
+ * Production receipt gateways); null otherwise, so no other deployment gains
886
+ * background reads.
887
+ */
888
+ export function startEarlySandboxListenerPathWarmer(input: {
889
+ env?: Record<string, string | undefined>;
890
+ find?: typeof findEarlySandboxListener;
891
+ lookupAll?: (hostname: string) => Promise<string[]>;
892
+ setIntervalFn?: (tick: () => void, ms: number) => { unref?: () => void };
893
+ clearIntervalFn?: (handle: { unref?: () => void }) => void;
894
+ log?: (line: Record<string, unknown>) => void;
895
+ }): EarlySandboxListenerPathWarmer | null {
896
+ const env = input.env ?? process.env;
897
+ if (!env.DEEPLINE_RUNTIME_WORKER_EARLY_SANDBOX_URL?.trim()) return null;
898
+ const target = runtimeWorkerEarlySandboxTargetFromEnv(env);
899
+ if (!target) return null;
900
+ const find = input.find ?? findEarlySandboxListener;
901
+ const lookupAll = input.lookupAll ?? defaultLookupAll;
902
+ const log =
903
+ input.log ??
904
+ ((line: Record<string, unknown>) =>
905
+ console.info({ ...line, message: '[runtime.listener_path_warm]' }));
906
+ let running: Promise<void> | null = null;
907
+ let stopped = false;
908
+ // `dns.lookup` cannot be cancelled: an abandoned lookup still holds a
909
+ // threadpool slot, so no pass starts until the last one has settled.
910
+ let lookupUnsettled = false;
911
+ const trackedLookup = (hostname: string) => {
912
+ lookupUnsettled = true;
913
+ const lookup = lookupAll(hostname);
914
+ void lookup.then(
915
+ () => {
916
+ lookupUnsettled = false;
917
+ },
918
+ () => {
919
+ lookupUnsettled = false;
920
+ },
921
+ );
922
+ return lookup;
923
+ };
924
+ // A line only when the pass outcome changes, so a lasting failure is one
925
+ // line (plus how many identical passes it stood for), not one per pass.
926
+ let lastLogged: string | null = null;
927
+ let suppressed = 0;
928
+ const controller = new AbortController();
929
+ const warmNow = () => {
930
+ if (stopped) return Promise.resolve();
931
+ if (running) return running;
932
+ if (lookupUnsettled) {
933
+ suppressed += 1;
934
+ return Promise.resolve();
935
+ }
936
+ running = (async () => {
937
+ let line: Record<string, unknown>;
938
+ try {
939
+ const found = await find({
940
+ url: target.url,
941
+ token: target.token,
942
+ queue: WARM_PASS_QUEUE,
943
+ timeoutMs: EARLY_SANDBOX_LISTENER_WARM_TIMEOUT_MS,
944
+ signal: controller.signal,
945
+ lookupAll: trackedLookup,
946
+ closeConnections: true,
947
+ });
948
+ const slowest = found.outcomes.slowestReadMs;
949
+ const unhealthy = Object.keys(found.outcomes.counts).filter(
950
+ (outcome) => outcome !== 'other_queue',
951
+ );
952
+ const cold = (slowest ?? 0) > EARLY_SANDBOX_LISTENER_STATUS_TIMEOUT_MS;
953
+ line = {
954
+ event: 'warm',
955
+ asked: found.asked,
956
+ counts: found.outcomes.counts,
957
+ lookupMs: found.outcomes.lookupMs,
958
+ slowestReadMs: slowest,
959
+ };
960
+ // A cold path is worth a line every time (a new worker or a lost
961
+ // route); an all-healthy pass resets the change detector silently.
962
+ if (!cold && unhealthy.length === 0) {
963
+ lastLogged = null;
964
+ suppressed = 0;
965
+ return;
966
+ }
967
+ if (!cold) {
968
+ // Canonical: `counts` keys follow whichever read finished first, so
969
+ // the same outcome must not read as a change (Production 2026-11-25:
970
+ // {other_queue, http_503} vs {http_503, other_queue} logged most
971
+ // passes).
972
+ const key = JSON.stringify(
973
+ Object.entries(found.outcomes.counts).sort(([a], [b]) =>
974
+ a < b ? -1 : a > b ? 1 : 0,
975
+ ),
976
+ );
977
+ if (key === lastLogged) {
978
+ suppressed += 1;
979
+ return;
980
+ }
981
+ lastLogged = key;
982
+ }
983
+ } catch {
984
+ line = { event: 'warm', failed: true };
985
+ } finally {
986
+ running = null;
987
+ }
988
+ // An aborted pass at shutdown is not a route failure.
989
+ if (stopped) return;
990
+ log(suppressed > 0 ? { ...line, suppressed } : line);
991
+ suppressed = 0;
992
+ })();
993
+ return running;
994
+ };
995
+ const handle = (input.setIntervalFn ?? setInterval)(() => {
996
+ void warmNow();
997
+ }, EARLY_SANDBOX_LISTENER_WARM_INTERVAL_MS);
998
+ handle.unref?.();
999
+ void warmNow();
1000
+ return {
1001
+ warmNow,
1002
+ stop: () => {
1003
+ stopped = true;
1004
+ (
1005
+ input.clearIntervalFn ??
1006
+ ((h) => clearInterval(h as ReturnType<typeof setInterval>))
1007
+ )(handle);
1008
+ controller.abort();
1009
+ },
1010
+ };
1011
+ }
@@ -1,4 +1,7 @@
1
- import { RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS } from './runtime-constants';
1
+ import {
2
+ RUNNER_ACCOUNT_ACCESS_UNAVAILABLE_RETRY_BUDGET_MS,
3
+ RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS,
4
+ } from './runtime-constants';
2
5
 
3
6
  export const SECRET_RESOLUTION_MAX_ATTEMPTS = 3;
4
7
  export const SECRET_RESOLUTION_MAX_RETRY_AFTER_MS = 2_000;
@@ -109,3 +112,25 @@ export function secretResolutionOutageRetryDelayMs(input: {
109
112
  ? delayMs
110
113
  : null;
111
114
  }
115
+
116
+ /**
117
+ * The wait before resending a lookup the app's account-access cutoff refused
118
+ * as unavailable (`isAccountAccessUnavailableResponse`) once its ordinary
119
+ * attempts are spent: 1 s growing by 1 s per attempt up to 8 s, or null when
120
+ * the account-access budget is used up. The cutoff ran before any route, so
121
+ * nothing was resolved.
122
+ */
123
+ export function secretResolutionAccountAccessRetryDelayMs(input: {
124
+ respondedAttempts: number;
125
+ elapsedMs: number;
126
+ }): number | null {
127
+ const delayMs = Math.min(
128
+ 8_000,
129
+ 1_000 *
130
+ Math.max(1, input.respondedAttempts - SECRET_RESOLUTION_MAX_ATTEMPTS + 1),
131
+ );
132
+ return input.elapsedMs + delayMs <=
133
+ RUNNER_ACCOUNT_ACCESS_UNAVAILABLE_RETRY_BUDGET_MS
134
+ ? delayMs
135
+ : null;
136
+ }