deepline 0.3.522 → 0.3.524

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 (176) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +178 -60
  2. package/dist/bundling-sources/sdk/src/index.ts +3 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +60 -14
  5. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +9 -3
  6. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +1 -1
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +406 -40
  8. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +1 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/db-session-renewal.ts +209 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -6
  11. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +388 -13
  12. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +28 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +5 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +1 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +38 -5
  16. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +92 -10
  17. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +96 -25
  18. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +29 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +139 -17
  20. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +26 -3
  21. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +145 -5
  22. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +190 -10
  23. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +85 -5
  24. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +21 -11
  25. package/dist/cli/auth-OKPHHMMP.js +43 -0
  26. package/dist/cli/{auth-YIBY5IKT.mjs → auth-QXJMVLPN.mjs} +5 -5
  27. package/dist/cli/{billing-UDKL53GI.js → billing-N5R4HTHT.js} +82 -82
  28. package/dist/cli/{billing-G3IX3SNY.mjs → billing-SNSIFM4B.mjs} +7 -7
  29. package/dist/cli/{chunk-EJBW7Y6Z.js → chunk-2ZWNIS54.js} +108 -96
  30. package/dist/cli/{chunk-3KMGVOBM.mjs → chunk-2ZX7XSAQ.mjs} +4 -4
  31. package/dist/cli/{chunk-4TUMKJZX.mjs → chunk-3WWTBQHC.mjs} +2 -2
  32. package/dist/cli/{chunk-MD524MRB.mjs → chunk-536TGWR6.mjs} +1 -1
  33. package/dist/cli/{chunk-37SXIFIU.js → chunk-66N76YZG.js} +44 -44
  34. package/dist/cli/{chunk-BZY335JP.js → chunk-7E6B7VMS.js} +5 -5
  35. package/dist/cli/{chunk-HYR34KFA.js → chunk-7OQGZBDG.js} +109 -24
  36. package/dist/cli/{chunk-GVKW3LCA.js → chunk-7QM6DNR4.js} +11 -11
  37. package/dist/cli/{chunk-DNJJ3ULJ.js → chunk-ANKD3AIR.js} +2 -2
  38. package/dist/cli/{chunk-4DFWDA2Q.js → chunk-ATATJNJ6.js} +9 -9
  39. package/dist/cli/{chunk-ZZ7U4YJS.mjs → chunk-BXIQD2IY.mjs} +1 -1
  40. package/dist/cli/{chunk-XT25FX6T.js → chunk-BXVYVIMB.js} +3 -3
  41. package/dist/cli/{chunk-XR6TN5DT.mjs → chunk-CH7JVSA7.mjs} +6 -6
  42. package/dist/cli/{chunk-RKE5YTHY.mjs → chunk-EO55Y4QW.mjs} +5 -5
  43. package/dist/cli/{chunk-RI672VNY.js → chunk-EQNAQENZ.js} +2 -2
  44. package/dist/cli/{chunk-LFSOBW7E.mjs → chunk-FXTV5B3D.mjs} +22 -10
  45. package/dist/cli/{chunk-C6WGMODR.mjs → chunk-GMO3JDZA.mjs} +2 -2
  46. package/dist/cli/{chunk-DRDZBRXV.js → chunk-GTGJBZVH.js} +7 -7
  47. package/dist/cli/{chunk-SFMCKB57.mjs → chunk-HLAFGQPV.mjs} +76 -34
  48. package/dist/cli/{chunk-534YYHIF.js → chunk-HTYT2OHB.js} +6 -6
  49. package/dist/cli/{chunk-ZZLZCO6Y.js → chunk-I75VRGQG.js} +22 -22
  50. package/dist/cli/{chunk-Y3LDRCMB.mjs → chunk-II3BJKCH.mjs} +2 -2
  51. package/dist/cli/{chunk-5BQPEHEP.js → chunk-JDIQBZ6O.js} +14 -14
  52. package/dist/cli/{chunk-ENWJFUWK.mjs → chunk-KKPBCB6D.mjs} +2 -2
  53. package/dist/cli/{chunk-BONXEWYF.mjs → chunk-KSQXBLRW.mjs} +3 -3
  54. package/dist/cli/{chunk-7JEN3FX4.js → chunk-LRWDZDBS.js} +5 -5
  55. package/dist/cli/{chunk-5477PEHL.mjs → chunk-MW3YMPD2.mjs} +1 -1
  56. package/dist/cli/{chunk-VFCVH2LV.mjs → chunk-NUC7ZVDG.mjs} +5 -5
  57. package/dist/cli/{chunk-DLDWAPA5.js → chunk-OCT4SUJA.js} +4 -4
  58. package/dist/cli/{chunk-FQQAAR3Q.mjs → chunk-OQ5G7RFQ.mjs} +1 -1
  59. package/dist/cli/{chunk-VIM6I7RC.js → chunk-PFKKZVFK.js} +41 -41
  60. package/dist/cli/{chunk-OAQIVJFY.mjs → chunk-PFKWKWUJ.mjs} +2 -2
  61. package/dist/cli/{chunk-52MHE7B4.mjs → chunk-R457IMHJ.mjs} +1 -1
  62. package/dist/cli/{chunk-UV6XCHOZ.mjs → chunk-RIX26ZJD.mjs} +1 -1
  63. package/dist/cli/{chunk-RDJTCW3I.mjs → chunk-RTDX5NNN.mjs} +3 -3
  64. package/dist/cli/{chunk-FNHUDCJE.js → chunk-RUULUCBP.js} +10 -10
  65. package/dist/cli/{chunk-GMYDVW7Z.js → chunk-SF4QJVBE.js} +3 -3
  66. package/dist/cli/{chunk-DARD7TJ7.js → chunk-SMWFOGUT.js} +53 -53
  67. package/dist/cli/{chunk-XXY4E57R.mjs → chunk-T43FF5PF.mjs} +2 -2
  68. package/dist/cli/{chunk-ZUAKRBZB.js → chunk-TZTWH53O.js} +1 -1
  69. package/dist/cli/{chunk-7J5PLHII.mjs → chunk-V2YIBBVT.mjs} +1 -1
  70. package/dist/cli/{chunk-6SJPZV5E.js → chunk-V4RJ57MA.js} +2 -2
  71. package/dist/cli/{chunk-4MF44THR.js → chunk-V7KUBDEB.js} +82 -40
  72. package/dist/cli/{chunk-ISUUSSS4.js → chunk-VHTVXS5A.js} +16 -16
  73. package/dist/cli/{chunk-NDNG3MAT.mjs → chunk-WCVIPZWX.mjs} +5 -5
  74. package/dist/cli/{chunk-F5D623KO.js → chunk-WOEPDSO3.js} +26 -26
  75. package/dist/cli/{chunk-VE6FHVXZ.mjs → chunk-XURWFEXM.mjs} +109 -24
  76. package/dist/cli/{chunk-G65FJ5JX.mjs → chunk-YCIXY66B.mjs} +2 -2
  77. package/dist/cli/{chunk-CFXERH7F.mjs → chunk-YGOI5ZE5.mjs} +1 -1
  78. package/dist/cli/{chunk-PDLRUZ42.mjs → chunk-YKFW3NNA.mjs} +5 -5
  79. package/dist/cli/{chunk-5H22VJPE.js → chunk-YXVYPYIP.js} +6 -6
  80. package/dist/cli/{chunk-KMBF3N2Z.js → chunk-Z4MOEQSY.js} +16 -16
  81. package/dist/cli/command-docs.js +2 -2
  82. package/dist/cli/command-docs.mjs +1 -1
  83. package/dist/cli/{csv-PE35WGRO.mjs → csv-HT2JBCW2.mjs} +4 -4
  84. package/dist/cli/{csv-3HIE4VCO.js → csv-Q2LWKXAV.js} +13 -13
  85. package/dist/cli/{db-L7ZMMQKW.mjs → db-CS3XQ2LX.mjs} +6 -6
  86. package/dist/cli/{db-O2YRTTDO.js → db-XEV4WEE4.js} +27 -27
  87. package/dist/cli/describe-5G5NXO5E.js +50 -0
  88. package/dist/cli/{describe-NI324Y2M.mjs → describe-OUTXLDGZ.mjs} +18 -18
  89. package/dist/cli/describe-core.d.mts +3 -3
  90. package/dist/cli/describe-core.d.ts +3 -3
  91. package/dist/cli/{executions-VH4DKLFI.js → executions-JCC34WAD.js} +8 -8
  92. package/dist/cli/{executions-T6KU2OKK.mjs → executions-L6XFG5MP.mjs} +6 -6
  93. package/dist/cli/{feedback-SCSJC3FX.mjs → feedback-AWBDO5I6.mjs} +5 -5
  94. package/dist/cli/{feedback-ZLC6G5OK.js → feedback-HV2M2G7N.js} +10 -10
  95. package/dist/cli/git-GDPTG52F.js +25 -0
  96. package/dist/cli/{git-I4LVQCID.mjs → git-S4LRXTRX.mjs} +5 -5
  97. package/dist/cli/index.js +146 -146
  98. package/dist/cli/index.mjs +45 -45
  99. package/dist/cli/{legacy-noops-44FQ2256.mjs → legacy-noops-7MOKBL4O.mjs} +6 -6
  100. package/dist/cli/{legacy-noops-UPFWEHPG.js → legacy-noops-RGSZUD6V.js} +9 -9
  101. package/dist/cli/{monitors-JN6IQGK6.js → monitors-JEFM2C5W.js} +100 -100
  102. package/dist/cli/{monitors-LMSASWXE.mjs → monitors-XQNXDZPQ.mjs} +7 -7
  103. package/dist/cli/{org-F7O3ZU5O.js → org-GYLA5V32.js} +235 -72
  104. package/dist/cli/{org-QYLVEE7A.mjs → org-KTMJZGTN.mjs} +169 -6
  105. package/dist/cli/{pages-KEL3Y4L4.js → pages-RY4U7OCL.js} +18 -18
  106. package/dist/cli/{pages-5XE4LBZN.mjs → pages-WOMU2T2O.mjs} +6 -6
  107. package/dist/cli/{play-OURHH6KV.js → play-2Q6MWJ3D.js} +363 -323
  108. package/dist/cli/{play-MWQG3G32.mjs → play-KOYGGNYS.mjs} +64 -24
  109. package/dist/cli/{providers-IQY7LUBB.mjs → providers-7YKDITJC.mjs} +6 -6
  110. package/dist/cli/{providers-ZCBWPE3C.js → providers-HOIRHMN2.js} +9 -9
  111. package/dist/cli/{quickstart-O53OXTN6.js → quickstart-OWCJOSQA.js} +6 -6
  112. package/dist/cli/{quickstart-L45NGRMI.mjs → quickstart-RDXHSMVX.mjs} +4 -4
  113. package/dist/cli/{run-W745Z3Z5.js → run-MT2ABKO5.js} +41 -41
  114. package/dist/cli/{run-VCSIWLEU.mjs → run-RT73NDP5.mjs} +23 -23
  115. package/dist/cli/search-7VBA6IGS.js +33 -0
  116. package/dist/cli/{search-THELKULN.mjs → search-CJPKIGSA.mjs} +8 -8
  117. package/dist/cli/{search-output-N7MJLYYD.mjs → search-output-AREMA544.mjs} +4 -4
  118. package/dist/cli/{search-output-SJW7LEOM.js → search-output-OSBZ7WK6.js} +6 -6
  119. package/dist/cli/{secrets-44ST3FJH.mjs → secrets-BTIY2FEJ.mjs} +6 -6
  120. package/dist/cli/{secrets-GDXPX3KB.js → secrets-OV6KH633.js} +15 -15
  121. package/dist/cli/{sessions-LYCBI77S.mjs → sessions-3CO3ZFOD.mjs} +6 -6
  122. package/dist/cli/sessions-B3WNEWRW.js +18 -0
  123. package/dist/cli/{settings-GXPDMJFG.mjs → settings-7BQIC7QN.mjs} +13 -13
  124. package/dist/cli/{settings-3WOFF642.js → settings-LBIECYDB.js} +86 -86
  125. package/dist/cli/{setup-YHLMBJP4.js → setup-QZE7QR3F.js} +50 -50
  126. package/dist/cli/{setup-YM6JEB64.mjs → setup-XPTSNNES.mjs} +10 -10
  127. package/dist/cli/{skills-WX4XWEAT.mjs → skills-TGGKIQLT.mjs} +8 -8
  128. package/dist/cli/skills-TXBRTWEV.js +37 -0
  129. package/dist/cli/{tools-K24VSQ7S.mjs → tools-MKIFX2TQ.mjs} +17 -17
  130. package/dist/cli/tools-RZJV4X3J.js +57 -0
  131. package/dist/cli/{update-PSSCF5AT.mjs → update-5R3D3WNH.mjs} +10 -10
  132. package/dist/cli/update-YWGGPWUA.js +35 -0
  133. package/dist/cli/{artifacts-RY2MK74N.mjs → views-VHKDHHUP.mjs} +76 -76
  134. package/dist/cli/views-VPWEINIA.js +270 -0
  135. package/dist/cli/{workflow-FPVI3NIA.js → workflow-7K2VEQ4V.js} +17 -17
  136. package/dist/cli/{workflow-DGOPYATO.mjs → workflow-D5DF65N6.mjs} +7 -7
  137. package/dist/{client-DA71-2_u.d.mts → client-C5_6W8yd.d.mts} +1 -1
  138. package/dist/{client-core-C0IzDKMJ.d.ts → client-core-B-GPfmaC.d.ts} +121 -44
  139. package/dist/{client-core-BXbds1cb.d.mts → client-core-Dob428Z4.d.mts} +121 -44
  140. package/dist/{client-B-2Am2y6.d.ts → client-iXW4TOat.d.ts} +1 -1
  141. package/dist/{compiler-manifest-B4mIIbw7.d.mts → compiler-manifest-DsxsQP-T.d.mts} +14 -7
  142. package/dist/{compiler-manifest-B4mIIbw7.d.ts → compiler-manifest-DsxsQP-T.d.ts} +14 -7
  143. package/dist/{errors-Gj9i5Rkd.d.ts → errors-Bk5h1D-C.d.ts} +1 -1
  144. package/dist/{errors-C2F4qzAq.d.mts → errors-qdJUVQ3g.d.mts} +1 -1
  145. package/dist/{index-5JZBufdF.d.mts → index-PaupwX1B.d.mts} +1 -1
  146. package/dist/{index-BXtSj8bv.d.ts → index-bL66eHYz.d.ts} +1 -1
  147. package/dist/index.d.mts +7 -7
  148. package/dist/index.d.ts +7 -7
  149. package/dist/index.js +9 -9
  150. package/dist/index.mjs +6 -6
  151. package/dist/install-integrity.json +117 -116
  152. package/dist/plays/bundle-play-file.d.mts +3 -3
  153. package/dist/plays/bundle-play-file.d.ts +3 -3
  154. package/dist/plays/bundle-play-file.mjs +7 -5
  155. package/dist/plays/play-description.d.mts +2 -2
  156. package/dist/plays/play-description.d.ts +2 -2
  157. package/dist/plays/run-request.d.mts +2 -2
  158. package/dist/plays/run-request.d.ts +2 -2
  159. package/dist/release.d.mts +1 -1
  160. package/dist/release.d.ts +1 -1
  161. package/dist/release.js +2 -2
  162. package/dist/release.mjs +1 -1
  163. package/dist/server.d.mts +4 -4
  164. package/dist/server.d.ts +4 -4
  165. package/dist/server.js +5 -5
  166. package/dist/server.mjs +3 -3
  167. package/package.json +1 -1
  168. package/dist/cli/artifacts-GIZZH5VA.js +0 -270
  169. package/dist/cli/auth-JSES2JOQ.js +0 -43
  170. package/dist/cli/describe-EB336DAO.js +0 -50
  171. package/dist/cli/git-23T7TXAH.js +0 -25
  172. package/dist/cli/search-R6K7ZAMU.js +0 -33
  173. package/dist/cli/sessions-2V5ZFOWL.js +0 -18
  174. package/dist/cli/skills-XNGADDO6.js +0 -37
  175. package/dist/cli/tools-ROUMCB7B.js +0 -57
  176. package/dist/cli/update-RXURGIRW.js +0 -35
@@ -295,7 +295,9 @@ import {
295
295
  executeWithFreshnessReceipt,
296
296
  latestCacheResultKey,
297
297
  latestCacheResultOutput,
298
+ type LegacySlotSearch,
298
299
  parseLatestCacheResult,
300
+ type ReplayMismatchPolicy,
299
301
  toolReadSemanticKey,
300
302
  } from './freshness-receipt-execution';
301
303
  import {
@@ -364,6 +366,7 @@ import {
364
366
  import {
365
367
  isAlwaysFreshIntegrationTool,
366
368
  isAlwaysFreshIntegrationWriteTool,
369
+ reusableWindowEligibility,
367
370
  } from './tool-cache-policy';
368
371
  import { isAbortLikeError, isRowIsolationExemptError } from './row-isolation';
369
372
  import {
@@ -653,6 +656,13 @@ function recordReplayCallAdvance(key: string, advance: number): void {
653
656
  }
654
657
  }
655
658
 
659
+ /**
660
+ * Call-order slots past the highest one allocated in this attempt that the
661
+ * pre-binding slot search also inspects: siblings that started earlier in
662
+ * the original attempt but have not started yet in this one.
663
+ */
664
+ const LEGACY_SLOT_SEARCH_LOOKAHEAD = 16;
665
+
656
666
  function nextReplayableCallIndex(key: string, freshIndex: number): number {
657
667
  const indexes = rowContext.getStore()?.replayCallIndexes;
658
668
  if (!indexes) return freshIndex;
@@ -3162,6 +3172,49 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3162
3172
  private readonly stepCallIndexByKey = new Map<string, number>();
3163
3173
  private readonly toolCallIndexByKey = new Map<string, number>();
3164
3174
  private readonly freshnessCallIndexByKey = new Map<string, number>();
3175
+ /**
3176
+ * Call-order artifacts only: the exact-request operation slot of each
3177
+ * call-order invocation id, consumed when the call reaches the freshness
3178
+ * layer. See `freshnessInvocationId`.
3179
+ */
3180
+ private readonly exactRequestInvocationIds = new Map<
3181
+ string,
3182
+ {
3183
+ exactRequestInvocationId?: string;
3184
+ inputFingerprint: string;
3185
+ /** The invocation id itself is numbered among identical requests. */
3186
+ keyEncodesRequest?: true;
3187
+ /** This call's call-order slot, for the pre-binding slot search. */
3188
+ legacySlot?: { scope: string; index: number };
3189
+ }
3190
+ >();
3191
+ /**
3192
+ * Per call-order scope, for receipts recorded before bindings: whether each
3193
+ * slot read in this attempt held an unbound receipt, and which slots a call
3194
+ * has already proven and taken.
3195
+ */
3196
+ private readonly legacySlotVerdicts = new Map<
3197
+ string,
3198
+ (unbound: boolean) => void
3199
+ >();
3200
+ private readonly legacySlotScopes = new Map<
3201
+ string,
3202
+ {
3203
+ /** Verdicts of slots allocated but not yet read, by index. */
3204
+ pending: Map<number, Promise<boolean>>;
3205
+ /** A slot of this scope held an unbound receipt in this attempt. */
3206
+ anyUnbound: boolean;
3207
+ /**
3208
+ * Slots taken by a proven pre-binding recovery, with the invocation
3209
+ * that took them. The same invocation may take its slot again (a row
3210
+ * re-entered after provider backpressure restores its call index);
3211
+ * a sibling may not.
3212
+ */
3213
+ consumed: Map<number, string>;
3214
+ }
3215
+ >();
3216
+ /** Authored calls whose unverified recovery was already reported. */
3217
+ private readonly unverifiedRecoveryReported = new Set<string>();
3165
3218
  /**
3166
3219
  * Parent-level inline-child aggregates. Maintained only by the single-writer
3167
3220
  * progress path (never per child) so concurrent fan-out cannot contend. See
@@ -4184,10 +4237,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4184
4237
  * slots. Callers pass the authored request without credentials, auth scope,
4185
4238
  * or runtime-assigned keys, so the slot follows the authored effect.
4186
4239
  */
4187
- private callSlotRequestDigest(request: unknown): string | undefined {
4188
- if (this.currentRuntimeSemantics.callSlotIdentity !== 'request_digest') {
4189
- return undefined;
4190
- }
4240
+ private callSlotRequestDigest(request: unknown): string {
4191
4241
  return sha256Hex(stableStringify(request));
4192
4242
  }
4193
4243
 
@@ -4195,10 +4245,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4195
4245
  private fetchCallSlotRequestDigest(
4196
4246
  input: string | URL,
4197
4247
  init: PlaySecretAwareRequestInit | SecretAwareRequestInit,
4198
- ): string | undefined {
4199
- if (this.currentRuntimeSemantics.callSlotIdentity !== 'request_digest') {
4200
- return undefined;
4201
- }
4248
+ ): string {
4202
4249
  const body = typeof init.body === 'string' ? init.body : null;
4203
4250
  return this.callSlotRequestDigest({
4204
4251
  method: (init.method ?? 'GET').toUpperCase(),
@@ -4236,23 +4283,215 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4236
4283
  // Edition 12 numbers same-id calls only among identical requests, so
4237
4284
  // parallel calls started in another order on resume keep their own slot.
4238
4285
  // Call-order artifacts keep their exact historical scope string.
4239
- const scope = stableStringify(
4240
- this.currentRuntimeSemantics.callSlotIdentity === 'request_digest'
4241
- ? { ...slotScope, request: requestDigest ?? null }
4242
- : slotScope,
4286
+ const exactRequestScope = stableStringify({
4287
+ ...slotScope,
4288
+ request: requestDigest ?? null,
4289
+ });
4290
+ const slot = (scope: string) => {
4291
+ const freshIndex = this.freshnessCallIndexByKey.get(scope) ?? 0;
4292
+ this.freshnessCallIndexByKey.set(scope, freshIndex + 1);
4293
+ // Invocation identity follows authored scope and call order. Keep it
4294
+ // separate from the request/auth/action fingerprint used by reusable
4295
+ // result caching, so credential or response-contract changes cannot
4296
+ // mint a second provider operation key for the same authored effect.
4297
+ // A mapped row can be re-entered after provider backpressure; its
4298
+ // replay cursor restores the original call position.
4299
+ const index = nextReplayableCallIndex(`freshness:${scope}`, freshIndex);
4300
+ return { id: sha256Hex(`${scope}:${index}`), index };
4301
+ };
4302
+ if (this.currentRuntimeSemantics.callSlotIdentity === 'request_digest') {
4303
+ const invocationId = slot(exactRequestScope).id;
4304
+ if (requestDigest !== undefined) {
4305
+ this.exactRequestInvocationIds.set(invocationId, {
4306
+ inputFingerprint: requestDigest,
4307
+ keyEncodesRequest: true,
4308
+ });
4309
+ }
4310
+ return invocationId;
4311
+ }
4312
+ // A call-order slot is only a candidate: same-id calls started in another
4313
+ // order on replay take each other's slots. The call also records and
4314
+ // recovers its exact-request slot (numbered among identical requests, as
4315
+ // in edition 12), and the freshness layer verifies the request
4316
+ // fingerprint before returning a call-order slot's result.
4317
+ const callOrderScope = stableStringify(slotScope);
4318
+ const callOrder = slot(callOrderScope);
4319
+ if (requestDigest !== undefined) {
4320
+ this.exactRequestInvocationIds.set(callOrder.id, {
4321
+ exactRequestInvocationId: slot(exactRequestScope).id,
4322
+ inputFingerprint: requestDigest,
4323
+ // Only tools record request identities a slot search can prove.
4324
+ ...(operation === 'tool'
4325
+ ? { legacySlot: { scope: callOrderScope, index: callOrder.index } }
4326
+ : {}),
4327
+ });
4328
+ if (operation === 'tool') {
4329
+ this.registerLegacySlot(callOrder.id, callOrderScope, callOrder.index);
4330
+ }
4331
+ }
4332
+ return callOrder.id;
4333
+ }
4334
+
4335
+ /**
4336
+ * A tool is a read on replay mismatch only when its metadata proves it: no
4337
+ * invocation-scoped idempotency, no execution fence, not SQL, and either a
4338
+ * provider-declared reusable read (`legacySharedCacheReuseSupport`, which
4339
+ * refuses write/persist tags) or a `read_safe` server-error replay class.
4340
+ * Anything unproven, including a metadata lookup failure, fails loudly.
4341
+ */
4342
+ private async toolReplayMismatchPolicy(
4343
+ toolId: string,
4344
+ input: Record<string, unknown>,
4345
+ ): Promise<ReplayMismatchPolicy> {
4346
+ if (
4347
+ isCustomerDbDatasetTool(toolId) ||
4348
+ isAlwaysFreshIntegrationWriteTool(toolId)
4349
+ ) {
4350
+ return 'fail';
4351
+ }
4352
+ try {
4353
+ const [scope, retry, reusable] = await Promise.all([
4354
+ this.#options.getToolIdempotencyScope?.(toolId),
4355
+ this.#options.getToolRetryPolicy?.(toolId, input),
4356
+ this.#options.getToolReusableResultSupport?.(toolId),
4357
+ ]);
4358
+ if (scope === 'invocation' || retry?.requiresExecutionFence === true) {
4359
+ return 'fail';
4360
+ }
4361
+ return reusable?.supported === true ||
4362
+ retry?.providerServerErrorReplay === 'read_safe'
4363
+ ? 'execute'
4364
+ : 'fail';
4365
+ } catch {
4366
+ return 'fail';
4367
+ }
4368
+ }
4369
+
4370
+ /**
4371
+ * Pre-binding slot search for one call: other call-order slots of its
4372
+ * scope, which a sibling started in another order may hold its own result
4373
+ * in. Only receipts proven by a recorded request identity are taken, each
4374
+ * at most once per attempt.
4375
+ */
4376
+ /**
4377
+ * Registered when the slot is allocated, in allocation order, so a later
4378
+ * sibling can wait for this slot's verdict. Settled by the freshness layer
4379
+ * once the slot is read, or by `settleLegacySlot` when the call ends first.
4380
+ * A scope without unbound receipts is dropped once its slots settle, so
4381
+ * runs without pre-binding receipts keep no state here.
4382
+ */
4383
+ private registerLegacySlot(
4384
+ invocationId: string,
4385
+ scopeKey: string,
4386
+ index: number,
4387
+ ): void {
4388
+ // A re-entered row reuses its slot; release the earlier registration.
4389
+ this.settleLegacySlot(invocationId, { keepSlotEntry: true });
4390
+ let scope = this.legacySlotScopes.get(scopeKey);
4391
+ if (!scope) {
4392
+ scope = { pending: new Map(), anyUnbound: false, consumed: new Map() };
4393
+ this.legacySlotScopes.set(scopeKey, scope);
4394
+ }
4395
+ const state = scope;
4396
+ let resolve!: (unbound: boolean) => void;
4397
+ const verdict: Promise<boolean> = new Promise<boolean>(
4398
+ (settle) => (resolve = settle),
4399
+ ).then((unbound) => {
4400
+ if (unbound) state.anyUnbound = true;
4401
+ if (state.pending.get(index) === verdict) state.pending.delete(index);
4402
+ if (
4403
+ state.pending.size === 0 &&
4404
+ !state.anyUnbound &&
4405
+ state.consumed.size === 0 &&
4406
+ this.legacySlotScopes.get(scopeKey) === state
4407
+ ) {
4408
+ this.legacySlotScopes.delete(scopeKey);
4409
+ }
4410
+ return unbound;
4411
+ });
4412
+ state.pending.set(index, verdict);
4413
+ this.legacySlotVerdicts.set(invocationId, resolve);
4414
+ }
4415
+
4416
+ /** The call ended (or never reached the freshness layer): release waiters. */
4417
+ private settleLegacySlot(
4418
+ invocationId: string,
4419
+ options?: { keepSlotEntry: true },
4420
+ ): void {
4421
+ this.legacySlotVerdicts.get(invocationId)?.(false);
4422
+ this.legacySlotVerdicts.delete(invocationId);
4423
+ if (!options?.keepSlotEntry) {
4424
+ this.exactRequestInvocationIds.delete(invocationId);
4425
+ }
4426
+ }
4427
+
4428
+ private legacySlotSearch(
4429
+ invocationId: string,
4430
+ slot: { scope: string; index: number },
4431
+ ): LegacySlotSearch {
4432
+ const scope = this.legacySlotScopes.get(slot.scope)!;
4433
+ const verdict = this.legacySlotVerdicts.get(invocationId);
4434
+ return {
4435
+ ownIndex: slot.index,
4436
+ reportOwnSlot: (unbound) => verdict?.(unbound),
4437
+ priorSlotsUnbound: async () => {
4438
+ await Promise.all(
4439
+ [...scope.pending]
4440
+ .filter(([index]) => index < slot.index)
4441
+ .map(([, observed]) => observed),
4442
+ );
4443
+ return scope.anyUnbound;
4444
+ },
4445
+ candidates: () => {
4446
+ const candidates: Array<{ index: number; invocationId: string }> = [];
4447
+ const allocated = Math.max(
4448
+ this.freshnessCallIndexByKey.get(slot.scope) ?? 0,
4449
+ slot.index + 1,
4450
+ );
4451
+ const end = allocated + LEGACY_SLOT_SEARCH_LOOKAHEAD;
4452
+ for (let index = 0; index < end; index += 1) {
4453
+ const claimant = scope.consumed.get(index);
4454
+ if (
4455
+ index === slot.index ||
4456
+ (claimant !== undefined && claimant !== invocationId)
4457
+ ) {
4458
+ continue;
4459
+ }
4460
+ candidates.push({
4461
+ index,
4462
+ invocationId: sha256Hex(`${slot.scope}:${index}`),
4463
+ });
4464
+ }
4465
+ return candidates;
4466
+ },
4467
+ consume: (index) => {
4468
+ const claimant = scope.consumed.get(index);
4469
+ if (claimant !== undefined && claimant !== invocationId) return false;
4470
+ scope.consumed.set(index, invocationId);
4471
+ return true;
4472
+ },
4473
+ };
4474
+ }
4475
+
4476
+ /** Rate-limited: once per authored call per run context. */
4477
+ private reportLegacyOperationRecovery(
4478
+ operation: DurableCtxOperation,
4479
+ id: string,
4480
+ ): void {
4481
+ const reportKey = `${operation}:${id}`;
4482
+ if (this.unverifiedRecoveryReported.has(reportKey)) return;
4483
+ this.unverifiedRecoveryReported.add(reportKey);
4484
+ this.runtimeLog(
4485
+ JSON.stringify({
4486
+ event: 'durable_operation_recovery_legacy_proven',
4487
+ operation,
4488
+ call_key: id,
4489
+ proof: 'recorded_request_identity',
4490
+ }),
4243
4491
  );
4244
- const freshIndex = this.freshnessCallIndexByKey.get(scope) ?? 0;
4245
- this.freshnessCallIndexByKey.set(scope, freshIndex + 1);
4246
- // Invocation identity follows authored scope and call order. Keep it
4247
- // separate from the request/auth/action fingerprint used by reusable
4248
- // result caching, so credential or response-contract changes cannot mint
4249
- // a second provider operation key for the same authored effect.
4250
- // A mapped row can be re-entered after provider backpressure; its replay
4251
- // cursor restores the original call position.
4252
- const index = nextReplayableCallIndex(`freshness:${scope}`, freshIndex);
4253
- return sha256Hex(`${scope}:${index}`);
4254
4492
  }
4255
4493
 
4494
+
4256
4495
  private async executeFreshnessControlledCall<T>(input: {
4257
4496
  operation: DurableCtxOperation;
4258
4497
  id: string;
@@ -4267,6 +4506,14 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4267
4506
  /** Names the tool in the shared-cache skip log. */
4268
4507
  toolId?: string;
4269
4508
  onOutcome?: (value: T, metadata: CallFreshnessMetadata) => T;
4509
+ /**
4510
+ * Whether this call is a read that may execute when its recorded slot
4511
+ * holds a different request. Omitted: it fails loudly instead.
4512
+ */
4513
+ replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
4514
+ /** See `executeWithFreshnessReceipt`. */
4515
+ legacyRequestIdentities?: () => Promise<readonly string[]>;
4516
+ operationKeyEncodesRequest?: true;
4270
4517
  }): Promise<T> {
4271
4518
  const orgId = this.#options.orgId?.trim();
4272
4519
  if (!orgId) {
@@ -4274,10 +4521,38 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4274
4521
  'Freshness-controlled calls require a resolved organization identity.',
4275
4522
  );
4276
4523
  }
4524
+ const slots = this.exactRequestInvocationIds.get(input.invocationId);
4525
+ this.exactRequestInvocationIds.delete(input.invocationId);
4277
4526
  return executeWithFreshnessReceipt({
4278
4527
  orgId,
4279
4528
  semanticKey: input.semanticKey,
4280
4529
  invocationId: input.invocationId,
4530
+ ...(slots?.exactRequestInvocationId
4531
+ ? { exactRequestInvocationId: slots.exactRequestInvocationId }
4532
+ : {}),
4533
+ ...(slots ? { inputFingerprint: slots.inputFingerprint } : {}),
4534
+ ...(slots?.keyEncodesRequest || input.operationKeyEncodesRequest
4535
+ ? { operationKeyEncodesRequest: true as const }
4536
+ : {}),
4537
+ ...(input.legacyRequestIdentities
4538
+ ? { legacyRequestIdentities: input.legacyRequestIdentities }
4539
+ : {}),
4540
+ ...(slots?.legacySlot &&
4541
+ this.legacySlotScopes.has(slots.legacySlot.scope)
4542
+ ? {
4543
+ legacySlotSearch: this.legacySlotSearch(
4544
+ input.invocationId,
4545
+ slots.legacySlot,
4546
+ ),
4547
+ }
4548
+ : {}),
4549
+ ...(input.replayMismatchPolicy
4550
+ ? { replayMismatchPolicy: input.replayMismatchPolicy }
4551
+ : {}),
4552
+ operation: input.operation,
4553
+ callId: input.id,
4554
+ onLegacyRecoveryProven: () =>
4555
+ this.reportLegacyOperationRecovery(input.operation, input.id),
4281
4556
  runId: this.currentReceiptOwnerRunId,
4282
4557
  receiptOwnerRunId: this.currentReceiptOwnerRunId,
4283
4558
  // Launches admitted without run-scoped keys wrote this operation under
@@ -7191,6 +7466,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7191
7466
  onClaimedResult?: (output: T, receiptKey: string) => T;
7192
7467
  shouldPersistFailure?: (error: unknown) => boolean;
7193
7468
  transient?: boolean;
7469
+ /** A read-only request: executes when its replayed slot holds another. */
7470
+ replayReadSafe?: boolean;
7194
7471
  markRunningBeforeExecute?: boolean;
7195
7472
  requiresExecutionLock?: boolean;
7196
7473
  executionLockTtlMs?: number;
@@ -7256,6 +7533,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7256
7533
  }),
7257
7534
  ),
7258
7535
  policy,
7536
+ replayMismatchPolicy: async () =>
7537
+ opts.replayReadSafe === true ? 'execute' : 'fail',
7259
7538
  execute: () => execute(null),
7260
7539
  sharesResult: (value) =>
7261
7540
  !(
@@ -7348,8 +7627,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7348
7627
  return this.currentExecutionScope.logical.runId;
7349
7628
  }
7350
7629
 
7630
+ /**
7631
+ * `id` keeps its admitted meaning: inside an inline child it is the
7632
+ * composition namespace, which repeats across parent runs. `rootId` is the
7633
+ * run at the root of the inline composition tree (the executing run), so it
7634
+ * is the per-run value authors need for external idempotency keys.
7635
+ */
7351
7636
  get run(): PlayAuthoringRunScope {
7352
- return { id: this.currentRunId, actor: this.#options.runActor ?? null };
7637
+ return {
7638
+ id: this.currentRunId,
7639
+ rootId: this.currentExecutionScope.logical.rootRunId,
7640
+ actor: this.#options.runActor ?? null,
7641
+ };
7353
7642
  }
7354
7643
 
7355
7644
  private get currentReceiptOwnerRunId(): string {
@@ -14656,6 +14945,27 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14656
14945
  toolId: string,
14657
14946
  input: Record<string, unknown>,
14658
14947
  options?: ToolCallOptions,
14948
+ ): Promise<unknown> {
14949
+ let invocationId: string | null = null;
14950
+ try {
14951
+ return await this.executeToolInternalWithSlot(
14952
+ key,
14953
+ toolId,
14954
+ input,
14955
+ options,
14956
+ (allocated) => (invocationId = allocated),
14957
+ );
14958
+ } finally {
14959
+ if (invocationId) this.settleLegacySlot(invocationId);
14960
+ }
14961
+ }
14962
+
14963
+ private async executeToolInternalWithSlot(
14964
+ key: string,
14965
+ toolId: string,
14966
+ input: Record<string, unknown>,
14967
+ options: ToolCallOptions | undefined,
14968
+ onSlotAllocated: (invocationId: string) => void,
14659
14969
  ): Promise<unknown> {
14660
14970
  if (!this.usesExplicitFreshness) {
14661
14971
  return this.executeToolLegacyInternal(key, toolId, input, options);
@@ -14683,6 +14993,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14683
14993
  normalizedKey,
14684
14994
  this.callSlotRequestDigest({ toolId, input }),
14685
14995
  );
14996
+ onSlotAllocated(invocationId);
14686
14997
  const sqlTool = isCustomerDbDatasetTool(toolId);
14687
14998
  const scalarCustomerDbQuery = sqlTool && input.result_mode === 'rows';
14688
14999
  const liveDataset =
@@ -14696,27 +15007,39 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14696
15007
  // A positive or null window on any tool call is the author's explicit
14697
15008
  // acceptance of reuse, including for writes, sends and purchases: a hit
14698
15009
  // returns the recorded answer and suppresses that repeat on purpose. Only
14699
- // calls that are structurally not answers stay refused: event waits,
14700
- // live datasets, Customer DB SQL mutations and Workspace operations.
15010
+ // calls that are structurally not answers stay refused, by the same rule
15011
+ // `plays check` applies (reusableWindowEligibility). This refusal is the
15012
+ // backstop for dynamic tool ids and inputs the checker cannot read.
15013
+ const reuseVerdict = reusableWindowEligibility({
15014
+ kind: 'tool',
15015
+ toolId,
15016
+ input,
15017
+ });
15018
+ if (policy.effective !== 0 && 'message' in reuseVerdict) {
15019
+ throw new Error(reuseVerdict.message);
15020
+ }
14701
15021
  const eventWait =
14702
15022
  policy.effective === 0 && !refreshMayPublish
14703
15023
  ? null
14704
15024
  : ((await this.#options.getIntegrationEventWaitHandler?.(toolId)) ??
14705
15025
  null);
14706
- const mustExecuteEveryTime = Boolean(
14707
- eventWait ||
14708
- liveDataset ||
14709
- sqlMutation ||
14710
- isAlwaysFreshIntegrationTool(toolId),
14711
- );
15026
+ // A registered event-wait handler refuses reuse even for a tool id the
15027
+ // rule does not list.
15028
+ const effectiveVerdict = eventWait
15029
+ ? reusableWindowEligibility({
15030
+ kind: 'tool',
15031
+ toolId,
15032
+ input,
15033
+ eventWait: true,
15034
+ })
15035
+ : reuseVerdict;
15036
+ if (policy.effective !== 0 && 'message' in effectiveVerdict) {
15037
+ throw new Error(effectiveVerdict.message);
15038
+ }
15039
+ const mustExecuteEveryTime = 'message' in effectiveVerdict;
14712
15040
  // A refresh of a reusable call still publishes its fresh result as the
14713
15041
  // request's newest shared result; an authored 0 never does.
14714
15042
  const publishLatestOnRefresh = refreshMayPublish && !mustExecuteEveryTime;
14715
- if (policy.effective !== 0 && mustExecuteEveryTime) {
14716
- throw new Error(
14717
- `Tool ${toolId} cannot reuse an older result; use staleAfterSeconds: 0. Live datasets, event waits, Customer DB mutations, and Workspace operations are never reused.`,
14718
- );
14719
- }
14720
15043
 
14721
15044
  // Independent lookups of one tool's identity: the first call per tool pays
14722
15045
  // two gateway requests, so ask for both at once.
@@ -14744,6 +15067,30 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14744
15067
  sqlTool && (sqlMutation || scalarCustomerDbQuery)
14745
15068
  ? { ...input, operation_key: `${this.historyRunId}:${invocationId}` }
14746
15069
  : input;
15070
+ /**
15071
+ * The result-cache keys this call's execution records with its result
15072
+ * (`executeToolLegacyInternal`): each hashes the request input, credential
15073
+ * scope, action version and the run's cache epoch. They prove an unbound
15074
+ * recorded operation is this call's.
15075
+ */
15076
+ const legacyRequestIdentities =
15077
+ (staleAfterSeconds: number | null | undefined) => async () => {
15078
+ const identity = {
15079
+ toolId,
15080
+ requestInput,
15081
+ executionAuthScopeDigest: authScope?.trim() || null,
15082
+ staleAfterSeconds: this.effectiveToolCallCachePolicy({
15083
+ ...options,
15084
+ force: true,
15085
+ staleAfterSeconds,
15086
+ }).staleAfterSeconds,
15087
+ };
15088
+ const [keys, legacy] = await Promise.all([
15089
+ this.compatibleDurableToolCallCacheKeys(identity),
15090
+ this.legacyDurableToolCallCacheKey(identity),
15091
+ ]);
15092
+ return legacy ? [...keys, legacy] : keys;
15093
+ };
14747
15094
 
14748
15095
  if (
14749
15096
  isAlwaysFreshIntegrationWriteTool(toolId) &&
@@ -14760,6 +15107,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14760
15107
  semanticKey,
14761
15108
  invocationId,
14762
15109
  policy: { requested: policy.requested, effective: 0 },
15110
+ legacyRequestIdentities: legacyRequestIdentities(0),
14763
15111
  execute: async () =>
14764
15112
  await this.executeToolLegacyInternal(key, toolId, requestInput, {
14765
15113
  ...options,
@@ -14770,6 +15118,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14770
15118
  }
14771
15119
 
14772
15120
  if (liveDataset || isAlwaysFreshIntegrationTool(toolId)) {
15121
+ // Never recovered: release the exact-request slot it reserved.
15122
+ this.exactRequestInvocationIds.delete(invocationId);
14773
15123
  const value = await this.executeToolLegacyInternal(
14774
15124
  key,
14775
15125
  toolId,
@@ -14801,6 +15151,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14801
15151
  invocationId,
14802
15152
  policy,
14803
15153
  toolId,
15154
+ replayMismatchPolicy: () => this.toolReplayMismatchPolicy(toolId, input),
15155
+ legacyRequestIdentities: legacyRequestIdentities(
15156
+ options?.staleAfterSeconds,
15157
+ ),
14804
15158
  ...(publishLatestOnRefresh
14805
15159
  ? { publishLatestOnRefresh: true as const }
14806
15160
  : {}),
@@ -17276,13 +17630,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17276
17630
  }
17277
17631
  } else if (
17278
17632
  this.usesExplicitFreshness &&
17279
- !reusableReadMethod &&
17280
17633
  options?.staleAfterSeconds !== undefined &&
17281
17634
  options.staleAfterSeconds !== 0
17282
17635
  ) {
17283
- throw new Error(
17284
- 'Edition 11 mutating or non-read-only fetches require staleAfterSeconds: 0.',
17285
- );
17636
+ const verdict = reusableWindowEligibility({ kind: 'fetch', method });
17637
+ if ('message' in verdict) throw new Error(verdict.message);
17286
17638
  }
17287
17639
  const urlContainsResolvedSecret =
17288
17640
  this.secretRedactor.containsRegisteredSecret(url, {
@@ -17376,6 +17728,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17376
17728
  invocationId,
17377
17729
  staleAfterSeconds: options?.staleAfterSeconds,
17378
17730
  transient: options?.transient === true,
17731
+ replayReadSafe: reusableReadMethod,
17379
17732
  onRecovered: (output) => {
17380
17733
  if (!output.ok) {
17381
17734
  this.logCtxFetchHttpFailure({
@@ -17742,6 +18095,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17742
18095
  id: normalizedKey,
17743
18096
  semanticKey,
17744
18097
  invocationId: boundaryId,
18098
+ // The boundary is scoped by the authored semanticKey: an
18099
+ // unbound receipt under it is this declared request's.
18100
+ ...(options?.semanticKey?.trim()
18101
+ ? { operationKeyEncodesRequest: true as const }
18102
+ : {}),
17745
18103
  policy: freshnessPolicy,
17746
18104
  completedAt: (value) => value.completedAt,
17747
18105
  sharesResult: (value) =>
@@ -20518,6 +20876,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20518
20876
  .catch(() => null);
20519
20877
  const retrySafeTransientHttp =
20520
20878
  retryPolicy?.retrySafeTransientHttp === true;
20879
+ const providerServerErrorReplay =
20880
+ retryPolicy?.providerServerErrorReplay ?? 'never';
20521
20881
  const requiresExecutionFence =
20522
20882
  retryPolicy?.requiresExecutionFence === true;
20523
20883
  // Fenced execution is an operation-specific opt-in. A gateway may
@@ -21824,6 +22184,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21824
22184
  transientHttpRetrySafe:
21825
22185
  retrySafeTransientHttp || fixtureReplaySafe,
21826
22186
  executionFenced: usesDurableInvocationFence,
22187
+ providerServerErrorReplay,
21827
22188
  });
21828
22189
  let failure = classifyToolExecuteHttpFailure({
21829
22190
  toolId,
@@ -21840,6 +22201,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21840
22201
  transientHttpRetrySafe:
21841
22202
  retrySafeTransientHttp || fixtureReplaySafe,
21842
22203
  executionFenced: usesDurableInvocationFence,
22204
+ providerServerErrorReplay,
21843
22205
  providerLatencyMs:
21844
22206
  Date.now() - dispatchedProviderCallStartedAt,
21845
22207
  });
@@ -21865,6 +22227,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21865
22227
  transientHttpRetrySafe:
21866
22228
  retrySafeTransientHttp || fixtureReplaySafe,
21867
22229
  executionFenced: usesDurableInvocationFence,
22230
+ providerServerErrorReplay,
21868
22231
  providerLatencyMs:
21869
22232
  Date.now() - dispatchedProviderCallStartedAt,
21870
22233
  });
@@ -22378,6 +22741,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22378
22741
  fixtureReplaySafe ||
22379
22742
  Boolean(asyncExecutionRecovery),
22380
22743
  executionFenced: usesDurableInvocationFence,
22744
+ providerServerErrorReplay,
22381
22745
  });
22382
22746
  const failure =
22383
22747
  preclassifiedHttpFailure.current?.failure ??
@@ -22394,6 +22758,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22394
22758
  fixtureReplaySafe ||
22395
22759
  Boolean(asyncExecutionRecovery),
22396
22760
  executionFenced: usesDurableInvocationFence,
22761
+ providerServerErrorReplay,
22397
22762
  ...(providerCallElapsedMs !== null
22398
22763
  ? { providerLatencyMs: providerCallElapsedMs }
22399
22764
  : {}),
@@ -22636,6 +23001,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22636
23001
  const billingRetryIdentity = toolExecuteBillingRetryIdentity({
22637
23002
  failure,
22638
23003
  executionFenced: usesDurableInvocationFence,
23004
+ asyncExecutionRecovery: Boolean(asyncExecutionRecovery),
22639
23005
  httpFailureAttempt,
22640
23006
  invocationAttempt,
22641
23007
  });
@@ -1153,6 +1153,7 @@ export interface ContextOptions {
1153
1153
  ) => Promise<{
1154
1154
  retrySafeTransientHttp?: boolean;
1155
1155
  requiresExecutionFence?: boolean;
1156
+ providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
1156
1157
  } | null>;
1157
1158
  getToolActionCacheVersion?: (toolId: string) => Promise<string> | string;
1158
1159
  /**