deepline 0.3.552 → 0.3.554

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 (323) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +107 -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 +118 -8
  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 +8 -1
  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 +9 -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-resource-failure.ts +26 -3
  43. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  45. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  46. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  47. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  49. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  50. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  51. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  52. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  53. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  54. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +168 -41
  55. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  56. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  57. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  58. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  60. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +444 -39
  61. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  64. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  65. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  67. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +72 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  71. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  73. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  74. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  78. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  79. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +254 -44
  82. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  83. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  86. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +259 -52
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +30 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  108. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  109. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  113. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  114. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  116. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  117. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  118. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  119. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  120. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  121. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  122. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  123. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  124. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  125. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  126. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  127. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  128. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  129. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  130. package/dist/cli/{auth-KVSBJZOX.mjs → auth-HJUNW7T2.mjs} +8 -7
  131. package/dist/cli/auth-SP6SKZJZ.js +44 -0
  132. package/dist/cli/{billing-FQREA7UA.js → billing-4TSA5HEC.js} +297 -161
  133. package/dist/cli/{billing-54RHFEBI.mjs → billing-SJYRJAQ2.mjs} +197 -61
  134. package/dist/cli/{chunk-4MK42735.js → chunk-2HMN5H54.js} +215 -130
  135. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  136. package/dist/cli/{chunk-EOPEYCY7.mjs → chunk-2ORPFQUA.mjs} +18 -18
  137. package/dist/cli/{chunk-RQZQVFCJ.js → chunk-2OVHNHCF.js} +2 -2
  138. package/dist/cli/{chunk-QX7LFGJR.mjs → chunk-33WRQSQ2.mjs} +1874 -91
  139. package/dist/cli/{chunk-UPMRIVZB.js → chunk-3IKGZ4CG.js} +74 -13
  140. package/dist/cli/{chunk-EUPVF4SU.mjs → chunk-3Z4VFCXO.mjs} +8 -8
  141. package/dist/cli/{chunk-GKYAYLRI.js → chunk-4DOFGIEJ.js} +27 -31
  142. package/dist/cli/{chunk-4TALT2M3.mjs → chunk-52Q5KETX.mjs} +69 -3
  143. package/dist/cli/{chunk-RBEUVDZF.js → chunk-5CYZHOKI.js} +249 -107
  144. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  145. package/dist/cli/{chunk-IYSTRCLX.mjs → chunk-62AUAWQV.mjs} +4 -4
  146. package/dist/cli/{chunk-ZIAXDBXX.mjs → chunk-62HWJXST.mjs} +17 -21
  147. package/dist/cli/{chunk-QY3ZNU6Z.mjs → chunk-6EXOAT6T.mjs} +2 -2
  148. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  149. package/dist/cli/{chunk-ADRC5I3R.js → chunk-7OWI736E.js} +30 -30
  150. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  151. package/dist/cli/{chunk-PTVD2GVQ.mjs → chunk-B6HO2XWH.mjs} +13 -13
  152. package/dist/cli/{chunk-YJHE3O5M.mjs → chunk-BOZAP2EM.mjs} +141 -56
  153. package/dist/cli/chunk-BVXIGOBZ.js +32 -0
  154. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  155. package/dist/cli/{chunk-WE5HES3H.mjs → chunk-D6Z6POKE.mjs} +151 -43
  156. package/dist/cli/{chunk-AZQ264ID.mjs → chunk-DSKSFFK2.mjs} +1 -1
  157. package/dist/cli/{chunk-SHLFOPD6.js → chunk-DUBXUAAO.js} +5 -5
  158. package/dist/cli/{chunk-V436Z54K.js → chunk-E2G2DNAB.js} +3 -1
  159. package/dist/cli/{chunk-HO3XK3R7.js → chunk-E74KGKFZ.js} +8 -8
  160. package/dist/cli/{chunk-77AAAGVB.js → chunk-ECHKAC7M.js} +2 -2
  161. package/dist/cli/{chunk-KWSH5T7K.js → chunk-EN5NHCCQ.js} +21 -21
  162. package/dist/cli/{chunk-6RZOWL2V.mjs → chunk-F7CMRKSK.mjs} +1 -1
  163. package/dist/cli/{chunk-JWUAX6OP.js → chunk-FBAFX43W.js} +11 -11
  164. package/dist/cli/{chunk-AQWQ2BFX.mjs → chunk-FXQ3JKE3.mjs} +1 -1
  165. package/dist/cli/{chunk-QPKH23EC.mjs → chunk-GA2M3G3Y.mjs} +5 -5
  166. package/dist/cli/{chunk-G4O75EXF.js → chunk-GHT2NDL7.js} +18 -18
  167. package/dist/cli/{chunk-MF2GHZDO.js → chunk-GRZENGNE.js} +2 -2
  168. package/dist/cli/{chunk-4UUR4TCH.js → chunk-IVZKMJUK.js} +1875 -92
  169. package/dist/cli/{chunk-FTJLJCE5.mjs → chunk-KVBQY4ST.mjs} +3 -3
  170. package/dist/cli/{chunk-S5S355UY.mjs → chunk-KZHBDMGF.mjs} +12 -12
  171. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  172. package/dist/cli/{chunk-6ZORHRKB.mjs → chunk-LRZGS6RZ.mjs} +2 -0
  173. package/dist/cli/{chunk-2WFPHBR4.js → chunk-LY5MMXFF.js} +47 -29
  174. package/dist/cli/{chunk-BAIST2BR.js → chunk-M7STM3MZ.js} +36 -36
  175. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  176. package/dist/cli/{chunk-45PVGZST.js → chunk-OPTV7D2V.js} +508 -361
  177. package/dist/cli/{chunk-PFO3ISXA.js → chunk-OVEYWO4H.js} +174 -129
  178. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-PC2FTUCP.mjs} +4 -4
  179. package/dist/cli/{chunk-WLN3SUIA.js → chunk-PQQMPUCZ.js} +3 -3
  180. package/dist/cli/{chunk-HYC4MKGK.mjs → chunk-Q7ACILL2.mjs} +5 -5
  181. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  182. package/dist/cli/{chunk-57VZVF5D.mjs → chunk-RBBTCYQB.mjs} +3 -3
  183. package/dist/cli/{chunk-F2LH7TGF.js → chunk-RTHMGSZX.js} +21 -21
  184. package/dist/cli/{chunk-YLTMXJFC.mjs → chunk-S6W6SJ6E.mjs} +158 -16
  185. package/dist/cli/chunk-STXDSVQZ.mjs +32 -0
  186. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-TGUQET3O.mjs} +67 -6
  187. package/dist/cli/{chunk-IHRKLXZN.js → chunk-TJ6HLN56.js} +5 -5
  188. package/dist/cli/{chunk-3FD5EQ62.js → chunk-TOO3YM5N.js} +6 -7
  189. package/dist/cli/{chunk-QILKGXYF.mjs → chunk-UBBYHB2B.mjs} +2 -2
  190. package/dist/cli/{chunk-6PRW5UBA.mjs → chunk-UC4BDZKI.mjs} +299 -69
  191. package/dist/cli/{chunk-634ZDA3F.js → chunk-UNNOZKRT.js} +1 -1
  192. package/dist/cli/{chunk-IDVVIXPJ.js → chunk-UOT7HPBH.js} +41 -41
  193. package/dist/cli/{chunk-6YCA5NKJ.js → chunk-UYCZFQYQ.js} +12 -12
  194. package/dist/cli/{chunk-7IKQKKNX.js → chunk-VIUUTEHY.js} +90 -24
  195. package/dist/cli/{chunk-Z5TSLLOW.mjs → chunk-VLO5NFH2.mjs} +63 -18
  196. package/dist/cli/{chunk-U7QRMBIY.mjs → chunk-VQ75KX7G.mjs} +5 -5
  197. package/dist/cli/{chunk-4NQF6KJ3.js → chunk-VV4XGZ24.js} +13 -13
  198. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  199. package/dist/cli/{chunk-S46HWQKO.js → chunk-W6CZDTIR.js} +69 -69
  200. package/dist/cli/{chunk-XVB7V4N7.js → chunk-WL7P32PI.js} +161 -53
  201. package/dist/cli/{chunk-DJ2JDK4O.mjs → chunk-XD3MFTHA.mjs} +1 -1
  202. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-XFZX6FNM.mjs} +40 -22
  203. package/dist/cli/{chunk-AWJPDPMA.mjs → chunk-XU6QNM4D.mjs} +1 -1
  204. package/dist/cli/{chunk-QAORXEY3.mjs → chunk-YCOGPOUX.mjs} +6 -7
  205. package/dist/cli/{chunk-VQALXEXO.js → chunk-YQKCH4R7.js} +348 -118
  206. package/dist/cli/{chunk-6O5HOODW.mjs → chunk-YY55NYAH.mjs} +207 -60
  207. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  208. package/dist/cli/command-docs.js +3 -3
  209. package/dist/cli/command-docs.mjs +2 -2
  210. package/dist/cli/{concurrent-runs-help-Q4KPAUJX.mjs → concurrent-runs-help-O3Q5IPLF.mjs} +9 -8
  211. package/dist/cli/concurrent-runs-help-ZFRZWX5V.js +22 -0
  212. package/dist/cli/{csv-F5VAGX4K.js → csv-4ZQ2RATI.js} +16 -15
  213. package/dist/cli/{csv-2PTVDNO6.mjs → csv-Y3BFPEM6.mjs} +7 -6
  214. package/dist/cli/{db-IEDXAUF7.mjs → db-3JYY4JNN.mjs} +17 -17
  215. package/dist/cli/{db-Z3OIUFMM.js → db-VEIFS4M7.js} +45 -45
  216. package/dist/cli/describe-EVJ4MFVU.mjs +50 -0
  217. package/dist/cli/describe-FG625QPF.js +50 -0
  218. package/dist/cli/describe-core.d.mts +3 -3
  219. package/dist/cli/describe-core.d.ts +3 -3
  220. package/dist/cli/describe-core.js +7 -7
  221. package/dist/cli/describe-core.mjs +6 -6
  222. package/dist/cli/{executions-H6H5655J.js → executions-HPZXOOVX.js} +12 -12
  223. package/dist/cli/{executions-R3LP74QN.mjs → executions-PCXZKEHM.mjs} +10 -10
  224. package/dist/cli/{feedback-WL3MRVT5.mjs → feedback-Y6VKZNY6.mjs} +9 -8
  225. package/dist/cli/{feedback-VFOUR66B.js → feedback-ZKFHFVL6.js} +17 -16
  226. package/dist/cli/git-RUBMALLH.js +26 -0
  227. package/dist/cli/{git-YX2J4GCI.mjs → git-UMPR2QYC.mjs} +8 -7
  228. package/dist/cli/index.js +170 -158
  229. package/dist/cli/index.mjs +60 -48
  230. package/dist/cli/{integrations-E2JZYKHS.js → integrations-3GQCTRTF.js} +23 -27
  231. package/dist/cli/{integrations-5ZK5KLVP.mjs → integrations-V3TM6XAB.mjs} +15 -19
  232. package/dist/cli/{legacy-noops-SMN3GSXY.mjs → legacy-noops-JZBUD7ZE.mjs} +9 -8
  233. package/dist/cli/{legacy-noops-3VW4IJTH.js → legacy-noops-VYCO7NGW.js} +12 -11
  234. package/dist/cli/{mcp-UQV2K4EW.js → mcp-4OIWTCE6.js} +121 -48
  235. package/dist/cli/{mcp-V6MGCYAG.mjs → mcp-PH4KZ76P.mjs} +100 -27
  236. package/dist/cli/{monitors-R3BBDCRC.js → monitors-E2A6VPBY.js} +221 -186
  237. package/dist/cli/{monitors-GGKS5W6M.mjs → monitors-SSMGIDGX.mjs} +58 -23
  238. package/dist/cli/org-SFDKSK5D.mjs +2289 -0
  239. package/dist/cli/org-WUDZGWBT.js +2289 -0
  240. package/dist/cli/outcomes-QT7LQBPK.mjs +2865 -0
  241. package/dist/cli/outcomes-Y7SZTLSL.js +2865 -0
  242. package/dist/cli/{play-MDWPR4XG.mjs → play-EK7KSFPL.mjs} +376 -106
  243. package/dist/cli/{play-2MVO27VO.js → play-GDNHCRRR.js} +1150 -880
  244. package/dist/cli/{providers-AKDYFZJZ.mjs → providers-FVZLRXAU.mjs} +10 -10
  245. package/dist/cli/{providers-2AACRUZH.js → providers-ZKOSECLV.js} +13 -13
  246. package/dist/cli/{quickstart-H6IV3PV3.js → quickstart-KSDKIXYD.js} +9 -8
  247. package/dist/cli/{quickstart-QDGRJFZY.mjs → quickstart-UJZ6PIQV.mjs} +7 -6
  248. package/dist/cli/{run-RTSQNGRD.mjs → run-E7MZ7P35.mjs} +35 -33
  249. package/dist/cli/{run-2634REDK.js → run-PD2BBG6S.js} +55 -53
  250. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  251. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  252. package/dist/cli/search-TKSPTPHA.js +32 -0
  253. package/dist/cli/{search-6AOJ4XPP.mjs → search-VTFUFTOY.mjs} +11 -11
  254. package/dist/cli/{search-output-S5ODBL5E.js → search-output-G2AGDCOY.js} +13 -12
  255. package/dist/cli/{search-output-6ADMTOU5.mjs → search-output-PFVXQCWA.mjs} +10 -9
  256. package/dist/cli/{secrets-TFIFBFB3.mjs → secrets-7CIMEMX7.mjs} +11 -11
  257. package/dist/cli/{secrets-LHCIIHMT.js → secrets-BCOQ4U7U.js} +20 -20
  258. package/dist/cli/sessions-4CO556VD.js +23 -0
  259. package/dist/cli/{sessions-WHBVUHVW.mjs → sessions-IUCQZEF7.mjs} +9 -8
  260. package/dist/cli/{settings-EBONWL5C.mjs → settings-KZN62UQK.mjs} +16 -16
  261. package/dist/cli/{settings-CP4FVK2W.js → settings-REL4736M.js} +89 -89
  262. package/dist/cli/{setup-I5AZE3IU.mjs → setup-2P7OG3OU.mjs} +22 -24
  263. package/dist/cli/{setup-LFGHTNLQ.js → setup-2XIVBBCS.js} +62 -64
  264. package/dist/cli/skills-JYT5DEY6.js +37 -0
  265. package/dist/cli/{skills-W76AO5XE.mjs → skills-VIGNDJKI.mjs} +10 -9
  266. package/dist/cli/tools-NTVUQ2TG.js +57 -0
  267. package/dist/cli/{tools-7IJHGF6W.mjs → tools-W3QT5EJY.mjs} +24 -24
  268. package/dist/cli/{update-GFOPZTHY.mjs → update-GZVBVMY3.mjs} +14 -11
  269. package/dist/cli/update-TWJZPUZM.js +37 -0
  270. package/dist/cli/{views-D4NX4SBG.mjs → views-BOGEH424.mjs} +47 -49
  271. package/dist/cli/{views-BPL2TQJ4.js → views-TOLJNLSV.js} +62 -64
  272. package/dist/cli/{workflow-ZYNAUCKC.js → workflow-ENWFRK5M.js} +23 -23
  273. package/dist/cli/{workflow-YXP42FUI.mjs → workflow-VDG2FDQV.mjs} +13 -13
  274. package/dist/{client-CyXGrO4D.d.mts → client-B8f7RNF8.d.mts} +1 -1
  275. package/dist/{client-Bf3IpUKN.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  276. package/dist/{client-core-BxsLnXlm.d.mts → client-core-SLLGBTht.d.mts} +268 -23
  277. package/dist/{client-core-BWd0lX0Z.d.ts → client-core-p0sOxnkl.d.ts} +268 -23
  278. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  279. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  280. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  281. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  282. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  283. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  284. package/dist/index.d.mts +7 -7
  285. package/dist/index.d.ts +7 -7
  286. package/dist/index.js +66 -55
  287. package/dist/index.mjs +25 -14
  288. package/dist/install-integrity.json +163 -144
  289. package/dist/plays/bundle-play-file.d.mts +3 -3
  290. package/dist/plays/bundle-play-file.d.ts +3 -3
  291. package/dist/plays/bundle-play-file.mjs +23 -4
  292. package/dist/plays/csv-data-input.js +3 -3
  293. package/dist/plays/csv-data-input.mjs +2 -2
  294. package/dist/plays/play-description.d.mts +2 -2
  295. package/dist/plays/play-description.d.ts +2 -2
  296. package/dist/plays/run-request.d.mts +2 -2
  297. package/dist/plays/run-request.d.ts +2 -2
  298. package/dist/plays/run-request.js +4 -4
  299. package/dist/plays/run-request.mjs +3 -3
  300. package/dist/release.d.mts +1 -1
  301. package/dist/release.d.ts +1 -1
  302. package/dist/release.js +2 -2
  303. package/dist/release.mjs +1 -1
  304. package/dist/server.d.mts +4 -4
  305. package/dist/server.d.ts +4 -4
  306. package/dist/server.js +15 -13
  307. package/dist/server.mjs +9 -7
  308. package/package.json +1 -1
  309. package/dist/cli/auth-MMNVWATX.js +0 -43
  310. package/dist/cli/chunk-AID3OYVJ.js +0 -8
  311. package/dist/cli/chunk-OVDNJAJN.mjs +0 -8
  312. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +0 -21
  313. package/dist/cli/describe-QDANCTS3.mjs +0 -50
  314. package/dist/cli/describe-VUTT5ZKU.js +0 -50
  315. package/dist/cli/git-ETB3GH3K.js +0 -25
  316. package/dist/cli/org-GRYVMNSW.js +0 -1282
  317. package/dist/cli/org-Z37NGJV4.mjs +0 -1282
  318. package/dist/cli/run-identity-G257GQED.js +0 -25
  319. package/dist/cli/search-VTW2YNBS.js +0 -32
  320. package/dist/cli/sessions-CJ4FJ2WB.js +0 -22
  321. package/dist/cli/skills-R7EBXREW.js +0 -36
  322. package/dist/cli/tools-V7U2BDXM.js +0 -57
  323. package/dist/cli/update-4COPZETK.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;
@@ -2284,11 +2290,18 @@ export type TargetBillingPlan = {
2284
2290
  export type TargetBillingPlansResult = {
2285
2291
  org_id: string;
2286
2292
  plans: TargetBillingPlan[];
2293
+ /** A plan may be bought by emailed invoice; absent on older APIs. */
2294
+ pay_by_invoice_available?: boolean;
2287
2295
  current_plan_sku: string;
2288
2296
  pending_plan_sku: string | null;
2297
+ pending_plan_public_sku?: PublicBillingPlanSku | null;
2289
2298
  pending_plan_display_name?: string | null;
2290
2299
  acquisition_enabled: boolean;
2291
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;
2292
2305
  /** The requested promo code's outcome; null or absent when none was sent. */
2293
2306
  promo_code?: {
2294
2307
  code: string;
@@ -2307,6 +2320,7 @@ export type TargetBillingStatusResult = {
2307
2320
  org_id: string;
2308
2321
  plan: {
2309
2322
  sku: string;
2323
+ public_sku?: PublicBillingPlanSku;
2310
2324
  name: string;
2311
2325
  display_name?: string;
2312
2326
  recurring_price_usd: number | null;
@@ -2438,12 +2452,9 @@ export type TargetBillingPlanTransitionOptions =
2438
2452
  | {
2439
2453
  action: 'start_or_change';
2440
2454
  targetPlanSku:
2441
- | 'payg-v1'
2442
- | 'builder-v1'
2443
- | 'growth-v1'
2444
- | 'growth-canary-v1'
2445
- | 'team-v1'
2446
- | 'team-v2';
2455
+ | PublicBillingPlanSku
2456
+ | TargetBillingPlan['sku']
2457
+ | 'enterprise-v1';
2447
2458
  billingEmail?: string;
2448
2459
  /** A plan promo code; an unknown, expired, or used code refuses the change. */
2449
2460
  promoCode?: string;
@@ -2452,6 +2463,12 @@ export type TargetBillingPlanTransitionOptions =
2452
2463
  * a cancellation takes effect at the end of the paid year.
2453
2464
  */
2454
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';
2455
2472
  idempotencyKey: string;
2456
2473
  }
2457
2474
  | {
@@ -2924,6 +2941,43 @@ export type BillingNamespace = {
2924
2941
  portalSession: (options?: {
2925
2942
  flow?: 'customer_update';
2926
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;
2927
2981
  };
2928
2982
 
2929
2983
  export type BillingQuoteRequest = {
@@ -3162,7 +3216,12 @@ function playRunResultFromStatus(
3162
3216
  };
3163
3217
  }
3164
3218
 
3165
- 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';
3166
3225
 
3167
3226
  export type View = {
3168
3227
  id: string;
@@ -3172,6 +3231,8 @@ export type View = {
3172
3231
  play: string;
3173
3232
  input: Record<string, unknown>;
3174
3233
  access: ViewAccess;
3234
+ /** The view's workspace; null is the org's default workspace. Absent from older servers. */
3235
+ team_id?: string | null;
3175
3236
  created_at: number;
3176
3237
  updated_at: number;
3177
3238
  };
@@ -3415,6 +3476,9 @@ export class DeeplineClient {
3415
3476
  transitionPlan: (options) => this.transitionTargetBillingPlan(options),
3416
3477
  portalSession: (options) =>
3417
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),
3418
3482
  };
3419
3483
  this.workspaces = {
3420
3484
  members: (options) => {
@@ -3588,6 +3652,31 @@ export class DeeplineClient {
3588
3652
  // Views
3589
3653
  // ——————————————————————————————————————————————————————————
3590
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
+
3591
3680
  /** List this workspace's views, most recently changed first. */
3592
3681
  async listViews(input?: {
3593
3682
  cursor?: string;
@@ -3633,7 +3722,7 @@ export class DeeplineClient {
3633
3722
  );
3634
3723
  }
3635
3724
 
3636
- /** 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. */
3637
3726
  async setViewAccess(id: string, access: ViewAccess): Promise<View> {
3638
3727
  return await this.http.post<View>(
3639
3728
  `/api/v2/views/${encodeURIComponent(id)}/access`,
@@ -5367,7 +5456,9 @@ export class DeeplineClient {
5367
5456
  if (!playName)
5368
5457
  throw new Error('runs.list options.steps requires options.play.');
5369
5458
  if (node)
5370
- 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
+ );
5371
5462
  params.set('steps', 'true');
5372
5463
  }
5373
5464
  if (typeof options.limit === 'number' && Number.isFinite(options.limit)) {
@@ -6492,7 +6583,7 @@ export class DeeplineClient {
6492
6583
 
6493
6584
  if (!legacyTarget && name.toLowerCase() === 'default') {
6494
6585
  throw new Error(
6495
- 'Default is reserved for the workspace default notification group.',
6586
+ 'Default is reserved for the org default notification group.',
6496
6587
  );
6497
6588
  }
6498
6589
 
@@ -6587,7 +6678,7 @@ export class DeeplineClient {
6587
6678
  const connectionId = current.slackConnection.connectionId;
6588
6679
  if (slackTargets.size > 0 && !connectionId) {
6589
6680
  throw new Error(
6590
- '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.',
6591
6682
  );
6592
6683
  }
6593
6684
  const resolvedSlackTargets = await Promise.all(
@@ -7606,7 +7697,7 @@ export class DeeplineClient {
7606
7697
  ? { billing_email: options.billingEmail }
7607
7698
  : {}),
7608
7699
  ...(options.targetPlanSku
7609
- ? { target_plan_sku: options.targetPlanSku }
7700
+ ? { target_plan_sku: resolvePublicPlanSku(options.targetPlanSku) }
7610
7701
  : {}),
7611
7702
  ...(options.action === 'start_or_change' && options.promoCode
7612
7703
  ? { promo_code: options.promoCode }
@@ -7617,6 +7708,10 @@ export class DeeplineClient {
7617
7708
  options.billingInterval === 'year'
7618
7709
  ? { billing_interval: 'year' }
7619
7710
  : {}),
7711
+ ...(options.action === 'start_or_change' &&
7712
+ options.paymentMethod === 'invoice'
7713
+ ? { payment_method: 'invoice' }
7714
+ : {}),
7620
7715
  },
7621
7716
  { 'Idempotency-Key': idempotencyKey },
7622
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
  /**