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
@@ -4,9 +4,9 @@
4
4
  * Static analysis turns top-level play statements it cannot attribute to a
5
5
  * structured step into `run_javascript` glue substeps whose alias is a
6
6
  * machine-generated source line range (`lines_<startLine>_<endLine>`, built in
7
- * `src/lib/plays/static-analysis.ts` → `createCodeStageForStatements`). The
7
+ * `apps/deepline-api/src/lib/plays/static-analysis.ts` → `createCodeStageForStatements`). The
8
8
  * execution plan / runtime node ids namespace every substep by its type
9
- * (`getStaticSubstepNodeId` in `src/lib/plays/step-progress.ts`), so glue nodes are ALWAYS
9
+ * (`getStaticSubstepNodeId` in `packages/play-runtime/step-progress.ts`), so glue nodes are ALWAYS
10
10
  * `run_javascript:<alias>` on the wire (ledger stepsById, snapshot
11
11
  * nodeStates, `play.step.*` stream events).
12
12
  *
@@ -0,0 +1,189 @@
1
+ /**
2
+ * The Absurd release-lane retirement gate, as dependency-free pure logic.
3
+ *
4
+ * This lives in its own module because three very different processes must
5
+ * reach exactly the same verdict and none of them may drag the others'
6
+ * dependencies in:
7
+ *
8
+ * - the Next.js app (`apps/deepline-api/src/lib/plays/runtime-lanes.ts`, the admin and internal
9
+ * lane endpoints), which also talks to Convex;
10
+ * - `scripts/fly-absurd-lane.ts` retire, run by the release controller; and
11
+ * - `apps/absurd-release-scaler/index.ts`, which owns retirement of every lane
12
+ * the release controller handed over, and whose Fly image does not contain
13
+ * `packages/convex/`.
14
+ *
15
+ * The gate clears two ways:
16
+ *
17
+ * 1. **Empty.** No non-terminal task on the lane's queue and no non-terminal
18
+ * run row referencing its release id.
19
+ * 2. **Adopted parked (lane handoff).** The lane has been marked not claiming,
20
+ * nothing on it is claimable or running, and every remaining non-terminal
21
+ * run is parked in a durable wait the newest lane adopts.
22
+ *
23
+ * Anything else is blocked, and `blockedBy` names which of the two halves is
24
+ * responsible so an operator is not left guessing at a bare depth count.
25
+ */
26
+
27
+ /**
28
+ * The subset of a lane's depth the gate reads.
29
+ *
30
+ * Every field is optional because the gate is also evaluated against a lane
31
+ * view that crossed the wire from a control plane which may be older than its
32
+ * caller: the release-aware scaler is deployed from the same release as the
33
+ * app, but a scaler image can outlive the app deployment it polls. A fact that
34
+ * did not arrive is never guessed — see `adoption-facts-unavailable`.
35
+ */
36
+ export type LaneRetirementGateFacts = {
37
+ /** Non-terminal tasks on `absurd.t_<queue>`. */
38
+ queuedTasks?: number;
39
+ claimableTasks?: number;
40
+ runningTasks?: number;
41
+ /** Non-terminal `runs` rows whose launch envelope pins this release id. */
42
+ nonTerminalRuns?: number;
43
+ /** Subset of `nonTerminalRuns` parked in a wait the newest lane adopts. */
44
+ adoptableParkedRuns?: number;
45
+ /** Whether this lane still claims work off its own queue. */
46
+ claiming?: boolean;
47
+ /** `queuedTasks === 0 && nonTerminalRuns === 0`. */
48
+ empty?: boolean;
49
+ /** `claimableTasks === 0 && runningTasks === 0 && nonTerminalRuns === adoptableParkedRuns`. */
50
+ emptyExceptAdoptableParked?: boolean;
51
+ };
52
+
53
+ export type LaneRetirementGateBasis = 'empty' | 'adopted-parked' | 'blocked';
54
+
55
+ /**
56
+ * Why a blocked lane is blocked. This is the operator-facing half of the gate:
57
+ * each value maps to exactly one remediation.
58
+ */
59
+ export type LaneRetirementBlockedReason =
60
+ /** Not blocked. */
61
+ | 'none'
62
+ /** Something on this lane is claimable or running right now. Wait. */
63
+ | 'executable-work'
64
+ /**
65
+ * The lane holds nothing but adoptable parked waits, and the ONLY thing
66
+ * keeping it alive is that its claiming switch was never flipped. The lane
67
+ * cannot flip it itself, so without an external write this lane is immortal.
68
+ */
69
+ | 'still-claiming'
70
+ /**
71
+ * Non-terminal runs this lane can no longer execute and no other lane can
72
+ * adopt: a `detached_runner` park whose sandbox is gone, or a run row with no
73
+ * engine task at all. Nothing will ever wake these; they need an explicit,
74
+ * evidence-gated terminal transition.
75
+ */
76
+ | 'unadoptable-non-terminal-runs'
77
+ /**
78
+ * The caller's lane view predates the adoption fields. The gate refuses to
79
+ * infer adoption from absent evidence and falls back to the strict `empty`
80
+ * half only.
81
+ */
82
+ | 'adoption-facts-unavailable';
83
+
84
+ export type LaneRetirementGateResult = {
85
+ ok: boolean;
86
+ basis: LaneRetirementGateBasis;
87
+ blockedBy: LaneRetirementBlockedReason;
88
+ };
89
+
90
+ /**
91
+ * Evaluate the retirement gate.
92
+ *
93
+ * Deliberately conservative in one direction only: it never clears a lane on a
94
+ * fact it did not receive. It is safe for the caller to retire on `ok`, because
95
+ * retirement deletes Machines and flips the registry row; it does not drop the
96
+ * queue tables an adopting lane still claims from.
97
+ */
98
+ export function laneRetirementGate(
99
+ depth: LaneRetirementGateFacts,
100
+ ): LaneRetirementGateResult {
101
+ if (depth.empty === true) {
102
+ return { ok: true, basis: 'empty', blockedBy: 'none' };
103
+ }
104
+ if (
105
+ typeof depth.claiming !== 'boolean' ||
106
+ typeof depth.emptyExceptAdoptableParked !== 'boolean' ||
107
+ typeof depth.adoptableParkedRuns !== 'number'
108
+ ) {
109
+ return {
110
+ ok: false,
111
+ basis: 'blocked',
112
+ blockedBy: 'adoption-facts-unavailable',
113
+ };
114
+ }
115
+ if (!depth.claiming && depth.emptyExceptAdoptableParked) {
116
+ return { ok: true, basis: 'adopted-parked', blockedBy: 'none' };
117
+ }
118
+ const executable =
119
+ (depth.claimableTasks ?? 0) > 0 || (depth.runningTasks ?? 0) > 0;
120
+ if (executable) {
121
+ return { ok: false, basis: 'blocked', blockedBy: 'executable-work' };
122
+ }
123
+ if (depth.claiming && depth.emptyExceptAdoptableParked) {
124
+ return { ok: false, basis: 'blocked', blockedBy: 'still-claiming' };
125
+ }
126
+ return {
127
+ ok: false,
128
+ basis: 'blocked',
129
+ blockedBy: 'unadoptable-non-terminal-runs',
130
+ };
131
+ }
132
+
133
+ /**
134
+ * The one operator-actionable sentence for a blocked lane.
135
+ *
136
+ * A depth count alone ("11 queued") has repeatedly sent operators looking for
137
+ * live work that is not there. Each reason below has exactly one next step.
138
+ */
139
+ export function laneRetirementRemediation(
140
+ result: LaneRetirementGateResult,
141
+ ): string {
142
+ switch (result.blockedBy) {
143
+ case 'none':
144
+ return result.basis === 'adopted-parked'
145
+ ? 'Retirable: nothing here is claimable or running and every remaining run is a parked wait the newest lane adopts.'
146
+ : 'Retirable: this lane holds no non-terminal task and no non-terminal run.';
147
+ case 'executable-work':
148
+ return 'Wait. Work on this lane is claimable or running right now; the scaler keeps a version-matched machine for it.';
149
+ case 'still-claiming':
150
+ return 'Demote the lane. It holds only adoptable parked waits; the newest lane cannot adopt them until this lane stops claiming (lane handoff). The release-aware scaler converges this, or run `bun scripts/fly-absurd-lane.ts stop-claiming --release <id>`.';
151
+ case 'unadoptable-non-terminal-runs':
152
+ return 'Inspect the runs. This lane holds non-terminal runs it can no longer execute and no lane can adopt. Run `deepline-admin runtime stranded scan --release <id> --environment production --json`, then remediate the reviewed cohort with `runtime stranded plan` / `runtime stranded resolve --dry-run`.';
153
+ case 'adoption-facts-unavailable':
154
+ return 'The lane view did not carry the lane handoff adoption fields, so only the strict empty gate was evaluated. Re-read the lane against a control plane from this release.';
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Should this lane's claiming switch be converged to `false`?
160
+ *
161
+ * The switch is written exactly once, by the release controller, as a
162
+ * `reclamation` effect whose failure is explicitly tolerated — a failed
163
+ * `stop-prior-lane-claiming` is logged and the release still SUCCEEDS. Absence
164
+ * of the control row reads as "claiming", so a lost write leaves a demoted lane
165
+ * claiming forever. With no machines the lane cannot make progress, and with
166
+ * `claiming` true the newest lane may not adopt it: a permanently unclaimable
167
+ * steady state.
168
+ *
169
+ * This predicate is intentionally narrow. It fires only for a lane whose gate
170
+ * is blocked by the lost write and nothing else, so it can never demote a lane
171
+ * that is still doing something, and it cannot fight `abort_retire` (which
172
+ * re-arms claiming for a lane that has real work, and therefore is not blocked
173
+ * by `still-claiming`).
174
+ */
175
+ export function shouldConvergeLaneToNotClaiming(lane: {
176
+ active?: boolean;
177
+ status?: string;
178
+ queueDepth?: LaneRetirementGateFacts;
179
+ }): boolean {
180
+ if (lane.active !== false) return false;
181
+ if (lane.status !== 'draining' && lane.status !== 'retiring') return false;
182
+ const depth = lane.queueDepth;
183
+ if (!depth) return false;
184
+ if ((depth.claimableTasks ?? 0) > 0 || (depth.runningTasks ?? 0) > 0) {
185
+ return false;
186
+ }
187
+ if ((depth.adoptableParkedRuns ?? 0) <= 0) return false;
188
+ return laneRetirementGate(depth).blockedBy === 'still-claiming';
189
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Queue-admission policy is about *how the run was invoked*, not whether its
3
+ * artifact is published, ad-hoc, or draft. A manual API run can launch a
4
+ * published artifact, while a webhook can launch a draft artifact.
5
+ */
6
+ export type PlayLaunchTriggerSource =
7
+ | 'api'
8
+ | 'webhook'
9
+ | 'cron'
10
+ | 'sql_listener'
11
+ | 'async_child';
12
+
13
+ export type PlayLaunchQueuePolicy = {
14
+ triggerSource: PlayLaunchTriggerSource;
15
+ /**
16
+ * Relative ordering within one scheduler queue. This only decides which
17
+ * runnable run gets a newly available worker/sandbox slot; it never
18
+ * preempts a running customer sandbox or bypasses cross-org fairness.
19
+ */
20
+ priority: number;
21
+ /**
22
+ * Absurd's maximum time waiting to be claimed, in seconds. `null` means the
23
+ * accepted launch is allowed to wait durably for capacity.
24
+ */
25
+ maxDelaySeconds: number | null;
26
+ /**
27
+ * Maximum total time an accepted run may wait for a live sandbox slot. This
28
+ * is evaluated by the worker after a claim, where Absurd's `max_delay`
29
+ * cannot help. Zero gives an interactive caller an immediate, typed
30
+ * capacity-full result instead of a stuck watch.
31
+ */
32
+ sandboxCapacityMaxWaitSeconds: number | null;
33
+ };
34
+
35
+ export function shouldTerminalizeSandboxCapacityRejection(input: {
36
+ triggerSource?: PlayLaunchTriggerSource | null;
37
+ submittedAtMs?: number | null;
38
+ nowMs?: number;
39
+ }): boolean {
40
+ const policy = resolvePlayLaunchQueuePolicy(input.triggerSource);
41
+ const maxWaitSeconds = policy.sandboxCapacityMaxWaitSeconds;
42
+ if (maxWaitSeconds === 0) return true;
43
+ if (maxWaitSeconds === null) return false;
44
+ const submittedAtMs = input.submittedAtMs;
45
+ if (
46
+ typeof submittedAtMs !== 'number' ||
47
+ !Number.isFinite(submittedAtMs) ||
48
+ submittedAtMs <= 0
49
+ ) {
50
+ // Old launch rows did not persist submit time. Preserve their historical
51
+ // durable behavior rather than making an age guess at execution time.
52
+ return false;
53
+ }
54
+ return (input.nowMs ?? Date.now()) >= submittedAtMs + maxWaitSeconds * 1_000;
55
+ }
56
+
57
+ /**
58
+ * Resolve the single queue-admission policy for every top-level play launch.
59
+ *
60
+ * Missing source is deliberately manual/API for backwards-compatible direct
61
+ * callers of `startPlayRunExecution`; webhook and cron callers must opt into
62
+ * their durable trigger source explicitly.
63
+ */
64
+ export function resolvePlayLaunchQueuePolicy(
65
+ triggerSource?: PlayLaunchTriggerSource | null,
66
+ ): PlayLaunchQueuePolicy {
67
+ switch (triggerSource ?? 'api') {
68
+ case 'api':
69
+ return {
70
+ triggerSource: 'api',
71
+ // A person waiting in the CLI/UI should get the next slot in their
72
+ // own organization rather than sitting behind that org's automation.
73
+ // The bounded deadline gives the caller a typed terminal outcome
74
+ // instead of an indefinite watch.
75
+ priority: 100,
76
+ maxDelaySeconds: 10,
77
+ sandboxCapacityMaxWaitSeconds: 0,
78
+ };
79
+ case 'webhook':
80
+ return {
81
+ triggerSource: 'webhook',
82
+ priority: 0,
83
+ // A 202 webhook response is a durable delivery promise. Capacity is
84
+ // not a delivery failure: retain it until it executes, is explicitly
85
+ // cancelled, or an operator terminalizes it. Interactive API launches
86
+ // remain separately bounded above.
87
+ maxDelaySeconds: null,
88
+ sandboxCapacityMaxWaitSeconds: null,
89
+ };
90
+ case 'cron':
91
+ return {
92
+ triggerSource: 'cron',
93
+ priority: -10,
94
+ maxDelaySeconds: 30 * 60,
95
+ sandboxCapacityMaxWaitSeconds: 30 * 60,
96
+ };
97
+ case 'sql_listener':
98
+ return {
99
+ triggerSource: 'sql_listener',
100
+ priority: -10,
101
+ maxDelaySeconds: 30 * 60,
102
+ sandboxCapacityMaxWaitSeconds: 30 * 60,
103
+ };
104
+ case 'async_child':
105
+ return {
106
+ triggerSource: 'async_child',
107
+ priority: 0,
108
+ maxDelaySeconds: null,
109
+ sandboxCapacityMaxWaitSeconds: null,
110
+ };
111
+ }
112
+ }
@@ -10,6 +10,14 @@ export function cloneMapFrame(frame: MapExecutionFrame): MapExecutionFrame {
10
10
  ...frame,
11
11
  completedRowKeys: [...frame.completedRowKeys],
12
12
  pendingRowKeys: [...frame.pendingRowKeys],
13
+ ...(frame.suspendedInputRows
14
+ ? {
15
+ suspendedInputRows: frame.suspendedInputRows.map((row) => ({
16
+ inputIndex: row.inputIndex,
17
+ data: { ...row.data },
18
+ })),
19
+ }
20
+ : {}),
13
21
  };
14
22
  }
15
23
 
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Structured per-run perf trace for play execution.
3
+ *
4
+ * Each call emits a single line JSON object prefixed with `[perf-trace]` to
5
+ * stdout. Server-side callers (Next.js dev server) ALSO append the same JSON
6
+ * object to `logs/perf-<runId>.jsonl` so post-mortem aggregation works even
7
+ * when stdout has been multiplexed across many runs.
8
+ *
9
+ * This is intentionally additive — it does NOT replace the existing
10
+ * `[perf][plays.start_run]` console.info lines that other tooling parses.
11
+ *
12
+ * Benchmark trace map:
13
+ * - `apps/deepline-api/src/app/api/v2/plays/run/route.ts` records start-route and watch/terminal
14
+ * spans, including the old "terminal wait" bucket.
15
+ * - `packages/play-runtime/scheduler-backends/*` and
16
+ * the submit path records scheduler submit
17
+ * and workflow-create spans.
18
+ * - the runner records execution,
19
+ * dataset, ledger, billing, and terminalization spans.
20
+ * - `scripts/analyze-v2-sdk-cli-benchmark.ts` reads these from local
21
+ * `logs/perf-*.jsonl`, dev logs, or exported Axiom JSONL.
22
+ *
23
+ * Design constraints:
24
+ * - Workerd-safe (Cloudflare Workers can't touch the filesystem). When
25
+ * `appendFileSync` isn't available we degrade silently to stdout-only.
26
+ * - No new dependencies; just `node:fs`.
27
+ * - Loud failures are NOT desired here — perf instrumentation must never
28
+ * break a real play run. We swallow FS errors, but never silently drop
29
+ * the stdout copy.
30
+ */
31
+
32
+ import {
33
+ createTelemetry,
34
+ type TelemetryEvent,
35
+ type TelemetryFields,
36
+ } from '../observability/telemetry';
37
+
38
+ export type PerfTraceEvent = {
39
+ ts?: number;
40
+ source: 'server' | 'coordinator' | 'dynamic_worker' | 'runner';
41
+ runId: string;
42
+ orgId?: string | null;
43
+ phase: string;
44
+ ms: number;
45
+ playName?: string;
46
+ graphHash?: string | null;
47
+ workerUrl?: string | null;
48
+ bytes?: number;
49
+ extra?: Record<string, unknown>;
50
+ };
51
+
52
+ const PERF_TRACE_PREFIX = '[perf-trace]';
53
+
54
+ let cachedAppendFile: ((path: string, data: string) => void) | null | undefined;
55
+
56
+ function getAppendFile(): ((path: string, data: string) => void) | null {
57
+ if (cachedAppendFile !== undefined) return cachedAppendFile;
58
+ try {
59
+ // Avoid bundling this into edge runtime call paths. Synchronous CJS
60
+ // require() is the right tool here: workerd will throw on load and we
61
+ // fall through to the null branch, which keeps the stdout-only path.
62
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
63
+ const fs = require('node:fs') as typeof import('node:fs');
64
+ cachedAppendFile = (path: string, data: string) => {
65
+ try {
66
+ fs.mkdirSync('logs', { recursive: true });
67
+ fs.appendFileSync(path, data);
68
+ } catch {
69
+ // Filesystem unavailable (workerd / read-only FS). Drop the sidecar
70
+ // copy; the stdout JSON line is still emitted by recordPerfTrace.
71
+ }
72
+ };
73
+ } catch {
74
+ cachedAppendFile = null;
75
+ }
76
+ return cachedAppendFile;
77
+ }
78
+
79
+ const perfTraceTelemetry = createTelemetry({
80
+ service: 'play-runtime',
81
+ component: 'perf-trace',
82
+ adapter: {
83
+ emit(event: TelemetryEvent) {
84
+ const json = JSON.stringify(event);
85
+ console.log(`${PERF_TRACE_PREFIX} ${json}`);
86
+ if (event.source === 'server' && typeof event.runId === 'string') {
87
+ getAppendFile()?.(
88
+ `logs/perf-${sanitizeRunIdForFilename(event.runId)}.jsonl`,
89
+ `${json}\n`,
90
+ );
91
+ }
92
+ },
93
+ },
94
+ });
95
+
96
+ function perfTraceFields(event: PerfTraceEvent): TelemetryFields {
97
+ return {
98
+ ts: typeof event.ts === 'number' ? event.ts : Date.now(),
99
+ source: event.source,
100
+ phase: event.phase,
101
+ ms: event.ms,
102
+ graphHash: event.graphHash ?? null,
103
+ workerUrl: event.workerUrl ?? null,
104
+ bytes: event.bytes,
105
+ ...(event.extra ?? {}),
106
+ };
107
+ }
108
+
109
+ export function recordPerfTrace(event: PerfTraceEvent): void {
110
+ const { runId, phase } = event;
111
+ if (!runId || !phase) return;
112
+ const orgId =
113
+ event.orgId ??
114
+ (typeof event.extra?.orgId === 'string' ? event.extra.orgId : null);
115
+ void perfTraceTelemetry
116
+ .child({
117
+ component: event.source,
118
+ context: { runId, orgId, playName: event.playName ?? null },
119
+ })
120
+ .info(phase, perfTraceFields(event), { tag: PERF_TRACE_PREFIX });
121
+ }
122
+
123
+ function sanitizeRunIdForFilename(runId: string): string {
124
+ return runId.replace(/[^a-zA-Z0-9._-]+/g, '_');
125
+ }
126
+
127
+ export const PERF_TRACE_LINE_PREFIX = PERF_TRACE_PREFIX;
@@ -24,6 +24,8 @@ import {
24
24
  */
25
25
  export type PlayArtifactRuntimeContract = Readonly<{
26
26
  semantics: PlayRuntimeSemantics;
27
+ /** Additive artifact fact; missing persisted fields resolve to `park`. */
28
+ slackHitlTimeoutOutcome: 'park' | 'error';
27
29
  toolErrorSchemaVersion: ToolExecutionErrorSchemaVersion;
28
30
  toolResponseContract: ToolResponseContract;
29
31
  toolResponseReceiptRevision?: string;
@@ -31,6 +33,7 @@ export type PlayArtifactRuntimeContract = Readonly<{
31
33
 
32
34
  export type PlayArtifactRuntimeContractInput = {
33
35
  authoringContractEdition?: PlayAuthoringContractEdition | null;
36
+ slackHitlTimeoutOutcome?: 'park' | 'error' | null;
34
37
  toolResponseContract?: ToolResponseContract | null;
35
38
  toolResponseReceiptRevision?: string | null;
36
39
  };
@@ -50,6 +53,8 @@ export function resolvePlayArtifactRuntimeContract(
50
53
  semantics: resolvePlayRuntimeSemantics(
51
54
  input.authoringContractEdition ?? PLAY_AUTHORING_CONTRACT_EDITION,
52
55
  ),
56
+ slackHitlTimeoutOutcome:
57
+ input.slackHitlTimeoutOutcome === 'error' ? 'error' : 'park',
53
58
  // Historic string-only failures are deliberately upgraded at the runtime
54
59
  // boundary. Rehydrating an old artifact must not regress a structured
55
60
  // durable failure into an unbranchable string.
@@ -41,6 +41,7 @@ export type PlayRunRecoveryReason =
41
41
  | 'modal_circuit_open_before_execution'
42
42
  | 'modal_sandbox_unavailable_before_execution'
43
43
  | 'modal_runner_start_failed_before_execution'
44
+ | 'daytona_sandbox_transition_pending_before_execution'
44
45
  | 'runtime_initialization_transport_before_execution'
45
46
  | 'runtime_traffic_hold_before_execution'
46
47
  | 'runtime_traffic_throttled_before_execution';
@@ -209,6 +210,27 @@ export function recoveryForRuntimeTrafficPolicy(input: {
209
210
  });
210
211
  }
211
212
 
213
+ /**
214
+ * Daytona acknowledged a named sandbox but has not finished creating it.
215
+ * Resume that durable provider operation after a bounded defer; another
216
+ * provider or a fresh Daytona create could execute the same Play twice.
217
+ */
218
+ export function recoveryForDaytonaSandboxTransitionPending(
219
+ error: unknown,
220
+ ): PlayRunRecoveryError {
221
+ return new PlayRunRecoveryError({
222
+ decision: {
223
+ stage: 'pre_code',
224
+ action: 'defer',
225
+ reason: 'daytona_sandbox_transition_pending_before_execution',
226
+ dependency: 'runtime',
227
+ },
228
+ message:
229
+ 'Daytona is still finishing a named sandbox create before customer execution began.',
230
+ cause: error,
231
+ });
232
+ }
233
+
212
234
  /**
213
235
  * This is constructed only by the detached-runner readiness check. That
214
236
  * check has not parked the runner or observed scheduler liveness, so it is a
@@ -241,7 +263,8 @@ export function recoveryForRuntimeInitializationTransportFailure(
241
263
  | 'runtime_postgres_connect'
242
264
  | 'runtime_api_transport'
243
265
  | 'runtime_receipt_gateway_transport'
244
- | 'daytona_public_status',
266
+ | 'daytona_public_status'
267
+ | 'daytona_runner_startup_transport',
245
268
  ): PlayRunRecoveryError {
246
269
  return new PlayRunRecoveryError({
247
270
  decision: {
@@ -0,0 +1,56 @@
1
+ import type { PlaySchedulerSubmitInput } from '../../scheduler-backend';
2
+
3
+ /**
4
+ * A fully prepared Play Run is ready to cross the one durable admission
5
+ * boundary. Construction, artifact validation, token minting, and provider
6
+ * resolution are intentionally finished before this value exists.
7
+ */
8
+ export type PlayRunAdmissionInput = {
9
+ launch: PlaySchedulerSubmitInput;
10
+ queueName: string;
11
+ recoverExistingTask?: boolean;
12
+ };
13
+
14
+ /** The durable facts returned by one atomic launch-row + queue-task commit. */
15
+ export type PlayRunAdmissionReceipt = {
16
+ taskId: string | null;
17
+ runCreated: boolean;
18
+ taskCreated: boolean;
19
+ taskRecoveryRequired: boolean;
20
+ };
21
+
22
+ /**
23
+ * The outcome makes the three useful cases explicit to callers. A retry may
24
+ * either observe its original queue task or repair the historical row-first
25
+ * crash window; it never creates a second Play Run.
26
+ */
27
+ export type PlayRunAdmissionOutcome =
28
+ | {
29
+ kind: 'created';
30
+ receipt: PlayRunAdmissionReceipt;
31
+ }
32
+ | {
33
+ kind: 'recovered';
34
+ receipt: PlayRunAdmissionReceipt;
35
+ }
36
+ | {
37
+ kind: 'replayed';
38
+ receipt: PlayRunAdmissionReceipt;
39
+ };
40
+
41
+ export type PlayRunAdmissionJob = {
42
+ admit(input: PlayRunAdmissionInput): Promise<PlayRunAdmissionOutcome>;
43
+ };
44
+
45
+ /** A stable, machine-readable rejection for a reused run id with new intent. */
46
+ export class PlayRunLaunchConflictError extends Error {
47
+ readonly code = 'PLAY_RUN_LAUNCH_CONFLICT';
48
+
49
+ constructor(runId: string, options?: { cause?: unknown }) {
50
+ super(
51
+ `Play run "${runId}" already exists with a different launch.`,
52
+ options,
53
+ );
54
+ this.name = 'PlayRunLaunchConflictError';
55
+ }
56
+ }
@@ -0,0 +1,13 @@
1
+ export { createPlayRunAdmissionJob } from '../../play-runs/admission/job';
2
+ export { createPostgresPlayRunAdmissionPorts } from '../../play-runs/admission/postgres-adapter';
3
+ export { PlayRunLaunchConflictError } from '../../play-runs/admission/contracts';
4
+ export type {
5
+ PlayRunAdmissionInput,
6
+ PlayRunAdmissionJob,
7
+ PlayRunAdmissionOutcome,
8
+ PlayRunAdmissionReceipt,
9
+ } from '../../play-runs/admission/contracts';
10
+ export type {
11
+ AtomicPlayRunQueueSubmitter,
12
+ PlayRunAdmissionPorts,
13
+ } from '../../play-runs/admission/ports';
@@ -0,0 +1,41 @@
1
+ import {
2
+ type PlayRunAdmissionInput,
3
+ type PlayRunAdmissionJob,
4
+ type PlayRunAdmissionOutcome,
5
+ } from '../../play-runs/admission/contracts';
6
+ import type { PlayRunAdmissionPorts } from '../../play-runs/admission/ports';
7
+
8
+ /**
9
+ * Play Run Admission owns the idempotency law for the launch boundary:
10
+ *
11
+ * exact launch retry -> original task
12
+ * existing queued row without task -> repair that row
13
+ * same run id + changed launch -> reject
14
+ *
15
+ * The storage Adapter enforces identity and atomicity. This job exposes the
16
+ * result without leaking SQL rows, scheduler queues, or task engine details.
17
+ */
18
+ export function createPlayRunAdmissionJob(
19
+ ports: PlayRunAdmissionPorts,
20
+ ): PlayRunAdmissionJob {
21
+ return {
22
+ async admit(
23
+ input: PlayRunAdmissionInput,
24
+ ): Promise<PlayRunAdmissionOutcome> {
25
+ validate(input);
26
+ const receipt = await ports.atomicQueueSubmitter.submit(input);
27
+ if (receipt.runCreated) return { kind: 'created', receipt };
28
+ if (receipt.taskCreated) return { kind: 'recovered', receipt };
29
+ return { kind: 'replayed', receipt };
30
+ },
31
+ };
32
+ }
33
+
34
+ function validate(input: PlayRunAdmissionInput): void {
35
+ if (!input.launch.runId.trim()) {
36
+ throw new Error('Play Run Admission requires a non-empty run id.');
37
+ }
38
+ if (!input.queueName.trim()) {
39
+ throw new Error('Play Run Admission requires a non-empty queue name.');
40
+ }
41
+ }
@@ -0,0 +1,17 @@
1
+ import type {
2
+ PlayRunAdmissionInput,
3
+ PlayRunAdmissionReceipt,
4
+ } from '../../play-runs/admission/contracts';
5
+
6
+ /**
7
+ * This port is deliberately one operation. Persisting a run and enqueueing
8
+ * it separately creates an unrepairable ambiguity: either can succeed after a
9
+ * lost reply. The implementation must commit both facts atomically.
10
+ */
11
+ export type AtomicPlayRunQueueSubmitter = {
12
+ submit(input: PlayRunAdmissionInput): Promise<PlayRunAdmissionReceipt>;
13
+ };
14
+
15
+ export type PlayRunAdmissionPorts = {
16
+ atomicQueueSubmitter: AtomicPlayRunQueueSubmitter;
17
+ };