deepline 0.3.89 → 0.3.91

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 (267) hide show
  1. package/contracts/install-commands.json +29 -0
  2. package/dist/bundling-sources/sdk/src/client.ts +221 -43
  3. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  4. package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +2 -556
  5. package/dist/bundling-sources/sdk/src/monitor-fleets.ts +2 -2
  6. package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
  7. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/release.ts +11 -9
  9. package/dist/bundling-sources/sdk/src/types.ts +29 -1
  10. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +549 -0
  11. package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
  12. package/dist/bundling-sources/shared_libs/monitors/fleets/errors.ts +96 -0
  13. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
  14. package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +320 -0
  15. package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +106 -0
  16. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +8 -1
  17. package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +4 -4
  18. package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
  19. package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +7 -9
  20. package/dist/bundling-sources/shared_libs/monitors/monitor-fleet-limits.ts +2 -12
  21. package/dist/bundling-sources/shared_libs/monitors/package.json +113 -4
  22. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +56 -9
  23. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +2 -2
  24. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +2 -2
  25. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +1 -1
  26. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
  27. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
  28. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
  29. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
  30. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
  31. package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +1 -1
  32. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +2 -2
  33. package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +1 -1
  34. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +1 -1
  35. package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
  36. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
  37. package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
  38. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +690 -0
  39. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
  40. package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
  41. package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
  42. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +46 -1
  44. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +0 -1
  46. package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +779 -140
  48. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +46 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/db-session-lease-store.ts +578 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +521 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +1378 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +1024 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-gateway-route-probe.ts +193 -0
  57. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machine-lifecycle.ts +104 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +1844 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +21 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/deployment/process-tree.ts +40 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +262 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-surface.ts +98 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +303 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-publication-guardian.ts +70 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +519 -0
  66. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +280 -0
  67. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-production-gate.ts +159 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +23 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
  71. package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +3 -3
  72. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
  73. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
  74. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
  75. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
  76. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/memory-store.ts +114 -0
  79. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
  82. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
  83. package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +1 -1
  84. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
  85. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
  86. package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
  89. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
  106. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
  108. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
  109. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
  113. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
  117. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +2 -0
  118. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
  119. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +3 -5
  120. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
  121. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +44 -5
  122. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/child-play-resolver.ts +26 -0
  123. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +3662 -0
  124. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +47 -0
  125. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +84 -0
  126. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-gateway-transport.ts +91 -0
  127. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +424 -0
  128. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +321 -0
  129. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-sheet-persistence-retry.ts +110 -0
  130. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +625 -0
  131. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +72 -9
  132. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
  133. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +19 -0
  134. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
  135. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -44
  136. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +103 -208
  137. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
  138. package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +6 -0
  139. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
  140. package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
  141. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
  142. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +14 -2
  143. package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
  144. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
  145. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
  146. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +7 -0
  147. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
  148. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
  149. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
  150. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
  151. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
  152. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
  153. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
  154. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
  155. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
  156. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
  157. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
  158. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
  159. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
  160. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
  161. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
  162. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
  163. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
  164. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
  165. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
  166. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
  167. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
  168. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
  169. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
  170. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
  171. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
  172. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
  173. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
  174. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
  175. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
  176. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
  177. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
  178. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
  179. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
  180. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
  181. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
  182. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
  183. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
  184. package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
  185. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
  186. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
  187. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
  188. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
  189. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
  190. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
  191. package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
  192. package/dist/bundling-sources/shared_libs/play-runtime/webhook-receipt-retry.ts +50 -0
  193. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
  194. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
  195. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
  196. package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
  197. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +2 -0
  198. package/dist/bundling-sources/shared_libs/plays/bundling/repository-adapter.ts +24 -0
  199. package/dist/bundling-sources/shared_libs/plays/child-run-projection.ts +174 -0
  200. package/dist/bundling-sources/shared_libs/plays/contracts.ts +2 -0
  201. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +267 -0
  202. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +73 -0
  203. package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +162 -0
  204. package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +87 -0
  205. package/dist/bundling-sources/shared_libs/plays/deploy/source-file-path.ts +26 -0
  206. package/dist/bundling-sources/shared_libs/plays/deploy/target-paths.ts +36 -0
  207. package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
  208. package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
  209. package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +400 -0
  210. package/dist/bundling-sources/shared_libs/plays/launch/prepare.ts +96 -0
  211. package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +385 -0
  212. package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +112 -0
  213. package/dist/bundling-sources/shared_libs/plays/play-reference.ts +117 -0
  214. package/dist/bundling-sources/shared_libs/plays/run-input-summary.ts +260 -0
  215. package/dist/bundling-sources/shared_libs/plays/run-summary-types.ts +49 -0
  216. package/dist/bundling-sources/shared_libs/plays/secrets/errors.ts +19 -0
  217. package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
  218. package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
  219. package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
  220. package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
  221. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
  222. package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
  223. package/dist/bundling-sources/shared_libs/plays/sheet-filter.ts +347 -0
  224. package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
  225. package/dist/bundling-sources/shared_libs/plays/standard-webhooks.ts +117 -0
  226. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -1
  227. package/dist/bundling-sources/shared_libs/plays/status-result.ts +388 -0
  228. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
  229. package/dist/bundling-sources/shared_libs/plays/transform-factor-structure.ts +377 -0
  230. package/dist/bundling-sources/shared_libs/plays/webhook-payload.ts +113 -0
  231. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +7 -1
  232. package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +3 -2
  233. package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
  234. package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
  235. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
  236. package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
  237. package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
  238. package/dist/bundling-sources/shared_libs/runtime-env.ts +6 -0
  239. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
  240. package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +10 -3
  241. package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
  242. package/dist/cli/getting-started.d.mts +52 -0
  243. package/dist/cli/getting-started.d.ts +52 -0
  244. package/dist/cli/getting-started.js +65 -0
  245. package/dist/cli/getting-started.mjs +36 -0
  246. package/dist/cli/index.d.mts +9 -0
  247. package/dist/cli/index.d.ts +9 -0
  248. package/dist/cli/index.js +895 -407
  249. package/dist/cli/index.mjs +893 -414
  250. package/dist/{compiler-manifest-DsLbQaew.d.mts → compiler-manifest-x14KL83E.d.mts} +4 -2
  251. package/dist/{compiler-manifest-DsLbQaew.d.ts → compiler-manifest-x14KL83E.d.ts} +4 -2
  252. package/dist/index.d.mts +124 -154
  253. package/dist/index.d.ts +124 -154
  254. package/dist/index.js +132 -28
  255. package/dist/index.mjs +132 -28
  256. package/dist/install-integrity.json +182 -2
  257. package/dist/monitor-fleet-contract.d.mts +131 -0
  258. package/dist/monitor-fleet-contract.d.ts +131 -0
  259. package/dist/monitor-fleet-contract.js +406 -0
  260. package/dist/monitor-fleet-contract.mjs +367 -0
  261. package/dist/plays/bundle-play-file.d.mts +2 -2
  262. package/dist/plays/bundle-play-file.d.ts +2 -2
  263. package/dist/release.d.mts +255 -0
  264. package/dist/release.d.ts +255 -0
  265. package/dist/release.js +210 -0
  266. package/dist/release.mjs +183 -0
  267. package/package.json +21 -4
@@ -0,0 +1,8 @@
1
+ /** One wire vocabulary and transaction-size contract for Fleet writers. */
2
+ export const FLEET_BLOCKED_BY = {
3
+ watchedEntities: 'monitor.watched_entities',
4
+ monitorsPerEntity: 'monitor.monitors_per_entity',
5
+ rolloutAccess: 'monitor.rollout_access',
6
+ } as const;
7
+ export const MAX_MEMBER_DEFINITION_BYTES = 2_048;
8
+ export const MAX_FLEET_SETTLE_ITEMS = 100;
@@ -0,0 +1,320 @@
1
+ /**
2
+ * The whole fleet planning decision, as pure functions.
3
+ *
4
+ * Everything here is a function of values the caller already read: the source
5
+ * frontier, the monitors the fleet owns, and the organization's limits. No
6
+ * Convex, no Customer DB, no provider. That is deliberate - every membership
7
+ * bug this feature has had lived in these rules, and each one used to cost a
8
+ * preview deploy to see. Here they cost a millisecond.
9
+ *
10
+ * The output is the `members` array `providerMonitorFleets:commitPlan` takes,
11
+ * verbatim. Planning decides; the commit publishes.
12
+ */
13
+
14
+ import { MONITOR_FLEET_REMOVAL_GRACE_MS } from '../../integration-contracts/monitor-fleet-contract';
15
+ import { FLEET_BLOCKED_BY } from './limits';
16
+ export { FLEET_BLOCKED_BY } from './limits';
17
+
18
+ // Rollout access is checked by convergence immediately before provider work,
19
+ // not by this pure planner: an admitted plan can outlive rollout access.
20
+
21
+ export type FleetMemberAction =
22
+ | 'create'
23
+ | 'update'
24
+ | 'remove'
25
+ | 'blocked'
26
+ | 'grace';
27
+
28
+ /** One monitor the fleet wants, fully resolved from its source row. */
29
+ export type DesiredFleetMember = {
30
+ sourceKey: string;
31
+ monitorKey: string;
32
+ /** The account this monitor watches. Null when the tool declares none. */
33
+ entityKey: string | null;
34
+ /** The rendered monitor definition: `{ key, tool, payload }`. */
35
+ definition: Record<string, unknown>;
36
+ desiredHash: string;
37
+ };
38
+
39
+ /** A monitor the fleet already owns, as Convex reports it. */
40
+ export type OwnedFleetMonitor = {
41
+ monitorKey: string;
42
+ sourceKey: string | null;
43
+ entityKey: string | null;
44
+ convergence:
45
+ | 'pending'
46
+ | 'submitting'
47
+ | 'rate_limited'
48
+ | 'settled'
49
+ | 'blocked'
50
+ | 'failed';
51
+ desiredHash: string | null;
52
+ appliedHash: string | null;
53
+ firstMissingAt: number | null;
54
+ };
55
+
56
+ export type PlannedFleetMember = {
57
+ monitorKey: string;
58
+ sourceKey: string;
59
+ entityKey?: string;
60
+ action: FleetMemberAction;
61
+ desiredHash?: string;
62
+ desiredDefinition?: Record<string, unknown>;
63
+ blockedBy?: string;
64
+ /** True when the commit must be given a monitor seed for this key. */
65
+ needsSeed: boolean;
66
+ };
67
+
68
+ export type FleetPlan = {
69
+ members: PlannedFleetMember[];
70
+ creates: number;
71
+ updates: number;
72
+ removes: number;
73
+ /** Refusals by the limit that caused them, e.g. `{'monitor.watched_entities': 3}`. */
74
+ blocked: Record<string, number>;
75
+ };
76
+
77
+ export type FleetMembershipMember = {
78
+ sourceKey: string;
79
+ firstMissingAt: number | null;
80
+ };
81
+
82
+ export type FleetMembershipDecision = {
83
+ /** Source keys the fleet holds after this plan, in selection order. */
84
+ selected: string[];
85
+ /** Slots held by members whose grace has not expired. */
86
+ reservedGraceSlots: number;
87
+ /** Members whose row vanished on this plan. Grace starts now. */
88
+ markMissing: string[];
89
+ /** Members whose grace has expired and are now removed. */
90
+ remove: string[];
91
+ };
92
+
93
+ /**
94
+ * Slots held by members whose source row has vanished but whose removal grace
95
+ * has not expired.
96
+ *
97
+ * Such a member is still a member: it keeps its monitor, and grace exists so a
98
+ * row that comes back is restored rather than recreated. Handing its vacancy
99
+ * to the next ranked candidate immediately would push the fleet past its own
100
+ * limit, and then the reappearance grace is designed to absorb would force an
101
+ * eviction to get back under it - exactly the churn stickiness promises not to
102
+ * cause. Reserve the slot until grace actually expires.
103
+ */
104
+ export function countReservedRemovalGraceSlots(input: {
105
+ members: readonly FleetMembershipMember[];
106
+ selectedSourceKeys: ReadonlySet<string>;
107
+ now: number;
108
+ }): number {
109
+ return input.members.filter((member) => {
110
+ if (input.selectedSourceKeys.has(member.sourceKey)) return false;
111
+ // Not yet marked missing means this plan is the one that starts grace.
112
+ return (
113
+ member.firstMissingAt === null ||
114
+ input.now - member.firstMissingAt < MONITOR_FLEET_REMOVAL_GRACE_MS
115
+ );
116
+ }).length;
117
+ }
118
+
119
+ /**
120
+ * Who the fleet holds after a plan, given what the source still returns.
121
+ *
122
+ * The whole sticky/grace/limit rule in one place: an active member keeps its
123
+ * slot while its row exists, a vanished member keeps its slot until grace
124
+ * expires, and ranking only ever fills what is genuinely free.
125
+ */
126
+ export function decideFleetMembership(input: {
127
+ limit: number;
128
+ members: readonly FleetMembershipMember[];
129
+ /** Member source keys whose row the source still returns. */
130
+ presentSourceKeys: ReadonlySet<string>;
131
+ /** Ranked non-member candidates, best first. */
132
+ candidates: readonly string[];
133
+ now: number;
134
+ }): FleetMembershipDecision {
135
+ const selected: string[] = [];
136
+ const selectedKeys = new Set<string>();
137
+ // Sticky: ranking only fills vacancies, so score movement cannot churn an
138
+ // active member out of the fleet.
139
+ for (const member of input.members) {
140
+ if (!input.presentSourceKeys.has(member.sourceKey)) continue;
141
+ if (selectedKeys.has(member.sourceKey)) continue;
142
+ selected.push(member.sourceKey);
143
+ selectedKeys.add(member.sourceKey);
144
+ }
145
+ const reservedGraceSlots = countReservedRemovalGraceSlots({
146
+ members: input.members,
147
+ selectedSourceKeys: selectedKeys,
148
+ now: input.now,
149
+ });
150
+ for (const candidate of input.candidates) {
151
+ if (selected.length + reservedGraceSlots >= input.limit) break;
152
+ if (selectedKeys.has(candidate)) continue;
153
+ selected.push(candidate);
154
+ selectedKeys.add(candidate);
155
+ }
156
+ const markMissing: string[] = [];
157
+ const remove: string[] = [];
158
+ for (const member of input.members) {
159
+ if (selectedKeys.has(member.sourceKey)) continue;
160
+ if (member.firstMissingAt === null) {
161
+ markMissing.push(member.sourceKey);
162
+ continue;
163
+ }
164
+ if (input.now - member.firstMissingAt < MONITOR_FLEET_REMOVAL_GRACE_MS) {
165
+ continue;
166
+ }
167
+ remove.push(member.sourceKey);
168
+ }
169
+ return { selected, reservedGraceSlots, markMissing, remove };
170
+ }
171
+
172
+ /** The account a monitor is counted against. Never null, so nothing is uncounted. */
173
+ export function fleetEntityKeyFor(input: {
174
+ monitorKey: string;
175
+ entityKey: string | null;
176
+ }): string {
177
+ // A monitor with no derivable account is its own account, so it still
178
+ // occupies exactly one unit of allowance rather than slipping through.
179
+ return input.entityKey ?? `monitor:${input.monitorKey}`;
180
+ }
181
+
182
+ export type FleetEntitlements = {
183
+ /** New accounts this organization may still open. */
184
+ watchedEntitiesRemaining: number;
185
+ /** Monitors admitted against any one account. */
186
+ monitorsPerEntity: number;
187
+ };
188
+
189
+ /**
190
+ * Turn "what the fleet wants" plus "what it already owns" into commit members.
191
+ *
192
+ * Ordering matters and is deliberate: creates are admitted in selection order,
193
+ * so a fleet at its account limit keeps the members the source ranked highest
194
+ * rather than whichever ones happened to sort first by key.
195
+ */
196
+ export function planFleetMembers(input: {
197
+ desired: readonly DesiredFleetMember[];
198
+ owned: readonly OwnedFleetMonitor[];
199
+ /** Source keys whose grace expired, from `decideFleetMembership`. */
200
+ remove: readonly string[];
201
+ /** Source keys whose row vanished on this plan. */
202
+ markMissing: readonly string[];
203
+ entitlements: FleetEntitlements;
204
+ /**
205
+ * Monitors already counted against an account, org-wide. An account absent
206
+ * from this map is one the organization does not watch yet, and opening it
207
+ * is what costs allowance.
208
+ */
209
+ entityMonitorCounts: ReadonlyMap<string, number>;
210
+ }): FleetPlan {
211
+ const ownedByKey = new Map(
212
+ input.owned.map((monitor) => [monitor.monitorKey, monitor]),
213
+ );
214
+ const ownedBySource = new Map<string, OwnedFleetMonitor>();
215
+ for (const monitor of input.owned) {
216
+ if (monitor.sourceKey) ownedBySource.set(monitor.sourceKey, monitor);
217
+ }
218
+
219
+ const entityCounts = new Map(input.entityMonitorCounts);
220
+ const heldEntities = new Set(
221
+ [...entityCounts.entries()]
222
+ .filter(([, count]) => count > 0)
223
+ .map(([entityKey]) => entityKey),
224
+ );
225
+ let newEntitiesUsed = 0;
226
+
227
+ const members: PlannedFleetMember[] = [];
228
+ const blocked: Record<string, number> = {};
229
+ let creates = 0;
230
+ let updates = 0;
231
+ let removes = 0;
232
+
233
+ const refuse = (member: PlannedFleetMember, blockedBy: string) => {
234
+ blocked[blockedBy] = (blocked[blockedBy] ?? 0) + 1;
235
+ members.push({ ...member, action: 'blocked', blockedBy });
236
+ };
237
+
238
+ for (const desired of input.desired) {
239
+ const owned =
240
+ ownedByKey.get(desired.monitorKey) ??
241
+ ownedBySource.get(desired.sourceKey);
242
+ const entityKey = fleetEntityKeyFor(desired);
243
+ const base: PlannedFleetMember = {
244
+ monitorKey: desired.monitorKey,
245
+ sourceKey: desired.sourceKey,
246
+ entityKey,
247
+ action: 'create',
248
+ desiredHash: desired.desiredHash,
249
+ desiredDefinition: desired.definition,
250
+ needsSeed: true,
251
+ };
252
+
253
+ const applied = owned?.appliedHash ?? null;
254
+ if (applied !== null) {
255
+ // The provider already holds this monitor. Nothing to admit against a
256
+ // limit: it is already counted, and an update never opens an account.
257
+ const settledOnDesired =
258
+ applied === desired.desiredHash &&
259
+ owned?.convergence === 'settled' &&
260
+ owned.firstMissingAt === null;
261
+ if (settledOnDesired) continue;
262
+ // A member whose row came back inside its grace window is restored by
263
+ // re-publishing the state it already holds. That clears the removal
264
+ // clock through the same guarded transition every other change uses,
265
+ // rather than needing a second write path that could disagree with it.
266
+ members.push({ ...base, action: 'update', needsSeed: false });
267
+ updates += 1;
268
+ continue;
269
+ }
270
+
271
+ const onEntity = entityCounts.get(entityKey) ?? 0;
272
+ if (onEntity >= input.entitlements.monitorsPerEntity) {
273
+ refuse(base, FLEET_BLOCKED_BY.monitorsPerEntity);
274
+ continue;
275
+ }
276
+ if (
277
+ !heldEntities.has(entityKey) &&
278
+ newEntitiesUsed >= input.entitlements.watchedEntitiesRemaining
279
+ ) {
280
+ refuse(base, FLEET_BLOCKED_BY.watchedEntities);
281
+ continue;
282
+ }
283
+ if (!heldEntities.has(entityKey)) {
284
+ heldEntities.add(entityKey);
285
+ newEntitiesUsed += 1;
286
+ }
287
+ entityCounts.set(entityKey, onEntity + 1);
288
+ members.push(base);
289
+ creates += 1;
290
+ }
291
+
292
+ const plannedKeys = new Set(members.map((member) => member.monitorKey));
293
+ for (const sourceKey of input.markMissing) {
294
+ const owned = ownedBySource.get(sourceKey);
295
+ if (!owned || plannedKeys.has(owned.monitorKey)) continue;
296
+ members.push({
297
+ monitorKey: owned.monitorKey,
298
+ sourceKey,
299
+ ...(owned.entityKey ? { entityKey: owned.entityKey } : {}),
300
+ action: 'grace',
301
+ needsSeed: false,
302
+ });
303
+ plannedKeys.add(owned.monitorKey);
304
+ }
305
+ for (const sourceKey of input.remove) {
306
+ const owned = ownedBySource.get(sourceKey);
307
+ if (!owned || plannedKeys.has(owned.monitorKey)) continue;
308
+ members.push({
309
+ monitorKey: owned.monitorKey,
310
+ sourceKey,
311
+ ...(owned.entityKey ? { entityKey: owned.entityKey } : {}),
312
+ action: 'remove',
313
+ needsSeed: false,
314
+ });
315
+ plannedKeys.add(owned.monitorKey);
316
+ removes += 1;
317
+ }
318
+
319
+ return { members, creates, updates, removes, blocked };
320
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * One place that decides what a fleet's convergence counts mean.
3
+ *
4
+ * The verdict is server-owned on purpose. Every surface that has ever shown a
5
+ * fleet - the CLI, the API, a dashboard - has to answer the same question
6
+ * ("is this fleet done, and if not, is anything wrong?"), and each one that
7
+ * derives it from raw counts derives it slightly differently. The counts are
8
+ * the fact; this is the single reading of them.
9
+ */
10
+
11
+ export type FleetConvergenceCounts = {
12
+ pending: number;
13
+ submitting: number;
14
+ rate_limited: number;
15
+ settled: number;
16
+ blocked: number;
17
+ failed: number;
18
+ };
19
+
20
+ /** The lifecycle a fleet row records. */
21
+ export type FleetLifecycleStatus =
22
+ | 'active'
23
+ | 'deactivating'
24
+ | 'deactivated'
25
+ | 'billing_suspending'
26
+ | 'billing_suspended'
27
+ | 'billing_reactivating';
28
+
29
+ /** What a caller is told the fleet is doing. */
30
+ export type FleetStatusVerdict =
31
+ | 'converging'
32
+ | 'converged'
33
+ | 'degraded'
34
+ | 'deactivating'
35
+ | 'deactivated'
36
+ | 'billing_suspending'
37
+ | 'billing_suspended'
38
+ | 'billing_reactivating';
39
+
40
+ const ZERO_FLEET_COUNTS: FleetConvergenceCounts = {
41
+ pending: 0,
42
+ submitting: 0,
43
+ rate_limited: 0,
44
+ settled: 0,
45
+ blocked: 0,
46
+ failed: 0,
47
+ };
48
+
49
+ export function fleetCounts(
50
+ raw: Partial<FleetConvergenceCounts> | null | undefined,
51
+ ): FleetConvergenceCounts {
52
+ return { ...ZERO_FLEET_COUNTS, ...(raw ?? {}) };
53
+ }
54
+
55
+ /** Monitors a provider still owes an answer for. */
56
+ export function fleetOutstanding(counts: FleetConvergenceCounts): number {
57
+ return counts.pending + counts.submitting + counts.rate_limited;
58
+ }
59
+
60
+ /** Monitors this fleet expects to exist, including the ones it cannot create. */
61
+ export function fleetExpected(counts: FleetConvergenceCounts): number {
62
+ return (
63
+ counts.settled +
64
+ counts.pending +
65
+ counts.submitting +
66
+ counts.rate_limited +
67
+ counts.blocked +
68
+ counts.failed
69
+ );
70
+ }
71
+
72
+ /** Monitors the provider is confirmed to hold. */
73
+ export function fleetLive(counts: FleetConvergenceCounts): number {
74
+ return counts.settled;
75
+ }
76
+
77
+ /**
78
+ * The verdict.
79
+ *
80
+ * `converged` deliberately requires the published generation to be the one
81
+ * that converged. Outstanding-is-zero alone is equally true of a generation
82
+ * whose monitors have not been committed yet, and answering "converged" then
83
+ * tells a caller its change is live before any provider has seen it.
84
+ *
85
+ * `degraded` is the honest middle: nothing is in flight, so waiting longer
86
+ * changes nothing, but some monitors are blocked or failed and the fleet does
87
+ * not hold what it was asked to hold.
88
+ */
89
+ export function fleetStatusVerdict(input: {
90
+ status: FleetLifecycleStatus;
91
+ counts: FleetConvergenceCounts;
92
+ generation: number;
93
+ convergedGeneration: number | null;
94
+ }): FleetStatusVerdict {
95
+ if (input.status === 'deactivated') return 'deactivated';
96
+ if (input.status === 'deactivating') return 'deactivating';
97
+ if (input.status === 'billing_suspended') return 'billing_suspended';
98
+ if (input.status === 'billing_suspending') return 'billing_suspending';
99
+ if (input.status === 'billing_reactivating') return 'billing_reactivating';
100
+ const outstanding = fleetOutstanding(input.counts);
101
+ if (outstanding > 0) return 'converging';
102
+ if (input.counts.blocked + input.counts.failed > 0) return 'degraded';
103
+ return input.convergedGeneration === input.generation
104
+ ? 'converged'
105
+ : 'converging';
106
+ }
@@ -137,6 +137,9 @@ export function monitorErrorNextAction(payload: MonitorErrorPayload): string {
137
137
  ? `Wait ${retryAfterMs} ms, then retry the same read or check once.`
138
138
  : 'Wait for Customer DB provisioning, then retry the same read or check once.';
139
139
  }
140
+ if (code === 'monitor_control_plane_unavailable') {
141
+ return 'Wait briefly, then rerun the same monitor read. No monitor state was changed.';
142
+ }
140
143
  if (code === 'provider_monitor_identity_backfill_in_progress') {
141
144
  return typeof retryAfterSeconds === 'number'
142
145
  ? `Wait ${retryAfterSeconds} seconds, then retry the same monitor lifecycle request once. No upstream monitor was created.`
@@ -186,7 +189,11 @@ export function monitorErrorNextAction(payload: MonitorErrorPayload): string {
186
189
  return `This workspace already has ${MAX_PRIORITY_MONITORS_PER_ORG} priority radars. Delete or update an existing priority radar only after confirming it is no longer needed, then retry the urgent preview.`;
187
190
  }
188
191
  if (code === 'monitor_already_exists') {
189
- const existing = asRecord(nestedError(payload)?.existing_monitor)?.key;
192
+ const existingMonitor = asRecord(nestedError(payload)?.existing_monitor);
193
+ const existing = existingMonitor?.key;
194
+ if (existingMonitor?.status === 'provisioning') {
195
+ return 'An in-progress provider operation owns this identity. Do not deploy another key or delete and redeploy. Wait for it to finish, then rerun this check; if the conflict remains, contact Deepline support with the returned tool and identity.';
196
+ }
190
197
  return typeof existing === 'string'
191
198
  ? `Run \`deepline monitors get ${existing} --json\` to inspect the monitor that owns this identity. Reuse it or contact Deepline support before replacing it; do not delete and redeploy blindly.`
192
199
  : 'Inspect the returned existing_monitor.key with `deepline monitors get <key> --json`. Reuse that monitor or contact Deepline support before replacing it; do not delete and redeploy blindly.';
@@ -4,13 +4,13 @@ import {
4
4
  recordSignalRadarDeadLetter as recordSignalRadarDeadLetterCore,
5
5
  type InboundFailureClass,
6
6
  type InboundPgClient,
7
- } from '@/lib/signal-radars/inbound-dead-letter';
7
+ } from '@deepline/monitors/signal-radars/inbound-dead-letter';
8
8
  import {
9
9
  send as sendSignalRadarInbound,
10
10
  SIGNAL_RADAR_INBOUND_TOPIC as SIGNAL_RADAR_INBOUND_TOPIC_VALUE,
11
11
  type SignalRadarInboundSendOptions,
12
- } from '@/lib/signal-radars/inbound-queue';
13
- import type { SignalRadarInboundMessage } from '@/lib/signal-radars/inbound-message';
12
+ } from '@deepline/monitors/signal-radars/inbound-queue';
13
+ import type { SignalRadarInboundMessage } from '@deepline/monitors/signal-radars/inbound-message';
14
14
 
15
15
  // Public inbound-queue surface used by the thin provider-callback receiver.
16
16
  // Re-exports the topic + producer and adds the Neon-free publish key helper and
@@ -78,5 +78,5 @@ export async function recordSignalRadarDeadLetter(
78
78
  });
79
79
  }
80
80
 
81
- export type { SignalRadarInboundMessage } from '@/lib/signal-radars/inbound-message';
81
+ export type { SignalRadarInboundMessage } from '@deepline/monitors/signal-radars/inbound-message';
82
82
  export { headersToObject };
@@ -0,0 +1,59 @@
1
+ /** Shared inventory rules. Job progress and missing evidence are not monitor states. */
2
+ export type InventoryRadar = {
3
+ id: string;
4
+ status: 'active' | 'inactive' | 'unknown';
5
+ };
6
+ export type InventoryDecision = {
7
+ verdict: 'converged' | 'desynced' | 'unknown';
8
+ reason: string;
9
+ radarId?: string;
10
+ };
11
+
12
+ /** Call only after BOTH inventories completed. Absence is otherwise unknown. */
13
+ export function compareMonitorInventory(input: {
14
+ desired: 'active' | 'inactive';
15
+ resourceId: string | null;
16
+ exact: InventoryRadar[];
17
+ marker: InventoryRadar[];
18
+ candidateOwnerCount: number;
19
+ }): InventoryDecision {
20
+ const { desired, resourceId, exact, marker, candidateOwnerCount } = input;
21
+ if (exact.length > 1 || candidateOwnerCount > (resourceId ? 1 : 0)) {
22
+ return { verdict: 'unknown', reason: 'ambiguous_tamradar_binding' };
23
+ }
24
+ if (!resourceId) {
25
+ if (marker.length > 1)
26
+ return { verdict: 'unknown', reason: 'ambiguous_tamradar_binding' };
27
+ if (marker.length === 1)
28
+ return {
29
+ verdict: 'desynced',
30
+ reason: 'adoptable_tamradar_radar',
31
+ radarId: marker[0]!.id,
32
+ };
33
+ }
34
+ const radar = exact[0];
35
+ if (!radar) {
36
+ if (!resourceId) {
37
+ // A complete account list proves that no stamped counterpart exists; it
38
+ // cannot prove which resource an unbound historical row used to own.
39
+ // Creation or adoption is a separate, explicit operator operation.
40
+ return { verdict: 'unknown', reason: 'missing_tamradar_binding' };
41
+ }
42
+ return desired === 'inactive'
43
+ ? { verdict: 'converged', reason: 'in_sync' }
44
+ : { verdict: 'desynced', reason: 'missing_tamradar_radar' };
45
+ }
46
+ if (radar.status === 'unknown')
47
+ return {
48
+ verdict: 'unknown',
49
+ reason: 'unknown_tamradar_state',
50
+ radarId: radar.id,
51
+ };
52
+ return radar.status === desired
53
+ ? { verdict: 'converged', reason: 'in_sync', radarId: radar.id }
54
+ : {
55
+ verdict: 'desynced',
56
+ reason: 'tamradar_state_differs',
57
+ radarId: radar.id,
58
+ };
59
+ }
@@ -1,7 +1,7 @@
1
1
  // Internal Slack notifications for monitor / triggered-play lifecycle + activity.
2
2
  //
3
3
  // These are thin, best-effort helpers (mirroring
4
- // `src/lib/plays/team-notifications.ts`) that build a Slack payload via
4
+ // `apps/deepline-api/src/lib/plays/team-notifications.ts`) that build a Slack payload via
5
5
  // `buildSlackActivityPayload` and dispatch it through `sendSlackEventSafe` on
6
6
  // one of two internal channels:
7
7
  //
@@ -17,19 +17,17 @@
17
17
  // (we set `bypassInternalActorBlock`), BUT synthetic `@deepline.local`
18
18
  // dev-bootstrap test orgs are always suppressed (see
19
19
  // `shouldSuppressMonitorActor` + the transport-level guard in
20
- // `slack-events.ts`).
20
+ // the shared Slack delivery contract).
21
21
  // - Environments: ALL (dev + preview + prod). The two channels declare
22
- // `requiredEnv: 'all'` in `slack-events.ts`, so they post in local dev too.
22
+ // `requiredEnv: 'all'` in the delivery contract, so they post in local dev too.
23
23
  // - Spend: NEVER include provider spend. These payloads carry only keys,
24
24
  // counts, and trigger metadata — no provider-cost fields.
25
25
 
26
26
  import { after } from 'next/server';
27
- import {
28
- buildSlackActivityPayload,
29
- isSyntheticActorEmail,
30
- sendSlackEventSafe,
31
- } from '@/lib/slack-events';
32
- import { getRuntimeEnv } from '@/lib/runtime-env';
27
+ import { sendSlackEventSafe } from '../product-notifications/slack-delivery';
28
+ import { isSyntheticActorEmail } from '@deepline/auth/synthetic-identity';
29
+ import { buildSlackActivityPayload } from '../product-notifications/slack-payload';
30
+ import { getRuntimeEnv } from '../play-runtime/runtime-env';
33
31
 
34
32
  /**
35
33
  * Schedule a best-effort Slack dispatch WITHOUT blocking the caller. The
@@ -1,19 +1,9 @@
1
1
  /**
2
2
  * How large one Monitor Fleet may be.
3
3
  *
4
- * This lives in `shared_libs` rather than in the SDK's fleet authoring contract
5
- * because Convex needs it too: the commit mutation sizes its own transaction
6
- * against the same number the authoring contract validates a fleet's selection
7
- * limit against. Two copies of that number would drift, and the drift would
8
- * only be visible as a mutation that refuses a plan the SDK admitted.
9
- *
10
- * `packages/sdk/src/monitor-fleet-contract.ts` cannot import this file - the
11
- * workspace-architecture ratchet forbids new `shared_libs` edges from packages
12
- * - so it mirrors the literal, and `tests/lib/monitors/monitor-fleet-limits-
13
- * mirror.test.ts` holds the two equal by name. Everything outside Convex reads
14
- * the contract module's copy and never learns this file exists.
4
+ * Convex transaction sizing and SDK admission use the same canonical limit.
15
5
  */
16
- export const MONITOR_FLEET_MAX_MEMBERS = 1_000;
6
+ export { MONITOR_FLEET_MAX_MEMBERS } from '../integration-contracts/monitor-fleet-contract';
17
7
 
18
8
  /**
19
9
  * A claim may carry at most this many independent (organization, fleet)