deepline 0.3.490 → 0.3.492

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 (146) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +6 -1
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/sdk/src/types.ts +4 -1
  4. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
  5. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  6. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +5 -3
  8. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +293 -110
  9. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +104 -2
  10. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +7 -2
  11. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +4 -0
  12. package/dist/bundling-sources/shared_libs/product-notifications/content.ts +13 -0
  13. package/dist/bundling-sources/shared_libs/product-notifications/email.ts +49 -10
  14. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +22 -0
  15. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +6 -1
  16. package/dist/cli/{auth-RL6LOZGC.mjs → auth-4I6QY5WX.mjs} +5 -5
  17. package/dist/cli/auth-7BCLZU6K.js +43 -0
  18. package/dist/cli/{billing-LIDDSOSY.js → billing-2H4GOJZY.js} +79 -79
  19. package/dist/cli/{billing-33THO76F.mjs → billing-4F6L4JSI.mjs} +6 -6
  20. package/dist/cli/{chunk-TVZJ6XWM.mjs → chunk-3BRDP4UP.mjs} +1 -1
  21. package/dist/cli/{chunk-FPYESYBO.js → chunk-3IBKEOL4.js} +4 -4
  22. package/dist/cli/{chunk-B7MPY7WH.js → chunk-3TISK5RQ.js} +6 -6
  23. package/dist/cli/{chunk-XSGJKXMP.js → chunk-42Z6VC2Q.js} +2 -2
  24. package/dist/cli/{chunk-2HYJU4LJ.mjs → chunk-4GJIJHRQ.mjs} +1 -1
  25. package/dist/cli/{chunk-63TNO23X.js → chunk-4RB74KJX.js} +10 -10
  26. package/dist/cli/{chunk-MBQZMHE6.mjs → chunk-6YO4OJPM.mjs} +4 -4
  27. package/dist/cli/{chunk-YYN2O43C.js → chunk-B2JE3HD6.js} +3 -3
  28. package/dist/cli/{chunk-Y2KHSQEF.js → chunk-BDUFZSUL.js} +8 -8
  29. package/dist/cli/{chunk-EPQZ42PY.js → chunk-DJOLMS2A.js} +1 -1
  30. package/dist/cli/{chunk-27IBWHR5.mjs → chunk-DVGCPOEA.mjs} +4 -4
  31. package/dist/cli/{chunk-PVMN4OE2.js → chunk-E47VAVAR.js} +5 -5
  32. package/dist/cli/{chunk-Z7W6VJFN.mjs → chunk-EANFUHRM.mjs} +1 -1
  33. package/dist/cli/{chunk-UQXHBCHU.js → chunk-EFFHRXKB.js} +2 -2
  34. package/dist/cli/{chunk-J5HMAZ34.mjs → chunk-F6EQWY4E.mjs} +2 -2
  35. package/dist/cli/{chunk-MEYQOZPF.mjs → chunk-FFOJRD53.mjs} +5 -2
  36. package/dist/cli/{chunk-QC6QUFKY.js → chunk-FPLN7PHP.js} +5 -5
  37. package/dist/cli/{chunk-QWJZSPCV.mjs → chunk-GDSZWTJK.mjs} +10 -10
  38. package/dist/cli/{chunk-QZPJWFGD.js → chunk-HFEJ7JJT.js} +26 -26
  39. package/dist/cli/{chunk-IFGBL3US.js → chunk-JHBRJDUC.js} +7 -7
  40. package/dist/cli/{chunk-WNVZV6VK.js → chunk-JJAHWKJ2.js} +53 -53
  41. package/dist/cli/{chunk-LQIKW55V.mjs → chunk-LCCFGSV7.mjs} +2 -2
  42. package/dist/cli/{chunk-CB7IFKXN.mjs → chunk-MJFVF5AW.mjs} +2 -2
  43. package/dist/cli/{chunk-CSSOP7XG.mjs → chunk-MPITIXW4.mjs} +1 -1
  44. package/dist/cli/{chunk-JSYCPTG6.mjs → chunk-MQ2LQOAM.mjs} +3 -3
  45. package/dist/cli/{chunk-FDYCUA7A.js → chunk-NBL6JMIY.js} +16 -16
  46. package/dist/cli/{chunk-TCBYQX5N.js → chunk-NF7NUKWF.js} +37 -37
  47. package/dist/cli/{chunk-HHGAY2A4.js → chunk-O2FB42N2.js} +53 -53
  48. package/dist/cli/{chunk-OFCP66VS.mjs → chunk-O65HDVA7.mjs} +2 -2
  49. package/dist/cli/{chunk-LZ37B62K.js → chunk-OGNIB64W.js} +3 -3
  50. package/dist/cli/{chunk-3M5VPIRL.mjs → chunk-OKHBAAJG.mjs} +2 -2
  51. package/dist/cli/{chunk-UTKNSD6T.js → chunk-OTDX4A4W.js} +21 -21
  52. package/dist/cli/{chunk-V47SUOAE.mjs → chunk-OTUT3XTX.mjs} +4 -4
  53. package/dist/cli/{chunk-JC2M6XG2.mjs → chunk-PIC6M4X3.mjs} +1 -1
  54. package/dist/cli/{chunk-L7QSZAF6.js → chunk-Q3CCCTRQ.js} +9 -9
  55. package/dist/cli/{chunk-MDKAPUN2.mjs → chunk-R5MP3CIY.mjs} +2 -2
  56. package/dist/cli/{chunk-NRM5OWH2.mjs → chunk-RC366IJS.mjs} +4 -4
  57. package/dist/cli/{chunk-SGG3TERP.js → chunk-SE23YSBK.js} +3 -3
  58. package/dist/cli/{chunk-6TTPAGNX.js → chunk-TVUE4CPW.js} +122 -119
  59. package/dist/cli/{chunk-PIENQTDE.mjs → chunk-UUH4GQRL.mjs} +1 -1
  60. package/dist/cli/{chunk-YPUDIEZX.js → chunk-W4FEX5ZF.js} +94 -94
  61. package/dist/cli/{chunk-BL5Q5JY7.mjs → chunk-Y7QCMOGZ.mjs} +5 -5
  62. package/dist/cli/{chunk-7W53Y4VH.mjs → chunk-YOCEY4EI.mjs} +5 -5
  63. package/dist/cli/{chunk-JTYKW3UL.mjs → chunk-YVOYZPMY.mjs} +2 -2
  64. package/dist/cli/{chunk-A3D677RX.mjs → chunk-ZCKUNXXR.mjs} +1 -1
  65. package/dist/cli/{chunk-E26477MJ.js → chunk-ZDTPSVGF.js} +7 -7
  66. package/dist/cli/{csv-PLJNQPLE.js → csv-JGJNDRSA.js} +13 -13
  67. package/dist/cli/{csv-TELSH4ND.mjs → csv-VGXGV7YM.mjs} +4 -4
  68. package/dist/cli/{db-GISAU665.mjs → db-OYG27ZBM.mjs} +6 -6
  69. package/dist/cli/{db-QDJ6GWF5.js → db-W52WJ6E5.js} +27 -27
  70. package/dist/cli/{describe-F4K54VXB.mjs → describe-FIXCRO5N.mjs} +17 -17
  71. package/dist/cli/describe-G3O6OUBG.js +50 -0
  72. package/dist/cli/describe-core.d.mts +2 -2
  73. package/dist/cli/describe-core.d.ts +2 -2
  74. package/dist/cli/{executions-3QE7MRBG.mjs → executions-EVE4KUGL.mjs} +6 -6
  75. package/dist/cli/{executions-VKUTKQNN.js → executions-LAJHZGPY.js} +8 -8
  76. package/dist/cli/{feedback-JU7PJGDL.mjs → feedback-75QB7KVG.mjs} +4 -4
  77. package/dist/cli/{feedback-HH5AUYLA.js → feedback-ZABCN7RT.js} +8 -8
  78. package/dist/cli/git-QBAR46NW.js +25 -0
  79. package/dist/cli/{git-ACXH7K7D.mjs → git-QIFEYQGY.mjs} +5 -5
  80. package/dist/cli/index.js +137 -137
  81. package/dist/cli/index.mjs +40 -40
  82. package/dist/cli/{legacy-noops-NRPYJZOP.js → legacy-noops-2TBIAMCM.js} +8 -8
  83. package/dist/cli/{legacy-noops-IOAZ3YJ2.mjs → legacy-noops-PNTWBBGY.mjs} +5 -5
  84. package/dist/cli/{monitors-PMQUOIOI.mjs → monitors-LOHUYJEI.mjs} +7 -7
  85. package/dist/cli/{monitors-4SKMAAMR.js → monitors-UKBOEGBS.js} +91 -91
  86. package/dist/cli/{org-WJM7X6WB.js → org-E7A6QLBW.js} +72 -72
  87. package/dist/cli/{org-XNT3W6OU.mjs → org-JRUKUOUF.mjs} +6 -6
  88. package/dist/cli/{pages-WXY4GGZG.js → pages-EUDFFLLD.js} +17 -17
  89. package/dist/cli/{pages-Y3JKBS4B.mjs → pages-K76HA473.mjs} +6 -6
  90. package/dist/cli/{play-NPWWAQYK.mjs → play-DG2N66SV.mjs} +19 -18
  91. package/dist/cli/{play-NKSRPIAV.js → play-UWHNUJRA.js} +314 -313
  92. package/dist/cli/{providers-VNPJHXK5.js → providers-DZX6TTC6.js} +9 -9
  93. package/dist/cli/{providers-CUIKFE6F.mjs → providers-RUTTPUZD.mjs} +6 -6
  94. package/dist/cli/{quickstart-PJYPKFZI.mjs → quickstart-RGZZN2YE.mjs} +4 -4
  95. package/dist/cli/{quickstart-6OTS2HDR.js → quickstart-U4NMD7KX.js} +6 -6
  96. package/dist/cli/{run-2DLJBYFC.js → run-5UNF4FHG.js} +36 -36
  97. package/dist/cli/{run-AGX3EUK4.mjs → run-MOJWQYFQ.mjs} +22 -22
  98. package/dist/cli/search-3DAEJL6S.js +32 -0
  99. package/dist/cli/{search-DVIEJ2UQ.mjs → search-5B3ZDU7H.mjs} +7 -7
  100. package/dist/cli/{search-output-TXSIPSPS.mjs → search-output-QS4IWWHA.mjs} +4 -4
  101. package/dist/cli/{search-output-PFLNDCA7.js → search-output-VQWJS3FN.js} +6 -6
  102. package/dist/cli/{secrets-O5OQTFVD.js → secrets-S3PJMEAC.js} +15 -15
  103. package/dist/cli/{secrets-OAGXFXEX.mjs → secrets-V5XVDBIS.mjs} +6 -6
  104. package/dist/cli/{sessions-GBR5PGB6.mjs → sessions-5V3X24XI.mjs} +5 -5
  105. package/dist/cli/{sessions-WT7P3F73.js → sessions-Y5QMEZ3D.js} +6 -6
  106. package/dist/cli/{settings-U7UNDUDB.js → settings-3U6RRO5F.js} +78 -78
  107. package/dist/cli/{settings-KGNBIFOU.mjs → settings-LHZYY5PT.mjs} +11 -11
  108. package/dist/cli/{setup-PYWSU4YM.mjs → setup-AJLWXYAN.mjs} +9 -9
  109. package/dist/cli/{setup-4MZNDFKM.js → setup-MLLIGO2S.js} +49 -49
  110. package/dist/cli/{skills-7Y6OBM7Z.mjs → skills-5O2MUWKK.mjs} +7 -7
  111. package/dist/cli/skills-BBLIML5M.js +36 -0
  112. package/dist/cli/{tools-O7L435CR.mjs → tools-PWNMI5CD.mjs} +16 -16
  113. package/dist/cli/tools-X5SQXUMM.js +57 -0
  114. package/dist/cli/update-AEJ2ZSZQ.js +34 -0
  115. package/dist/cli/{update-SPHIBY5L.mjs → update-SXT4QW7S.mjs} +9 -9
  116. package/dist/cli/{workflow-GTDKPIEV.js → workflow-3WTF5IYT.js} +17 -17
  117. package/dist/cli/{workflow-ZRYO5J3K.mjs → workflow-KPRM6ARO.mjs} +7 -7
  118. package/dist/{client-D3hVHXjK.d.ts → client-Cb1ej1Vr.d.ts} +1 -1
  119. package/dist/{client-core-DUdVqO_m.d.ts → client-core-BmVs6SP0.d.ts} +72 -3
  120. package/dist/{client-core-BZoSMKcY.d.mts → client-core-CoBTvsXG.d.mts} +72 -3
  121. package/dist/{client-BkbDHRIg.d.mts → client-vWpbLNCB.d.mts} +1 -1
  122. package/dist/index.d.mts +3 -3
  123. package/dist/index.d.ts +3 -3
  124. package/dist/index.js +9 -9
  125. package/dist/index.mjs +6 -6
  126. package/dist/install-integrity.json +102 -102
  127. package/dist/plays/play-description.d.mts +1 -1
  128. package/dist/plays/play-description.d.ts +1 -1
  129. package/dist/plays/run-request.d.mts +1 -1
  130. package/dist/plays/run-request.d.ts +1 -1
  131. package/dist/release.d.mts +1 -1
  132. package/dist/release.d.ts +1 -1
  133. package/dist/release.js +2 -2
  134. package/dist/release.mjs +1 -1
  135. package/dist/server.d.mts +2 -2
  136. package/dist/server.d.ts +2 -2
  137. package/dist/server.js +5 -5
  138. package/dist/server.mjs +3 -3
  139. package/package.json +1 -1
  140. package/dist/cli/auth-AW34RGV5.js +0 -43
  141. package/dist/cli/describe-R6NVISAS.js +0 -50
  142. package/dist/cli/git-CXRU4CRW.js +0 -25
  143. package/dist/cli/search-Y7VFEFJJ.js +0 -32
  144. package/dist/cli/skills-BQC2323O.js +0 -36
  145. package/dist/cli/tools-732SZ4KV.js +0 -57
  146. package/dist/cli/update-PCYIUORM.js +0 -34
@@ -636,6 +636,8 @@ export type RunsGetOptions = {
636
636
  full?: boolean;
637
637
  /** Explicitly read this run's recorded graph and source, without full results. */
638
638
  configuration?: boolean;
639
+ /** Include terminal runtime diagnostics (`run.performance`) without full results. */
640
+ performance?: boolean;
639
641
  /** Attach a bounded end-of-stream window for a failed run. */
640
642
  failedLogs?: boolean;
641
643
  /** Requested failed-log lines to attach (default 20, hard-capped at 20). */
@@ -4631,7 +4633,10 @@ export class DeeplineClient {
4631
4633
  params.set('full', 'true');
4632
4634
  }
4633
4635
  if (options?.configuration === true) {
4634
- params.set('include', 'configuration');
4636
+ params.append('include', 'configuration');
4637
+ }
4638
+ if (options?.performance === true) {
4639
+ params.append('include', 'performance');
4635
4640
  }
4636
4641
  const query = params.size > 0 ? `?${params.toString()}` : '';
4637
4642
  const response = await this.http.get<Record<string, unknown>>(
@@ -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.490',
208
+ version: '0.3.492',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -920,7 +920,10 @@ export interface PlayRunPackage {
920
920
  sourceRunId?: string;
921
921
  };
922
922
  error?: string;
923
- /** Accepted terminal invocation only; absent on older/unsupported runtimes. */
923
+ /**
924
+ * Accepted terminal invocation only, on full reads or `include=performance`.
925
+ * Absent on older/unsupported runtimes.
926
+ */
924
927
  performance?: TerminalRuntimePerformance;
925
928
  performanceUnavailableReason?: TerminalRuntimePerformanceUnavailableReason;
926
929
  /** Canonical explanation of what this run is doing or waiting on. */
@@ -316,6 +316,15 @@ export const OPERATIONS_QUEUE_CATALOG = [
316
316
  60_000,
317
317
  300_000,
318
318
  ),
319
+ queue(
320
+ 'inbound-demo-sales',
321
+ 'Inbound demo sales notifications',
322
+ 'leased_workset',
323
+ 'inbound-demo',
324
+ 'Log form submissions and prepare one-hour follow-up drafts for review',
325
+ 3_720_000,
326
+ 3_900_000,
327
+ ),
319
328
  queue(
320
329
  'usage-rollup-fold',
321
330
  'Usage rollup fold',
@@ -288,6 +288,7 @@ export const QUEUE_CONNECTOR_BACKENDS: Readonly<
288
288
  'async-usage-recovery': 'postgres-outbox',
289
289
  'notification-deliveries': 'workpool',
290
290
  'inbound-demo-form-submissions': 'convex',
291
+ 'inbound-demo-sales': 'convex',
291
292
  'usage-rollup-fold': 'postgres-outbox',
292
293
  'play-deployment-jobs': 'workpool',
293
294
  'github-runner-wait': 'provider',
@@ -1648,6 +1648,24 @@
1648
1648
  "failureAlert": "convex_action_wrapper",
1649
1649
  "domainReportRequired": true
1650
1650
  },
1651
+ {
1652
+ "id": "convex.inbound-demo-sales",
1653
+ "name": "Inbound demo sales notifications",
1654
+ "scheduler": "convex_scheduled_action",
1655
+ "cadence": "on demand at form submission and one hour later",
1656
+ "timezone": "UTC",
1657
+ "source": "packages/convex/scheduledJobsNode.ts",
1658
+ "locator": "deliverInboundSalesTask",
1659
+ "owner": "inbound-demo",
1660
+ "criticality": "reporting",
1661
+ "purpose": "Log demo submissions and prepare unbooked follow-up drafts in Slack.",
1662
+ "successDefinition": "Slack delivery is confirmed or the task is suppressed for a booked meeting or a non-production environment.",
1663
+ "failureDefinition": "Booking verification, Slack delivery, or durable settlement fails.",
1664
+ "startGraceMs": 120000,
1665
+ "runTimeoutMs": 120000,
1666
+ "failureAlert": "convex_action_wrapper",
1667
+ "domainReportRequired": true
1668
+ },
1651
1669
  {
1652
1670
  "id": "convex.customer-db-preparation",
1653
1671
  "name": "Customer DB preparation",
@@ -59,10 +59,12 @@ export const RUNTIME_RECEIPT_CONTROL_BUFFER_MAX_ITEMS = 2_000;
59
59
  */
60
60
  export const RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES = 16 * 1024 * 1024;
61
61
  /**
62
- * Oversized sheet admissions use bounded requests with room for returned row
63
- * metadata. A single row may exceed this target, up to the unchanged gateway
64
- * body ceiling; the target is never a new customer input-value limit.
62
+ * Stable-intent sheet admission responses include row details, so input bytes
63
+ * alone do not bound response size. Use a conservative row page size and
64
+ * split further when the gateway reports that the decoded response is too
65
+ * large. This is transport paging, not a customer input or output limit.
65
66
  */
67
+ export const RUNTIME_SHEET_START_MAX_RESPONSE_ROWS = 64;
66
68
  export const RUNTIME_SHEET_START_TARGET_BODY_BYTES = 12 * 1024 * 1024;
67
69
  /**
68
70
  * Receipt commands are measured before the runtime client adds its request
@@ -185,6 +185,7 @@ import { BoundedBatchFunction } from './bounded-batch-function';
185
185
  import {
186
186
  jsonByteLengthUpTo,
187
187
  RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES,
188
+ RUNTIME_SHEET_START_MAX_RESPONSE_ROWS,
188
189
  RUNTIME_SHEET_START_TARGET_BODY_BYTES,
189
190
  } from './output-size-limits';
190
191
  import {
@@ -876,11 +877,54 @@ function normalizeRuntimeUserEmail(
876
877
  return email ? email : null;
877
878
  }
878
879
 
880
+ export const RUNTIME_SHEET_START_INSERTED_COUNT_HEADER =
881
+ 'x-deepline-runtime-sheet-start-inserted';
882
+ export const RUNTIME_SHEET_START_SKIPPED_COUNT_HEADER =
883
+ 'x-deepline-runtime-sheet-start-skipped';
884
+
885
+ type RuntimeSheetStartAdmissionCounts = {
886
+ inserted: number;
887
+ skipped: number;
888
+ };
889
+
890
+ function readRuntimeSheetStartAdmissionCounts(
891
+ response: Response,
892
+ action: RuntimeApiActionRequest['action'],
893
+ ): RuntimeSheetStartAdmissionCounts | undefined {
894
+ if (action !== 'runtime_sheet_start_with_intent') return undefined;
895
+ const insertedHeader = response.headers.get(
896
+ RUNTIME_SHEET_START_INSERTED_COUNT_HEADER,
897
+ );
898
+ const skippedHeader = response.headers.get(
899
+ RUNTIME_SHEET_START_SKIPPED_COUNT_HEADER,
900
+ );
901
+ if (
902
+ insertedHeader === null ||
903
+ skippedHeader === null ||
904
+ !/^\d+$/.test(insertedHeader) ||
905
+ !/^\d+$/.test(skippedHeader)
906
+ ) {
907
+ return undefined;
908
+ }
909
+ const inserted = Number(insertedHeader);
910
+ const skipped = Number(skippedHeader);
911
+ if (
912
+ !Number.isSafeInteger(inserted) ||
913
+ inserted < 0 ||
914
+ !Number.isSafeInteger(skipped) ||
915
+ skipped < 0
916
+ ) {
917
+ return undefined;
918
+ }
919
+ return { inserted, skipped };
920
+ }
921
+
879
922
  class RuntimeApiResponseTooLargeError extends Error {
880
923
  constructor(
881
924
  readonly action: RuntimeApiActionRequest['action'],
882
925
  readonly limitBytes: number,
883
926
  readonly observedBytes: number,
927
+ readonly admissionCounts?: RuntimeSheetStartAdmissionCounts,
884
928
  ) {
885
929
  super(
886
930
  `Runtime API ${action} response exceeds the ${limitBytes} byte decoded-body budget (observed at least ${observedBytes} bytes).`,
@@ -911,6 +955,7 @@ async function readRuntimeApiResponseJson(input: {
911
955
  input.action,
912
956
  limitBytes,
913
957
  declaredLength,
958
+ readRuntimeSheetStartAdmissionCounts(input.response, input.action),
914
959
  );
915
960
  }
916
961
  if (!input.response.body) return null;
@@ -928,6 +973,7 @@ async function readRuntimeApiResponseJson(input: {
928
973
  input.action,
929
974
  limitBytes,
930
975
  nextBytes,
976
+ readRuntimeSheetStartAdmissionCounts(input.response, input.action),
931
977
  );
932
978
  }
933
979
  chunks.push(value);
@@ -7452,6 +7498,89 @@ function runtimeSheetStartRequestBytes(input: {
7452
7498
  return { bytes: measurement.bytes, exceeded: measurement.exceeded };
7453
7499
  }
7454
7500
 
7501
+ type RuntimeSheetAdmissionPageRunner = (
7502
+ operation: () => Promise<PrepareRuntimeSheetResult>,
7503
+ ) => Promise<PrepareRuntimeSheetResult>;
7504
+
7505
+ async function postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7506
+ context: RuntimeApiContext,
7507
+ input: RuntimeSheetDatasetStartInput,
7508
+ runPage: RuntimeSheetAdmissionPageRunner = (operation) => operation(),
7509
+ ): Promise<PrepareRuntimeSheetResult[]> {
7510
+ const request: RuntimeApiActionRequest = {
7511
+ action:
7512
+ input.stableWriteIntent === true
7513
+ ? 'runtime_sheet_start_with_intent'
7514
+ : 'runtime_sheet_start',
7515
+ input: { ...input, playInput: undefined, pendingRerunAdmission: true },
7516
+ };
7517
+ const preparedBodyJson = JSON.stringify(
7518
+ prepareRetainedPlayPipelinesForTransport(request),
7519
+ );
7520
+ try {
7521
+ return [
7522
+ await runPage(() =>
7523
+ postRuntimeApi<PrepareRuntimeSheetResult>(
7524
+ context,
7525
+ request,
7526
+ preparedBodyJson,
7527
+ ),
7528
+ ),
7529
+ ];
7530
+ } catch (error) {
7531
+ if (
7532
+ !(error instanceof RuntimeApiResponseTooLargeError) ||
7533
+ error.action !== 'runtime_sheet_start_with_intent' ||
7534
+ input.stableWriteIntent !== true ||
7535
+ !error.admissionCounts ||
7536
+ input.rows.length <= 1
7537
+ ) {
7538
+ throw error;
7539
+ }
7540
+
7541
+ // The gateway committed this stable intent before its oversized response
7542
+ // reached the runner. Replay the same attempt in smaller row groups; the
7543
+ // persisted identity makes these admissions idempotent, and the response
7544
+ // headers preserve the counts from the committed full-page operation.
7545
+ const splitAt = Math.floor(input.rows.length / 2);
7546
+ const inputOffset = Math.max(0, Math.floor(input.inputOffset ?? 0));
7547
+ const left = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7548
+ context,
7549
+ { ...input, rows: input.rows.slice(0, splitAt) },
7550
+ runPage,
7551
+ );
7552
+ const leftLast = left.at(-1);
7553
+ if (!leftLast) {
7554
+ throw new Error('Runtime sheet response split produced no left page.');
7555
+ }
7556
+ const right = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7557
+ context,
7558
+ {
7559
+ ...input,
7560
+ inputOffset: inputOffset + splitAt,
7561
+ ...(leftLast.writeVersion != null
7562
+ ? { writeVersion: leftLast.writeVersion }
7563
+ : {}),
7564
+ rows: input.rows.slice(splitAt),
7565
+ },
7566
+ runPage,
7567
+ );
7568
+ const results = [...left, ...right];
7569
+ const [first, ...rest] = results;
7570
+ if (!first) {
7571
+ throw new Error('Runtime sheet response split produced no pages.');
7572
+ }
7573
+ return [
7574
+ {
7575
+ ...first,
7576
+ inserted: error.admissionCounts.inserted,
7577
+ skipped: error.admissionCounts.skipped,
7578
+ },
7579
+ ...rest.map((result) => ({ ...result, inserted: 0, skipped: 0 })),
7580
+ ];
7581
+ }
7582
+ }
7583
+
7455
7584
  async function startRuntimeSheetDatasetViaGateway(
7456
7585
  context: RuntimeApiContext,
7457
7586
  input: RuntimeSheetDatasetStartInput,
@@ -7467,98 +7596,127 @@ async function startRuntimeSheetDatasetViaGateway(
7467
7596
  // that duplicate payload from both sizing and every actual page request.
7468
7597
  input: { ...pageInput, playInput: undefined, pendingRerunAdmission: true },
7469
7598
  });
7470
- const completeRequest = request(input);
7471
- if (
7472
- !runtimeSheetStartRequestBytes({
7473
- request: completeRequest,
7474
- limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7475
- }).exceeded
7476
- ) {
7477
- return await postRuntimeApi<PrepareRuntimeSheetResult>(
7478
- context,
7479
- completeRequest,
7480
- );
7481
- }
7482
-
7483
7599
  const requestInput: RuntimeSheetDatasetStartInput = {
7484
7600
  ...input,
7485
- attemptId: input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7601
+ ...(input.stableWriteIntent === true
7602
+ ? {
7603
+ attemptId:
7604
+ input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7605
+ }
7606
+ : {}),
7486
7607
  pendingRerunAdmission: true,
7487
7608
  };
7488
- // Keep every page under the app-function ingress ceiling while preserving
7489
- // the stable write intent, rerun admission, and attempt fence.
7609
+ const completeRequest = request(requestInput);
7610
+ const pageResults: PrepareRuntimeSheetResult[] = [];
7611
+ const startedAt = Date.now();
7612
+ const requestBodyFits = !runtimeSheetStartRequestBytes({
7613
+ request: completeRequest,
7614
+ limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7615
+ }).exceeded;
7616
+ const shouldPage =
7617
+ (input.stableWriteIntent === true &&
7618
+ input.rows.length > RUNTIME_SHEET_START_MAX_RESPONSE_ROWS) ||
7619
+ !requestBodyFits;
7620
+ const pageRequestInput: RuntimeSheetDatasetStartInput =
7621
+ shouldPage && input.stableWriteIntent !== true
7622
+ ? {
7623
+ ...requestInput,
7624
+ attemptId:
7625
+ input.attemptId?.trim() || runtimeSheetStartIntentId(input),
7626
+ }
7627
+ : requestInput;
7490
7628
  const inputOffset = Math.max(0, Math.floor(input.inputOffset ?? 0));
7491
7629
  const continuationInput: RuntimeSheetDatasetStartInput = {
7492
- ...requestInput,
7630
+ ...pageRequestInput,
7493
7631
  inputOffset,
7494
7632
  rows: [],
7495
7633
  };
7496
- const emptyRequestBytes = runtimeSheetStartRequestBytes({
7497
- request: request(continuationInput),
7498
- limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7499
- });
7500
- if (emptyRequestBytes.exceeded) {
7501
- throw new Error(
7502
- `Runtime sheet start metadata exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget before row data is included.`,
7503
- );
7504
- }
7505
- // Leave space for fields returned by the first page and sent on continuation.
7506
- const rowPageBudgetBytes =
7507
- RUNTIME_SHEET_START_REQUEST_MAX_BYTES - emptyRequestBytes.bytes - 4 * 1024;
7508
- if (rowPageBudgetBytes < 1) {
7509
- throw new Error(
7510
- 'Runtime sheet start metadata leaves no room for a row in the app request budget.',
7634
+ if (!shouldPage) {
7635
+ pageResults.push(
7636
+ ...(await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7637
+ context,
7638
+ requestInput,
7639
+ )),
7511
7640
  );
7512
- }
7513
-
7514
- const pageResults: PrepareRuntimeSheetResult[] = [];
7515
- let pageInput = continuationInput;
7516
- const startedAt = Date.now();
7517
- for await (const page of iteratePlayDatasetInputPages(input.rows, {
7518
- maxPageBytes: rowPageBudgetBytes,
7519
- estimateRowBytes: (row) => {
7520
- const measured = jsonByteLengthUpTo(
7521
- row,
7522
- RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7523
- );
7524
- return measured.bytes + 1;
7525
- },
7526
- })) {
7527
- const nextInput: RuntimeSheetDatasetStartInput = {
7528
- ...pageInput,
7529
- rows: page.rows,
7530
- inputOffset: inputOffset + page.offset,
7531
- };
7532
- const pageRequest = request(nextInput);
7533
- const pageBytes = runtimeSheetStartRequestBytes({
7534
- request: pageRequest,
7641
+ } else {
7642
+ // Keep every page under the app-function ingress ceiling while preserving
7643
+ // the stable write intent, rerun admission, and attempt fence.
7644
+ const emptyRequestBytes = runtimeSheetStartRequestBytes({
7645
+ request: request(continuationInput),
7535
7646
  limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7536
7647
  });
7537
- if (pageBytes.exceeded) {
7648
+ if (emptyRequestBytes.exceeded) {
7538
7649
  throw new Error(
7539
- `A runtime sheet start page exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget.`,
7650
+ `Runtime sheet start metadata exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget before row data is included.`,
7540
7651
  );
7541
7652
  }
7542
- const result = await postRuntimeApi<PrepareRuntimeSheetResult>(
7543
- context,
7544
- pageRequest,
7545
- );
7546
- pageResults.push(result);
7547
- pageInput = {
7548
- ...nextInput,
7549
- attemptId: result.attemptId ?? nextInput.attemptId,
7550
- attemptOwnerRunId:
7551
- result.attemptOwnerRunId ?? nextInput.attemptOwnerRunId,
7552
- attemptExpiresAt: result.attemptExpiresAt ?? nextInput.attemptExpiresAt,
7553
- attemptSeq: result.attemptSeq ?? nextInput.attemptSeq,
7554
- writeVersion: result.writeVersion ?? nextInput.writeVersion,
7555
- };
7653
+ // Leave space for fields returned by the first page and sent on continuation.
7654
+ const rowPageBudgetBytes =
7655
+ RUNTIME_SHEET_START_REQUEST_MAX_BYTES -
7656
+ emptyRequestBytes.bytes -
7657
+ 4 * 1024;
7658
+ if (rowPageBudgetBytes < 1) {
7659
+ throw new Error(
7660
+ 'Runtime sheet start metadata leaves no room for a row in the app request budget.',
7661
+ );
7662
+ }
7663
+
7664
+ let pageInput = continuationInput;
7665
+ for await (const page of iteratePlayDatasetInputPages(input.rows, {
7666
+ ...(input.stableWriteIntent === true
7667
+ ? { pageSize: RUNTIME_SHEET_START_MAX_RESPONSE_ROWS }
7668
+ : {}),
7669
+ maxPageBytes: rowPageBudgetBytes,
7670
+ estimateRowBytes: (row) => {
7671
+ const measured = jsonByteLengthUpTo(
7672
+ row,
7673
+ RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7674
+ );
7675
+ return measured.bytes + 1;
7676
+ },
7677
+ })) {
7678
+ const nextInput: RuntimeSheetDatasetStartInput = {
7679
+ ...pageInput,
7680
+ rows: page.rows,
7681
+ inputOffset: inputOffset + page.offset,
7682
+ };
7683
+ const pageRequest = request(nextInput);
7684
+ const pageBytes = runtimeSheetStartRequestBytes({
7685
+ request: pageRequest,
7686
+ limitBytes: RUNTIME_SHEET_START_REQUEST_MAX_BYTES,
7687
+ });
7688
+ if (pageBytes.exceeded) {
7689
+ throw new Error(
7690
+ `A runtime sheet start page exceeds the ${RUNTIME_SHEET_START_REQUEST_MAX_BYTES}-byte app request budget.`,
7691
+ );
7692
+ }
7693
+ const results = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7694
+ context,
7695
+ nextInput,
7696
+ );
7697
+ pageResults.push(...results);
7698
+ const result = results.at(-1);
7699
+ if (!result) {
7700
+ throw new Error('Runtime sheet start page returned no result.');
7701
+ }
7702
+ pageInput = {
7703
+ ...nextInput,
7704
+ attemptId: result.attemptId ?? nextInput.attemptId,
7705
+ attemptOwnerRunId:
7706
+ result.attemptOwnerRunId ?? nextInput.attemptOwnerRunId,
7707
+ attemptExpiresAt: result.attemptExpiresAt ?? nextInput.attemptExpiresAt,
7708
+ attemptSeq: result.attemptSeq ?? nextInput.attemptSeq,
7709
+ writeVersion: result.writeVersion ?? nextInput.writeVersion,
7710
+ };
7711
+ }
7556
7712
  }
7557
7713
 
7558
7714
  if (pageResults.length === 0) {
7559
- return await postRuntimeApi<PrepareRuntimeSheetResult>(
7560
- context,
7561
- request(continuationInput),
7715
+ pageResults.push(
7716
+ ...(await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
7717
+ context,
7718
+ continuationInput,
7719
+ )),
7562
7720
  );
7563
7721
  }
7564
7722
  if (pageResults.length === 1) return pageResults[0]!;
@@ -7716,6 +7874,11 @@ export async function* startRuntimeSheetDatasetPages(
7716
7874
  pendingRerunAdmission: true,
7717
7875
  }),
7718
7876
  ) as RuntimeSheetStartMetadata;
7877
+ if (input.stableWriteIntent === true) {
7878
+ frozenMetadata.attemptId = normalizeRuntimeSheetAttemptId(
7879
+ frozenMetadata.attemptId ?? runtimeSheetStartIntentId(input),
7880
+ );
7881
+ }
7719
7882
  const tableNamespace = frozenMetadata.tableNamespace;
7720
7883
  const includePreviousCells = frozenMetadata.includePreviousCells === true;
7721
7884
  const previousCellsBudgetBytes = frozenMetadata.previousCellsBudgetBytes;
@@ -7739,7 +7902,11 @@ export async function* startRuntimeSheetDatasetPages(
7739
7902
  ) + rowBytes;
7740
7903
  const pages: RuntimeSheetStartTransportPage[] = [];
7741
7904
  let duplicateRows = 0;
7742
- if (fullBytes <= RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES) {
7905
+ if (
7906
+ fullBytes <= RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES &&
7907
+ (input.stableWriteIntent !== true ||
7908
+ rowsJson.length <= RUNTIME_SHEET_START_MAX_RESPONSE_ROWS)
7909
+ ) {
7743
7910
  // Keep every previously transportable admission as one transaction, with
7744
7911
  // its existing receiver-side deduplication and optional response fields.
7745
7912
  pages.push({ rowsJson });
@@ -7815,6 +7982,14 @@ export async function* startRuntimeSheetDatasetPages(
7815
7982
  if (page.rowsJson.length === 0) page.inputOffset = inputOffset + index;
7816
7983
  pageBytes += bytes + (page.rowsJson.length > 0 ? 1 : 0);
7817
7984
  page.rowsJson.push(serialized);
7985
+ if (
7986
+ input.stableWriteIntent === true &&
7987
+ page.rowsJson.length >= RUNTIME_SHEET_START_MAX_RESPONSE_ROWS
7988
+ ) {
7989
+ pages.push(page);
7990
+ page = { rowsJson: [] };
7991
+ pageBytes = framingBytes;
7992
+ }
7818
7993
  }
7819
7994
  if (page.rowsJson.length > 0) pages.push(page);
7820
7995
  if (pages.length === 0) {
@@ -7826,7 +8001,8 @@ export async function* startRuntimeSheetDatasetPages(
7826
8001
 
7827
8002
  let writeVersion = frozenMetadata.writeVersion;
7828
8003
  let membershipCapture: boolean | undefined;
7829
- for (const [index, page] of pages.entries()) {
8004
+ let admittedPageCount = 0;
8005
+ for (const page of pages) {
7830
8006
  const pageMetadata = {
7831
8007
  ...frozenMetadata,
7832
8008
  ...(page.inputOffset !== undefined
@@ -7847,47 +8023,54 @@ export async function* startRuntimeSheetDatasetPages(
7847
8023
  'Runtime sheet start page exceeded its preflight body budget.',
7848
8024
  );
7849
8025
  }
7850
- const request = JSON.parse(preparedBodyJson) as Extract<
7851
- RuntimeApiActionRequest,
7852
- { action: RuntimeSheetStartAction }
7853
- >;
7854
- const result = await runPage(() =>
7855
- postRuntimeApi<PrepareRuntimeSheetResult>(
7856
- context,
7857
- request,
7858
- preparedBodyJson,
8026
+ const pageInput: RuntimeSheetDatasetStartInput = {
8027
+ ...pageMetadata,
8028
+ rows: page.rowsJson.map(
8029
+ (serialized) => JSON.parse(serialized) as Record<string, unknown>,
7859
8030
  ),
8031
+ };
8032
+ const results = await postRuntimeSheetStartPageWithAdaptiveResponseLimit(
8033
+ context,
8034
+ pageInput,
8035
+ runPage,
7860
8036
  );
7861
8037
  page.rowsJson.length = 0;
7862
- if (includePreviousCells) {
7863
- assertDatasetAdmissionHistory(result, previousCellsBudgetBytes);
7864
- }
7865
- if (pages.length > 1) {
7866
- const admittedVersion = result.writeVersion;
8038
+ for (const result of results) {
8039
+ if (includePreviousCells) {
8040
+ assertDatasetAdmissionHistory(result, previousCellsBudgetBytes);
8041
+ }
7867
8042
  if (
7868
- typeof admittedVersion !== 'number' ||
7869
- !Number.isSafeInteger(admittedVersion) ||
7870
- admittedVersion <= 0 ||
7871
- (writeVersion != null && result.writeVersion !== writeVersion) ||
7872
- normalizeTableNamespace(result.tableNamespace) !==
7873
- normalizeTableNamespace(tableNamespace) ||
7874
- (result.attemptId !== undefined &&
7875
- result.attemptId !== frozenMetadata.attemptId) ||
7876
- (result.attemptOwnerRunId !== undefined &&
7877
- result.attemptOwnerRunId !== attemptOwnerRunId) ||
7878
- (result.attemptSeq !== undefined && result.attemptSeq !== attemptSeq) ||
7879
- (index > 0 && result.membershipCapture !== membershipCapture)
8043
+ (input.stableWriteIntent === true || pages.length > 1) &&
8044
+ admittedPageCount > 0
7880
8045
  ) {
7881
- throw new Error(
7882
- 'Runtime sheet admission pages disagree on their write intent or identity.',
7883
- );
8046
+ const admittedVersion = result.writeVersion;
8047
+ if (
8048
+ typeof admittedVersion !== 'number' ||
8049
+ !Number.isSafeInteger(admittedVersion) ||
8050
+ admittedVersion <= 0 ||
8051
+ (writeVersion != null && result.writeVersion !== writeVersion) ||
8052
+ normalizeTableNamespace(result.tableNamespace) !==
8053
+ normalizeTableNamespace(tableNamespace) ||
8054
+ (result.attemptId !== undefined &&
8055
+ result.attemptId !== frozenMetadata.attemptId) ||
8056
+ (result.attemptOwnerRunId !== undefined &&
8057
+ result.attemptOwnerRunId !== attemptOwnerRunId) ||
8058
+ (result.attemptSeq !== undefined &&
8059
+ result.attemptSeq !== attemptSeq) ||
8060
+ result.membershipCapture !== membershipCapture
8061
+ ) {
8062
+ throw new Error(
8063
+ 'Runtime sheet admission pages disagree on their write intent or identity.',
8064
+ );
8065
+ }
7884
8066
  }
7885
- writeVersion = result.writeVersion;
8067
+ if (result.writeVersion != null) writeVersion = result.writeVersion;
8068
+ membershipCapture = result.membershipCapture;
8069
+ admittedPageCount += 1;
8070
+ yield admittedPageCount === 1 && duplicateRows > 0
8071
+ ? { ...result, skipped: result.skipped + duplicateRows }
8072
+ : result;
7886
8073
  }
7887
- membershipCapture = result.membershipCapture;
7888
- yield index === 0 && duplicateRows > 0
7889
- ? { ...result, skipped: result.skipped + duplicateRows }
7890
- : result;
7891
8074
  }
7892
8075
  }
7893
8076