deepline 0.1.243 → 0.1.244

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 (71) hide show
  1. package/README.md +1 -1
  2. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +5 -25
  3. package/dist/bundling-sources/sdk/src/release.ts +23 -21
  4. package/dist/bundling-sources/sdk/src/types.ts +1 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/backend.ts +2 -21
  6. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +5 -6
  7. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +6 -13
  8. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +9 -26
  9. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +1 -2
  10. package/dist/bundling-sources/shared_libs/play-runtime/map-row-identity.ts +1 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +191 -29
  12. package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +1 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +1 -36
  14. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +2 -3
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/index.ts +0 -7
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1 -12
  17. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-pg.ts +2 -3
  18. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver.ts +5 -15
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -21
  20. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +3 -4
  21. package/dist/bundling-sources/shared_libs/plays/artifact-kind-guard.ts +16 -29
  22. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -8
  23. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +21 -712
  24. package/dist/bundling-sources/shared_libs/plays/bundling/limits.ts +1 -18
  25. package/dist/cli/index.js +29 -71
  26. package/dist/cli/index.mjs +29 -71
  27. package/dist/{compiler-manifest-CYcwzSOJ.d.ts → compiler-manifest-DlE7dnRm.d.mts} +2 -8
  28. package/dist/{compiler-manifest-CYcwzSOJ.d.mts → compiler-manifest-DlE7dnRm.d.ts} +2 -8
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +24 -22
  32. package/dist/index.mjs +24 -22
  33. package/dist/plays/bundle-play-file.d.mts +7 -22
  34. package/dist/plays/bundle-play-file.d.ts +7 -22
  35. package/dist/plays/bundle-play-file.mjs +26 -614
  36. package/package.json +2 -2
  37. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +0 -4504
  38. package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +0 -1386
  39. package/dist/bundling-sources/apps/play-runner-workers/src/durable-object-deploy-handoff.ts +0 -30
  40. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +0 -8385
  41. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/README.md +0 -21
  42. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/batching.ts +0 -251
  43. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/coordinator-progress.ts +0 -289
  44. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/csv-rows.ts +0 -85
  45. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/customer-console.ts +0 -23
  46. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/dataset-handles.ts +0 -528
  47. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +0 -229
  48. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/ledger-event-batches.ts +0 -81
  49. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/live-progress.ts +0 -22
  50. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +0 -920
  51. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-latency-profile.ts +0 -90
  52. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/output-datasets.ts +0 -475
  53. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +0 -570
  54. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/result-dataset-persistence.ts +0 -50
  55. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/row-isolation.ts +0 -5
  56. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/run-work-dispatcher.ts +0 -519
  57. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -107
  58. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +0 -2541
  59. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-http-errors.ts +0 -7
  60. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +0 -227
  61. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/work-budget.ts +0 -130
  62. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/worker-platform-budget.ts +0 -39
  63. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/workflow-preview.ts +0 -26
  64. package/dist/bundling-sources/apps/play-runner-workers/src/runtime-api-retry.ts +0 -23
  65. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-instance-create.ts +0 -47
  66. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +0 -167
  67. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry.ts +0 -91
  68. package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +0 -329
  69. package/dist/bundling-sources/sdk/src/worker-play-entry.ts +0 -240
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/coordinator-rate-state-backend.ts +0 -252
  71. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -217
@@ -15,7 +15,6 @@ import {
15
15
  extname,
16
16
  isAbsolute,
17
17
  join,
18
- relative,
19
18
  resolve
20
19
  } from "path";
21
20
  import { builtinModules } from "module";
@@ -26,15 +25,10 @@ import { build, transformSync } from "esbuild";
26
25
  // ../shared_libs/play-runtime/backend.ts
27
26
  var PLAY_RUNTIME_BACKENDS = {
28
27
  localProcess: "local_process",
29
- daytona: "daytona",
30
- // Artifact/runtime contract for Cloudflare Dynamic Workers. This is no
31
- // longer a standalone runner backend; use profile=workers_edge so the
32
- // cf-workflows scheduler owns loading and execution.
33
- cloudflareWorkers: "cloudflare_workers"
28
+ daytona: "daytona"
34
29
  };
35
30
  var PLAY_ARTIFACT_KINDS = {
36
- cjsNode20: "cjs_node20",
37
- esmWorkers: "esm_workers"
31
+ cjsNode20: "cjs_node20"
38
32
  };
39
33
  var PLAY_BACKEND_DESCRIPTORS = {
40
34
  [PLAY_RUNTIME_BACKENDS.localProcess]: {
@@ -46,11 +40,6 @@ var PLAY_BACKEND_DESCRIPTORS = {
46
40
  id: PLAY_RUNTIME_BACKENDS.daytona,
47
41
  artifactKind: PLAY_ARTIFACT_KINDS.cjsNode20,
48
42
  label: "Daytona sandbox"
49
- },
50
- [PLAY_RUNTIME_BACKENDS.cloudflareWorkers]: {
51
- id: PLAY_RUNTIME_BACKENDS.cloudflareWorkers,
52
- artifactKind: PLAY_ARTIFACT_KINDS.esmWorkers,
53
- label: "Cloudflare Dynamic Workers"
54
43
  }
55
44
  };
56
45
 
@@ -137,7 +126,6 @@ function validatePlaySourceFilesHaveNoInlineSecrets(sourceFiles) {
137
126
 
138
127
  // ../shared_libs/plays/bundling/limits.ts
139
128
  var MAX_PLAY_BUNDLE_BYTES = 30 * 1024 * 1024;
140
- var MAX_ESM_WORKERS_BUNDLE_BYTES = 115e4;
141
129
 
142
130
  // ../shared_libs/plays/bundling/index.ts
143
131
  var PLAY_BUNDLE_CACHE_VERSION = 25;
@@ -157,7 +145,6 @@ var SOURCE_EXTENSIONS = [
157
145
  ".cjs",
158
146
  ".json"
159
147
  ];
160
- var WORKERS_PLAY_ENTRY_VIRTUAL = "deepline-play-entry";
161
148
  var PLAY_SOURCE_FILE_PATTERN = /\.play\.(?:[cm]?[jt]sx?)$/i;
162
149
  var NODE_BUILTIN_SET = new Set(
163
150
  builtinModules.flatMap(
@@ -222,93 +209,6 @@ function stripCommentsToSpaces(source) {
222
209
  (match, prefix) => prefix + " ".repeat(Math.max(0, match.length - prefix.length))
223
210
  );
224
211
  }
225
- function previousSignificantToken(source, index) {
226
- let cursor = index - 1;
227
- while (cursor >= 0 && /\s/.test(source[cursor])) cursor -= 1;
228
- if (cursor < 0) return "";
229
- const char = source[cursor];
230
- if (!/[A-Za-z0-9_$]/.test(char)) return char;
231
- let start = cursor;
232
- while (start > 0 && /[A-Za-z0-9_$]/.test(source[start - 1])) start -= 1;
233
- return source.slice(start, cursor + 1);
234
- }
235
- function canStartRegexLiteral(source, slashIndex) {
236
- const token = previousSignificantToken(source, slashIndex);
237
- return !token || token === "return" || token === "throw" || token === "case" || token === "delete" || token === "typeof" || token === "void" || token === "instanceof" || /^(?:[({[=,:;!&|?+\-*~^<>%]|\.\.\.)$/.test(token);
238
- }
239
- function maskSourceForStructure(source) {
240
- const chars = source.split("");
241
- const maskRange = (start, end) => {
242
- for (let cursor = start; cursor < end; cursor += 1) {
243
- if (chars[cursor] !== "\n") chars[cursor] = " ";
244
- }
245
- };
246
- for (let index = 0; index < source.length; index += 1) {
247
- const char = source[index];
248
- const next = source[index + 1];
249
- if (char === "/" && next === "/") {
250
- let end = index + 2;
251
- while (end < source.length && source[end] !== "\n") end += 1;
252
- maskRange(index, end);
253
- index = end;
254
- continue;
255
- }
256
- if (char === "/" && next === "*") {
257
- const close = source.indexOf("*/", index + 2);
258
- const end = close >= 0 ? close + 2 : source.length;
259
- maskRange(index, end);
260
- index = end - 1;
261
- continue;
262
- }
263
- if (char === '"' || char === "'" || char === "`") {
264
- const quote = char;
265
- let end = index + 1;
266
- let escaped = false;
267
- while (end < source.length) {
268
- const current = source[end];
269
- if (escaped) {
270
- escaped = false;
271
- } else if (current === "\\") {
272
- escaped = true;
273
- } else if (current === quote) {
274
- end += 1;
275
- break;
276
- }
277
- end += 1;
278
- }
279
- maskRange(index, end);
280
- index = end - 1;
281
- continue;
282
- }
283
- if (char === "/" && canStartRegexLiteral(source, index)) {
284
- let end = index + 1;
285
- let escaped = false;
286
- let inCharacterClass = false;
287
- while (end < source.length) {
288
- const current = source[end];
289
- if (escaped) {
290
- escaped = false;
291
- } else if (current === "\\") {
292
- escaped = true;
293
- } else if (current === "[") {
294
- inCharacterClass = true;
295
- } else if (current === "]") {
296
- inCharacterClass = false;
297
- } else if (current === "/" && !inCharacterClass) {
298
- end += 1;
299
- while (/[A-Za-z]/.test(source[end] ?? "")) end += 1;
300
- break;
301
- } else if (current === "\n") {
302
- break;
303
- }
304
- end += 1;
305
- }
306
- maskRange(index, end);
307
- index = end - 1;
308
- }
309
- }
310
- return chars.join("");
311
- }
312
212
  function lineAndColumnAt(source, index) {
313
213
  const prefix = source.slice(0, index);
314
214
  const lines = prefix.split("\n");
@@ -375,19 +275,6 @@ function findSourceImportReferences(sourceCode) {
375
275
  (left, right) => left.line === right.line ? left.column - right.column : left.line - right.line
376
276
  );
377
277
  }
378
- function findMatchingBrace(source, openIndex) {
379
- const structuralSource = maskSourceForStructure(source);
380
- let depth = 0;
381
- for (let index = openIndex; index < structuralSource.length; index += 1) {
382
- const char = structuralSource[index];
383
- if (char === "{") depth += 1;
384
- if (char === "}") {
385
- depth -= 1;
386
- if (depth === 0) return index;
387
- }
388
- }
389
- return -1;
390
- }
391
278
  function extractDefinedPlayName(sourceCode) {
392
279
  return extractDefinedPlayMetadata(sourceCode, null)?.name ?? null;
393
280
  }
@@ -759,71 +646,6 @@ function extractDefinedPlayMetadata(sourceCode, exportName) {
759
646
  }
760
647
  return null;
761
648
  }
762
- function canonicalizeRootPlayNameForWorkersRuntimeHash(sourceCode) {
763
- const source = stripCommentsToSpaces(sourceCode);
764
- const callPattern = /(?:\b[A-Za-z_$][\w$]*\s*\.\s*)?\b(?:definePlay|defineWorkflow)\s*\(/g;
765
- const match = callPattern.exec(source);
766
- if (!match) return sourceCode;
767
- const openParen = match.index + match[0].length - 1;
768
- const firstArgStart = openParen + 1;
769
- const firstNonSpace = source.slice(firstArgStart).search(/\S/);
770
- if (firstNonSpace < 0) return sourceCode;
771
- const argIndex = firstArgStart + firstNonSpace;
772
- const quote = source[argIndex];
773
- if (quote === '"' || quote === "'") {
774
- const literalMatch = source.slice(argIndex).match(/^(['"])(?:\\.|(?!\1)[\s\S])*\1/);
775
- if (!literalMatch) return sourceCode;
776
- const replacement = `${quote}__deepline_runtime_play_name__${quote}`;
777
- return `${sourceCode.slice(0, argIndex)}${replacement}${sourceCode.slice(argIndex + literalMatch[0].length)}`;
778
- }
779
- if (quote !== "{") return sourceCode;
780
- const closeBrace = findMatchingBrace(source, argIndex);
781
- if (closeBrace < 0) return sourceCode;
782
- const objectSource = source.slice(argIndex + 1, closeBrace);
783
- const idMatch = objectSource.match(
784
- /(^|[,{\s])((?:id|['"]id['"])\s*:\s*)(['"])([\s\S]*?)\3/
785
- );
786
- if (!idMatch || idMatch.index === void 0) return sourceCode;
787
- const idValueStart = argIndex + 1 + idMatch.index + idMatch[1].length + idMatch[2].length + idMatch[3].length;
788
- return `${sourceCode.slice(0, idValueStart)}__deepline_runtime_play_name__${sourceCode.slice(idValueStart + idMatch[4].length)}`;
789
- }
790
- function workersRuntimeGraphFilePath(input) {
791
- if (input.filePath === input.entryFile) return "<entry>";
792
- const entryRelative = relative(dirname(input.entryFile), input.filePath);
793
- if (entryRelative && !entryRelative.startsWith("..")) {
794
- return entryRelative.replaceAll("\\", "/");
795
- }
796
- return `<project>/${relative(input.adapter.projectRoot, input.filePath).replaceAll("\\", "/")}`;
797
- }
798
- function buildWorkersRuntimeGraphHash(input) {
799
- const sourceFiles = Object.entries(input.analysis.sourceFiles).map(([filePath, contents]) => ({
800
- filePath: workersRuntimeGraphFilePath({
801
- entryFile: input.entryFile,
802
- filePath,
803
- adapter: input.adapter
804
- }),
805
- hash: sha256(
806
- filePath === input.entryFile ? canonicalizeRootPlayNameForWorkersRuntimeHash(contents) : contents
807
- )
808
- })).sort((left, right) => left.filePath.localeCompare(right.filePath));
809
- return sha256(
810
- JSON.stringify({
811
- entryFile: "<entry>",
812
- entryExport: input.exportName,
813
- localFiles: sourceFiles,
814
- nodeBuiltins: [...input.analysis.importPolicy.nodeBuiltins].sort(),
815
- packages: input.analysis.importPolicy.packages.map(({ name, version }) => ({ name, version })).sort((left, right) => left.name.localeCompare(right.name)),
816
- importedPlayDependencies: input.analysis.importedPlayDependencies.map((dependency) => ({
817
- filePath: workersRuntimeGraphFilePath({
818
- entryFile: input.entryFile,
819
- filePath: dependency.filePath,
820
- adapter: input.adapter
821
- }),
822
- playName: dependency.playName
823
- })).sort((left, right) => left.filePath.localeCompare(right.filePath))
824
- })
825
- );
826
- }
827
649
  function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
828
650
  try {
829
651
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
@@ -879,8 +701,8 @@ function findPackageJsonPath(packageName, fromFile, adapter) {
879
701
  );
880
702
  return existsSync(adapterNodeModulesPackageJson) ? adapterNodeModulesPackageJson : null;
881
703
  }
882
- function localSdkAliasPlugin(adapter, options) {
883
- const entryFile = options?.workersRuntime ? adapter.sdkWorkersEntryFile : adapter.sdkEntryFile;
704
+ function localSdkAliasPlugin(adapter) {
705
+ const entryFile = adapter.sdkEntryFile;
884
706
  if (!existsSync(entryFile)) {
885
707
  return null;
886
708
  }
@@ -896,193 +718,6 @@ function localSdkAliasPlugin(adapter, options) {
896
718
  }
897
719
  };
898
720
  }
899
- function workersPlayEntryAliasPlugin(playFilePath) {
900
- return {
901
- name: "deepline-workers-play-entry-alias",
902
- setup(buildContext) {
903
- buildContext.onResolve(
904
- { filter: new RegExp(`^${WORKERS_PLAY_ENTRY_VIRTUAL}$`) },
905
- () => ({ path: playFilePath })
906
- );
907
- }
908
- };
909
- }
910
- var CUSTOMER_CONSOLE_CAPTURE_GLOBAL = "__deeplineCaptureCustomerConsole";
911
- function sourceLoaderForPath(path) {
912
- const extension = extname(path).toLowerCase();
913
- if (extension === ".tsx") return "tsx";
914
- if (extension === ".jsx") return "jsx";
915
- if (extension === ".js" || extension === ".mjs" || extension === ".cjs") {
916
- return "js";
917
- }
918
- return "ts";
919
- }
920
- function workersCustomerConsolePlugin(customerSourceFilePaths) {
921
- const customerSourceFiles = new Set(
922
- customerSourceFilePaths.filter((path) => extname(path).toLowerCase() !== ".json").map((path) => resolve(path))
923
- );
924
- return {
925
- name: "deepline-workers-customer-console",
926
- setup(buildContext) {
927
- buildContext.onLoad({ filter: /./ }, (args) => {
928
- if (!customerSourceFiles.has(resolve(args.path))) return void 0;
929
- const source = readFileSync(args.path, "utf8");
930
- const declaresOwnConsole = /(?:^|\n)\s*(?:(?:const|let|var|class|function)\s+console\b|import[^\n]*\bconsole\b)/m.test(
931
- source
932
- );
933
- if (declaresOwnConsole) {
934
- return {
935
- contents: source,
936
- loader: sourceLoaderForPath(args.path),
937
- resolveDir: dirname(args.path)
938
- };
939
- }
940
- const prelude = `
941
- const console = new Proxy(globalThis.console, {
942
- get(target, property) {
943
- const capture = globalThis.${CUSTOMER_CONSOLE_CAPTURE_GLOBAL};
944
- if (typeof capture === 'function') {
945
- return (...args) => capture(String(property), args);
946
- }
947
- const value = Reflect.get(target, property);
948
- return typeof value === 'function' ? value.bind(target) : value;
949
- },
950
- });
951
- `;
952
- return {
953
- contents: `${prelude}
954
- ${source}`,
955
- loader: sourceLoaderForPath(args.path),
956
- resolveDir: dirname(args.path)
957
- };
958
- });
959
- }
960
- };
961
- }
962
- function workersNamedPlayEntryAliasPlugin(playFilePath, exportName) {
963
- return {
964
- name: "deepline-workers-named-play-entry-alias",
965
- setup(buildContext) {
966
- buildContext.onResolve(
967
- { filter: new RegExp(`^${WORKERS_PLAY_ENTRY_VIRTUAL}$`) },
968
- () => ({
969
- path: `${playFilePath}.${exportName}.entry.ts`,
970
- namespace: "deepline-named-play-entry"
971
- })
972
- );
973
- buildContext.onLoad(
974
- { filter: /.*/, namespace: "deepline-named-play-entry" },
975
- () => ({
976
- contents: `export { ${exportName} as default } from ${JSON.stringify(playFilePath)};
977
- `,
978
- loader: "ts",
979
- resolveDir: dirname(playFilePath)
980
- })
981
- );
982
- }
983
- };
984
- }
985
- function workersNodeBuiltinStubPlugin() {
986
- const UNSUPPORTED = /* @__PURE__ */ new Set([
987
- "node:fs",
988
- "node:fs/promises",
989
- "node:os",
990
- "node:child_process"
991
- ]);
992
- return {
993
- name: "deepline-workers-node-builtin-stub",
994
- setup(buildContext) {
995
- buildContext.onResolve({ filter: /^node:/ }, (args) => {
996
- if (!UNSUPPORTED.has(args.path)) return null;
997
- return { path: args.path, namespace: "deepline-workers-node-stub" };
998
- });
999
- buildContext.onLoad(
1000
- { filter: /.*/, namespace: "deepline-workers-node-stub" },
1001
- (args) => {
1002
- const builtinName = args.path;
1003
- const stubSource = `
1004
- const message = ${JSON.stringify(
1005
- `Workers backend: ${builtinName} is not available in Cloudflare Workers (no filesystem / no OS). Run this play on Daytona or local-process backend if it needs node builtins.`
1006
- )};
1007
- function makeThrower(name) {
1008
- return new Proxy(function() { throw new Error(message + ' (called: ' + name + ')'); }, {
1009
- get(_t, prop) {
1010
- if (prop === '__esModule') return true;
1011
- if (typeof prop === 'symbol') return undefined;
1012
- return makeThrower(name + '.' + String(prop));
1013
- },
1014
- apply() { throw new Error(message + ' (called: ' + name + ')'); },
1015
- construct() { throw new Error(message + ' (constructed: ' + name + ')'); },
1016
- });
1017
- }
1018
- module.exports = makeThrower(${JSON.stringify(builtinName)});
1019
- `;
1020
- return { contents: stubSource, loader: "js" };
1021
- }
1022
- );
1023
- }
1024
- };
1025
- }
1026
- function zodNonEnglishLocaleStubPlugin() {
1027
- const LOCALE_PATH_FILTER = /[\\/]zod[\\/]v4[\\/]locales[\\/][^\\/]+\.(?:c?js|mjs)$/;
1028
- const NAMESPACE = "deepline-zod-locale-stub";
1029
- return {
1030
- name: "deepline-zod-non-english-locale-stub",
1031
- setup(buildContext) {
1032
- buildContext.onResolve({ filter: LOCALE_PATH_FILTER }, (args) => {
1033
- const norm = args.path.replace(/\\/g, "/");
1034
- const file = norm.slice(norm.lastIndexOf("/") + 1);
1035
- if (/^en(?:[-_][A-Za-z]+)?\.(?:c?js|mjs)$/.test(file)) {
1036
- return null;
1037
- }
1038
- return { path: args.path, namespace: NAMESPACE };
1039
- });
1040
- buildContext.onLoad({ filter: /.*/, namespace: NAMESPACE }, () => ({
1041
- // zod locales export a default object literal. Empty object is
1042
- // structurally compatible — accessing any locale key returns
1043
- // undefined and zod falls back to its built-in English.
1044
- contents: "export default {};",
1045
- loader: "js"
1046
- }));
1047
- }
1048
- };
1049
- }
1050
- var WORKERS_BANNED_NODE_MODULES = /* @__PURE__ */ new Set([
1051
- "node:fs",
1052
- "node:fs/promises",
1053
- "node:net",
1054
- "node:child_process",
1055
- "node:cluster",
1056
- "node:tls",
1057
- "node:dgram",
1058
- "node:dns",
1059
- "node:dns/promises",
1060
- "node:repl",
1061
- "node:vm",
1062
- "node:worker_threads"
1063
- ]);
1064
- function workersNodeImportBanlistPlugin(adapter) {
1065
- return {
1066
- name: "deepline-workers-node-import-banlist",
1067
- setup(buildContext) {
1068
- buildContext.onResolve({ filter: /^node:/ }, (args) => {
1069
- if (!WORKERS_BANNED_NODE_MODULES.has(args.path)) return null;
1070
- const importer = args.importer ?? "";
1071
- if (importer.startsWith(adapter.sdkSourceRoot)) {
1072
- return null;
1073
- }
1074
- return {
1075
- errors: [
1076
- {
1077
- text: `Module "${args.path}" is not allowed in workers_edge plays. See AGENTS.md for the V8 isolate boundary.`,
1078
- detail: { importer: args.importer, kind: args.kind }
1079
- }
1080
- ]
1081
- };
1082
- });
1083
- }
1084
- };
1085
- }
1086
721
  function buildImportedPlayProxyModule(playName) {
1087
722
  const serializedName = JSON.stringify(playName);
1088
723
  return `
@@ -1343,66 +978,6 @@ async function analyzeSourceGraph(entryFile, adapter, exportName) {
1343
978
  )
1344
979
  };
1345
980
  }
1346
- async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
1347
- const { readdir } = await import("fs/promises");
1348
- const addFilePart = async (parts2, rootDir, filePath) => {
1349
- const contents = await readFile(filePath, "utf-8");
1350
- parts2.push({
1351
- name: `${basename(rootDir)}:${filePath.slice(rootDir.length + 1)}`,
1352
- hash: sha256(contents)
1353
- });
1354
- };
1355
- const collectTsFilesRecursive = async (rootDir, parts2) => {
1356
- if (!await fileExists(rootDir)) return;
1357
- const filePaths = [];
1358
- const visitDir = async (dir) => {
1359
- const entries = await readdir(dir, { withFileTypes: true });
1360
- for (const entry of entries) {
1361
- const childPath = join(dir, entry.name);
1362
- if (entry.isDirectory()) {
1363
- await visitDir(childPath);
1364
- continue;
1365
- }
1366
- if (entry.isFile() && /\.[cm]?ts$/.test(entry.name)) {
1367
- filePaths.push(childPath);
1368
- }
1369
- }
1370
- };
1371
- await visitDir(rootDir);
1372
- for (const filePath of filePaths.sort()) {
1373
- await addFilePart(parts2, rootDir, filePath);
1374
- }
1375
- };
1376
- const collectIntegrationBatchingFiles = async (rootDir, parts2) => {
1377
- if (!await fileExists(rootDir)) return;
1378
- const entries = await readdir(rootDir, { withFileTypes: true });
1379
- const filePaths = [];
1380
- for (const entry of entries) {
1381
- if (entry.isFile() && (entry.name === "play-runtime-batching-registry.ts" || /^batching.*\.ts$/.test(entry.name))) {
1382
- filePaths.push(join(rootDir, entry.name));
1383
- }
1384
- if (entry.isDirectory()) {
1385
- const batchingFile = join(rootDir, entry.name, "batching.ts");
1386
- if (await fileExists(batchingFile)) {
1387
- filePaths.push(batchingFile);
1388
- }
1389
- }
1390
- }
1391
- for (const filePath of filePaths.sort()) {
1392
- await addFilePart(parts2, rootDir, filePath);
1393
- }
1394
- };
1395
- const parts = [];
1396
- await collectTsFilesRecursive(adapter.workersHarnessFilesDir, parts);
1397
- for (const dir of adapter.workersRuntimeFingerprintDirs ?? []) {
1398
- if (basename(dir) === "integrations") {
1399
- await collectIntegrationBatchingFiles(dir, parts);
1400
- } else {
1401
- await collectTsFilesRecursive(dir, parts);
1402
- }
1403
- }
1404
- return sha256(JSON.stringify(parts));
1405
- }
1406
981
  function artifactCachePath(graphHash, artifactKind, adapter) {
1407
982
  return join(
1408
983
  adapter.cacheDir ?? PLAY_ARTIFACT_CACHE_DIR,
@@ -1444,15 +1019,10 @@ function normalizeSourceMapForRuntime(sourceMapText, projectRoot) {
1444
1019
  parsed.sourceRoot = void 0;
1445
1020
  return JSON.stringify(parsed);
1446
1021
  }
1447
- function getBundleSizeErrorForBytes(filePath, bundleBytes, artifactKind) {
1022
+ function getBundleSizeErrorForBytes(filePath, bundleBytes, _artifactKind) {
1448
1023
  if (bundleBytes > MAX_PLAY_BUNDLE_BYTES) {
1449
1024
  return `${filePath} Play bundle exceeds the 30 MiB limit (${bundleBytes} bytes > ${MAX_PLAY_BUNDLE_BYTES} bytes).`;
1450
1025
  }
1451
- if (artifactKind === PLAY_ARTIFACT_KINDS.esmWorkers && bundleBytes > MAX_ESM_WORKERS_BUNDLE_BYTES) {
1452
- const mib = (bundleBytes / 1024 / 1024).toFixed(2);
1453
- const limitMib = (MAX_ESM_WORKERS_BUNDLE_BYTES / 1024 / 1024).toFixed(2);
1454
- return `${filePath} Cloudflare Workers bundle is ${mib} MiB, above the workerd local-mode threshold of ${limitMib} MiB. Bundles past this size silently hang without executing the workflow body. Reduce dependencies (top offenders are usually date-fns, lodash, large schema libs) or split the play into smaller pieces with ctx.runPlay.`;
1455
- }
1456
1026
  return null;
1457
1027
  }
1458
1028
  function getBundleSizeError(filePath, bundledCode, artifactKind) {
@@ -1503,126 +1073,9 @@ async function runEsbuildForCjsNode(entryFile, _customerSourceFilePaths, importe
1503
1073
  outputExtension: "cjs"
1504
1074
  };
1505
1075
  }
1506
- async function runEsbuildForEsmWorkers(playEntryFile, customerSourceFilePaths, importedPlayDependencies, adapter, exportName) {
1507
- const sdkAliasPlugin = localSdkAliasPlugin(adapter, { workersRuntime: true });
1508
- const playProxyPlugin = importedPlayProxyPlugin(importedPlayDependencies);
1509
- const playEntryAlias = exportName === "default" ? workersPlayEntryAliasPlugin(playEntryFile) : workersNamedPlayEntryAliasPlugin(playEntryFile, exportName);
1510
- const customerConsolePlugin = workersCustomerConsolePlugin(
1511
- customerSourceFilePaths
1512
- );
1513
- const result = await build({
1514
- // Entry is the Workers harness; it imports the play via the virtual
1515
- // `deepline-play-entry` alias resolved by workersPlayEntryAliasPlugin.
1516
- entryPoints: [adapter.workersHarnessEntryFile],
1517
- absWorkingDir: adapter.projectRoot,
1518
- bundle: true,
1519
- format: "esm",
1520
- nodePaths: [adapter.nodeModulesDir],
1521
- // Browser platform with workerd + worker conditions matches Cloudflare's
1522
- // V8-isolate runtime. Avoids accidentally pulling node-only branches of
1523
- // dual-publish packages.
1524
- platform: "browser",
1525
- conditions: ["workerd", "worker", "browser", "import", "default"],
1526
- mainFields: ["module", "main"],
1527
- target: ["es2022"],
1528
- outfile: "play-worker.mjs",
1529
- write: false,
1530
- sourcemap: "external",
1531
- sourcesContent: false,
1532
- logLevel: "silent",
1533
- legalComments: "none",
1534
- // Aggressive minify + treeshake: a tiny play (<1KB source) was producing
1535
- // an ~870KB bundle, dominated by zod's locale files (~260KB unused) and
1536
- // dead-code branches across `shared_libs/play-runtime/*` and the SDK.
1537
- // Both DCE on with these flags. workerd compiles each unique-graphHash
1538
- // bundle on first dispatch, so bundle bytes translate ~linearly into
1539
- // per-play cold latency on workers_edge. External sourcemap remains
1540
- // unchanged (`sourcemap: 'external'`), so debugging is unaffected.
1541
- minify: true,
1542
- treeShaking: true,
1543
- // Most node:* builtins are provided by Cloudflare's `nodejs_compat` flag.
1544
- // The unsupported subset (fs, fs/promises, os, child_process) gets
1545
- // replaced with throwing stubs by workersNodeBuiltinStubPlugin so deploy
1546
- // validation passes; anything supported (path, crypto, buffer, etc.) is
1547
- // marked external and resolved at runtime by the Workers runtime.
1548
- external: ["node:*", "cloudflare:workers"],
1549
- plugins: [
1550
- // Banlist runs first so a forbidden import errors out before any other
1551
- // resolver (esp. the workersNodeBuiltinStubPlugin which would silently
1552
- // turn it into a throwing-stub).
1553
- workersNodeImportBanlistPlugin(adapter),
1554
- sdkAliasPlugin,
1555
- playProxyPlugin,
1556
- playEntryAlias,
1557
- customerConsolePlugin,
1558
- workersNodeBuiltinStubPlugin(),
1559
- // Strip non-English zod locale data from the bundle. zod's locales
1560
- // are re-exported as a static namespace from `zod/v4/core`, so
1561
- // tree-shaking can't drop them; this plugin replaces each
1562
- // non-English locale module with an empty default export at bundle
1563
- // time. ~150–200 KB savings on every per-play bundle, with no
1564
- // behavior change (we only surface English messages anyway).
1565
- // If the bundle suddenly grows back, check whether a new dep added
1566
- // its own zod copy or whether zod's locale layout changed.
1567
- zodNonEnglishLocaleStubPlugin()
1568
- ].filter((plugin) => plugin != null)
1569
- });
1570
- const codeFile = result.outputFiles?.find((f) => f.path.endsWith(".mjs"));
1571
- const mapFile = result.outputFiles?.find((f) => f.path.endsWith(".mjs.map"));
1572
- if (!codeFile?.text || !mapFile?.text) {
1573
- return ["Workers play bundling produced incomplete output."];
1574
- }
1575
- return {
1576
- bundledCode: codeFile.text,
1577
- sourceMapText: mapFile.text,
1578
- outputExtension: "mjs"
1579
- };
1580
- }
1581
- var PLAY_ARTIFACT_TARGET_ADAPTERS = {
1582
- [PLAY_ARTIFACT_KINDS.cjsNode20]: {
1583
- artifactKind: PLAY_ARTIFACT_KINDS.cjsNode20,
1584
- codeFormat: "cjs_module",
1585
- includeWorkersHarnessInGraphHash: false,
1586
- runEsbuild: ({
1587
- entryFile,
1588
- customerSourceFilePaths,
1589
- importedPlayDependencies,
1590
- adapter,
1591
- exportName
1592
- }) => runEsbuildForCjsNode(
1593
- entryFile,
1594
- customerSourceFilePaths,
1595
- importedPlayDependencies,
1596
- adapter,
1597
- exportName
1598
- )
1599
- },
1600
- [PLAY_ARTIFACT_KINDS.esmWorkers]: {
1601
- artifactKind: PLAY_ARTIFACT_KINDS.esmWorkers,
1602
- codeFormat: "esm_module",
1603
- includeWorkersHarnessInGraphHash: true,
1604
- runEsbuild: ({
1605
- entryFile,
1606
- customerSourceFilePaths,
1607
- importedPlayDependencies,
1608
- adapter,
1609
- exportName
1610
- }) => runEsbuildForEsmWorkers(
1611
- entryFile,
1612
- customerSourceFilePaths,
1613
- importedPlayDependencies,
1614
- adapter,
1615
- exportName
1616
- )
1617
- }
1618
- };
1619
- function resolvePlayArtifactTargetAdapter(artifactKind) {
1620
- return PLAY_ARTIFACT_TARGET_ADAPTERS[artifactKind];
1621
- }
1622
1076
  async function bundlePlayFile(filePath, options) {
1623
1077
  const adapter = options.adapter;
1624
1078
  const target = options.target ?? PLAY_ARTIFACT_KINDS.cjsNode20;
1625
- const targetAdapter = resolvePlayArtifactTargetAdapter(target);
1626
1079
  const exportName = options.exportName?.trim() || "default";
1627
1080
  assertValidExportName(exportName);
1628
1081
  const absolutePath = await normalizeLocalPath(filePath);
@@ -1633,20 +1086,10 @@ async function bundlePlayFile(filePath, options) {
1633
1086
  adapter,
1634
1087
  exportName
1635
1088
  );
1636
- analysis.graphHash = target === PLAY_ARTIFACT_KINDS.esmWorkers ? buildWorkersRuntimeGraphHash({
1637
- analysis,
1638
- entryFile: absolutePath,
1639
- adapter,
1640
- exportName
1641
- }) : sha256(`${analysis.graphHash}
1642
- entry-export:${exportName}`);
1643
- if (targetAdapter.includeWorkersHarnessInGraphHash) {
1644
- const harnessFingerprint = await computeWorkersHarnessFingerprintWithAdapter(adapter);
1645
- analysis.graphHash = sha256(
1646
- `${analysis.graphHash}
1647
- workers-harness:${harnessFingerprint}`
1648
- );
1649
- }
1089
+ analysis.graphHash = sha256(
1090
+ `${analysis.graphHash}
1091
+ entry-export:${exportName}`
1092
+ );
1650
1093
  try {
1651
1094
  validatePlaySourceFilesHaveNoInlineSecrets(analysis.sourceFiles);
1652
1095
  } catch (error) {
@@ -1675,8 +1118,11 @@ workers-harness:${harnessFingerprint}`
1675
1118
  errors: typecheckErrors
1676
1119
  };
1677
1120
  }
1678
- const canUseArtifactCache = target !== PLAY_ARTIFACT_KINDS.esmWorkers;
1679
- const cachedArtifact = canUseArtifactCache ? await readArtifactCache(analysis.graphHash, target, adapter) : null;
1121
+ const cachedArtifact = await readArtifactCache(
1122
+ analysis.graphHash,
1123
+ target,
1124
+ adapter
1125
+ );
1680
1126
  const discoveredFiles = await adapter.discoverPackagedLocalFiles(absolutePath);
1681
1127
  if (cachedArtifact) {
1682
1128
  const cachedArtifactSizeError = getBundleSizeError(
@@ -1710,13 +1156,13 @@ workers-harness:${harnessFingerprint}`
1710
1156
  importedPlayDependencies: analysis.importedPlayDependencies
1711
1157
  };
1712
1158
  }
1713
- const buildOutcome = await targetAdapter.runEsbuild({
1714
- entryFile: absolutePath,
1715
- customerSourceFilePaths: analysis.importPolicy.localFiles,
1716
- importedPlayDependencies: analysis.importedPlayDependencies,
1159
+ const buildOutcome = await runEsbuildForCjsNode(
1160
+ absolutePath,
1161
+ analysis.importPolicy.localFiles,
1162
+ analysis.importedPlayDependencies,
1717
1163
  adapter,
1718
1164
  exportName
1719
- });
1165
+ );
1720
1166
  if (Array.isArray(buildOutcome)) {
1721
1167
  return {
1722
1168
  success: false,
@@ -1747,7 +1193,7 @@ workers-harness:${harnessFingerprint}`
1747
1193
  };
1748
1194
  }
1749
1195
  const artifact = {
1750
- codeFormat: targetAdapter.codeFormat,
1196
+ codeFormat: "cjs_module",
1751
1197
  artifactKind: target,
1752
1198
  entryFile: absolutePath,
1753
1199
  virtualFilename,
@@ -1762,9 +1208,7 @@ workers-harness:${harnessFingerprint}`
1762
1208
  generatedAt: Date.now(),
1763
1209
  cacheHit: false
1764
1210
  };
1765
- if (canUseArtifactCache) {
1766
- await writeArtifactCache(artifact, adapter);
1767
- }
1211
+ await writeArtifactCache(artifact, adapter);
1768
1212
  return {
1769
1213
  success: true,
1770
1214
  artifact,
@@ -1803,9 +1247,6 @@ var PLAY_DEDUP_BACKENDS = {
1803
1247
 
1804
1248
  // ../shared_libs/play-runtime/scheduler-backend.ts
1805
1249
  var PLAY_SCHEDULER_BACKENDS = {
1806
- cfWorkflows: "cf-workflows",
1807
- /** Private legacy id retained only so old persisted rows can be interpreted. */
1808
- postgres: "postgres",
1809
1250
  /**
1810
1251
  * Postgres-native durable-execution scheduler (vendored Absurd engine). Runs
1811
1252
  * on the battle-tested run-state store without an external workflow engine.
@@ -1817,18 +1258,9 @@ var PLAY_SCHEDULER_BACKENDS = {
1817
1258
 
1818
1259
  // ../shared_libs/play-runtime/providers.ts
1819
1260
  var PLAY_RUNTIME_PROVIDER_IDS = {
1820
- workersEdge: "workers_edge",
1821
1261
  absurd: "absurd"
1822
1262
  };
1823
1263
  var PLAY_RUNTIME_PROVIDERS = {
1824
- workers_edge: {
1825
- id: PLAY_RUNTIME_PROVIDER_IDS.workersEdge,
1826
- scheduler: PLAY_SCHEDULER_BACKENDS.cfWorkflows,
1827
- runner: PLAY_RUNTIME_BACKENDS.cloudflareWorkers,
1828
- dedup: PLAY_DEDUP_BACKENDS.durableObject,
1829
- artifactKind: PLAY_ARTIFACT_KINDS.esmWorkers,
1830
- label: "Cloudflare Dynamic Workflows + Dynamic Workers + DO dedup"
1831
- },
1832
1264
  absurd: {
1833
1265
  id: PLAY_RUNTIME_PROVIDER_IDS.absurd,
1834
1266
  scheduler: PLAY_SCHEDULER_BACKENDS.absurd,
@@ -2221,7 +1653,7 @@ var MODULE_DIR = dirname3(fileURLToPath(import.meta.url));
2221
1653
  var SDK_PACKAGE_ROOT = resolve3(MODULE_DIR, "..", "..");
2222
1654
  var SOURCE_REPO_ROOT = resolve3(SDK_PACKAGE_ROOT, "..");
2223
1655
  var HAS_SOURCE_BUNDLING_SOURCES = existsSync2(
2224
- resolve3(SOURCE_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
1656
+ resolve3(SOURCE_REPO_ROOT, "shared_libs", "plays", "bundling", "index.ts")
2225
1657
  );
2226
1658
  var PACKAGED_BUNDLING_SOURCE_ROOT = resolve3(
2227
1659
  SDK_PACKAGE_ROOT,
@@ -2231,10 +1663,10 @@ var PACKAGED_BUNDLING_SOURCE_ROOT = resolve3(
2231
1663
  var HAS_PACKAGED_BUNDLING_SOURCES = existsSync2(
2232
1664
  resolve3(
2233
1665
  PACKAGED_BUNDLING_SOURCE_ROOT,
2234
- "apps",
2235
- "play-runner-workers",
2236
- "src",
2237
- "entry.ts"
1666
+ "shared_libs",
1667
+ "plays",
1668
+ "bundling",
1669
+ "index.ts"
2238
1670
  )
2239
1671
  );
2240
1672
  var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_BUNDLING_SOURCE_ROOT : resolve3(SDK_PACKAGE_ROOT, "..");
@@ -2242,20 +1674,6 @@ var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? resolve3(SOURCE_REPO_ROOT, "
2242
1674
  var SDK_PACKAGE_JSON = resolve3(SDK_PACKAGE_ROOT, "package.json");
2243
1675
  var SDK_ENTRY_FILE = resolve3(SDK_SOURCE_ROOT, "index.ts");
2244
1676
  var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : resolve3(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
2245
- var SDK_WORKERS_ENTRY_FILE = resolve3(SDK_SOURCE_ROOT, "worker-play-entry.ts");
2246
- var WORKERS_HARNESS_ENTRY_FILE = resolve3(
2247
- PROJECT_ROOT,
2248
- "apps",
2249
- "play-runner-workers",
2250
- "src",
2251
- "entry.ts"
2252
- );
2253
- var WORKERS_HARNESS_FILES_DIR = resolve3(
2254
- PROJECT_ROOT,
2255
- "apps",
2256
- "play-runner-workers",
2257
- "src"
2258
- );
2259
1677
  var hasWarnedAboutNonDevelopmentBundling = false;
2260
1678
  function warnAboutNonDevelopmentBundling(filePath) {
2261
1679
  if (hasWarnedAboutNonDevelopmentBundling) {
@@ -2288,12 +1706,6 @@ function createSdkPlayBundlingAdapter() {
2288
1706
  sdkPackageJson: SDK_PACKAGE_JSON,
2289
1707
  sdkEntryFile: SDK_ENTRY_FILE,
2290
1708
  sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !existsSync2(SDK_TYPES_ENTRY_FILE) ? SDK_ENTRY_FILE : SDK_TYPES_ENTRY_FILE,
2291
- sdkWorkersEntryFile: SDK_WORKERS_ENTRY_FILE,
2292
- workersHarnessEntryFile: WORKERS_HARNESS_ENTRY_FILE,
2293
- workersHarnessFilesDir: WORKERS_HARNESS_FILES_DIR,
2294
- workersRuntimeFingerprintDirs: [
2295
- resolve3(PROJECT_ROOT, "shared_libs", "play-runtime")
2296
- ],
2297
1709
  discoverPackagedLocalFiles,
2298
1710
  warnAboutNonDevelopmentBundling
2299
1711
  };