deepline 0.3.516 → 0.3.518

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 (167) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/bounded-batch-function.ts +21 -3
  4. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +163 -63
  5. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-production-gate.ts +32 -5
  6. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +8 -13
  7. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +14 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +119 -9
  9. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +8 -2
  10. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +12 -11
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +44 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +16 -6
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +42 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-completion-coalescer.ts +8 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +22 -0
  16. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -7
  17. package/dist/cli/{artifacts-KMWS32R5.js → artifacts-EAOGAB5K.js} +21 -19
  18. package/dist/cli/{artifacts-G56FISIE.mjs → artifacts-LGFPVJSE.mjs} +9 -7
  19. package/dist/cli/auth-CLNPH65D.js +43 -0
  20. package/dist/cli/{auth-RSS7MOBV.mjs → auth-FXXZIWLI.mjs} +5 -5
  21. package/dist/cli/{billing-2ALO3XEG.mjs → billing-4Q5WAB5D.mjs} +7 -7
  22. package/dist/cli/{billing-RCC6WBIZ.js → billing-ESZXVREA.js} +82 -82
  23. package/dist/cli/{chunk-ZFRN3B2R.mjs → chunk-2DRW5ALK.mjs} +1 -1
  24. package/dist/cli/{chunk-YS7AI7R6.js → chunk-2G6MARKU.js} +7 -7
  25. package/dist/cli/{chunk-LWUFEX26.mjs → chunk-2LBKIVIW.mjs} +2 -2
  26. package/dist/cli/{chunk-UW5QWTUG.js → chunk-3NMQ5EIV.js} +14 -14
  27. package/dist/cli/{chunk-Q47MAAHI.mjs → chunk-4YR3W2YB.mjs} +1 -1
  28. package/dist/cli/{chunk-4IIK6GIY.js → chunk-5X4P3MNG.js} +9 -9
  29. package/dist/cli/{chunk-LZROM6VQ.js → chunk-6IPKRQMH.js} +2 -2
  30. package/dist/cli/{chunk-W5I53WQ4.js → chunk-7X32UR2E.js} +96 -96
  31. package/dist/cli/{chunk-6ZLL5GDN.js → chunk-B26LSUCI.js} +2 -2
  32. package/dist/cli/{chunk-LCKAG5RL.mjs → chunk-B2MSOFEI.mjs} +2 -2
  33. package/dist/cli/{chunk-RB3OR32I.js → chunk-BVQDUYXJ.js} +16 -16
  34. package/dist/cli/{chunk-WCQ7JGDV.mjs → chunk-DYWQ72ZQ.mjs} +1 -1
  35. package/dist/cli/{chunk-N6Q5SDGA.js → chunk-ENVSFG5E.js} +44 -44
  36. package/dist/cli/{chunk-HY6KAW5H.mjs → chunk-G6BD4K3K.mjs} +5 -5
  37. package/dist/cli/{chunk-7R2V5Z6O.js → chunk-GDMO6MMY.js} +41 -41
  38. package/dist/cli/{chunk-PPYJXP4Z.js → chunk-HIJM54NU.js} +22 -22
  39. package/dist/cli/{chunk-D4OZSC3C.js → chunk-HYR34KFA.js} +5 -4
  40. package/dist/cli/{chunk-JB6FEEDQ.js → chunk-ICHUGGZ3.js} +2 -2
  41. package/dist/cli/{chunk-FIIBDWAO.js → chunk-J2UOHFDH.js} +53 -53
  42. package/dist/cli/{chunk-72L5HQ3J.js → chunk-JKSLK5PS.js} +5 -5
  43. package/dist/cli/{chunk-PKKSXXZ5.js → chunk-K5GUMXRT.js} +26 -26
  44. package/dist/cli/{chunk-V46UBZBJ.mjs → chunk-KIYDPAGX.mjs} +2 -2
  45. package/dist/cli/{chunk-X2YP36YP.mjs → chunk-KP5AAMJ3.mjs} +1 -1
  46. package/dist/cli/{chunk-ZMCQP4EU.mjs → chunk-KQV75ZUA.mjs} +10 -10
  47. package/dist/cli/{chunk-QG4LIOGI.mjs → chunk-L256EFFV.mjs} +2 -2
  48. package/dist/cli/{chunk-E7ZM2ZRD.mjs → chunk-L4RQDVCN.mjs} +5 -5
  49. package/dist/cli/{chunk-CKEZXNMV.js → chunk-LLO5UYI5.js} +6 -6
  50. package/dist/cli/{chunk-6ADGVZRX.mjs → chunk-LTCNF6KG.mjs} +5 -5
  51. package/dist/cli/{chunk-WE223LFR.js → chunk-M4DA3HTT.js} +16 -16
  52. package/dist/cli/{chunk-RB5EMAWD.mjs → chunk-MNWLM3FA.mjs} +1 -1
  53. package/dist/cli/{chunk-TZNQRKDF.js → chunk-NQFVQCCV.js} +1 -1
  54. package/dist/cli/{chunk-72MFP7V4.mjs → chunk-QX4QFGU7.mjs} +1 -1
  55. package/dist/cli/{chunk-QG3MRMU5.js → chunk-R4ZEJD5F.js} +4 -4
  56. package/dist/cli/{chunk-JPLEDOEW.mjs → chunk-RASCFMYI.mjs} +2 -2
  57. package/dist/cli/{chunk-VIZJIBI4.js → chunk-REEWKGQZ.js} +10 -10
  58. package/dist/cli/{chunk-J4VMWSQK.mjs → chunk-RFUJBBJE.mjs} +6 -6
  59. package/dist/cli/{chunk-C2SR3X7Y.mjs → chunk-RYHNKT4P.mjs} +2 -2
  60. package/dist/cli/{chunk-QUSYG3VP.js → chunk-SNFRDG7G.js} +3 -3
  61. package/dist/cli/{chunk-PMS3LQ6B.js → chunk-ST7WCRVQ.js} +5 -5
  62. package/dist/cli/{chunk-2YEFJHAF.mjs → chunk-TH2AQ4VG.mjs} +3 -3
  63. package/dist/cli/{chunk-CA24C3XL.mjs → chunk-TU5RR775.mjs} +3 -3
  64. package/dist/cli/{chunk-QX7WDG4V.js → chunk-UY5JSZDA.js} +11 -11
  65. package/dist/cli/{chunk-C72J6JE3.mjs → chunk-V6DIYGTK.mjs} +1 -1
  66. package/dist/cli/{chunk-YXGTO5XA.mjs → chunk-VE6FHVXZ.mjs} +5 -4
  67. package/dist/cli/{chunk-RLI6FDQM.js → chunk-VHFICSS7.js} +6 -6
  68. package/dist/cli/{chunk-PVVWKOEB.mjs → chunk-W3UFYU63.mjs} +1 -1
  69. package/dist/cli/{chunk-EYWP5JPU.mjs → chunk-WTQF2Z6X.mjs} +4 -4
  70. package/dist/cli/{chunk-5NU37KME.mjs → chunk-X6H3JGOP.mjs} +2 -2
  71. package/dist/cli/{chunk-H6BSB2YJ.mjs → chunk-XA7OTIYW.mjs} +1 -1
  72. package/dist/cli/{chunk-P6AADORO.js → chunk-XJ5NVLIP.js} +3 -3
  73. package/dist/cli/{chunk-Z3KLCDCB.mjs → chunk-YNIH4YTR.mjs} +5 -5
  74. package/dist/cli/{chunk-XEQBYK4B.js → chunk-ZJ3HEEGF.js} +7 -7
  75. package/dist/cli/command-docs.js +2 -2
  76. package/dist/cli/command-docs.mjs +1 -1
  77. package/dist/cli/{csv-YXK5TB47.mjs → csv-KRGEVVN7.mjs} +4 -4
  78. package/dist/cli/{csv-RPR64UBS.js → csv-RLFOF4P4.js} +13 -13
  79. package/dist/cli/{db-UQYILAMF.mjs → db-2B6G4YO3.mjs} +6 -6
  80. package/dist/cli/{db-KO3JCGRG.js → db-NJC3NPOL.js} +27 -27
  81. package/dist/cli/{describe-P2OK5X2S.mjs → describe-BLJFAM4U.mjs} +18 -18
  82. package/dist/cli/describe-DRMUODJN.js +50 -0
  83. package/dist/cli/describe-core.d.mts +3 -3
  84. package/dist/cli/describe-core.d.ts +3 -3
  85. package/dist/cli/{executions-IQCRQXVA.mjs → executions-25XYBGJ5.mjs} +6 -6
  86. package/dist/cli/{executions-5Z7H7HV3.js → executions-ENELLT7A.js} +8 -8
  87. package/dist/cli/{feedback-ZO6A4HTV.mjs → feedback-5OAKHVQE.mjs} +5 -5
  88. package/dist/cli/{feedback-EDZJDARP.js → feedback-UPI2JQPL.js} +10 -10
  89. package/dist/cli/{git-OBXSILWM.mjs → git-MRYSIZV4.mjs} +5 -5
  90. package/dist/cli/git-P4OPT6Q7.js +25 -0
  91. package/dist/cli/index.js +145 -145
  92. package/dist/cli/index.mjs +44 -44
  93. package/dist/cli/{legacy-noops-HKXU2EU6.js → legacy-noops-DHEWQKER.js} +9 -9
  94. package/dist/cli/{legacy-noops-4UJM3FMN.mjs → legacy-noops-OJD5KYUO.mjs} +6 -6
  95. package/dist/cli/{monitors-7EP3Q2DX.js → monitors-22AFKUQN.js} +100 -100
  96. package/dist/cli/{monitors-ZXF2KCW7.mjs → monitors-24JM24NV.mjs} +7 -7
  97. package/dist/cli/{org-GFGOTUWP.js → org-HNYKUDJB.js} +72 -72
  98. package/dist/cli/{org-EDHCUR6V.mjs → org-I2X7ZZGQ.mjs} +6 -6
  99. package/dist/cli/{pages-EGEWMPJN.mjs → pages-4LSYUDES.mjs} +6 -6
  100. package/dist/cli/{pages-TLFQQL5S.js → pages-OUSF2RNH.js} +18 -18
  101. package/dist/cli/{play-NBO3MPDL.mjs → play-64XKQRA4.mjs} +18 -18
  102. package/dist/cli/{play-XDHJY5R4.js → play-ESY43EFW.js} +317 -317
  103. package/dist/cli/{providers-RU6BGEDM.js → providers-ENWSSRYR.js} +9 -9
  104. package/dist/cli/{providers-NXJ7WPNH.mjs → providers-VHK26CSP.mjs} +6 -6
  105. package/dist/cli/{quickstart-YBNDPNAR.mjs → quickstart-4NNLQMD7.mjs} +4 -4
  106. package/dist/cli/{quickstart-4ZZBMZPF.js → quickstart-TZ6IAUMS.js} +6 -6
  107. package/dist/cli/{run-LX52KVZM.mjs → run-DOH3AMYU.mjs} +23 -23
  108. package/dist/cli/{run-374CTJBV.js → run-RR7KPWP7.js} +41 -41
  109. package/dist/cli/search-SE6PM33H.js +33 -0
  110. package/dist/cli/{search-EH6JPV62.mjs → search-YFOCGXWL.mjs} +8 -8
  111. package/dist/cli/{search-output-NATLJOWW.js → search-output-AOTV6C36.js} +6 -6
  112. package/dist/cli/{search-output-XIQERUHF.mjs → search-output-IV2HSRLQ.mjs} +4 -4
  113. package/dist/cli/{secrets-A3UXDE5V.js → secrets-ATPM2AXV.js} +15 -15
  114. package/dist/cli/{secrets-VRJQFUKF.mjs → secrets-GMFCHPTV.mjs} +6 -6
  115. package/dist/cli/sessions-NN3H2KSE.js +18 -0
  116. package/dist/cli/{sessions-5TTH5FGZ.mjs → sessions-X3M4H2WY.mjs} +6 -6
  117. package/dist/cli/{settings-LX5EGLVT.js → settings-4V52LMWP.js} +86 -86
  118. package/dist/cli/{settings-VRGFTOTJ.mjs → settings-GRXFOR5V.mjs} +13 -13
  119. package/dist/cli/{setup-FXP5Y3Y6.mjs → setup-63WAXGPH.mjs} +10 -10
  120. package/dist/cli/{setup-QL4YWKOR.js → setup-OCCXAVQL.js} +50 -50
  121. package/dist/cli/skills-6XXVKQP4.js +37 -0
  122. package/dist/cli/{skills-ET4PMBJE.mjs → skills-IVGTO4NE.mjs} +8 -8
  123. package/dist/cli/tools-5COWG5TH.js +57 -0
  124. package/dist/cli/{tools-WPL3NZAA.mjs → tools-KGHX6MLB.mjs} +17 -17
  125. package/dist/cli/{update-OCAHAKL2.mjs → update-2OBZ4IUJ.mjs} +10 -10
  126. package/dist/cli/update-SQD25OCL.js +35 -0
  127. package/dist/cli/{workflow-CWO3XL4O.js → workflow-HGLO4V7R.js} +17 -17
  128. package/dist/cli/{workflow-NPZ2RLQG.mjs → workflow-ZZOATQYV.mjs} +7 -7
  129. package/dist/{client-K1g4ab5Y.d.mts → client-CpSiHSti.d.mts} +1 -1
  130. package/dist/{client-CQSPuqxh.d.ts → client-CswZYCGj.d.ts} +1 -1
  131. package/dist/{client-core-BksGf5Gd.d.mts → client-core-C1xVOg8Y.d.mts} +1 -1
  132. package/dist/{client-core-BlaqOlQ7.d.ts → client-core-D2pLt36Q.d.ts} +1 -1
  133. package/dist/{compiler-manifest-BliMS7ax.d.mts → compiler-manifest-B4mIIbw7.d.mts} +3 -3
  134. package/dist/{compiler-manifest-BliMS7ax.d.ts → compiler-manifest-B4mIIbw7.d.ts} +3 -3
  135. package/dist/{errors-BZ6Zq1cz.d.mts → errors-C2F4qzAq.d.mts} +1 -1
  136. package/dist/{errors-xfNscfS1.d.ts → errors-Gj9i5Rkd.d.ts} +1 -1
  137. package/dist/{index-DbvCg4zg.d.mts → index-5JZBufdF.d.mts} +1 -1
  138. package/dist/{index-FGdQv8J8.d.ts → index-BXtSj8bv.d.ts} +1 -1
  139. package/dist/index.d.mts +7 -7
  140. package/dist/index.d.ts +7 -7
  141. package/dist/index.js +9 -9
  142. package/dist/index.mjs +6 -6
  143. package/dist/install-integrity.json +117 -116
  144. package/dist/plays/bundle-play-file.d.mts +3 -3
  145. package/dist/plays/bundle-play-file.d.ts +3 -3
  146. package/dist/plays/bundle-play-file.mjs +3 -4
  147. package/dist/plays/play-description.d.mts +2 -2
  148. package/dist/plays/play-description.d.ts +2 -2
  149. package/dist/plays/run-request.d.mts +2 -2
  150. package/dist/plays/run-request.d.ts +2 -2
  151. package/dist/release.d.mts +1 -1
  152. package/dist/release.d.ts +1 -1
  153. package/dist/release.js +2 -2
  154. package/dist/release.mjs +1 -1
  155. package/dist/server.d.mts +4 -4
  156. package/dist/server.d.ts +4 -4
  157. package/dist/server.js +5 -5
  158. package/dist/server.mjs +3 -3
  159. package/package.json +1 -1
  160. package/dist/cli/auth-6EIEZ3UE.js +0 -43
  161. package/dist/cli/describe-BPX3U2BF.js +0 -50
  162. package/dist/cli/git-Y34J73QC.js +0 -25
  163. package/dist/cli/search-YS4DHSQC.js +0 -33
  164. package/dist/cli/sessions-EXII5VOV.js +0 -18
  165. package/dist/cli/skills-5L4CYX3V.js +0 -37
  166. package/dist/cli/tools-5V77VIUA.js +0 -57
  167. package/dist/cli/update-G5RSSWM5.js +0 -35
@@ -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.516',
208
+ version: '0.3.518',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -291,6 +291,24 @@
291
291
  "failureAlert": "github_workflow_run",
292
292
  "domainReportRequired": true
293
293
  },
294
+ {
295
+ "id": "github.search-evals-nightly",
296
+ "name": "Search evals",
297
+ "scheduler": "github_actions",
298
+ "cadence": "15 8 * * *",
299
+ "timezone": "UTC",
300
+ "source": ".github/workflows/search-evals-nightly.yml",
301
+ "locator": "schedule:",
302
+ "owner": "evals",
303
+ "criticality": "reporting",
304
+ "purpose": "Send every labeled search case and a sample of the last 28 days of customer searches to Production search from a disposable workspace and publish each search's served results and per-group scores for Ojos.",
305
+ "successDefinition": "The actual-usage suite is built, every search is answered, the summary and cases publish, and the disposable workspace is deleted.",
306
+ "failureDefinition": "The actual-usage suite cannot be built, workspace bootstrap, a search, the publish, or workspace deletion fails.",
307
+ "startGraceMs": 600000,
308
+ "runTimeoutMs": 7200000,
309
+ "failureAlert": "github_workflow_run",
310
+ "domainReportRequired": true
311
+ },
294
312
  {
295
313
  "id": "github.fly-pr-preview-cleanup",
296
314
  "name": "Reconcile Fly PR Preview Capacity",
@@ -158,6 +158,7 @@ export class BoundedBatchFunction<Value, Result, Key> {
158
158
  readonly #maxOpenGroups: number;
159
159
  readonly #maxInFlightBatches: number;
160
160
  readonly #flushMs: number;
161
+ readonly #flushImmediatelyWhenIdle: boolean;
161
162
  readonly #now: () => number;
162
163
  readonly #closedController = new AbortController();
163
164
  readonly #groups = new Map<string, OpenGroup<Value, Result, Key>>();
@@ -191,6 +192,14 @@ export class BoundedBatchFunction<Value, Result, Key> {
191
192
  maxOpenGroups?: number;
192
193
  maxInFlightBatches?: number;
193
194
  flushMs?: number;
195
+ /**
196
+ * Flush a window opened on a completely idle function (no other open
197
+ * window, nothing ready, nothing in flight) on the next timer turn rather
198
+ * than after `flushMs`. Values arriving in that same turn still join the
199
+ * window; a lone value stops paying a hold that no peer can use. Windows
200
+ * opened while the function is busy keep the full `flushMs`.
201
+ */
202
+ flushImmediatelyWhenIdle?: boolean;
194
203
  now?: () => number;
195
204
  }) {
196
205
  this.#keyId = input.keyId;
@@ -226,6 +235,7 @@ export class BoundedBatchFunction<Value, Result, Key> {
226
235
  'maxInFlightBatches',
227
236
  );
228
237
  this.#flushMs = Math.max(0, Math.floor(input.flushMs ?? 0));
238
+ this.#flushImmediatelyWhenIdle = input.flushImmediatelyWhenIdle === true;
229
239
  this.#now = input.now ?? Date.now;
230
240
  }
231
241
 
@@ -354,6 +364,11 @@ export class BoundedBatchFunction<Value, Result, Key> {
354
364
  ) {
355
365
  this.#sealGroup(keyId);
356
366
  }
367
+ const wasIdle =
368
+ this.#flushImmediatelyWhenIdle &&
369
+ this.#groups.size === 0 &&
370
+ this.#ready.length === 0 &&
371
+ this.#inFlight.size === 0;
357
372
  const group = this.#groups.get(keyId) ?? {
358
373
  key: input.key,
359
374
  keyId,
@@ -375,7 +390,7 @@ export class BoundedBatchFunction<Value, Result, Key> {
375
390
  ) {
376
391
  this.#sealGroup(keyId);
377
392
  } else {
378
- this.#scheduleGroupFlush(group);
393
+ this.#scheduleGroupFlush(group, wasIdle ? 0 : this.#flushMs);
379
394
  }
380
395
  this.#scheduleDeadlineTimer();
381
396
  this.#pump();
@@ -454,13 +469,16 @@ export class BoundedBatchFunction<Value, Result, Key> {
454
469
  this.#retainedUnits -= pending.units;
455
470
  }
456
471
 
457
- #scheduleGroupFlush(group: OpenGroup<Value, Result, Key>): void {
472
+ #scheduleGroupFlush(
473
+ group: OpenGroup<Value, Result, Key>,
474
+ delayMs: number,
475
+ ): void {
458
476
  if (group.timer !== null) return;
459
477
  group.timer = setTimeout(() => {
460
478
  group.timer = null;
461
479
  this.#sealGroup(group.keyId);
462
480
  this.#pump();
463
- }, this.#flushMs);
481
+ }, delayMs);
464
482
  group.timer.unref?.();
465
483
  }
466
484
 
@@ -291,6 +291,7 @@ import {
291
291
  import { resolveExplicitDurableCallPolicy } from './durable-call-policy';
292
292
  import {
293
293
  completedCallForResult,
294
+ type DeferredReceiptPublication,
294
295
  executeWithFreshnessReceipt,
295
296
  latestCacheResultKey,
296
297
  latestCacheResultOutput,
@@ -301,7 +302,6 @@ import {
301
302
  CtxFetchHttpError,
302
303
  LEGACY_PLAY_AUTHORING_CONTRACT_EDITION,
303
304
  PLAY_AUTHORING_CONTRACT_EDITION,
304
- PlayAuthoringFieldValidationError,
305
305
  normalizePlayAuthoringCustomerDbStatement,
306
306
  validateOptionalPlayAuthoringField,
307
307
  validatePlayAuthoringField,
@@ -3379,16 +3379,6 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
3379
3379
  options.staleAfterSeconds,
3380
3380
  );
3381
3381
  }
3382
- if (
3383
- this.usesExplicitFreshness &&
3384
- options?.staleAfterSeconds === undefined
3385
- ) {
3386
- throw new PlayAuthoringFieldValidationError(
3387
- 'ctx.customerDb.query.options.staleAfterSeconds',
3388
- 'play_authoring_durable_policy_invalid',
3389
- 'Edition 11 Customer DB queries require staleAfterSeconds: 0.',
3390
- );
3391
- }
3392
3382
  if (options?.maxRows !== undefined) {
3393
3383
  validatePlayAuthoringField(
3394
3384
  'ctx.customerDb.query.options.maxRows',
@@ -4143,7 +4133,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4143
4133
  semanticKey: string;
4144
4134
  invocationId: string;
4145
4135
  policy: { requested: number | null; effective: number | null };
4146
- execute: () => Promise<T>;
4136
+ execute: (publication: DeferredReceiptPublication) => Promise<T>;
4147
4137
  completedAt?: (value: T) => number | undefined;
4148
4138
  sharesResult?: (value: T) => boolean;
4149
4139
  eligibleAnswer?: (value: T) => boolean;
@@ -4192,8 +4182,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4192
4182
  ),
4193
4183
  { ...options, source: 'durable_operation' },
4194
4184
  ),
4195
- execute: async () => {
4196
- const value = await input.execute();
4185
+ execute: async (publication) => {
4186
+ const value = await input.execute(publication);
4197
4187
  this.assertNoPendingDurableSuspension();
4198
4188
  return value;
4199
4189
  },
@@ -5105,6 +5095,43 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
5105
5095
  );
5106
5096
  },
5107
5097
  });
5098
+ } catch (error) {
5099
+ if (isAbortLikeError(error)) throw error;
5100
+ this.runtimeLog(
5101
+ `Tool source-run receipt manifest write skipped: ${error instanceof Error ? error.message : String(error)}`,
5102
+ );
5103
+ }
5104
+ }
5105
+
5106
+ /**
5107
+ * Same pointer as `persistSourceRunToolReceiptManifests`, handed to the
5108
+ * freshness layer to publish in its finishing request. A failure to build
5109
+ * it is logged, never raised: it is optional recovery metadata.
5110
+ */
5111
+ private async deferSourceRunToolReceiptManifest(
5112
+ input: {
5113
+ toolId: string;
5114
+ logicalCallId?: string | null;
5115
+ executionAuthScopeDigest?: string | null;
5116
+ resultReceiptKey: string;
5117
+ },
5118
+ publication: DeferredReceiptPublication,
5119
+ ): Promise<void> {
5120
+ try {
5121
+ const providerActionVersion =
5122
+ (
5123
+ await this.#options.getToolActionCacheVersion?.(input.toolId)
5124
+ )?.trim() ?? '';
5125
+ for (const manifest of this.sourceRunToolReceiptManifestCompletionInputs([
5126
+ { ...input, providerActionVersion },
5127
+ ])) {
5128
+ publication.defer({
5129
+ key: manifest.key,
5130
+ output: manifest.output,
5131
+ bestEffort: true,
5132
+ sourceRunManifest: true,
5133
+ });
5134
+ }
5108
5135
  } catch (error) {
5109
5136
  this.runtimeLog(
5110
5137
  `Tool source-run receipt manifest write skipped: ${error instanceof Error ? error.message : String(error)}`,
@@ -5495,6 +5522,29 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
5495
5522
  return byKey;
5496
5523
  }
5497
5524
 
5525
+ /**
5526
+ * Read independent keys of one call together. A host with a batch read
5527
+ * sends one request; otherwise each key is its own single read, issued at
5528
+ * once. Either way each key is answered under the key that was asked for.
5529
+ */
5530
+ private async getRuntimeStepReceiptsByRequestedKey(
5531
+ keys: string[],
5532
+ ): Promise<Map<string, RuntimeStepReceipt>> {
5533
+ if (this.#options.getRuntimeStepReceipts) {
5534
+ return await this.getRuntimeStepReceipts(keys);
5535
+ }
5536
+ const unique = [...new Set(keys.map((key) => key.trim()).filter(Boolean))];
5537
+ const receipts = await Promise.all(
5538
+ unique.map((key) => this.getRuntimeStepReceipt(key)),
5539
+ );
5540
+ const byKey = new Map<string, RuntimeStepReceipt>();
5541
+ unique.forEach((key, index) => {
5542
+ const receipt = receipts[index];
5543
+ if (receipt) byKey.set(key, receipt);
5544
+ });
5545
+ return byKey;
5546
+ }
5547
+
5498
5548
  private async claimRuntimeStepReceipts(
5499
5549
  keys: string[],
5500
5550
  _runId: string,
@@ -5907,7 +5957,12 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
5907
5957
  const outcome = settled[index];
5908
5958
  if (outcome?.status !== 'rejected') continue;
5909
5959
  const key = normalizedInputs[index]?.key.trim() ?? '';
5910
- if (key && options.bestEffortKeys?.has(key)) {
5960
+ // A cancellation is the run stopping, not a lost optional pointer.
5961
+ if (
5962
+ key &&
5963
+ options.bestEffortKeys?.has(key) &&
5964
+ !isAbortLikeError(outcome.reason)
5965
+ ) {
5911
5966
  options.onBestEffortFailure?.({ key, error: outcome.reason });
5912
5967
  continue;
5913
5968
  }
@@ -6899,6 +6954,40 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
6899
6954
  : {}),
6900
6955
  complete: (receiptKey, runId, output, leaseId) =>
6901
6956
  this.completeRuntimeStepReceipt(receiptKey, runId, output, leaseId),
6957
+ ...(this.#options.completeRuntimeStepReceipts
6958
+ ? {
6959
+ completeMany: (writes) =>
6960
+ this.completeRuntimeStepReceipts(
6961
+ writes.map((write) => ({
6962
+ key: write.key,
6963
+ runId: this.currentReceiptOwnerRunId,
6964
+ runAttempt: this.currentRunAttempt,
6965
+ leaseId: COMPLETED_RECEIPT_CACHE_INSERT_LEASE_ID,
6966
+ output: write.output,
6967
+ ...(write.sourceRunManifest
6968
+ ? { sourceRunManifest: true }
6969
+ : {}),
6970
+ })),
6971
+ undefined,
6972
+ undefined,
6973
+ {
6974
+ // The caller keeps the live value it just produced; an
6975
+ // acknowledgement without a body must not trigger a read-back.
6976
+ retainLiveResult: true,
6977
+ bestEffortKeys: new Set(
6978
+ writes
6979
+ .filter((write) => write.bestEffort)
6980
+ .map((write) => write.key),
6981
+ ),
6982
+ onBestEffortFailure: ({ key, error }) => {
6983
+ this.runtimeLog(
6984
+ `Tool source-run receipt manifest write skipped for ${key}: ${error instanceof Error ? error.message : String(error)}`,
6985
+ );
6986
+ },
6987
+ },
6988
+ ),
6989
+ }
6990
+ : {}),
6902
6991
  ...(this.#options.publishLatestCacheResult
6903
6992
  ? { publishLatestCacheResult: this.#options.publishLatestCacheResult }
6904
6993
  : {}),
@@ -14491,9 +14580,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14491
14580
  );
14492
14581
  }
14493
14582
 
14494
- const authScope = await this.resolveToolAuthScopeDigest(toolId);
14495
- const actionVersion =
14496
- (await this.#options.getToolActionCacheVersion?.(toolId))?.trim() ?? '';
14583
+ // Independent lookups of one tool's identity: the first call per tool pays
14584
+ // two gateway requests, so ask for both at once.
14585
+ const [authScope, rawActionVersion] = await Promise.all([
14586
+ this.resolveToolAuthScopeDigest(toolId),
14587
+ this.#options.getToolActionCacheVersion?.(toolId),
14588
+ ]);
14589
+ const actionVersion = rawActionVersion?.trim() ?? '';
14497
14590
  if (!actionVersion) {
14498
14591
  throw new Error(`Tool ${toolId} has no action identity for freshness.`);
14499
14592
  }
@@ -14586,7 +14679,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14586
14679
  },
14587
14680
  sharesResult: isCompletedSuccessfulAnswer,
14588
14681
  eligibleAnswer: isCompletedSuccessfulAnswer,
14589
- execute: async () => {
14682
+ execute: async (publication) => {
14590
14683
  // The freshness layer is the only reuse authority here. The legacy
14591
14684
  // durable call cache below it would otherwise hand back an earlier
14592
14685
  // completed-but-ineligible answer (a pending or empty result) that the
@@ -14597,6 +14690,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14597
14690
  requestInput,
14598
14691
  { ...options, force: true },
14599
14692
  true,
14693
+ publication,
14600
14694
  );
14601
14695
  if ((await this.resolveToolAuthScopeDigest(toolId)) !== authScope) {
14602
14696
  throw new Error(
@@ -14703,6 +14797,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14703
14797
  input: Record<string, unknown>,
14704
14798
  options?: ToolCallOptions,
14705
14799
  deferResponseMaterialization = false,
14800
+ /**
14801
+ * The caller publishes this call's result receipt and replay pointer with
14802
+ * its own finishing writes, before the call returns to customer code.
14803
+ */
14804
+ publication?: DeferredReceiptPublication,
14706
14805
  ): Promise<unknown> {
14707
14806
  if (!rowContext.getStore()) this.assertRowAdmissionOpen();
14708
14807
  this.assertNoPendingDurableSuspension();
@@ -14954,19 +15053,31 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14954
15053
  // reader seam rather than teaching the deep Module an untyped result.
14955
15054
  // New direct calls use the real Tool Result Receipt Adapter below.
14956
15055
  if (cacheableToolResult && !toolCachePolicy.force) {
15056
+ // The compatibility receipts, the primary receipt, the request's
15057
+ // shared result and the response-contract recovery receipt are
15058
+ // independent keys of this one call. Read them in one request and
15059
+ // evaluate them below in the same priority order, instead of paying
15060
+ // a gateway round trip for each in turn.
15061
+ const sharedReadKey = latestCache?.read ? latestCache.key : null;
15062
+ const lookedUp = await this.withRuntimeReceiptHydrationTurn(
15063
+ async (turn) => {
15064
+ const byKey = await this.getRuntimeStepReceiptsByRequestedKey([
15065
+ ...compatibleDurableCacheKeys.slice(1),
15066
+ directCacheKey,
15067
+ ...(sharedReadKey ? [sharedReadKey] : []),
15068
+ ...(legacyDurableCacheKey ? [legacyDurableCacheKey] : []),
15069
+ ]);
15070
+ turn.settleBytes(
15071
+ runtimeStepReceiptPayloadBytes([...byKey.values()]),
15072
+ );
15073
+ return byKey;
15074
+ },
15075
+ { source: 'direct_tool_legacy_cache' },
15076
+ );
14957
15077
  for (const compatibleCacheKey of compatibleDurableCacheKeys.slice(
14958
15078
  1,
14959
15079
  )) {
14960
- const compatibleReceipt =
14961
- await this.withRuntimeReceiptHydrationTurn(
14962
- async (turn) => {
14963
- const receipt =
14964
- await this.getRuntimeStepReceipt(compatibleCacheKey);
14965
- turn.settleBytes(runtimeStepReceiptPayloadBytes([receipt]));
14966
- return receipt;
14967
- },
14968
- { source: 'direct_tool_legacy_cache' },
14969
- );
15080
+ const compatibleReceipt = lookedUp.get(compatibleCacheKey) ?? null;
14970
15081
  if (
14971
15082
  compatibleReceipt &&
14972
15083
  (compatibleReceipt.status === 'completed' ||
@@ -14996,27 +15107,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14996
15107
  // An older edition reads the request's shared result in the same
14997
15108
  // batch as its play-local receipt; the play-local result wins.
14998
15109
  const sharedRead = latestCache?.read ? latestCache : null;
14999
- let sharedReceipt: RuntimeStepReceipt | null = null;
15000
- const historicalReceipt = await this.withRuntimeReceiptHydrationTurn(
15001
- async (turn) => {
15002
- if (sharedRead) {
15003
- const byKey = await this.getRuntimeStepReceipts([
15004
- directCacheKey,
15005
- sharedRead.key,
15006
- ]);
15007
- const receipt = byKey.get(directCacheKey) ?? null;
15008
- sharedReceipt = byKey.get(sharedRead.key) ?? null;
15009
- turn.settleBytes(
15010
- runtimeStepReceiptPayloadBytes([receipt, sharedReceipt]),
15011
- );
15012
- return receipt;
15013
- }
15014
- const receipt = await this.getRuntimeStepReceipt(directCacheKey);
15015
- turn.settleBytes(runtimeStepReceiptPayloadBytes([receipt]));
15016
- return receipt;
15017
- },
15018
- { source: 'direct_tool_legacy_cache' },
15019
- );
15110
+ const sharedReceipt: RuntimeStepReceipt | null = sharedRead
15111
+ ? (lookedUp.get(sharedRead.key) ?? null)
15112
+ : null;
15113
+ const historicalReceipt = lookedUp.get(directCacheKey) ?? null;
15020
15114
  const historicalOutput = historicalReceipt
15021
15115
  ? this.runtimeReceiptOutput<unknown>(historicalReceipt)
15022
15116
  : undefined;
@@ -15060,16 +15154,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
15060
15154
  (!historicalReceipt || !historicalCanServeCurrentContract) &&
15061
15155
  legacyDurableCacheKey
15062
15156
  ) {
15063
- const legacyReceipt = await this.withRuntimeReceiptHydrationTurn(
15064
- async (turn) => {
15065
- const receipt = await this.getRuntimeStepReceipt(
15066
- legacyDurableCacheKey!,
15067
- );
15068
- turn.settleBytes(runtimeStepReceiptPayloadBytes([receipt]));
15069
- return receipt;
15070
- },
15071
- { source: 'direct_tool_legacy_cache' },
15072
- );
15157
+ const legacyReceipt = lookedUp.get(legacyDurableCacheKey) ?? null;
15073
15158
  if (
15074
15159
  legacyReceipt &&
15075
15160
  (legacyReceipt.status === 'completed' ||
@@ -15313,13 +15398,27 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
15313
15398
  this.withRuntimeReceiptHydrationTurn(hydrate, {
15314
15399
  source: 'direct_tool_result_receipt',
15315
15400
  }),
15401
+ ...(publication ? { deferPublication: publication } : {}),
15316
15402
  onStored: async ({ resultReceiptKey }) => {
15317
- await this.persistSourceRunToolReceiptManifest({
15403
+ const pointer = {
15318
15404
  toolId,
15319
15405
  logicalCallId,
15320
15406
  executionAuthScopeDigest,
15321
15407
  resultReceiptKey,
15322
- });
15408
+ };
15409
+ // An execution-fenced call keeps its own write path: its
15410
+ // lock is held until the result is durable.
15411
+ if (
15412
+ publication &&
15413
+ toolRetryPolicy?.requiresExecutionFence !== true
15414
+ ) {
15415
+ await this.deferSourceRunToolReceiptManifest(
15416
+ pointer,
15417
+ publication,
15418
+ );
15419
+ return;
15420
+ }
15421
+ await this.persistSourceRunToolReceiptManifest(pointer);
15323
15422
  },
15324
15423
  ...(toolRetryPolicy?.requiresExecutionFence === true
15325
15424
  ? {
@@ -17040,7 +17139,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
17040
17139
  } else if (
17041
17140
  this.usesExplicitFreshness &&
17042
17141
  !reusableReadMethod &&
17043
- options?.staleAfterSeconds !== 0
17142
+ options?.staleAfterSeconds !== undefined &&
17143
+ options.staleAfterSeconds !== 0
17044
17144
  ) {
17045
17145
  throw new Error(
17046
17146
  'Edition 11 mutating or non-read-only fetches require staleAfterSeconds: 0.',
@@ -2,6 +2,7 @@ export type VercelDeployment = {
2
2
  id?: string;
3
3
  /** Vercel's deployment-list endpoint names this same identifier `uid`. */
4
4
  uid?: string;
5
+ projectId?: string;
5
6
  url?: string;
6
7
  gitSource?: { sha?: string };
7
8
  meta?: { githubCommitSha?: string };
@@ -38,18 +39,35 @@ export function decideVercelStagedProductionPolicy(input: {
38
39
  : { kind: 'auto-assign-enabled' };
39
40
  }
40
41
 
41
- function deploymentSha(deployment: VercelDeployment): string | undefined {
42
- return deployment.meta?.githubCommitSha ?? deployment.gitSource?.sha;
42
+ export function deploymentSha(
43
+ deployment: VercelDeployment,
44
+ ): string | undefined {
45
+ return deployment.gitSource?.sha ?? deployment.meta?.githubCommitSha;
43
46
  }
44
47
 
45
48
  export function deploymentId(deployment: VercelDeployment): string | undefined {
46
49
  return deployment.id ?? deployment.uid;
47
50
  }
48
51
 
52
+ const buildingStates = new Set(['QUEUED', 'INITIALIZING', 'BUILDING']);
53
+
54
+ export function isUsableVercelProductionBuild(
55
+ deployment: VercelDeployment,
56
+ expectedSha: string,
57
+ ): boolean {
58
+ return (
59
+ deploymentSha(deployment) === expectedSha &&
60
+ deployment.target === 'production' &&
61
+ Boolean(deploymentId(deployment)) &&
62
+ (deployment.readyState === 'READY'
63
+ ? Boolean(deployment.url)
64
+ : buildingStates.has(deployment.readyState ?? ''))
65
+ );
66
+ }
67
+
49
68
  /**
50
- * Git creates the production build; the release controller only promotes the
51
- * already-staged deployment after its runtime proof has passed. Keep that one
52
- * provider mutation shared by normal release and panic recovery.
69
+ * The release controller promotes the staged deployment after its runtime
70
+ * proof has passed. Normal release and panic recovery share this mutation.
53
71
  */
54
72
  export async function promoteVercelProductionDeployment(input: {
55
73
  deploymentId: string;
@@ -117,6 +135,15 @@ export function decideVercelStagedProductionGate(input: {
117
135
  );
118
136
  if (staged) return { kind: 'ready', deployment: staged };
119
137
 
138
+ // A prior build for this SHA can be red while its replacement is building.
139
+ if (
140
+ candidates.some((deployment) =>
141
+ isUsableVercelProductionBuild(deployment, input.expectedSha),
142
+ )
143
+ ) {
144
+ return { kind: 'wait' };
145
+ }
146
+
120
147
  if (candidates.some((deployment) => deployment.readyState === 'ERROR')) {
121
148
  return {
122
149
  kind: 'vercel-failed',
@@ -18,26 +18,21 @@ export function resolveExplicitDurableCallPolicy(input: {
18
18
  staleAfterSeconds?: number | null;
19
19
  force?: boolean;
20
20
  }): { requested: number | null; effective: number | null } {
21
- if (input.staleAfterSeconds === undefined) {
22
- throw new Error(
23
- 'Choose staleAfterSeconds explicitly: 0 for a fresh call, a positive whole number of seconds to accept a completed answer up to that old, or null to accept any age.',
24
- );
25
- }
26
- resolveDurableCallCachePolicy(input.staleAfterSeconds);
27
- if (
28
- input.staleAfterSeconds !== null &&
29
- !Number.isSafeInteger(input.staleAfterSeconds)
30
- ) {
21
+ // Omitted means 0 (no cross-run reuse), the same as an authored 0.
22
+ const staleAfterSeconds =
23
+ input.staleAfterSeconds === undefined ? 0 : input.staleAfterSeconds;
24
+ resolveDurableCallCachePolicy(staleAfterSeconds);
25
+ if (staleAfterSeconds !== null && !Number.isSafeInteger(staleAfterSeconds)) {
31
26
  throw new Error(DURABLE_CALL_STALE_AFTER_SECONDS_ERROR);
32
27
  }
33
- if (input.force === true && input.staleAfterSeconds !== 0) {
28
+ if (input.force === true && staleAfterSeconds !== 0) {
34
29
  throw new Error(
35
30
  'force: true contradicts reusable freshness. Use staleAfterSeconds: 0.',
36
31
  );
37
32
  }
38
33
  return {
39
- requested: input.staleAfterSeconds,
40
- effective: input.staleAfterSeconds,
34
+ requested: staleAfterSeconds,
35
+ effective: staleAfterSeconds,
41
36
  };
42
37
  }
43
38
 
@@ -854,6 +854,20 @@ export type DurableReceiptExecutionStore = {
854
854
  output: unknown | null,
855
855
  leaseId?: string | null,
856
856
  ): Promise<RuntimeStepReceipt | null>;
857
+ /**
858
+ * Publish several immutable completed-cache receipts (the completed-cache
859
+ * insert lease) handed over together, so they share one gateway request.
860
+ * Receipts with `bestEffort` never fail the call; any other failure throws.
861
+ * Absent when the host cannot batch; callers then write them one by one.
862
+ */
863
+ completeMany?(
864
+ writes: ReadonlyArray<{
865
+ key: string;
866
+ output: unknown;
867
+ bestEffort?: true;
868
+ sourceRunManifest?: true;
869
+ }>,
870
+ ): Promise<ReadonlyMap<string, RuntimeStepReceipt | null>>;
857
871
  /**
858
872
  * Newest-wins shared read result (`ctx:{org}:cache:v1:*`). The receiver
859
873
  * stamps the time; absent when the host has no receipt gateway.