deepline 0.3.408 → 0.3.410

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 (217) hide show
  1. package/dist/bundling-sources/sdk/src/agent-runtime.ts +18 -1
  2. package/dist/bundling-sources/sdk/src/client.ts +212 -334
  3. package/dist/bundling-sources/sdk/src/compat.ts +45 -2
  4. package/dist/bundling-sources/sdk/src/db/query.ts +9 -10
  5. package/dist/bundling-sources/sdk/src/http.ts +38 -20
  6. package/dist/bundling-sources/sdk/src/index.ts +4 -5
  7. package/dist/bundling-sources/sdk/src/play.ts +10 -10
  8. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +6 -4
  9. package/dist/bundling-sources/sdk/src/plays/check-local-play-graph.ts +114 -0
  10. package/dist/bundling-sources/sdk/src/plays/client.ts +431 -0
  11. package/dist/bundling-sources/sdk/src/plays/local-play-execution.ts +2 -2
  12. package/dist/bundling-sources/sdk/src/plays/run-request.ts +106 -16
  13. package/dist/bundling-sources/sdk/src/release.ts +13 -7
  14. package/dist/bundling-sources/sdk/src/runs/read-errors.ts +8 -0
  15. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +124 -13
  16. package/dist/bundling-sources/sdk/src/tool-calls.ts +108 -19
  17. package/dist/bundling-sources/sdk/src/types.ts +18 -0
  18. package/dist/bundling-sources/shared_libs/integration-contracts/execute-retry-contract.ts +37 -0
  19. package/dist/bundling-sources/shared_libs/integration-contracts/package.json +3 -0
  20. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +3 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +277 -76
  22. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/dataset-row-input.ts +124 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +6 -62
  25. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +1 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +67 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +64 -6
  28. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +1 -5
  29. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +1 -1
  30. package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +3 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +10 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +3 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/egress-probe.ts +3 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +26 -16
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +36 -11
  36. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +35 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +21 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +21 -6
  39. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +11 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +85 -20
  41. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +71 -13
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-execution-queries.ts +100 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +9 -5
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +337 -146
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +26 -12
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +3 -1
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +425 -102
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-dispatch-authority.ts +4 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +4 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +9 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +181 -124
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +152 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +5 -3
  54. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +31 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +10 -0
  56. package/dist/bundling-sources/shared_libs/plays/ambiguous-write-error.ts +25 -0
  57. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -0
  58. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +63 -68
  59. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +129 -63
  60. package/dist/bundling-sources/shared_libs/plays/contracts.ts +14 -0
  61. package/dist/bundling-sources/shared_libs/plays/enrich-play-compiler.ts +58 -16
  62. package/dist/bundling-sources/shared_libs/plays/fetch-http-error.ts +50 -0
  63. package/dist/bundling-sources/shared_libs/plays/source-authoring-edition.ts +351 -0
  64. package/dist/bundling-sources/shared_libs/plays/tool-list-getter-mode.ts +9 -0
  65. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
  66. package/dist/cli/{auth-UVD3CUBB.mjs → auth-LLXLIILR.mjs} +6 -6
  67. package/dist/cli/auth-UG4WOYGL.js +40 -0
  68. package/dist/cli/{billing-BZVTXXLM.mjs → billing-5FVXZYAC.mjs} +8 -8
  69. package/dist/cli/{billing-BZVYAF6T.js → billing-NFPK7GYP.js} +84 -84
  70. package/dist/cli/{chunk-ZAAKSJAS.js → chunk-27GJKC5Q.js} +17 -10
  71. package/dist/cli/{chunk-UHNDVD3P.js → chunk-2H4EY7KH.js} +100 -41
  72. package/dist/cli/{chunk-WTT6CLED.mjs → chunk-2YR7BIIC.mjs} +5 -2
  73. package/dist/cli/{chunk-3ZB6IIA7.js → chunk-36AHOWVS.js} +26 -26
  74. package/dist/cli/{chunk-OSDXE27V.mjs → chunk-4PG4ARL2.mjs} +17 -10
  75. package/dist/cli/{chunk-LOYISF7S.mjs → chunk-4XQLVUC7.mjs} +738 -512
  76. package/dist/cli/{chunk-J5PTX66Y.js → chunk-5MLCBXXU.js} +8 -1
  77. package/dist/cli/chunk-5TUGWDEB.js +313 -0
  78. package/dist/cli/{chunk-D6FFBSM5.js → chunk-5UUQAGJS.js} +5 -2
  79. package/dist/cli/{chunk-4CFULMRB.mjs → chunk-5V5Y37BC.mjs} +2 -2
  80. package/dist/cli/{chunk-PMVFAYL7.mjs → chunk-63ILLN5H.mjs} +2 -2
  81. package/dist/cli/{chunk-AUMD2VXP.js → chunk-63S7X326.js} +1032 -806
  82. package/dist/cli/{chunk-4QFT5LGV.mjs → chunk-6PGATQ6L.mjs} +6 -3
  83. package/dist/cli/{chunk-6BJK4EJ3.mjs → chunk-AARWVK4C.mjs} +2132 -65
  84. package/dist/cli/{chunk-FERRDNMO.js → chunk-AD47BXN2.js} +5 -5
  85. package/dist/cli/{chunk-4RNDKFNQ.js → chunk-D37FEBES.js} +2 -2
  86. package/dist/cli/{chunk-S6R3OX7B.js → chunk-E4CABWXL.js} +25 -2
  87. package/dist/cli/{chunk-NXGCO4JB.mjs → chunk-E4IXDAZI.mjs} +5 -0
  88. package/dist/cli/chunk-EQ4Z7RJW.mjs +35 -0
  89. package/dist/cli/chunk-FR2ILQ4G.mjs +8 -0
  90. package/dist/cli/{chunk-QUAQX3FQ.js → chunk-FVLNYDI4.js} +128 -376
  91. package/dist/cli/{chunk-BRJUESQV.js → chunk-FZJAM576.js} +50 -50
  92. package/dist/cli/{chunk-BZAMOCPA.mjs → chunk-IMZ56EOH.mjs} +3 -3
  93. package/dist/cli/{chunk-IOHRWLQE.mjs → chunk-IPG42SD2.mjs} +452 -138
  94. package/dist/cli/chunk-J33TSWO5.js +8 -0
  95. package/dist/cli/{chunk-XXLXOUUU.mjs → chunk-JNXJZ577.mjs} +1 -1
  96. package/dist/cli/{chunk-JI2B4RZP.mjs → chunk-KCC3FKIW.mjs} +71 -12
  97. package/dist/cli/{chunk-6IKARAYD.mjs → chunk-L2VKAASU.mjs} +23 -0
  98. package/dist/cli/{chunk-PYZZMAJQ.mjs → chunk-LFSHGNT2.mjs} +8 -1
  99. package/dist/cli/{chunk-2XXXFPTD.js → chunk-LTFL4JRN.js} +426 -721
  100. package/dist/cli/{chunk-YHPYUZZX.mjs → chunk-MAMVGOSC.mjs} +1 -1
  101. package/dist/cli/{chunk-URACNNLO.mjs → chunk-MN2OWLFA.mjs} +2 -2
  102. package/dist/cli/{chunk-Q3PUHXOY.js → chunk-NF4V5DTY.js} +12 -12
  103. package/dist/cli/{chunk-Q2E4E4FJ.js → chunk-NPBJI7RE.js} +8 -8
  104. package/dist/cli/chunk-NTVLGHFM.js +501 -0
  105. package/dist/cli/{chunk-HQXL5526.mjs → chunk-NUX2QHNC.mjs} +1 -1
  106. package/dist/cli/{chunk-E3PJF6YP.js → chunk-OBB4QXHA.js} +19 -4
  107. package/dist/cli/{chunk-SEFMGO3Z.js → chunk-OQQOXSYA.js} +2184 -117
  108. package/dist/cli/chunk-OZ6E3IRZ.js +6084 -0
  109. package/dist/cli/{chunk-7P5AA3SN.js → chunk-PPDBRJRW.js} +6 -1
  110. package/dist/cli/{chunk-IWBXJDZA.mjs → chunk-PZSLPBDA.mjs} +2 -2
  111. package/dist/cli/{chunk-ILHRA7AD.js → chunk-QADCFSGH.js} +7 -7
  112. package/dist/cli/{chunk-ECVLPS67.js → chunk-QJI5FIOW.js} +170 -49
  113. package/dist/cli/{chunk-I3DHIXVJ.mjs → chunk-QL22Y56M.mjs} +149 -28
  114. package/dist/cli/{chunk-SD7MXAJA.mjs → chunk-RFB25DSQ.mjs} +36 -284
  115. package/dist/cli/chunk-T44IIOT6.mjs +501 -0
  116. package/dist/cli/chunk-VK2LZ5IP.js +35 -0
  117. package/dist/cli/chunk-VKKVSFRD.js +62 -0
  118. package/dist/cli/{chunk-RWCY6YI2.js → chunk-VYKV5XHL.js} +644 -330
  119. package/dist/cli/{chunk-GSK6NHVM.js → chunk-WU4U6VSB.js} +5 -5
  120. package/dist/cli/chunk-XHLKJOTN.mjs +313 -0
  121. package/dist/cli/{chunk-MJELBQBU.mjs → chunk-XIHWSXSV.mjs} +330 -625
  122. package/dist/cli/chunk-XNZJKRJA.mjs +6084 -0
  123. package/dist/cli/chunk-ZCALLYF6.mjs +62 -0
  124. package/dist/cli/{chunk-ZBABPK6Y.js → chunk-ZFZ427HN.js} +11 -8
  125. package/dist/cli/{chunk-SJVVBWRL.mjs → chunk-ZKYEW55U.mjs} +16 -1
  126. package/dist/cli/command-docs.js +2 -2
  127. package/dist/cli/command-docs.mjs +1 -1
  128. package/dist/cli/{csv-XLGLHJ6P.js → csv-7U3FJYKZ.js} +14 -14
  129. package/dist/cli/{csv-WPSXG6ZZ.mjs → csv-ZWLDMM4A.mjs} +5 -5
  130. package/dist/cli/{db-5PTNJG4X.js → db-DNCGV5PC.js} +42 -47
  131. package/dist/cli/{db-ABS57ABJ.mjs → db-IMYXVMGI.mjs} +15 -20
  132. package/dist/cli/{describe-PVWQJ2PB.mjs → describe-Q23DWJUK.mjs} +20 -15
  133. package/dist/cli/{describe-EZS6PQXA.js → describe-S34JUX5W.js} +27 -22
  134. package/dist/cli/describe-core.d.mts +2 -2
  135. package/dist/cli/describe-core.d.ts +2 -2
  136. package/dist/cli/describe-core.js +6 -6
  137. package/dist/cli/describe-core.mjs +5 -5
  138. package/dist/cli/{executions-OKJGATQZ.mjs → executions-A73EUGSI.mjs} +8 -8
  139. package/dist/cli/{executions-FNTAFQ7Y.js → executions-XOMPX2YJ.js} +10 -10
  140. package/dist/cli/{feedback-W27HDMRR.mjs → feedback-N4GJ2POI.mjs} +11 -7
  141. package/dist/cli/{feedback-6YBOMSUA.js → feedback-QTCHNJJH.js} +13 -9
  142. package/dist/cli/{git-YOOUEL6M.mjs → git-4Q3JIQYZ.mjs} +6 -6
  143. package/dist/cli/git-I6CPBEVG.js +24 -0
  144. package/dist/cli/index.js +240 -352
  145. package/dist/cli/index.mjs +163 -275
  146. package/dist/cli/{legacy-noops-V6OKW7VR.mjs → legacy-noops-3SOVGFF7.mjs} +6 -6
  147. package/dist/cli/{legacy-noops-2VZ7XT6C.js → legacy-noops-4OSHZM34.js} +9 -9
  148. package/dist/cli/{monitors-FBWGVIUS.js → monitors-LVE2KZNG.js} +94 -94
  149. package/dist/cli/{monitors-P2YYWTWT.mjs → monitors-QP2XID2B.mjs} +8 -8
  150. package/dist/cli/{org-DVMG6H3C.mjs → org-IVRETVQA.mjs} +8 -8
  151. package/dist/cli/{org-3XUSVX5T.js → org-XFLK5IAP.js} +68 -68
  152. package/dist/cli/{play-GNC5CQAS.mjs → play-DE7VH6NU.mjs} +533 -98
  153. package/dist/cli/{play-YG5L4BWQ.js → play-XXTPPP23.js} +1067 -632
  154. package/dist/cli/{providers-7PSWG2OV.js → providers-DLD3I4JF.js} +11 -11
  155. package/dist/cli/{providers-JR33SLWL.mjs → providers-GX2NIZQQ.mjs} +8 -8
  156. package/dist/cli/{quickstart-VUOBQYIQ.mjs → quickstart-72B4L4PK.mjs} +5 -5
  157. package/dist/cli/{quickstart-FDVZ5BL3.js → quickstart-XNS3HSWC.js} +7 -7
  158. package/dist/cli/search-6NCH4HB5.js +30 -0
  159. package/dist/cli/{search-JZYLO33K.mjs → search-SUTRANJI.mjs} +9 -9
  160. package/dist/cli/{secrets-VS266FVA.js → secrets-6OBLOVEV.js} +17 -17
  161. package/dist/cli/{secrets-3MCYBT4I.mjs → secrets-FPFXXNUH.mjs} +8 -8
  162. package/dist/cli/sessions-235532DR.js +16 -0
  163. package/dist/cli/{sessions-ELLLT23E.mjs → sessions-R25I4QKN.mjs} +6 -6
  164. package/dist/cli/{settings-PZCKAFII.mjs → settings-AOP6F5PZ.mjs} +12 -12
  165. package/dist/cli/{settings-7364NMMA.js → settings-VL5FOFPN.js} +79 -79
  166. package/dist/cli/{setup-PMWYLCT6.js → setup-BSC67YT3.js} +45 -44
  167. package/dist/cli/{setup-A7GQ4KIA.mjs → setup-ZMPHBHVJ.mjs} +11 -10
  168. package/dist/cli/skills-3IWLYYRL.js +29 -0
  169. package/dist/cli/{skills-WS6BIFPQ.mjs → skills-KF65TVFO.mjs} +7 -7
  170. package/dist/cli/tools-LR66SPYU.js +44 -0
  171. package/dist/cli/{tools-BR4DOZA2.mjs → tools-SX4XIPM7.mjs} +19 -14
  172. package/dist/cli/{update-D2B7UNFT.mjs → update-QRMFRAQQ.mjs} +11 -9
  173. package/dist/cli/update-SP7UEO53.js +31 -0
  174. package/dist/cli/{workflow-PQXC2R47.mjs → workflow-FOEEEB7G.mjs} +44 -20
  175. package/dist/cli/{workflow-6ODTCYXU.js → workflow-KOCK2FLW.js} +54 -30
  176. package/dist/{client-Z9Pye1Wm.d.mts → client-74k4IPh6.d.mts} +137 -54
  177. package/dist/{client-BcvhDfJJ.d.ts → client-C1IK1f8c.d.ts} +137 -54
  178. package/dist/{compiler-manifest-Ycx-hoAr.d.mts → compiler-manifest-lzWpbV3w.d.mts} +83 -66
  179. package/dist/{compiler-manifest-Ycx-hoAr.d.ts → compiler-manifest-lzWpbV3w.d.ts} +83 -66
  180. package/dist/{index-CZXgiN3E.d.mts → index-C8Cy-YTm.d.ts} +5 -1
  181. package/dist/{index-NPG5pqxQ.d.ts → index-CtNK-0nI.d.mts} +5 -1
  182. package/dist/index.d.mts +47 -9
  183. package/dist/index.d.ts +47 -9
  184. package/dist/index.js +17 -14
  185. package/dist/index.mjs +13 -10
  186. package/dist/install-integrity.json +120 -104
  187. package/dist/plays/bundle-play-file.d.mts +3 -3
  188. package/dist/plays/bundle-play-file.d.ts +3 -3
  189. package/dist/plays/bundle-play-file.mjs +5 -4
  190. package/dist/plays/csv-data-input.js +3 -3
  191. package/dist/plays/csv-data-input.mjs +2 -2
  192. package/dist/plays/play-description.d.mts +2 -2
  193. package/dist/plays/play-description.d.ts +2 -2
  194. package/dist/plays/run-request.d.mts +2 -2
  195. package/dist/plays/run-request.d.ts +2 -2
  196. package/dist/plays/run-request.js +11 -3
  197. package/dist/plays/run-request.mjs +10 -2
  198. package/dist/release.d.mts +15 -6
  199. package/dist/release.d.ts +15 -6
  200. package/dist/release.js +2 -2
  201. package/dist/release.mjs +1 -1
  202. package/package.json +2 -2
  203. package/dist/cli/auth-3GB2K636.js +0 -40
  204. package/dist/cli/chunk-67RWR34T.mjs +0 -155
  205. package/dist/cli/chunk-CLJGSOVM.mjs +0 -1716
  206. package/dist/cli/chunk-HQY2SG3K.js +0 -83
  207. package/dist/cli/chunk-OSFWFV72.js +0 -155
  208. package/dist/cli/chunk-Q3LFI3VH.js +0 -392
  209. package/dist/cli/chunk-WPAB4DCU.mjs +0 -83
  210. package/dist/cli/chunk-YMOFWHGO.mjs +0 -392
  211. package/dist/cli/chunk-Z4VNJOF7.js +0 -1716
  212. package/dist/cli/git-YKUXXJOR.js +0 -24
  213. package/dist/cli/search-PPPYC5OZ.js +0 -30
  214. package/dist/cli/sessions-TEHEWW7O.js +0 -16
  215. package/dist/cli/skills-SYS7VRRK.js +0 -29
  216. package/dist/cli/tools-KK4BKVQR.js +0 -39
  217. package/dist/cli/update-2IV5JTX2.js +0 -29
@@ -1,17 +1,19 @@
1
1
  import {
2
2
  npmSupportsAllowScripts,
3
3
  readNpmVersion
4
- } from "./chunk-XXLXOUUU.mjs";
4
+ } from "./chunk-JNXJZ577.mjs";
5
5
  import {
6
- resolveShellSpawn,
7
6
  runSkillsCommand
8
- } from "./chunk-MJELBQBU.mjs";
7
+ } from "./chunk-T44IIOT6.mjs";
8
+ import {
9
+ resolveShellSpawn
10
+ } from "./chunk-XIHWSXSV.mjs";
9
11
  import {
10
12
  printCommandEnvelope
11
- } from "./chunk-4CFULMRB.mjs";
13
+ } from "./chunk-5V5Y37BC.mjs";
12
14
  import {
13
15
  autoDetectBaseUrl
14
- } from "./chunk-SD7MXAJA.mjs";
16
+ } from "./chunk-RFB25DSQ.mjs";
15
17
 
16
18
  // src/cli/commands/update.ts
17
19
  import { spawn, spawnSync } from "child_process";
@@ -26,6 +28,7 @@ import {
26
28
  writeFileSync as writeFileSync2
27
29
  } from "fs";
28
30
  import { homedir as homedir2 } from "os";
31
+ import { setTimeout as delay } from "timers/promises";
29
32
  import {
30
33
  basename,
31
34
  dirname as dirname2,
@@ -210,6 +213,9 @@ import {
210
213
  import { homedir } from "os";
211
214
  import { dirname, join as join2 } from "path";
212
215
  var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
216
+ function defaultHomeDir() {
217
+ return process.env.HOME?.trim() || homedir();
218
+ }
213
219
  var CLI_UPDATE_MESSAGES = [
214
220
  {
215
221
  id: "auto-update-default-v1",
@@ -236,7 +242,7 @@ function unreadablePreferences(path, error) {
236
242
  acknowledgedMessages: CLI_UPDATE_MESSAGES.map(({ id }) => id)
237
243
  };
238
244
  }
239
- function cliUpdatePreferencesPath(homeDir = homedir()) {
245
+ function cliUpdatePreferencesPath(homeDir = defaultHomeDir()) {
240
246
  return join2(
241
247
  homeDir,
242
248
  ".local",
@@ -245,7 +251,7 @@ function cliUpdatePreferencesPath(homeDir = homedir()) {
245
251
  "update-preferences.json"
246
252
  );
247
253
  }
248
- function readCliUpdatePreferences(homeDir = homedir()) {
254
+ function readCliUpdatePreferences(homeDir = defaultHomeDir()) {
249
255
  const path = cliUpdatePreferencesPath(homeDir);
250
256
  if (!existsSync2(path)) return defaultPreferences();
251
257
  try {
@@ -262,7 +268,7 @@ function readCliUpdatePreferences(homeDir = homedir()) {
262
268
  return unreadablePreferences(path, error);
263
269
  }
264
270
  }
265
- function writeCliUpdatePreferences(preferences, homeDir = homedir()) {
271
+ function writeCliUpdatePreferences(preferences, homeDir = defaultHomeDir()) {
266
272
  const path = cliUpdatePreferencesPath(homeDir);
267
273
  const tempPath = `${path}.${process.pid}.tmp`;
268
274
  mkdirSync(dirname(path), { recursive: true });
@@ -277,7 +283,7 @@ function writeCliUpdatePreferences(preferences, homeDir = homedir()) {
277
283
  rmSync(tempPath, { force: true });
278
284
  }
279
285
  }
280
- function setCliAutoUpdateEnabled(enabled, homeDir = homedir()) {
286
+ function setCliAutoUpdateEnabled(enabled, homeDir = defaultHomeDir()) {
281
287
  const current = readCliUpdatePreferences(homeDir);
282
288
  const next = {
283
289
  ...current,
@@ -287,7 +293,7 @@ function setCliAutoUpdateEnabled(enabled, homeDir = homedir()) {
287
293
  writeCliUpdatePreferences(next, homeDir);
288
294
  return next;
289
295
  }
290
- function setCliPinnedVersion(version, homeDir = homedir()) {
296
+ function setCliPinnedVersion(version, homeDir = defaultHomeDir()) {
291
297
  const next = {
292
298
  ...readCliUpdatePreferences(homeDir),
293
299
  pinnedVersion: version
@@ -295,14 +301,14 @@ function setCliPinnedVersion(version, homeDir = homedir()) {
295
301
  writeCliUpdatePreferences(next, homeDir);
296
302
  return next;
297
303
  }
298
- function clearCliPinnedVersion(homeDir = homedir()) {
304
+ function clearCliPinnedVersion(homeDir = defaultHomeDir()) {
299
305
  const current = readCliUpdatePreferences(homeDir);
300
306
  if (current.pinnedVersion === null) return current;
301
307
  const next = { ...current, pinnedVersion: null };
302
308
  writeCliUpdatePreferences(next, homeDir);
303
309
  return next;
304
310
  }
305
- function shouldRunCliAutoUpdate(homeDir = homedir()) {
311
+ function shouldRunCliAutoUpdate(homeDir = defaultHomeDir()) {
306
312
  const preferences = readCliUpdatePreferences(homeDir);
307
313
  return preferences.autoUpdateEnabled && preferences.pinnedVersion === null;
308
314
  }
@@ -489,7 +495,12 @@ function normalizedNpmPrefix(value) {
489
495
  }
490
496
  function resolveNpmGlobalPrefix(env) {
491
497
  try {
492
- const plan = resolveShellSpawn("npm", ["prefix", "-g"], process.platform, env);
498
+ const plan = resolveShellSpawn(
499
+ "npm",
500
+ ["prefix", "-g"],
501
+ process.platform,
502
+ env
503
+ );
493
504
  const result = spawnSync(plan.command, plan.args, {
494
505
  encoding: "utf8",
495
506
  env,
@@ -636,24 +647,126 @@ function matchingAutoUpdateFailure(plan) {
636
647
  return marker;
637
648
  }
638
649
  async function runAutomaticUpdatePlan(plan) {
639
- const previousFailure = matchingAutoUpdateFailure(plan);
640
- if (previousFailure) {
650
+ try {
651
+ const installation = resolveUpdateInstallation(plan);
652
+ return await withUpdateLock(installation?.directory ?? null, async () => {
653
+ const previousFailure = matchingAutoUpdateFailure(plan);
654
+ if (previousFailure) {
655
+ process.stderr.write(
656
+ [
657
+ "Skipping Deepline SDK/CLI auto-update because this same update already failed on this machine.",
658
+ `Fix Node/npm native package installation issues, then run: ${previousFailure.manualCommand}`,
659
+ "Common causes include broken esbuild installs, node-gyp build toolchain errors, npm cache corruption, or registry/network failures.",
660
+ ""
661
+ ].join("\n")
662
+ );
663
+ return {
664
+ status: "skipped_previous_failure",
665
+ exitCode: previousFailure.exitCode || 1,
666
+ previousFailure
667
+ };
668
+ }
669
+ const targetVersion = autoUpdatePackageSpec(plan).match(
670
+ /^deepline@(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/
671
+ )?.[1];
672
+ const installedVersion = installedUpdateVersion(installation);
673
+ if (targetVersion && parseSemver(installedVersion) && compareUpdateVersions(installedVersion, targetVersion) >= 0) {
674
+ return { status: "updated", exitCode: 0 };
675
+ }
676
+ const exitCode = await applyUpdatePlan(plan);
677
+ return exitCode === 0 ? { status: "updated", exitCode: 0 } : { status: "failed", exitCode };
678
+ });
679
+ } catch (error) {
641
680
  process.stderr.write(
642
- [
643
- "Skipping Deepline SDK/CLI auto-update because this same update already failed on this machine.",
644
- `Fix Node/npm native package installation issues, then run: ${previousFailure.manualCommand}`,
645
- "Common causes include broken esbuild installs, node-gyp build toolchain errors, npm cache corruption, or registry/network failures.",
646
- ""
647
- ].join("\n")
681
+ `Could not complete the automatic Deepline CLI update: ${error instanceof Error ? error.message : String(error)}
682
+ `
648
683
  );
649
- return {
650
- status: "skipped_previous_failure",
651
- exitCode: previousFailure.exitCode || 1,
652
- previousFailure
653
- };
684
+ return { status: "failed", exitCode: 1 };
685
+ }
686
+ }
687
+ function parseSemver(version) {
688
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(
689
+ version.trim()
690
+ );
691
+ if (!match) return null;
692
+ return {
693
+ major: Number(match[1]),
694
+ minor: Number(match[2]),
695
+ patch: Number(match[3]),
696
+ prerelease: match[4] ?? ""
697
+ };
698
+ }
699
+ function compareUpdateVersions(left, right) {
700
+ const a = parseSemver(left);
701
+ const b = parseSemver(right);
702
+ if (!a || !b) return left.localeCompare(right);
703
+ for (const key of ["major", "minor", "patch"]) {
704
+ if (a[key] !== b[key]) return a[key] > b[key] ? 1 : -1;
705
+ }
706
+ if (a.prerelease === b.prerelease) return 0;
707
+ if (!a.prerelease) return 1;
708
+ if (!b.prerelease) return -1;
709
+ return a.prerelease.localeCompare(b.prerelease);
710
+ }
711
+ function resolveUpdateInstallation(plan) {
712
+ if (plan.kind === "source" || plan.kind === "homebrew") return null;
713
+ const prefixIndex = plan.kind === "npm-global" ? plan.args.indexOf("--prefix") : -1;
714
+ const directory = plan.kind === "python-sidecar" ? plan.stateDir : plan.installPrefix ?? (prefixIndex >= 0 ? plan.args[prefixIndex + 1] : void 0) ?? resolveNpmGlobalPrefix(process.env);
715
+ if (!directory)
716
+ throw new Error("Cannot determine the npm global installation to lock.");
717
+ return {
718
+ kind: plan.kind,
719
+ directory: normalizedNpmPrefix(directory) ?? resolve2(directory)
720
+ };
721
+ }
722
+ function installedUpdateVersion(installation) {
723
+ if (!installation) return "";
724
+ const { kind, directory } = installation;
725
+ if (kind === "python-sidecar") {
726
+ try {
727
+ const version = safeVersionSegment(
728
+ readFileSync3(join3(directory, ".version"), "utf8")
729
+ );
730
+ return !version || sidecarStructureFailure(join3(directory, "versions", version)) ? "" : version;
731
+ } catch {
732
+ return "";
733
+ }
734
+ }
735
+ return installedPackageVersion(
736
+ process.platform === "win32" ? directory : join3(directory, "lib")
737
+ );
738
+ }
739
+ async function withUpdateLock(installationDirectory, action) {
740
+ if (!installationDirectory) return action();
741
+ mkdirSync2(installationDirectory, { recursive: true });
742
+ const lockPath = join3(installationDirectory, ".deepline-update.lock");
743
+ const deadline = Date.now() + 12e4;
744
+ let waiting = false;
745
+ for (; ; ) {
746
+ try {
747
+ mkdirSync2(lockPath, { mode: 448 });
748
+ break;
749
+ } catch (error) {
750
+ if (error.code !== "EEXIST") throw error;
751
+ if (Date.now() >= deadline) {
752
+ throw new Error(
753
+ `Timed out waiting for the Deepline CLI update lock at ${lockPath}. Check for an active installer before removing a lock left by an interrupted update.`
754
+ );
755
+ }
756
+ if (!waiting) {
757
+ process.stderr.write(
758
+ "Another Deepline CLI update is in progress; waiting for it to finish.\n"
759
+ );
760
+ waiting = true;
761
+ }
762
+ await delay(100);
763
+ }
764
+ }
765
+ try {
766
+ return await action();
767
+ } finally {
768
+ rmSync2(lockPath, { recursive: true });
654
769
  }
655
- const exitCode = await runUpdatePlan(plan);
656
- return exitCode === 0 ? { status: "updated", exitCode: 0 } : { status: "failed", exitCode };
657
770
  }
658
771
  function safeVersionSegment(value) {
659
772
  const normalized = value.trim();
@@ -1014,6 +1127,13 @@ async function runPythonSidecarUpdatePlan(plan) {
1014
1127
  return 0;
1015
1128
  }
1016
1129
  async function runUpdatePlan(plan) {
1130
+ const installation = resolveUpdateInstallation(plan);
1131
+ return withUpdateLock(
1132
+ installation?.directory ?? null,
1133
+ () => applyUpdatePlan(plan)
1134
+ );
1135
+ }
1136
+ async function applyUpdatePlan(plan) {
1017
1137
  let exitCode = 1;
1018
1138
  if (plan.kind === "npm-global") {
1019
1139
  exitCode = await runNpmInstallWithRegistryFallback({
@@ -1246,6 +1366,7 @@ export {
1246
1366
  canAutomaticallyApplyUpdatePlan,
1247
1367
  resolveUpdatePlan,
1248
1368
  runAutomaticUpdatePlan,
1369
+ compareUpdateVersions,
1249
1370
  runUpdatePlan,
1250
1371
  publishedVersionSupportsPin,
1251
1372
  runUpdateCommand,
@@ -3,7 +3,7 @@ import {
3
3
  ConfigError,
4
4
  RateLimitError,
5
5
  ToolRateLimitError
6
- } from "./chunk-YHPYUZZX.mjs";
6
+ } from "./chunk-MAMVGOSC.mjs";
7
7
  import {
8
8
  apiErrorCodeFromResponse,
9
9
  apiErrorMessage
@@ -14,10 +14,10 @@ import {
14
14
  ToolExecutionError,
15
15
  deserializeToolExecutionFailure,
16
16
  serializeToolExecutionFailure
17
- } from "./chunk-NXGCO4JB.mjs";
17
+ } from "./chunk-E4IXDAZI.mjs";
18
18
  import {
19
19
  SDK_RELEASE
20
- } from "./chunk-WTT6CLED.mjs";
20
+ } from "./chunk-2YR7BIIC.mjs";
21
21
 
22
22
  // src/config.ts
23
23
  import {
@@ -682,8 +682,13 @@ var AGENT_SESSION_ID_VARIABLES = [
682
682
  "CODEX_SESSION_ID",
683
683
  "CODEX_THREAD_ID"
684
684
  ];
685
- function agentSessionIdFromEnvironment(env = process.env) {
686
- for (const variable of AGENT_SESSION_ID_VARIABLES) {
685
+ function agentSessionIdFromEnvironment(env = process.env, agentRuntime) {
686
+ const detectedRuntime = normalizeAgentRuntime(
687
+ agentRuntime ?? env.DEEPLINE_AGENT_RUNTIME
688
+ );
689
+ const runtime = (detectedRuntime === "unknown" ? null : detectedRuntime) ?? (env.CODEX_SESSION_ID?.trim() || env.CODEX_THREAD_ID?.trim() ? "codex" : null);
690
+ const variables = runtime === "codex" ? ["CODEX_SESSION_ID", "CODEX_THREAD_ID"] : runtime === "claude_code" || runtime === "claude_cowork" ? ["CLAUDE_CODE_SESSION_ID"] : runtime === null ? AGENT_SESSION_ID_VARIABLES : [];
691
+ for (const variable of variables) {
687
692
  const sessionId = env[variable]?.trim();
688
693
  if (sessionId) return sessionId;
689
694
  }
@@ -878,285 +883,24 @@ var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
878
883
  var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
879
884
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
880
885
 
881
- // ../play-runtime/runtime-incident-drills.ts
882
- var RUNTIME_TEST_FAULT_IDS = [
883
- "receipt_complete_write_fail",
884
- "receipt_fail_write_fail",
885
- "worker_receipt_complete_write_fail",
886
- "invocation_response_delivery_abort",
887
- "execution_upstream_response_loss",
888
- "receipt_gateway_hold_ms",
889
- "receipt_claim_query_hold_once_ms",
890
- "receipt_claim_response_timeout",
891
- "modal_sandbox_create_resource_exhausted",
892
- "runtime_sheet_page_tail_hold_ms"
893
- ];
894
- var LOCAL_TOPOLOGY = ["local_daytona"];
895
- var LOCAL_AND_PREVIEW_TOPOLOGIES = [
896
- "local_daytona",
897
- "preview_fly",
898
- "preview_direct_modal"
899
- ];
900
- var MODAL_PREVIEW_TOPOLOGY = ["preview_direct_modal"];
901
- var RUNTIME_INCIDENT_DRILL_CATALOG = [
902
- {
903
- id: "local_worker_process_outage",
904
- description: "Interrupt the scheduler worker in the selected non-production runtime topology.",
905
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
906
- control: {
907
- kind: "process",
908
- component: "worker",
909
- modes: ["pause", "crash"]
910
- },
911
- expected: {
912
- outcome: "The same logical run stays durable through the worker outage and completes after the selected topology recovers.",
913
- safetyFacts: ["same_logical_run", "no_false_success"]
914
- },
915
- verification: {
916
- kind: "local_black_box",
917
- target: "local-component-outage-recovery-e2e"
918
- }
919
- },
920
- {
921
- id: "local_gateway_process_outage",
922
- description: "Interrupt the receipt gateway in the selected non-production runtime topology.",
923
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
924
- control: {
925
- kind: "process",
926
- component: "gateway",
927
- modes: ["pause", "crash"]
928
- },
929
- expected: {
930
- outcome: "In-flight work recovers only at a safe receipt boundary and the same logical run completes after the gateway recovers.",
931
- safetyFacts: [
932
- "same_logical_run",
933
- "no_false_success",
934
- "bounded_provider_execution"
935
- ]
936
- },
937
- verification: {
938
- kind: "local_black_box",
939
- target: "local-component-outage-recovery-e2e"
940
- }
941
- },
942
- {
943
- id: "local_runtime_process_outage",
944
- description: "Interrupt both runtime components in the selected non-production topology.",
945
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
946
- control: { kind: "process", component: "all", modes: ["pause", "crash"] },
947
- expected: {
948
- outcome: "Durable work waits through the combined outage; it never becomes a false success or creates a second logical run.",
949
- safetyFacts: ["same_logical_run", "no_false_success"]
950
- },
951
- verification: {
952
- kind: "local_black_box",
953
- target: "local-component-outage-recovery-e2e"
954
- }
955
- },
956
- {
957
- id: "receipt_complete_write_fail",
958
- description: "Fail the next durable receipt-completion write.",
959
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
960
- control: {
961
- kind: "runtime_test_fault",
962
- defaultValue: 1,
963
- valueMeaning: "occurrence"
964
- },
965
- expected: {
966
- outcome: "The failed run is loud, and a later bounded recovery may repeat the affected provider operation if its prior completion was not durable.",
967
- safetyFacts: ["retry_or_explicit_recovery", "bounded_provider_execution"]
968
- },
969
- verification: {
970
- kind: "local_black_box",
971
- target: "receipt-persist-failure-run-fatal-e2e"
972
- }
973
- },
974
- {
975
- id: "receipt_fail_write_fail",
976
- description: "Fail the next durable receipt-failure write.",
977
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
978
- control: {
979
- kind: "runtime_test_fault",
980
- defaultValue: 1,
981
- valueMeaning: "occurrence"
982
- },
983
- expected: {
984
- outcome: "The failure is loud; recovery remains bounded and may repeat an operation whose prior outcome was not durably recorded.",
985
- safetyFacts: ["retry_or_explicit_recovery", "bounded_provider_execution"]
986
- },
987
- verification: {
988
- kind: "focused_regression",
989
- target: "tests/lib/plays/runtime-test-fault-registry.test.ts"
990
- }
991
- },
992
- {
993
- id: "worker_receipt_complete_write_fail",
994
- description: "Fail the worker-side receipt-completion write once.",
995
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
996
- control: {
997
- kind: "runtime_test_fault",
998
- defaultValue: 1,
999
- valueMeaning: "occurrence"
1000
- },
1001
- expected: {
1002
- outcome: "The worker reports the persistence failure loudly; bounded recovery may repeat work whose completion was not durable.",
1003
- safetyFacts: ["retry_or_explicit_recovery", "bounded_provider_execution"]
1004
- },
1005
- verification: {
1006
- kind: "focused_regression",
1007
- target: "tests/lib/plays/runtime-test-fault-registry.test.ts"
1008
- }
1009
- },
1010
- {
1011
- id: "invocation_response_delivery_abort",
1012
- description: "Abort one receipt-gateway response after invocation delivery.",
1013
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
1014
- control: {
1015
- kind: "runtime_test_fault",
1016
- defaultValue: 1,
1017
- valueMeaning: "occurrence"
1018
- },
1019
- expected: {
1020
- outcome: "The same logical run completes through terminal-cache replay; any provider retry is governed by its separate operation policy.",
1021
- safetyFacts: ["same_logical_run", "bounded_provider_execution"]
1022
- },
1023
- verification: {
1024
- kind: "local_black_box",
1025
- target: "invocation-delivery-replay-e2e"
1026
- }
1027
- },
1028
- {
1029
- id: "execution_upstream_response_loss",
1030
- description: "Lose the first response of each keyed execution after the upstream app durably stores it.",
1031
- topologies: ["preview_fly"],
1032
- control: {
1033
- kind: "runtime_test_fault",
1034
- defaultValue: 1,
1035
- valueMeaning: "occurrence"
1036
- },
1037
- expected: {
1038
- outcome: "The same invocation recovers the stored response without repeating provider work or customer charges, and every row retains its usable result.",
1039
- safetyFacts: [
1040
- "same_logical_run",
1041
- "bounded_provider_execution",
1042
- "all_rows_settle_once",
1043
- "no_false_success"
1044
- ]
1045
- },
1046
- verification: {
1047
- kind: "preview_black_box",
1048
- target: "101-agent-heavy-gateway-load-e2e"
1049
- }
1050
- },
1051
- {
1052
- id: "receipt_gateway_hold_ms",
1053
- description: "Hold one checked-out receipt-gateway scheduler client.",
1054
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
1055
- control: {
1056
- kind: "runtime_test_fault",
1057
- defaultValue: 500,
1058
- valueMeaning: "milliseconds"
1059
- },
1060
- expected: {
1061
- outcome: "The request is delayed inside the real gateway pool and either completes within its deadline or follows bounded transport recovery.",
1062
- safetyFacts: ["bounded_provider_execution"]
1063
- },
1064
- verification: {
1065
- kind: "local_black_box",
1066
- target: "agent-heavy-gateway-load-e2e"
1067
- }
1068
- },
1069
- {
1070
- id: "receipt_claim_query_hold_once_ms",
1071
- description: "Hold one physical receipt-claim query.",
1072
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
1073
- control: {
1074
- kind: "runtime_test_fault",
1075
- defaultValue: 500,
1076
- valueMeaning: "milliseconds"
1077
- },
1078
- expected: {
1079
- outcome: "The checked-out claim either completes or times out through bounded recovery; an ambiguous outcome may be retried within its budget.",
1080
- safetyFacts: ["bounded_provider_execution"]
1081
- },
1082
- verification: {
1083
- kind: "local_black_box",
1084
- target: "receipt-claim-deadline-recovery-e2e"
1085
- }
1086
- },
1087
- {
1088
- id: "receipt_claim_response_timeout",
1089
- description: "Report one fully received receipt-claim response as timed out.",
1090
- topologies: LOCAL_AND_PREVIEW_TOPOLOGIES,
1091
- control: {
1092
- kind: "runtime_test_fault",
1093
- defaultValue: 1,
1094
- valueMeaning: "occurrence"
1095
- },
1096
- expected: {
1097
- outcome: "The same logical run completes by replaying the committed receipt response or uses bounded recovery if that response is unavailable.",
1098
- safetyFacts: ["same_logical_run", "bounded_provider_execution"]
1099
- },
1100
- verification: {
1101
- kind: "local_black_box",
1102
- target: "receipt-ambiguous-response-recovery-e2e"
1103
- }
1104
- },
1105
- {
1106
- id: "modal_sandbox_create_resource_exhausted",
1107
- description: "Make Modal sandbox creation return RESOURCE_EXHAUSTED before user code.",
1108
- topologies: MODAL_PREVIEW_TOPOLOGY,
1109
- control: {
1110
- kind: "runtime_test_fault",
1111
- defaultValue: 1,
1112
- valueMeaning: "occurrence"
1113
- },
1114
- expected: {
1115
- outcome: "The same logical run enters bounded pre-code defer/recovery and later retries sandbox startup; no user code or provider call precedes the retry.",
1116
- safetyFacts: [
1117
- "same_logical_run",
1118
- "no_user_code_before_recovery",
1119
- "bounded_provider_execution"
1120
- ]
1121
- },
1122
- verification: {
1123
- kind: "preview_black_box",
1124
- target: "modal-sandbox-recovery-e2e"
1125
- }
1126
- },
1127
- {
1128
- id: "runtime_sheet_page_tail_hold_ms",
1129
- description: "Hold one runtime-sheet tail-page operation.",
1130
- topologies: LOCAL_TOPOLOGY,
1131
- control: {
1132
- kind: "runtime_test_fault",
1133
- defaultValue: 500,
1134
- valueMeaning: "milliseconds"
1135
- },
1136
- expected: {
1137
- outcome: "Page-tail work stays pending during the bounded hold, then completes without losing or duplicating rows.",
1138
- safetyFacts: ["all_rows_settle_once"]
1139
- },
1140
- verification: {
1141
- kind: "local_black_box",
1142
- target: "page-tail-sheet-write-hold-e2e"
1143
- }
1144
- }
1145
- ];
1146
- function isRuntimeTestFaultDrill(drill) {
1147
- return drill.control.kind === "runtime_test_fault" && RUNTIME_TEST_FAULT_IDS.some((faultId) => faultId === drill.id);
1148
- }
1149
- function runtimeTestFaultDrills() {
1150
- return RUNTIME_INCIDENT_DRILL_CATALOG.filter(isRuntimeTestFaultDrill);
1151
- }
1152
-
1153
886
  // ../play-runtime/test-runtime-seams.ts
1154
887
  var PLAY_RUNTIME_TEST_FAULT_HEADER = "x-deepline-test-fault";
1155
- var SUPPORTED_RUNTIME_TEST_FAULTS = new Set(
1156
- runtimeTestFaultDrills().map(({ id }) => id)
1157
- );
1158
888
  var MAX_RUNTIME_TEST_POLICY_MS = 10 * 6e4;
1159
889
 
890
+ // ../integration-contracts/execute-retry-contract.ts
891
+ var EXECUTE_RETRY_POLICY_HEADER = "x-deepline-execute-retry-policy";
892
+ var EXECUTE_RETRY_POLICY_VERSION = 1;
893
+ function parseExecuteRetryPolicy(value) {
894
+ if (value === `v${EXECUTE_RETRY_POLICY_VERSION}:transient-http-safe`) {
895
+ return "transient-http-safe";
896
+ }
897
+ if (value === `v${EXECUTE_RETRY_POLICY_VERSION}:transient-http-unsafe`) {
898
+ return "transient-http-unsafe";
899
+ }
900
+ return null;
901
+ }
902
+ var ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER = "x-deepline-atomic-tool-supported";
903
+
1160
904
  // src/http.ts
1161
905
  var MAX_DIAGNOSTIC_HEADER_LENGTH = 120;
1162
906
  var COWORK_NETWORK_HINT = "Claude Cowork appears to be running Deepline in a network-restricted sandbox. In Claude Desktop, open Settings > Capabilities, turn on Allow network egress, and set Domain allowlist to All domains for the Cowork session.";
@@ -1377,7 +1121,7 @@ var HttpClient = class {
1377
1121
  const candidateUrls = options?.exactUrlOnly ? [url] : buildCandidateUrls(url);
1378
1122
  let retryAfterDelayMs = null;
1379
1123
  let totalRetryWaitMs = 0;
1380
- const maxRetries = options?.maxRetries ?? this.config.maxRetries;
1124
+ let maxRetries = options?.maxRetries ?? this.config.maxRetries;
1381
1125
  requestAttempts: for (let attempt = 0; attempt <= maxRetries; attempt++) {
1382
1126
  if (options?.signal?.aborted) {
1383
1127
  lastError = requestCancelledError(options.signal);
@@ -1445,6 +1189,12 @@ var HttpClient = class {
1445
1189
  httpStatus: response.status,
1446
1190
  body: parsed
1447
1191
  });
1192
+ const responseRetryAllowed = options?.retryFromExecutePolicy !== true || parseExecuteRetryPolicy(
1193
+ response.headers.get(EXECUTE_RETRY_POLICY_HEADER)
1194
+ ) === "transient-http-safe";
1195
+ if (options?.retryFromExecutePolicy === true && responseRetryAllowed && options.executePolicyMaxRetries !== void 0) {
1196
+ maxRetries = options.executePolicyMaxRetries;
1197
+ }
1448
1198
  const structuredToolError = options?.toolId && !response.ok ? deserializeToolExecutionFailure(
1449
1199
  apiErrorMessage(parsed, response.status),
1450
1200
  isRecord(parsed) ? parsed.tool_error : null,
@@ -1458,7 +1208,7 @@ var HttpClient = class {
1458
1208
  ...failure,
1459
1209
  retryAfterMs: failure.retryAfterMs ?? Math.max(0, retryAfter)
1460
1210
  });
1461
- if (attempt < maxRetries) {
1211
+ if (responseRetryAllowed && attempt < maxRetries) {
1462
1212
  retryAfterDelayMs = retryAfter;
1463
1213
  break;
1464
1214
  }
@@ -1477,7 +1227,7 @@ var HttpClient = class {
1477
1227
  }
1478
1228
  const retryAfter = parseRetryAfter(response);
1479
1229
  lastError = new RateLimitError(retryAfter);
1480
- if (attempt < maxRetries) {
1230
+ if (responseRetryAllowed && attempt < maxRetries) {
1481
1231
  retryAfterDelayMs = retryAfter;
1482
1232
  break;
1483
1233
  }
@@ -1487,7 +1237,7 @@ var HttpClient = class {
1487
1237
  throw new AuthError(apiErrorMessage(parsed, response.status));
1488
1238
  }
1489
1239
  if (!response.ok) {
1490
- const retryableApiError = options?.retryApiErrors === true && isRetryableApiErrorResponse(response.status);
1240
+ const retryableApiError = options?.retryApiErrors === true && responseRetryAllowed && isRetryableApiErrorResponse(response.status);
1491
1241
  const htmlError = detectHtmlErrorBody(
1492
1242
  body,
1493
1243
  response.headers.get("content-type")
@@ -1554,6 +1304,7 @@ var HttpClient = class {
1554
1304
  timeoutMs,
1555
1305
  timedOut: requestTimedOut
1556
1306
  });
1307
+ if (options?.retryFromExecutePolicy) break requestAttempts;
1557
1308
  } finally {
1558
1309
  clearTimeout(timeoutId);
1559
1310
  options?.signal?.removeEventListener("abort", abortRequest);
@@ -1935,6 +1686,7 @@ export {
1935
1686
  getActiveProjectAuthSource,
1936
1687
  resolveCliAuthProvenance,
1937
1688
  resolveCliCommandContext,
1689
+ ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER,
1938
1690
  SDK_VERSION,
1939
1691
  SDK_API_MAJOR,
1940
1692
  SDK_API_CONTRACT,