veryfront 0.1.368 → 0.1.369

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 (139) hide show
  1. package/esm/cli/commands/init/config-generator.d.ts.map +1 -1
  2. package/esm/cli/commands/init/config-generator.js +1 -0
  3. package/esm/cli/main.js +15 -0
  4. package/esm/deno.d.ts +3 -3
  5. package/esm/deno.js +5 -5
  6. package/esm/extensions/ext-esbuild/src/binary.d.ts +7 -0
  7. package/esm/extensions/ext-esbuild/src/binary.d.ts.map +1 -0
  8. package/esm/extensions/ext-esbuild/src/binary.js +143 -0
  9. package/esm/extensions/ext-esbuild/src/es-module-lexer.d.ts +17 -0
  10. package/esm/extensions/ext-esbuild/src/es-module-lexer.d.ts.map +1 -0
  11. package/esm/extensions/ext-esbuild/src/es-module-lexer.js +29 -0
  12. package/esm/extensions/ext-esbuild/src/esbuild-bundler.d.ts +20 -0
  13. package/esm/extensions/ext-esbuild/src/esbuild-bundler.d.ts.map +1 -0
  14. package/esm/extensions/ext-esbuild/src/esbuild-bundler.js +98 -0
  15. package/esm/extensions/ext-esbuild/src/index.d.ts +19 -0
  16. package/esm/extensions/ext-esbuild/src/index.d.ts.map +1 -0
  17. package/esm/extensions/ext-esbuild/src/index.js +40 -0
  18. package/esm/extensions/ext-esbuild/src/plugin-adapter.d.ts +14 -0
  19. package/esm/extensions/ext-esbuild/src/plugin-adapter.d.ts.map +1 -0
  20. package/esm/extensions/ext-esbuild/src/plugin-adapter.js +55 -0
  21. package/esm/extensions/ext-esbuild/src/runtime.d.ts +4 -0
  22. package/esm/extensions/ext-esbuild/src/runtime.d.ts.map +1 -0
  23. package/esm/extensions/ext-esbuild/src/runtime.js +43 -0
  24. package/esm/src/agent/fork-runtime-stream.d.ts +11 -1
  25. package/esm/src/agent/fork-runtime-stream.d.ts.map +1 -1
  26. package/esm/src/agent/fork-runtime-stream.js +36 -0
  27. package/esm/src/agent/index.d.ts +1 -1
  28. package/esm/src/agent/index.d.ts.map +1 -1
  29. package/esm/src/agent/index.js +1 -1
  30. package/esm/src/build/bundler/code-splitter/build-context.d.ts +1 -1
  31. package/esm/src/build/bundler/code-splitter/build-context.d.ts.map +1 -1
  32. package/esm/src/build/bundler/code-splitter/build-context.js +1 -1
  33. package/esm/src/build/bundler/code-splitter/esbuild-plugin.d.ts +1 -1
  34. package/esm/src/build/bundler/code-splitter/esbuild-plugin.d.ts.map +1 -1
  35. package/esm/src/build/bundler/code-splitter/manifest-builder.d.ts +1 -1
  36. package/esm/src/build/bundler/code-splitter/manifest-builder.d.ts.map +1 -1
  37. package/esm/src/build/bundler/code-splitter/types.d.ts +1 -1
  38. package/esm/src/build/bundler/code-splitter/types.d.ts.map +1 -1
  39. package/esm/src/build/compiler/mdx-compiler/transpiler.js +1 -1
  40. package/esm/src/build/compiler/mdx-to-js.js +1 -1
  41. package/esm/src/build/embedded/preset.js +1 -1
  42. package/esm/src/build/production-build/client-runtime.js +1 -1
  43. package/esm/src/discovery/transpiler.js +1 -1
  44. package/esm/src/extensions/bundler.d.ts +28 -0
  45. package/esm/src/extensions/bundler.d.ts.map +1 -0
  46. package/esm/src/extensions/bundler.js +42 -0
  47. package/esm/src/extensions/interfaces/bundler.d.ts +162 -27
  48. package/esm/src/extensions/interfaces/bundler.d.ts.map +1 -1
  49. package/esm/src/extensions/interfaces/index.d.ts +2 -1
  50. package/esm/src/extensions/interfaces/index.d.ts.map +1 -1
  51. package/esm/src/extensions/interfaces/module-lexer.d.ts +45 -0
  52. package/esm/src/extensions/interfaces/module-lexer.d.ts.map +1 -0
  53. package/esm/src/extensions/interfaces/module-lexer.js +13 -0
  54. package/esm/src/extensions/loader.d.ts.map +1 -1
  55. package/esm/src/extensions/loader.js +7 -1
  56. package/esm/src/extensions/recommendations.d.ts.map +1 -1
  57. package/esm/src/extensions/recommendations.js +3 -0
  58. package/esm/src/platform/compat/esbuild.d.ts +20 -6
  59. package/esm/src/platform/compat/esbuild.d.ts.map +1 -1
  60. package/esm/src/platform/compat/esbuild.js +20 -137
  61. package/esm/src/rendering/script-page-handling.js +1 -1
  62. package/esm/src/routing/api/module-loader/esbuild-plugin.d.ts +1 -1
  63. package/esm/src/routing/api/module-loader/esbuild-plugin.d.ts.map +1 -1
  64. package/esm/src/routing/api/module-loader/loader.js +1 -1
  65. package/esm/src/server/bootstrap.d.ts.map +1 -1
  66. package/esm/src/server/bootstrap.js +22 -0
  67. package/esm/src/server/dev-server/middleware.js +1 -1
  68. package/esm/src/server/handlers/dev/files/esbuild-plugins.d.ts +1 -1
  69. package/esm/src/server/handlers/dev/files/esbuild-plugins.d.ts.map +1 -1
  70. package/esm/src/server/handlers/studio/bridge-modules.handler.js +1 -1
  71. package/esm/src/server/services/rsc/endpoints/script-handlers.js +1 -1
  72. package/esm/src/server/services/rsc/orchestrators/hydrator-handler.js +1 -1
  73. package/esm/src/server/shared/browser-module-bundler.js +1 -1
  74. package/esm/src/testing/bdd.d.ts +1 -0
  75. package/esm/src/testing/bdd.d.ts.map +1 -1
  76. package/esm/src/testing/bdd.js +1 -0
  77. package/esm/src/testing/init.js +7 -0
  78. package/esm/src/transforms/esm/http-bundler.d.ts +1 -1
  79. package/esm/src/transforms/esm/http-bundler.d.ts.map +1 -1
  80. package/esm/src/transforms/esm/lexer.d.ts +2 -9
  81. package/esm/src/transforms/esm/lexer.d.ts.map +1 -1
  82. package/esm/src/transforms/esm/lexer.js +9 -10
  83. package/esm/src/transforms/esm/transform-utils.d.ts +1 -1
  84. package/esm/src/transforms/esm/transform-utils.d.ts.map +1 -1
  85. package/esm/src/transforms/import-rewriter/parse-cache.d.ts +1 -1
  86. package/esm/src/transforms/import-rewriter/parse-cache.d.ts.map +1 -1
  87. package/esm/src/transforms/import-rewriter/parse-cache.js +8 -7
  88. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.js +1 -1
  89. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +2 -2
  90. package/esm/src/utils/version-constant.d.ts +1 -1
  91. package/esm/src/utils/version-constant.js +1 -1
  92. package/package.json +1 -1
  93. package/src/cli/commands/init/config-generator.ts +1 -0
  94. package/src/cli/main.ts +14 -0
  95. package/src/deno.js +5 -5
  96. package/src/extensions/ext-esbuild/src/binary.ts +154 -0
  97. package/src/extensions/ext-esbuild/src/es-module-lexer.ts +34 -0
  98. package/src/extensions/ext-esbuild/src/esbuild-bundler.ts +122 -0
  99. package/src/extensions/ext-esbuild/src/index.ts +46 -0
  100. package/src/extensions/ext-esbuild/src/plugin-adapter.ts +66 -0
  101. package/src/extensions/ext-esbuild/src/runtime.ts +54 -0
  102. package/src/src/agent/fork-runtime-stream.ts +61 -1
  103. package/src/src/agent/index.ts +2 -0
  104. package/src/src/build/bundler/code-splitter/build-context.ts +1 -1
  105. package/src/src/build/bundler/code-splitter/esbuild-plugin.ts +1 -1
  106. package/src/src/build/bundler/code-splitter/manifest-builder.ts +1 -1
  107. package/src/src/build/bundler/code-splitter/splitter.ts +1 -1
  108. package/src/src/build/bundler/code-splitter/types.ts +1 -1
  109. package/src/src/build/compiler/mdx-compiler/transpiler.ts +1 -1
  110. package/src/src/build/compiler/mdx-to-js.ts +1 -1
  111. package/src/src/build/embedded/preset.ts +1 -1
  112. package/src/src/build/production-build/client-runtime.ts +2 -2
  113. package/src/src/discovery/transpiler.ts +2 -2
  114. package/src/src/extensions/bundler.ts +85 -0
  115. package/src/src/extensions/interfaces/bundler.ts +189 -16
  116. package/src/src/extensions/interfaces/index.ts +16 -0
  117. package/src/src/extensions/interfaces/module-lexer.ts +46 -0
  118. package/src/src/extensions/loader.ts +6 -1
  119. package/src/src/extensions/recommendations.ts +3 -0
  120. package/src/src/platform/compat/esbuild.ts +48 -160
  121. package/src/src/rendering/script-page-handling.ts +1 -1
  122. package/src/src/routing/api/module-loader/esbuild-plugin.ts +1 -1
  123. package/src/src/routing/api/module-loader/loader.ts +2 -2
  124. package/src/src/server/bootstrap.ts +29 -0
  125. package/src/src/server/dev-server/middleware.ts +1 -1
  126. package/src/src/server/handlers/dev/files/esbuild-plugins.ts +1 -1
  127. package/src/src/server/handlers/studio/bridge-modules.handler.ts +1 -1
  128. package/src/src/server/services/rsc/endpoints/script-handlers.ts +4 -4
  129. package/src/src/server/services/rsc/orchestrators/hydrator-handler.ts +1 -1
  130. package/src/src/server/shared/browser-module-bundler.ts +1 -1
  131. package/src/src/testing/bdd.ts +1 -0
  132. package/src/src/testing/init.ts +9 -0
  133. package/src/src/transforms/esm/http-bundler.ts +1 -1
  134. package/src/src/transforms/esm/lexer.ts +13 -21
  135. package/src/src/transforms/esm/transform-utils.ts +1 -1
  136. package/src/src/transforms/import-rewriter/parse-cache.ts +10 -7
  137. package/src/src/transforms/mdx/esm-module-loader/import-transformer.ts +1 -1
  138. package/src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts +2 -2
  139. package/src/src/utils/version-constant.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/config-generator.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CA0Df"}
1
+ {"version":3,"file":"config-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/config-generator.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CA2Df"}
@@ -44,6 +44,7 @@ export async function createPackageJson(projectDir, projectName, options = {}) {
44
44
  react: `^${DEFAULT_INIT_REACT_VERSION}`,
45
45
  "react-dom": `^${DEFAULT_INIT_REACT_VERSION}`,
46
46
  veryfront: `^${VERSION}`,
47
+ "@veryfront/ext-esbuild": `^${VERSION}`,
47
48
  zod: "^3.24.0",
48
49
  },
49
50
  };
package/esm/cli/main.js CHANGED
@@ -13,6 +13,21 @@
13
13
  import "../_dnt.polyfills.js";
14
14
  import * as dntShim from "../_dnt.shims.js";
15
15
  await import("../src/platform/compat/esbuild-init.js");
16
+ // Register the default Bundler + ModuleLexer contracts shipped with the
17
+ // binary so bootstrap paths can resolve them without the user having to
18
+ // declare @veryfront/ext-esbuild as a project extension. User-installed
19
+ // extensions (orchestrated later) can still override these.
20
+ {
21
+ const { register } = await import("../src/extensions/contracts.js");
22
+ const { tryResolve } = await import("../src/extensions/index.js");
23
+ if (!tryResolve("Bundler") || !tryResolve("ModuleLexer")) {
24
+ const { EsbuildBundler, EsModuleLexer } = await import("../extensions/ext-esbuild/src/index.js");
25
+ if (!tryResolve("Bundler"))
26
+ register("Bundler", new EsbuildBundler());
27
+ if (!tryResolve("ModuleLexer"))
28
+ register("ModuleLexer", new EsModuleLexer());
29
+ }
30
+ }
16
31
  // All imports below must be dynamic to ensure esbuild init completes first
17
32
  const { getArgs } = await import("../src/platform/index.js");
18
33
  const { hasEnvLoaded, loadEnv, markEnvLoaded, supportsEnvFiles } = await import("../src/utils/env-loader.js");
package/esm/deno.d.ts CHANGED
@@ -123,6 +123,9 @@ declare namespace _default {
123
123
  "veryfront/testing": string;
124
124
  "veryfront/testing/assert": string;
125
125
  "veryfront/testing/bdd": string;
126
+ "veryfront/extensions/bundler": string;
127
+ "veryfront/extensions/contracts": string;
128
+ "veryfront/extensions/interfaces": string;
126
129
  "#veryfront": string;
127
130
  "#veryfront/agent": string;
128
131
  "#veryfront/agent/react": string;
@@ -255,9 +258,6 @@ declare namespace _default {
255
258
  "rehype-raw": string;
256
259
  "rehype-sanitize": string;
257
260
  "rehype-stringify": string;
258
- esbuild: string;
259
- "esbuild/mod.js": string;
260
- "es-module-lexer": string;
261
261
  "gray-matter": string;
262
262
  zod: string;
263
263
  mdast: string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.368",
3
+ "version": "0.1.369",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -10,6 +10,7 @@ export default {
10
10
  "./extensions/ext-node-compat",
11
11
  "./extensions/ext-openai",
12
12
  "./extensions/ext-opentelemetry",
13
+ "./extensions/ext-esbuild",
13
14
  "./extensions/ext-redis",
14
15
  "./extensions/ext-tailwind"
15
16
  ],
@@ -143,6 +144,9 @@ export default {
143
144
  "veryfront/testing": "./src/testing/index.ts",
144
145
  "veryfront/testing/assert": "./src/testing/assert.ts",
145
146
  "veryfront/testing/bdd": "./src/testing/bdd.ts",
147
+ "veryfront/extensions/bundler": "./src/extensions/bundler.ts",
148
+ "veryfront/extensions/contracts": "./src/extensions/contracts.ts",
149
+ "veryfront/extensions/interfaces": "./src/extensions/interfaces/index.ts",
146
150
  "#veryfront": "./src/index.ts",
147
151
  "#veryfront/agent": "./src/agent/index.ts",
148
152
  "#veryfront/agent/react": "./src/agent/react/index.ts",
@@ -275,9 +279,6 @@ export default {
275
279
  "rehype-raw": "npm:rehype-raw@7.0.0",
276
280
  "rehype-sanitize": "npm:rehype-sanitize@6.0.0",
277
281
  "rehype-stringify": "npm:rehype-stringify@10.0.1",
278
- "esbuild": "npm:esbuild@0.27.4",
279
- "esbuild/mod.js": "npm:esbuild@0.27.4",
280
- "es-module-lexer": "npm:es-module-lexer@2.0.0",
281
282
  "gray-matter": "npm:gray-matter@4.0.3",
282
283
  "zod": "npm:zod@4.3.6",
283
284
  "mdast": "npm:@types/mdast@4.0.3",
@@ -440,7 +441,6 @@ export default {
440
441
  "npm:onnxruntime-node@1.21.0"
441
442
  ],
442
443
  "deny": [
443
- "npm:esbuild@0.27.4",
444
444
  "npm:protobufjs@7.5.4"
445
445
  ]
446
446
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Idempotent one-shot setup — copies the esbuild binary out of the VFS (if
3
+ * running in `deno compile`) and sets ESBUILD_BINARY_PATH. No-op on normal
4
+ * Deno or when the env var is already set.
5
+ */
6
+ export declare function ensureEsbuildBinary(): Promise<void>;
7
+ //# sourceMappingURL=binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/binary.ts"],"names":[],"mappings":"AAmHA;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiCzD"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Binary extraction for `deno compile` VFS.
3
+ *
4
+ * Ported from src/platform/compat/esbuild.ts + esbuild-shared.ts. When the
5
+ * framework runs as a compiled Deno binary, the esbuild native binary lives
6
+ * inside the VFS and must be copied to a writable path before esbuild's
7
+ * child-process spawn can find it.
8
+ *
9
+ * On normal Deno (not `deno compile`) or when ESBUILD_BINARY_PATH is already
10
+ * set, `ensureEsbuildBinary()` is a no-op.
11
+ *
12
+ * @module extensions/ext-esbuild/binary
13
+ */
14
+ import * as dntShim from "../../../_dnt.shims.js";
15
+ import { isDenoCompiled } from "./runtime.js";
16
+ const ESBUILD_VERSION = "0.27.4";
17
+ function getTempDir() {
18
+ try {
19
+ return (dntShim.Deno.env.get("TMPDIR") ?? dntShim.Deno.env.get("TEMP") ?? dntShim.Deno.env.get("TMP") ?? "/tmp");
20
+ }
21
+ catch {
22
+ return "/tmp";
23
+ }
24
+ }
25
+ function getEsbuildBinaryName() {
26
+ const archMap = { x86_64: "x64", aarch64: "arm64" };
27
+ const arch = archMap[dntShim.Deno.build.arch] ?? dntShim.Deno.build.arch;
28
+ return `@esbuild/${dntShim.Deno.build.os}-${arch}`;
29
+ }
30
+ function getVFSBasePath(filePath, tempDir) {
31
+ const denoCompileMatch = filePath.match(/^(.*\/deno-compile-[^/]+)\//);
32
+ if (denoCompileMatch?.[1])
33
+ return denoCompileMatch[1];
34
+ const parts = filePath.split("/");
35
+ const srcIndex = parts.lastIndexOf("src");
36
+ if (srcIndex > 0)
37
+ return parts.slice(0, srcIndex).join("/");
38
+ return `${tempDir}/deno-compile-veryfront`;
39
+ }
40
+ async function isFile(path) {
41
+ try {
42
+ const stat = await dntShim.Deno.stat(path);
43
+ return stat.isFile;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
49
+ async function findEsbuildInVFS() {
50
+ const binaryName = getEsbuildBinaryName();
51
+ const vfsBase = getVFSBasePath(new URL(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url).pathname, getTempDir());
52
+ const possiblePaths = [
53
+ `${vfsBase}/node_modules/${binaryName}/bin/esbuild`,
54
+ `${vfsBase}/node_modules/.deno/${binaryName}@${ESBUILD_VERSION}/node_modules/${binaryName}/bin/esbuild`,
55
+ `${vfsBase}/node_modules/.deno/esbuild@${ESBUILD_VERSION}/node_modules/${binaryName}/bin/esbuild`,
56
+ `${vfsBase}/node_modules/esbuild/bin/esbuild`,
57
+ `${vfsBase}/node_modules/.package/esbuild@${ESBUILD_VERSION}/bin/esbuild`,
58
+ `${vfsBase}/node_modules/.package/${binaryName}@${ESBUILD_VERSION}/bin/esbuild`,
59
+ ];
60
+ for (const p of possiblePaths) {
61
+ if (await isFile(p))
62
+ return p;
63
+ }
64
+ try {
65
+ const nodeModulesPath = `${vfsBase}/node_modules`;
66
+ for await (const entry of dntShim.Deno.readDir(nodeModulesPath)) {
67
+ if (entry.name !== binaryName && !entry.name.startsWith("@esbuild"))
68
+ continue;
69
+ const binPath = `${nodeModulesPath}/${entry.name}/bin/esbuild`;
70
+ if (await isFile(binPath))
71
+ return binPath;
72
+ }
73
+ }
74
+ catch {
75
+ /* node_modules not readable in VFS */
76
+ }
77
+ return null;
78
+ }
79
+ async function extractEsbuildBinary() {
80
+ const cacheDir = `${getTempDir()}/veryfront-esbuild`;
81
+ const targetPath = `${cacheDir}/esbuild-${ESBUILD_VERSION}`;
82
+ try {
83
+ const stat = await dntShim.Deno.stat(targetPath);
84
+ if (stat.isFile && stat.mode && (stat.mode & 0o111))
85
+ return targetPath;
86
+ }
87
+ catch {
88
+ /* cache miss */
89
+ }
90
+ const vfsPath = await findEsbuildInVFS();
91
+ if (!vfsPath) {
92
+ throw new Error(`[ext-esbuild] Could not find esbuild binary in deno compile VFS. ` +
93
+ `Platform: ${getEsbuildBinaryName()}. ` +
94
+ `Ensure esbuild is in dependencies and deno compile includes node_modules.`);
95
+ }
96
+ await dntShim.Deno.mkdir(cacheDir, { recursive: true });
97
+ const binary = await dntShim.Deno.readFile(vfsPath);
98
+ await dntShim.Deno.writeFile(targetPath, binary, { mode: 0o755 });
99
+ return targetPath;
100
+ }
101
+ let setupComplete = false;
102
+ let setupPromise = null;
103
+ /**
104
+ * Idempotent one-shot setup — copies the esbuild binary out of the VFS (if
105
+ * running in `deno compile`) and sets ESBUILD_BINARY_PATH. No-op on normal
106
+ * Deno or when the env var is already set.
107
+ */
108
+ export async function ensureEsbuildBinary() {
109
+ if (setupComplete)
110
+ return;
111
+ if (setupPromise) {
112
+ await setupPromise;
113
+ return;
114
+ }
115
+ setupPromise = (async () => {
116
+ try {
117
+ if (dntShim.Deno.env.get("ESBUILD_BINARY_PATH") || !isDenoCompiled) {
118
+ setupComplete = true;
119
+ return;
120
+ }
121
+ try {
122
+ const binaryPath = await extractEsbuildBinary();
123
+ dntShim.Deno.env.set("ESBUILD_BINARY_PATH", binaryPath);
124
+ // esbuild reads process.env (not Deno.env) on some code paths.
125
+ const proc = dntShim.dntGlobalThis.process;
126
+ if (proc?.env)
127
+ proc.env.ESBUILD_BINARY_PATH = binaryPath;
128
+ }
129
+ catch (err) {
130
+ console.error("[ext-esbuild] Binary extraction failed:", err);
131
+ }
132
+ }
133
+ finally {
134
+ setupComplete = true;
135
+ }
136
+ })();
137
+ try {
138
+ await setupPromise;
139
+ }
140
+ finally {
141
+ setupPromise = null;
142
+ }
143
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * es-module-lexer-backed implementation of the {@link ModuleLexer} contract.
3
+ *
4
+ * es-module-lexer@2 exports `init` as a Promise in its ESM build but older
5
+ * typings expect a function. We tolerate both shapes (as the in-tree
6
+ * src/transforms/esm/lexer.ts did).
7
+ *
8
+ * @module extensions/ext-esbuild/es-module-lexer
9
+ */
10
+ import type { ImportSpecifier, ModuleLexer } from "../../../src/extensions/interfaces/index.js";
11
+ /** es-module-lexer-backed {@link ModuleLexer} implementation. */
12
+ export declare class EsModuleLexer implements ModuleLexer {
13
+ private initPromise;
14
+ init(): Promise<void>;
15
+ parse(code: string): readonly ImportSpecifier[];
16
+ }
17
+ //# sourceMappingURL=es-module-lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"es-module-lexer.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/es-module-lexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAGhG,iEAAiE;AACjE,qBAAa,aAAc,YAAW,WAAW;IAC/C,OAAO,CAAC,WAAW,CAA8B;IAE3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE;CAIhD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * es-module-lexer-backed implementation of the {@link ModuleLexer} contract.
3
+ *
4
+ * es-module-lexer@2 exports `init` as a Promise in its ESM build but older
5
+ * typings expect a function. We tolerate both shapes (as the in-tree
6
+ * src/transforms/esm/lexer.ts did).
7
+ *
8
+ * @module extensions/ext-esbuild/es-module-lexer
9
+ */
10
+ import { init, parse } from "es-module-lexer";
11
+ /** es-module-lexer-backed {@link ModuleLexer} implementation. */
12
+ export class EsModuleLexer {
13
+ initPromise = null;
14
+ async init() {
15
+ if (this.initPromise) {
16
+ await this.initPromise;
17
+ return;
18
+ }
19
+ const anyInit = init;
20
+ this.initPromise = typeof anyInit === "function"
21
+ ? anyInit()
22
+ : anyInit;
23
+ await this.initPromise;
24
+ }
25
+ parse(code) {
26
+ const [imports] = parse(code);
27
+ return imports;
28
+ }
29
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * esbuild-backed implementation of the {@link Bundler} contract.
3
+ *
4
+ * Lazy-initializes the esbuild binary (including `deno compile` VFS
5
+ * extraction) on first use. All options pass through to esbuild unchanged
6
+ * because the {@link BundleOptions} shape was designed to be esbuild-compatible;
7
+ * the only translation is converting {@link BundlerPlugin}s into esbuild
8
+ * plugins via {@link toEsbuildPlugin}.
9
+ *
10
+ * @module extensions/ext-esbuild/esbuild-bundler
11
+ */
12
+ import type { BuildContext, BundleOptions, Bundler, BundleResult, TransformOptions, TransformResult } from "../../../src/extensions/interfaces/index.js";
13
+ /** esbuild-backed {@link Bundler} implementation. */
14
+ export declare class EsbuildBundler implements Bundler {
15
+ bundle(options: BundleOptions): Promise<BundleResult>;
16
+ transform(options: TransformOptions): Promise<TransformResult>;
17
+ context(options: BundleOptions): Promise<BuildContext>;
18
+ stop(): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=esbuild-bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild-bundler.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/esbuild-bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,OAAO,EACP,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAoDrD,qDAAqD;AACrD,qBAAa,cAAe,YAAW,OAAO;IACtC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAWrD,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAW9D,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAiBtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAM5B"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * esbuild-backed implementation of the {@link Bundler} contract.
3
+ *
4
+ * Lazy-initializes the esbuild binary (including `deno compile` VFS
5
+ * extraction) on first use. All options pass through to esbuild unchanged
6
+ * because the {@link BundleOptions} shape was designed to be esbuild-compatible;
7
+ * the only translation is converting {@link BundlerPlugin}s into esbuild
8
+ * plugins via {@link toEsbuildPlugin}.
9
+ *
10
+ * @module extensions/ext-esbuild/esbuild-bundler
11
+ */
12
+ import { ensureEsbuildBinary } from "./binary.js";
13
+ import { toEsbuildPlugin } from "./plugin-adapter.js";
14
+ let esbuildModule = null;
15
+ async function getEsbuild() {
16
+ await ensureEsbuildBinary();
17
+ if (esbuildModule)
18
+ return esbuildModule;
19
+ esbuildModule = await import("esbuild");
20
+ return esbuildModule;
21
+ }
22
+ // deno-lint-ignore no-explicit-any
23
+ function toMessage(m) {
24
+ return {
25
+ text: m.text,
26
+ location: m.location ?? null,
27
+ notes: m.notes,
28
+ pluginName: m.pluginName,
29
+ detail: m.detail,
30
+ };
31
+ }
32
+ // deno-lint-ignore no-explicit-any
33
+ function toMessages(ms) {
34
+ return (ms ?? []).map(toMessage);
35
+ }
36
+ // deno-lint-ignore no-explicit-any
37
+ function toOutput(f) {
38
+ return {
39
+ path: f.path,
40
+ contents: f.contents,
41
+ text: f.text,
42
+ hash: f.hash,
43
+ };
44
+ }
45
+ function mapOptions(options) {
46
+ const { plugins, ...rest } = options;
47
+ const mapped = { ...rest };
48
+ if (plugins && plugins.length > 0) {
49
+ mapped.plugins = plugins.map(toEsbuildPlugin);
50
+ }
51
+ return mapped;
52
+ }
53
+ /** esbuild-backed {@link Bundler} implementation. */
54
+ export class EsbuildBundler {
55
+ async bundle(options) {
56
+ const esbuild = await getEsbuild();
57
+ const result = await esbuild.build(mapOptions(options));
58
+ return {
59
+ outputFiles: (result.outputFiles ?? []).map(toOutput),
60
+ warnings: toMessages(result.warnings),
61
+ errors: toMessages(result.errors),
62
+ metafile: result.metafile,
63
+ };
64
+ }
65
+ async transform(options) {
66
+ const esbuild = await getEsbuild();
67
+ const { code, ...rest } = options;
68
+ const result = await esbuild.transform(code, rest);
69
+ return {
70
+ code: result.code,
71
+ map: result.map,
72
+ warnings: toMessages(result.warnings).map((m) => m.text),
73
+ };
74
+ }
75
+ async context(options) {
76
+ const esbuild = await getEsbuild();
77
+ const ctx = await esbuild.context(mapOptions(options));
78
+ return {
79
+ rebuild: async () => {
80
+ const result = await ctx.rebuild();
81
+ return {
82
+ outputFiles: (result.outputFiles ?? []).map(toOutput),
83
+ warnings: toMessages(result.warnings),
84
+ errors: toMessages(result.errors),
85
+ metafile: result.metafile,
86
+ };
87
+ },
88
+ dispose: () => ctx.dispose(),
89
+ };
90
+ }
91
+ async stop() {
92
+ const m = esbuildModule;
93
+ if (!m)
94
+ return;
95
+ esbuildModule = null;
96
+ await m.stop();
97
+ }
98
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ext-esbuild — Bundler + ModuleLexer contract implementations backed by
3
+ * esbuild and es-module-lexer.
4
+ *
5
+ * @module extensions/ext-esbuild
6
+ */
7
+ import type { ExtensionFactory } from "../../../src/extensions/index.js";
8
+ import { EsbuildBundler } from "./esbuild-bundler.js";
9
+ import { EsModuleLexer } from "./es-module-lexer.js";
10
+ /**
11
+ * Default export — the ext-esbuild extension factory.
12
+ *
13
+ * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
14
+ * (es-module-lexer-backed) contracts.
15
+ */
16
+ declare const extEsbuild: ExtensionFactory;
17
+ export default extEsbuild;
18
+ export { EsbuildBundler, EsModuleLexer };
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,QAAA,MAAM,UAAU,EAAE,gBAwBjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * ext-esbuild — Bundler + ModuleLexer contract implementations backed by
3
+ * esbuild and es-module-lexer.
4
+ *
5
+ * @module extensions/ext-esbuild
6
+ */
7
+ import { EsbuildBundler } from "./esbuild-bundler.js";
8
+ import { EsModuleLexer } from "./es-module-lexer.js";
9
+ /**
10
+ * Default export — the ext-esbuild extension factory.
11
+ *
12
+ * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
13
+ * (es-module-lexer-backed) contracts.
14
+ */
15
+ const extEsbuild = () => {
16
+ const bundler = new EsbuildBundler();
17
+ const lexer = new EsModuleLexer();
18
+ return {
19
+ name: "ext-esbuild",
20
+ version: "0.1.0",
21
+ capabilities: [
22
+ { type: "contract", name: "Bundler" },
23
+ { type: "contract", name: "ModuleLexer" },
24
+ ],
25
+ setup(ctx) {
26
+ if (!ctx.get("Bundler")) {
27
+ ctx.provide("Bundler", bundler);
28
+ }
29
+ if (!ctx.get("ModuleLexer")) {
30
+ ctx.provide("ModuleLexer", lexer);
31
+ }
32
+ ctx.logger.info("[ext-esbuild] Bundler + ModuleLexer registered");
33
+ },
34
+ async teardown() {
35
+ await bundler.stop?.();
36
+ },
37
+ };
38
+ };
39
+ export default extEsbuild;
40
+ export { EsbuildBundler, EsModuleLexer };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
+ * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
+ * onLoad shapes were deliberately designed to match esbuild's, so the
5
+ * translation is near-1:1; this module exists to isolate the esbuild
6
+ * import from the rest of the extension.
7
+ *
8
+ * @module extensions/ext-esbuild/plugin-adapter
9
+ */
10
+ import type { BundlerPlugin } from "../../../src/extensions/interfaces/index.js";
11
+ type EsbuildPlugin = any;
12
+ export declare function toEsbuildPlugin(plugin: BundlerPlugin): EsbuildPlugin;
13
+ export {};
14
+ //# sourceMappingURL=plugin-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-adapter.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/plugin-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,6CAA6C,CAAC;AAErD,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CA4CpE"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
+ * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
+ * onLoad shapes were deliberately designed to match esbuild's, so the
5
+ * translation is near-1:1; this module exists to isolate the esbuild
6
+ * import from the rest of the extension.
7
+ *
8
+ * @module extensions/ext-esbuild/plugin-adapter
9
+ */
10
+ export function toEsbuildPlugin(plugin) {
11
+ return {
12
+ name: plugin.name,
13
+ // deno-lint-ignore no-explicit-any
14
+ setup(build) {
15
+ const bridged = {
16
+ onResolve(options, callback) {
17
+ // deno-lint-ignore no-explicit-any
18
+ build.onResolve(options, async (args) => {
19
+ const resolveArgs = {
20
+ path: args.path,
21
+ importer: args.importer,
22
+ namespace: args.namespace,
23
+ resolveDir: args.resolveDir,
24
+ kind: args.kind,
25
+ pluginData: args.pluginData,
26
+ };
27
+ const result = await callback(resolveArgs);
28
+ if (result == null)
29
+ return result ?? null;
30
+ return result;
31
+ });
32
+ },
33
+ onLoad(options, callback) {
34
+ // deno-lint-ignore no-explicit-any
35
+ build.onLoad(options, async (args) => {
36
+ const loadArgs = {
37
+ path: args.path,
38
+ namespace: args.namespace,
39
+ suffix: args.suffix,
40
+ pluginData: args.pluginData,
41
+ };
42
+ const result = await callback(loadArgs);
43
+ if (result == null)
44
+ return result ?? null;
45
+ return result;
46
+ });
47
+ },
48
+ onDispose(callback) {
49
+ build.onDispose(callback);
50
+ },
51
+ };
52
+ plugin.setup(bridged);
53
+ },
54
+ };
55
+ }
@@ -0,0 +1,4 @@
1
+ export declare const isDeno: boolean;
2
+ /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
3
+ export declare const isDenoCompiled: boolean;
4
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-esbuild/src/runtime.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,MAAM,EAAE,OAA+D,CAAC;AAkBrF,+EAA+E;AAC/E,eAAO,MAAM,cAAc,EAAE,OAA0C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Runtime detection — inlined from src/platform/compat/runtime.ts so the
3
+ * extension stays dependency-free on core.
4
+ *
5
+ * Only the bits needed by the esbuild binary extractor are included here.
6
+ *
7
+ * @module extensions/ext-esbuild/runtime
8
+ */
9
+ import * as dntShim from "../../../_dnt.shims.js";
10
+ function hasRealDeno() {
11
+ return (typeof dntShim.Deno !== "undefined" &&
12
+ typeof dntShim.Deno.version === "object" &&
13
+ typeof dntShim.Deno.build === "object" &&
14
+ typeof dntShim.Deno.build.os === "string");
15
+ }
16
+ function hasBunGlobal() {
17
+ return dntShim.dntGlobalThis.Bun != null;
18
+ }
19
+ function hasNodeProcess() {
20
+ const g = dntShim.dntGlobalThis;
21
+ return g.process?.versions?.node != null && !g.process?.versions?.deno;
22
+ }
23
+ export const isDeno = !hasNodeProcess() && !hasBunGlobal() && hasRealDeno();
24
+ function testDenoCompiledDetection(execPath) {
25
+ if (!execPath)
26
+ return false;
27
+ const binary = execPath.split(/[/\\]/).pop()?.toLowerCase();
28
+ if (!binary)
29
+ return false;
30
+ return binary !== "deno" && binary !== "deno.exe";
31
+ }
32
+ function isDenoCompiledBinary() {
33
+ if (!hasRealDeno())
34
+ return false;
35
+ try {
36
+ return testDenoCompiledDetection(dntShim.Deno.execPath());
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
43
+ export const isDenoCompiled = isDeno && isDenoCompiledBinary();
@@ -1,4 +1,4 @@
1
- import type { Tool } from "../tool/index.js";
1
+ import { type HostToolSet, type Tool, type TraceHostToolsOptions } from "../tool/index.js";
2
2
  import type { AgUiRuntimeStreamEvent } from "./ag-ui-browser-encoder.js";
3
3
  import type { AgentResponse, Message as AgentMessage } from "./schemas/index.js";
4
4
  interface ForkStreamPart {
@@ -146,6 +146,16 @@ export type StartAgentRuntimeForkInput = {
146
146
  prepareStep?: ForkRuntimeStepPreparer;
147
147
  runStep?: AgentRuntimeForkStepRunner;
148
148
  };
149
+ export type StartAgentRuntimeForkWithHostToolsInput = Omit<StartAgentRuntimeForkInput, "forkToolNames" | "model" | "runtimeTools"> & {
150
+ provider: string;
151
+ forkModel: string;
152
+ forkTools: HostToolSet;
153
+ traceTools?: TraceHostToolsOptions;
154
+ };
155
+ export declare function startAgentRuntimeForkWithHostTools(input: StartAgentRuntimeForkWithHostToolsInput): {
156
+ streamResult: ForkRuntimeStreamResult;
157
+ forkToolNames: string[];
158
+ };
149
159
  export type RunAgentRuntimeForkStepInput = {
150
160
  apiUrl: string;
151
161
  authToken: string;