deepline 0.3.545 → 0.3.547

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 (222) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
  2. package/dist/bundling-sources/sdk/src/errors.ts +1 -1
  3. package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
  4. package/dist/bundling-sources/sdk/src/index.ts +7 -1
  5. package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
  6. package/dist/bundling-sources/sdk/src/play.ts +71 -0
  7. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
  9. package/dist/bundling-sources/sdk/src/types.ts +33 -0
  10. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
  12. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
  13. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
  14. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
  15. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
  16. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
  18. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
  19. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
  24. package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
  31. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
  32. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
  33. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
  34. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
  39. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
  42. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
  43. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
  44. package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
  45. package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
  46. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
  47. package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
  48. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
  49. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
  50. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
  51. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
  52. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
  53. package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
  54. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
  55. package/dist/cli/auth-AC5277PI.js +43 -0
  56. package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
  57. package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
  58. package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
  59. package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
  60. package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
  61. package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
  62. package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
  63. package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
  64. package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
  65. package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
  66. package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
  67. package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
  68. package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
  69. package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
  70. package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
  71. package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
  72. package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
  73. package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
  74. package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
  75. package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
  76. package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
  77. package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
  78. package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
  79. package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
  80. package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
  81. package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
  82. package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
  83. package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
  84. package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
  85. package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
  86. package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
  87. package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
  88. package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
  89. package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
  90. package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
  91. package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
  92. package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
  93. package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
  94. package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
  95. package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
  96. package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
  97. package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
  98. package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
  99. package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
  100. package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
  101. package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
  102. package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
  103. package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
  104. package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
  105. package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
  106. package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
  107. package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
  108. package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
  109. package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
  110. package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
  111. package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
  112. package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
  113. package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
  114. package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
  115. package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
  116. package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
  117. package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
  118. package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
  119. package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
  120. package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
  121. package/dist/cli/command-docs.js +2 -2
  122. package/dist/cli/command-docs.mjs +1 -1
  123. package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
  124. package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
  125. package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
  126. package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
  127. package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
  128. package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
  129. package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
  130. package/dist/cli/describe-GYYSLZLV.js +50 -0
  131. package/dist/cli/describe-core.d.mts +4 -4
  132. package/dist/cli/describe-core.d.ts +4 -4
  133. package/dist/cli/describe-core.js +1 -1
  134. package/dist/cli/describe-core.mjs +1 -1
  135. package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
  136. package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
  137. package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
  138. package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
  139. package/dist/cli/git-FZIQZNI4.js +25 -0
  140. package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
  141. package/dist/cli/index.js +150 -150
  142. package/dist/cli/index.mjs +46 -46
  143. package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
  144. package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
  145. package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
  146. package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
  147. package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
  148. package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
  149. package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
  150. package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
  151. package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
  152. package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
  153. package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
  154. package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
  155. package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
  156. package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
  157. package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
  158. package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
  159. package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
  160. package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
  161. package/dist/cli/search-JCWJX2XD.js +32 -0
  162. package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
  163. package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
  164. package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
  165. package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
  166. package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
  167. package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
  168. package/dist/cli/sessions-NA4SJH6Q.js +22 -0
  169. package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
  170. package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
  171. package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
  172. package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
  173. package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
  174. package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
  175. package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
  176. package/dist/cli/tools-WJQ6Y7E4.js +57 -0
  177. package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
  178. package/dist/cli/update-ZLRLTBRD.js +34 -0
  179. package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
  180. package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
  181. package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
  182. package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
  183. package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
  184. package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
  185. package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
  186. package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
  187. package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
  188. package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
  189. package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
  190. package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
  191. package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
  192. package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
  193. package/dist/index.d.mts +28 -8
  194. package/dist/index.d.ts +28 -8
  195. package/dist/index.js +65 -40
  196. package/dist/index.mjs +33 -8
  197. package/dist/install-integrity.json +137 -130
  198. package/dist/plays/bundle-play-file.d.mts +3 -3
  199. package/dist/plays/bundle-play-file.d.ts +3 -3
  200. package/dist/plays/bundle-play-file.mjs +640 -125
  201. package/dist/plays/play-description.d.mts +3 -3
  202. package/dist/plays/play-description.d.ts +3 -3
  203. package/dist/plays/run-request.d.mts +2 -2
  204. package/dist/plays/run-request.d.ts +2 -2
  205. package/dist/release.d.mts +1 -1
  206. package/dist/release.d.ts +1 -1
  207. package/dist/release.js +2 -2
  208. package/dist/release.mjs +1 -1
  209. package/dist/server.d.mts +4 -4
  210. package/dist/server.d.ts +4 -4
  211. package/dist/server.js +11 -11
  212. package/dist/server.mjs +5 -5
  213. package/package.json +1 -1
  214. package/dist/cli/auth-455MB4K6.js +0 -43
  215. package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
  216. package/dist/cli/describe-ZRGYAEBT.js +0 -50
  217. package/dist/cli/git-RC4XDATD.js +0 -25
  218. package/dist/cli/search-O5VVMXII.js +0 -32
  219. package/dist/cli/sessions-3PWFWCHO.js +0 -22
  220. package/dist/cli/skills-RFOMVXIT.js +0 -36
  221. package/dist/cli/tools-CAO6EVUW.js +0 -57
  222. package/dist/cli/update-L4DQZY3G.js +0 -34
@@ -556,6 +556,8 @@ export type RunsListOptions = {
556
556
  status?: string;
557
557
  /** Mermaid node id; returns that node's latest settled input/output per run. Requires play. */
558
558
  node?: string;
559
+ /** Include each run's per-step outcome and the diagram's steps. Requires play; at most 50 runs per page. */
560
+ steps?: boolean;
559
561
  limit?: number;
560
562
  /** Zero-based page offset. Requires `play` because status-only inventory is not paginated. */
561
563
  offset?: number;
@@ -564,6 +566,10 @@ export type RunsListOptions = {
564
566
  /** One server page; legacy runs.list continues to return an array. */
565
567
  export type RunsListPage = {
566
568
  runs: PlayRunListItem[];
569
+ /** The diagram's steps in flow order, when `steps` was asked for. */
570
+ stepNodes?: import('./types').PlayRunStepNode[];
571
+ /** Set when `steps` was asked for but the Play draws no diagram. */
572
+ stepsUnavailable?: 'no_diagram';
567
573
  total?: number;
568
574
  offset?: number;
569
575
  limit?: number;
@@ -5309,6 +5315,13 @@ export class DeeplineClient {
5309
5315
  );
5310
5316
  params.set('node', node);
5311
5317
  }
5318
+ if (options.steps) {
5319
+ if (!playName)
5320
+ throw new Error('runs.list options.steps requires options.play.');
5321
+ if (node)
5322
+ throw new Error('runs.list options.steps cannot be combined with node.');
5323
+ params.set('steps', 'true');
5324
+ }
5312
5325
  if (typeof options.limit === 'number' && Number.isFinite(options.limit)) {
5313
5326
  params.set('limit', String(Math.max(1, Math.floor(options.limit))));
5314
5327
  }
@@ -133,7 +133,7 @@ export class AuthError extends DeeplineError {
133
133
  * @sdkReference errors 100
134
134
  */
135
135
  export class RateLimitError extends DeeplineError {
136
- /** Milliseconds to wait before retrying, from the `Retry-After` response header. Defaults to 5000. */
136
+ /** Milliseconds to wait before retrying: the exact `retry-after-ms` delay when Deepline sends one, else the `Retry-After` header. Defaults to 5000. */
137
137
  public retryAfterMs: number;
138
138
 
139
139
  /** Constructed by the SDK after exhausting HTTP-level rate-limit retries. */
@@ -546,7 +546,7 @@ export class HttpClient {
546
546
  const candidateUrls = options?.exactUrlOnly
547
547
  ? [url]
548
548
  : buildCandidateUrls(url);
549
- let retryAfterDelayMs: number | null = null;
549
+ let retryAfterHint: RetryAfterHint | null = null;
550
550
  let totalRetryWaitMs = 0;
551
551
 
552
552
  let maxRetries = options?.maxRetries ?? this.config.maxRetries;
@@ -559,11 +559,19 @@ export class HttpClient {
559
559
  }
560
560
  if (attempt > 0) {
561
561
  const backoffMs = Math.min(1000 * Math.pow(2, attempt - 1), 30_000);
562
+ // An exact limiter hint is when the next slot frees, so the first
563
+ // retry waits only that. Being refused again means other callers took
564
+ // the slot: later retries keep the exponential backoff floor so a
565
+ // crowd of refused callers spreads out instead of spending every
566
+ // retry in the same instant. A whole-second Retry-After is always a
567
+ // floor under the backoff.
562
568
  const delayMs =
563
- retryAfterDelayMs === null
569
+ retryAfterHint === null
564
570
  ? backoffMs
565
- : Math.max(backoffMs, retryAfterDelayMs);
566
- retryAfterDelayMs = null;
571
+ : retryAfterHint.exact && attempt === 1
572
+ ? retryAfterHint.delayMs
573
+ : Math.max(backoffMs, retryAfterHint.delayMs);
574
+ retryAfterHint = null;
567
575
  if (totalRetryWaitMs + delayMs > MAX_AUTOMATIC_RETRY_WAIT_MS) {
568
576
  // Honor the upstream delay by returning its original error. Never
569
577
  // retry sooner than requested, and never let automatic retries hold
@@ -675,7 +683,10 @@ export class HttpClient {
675
683
  failure.retryAfterMs ?? Math.max(0, retryAfter),
676
684
  });
677
685
  if (responseRetryAllowed && attempt < maxRetries) {
678
- retryAfterDelayMs = retryAfter;
686
+ retryAfterHint = parseRetryAfterHint(response) ?? {
687
+ delayMs: retryAfter,
688
+ exact: false,
689
+ };
679
690
  break;
680
691
  }
681
692
  throw attachToolUpstreamResponse(lastError, parsed);
@@ -698,7 +709,10 @@ export class HttpClient {
698
709
  const retryAfter = parseRetryAfter(response);
699
710
  lastError = new RateLimitError(retryAfter);
700
711
  if (responseRetryAllowed && attempt < maxRetries) {
701
- retryAfterDelayMs = retryAfter;
712
+ retryAfterHint = parseRetryAfterHint(response) ?? {
713
+ delayMs: retryAfter,
714
+ exact: false,
715
+ };
702
716
  break;
703
717
  }
704
718
  throw options?.toolId
@@ -740,7 +754,7 @@ export class HttpClient {
740
754
  },
741
755
  );
742
756
  if (retryableApiError && attempt < maxRetries) {
743
- retryAfterDelayMs = parseOptionalRetryAfter(response);
757
+ retryAfterHint = parseRetryAfterHint(response);
744
758
  break;
745
759
  }
746
760
  throw lastError;
@@ -770,7 +784,7 @@ export class HttpClient {
770
784
  response: parsed,
771
785
  });
772
786
  if (retryableApiError && attempt < maxRetries) {
773
- retryAfterDelayMs = parseOptionalRetryAfter(response);
787
+ retryAfterHint = parseRetryAfterHint(response);
774
788
  break;
775
789
  }
776
790
  throw options?.toolId
@@ -1220,17 +1234,32 @@ function detectHtmlErrorBody(
1220
1234
  };
1221
1235
  }
1222
1236
 
1223
- /** Parse the `Retry-After` header as milliseconds. Falls back to 5000ms. */
1237
+ type RetryAfterHint = {
1238
+ delayMs: number;
1239
+ /** True when the server sent the limiter's exact delay (`retry-after-ms`). */
1240
+ exact: boolean;
1241
+ };
1242
+
1243
+ /** The response's retry delay in milliseconds. Falls back to 5000ms. */
1224
1244
  function parseRetryAfter(response: Response): number {
1225
- return parseOptionalRetryAfter(response) ?? 5000;
1245
+ return parseRetryAfterHint(response)?.delayMs ?? 5000;
1226
1246
  }
1227
1247
 
1228
- function parseOptionalRetryAfter(response: Response): number | null {
1248
+ /**
1249
+ * Deepline's execute limiter sends `retry-after-ms`, the exact delay until
1250
+ * its window frees a slot, beside `Retry-After`, which can only say whole
1251
+ * seconds. Prefer the exact delay when it is present.
1252
+ */
1253
+ function parseRetryAfterHint(response: Response): RetryAfterHint | null {
1254
+ const exactMs = Number(response.headers.get('retry-after-ms') ?? '');
1255
+ if (Number.isFinite(exactMs) && exactMs > 0) {
1256
+ return { delayMs: Math.ceil(exactMs), exact: true };
1257
+ }
1229
1258
  const header = response.headers.get('retry-after');
1230
1259
  if (header) {
1231
1260
  const seconds = Number(header);
1232
1261
  if (Number.isFinite(seconds) && seconds > 0) {
1233
- return seconds * 1000;
1262
+ return { delayMs: seconds * 1000, exact: false };
1234
1263
  }
1235
1264
  }
1236
1265
  return null;
@@ -315,7 +315,13 @@ export {
315
315
  readList,
316
316
  steps,
317
317
  } from './play';
318
- export { deepline as default, deepline, runScriptPlay } from './play';
318
+ export {
319
+ deepline as default,
320
+ deepline,
321
+ runScriptPlay,
322
+ __deeplineCurrentDocflowContext,
323
+ __deeplineRunWithDocflowContext,
324
+ } from './play';
319
325
  export type { ScriptPlayContext } from './play';
320
326
 
321
327
  // ——— Tool output processing ———
@@ -1,8 +1,9 @@
1
1
  import type { CalendarDelegationChange } from '../../shared_libs/integration-contracts/calendar-delegation';
2
2
  import {
3
3
  GOOGLE_WORKSPACE_DOMAIN_PATTERN,
4
- GOOGLE_WORKSPACE_BOOKING_SCOPES,
4
+ GOOGLE_WORKSPACE_AVAILABILITY_SCOPE,
5
5
  GOOGLE_WORKSPACE_BOOKING_SCOPE,
6
+ GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE,
6
7
  } from '../../shared_libs/integration-contracts/calendar-delegation';
7
8
  import type { DeeplineClient } from './client-core';
8
9
  import { DeeplineError } from './errors';
@@ -26,6 +27,7 @@ export type IntegrationChangeOptions = {
26
27
  verificationEmail?: string;
27
28
  dryRun?: boolean;
28
29
  booking?: boolean;
30
+ listCalendars?: boolean;
29
31
  };
30
32
 
31
33
  function invalid(message: string): never {
@@ -67,6 +69,11 @@ async function changeConnection(
67
69
  (action !== 'reconnect' || row.type !== 'workspace_delegation')
68
70
  )
69
71
  invalid('Use --booking with Google Workspace verify or reconnect.');
72
+ if (
73
+ options.listCalendars &&
74
+ (action !== 'reconnect' || row.type !== 'workspace_delegation')
75
+ )
76
+ invalid('Use --list-calendars with Google Workspace verify or reconnect.');
70
77
  if (row.type === 'workspace_delegation') {
71
78
  if (row.provider !== CALENDAR_PROVIDER || !row.domain)
72
79
  invalid('The workspace approval is missing its provider or domain.');
@@ -146,18 +153,21 @@ async function verifyWorkspace(
146
153
  : await client.getCalendarDelegation(undefined, undefined, domain);
147
154
  if (settings.grantRevision === undefined)
148
155
  invalid('The API did not return a workspace approval revision.');
149
- const requestedScopes = options.booking
150
- ? [...GOOGLE_WORKSPACE_BOOKING_SCOPES]
151
- : settings.grantedScopes;
156
+ const requestedScopes = [
157
+ ...new Set([
158
+ GOOGLE_WORKSPACE_AVAILABILITY_SCOPE,
159
+ ...(settings.grantedScopes ?? []),
160
+ ...(options.booking ? [GOOGLE_WORKSPACE_BOOKING_SCOPE] : []),
161
+ ...(options.listCalendars ? [GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE] : []),
162
+ ]),
163
+ ];
152
164
  const change: CalendarDelegationChange = {
153
165
  action: 'enable_workspace',
154
166
  domain,
155
167
  grantRevision: settings.grantRevision,
156
168
  ...(settings.connectionId ? { connectionId: settings.connectionId } : {}),
157
169
  verificationEmail: email,
158
- ...(requestedScopes?.includes(GOOGLE_WORKSPACE_BOOKING_SCOPE)
159
- ? { requestedScopes }
160
- : {}),
170
+ ...(requestedScopes.length > 1 ? { requestedScopes } : {}),
161
171
  };
162
172
  if (options.dryRun) return change;
163
173
  return client.changeCalendarDelegation(change);
@@ -516,6 +516,77 @@ type ScriptRun = {
516
516
 
517
517
  const scriptRuns = new AsyncLocalStorage<ScriptRun>();
518
518
 
519
+ /**
520
+ * The context of the definePlay run executing in this async flow. The bundler
521
+ * wraps an entry's run function in {@link __deeplineRunWithDocflowContext}
522
+ * only when an imported helper module holds a diagram box the entry draws.
523
+ */
524
+ /*
525
+ * Created on first use, not at module load: the SDK is bundled into every Play,
526
+ * and a module-level `new` is a side effect esbuild cannot drop, so a Play
527
+ * without helper-module diagram boxes would otherwise carry it.
528
+ */
529
+ let docflowRunContexts: AsyncLocalStorage<DeeplinePlayRuntimeContext> | null =
530
+ null;
531
+
532
+ /**
533
+ * Runs a play body with its context published for compiler-instrumented
534
+ * diagram boxes in helper modules, which have no context in scope.
535
+ *
536
+ * @internal
537
+ */
538
+ export function __deeplineRunWithDocflowContext<T>(
539
+ context: DeeplinePlayRuntimeContext,
540
+ body: () => T,
541
+ ): T {
542
+ docflowRunContexts ??= new AsyncLocalStorage<DeeplinePlayRuntimeContext>();
543
+ return docflowRunContexts.run(context, body);
544
+ }
545
+
546
+ /** What a helper module's compiler-injected box observation calls. */
547
+ type DocflowHelperObserver = {
548
+ __deeplineObserveDocflowNode(
549
+ nodeId: string,
550
+ inputCaptures: readonly unknown[],
551
+ outputPaths: readonly string[],
552
+ execute: () => unknown,
553
+ ): unknown;
554
+ };
555
+
556
+ /**
557
+ * The observer a helper module's diagram box reports through, or null outside
558
+ * a run (unit tests, module initialization), where the box is a pass-through.
559
+ * Observations are marked `origin: 'helper'` so the runtime can decline ones
560
+ * made inside a dataset row: maps observe at the node level (ADR 0016).
561
+ *
562
+ * @internal
563
+ */
564
+ export function __deeplineCurrentDocflowContext(): DocflowHelperObserver | null {
565
+ const context =
566
+ docflowRunContexts?.getStore() ??
567
+ scriptRuns.getStore()?.context ??
568
+ null;
569
+ if (!context) return null;
570
+ // Display-only: a context that cannot be read is no context at all.
571
+ let observe: unknown;
572
+ try {
573
+ // A runtime that predates helper observation would ignore `origin` and
574
+ // observe a helper once per dataset row: only one declaring it is used.
575
+ if (Reflect.get(context, '__deeplineDocflowHelperObservation') !== true)
576
+ return null;
577
+ observe = Reflect.get(context, '__deeplineObserveDocflowNode');
578
+ } catch {
579
+ return null;
580
+ }
581
+ if (typeof observe !== 'function') return null;
582
+ return {
583
+ __deeplineObserveDocflowNode: (nodeId, inputCaptures, outputPaths, execute) =>
584
+ observe.call(context, nodeId, inputCaptures, outputPaths, execute, {
585
+ origin: 'helper',
586
+ }),
587
+ };
588
+ }
589
+
519
590
  /**
520
591
  * The run whose context a callback the runtime invokes outside the play's
521
592
  * async flow belongs to, such as a dataset `key` function called while rows
@@ -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.545',
208
+ version: '0.3.547',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -15,6 +15,12 @@ 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
+ // Interactive Plays usually finish 6–30 s after the watch starts (admission,
19
+ // sandbox launch and a few calls). A 2 s cadence there made the CLI notice a
20
+ // finished run up to 2 s late (Production 1-call runs, 2026-11-18). Poll every
21
+ // 500 ms until 30 s, then fall back to the steady-state cadence.
22
+ const RUN_WATCH_INTERACTIVE_POLL_INTERVAL_MS = 500;
23
+ const RUN_WATCH_INTERACTIVE_WINDOW_MS = 30_000;
18
24
  /**
19
25
  * Server-held wait per snapshot request once the startup window has passed:
20
26
  * the run route answers as soon as the run is terminal, or after this bound,
@@ -232,8 +238,9 @@ export async function* watchRunEvents(
232
238
  const poll = ++pollCount;
233
239
  // Keep terminal detection responsive through the sandbox startup window,
234
240
  // then reduce snapshot reads for runs that continue beyond it.
235
- const pastStartup =
236
- pollStartedAt - watchStartedAt >= RUN_WATCH_STARTUP_WINDOW_MS;
241
+ const watchedMs = pollStartedAt - watchStartedAt;
242
+ const pastStartup = watchedMs >= RUN_WATCH_STARTUP_WINDOW_MS;
243
+ const pastInteractive = watchedMs >= RUN_WATCH_INTERACTIVE_WINDOW_MS;
237
244
  const serverWaitMs =
238
245
  options.pollIntervalMs === undefined &&
239
246
  options.deferLogs &&
@@ -246,9 +253,11 @@ export async function* watchRunEvents(
246
253
  options.pollIntervalMs ??
247
254
  (serverWaitMs > 0
248
255
  ? 0
249
- : pastStartup
256
+ : pastInteractive
250
257
  ? RUN_WATCH_POLL_INTERVAL_MS
251
- : RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
258
+ : pastStartup
259
+ ? RUN_WATCH_INTERACTIVE_POLL_INTERVAL_MS
260
+ : RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
252
261
  let snapshot: PlayRunLiveSnapshot;
253
262
  let terminalStatus: Record<string, unknown> | undefined;
254
263
  let responseStatus: number | undefined;
@@ -1460,6 +1460,11 @@ export interface PlayRunListItem {
1460
1460
  inputsTruncated: boolean;
1461
1461
  outputsTruncated: boolean;
1462
1462
  } | null;
1463
+ /**
1464
+ * What the run did at each diagram step it reached, when `runs.list` asks
1465
+ * for `steps`. Fixed size per step; unreached steps are absent.
1466
+ */
1467
+ steps?: PlayRunStepSummary[];
1463
1468
  /** Metadata attached to the workflow. */
1464
1469
  memo: {
1465
1470
  /** Organization that owns this run. */
@@ -1471,6 +1476,28 @@ export interface PlayRunListItem {
1471
1476
  };
1472
1477
  }
1473
1478
 
1479
+ /** One run's outcome at one diagram step (`runs.list` with `steps`). */
1480
+ export interface PlayRunStepSummary {
1481
+ /** Diagram node id. */
1482
+ nodeId: string;
1483
+ status: 'completed' | 'failed' | 'running';
1484
+ /** The step's one-line result, as its canvas card shows it (≤ 80 chars). */
1485
+ label: string | null;
1486
+ /** The arm a decision took, as drawn (≤ 80 chars). */
1487
+ arm: string | null;
1488
+ /** Why the step failed, first line (≤ 160 chars). */
1489
+ error: string | null;
1490
+ }
1491
+
1492
+ /** One diagram step, in flow order (`runs.list` with `steps`). */
1493
+ export interface PlayRunStepNode {
1494
+ id: string;
1495
+ label: string;
1496
+ kind: string;
1497
+ regionId: string | null;
1498
+ regionLabel: string | null;
1499
+ }
1500
+
1474
1501
  /**
1475
1502
  * A single revision (version) of a play's code and configuration.
1476
1503
  */
@@ -2117,6 +2144,12 @@ export interface PlayCheckIssue {
2117
2144
  hint?: string;
2118
2145
  validOptions?: string[];
2119
2146
  docsHint?: string;
2147
+ /** The diagram box or subgraph id a diagram issue is about. */
2148
+ node?: string;
2149
+ /** The checked entry file's 1-based line to edit, when known. */
2150
+ line?: number;
2151
+ /** One line to paste that fixes this issue, tailored to it. */
2152
+ fix?: string;
2120
2153
  }
2121
2154
 
2122
2155
  /**
@@ -3,10 +3,16 @@ export const GOOGLE_WORKSPACE_AVAILABILITY_SCOPE =
3
3
  'https://www.googleapis.com/auth/calendar.freebusy';
4
4
  export const GOOGLE_WORKSPACE_BOOKING_SCOPE =
5
5
  'https://www.googleapis.com/auth/calendar.events.owned';
6
+ export const GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE =
7
+ 'https://www.googleapis.com/auth/calendar.calendarlist.readonly';
6
8
  export const GOOGLE_WORKSPACE_BOOKING_SCOPES = [
7
9
  GOOGLE_WORKSPACE_AVAILABILITY_SCOPE,
8
10
  GOOGLE_WORKSPACE_BOOKING_SCOPE,
9
11
  ] as const;
12
+ export const GOOGLE_WORKSPACE_APPROVAL_SCOPES = [
13
+ ...GOOGLE_WORKSPACE_BOOKING_SCOPES,
14
+ GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE,
15
+ ] as const;
10
16
  export const GOOGLE_WORKSPACE_DOMAIN_PATTERN =
11
17
  /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
12
18
 
@@ -116,6 +122,7 @@ export type CalendarDelegationCheck = {
116
122
  | 'runtime_identity'
117
123
  | 'signing'
118
124
  | 'google_grant'
125
+ | 'calendar_list'
119
126
  | 'primary_calendar';
120
127
  };
121
128
 
@@ -540,6 +540,8 @@ export const PROVIDER_MONITOR_BATCH_CHANGE_BUCKETS: Readonly<
540
540
  deleted_monitor_intent_closed: 'removed',
541
541
  fleet_member_removed: 'removed',
542
542
  fleet_converged_inactive: 'removed',
543
+ // A billing suspension's confirmed delete (desired state kept).
544
+ fleet_suspended: 'removed',
543
545
  provider_batch_created_then_stopped: 'removed',
544
546
  provider_batch_created_then_deleted: 'removed',
545
547
  // A start's radar deleted, never adopted, after a newer stop (KAR-198).
@@ -29,6 +29,7 @@ export const RB2B_POST_DEPLOY_GUIDANCE = {
29
29
  'In RB2B, open Integrations and choose Webhook.',
30
30
  'Paste {{callback_url}} as the single webhook URL and save.',
31
31
  "Use RB2B's Send a Test Event action to verify the connection.",
32
+ "Optional: turn on Send company-only profiles to also receive company-level visits. They arrive with profile_type 'company' and no person fields.",
32
33
  ],
33
34
  documentation: [
34
35
  {
@@ -284,7 +284,7 @@
284
284
  "owner": "evals",
285
285
  "criticality": "reporting",
286
286
  "purpose": "Run each prebuilt play on its fixed labeled sample in the persistent benchmark workspace on Production with the published CLI (reusing results under 4 days old when nothing changed) and publish found, exact, recall, precision and settled credits.",
287
- "successDefinition": "Every benchmark exports its rows (or reuses a recent fresh run), scores them, settles within its credit cap and the workspace's 2000-credit monthly usage cap, and the summary uploads.",
287
+ "successDefinition": "Every benchmark exports its rows (or reuses a recent fresh run), scores them, settles within its credit cap and the workspace's monthly usage cap, and the summary uploads.",
288
288
  "failureDefinition": "A dataset load, play run, export, scoring or credit-cap overrun fails, or the workspace's monthly usage cap is missing or used up.",
289
289
  "startGraceMs": 600000,
290
290
  "runTimeoutMs": 18000000,
@@ -1126,6 +1126,24 @@
1126
1126
  "failureAlert": "convex_action_wrapper",
1127
1127
  "domainReportRequired": true
1128
1128
  },
1129
+ {
1130
+ "id": "convex.monitor-billing-policy-continuation",
1131
+ "name": "Monitor billing policy pass continuation",
1132
+ "scheduler": "convex_scheduled_action",
1133
+ "cadence": "runAfter(0) when a billing policy pass reaches its 200-page invocation budget, and runAfter with 30 s doubling backoff to retry a failed continuation",
1134
+ "timezone": "UTC",
1135
+ "source": "packages/convex/scheduledJobsNode.ts",
1136
+ "locator": "dispatchMonitorBillingPolicyPassContinuation",
1137
+ "owner": "billing",
1138
+ "criticality": "critical",
1139
+ "purpose": "Continue a workspace or Fleet billing policy pass (spend shutdown, cap change, credit recovery, sweep or operator run) past one invocation from its committed cursor, so Monitors past the first 20,000 definitions are switched off or revived and the pass's notification and cap recovery run once at its last page.",
1140
+ "successDefinition": "The invocation commits its pages and schedules the next one, or reads the last page and runs the post-pass work, or ends the chain as superseded because the cap, the wallet's admission or the archive changed; a failed page or spend re-check schedules a retry from the last committed page.",
1141
+ "failureDefinition": "Five attempts at the same continuation fail, so the rest of the pass, its shutdown or recovery notification and its cap recovery do not run. The hourly provider-monitor policy sweep remains the backstop.",
1142
+ "startGraceMs": 120000,
1143
+ "runTimeoutMs": 600000,
1144
+ "failureAlert": "convex_action_wrapper",
1145
+ "domainReportRequired": true
1146
+ },
1129
1147
  {
1130
1148
  "id": "inngest.workflow-run-watchdog",
1131
1149
  "name": "Workflow run watchdog",
@@ -1245,8 +1263,8 @@
1245
1263
  "owner": "billing",
1246
1264
  "criticality": "operational",
1247
1265
  "purpose": "Request workspace drains for indexed pending usage from closed UTC days, including late arrivals.",
1248
- "successDefinition": "Discovery reaches the end of the indexed pending workspaces and issues closed-day wake requests. Each invocation inspects at most 200 workspaces.",
1249
- "failureDefinition": "Discovery or wake dispatch fails, or the bounded pass stops before reaching the end. The next invocation resumes from its saved workspace cursor.",
1266
+ "successDefinition": "Discovery reaches the end of the chronological pending-event scan and issues asynchronous workspace wake requests. Each query reads at most 25 events or 128 KiB; each invocation commits at most 40 pages within five minutes.",
1267
+ "failureDefinition": "Discovery or wake dispatch fails, or the bounded pass stops before reaching the end. The next invocation resumes from its saved event cursor and frozen time range.",
1250
1268
  "startGraceMs": 120000,
1251
1269
  "runTimeoutMs": 420000,
1252
1270
  "failureAlert": "convex_action_wrapper",
@@ -34,4 +34,9 @@ export interface PlaySheetColumnContract {
34
34
  export interface PlaySheetContract {
35
35
  tableNamespace: string;
36
36
  columns: PlaySheetColumnContract[];
37
+ /**
38
+ * Authored fields the run page shows first, in this order, from
39
+ * `.run({ columnOrder: [...] })`. Display only; absent on older contracts.
40
+ */
41
+ columnOrder?: string[];
37
42
  }
@@ -199,10 +199,24 @@ export async function confirmR2ObjectAbsent(
199
199
  );
200
200
  return false;
201
201
  } catch (error) {
202
- const details = error as {
202
+ if (isMissingR2Object(error)) return true;
203
+ throw error;
204
+ }
205
+ }
206
+
207
+ /**
208
+ * The object store answered that the key does not exist (and nothing else).
209
+ * A reader that wraps the store's error keeps it as its cause.
210
+ */
211
+ export function isMissingR2Object(error: unknown): boolean {
212
+ let current: unknown = error;
213
+ for (let depth = 0; depth < 4; depth += 1) {
214
+ if (!current || typeof current !== 'object') return false;
215
+ const details = current as {
203
216
  name?: string;
204
217
  Code?: string;
205
218
  $metadata?: { httpStatusCode?: number };
219
+ cause?: unknown;
206
220
  };
207
221
  if (
208
222
  details.$metadata?.httpStatusCode === 404 ||
@@ -212,8 +226,9 @@ export async function confirmR2ObjectAbsent(
212
226
  details.Code === 'NoSuchKey'
213
227
  )
214
228
  return true;
215
- throw error;
229
+ current = details.cause;
216
230
  }
231
+ return false;
217
232
  }
218
233
 
219
234
  export async function uploadBufferToR2(input: {
@@ -318,3 +318,30 @@ export function datasetWrittenColumnOrder(input: {
318
318
  for (const field of input.outputFields ?? []) append(field);
319
319
  return order;
320
320
  }
321
+
322
+ /**
323
+ * The written order to show: the contract's `columnOrder` columns first, in
324
+ * that order, then every other written column in written order. Always a
325
+ * permutation of `written` (a listed column the run never wrote is skipped),
326
+ * so the ledger's longest-list rule still sees the full set. `written` stays
327
+ * the append-only order; apply this to a copy at emission.
328
+ */
329
+ export function datasetDisplayColumnOrder(
330
+ written: readonly string[],
331
+ contract: Pick<PlaySheetContract, 'columns' | 'columnOrder'>,
332
+ ): string[] {
333
+ if (!contract.columnOrder?.length) return [...written];
334
+ const present = new Set(written);
335
+ const leading: string[] = [];
336
+ for (const field of contract.columnOrder) {
337
+ const declared = contract.columns.find(
338
+ (column) =>
339
+ (column.source === 'input' || column.source === 'datasetColumn') &&
340
+ (column.field ?? column.id) === field,
341
+ );
342
+ const sqlName = declared?.sqlName ?? sqlSafePlayColumnName(field);
343
+ if (present.has(sqlName) && !leading.includes(sqlName)) leading.push(sqlName);
344
+ }
345
+ const lead = new Set(leading);
346
+ return [...leading, ...written.filter((name) => !lead.has(name))];
347
+ }