experimental-ash 0.4.0-alpha.4 → 0.4.0-alpha.5

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 (34) hide show
  1. package/dist/src/chunks/{chunk-RFVUX6HI.js → chunk-5MWN254M.js} +2 -2
  2. package/dist/src/chunks/{chunk-26J42T7K.js → chunk-64BCIOPA.js} +3 -5
  3. package/dist/src/chunks/{chunk-CRDH75PY.js → chunk-CZAR3ZGN.js} +2 -2
  4. package/dist/src/chunks/{chunk-TP5TFXAL.js → chunk-DQ3VFCWN.js} +78 -5
  5. package/dist/src/chunks/chunk-DQ3VFCWN.js.map +7 -0
  6. package/dist/src/chunks/{chunk-VUESBSNV.js → chunk-XMBTGWNT.js} +42 -149
  7. package/dist/src/chunks/{chunk-VUESBSNV.js.map → chunk-XMBTGWNT.js.map} +2 -2
  8. package/dist/src/chunks/{dev-authored-source-watcher-6TM2MLOF.js → dev-authored-source-watcher-VAWAOB2Z.js} +4 -4
  9. package/dist/src/chunks/{host-DABU6JKC.js → host-W7OLYKOF.js} +5 -5
  10. package/dist/src/cli/commands/info.js +2 -2
  11. package/dist/src/cli/run.js +2 -2
  12. package/dist/src/context/providers/sandbox.d.ts.map +1 -1
  13. package/dist/src/context/providers/sandbox.js +1 -0
  14. package/dist/src/context/providers/sandbox.js.map +1 -1
  15. package/dist/src/evals/cli/eval.js +5 -5
  16. package/dist/src/evals/runner/discover.js +2 -2
  17. package/dist/src/execution/sandbox/prewarm.d.ts +4 -4
  18. package/dist/src/execution/sandbox/prewarm.d.ts.map +1 -1
  19. package/dist/src/execution/sandbox/prewarm.js +28 -132
  20. package/dist/src/execution/sandbox/prewarm.js.map +1 -1
  21. package/dist/src/execution/skills/seed.d.ts +4 -13
  22. package/dist/src/execution/skills/seed.d.ts.map +1 -1
  23. package/dist/src/execution/skills/seed.js +13 -52
  24. package/dist/src/execution/skills/seed.js.map +1 -1
  25. package/dist/src/internal/application/package.js +1 -1
  26. package/dist/src/internal/authored-module-loader.js +89 -12
  27. package/dist/src/internal/authored-module-loader.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/src/chunks/chunk-TP5TFXAL.js.map +0 -7
  30. /package/dist/src/chunks/{chunk-RFVUX6HI.js.map → chunk-5MWN254M.js.map} +0 -0
  31. /package/dist/src/chunks/{chunk-26J42T7K.js.map → chunk-64BCIOPA.js.map} +0 -0
  32. /package/dist/src/chunks/{chunk-CRDH75PY.js.map → chunk-CZAR3ZGN.js.map} +0 -0
  33. /package/dist/src/chunks/{dev-authored-source-watcher-6TM2MLOF.js.map → dev-authored-source-watcher-VAWAOB2Z.js.map} +0 -0
  34. /package/dist/src/chunks/{host-DABU6JKC.js.map → host-W7OLYKOF.js.map} +0 -0
@@ -11,7 +11,7 @@ import {
11
11
  loadCompiledManifest,
12
12
  resolveWorkflowBuildDirectory,
13
13
  stringifyEsmImportSpecifier
14
- } from "./chunk-26J42T7K.js";
14
+ } from "./chunk-64BCIOPA.js";
15
15
  import {
16
16
  resolvePackageSourceFilePath
17
17
  } from "./chunk-E7IAIRUB.js";
@@ -594,4 +594,4 @@ export {
594
594
  createAuthoredSourceRuntimeCompiledArtifactsSource,
595
595
  prepareApplicationHost
596
596
  };
597
- //# sourceMappingURL=chunk-RFVUX6HI.js.map
597
+ //# sourceMappingURL=chunk-5MWN254M.js.map
@@ -13,7 +13,7 @@ import {
13
13
  loadAuthoredModuleNamespace,
14
14
  materializeAuthoredModuleExport,
15
15
  registerChannelModuleInCache
16
- } from "./chunk-TP5TFXAL.js";
16
+ } from "./chunk-DQ3VFCWN.js";
17
17
  import {
18
18
  require_gray_matter
19
19
  } from "./chunk-UQPZY6ZZ.js";
@@ -28809,15 +28809,13 @@ export {
28809
28809
  loadCompileMetadata,
28810
28810
  resolveRuntimeCompiledArtifactsVersionedCacheKey,
28811
28811
  ROOT_RUNTIME_AGENT_NODE_ID,
28812
+ getResolvedRuntimeAgentNode,
28812
28813
  loadCompiledManifest,
28813
28814
  WORKSPACE_ROOT,
28814
28815
  createWorkspaceSpec,
28815
28816
  getFrameworkChannelDefinitions,
28816
28817
  getAllFrameworkChannelNames,
28817
- DEFAULT_SANDBOX_SOURCE_ID,
28818
- createFrameworkSandboxDefinition,
28819
28818
  resolveRuntimeAgentGraph,
28820
- getCompiledRuntimeAgentBundle,
28821
28819
  clearCompiledRuntimeAgentBundleCache,
28822
28820
  resolveApplicationRoot,
28823
28821
  resolveNitroBuildDirectory,
@@ -28825,4 +28823,4 @@ export {
28825
28823
  resolveWorkflowBuildDirectory,
28826
28824
  getApplicationInfo
28827
28825
  };
28828
- //# sourceMappingURL=chunk-26J42T7K.js.map
28826
+ //# sourceMappingURL=chunk-64BCIOPA.js.map
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __ashCreateRequire } from "node:module"; const require = __ashCreateRequire(import.meta.url);
2
2
  import {
3
3
  loadAuthoredModuleNamespace
4
- } from "./chunk-TP5TFXAL.js";
4
+ } from "./chunk-DQ3VFCWN.js";
5
5
 
6
6
  // src/evals/runner/discover.ts
7
7
  import { readdir } from "node:fs/promises";
@@ -77,4 +77,4 @@ export {
77
77
  importSuiteFile,
78
78
  discoverAndImportSuites
79
79
  };
80
- //# sourceMappingURL=chunk-CRDH75PY.js.map
80
+ //# sourceMappingURL=chunk-CZAR3ZGN.js.map
@@ -3,7 +3,7 @@ import { createRequire as __ashCreateRequire } from "node:module"; const require
3
3
  // src/internal/authored-module-loader.ts
4
4
  import { createHash } from "node:crypto";
5
5
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
6
- import { dirname, join, resolve } from "node:path";
6
+ import { dirname, join, resolve, sep } from "node:path";
7
7
 
8
8
  // src/internal/authored-module.ts
9
9
  function getAuthoredModuleExport(moduleNamespace, source) {
@@ -117,7 +117,9 @@ function createFileImportSpecifier(modulePath) {
117
117
  async function loadBundledAuthoredModule(modulePath) {
118
118
  const channelCache = getChannelModuleCache();
119
119
  const { build } = await import("esbuild");
120
- const plugins = channelCache && channelCache.size > 0 ? [
120
+ const packageRoot = resolveAuthoredPackageRoot(modulePath);
121
+ const packageBoundaryPlugin = createPackageBoundaryPlugin(packageRoot);
122
+ const channelIdentityPlugins = channelCache && channelCache.size > 0 ? [
121
123
  {
122
124
  name: "ash-channel-identity",
123
125
  setup(pluginBuild) {
@@ -146,14 +148,23 @@ async function loadBundledAuthoredModule(modulePath) {
146
148
  }
147
149
  }
148
150
  ] : [];
149
- const packageRoot = resolveAuthoredPackageRoot(modulePath);
151
+ const plugins = [packageBoundaryPlugin, ...channelIdentityPlugins];
150
152
  const result = await build({
151
153
  absWorkingDir: packageRoot,
154
+ banner: {
155
+ js: [
156
+ 'import { createRequire as __ashCreateRequire } from "node:module";',
157
+ 'import { dirname as __ashDirname } from "node:path";',
158
+ 'import { fileURLToPath as __ashFileURLToPath } from "node:url";',
159
+ "const require = __ashCreateRequire(import.meta.url);",
160
+ "const __filename = __ashFileURLToPath(import.meta.url);",
161
+ "const __dirname = __ashDirname(__filename);"
162
+ ].join("\n")
163
+ },
152
164
  bundle: true,
153
165
  entryPoints: [modulePath],
154
166
  format: "esm",
155
167
  legalComments: "none",
156
- packages: "external",
157
168
  platform: "node",
158
169
  plugins,
159
170
  resolveExtensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json"],
@@ -174,6 +185,68 @@ async function loadBundledAuthoredModule(modulePath) {
174
185
  }
175
186
  return await import(`${createFileImportSpecifier(bundlePath)}?v=${bundleHash}`);
176
187
  }
188
+ function createPackageBoundaryPlugin(packageRoot) {
189
+ return {
190
+ name: "ash-package-boundary",
191
+ setup(pluginBuild) {
192
+ pluginBuild.onResolve({ filter: /.*/ }, async (args) => {
193
+ if (args.pluginData?.ashPackageBoundaryResolving === true) {
194
+ return void 0;
195
+ }
196
+ if (!isPackageImport(args.path)) {
197
+ return void 0;
198
+ }
199
+ if (isAshFrameworkImport(args.path)) {
200
+ return {
201
+ external: true,
202
+ path: args.path
203
+ };
204
+ }
205
+ const importer = args.importer === "" ? void 0 : resolve(args.importer);
206
+ if (importer !== void 0 && isPathInsideOrEqual(importer, packageRoot)) {
207
+ const resolved = await pluginBuild.resolve(args.path, {
208
+ kind: args.kind,
209
+ pluginData: { ashPackageBoundaryResolving: true },
210
+ resolveDir: args.resolveDir
211
+ });
212
+ if (resolved.errors.length > 0 || resolved.path === "") {
213
+ return {
214
+ external: true,
215
+ path: args.path
216
+ };
217
+ }
218
+ if (isNodeModulesPath(resolved.path)) {
219
+ return {
220
+ external: true,
221
+ path: args.path
222
+ };
223
+ }
224
+ }
225
+ return void 0;
226
+ });
227
+ }
228
+ };
229
+ }
230
+ function isPackageImport(source) {
231
+ if (source.startsWith(".") || source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source)) {
232
+ return false;
233
+ }
234
+ if (/^(?:node|data|file):/.test(source)) {
235
+ return false;
236
+ }
237
+ return true;
238
+ }
239
+ function isAshFrameworkImport(source) {
240
+ return source === "experimental-ash" || source.startsWith("experimental-ash/");
241
+ }
242
+ function isNodeModulesPath(path) {
243
+ return path.replaceAll("\\", "/").includes("/node_modules/");
244
+ }
245
+ function isPathInsideOrEqual(path, directory) {
246
+ const resolvedPath = resolve(path);
247
+ const resolvedDirectory = resolve(directory);
248
+ return resolvedPath === resolvedDirectory || resolvedPath.startsWith(`${resolvedDirectory}${sep}`);
249
+ }
177
250
  function resolveAuthoredPackageRoot(modulePath) {
178
251
  let currentDirectory = dirname(modulePath);
179
252
  while (true) {
@@ -200,4 +273,4 @@ export {
200
273
  registerChannelModuleInCache,
201
274
  loadAuthoredModuleNamespace
202
275
  };
203
- //# sourceMappingURL=chunk-TP5TFXAL.js.map
276
+ //# sourceMappingURL=chunk-DQ3VFCWN.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/authored-module-loader.ts", "../../../src/internal/authored-module.ts"],
4
+ "sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, resolve, sep } from \"node:path\";\n\nimport { expectObjectRecord } from \"#internal/authored-module.js\";\n\nconst AUTHORED_BUNDLED_MODULE_EXTENSION = /\\.[cm]?[jt]sx?$/;\nconst AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH = join(\n \"node_modules\",\n \".cache\",\n \"experimental-ash\",\n \"authored-modules\",\n);\n\nconst CHANNEL_MODULE_CACHE_KEY = \"__ashChannelModuleCache__\";\n\n/**\n * Registers a loaded channel module in the global cache so esbuild-\n * bundled schedule modules that import the same channel get the exact\n * same route object instance.\n */\nexport function registerChannelModuleInCache(absolutePath: string, moduleDefault: unknown): void {\n const cache = ((globalThis as Record<string, unknown>)[CHANNEL_MODULE_CACHE_KEY] ??= new Map<\n string,\n unknown\n >()) as Map<string, unknown>;\n cache.set(resolve(absolutePath), moduleDefault);\n}\n\nfunction getChannelModuleCache(): Map<string, unknown> | undefined {\n return (globalThis as Record<string, unknown>)[CHANNEL_MODULE_CACHE_KEY] as\n | Map<string, unknown>\n | undefined;\n}\n\n/**\n * In-flight load deduplication map keyed by the absolute module path.\n *\n * The compiler walks every authored slot concurrently\n * (`compileChannelDefinition` and `buildChannelRouteIdentityMap` both\n * load the same channel module via `Promise.all`), so the same module\n * path is frequently loaded twice in parallel. Without dedup, both\n * callers race the esbuild bundle/write/import pipeline against the\n * same `node_modules/.cache/.../<hash>.mjs` file: one call's\n * `writeFile` can truncate the bundle while another's `import()` is\n * still resolving it, surfacing as intermittent\n * \"Expected \u2026 to match the public Ash shape\" failures during\n * compilation.\n *\n * The map only holds in-flight promises; once a load settles the entry\n * is cleared so subsequent compiles (e.g. a dev-server reload after\n * the author edits a file) re-run the bundle pipeline against the\n * fresh source. Node's ESM cache then dedupes by content-hashed URL\n * for unchanged files. The companion \"skip write when the cache file\n * already exists\" check inside {@link loadBundledAuthoredModule}\n * eliminates the write/read race even when two non-concurrent compile\n * passes overlap on the same hashed bundle path.\n */\nconst inFlightModuleLoads = new Map<string, Promise<Record<string, unknown>>>();\n\n/**\n * Loads one authored module namespace from disk during compile-time\n * discovery. Concurrent loads of the same `modulePath` share a single\n * Promise so the underlying esbuild bundle/import pipeline runs once.\n */\nexport function loadAuthoredModuleNamespace(modulePath: string): Promise<Record<string, unknown>> {\n const cacheKey = resolve(modulePath);\n const inFlight = inFlightModuleLoads.get(cacheKey);\n\n if (inFlight !== undefined) {\n return inFlight;\n }\n\n const loadPromise = (async () => {\n try {\n return await doLoadAuthoredModuleNamespace(modulePath);\n } finally {\n inFlightModuleLoads.delete(cacheKey);\n }\n })();\n inFlightModuleLoads.set(cacheKey, loadPromise);\n return loadPromise;\n}\n\nasync function doLoadAuthoredModuleNamespace(modulePath: string): Promise<Record<string, unknown>> {\n const loadedModule = AUTHORED_BUNDLED_MODULE_EXTENSION.test(modulePath)\n ? await loadBundledAuthoredModule(modulePath)\n : await import(createFileImportSpecifier(modulePath));\n\n return expectObjectRecord(\n loadedModule,\n `Expected \"${modulePath}\" to export a module namespace object.`,\n );\n}\n\nfunction createFileImportSpecifier(modulePath: string): string {\n const normalizedPath = modulePath.replaceAll(\"\\\\\", \"/\");\n\n if (/^[A-Za-z]:\\//.test(normalizedPath)) {\n return `file:///${encodeURI(normalizedPath)}`;\n }\n\n if (normalizedPath.startsWith(\"/\")) {\n return `file://${encodeURI(normalizedPath)}`;\n }\n\n return normalizedPath;\n}\n\nasync function loadBundledAuthoredModule(modulePath: string): Promise<unknown> {\n const channelCache = getChannelModuleCache();\n const { build } = await import(\"esbuild\");\n // Pin esbuild's working directory to the authored package root. The\n // shared esbuild service inherits its cwd from whatever directory the\n // host process happened to be in when esbuild was first imported, and\n // that directory may no longer exist (or no longer contain the entry\n // point) by the time later compile calls run from a freshly-created\n // scratch directory. Pinning to the package root keeps resolution\n // deterministic and produces stable relative paths in error messages\n // (e.g. \"agent/tools/bad.ts\" rather than just \"bad.ts\").\n const packageRoot = resolveAuthoredPackageRoot(modulePath);\n const packageBoundaryPlugin = createPackageBoundaryPlugin(packageRoot);\n const channelIdentityPlugins =\n channelCache && channelCache.size > 0\n ? [\n {\n name: \"ash-channel-identity\",\n setup(pluginBuild: import(\"esbuild\").PluginBuild) {\n pluginBuild.onResolve({ filter: /channels[/\\\\]/ }, (args) => {\n if (args.pluginData?.resolving || args.kind !== \"import-statement\") {\n return undefined;\n }\n return pluginBuild\n .resolve(args.path, {\n kind: args.kind,\n resolveDir: args.resolveDir,\n pluginData: { resolving: true },\n })\n .then((r) => {\n if (r.errors.length > 0) return undefined;\n const resolved = resolve(r.path);\n if (!channelCache.has(resolved)) return undefined;\n return { path: resolved, namespace: \"ash-cached-channel\" };\n });\n });\n pluginBuild.onLoad({ filter: /.*/, namespace: \"ash-cached-channel\" }, (args) => ({\n contents: [\n `const cache = globalThis[\"${CHANNEL_MODULE_CACHE_KEY}\"];`,\n `export default cache.get(${JSON.stringify(args.path)});`,\n ].join(\"\\n\"),\n loader: \"js\" as const,\n }));\n },\n },\n ]\n : [];\n const plugins = [packageBoundaryPlugin, ...channelIdentityPlugins];\n const result = await build({\n absWorkingDir: packageRoot,\n banner: {\n js: [\n 'import { createRequire as __ashCreateRequire } from \"node:module\";',\n 'import { dirname as __ashDirname } from \"node:path\";',\n 'import { fileURLToPath as __ashFileURLToPath } from \"node:url\";',\n \"const require = __ashCreateRequire(import.meta.url);\",\n \"const __filename = __ashFileURLToPath(import.meta.url);\",\n \"const __dirname = __ashDirname(__filename);\",\n ].join(\"\\n\"),\n },\n bundle: true,\n entryPoints: [modulePath],\n format: \"esm\",\n legalComments: \"none\",\n platform: \"node\",\n plugins,\n resolveExtensions: [\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n sourcemap: \"inline\",\n target: [`node${process.versions.node.split(\".\")[0]}`],\n write: false,\n });\n const outputFile = result.outputFiles[0];\n\n if (outputFile === undefined) {\n throw new Error(`Expected esbuild to emit one bundled module for \"${modulePath}\".`);\n }\n\n const bundleHash = createHash(\"sha1\")\n .update(modulePath)\n .update(\"\\0\")\n .update(outputFile.text)\n .digest(\"hex\");\n const bundleDirectoryPath = join(packageRoot, AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH);\n const bundlePath = join(bundleDirectoryPath, `${bundleHash}.mjs`);\n\n // The bundle filename is the content hash, so if the file already\n // exists it must already hold the correct bytes. Skipping the write\n // avoids re-truncating the file underneath any in-flight `import()`\n // that's still reading the previous compile's bytes. Sync I/O keeps\n // the writer atomic from JS's perspective: nothing else on this\n // event loop can touch the file between mkdir and writeFile.\n if (!existsSync(bundlePath)) {\n mkdirSync(bundleDirectoryPath, { recursive: true });\n writeFileSync(bundlePath, outputFile.text);\n }\n\n return await import(`${createFileImportSpecifier(bundlePath)}?v=${bundleHash}`);\n}\n\nfunction createPackageBoundaryPlugin(packageRoot: string): import(\"esbuild\").Plugin {\n return {\n name: \"ash-package-boundary\",\n setup(pluginBuild) {\n pluginBuild.onResolve({ filter: /.*/ }, async (args) => {\n if (args.pluginData?.ashPackageBoundaryResolving === true) {\n return undefined;\n }\n\n if (!isPackageImport(args.path)) {\n return undefined;\n }\n\n if (isAshFrameworkImport(args.path)) {\n return {\n external: true,\n path: args.path,\n };\n }\n\n const importer = args.importer === \"\" ? undefined : resolve(args.importer);\n\n // Keep package imports authored directly by the app external by\n // default, but let symlinked/file workspace packages compile as\n // source. Those packages often export `.ts` files and rely on the\n // bundler's extension resolution for their own relative imports.\n if (importer !== undefined && isPathInsideOrEqual(importer, packageRoot)) {\n const resolved = await pluginBuild.resolve(args.path, {\n kind: args.kind,\n pluginData: { ashPackageBoundaryResolving: true },\n resolveDir: args.resolveDir,\n });\n\n if (resolved.errors.length > 0 || resolved.path === \"\") {\n return {\n external: true,\n path: args.path,\n };\n }\n\n if (isNodeModulesPath(resolved.path)) {\n return {\n external: true,\n path: args.path,\n };\n }\n }\n\n return undefined;\n });\n },\n };\n}\n\nfunction isPackageImport(source: string): boolean {\n if (source.startsWith(\".\") || source.startsWith(\"/\") || /^[A-Za-z]:[\\\\/]/.test(source)) {\n return false;\n }\n\n if (/^(?:node|data|file):/.test(source)) {\n return false;\n }\n\n return true;\n}\n\nfunction isAshFrameworkImport(source: string): boolean {\n return source === \"experimental-ash\" || source.startsWith(\"experimental-ash/\");\n}\n\nfunction isNodeModulesPath(path: string): boolean {\n return path.replaceAll(\"\\\\\", \"/\").includes(\"/node_modules/\");\n}\n\nfunction isPathInsideOrEqual(path: string, directory: string): boolean {\n const resolvedPath = resolve(path);\n const resolvedDirectory = resolve(directory);\n\n return (\n resolvedPath === resolvedDirectory || resolvedPath.startsWith(`${resolvedDirectory}${sep}`)\n );\n}\n\nfunction resolveAuthoredPackageRoot(modulePath: string): string {\n let currentDirectory = dirname(modulePath);\n\n while (true) {\n if (existsSync(join(currentDirectory, \"package.json\"))) {\n return currentDirectory;\n }\n\n const parentDirectory = dirname(currentDirectory);\n\n if (parentDirectory === currentDirectory) {\n throw new Error(`Failed to resolve the authored package root for \"${modulePath}\".`);\n }\n\n currentDirectory = parentDirectory;\n }\n}\n", "import type { ModuleDefinitionExport } from \"#public/definitions/source.js\";\nimport type { JsonObject } from \"#shared/json.js\";\nimport type { ModuleSourceRef } from \"#shared/source-ref.js\";\nimport type { AgentModelOptionsDefinition } from \"#shared/agent-definition.js\";\n\n/**\n * Returns the selected authored module export from one namespace.\n */\nexport function getAuthoredModuleExport(\n moduleNamespace: Record<string, unknown>,\n source: ModuleSourceRef | { readonly exportName?: string; readonly logicalPath: string },\n): unknown {\n return moduleNamespace[source.exportName ?? \"default\"];\n}\n\n/**\n * Materializes one authored module export that may be a definition factory.\n */\nexport async function materializeAuthoredModuleExport<TDefinition>(\n exportValue: ModuleDefinitionExport<TDefinition>,\n): Promise<TDefinition> {\n if (typeof exportValue === \"function\") {\n const definitionFactory = exportValue as () => TDefinition | Promise<TDefinition>;\n return await definitionFactory();\n }\n\n return exportValue;\n}\n\n/**\n * Returns the value as a plain object or throws.\n */\nexport function expectObjectRecord(value: unknown, message: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new Error(message);\n }\n\n return value as Record<string, unknown>;\n}\n\n/**\n * Returns the value as a string or throws.\n */\nexport function expectString(value: unknown, message: string): string {\n if (typeof value !== \"string\") {\n throw new Error(message);\n }\n\n return value;\n}\n\n/**\n * Returns the value as a function or throws.\n */\nexport function expectFunction<TFunction extends (...args: never[]) => unknown>(\n value: unknown,\n message: string,\n): TFunction {\n if (typeof value !== \"function\") {\n throw new Error(message);\n }\n\n return value as TFunction;\n}\n\n/**\n * Returns the value as a provider options object or throws.\n */\nexport function expectProviderOptions(\n value: unknown,\n message: string,\n): Required<AgentModelOptionsDefinition>[\"providerOptions\"] {\n const record = expectObjectRecord(value, message);\n const providerOptions: Required<AgentModelOptionsDefinition>[\"providerOptions\"] = {};\n for (const [key, entryValue] of Object.entries(record)) {\n const entryRecord = expectObjectRecord(entryValue, message);\n providerOptions[key] = entryRecord as JsonObject;\n }\n return providerOptions;\n}\n\n/**\n * Rejects unexpected keys on one plain object.\n */\nexport function expectOnlyKnownKeys(\n record: Record<string, unknown>,\n knownKeys: readonly string[],\n message: string,\n): void {\n const knownKeySet = new Set(knownKeys);\n\n for (const key of Object.keys(record)) {\n if (!knownKeySet.has(key)) {\n throw new Error(`${message} Unknown key \"${key}\".`);\n }\n }\n}\n\n/**\n * Returns one optional string property when present.\n */\nexport function getOptionalStringProperty(\n record: Record<string, unknown>,\n key: string,\n message: string,\n): string | undefined {\n const value = record[key];\n\n if (value === undefined) {\n return undefined;\n }\n\n return expectString(value, message);\n}\n\n/**\n * Returns one optional string-record property when present.\n */\nexport function getOptionalStringRecordProperty(\n record: Record<string, unknown>,\n key: string,\n message: string,\n): Record<string, string> | undefined {\n const value = record[key];\n\n if (value === undefined) {\n return undefined;\n }\n\n const objectValue = expectObjectRecord(value, message);\n const normalizedValue: Record<string, string> = {};\n\n for (const [entryKey, entryValue] of Object.entries(objectValue)) {\n normalizedValue[entryKey] = expectString(entryValue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S,gBAAgB;AAC7D;AAEA,SAAS,oBAAoB,MAAc,WAA4B;AACrE,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,oBAAoB,QAAQ,SAAS;AAE3C,SACE,iBAAiB,qBAAqB,aAAa,WAAW,GAAG,iBAAiB,GAAG,GAAG,EAAE;AAE9F;AAEA,SAAS,2BAA2B,YAA4B;AAC9D,MAAI,mBAAmB,QAAQ,UAAU;AAEzC,SAAO,MAAM;AACX,QAAI,WAAW,KAAK,kBAAkB,cAAc,CAAC,GAAG;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,kBAAkB,QAAQ,gBAAgB;AAEhD,QAAI,oBAAoB,kBAAkB;AACxC,YAAM,IAAI,MAAM,oDAAoD,UAAU,IAAI;AAAA,IACpF;AAEA,uBAAmB;AAAA,EACrB;AACF;",
6
+ "names": []
7
+ }
@@ -7,15 +7,13 @@ import {
7
7
  prepareApplicationHost,
8
8
  registerChannelVirtualHandlers,
9
9
  registerScheduleTaskHandlers
10
- } from "./chunk-RFVUX6HI.js";
10
+ } from "./chunk-5MWN254M.js";
11
11
  import {
12
- DEFAULT_SANDBOX_SOURCE_ID,
13
12
  ROOT_COMPILED_AGENT_NODE_ID,
14
13
  ROOT_RUNTIME_AGENT_NODE_ID,
15
14
  WORKSPACE_ROOT,
16
15
  collectModuleRefsForManifest,
17
- createFrameworkSandboxDefinition,
18
- getCompiledRuntimeAgentBundle,
16
+ getResolvedRuntimeAgentNode,
19
17
  getRuntimeCompiledArtifactsAppRoot,
20
18
  getRuntimeCompiledArtifactsCacheKey,
21
19
  loadCompileMetadata,
@@ -28,10 +26,10 @@ import {
28
26
  resolveRuntimeAgentGraph,
29
27
  resolveRuntimeCompiledArtifactsVersionedCacheKey,
30
28
  stringifyEsmImportSpecifier
31
- } from "./chunk-26J42T7K.js";
29
+ } from "./chunk-64BCIOPA.js";
32
30
  import {
33
31
  loadAuthoredModuleNamespace
34
- } from "./chunk-TP5TFXAL.js";
32
+ } from "./chunk-DQ3VFCWN.js";
35
33
  import {
36
34
  ASH_PACKAGE_NAME,
37
35
  resolveInstalledPackageInfo,
@@ -1730,28 +1728,26 @@ async function collectSkillSeedFiles(skills) {
1730
1728
  }
1731
1729
  return files;
1732
1730
  }
1733
- async function collectGraphSkillSeedFiles(graph) {
1734
- const collected = await collectSkillSeedFiles(collectGraphSkillSources(graph));
1735
- return dedupeSeedFiles(collected);
1736
- }
1737
1731
  async function getCompiledSkillSeedFiles(input) {
1738
1732
  const sourceKey = getRuntimeCompiledArtifactsCacheKey(input.compiledArtifactsSource);
1739
- const cacheKey = await resolveRuntimeCompiledArtifactsVersionedCacheKey(
1733
+ const versionedSourceKey = await resolveRuntimeCompiledArtifactsVersionedCacheKey(
1740
1734
  input.compiledArtifactsSource
1741
1735
  );
1742
- const previousKey = compiledSkillSeedFilesCacheKeyBySourceKey.get(sourceKey);
1736
+ const sourceNodeKey = `${sourceKey}:${input.nodeId}`;
1737
+ const cacheKey = `${versionedSourceKey}:${input.nodeId}`;
1738
+ const previousKey = compiledSkillSeedFilesCacheKeyBySourceKey.get(sourceNodeKey);
1743
1739
  if (previousKey !== void 0 && previousKey !== cacheKey) {
1744
1740
  compiledSkillSeedFilesCache.delete(previousKey);
1745
1741
  }
1746
- compiledSkillSeedFilesCacheKeyBySourceKey.set(sourceKey, cacheKey);
1742
+ compiledSkillSeedFilesCacheKeyBySourceKey.set(sourceNodeKey, cacheKey);
1747
1743
  const cached = compiledSkillSeedFilesCache.get(cacheKey);
1748
1744
  if (cached !== void 0) {
1749
1745
  return cached;
1750
1746
  }
1751
- const promise = loadCompiledSkillSeedFiles(input).catch((error) => {
1747
+ const promise = loadCompiledSkillSeedFiles(input.graph, input.nodeId).catch((error) => {
1752
1748
  compiledSkillSeedFilesCache.delete(cacheKey);
1753
- if (compiledSkillSeedFilesCacheKeyBySourceKey.get(sourceKey) === cacheKey) {
1754
- compiledSkillSeedFilesCacheKeyBySourceKey.delete(sourceKey);
1749
+ if (compiledSkillSeedFilesCacheKeyBySourceKey.get(sourceNodeKey) === cacheKey) {
1750
+ compiledSkillSeedFilesCacheKeyBySourceKey.delete(sourceNodeKey);
1755
1751
  }
1756
1752
  throw error;
1757
1753
  });
@@ -1773,38 +1769,9 @@ async function collectDirectoryFiles(dirPath) {
1773
1769
  }
1774
1770
  return results;
1775
1771
  }
1776
- async function loadCompiledSkillSeedFiles(input) {
1777
- const graph = input.graph ?? (await getCompiledRuntimeAgentBundle({
1778
- compiledArtifactsSource: input.compiledArtifactsSource
1779
- })).graph;
1780
- return await collectGraphSkillSeedFiles(graph);
1781
- }
1782
- function collectGraphSkillSources(graph) {
1783
- const skillsBySourceId = /* @__PURE__ */ new Map();
1784
- for (const node of graph.nodesByNodeId.values()) {
1785
- for (const skill of node.turnAgent.skills) {
1786
- if (!skillsBySourceId.has(skill.sourceId)) {
1787
- skillsBySourceId.set(skill.sourceId, skill);
1788
- }
1789
- }
1790
- }
1791
- return [...skillsBySourceId.values()].sort(
1792
- (left, right) => left.logicalPath.localeCompare(right.logicalPath)
1793
- );
1794
- }
1795
- function dedupeSeedFiles(files) {
1796
- const filesByPath = /* @__PURE__ */ new Map();
1797
- for (const file of files) {
1798
- const existing = filesByPath.get(file.path);
1799
- if (existing === void 0) {
1800
- filesByPath.set(file.path, file);
1801
- continue;
1802
- }
1803
- if (!existing.content.equals(file.content)) {
1804
- throw new Error(`Conflicting skill seed file contents for "${file.path}".`);
1805
- }
1806
- }
1807
- return [...filesByPath.values()].sort((left, right) => left.path.localeCompare(right.path));
1772
+ async function loadCompiledSkillSeedFiles(graph, nodeId) {
1773
+ const node = getResolvedRuntimeAgentNode(graph, nodeId);
1774
+ return await collectSkillSeedFiles(node.turnAgent.skills);
1808
1775
  }
1809
1776
 
1810
1777
  // src/execution/sandbox/prewarm.ts
@@ -1814,63 +1781,42 @@ async function prewarmExecutionSandboxTemplates(input) {
1814
1781
  return;
1815
1782
  }
1816
1783
  input.log?.(
1817
- `Ash: initializing ${targets.length} execution sandbox ${pluralize(targets.length, "template")} during build for runtime use (${formatExecutionSandboxPrewarmCounts(targets)})...`
1784
+ `Ash: initializing ${targets.length} execution sandbox ${pluralize(targets.length, "template")} during build for runtime use (${formatExecutionSandboxPrewarmTemplateCount(targets)})...`
1818
1785
  );
1819
1786
  const dispatch = input.dispatch ?? (async ({ backend, input: prewarmInput }) => {
1820
1787
  await backend.prewarm?.(prewarmInput);
1821
1788
  });
1822
1789
  await Promise.all(
1823
- targets.map(async ({ backend, kind, label, prewarmInput }) => {
1824
- input.log?.(
1825
- `Ash: initializing ${formatExecutionSandboxPrewarmKind(kind)} sandbox template "${label}"...`
1826
- );
1790
+ targets.map(async ({ backend, label, prewarmInput }) => {
1791
+ input.log?.(`Ash: initializing sandbox template "${label}"...`);
1827
1792
  await dispatch({ backend, input: prewarmInput });
1828
- input.log?.(
1829
- `Ash: ${formatExecutionSandboxPrewarmKind(kind)} sandbox template "${label}" is initialized for runtime.`
1830
- );
1793
+ input.log?.(`Ash: sandbox template "${label}" is initialized for runtime.`);
1831
1794
  })
1832
1795
  );
1833
1796
  input.log?.(
1834
- `Ash: finished initializing ${targets.length} execution sandbox ${pluralize(targets.length, "template")} for runtime use (${formatExecutionSandboxPrewarmCounts(targets)}).`
1797
+ `Ash: finished initializing ${targets.length} execution sandbox ${pluralize(targets.length, "template")} for runtime use (${formatExecutionSandboxPrewarmTemplateCount(targets)}).`
1835
1798
  );
1836
1799
  }
1837
1800
  async function collectExecutionSandboxPrewarmTargets(input) {
1838
- const prewarmableSandboxes = collectAuthoredRegisteredSandboxes(input.graph).filter(
1801
+ const prewarmableSandboxes = collectNodeRegisteredSandboxes(input.graph).filter(
1839
1802
  (registered) => registered.definition.backend.prewarm !== void 0
1840
1803
  );
1841
- const skillSeedFiles = await getCompiledSkillSeedFiles({
1842
- compiledArtifactsSource: input.compiledArtifactsSource,
1843
- graph: input.graph
1844
- });
1845
- const hasAuthoredRootSandbox = prewarmableSandboxes.some(
1846
- (registered) => registered.nodeId === ROOT_RUNTIME_AGENT_NODE_ID
1847
- );
1848
- const authoredTargets = await collectAuthoredPrewarmTargets({
1804
+ const targets = await collectNodePrewarmTargets({
1849
1805
  compiledArtifactsSource: input.compiledArtifactsSource,
1850
- rootSkillSeedFiles: hasAuthoredRootSandbox ? skillSeedFiles : [],
1806
+ graph: input.graph,
1851
1807
  sandboxes: prewarmableSandboxes
1852
1808
  });
1853
1809
  const targetsByTemplateKey = /* @__PURE__ */ new Map();
1854
- for (const target of authoredTargets) {
1810
+ for (const target of targets) {
1855
1811
  if (!targetsByTemplateKey.has(target.prewarmInput.templateKey)) {
1856
1812
  targetsByTemplateKey.set(target.prewarmInput.templateKey, target);
1857
1813
  }
1858
1814
  }
1859
- if (!hasAuthoredRootSandbox) {
1860
- const frameworkTarget = await collectFrameworkDefaultPrewarmTarget({
1861
- compiledArtifactsSource: input.compiledArtifactsSource,
1862
- graph: input.graph,
1863
- skillSeedFiles
1864
- });
1865
- if (frameworkTarget !== void 0) {
1866
- targetsByTemplateKey.set(frameworkTarget.prewarmInput.templateKey, frameworkTarget);
1867
- }
1868
- }
1869
1815
  return [...targetsByTemplateKey.values()].sort(
1870
1816
  (left, right) => left.label.localeCompare(right.label)
1871
1817
  );
1872
1818
  }
1873
- async function collectAuthoredPrewarmTargets(input) {
1819
+ async function collectNodePrewarmTargets(input) {
1874
1820
  return await Promise.all(
1875
1821
  input.sandboxes.map(async ({ definition, nodeId, workspaceFileSources }) => {
1876
1822
  const templateKey = await createRuntimeSandboxTemplateKey({
@@ -1880,8 +1826,12 @@ async function collectAuthoredPrewarmTargets(input) {
1880
1826
  sourceId: definition.sourceId
1881
1827
  });
1882
1828
  const workspaceSeedFiles = await materializePerSandboxSeedFiles(workspaceFileSources);
1883
- const isRootSandbox = nodeId === ROOT_RUNTIME_AGENT_NODE_ID;
1884
- const seedFiles = isRootSandbox ? [...workspaceSeedFiles, ...input.rootSkillSeedFiles] : workspaceSeedFiles;
1829
+ const skillSeedFiles = await getCompiledSkillSeedFiles({
1830
+ compiledArtifactsSource: input.compiledArtifactsSource,
1831
+ graph: input.graph,
1832
+ nodeId
1833
+ });
1834
+ const seedFiles = [...workspaceSeedFiles, ...skillSeedFiles];
1885
1835
  const prewarmInput = {
1886
1836
  bootstrap: definition.bootstrap === void 0 ? void 0 : async (ctx) => {
1887
1837
  await definition.bootstrap?.(ctx);
@@ -1891,41 +1841,12 @@ async function collectAuthoredPrewarmTargets(input) {
1891
1841
  };
1892
1842
  return {
1893
1843
  backend: definition.backend,
1894
- kind: "authored",
1895
- label: "default",
1844
+ label: formatExecutionSandboxPrewarmLabel(nodeId),
1896
1845
  prewarmInput
1897
1846
  };
1898
1847
  })
1899
1848
  );
1900
1849
  }
1901
- async function collectFrameworkDefaultPrewarmTarget(input) {
1902
- const defaultBackend = findFirstPrewarmableFrameworkSandboxBackend(input.graph);
1903
- if (defaultBackend === void 0) {
1904
- return void 0;
1905
- }
1906
- const defaultWorkspaceFiles = await materializePerSandboxSeedFiles(
1907
- collectFrameworkSandboxWorkspaceFileSources(input.graph)
1908
- );
1909
- const seedFiles = [...defaultWorkspaceFiles, ...input.skillSeedFiles];
1910
- if (seedFiles.length === 0) {
1911
- return void 0;
1912
- }
1913
- const templateKey = await createRuntimeSandboxTemplateKey({
1914
- backendName: defaultBackend.name,
1915
- compiledArtifactsSource: input.compiledArtifactsSource,
1916
- nodeId: ROOT_RUNTIME_AGENT_NODE_ID,
1917
- sourceId: DEFAULT_SANDBOX_SOURCE_ID
1918
- });
1919
- return {
1920
- backend: defaultBackend,
1921
- kind: "framework",
1922
- label: "default",
1923
- prewarmInput: {
1924
- seedFiles,
1925
- templateKey
1926
- }
1927
- };
1928
- }
1929
1850
  async function materializePerSandboxSeedFiles(fileSources) {
1930
1851
  if (fileSources.length === 0) {
1931
1852
  return [];
@@ -1936,33 +1857,14 @@ async function materializePerSandboxSeedFiles(fileSources) {
1936
1857
  path: file.path
1937
1858
  }));
1938
1859
  }
1939
- function collectFrameworkSandboxWorkspaceFileSources(graph) {
1940
- for (const node of graph.nodesByNodeId.values()) {
1941
- const registered = node.sandboxRegistry.sandbox;
1942
- if (registered !== null && registered.definition.sourceId === DEFAULT_SANDBOX_SOURCE_ID && registered.workspaceFileSources.length > 0) {
1943
- return registered.workspaceFileSources;
1944
- }
1945
- }
1946
- return [];
1947
- }
1948
- function findFirstPrewarmableFrameworkSandboxBackend(graph) {
1949
- for (const node of graph.nodesByNodeId.values()) {
1950
- const registered = node.sandboxRegistry.sandbox;
1951
- if (registered !== null && registered.definition.sourceId === DEFAULT_SANDBOX_SOURCE_ID && registered.definition.backend.prewarm !== void 0) {
1952
- return registered.definition.backend;
1953
- }
1954
- }
1955
- const fallback = createFrameworkSandboxDefinition().backend;
1956
- return fallback.prewarm !== void 0 ? fallback : void 0;
1957
- }
1958
- function collectAuthoredRegisteredSandboxes(graph) {
1860
+ function collectNodeRegisteredSandboxes(graph) {
1959
1861
  return [...graph.nodesByNodeId.entries()].flatMap(
1960
- ([nodeId, node]) => collectAuthoredNodeSandboxes(node, nodeId)
1862
+ ([nodeId, node]) => collectNodeRegisteredSandbox(node, nodeId)
1961
1863
  );
1962
1864
  }
1963
- function collectAuthoredNodeSandboxes(node, nodeId) {
1865
+ function collectNodeRegisteredSandbox(node, nodeId) {
1964
1866
  const registered = node.sandboxRegistry.sandbox;
1965
- if (registered === null || registered.definition.sourceId === DEFAULT_SANDBOX_SOURCE_ID) {
1867
+ if (registered === null) {
1966
1868
  return [];
1967
1869
  }
1968
1870
  return [
@@ -1975,20 +1877,11 @@ function collectAuthoredNodeSandboxes(node, nodeId) {
1975
1877
  function pluralize(count, singular) {
1976
1878
  return count === 1 ? singular : `${singular}s`;
1977
1879
  }
1978
- function formatExecutionSandboxPrewarmKind(kind) {
1979
- return kind === "framework" ? "framework" : "authored";
1880
+ function formatExecutionSandboxPrewarmLabel(nodeId) {
1881
+ return nodeId === ROOT_RUNTIME_AGENT_NODE_ID ? "root" : nodeId;
1980
1882
  }
1981
- function formatExecutionSandboxPrewarmCounts(targets) {
1982
- const authoredCount = targets.filter((target) => target.kind === "authored").length;
1983
- const frameworkCount = targets.length - authoredCount;
1984
- const parts = [];
1985
- if (authoredCount > 0) {
1986
- parts.push(`${authoredCount} authored`);
1987
- }
1988
- if (frameworkCount > 0) {
1989
- parts.push(`${frameworkCount} framework`);
1990
- }
1991
- return parts.join(", ");
1883
+ function formatExecutionSandboxPrewarmTemplateCount(targets) {
1884
+ return `${targets.length} ${pluralize(targets.length, "template")}`;
1992
1885
  }
1993
1886
 
1994
1887
  // src/internal/authored-module-map-loader.ts
@@ -2315,7 +2208,7 @@ async function startDevelopmentServer(rootDir, options = {}) {
2315
2208
  restoreWorkflowLocalQueueEnvironment = installWorkflowLocalQueueEnvironment(server.url);
2316
2209
  await prepare2(nitro);
2317
2210
  await buildNitro2(nitro);
2318
- const { startAuthoredSourceWatcher } = await import("./dev-authored-source-watcher-6TM2MLOF.js");
2211
+ const { startAuthoredSourceWatcher } = await import("./dev-authored-source-watcher-VAWAOB2Z.js");
2319
2212
  const authoredSourceWatcher = await startAuthoredSourceWatcher({
2320
2213
  nitro,
2321
2214
  preparedHost,
@@ -2359,4 +2252,4 @@ export {
2359
2252
  buildHost,
2360
2253
  startHost
2361
2254
  };
2362
- //# sourceMappingURL=chunk-VUESBSNV.js.map
2255
+ //# sourceMappingURL=chunk-XMBTGWNT.js.map