deepline 0.3.484 → 0.3.486

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 (210) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +91 -30
  2. package/dist/bundling-sources/sdk/src/compat.ts +13 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +4 -1
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +143 -9
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +31 -4
  7. package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/types.ts +7 -1
  9. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +32 -3
  10. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +126 -41
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +231 -25
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +9 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +130 -19
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +105 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +194 -56
  17. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +8 -4
  18. package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +11 -6
  19. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +3 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +2 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +2 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +30 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +195 -2
  24. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +20 -1
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +15 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +2 -2
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +139 -67
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +9 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +25 -5
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +133 -82
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +58 -16
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-sandbox-absence.ts +171 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +69 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +100 -40
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +8 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -9
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +5 -5
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +6 -3
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +14 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +87 -31
  41. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +18 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +19 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +14 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +206 -7
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +39 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +12 -1
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +28 -9
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +44 -15
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +60 -11
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +656 -64
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +6 -1
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +17 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +25 -33
  54. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +12 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +21 -0
  56. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -1
  57. package/dist/bundling-sources/shared_libs/plays/source-authoring-edition.ts +1 -1
  58. package/dist/cli/auth-ARKH3OAU.js +43 -0
  59. package/dist/cli/{auth-EBFOTF7X.mjs → auth-B4DJO4FB.mjs} +5 -5
  60. package/dist/cli/{billing-G2G3EF3I.js → billing-GDWAMARK.js} +80 -80
  61. package/dist/cli/{billing-2ZOIMW5V.mjs → billing-IIQ3VNXU.mjs} +7 -7
  62. package/dist/cli/{chunk-YWC5AN26.mjs → chunk-2DVFQYPG.mjs} +62 -34
  63. package/dist/cli/{chunk-UWOY74RU.js → chunk-5DUP4ZUE.js} +21 -21
  64. package/dist/cli/{chunk-EACX7QXO.mjs → chunk-5QYZ4MEW.mjs} +2 -2
  65. package/dist/cli/{chunk-HEI3BWIV.mjs → chunk-5RLVCOKH.mjs} +1 -1
  66. package/dist/cli/{chunk-TIRSKEZH.mjs → chunk-5Y7LLRWO.mjs} +1 -1
  67. package/dist/cli/{chunk-IXWQOVNW.js → chunk-5YILTBF7.js} +87 -76
  68. package/dist/cli/{chunk-OHKKDPA5.js → chunk-7FTQKEZ6.js} +13 -13
  69. package/dist/cli/{chunk-TN2GW57M.mjs → chunk-A456YVDE.mjs} +1 -1
  70. package/dist/cli/{chunk-GVAENVIG.js → chunk-AUQQVDAB.js} +110 -21
  71. package/dist/cli/{chunk-3XQIVEAT.js → chunk-BJL7RYQN.js} +3 -3
  72. package/dist/cli/{chunk-2AWYJXBX.js → chunk-BNB2RK4L.js} +5 -5
  73. package/dist/cli/{chunk-U7IJAGWB.js → chunk-BYEDI5PM.js} +7 -7
  74. package/dist/cli/{chunk-RLLEH2SP.js → chunk-C4GFBB52.js} +26 -26
  75. package/dist/cli/{chunk-AK7UKQ5R.js → chunk-CSBMKHTV.js} +5 -5
  76. package/dist/cli/{chunk-UT4YMA2N.js → chunk-DFHS5XVZ.js} +5 -4
  77. package/dist/cli/{chunk-XZXIWPT3.mjs → chunk-F3G2HAUQ.mjs} +1 -1
  78. package/dist/cli/{chunk-C62NI2X6.js → chunk-FCAKAW6S.js} +5 -5
  79. package/dist/cli/{chunk-AF7MOUZP.mjs → chunk-FGPJXQEJ.mjs} +2 -2
  80. package/dist/cli/chunk-FSCOYTRV.js +42 -0
  81. package/dist/cli/{chunk-6GRZEYSG.js → chunk-GCEUOHJW.js} +7 -7
  82. package/dist/cli/{chunk-SD7QWZTV.mjs → chunk-INW22YP7.mjs} +1 -1
  83. package/dist/cli/{chunk-OWUZKXE7.mjs → chunk-J7EENGKJ.mjs} +1 -1
  84. package/dist/cli/{chunk-QIDDTIVZ.js → chunk-KPIVQFXZ.js} +322 -294
  85. package/dist/cli/{chunk-4IOY2SCQ.js → chunk-LOX3BISD.js} +4 -4
  86. package/dist/cli/{chunk-WYUCDLVR.mjs → chunk-MJ56FCYU.mjs} +2 -1
  87. package/dist/cli/{chunk-DBJ62RAO.js → chunk-NSPMJLYA.js} +3 -3
  88. package/dist/cli/{chunk-HNRELVCS.mjs → chunk-ONONSV2Q.mjs} +96 -7
  89. package/dist/cli/{chunk-PU52JXKA.mjs → chunk-P6KGYOCM.mjs} +13 -4
  90. package/dist/cli/{chunk-VEVGM6B5.js → chunk-PCYZDTDC.js} +14 -14
  91. package/dist/cli/{chunk-NW4QJE54.js → chunk-PHWFY26F.js} +2 -2
  92. package/dist/cli/{chunk-LTZXLYKE.mjs → chunk-PKOFEHZL.mjs} +93 -17
  93. package/dist/cli/{chunk-7K5CWKKZ.mjs → chunk-PQHDZHZG.mjs} +2 -2
  94. package/dist/cli/{chunk-UKM74PAA.js → chunk-PTM3QRAT.js} +37 -37
  95. package/dist/cli/{chunk-YGN77QA5.mjs → chunk-PV7AYBKQ.mjs} +3 -3
  96. package/dist/cli/{chunk-4OEOM6GP.mjs → chunk-PYDHVRAF.mjs} +5 -5
  97. package/dist/cli/{chunk-FRD5WFT4.js → chunk-QD22TY33.js} +323 -247
  98. package/dist/cli/{chunk-5KNRQWHE.js → chunk-QEQ3KHVY.js} +3 -3
  99. package/dist/cli/{chunk-KGOC6HGI.js → chunk-S5EYODEG.js} +53 -53
  100. package/dist/cli/{chunk-FQK7BULS.js → chunk-S7OILDJH.js} +1 -1
  101. package/dist/cli/{chunk-TRLDJNVE.mjs → chunk-T3Q6BMVH.mjs} +1 -1
  102. package/dist/cli/{chunk-5K5CAND4.mjs → chunk-TBE2K5W4.mjs} +4 -4
  103. package/dist/cli/{chunk-YHA3EV3I.mjs → chunk-TE2QT2MX.mjs} +15 -4
  104. package/dist/cli/{chunk-ZOKM7DVA.js → chunk-TNHY3ATN.js} +8 -8
  105. package/dist/cli/{chunk-4OVHIWE7.mjs → chunk-U23L57VU.mjs} +2 -2
  106. package/dist/cli/{chunk-5GOG5ZGC.mjs → chunk-UEJLWUJ3.mjs} +2 -2
  107. package/dist/cli/{chunk-6NPWXE32.mjs → chunk-VJLL5XIP.mjs} +1 -1
  108. package/dist/cli/{chunk-WXRM3UC6.mjs → chunk-WCOJH4W4.mjs} +3 -3
  109. package/dist/cli/{chunk-4SFC2XUF.mjs → chunk-XAZWUW6I.mjs} +5 -5
  110. package/dist/cli/{chunk-ZM2YPJQJ.js → chunk-XK5DMLZE.js} +5 -1
  111. package/dist/cli/{chunk-LJ5747UC.mjs → chunk-XRDXNAAY.mjs} +5 -1
  112. package/dist/cli/{chunk-V7JCMBLU.mjs → chunk-YIKHNZ6B.mjs} +4 -4
  113. package/dist/cli/{chunk-M4PG7FGC.js → chunk-YS6JOYYS.js} +2 -2
  114. package/dist/cli/{chunk-DEXSQGXB.mjs → chunk-ZMRZ3BXG.mjs} +5 -5
  115. package/dist/cli/{chunk-CYWBAV5H.js → chunk-ZQI26KE4.js} +16 -16
  116. package/dist/cli/{csv-S3CHUKI6.js → csv-3PSMPZM5.js} +13 -13
  117. package/dist/cli/{csv-NLWVWD3H.mjs → csv-LFCT3WQ4.mjs} +4 -4
  118. package/dist/cli/{db-OGRPAEEM.mjs → db-HULKVAMU.mjs} +7 -7
  119. package/dist/cli/{db-WBSKMMOH.js → db-R7I2PPTV.js} +28 -28
  120. package/dist/cli/{describe-FAD3Z7LN.mjs → describe-D55V42LH.mjs} +21 -21
  121. package/dist/cli/describe-H47BLOEP.js +49 -0
  122. package/dist/cli/describe-core.d.mts +3 -3
  123. package/dist/cli/describe-core.d.ts +3 -3
  124. package/dist/cli/describe-core.js +4 -4
  125. package/dist/cli/describe-core.mjs +3 -3
  126. package/dist/cli/{executions-LYCL344R.mjs → executions-ICVVOYVG.mjs} +7 -7
  127. package/dist/cli/{executions-SOAZHCY4.js → executions-O37FN2SK.js} +9 -9
  128. package/dist/cli/{feedback-AVF6V7SV.mjs → feedback-3K3QPGCQ.mjs} +4 -4
  129. package/dist/cli/{feedback-OROUPUNJ.js → feedback-MAZQ7C6S.js} +8 -8
  130. package/dist/cli/{git-J5N5M57H.mjs → git-2MMD5KJS.mjs} +5 -5
  131. package/dist/cli/git-RQ2XLFYZ.js +25 -0
  132. package/dist/cli/index.js +142 -139
  133. package/dist/cli/index.mjs +45 -42
  134. package/dist/cli/{legacy-noops-QAQMZMEG.js → legacy-noops-2OX2Y3Y2.js} +8 -8
  135. package/dist/cli/{legacy-noops-ENRRM7BL.mjs → legacy-noops-VLSWJ6VE.mjs} +5 -5
  136. package/dist/cli/{monitors-CKQ65WRL.mjs → monitors-2NODQQWG.mjs} +8 -8
  137. package/dist/cli/{monitors-SFMQ5LFR.js → monitors-UCSV5FOR.js} +92 -92
  138. package/dist/cli/{org-3UNTDLT2.js → org-4YY73VTW.js} +73 -73
  139. package/dist/cli/{org-K4UIEU5P.mjs → org-W7AUQCDE.mjs} +7 -7
  140. package/dist/cli/{pages-NKZTGB4C.js → pages-FBZEUMXK.js} +18 -18
  141. package/dist/cli/{pages-6GPGBIAH.mjs → pages-ZRP7U5PO.mjs} +7 -7
  142. package/dist/cli/{play-BDEADESI.js → play-LFCTQJXA.js} +858 -632
  143. package/dist/cli/{play-62BEE7IX.mjs → play-XF2BSGTP.mjs} +372 -146
  144. package/dist/cli/{providers-SXGP44GH.js → providers-5456JNHP.js} +10 -10
  145. package/dist/cli/{providers-X3CUWMFP.mjs → providers-SICAPKGI.mjs} +7 -7
  146. package/dist/cli/{quickstart-XQ4426M4.js → quickstart-2KLLIPIU.js} +6 -6
  147. package/dist/cli/{quickstart-7LN22BKX.mjs → quickstart-IBVG6GX6.mjs} +4 -4
  148. package/dist/cli/{run-PBJ4ZJ4W.js → run-DNLDGJRC.js} +41 -41
  149. package/dist/cli/{run-XXSN3B5A.mjs → run-XPIZIQ7H.mjs} +26 -26
  150. package/dist/cli/search-2KQA65LH.js +32 -0
  151. package/dist/cli/{search-M75VMADD.mjs → search-PW22AEAL.mjs} +8 -8
  152. package/dist/cli/{search-output-F6HCFYEI.js → search-output-H6F6QMRF.js} +22 -16
  153. package/dist/cli/{search-output-NUQAKWDM.mjs → search-output-JFD53H2N.mjs} +14 -8
  154. package/dist/cli/{secrets-J2H6V33R.mjs → secrets-542CTZRZ.mjs} +7 -7
  155. package/dist/cli/{secrets-LRYY4QPE.js → secrets-LCCRRAN7.js} +16 -16
  156. package/dist/cli/{sessions-YPF62CZE.js → sessions-5FYDQE3N.js} +6 -6
  157. package/dist/cli/{sessions-IMT336UV.mjs → sessions-CALLS2XD.mjs} +5 -5
  158. package/dist/cli/{settings-PDWVQIGH.mjs → settings-GSKPHUEC.mjs} +12 -12
  159. package/dist/cli/{settings-35YYC5WA.js → settings-ORGKOBP6.js} +79 -79
  160. package/dist/cli/{setup-UR7GOR7H.js → setup-4BUWJKB6.js} +47 -47
  161. package/dist/cli/{setup-DG5DISSE.mjs → setup-V57GHVAF.mjs} +9 -9
  162. package/dist/cli/skills-KYZPPGSN.js +33 -0
  163. package/dist/cli/{skills-U6NJD5J7.mjs → skills-NGLCFQFT.mjs} +7 -7
  164. package/dist/cli/tools-AFYXUEMD.js +56 -0
  165. package/dist/cli/{tools-2HGEOELR.mjs → tools-G2YNCFNX.mjs} +19 -19
  166. package/dist/cli/{update-FRAYBAHK.mjs → update-IZ3Z5T5C.mjs} +9 -9
  167. package/dist/cli/update-T6JJ7A3K.js +33 -0
  168. package/dist/cli/{workflow-JKKLOMBX.js → workflow-7AHST2XV.js} +18 -18
  169. package/dist/cli/{workflow-DDKVTF36.mjs → workflow-L7ROQIM7.mjs} +8 -8
  170. package/dist/{client-DJ3r8VQJ.d.mts → client-BkbDHRIg.d.mts} +1 -1
  171. package/dist/{client-JPSNljtj.d.ts → client-D3hVHXjK.d.ts} +1 -1
  172. package/dist/{client-core-3SJlNsKU.d.mts → client-core-BZoSMKcY.d.mts} +30 -15
  173. package/dist/{client-core-rCoQ5Xz3.d.ts → client-core-DUdVqO_m.d.ts} +30 -15
  174. package/dist/{compiler-manifest-gkO9ZkVg.d.mts → compiler-manifest-BFTwq1HI.d.mts} +1 -1
  175. package/dist/{compiler-manifest-gkO9ZkVg.d.ts → compiler-manifest-BFTwq1HI.d.ts} +1 -1
  176. package/dist/{errors-Cc92LKH-.d.ts → errors-c3pMsylw.d.ts} +1 -1
  177. package/dist/{errors-CeCCOKSA.d.mts → errors-w31ybrQM.d.mts} +1 -1
  178. package/dist/{index-DJQKdV76.d.ts → index-CQ-15-QL.d.ts} +1 -1
  179. package/dist/{index-DsqWJL3Q.d.mts → index-DvNtxucX.d.mts} +1 -1
  180. package/dist/index.d.mts +7 -7
  181. package/dist/index.d.ts +7 -7
  182. package/dist/index.js +10 -10
  183. package/dist/index.mjs +7 -7
  184. package/dist/install-integrity.json +117 -116
  185. package/dist/plays/bundle-play-file.d.mts +3 -3
  186. package/dist/plays/bundle-play-file.d.ts +3 -3
  187. package/dist/plays/bundle-play-file.mjs +2 -2
  188. package/dist/plays/play-description.d.mts +2 -2
  189. package/dist/plays/play-description.d.ts +2 -2
  190. package/dist/plays/run-request.d.mts +2 -2
  191. package/dist/plays/run-request.d.ts +2 -2
  192. package/dist/plays/run-request.js +12 -2
  193. package/dist/plays/run-request.mjs +11 -1
  194. package/dist/release.d.mts +1 -1
  195. package/dist/release.d.ts +1 -1
  196. package/dist/release.js +2 -2
  197. package/dist/release.mjs +1 -1
  198. package/dist/server.d.mts +4 -4
  199. package/dist/server.d.ts +4 -4
  200. package/dist/server.js +6 -6
  201. package/dist/server.mjs +4 -4
  202. package/package.json +1 -1
  203. package/dist/cli/auth-L5CSV3UO.js +0 -43
  204. package/dist/cli/chunk-KA2LNIUP.js +0 -33
  205. package/dist/cli/describe-UIAYCHWW.js +0 -49
  206. package/dist/cli/git-ATMWC27D.js +0 -25
  207. package/dist/cli/search-IGHLRLBD.js +0 -32
  208. package/dist/cli/skills-4U5WC4MJ.js +0 -33
  209. package/dist/cli/tools-PYJTQVVS.js +0 -56
  210. package/dist/cli/update-344OTRFM.js +0 -33
@@ -29,6 +29,7 @@ import { AppRuntimeRateStateBackend } from '../governor/app-runtime-rate-state-b
29
29
  import { AppRuntimeBudgetStateBackend } from '../governor/app-runtime-budget-state-backend';
30
30
  import {
31
31
  parseCtxFetchHttpFailureDiagnostic,
32
+ tagLogProvenance,
32
33
  type CtxFetchHttpFailureDiagnostic,
33
34
  } from '../log-provenance';
34
35
  import type {
@@ -585,16 +586,18 @@ export async function fetchRunnerRuntimeControl(input: {
585
586
  const fetchImpl = input.fetchImpl ?? fetch;
586
587
  const sleepImpl = input.sleepImpl ?? sleepRunnerRuntimeControlRetry;
587
588
  const startedAt = Date.now();
588
- // Error responses spend the ordinary attempts. A request that gets no
589
- // response at all keeps retrying through a sandbox network cut.
589
+ // Header/body retries and no-response retries use independent ordinary
590
+ // budgets. Classified network cuts can also use the bounded outage budget.
590
591
  let respondedAttempts = 0;
591
- for (let attempt = 1; ; attempt += 1) {
592
+ let noResponseAttempts = 0;
593
+ for (;;) {
592
594
  const timeoutMs =
593
595
  input.timeoutMs ?? RUNNER_RUNTIME_CONTROL_REQUEST_TIMEOUT_MS;
594
596
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
595
597
  const signal = input.init.signal
596
598
  ? AbortSignal.any([input.init.signal, timeoutSignal])
597
599
  : timeoutSignal;
600
+ let responseReceived = false;
598
601
  try {
599
602
  // Never follow redirects on the sandbox -> receipt-gateway control plane.
600
603
  // Every runtime-control call from the Daytona sandbox targets the gateway
@@ -609,6 +612,7 @@ export async function fetchRunnerRuntimeControl(input: {
609
612
  redirect: 'manual',
610
613
  signal,
611
614
  });
615
+ responseReceived = true;
612
616
  if (response.status >= 300 && response.status < 400) {
613
617
  const location = response.headers.get('location') ?? '<none>';
614
618
  await response.text().catch(() => '');
@@ -659,22 +663,26 @@ export async function fetchRunnerRuntimeControl(input: {
659
663
  `${input.description} transport failed: ${transportMessage}`,
660
664
  );
661
665
  if (!input.retrySafe || input.init.signal?.aborted) throw failure;
666
+ if (!responseReceived) noResponseAttempts += 1;
667
+ const retryAttempt = responseReceived
668
+ ? respondedAttempts
669
+ : noResponseAttempts;
662
670
  const delayMs =
663
- RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS[attempt - 1] ??
671
+ RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS[retryAttempt - 1] ??
664
672
  Math.min(
665
673
  8_000,
666
- 1_000 * (attempt - RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS.length),
674
+ 1_000 *
675
+ (retryAttempt - RUNNER_RUNTIME_CONTROL_RETRY_DELAYS_MS.length),
667
676
  );
668
677
  const outageRetryAllowed =
678
+ !responseReceived &&
669
679
  (timeoutSignal.aborted || isRunnerGatewayNoResponseError(error)) &&
670
680
  Date.now() - startedAt + delayMs <=
671
681
  RUNNER_GATEWAY_CONNECTION_RETRY_BUDGET_MS;
672
- if (
673
- attempt >= RUNNER_RUNTIME_CONTROL_MAX_ATTEMPTS &&
674
- !outageRetryAllowed
675
- ) {
676
- throw failure;
677
- }
682
+ const normalRetryAllowed = responseReceived
683
+ ? respondedAttempts < RUNNER_RUNTIME_CONTROL_MAX_ATTEMPTS
684
+ : noResponseAttempts < RUNNER_RUNTIME_CONTROL_MAX_ATTEMPTS;
685
+ if (!normalRetryAllowed && !outageRetryAllowed) throw failure;
678
686
  await sleepImpl(delayMs);
679
687
  }
680
688
  }
@@ -890,10 +898,9 @@ export function createAppRuntimeToolAuthScopeDigestResolver(
890
898
 
891
899
  function createRateStateBackendForConfig(
892
900
  config: PlayRunnerExecutionConfig,
893
- ): Pick<
894
- ContextOptions,
895
- 'rateState' | 'budgetState' | 'requireSharedRateState'
896
- > {
901
+ ): Pick<ContextOptions, 'budgetState' | 'requireSharedRateState'> & {
902
+ rateState?: AppRuntimeRateStateBackend;
903
+ } {
897
904
  const backend = config.context.rateStateBackend;
898
905
  if (!backend || backend.kind === 'in_memory') return {};
899
906
  const baseUrl = config.context.baseUrl?.trim();
@@ -1255,6 +1262,8 @@ async function createStreamingCsvDataset(input: {
1255
1262
 
1256
1263
  export interface ExecutePlayRunnerOptions {
1257
1264
  emitEvent?: (event: PlayRunnerEvent) => void;
1265
+ /** Bounded phase values collected for the direct-runner timing summary. */
1266
+ runnerPhaseTimingsMs?: RunnerPhaseTimingsMs;
1258
1267
  signal?: AbortSignal;
1259
1268
  /** Stops future row admission while already admitted rows can persist. */
1260
1269
  rowAdmissionSignal?: AbortSignal;
@@ -1266,6 +1275,31 @@ export interface ExecutePlayRunnerOptions {
1266
1275
  }) => void;
1267
1276
  }
1268
1277
 
1278
+ const RUNNER_PHASE_NAMES = [
1279
+ 'process main',
1280
+ 'config load',
1281
+ 'artifact materialize',
1282
+ 'context setup',
1283
+ 'artifact compile',
1284
+ 'user function returned',
1285
+ 'play body returned',
1286
+ ] as const;
1287
+
1288
+ type RunnerPhaseName = (typeof RUNNER_PHASE_NAMES)[number];
1289
+ type RunnerPhaseTimingsMs = Partial<Record<RunnerPhaseName, number>>;
1290
+
1291
+ function recordRunnerPhaseTiming(
1292
+ timings: RunnerPhaseTimingsMs,
1293
+ line: string,
1294
+ ): void {
1295
+ const match = /^\[perf\] (.+) elapsed_ms=(\d+(?:\.\d+)?)$/.exec(line);
1296
+ if (!match) return;
1297
+ const phase = match[1] as RunnerPhaseName;
1298
+ if (!RUNNER_PHASE_NAMES.includes(phase)) return;
1299
+ const value = Number(match[2]);
1300
+ if (Number.isFinite(value) && value >= 0) timings[phase] = value;
1301
+ }
1302
+
1269
1303
  function emitRunnerEvent(
1270
1304
  event: PlayRunnerEvent,
1271
1305
  options?: ExecutePlayRunnerOptions,
@@ -1330,6 +1364,16 @@ function emitWorkerLog(line: string, options?: ExecutePlayRunnerOptions): void {
1330
1364
  );
1331
1365
  }
1332
1366
 
1367
+ function emitRunnerTiming(
1368
+ line: string,
1369
+ options: ExecutePlayRunnerOptions | undefined,
1370
+ ): void {
1371
+ emitWorkerLog(line, options);
1372
+ if (options?.runnerPhaseTimingsMs) {
1373
+ recordRunnerPhaseTiming(options.runnerPhaseTimingsMs, line);
1374
+ }
1375
+ }
1376
+
1333
1377
  function emitSystemLog(line: string, options?: ExecutePlayRunnerOptions): void {
1334
1378
  emitRunnerEvent(
1335
1379
  {
@@ -1500,6 +1544,14 @@ process.stdout.on('error', (err: NodeJS.ErrnoException) => {
1500
1544
  // instead of polled out of a sidecar file by the worker. Set once in main().
1501
1545
  let runnerProgressPusher: RunnerProgressPusher | null = null;
1502
1546
 
1547
+ /**
1548
+ * Host diagnostic for the progress transport at a runtime deadline. It goes to
1549
+ * stderr like `[play-runner.runtime-deadline]`, not to the customer Run Log.
1550
+ */
1551
+ function logRunnerLogTransport(pusher: RunnerProgressPusher | null): void {
1552
+ console.warn('[runtime.log_transport]', pusher?.snapshot() ?? null);
1553
+ }
1554
+
1503
1555
  function emit(event: PlayRunnerEvent): void {
1504
1556
  emitProgressSidecarEvent(event);
1505
1557
  if (runnerProgressPusher && shouldEmitProgressSidecarEvent(event)) {
@@ -1861,7 +1913,7 @@ async function executeRuntimePlayCode(input: {
1861
1913
  input.artifact.virtualFilename,
1862
1914
  dirname(input.artifact.virtualFilename),
1863
1915
  );
1864
- emitWorkerLog(
1916
+ emitRunnerTiming(
1865
1917
  `[perf] artifact compile elapsed_ms=${Date.now() - compileStartedAt}`,
1866
1918
  input.options,
1867
1919
  );
@@ -1890,7 +1942,7 @@ async function executeRuntimePlayCode(input: {
1890
1942
  // whose Slack-card replacement was confirmed. Provider capacity remains a
1891
1943
  // normal typed waterfall miss.
1892
1944
  input.ctx.assertNoRunFatalToolFailure();
1893
- emitWorkerLog(
1945
+ emitRunnerTiming(
1894
1946
  `[perf] user function returned elapsed_ms=${Date.now() - userFunctionStartedAt}`,
1895
1947
  input.options,
1896
1948
  );
@@ -2086,38 +2138,26 @@ async function releaseRuntimeLeasesOnAppRunnerSettlement(input: {
2086
2138
  }
2087
2139
  }
2088
2140
 
2089
- function terminalLogIdsWithPhaseSummary(ctx: {
2090
- getLogIds(): string[];
2091
- }): string[] {
2092
- // Summaries are new occurrences at result construction. Terminal retries
2093
- // reuse that result and its IDs, including the frozen summary bodies.
2094
- return [...ctx.getLogIds(), crypto.randomUUID(), crypto.randomUUID()];
2095
- }
2096
-
2097
- function terminalLogsWithPhaseSummary(ctx: {
2098
- getLogs(): string[];
2099
- getRuntimeResourceSnapshot(): unknown;
2100
- getLogDiagnostics(): unknown;
2101
- }): string[] {
2102
- return [
2103
- ...ctx.getLogs(),
2104
- `[runtime.logs] ${JSON.stringify(ctx.getLogDiagnostics())}`,
2105
- `[runtime.phase_summary] ${JSON.stringify(ctx.getRuntimeResourceSnapshot())}`,
2106
- ];
2141
+ // Runtime measurements travel as structured `stats` (`runtimeResources`,
2142
+ // `runtimeLogBuffer`), never as Run Log lines: a diagnostic line could reach
2143
+ // the ledger by both the live and terminal paths with different bodies.
2144
+ function terminalLogs(ctx: { getLogs(): string[] }): string[] {
2145
+ // A copy: terminal retries reuse this result, aligned with its log IDs.
2146
+ return ctx.getLogs().slice();
2107
2147
  }
2108
2148
 
2109
- function terminalLogMetadataWithPhaseSummary(ctx: {
2149
+ function terminalLogMetadata(ctx: {
2110
2150
  getLogMetadata(): Array<PlayLogMetadata | null>;
2111
2151
  }): Array<PlayLogMetadata | null> | undefined {
2112
2152
  const metadata = ctx.getLogMetadata();
2113
- return metadata.some(Boolean) ? [...metadata, null, null] : undefined;
2153
+ return metadata.some(Boolean) ? metadata : undefined;
2114
2154
  }
2115
2155
 
2116
- function terminalLogContextsWithPhaseSummary(ctx: {
2156
+ function terminalLogContexts(ctx: {
2117
2157
  getLogContexts(): Array<PlayLogContext | null>;
2118
2158
  }): Array<PlayLogContext | null> | undefined {
2119
2159
  const contexts = ctx.getLogContexts();
2120
- return contexts.some(Boolean) ? [...contexts, null, null] : undefined;
2160
+ return contexts.some(Boolean) ? contexts : undefined;
2121
2161
  }
2122
2162
 
2123
2163
  function rowOutcomesFromCheckpoint(checkpoint: {
@@ -2735,7 +2775,6 @@ async function run(
2735
2775
  assertPlayRunnerRuntimeSheetPersistenceContext(config.context);
2736
2776
  const { baseUrl, orgId } = config.context;
2737
2777
  const startedAt = Date.now();
2738
- totalRows += items.length;
2739
2778
  const userEmail = config.context.userEmail;
2740
2779
  const playName = mapContext.playName ?? config.context.playName;
2741
2780
  const runId =
@@ -3238,6 +3277,11 @@ async function run(
3238
3277
  };
3239
3278
  },
3240
3279
  });
3280
+ rateStateBackend.rateState?.setDiagnosticSink((fields) =>
3281
+ ctx.logRunnerDiagnostic(
3282
+ `[runtime.provider.rate_state.decision] ${JSON.stringify(fields)}`,
3283
+ ),
3284
+ );
3241
3285
  receiptGatewayResponseObserver.attach(ctx);
3242
3286
 
3243
3287
  const csvSourceCache = new Map<string, ReplayableCsvSource>();
@@ -3374,7 +3418,7 @@ async function run(
3374
3418
  csvDatasetCache.set(datasetCacheKey, dataset);
3375
3419
  return dataset;
3376
3420
  };
3377
- emitWorkerLog(
3421
+ emitRunnerTiming(
3378
3422
  `[perf] context setup elapsed_ms=${Date.now() - contextSetupStartedAt}`,
3379
3423
  options,
3380
3424
  );
@@ -3410,6 +3454,7 @@ async function run(
3410
3454
  };
3411
3455
  const runtimeStats = () => ({
3412
3456
  ...ctx.getStats(),
3457
+ runtimeLogBuffer: ctx.getLogDiagnostics(),
3413
3458
  runtimeWorkCounterSegment: {
3414
3459
  invocationSeq: workCounterInvocationSeq,
3415
3460
  segmentId: workCounterSegmentId,
@@ -3423,12 +3468,12 @@ async function run(
3423
3468
  status: 'failed',
3424
3469
  error: runtimeLimitExceededCause(runtimeLimitSeconds),
3425
3470
  errors: [runtimeLimitExceededFailure(runtimeLimitSeconds)],
3426
- logs: terminalLogsWithPhaseSummary(ctx),
3471
+ logs: terminalLogs(ctx),
3427
3472
  ...(config.context.runtimeLogIdentity === 'origin'
3428
- ? { logIds: terminalLogIdsWithPhaseSummary(ctx) }
3473
+ ? { logIds: ctx.getLogIds() }
3429
3474
  : {}),
3430
- logContexts: terminalLogContextsWithPhaseSummary(ctx),
3431
- logMetadata: terminalLogMetadataWithPhaseSummary(ctx),
3475
+ logContexts: terminalLogContexts(ctx),
3476
+ logMetadata: terminalLogMetadata(ctx),
3432
3477
  stats: runtimeStats(),
3433
3478
  steps: ctx.getSteps(),
3434
3479
  tableNamespace: null,
@@ -3484,7 +3529,7 @@ async function run(
3484
3529
  // catch that error, so the context keeps a sticky handoff that remains
3485
3530
  // authoritative until this invocation returns it to the scheduler.
3486
3531
  ctx.assertNoPendingDurableSuspension();
3487
- emitWorkerLog(
3532
+ emitRunnerTiming(
3488
3533
  `[perf] play body returned elapsed_ms=${Date.now() - runStartedAt}`,
3489
3534
  options,
3490
3535
  );
@@ -3647,7 +3692,7 @@ async function run(
3647
3692
  reason: 'completed',
3648
3693
  });
3649
3694
 
3650
- const logs = terminalLogsWithPhaseSummary(ctx);
3695
+ const logs = terminalLogs(ctx);
3651
3696
  const runtimeDiagnostics = Array.from(
3652
3697
  new Map(
3653
3698
  logs
@@ -3673,10 +3718,10 @@ async function run(
3673
3718
  outputRowCount,
3674
3719
  logs,
3675
3720
  ...(config.context.runtimeLogIdentity === 'origin'
3676
- ? { logIds: terminalLogIdsWithPhaseSummary(ctx) }
3721
+ ? { logIds: ctx.getLogIds() }
3677
3722
  : {}),
3678
- logContexts: terminalLogContextsWithPhaseSummary(ctx),
3679
- logMetadata: terminalLogMetadataWithPhaseSummary(ctx),
3723
+ logContexts: terminalLogContexts(ctx),
3724
+ logMetadata: terminalLogMetadata(ctx),
3680
3725
  ...(runtimeDiagnostics.length > 0 ? { runtimeDiagnostics } : {}),
3681
3726
  ...(rowOutcomes ? { rowOutcomes } : {}),
3682
3727
  stats: runtimeStats(),
@@ -3730,12 +3775,12 @@ async function run(
3730
3775
  return {
3731
3776
  status: 'suspended',
3732
3777
  suspension: error.suspension,
3733
- logs: terminalLogsWithPhaseSummary(ctx),
3778
+ logs: terminalLogs(ctx),
3734
3779
  ...(config.context.runtimeLogIdentity === 'origin'
3735
- ? { logIds: terminalLogIdsWithPhaseSummary(ctx) }
3780
+ ? { logIds: ctx.getLogIds() }
3736
3781
  : {}),
3737
- logContexts: terminalLogContextsWithPhaseSummary(ctx),
3738
- logMetadata: terminalLogMetadataWithPhaseSummary(ctx),
3782
+ logContexts: terminalLogContexts(ctx),
3783
+ logMetadata: terminalLogMetadata(ctx),
3739
3784
  stats: runtimeStats(),
3740
3785
  steps: ctx.getSteps(),
3741
3786
  checkpoint: ctx.getCheckpoint(),
@@ -3770,12 +3815,12 @@ async function run(
3770
3815
  status: 'failed',
3771
3816
  error: formatRunnerFailure(error),
3772
3817
  errors: [failure],
3773
- logs: terminalLogsWithPhaseSummary(ctx),
3818
+ logs: terminalLogs(ctx),
3774
3819
  ...(config.context.runtimeLogIdentity === 'origin'
3775
- ? { logIds: terminalLogIdsWithPhaseSummary(ctx) }
3820
+ ? { logIds: ctx.getLogIds() }
3776
3821
  : {}),
3777
- logContexts: terminalLogContextsWithPhaseSummary(ctx),
3778
- logMetadata: terminalLogMetadataWithPhaseSummary(ctx),
3822
+ logContexts: terminalLogContexts(ctx),
3823
+ logMetadata: terminalLogMetadata(ctx),
3779
3824
  ...(rowOutcomes ? { rowOutcomes } : {}),
3780
3825
  stats: runtimeStats(),
3781
3826
  steps: ctx.getSteps(),
@@ -4056,7 +4101,12 @@ export async function materializeTransportedArtifact(
4056
4101
  }
4057
4102
 
4058
4103
  async function main() {
4059
- emitWorkerLog(
4104
+ const runnerPhaseTimingsMs: RunnerPhaseTimingsMs = {};
4105
+ const emitStartupRunnerTiming = (line: string) => {
4106
+ recordRunnerPhaseTiming(runnerPhaseTimingsMs, line);
4107
+ emitWorkerLog(line);
4108
+ };
4109
+ emitStartupRunnerTiming(
4060
4110
  `[perf] process main elapsed_ms=${Math.round(performance.now())}`,
4061
4111
  );
4062
4112
  const waitForConfig = process.argv[2] === '--wait-config';
@@ -4079,7 +4129,7 @@ async function main() {
4079
4129
  process.env.DEEPLINE_PLAY_RUNNER_STARTUP_DIAGNOSTIC_PATH,
4080
4130
  { phase: 'booted' },
4081
4131
  );
4082
- emitWorkerLog(
4132
+ emitStartupRunnerTiming(
4083
4133
  `[perf] config load elapsed_ms=${Date.now() - configLoadStartedAt}`,
4084
4134
  );
4085
4135
 
@@ -4103,7 +4153,7 @@ async function main() {
4103
4153
  parsedConfig,
4104
4154
  heartbeat,
4105
4155
  );
4106
- emitWorkerLog(
4156
+ emitStartupRunnerTiming(
4107
4157
  `[perf] artifact materialize elapsed_ms=${Date.now() - artifactMaterializeStartedAt}`,
4108
4158
  );
4109
4159
 
@@ -4111,9 +4161,7 @@ async function main() {
4111
4161
  const runtimeDeadline = startConfiguredPlayRunnerRuntimeDeadline({
4112
4162
  config,
4113
4163
  onDrain: (runtimeLimitSeconds) => {
4114
- runtimeState?.log(
4115
- `[runtime.log_transport] ${JSON.stringify(runnerProgressPusher?.snapshot() ?? null)}`,
4116
- );
4164
+ logRunnerLogTransport(runnerProgressPusher);
4117
4165
  runtimeState?.log(
4118
4166
  `Runtime limit approaching (${runtimeLimitSeconds}s configured); stopping new rows and saving started work for up to 4 seconds.`,
4119
4167
  );
@@ -4122,9 +4170,7 @@ async function main() {
4122
4170
  );
4123
4171
  },
4124
4172
  onDeadline: async (runtimeLimitSeconds) => {
4125
- runtimeState?.log(
4126
- `[runtime.log_transport] ${JSON.stringify(runnerProgressPusher?.snapshot() ?? null)}`,
4127
- );
4173
+ logRunnerLogTransport(runnerProgressPusher);
4128
4174
  executionController.abort(
4129
4175
  new Error(
4130
4176
  `Play runner reached its ${runtimeLimitSeconds}-second runtime limit.`,
@@ -4158,6 +4204,9 @@ async function main() {
4158
4204
  let executionError: unknown = undefined;
4159
4205
  try {
4160
4206
  result = await executePlayRunner(config, {
4207
+ ...(config.context.runtimeLogIdentity === 'origin'
4208
+ ? { runnerPhaseTimingsMs }
4209
+ : {}),
4161
4210
  signal: executionController.signal,
4162
4211
  rowAdmissionSignal: rowAdmissionController.signal,
4163
4212
  executionDrainAtMs: runtimeDeadline.drainAtMs,
@@ -4200,6 +4249,29 @@ async function main() {
4200
4249
  if (!result) {
4201
4250
  throw new Error('Play runner completed without a result.');
4202
4251
  }
4252
+ const runId = config.context.runId ?? config.context.workflowId;
4253
+ const playBodyMs = runnerPhaseTimingsMs['play body returned'];
4254
+ if (
4255
+ config.context.runtimeLogIdentity === 'origin' &&
4256
+ result.status === 'completed' &&
4257
+ runId &&
4258
+ typeof playBodyMs === 'number' &&
4259
+ Number.isFinite(playBodyMs)
4260
+ ) {
4261
+ emitWorkerLog(
4262
+ tagLogProvenance(
4263
+ 'infra',
4264
+ `[perf-trace] ${JSON.stringify({
4265
+ ts: Date.now(),
4266
+ source: 'runner',
4267
+ runId,
4268
+ phase: 'runner.phase_summary',
4269
+ ms: playBodyMs,
4270
+ phaseDurationsMs: runnerPhaseTimingsMs,
4271
+ })}`,
4272
+ ),
4273
+ );
4274
+ }
4203
4275
  (
4204
4276
  result as PlayRunnerResult & { workCompletedAtMs?: number }
4205
4277
  ).workCompletedAtMs = workCompletedAtMs;
@@ -1,4 +1,5 @@
1
1
  import type { PlayRunnerEvent } from '../protocol';
2
+ import { readProvenanceTag } from '../log-provenance';
2
3
 
3
4
  export const PLAY_RUNNER_STDOUT_EVENT_MODE_ENV =
4
5
  'DEEPLINE_PLAY_RUNNER_STDOUT_EVENT_MODE';
@@ -15,10 +16,17 @@ const PROGRESS_SIDECAR_LOG_PATTERNS = [
15
16
  /^\[perf\] runtime receipt /i,
16
17
  /^\[perf\] runtime state(?:[ =])/i,
17
18
  /^\[perf\]\[worker\.receipt_writer\.retry\] /i,
19
+ /^\[perf-trace\] \{"ts":\d+,"source":"runner","runId":"[^"]+","phase":"runner\.phase_summary","ms":\d+(?:\.\d+)?,"phaseDurationsMs":\{/,
18
20
  ] as const;
19
21
 
20
22
  function shouldEmitProgressSidecarLog(line: string): boolean {
21
- return PROGRESS_SIDECAR_LOG_PATTERNS.some((pattern) => pattern.test(line));
23
+ const tagged = readProvenanceTag(line);
24
+ if (tagged.provenance !== null && tagged.provenance !== 'infra') {
25
+ return false;
26
+ }
27
+ return PROGRESS_SIDECAR_LOG_PATTERNS.some((pattern) =>
28
+ pattern.test(tagged.line),
29
+ );
22
30
  }
23
31
 
24
32
  export function shouldEmitProgressSidecarEvent(
@@ -1,3 +1,4 @@
1
+ import { deleteDaytonaSandboxAndConfirmAbsence } from './daytona-sandbox-absence';
1
2
  import {
2
3
  Configuration,
3
4
  SandboxApi,
@@ -6,6 +7,7 @@ import {
6
7
  } from '@daytona/api-client';
7
8
  import { Daytona, Sandbox } from '@daytonaio/sdk';
8
9
  import axios from 'axios';
10
+ import type { DaytonaDeleteRetryAuthorization } from './daytona-lifecycle';
9
11
  import type { DaytonaClientOptions } from '../../daytona-runtime-config';
10
12
 
11
13
  /** Control-plane recovery must not inherit the SDK's 24-hour HTTP timeout. */
@@ -150,11 +152,29 @@ export function createDaytonaControlClient(
150
152
  );
151
153
  return { fs: recovery.fs };
152
154
  },
153
- async delete(sandbox: Pick<Sandbox, 'id'>): Promise<void> {
154
- // SDK Sandbox.delete starts an unawaited refresh after success. The
155
- // generated deletion endpoint preserves the same confirmed outcome
156
- // without starting a new request after this scope finishes.
157
- await call(() => api.deleteSandbox(sandbox.id));
155
+ async delete(
156
+ sandbox: Pick<Sandbox, 'id'>,
157
+ retry?: DaytonaDeleteRetryAuthorization,
158
+ ): Promise<void> {
159
+ const owned = sandboxData.get(sandbox as Sandbox);
160
+ if (owned?.id !== sandbox.id || !owned.organizationId?.trim()) {
161
+ throw new Error(
162
+ 'Daytona deletion requires this client’s exact owned sandbox and organization.',
163
+ );
164
+ }
165
+ await deleteDaytonaSandboxAndConfirmAbsence({
166
+ retry,
167
+ delete: () => call(() => api.deleteSandbox(owned.id)),
168
+ sandboxId: owned.id,
169
+ organizationId: owned.organizationId.trim(),
170
+ signal: controller.signal,
171
+ assertWithinDeadline: () => {
172
+ if (Date.now() >= deadlineAtMs)
173
+ controller.abort(new DaytonaControlTimeoutError());
174
+ controller.signal.throwIfAborted();
175
+ },
176
+ read: async () => (await call(() => api.getSandbox(owned.id))).data,
177
+ });
158
178
  },
159
179
  dispose(): void {
160
180
  clearTimeout(timer);