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
@@ -0,0 +1,120 @@
1
+ import type { WorkerQueueMetrics } from './worker-queue-metrics';
2
+ import {
3
+ renderRuntimeProcessResourceMetrics,
4
+ type WorkerResourceMetrics,
5
+ } from './worker-resource-metrics';
6
+
7
+ /** A `/metrics` response is rendered solely from a process-local snapshot. */
8
+ export type AbsurdWorkerMetricsSnapshot = Readonly<{
9
+ queue: WorkerQueueMetrics;
10
+ schema: string;
11
+ releaseId: string;
12
+ queueName: string;
13
+ workerName: string | null;
14
+ pool: Readonly<{
15
+ totalCount: number;
16
+ idleCount: number;
17
+ waitingCount: number;
18
+ capacityRejections: number;
19
+ saturationRejections: number;
20
+ breakerRejections: number;
21
+ }>;
22
+ resources: WorkerResourceMetrics;
23
+ launchReads: readonly Readonly<{
24
+ caller: string;
25
+ releaseId: string;
26
+ found: number;
27
+ missing: number;
28
+ errors: number;
29
+ durationMsTotal: number;
30
+ }>[];
31
+ }>;
32
+
33
+ function prometheusLabel(value: string): string {
34
+ return value
35
+ .replaceAll('\\', '\\\\')
36
+ .replaceAll('"', '\\"')
37
+ .replaceAll('\n', '\\n');
38
+ }
39
+
40
+ /**
41
+ * This deliberately has no database Adapter. Callers must collect all values
42
+ * while doing normal work, then pass the in-memory snapshot to this renderer.
43
+ */
44
+ export function renderAbsurdWorkerMetrics(
45
+ input: AbsurdWorkerMetricsSnapshot,
46
+ ): string {
47
+ const labels = `{schema="${prometheusLabel(input.schema)}",worker_release_id="${prometheusLabel(input.releaseId)}",worker_queue="${prometheusLabel(input.queueName)}",worker_name="${prometheusLabel(input.workerName ?? 'unnamed')}"}`;
48
+ return [
49
+ '# HELP deepline_absurd_runtime_worker_info Current worker identity. A series exists only while this Fly Machine is scrapeable.',
50
+ '# TYPE deepline_absurd_runtime_worker_info gauge',
51
+ `deepline_absurd_runtime_worker_info${labels} 1`,
52
+ '# HELP deepline_absurd_runtime_queue_metrics_available Whether this worker can provide current global queue state without a database scan.',
53
+ '# TYPE deepline_absurd_runtime_queue_metrics_available gauge',
54
+ `deepline_absurd_runtime_queue_metrics_available${labels} 0`,
55
+ '# HELP deepline_absurd_runtime_queue_depth Queued attempts.',
56
+ '# TYPE deepline_absurd_runtime_queue_depth gauge',
57
+ `deepline_absurd_runtime_queue_depth${labels} ${input.queue.queued}`,
58
+ '# HELP deepline_absurd_runtime_running Running attempts.',
59
+ '# TYPE deepline_absurd_runtime_running gauge',
60
+ `deepline_absurd_runtime_running${labels} ${input.queue.running}`,
61
+ '# HELP deepline_absurd_runtime_oldest_queued_seconds Age of the oldest queued attempt.',
62
+ '# TYPE deepline_absurd_runtime_oldest_queued_seconds gauge',
63
+ `deepline_absurd_runtime_oldest_queued_seconds${labels} ${input.queue.oldest_queued_s}`,
64
+ '# HELP deepline_absurd_runtime_oldest_running_seconds Age of the oldest running attempt.',
65
+ '# TYPE deepline_absurd_runtime_oldest_running_seconds gauge',
66
+ `deepline_absurd_runtime_oldest_running_seconds${labels} ${input.queue.oldest_running_s}`,
67
+ '# HELP deepline_absurd_runtime_stale_leases Running attempts whose lease expired.',
68
+ '# TYPE deepline_absurd_runtime_stale_leases gauge',
69
+ `deepline_absurd_runtime_stale_leases${labels} ${input.queue.stale_leases}`,
70
+ '# HELP deepline_absurd_runtime_completed_runner_handoffs Completed detached-runner terminals awaiting scheduler finalization.',
71
+ '# TYPE deepline_absurd_runtime_completed_runner_handoffs gauge',
72
+ `deepline_absurd_runtime_completed_runner_handoffs${labels} ${input.queue.completed_runner_handoffs}`,
73
+ '# HELP deepline_absurd_runtime_running_without_lease Running attempts with no lease expiry.',
74
+ '# TYPE deepline_absurd_runtime_running_without_lease gauge',
75
+ `deepline_absurd_runtime_running_without_lease${labels} ${input.queue.running_without_lease}`,
76
+ '# HELP deepline_absurd_runtime_stale_heartbeats Running attempts without a recent heartbeat.',
77
+ '# TYPE deepline_absurd_runtime_stale_heartbeats gauge',
78
+ `deepline_absurd_runtime_stale_heartbeats${labels} ${input.queue.stale_heartbeats}`,
79
+ '# HELP deepline_absurd_runtime_play_run_dead_letters Failed Play Runs awaiting operator recovery.',
80
+ '# TYPE deepline_absurd_runtime_play_run_dead_letters gauge',
81
+ `deepline_absurd_runtime_play_run_dead_letters${labels} ${input.queue.play_run_dead_letters}`,
82
+ '# HELP deepline_absurd_runtime_scheduler_pool_clients Checked-out and idle scheduler pool clients.',
83
+ '# TYPE deepline_absurd_runtime_scheduler_pool_clients gauge',
84
+ `deepline_absurd_runtime_scheduler_pool_clients${labels} ${input.pool.totalCount}`,
85
+ '# HELP deepline_absurd_runtime_scheduler_pool_idle_clients Idle scheduler pool clients.',
86
+ '# TYPE deepline_absurd_runtime_scheduler_pool_idle_clients gauge',
87
+ `deepline_absurd_runtime_scheduler_pool_idle_clients${labels} ${input.pool.idleCount}`,
88
+ '# HELP deepline_absurd_runtime_scheduler_pool_waiters Pending scheduler pool acquires.',
89
+ '# TYPE deepline_absurd_runtime_scheduler_pool_waiters gauge',
90
+ `deepline_absurd_runtime_scheduler_pool_waiters${labels} ${input.pool.waitingCount}`,
91
+ '# HELP deepline_absurd_runtime_scheduler_capacity_rejections_total Deferred work due to PgBouncer or local pool capacity.',
92
+ '# TYPE deepline_absurd_runtime_scheduler_capacity_rejections_total counter',
93
+ `deepline_absurd_runtime_scheduler_capacity_rejections_total${labels} ${input.pool.capacityRejections}`,
94
+ '# HELP deepline_absurd_runtime_scheduler_saturation_rejections_total Local scheduler pool saturation rejections.',
95
+ '# TYPE deepline_absurd_runtime_scheduler_saturation_rejections_total counter',
96
+ `deepline_absurd_runtime_scheduler_saturation_rejections_total${labels} ${input.pool.saturationRejections}`,
97
+ '# HELP deepline_absurd_runtime_scheduler_breaker_rejections_total Database failure circuit rejections.',
98
+ '# TYPE deepline_absurd_runtime_scheduler_breaker_rejections_total counter',
99
+ `deepline_absurd_runtime_scheduler_breaker_rejections_total${labels} ${input.pool.breakerRejections}`,
100
+ renderRuntimeProcessResourceMetrics({
101
+ service: 'scheduler',
102
+ machine: input.workerName ?? 'local',
103
+ metrics: input.resources,
104
+ }),
105
+ '# HELP deepline_absurd_runtime_launch_reads_total Immutable launch lookups by callsite and resolved release.',
106
+ '# TYPE deepline_absurd_runtime_launch_reads_total counter',
107
+ '# HELP deepline_absurd_runtime_launch_read_duration_milliseconds_total Total immutable launch-read database time by callsite and resolved release.',
108
+ '# TYPE deepline_absurd_runtime_launch_read_duration_milliseconds_total counter',
109
+ ...input.launchReads.flatMap((metric) => {
110
+ const metricLabels = `${labels.slice(0, -1)},caller="${prometheusLabel(metric.caller)}",launch_release_id="${prometheusLabel(metric.releaseId)}"`;
111
+ return [
112
+ `deepline_absurd_runtime_launch_reads_total${metricLabels},outcome="found"} ${metric.found}`,
113
+ `deepline_absurd_runtime_launch_reads_total${metricLabels},outcome="missing"} ${metric.missing}`,
114
+ `deepline_absurd_runtime_launch_reads_total${metricLabels},outcome="error"} ${metric.errors}`,
115
+ `deepline_absurd_runtime_launch_read_duration_milliseconds_total${metricLabels}} ${metric.durationMsTotal}`,
116
+ ];
117
+ }),
118
+ '',
119
+ ].join('\n');
120
+ }
@@ -0,0 +1,76 @@
1
+ import {
2
+ normalizePlayRuntimeBackend,
3
+ type PlayRuntimeBackendId,
4
+ } from '../backend';
5
+ import { runtimeSandboxPlacementPoliciesForBackend } from '../runtime-sandbox-placement-policy';
6
+
7
+ /**
8
+ * Boot-time required-env contract for the Absurd runtime worker entrypoint.
9
+ *
10
+ * Extracted from `apps/absurd-runtime-worker/index.ts` so the invariant is
11
+ * importable (and testable) without launching the worker process.
12
+ *
13
+ * SECURITY INVARIANT: the Fly worker NEVER holds
14
+ * an auth signing key. It proves its active scheduler attempt to the launch-
15
+ * pinned Vercel deployment and receives a short-lived executor JWT; the gateway
16
+ * verifies that JWT against the deployment JWKS. So `BETTER_AUTH_SECRET` must
17
+ * never appear in this required set — a worker that demanded it would either
18
+ * refuse to boot without a key it must not have, or (worse) be handed one and
19
+ * start minting tokens locally, defeating the lane-isolation model.
20
+ * `tests/lib/plays/absurd-worker-required-env.test.ts` guards this.
21
+ *
22
+ * - `WORKFLOW_RUNTIME_POSTGRES`: the runtime scheduler Postgres URL.
23
+ * - provider credentials are selected by `DEEPLINE_PLAY_RUNNER_BACKEND`.
24
+ * - `DEEPLINE_INTERNAL_TOKEN`: authenticates the worker -> app runtime API
25
+ * (ledger, billing, sessions, and the executor-JWT gateways).
26
+ * - `DEEPLINE_RUNTIME_RECEIPT_GATEWAY_URL`: the only receipt and Runtime Sheet
27
+ * persistence path available to Daytona runners.
28
+ */
29
+ export const ABSURD_WORKER_REQUIRED_ENV = [
30
+ 'WORKFLOW_RUNTIME_POSTGRES',
31
+ 'DEEPLINE_INTERNAL_TOKEN',
32
+ 'DEEPLINE_RUNTIME_RECEIPT_GATEWAY_URL',
33
+ ] as const;
34
+
35
+ export function runtimeSandboxProviderCapabilities(
36
+ backend: PlayRuntimeBackendId,
37
+ ): Array<'daytona' | 'modal'> {
38
+ return [
39
+ ...new Set(
40
+ runtimeSandboxPlacementPoliciesForBackend(backend).flatMap(
41
+ (policy) => policy.cleanupProviders,
42
+ ),
43
+ ),
44
+ ];
45
+ }
46
+
47
+ /**
48
+ * A signing-key env that the Fly worker must never require at boot. The worker
49
+ * is signing-key-free by design; requiring any of these would violate the lane-
50
+ * isolation invariant above.
51
+ */
52
+ export const ABSURD_WORKER_FORBIDDEN_REQUIRED_ENV = [
53
+ 'BETTER_AUTH_SECRET',
54
+ ] as const;
55
+
56
+ export function assertAbsurdWorkerRequiredEnv(
57
+ env: Readonly<Record<string, string | undefined>> = process.env,
58
+ ): void {
59
+ const backend = normalizePlayRuntimeBackend(
60
+ env.DEEPLINE_PLAY_RUNNER_BACKEND?.trim() || 'daytona',
61
+ );
62
+ const providerRequired = [
63
+ ...new Set(
64
+ runtimeSandboxPlacementPoliciesForBackend(backend).flatMap(
65
+ (policy) => policy.requiredCredentialEnv,
66
+ ),
67
+ ),
68
+ ];
69
+ const missing = [...providerRequired, ...ABSURD_WORKER_REQUIRED_ENV].filter(
70
+ (name) => !env[name]?.trim(),
71
+ );
72
+ if (missing.length === 0) return;
73
+ throw new Error(
74
+ `Missing required absurd runtime worker configuration: ${missing.join(', ')}.`,
75
+ );
76
+ }
@@ -0,0 +1,476 @@
1
+ /**
2
+ * `absurd` play-runtime scheduler backend.
3
+ *
4
+ * Postgres-native durable execution: the vendored Absurd engine
5
+ * (`packages/absurd`) provides the queue/claim/park/resume control plane,
6
+ * while the battle-tested Postgres run-state store (`postgres.ts`) remains the
7
+ * source of truth for launch rows, attempts, receipts, signals, and terminal
8
+ * state. This module is greenfield and does not import legacy scheduler
9
+ * modules.
10
+ *
11
+ * Lifecycle:
12
+ * submit → ensure schemas + queues → insert launch row (postgres) → spawn an
13
+ * absurd task (idempotencyKey=runId, orgKey=orgId) on `runs`.
14
+ * Persist the absurd task id
15
+ * on the run row so a later cancel can target it.
16
+ * observe/result → reuse the postgres LISTEN/NOTIFY run handle.
17
+ * cancel → postgres terminal cancel intent + absurd cancelTask.
18
+ * signal → durable signal row (authoritative payload) + absurd emitEvent
19
+ * (the wakeup only; payload is re-read from the signal row).
20
+ */
21
+ import { recordPerfTrace } from '../perf-trace';
22
+ import { CTX_RUN_PLAY_INLINE_ONLY } from '../child-execution-strategy';
23
+ import {
24
+ defaultRuntimeSandboxReconciliation,
25
+ runtimeSandboxDeleteSucceeded,
26
+ runtimeSandboxRefIdentityKey,
27
+ runtimeSandboxRefFromResource,
28
+ type RuntimeSandboxRef,
29
+ } from '../runner-backends/runtime-sandbox-reconciliation';
30
+ import {
31
+ PLAY_SCHEDULER_BACKENDS,
32
+ type PlaySchedulerBackend,
33
+ type PlaySchedulerRunHandle,
34
+ type PlaySchedulerSubmitInput,
35
+ } from '../scheduler-backend';
36
+ import {
37
+ postgresSchedulerRunHandle,
38
+ readPostgresSchedulerLaunch,
39
+ readPostgresSchedulerAbsurdTaskId,
40
+ readPostgresSchedulerRuntimeResourcesForRun,
41
+ recordPostgresSchedulerSignal,
42
+ } from './postgres';
43
+ import {
44
+ createPlayRunAdmissionJob,
45
+ createPostgresPlayRunAdmissionPorts,
46
+ } from '../play-runs/admission';
47
+ import { withRuntimeSchedulerClient } from './postgres-pool';
48
+ import { withRuntimeSchedulerSubmitAdmission } from './submit-admission';
49
+ import {
50
+ ABSURD_PLAY_RUN_MAX_ATTEMPTS,
51
+ ABSURD_PLAY_RUN_RETRY_STRATEGY,
52
+ ABSURD_DAYTONA_SANDBOX_CLEANUP_TASK,
53
+ absurdIntegrationEventName,
54
+ absurdQueueNameForRelease,
55
+ absurdReleaseIdForLaunch,
56
+ absurdReleaseIdForSuffix,
57
+ createAbsurdRuntimeClient,
58
+ ensureAbsurdRuntimeReady,
59
+ normalizeAbsurdSchedulerOptions,
60
+ resolveAbsurdPoolOptions,
61
+ type AbsurdDaytonaSandboxCleanupTaskParams,
62
+ type AbsurdSchedulerOptions,
63
+ } from './absurd-shared';
64
+
65
+ export type AbsurdSchedulerBackendOptions = AbsurdSchedulerOptions & {
66
+ /**
67
+ * Explicit per-request queue suffix, resolved in `lazy.ts` from the
68
+ * per-request scheduler schema. When absent, queue names fall back to the
69
+ * process env suffix (Fly worker / dev:v2) or base names (unit tests / prod).
70
+ * This is what makes the shared hosted preview app enqueue onto the SAME
71
+ * suffixed queues the isolated Fly worker drains.
72
+ */
73
+ queueSuffix?: string | null;
74
+ };
75
+
76
+ function recordAbsurdSubmitPhase(
77
+ input: Pick<PlaySchedulerSubmitInput, 'runId' | 'playName' | 'graphHash'>,
78
+ phase: string,
79
+ startedAt: number,
80
+ extra: Record<string, unknown> = {},
81
+ ): void {
82
+ recordPerfTrace({
83
+ source: 'server',
84
+ runId: input.runId,
85
+ playName: input.playName,
86
+ graphHash: input.graphHash,
87
+ phase: `server.absurd_${phase}`,
88
+ ms: Date.now() - startedAt,
89
+ extra,
90
+ });
91
+ }
92
+
93
+ function absurdRunHandle(input: {
94
+ runId: string;
95
+ schedulerOptions: AbsurdSchedulerOptions;
96
+ queueSuffix?: string | null;
97
+ releaseId?: string | null;
98
+ initialState?: Record<string, unknown> | null;
99
+ }): PlaySchedulerRunHandle & { initialState?: Record<string, unknown> } {
100
+ const schedulerOptions = input.schedulerOptions;
101
+ const delegate = postgresSchedulerRunHandle(input.runId, {
102
+ ...schedulerOptions,
103
+ // Release lanes can contain workers that predate the terminal-notify
104
+ // contract. Until the release registry versions this capability, polling
105
+ // every second is the only safe completion bound for attached runs.
106
+ // TODO(runtime-terminal-notify): use a low-risk two-phase rollout. First,
107
+ // enable notifications only as an additive wake hint while retaining the
108
+ // one-second safety poll for mixed-version workers. After every pre-notify
109
+ // lane and suspended run has drained, long-lived non-Vercel listeners may
110
+ // move to the sparse safety cadence. Vercel must keep polling unless a
111
+ // fixed-cardinality notification relay owns the direct LISTEN sessions;
112
+ // PostgreSQL notifications are never the durable source of truth.
113
+ terminalNotifications: false,
114
+ });
115
+ const poolOptions = resolveAbsurdPoolOptions(schedulerOptions.url);
116
+
117
+ const initialStateSchema =
118
+ typeof input.initialState?.schedulerSchema === 'string' &&
119
+ input.initialState.schedulerSchema.trim()
120
+ ? input.initialState.schedulerSchema.trim()
121
+ : null;
122
+ const effectiveOptions: AbsurdSchedulerOptions = initialStateSchema
123
+ ? { schema: initialStateSchema }
124
+ : schedulerOptions;
125
+
126
+ // The run rides ONE release lane queue for its whole life. Prefer the explicit
127
+ // release id (from the launch envelope). Fall back to the suffix-derived
128
+ // release so direct backend construction in unit tests (no releaseId, no
129
+ // suffix, env cleared) stays on the base `runs` queue and worker/dev:v2 keep
130
+ // their suffixed queues.
131
+ const releaseId =
132
+ input.releaseId?.trim() || absurdReleaseIdForSuffix(input.queueSuffix);
133
+ const runsQueue = absurdQueueNameForRelease(releaseId);
134
+
135
+ const cancelAbsurdTask = async () => {
136
+ const taskId = await withRuntimeSchedulerClient(poolOptions, (client) =>
137
+ readPostgresSchedulerAbsurdTaskId(client, input.runId, effectiveOptions),
138
+ );
139
+ if (!taskId) return;
140
+ const absurd = createAbsurdRuntimeClient(poolOptions, runsQueue);
141
+ await absurd.cancelTask(taskId, runsQueue);
142
+ };
143
+
144
+ const cleanupPersistedRuntimeSandboxes = async () => {
145
+ const resources = await withRuntimeSchedulerClient(poolOptions, (client) =>
146
+ readPostgresSchedulerRuntimeResourcesForRun(
147
+ client,
148
+ { runId: input.runId },
149
+ effectiveOptions,
150
+ ),
151
+ );
152
+ const productionRefs = new Map<string, RuntimeSandboxRef>();
153
+ const workerOwnedRefs = new Map<string, RuntimeSandboxRef>();
154
+ for (const resource of resources) {
155
+ if (
156
+ !resource ||
157
+ typeof resource !== 'object' ||
158
+ Array.isArray(resource)
159
+ ) {
160
+ continue;
161
+ }
162
+ const record = resource as Record<string, unknown>;
163
+ const ref = runtimeSandboxRefFromResource(record);
164
+ if (!ref) continue;
165
+ const refKey = runtimeSandboxRefIdentityKey(ref);
166
+ // Modal credentials and all preview provider credentials are worker-only.
167
+ // This explicit task keeps deletion on the owning release lane. Legacy
168
+ // Daytona records predate runtimeEnvironment, so retain their marker.
169
+ const runtimeEnvironment =
170
+ record.runtimeEnvironment === 'preview' ||
171
+ record.daytonaEnvironment === 'preview'
172
+ ? 'preview'
173
+ : 'production';
174
+ if (runtimeEnvironment === 'preview' || ref.provider === 'modal') {
175
+ workerOwnedRefs.set(refKey, ref);
176
+ continue;
177
+ }
178
+ productionRefs.set(refKey, ref);
179
+ }
180
+ if (workerOwnedRefs.size > 0) {
181
+ const absurd = createAbsurdRuntimeClient(poolOptions, runsQueue);
182
+ await Promise.all(
183
+ [...workerOwnedRefs.values()].map((runtimeSandboxRef) => {
184
+ // sandboxId remains in the payload for workers deployed before the
185
+ // provider-scoped cleanup cutover. New workers use the versioned ref.
186
+ const params: AbsurdDaytonaSandboxCleanupTaskParams & {
187
+ runtimeSandboxRef: RuntimeSandboxRef;
188
+ } = {
189
+ runId: input.runId,
190
+ sandboxId: runtimeSandboxRef.resourceId,
191
+ runtimeSandboxRef,
192
+ };
193
+ return absurd.spawn(ABSURD_DAYTONA_SANDBOX_CLEANUP_TASK, params, {
194
+ queue: runsQueue,
195
+ idempotencyKey: `sandbox-cleanup:${input.runId}:${runtimeSandboxRefIdentityKey(runtimeSandboxRef)}`,
196
+ maxAttempts: ABSURD_PLAY_RUN_MAX_ATTEMPTS,
197
+ retryStrategy: ABSURD_PLAY_RUN_RETRY_STRATEGY,
198
+ });
199
+ }),
200
+ );
201
+ }
202
+ if (productionRefs.size === 0) return;
203
+ const cleanupResults = await Promise.allSettled(
204
+ [...productionRefs.values()].map(async (ref) => {
205
+ const outcome = await defaultRuntimeSandboxReconciliation.delete(ref);
206
+ if (!runtimeSandboxDeleteSucceeded(outcome)) {
207
+ throw new Error(
208
+ `${ref.provider} sandbox cleanup did not delete ${ref.resourceId}.`,
209
+ );
210
+ }
211
+ }),
212
+ );
213
+ for (const result of cleanupResults) {
214
+ if (result.status === 'rejected') {
215
+ console.warn('[absurd.runtime_sandbox_cleanup_failed]', {
216
+ runId: input.runId,
217
+ error:
218
+ result.reason instanceof Error
219
+ ? result.reason.message
220
+ : String(result.reason),
221
+ });
222
+ }
223
+ }
224
+ };
225
+
226
+ return {
227
+ ...delegate,
228
+ runId: input.runId,
229
+ initialState: input.initialState ?? undefined,
230
+ cancel: async () => {
231
+ const cleanup = cleanupPersistedRuntimeSandboxes();
232
+ await Promise.all([delegate.cancel(), cancelAbsurdTask(), cleanup]);
233
+ },
234
+ signal: async (payload) => {
235
+ if (payload.kind === 'cancel') {
236
+ const cleanup = cleanupPersistedRuntimeSandboxes();
237
+ await Promise.all([
238
+ delegate.signal(payload),
239
+ cancelAbsurdTask(),
240
+ cleanup,
241
+ ]);
242
+ return;
243
+ }
244
+ if (payload.kind !== 'integration_event' || !payload.eventKey) {
245
+ throw new Error(
246
+ `absurd scheduler signal requires kind=integration_event with an eventKey (got ${payload.kind}).`,
247
+ );
248
+ }
249
+ const eventKey = payload.eventKey;
250
+ const data =
251
+ payload.data &&
252
+ typeof payload.data === 'object' &&
253
+ !Array.isArray(payload.data)
254
+ ? { ...(payload.data as Record<string, unknown>) }
255
+ : {};
256
+ const boundaryId =
257
+ typeof data.boundaryId === 'string' && data.boundaryId.trim()
258
+ ? data.boundaryId.trim()
259
+ : null;
260
+ if (boundaryId) {
261
+ delete data.boundaryId;
262
+ }
263
+ const eventPayload = { eventKey, boundaryId, data };
264
+
265
+ // Durable signal row is authoritative: the worker claims it for the real
266
+ // payload on wake. It is written BEFORE the absurd event so a fast wake
267
+ // never races ahead of the payload.
268
+ await withRuntimeSchedulerClient(poolOptions, (client) =>
269
+ recordPostgresSchedulerSignal(
270
+ client,
271
+ { runId: input.runId, eventKey, boundaryId, payload: eventPayload },
272
+ effectiveOptions,
273
+ ),
274
+ );
275
+
276
+ // The absurd event is only the wakeup. Scoped by runId so it wakes just
277
+ // this run on the shared queue.
278
+ const absurd = createAbsurdRuntimeClient(poolOptions, runsQueue);
279
+ const eventName = absurdIntegrationEventName(input.runId, eventKey);
280
+ await absurd.emitEvent(eventName, null, runsQueue);
281
+ console.info('[absurd-runtime.signal] event_emitted', {
282
+ runId: input.runId,
283
+ eventKey,
284
+ boundaryId,
285
+ releaseId,
286
+ queue: runsQueue,
287
+ schema: effectiveOptions.schema ?? null,
288
+ });
289
+ },
290
+ };
291
+ }
292
+
293
+ export function createAbsurdSchedulerBackend(
294
+ schedulerOptions: AbsurdSchedulerBackendOptions = {},
295
+ ): PlaySchedulerBackend {
296
+ const normalizedSchedulerOptions =
297
+ normalizeAbsurdSchedulerOptions(schedulerOptions);
298
+ const queueSuffix = schedulerOptions.queueSuffix?.trim() || null;
299
+ return {
300
+ id: PLAY_SCHEDULER_BACKENDS.absurd,
301
+ async submit(input) {
302
+ const legacyParentRunId = (
303
+ input as PlaySchedulerSubmitInput & {
304
+ playCallGovernance?: { parentRunId?: unknown } | null;
305
+ }
306
+ ).playCallGovernance?.parentRunId;
307
+ if (typeof legacyParentRunId === 'string' && legacyParentRunId.trim()) {
308
+ throw new Error(
309
+ `${CTX_RUN_PLAY_INLINE_ONLY}: scheduled ctx.runPlay children are unsupported. ` +
310
+ 'ctx.runPlay composes a resolved scalar child inline; submit independent work as a top-level play.',
311
+ );
312
+ }
313
+ const submitStartedAt = Date.now();
314
+ const poolOptions = resolveAbsurdPoolOptions(
315
+ normalizedSchedulerOptions.url,
316
+ );
317
+ // The run pins its release lane at launch: prefer the release id stamped
318
+ // in the envelope; fall back to the suffix-derived release for pre-release
319
+ // launch rows and unit tests (enforce-when-exists / allow-when-absent).
320
+ const releaseId = absurdReleaseIdForLaunch({
321
+ absurdReleaseId: input.absurdReleaseId ?? null,
322
+ });
323
+ const queue = absurdQueueNameForRelease(releaseId);
324
+ // The launch row and the actual play-run task are one Postgres commit.
325
+ // Returning from submit therefore means the durable work is runnable;
326
+ // there is no outbox, dispatcher, or second admission boundary.
327
+ let submissionQueue = queue;
328
+ const admissionParams = {
329
+ schedulerUrl: poolOptions.url,
330
+ schedulerSchema: normalizedSchedulerOptions.schema,
331
+ };
332
+ let spawn = await withRuntimeSchedulerSubmitAdmission(
333
+ admissionParams,
334
+ async (permit) => {
335
+ recordAbsurdSubmitPhase(input, 'submit_admitted', submitStartedAt, {
336
+ queueDepth: permit.queueDepth,
337
+ waitMs: permit.waitMs,
338
+ });
339
+ await ensureAbsurdRuntimeReady(
340
+ poolOptions,
341
+ normalizedSchedulerOptions,
342
+ queueSuffix,
343
+ releaseId,
344
+ );
345
+ recordAbsurdSubmitPhase(input, 'schema_ready', submitStartedAt);
346
+
347
+ // Loud, structured submit log: the #1 way an absurd run silently hangs
348
+ // is an app→worker queue-name mismatch (the shared preview app
349
+ // enqueuing on a queue no Fly worker drains).
350
+ console.info('[absurd-runtime.submit] enqueue', {
351
+ runId: input.runId,
352
+ orgId: input.orgId,
353
+ queue,
354
+ releaseId,
355
+ schedulerSchema: normalizedSchedulerOptions.schema ?? null,
356
+ queueSuffix: queueSuffix ?? null,
357
+ });
358
+ return withRuntimeSchedulerClient(
359
+ poolOptions,
360
+ async (client) =>
361
+ (
362
+ await createPlayRunAdmissionJob(
363
+ createPostgresPlayRunAdmissionPorts({
364
+ client,
365
+ schema: normalizedSchedulerOptions.schema,
366
+ }),
367
+ ).admit({
368
+ launch: input,
369
+ queueName: queue,
370
+ })
371
+ ).receipt,
372
+ {
373
+ runId: input.runId,
374
+ phase: 'launch_persist_and_enqueue',
375
+ },
376
+ );
377
+ },
378
+ );
379
+ if (spawn.taskRecoveryRequired) {
380
+ const existingLaunch = await withRuntimeSchedulerClient(
381
+ poolOptions,
382
+ (client) =>
383
+ readPostgresSchedulerLaunch(
384
+ client,
385
+ input.runId,
386
+ normalizedSchedulerOptions,
387
+ { caller: 'scheduler_submit_recovery' },
388
+ ),
389
+ );
390
+ if (!existingLaunch) {
391
+ throw new Error(
392
+ `Play run "${input.runId}" requires task recovery but its launch row is missing.`,
393
+ );
394
+ }
395
+ const recoveryReleaseId = absurdReleaseIdForLaunch(existingLaunch);
396
+ submissionQueue = absurdQueueNameForRelease(recoveryReleaseId);
397
+ spawn = await withRuntimeSchedulerSubmitAdmission(
398
+ admissionParams,
399
+ async () => {
400
+ await ensureAbsurdRuntimeReady(
401
+ poolOptions,
402
+ normalizedSchedulerOptions,
403
+ queueSuffix,
404
+ recoveryReleaseId,
405
+ );
406
+ return withRuntimeSchedulerClient(
407
+ poolOptions,
408
+ async (client) =>
409
+ (
410
+ await createPlayRunAdmissionJob(
411
+ createPostgresPlayRunAdmissionPorts({
412
+ client,
413
+ schema: normalizedSchedulerOptions.schema,
414
+ }),
415
+ ).admit({
416
+ launch: input,
417
+ queueName: submissionQueue,
418
+ recoverExistingTask: true,
419
+ })
420
+ ).receipt,
421
+ {
422
+ runId: input.runId,
423
+ phase: 'launch_recovery_persist_and_enqueue',
424
+ },
425
+ );
426
+ },
427
+ );
428
+ if (!spawn.taskId) {
429
+ throw new Error(
430
+ `Play run "${input.runId}" task recovery did not create an Absurd task.`,
431
+ );
432
+ }
433
+ }
434
+ recordAbsurdSubmitPhase(input, 'spawned', submitStartedAt, {
435
+ created: spawn.runCreated,
436
+ taskCreated: spawn.taskCreated,
437
+ queue: submissionQueue,
438
+ });
439
+
440
+ return absurdRunHandle({
441
+ runId: input.runId,
442
+ schedulerOptions: normalizedSchedulerOptions,
443
+ queueSuffix,
444
+ releaseId,
445
+ initialState: {
446
+ scheduler: PLAY_SCHEDULER_BACKENDS.absurd,
447
+ schedulerSchema: normalizedSchedulerOptions.schema ?? null,
448
+ absurdReleaseId: releaseId,
449
+ absurdTaskId: spawn.taskId,
450
+ runCreated: spawn.runCreated,
451
+ taskCreated: spawn.taskCreated,
452
+ },
453
+ });
454
+ },
455
+ async attach(runId, options) {
456
+ // The initialState may carry the run's stamped release id (from a prior
457
+ // submit's handle or a caller that read the launch row); prefer it so the
458
+ // cancel/signal wakeup lands on the run's lane, not this process's default.
459
+ const initialStateReleaseId =
460
+ typeof options?.initialState?.absurdReleaseId === 'string' &&
461
+ options.initialState.absurdReleaseId.trim()
462
+ ? options.initialState.absurdReleaseId.trim()
463
+ : null;
464
+ return absurdRunHandle({
465
+ runId,
466
+ schedulerOptions: normalizedSchedulerOptions,
467
+ queueSuffix,
468
+ releaseId: initialStateReleaseId,
469
+ initialState: options?.initialState ?? null,
470
+ });
471
+ },
472
+ };
473
+ }
474
+
475
+ export const absurdSchedulerBackend: PlaySchedulerBackend =
476
+ createAbsurdSchedulerBackend();