deepline 0.3.537 → 0.3.538

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 (204) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +22 -5
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
  6. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
  7. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +330 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
  11. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
  16. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
  17. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
  20. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -3
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2390 -110
  35. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
  54. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
  55. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
  57. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
  59. package/dist/cli/auth-4WEVLYK4.js +43 -0
  60. package/dist/cli/{auth-4SUPGDIM.mjs → auth-KYH7N7RQ.mjs} +5 -5
  61. package/dist/cli/{billing-SQU726P7.js → billing-4KTUVZ4S.js} +114 -90
  62. package/dist/cli/{billing-5JUA3ZM3.mjs → billing-WK346KAI.mjs} +31 -7
  63. package/dist/cli/{chunk-KULT6O5K.js → chunk-25RGHJQL.js} +15 -15
  64. package/dist/cli/{chunk-PJ4ZGZAN.js → chunk-34PLG5OE.js} +13 -13
  65. package/dist/cli/{chunk-37AZHCTP.mjs → chunk-35OCRH5C.mjs} +5 -5
  66. package/dist/cli/{chunk-JMHYDDBQ.js → chunk-3I5TU5XE.js} +292 -279
  67. package/dist/cli/{chunk-Y6AMMXWS.mjs → chunk-4KZF6OYY.mjs} +3 -3
  68. package/dist/cli/{chunk-BRRCWUOW.mjs → chunk-4NEOGPKD.mjs} +1 -1
  69. package/dist/cli/{chunk-NU7B5X6J.mjs → chunk-4WQR4DG4.mjs} +1 -1
  70. package/dist/cli/{chunk-AVQET3NR.js → chunk-5VSPRRTI.js} +7 -7
  71. package/dist/cli/{chunk-EEFSUCYP.mjs → chunk-6JG3MRTM.mjs} +2 -2
  72. package/dist/cli/{chunk-D77W6Q67.js → chunk-6SLQLWWL.js} +26 -26
  73. package/dist/cli/{chunk-ZUAMXZXC.mjs → chunk-7XDJKIM2.mjs} +4 -4
  74. package/dist/cli/{chunk-C37VELBR.mjs → chunk-A6E7TCK2.mjs} +5 -5
  75. package/dist/cli/{chunk-JS2SBCWD.js → chunk-ADLDU2QG.js} +6 -6
  76. package/dist/cli/{chunk-VP2K5B3R.mjs → chunk-ALARRSMZ.mjs} +3 -3
  77. package/dist/cli/{chunk-CHIGEDAE.js → chunk-B2BTBHX2.js} +3 -3
  78. package/dist/cli/{chunk-CFND2ACL.js → chunk-BBS2BLPV.js} +16 -16
  79. package/dist/cli/{chunk-QDBGPRR2.mjs → chunk-CLO562KG.mjs} +3 -1
  80. package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
  81. package/dist/cli/{chunk-UGA5KI4A.js → chunk-ESX3H7Q7.js} +22 -22
  82. package/dist/cli/{chunk-BFHR7IC2.mjs → chunk-FJ5KPGCS.mjs} +10 -10
  83. package/dist/cli/{chunk-R7JYG6XO.mjs → chunk-FWE37N2P.mjs} +1 -1
  84. package/dist/cli/{chunk-K4WJ4BYO.mjs → chunk-ICTA5ICE.mjs} +1 -1
  85. package/dist/cli/{chunk-PU42VOBI.js → chunk-IMLFB66A.js} +3 -3
  86. package/dist/cli/{chunk-GI3V4D7K.mjs → chunk-IP3XJTWA.mjs} +2 -2
  87. package/dist/cli/{chunk-WBFOV5HT.js → chunk-JCLRSMUP.js} +5 -5
  88. package/dist/cli/{chunk-L3JVGNAT.mjs → chunk-JPEBKN3K.mjs} +2 -2
  89. package/dist/cli/{chunk-Z2PPB3IO.mjs → chunk-JTOV5RUA.mjs} +1 -1
  90. package/dist/cli/{chunk-WBTYWJLN.js → chunk-KCUQNH4K.js} +2 -2
  91. package/dist/cli/{chunk-C3XD2WHM.mjs → chunk-KNIYEZVV.mjs} +2 -2
  92. package/dist/cli/{chunk-3PMCQ3LK.js → chunk-LPTBHNGB.js} +7 -5
  93. package/dist/cli/{chunk-KH27B2HJ.mjs → chunk-M3NCXGNN.mjs} +2 -2
  94. package/dist/cli/{chunk-XDS26J7Z.js → chunk-MNBIGX6O.js} +10 -10
  95. package/dist/cli/{chunk-L6QAIZNZ.js → chunk-MYSPQUAO.js} +44 -44
  96. package/dist/cli/{chunk-W3J3LT22.mjs → chunk-N2BCPZVR.mjs} +5 -5
  97. package/dist/cli/{chunk-ZFSB7GXF.js → chunk-N5HSG4OV.js} +5 -5
  98. package/dist/cli/{chunk-2Q7VXTMS.js → chunk-O765M4LT.js} +2 -2
  99. package/dist/cli/{chunk-QPDLG7DQ.js → chunk-OOLBE6FR.js} +53 -53
  100. package/dist/cli/{chunk-IQOIT6E3.js → chunk-P3DP56HB.js} +41 -41
  101. package/dist/cli/{chunk-BGXEMTIG.js → chunk-PQKD5DMT.js} +19 -19
  102. package/dist/cli/{chunk-V5IIBG2E.mjs → chunk-T6GPTJ5F.mjs} +1 -1
  103. package/dist/cli/{chunk-GPMS6OPX.mjs → chunk-TWWYCJJW.mjs} +5 -5
  104. package/dist/cli/{chunk-ZHPSJ3LJ.mjs → chunk-UE7JHAZ2.mjs} +29 -16
  105. package/dist/cli/{chunk-VRYX2BR4.js → chunk-UEZNIPFO.js} +107 -107
  106. package/dist/cli/{chunk-AX2OAXDL.mjs → chunk-VCHV4LS3.mjs} +1 -1
  107. package/dist/cli/{chunk-NXGLJGPB.js → chunk-VIFLWQXS.js} +2 -2
  108. package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
  109. package/dist/cli/{chunk-5EOEJKSV.js → chunk-YQURGSRB.js} +1 -1
  110. package/dist/cli/{chunk-ALHKB3AE.js → chunk-YZ2ZPHWR.js} +9 -9
  111. package/dist/cli/{chunk-CGDW2CRR.mjs → chunk-ZDLDCXY3.mjs} +2 -2
  112. package/dist/cli/{chunk-RMVZTBI5.mjs → chunk-ZU6JBRV5.mjs} +4 -4
  113. package/dist/cli/command-docs.js +2 -2
  114. package/dist/cli/command-docs.mjs +1 -1
  115. package/dist/cli/{csv-HZP6QMG7.mjs → csv-2YKLUKDR.mjs} +4 -4
  116. package/dist/cli/{csv-JITYN27L.js → csv-LM7FBECI.js} +13 -13
  117. package/dist/cli/{db-QRIRTOMM.mjs → db-234UBWJH.mjs} +6 -6
  118. package/dist/cli/{db-FYSRB7O4.js → db-5PMA4IVW.js} +27 -27
  119. package/dist/cli/describe-C7GOSGYB.js +49 -0
  120. package/dist/cli/{describe-REXJVJC3.mjs → describe-W26LW5O7.mjs} +17 -17
  121. package/dist/cli/describe-core.d.mts +3 -3
  122. package/dist/cli/describe-core.d.ts +3 -3
  123. package/dist/cli/{executions-BSTF4DDS.js → executions-3S736GXX.js} +8 -8
  124. package/dist/cli/{executions-53KJAFOW.mjs → executions-GD7GXTJM.mjs} +6 -6
  125. package/dist/cli/{feedback-6MW3QOXX.js → feedback-BUWTDY4R.js} +14 -14
  126. package/dist/cli/{feedback-CWUJJF3J.mjs → feedback-GBV5HJJZ.mjs} +6 -6
  127. package/dist/cli/git-YG36MROC.js +25 -0
  128. package/dist/cli/{git-CKVZTJFS.mjs → git-YXJGTDQL.mjs} +5 -5
  129. package/dist/cli/index.js +143 -143
  130. package/dist/cli/index.mjs +42 -42
  131. package/dist/cli/{legacy-noops-USTBRFRX.mjs → legacy-noops-UJM6GBNP.mjs} +6 -6
  132. package/dist/cli/{legacy-noops-QBL4PNGB.js → legacy-noops-ZSF64V2U.js} +9 -9
  133. package/dist/cli/{monitors-6UCG5D7W.mjs → monitors-UERUQ6CT.mjs} +7 -7
  134. package/dist/cli/{monitors-VCR6SUZD.js → monitors-XQ2GNH6D.js} +100 -100
  135. package/dist/cli/{org-GSRBOJVO.mjs → org-CP4VLH6M.mjs} +6 -6
  136. package/dist/cli/{org-HPILTEG4.js → org-IF6MPVNR.js} +86 -86
  137. package/dist/cli/{play-TK7WOP5H.js → play-2NHQO5MO.js} +317 -317
  138. package/dist/cli/{play-QRTYQNG4.mjs → play-ZWDYYVPI.mjs} +17 -17
  139. package/dist/cli/{providers-OAQJWVBS.mjs → providers-2CVIATU4.mjs} +6 -6
  140. package/dist/cli/{providers-HEXNJ5QC.js → providers-LOPXQN56.js} +9 -9
  141. package/dist/cli/{quickstart-FFVHTPSP.mjs → quickstart-KVCFXLID.mjs} +4 -4
  142. package/dist/cli/{quickstart-PYZTFXZX.js → quickstart-N4WDEQZY.js} +6 -6
  143. package/dist/cli/{run-4DWJXJRO.js → run-BDT5LK3I.js} +42 -42
  144. package/dist/cli/{run-HLN6YYZH.mjs → run-RUXHYWLF.mjs} +22 -22
  145. package/dist/cli/search-ATDDVADT.js +32 -0
  146. package/dist/cli/{search-ZHRCXGEL.mjs → search-BFUTNPA5.mjs} +7 -7
  147. package/dist/cli/{search-output-2KY6PFDH.js → search-output-CTXI2QZU.js} +6 -6
  148. package/dist/cli/{search-output-N7QXACVK.mjs → search-output-WUGH4PZA.mjs} +4 -4
  149. package/dist/cli/{secrets-WXQ7XO5C.js → secrets-BZJZYFOU.js} +15 -15
  150. package/dist/cli/{secrets-FKMWBLHU.mjs → secrets-Z4XQVTC6.mjs} +6 -6
  151. package/dist/cli/sessions-HNU35AFM.js +22 -0
  152. package/dist/cli/{sessions-3YDTEDA5.mjs → sessions-VZXR3MQZ.mjs} +6 -6
  153. package/dist/cli/{settings-JTPASUZN.mjs → settings-VYEZFR4L.mjs} +12 -12
  154. package/dist/cli/{settings-67TWLQ6E.js → settings-WBYA4JMM.js} +85 -85
  155. package/dist/cli/{setup-KUERQJUX.js → setup-FS2RMSS2.js} +49 -49
  156. package/dist/cli/{setup-VYNGXUJ6.mjs → setup-H7KCI4SO.mjs} +9 -9
  157. package/dist/cli/skills-VPIURCAZ.js +36 -0
  158. package/dist/cli/{skills-KI4KYHH6.mjs → skills-YQNSJUUG.mjs} +7 -7
  159. package/dist/cli/tools-273GS5HU.js +56 -0
  160. package/dist/cli/{tools-UQDJS2RS.mjs → tools-ZF6SVEGW.mjs} +16 -16
  161. package/dist/cli/{update-7FQQUBOD.mjs → update-RKQNNJM4.mjs} +9 -9
  162. package/dist/cli/update-TOD3XY55.js +34 -0
  163. package/dist/cli/{views-JAM4MNNV.mjs → views-JHHOTWDU.mjs} +6 -6
  164. package/dist/cli/{views-MJK7JGZG.js → views-KN7FEDGT.js} +21 -21
  165. package/dist/cli/{workflow-AQPRIWQX.js → workflow-2WHSKTTV.js} +17 -17
  166. package/dist/cli/{workflow-TQRV5FGO.mjs → workflow-AAYLCLWA.mjs} +7 -7
  167. package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
  168. package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
  169. package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
  170. package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
  171. package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
  172. package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
  173. package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
  174. package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
  175. package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
  176. package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +1 -1
  177. package/dist/index.d.mts +7 -7
  178. package/dist/index.d.ts +7 -7
  179. package/dist/index.js +9 -9
  180. package/dist/index.mjs +6 -6
  181. package/dist/install-integrity.json +120 -112
  182. package/dist/plays/bundle-play-file.d.mts +3 -3
  183. package/dist/plays/bundle-play-file.d.ts +3 -3
  184. package/dist/plays/play-description.d.mts +2 -2
  185. package/dist/plays/play-description.d.ts +2 -2
  186. package/dist/plays/run-request.d.mts +2 -2
  187. package/dist/plays/run-request.d.ts +2 -2
  188. package/dist/release.d.mts +1 -1
  189. package/dist/release.d.ts +1 -1
  190. package/dist/release.js +2 -2
  191. package/dist/release.mjs +1 -1
  192. package/dist/server.d.mts +4 -4
  193. package/dist/server.d.ts +4 -4
  194. package/dist/server.js +5 -5
  195. package/dist/server.mjs +3 -3
  196. package/package.json +1 -1
  197. package/dist/cli/auth-Y2K2ZYYA.js +0 -43
  198. package/dist/cli/describe-LSOHOLFI.js +0 -49
  199. package/dist/cli/git-S7SWUZ3T.js +0 -25
  200. package/dist/cli/search-WERQBC6V.js +0 -32
  201. package/dist/cli/sessions-LXQ4Q6BS.js +0 -22
  202. package/dist/cli/skills-EFRLHY3F.js +0 -36
  203. package/dist/cli/tools-C3EIGFFP.js +0 -56
  204. package/dist/cli/update-KCY72RXH.js +0 -34
@@ -89,6 +89,7 @@ import {
89
89
  normalizePlayRunIntegrationMode,
90
90
  normalizePlayStatus,
91
91
  resolveStartPlayRunRequest,
92
+ playRunStartHeaders,
92
93
  runtimeSelectionHeaders,
93
94
  } from './plays/client-core';
94
95
  import { PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES } from '../../shared_libs/product-notifications/contract.js';
@@ -2592,6 +2593,18 @@ export type WorkspacesNamespace = {
2592
2593
  serviceAccounts: WorkspaceServiceAccountsNamespace;
2593
2594
  };
2594
2595
 
2596
+ /** Recorded retained-result consumers, not counterfactual credit savings. */
2597
+ export type WorkspaceReuseResult = {
2598
+ org_id: string;
2599
+ reuse: {
2600
+ reused_result_calls: number;
2601
+ confirmed_runs: number;
2602
+ recorded_since: number;
2603
+ updated_at: number;
2604
+ coverage: 'confirmed_recorded_runs';
2605
+ } | null;
2606
+ };
2607
+
2595
2608
  /** One authenticated per-request usage event from `/api/v2/usage/events`. */
2596
2609
  export type BillingUsageEvent = {
2597
2610
  id: string | null;
@@ -2783,6 +2796,8 @@ export type BillingNamespace = {
2783
2796
  ) => Promise<BillingUsageEventsResult>;
2784
2797
  /** Read current billing usage, or look up one exact execution charge by request ID. */
2785
2798
  usage: (options?: BillingUsageOptions) => Promise<BillingUsageResult>;
2799
+ /** Recorded result reuse; historical or incomplete runs are excluded. */
2800
+ reuse: () => Promise<WorkspaceReuseResult>;
2786
2801
  /** Metronome-authored target catalog and current Contract projection. */
2787
2802
  targetPlans: (options?: {
2788
2803
  promoCode?: string;
@@ -3272,6 +3287,7 @@ export class DeeplineClient {
3272
3287
  usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
3273
3288
  usageEvents: (options) => this.getBillingUsageEvents(options),
3274
3289
  usage: (options) => this.getBillingUsage(options),
3290
+ reuse: () => this.http.get<WorkspaceReuseResult>('/api/v2/usage/reuse'),
3275
3291
  targetPlans: (options) => this.getTargetBillingPlans(options),
3276
3292
  targetStatus: () => this.getTargetBillingStatus(),
3277
3293
  autoRecharge: {
@@ -3556,9 +3572,7 @@ export class DeeplineClient {
3556
3572
 
3557
3573
  /** The view's share links, newest first. Their tokens are never returned. */
3558
3574
  async listViewShareLinks(id: string): Promise<{ links: ViewShareLink[] }> {
3559
- return await this.http.get(
3560
- `/api/v2/views/${encodeURIComponent(id)}/links`,
3561
- );
3575
+ return await this.http.get(`/api/v2/views/${encodeURIComponent(id)}/links`);
3562
3576
  }
3563
3577
 
3564
3578
  /**
@@ -3587,7 +3601,10 @@ export class DeeplineClient {
3587
3601
  }
3588
3602
 
3589
3603
  /** Revoke a share link. It stops opening the view at once. */
3590
- async revokeViewShareLink(id: string, linkId: string): Promise<ViewShareLink> {
3604
+ async revokeViewShareLink(
3605
+ id: string,
3606
+ linkId: string,
3607
+ ): Promise<ViewShareLink> {
3591
3608
  return await this.http.delete(
3592
3609
  `/api/v2/views/${encodeURIComponent(id)}/links/${encodeURIComponent(linkId)}`,
3593
3610
  );
@@ -4066,7 +4083,7 @@ export class DeeplineClient {
4066
4083
  options,
4067
4084
  );
4068
4085
  const bodyJson = JSON.stringify(prepared.body);
4069
- const runtimeHeaders = runtimeSelectionHeaders(
4086
+ const runtimeHeaders = playRunStartHeaders(
4070
4087
  resolved.runtime,
4071
4088
  this.environment,
4072
4089
  );
@@ -433,3 +433,5 @@ export type {
433
433
  RunToolReceiptResult,
434
434
  RunToolReceiptsResponse,
435
435
  } from './runs/receipts';
436
+
437
+ export type { WorkspaceReuseResult } from './client-core.js';
@@ -25,6 +25,7 @@ import {
25
25
  type PlayRunStartOptions,
26
26
  } from './run-request';
27
27
  import {
28
+ EXPERIMENT_SWITCHES_HEADER,
28
29
  RUNTIME_ENVIRONMENT_TOKEN_HEADER,
29
30
  RETAINED_PIPELINE_RECEIVERS_HEADER,
30
31
  } from '../../../shared_libs/play-runtime/coordinator-headers.js';
@@ -230,6 +231,22 @@ export function runtimeSelectionHeaders(
230
231
  };
231
232
  }
232
233
 
234
+ /**
235
+ * Headers for a Play run start: the runtime selection credential plus, for
236
+ * internal measurement only, `DEEPLINE_EXPERIMENT_SWITCHES` forwarded verbatim.
237
+ * The server validates and authorizes it and rejects a bad or unauthorized
238
+ * value; the SDK never interprets it.
239
+ */
240
+ export function playRunStartHeaders(
241
+ runtime: PlayRunRuntimeSelection | undefined,
242
+ env: ClientEnvironment,
243
+ ): Record<string, string> | undefined {
244
+ const headers = runtimeSelectionHeaders(runtime, env);
245
+ const experimentSwitches = env.DEEPLINE_EXPERIMENT_SWITCHES?.trim();
246
+ if (!experimentSwitches) return headers;
247
+ return { ...headers, [EXPERIMENT_SWITCHES_HEADER]: experimentSwitches };
248
+ }
249
+
233
250
  function normalizeTestPolicyOverrides(
234
251
  value: unknown,
235
252
  source: string,
@@ -327,7 +344,7 @@ export class PlayClient {
327
344
  options?: PlayRunStartOptions,
328
345
  ): Promise<PlayRunStart> {
329
346
  const resolved = resolveStartPlayRunRequest(request, this.environment);
330
- const headers = runtimeSelectionHeaders(resolved.runtime, this.environment);
347
+ const headers = playRunStartHeaders(resolved.runtime, this.environment);
331
348
  return startPlayRun(
332
349
  this.http,
333
350
  resolved.request,
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.537',
208
+ version: '0.3.538',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -15,6 +15,21 @@ export const RUN_WATCH_POLL_INTERVAL_MS = 2_000;
15
15
  // two-second steady-state cadence below.
16
16
  const RUN_WATCH_STARTUP_POLL_INTERVAL_MS = 300;
17
17
  const RUN_WATCH_STARTUP_WINDOW_MS = 6_000;
18
+ /**
19
+ * Server-held wait per snapshot request once the startup window has passed:
20
+ * the run route answers as soon as the run is terminal, or after this bound,
21
+ * so terminal detection no longer waits out the 2 s cadence. 0 (off) keeps
22
+ * client-side polling only. Used only by watchers that defer logs, whose
23
+ * progress output does not depend on intermediate snapshots. Lands off.
24
+ */
25
+ export const RUN_WATCH_SERVER_WAIT_MS = 0;
26
+ /**
27
+ * Use the server-held wait from the first snapshot request instead of only
28
+ * after the startup window, so a short run is seen as soon as it is terminal
29
+ * rather than on the next 300 ms poll. Same watchers (deferred logs) and the
30
+ * same bounded server wait. Off.
31
+ */
32
+ export const RUN_WATCH_SERVER_WAIT_FROM_START = false;
18
33
  export const TERMINAL_LOG_PROJECTION_RETRY_LIMIT = 3;
19
34
 
20
35
  type WatchHttp = {
@@ -217,11 +232,23 @@ export async function* watchRunEvents(
217
232
  const poll = ++pollCount;
218
233
  // Keep terminal detection responsive through the sandbox startup window,
219
234
  // then reduce snapshot reads for runs that continue beyond it.
235
+ const pastStartup =
236
+ pollStartedAt - watchStartedAt >= RUN_WATCH_STARTUP_WINDOW_MS;
237
+ const serverWaitMs =
238
+ options.pollIntervalMs === undefined &&
239
+ options.deferLogs &&
240
+ (pastStartup || RUN_WATCH_SERVER_WAIT_FROM_START) &&
241
+ RUN_WATCH_SERVER_WAIT_MS > 0
242
+ ? RUN_WATCH_SERVER_WAIT_MS
243
+ : 0;
244
+ // A held request already waited server-side; poll again immediately.
220
245
  const pollIntervalMs =
221
246
  options.pollIntervalMs ??
222
- (pollStartedAt - watchStartedAt < RUN_WATCH_STARTUP_WINDOW_MS
223
- ? RUN_WATCH_STARTUP_POLL_INTERVAL_MS
224
- : RUN_WATCH_POLL_INTERVAL_MS);
247
+ (serverWaitMs > 0
248
+ ? 0
249
+ : pastStartup
250
+ ? RUN_WATCH_POLL_INTERVAL_MS
251
+ : RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
225
252
  let snapshot: PlayRunLiveSnapshot;
226
253
  let terminalStatus: Record<string, unknown> | undefined;
227
254
  let responseStatus: number | undefined;
@@ -242,7 +269,9 @@ export async function* watchRunEvents(
242
269
  }
243
270
  };
244
271
  try {
245
- const response = await http.get<unknown>(path, {
272
+ const response = await http.get<unknown>(
273
+ serverWaitMs > 0 ? `${path}&waitForTerminalMs=${serverWaitMs}` : path,
274
+ {
246
275
  signal,
247
276
  ...(options.onPoll
248
277
  ? {
@@ -72,7 +72,7 @@ export type BillingEntitlements = {
72
72
 
73
73
  /** `GET`/`POST /api/v2/billing/included-compute`. */
74
74
  export type IncludedCompute = {
75
- /** `unavailable`: the workspace is outside the November pricing rollout. */
75
+ /** `unavailable`: returned only by older deployments (retired November rollout). */
76
76
  status: 'on' | 'off' | 'unavailable';
77
77
  /** Credits per standard-equivalent sandbox minute; null at provider cost. */
78
78
  credits_per_minute: number | null;
@@ -1935,5 +1935,23 @@
1935
1935
  "runTimeoutMs": 800000,
1936
1936
  "failureAlert": "vercel_route_wrapper",
1937
1937
  "domainReportRequired": true
1938
+ },
1939
+ {
1940
+ "id": "convex.play-result-reuse-fold",
1941
+ "name": "Play result reuse summary fold",
1942
+ "scheduler": "convex_scheduled_mutation",
1943
+ "cadence": "runAfter(0) after confirmed terminal run summaries; lease-owned continuation",
1944
+ "timezone": "UTC",
1945
+ "source": "packages/convex/playRunReuse.ts",
1946
+ "locator": "drainDeltas",
1947
+ "owner": "platform",
1948
+ "criticality": "reporting",
1949
+ "purpose": "Fold confirmed terminal Play reuse contributions into a workspace total through the existing counter journal.",
1950
+ "successDefinition": "A bounded journal page applies and deletes atomically, or the owner observes no pending contributions.",
1951
+ "failureDefinition": "The native scheduled mutation fails; its unapplied journal contributions remain available to the owning drain.",
1952
+ "startGraceMs": 120000,
1953
+ "runTimeoutMs": 120000,
1954
+ "failureAlert": "convex_native_scheduled_function",
1955
+ "domainReportRequired": true
1938
1956
  }
1939
1957
  ]
@@ -148,6 +148,7 @@ export type RuntimeStatusUpdate = {
148
148
  attempt: number;
149
149
  invocationSeq: number;
150
150
  segmentId: string;
151
+ reusableResultCalls?: number;
151
152
  logicalCalls: number;
152
153
  providerRequests: number;
153
154
  provider429s: number;
@@ -0,0 +1,330 @@
1
+ /**
2
+ * Prebaked runner image contract (Modal published image).
3
+ *
4
+ * The play-runner bundle is static across runs of one deploy, yet every run
5
+ * used to gzip and upload it inside the payload envelope. A sandbox image that
6
+ * already carries the bundle at a path keyed by the bundle's own SHA-256 lets
7
+ * the launcher upload only the per-run config and Play artifact.
8
+ *
9
+ * Trust model: nothing here is assumed. The launcher only plans a baked run
10
+ * when an operator configured the expected hash AND that hash equals the hash
11
+ * of the bundle this very launcher would otherwise upload. It then verifies,
12
+ * inside the acquired sandbox and before any command that could start the
13
+ * runner, that the file exists and hashes to that value. Any other outcome
14
+ * (unset, stale, absent file, mismatched bytes, probe failure) keeps the
15
+ * existing full-upload path. No wire or schema version changes: the envelope
16
+ * field set is unchanged and `runnerCode: ''` simply means "already on disk".
17
+ */
18
+ import { createHash } from 'node:crypto';
19
+ import { gzipSync } from 'node:zlib';
20
+
21
+ /** Operator opt-in. Unset (the default) keeps today's full upload. */
22
+ export const BAKED_RUNNER_HASH_ENV = 'DEEPLINE_BAKED_RUNNER_HASH';
23
+ export const BAKED_RUNNER_ROOT = '/opt/deepline/runner';
24
+ export const BAKED_RUNNER_FILE_NAME = 'play-runner.cjs';
25
+
26
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
27
+
28
+ export function runnerBundleSha256(bundle: string): string {
29
+ return createHash('sha256').update(bundle, 'utf-8').digest('hex');
30
+ }
31
+
32
+ let lastHashed: { bundle: string; hash: string } | null = null;
33
+
34
+ /**
35
+ * The bundle is cached per worker process, so the same string is hashed run
36
+ * after run. Single-entry memo by content: a changed bundle recomputes.
37
+ */
38
+ export function runnerBundleSha256Memoized(bundle: string): string {
39
+ if (lastHashed && lastHashed.bundle === bundle) return lastHashed.hash;
40
+ const hash = runnerBundleSha256(bundle);
41
+ lastHashed = { bundle, hash };
42
+ return hash;
43
+ }
44
+
45
+ export function bakedRunnerPath(hash: string): string {
46
+ if (!SHA256_HEX.test(hash)) {
47
+ throw new Error('Baked runner hash must be 64 lowercase hex characters.');
48
+ }
49
+ return `${BAKED_RUNNER_ROOT}/${hash}/${BAKED_RUNNER_FILE_NAME}`;
50
+ }
51
+
52
+ export type BakedRunnerPlan =
53
+ | { status: 'disabled' }
54
+ | { status: 'invalid_config' }
55
+ | { status: 'stale_config'; configuredHash: string; bundleHash: string }
56
+ | { status: 'expected'; hash: string; path: string };
57
+
58
+ /**
59
+ * Decide whether this launch should try the baked path. `expected` is only a
60
+ * hypothesis that still has to be verified in the sandbox.
61
+ */
62
+ export function planBakedRunner(input: {
63
+ configuredHash: string | null | undefined;
64
+ bundle: string;
65
+ }): BakedRunnerPlan {
66
+ const configured = input.configuredHash?.trim().toLowerCase() ?? '';
67
+ if (!configured) return { status: 'disabled' };
68
+ if (!SHA256_HEX.test(configured)) return { status: 'invalid_config' };
69
+ const bundleHash = runnerBundleSha256Memoized(input.bundle);
70
+ if (bundleHash !== configured) {
71
+ return { status: 'stale_config', configuredHash: configured, bundleHash };
72
+ }
73
+ return {
74
+ status: 'expected',
75
+ hash: configured,
76
+ path: bakedRunnerPath(configured),
77
+ };
78
+ }
79
+
80
+ /** The configured hash when it is well formed; malformed config enables nothing. */
81
+ export function configuredBakedRunnerHash(
82
+ env: NodeJS.ProcessEnv = process.env,
83
+ ): string | null {
84
+ const configured = env[BAKED_RUNNER_HASH_ENV]?.trim().toLowerCase() ?? '';
85
+ return SHA256_HEX.test(configured) ? configured : null;
86
+ }
87
+
88
+ const MODAL_IMAGE_PRESENT_TTL_MS = 10 * 60_000;
89
+ const MODAL_IMAGE_ABSENT_TTL_MS = 30_000;
90
+
91
+ /**
92
+ * Modal published-image name for a runner hash. Modal object names must be
93
+ * shorter than 64 characters, so the tag is a 32-hex (128-bit) prefix; the
94
+ * full hash is still what the sandbox verifies before the file is used.
95
+ */
96
+ export const BAKED_MODAL_IMAGE_NAME = 'deepline-play-runner';
97
+
98
+ export function bakedModalImageRef(hash: string): string {
99
+ if (!SHA256_HEX.test(hash)) {
100
+ throw new Error('Baked runner hash must be 64 lowercase hex characters.');
101
+ }
102
+ return `${BAKED_MODAL_IMAGE_NAME}:${hash.slice(0, 32)}`;
103
+ }
104
+
105
+ /** Below Linux's 128 KiB single-argument limit for each `/bin/sh -c` RUN. */
106
+ const MODAL_RUN_CHUNK_CHARS = 96 * 1024;
107
+
108
+ /**
109
+ * Dockerfile commands that bake the runner into a Modal-built image. Modal's
110
+ * JS SDK cannot COPY from a local build context, so the gzipped bundle is
111
+ * carried as base64 in bounded RUN chunks and reassembled at
112
+ * /opt/deepline/runner/<sha256>/play-runner.cjs (file 0444, directory 0555),
113
+ * and the build fails unless the reassembled bytes hash to the bundle's SHA-256.
114
+ * The commands are a pure function of the bundle, so a rebuild is a cache hit.
115
+ */
116
+ export function bakedRunnerModalDockerfileCommands(bundle: string): string[] {
117
+ if (bundle.length === 0) throw new Error('Runner bundle is empty.');
118
+ const hash = runnerBundleSha256(bundle);
119
+ const encoded = gzipSync(Buffer.from(bundle, 'utf-8'), { level: 9 }).toString(
120
+ 'base64',
121
+ );
122
+ const staged = '/tmp/deepline-play-runner.gz.b64';
123
+ const commands = [`RUN rm -f ${staged}`];
124
+ for (
125
+ let offset = 0;
126
+ offset < encoded.length;
127
+ offset += MODAL_RUN_CHUNK_CHARS
128
+ ) {
129
+ commands.push(
130
+ `RUN printf '%s' '${encoded.slice(offset, offset + MODAL_RUN_CHUNK_CHARS)}' >> ${staged}`,
131
+ );
132
+ }
133
+ const dir = `${BAKED_RUNNER_ROOT}/${hash}`;
134
+ commands.push(
135
+ [
136
+ 'RUN set -eu',
137
+ `base64 -d < ${staged} | gzip -dc > /tmp/play-runner.cjs`,
138
+ `echo "${hash} /tmp/play-runner.cjs" | sha256sum -c -`,
139
+ `install -d -m 0755 "${dir}"`,
140
+ `install -m 0444 /tmp/play-runner.cjs "${dir}/${BAKED_RUNNER_FILE_NAME}"`,
141
+ `chmod 0555 "${dir}"`,
142
+ `rm -f /tmp/play-runner.cjs ${staged}`,
143
+ ].join('; '),
144
+ );
145
+ return commands;
146
+ }
147
+
148
+ /**
149
+ * The published image id, or null only when Modal says the name does not
150
+ * exist. Any other lookup failure (auth, network, throttling) is rethrown:
151
+ * a publisher must not read it as "absent" and rebuild over a live image.
152
+ */
153
+ export async function existingPublishedModalImageId(
154
+ lookup: () => Promise<{ imageId: string }>,
155
+ ): Promise<string | null> {
156
+ try {
157
+ return (await lookup()).imageId;
158
+ } catch (error) {
159
+ if (error instanceof Error && error.name === 'NotFoundError') return null;
160
+ throw error;
161
+ }
162
+ }
163
+
164
+ type ModalImageLookup<TImage> = { image: TImage | null; expiresAtMs: number };
165
+ const modalImageCaches = new WeakMap<
166
+ object,
167
+ Map<string, Promise<ModalImageLookup<unknown>>>
168
+ >();
169
+ const MODAL_IMAGE_LOOKUP_TIMEOUT_MS = 5_000;
170
+
171
+ /**
172
+ * Pick the image a new Modal sandbox is created from. The published baked
173
+ * image is chosen only when an operator configured a hash AND Modal resolves
174
+ * that exact published name; absence, any lookup failure, or a slow lookup
175
+ * keeps the profile's existing image. An operator-chosen runner image
176
+ * (DEEPLINE_MODAL_RUNNER_IMAGE) keeps its precedence: the baked image never
177
+ * replaces it, and the result says so (`skipped`) instead of silently. The runner file inside it is still
178
+ * verified in the sandbox before use, so a wrong image is harmless.
179
+ *
180
+ * Cached per Modal client (an image handle is bound to its client) for the
181
+ * 10 minutes when present and 30 seconds when absent; concurrent callers share
182
+ * one lookup.
183
+ */
184
+ export async function resolveModalRunnerImage<TImage>(input: {
185
+ client: object;
186
+ configuredHash: string | null;
187
+ /** DEEPLINE_MODAL_RUNNER_IMAGE chose the default image. */
188
+ explicitImage?: boolean;
189
+ defaultImage: () => TImage;
190
+ lookupPublished: (ref: string) => Promise<TImage>;
191
+ now?: () => number;
192
+ timeoutMs?: number;
193
+ }): Promise<{
194
+ image: TImage;
195
+ baked: boolean;
196
+ ref: string | null;
197
+ skipped?: 'explicit_runner_image';
198
+ }> {
199
+ if (!input.configuredHash) {
200
+ return { image: input.defaultImage(), baked: false, ref: null };
201
+ }
202
+ if (input.explicitImage) {
203
+ return {
204
+ image: input.defaultImage(),
205
+ baked: false,
206
+ ref: null,
207
+ skipped: 'explicit_runner_image',
208
+ };
209
+ }
210
+ const ref = bakedModalImageRef(input.configuredHash);
211
+ const now = input.now ?? Date.now;
212
+ let cache = modalImageCaches.get(input.client);
213
+ if (!cache) {
214
+ cache = new Map();
215
+ modalImageCaches.set(input.client, cache);
216
+ }
217
+ let entry: ModalImageLookup<TImage> | null = null;
218
+ const cached = cache.get(ref) as
219
+ | Promise<ModalImageLookup<TImage>>
220
+ | undefined;
221
+ if (cached) {
222
+ entry = await cached;
223
+ if (entry.expiresAtMs <= now()) entry = null;
224
+ }
225
+ if (!entry) {
226
+ let timer: ReturnType<typeof setTimeout> | undefined;
227
+ const absent = (): ModalImageLookup<TImage> => ({
228
+ image: null,
229
+ expiresAtMs: now() + MODAL_IMAGE_ABSENT_TTL_MS,
230
+ });
231
+ const lookup = Promise.race([
232
+ // A synchronous throw (for example a client without named images) is
233
+ // a failed lookup like any other, never a failed launch.
234
+ Promise.resolve()
235
+ .then(() => input.lookupPublished(ref))
236
+ .then(
237
+ (image): ModalImageLookup<TImage> => ({
238
+ image,
239
+ expiresAtMs: now() + MODAL_IMAGE_PRESENT_TTL_MS,
240
+ }),
241
+ absent,
242
+ ),
243
+ new Promise<ModalImageLookup<TImage>>((resolve) => {
244
+ timer = setTimeout(
245
+ () => resolve(absent()),
246
+ input.timeoutMs ?? MODAL_IMAGE_LOOKUP_TIMEOUT_MS,
247
+ );
248
+ }),
249
+ ]).finally(() => {
250
+ if (timer) clearTimeout(timer);
251
+ });
252
+ cache.set(ref, lookup);
253
+ entry = await lookup;
254
+ }
255
+ return entry.image === null
256
+ ? { image: input.defaultImage(), baked: false, ref }
257
+ : { image: entry.image, baked: true, ref };
258
+ }
259
+
260
+ const VERIFICATION_PREFIX = 'baked-runner:';
261
+
262
+ /**
263
+ * Runs inside the sandbox with Node alone. Arguments: absolute path, expected
264
+ * hash. Prints exactly one verdict line and always exits 0, so a probe failure
265
+ * is distinguishable from a verdict (no verdict line means "not verified").
266
+ */
267
+ export function buildBakedRunnerVerifySource(): string {
268
+ return `const fs=require('node:fs');const c=require('node:crypto');let r='missing';try{r=c.createHash('sha256').update(fs.readFileSync(process.argv[1])).digest('hex')===process.argv[2]?'ok':'mismatch'}catch(e){}console.log('${VERIFICATION_PREFIX}'+r);`;
269
+ }
270
+
271
+ /**
272
+ * `late`: no verdict line within the launcher's bound while the stream was
273
+ * still open. The in-sandbox guard alone decides then (it runs the baked file
274
+ * only on `ok`), and the detached-runner readiness check proves the runner
275
+ * live or recovers the attempt. A fallback on `late` could stop a runner that
276
+ * is already running.
277
+ */
278
+ export type BakedRunnerVerdict =
279
+ | 'ok'
280
+ | 'mismatch'
281
+ | 'missing'
282
+ | 'no_verdict'
283
+ | 'late';
284
+
285
+ /** Whether the launcher must start today's full upload for this verdict. */
286
+ export function bakedVerdictRequiresFallback(
287
+ verdict: BakedRunnerVerdict,
288
+ ): boolean {
289
+ return verdict !== 'ok' && verdict !== 'late';
290
+ }
291
+
292
+ /** Anything but an exact `ok` verdict is "not verified". */
293
+ export function parseBakedRunnerVerdict(stdout: string): BakedRunnerVerdict {
294
+ const line = stdout
295
+ .split(/\r?\n/)
296
+ .map((value) => value.trim())
297
+ .find((value) => value.startsWith(VERIFICATION_PREFIX));
298
+ const verdict = line?.slice(VERIFICATION_PREFIX.length);
299
+ return verdict === 'ok' || verdict === 'mismatch' || verdict === 'missing'
300
+ ? verdict
301
+ : 'no_verdict';
302
+ }
303
+
304
+ /**
305
+ * The launch-time decision. Resolves to a plan only when the operator enabled
306
+ * the baked path and this deploy's bundle hashes to the configured value; a
307
+ * stale or disabled configuration returns undefined and leaves the full upload
308
+ * untouched. `onStale` lets the caller log the skipped, otherwise silent, case.
309
+ */
310
+ export async function bakedRunnerPlanForLaunch(input: {
311
+ bundlePromise: Promise<string>;
312
+ configuredHash?: string | null;
313
+ onStale?: (
314
+ plan: Extract<BakedRunnerPlan, { status: 'stale_config' }>,
315
+ ) => void;
316
+ }): Promise<{ hash: string; path: string } | undefined> {
317
+ const configuredHash =
318
+ input.configuredHash === undefined
319
+ ? configuredBakedRunnerHash()
320
+ : input.configuredHash;
321
+ if (!configuredHash) return undefined;
322
+ const plan = planBakedRunner({
323
+ configuredHash,
324
+ bundle: await input.bundlePromise,
325
+ });
326
+ if (plan.status === 'stale_config') input.onStale?.(plan);
327
+ return plan.status === 'expected'
328
+ ? { hash: plan.hash, path: plan.path }
329
+ : undefined;
330
+ }