deepline 0.3.127 → 0.3.129

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 (128) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +34 -9
  2. package/dist/bundling-sources/sdk/src/http.ts +22 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +22 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +265 -2
  6. package/dist/bundling-sources/shared_libs/play-runtime/bounded-batch-function.ts +682 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +21 -5
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +5390 -1732
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +107 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +7 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +229 -7
  12. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +25 -4
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-capacity.ts +71 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +1 -1
  15. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +4 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +694 -28
  17. package/dist/bundling-sources/shared_libs/play-runtime/egress-bandwidth-probe.ts +167 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +103 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-receipt-output-reference.ts +34 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-response-size.ts +27 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +66 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +425 -71
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +210 -32
  24. package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +27 -13
  25. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +19 -6
  26. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +61 -2
  27. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +33 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +42 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +11 -11
  30. package/dist/bundling-sources/shared_libs/play-runtime/ledger-safe-payload.ts +49 -16
  31. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +1653 -98
  32. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +807 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/memory-pressure-signal.ts +138 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +85 -3
  35. package/dist/bundling-sources/shared_libs/play-runtime/persistence-latch.ts +60 -2
  36. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +46 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +2 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +1 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +1 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +1 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +70 -27
  42. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +56 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/adaptive-provider-capacity-controller.ts +192 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/epoch-aimd-rate-controller.ts +194 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +220 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +214 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +43 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +30 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-rate-policy.ts +95 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-throttle-classifier.ts +40 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +1535 -11
  52. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +49 -2
  53. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +6 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +55 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/egress-probe.ts +221 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +339 -29
  57. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +28 -1
  58. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +192 -165
  59. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +6 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +90 -5
  61. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +281 -6
  62. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +27 -1
  63. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +19 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +108 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +40 -0
  66. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +11 -5
  67. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +30 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +276 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +723 -115
  70. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +98 -2
  71. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +3 -2
  72. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +41 -4
  73. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +448 -0
  74. package/dist/bundling-sources/shared_libs/play-runtime/runtime-map-row-feed.ts +215 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +11 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +161 -14
  77. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-value.ts +184 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +607 -121
  79. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +4 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +21 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +15 -2
  82. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +71 -14
  83. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +2 -2
  84. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +288 -119
  85. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +8 -6
  86. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +28 -3
  87. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/canonical-integration-operation-store.ts +179 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +80 -2
  89. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +31 -2
  90. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-store-contract.ts +104 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-reference.ts +47 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-retirement.ts +193 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +420 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +41 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +134 -3
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +1657 -95
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +885 -73
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-completion-coalescer.ts +452 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +601 -42
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +1 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +371 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +86 -7
  103. package/dist/bundling-sources/shared_libs/play-runtime/secret-redaction.ts +153 -22
  104. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +1 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +188 -38
  106. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +28 -13
  107. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +44 -1
  108. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +56 -4
  109. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +2 -0
  110. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +16 -10
  111. package/dist/bundling-sources/shared_libs/plays/dataset.ts +4 -1
  112. package/dist/cli/index.js +254 -38
  113. package/dist/cli/index.mjs +254 -38
  114. package/dist/{compiler-manifest-DfSnbCTW.d.mts → compiler-manifest-BIqRyj5m.d.mts} +1 -1
  115. package/dist/{compiler-manifest-DfSnbCTW.d.ts → compiler-manifest-BIqRyj5m.d.ts} +1 -1
  116. package/dist/index.d.mts +4 -2
  117. package/dist/index.d.ts +4 -2
  118. package/dist/index.js +231 -35
  119. package/dist/index.mjs +231 -35
  120. package/dist/install-integrity.json +31 -2
  121. package/dist/plays/bundle-play-file.d.mts +2 -2
  122. package/dist/plays/bundle-play-file.d.ts +2 -2
  123. package/dist/plays/bundle-play-file.mjs +65 -1
  124. package/dist/release.d.mts +1 -1
  125. package/dist/release.d.ts +1 -1
  126. package/dist/release.js +1 -1
  127. package/dist/release.mjs +1 -1
  128. package/package.json +1 -1
@@ -59,6 +59,7 @@ import {
59
59
  providerMetaFromToolResponseRawV2,
60
60
  type ToolResponseView,
61
61
  } from '../plays/tool-response-contract';
62
+ import type { RuntimeReceiptValueReference } from './runtime-receipt-value';
62
63
 
63
64
  type PathSegment = string | number | '*';
64
65
 
@@ -69,9 +70,48 @@ const SERIALIZED_TOOL_EXECUTE_RESULT_V2_KIND =
69
70
  const SERIALIZED_TOOL_RESULT_LIST_PREVIEW_LIMIT = 5;
70
71
  const LIVE_TOOL_RESULT_LIST_DATASET_REGISTRY_LIMIT = 256;
71
72
  const SERIALIZED_TOOL_LIST_ROWS = Symbol('deepline.serialized_tool_list_rows');
73
+
74
+ /**
75
+ * A live tool result may have been durably published by the execution relay
76
+ * before the runner sees its provider body. Keep that transport-only fact out
77
+ * of the public ToolExecuteResult and its persisted schema: the caller still
78
+ * receives the ordinary fully materialized result, while receipt publication
79
+ * can use the compact immutable R2 reference.
80
+ */
81
+ const relayPublishedResultReferences = new WeakMap<
82
+ object,
83
+ RuntimeReceiptValueReference
84
+ >();
85
+
86
+ export function attachRelayPublishedToolResultReference(
87
+ result: ToolExecuteResult,
88
+ reference: RuntimeReceiptValueReference,
89
+ ): ToolExecuteResult {
90
+ relayPublishedResultReferences.set(result, reference);
91
+ return result;
92
+ }
93
+
94
+ export function relayPublishedToolResultReference(
95
+ result: ToolExecuteResult,
96
+ ): RuntimeReceiptValueReference | null {
97
+ return relayPublishedResultReferences.get(result) ?? null;
98
+ }
99
+ /**
100
+ * This registry is a same-process rehydration fast path, not an owner of a
101
+ * tool result. A strong process-global cache retained the full rows behind up
102
+ * to 256 otherwise-discarded list results. At map scale, a caller that only
103
+ * awaits `ctx.tools.execute()` could therefore keep hundreds of provider
104
+ * bodies alive after its cell had returned.
105
+ *
106
+ * The ToolExecuteResult that owns a live list already strongly owns its
107
+ * accessor and dataset. A weak lookup keeps the fast path while that result is
108
+ * still reachable, but lets the runtime release a result the authored Play no
109
+ * longer uses. Durable serialization still carries its normal list rows or
110
+ * preview, so a collected entry falls back to the existing durable path.
111
+ */
72
112
  const liveToolResultListDatasets = new Map<
73
113
  string,
74
- PlayDataset<Record<string, unknown>>
114
+ WeakRef<PlayDataset<Record<string, unknown>>>
75
115
  >();
76
116
 
77
117
  /**
@@ -229,6 +269,12 @@ export type ParsedToolExecuteResponse = {
229
269
  result: unknown;
230
270
  /** Tool extractor metadata parsed from `_metadata.tool`, if present. */
231
271
  metadata: ToolResultMetadataInput | null;
272
+ /**
273
+ * Transport-only reference attached by the trusted execution relay after it
274
+ * persisted the complete serialized result. The raw response still remains
275
+ * present for ordinary live Play evaluation.
276
+ */
277
+ receiptOutputRef?: RuntimeReceiptValueReference;
232
278
  };
233
279
 
234
280
  export function parseToolExecuteResponse(
@@ -1473,7 +1519,7 @@ function rememberLiveToolResultListDataset(
1473
1519
  ): void {
1474
1520
  if (!datasetId) return;
1475
1521
  liveToolResultListDatasets.delete(datasetId);
1476
- liveToolResultListDatasets.set(datasetId, dataset);
1522
+ liveToolResultListDatasets.set(datasetId, new WeakRef(dataset));
1477
1523
  while (
1478
1524
  liveToolResultListDatasets.size >
1479
1525
  LIVE_TOOL_RESULT_LIST_DATASET_REGISTRY_LIMIT
@@ -1487,8 +1533,14 @@ function rememberLiveToolResultListDataset(
1487
1533
  function readLiveToolResultListDataset(
1488
1534
  serialized: SerializedPlayDataset<Record<string, unknown>>,
1489
1535
  ): PlayDataset<Record<string, unknown>> | null {
1490
- const dataset = liveToolResultListDatasets.get(serialized.datasetId);
1491
- if (!dataset) return null;
1536
+ const reference = liveToolResultListDatasets.get(serialized.datasetId);
1537
+ const dataset = reference?.deref();
1538
+ if (!dataset) {
1539
+ // Keep the small key registry honest too. A dead weak entry is not useful
1540
+ // to a later deserialize and must not consume one of the LRU slots.
1541
+ liveToolResultListDatasets.delete(serialized.datasetId);
1542
+ return null;
1543
+ }
1492
1544
  const current = dataset.toJSON();
1493
1545
  if (current.count !== serialized.count) return null;
1494
1546
  return dataset;
@@ -43,6 +43,8 @@ export function workReceiptFailureKindCodeForWrite(
43
43
 
44
44
  export type WorkReceipt = {
45
45
  key: string;
46
+ /** Completion acknowledgement only: whether this request published the output. */
47
+ completionDisposition?: 'persisted' | 'existing';
46
48
  status: WorkReceiptStatus;
47
49
  output?: unknown;
48
50
  error?: string | null;
@@ -7,18 +7,17 @@ import type { ToolExecutionErrorSchemaVersion } from './tool-execution-error';
7
7
  import type { PlayDataset, PlayDatasetInput, PlayDatasetRow } from './dataset';
8
8
 
9
9
  export const LEGACY_PLAY_AUTHORING_CONTRACT_EDITION = 1 as const;
10
- export const PLAY_AUTHORING_CONTRACT_EDITION = 7 as const;
10
+ export const PLAY_AUTHORING_CONTRACT_EDITION = 8 as const;
11
11
  export const PLAY_AUTHORING_INPUT_SCHEMA_SNAPSHOT_EDITION = 3 as const;
12
12
  export const SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS = [
13
- 1, 2, 3, 4, 5, 6, 7,
13
+ 1, 2, 3, 4, 5, 6, 7, 8,
14
14
  ] as const;
15
15
 
16
16
  export type PlayAuthoringContractEdition =
17
17
  (typeof SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS)[number];
18
18
 
19
- export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
19
+ const PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS = [
20
20
  {
21
- edition: 1,
22
21
  changed:
23
22
  'Historical extraction semantics. Invalid or unresolved optional authoring fields may normalize to absence.',
24
23
  compatibilityOwner: 'Plays Runtime',
@@ -27,7 +26,6 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
27
26
  'After every retained edition 1 artifact has a materialized admitted snapshot.',
28
27
  },
29
28
  {
30
- edition: 2,
31
29
  changed:
32
30
  'Pins admitted authoring snapshots and rejects ambiguous billing, secret, webhook, fetch, timeout, receipt-wait, and freshness contracts.',
33
31
  compatibilityOwner: 'Plays Runtime',
@@ -36,7 +34,6 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
36
34
  'After every retained edition 2 artifact has an admitted input schema or has been republished.',
37
35
  },
38
36
  {
39
- edition: 3,
40
37
  changed:
41
38
  'Materializes the declared input schema in the admitted snapshot so launch never reparses current source.',
42
39
  compatibilityOwner: 'Plays Runtime',
@@ -44,7 +41,6 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
44
41
  readerRemoval: null,
45
42
  },
46
43
  {
47
- edition: 4,
48
44
  changed:
49
45
  'ctx.secrets.get(name) resolves an allowed secret to a plaintext string for ordinary Play code. Editions 1–3 retain opaque secret handles.',
50
46
  compatibilityOwner: 'Plays Runtime',
@@ -52,7 +48,6 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
52
48
  readerRemoval: null,
53
49
  },
54
50
  {
55
- edition: 5,
56
51
  changed:
57
52
  'ctx.fetch throws a typed, redacted CtxFetchHttpError for non-2xx responses. Editions 1–4 continue to return the response record for every HTTP status.',
58
53
  compatibilityOwner: 'Plays Runtime',
@@ -60,7 +55,6 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
60
55
  readerRemoval: null,
61
56
  },
62
57
  {
63
- edition: 6,
64
58
  changed:
65
59
  'Adds static cron input and rejects unknown definePlay and binding fields during new admission. Editions 1–5 retain their admitted binding semantics.',
66
60
  compatibilityOwner: 'Plays Runtime',
@@ -68,15 +62,27 @@ export const PLAY_AUTHORING_CONTRACT_CHANGELOG = [
68
62
  readerRemoval: null,
69
63
  },
70
64
  {
71
- edition: 7,
72
65
  changed:
73
66
  'Slack HITL calls that omit timeout wait one week. Editions 1–6 retain the historical 24-hour default.',
74
67
  compatibilityOwner: 'Plays Runtime',
75
68
  newWritesEnd: null,
76
69
  readerRemoval: null,
77
70
  },
71
+ {
72
+ changed:
73
+ 'Lets an inline scalar child execute without a stored static pipeline. Dataset creation and suspension remain rejected by the authoritative runtime capability boundary; editions 1–7 retain static-contract preflight rejection.',
74
+ compatibilityOwner: 'Plays Runtime',
75
+ newWritesEnd: null,
76
+ readerRemoval: null,
77
+ },
78
78
  ] as const;
79
79
 
80
+ export const PLAY_AUTHORING_CONTRACT_CHANGELOG =
81
+ SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS.map((edition, index) => ({
82
+ edition,
83
+ ...PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS[index]!,
84
+ }));
85
+
80
86
  /**
81
87
  * Customer-visible runtime capabilities that are not expressible as one
82
88
  * `ctx.*` signature. The generated authoring reference renders this inventory
@@ -6,6 +6,7 @@ const residentRowsByDataset = new WeakMap<object, readonly unknown[]>();
6
6
  const DEFAULT_MATERIALIZE_LIMIT = 10_000;
7
7
  export const PLAY_DATASET_EXECUTION_PAGE_ROWS = 1_000;
8
8
  export const PLAY_DATASET_EXECUTION_PAGE_BYTES = 64 * 1024 * 1024;
9
+ const DATASET_UTF8_ENCODER = new TextEncoder();
9
10
 
10
11
  export type PlayDatasetKind = 'csv' | 'map';
11
12
 
@@ -899,7 +900,9 @@ export async function* iteratePlayDatasetInputPages<T>(
899
900
  options?.estimateRowBytes ??
900
901
  ((row: T) => {
901
902
  const serialized = JSON.stringify(row);
902
- return serialized === undefined ? 0 : serialized.length;
903
+ return serialized === undefined
904
+ ? 0
905
+ : DATASET_UTF8_ENCODER.encode(serialized).byteLength;
903
906
  });
904
907
  let page: T[] = [];
905
908
  let pageBytes = 0;