deepline 0.3.88 → 0.3.90

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 (280) hide show
  1. package/contracts/install-commands.json +29 -0
  2. package/dist/bundling-sources/sdk/src/client.ts +652 -39
  3. package/dist/bundling-sources/sdk/src/config.ts +77 -0
  4. package/dist/bundling-sources/sdk/src/http.ts +76 -30
  5. package/dist/bundling-sources/sdk/src/index.ts +10 -0
  6. package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +1 -1
  7. package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
  8. package/dist/bundling-sources/sdk/src/play.ts +15 -1
  9. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +3 -3
  10. package/dist/bundling-sources/sdk/src/release.ts +16 -9
  11. package/dist/bundling-sources/sdk/src/types.ts +106 -4
  12. package/dist/bundling-sources/shared_libs/integration-contracts/AGENTS.md +9 -0
  13. package/dist/bundling-sources/shared_libs/integration-contracts/README.md +3 -0
  14. package/dist/bundling-sources/shared_libs/integration-contracts/index.ts +2 -0
  15. package/dist/bundling-sources/shared_libs/monitors/analytics-install-guides.ts +77 -0
  16. package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
  17. package/dist/bundling-sources/shared_libs/monitors/billing/charges.ts +125 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +686 -0
  19. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +54 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/public-pricing.ts +72 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/session.ts +45 -0
  22. package/dist/bundling-sources/shared_libs/monitors/billing/state.ts +454 -0
  23. package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +260 -0
  24. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +215 -0
  25. package/dist/bundling-sources/shared_libs/monitors/callback-security.ts +333 -0
  26. package/dist/bundling-sources/shared_libs/monitors/cursor-page.ts +42 -0
  27. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +16 -0
  28. package/dist/bundling-sources/shared_libs/monitors/framework-managed-payload-fields.ts +71 -0
  29. package/dist/bundling-sources/shared_libs/monitors/generated/provider-monitor-callback-admission-targets.ts +16 -0
  30. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +270 -0
  31. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +39 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +82 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
  34. package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +471 -0
  35. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +1 -1
  36. package/dist/bundling-sources/shared_libs/monitors/package.json +36 -0
  37. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +1125 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +305 -0
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +964 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +56 -0
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +131 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +535 -0
  43. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-legacy-aliases.ts +16 -0
  44. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-priority-execution.ts +56 -0
  45. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +28 -0
  46. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-runtime-read-eligibility.ts +38 -0
  47. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +122 -0
  48. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-status.ts +10 -0
  49. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +112 -0
  50. package/dist/bundling-sources/shared_libs/monitors/provider-webhook-monitor-runtime.ts +300 -0
  51. package/dist/bundling-sources/shared_libs/monitors/quickstart-prompts.ts +22 -0
  52. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
  53. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
  54. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
  55. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
  56. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
  57. package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +93 -0
  58. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +332 -0
  59. package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +221 -0
  60. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +105 -0
  61. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +73 -0
  62. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +81 -0
  63. package/dist/bundling-sources/shared_libs/monitors/tsconfig.json +10 -0
  64. package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
  65. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
  66. package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
  67. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +654 -0
  68. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
  69. package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
  70. package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
  71. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +6 -11
  73. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +135 -12
  74. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
  75. package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +77 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/checkpoint-boundaries.ts +70 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1159 -166
  79. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +1 -32
  80. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +103 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
  82. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
  83. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
  84. package/dist/bundling-sources/shared_libs/play-runtime/default-batch-strategies.ts +20 -1
  85. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
  86. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +29 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +7 -1
  89. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
  93. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +189 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
  105. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
  106. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
  108. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
  109. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
  113. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
  117. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
  118. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
  119. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
  120. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
  121. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
  122. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
  123. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
  124. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
  125. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
  126. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
  127. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
  128. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
  129. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
  130. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
  131. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
  132. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
  133. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +28 -0
  134. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +4 -0
  135. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
  136. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +23 -2
  137. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
  138. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +1 -1
  139. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +90 -13
  140. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
  141. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +68 -0
  142. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +21 -0
  143. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
  144. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -43
  145. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -213
  146. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
  147. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +20 -0
  148. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +6 -0
  149. package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +12 -0
  150. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
  151. package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
  152. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
  153. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +38 -2
  154. package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
  155. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
  156. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
  157. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +37 -1
  158. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
  159. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
  160. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
  161. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
  162. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
  163. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
  164. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
  165. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
  166. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
  167. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
  168. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
  169. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
  170. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
  171. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
  172. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
  173. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
  174. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
  175. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
  176. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
  177. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
  178. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
  179. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
  180. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
  181. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
  182. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
  183. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
  184. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
  185. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
  186. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
  187. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
  188. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
  189. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
  190. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
  191. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
  192. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
  193. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
  194. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
  195. package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
  196. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
  197. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
  198. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
  199. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
  200. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
  201. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +1 -1
  202. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +1 -1
  203. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
  204. package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
  205. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
  206. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
  207. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
  208. package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
  209. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +8 -3
  210. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +454 -17
  211. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +19 -4
  212. package/dist/bundling-sources/shared_libs/plays/contracts.ts +8 -14
  213. package/dist/bundling-sources/shared_libs/plays/core.ts +11 -6
  214. package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
  215. package/dist/bundling-sources/shared_libs/plays/docflow-binding-owner.ts +16 -11
  216. package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
  217. package/dist/bundling-sources/shared_libs/plays/email-status.ts +1 -1
  218. package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +39 -0
  219. package/dist/bundling-sources/shared_libs/plays/resolve-static-pipeline.ts +1 -1
  220. package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
  221. package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
  222. package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
  223. package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
  224. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
  225. package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
  226. package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
  227. package/dist/bundling-sources/shared_libs/plays/slug.ts +115 -0
  228. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +50 -15
  229. package/dist/bundling-sources/shared_libs/plays/tool-category-descriptions.ts +2 -2
  230. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
  231. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +877 -0
  232. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +456 -0
  233. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +566 -0
  234. package/dist/bundling-sources/shared_libs/product-notifications/content.ts +28 -0
  235. package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +60 -0
  236. package/dist/bundling-sources/shared_libs/product-notifications/email.ts +246 -0
  237. package/dist/bundling-sources/shared_libs/product-notifications/evaluation.ts +280 -0
  238. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +433 -0
  239. package/dist/bundling-sources/shared_libs/product-notifications/legacy-slack.ts +80 -0
  240. package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
  241. package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
  242. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
  243. package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
  244. package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
  245. package/dist/bundling-sources/shared_libs/product-notifications/workspace.ts +38 -0
  246. package/dist/bundling-sources/shared_libs/runtime-env.ts +12 -0
  247. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
  248. package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +35 -0
  249. package/dist/bundling-sources/shared_libs/security/internal-actor.ts +50 -0
  250. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +267 -0
  251. package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
  252. package/dist/cli/getting-started.d.mts +52 -0
  253. package/dist/cli/getting-started.d.ts +52 -0
  254. package/dist/cli/getting-started.js +65 -0
  255. package/dist/cli/getting-started.mjs +36 -0
  256. package/dist/cli/index.d.mts +9 -0
  257. package/dist/cli/index.d.ts +9 -0
  258. package/dist/cli/index.js +1611 -453
  259. package/dist/cli/index.mjs +1596 -447
  260. package/dist/{compiler-manifest-Dbov16F7.d.mts → compiler-manifest-BaJfE-5H.d.mts} +136 -10
  261. package/dist/{compiler-manifest-Dbov16F7.d.ts → compiler-manifest-BaJfE-5H.d.ts} +136 -10
  262. package/dist/index.d.mts +910 -155
  263. package/dist/index.d.ts +910 -155
  264. package/dist/index.js +550 -64
  265. package/dist/index.mjs +550 -64
  266. package/dist/install-integrity.json +193 -4
  267. package/dist/monitor-fleet-contract.d.mts +138 -0
  268. package/dist/monitor-fleet-contract.d.ts +138 -0
  269. package/dist/monitor-fleet-contract.js +404 -0
  270. package/dist/monitor-fleet-contract.mjs +367 -0
  271. package/dist/plays/bundle-play-file.d.mts +8 -3
  272. package/dist/plays/bundle-play-file.d.ts +8 -3
  273. package/dist/plays/bundle-play-file.mjs +100 -20
  274. package/dist/release.d.mts +255 -0
  275. package/dist/release.d.ts +255 -0
  276. package/dist/release.js +215 -0
  277. package/dist/release.mjs +188 -0
  278. package/package.json +23 -4
  279. /package/dist/bundling-sources/shared_libs/{integrations/bettercontact-execution-policy.ts → integration-contracts/bettercontact/execution-policy.ts} +0 -0
  280. /package/dist/bundling-sources/shared_libs/{integrations/theirstack-execution-policy.ts → integration-contracts/theirstack/execution-policy.ts} +0 -0
@@ -1,13 +1,10 @@
1
1
  import type { WorkReceiptStatus } from './work-receipts';
2
+ import { WORK_RECEIPT_STATUS_CODE } from './work-receipt-storage-contract';
2
3
 
3
- export const RECEIPT_STATUS_CODE = {
4
- queued: 0,
5
- pending: 0,
6
- running: 1,
7
- completed: 2,
8
- failed: 3,
9
- skipped: 4,
10
- } as const satisfies Record<WorkReceiptStatus, number>;
4
+ export const RECEIPT_STATUS_CODE = WORK_RECEIPT_STATUS_CODE satisfies Record<
5
+ WorkReceiptStatus,
6
+ number
7
+ >;
11
8
 
12
9
  export type ReceiptStatusCode =
13
10
  (typeof RECEIPT_STATUS_CODE)[keyof typeof RECEIPT_STATUS_CODE];
@@ -63,10 +63,10 @@ export const WORKSPACE_STORAGE_NOT_READY_CODE = 'WORKSPACE_STORAGE_NOT_READY';
63
63
  // postgres-URI passwords). The raw pg error goes in the Error `cause` for server
64
64
  // logs only, never into this message or the normalized public failure.
65
65
  export const WORKSPACE_STORAGE_NOT_READY_MESSAGE =
66
- 'Workspace storage for this organization is unavailable, so this operation could not start. ' +
66
+ 'Deepline could not prepare your workspace storage in time, so this operation did not start. ' +
67
+ 'Try again in a few moments. You do not need to run a database command. ' +
67
68
  'This blocked operation did not use Deepline credits. ' +
68
69
  'Earlier completed operations in the same run may already have used credits. ' +
69
- 'Re-run the command. If it fails again, ask an organization admin to run `deepline db repair` (POST /api/v2/ingestion/repair), then re-run. ' +
70
70
  'If this keeps happening, contact Deepline support with the run ID.';
71
71
 
72
72
  export class WorkspaceStorageNotReadyError extends Error {
@@ -170,6 +170,27 @@ export class ProviderExhaustedError extends Error {
170
170
  }
171
171
  }
172
172
 
173
+ /**
174
+ * `ProviderExhaustedError` is created inside the runtime, but a tool execution
175
+ * can cross the execution gateway before a step program sees it. The gateway
176
+ * deliberately serializes that error as the public, provider-owned
177
+ * `ToolExecutionError` shape. Treat those two representations as the same
178
+ * typed exhaustion outcome; do not fall back based on a message substring.
179
+ */
180
+ export function isProviderExhaustedFailure(error: unknown): error is
181
+ | ProviderExhaustedError
182
+ | (ToolExecutionError & {
183
+ readonly origin: 'provider';
184
+ readonly code: typeof PROVIDER_EXHAUSTED_CODE;
185
+ }) {
186
+ return (
187
+ error instanceof ProviderExhaustedError ||
188
+ (error instanceof ToolExecutionError &&
189
+ error.origin === 'provider' &&
190
+ error.code === PROVIDER_EXHAUSTED_CODE)
191
+ );
192
+ }
193
+
173
194
  /**
174
195
  * Derive the human provider name for a PROVIDER_EXHAUSTED error from a pacing
175
196
  * bucketId. Bucket ids are `${orgId}:${provider}`; the provider itself is
@@ -0,0 +1,168 @@
1
+ import { sha256Hex, stableStringify } from '../plays/row-identity';
2
+ function sanitizePlayNameForWorkflowSegment(value: string): string {
3
+ return value
4
+ .toLowerCase()
5
+ .replace(/[^a-z0-9-]/g, '-')
6
+ .replace(/-+/g, '-')
7
+ .replace(/^-+|-+$/g, '')
8
+ .slice(0, 64);
9
+ }
10
+
11
+ export function buildPlayWorkflowFamilyKey(playName: string): string {
12
+ const normalized = playName
13
+ .split('/')
14
+ .map(sanitizePlayNameForWorkflowSegment)
15
+ .filter(Boolean)
16
+ .join('/');
17
+ return normalized || 'play';
18
+ }
19
+
20
+ export function buildPlayWorkflowRunSuffix(now: Date): string {
21
+ const pad = (value: number, size = 2) => String(value).padStart(size, '0');
22
+ return [
23
+ now.getUTCFullYear(),
24
+ pad(now.getUTCMonth() + 1),
25
+ pad(now.getUTCDate()),
26
+ 't',
27
+ pad(now.getUTCHours()),
28
+ pad(now.getUTCMinutes()),
29
+ pad(now.getUTCSeconds()),
30
+ '-',
31
+ pad(now.getUTCMilliseconds(), 3),
32
+ ].join('');
33
+ }
34
+
35
+ const CANONICAL_PLAY_RUN_TIMESTAMP_RE =
36
+ /\/run\/(\d{4})(\d{2})(\d{2})t(\d{2})(\d{2})(\d{2})-(\d{3})(?:-|$)/;
37
+
38
+ /** Read the UTC creation time embedded in a canonical root play-run id. */
39
+ export function canonicalPlayRunStartedAtMs(runId: string): number | null {
40
+ const match = CANONICAL_PLAY_RUN_TIMESTAMP_RE.exec(runId);
41
+ if (!match) return null;
42
+ const [, year, month, day, hour, minute, second, millisecond] = match;
43
+ const value = Date.UTC(
44
+ Number(year),
45
+ Number(month) - 1,
46
+ Number(day),
47
+ Number(hour),
48
+ Number(minute),
49
+ Number(second),
50
+ Number(millisecond),
51
+ );
52
+ if (!Number.isFinite(value)) return null;
53
+ const roundTrip = new Date(value);
54
+ return roundTrip.getUTCFullYear() === Number(year) &&
55
+ roundTrip.getUTCMonth() === Number(month) - 1 &&
56
+ roundTrip.getUTCDate() === Number(day) &&
57
+ roundTrip.getUTCHours() === Number(hour) &&
58
+ roundTrip.getUTCMinutes() === Number(minute) &&
59
+ roundTrip.getUTCSeconds() === Number(second) &&
60
+ roundTrip.getUTCMilliseconds() === Number(millisecond)
61
+ ? value
62
+ : null;
63
+ }
64
+
65
+ type BuildPlayWorkflowIdOptions = {
66
+ /**
67
+ * Add entropy for new run creation. Keep false for tests and explicit
68
+ * externally-owned ids that need deterministic reconstruction.
69
+ */
70
+ unique?: boolean;
71
+ };
72
+
73
+ function buildRunEntropySuffix(): string {
74
+ const randomUuid = globalThis.crypto?.randomUUID?.();
75
+ if (randomUuid) {
76
+ return randomUuid.replace(/-/g, '').slice(0, 8);
77
+ }
78
+ return Math.random().toString(36).slice(2, 10).padEnd(8, '0');
79
+ }
80
+
81
+ export function buildPlayWorkflowId(
82
+ playName: string,
83
+ now?: Date,
84
+ options: BuildPlayWorkflowIdOptions = {},
85
+ ): string {
86
+ const familyKey = buildPlayWorkflowFamilyKey(playName);
87
+ const timestamp = now ?? new Date();
88
+ const unique = options.unique ?? now === undefined;
89
+ const entropy = unique ? `-${buildRunEntropySuffix()}` : '';
90
+ return `play/${familyKey}/run/${buildPlayWorkflowRunSuffix(timestamp)}${entropy}`;
91
+ }
92
+
93
+ export type PlayRunIdentity = {
94
+ workflowId: string;
95
+ runId: string;
96
+ workflowFamilyKey: string;
97
+ };
98
+
99
+ /**
100
+ * Convex and runtime schedulers share one run identity contract.
101
+ *
102
+ * - `workflowId` is the unique execution id.
103
+ * - `runId` is the same execution id surfaced in dashboard/API state.
104
+ * - `workflowFamilyKey` is the stable play-name-derived family/group key.
105
+ *
106
+ * Keeping these three values explicit removes the old ambiguity where one field
107
+ * pretended to mean both "this specific run" and "this play family".
108
+ */
109
+ export function buildPlayRunIdentity(
110
+ playName: string,
111
+ now?: Date,
112
+ options: BuildPlayWorkflowIdOptions = {},
113
+ ): PlayRunIdentity {
114
+ const workflowId = buildPlayWorkflowId(playName, now, {
115
+ unique: options.unique ?? now === undefined,
116
+ });
117
+ return {
118
+ workflowId,
119
+ runId: workflowId,
120
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(playName),
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Build the replay-stable identity for one ctx.runPlayAsync invocation.
126
+ *
127
+ * The parent's embedded timestamp keeps ordinary run ordering useful while
128
+ * the digest makes retries converge on exactly one independently scheduled
129
+ * child. Input is deliberately excluded: a changed request must conflict with
130
+ * the first immutable launch rather than silently minting another Run.
131
+ */
132
+ export function buildAsyncPlayRunIdentity(input: {
133
+ playName: string;
134
+ parentRunId: string;
135
+ invocationKey: string;
136
+ }): PlayRunIdentity {
137
+ const digest = sha256Hex(
138
+ `${input.parentRunId}\0${input.invocationKey}`,
139
+ ).slice(0, 20);
140
+ const parentStartedAt = canonicalPlayRunStartedAtMs(input.parentRunId) ?? 0;
141
+ // The run id is the durable identity of the authored invocation, so it must
142
+ // be reconstructible before resolving a mutable live Play reference. The
143
+ // workflow family remains the resolved child Play for grouping and display.
144
+ const base = buildPlayWorkflowId('async-child', new Date(parentStartedAt), {
145
+ unique: false,
146
+ });
147
+ const workflowId = `${base}-async-${digest}`;
148
+ return {
149
+ workflowId,
150
+ runId: workflowId,
151
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(input.playName),
152
+ };
153
+ }
154
+
155
+ /** Immutable authored request identity, separate from the resolved revision. */
156
+ export function buildAsyncPlayRequestFingerprint(input: {
157
+ key: string;
158
+ playRef: string;
159
+ childInput: Record<string, unknown>;
160
+ }): string {
161
+ return sha256Hex(
162
+ stableStringify({
163
+ key: input.key,
164
+ playRef: input.playRef,
165
+ input: input.childInput,
166
+ }),
167
+ );
168
+ }
@@ -130,7 +130,7 @@ export function isActivePlayRunStatus(status: unknown): boolean {
130
130
  * The minimal persisted Play Run document shape required to project the live
131
131
  * snapshot. This is a structural subset of the Convex `playRuns` doc and of
132
132
  * the run-observer projection returned by
133
- * `convex/runObservers.getPlayRunSnapshotForObserver`.
133
+ * `packages/convex/runObservers.getPlayRunSnapshotForObserver`.
134
134
  */
135
135
  export type LedgerBackedRunLike = {
136
136
  workflowId: string;
@@ -11,8 +11,15 @@ import {
11
11
  } from '../../../plays/sandbox-runtime-limits';
12
12
  import type { PlayRunnerRuntimeLifecycleEvent } from '../types';
13
13
  import { DAYTONA_PLAY_RUNNER_LABEL_SOURCE } from './daytona-labels';
14
-
15
- const DAYTONA_CREATE_TIMEOUT_SECONDS = 10;
14
+ import type { DaytonaSandboxStartAdmission } from './daytona-start-admission';
15
+
16
+ // Match Daytona's supported default create window. Ten seconds is shorter
17
+ // than normal provider startup under burst load: the SDK abandons an otherwise
18
+ // healthy create, and the resulting provider-side transition cannot safely be
19
+ // deleted or hedged with a second sandbox. The runner deadline still bounds
20
+ // the full lifecycle, while ambiguous creates retain the fail-closed cleanup
21
+ // path below.
22
+ const DAYTONA_CREATE_TIMEOUT_SECONDS = 60;
16
23
  const DAYTONA_CREATE_RETRY_DELAYS_MS = [0, 500, 1_500] as const;
17
24
  const DAYTONA_TIMED_OUT_CREATE_RECONCILE_DELAYS_MS = [
18
25
  0, 1_000, 3_000, 6_000, 12_000, 24_000, 36_000,
@@ -85,6 +92,20 @@ export class DaytonaSandboxAcquisitionUnavailableError extends Error {
85
92
  }
86
93
  }
87
94
 
95
+ /**
96
+ * A named Daytona create is still changing state after the client deadline.
97
+ * The scheduler must defer and resume this exact identity; falling back or
98
+ * creating another sandbox could execute the Play twice.
99
+ */
100
+ export class DaytonaSandboxTransitionPendingError extends Error {
101
+ constructor(readonly sandboxName: string) {
102
+ super(
103
+ `Daytona sandbox ${sandboxName} is still transitioning after create timed out.`,
104
+ );
105
+ this.name = 'DaytonaSandboxTransitionPendingError';
106
+ }
107
+ }
108
+
88
109
  export function resolveDaytonaSandboxAcquisitionUnavailableReason(
89
110
  errors: readonly string[],
90
111
  ): DaytonaSandboxAcquisitionUnavailableReason | null {
@@ -105,7 +126,7 @@ export function resolveDaytonaSandboxAcquisitionUnavailableReason(
105
126
  }
106
127
 
107
128
  function isDaytonaSandboxStartTimeout(error: string): boolean {
108
- return /Failed to create and start sandbox within 10 seconds\. Operation timed out\./.test(
129
+ return /Failed to create and start sandbox within \d+ seconds\. Operation timed out\./.test(
109
130
  error,
110
131
  );
111
132
  }
@@ -319,7 +340,8 @@ async function createOneShotDaytonaSandbox(input: {
319
340
  type TimedOutDaytonaSandboxReconciliation =
320
341
  | { kind: 'started'; sandbox: DaytonaSandbox }
321
342
  | { kind: 'deleted' }
322
- | { kind: 'not_found' };
343
+ | { kind: 'not_found' }
344
+ | { kind: 'transition_pending' };
323
345
 
324
346
  async function reconcileAndDeleteTimedOutDaytonaSandbox(input: {
325
347
  daytona: DaytonaClient;
@@ -369,23 +391,28 @@ async function reconcileAndDeleteTimedOutDaytonaSandbox(input: {
369
391
  return { kind: 'deleted' };
370
392
  }
371
393
  if (lastDeleteConflict) {
372
- throw new Error(
373
- `Daytona timed-out sandbox ${input.sandboxName} remained in a state transition across the bounded cleanup window. Modal fallback suppressed.`,
374
- { cause: lastDeleteConflict },
375
- );
394
+ return { kind: 'transition_pending' };
376
395
  }
377
396
  return { kind: 'not_found' };
378
397
  }
379
398
 
399
+ function daytonaSandboxName(providerOperationToken?: string | null): string {
400
+ return providerOperationToken
401
+ ? `dl-${providerOperationToken}`
402
+ : `dl-${crypto.randomUUID()}`;
403
+ }
404
+
380
405
  async function createRetriedOneShotDaytonaSandbox(input: {
381
406
  daytona: DaytonaClient;
382
407
  orgId: string;
383
408
  context: DaytonaExecutionContext;
384
409
  emitStage: DaytonaStageEmitter;
385
410
  observeCreateCall?: DaytonaCreateCallObserver;
386
- reserveSandboxCapacity?: (
387
- providerAttempt: number,
388
- ) => Promise<{ leaseId: string; providerOperationToken: string | null }>;
411
+ reserveSandboxCapacity?: (providerAttempt: number) => Promise<{
412
+ leaseId: string;
413
+ providerOperationToken: string | null;
414
+ resumeExistingProviderOperation?: boolean;
415
+ }>;
389
416
  releaseSandboxCapacity?: (leaseId: string) => Promise<void>;
390
417
  nextProviderAttempt: () => number;
391
418
  startedAt: number;
@@ -393,7 +420,6 @@ async function createRetriedOneShotDaytonaSandbox(input: {
393
420
  const errors: string[] = [];
394
421
  for (const [index, delayMs] of DAYTONA_CREATE_RETRY_DELAYS_MS.entries()) {
395
422
  const attempt = input.nextProviderAttempt();
396
- const sandboxName = `dl-${crypto.randomUUID()}`;
397
423
  if (delayMs > 0) {
398
424
  input.emitStage('create:retry', {
399
425
  attempt: index,
@@ -410,6 +436,40 @@ async function createRetriedOneShotDaytonaSandbox(input: {
410
436
  providerAttempt: attempt,
411
437
  });
412
438
  const reservation = await input.reserveSandboxCapacity?.(attempt);
439
+ const sandboxName = daytonaSandboxName(reservation?.providerOperationToken);
440
+ if (reservation?.resumeExistingProviderOperation) {
441
+ if (!input.daytona.get) {
442
+ throw new DaytonaSandboxTransitionPendingError(sandboxName);
443
+ }
444
+ try {
445
+ const sandbox = await input.daytona.get(sandboxName);
446
+ if (sandbox.state !== 'started') {
447
+ throw new DaytonaSandboxTransitionPendingError(sandboxName);
448
+ }
449
+ const acquiredAt = Date.now();
450
+ input.emitStage('create:resumed', {
451
+ attempt,
452
+ elapsedMs: acquiredAt - input.startedAt,
453
+ sandboxId: sandbox.id,
454
+ });
455
+ return {
456
+ sandbox,
457
+ attempt,
458
+ attemptElapsedMs: acquiredAt - attemptStartedAt,
459
+ sandboxCapacityLeaseId: reservation.leaseId,
460
+ };
461
+ } catch (error) {
462
+ if (error instanceof DaytonaSandboxTransitionPendingError) throw error;
463
+ if (!isDaytonaSandboxNotFound(error)) {
464
+ throw new DaytonaSandboxTransitionPendingError(sandboxName);
465
+ }
466
+ await input.releaseSandboxCapacity?.(reservation.leaseId);
467
+ throw new DaytonaSandboxAcquisitionUnavailableError(
468
+ 'daytona_sandbox_start_timeout',
469
+ `Timed-out Daytona sandbox ${sandboxName} was confirmed absent before resume.`,
470
+ );
471
+ }
472
+ }
413
473
  let sandbox: DaytonaSandbox;
414
474
  try {
415
475
  sandbox = await createOneShotDaytonaSandbox({
@@ -489,6 +549,15 @@ async function createRetriedOneShotDaytonaSandbox(input: {
489
549
  };
490
550
  }
491
551
  await recordCreateFailure();
552
+ if (reconciliation.kind === 'transition_pending') {
553
+ if (reservation?.providerOperationToken) {
554
+ throw new DaytonaSandboxTransitionPendingError(sandboxName);
555
+ }
556
+ throw new Error(
557
+ `Daytona timed-out sandbox ${sandboxName} remained in a state transition across the bounded cleanup window. Modal fallback suppressed.`,
558
+ { cause: error },
559
+ );
560
+ }
492
561
  if (reconciliation.kind === 'deleted') {
493
562
  // The provider-confirmed reconciliation means this reservation can
494
563
  // no longer represent a live sandbox. Release before returning the
@@ -575,6 +644,7 @@ async function acquireOneShotDaytonaSandbox(input: {
575
644
  releaseSandboxCapacity?: (leaseId: string) => Promise<void>;
576
645
  nextProviderAttempt: () => number;
577
646
  startedAt: number;
647
+ startAdmission?: DaytonaSandboxStartAdmission;
578
648
  }): Promise<AcquiredDaytonaSandbox> {
579
649
  const limits = validatePlaySandboxRuntimeLimits(
580
650
  input.context.sandboxRuntimeLimits ?? {
@@ -582,7 +652,11 @@ async function acquireOneShotDaytonaSandbox(input: {
582
652
  },
583
653
  );
584
654
  input.emitStage('create:start');
585
- const result = await createRetriedOneShotDaytonaSandbox(input);
655
+ const result = input.startAdmission
656
+ ? await input.startAdmission.run(() =>
657
+ createRetriedOneShotDaytonaSandbox(input),
658
+ )
659
+ : await createRetriedOneShotDaytonaSandbox(input);
586
660
  const granted = {
587
661
  cpu: result.sandbox.cpu,
588
662
  memoryGiB: result.sandbox.memory,
@@ -681,8 +755,10 @@ export function createOneShotDaytonaSandboxLifecycle(input: {
681
755
  reserveSandboxCapacity?: (providerAttempt: number) => Promise<{
682
756
  leaseId: string;
683
757
  providerOperationToken: string | null;
758
+ resumeExistingProviderOperation?: boolean;
684
759
  }>;
685
760
  releaseSandboxCapacity?: (leaseId: string) => Promise<void>;
761
+ startAdmission?: DaytonaSandboxStartAdmission;
686
762
  startedAt?: number;
687
763
  }): OneShotDaytonaSandboxLifecycle {
688
764
  const orgId = validateDaytonaExecutionContext(input.context);
@@ -700,6 +776,7 @@ export function createOneShotDaytonaSandboxLifecycle(input: {
700
776
  observeCreateCall: input.observeCreateCall,
701
777
  reserveSandboxCapacity: input.reserveSandboxCapacity,
702
778
  releaseSandboxCapacity: input.releaseSandboxCapacity,
779
+ startAdmission: input.startAdmission,
703
780
  nextProviderAttempt: () => {
704
781
  providerAttempt += 1;
705
782
  return providerAttempt;
@@ -26,6 +26,11 @@ import {
26
26
  RUNTIME_SANDBOX_KILLED_MESSAGE,
27
27
  RUNTIME_SANDBOX_OOM_MESSAGE,
28
28
  } from '../../run-failure';
29
+ import {
30
+ buildDaytonaPayloadMaterializerSource,
31
+ type DaytonaPayloadEnvelope,
32
+ } from '../../daytona-payload-contract';
33
+ export { buildDaytonaPayloadMaterializerSource } from '../../daytona-payload-contract';
29
34
  import { compactPlayArtifactForRuntimeTransport } from '../../../plays/artifact-transport';
30
35
  import type {
31
36
  DaytonaExecutionContext,
@@ -36,16 +41,6 @@ import { buildDaytonaRuntimeWatchdogSource } from './daytona-runtime-watchdog';
36
41
 
37
42
  type DaytonaRemoteRuntimeContext = PlayRunnerExecutionConfig['context'];
38
43
 
39
- type DaytonaPayloadEnvelope = {
40
- schemaVersion: 1;
41
- runnerCode: string;
42
- artifactBundledCode: string;
43
- artifactSourceMap: string;
44
- config: PlayRunnerExecutionConfig;
45
- /** Crash-containment epilogue script (see buildDaytonaCrashTerminalPusherSource). */
46
- crashPusherCode: string;
47
- };
48
-
49
44
  /**
50
45
  * The crash pusher must be able to recover one complete terminal event after
51
46
  * a runner exits before its primary gateway push. A stdout `result` event is
@@ -116,8 +111,7 @@ function nodeMaterializePayloadCommand(input: {
116
111
  artifactSourceMapPath: string;
117
112
  crashPusherPath: string;
118
113
  }): string {
119
- const script =
120
- "const fs=require('node:fs');const zlib=require('node:zlib');const p=JSON.parse(zlib.gunzipSync(fs.readFileSync(process.argv[1])));if(p.schemaVersion!==1)throw new Error('Unsupported Daytona payload envelope');fs.writeFileSync(process.argv[2],p.runnerCode);fs.writeFileSync(process.argv[3],JSON.stringify(p.config));fs.writeFileSync(process.argv[4],p.artifactBundledCode);fs.writeFileSync(process.argv[5],p.artifactSourceMap);fs.writeFileSync(process.argv[6],p.crashPusherCode);";
114
+ const script = buildDaytonaPayloadMaterializerSource();
121
115
  return [
122
116
  'node',
123
117
  '-e',
@@ -0,0 +1,68 @@
1
+ import { RUNTIME_CAPACITY_POLICY } from '../../runtime-capacity-policy';
2
+
3
+ export type DaytonaSandboxStartAdmission = {
4
+ run<T>(operation: () => Promise<T>): Promise<T>;
5
+ };
6
+
7
+ /**
8
+ * Daytona sandbox starts are control-plane transitions, not execution work.
9
+ * Keep their admission independent from Absurd worker slots so a run burst can
10
+ * still multiplex started sandboxes without stampeding the provider's create
11
+ * transition. A permit covers timeout reconciliation too: releasing it when
12
+ * `create` times out would admit another create while the first named sandbox
13
+ * is still transitioning, recreating the unsafe overlap this gate prevents.
14
+ */
15
+ export function createDaytonaSandboxStartAdmission(
16
+ concurrency =
17
+ RUNTIME_CAPACITY_POLICY.sandboxAcquisition
18
+ .daytonaConcurrentStartsPerProcess,
19
+ ): DaytonaSandboxStartAdmission {
20
+ if (!Number.isInteger(concurrency) || concurrency <= 0) {
21
+ throw new Error(
22
+ 'Daytona sandbox-start concurrency must be a positive integer.',
23
+ );
24
+ }
25
+
26
+ let active = 0;
27
+ const waiters: Array<(release: () => void) => void> = [];
28
+
29
+ const createRelease = (): (() => void) => {
30
+ let released = false;
31
+ return () => {
32
+ if (released) return;
33
+ released = true;
34
+ const next = waiters.shift();
35
+ if (next) {
36
+ // Transfer the occupied permit directly. Keeping `active` unchanged
37
+ // prevents a new eager caller from jumping ahead of the FIFO waiter.
38
+ next(createRelease());
39
+ return;
40
+ }
41
+ active -= 1;
42
+ };
43
+ };
44
+
45
+ return {
46
+ async run<T>(operation: () => Promise<T>): Promise<T> {
47
+ // Preserve eager prepare semantics when capacity is free: the provider
48
+ // create begins in this turn, just as it did before admission existed.
49
+ // Only contended callers cross an asynchronous queue boundary.
50
+ const release =
51
+ active < concurrency
52
+ ? (() => {
53
+ active += 1;
54
+ return createRelease();
55
+ })()
56
+ : await new Promise<() => void>((resolve) => waiters.push(resolve));
57
+ try {
58
+ return await operation();
59
+ } finally {
60
+ release();
61
+ }
62
+ },
63
+ };
64
+ }
65
+
66
+ /** One admission queue per worker process; all run slots share it. */
67
+ export const daytonaSandboxStartAdmission =
68
+ createDaytonaSandboxStartAdmission();
@@ -28,6 +28,7 @@ import {
28
28
  import {
29
29
  DAYTONA_CANCELLED_ERROR,
30
30
  DaytonaSandboxAcquisitionUnavailableError,
31
+ DaytonaSandboxTransitionPendingError,
31
32
  createDaytonaSandboxCleanupManager,
32
33
  createOneShotDaytonaSandboxLifecycle,
33
34
  type AcquiredDaytonaSandbox,
@@ -37,12 +38,14 @@ import {
37
38
  type OneShotDaytonaSandboxLifecycle,
38
39
  validateDaytonaExecutionContext,
39
40
  } from './daytona-lifecycle';
41
+ import { recoveryForDaytonaSandboxTransitionPending } from '../../play-run-recovery-policy';
40
42
  import { stageDaytonaRunnerPayload } from './daytona-payload-transport';
41
43
  import {
42
44
  DaytonaRunnerInitializationError,
43
45
  prepareDetachedDaytonaRunner,
44
46
  } from './daytona-session-execution';
45
47
  import { RUNTIME_RELIABILITY_POLICY } from '../../runtime-reliability-policy';
48
+ import { daytonaSandboxStartAdmission } from './daytona-start-admission';
46
49
 
47
50
  const DAYTONA_COMMAND_RECOVERY_TIMEOUT_MS =
48
51
  RUNTIME_RELIABILITY_POLICY.sandbox.daytonaCommandRecoveryTimeoutMs;
@@ -68,6 +71,12 @@ const RUNTIME_API_TRANSPORT_RETRY_PATTERN =
68
71
  // with user code that has already had side effects.
69
72
  const DAYTONA_PUBLIC_STATUS_TRANSIENT_RETRY_PATTERN =
70
73
  /\bDaytonaValidationError:\s*bad request:\s*failed to get sandbox public status:\s*an unexpected error occurred\.?\b/i;
74
+ // A detached runner sends its first authenticated heartbeat before it can run
75
+ // customer code. Persisted terminal results retain the bounded startup
76
+ // diagnostic, so the worker can distinguish that proven pre-code transport
77
+ // failure from a generic readiness timeout on a later wake.
78
+ const DAYTONA_RUNNER_STARTUP_TRANSPORT_RETRY_PATTERN =
79
+ /\bDaytonaRunnerInitializationError:\s*RUNTIME_SANDBOX_START_FAILED:.*\bScheduler diagnosis:\s*runner_heartbeat_not_observed\..*"schedulerReadinessObserved":false.*"commandFound":true.*"exitCode":null.*"sessionFound":true.*"exitCodeFile":null.*"runnerStartup":\{"phase":"heartbeat_transport","outcome":"network_error","errorCode":"(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|UND_ERR_CONNECT_TIMEOUT)"/i;
71
80
  const DAYTONA_INFRASTRUCTURE_RETRY_PATTERN =
72
81
  /\b(?:Request failed with status code (?:408|429|500|502|503|504)|ECONNRESET|ECONNREFUSED|ETIMEDOUT|UND_ERR_CONNECT_TIMEOUT|fetch failed|socket hang up|Daytona sandbox create failed across|Daytona sandbox create did not complete|Daytona readiness baseline)\b/i;
73
82
 
@@ -901,6 +910,7 @@ export function retryableRuntimeInitializationFailureReason(
901
910
  | 'runtime_api_transport'
902
911
  | 'runtime_receipt_gateway_transport'
903
912
  | 'daytona_public_status'
913
+ | 'daytona_runner_startup_transport'
904
914
  | null {
905
915
  if (result.status !== 'failed') return null;
906
916
  if (RUNTIME_POSTGRES_CONNECT_RETRY_PATTERN.test(result.error)) {
@@ -910,6 +920,13 @@ export function retryableRuntimeInitializationFailureReason(
910
920
  return 'runtime_receipt_gateway_transport';
911
921
  }
912
922
  const rowsProcessed = Number(result.stats?.rowsProcessed ?? 0);
923
+ if (
924
+ rowsProcessed === 0 &&
925
+ result.steps.length === 0 &&
926
+ DAYTONA_RUNNER_STARTUP_TRANSPORT_RETRY_PATTERN.test(result.error)
927
+ ) {
928
+ return 'daytona_runner_startup_transport';
929
+ }
913
930
  if (
914
931
  rowsProcessed === 0 &&
915
932
  result.steps.length === 0 &&
@@ -973,6 +990,7 @@ function prepareDaytonaExecution(
973
990
  callbacks.reserveSandboxCapacity!('daytona', providerAttempt)
974
991
  : undefined,
975
992
  releaseSandboxCapacity: callbacks?.releaseSandboxCapacity,
993
+ startAdmission: daytonaSandboxStartAdmission,
976
994
  });
977
995
  return {
978
996
  kind: 'daytona',
@@ -1468,6 +1486,9 @@ export const daytonaPlayRunnerBackend: PlayRunnerBackend = {
1468
1486
  if (error instanceof SandboxRunnerPreCodeDeferralError) {
1469
1487
  throw error;
1470
1488
  }
1489
+ if (error instanceof DaytonaSandboxTransitionPendingError) {
1490
+ throw recoveryForDaytonaSandboxTransitionPending(error);
1491
+ }
1471
1492
  if (error instanceof DaytonaSandboxAcquisitionUnavailableError) {
1472
1493
  throw error;
1473
1494
  }
@@ -206,7 +206,6 @@ export async function buildPlayRunnerBundle(): Promise<string> {
206
206
  resolve(process.cwd(), 'packages', 'play-runtime'),
207
207
  resolve(process.cwd(), 'packages', 'plays'),
208
208
  resolve(process.cwd(), 'packages', 'security'),
209
- resolve(process.cwd(), 'shared_libs'),
210
209
  ];
211
210
  const sourceHash = await hashRunnerSources(sourceRoots);
212
211
  setSpanAttributes(span, {