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,355 @@
1
+ /**
2
+ * Recovery loop for durable Run Ledger outbox events.
3
+ *
4
+ * Runtime workers may accelerate their terminal event, but this controller is
5
+ * the independent delivery owner for durable lifecycle facts. In particular,
6
+ * it projects `run.created` before an execution slot is available. It has one
7
+ * durable source of truth (the outbox), one direct Postgres LISTEN connection
8
+ * as a wake hint, and one exact timer for the next due row. There is
9
+ * deliberately no worker fleet polling cadence.
10
+ */
11
+ import {
12
+ dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope,
13
+ postgresSchedulerNotifyChannel,
14
+ readPostgresSchedulerOutboxNextDueAt,
15
+ type PostgresSchedulerOptions,
16
+ type PostgresSchedulerOutboxProjectionResult,
17
+ } from './postgres';
18
+ import {
19
+ acquirePgNotifyHub,
20
+ withRuntimeSchedulerClient,
21
+ type PgNotifyHubLease,
22
+ type PgNotifyHubState,
23
+ type RuntimeSchedulerPoolOptions,
24
+ } from './postgres-pool';
25
+
26
+ const RECOVERY_FAILURE_RETRY_BASE_MS = 5_000;
27
+ const RECOVERY_FAILURE_RETRY_MAX_MS = 60_000;
28
+ // LISTEN/NOTIFY is the normal, immediate wake path. This fallback exists only
29
+ // while the optional direct connection is unavailable. It is intentionally
30
+ // short: a durable `run.created` fact is on the execution causal path, so a
31
+ // direct-session outage must add one small indexed poll rather than tens of
32
+ // seconds of worker deferrals. Only the dedicated projector performs this
33
+ // fallback; the worker fleet still never polls the outbox.
34
+ export const NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS = 1_000;
35
+ const MAX_TIMEOUT_MS = 2_147_483_647;
36
+ /**
37
+ * Two short claim/deliver waves match each projector's bounded scheduler pool.
38
+ * The claim query uses SKIP LOCKED, so the wave can advance separate runs
39
+ * without splitting the ordered lifecycle of any one run.
40
+ */
41
+ export const RUN_LEDGER_OUTBOX_RECOVERY_MAX_IN_FLIGHT = 2;
42
+
43
+ type RecoveryTimer = ReturnType<typeof setTimeout>;
44
+
45
+ export type RunLedgerOutboxRecoveryLogger = Pick<Console, 'info' | 'warn'>;
46
+
47
+ export type RunLedgerOutboxRecoveryDeps = {
48
+ /** One bounded durable claim/delivery attempt. */
49
+ dispatchOnce: () => Promise<PostgresSchedulerOutboxProjectionResult>;
50
+ /** Earliest pending retry time or active lease expiry in the durable outbox. */
51
+ readNextDueAt: () => Promise<Date | null>;
52
+ /** A direct LISTEN connection. It is a hint only; a null lease is safe. */
53
+ acquireNotifyHub: () => PgNotifyHubLease | null;
54
+ /** Bounded number of independent runs this replica may deliver at once. */
55
+ parallelism?: number;
56
+ now?: () => number;
57
+ setTimer?: (callback: () => void, delayMs: number) => RecoveryTimer;
58
+ clearTimer?: (timer: RecoveryTimer) => void;
59
+ logger?: RunLedgerOutboxRecoveryLogger;
60
+ };
61
+
62
+ export type RunLedgerOutboxRecoveryController = {
63
+ /**
64
+ * Ask the singleton projector to re-read durable outbox work. This is
65
+ * intentionally a coalesced wake, never an unbounded concurrent drain.
66
+ */
67
+ wake: (reason?: string) => void;
68
+ /** Whether the optional direct LISTEN hint is currently usable. */
69
+ notifyState: () => PgNotifyHubState | 'unavailable';
70
+ close: () => Promise<void>;
71
+ };
72
+
73
+ function boundedFailureDelayMs(failures: number): number {
74
+ const exponent = Math.min(Math.max(0, failures - 1), 4);
75
+ return Math.min(
76
+ RECOVERY_FAILURE_RETRY_MAX_MS,
77
+ RECOVERY_FAILURE_RETRY_BASE_MS * 2 ** exponent,
78
+ );
79
+ }
80
+
81
+ /**
82
+ * Start a bounded, work-conserving recovery controller from injected seams.
83
+ * Subscription happens before the first database scan, so a terminal commit
84
+ * cannot slip between startup scan and listener registration.
85
+ */
86
+ export function startRunLedgerOutboxRecovery(
87
+ deps: RunLedgerOutboxRecoveryDeps,
88
+ ): RunLedgerOutboxRecoveryController {
89
+ const now = deps.now ?? Date.now;
90
+ const setTimer = deps.setTimer ?? setTimeout;
91
+ const clearTimer = deps.clearTimer ?? clearTimeout;
92
+ const logger = deps.logger ?? console;
93
+ const requestedParallelism = Math.floor(deps.parallelism ?? 1);
94
+ const parallelism = Number.isFinite(requestedParallelism)
95
+ ? Math.max(
96
+ 1,
97
+ Math.min(
98
+ RUN_LEDGER_OUTBOX_RECOVERY_MAX_IN_FLIGHT,
99
+ requestedParallelism,
100
+ ),
101
+ )
102
+ : 1;
103
+ let closed = false;
104
+ let requested = false;
105
+ let failureCount = 0;
106
+ let timer: RecoveryTimer | null = null;
107
+ let drainPromise: Promise<void> | null = null;
108
+ let cooldownUntilMs: number | null = null;
109
+ let hubLease: PgNotifyHubLease | null = null;
110
+ let unsubscribeNotify: (() => void) | undefined;
111
+ let unsubscribeState: (() => void) | undefined;
112
+ let requestDrain: (reason: string) => void = () => undefined;
113
+
114
+ const clearWakeTimer = () => {
115
+ if (!timer) return;
116
+ clearTimer(timer);
117
+ timer = null;
118
+ };
119
+
120
+ const listenerIsAvailable = () => hubLease?.hub.state() === 'listening';
121
+
122
+ const attachNotifyHub = () => {
123
+ if (closed || hubLease) return;
124
+ const lease = deps.acquireNotifyHub();
125
+ if (!lease) return;
126
+ hubLease = lease;
127
+ unsubscribeNotify = lease.hub.subscribe(() =>
128
+ requestDrain('postgres_notify'),
129
+ );
130
+ unsubscribeState = lease.hub.subscribeState((state) => {
131
+ // A reconnect is a durable catch-up boundary. The controller re-reads
132
+ // Postgres rather than trusting payloads from the notification channel.
133
+ if (state === 'listening') requestDrain('listener_connected');
134
+ // `down` and `standby` are safe: scheduleNextDue installs the indexed
135
+ // safety wake after this scan reaches idle.
136
+ else requestDrain('listener_unavailable');
137
+ });
138
+ };
139
+
140
+ requestDrain = (reason: string) => {
141
+ if (closed) return;
142
+ requested = true;
143
+ if (cooldownUntilMs !== null && now() < cooldownUntilMs) return;
144
+ clearWakeTimer();
145
+ if (drainPromise) return;
146
+ drainPromise = drain(reason)
147
+ .catch((error) => {
148
+ // drain() handles expected database/projection faults itself. This is a
149
+ // final guard so the singleton process never dies silently.
150
+ logger.warn('[run-ledger-outbox.recovery_unhandled_failure]', {
151
+ reason,
152
+ error: error instanceof Error ? error.message : String(error),
153
+ });
154
+ })
155
+ .finally(() => {
156
+ drainPromise = null;
157
+ if (requested && !closed) requestDrain('coalesced_wake');
158
+ });
159
+ };
160
+
161
+ const recordProjectionRetry = (retrying: number) => {
162
+ failureCount += 1;
163
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
164
+ stage: 'projection',
165
+ retrying,
166
+ });
167
+ };
168
+
169
+ const scheduleFailureRetry = (
170
+ stage: 'dispatch' | 'next_due',
171
+ error: unknown,
172
+ ) => {
173
+ failureCount += 1;
174
+ // A rejected pooled query is normally worth exponential backoff. The
175
+ // exception is an unavailable LISTEN session: this dedicated projector is
176
+ // the one durable poller, and its one-second safety wake is what keeps
177
+ // `run.created` delivery live while a direct PostgreSQL connection is
178
+ // refused (for example, during a connection-capacity spike). Do not let a
179
+ // process-local exponential cooldown silently disable that fallback.
180
+ const delayMs = listenerIsAvailable()
181
+ ? boundedFailureDelayMs(failureCount)
182
+ : NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS;
183
+ logger.warn('[run-ledger-outbox.recovery_retry]', {
184
+ stage,
185
+ delayMs,
186
+ error: error instanceof Error ? error.message : String(error),
187
+ });
188
+ clearWakeTimer();
189
+ cooldownUntilMs = now() + delayMs;
190
+ timer = setTimer(() => {
191
+ timer = null;
192
+ cooldownUntilMs = null;
193
+ requestDrain('recovery_error_retry');
194
+ }, delayMs);
195
+ timer.unref?.();
196
+ };
197
+
198
+ const scheduleNextDue = async (): Promise<void> => {
199
+ let dueAt: Date | null;
200
+ try {
201
+ dueAt = await deps.readNextDueAt();
202
+ failureCount = 0;
203
+ } catch (error) {
204
+ scheduleFailureRetry('next_due', error);
205
+ return;
206
+ }
207
+ if (closed || requested) return;
208
+ // When LISTEN is healthy the exact durable due time is sufficient. If the
209
+ // optional listener is absent, down, or lost an election, an indexed
210
+ // short safety wake discovers a fresh row that otherwise had no
211
+ // notification or existing due time to wake this replica.
212
+ const exactDueMs = dueAt ? Math.max(0, dueAt.getTime() - now()) : null;
213
+ const delayMs = listenerIsAvailable()
214
+ ? exactDueMs
215
+ : Math.min(exactDueMs ?? Infinity, NOTIFY_UNAVAILABLE_SAFETY_WAKE_MS);
216
+ if (delayMs === null || !Number.isFinite(delayMs)) return;
217
+ clearWakeTimer();
218
+ timer = setTimer(
219
+ () => {
220
+ timer = null;
221
+ if (!listenerIsAvailable()) attachNotifyHub();
222
+ requestDrain(dueAt ? 'next_due' : 'listener_safety_wake');
223
+ },
224
+ Math.min(MAX_TIMEOUT_MS, delayMs),
225
+ );
226
+ timer.unref?.();
227
+ };
228
+
229
+ const drain = async (_reason: string): Promise<void> => {
230
+ while (requested && !closed) {
231
+ requested = false;
232
+ const settled = await Promise.allSettled(
233
+ Array.from({ length: parallelism }, () => deps.dispatchOnce()),
234
+ );
235
+ const rejected = settled.find(
236
+ (result): result is PromiseRejectedResult =>
237
+ result.status === 'rejected',
238
+ );
239
+ if (rejected) {
240
+ scheduleFailureRetry('dispatch', rejected.reason);
241
+ return;
242
+ }
243
+
244
+ const results = settled.map(
245
+ (result) =>
246
+ (
247
+ result as PromiseFulfilledResult<PostgresSchedulerOutboxProjectionResult>
248
+ ).value,
249
+ );
250
+ const retrying = results.reduce(
251
+ (total, result) => total + result.retrying,
252
+ 0,
253
+ );
254
+
255
+ if (retrying > 0) {
256
+ // The failed row owns its own durable retry clock. Do NOT stop this
257
+ // drain: the claim query preserves causal order within a run, while
258
+ // independent runs are safe to project now. Returning here turns one
259
+ // transient projection failure into global head-of-line blocking when
260
+ // this is the only healthy projector replica.
261
+ recordProjectionRetry(retrying);
262
+ } else {
263
+ failureCount = 0;
264
+ }
265
+
266
+ // Continue until no event was claimable. A transient failure schedules
267
+ // its own durable retry, so the next pass naturally skips that run while
268
+ // moving unrelated runs forward. A permanent failure is settled once and
269
+ // likewise cannot block another run's causal prefix.
270
+ if (results.some((result) => result.attempted > 0)) {
271
+ requested = true;
272
+ continue;
273
+ }
274
+ await scheduleNextDue();
275
+ }
276
+ };
277
+
278
+ // Subscribe first, then scan. Notifications are lossy by design, so every
279
+ // wake re-reads durable state and reconnect transitions also trigger a scan.
280
+ attachNotifyHub();
281
+ requestDrain('startup');
282
+
283
+ return {
284
+ wake: (reason = 'external_safety_wake') => requestDrain(reason),
285
+ notifyState: () => hubLease?.hub.state() ?? 'unavailable',
286
+ close: async () => {
287
+ if (closed) return;
288
+ closed = true;
289
+ clearWakeTimer();
290
+ cooldownUntilMs = null;
291
+ unsubscribeNotify?.();
292
+ unsubscribeState?.();
293
+ await drainPromise;
294
+ hubLease?.release();
295
+ },
296
+ };
297
+ }
298
+
299
+ /**
300
+ * Production wiring shared by each stateless Fly projector replica. Every
301
+ * replica uses gateway authority because Fly holds no signing key; leased
302
+ * outbox rows and idempotent appends provide the coordination boundary.
303
+ */
304
+ export function startRunLedgerOutboxRecoveryController(input: {
305
+ poolOptions: RuntimeSchedulerPoolOptions;
306
+ schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
307
+ /** Direct LISTEN is a latency hint and may be disabled for isolated schemas. */
308
+ useDirectNotify?: boolean;
309
+ }): RunLedgerOutboxRecoveryController {
310
+ const schedulerOptions = input.schedulerOptions ?? {};
311
+ return startRunLedgerOutboxRecovery({
312
+ acquireNotifyHub: () =>
313
+ input.useDirectNotify === false
314
+ ? null
315
+ : acquirePgNotifyHub(
316
+ runLedgerOutboxRecoveryNotifyHubInput({
317
+ poolOptions: input.poolOptions,
318
+ schedulerOptions,
319
+ }),
320
+ ),
321
+ dispatchOnce: () =>
322
+ dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
323
+ (operation) => withRuntimeSchedulerClient(input.poolOptions, operation),
324
+ { tokenAuthority: 'gateway', limit: 8 },
325
+ schedulerOptions,
326
+ ),
327
+ parallelism: Math.min(
328
+ RUN_LEDGER_OUTBOX_RECOVERY_MAX_IN_FLIGHT,
329
+ Math.max(1, input.poolOptions.maxClients ?? 1),
330
+ ),
331
+ readNextDueAt: () =>
332
+ withRuntimeSchedulerClient(input.poolOptions, (client) =>
333
+ readPostgresSchedulerOutboxNextDueAt(client, schedulerOptions),
334
+ ),
335
+ });
336
+ }
337
+
338
+ /** Production projector replicas LISTEN; durable row leases arbitrate work. */
339
+ export function runLedgerOutboxRecoveryNotifyHubInput(input: {
340
+ poolOptions: RuntimeSchedulerPoolOptions;
341
+ schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
342
+ }): {
343
+ url: string;
344
+ channel: string;
345
+ applicationName: string;
346
+ } {
347
+ return {
348
+ url: input.poolOptions.url,
349
+ channel: postgresSchedulerNotifyChannel(
350
+ 'outbox',
351
+ input.schedulerOptions ?? {},
352
+ ),
353
+ applicationName: 'deepline-run-ledger-outbox-recovery',
354
+ };
355
+ }
@@ -0,0 +1,46 @@
1
+ import {
2
+ createPlayRunTerminalJob,
3
+ createPostgresPlayRunTerminalPorts,
4
+ resolvePlayRunTerminalAuthority,
5
+ type PlayRunTerminalAuthority,
6
+ type PlayRunTerminalOutcome,
7
+ } from '../play-runs/terminal';
8
+ import type { PostgresSchedulerQueryClient } from './postgres';
9
+
10
+ /**
11
+ * Compatibility facade for older receipt-gateway imports. New code belongs in
12
+ * the Play Run Terminal Module, whose job owns the transition law and whose
13
+ * Postgres Adapter owns scheduler SQL.
14
+ */
15
+ export type RunnerTerminalAttemptAuthority = PlayRunTerminalAuthority;
16
+ export const resolveRunnerTerminalAttemptAuthority =
17
+ resolvePlayRunTerminalAuthority;
18
+ export type RunnerTerminalIngressOutcome = PlayRunTerminalOutcome;
19
+
20
+ /**
21
+ * Accept a detached runner's terminal result.
22
+ *
23
+ * Eligible completions commit their terminal state, cleanup obligations, and
24
+ * Absurd retirement event atomically. Compatibility outcomes persist the
25
+ * terminal receipt before queuing the retirement event. Callers do not need to
26
+ * know the event name or notification channel.
27
+ */
28
+ export async function acceptRunnerTerminal(
29
+ client: PostgresSchedulerQueryClient,
30
+ input: {
31
+ queueName: string;
32
+ runId: string;
33
+ attempt: number;
34
+ authority?: RunnerTerminalAttemptAuthority | null;
35
+ result: unknown;
36
+ },
37
+ options?: { schema?: string },
38
+ ): Promise<RunnerTerminalIngressOutcome> {
39
+ const job = createPlayRunTerminalJob(
40
+ createPostgresPlayRunTerminalPorts({
41
+ client,
42
+ schema: options?.schema,
43
+ }),
44
+ );
45
+ return await job.accept(input);
46
+ }
@@ -0,0 +1,60 @@
1
+ import type { PostgresSchedulerQueryClient } from './postgres';
2
+ import {
3
+ heartbeatPostgresSchedulerDetachedRunner,
4
+ readPostgresSchedulerRunnerLiveness,
5
+ } from './postgres';
6
+
7
+ /**
8
+ * Detached-runner heartbeat control for the receipt gateway.
9
+ *
10
+ * The worker parks after the detached runner start — it holds no claim while
11
+ * the sandbox executes — so a parked run has no Absurd claim to extend.
12
+ * Heartbeats read the Play Run status, update attempt liveness, and carry the
13
+ * cancellation signal back to the runner.
14
+ *
15
+ * Terminal ingress lives in the Run Terminal Transition Module.
16
+ */
17
+
18
+ export type RunnerHeartbeatOutcome =
19
+ | { ok: true; schedulerStatus: 'queued' | 'running' | 'waiting' }
20
+ | { ok: false; terminal: 'cancelled' | 'failed' | 'completed' };
21
+
22
+ export async function runnerHeartbeat(
23
+ client: PostgresSchedulerQueryClient,
24
+ input: { runId: string; attempt: number },
25
+ options?: { schema?: string },
26
+ ): Promise<RunnerHeartbeatOutcome | null> {
27
+ const status = await heartbeatPostgresSchedulerDetachedRunner(
28
+ client,
29
+ input,
30
+ options,
31
+ );
32
+ if (status === null) return null;
33
+ if (status === 'cancelled') return { ok: false, terminal: 'cancelled' };
34
+ if (status === 'failed') return { ok: false, terminal: 'failed' };
35
+ if (status === 'completed') return { ok: false, terminal: 'completed' };
36
+ return { ok: true, schedulerStatus: status };
37
+ }
38
+
39
+ export async function runnerReadiness(
40
+ client: PostgresSchedulerQueryClient,
41
+ input: {
42
+ runId: string;
43
+ attempt: number;
44
+ baselineHeartbeatAt?: string | null;
45
+ },
46
+ options?: { schema?: string },
47
+ ): Promise<{ ready: boolean; heartbeatAt: string | null } | null> {
48
+ const liveness = await readPostgresSchedulerRunnerLiveness(
49
+ client,
50
+ { runId: input.runId, attempt: input.attempt },
51
+ options,
52
+ );
53
+ if (!liveness) return null;
54
+ return {
55
+ ready:
56
+ input.baselineHeartbeatAt !== undefined &&
57
+ liveness.heartbeatAt !== input.baselineHeartbeatAt,
58
+ heartbeatAt: liveness.heartbeatAt,
59
+ };
60
+ }
@@ -0,0 +1,33 @@
1
+ import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
2
+
3
+ /**
4
+ * Resolve the app origin used for authenticated runtime API calls.
5
+ *
6
+ * New Play Launch Envelopes carry an executor-reachable runtime API origin.
7
+ * Older launch rows predate that field and retain the callback URL fallback.
8
+ */
9
+ export function runtimeApiBaseUrlFromLaunch(
10
+ launch: Pick<PlaySchedulerSubmitInput, 'baseUrl' | 'runtimeApiBaseUrl'>,
11
+ ): string {
12
+ return launch.runtimeApiBaseUrl?.trim() || launch.baseUrl;
13
+ }
14
+
15
+ /**
16
+ * Resolve the origin whose JWKS verifies a run's executor token.
17
+ *
18
+ * The API endpoint remains launch-pinned so a staged Vercel deployment is
19
+ * genuinely exercised before promotion. The signing origin instead remains
20
+ * the stable public production authority, which both gateway fleets already
21
+ * trust. Legacy launch rows deliberately preserve the old single-origin
22
+ * behavior.
23
+ */
24
+ export function runtimeTokenOriginFromLaunch(
25
+ launch: Pick<
26
+ PlaySchedulerSubmitInput,
27
+ 'baseUrl' | 'runtimeApiBaseUrl' | 'runtimeTokenOrigin'
28
+ >,
29
+ ): string {
30
+ return (
31
+ launch.runtimeTokenOrigin?.trim() || runtimeApiBaseUrlFromLaunch(launch)
32
+ );
33
+ }
@@ -0,0 +1,64 @@
1
+ import {
2
+ LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_HEADER,
3
+ LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_VALUE,
4
+ } from '../durable-invocation-fence';
5
+
6
+ const RECEIPT_GATEWAY_HEALTH_PATH = '/healthz';
7
+ const RECEIPT_GATEWAY_HEALTH_TIMEOUT_MS = 5_000;
8
+
9
+ function gatewayOrigin(gatewayBaseUrl: string): string {
10
+ try {
11
+ const url = new URL(gatewayBaseUrl);
12
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
13
+ throw new Error('unsupported protocol');
14
+ }
15
+ return url.origin;
16
+ } catch {
17
+ throw new Error(
18
+ 'Runtime gateway URL must be a valid absolute URL using HTTP(S).',
19
+ );
20
+ }
21
+ }
22
+
23
+ export async function verifyRuntimeReceiptGatewayHealth(input: {
24
+ gatewayBaseUrl: string;
25
+ fetchImpl?: typeof fetch;
26
+ timeoutMs?: number;
27
+ }): Promise<void> {
28
+ let origin: string;
29
+ try {
30
+ origin = gatewayOrigin(input.gatewayBaseUrl);
31
+ } catch {
32
+ throw new Error(
33
+ 'DEEPLINE_RUNTIME_RECEIPT_GATEWAY_URL must be a valid absolute URL using HTTP(S).',
34
+ );
35
+ }
36
+
37
+ const response = await (input.fetchImpl ?? fetch)(
38
+ `${origin}${RECEIPT_GATEWAY_HEALTH_PATH}`,
39
+ {
40
+ method: 'GET',
41
+ redirect: 'manual',
42
+ signal: AbortSignal.timeout(
43
+ input.timeoutMs ?? RECEIPT_GATEWAY_HEALTH_TIMEOUT_MS,
44
+ ),
45
+ },
46
+ );
47
+ if (!response.ok) {
48
+ throw new Error(
49
+ `Receipt gateway ${origin} health check returned HTTP ${response.status}.`,
50
+ );
51
+ }
52
+ // This proves only receipt-gateway identity and liveness. v2 execution
53
+ // capability is checked by the caller of execute-fenced-v2 against the
54
+ // execution receiver; making it a worker boot condition would block valid
55
+ // ordinary and receipt traffic during a split-gateway rollout.
56
+ if (
57
+ response.headers.get(LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_HEADER) !==
58
+ LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_VALUE
59
+ ) {
60
+ throw new Error(
61
+ `Receipt gateway ${origin} did not attest itself with ${LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_HEADER}: ${LEGACY_DURABLE_INVOCATION_FENCE_ATTESTATION_VALUE}.`,
62
+ );
63
+ }
64
+ }