deepline 0.3.551 → 0.3.553

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 (324) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +130 -12
  2. package/dist/bundling-sources/sdk/src/compat.ts +239 -87
  3. package/dist/bundling-sources/sdk/src/config.ts +113 -2
  4. package/dist/bundling-sources/sdk/src/errors.ts +2 -0
  5. package/dist/bundling-sources/sdk/src/http-core.ts +124 -10
  6. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  7. package/dist/bundling-sources/sdk/src/integrations.ts +6 -4
  8. package/dist/bundling-sources/sdk/src/play.ts +3 -0
  9. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
  10. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +66 -30
  12. package/dist/bundling-sources/sdk/src/tool-calls.ts +2 -1
  13. package/dist/bundling-sources/sdk/src/tool-failure-hint.ts +104 -0
  14. package/dist/bundling-sources/sdk/src/types.ts +9 -1
  15. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/integration-contracts/billing-plan-skus.ts +25 -0
  17. package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +2 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +58 -4
  19. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +8 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +11 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +13 -0
  22. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +103 -5
  23. package/dist/bundling-sources/shared_libs/monitors/fleets/converge-admission.ts +133 -0
  24. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-attention.ts +165 -0
  25. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-release.ts +726 -0
  26. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-walk.ts +274 -0
  27. package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +28 -0
  29. package/dist/bundling-sources/shared_libs/monitors/fleets/provider-bulk-wait.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/monitors/fleets/shared-payload.ts +189 -0
  31. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +28 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +4 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-counter-errors.ts +25 -0
  34. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +65 -0
  35. package/dist/bundling-sources/shared_libs/monitors/package.json +11 -0
  36. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +152 -1
  37. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +6 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +390 -10
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +34 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +66 -30
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +30 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +80 -13
  43. package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  45. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  46. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  47. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tamradar-countries.ts +285 -0
  49. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  50. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  51. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  52. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  53. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  54. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  55. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  56. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +312 -41
  57. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  58. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  59. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  60. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  62. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +568 -26
  63. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  67. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +14 -2
  68. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  69. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  70. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  71. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +92 -16
  72. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  73. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  74. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  76. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  77. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  79. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  81. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  82. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  83. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +300 -57
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  86. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  87. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  88. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +298 -46
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +39 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  95. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +32 -10
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  108. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  109. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  110. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  112. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  113. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  117. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  118. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +37 -7
  119. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  120. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  121. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  122. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  123. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  124. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  125. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  126. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  127. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  128. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  129. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  130. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  131. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  132. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  133. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  134. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  135. package/dist/cli/{auth-E7BH4GMJ.mjs → auth-I3QAU4RV.mjs} +8 -7
  136. package/dist/cli/auth-MQCN7WGZ.js +44 -0
  137. package/dist/cli/{billing-OXKU462W.mjs → billing-3IC54OQQ.mjs} +202 -59
  138. package/dist/cli/{billing-DNQAZGX7.js → billing-YGFFVAIC.js} +302 -159
  139. package/dist/cli/{chunk-COGREZAO.js → chunk-2B5B5KAW.js} +210 -128
  140. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  141. package/dist/cli/{chunk-T2B5BVZE.js → chunk-3NTP2OSG.js} +13 -13
  142. package/dist/cli/{chunk-FOTGUFVK.mjs → chunk-45OAVGU6.mjs} +5 -5
  143. package/dist/cli/{chunk-54EEYLTF.js → chunk-4747TPLV.js} +3 -3
  144. package/dist/cli/{chunk-CLRAANWH.mjs → chunk-4BFTDNHU.mjs} +1 -1
  145. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-4HYNMXXF.mjs} +4 -4
  146. package/dist/cli/{chunk-5S6PHKRV.mjs → chunk-4SMCFQ23.mjs} +1 -1
  147. package/dist/cli/{chunk-VWLHRZFG.mjs → chunk-55F6HNOY.mjs} +5 -5
  148. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  149. package/dist/cli/{chunk-VTGG2RT3.js → chunk-6NE3RRRY.js} +1 -1
  150. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  151. package/dist/cli/{chunk-MNSTCJMX.mjs → chunk-72V4PDH5.mjs} +18 -18
  152. package/dist/cli/{chunk-ZCDKE4UH.js → chunk-74RES4DS.js} +5 -5
  153. package/dist/cli/{chunk-WKBHUB6R.js → chunk-7GEMELKI.js} +366 -320
  154. package/dist/cli/{chunk-C4CUZH57.js → chunk-7O6J6A7P.js} +1871 -92
  155. package/dist/cli/{chunk-7RSIFA72.js → chunk-7SERLBNR.js} +161 -53
  156. package/dist/cli/{chunk-3G6QZACZ.js → chunk-7YRJ5UC4.js} +21 -21
  157. package/dist/cli/{chunk-I4VKGNAQ.mjs → chunk-A7DLBE5K.mjs} +136 -54
  158. package/dist/cli/{chunk-GGB3JYCW.mjs → chunk-AGICYWGN.mjs} +299 -69
  159. package/dist/cli/{chunk-44KSACJW.mjs → chunk-AGIQDA2T.mjs} +12 -12
  160. package/dist/cli/{chunk-PACD5DGC.js → chunk-AGLR6QVN.js} +255 -109
  161. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  162. package/dist/cli/{chunk-4OMAGJ6U.js → chunk-BVDKFS2T.js} +2 -2
  163. package/dist/cli/{chunk-LPJPCGT3.js → chunk-CACFJODG.js} +190 -134
  164. package/dist/cli/{chunk-GVYLCCKN.mjs → chunk-CAEBJOYU.mjs} +1 -1
  165. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  166. package/dist/cli/{chunk-POLUE7D5.js → chunk-DP2VH7CO.js} +12 -12
  167. package/dist/cli/{chunk-D6M5HFBB.mjs → chunk-DP64MD6U.mjs} +1 -1
  168. package/dist/cli/{chunk-W425ERWN.mjs → chunk-DZA7RFGL.mjs} +5 -5
  169. package/dist/cli/{chunk-R7J7CJPZ.js → chunk-E2G2DNAB.js} +4 -1
  170. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-E7WZOX2A.mjs} +22 -18
  171. package/dist/cli/{chunk-44I675YK.js → chunk-FM7LPUPA.js} +41 -41
  172. package/dist/cli/{chunk-2UXDHFSF.mjs → chunk-GAVZ4EOD.mjs} +1 -1
  173. package/dist/cli/{chunk-Z2FIOG3V.js → chunk-HEBO3XNZ.js} +27 -31
  174. package/dist/cli/{chunk-6PWJKMFQ.mjs → chunk-HSJ6X2AQ.mjs} +4 -4
  175. package/dist/cli/{chunk-UPMRIVZB.js → chunk-HVI55MTK.js} +61 -10
  176. package/dist/cli/{chunk-KWSH5T7K.js → chunk-IH6GDNKW.js} +21 -21
  177. package/dist/cli/{chunk-3KYBDAR3.js → chunk-IMX7J4DU.js} +8 -8
  178. package/dist/cli/{chunk-HEHVGEZV.mjs → chunk-INEMTYMT.mjs} +8 -8
  179. package/dist/cli/{chunk-5VVSEU67.js → chunk-IUOGII7D.js} +6 -7
  180. package/dist/cli/{chunk-MXGA6JFI.mjs → chunk-JJGWHITQ.mjs} +5 -5
  181. package/dist/cli/{chunk-QM6Y6S4E.js → chunk-JLGP5XAJ.js} +5 -5
  182. package/dist/cli/{chunk-V6SCP4B7.mjs → chunk-LFOERUQY.mjs} +69 -3
  183. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  184. package/dist/cli/{chunk-ZMNGZ6XS.mjs → chunk-LH5PZKER.mjs} +80 -24
  185. package/dist/cli/{chunk-MR5LTVHD.js → chunk-LRDHPOZW.js} +69 -69
  186. package/dist/cli/{chunk-5LUF4LAR.mjs → chunk-LRZGS6RZ.mjs} +3 -0
  187. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  188. package/dist/cli/{chunk-UDXULACQ.js → chunk-MLABYI4M.js} +90 -24
  189. package/dist/cli/{chunk-S7IZWGUA.mjs → chunk-NDNHYONK.mjs} +17 -21
  190. package/dist/cli/{chunk-4D3WIZST.mjs → chunk-OTV2UUKW.mjs} +164 -18
  191. package/dist/cli/{chunk-XYE5XPGF.js → chunk-Q6Z6N3A7.js} +18 -18
  192. package/dist/cli/{chunk-7WQNWJQW.mjs → chunk-QG6JIWUL.mjs} +151 -43
  193. package/dist/cli/{chunk-3T65J5RG.mjs → chunk-QI5S5HWB.mjs} +2 -2
  194. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  195. package/dist/cli/{chunk-PM7MO62Y.mjs → chunk-RMNOZKRI.mjs} +3 -3
  196. package/dist/cli/{chunk-NMWGZD6Y.js → chunk-RTV4RF7N.js} +36 -36
  197. package/dist/cli/{chunk-CQ6JYQSW.js → chunk-SBH4CKPN.js} +11 -11
  198. package/dist/cli/{chunk-BIIJATTX.mjs → chunk-SG3LUONJ.mjs} +3 -3
  199. package/dist/cli/{chunk-2WFPHBR4.js → chunk-TFEXSHPM.js} +22 -18
  200. package/dist/cli/{chunk-5IL7SC45.mjs → chunk-TN4TY6TT.mjs} +6 -7
  201. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-UEVKMZLR.mjs} +54 -3
  202. package/dist/cli/{chunk-RE5MJBEV.mjs → chunk-UVQJYV76.mjs} +2 -2
  203. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  204. package/dist/cli/{chunk-W2ZWQUHT.js → chunk-WOCHZCUJ.js} +2 -2
  205. package/dist/cli/{chunk-ZDQFBJPO.js → chunk-XLIHTJVM.js} +348 -118
  206. package/dist/cli/{chunk-2ZYRBMQM.js → chunk-Y6SP3JMI.js} +22 -22
  207. package/dist/cli/{chunk-PPSDCN6C.js → chunk-YUA6HA6D.js} +2 -2
  208. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  209. package/dist/cli/{chunk-E64HFB4L.mjs → chunk-Z6XPSHKM.mjs} +87 -41
  210. package/dist/cli/{chunk-7DOQ3OEX.mjs → chunk-Z7AOIHFE.mjs} +1870 -91
  211. package/dist/cli/command-docs.js +3 -3
  212. package/dist/cli/command-docs.mjs +2 -2
  213. package/dist/cli/concurrent-runs-help-CFJH4KXV.js +22 -0
  214. package/dist/cli/{concurrent-runs-help-C6L6I5OR.mjs → concurrent-runs-help-DNV2X5AZ.mjs} +9 -8
  215. package/dist/cli/{csv-QMF4FWE7.js → csv-SA6ELJY6.js} +16 -15
  216. package/dist/cli/{csv-SYSDXFEM.mjs → csv-ZXZGHWOM.mjs} +7 -6
  217. package/dist/cli/{db-Q7HURWRZ.mjs → db-A54SP6AD.mjs} +16 -16
  218. package/dist/cli/{db-YSHPPA4H.js → db-JHFEIQBU.js} +43 -43
  219. package/dist/cli/describe-PHQ33AGS.mjs +50 -0
  220. package/dist/cli/describe-RHJ4XRFI.js +50 -0
  221. package/dist/cli/describe-core.d.mts +3 -3
  222. package/dist/cli/describe-core.d.ts +3 -3
  223. package/dist/cli/describe-core.js +6 -6
  224. package/dist/cli/describe-core.mjs +5 -5
  225. package/dist/cli/{executions-G7U3VUXN.mjs → executions-HL2M2DFU.mjs} +10 -10
  226. package/dist/cli/{executions-MWBC5TAW.js → executions-TLFZRHBJ.js} +12 -12
  227. package/dist/cli/{feedback-SD55OY6H.js → feedback-5UEX5UZK.js} +17 -16
  228. package/dist/cli/{feedback-GMHIFLBJ.mjs → feedback-QMBTNXVG.mjs} +9 -8
  229. package/dist/cli/git-4JWOOHBG.js +26 -0
  230. package/dist/cli/{git-HPE45OPD.mjs → git-LKGXVIVC.mjs} +8 -7
  231. package/dist/cli/index.js +170 -158
  232. package/dist/cli/index.mjs +60 -48
  233. package/dist/cli/{integrations-HFKVBY6G.js → integrations-6RUTLMN7.js} +23 -27
  234. package/dist/cli/{integrations-2W4MGIQR.mjs → integrations-FGGRVUJ7.mjs} +15 -19
  235. package/dist/cli/{legacy-noops-SXVNDEXN.js → legacy-noops-J3Z7QRWZ.js} +12 -11
  236. package/dist/cli/{legacy-noops-GZYKNU2Z.mjs → legacy-noops-YIPRMVXZ.mjs} +9 -8
  237. package/dist/cli/{mcp-PJRHQHHU.js → mcp-6LWFP7RW.js} +121 -48
  238. package/dist/cli/{mcp-BWA6KULG.mjs → mcp-CHDYFO7F.mjs} +100 -27
  239. package/dist/cli/{monitors-K2WSI6CR.js → monitors-STM6A7OU.js} +221 -186
  240. package/dist/cli/{monitors-SYQKCATO.mjs → monitors-UGRY2BXI.mjs} +58 -23
  241. package/dist/cli/org-3SYOUQCX.mjs +2289 -0
  242. package/dist/cli/org-ZOBSNSIB.js +2289 -0
  243. package/dist/cli/outcomes-H4YYAT5X.js +2865 -0
  244. package/dist/cli/outcomes-Z3P2JE67.mjs +2865 -0
  245. package/dist/cli/{play-SZXY2F2S.js → play-SM4CW2GS.js} +1116 -846
  246. package/dist/cli/{play-TTMABJEI.mjs → play-SN5YWLS7.mjs} +375 -105
  247. package/dist/cli/{providers-GQIOMRQO.mjs → providers-WZ4YBR5Y.mjs} +10 -10
  248. package/dist/cli/{providers-YDHCTZAF.js → providers-WZARYMCF.js} +13 -13
  249. package/dist/cli/{quickstart-PHSSMKCA.mjs → quickstart-2575BNKA.mjs} +7 -6
  250. package/dist/cli/{quickstart-BNYOXQXG.js → quickstart-PS4YHQJ6.js} +9 -8
  251. package/dist/cli/{run-GFIAZXVL.js → run-FLZ6OTM7.js} +51 -51
  252. package/dist/cli/{run-74C3C75C.mjs → run-ZUHCZOJS.mjs} +31 -31
  253. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  254. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  255. package/dist/cli/{search-3SWUB7KX.mjs → search-HLPPKQEO.mjs} +11 -11
  256. package/dist/cli/search-JJWVHR3N.js +32 -0
  257. package/dist/cli/{search-output-K2SWHVHQ.mjs → search-output-PDAXNOGP.mjs} +9 -8
  258. package/dist/cli/{search-output-6JF3S4TP.js → search-output-RXJLU36B.js} +12 -11
  259. package/dist/cli/{secrets-2M4XWEKE.mjs → secrets-CGELYQ3H.mjs} +11 -11
  260. package/dist/cli/{secrets-2SAKLH2H.js → secrets-QJNG7G2Y.js} +20 -20
  261. package/dist/cli/sessions-DHTBT2GN.js +23 -0
  262. package/dist/cli/{sessions-A64BCXTO.mjs → sessions-ELMWVR4M.mjs} +9 -8
  263. package/dist/cli/{settings-HV64WIJF.js → settings-44I44P5F.js} +89 -89
  264. package/dist/cli/{settings-SVGEC3FI.mjs → settings-RR3LZXL7.mjs} +16 -16
  265. package/dist/cli/{setup-EDC3NEJ3.mjs → setup-KGWRWH4B.mjs} +20 -19
  266. package/dist/cli/{setup-FHXOLQGQ.js → setup-KTEYOCJO.js} +60 -59
  267. package/dist/cli/skills-EPZPEXI2.js +37 -0
  268. package/dist/cli/{skills-3HGHZMXB.mjs → skills-FPRID2I5.mjs} +10 -9
  269. package/dist/cli/tools-IGQQ5TML.js +57 -0
  270. package/dist/cli/{tools-P2QS6A6Q.mjs → tools-PI4WMDLY.mjs} +23 -23
  271. package/dist/cli/update-4RNCVYGE.js +37 -0
  272. package/dist/cli/{update-552BYQM4.mjs → update-VJOJAZ7B.mjs} +14 -11
  273. package/dist/cli/{views-PA25NAE3.js → views-NTUOLNQU.js} +62 -64
  274. package/dist/cli/{views-LD5HXJYY.mjs → views-OVPSINZO.mjs} +47 -49
  275. package/dist/cli/{workflow-FIDBUQV6.js → workflow-2UDYDM6F.js} +23 -23
  276. package/dist/cli/{workflow-LDYFGBYP.mjs → workflow-7OEFNXZC.mjs} +13 -13
  277. package/dist/{client-DuDFiJDU.d.mts → client-B8f7RNF8.d.mts} +1 -1
  278. package/dist/{client-t9HZAkFD.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  279. package/dist/{client-core-DydMQOft.d.mts → client-core-SLLGBTht.d.mts} +285 -23
  280. package/dist/{client-core-CJRzLanv.d.ts → client-core-p0sOxnkl.d.ts} +285 -23
  281. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  282. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  283. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  284. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  285. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  286. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  287. package/dist/index.d.mts +7 -7
  288. package/dist/index.d.ts +7 -7
  289. package/dist/index.js +66 -55
  290. package/dist/index.mjs +25 -14
  291. package/dist/install-integrity.json +162 -142
  292. package/dist/plays/bundle-play-file.d.mts +3 -3
  293. package/dist/plays/bundle-play-file.d.ts +3 -3
  294. package/dist/plays/bundle-play-file.mjs +23 -4
  295. package/dist/plays/csv-data-input.js +3 -3
  296. package/dist/plays/csv-data-input.mjs +2 -2
  297. package/dist/plays/play-description.d.mts +2 -2
  298. package/dist/plays/play-description.d.ts +2 -2
  299. package/dist/plays/run-request.d.mts +2 -2
  300. package/dist/plays/run-request.d.ts +2 -2
  301. package/dist/plays/run-request.js +4 -4
  302. package/dist/plays/run-request.mjs +3 -3
  303. package/dist/release.d.mts +1 -1
  304. package/dist/release.d.ts +1 -1
  305. package/dist/release.js +2 -2
  306. package/dist/release.mjs +1 -1
  307. package/dist/server.d.mts +4 -4
  308. package/dist/server.d.ts +4 -4
  309. package/dist/server.js +15 -13
  310. package/dist/server.mjs +9 -7
  311. package/package.json +1 -1
  312. package/dist/cli/auth-B4PI7GVY.js +0 -43
  313. package/dist/cli/concurrent-runs-help-JEFQZTJI.js +0 -21
  314. package/dist/cli/describe-PXTSBJTL.js +0 -50
  315. package/dist/cli/describe-YGMQBV44.mjs +0 -50
  316. package/dist/cli/git-I3JV7IGH.js +0 -25
  317. package/dist/cli/org-5KD7X7IA.mjs +0 -1282
  318. package/dist/cli/org-YQ2CR32B.js +0 -1282
  319. package/dist/cli/run-identity-G257GQED.js +0 -25
  320. package/dist/cli/search-2RRRF4LW.js +0 -32
  321. package/dist/cli/sessions-SBH27JNW.js +0 -22
  322. package/dist/cli/skills-Y3SRLOYD.js +0 -36
  323. package/dist/cli/tools-OFYPUPUV.js +0 -57
  324. package/dist/cli/update-SOUSCLB7.js +0 -34
@@ -17,6 +17,10 @@ export type {
17
17
  BillingEntitlements,
18
18
  IncludedCompute,
19
19
  } from '../../shared_libs/integration-contracts/billing-entitlements';
20
+ import {
21
+ resolvePublicPlanSku,
22
+ type PublicBillingPlanSku,
23
+ } from '../../shared_libs/integration-contracts/billing-plan-skus';
20
24
  import type {
21
25
  PlaySettingsResult,
22
26
  PlaySettingsPatch,
@@ -2252,6 +2256,8 @@ export type TargetBillingPlan = {
2252
2256
  | 'team-v1'
2253
2257
  | 'team-v2'
2254
2258
  | 'legacy-growth-v1';
2259
+ /** Customer-facing alias accepted by plan transitions. */
2260
+ public_sku?: PublicBillingPlanSku;
2255
2261
  name: string;
2256
2262
  display_name?: string;
2257
2263
  recurring_price_usd: number;
@@ -2266,6 +2272,14 @@ export type TargetBillingPlan = {
2266
2272
  */
2267
2273
  bonus_credits?: number | null;
2268
2274
  interval: 'month' | 'year';
2275
+ /**
2276
+ * The price of a year paid up front (`billingInterval: 'year'` on a plan
2277
+ * transition); null or absent when annual billing is not offered. Credits
2278
+ * and limits stay monthly.
2279
+ */
2280
+ annual_price_usd?: number | null;
2281
+ /** What the annual offer is called, such as "10% off"; null with no annual price. */
2282
+ annual_offer_label?: string | null;
2269
2283
  included_credits: number;
2270
2284
  /** Offered benefit terms; omitted by older API deployments. */
2271
2285
  benefits?: Partial<BillingBenefitValues>;
@@ -2276,11 +2290,18 @@ export type TargetBillingPlan = {
2276
2290
  export type TargetBillingPlansResult = {
2277
2291
  org_id: string;
2278
2292
  plans: TargetBillingPlan[];
2293
+ /** A plan may be bought by emailed invoice; absent on older APIs. */
2294
+ pay_by_invoice_available?: boolean;
2279
2295
  current_plan_sku: string;
2280
2296
  pending_plan_sku: string | null;
2297
+ pending_plan_public_sku?: PublicBillingPlanSku | null;
2281
2298
  pending_plan_display_name?: string | null;
2282
2299
  acquisition_enabled: boolean;
2283
2300
  enabled_offer_keys: TargetBillingPlan['sku'][];
2301
+ /** Enterprise terms offered to this workspace, when available. */
2302
+ enterprise_plan?:
2303
+ | (Omit<TargetBillingPlan, 'sku'> & { sku: 'enterprise-v1' })
2304
+ | null;
2284
2305
  /** The requested promo code's outcome; null or absent when none was sent. */
2285
2306
  promo_code?: {
2286
2307
  code: string;
@@ -2299,6 +2320,7 @@ export type TargetBillingStatusResult = {
2299
2320
  org_id: string;
2300
2321
  plan: {
2301
2322
  sku: string;
2323
+ public_sku?: PublicBillingPlanSku;
2302
2324
  name: string;
2303
2325
  display_name?: string;
2304
2326
  recurring_price_usd: number | null;
@@ -2340,6 +2362,10 @@ export type TargetBillingStatusResult = {
2340
2362
  pending_plan_starts_at?: string | null;
2341
2363
  /** Next cycle boundary from the current Contract’s retained cadence. */
2342
2364
  current_period_end?: string | null;
2365
+ /** 'year' while the plan is inside a prepaid annual term. */
2366
+ billing_interval?: 'month' | 'year' | null;
2367
+ /** The price of the paid year while the plan is billed annually. */
2368
+ annual_price_usd?: number | null;
2343
2369
  as_of: string | null;
2344
2370
  };
2345
2371
 
@@ -2426,15 +2452,23 @@ export type TargetBillingPlanTransitionOptions =
2426
2452
  | {
2427
2453
  action: 'start_or_change';
2428
2454
  targetPlanSku:
2429
- | 'payg-v1'
2430
- | 'builder-v1'
2431
- | 'growth-v1'
2432
- | 'growth-canary-v1'
2433
- | 'team-v1'
2434
- | 'team-v2';
2455
+ | PublicBillingPlanSku
2456
+ | TargetBillingPlan['sku']
2457
+ | 'enterprise-v1';
2435
2458
  billingEmail?: string;
2436
2459
  /** A plan promo code; an unknown, expired, or used code refuses the change. */
2437
2460
  promoCode?: string;
2461
+ /**
2462
+ * 'year' pays for a year up front; credits and limits stay monthly, and
2463
+ * a cancellation takes effect at the end of the paid year.
2464
+ */
2465
+ billingInterval?: 'month' | 'year';
2466
+ /**
2467
+ * 'invoice' emails an invoice to `billingEmail` instead of charging a
2468
+ * card; the plan starts once it is paid. Monthly or annual, from
2469
+ * Solo, when the workspace is offered it.
2470
+ */
2471
+ paymentMethod?: 'card' | 'invoice';
2438
2472
  idempotencyKey: string;
2439
2473
  }
2440
2474
  | {
@@ -2907,6 +2941,43 @@ export type BillingNamespace = {
2907
2941
  portalSession: (options?: {
2908
2942
  flow?: 'customer_update';
2909
2943
  }) => Promise<{ url: string }>;
2944
+ /** Read the company name, address and tax ID printed on invoices. */
2945
+ getDetails: () => Promise<{ data: BillingDetails }>;
2946
+ /** Set invoice billing details; omitted fields are unchanged, null clears. */
2947
+ setDetails: (
2948
+ details: BillingDetailsUpdate,
2949
+ ) => Promise<{ data: BillingDetails }>;
2950
+ };
2951
+
2952
+ export type BillingDetailsAddress = {
2953
+ line1: string | null;
2954
+ line2: string | null;
2955
+ city: string | null;
2956
+ state: string | null;
2957
+ postal_code: string | null;
2958
+ country: string | null;
2959
+ };
2960
+
2961
+ export type BillingDetails = {
2962
+ name: string | null;
2963
+ email: string | null;
2964
+ address: BillingDetailsAddress | null;
2965
+ tax_ids: Array<{ type: string; value: string }>;
2966
+ };
2967
+
2968
+ export type BillingDetailsUpdate = {
2969
+ name?: string | null;
2970
+ address?: {
2971
+ line1: string;
2972
+ line2?: string | null;
2973
+ city?: string | null;
2974
+ state?: string | null;
2975
+ postal_code?: string | null;
2976
+ /** ISO 3166-1 alpha-2 country code. */
2977
+ country: string;
2978
+ } | null;
2979
+ /** A Stripe tax ID type (eu_vat, gb_vat, us_ein, ...) and its value. */
2980
+ tax_id?: { type: string; value: string } | null;
2910
2981
  };
2911
2982
 
2912
2983
  export type BillingQuoteRequest = {
@@ -3145,7 +3216,12 @@ function playRunResultFromStatus(
3145
3216
  };
3146
3217
  }
3147
3218
 
3148
- export type ViewAccess = 'workspace' | 'public';
3219
+ /**
3220
+ * Who can open a view. `workspace`: people who can access the view's
3221
+ * workspace (a view in a named workspace only); `org`: every org member;
3222
+ * `public`: anyone with the URL.
3223
+ */
3224
+ export type ViewAccess = 'workspace' | 'org' | 'public';
3149
3225
 
3150
3226
  export type View = {
3151
3227
  id: string;
@@ -3155,6 +3231,8 @@ export type View = {
3155
3231
  play: string;
3156
3232
  input: Record<string, unknown>;
3157
3233
  access: ViewAccess;
3234
+ /** The view's workspace; null is the org's default workspace. Absent from older servers. */
3235
+ team_id?: string | null;
3158
3236
  created_at: number;
3159
3237
  updated_at: number;
3160
3238
  };
@@ -3398,6 +3476,9 @@ export class DeeplineClient {
3398
3476
  transitionPlan: (options) => this.transitionTargetBillingPlan(options),
3399
3477
  portalSession: (options) =>
3400
3478
  this.createTargetBillingPortalSession(options),
3479
+ getDetails: () => this.http.get('/api/v2/billing/details'),
3480
+ setDetails: (details) =>
3481
+ this.http.put('/api/v2/billing/details', details),
3401
3482
  };
3402
3483
  this.workspaces = {
3403
3484
  members: (options) => {
@@ -3571,6 +3652,31 @@ export class DeeplineClient {
3571
3652
  // Views
3572
3653
  // ——————————————————————————————————————————————————————————
3573
3654
 
3655
+ /**
3656
+ * Call the outcomes API. Outcomes are roles handed
3657
+ * to agents and people: a versioned spec, a feed of entries, tasks and asks
3658
+ * with states, and stakeholders. `deepline outcomes` renders these calls;
3659
+ * `deepline outcomes --help` documents each one.
3660
+ *
3661
+ * @param path - Path below `/api/v2/outcomes`, starting with `/` or empty.
3662
+ * @param options.timeout - Raise this for held requests (`wait`, `claim --wait`).
3663
+ * @param options.maxRetries - Automatic retries of a failed request. The
3664
+ * client default applies when it is left out.
3665
+ * @internal Out of the public reference while Outcomes is behind its rollout.
3666
+ */
3667
+ async outcomesApi<T = unknown>(
3668
+ method: 'GET' | 'POST' | 'PATCH' | 'DELETE',
3669
+ path: string,
3670
+ body?: unknown,
3671
+ options?: { timeout?: number; maxRetries?: number },
3672
+ ): Promise<T> {
3673
+ return await this.http.request<T>(`/api/v2/outcomes${path}`, {
3674
+ method,
3675
+ ...(method === 'GET' ? {} : { body: body ?? {} }),
3676
+ ...options,
3677
+ });
3678
+ }
3679
+
3574
3680
  /** List this workspace's views, most recently changed first. */
3575
3681
  async listViews(input?: {
3576
3682
  cursor?: string;
@@ -3616,7 +3722,7 @@ export class DeeplineClient {
3616
3722
  );
3617
3723
  }
3618
3724
 
3619
- /** Who can open a view: workspace members, or anyone with its URL. */
3725
+ /** Who can open a view: its workspace, every org member, or anyone with its URL. */
3620
3726
  async setViewAccess(id: string, access: ViewAccess): Promise<View> {
3621
3727
  return await this.http.post<View>(
3622
3728
  `/api/v2/views/${encodeURIComponent(id)}/access`,
@@ -5350,7 +5456,9 @@ export class DeeplineClient {
5350
5456
  if (!playName)
5351
5457
  throw new Error('runs.list options.steps requires options.play.');
5352
5458
  if (node)
5353
- throw new Error('runs.list options.steps cannot be combined with node.');
5459
+ throw new Error(
5460
+ 'runs.list options.steps cannot be combined with node.',
5461
+ );
5354
5462
  params.set('steps', 'true');
5355
5463
  }
5356
5464
  if (typeof options.limit === 'number' && Number.isFinite(options.limit)) {
@@ -6475,7 +6583,7 @@ export class DeeplineClient {
6475
6583
 
6476
6584
  if (!legacyTarget && name.toLowerCase() === 'default') {
6477
6585
  throw new Error(
6478
- 'Default is reserved for the workspace default notification group.',
6586
+ 'Default is reserved for the org default notification group.',
6479
6587
  );
6480
6588
  }
6481
6589
 
@@ -6570,7 +6678,7 @@ export class DeeplineClient {
6570
6678
  const connectionId = current.slackConnection.connectionId;
6571
6679
  if (slackTargets.size > 0 && !connectionId) {
6572
6680
  throw new Error(
6573
- 'Slack is not connected to this workspace. Connect it in Dashboard → Integrations, then retry.',
6681
+ 'Slack is not connected to this org. Connect it in Dashboard → Integrations, then retry.',
6574
6682
  );
6575
6683
  }
6576
6684
  const resolvedSlackTargets = await Promise.all(
@@ -7589,11 +7697,21 @@ export class DeeplineClient {
7589
7697
  ? { billing_email: options.billingEmail }
7590
7698
  : {}),
7591
7699
  ...(options.targetPlanSku
7592
- ? { target_plan_sku: options.targetPlanSku }
7700
+ ? { target_plan_sku: resolvePublicPlanSku(options.targetPlanSku) }
7593
7701
  : {}),
7594
7702
  ...(options.action === 'start_or_change' && options.promoCode
7595
7703
  ? { promo_code: options.promoCode }
7596
7704
  : {}),
7705
+ // Sent only for an annual purchase, so a monthly request's body (and
7706
+ // its idempotency hash) is unchanged.
7707
+ ...(options.action === 'start_or_change' &&
7708
+ options.billingInterval === 'year'
7709
+ ? { billing_interval: 'year' }
7710
+ : {}),
7711
+ ...(options.action === 'start_or_change' &&
7712
+ options.paymentMethod === 'invoice'
7713
+ ? { payment_method: 'invoice' }
7714
+ : {}),
7597
7715
  },
7598
7716
  { 'Idempotency-Key': idempotencyKey },
7599
7717
  { maxRetries: 0, exactUrlOnly: true },
@@ -11,7 +11,15 @@ import {
11
11
  } from 'node:fs';
12
12
  import { homedir } from 'node:os';
13
13
  import { dirname, join } from 'node:path';
14
- import { resolveApiKeyForBaseUrl, sdkCliStateDirPath } from './config.js';
14
+ import {
15
+ DEFAULT_MAX_RETRIES,
16
+ DEFAULT_TIMEOUT,
17
+ TRANSIENT_HTTP_STATUSES,
18
+ defaultRetryBackoffMs,
19
+ resolveApiKeyForBaseUrl,
20
+ sdkCliStateDirPath,
21
+ } from './config.js';
22
+ import { DeeplineError } from './errors.js';
15
23
  import { deploymentProtectionHeaders } from './deployment-protection.js';
16
24
 
17
25
  export type SdkCompatibilityStatus =
@@ -369,40 +377,55 @@ function writeCachedCompatibility(
369
377
  }
370
378
  }
371
379
 
372
- export async function checkSdkCompatibility(
373
- baseUrl: string,
374
- options: {
375
- command?: string | null;
376
- skillsVersion?: string | null;
377
- /** Blocking budget for the live request; defaults to the full timeout. */
378
- timeoutMs?: number;
379
- /** Disable cache writes and invalidation for commands that permit no local maintenance. */
380
- persistCache?: boolean;
381
- /** Stop this check when the enclosing CLI operation reaches its deadline. */
382
- signal?: AbortSignal;
383
- /** Optional read-only catalog result carried by the same live check. */
384
- catalog?: {
385
- toolId: string;
386
- cliInvocationId?: string;
387
- purpose?: 'execution_warnings';
388
- acceptMetadata: (metadata: unknown) => void;
380
+ type SdkCompatibilityRequestOptions = {
381
+ command?: string | null;
382
+ skillsVersion?: string | null;
383
+ /** Disable cache writes and invalidation for commands that permit no local maintenance. */
384
+ persistCache?: boolean;
385
+ /** Stop this check when the enclosing CLI operation reaches its deadline. */
386
+ signal?: AbortSignal;
387
+ /** Optional read-only catalog result carried by the same live check. */
388
+ catalog?: {
389
+ toolId: string;
390
+ cliInvocationId?: string;
391
+ purpose?: 'execution_warnings';
392
+ acceptMetadata: (metadata: unknown) => void;
393
+ };
394
+ };
395
+
396
+ type SdkCompatibilityAttempt =
397
+ | {
398
+ ok: true;
399
+ response: SdkCompatibilityResponse;
400
+ catalogMetadata: unknown;
401
+ }
402
+ | {
403
+ ok: false;
404
+ error: Error;
405
+ /** The request never reached a policy answer: retrying may reach one. */
406
+ transient: boolean;
389
407
  };
390
- } = {},
391
- ): Promise<{
392
- response: SdkCompatibilityResponse | null;
393
- error: Error | null;
394
- }> {
395
- if (shouldSkipCompatibilityCheck()) {
396
- return { response: null, error: null };
397
- }
408
+
409
+ function asError(error: unknown): Error {
410
+ return error instanceof Error ? error : new Error(String(error));
411
+ }
412
+
413
+ /**
414
+ * One live compatibility request bounded by `timeoutMs`. A transport failure
415
+ * or this attempt's own timeout is a transient miss; the enclosing
416
+ * operation's `signal` throws its own reason instead.
417
+ */
418
+ async function attemptSdkCompatibility(
419
+ baseUrl: string,
420
+ options: SdkCompatibilityRequestOptions,
421
+ timeoutMs: number,
422
+ ): Promise<SdkCompatibilityAttempt> {
398
423
  const controller = new AbortController();
399
424
  const abortFromCaller = () => controller.abort(options.signal?.reason);
400
425
  if (options.signal?.aborted) abortFromCaller();
401
- else options.signal?.addEventListener('abort', abortFromCaller, { once: true });
402
- const timeout = setTimeout(
403
- () => controller.abort(),
404
- options.timeoutMs ?? CHECK_TIMEOUT_MS,
405
- );
426
+ else
427
+ options.signal?.addEventListener('abort', abortFromCaller, { once: true });
428
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
406
429
  try {
407
430
  const url = new URL('/api/v2/sdk/compat', baseUrl);
408
431
  url.searchParams.set('version', SDK_VERSION);
@@ -441,76 +464,205 @@ export async function checkSdkCompatibility(
441
464
  },
442
465
  signal: controller.signal,
443
466
  });
444
- const raw = (await response.json().catch(() => null)) as
445
- | (SdkCompatibilityResponse & { catalog_metadata?: unknown })
446
- | null;
447
- options.signal?.throwIfAborted();
467
+ // A connection lost or timed out while the body streams is a missed
468
+ // answer, not a junk body: the read stays inside the transport boundary.
469
+ const text = await response.text();
470
+ controller.signal.throwIfAborted();
471
+ type PolicyBody = SdkCompatibilityResponse & { catalog_metadata?: unknown };
472
+ let raw: PolicyBody | null;
473
+ try {
474
+ raw = JSON.parse(text) as PolicyBody | null;
475
+ } catch {
476
+ raw = null;
477
+ }
448
478
  // Only a policy-shaped body counts as a response. A JSON error page from
449
479
  // a proxy is a failed check: it is never cached, and it falls through to
450
- // the cached-policy fallback below like a network error would.
480
+ // the cached-policy fallback like a network error would.
451
481
  if (!raw || typeof raw.ok !== 'boolean' || typeof raw.status !== 'string') {
452
- throw new Error(
453
- `SDK compatibility endpoint returned a non-policy response (HTTP ${response.status}).`,
454
- );
482
+ return {
483
+ ok: false,
484
+ transient: TRANSIENT_HTTP_STATUSES.has(response.status),
485
+ error: new Error(
486
+ `SDK compatibility endpoint returned a non-policy response (HTTP ${response.status}).`,
487
+ ),
488
+ };
455
489
  }
456
490
  // Catalog results belong to this command only, never the policy cache.
457
491
  const { catalog_metadata: catalogMetadata, ...data } = raw;
458
- if (options.persistCache !== false) {
459
- writeCachedCompatibility(
460
- baseUrl,
461
- options.command,
462
- options.skillsVersion,
463
- data,
464
- );
465
- }
466
- if (
467
- data.ok &&
468
- options.catalog &&
469
- catalogMetadata &&
470
- typeof catalogMetadata === 'object' &&
471
- 'toolId' in catalogMetadata &&
472
- catalogMetadata.toolId === options.catalog.toolId
473
- ) {
474
- options.catalog.acceptMetadata(catalogMetadata);
475
- }
476
- return { response: data, error: null };
492
+ return { ok: true, response: data, catalogMetadata };
477
493
  } catch (error) {
478
- if (options.signal?.aborted) {
479
- return {
480
- response: null,
481
- error: error instanceof Error ? error : new Error(String(error)),
482
- };
483
- }
484
- // Live compat policy must win when the server is reachable: rollback and
485
- // support-floor changes are blocking controls. The cache is only a
486
- // resilience fallback for transient network failures.
487
- const cached = readCachedCompatibility(
494
+ options.signal?.throwIfAborted();
495
+ return { ok: false, transient: true, error: asError(error) };
496
+ } finally {
497
+ clearTimeout(timeout);
498
+ options.signal?.removeEventListener('abort', abortFromCaller);
499
+ }
500
+ }
501
+
502
+ /** Cache a live policy and hand its catalog result to the caller. */
503
+ function acceptSdkCompatibility(
504
+ baseUrl: string,
505
+ options: SdkCompatibilityRequestOptions,
506
+ attempt: Extract<SdkCompatibilityAttempt, { ok: true }>,
507
+ ): SdkCompatibilityResponse {
508
+ const { response: data, catalogMetadata } = attempt;
509
+ if (options.persistCache !== false) {
510
+ writeCachedCompatibility(
488
511
  baseUrl,
489
512
  options.command,
490
513
  options.skillsVersion,
514
+ data,
491
515
  );
492
- if (cached) {
493
- if (
494
- options.persistCache !== false &&
495
- options.timeoutMs !== undefined &&
496
- options.timeoutMs < CHECK_TIMEOUT_MS
497
- ) {
498
- invalidateCachedCompatibility(
499
- baseUrl,
500
- options.command,
501
- options.skillsVersion,
502
- );
503
- }
504
- return { response: cached, error: null };
505
- }
516
+ }
517
+ if (
518
+ data.ok &&
519
+ options.catalog &&
520
+ catalogMetadata &&
521
+ typeof catalogMetadata === 'object' &&
522
+ 'toolId' in catalogMetadata &&
523
+ catalogMetadata.toolId === options.catalog.toolId
524
+ ) {
525
+ options.catalog.acceptMetadata(catalogMetadata);
526
+ }
527
+ return data;
528
+ }
529
+
530
+ /**
531
+ * Advisory compatibility check: one live request on a short budget. A failed
532
+ * check returns its `error` so the caller can run with no policy (or the
533
+ * cached one); it is never a reason to fail the command. `live` is true only
534
+ * when the server answered this request. A command that must not run without
535
+ * a live policy uses `requireSdkCompatibility` instead.
536
+ */
537
+ export async function checkSdkCompatibility(
538
+ baseUrl: string,
539
+ options: SdkCompatibilityRequestOptions & {
540
+ /** Blocking budget for the live request; defaults to the full timeout. */
541
+ timeoutMs?: number;
542
+ } = {},
543
+ ): Promise<{
544
+ response: SdkCompatibilityResponse | null;
545
+ error: Error | null;
546
+ live: boolean;
547
+ }> {
548
+ if (shouldSkipCompatibilityCheck()) {
549
+ return { response: null, error: null, live: false };
550
+ }
551
+ let attempt: SdkCompatibilityAttempt;
552
+ try {
553
+ attempt = await attemptSdkCompatibility(
554
+ baseUrl,
555
+ options,
556
+ options.timeoutMs ?? CHECK_TIMEOUT_MS,
557
+ );
558
+ } catch (error) {
559
+ // The enclosing operation's deadline: no cached fallback.
560
+ return { response: null, error: asError(error), live: false };
561
+ }
562
+ if (attempt.ok) {
506
563
  return {
507
- response: null,
508
- error: error instanceof Error ? error : new Error(String(error)),
564
+ response: acceptSdkCompatibility(baseUrl, options, attempt),
565
+ error: null,
566
+ live: true,
509
567
  };
510
- } finally {
511
- clearTimeout(timeout);
512
- options.signal?.removeEventListener('abort', abortFromCaller);
513
568
  }
569
+ // Live compat policy must win when the server is reachable: rollback and
570
+ // support-floor changes are blocking controls. The cache is only a
571
+ // resilience fallback for transient network failures.
572
+ const cached = readCachedCompatibility(
573
+ baseUrl,
574
+ options.command,
575
+ options.skillsVersion,
576
+ );
577
+ if (cached) {
578
+ if (
579
+ options.persistCache !== false &&
580
+ options.timeoutMs !== undefined &&
581
+ options.timeoutMs < CHECK_TIMEOUT_MS
582
+ ) {
583
+ invalidateCachedCompatibility(
584
+ baseUrl,
585
+ options.command,
586
+ options.skillsVersion,
587
+ );
588
+ }
589
+ return { response: cached, error: null, live: false };
590
+ }
591
+ return { response: null, error: attempt.error, live: false };
592
+ }
593
+
594
+ /**
595
+ * Compatibility policy for a command that must not run without one: file
596
+ * staging, imported publication, or an older server's admission. The short
597
+ * advisory budget fits only callers for which a timeout means "run with no
598
+ * policy"; here a timeout would fail the command, so a slow but healthy server
599
+ * must not be read as a verdict. Each attempt gets the ordinary request
600
+ * budget, and a transport failure, attempt timeout or gateway/rate-limit
601
+ * status is "not yet": it retries with the same backoff and retry count as
602
+ * every other SDK request. The enclosing operation's `signal` ends the wait
603
+ * with its own reason. When no attempt reaches a policy, a cached policy is
604
+ * the same resilience fallback the advisory check uses; with none, the command
605
+ * fails with `SDK_COMPATIBILITY_UNAVAILABLE` naming the last cause.
606
+ *
607
+ * Returns null only when the check is disabled by environment.
608
+ */
609
+ export async function requireSdkCompatibility(
610
+ baseUrl: string,
611
+ options: SdkCompatibilityRequestOptions & {
612
+ /** Per-attempt budget; defaults to the SDK request timeout. */
613
+ attemptTimeoutMs?: number;
614
+ /** Retries after a transient miss; defaults to the SDK retry count. */
615
+ maxRetries?: number;
616
+ /** Backoff before retry `n` (1-based); defaults to the SDK backoff. */
617
+ backoffMs?: (retry: number) => number;
618
+ } = {},
619
+ ): Promise<SdkCompatibilityResponse | null> {
620
+ if (shouldSkipCompatibilityCheck()) return null;
621
+ const maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
622
+ const backoffMs = options.backoffMs ?? defaultRetryBackoffMs;
623
+ let attempt: SdkCompatibilityAttempt;
624
+ let attempts = 0;
625
+ for (;;) {
626
+ attempts += 1;
627
+ attempt = await attemptSdkCompatibility(
628
+ baseUrl,
629
+ options,
630
+ options.attemptTimeoutMs ?? DEFAULT_TIMEOUT,
631
+ );
632
+ if (attempt.ok) return acceptSdkCompatibility(baseUrl, options, attempt);
633
+ if (!attempt.transient || attempts > maxRetries) break;
634
+ await sleepUnlessAborted(backoffMs(attempts), options.signal);
635
+ }
636
+ const cached = readCachedCompatibility(
637
+ baseUrl,
638
+ options.command,
639
+ options.skillsVersion,
640
+ );
641
+ if (cached) return cached;
642
+ throw Object.assign(
643
+ new DeeplineError(
644
+ `Could not read the Deepline SDK compatibility policy from ${baseUrl} after ${attempts} attempt${attempts === 1 ? '' : 's'}: ${attempt.error.message}`,
645
+ undefined,
646
+ 'SDK_COMPATIBILITY_UNAVAILABLE',
647
+ { attempts, transient: attempt.transient },
648
+ ),
649
+ { cause: attempt.error },
650
+ );
651
+ }
652
+
653
+ function sleepUnlessAborted(ms: number, signal?: AbortSignal): Promise<void> {
654
+ signal?.throwIfAborted();
655
+ return new Promise((resolve, reject) => {
656
+ const onAbort = () => {
657
+ clearTimeout(timer);
658
+ reject(signal?.reason);
659
+ };
660
+ const timer = setTimeout(() => {
661
+ signal?.removeEventListener('abort', onAbort);
662
+ resolve();
663
+ }, ms);
664
+ signal?.addEventListener('abort', onAbort, { once: true });
665
+ });
514
666
  }
515
667
 
516
668
  /**