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
@@ -96,6 +96,8 @@ export type AsyncOperationResultMaterialization = {
96
96
 
97
97
  export type AsyncOperationContractWire = {
98
98
  version: 1;
99
+ /** External delivery is caller-owned; completion is not available to this runtime. */
100
+ delivery?: { kind: 'external_callback'; callbackInputField: string };
99
101
  /**
100
102
  * Keep a default synchronous Play call in the runner process: launch the
101
103
  * provider job, expose its handle in run progress, then poll companion tools
@@ -239,7 +241,34 @@ export function defineAsyncOperation(
239
241
  contract: AsyncOperationContract,
240
242
  ): AsyncOperationContract {
241
243
  required(contract.lifecycle.startAction, 'lifecycle.startAction');
242
- if (contract.lifecycle.pollActions.length === 0) {
244
+ const externalCallback = contract.delivery?.kind === 'external_callback';
245
+ if (contract.delivery) {
246
+ if (!externalCallback)
247
+ throw new Error('Unsupported async operation delivery kind.');
248
+ required(
249
+ contract.delivery.callbackInputField,
250
+ 'delivery.callbackInputField',
251
+ );
252
+ if (
253
+ contract.wait.kind !== 'caller_managed' ||
254
+ contract.runtimeManagedWait !== undefined ||
255
+ contract.recoveryWait !== undefined ||
256
+ contract.lifecycle.finishAction !== undefined ||
257
+ contract.lifecycle.cancelAction !== undefined ||
258
+ contract.lifecycle.pollActions.length !== 0 ||
259
+ contract.job.idPaths.length !== 0 ||
260
+ contract.launch !== undefined ||
261
+ contract.result.source !== 'start_result' ||
262
+ typeof contract.compatibility?.asyncGetAction === 'string' ||
263
+ contract.terminal.defaultOutcome !== 'running' ||
264
+ contract.terminal.rules.some((rule) => rule.outcome !== 'running')
265
+ ) {
266
+ throw new Error(
267
+ 'External callback delivery requires a caller-managed submission with no managed wait, recovery, polling, job ID, finish, cancel, or terminal enrichment result.',
268
+ );
269
+ }
270
+ }
271
+ if (!externalCallback && contract.lifecycle.pollActions.length === 0) {
243
272
  throw new Error(
244
273
  'AsyncOperationContract requires at least one lifecycle.pollActions entry.',
245
274
  );
@@ -318,7 +347,7 @@ export function defineAsyncOperation(
318
347
  'lifecycle.cancelAction',
319
348
  );
320
349
  }
321
- if (contract.job.idPaths.length === 0) {
350
+ if (!externalCallback && contract.job.idPaths.length === 0) {
322
351
  throw new Error(
323
352
  'AsyncOperationContract requires at least one job.idPaths entry.',
324
353
  );
@@ -437,8 +466,8 @@ export function projectAsyncGetAction(
437
466
  }
438
467
  return (
439
468
  contract.lifecycle.finishAction?.action ??
440
- contract.lifecycle.pollActions[contract.lifecycle.pollActions.length - 1]!
441
- .action
469
+ contract.lifecycle.pollActions[contract.lifecycle.pollActions.length - 1]
470
+ ?.action
442
471
  );
443
472
  }
444
473
 
@@ -493,12 +522,30 @@ export function resolveAsyncOperationPolling(input: {
493
522
  };
494
523
  }
495
524
 
525
+ /** A callback-only API has no poll action, provider handle, or runtime-owned completion. */
526
+ export function defineExternalCallbackAsyncOperation(input: {
527
+ startAction: string;
528
+ callbackInputField: string;
529
+ }): AsyncOperationContract {
530
+ return defineCallerManagedAsyncOperation({
531
+ startAction: input.startAction,
532
+ delivery: {
533
+ kind: 'external_callback',
534
+ callbackInputField: input.callbackInputField,
535
+ },
536
+ pollActions: [],
537
+ jobIdPaths: [],
538
+ asyncGetAction: null,
539
+ });
540
+ }
541
+
496
542
  /**
497
543
  * Compatibility-preserving declaration for intentionally caller-managed jobs.
498
544
  * The runner publishes the full lifecycle metadata but never polls it unless a
499
545
  * later provider migration explicitly changes `wait`.
500
546
  */
501
547
  export function defineCallerManagedAsyncOperation(input: {
548
+ delivery?: AsyncOperationContract['delivery'];
502
549
  startAction: string;
503
550
  pollActions: readonly string[];
504
551
  finishAction?: string;
@@ -526,6 +573,7 @@ export function defineCallerManagedAsyncOperation(input: {
526
573
  });
527
574
  return defineAsyncOperation({
528
575
  version: 1,
576
+ ...(input.delivery ? { delivery: input.delivery } : {}),
529
577
  compatibility: {
530
578
  asyncGetAction:
531
579
  input.asyncGetAction !== undefined
@@ -588,7 +636,11 @@ export function defineCallerManagedAsyncOperation(input: {
588
636
  export function projectAsyncOperationPollExecution(
589
637
  contract: AsyncOperationContractWire,
590
638
  ): AsyncOperationPollExecution | null {
591
- if (contract.wait.kind !== 'caller_managed') return null;
639
+ if (
640
+ contract.wait.kind !== 'caller_managed' ||
641
+ contract.delivery?.kind === 'external_callback'
642
+ )
643
+ return null;
592
644
  return {
593
645
  checkTimeoutMs:
594
646
  contract.polling.checkTimeoutMs ?? contract.polling.intervalMs,
@@ -1,4 +1,8 @@
1
1
  import { DURABLE_RUNS_ROLLOUT } from './durable-runs-rollout';
2
+ import {
3
+ createFencedCallDiagnosticsBudget,
4
+ startFencedCallDiagnostics,
5
+ } from './fenced-call-diagnostics';
2
6
  import { RuntimeSheetAdmissionRequestTooLargeError } from './runtime-sheet-errors';
3
7
  import {
4
8
  DatasetRowInputView,
@@ -234,6 +238,7 @@ import {
234
238
  projectToolResultListGetters,
235
239
  parseToolExecuteResponse,
236
240
  isToolExecuteResult,
241
+ docflowToolResultPreviewProjection,
237
242
  isSerializedToolExecuteResult,
238
243
  relayPublishedToolResultReference,
239
244
  serializeToolExecuteResult,
@@ -521,9 +526,21 @@ import {
521
526
  import {
522
527
  buildPlayDocflowNodeErrorPreview,
523
528
  buildPlayDocflowNodeInputPreviewMap,
529
+ isDocflowInvocationObserved,
524
530
  type PlayDocflowNodeInputCapture,
525
531
  } from './docflow-node-io';
526
532
  import type { DocflowObservationUpsert } from './docflow-observation';
533
+ import {
534
+ boundedText,
535
+ DocflowDecisionTracker,
536
+ } from './docflow-decision-tracker';
537
+ import {
538
+ DocflowTrackingFaultCounter,
539
+ guardDocflowTracking,
540
+ runDocflowObservationFailOpen,
541
+ type DocflowObservationSettlement,
542
+ type DocflowTrackingFaultStage,
543
+ } from './docflow-fail-open';
527
544
  import {
528
545
  assertNoSecretTaint,
529
546
  assertSecretAuthUsesTls,
@@ -3234,6 +3251,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3234
3251
  private processedRowCount = 0;
3235
3252
  /** New retained-result consumers in this runner invocation; recovery is excluded. */
3236
3253
  private reusableResultCalls = 0;
3254
+ /** Bounds fenced-call platform diagnostics for this run attempt. */
3255
+ private readonly fencedCallDiagnosticsBudget =
3256
+ createFencedCallDiagnosticsBudget();
3237
3257
  private reuseCountSupported = true;
3238
3258
  /**
3239
3259
  * Sleep call positions are scoped per mapped row. A single global counter is
@@ -3244,6 +3264,20 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3244
3264
  private sleepBoundaryIndex = 0;
3245
3265
  private readonly activeInlineInvocations = new Set<symbol>();
3246
3266
  private nextDocflowInvocationSequence = 0;
3267
+ /** Invocations of each box this attempt (`attempt:nodeId`), for sampling. */
3268
+ private readonly docflowInvocationCounts = new Map<string, number>();
3269
+ /**
3270
+ * @internal Declares that `__deeplineObserveDocflowNode` honours
3271
+ * `origin: 'helper'` (declines per-row helper observations and samples
3272
+ * repeated ones). The SDK routes helper-module boxes only to a runtime that
3273
+ * declares it, so a newer artifact on an older runtime observes nothing
3274
+ * there rather than one observation per dataset row.
3275
+ */
3276
+ readonly __deeplineDocflowHelperObservation = true;
3277
+ /** Decision boxes awaiting the arm the run takes (see the tracker). */
3278
+ private readonly docflowDecisions = new DocflowDecisionTracker<
3279
+ Extract<PlayExecutionEvent, { type: 'docflow.node.completed' }>
3280
+ >();
3247
3281
  /**
3248
3282
  * Whether this run captures the docflow trace at all (ADR 0019), decided at
3249
3283
  * admission and handed down through the signed runtime authority.
@@ -4051,38 +4085,119 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4051
4085
  );
4052
4086
  }
4053
4087
 
4054
- /** @internal Compiler-injected authored-flow execution marker. */
4055
- async __deeplineDocflowHit(nodeId: string): Promise<void> {
4056
- const normalizedNodeId = nodeId.trim();
4057
- if (!normalizedNodeId) {
4058
- throw new Error('Docflow runtime node id must be non-empty.');
4088
+ /**
4089
+ * Bounded internal reporting for docflow tracking faults. Tracking is
4090
+ * display-only (`docflow-fail-open.ts`): a fault is counted and written to
4091
+ * the runner's stderr (forwarded by the runtime log shipper), never to the
4092
+ * customer's run log, and never thrown into the Play.
4093
+ */
4094
+ private readonly docflowTrackingFaults = new DocflowTrackingFaultCounter(
4095
+ (line) => console.warn(line),
4096
+ () => ({
4097
+ run_id: this.currentRunId,
4098
+ play_name: this.#options.playName ?? null,
4099
+ }),
4100
+ );
4101
+
4102
+ private reportDocflowTrackingFault(
4103
+ stage: DocflowTrackingFaultStage,
4104
+ nodeId: unknown,
4105
+ error: unknown,
4106
+ ): void {
4107
+ try {
4108
+ this.docflowTrackingFaults.record(stage, nodeId, error);
4109
+ } catch {
4110
+ // Reporting is best-effort as well.
4059
4111
  }
4060
- // These calls are COMPILER-INJECTED, so bundle-time gating cannot reach
4061
- // them: a prebuilt is compiled once, with its diagram, and then runs for
4062
- // every org. Without this check an ungated customer running a prebuilt gets
4063
- // `docflow.node.*` events on the wire and a `step docflow:*` sequence in
4064
- // `plays run --watch` — the vocabulary of a feature they do not have.
4065
- // The id is still validated above: a malformed injection is a compiler bug
4066
- // and stays loud whether or not the run is capturing.
4067
- if (!this.docflowCaptureEnabled) return;
4068
- this.emitExecutionEvent({
4069
- type: 'docflow.node.hit',
4070
- nodeId: `docflow:${normalizedNodeId}`,
4071
- at: Date.now(),
4072
- });
4073
4112
  }
4074
4113
 
4075
- /** @internal Compiler-injected bounded authored-node observation boundary. */
4114
+ /**
4115
+ * @internal Compiler-injected authored-flow execution marker.
4116
+ *
4117
+ * Never rejects: older artifacts `await` it inline in the Play body, so a
4118
+ * rejection here would fail the run over a display-only marker.
4119
+ */
4120
+ async __deeplineDocflowHit(nodeId: string): Promise<void> {
4121
+ guardDocflowTracking(
4122
+ 'hit',
4123
+ (stage, error) => this.reportDocflowTrackingFault(stage, nodeId, error),
4124
+ () => {
4125
+ const normalizedNodeId = nodeId.trim();
4126
+ if (!normalizedNodeId) {
4127
+ // A malformed injection is a compiler bug: reported as a fault,
4128
+ // never thrown into the Play.
4129
+ throw new Error('Docflow runtime node id must be non-empty.');
4130
+ }
4131
+ // These calls are COMPILER-INJECTED, so bundle-time gating cannot
4132
+ // reach them: a prebuilt is compiled once, with its diagram, and then
4133
+ // runs for every org. Without this check an ungated customer running a
4134
+ // prebuilt gets `docflow.node.*` events on the wire and a
4135
+ // `step docflow:*` sequence in `plays run --watch` — the vocabulary of
4136
+ // a feature they do not have.
4137
+ if (!this.docflowCaptureEnabled) return;
4138
+ this.recordDocflowDecisionArmsSafely(normalizedNodeId);
4139
+ this.emitExecutionEvent({
4140
+ type: 'docflow.node.hit',
4141
+ nodeId: `docflow:${normalizedNodeId}`,
4142
+ at: Date.now(),
4143
+ });
4144
+ },
4145
+ );
4146
+ }
4147
+
4148
+ /**
4149
+ * @internal Compiler-injected bounded authored-node observation boundary.
4150
+ *
4151
+ * Fail-open by construction (`runDocflowObservationFailOpen`): `execute`
4152
+ * runs exactly once and its value or throw reaches the Play unchanged,
4153
+ * whatever any capture, preview, emit, or decision stage does.
4154
+ */
4076
4155
  __deeplineObserveDocflowNode<T>(
4077
4156
  nodeId: string,
4078
4157
  inputCaptures: readonly PlayDocflowNodeInputCapture[],
4079
4158
  outputPaths: readonly string[],
4080
4159
  execute: () => T | Promise<T>,
4160
+ /**
4161
+ * Optional, absent from every artifact bundled before helper-module
4162
+ * observation: `origin: 'helper'` marks a box bound inside an imported
4163
+ * helper, reached through the SDK's run-context store.
4164
+ */
4165
+ options?: { origin?: 'helper' },
4081
4166
  ): T | Promise<T> {
4167
+ return runDocflowObservationFailOpen(
4168
+ execute,
4169
+ () =>
4170
+ this.beginDocflowObservation<T>(
4171
+ nodeId,
4172
+ inputCaptures,
4173
+ outputPaths,
4174
+ options,
4175
+ ),
4176
+ (stage, error) => this.reportDocflowTrackingFault(stage, nodeId, error),
4177
+ );
4178
+ }
4179
+
4180
+ /**
4181
+ * Captures inputs and emits `started`; returns how to settle the
4182
+ * observation, or null when this invocation is not tracked. Any throw is a
4183
+ * tracking fault: the caller still runs the statement, untracked.
4184
+ */
4185
+ private beginDocflowObservation<T>(
4186
+ nodeId: string,
4187
+ inputCaptures: readonly PlayDocflowNodeInputCapture[],
4188
+ outputPaths: readonly string[],
4189
+ options: { origin?: 'helper' } | undefined,
4190
+ ): DocflowObservationSettlement<T> | null {
4082
4191
  const normalizedNodeId = nodeId.trim();
4083
4192
  if (!normalizedNodeId) {
4084
4193
  throw new Error('Docflow runtime node id must be non-empty.');
4085
4194
  }
4195
+ // A helper can be called from a dataset's per-row resolver. Maps observe at
4196
+ // the node level, not per row (ADR 0016): per-row truth already lives in
4197
+ // the sheet, and an observation per row per box would grow with the input.
4198
+ if (options?.origin === 'helper' && rowContext.getStore()) {
4199
+ return null;
4200
+ }
4086
4201
  // Ungated, this boundary is a pass-through: the wrapped work still runs and
4087
4202
  // still returns what it returned, but nothing is previewed, redacted, or
4088
4203
  // emitted. Returning before `buildPlayDocflowNodeInputPreviewMap` is the
@@ -4090,17 +4205,25 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4090
4205
  // customer outside the rollout should not pay for a capture they cannot
4091
4206
  // read. Same reasoning as `__deeplineDocflowHit` above: injected at compile
4092
4207
  // time, so the run is the only place left to decide.
4093
- if (!this.docflowCaptureEnabled) return execute();
4208
+ if (!this.docflowCaptureEnabled) return null;
4094
4209
  // Inline composition changes logical identity, but its gateway token and
4095
4210
  // durable observations remain owned by the executing receipt scope.
4096
4211
  const runId = this.currentReceiptOwnerRunId;
4097
4212
  const attempt = this.currentRunAttempt;
4213
+ // A box in a loop is invoked once per item: observe a bounded sample so the
4214
+ // durable writes per box stay O(log n) in the items processed.
4215
+ const invocationKey = `${attempt}:${normalizedNodeId}`;
4216
+ const ordinal = (this.docflowInvocationCounts.get(invocationKey) ?? 0) + 1;
4217
+ this.docflowInvocationCounts.set(invocationKey, ordinal);
4218
+ if (!isDocflowInvocationObserved(ordinal)) return null;
4098
4219
  const inputs = buildPlayDocflowNodeInputPreviewMap(inputCaptures, {
4099
4220
  redactor: this.secretRedactor,
4221
+ projectRoot: docflowToolResultPreviewProjection,
4100
4222
  });
4101
4223
  const invocationSeq = this.nextDocflowInvocationSequence++;
4102
4224
  const invocationId = `${attempt}:${invocationSeq}`;
4103
4225
  const observationNodeId = `docflow:${normalizedNodeId}`;
4226
+ this.recordDocflowDecisionArmsSafely(normalizedNodeId);
4104
4227
  this.emitExecutionEvent({
4105
4228
  type: 'docflow.node.started',
4106
4229
  nodeId: observationNodeId,
@@ -4143,9 +4266,15 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4143
4266
  ? path.split('.')
4144
4267
  : path.split('.').slice(1),
4145
4268
  })),
4146
- { redactor: this.secretRedactor },
4269
+ {
4270
+ redactor: this.secretRedactor,
4271
+ projectRoot: docflowToolResultPreviewProjection,
4272
+ },
4147
4273
  );
4148
- this.emitExecutionEvent({
4274
+ const completed: Extract<
4275
+ PlayExecutionEvent,
4276
+ { type: 'docflow.node.completed' }
4277
+ > = {
4149
4278
  type: 'docflow.node.completed',
4150
4279
  nodeId: observationNodeId,
4151
4280
  attempt,
@@ -4155,7 +4284,19 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4155
4284
  outputs: outputs.values,
4156
4285
  ...(outputs.truncated ? { outputsTruncated: true } : {}),
4157
4286
  at: Date.now(),
4158
- });
4287
+ };
4288
+ this.emitExecutionEvent(completed);
4289
+ guardDocflowTracking(
4290
+ 'decision',
4291
+ (stage, error) =>
4292
+ this.reportDocflowTrackingFault(stage, normalizedNodeId, error),
4293
+ () => {
4294
+ const docflow = this.currentStaticPipeline?.docflow;
4295
+ if (docflow && !rowContext.getStore()) {
4296
+ this.docflowDecisions.settle(docflow, normalizedNodeId, completed);
4297
+ }
4298
+ },
4299
+ );
4159
4300
  this.emitDocflowObservation({
4160
4301
  runId,
4161
4302
  attempt,
@@ -4201,18 +4342,73 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4201
4342
  at: Date.now(),
4202
4343
  });
4203
4344
  };
4345
+ return { complete, fail };
4346
+ }
4204
4347
 
4205
- try {
4206
- const result = execute();
4207
- if (result instanceof Promise) {
4208
- void result.then(complete, fail);
4209
- return result;
4210
- }
4211
- complete(result);
4212
- return result;
4213
- } catch (error) {
4214
- fail(error);
4215
- throw error;
4348
+ /** Decision-arm recording is display-only: a fault never skips the node. */
4349
+ private recordDocflowDecisionArmsSafely(reachedNodeId: string): void {
4350
+ guardDocflowTracking(
4351
+ 'decision',
4352
+ (stage, error) =>
4353
+ this.reportDocflowTrackingFault(stage, reachedNodeId, error),
4354
+ () => this.recordDocflowDecisionArms(reachedNodeId),
4355
+ );
4356
+ }
4357
+
4358
+ /**
4359
+ * A bound box was reached: record the arm of every settled decision it names
4360
+ * (`DocflowDecisionTracker`). Two records, both runtime-owned:
4361
+ *
4362
+ * - the decision's completion is re-emitted with optional `decision`, which
4363
+ * folds into its node state (`nodeIo.decision`) so a canvas reads the arm
4364
+ * without another query;
4365
+ * - a run log line carrying the node id, arm, target and invocation as
4366
+ * structured context, which lands in the run's event stream and is
4367
+ * searchable by `$.context.docflowNode`. Once per arm per attempt, so a
4368
+ * loop re-deciding thousands of times cannot exhaust the log budget; its
4369
+ * counts live in the node state.
4370
+ *
4371
+ * Per-row decisions are not tracked here: a `runIf` records each row's arm in
4372
+ * the row's cell trace, counted into `conditionCounts`.
4373
+ */
4374
+ private recordDocflowDecisionArms(reachedNodeId: string): void {
4375
+ const docflow = this.currentStaticPipeline?.docflow;
4376
+ if (!docflow || rowContext.getStore()) return;
4377
+ for (const resolved of this.docflowDecisions.reach(
4378
+ docflow,
4379
+ reachedNodeId,
4380
+ )) {
4381
+ this.emitExecutionEvent({
4382
+ ...resolved.settled,
4383
+ decision: resolved.decision,
4384
+ });
4385
+ if (!resolved.firstForArm) continue;
4386
+ const node = docflow.nodes.find(
4387
+ (candidate) => candidate.id === resolved.decisionId,
4388
+ );
4389
+ const value = Object.values(resolved.settled.outputs)[0];
4390
+ const valuePreview =
4391
+ value?.kind === 'scalar'
4392
+ ? String(value.value)
4393
+ : value?.kind === 'null'
4394
+ ? 'null'
4395
+ : null;
4396
+ const context: Record<string, string> = {
4397
+ docflowNode: boundedText(resolved.decisionId),
4398
+ docflowArm: resolved.decision.arm,
4399
+ docflowArmTarget: resolved.decision.to,
4400
+ docflowInvocation: boundedText(resolved.settled.invocationId),
4401
+ ...(valuePreview !== null
4402
+ ? { docflowValue: boundedText(valuePreview) }
4403
+ : {}),
4404
+ };
4405
+ const message = `Decision ${JSON.stringify(node?.label ?? resolved.decisionId)}: ${resolved.decision.arm}`;
4406
+ assertNoSecretTaint(message, 'runtime log');
4407
+ this.appendRunLog(
4408
+ `[${new Date().toISOString()}] ${this.secretRedactor.redactRegisteredSecrets(boundRunLogLine(message))}`,
4409
+ false,
4410
+ normalizePlayLogContext(this.secretRedactor.redact(context)),
4411
+ );
4216
4412
  }
4217
4413
  }
4218
4414
 
@@ -7990,6 +8186,26 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7990
8186
  await this.#options.getToolActionCacheVersion?.(input.dispatchToolId)
7991
8187
  )?.trim() ?? '';
7992
8188
  const alwaysFresh = !input.apiOptions.durableCallReceiptKey;
8189
+ // Diagnostics only (no behavior): an execution-fenced call reports when
8190
+ // its relay response arrives, when its receipt completion settles, and
8191
+ // when that completion is overdue, to the runner's internal stderr
8192
+ // telemetry (never the run log). Receipt key as a digest, never raw.
8193
+ const fencedDiagnostics =
8194
+ input.request.requiresExecutionFence === true
8195
+ ? startFencedCallDiagnostics({
8196
+ tool: input.dispatchToolId,
8197
+ callKeyHash: runtimeReceiptKeyDigest(
8198
+ input.resultReceiptKey ?? input.request.callId,
8199
+ ),
8200
+ attempt: this.currentRunAttempt,
8201
+ receiptWriter: alwaysFresh
8202
+ ? 'none'
8203
+ : input.resultReceipts
8204
+ ? 'call'
8205
+ : 'map',
8206
+ budget: this.fencedCallDiagnosticsBudget,
8207
+ })
8208
+ : null;
7993
8209
  const dispatcher = {
7994
8210
  dispatch: async ({
7995
8211
  providerOperationKey,
@@ -8064,7 +8280,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
8064
8280
  // the one whose result is delivered.
8065
8281
  onProviderBodyCompleted: (bodyCompletedAtMs) => {
8066
8282
  input.request.providerBodyCompletedAtMs = bodyCompletedAtMs;
8283
+ fencedDiagnostics?.responseArrived();
8067
8284
  },
8285
+ // Runner-local signal, chained: a native batch's own observer
8286
+ // still runs first, and nothing reaches the wire.
8287
+ ...(fencedDiagnostics
8288
+ ? {
8289
+ onProviderDispatched: () => {
8290
+ input.apiOptions.onProviderDispatched?.();
8291
+ fencedDiagnostics.dispatched();
8292
+ },
8293
+ }
8294
+ : {}),
8068
8295
  },
8069
8296
  );
8070
8297
  const wrapped = await this.wrapToolExecutionResult({
@@ -8093,6 +8320,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
8093
8320
  // this is the instant the row's result actually exists. Everything
8094
8321
  // after it is receipt publication, not provider work.
8095
8322
  this.observeDeliveryWrap(input.request);
8323
+ fencedDiagnostics?.wrapped();
8096
8324
  return wrapped;
8097
8325
  },
8098
8326
  };
@@ -8127,32 +8355,47 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
8127
8355
  };
8128
8356
  if (alwaysFresh) {
8129
8357
  try {
8130
- return await createAlwaysFreshToolCallAdapter({ dispatcher }).call(
8131
- call,
8132
- );
8358
+ const result = await createAlwaysFreshToolCallAdapter({
8359
+ dispatcher,
8360
+ }).call(call);
8361
+ fencedDiagnostics?.settled('recorded');
8362
+ return result;
8363
+ } catch (error) {
8364
+ fencedDiagnostics?.settled('failed');
8365
+ throw error;
8133
8366
  } finally {
8134
8367
  this.observeReceiptlessDeliveryPublication(input.request);
8135
8368
  }
8136
8369
  }
8137
8370
  if (!input.resultReceiptKey || !input.providerOperationKey) {
8371
+ fencedDiagnostics?.settled('failed');
8138
8372
  throw new Error('Receipt-backed map Tool Call needs durable identities.');
8139
8373
  }
8140
- return await createToolCallJob({
8141
- resultReceipts:
8142
- input.resultReceipts ??
8143
- createExternallyOwnedToolResultReceipts({
8374
+ try {
8375
+ // With the map's receipt cohort, this resolves only after this call's
8376
+ // receipt write settled; otherwise the map records it afterwards.
8377
+ const result = await createToolCallJob({
8378
+ resultReceipts:
8379
+ input.resultReceipts ??
8380
+ createExternallyOwnedToolResultReceipts({
8381
+ resultReceiptKey: input.resultReceiptKey,
8382
+ ownerRunId: this.currentReceiptOwnerRunId,
8383
+ leaseId: input.request.receiptLeaseId,
8384
+ }),
8385
+ dispatcher,
8386
+ }).call({
8387
+ ...call,
8388
+ compatibility: {
8144
8389
  resultReceiptKey: input.resultReceiptKey,
8145
- ownerRunId: this.currentReceiptOwnerRunId,
8146
- leaseId: input.request.receiptLeaseId,
8147
- }),
8148
- dispatcher,
8149
- }).call({
8150
- ...call,
8151
- compatibility: {
8152
- resultReceiptKey: input.resultReceiptKey,
8153
- providerOperationKey: input.providerOperationKey,
8154
- },
8155
- });
8390
+ providerOperationKey: input.providerOperationKey,
8391
+ },
8392
+ });
8393
+ fencedDiagnostics?.settled('recorded');
8394
+ return result;
8395
+ } catch (error) {
8396
+ fencedDiagnostics?.settled('failed');
8397
+ throw error;
8398
+ }
8156
8399
  }
8157
8400
 
8158
8401
  /** One replay-stable physical delivery identity for each invocation. */
@@ -9719,6 +9962,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
9719
9962
  'ctx.dataset.run.undrawnColumns',
9720
9963
  options.undrawnColumns,
9721
9964
  );
9965
+ validateOptionalPlayAuthoringField(
9966
+ 'ctx.dataset.run.columnOrder',
9967
+ options.columnOrder,
9968
+ );
9722
9969
  if (options.key !== undefined) {
9723
9970
  validatePlayAuthoringField('ctx.dataset.run.key', options.key);
9724
9971
  }
@@ -54,7 +54,10 @@ import type { MapRowOutcome } from './durability-store';
54
54
  import type { WorkReceiptFailureKind } from './work-receipts';
55
55
  import type { RunExecutionScope } from './run-execution-scope';
56
56
  import type { PlayCallExecution } from './play-call-execution';
57
- import type { PlayDocflowNodeIoPreviewMap } from './docflow-node-io';
57
+ import type {
58
+ PlayDocflowNodeDecision,
59
+ PlayDocflowNodeIoPreviewMap,
60
+ } from './docflow-node-io';
58
61
  import type { PlayActivityEvent } from './activity-observation';
59
62
  import type {
60
63
  ToolExecutionErrorSchemaVersion,
@@ -461,6 +464,13 @@ export interface RuntimeDatasetOptions<TItem = Record<string, unknown>> {
461
464
  * execution behavior.
462
465
  */
463
466
  undrawnColumns?: readonly string[];
467
+ /**
468
+ * Columns the run page shows first, in this order. Every other column keeps
469
+ * the order the run wrote it in (row keys, then each `withColumn`), and a
470
+ * cascade's attempt columns stay right after the cascade. Display only:
471
+ * read from literals at compile time, it changes no execution or stored value.
472
+ */
473
+ columnOrder?: readonly string[];
464
474
  }
465
475
 
466
476
  export type RuntimeDatasetDefinitionOptions<TItem = Record<string, unknown>> =
@@ -474,6 +484,7 @@ export type RuntimeDatasetRunOptions<TItem = Record<string, unknown>> = Pick<
474
484
  | 'onRowError'
475
485
  | 'mode'
476
486
  | 'undrawnColumns'
487
+ | 'columnOrder'
477
488
  >;
478
489
 
479
490
  /** Runtime-only receipt recovery bit; never part of the customer authoring API. */
@@ -641,6 +652,12 @@ export type PlayExecutionEvent =
641
652
  inputsTruncated?: boolean;
642
653
  outputs: PlayDocflowNodeIoPreviewMap;
643
654
  outputsTruncated?: boolean;
655
+ /**
656
+ * Optional, reader-first: a decision box's completion is re-emitted with
657
+ * the arm it took once the run reaches that arm's first bound box. Older
658
+ * readers fold the repeat as the same completion and ignore the field.
659
+ */
660
+ decision?: PlayDocflowNodeDecision;
644
661
  at: number;
645
662
  }
646
663
  | {