deepline 0.3.128 → 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 +250 -38
  113. package/dist/cli/index.mjs +250 -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
package/dist/index.js CHANGED
@@ -864,7 +864,7 @@ var SDK_RELEASE = {
864
864
  // getters keep their established compatibility behavior.
865
865
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
866
866
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
867
- version: "0.3.128",
867
+ version: "0.3.129",
868
868
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
869
869
  packageCapabilities: {
870
870
  updatePreferences: 1
@@ -1684,6 +1684,20 @@ var HttpClient = class {
1684
1684
  }
1685
1685
  throw lastError;
1686
1686
  }
1687
+ if (typeof parsed === "string") {
1688
+ const interstitial = detectHtmlErrorBody(
1689
+ body,
1690
+ response.headers.get("content-type")
1691
+ );
1692
+ if (interstitial) {
1693
+ throw new DeeplineError(
1694
+ `${this.config.baseUrl} returned a deployment-protection page instead of JSON. Set VERCEL_PROTECTION_BYPASS_TOKEN, or run \`vercel login\` if the CLI session expired.`,
1695
+ response.status,
1696
+ "DEPLOYMENT_PROTECTED",
1697
+ { htmlErrorPage: true }
1698
+ );
1699
+ }
1700
+ }
1687
1701
  return parsed;
1688
1702
  } catch (error) {
1689
1703
  clearTimeout(timeoutId);
@@ -2155,6 +2169,11 @@ function normalizePlayRunLedgerTerminalSource(value) {
2155
2169
  ) ? value : null;
2156
2170
  }
2157
2171
 
2172
+ // ../play-runtime/run-log-buffer.ts
2173
+ var RUNNER_LOG_MAX_BYTES = 5 * 1024 * 1024;
2174
+ var TERMINAL_RESERVE_BYTES = 64 * 1024;
2175
+ var encoder = new TextEncoder();
2176
+
2158
2177
  // ../play-runtime/secret-redaction.ts
2159
2178
  var SECRET_REDACTION_PLACEHOLDER = "[REDACTED_SECRET]";
2160
2179
  var BEARER_TOKEN_RE = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/g;
@@ -2172,6 +2191,18 @@ var SENSITIVE_FIELD_NAME_RE = new RegExp(
2172
2191
  `(^|[._-])(?:${SENSITIVE_FIELD_NAME})$`,
2173
2192
  "i"
2174
2193
  );
2194
+ var SENSITIVE_FIELD_NAME_CACHE_MAX_ENTRIES = 4096;
2195
+ var sensitiveFieldNameCache = /* @__PURE__ */ new Map();
2196
+ function isSensitiveFieldName(key) {
2197
+ const cached = sensitiveFieldNameCache.get(key);
2198
+ if (cached !== void 0) return cached;
2199
+ const sensitive = SENSITIVE_FIELD_NAME_RE.test(key);
2200
+ if (sensitiveFieldNameCache.size >= SENSITIVE_FIELD_NAME_CACHE_MAX_ENTRIES) {
2201
+ sensitiveFieldNameCache.clear();
2202
+ }
2203
+ sensitiveFieldNameCache.set(key, sensitive);
2204
+ return sensitive;
2205
+ }
2175
2206
  var SERIALIZED_SECRET_FIELD_RE = new RegExp(
2176
2207
  `"(${SENSITIVE_FIELD_NAME})"\\s*:\\s*(?:"[^"\\\\]*"|\\{[^{}]*\\})`,
2177
2208
  "gi"
@@ -2179,7 +2210,45 @@ var SERIALIZED_SECRET_FIELD_RE = new RegExp(
2179
2210
  function escapeRegExp(value) {
2180
2211
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2181
2212
  }
2213
+ var REDACTION_TRIGGER_RE = new RegExp(
2214
+ [
2215
+ // Sensitive field names, in object keys and in `name=`/`"name":` text.
2216
+ "token",
2217
+ "secret",
2218
+ "password",
2219
+ "authorization",
2220
+ "cookie",
2221
+ "credential",
2222
+ // One `key` branch instead of `api[_-]?key`, `private[_-]?key` and `key_`.
2223
+ // A regex alternation costs roughly one substring scan per branch, and a
2224
+ // broader branch can only send more payloads down the exact path.
2225
+ "key",
2226
+ // Self-identifying credential prefixes.
2227
+ "bearer",
2228
+ "basic",
2229
+ "-----BEGIN",
2230
+ "xox[baprs]-",
2231
+ "[prs]k_",
2232
+ "pat_",
2233
+ "ghp_",
2234
+ // URL credentials: `//user:pass@host` userinfo and sensitive query params.
2235
+ // The userinfo class excludes `/` exactly as the rule it guards does.
2236
+ "//[^\\s/]{0,256}@",
2237
+ "[?#&]sig",
2238
+ // JWTs carry no keyword at all, so the shape itself is the marker. Anchor
2239
+ // on the separating dot and drop JWT_RE's leading `{8,}` segment: a dot is
2240
+ // rare enough for the engine to skip between candidates, which makes this
2241
+ // gate roughly ten times cheaper than re-running JWT_RE itself, and
2242
+ // dropping a required segment can only widen what it accepts.
2243
+ "\\.[A-Za-z0-9_-]{1,16384}\\.[A-Za-z0-9_-]{8}"
2244
+ ].join("|"),
2245
+ "i"
2246
+ );
2247
+ function mightContainRedactableSecret(value) {
2248
+ return REDACTION_TRIGGER_RE.test(value);
2249
+ }
2182
2250
  function redactSecretLikeString(value) {
2251
+ if (!mightContainRedactableSecret(value)) return value;
2183
2252
  const serializedRedacted = value.replace(
2184
2253
  SERIALIZED_SECRET_FIELD_RE,
2185
2254
  `"$1":"${SECRET_REDACTION_PLACEHOLDER}"`
@@ -2201,9 +2270,26 @@ function redactSecretLikeString(value) {
2201
2270
  }
2202
2271
  function createSecretRedactionContext(initialValues = []) {
2203
2272
  const exactSecrets = /* @__PURE__ */ new Set();
2273
+ const exactSecretMatchers = /* @__PURE__ */ new Map();
2204
2274
  function register(value) {
2205
2275
  if (value.length > 0) exactSecrets.add(value);
2206
2276
  }
2277
+ function matchersForSecret(secret) {
2278
+ const cached = exactSecretMatchers.get(secret);
2279
+ if (cached) return cached;
2280
+ const literals = [secret];
2281
+ try {
2282
+ const encoded = encodeURIComponent(secret);
2283
+ if (encoded !== secret) literals.push(encoded);
2284
+ } catch {
2285
+ }
2286
+ const built = literals.map((literal) => ({
2287
+ literal,
2288
+ matcher: new RegExp(escapeRegExp(literal), "g")
2289
+ }));
2290
+ exactSecretMatchers.set(secret, built);
2291
+ return built;
2292
+ }
2207
2293
  for (const value of initialValues) register(value);
2208
2294
  function containsRegisteredSecret(value, {
2209
2295
  includeEncoded = false,
@@ -2226,21 +2312,13 @@ function createSecretRedactionContext(initialValues = []) {
2226
2312
  return exactSecrets.has(value);
2227
2313
  }
2228
2314
  function redactRegisteredSecrets(value) {
2315
+ if (exactSecrets.size === 0) return value;
2229
2316
  let output = value;
2230
2317
  for (const secret of exactSecrets) {
2231
- output = output.replace(
2232
- new RegExp(escapeRegExp(secret), "g"),
2233
- SECRET_REDACTION_PLACEHOLDER
2234
- );
2235
- try {
2236
- const encoded = encodeURIComponent(secret);
2237
- if (encoded !== secret) {
2238
- output = output.replace(
2239
- new RegExp(escapeRegExp(encoded), "g"),
2240
- SECRET_REDACTION_PLACEHOLDER
2241
- );
2242
- }
2243
- } catch {
2318
+ for (const { literal, matcher } of matchersForSecret(secret)) {
2319
+ if (!output.includes(literal)) continue;
2320
+ matcher.lastIndex = 0;
2321
+ output = output.replace(matcher, SECRET_REDACTION_PLACEHOLDER);
2244
2322
  }
2245
2323
  }
2246
2324
  return output;
@@ -2251,13 +2329,33 @@ function createSecretRedactionContext(initialValues = []) {
2251
2329
  }
2252
2330
  function redact(value) {
2253
2331
  if (typeof value === "string") return redactString2(value);
2254
- if (Array.isArray(value)) return value.map((entry) => redact(entry));
2332
+ if (Array.isArray(value)) {
2333
+ let changed = false;
2334
+ const next = new Array(value.length);
2335
+ for (let index = 0; index < value.length; index += 1) {
2336
+ const entry = value[index];
2337
+ const redacted = redact(entry);
2338
+ next[index] = redacted;
2339
+ if (redacted !== entry) changed = true;
2340
+ }
2341
+ return changed ? next : value;
2342
+ }
2255
2343
  if (value && typeof value === "object") {
2344
+ const prototype = Object.getPrototypeOf(value);
2345
+ let changed = prototype !== Object.prototype && prototype !== null;
2346
+ const source = value;
2347
+ const keys = Object.keys(source);
2348
+ const redactedValues = new Array(keys.length);
2349
+ for (let index = 0; index < keys.length; index += 1) {
2350
+ const key = keys[index];
2351
+ const entry = source[key];
2352
+ const redacted = isSensitiveFieldName(key) ? SECRET_REDACTION_PLACEHOLDER : redact(entry);
2353
+ redactedValues[index] = redacted;
2354
+ if (redacted !== entry) changed = true;
2355
+ }
2356
+ if (!changed) return value;
2256
2357
  return Object.fromEntries(
2257
- Object.entries(value).map(([key, entry]) => [
2258
- key,
2259
- SENSITIVE_FIELD_NAME_RE.test(key) ? SECRET_REDACTION_PLACEHOLDER : redact(entry)
2260
- ])
2358
+ keys.map((key, index) => [key, redactedValues[index]])
2261
2359
  );
2262
2360
  }
2263
2361
  return value;
@@ -2295,9 +2393,10 @@ var CUSTOMER_OUTPUT_VALUE_MAX_BYTES = 5 * 1024 * 1024;
2295
2393
  var CUSTOMER_OUTPUT_TOTAL_MAX_BYTES = 5 * 1024 * 1024;
2296
2394
  var RUNTIME_RECEIPT_OUTPUT_MAX_BYTES = 10 * 1024 * 1024;
2297
2395
  var RUNTIME_RECEIPT_COMPLETION_BUFFER_MAX_BYTES = 32 * 1024 * 1024;
2396
+ var RUNTIME_RECEIPT_CONTROL_BUFFER_MAX_BYTES = 2 * 1024 * 1024;
2298
2397
  var RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES = 16 * 1024 * 1024;
2299
2398
  var RUNTIME_RECEIPT_GATEWAY_BATCH_MAX_BYTES = 12 * 1024 * 1024;
2300
- var RUNTIME_RECEIPT_WRITER_TARGET_BATCH_BYTES = 4 * 1024 * 1024;
2399
+ var RUNTIME_RECEIPT_WRITER_TARGET_BATCH_BYTES = 8 * 1024 * 1024;
2301
2400
  var RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES = 64 * 1024;
2302
2401
  var JSON_SIZE_LIMIT_REACHED = Symbol("JSON_SIZE_LIMIT_REACHED");
2303
2402
 
@@ -3105,7 +3204,11 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
3105
3204
  finiteNumber(value.totalLogCount) ?? logTail.length,
3106
3205
  logTail.length
3107
3206
  ),
3108
- logsTruncated: value.logsTruncated === true,
3207
+ // A persisted snapshot carrying more lines than the tail keeps is
3208
+ // truncated here, whatever the stored flag says. Reporting `false` while
3209
+ // dropping lines is silent loss: a reader would take the tail for the
3210
+ // whole log.
3211
+ logsTruncated: value.logsTruncated === true || logTail.length > LOG_TAIL_LIMIT,
3109
3212
  activeStepId: optionalNullableString(value.activeStepId),
3110
3213
  activeActivityId: optionalNullableString(value.activeActivityId),
3111
3214
  activeArtifactTableNamespace: optionalNullableString(
@@ -3996,28 +4099,42 @@ var PLAY_BACKEND_DESCRIPTORS = {
3996
4099
  // ../play-runtime/runtime-environment.ts
3997
4100
  var PLAY_RUNTIME_ENVIRONMENTS = ["preview"];
3998
4101
  var PLAY_RUNTIME_NAMESPACE_PATTERN = /^[a-z][a-z0-9-]{0,30}$/;
4102
+ var PLAY_RUNTIME_SANDBOX_PLACEMENT_POLICY_PATTERN = /^[a-z][a-z0-9_]*@[1-9][0-9]*$/;
3999
4103
  function normalizePlayRuntimeNamespace(value) {
4000
4104
  if (typeof value !== "string") return null;
4001
4105
  const normalized = value.trim();
4002
4106
  return PLAY_RUNTIME_NAMESPACE_PATTERN.test(normalized) ? normalized : null;
4003
4107
  }
4108
+ function normalizePlayRuntimeSandboxPlacementPolicy(value) {
4109
+ if (typeof value !== "string") return null;
4110
+ const normalized = value.trim();
4111
+ return PLAY_RUNTIME_SANDBOX_PLACEMENT_POLICY_PATTERN.test(normalized) ? normalized : null;
4112
+ }
4004
4113
  function normalizePlayRuntimeSelection(value) {
4005
4114
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
4006
4115
  const record3 = value;
4007
4116
  if (Object.keys(record3).some(
4008
- (key) => key !== "environment" && key !== "namespace" && key !== "backend"
4117
+ (key) => key !== "environment" && key !== "namespace" && key !== "backend" && key !== "sandboxPlacementPolicy"
4009
4118
  ) || record3.environment !== "preview") {
4010
4119
  return null;
4011
4120
  }
4012
4121
  const namespace = normalizePlayRuntimeNamespace(record3.namespace);
4013
4122
  if (!namespace) return null;
4014
- if (record3.backend === void 0) {
4015
- return { environment: "preview", namespace };
4123
+ const sandboxPlacementPolicy = record3.sandboxPlacementPolicy === void 0 ? void 0 : normalizePlayRuntimeSandboxPlacementPolicy(
4124
+ record3.sandboxPlacementPolicy
4125
+ );
4126
+ if (record3.sandboxPlacementPolicy !== void 0 && sandboxPlacementPolicy === null) {
4127
+ return null;
4016
4128
  }
4017
- if (record3.backend !== PLAY_RUNTIME_BACKENDS.daytona && record3.backend !== PLAY_RUNTIME_BACKENDS.modal) {
4129
+ if (record3.backend !== void 0 && record3.backend !== PLAY_RUNTIME_BACKENDS.daytona && record3.backend !== PLAY_RUNTIME_BACKENDS.modal) {
4018
4130
  return null;
4019
4131
  }
4020
- return { environment: "preview", namespace, backend: record3.backend };
4132
+ return {
4133
+ environment: "preview",
4134
+ namespace,
4135
+ ...record3.backend === void 0 ? {} : { backend: record3.backend },
4136
+ ...sandboxPlacementPolicy ? { sandboxPlacementPolicy } : {}
4137
+ };
4021
4138
  }
4022
4139
  function normalizePlayRuntimeEnvironment(value) {
4023
4140
  return typeof value === "string" && PLAY_RUNTIME_ENVIRONMENTS.includes(value) ? value : null;
@@ -4111,7 +4228,7 @@ function resolvePlayRunRuntimeSelection(request) {
4111
4228
  const runtime = normalizePlayRuntimeSelection(request.runtime);
4112
4229
  if (!runtime) {
4113
4230
  throw new DeeplineError(
4114
- 'runtime must be { environment: "preview", namespace, backend?: "daytona" | "modal" } with namespace matching ^[a-z][a-z0-9-]{0,30}$.',
4231
+ 'runtime must be { environment: "preview", namespace, backend?: "daytona" | "modal", sandboxPlacementPolicy?: "policy_name@1" } with namespace matching ^[a-z][a-z0-9-]{0,30}$.',
4115
4232
  void 0,
4116
4233
  "INVALID_RUNTIME_SELECTION"
4117
4234
  );
@@ -4121,11 +4238,15 @@ function resolvePlayRunRuntimeSelection(request) {
4121
4238
  const configured = process.env.DEEPLINE_RUNTIME_ENVIRONMENT?.trim();
4122
4239
  const configuredNamespace = process.env.DEEPLINE_RUNTIME_NAMESPACE?.trim();
4123
4240
  const configuredToken = process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
4241
+ const configuredPlacementPolicy = process.env.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY?.trim();
4124
4242
  if (!configured) {
4125
- if (configuredNamespace || configuredToken) {
4243
+ if (configuredNamespace || configuredToken || configuredPlacementPolicy) {
4126
4244
  const present = [];
4127
4245
  if (configuredNamespace) present.push("DEEPLINE_RUNTIME_NAMESPACE");
4128
4246
  if (configuredToken) present.push("DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN");
4247
+ if (configuredPlacementPolicy) {
4248
+ present.push("DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY");
4249
+ }
4129
4250
  const isPlural = present.length > 1;
4130
4251
  throw new DeeplineError(
4131
4252
  [
@@ -4156,18 +4277,28 @@ function resolvePlayRunRuntimeSelection(request) {
4156
4277
  "INVALID_RUNTIME_NAMESPACE"
4157
4278
  );
4158
4279
  }
4159
- const configuredBackend = process.env.DEEPLINE_PLAY_RUNNER_BACKEND?.trim();
4160
- if (!configuredBackend) {
4161
- return { environment, namespace };
4162
- }
4163
- if (configuredBackend !== "daytona" && configuredBackend !== "modal") {
4280
+ const configuredBackendValue = process.env.DEEPLINE_PLAY_RUNNER_BACKEND?.trim();
4281
+ const configuredBackend = configuredBackendValue === "daytona" || configuredBackendValue === "modal" ? configuredBackendValue : void 0;
4282
+ if (configuredBackendValue && !configuredBackend) {
4164
4283
  throw new DeeplineError(
4165
- `DEEPLINE_PLAY_RUNNER_BACKEND must be daytona or modal for preview runtime selection. Received "${configuredBackend}".`,
4284
+ `DEEPLINE_PLAY_RUNNER_BACKEND must be daytona or modal for preview runtime selection. Received "${configuredBackendValue}".`,
4166
4285
  void 0,
4167
4286
  "INVALID_RUNTIME_BACKEND"
4168
4287
  );
4169
4288
  }
4170
- return { environment, namespace, backend: configuredBackend };
4289
+ if (configuredPlacementPolicy && !normalizePlayRuntimeSandboxPlacementPolicy(configuredPlacementPolicy)) {
4290
+ throw new DeeplineError(
4291
+ `DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY must be a versioned placement policy id such as daytona_only@1. Received "${configuredPlacementPolicy}".`,
4292
+ void 0,
4293
+ "INVALID_RUNTIME_SANDBOX_PLACEMENT_POLICY"
4294
+ );
4295
+ }
4296
+ return {
4297
+ environment,
4298
+ namespace,
4299
+ ...configuredBackend ? { backend: configuredBackend } : {},
4300
+ ...configuredPlacementPolicy ? { sandboxPlacementPolicy: configuredPlacementPolicy } : {}
4301
+ };
4171
4302
  }
4172
4303
  function runtimeSelectionHeaders(runtime) {
4173
4304
  if (!runtime) return void 0;
@@ -7982,6 +8113,7 @@ var NODE_INSPECT_CUSTOM = Symbol.for("nodejs.util.inspect.custom");
7982
8113
  var residentRowsByDataset = /* @__PURE__ */ new WeakMap();
7983
8114
  var DEFAULT_MATERIALIZE_LIMIT = 1e4;
7984
8115
  var PLAY_DATASET_EXECUTION_PAGE_BYTES = 64 * 1024 * 1024;
8116
+ var DATASET_UTF8_ENCODER = new TextEncoder();
7985
8117
  var PLAY_DATASET_CELL_MAX_BYTES = 5 * 1024 * 1024;
7986
8118
  function resolveMaterializeLimitCap() {
7987
8119
  const raw = process.env.DEEPLINE_PLAY_DATASET_MATERIALIZE_LIMIT;
@@ -9260,6 +9392,70 @@ function replaceAtPath(root, path, replacement) {
9260
9392
  // ../plays/authoring-contract.ts
9261
9393
  var import_typebox = require("@sinclair/typebox");
9262
9394
  var import_value = require("@sinclair/typebox/value");
9395
+ var SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS = [
9396
+ 1,
9397
+ 2,
9398
+ 3,
9399
+ 4,
9400
+ 5,
9401
+ 6,
9402
+ 7,
9403
+ 8
9404
+ ];
9405
+ var PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS = [
9406
+ {
9407
+ changed: "Historical extraction semantics. Invalid or unresolved optional authoring fields may normalize to absence.",
9408
+ compatibilityOwner: "Plays Runtime",
9409
+ newWritesEnd: "2026-11-03",
9410
+ readerRemoval: "After every retained edition 1 artifact has a materialized admitted snapshot."
9411
+ },
9412
+ {
9413
+ changed: "Pins admitted authoring snapshots and rejects ambiguous billing, secret, webhook, fetch, timeout, receipt-wait, and freshness contracts.",
9414
+ compatibilityOwner: "Plays Runtime",
9415
+ newWritesEnd: "2026-08-03",
9416
+ readerRemoval: "After every retained edition 2 artifact has an admitted input schema or has been republished."
9417
+ },
9418
+ {
9419
+ changed: "Materializes the declared input schema in the admitted snapshot so launch never reparses current source.",
9420
+ compatibilityOwner: "Plays Runtime",
9421
+ newWritesEnd: "2026-08-19",
9422
+ readerRemoval: null
9423
+ },
9424
+ {
9425
+ changed: "ctx.secrets.get(name) resolves an allowed secret to a plaintext string for ordinary Play code. Editions 1\u20133 retain opaque secret handles.",
9426
+ compatibilityOwner: "Plays Runtime",
9427
+ newWritesEnd: null,
9428
+ readerRemoval: null
9429
+ },
9430
+ {
9431
+ changed: "ctx.fetch throws a typed, redacted CtxFetchHttpError for non-2xx responses. Editions 1\u20134 continue to return the response record for every HTTP status.",
9432
+ compatibilityOwner: "Plays Runtime",
9433
+ newWritesEnd: null,
9434
+ readerRemoval: null
9435
+ },
9436
+ {
9437
+ changed: "Adds static cron input and rejects unknown definePlay and binding fields during new admission. Editions 1\u20135 retain their admitted binding semantics.",
9438
+ compatibilityOwner: "Plays Runtime",
9439
+ newWritesEnd: null,
9440
+ readerRemoval: null
9441
+ },
9442
+ {
9443
+ changed: "Slack HITL calls that omit timeout wait one week. Editions 1\u20136 retain the historical 24-hour default.",
9444
+ compatibilityOwner: "Plays Runtime",
9445
+ newWritesEnd: null,
9446
+ readerRemoval: null
9447
+ },
9448
+ {
9449
+ changed: "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\u20137 retain static-contract preflight rejection.",
9450
+ compatibilityOwner: "Plays Runtime",
9451
+ newWritesEnd: null,
9452
+ readerRemoval: null
9453
+ }
9454
+ ];
9455
+ var PLAY_AUTHORING_CONTRACT_CHANGELOG = SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS.map((edition, index) => ({
9456
+ edition,
9457
+ ...PLAY_AUTHORING_CONTRACT_CHANGELOG_DETAILS[index]
9458
+ }));
9263
9459
  var PLAY_SQL_LISTENER_WHERE_OPERATORS = [
9264
9460
  "eq",
9265
9461
  "neq",