eve 0.24.6 → 0.25.0
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.
- package/CHANGELOG.md +15 -0
- package/dist/src/chunks/{use-eve-agent-6BO9gFVq.js → use-eve-agent-CQIeqmKc.js} +69 -64
- package/dist/src/chunks/{use-eve-agent-B1MJNRE-.js → use-eve-agent-Cy73lgA6.js} +69 -64
- package/dist/src/cli/commands/agent-instructions.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/extension-build.d.ts +1 -1
- package/dist/src/cli/commands/extension-build.js +1 -1
- package/dist/src/client/output-schema.d.ts +0 -7
- package/dist/src/client/output-schema.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +56 -0
- package/dist/src/compiler/extension-compatibility.js +1 -0
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.d.ts +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/discover/discover-agent.d.ts +29 -7
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extensions.d.ts +43 -8
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/filesystem.d.ts +3 -1
- package/dist/src/discover/filesystem.js +1 -1
- package/dist/src/discover/named-source-directory.js +1 -1
- package/dist/src/discover/skills.js +1 -1
- package/dist/src/evals/autoevals-client.js +2 -2
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
- package/dist/src/execution/sandbox/development-cleanup.d.ts +1 -1
- package/dist/src/execution/sandbox/development-cleanup.js +1 -1
- package/dist/src/execution/sandbox/development-run.d.ts +0 -3
- package/dist/src/execution/sandbox/development-run.js +1 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/input-extraction.d.ts +10 -1
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-requests.d.ts +12 -2
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/messages.d.ts +8 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/stale-input-responses.d.ts +26 -0
- package/dist/src/harness/stale-input-responses.js +3 -0
- package/dist/src/harness/step-hooks.d.ts +1 -12
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-call-input-errors.d.ts +11 -0
- package/dist/src/harness/tool-call-input-errors.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/workflow-sandbox.d.ts +1 -1
- package/dist/src/harness/workflow-sandbox.js +1 -1
- package/dist/src/internal/application/optional-package-install.d.ts +5 -0
- package/dist/src/internal/application/optional-package-install.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +17 -0
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +8 -0
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.d.ts +4 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.d.ts +6 -21
- package/dist/src/internal/nitro/host/build-extension.js +2 -4
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-workspace-extensions.d.ts +18 -0
- package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -0
- package/dist/src/internal/nitro/host/extension-build-config.d.ts +18 -0
- package/dist/src/internal/nitro/host/extension-build-config.js +1 -0
- package/dist/src/internal/nitro/host/extension-capability-requirements.d.ts +10 -0
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -0
- package/dist/src/internal/nitro/host/extension-declarations.d.ts +10 -0
- package/dist/src/internal/nitro/host/extension-declarations.js +2 -0
- package/dist/src/internal/nitro/host/extension-distribution.d.ts +32 -0
- package/dist/src/internal/nitro/host/extension-distribution.js +3 -0
- package/dist/src/internal/nitro/host/extension-state-usage.d.ts +7 -0
- package/dist/src/internal/nitro/host/extension-state-usage.js +1 -0
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +5 -1
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +2 -0
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/public/definitions/tool.d.ts +2 -2
- package/dist/src/public/tools/internal.js +1 -1
- package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/framework-tools/ask-question.d.ts +23 -9
- package/dist/src/runtime/framework-tools/ask-question.js +1 -1
- package/dist/src/runtime/framework-tools/bash.d.ts +10 -3
- package/dist/src/runtime/framework-tools/bash.js +1 -1
- package/dist/src/runtime/framework-tools/connection-search-dynamic.js +1 -1
- package/dist/src/runtime/framework-tools/final-output.d.ts +1 -1
- package/dist/src/runtime/framework-tools/final-output.js +1 -1
- package/dist/src/runtime/framework-tools/glob.d.ts +12 -3
- package/dist/src/runtime/framework-tools/glob.js +1 -1
- package/dist/src/runtime/framework-tools/grep.d.ts +16 -3
- package/dist/src/runtime/framework-tools/grep.js +1 -1
- package/dist/src/runtime/framework-tools/read-file.d.ts +13 -3
- package/dist/src/runtime/framework-tools/read-file.js +1 -1
- package/dist/src/runtime/framework-tools/skill.d.ts +5 -2
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/framework-tools/todo.d.ts +57 -10
- package/dist/src/runtime/framework-tools/todo.js +3 -3
- package/dist/src/runtime/framework-tools/web-fetch.d.ts +16 -3
- package/dist/src/runtime/framework-tools/web-fetch.js +1 -1
- package/dist/src/runtime/framework-tools/write-file.d.ts +9 -3
- package/dist/src/runtime/framework-tools/write-file.js +1 -1
- package/dist/src/runtime/loaders/compile-metadata.js +1 -1
- package/dist/src/runtime/loaders/manifest.js +1 -1
- package/dist/src/runtime/loaders/module-map.js +1 -1
- package/dist/src/runtime/resolve-tool.d.ts +4 -5
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/subagents/registry.d.ts +6 -3
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +7 -9
- package/dist/src/setup/boxes/deploy-project.d.ts +11 -1
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/extension.js +2 -2
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/setup/scaffold/update/connections.js +1 -1
- package/dist/src/setup/vercel-project-framework.d.ts +4 -2
- package/dist/src/shared/extension-package-contract.d.ts +11 -0
- package/dist/src/shared/extension-package-contract.js +1 -0
- package/dist/src/shared/json.d.ts +4 -0
- package/dist/src/shared/json.js +1 -1
- package/dist/src/shared/tool-schema.d.ts +52 -0
- package/dist/src/shared/tool-schema.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +6 -0
- package/docs/extensions.md +22 -6
- package/docs/reference/cli.md +2 -2
- package/package.json +1 -1
- package/dist/src/internal/json-schema.d.ts +0 -1
- package/dist/src/internal/json-schema.js +0 -1
- package/dist/src/setup/boxes/reconcile-host-framework-preset.d.ts +0 -26
- package/dist/src/setup/boxes/reconcile-host-framework-preset.js +0 -1
- package/dist/src/shared/json-schema.d.ts +0 -9
- package/dist/src/shared/json-schema.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{createHash}from"node:crypto";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{buildSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{assertNoWorkflowDirectivePrologue}from"#internal/authored-directive-prologue.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createExtensionScopePlugin,createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(t,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)?await loadBundledAuthoredModule(t,n):await import(createFileImportSpecifier(t)),`Expected "${t}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=normalizeExternalDependencies([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.config.build?.externalDependencies??[])),r=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath}),i=createExtensionScopePlugin(e.manifest.extensionMounts.map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot}))),a=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:r}),createAuthoredDirectiveGuardPlugin(),i,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:n,packageRoot:t})].filter(e=>e!==null);try{return removeRolldownModuleRegionComments((await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:a,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}})).code)}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),a=resolveAuthoredTsConfigPath(i),o=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let a=resolve(i.id);if(r.has(a))return{id:`${CACHED_CHANNEL_PREFIX}${a}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
|
|
1
|
+
import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,realpathSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{createHash}from"node:crypto";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{assertNoWorkflowDirectivePrologue}from"#internal/authored-directive-prologue.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createExtensionScopePlugin,createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(t,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)?await loadBundledAuthoredModule(t,n):await import(createFileImportSpecifier(t)),`Expected "${t}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`_chunks/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map;for(let e of n.output)e.type===`chunk`&&r.set(e.fileName,removeRolldownModuleRegionComments(e.code));return r}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=normalizeExternalDependencies([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.config.build?.externalDependencies??[])),r=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath}),i=createExtensionScopePlugin(e.manifest.extensionMounts.map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot}))),a=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:r}),createAuthoredDirectiveGuardPlugin(),i,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:n,packageRoot:t})].filter(e=>e!==null);try{return removeRolldownModuleRegionComments((await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:a,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}})).code)}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),a=resolveAuthoredTsConfigPath(i),o=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let a=resolve(i.id);if(r.has(a))return{id:`${CACHED_CHANNEL_PREFIX}${a}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
|
|
2
2
|
`),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:i,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:i,input:e,platform:`node`,plugins:o,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:a,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t)||await assertNoWorkflowDirectivePrologue({filePath:t,source:e})}}}function removeRolldownModuleRegionComments(e){return e.split(`
|
|
3
3
|
`).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
|
|
4
|
-
`)}async function loadBundledAuthoredModule(e,r){let
|
|
4
|
+
`)}async function loadBundledAuthoredModule(e,r){let i=await bundleAuthoredModuleCode(e,r),o=normalizeExternalDependencies(r.externalDependencies),s=createHash(`sha1`).update(e).update(`\0`).update(o.join(`\0`)).update(`\0`).update(r.extensionScopeNamespace??``).update(`\0`).update(i).digest(`hex`),c=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),l=join(c,`${s}.mjs`);return existsSync(l)||(mkdirSync(c,{recursive:!0}),writeFileSync(l,i)),await import(`${createFileImportSpecifier(l)}?v=${s}`)}function createAuthoredRelativeExtensionResolverPlugin(e){return{name:`eve-authored-relative-extension-resolver`,resolveId(t,n){if(n===void 0||n.startsWith(`\0`)||n.startsWith(CACHED_CHANNEL_PREFIX)||!isPathImport(t))return;let r=resolveExistingImportPath(isAbsolute(t)?t:resolve(dirname(n),t),e.extensions);if(r!==void 0)return{id:isNodeModulesPath(r)?toRealModulePath(r):r}}}}function toRealModulePath(e){try{return realpathSync(e)}catch{return e}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extensionScopeNamespace??``}`}function resolveExistingImportPath(e,t){if(isFile(e))return e;for(let n of t){let t=`${e}${n}`;if(isFile(t))return t}for(let n of t){let t=join(e,`index${n}`);if(isFile(t))return t}}function isFile(e){try{return statSync(e).isFile()}catch{return!1}}function resolveAuthoredTsConfigPath(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);if(existsSync(r))return r}return!1}function resolveAuthoredPackageRoot(e){let n=dirname(e);for(;;){if(existsSync(join(n,`package.json`)))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve the authored package root for "${e}".`);n=r}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration,bundleExtensionDistributionGraph,loadAuthoredModuleNamespace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{collectModuleRefsForManifest,compiledModuleMapSchema}from"#compiler/module-map.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{pathToFileURL}from"node:url";
|
|
1
|
+
import{join}from"node:path";import{collectModuleRefsForManifest,compiledModuleMapSchema}from"#compiler/module-map.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{formatValidationError}from"#runtime/validation.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{pathToFileURL}from"node:url";const EXT_CONFIG_SCOPE=Symbol.for(`eve.ext-config-scope`);async function loadCompiledModuleMapFromAuthoredSource(e){return await hydrateCompiledModuleMapFromManifest(await loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),e.compiledArtifactsSource.appRoot)}async function hydrateCompiledModuleMapFromManifest(e,t){let n=await readMaterializedAuthoredModuleIndex(t);if(n!==void 0)return await loadMaterializedCompiledModuleMap({moduleMapPath:n.moduleMap,runtimeAppRoot:t});let i={},a=[{agentRoot:e.agentRoot,manifest:e,nodeId:ROOT_COMPILED_AGENT_NODE_ID},...[...e.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))],o={byMountNamespace:new Map(e.extensionMounts.map(e=>[e.namespace,e.packageNamespace])),byMountSourceId:new Map(e.extensionMounts.map(e=>[e.mountSourceId,e.packageNamespace]))};for(let e of a)i[e.nodeId]={modules:await hydrateCompiledNodeScope({agentRoot:e.agentRoot,manifest:e.manifest,scopeIndex:o})};return{nodes:i}}async function loadMaterializedCompiledModuleMap(t){let r=join(t.runtimeAppRoot,`.eve`,`compile`,t.moduleMapPath),a=await import(`${pathToFileURL(r).href}?generation=${encodeURIComponent(t.moduleMapPath)}`),o=compiledModuleMapSchema.safeParse(a.moduleMap??a.default);if(!o.success)throw Error(`Expected materialized authored module map "${r}" to export a valid compiled eve module map. ${formatValidationError(o.error)}`);return o.data}function extensionNamespaceForSourceId(e,t){let n=e.match(/^ext:([^:]+):/);return n===null?void 0:t.byMountNamespace.get(n[1])}async function hydrateCompiledNodeScope(n){let r=collectModuleRefsForManifest(n.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId)),i=n.manifest.config.build?.externalDependencies??[],o=globalThis,s={};for(let t of r){let r=join(n.agentRoot,t.logicalPath),c=extensionNamespaceForSourceId(t.sourceId,n.scopeIndex),l=n.scopeIndex.byMountSourceId.get(t.sourceId);l!==void 0&&(o[EXT_CONFIG_SCOPE]=l);try{s[t.sourceId]=await loadAuthoredModuleNamespace(r,{externalDependencies:i,extensionScopeNamespace:c})}finally{l!==void 0&&(o[EXT_CONFIG_SCOPE]=void 0)}}return s}export{loadCompiledModuleMapFromAuthoredSource};
|
|
@@ -17,6 +17,14 @@ export declare function createRuntimeLoaderPackageBoundaryPlugin(input: {
|
|
|
17
17
|
readonly externalDependencies: readonly string[];
|
|
18
18
|
readonly packageRoot: string;
|
|
19
19
|
}): Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Keeps package imports external in an extension distribution while enforcing
|
|
22
|
+
* that every runtime package is declared by the extension.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDistributionPackageBoundaryPlugin(input: {
|
|
25
|
+
readonly runtimeDependencies: readonly string[];
|
|
26
|
+
readonly packageRoot: string;
|
|
27
|
+
}): Record<string, unknown>;
|
|
20
28
|
export declare function normalizeExternalDependencies(externalDependencies?: readonly string[]): string[];
|
|
21
29
|
export declare function isPathImport(source: string): boolean;
|
|
22
30
|
export declare function isNodeModulesPath(path: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,realpathSync}from"node:fs";import{join,resolve,sep}from"node:path";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)&&(isFrameworkRuntimeImport(t,n)||await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t})!==void 0))return{external:!0,id:t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,i
|
|
1
|
+
import{isBuiltin}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{dirname,join,resolve,sep}from"node:path";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)&&(isFrameworkRuntimeImport(t,n)||await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t})!==void 0))return{external:!0,id:t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,r,i){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,r))return{external:!0,id:n};let a=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:r,kind:i.kind,packageRoot:e.packageRoot,source:n});if(a!==void 0)return{external:!0,id:resolveExistingExternalFilePath(a.resolvedId)??a.resolvedId};let s=r===void 0||r.startsWith(`\0`)||r.startsWith(`eve-cached-channel:`)?void 0:resolve(r);if(s!==void 0&&isPathInsideOrEqual(toCanonicalPath(s),t)){let e=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${s}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(t){let n=new Set(t.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(r,i,o){if(!isPackageImport(r))return;if(r.startsWith(`#`)){let e=await this.resolve(r,i,{kind:o.kind,skipSelf:!0});if(e!==null&&typeof e.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(e.id),toCanonicalPath(t.packageRoot))){let t=nearestPackageName(e.id);if(t!==void 0&&!n.has(t))throw Error(`Package import "${r}" resolves to undeclared package "${t}". Add "${t}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(r))return{external:!0,id:r};let s=packageImportName(r);if(!n.has(s))throw Error(`Package "${r}" is not declared by the extension. Add "${s}" to dependencies, optionalDependencies, or peerDependencies.`);let c=await this.resolve(r,i,{kind:o.kind,skipSelf:!0});if(c===null&&(c=await this.resolve(r,join(t.packageRoot,`package.json`),{kind:o.kind,skipSelf:!0})),c===null||typeof c.id!=`string`)throw Error(`Cannot resolve declared package "${r}". Install the extension's dependencies before building.`);return{external:!0,id:r}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let n=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(n===null&&(n=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),n===null||typeof n.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:n.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let r=dirname(toCanonicalPath(e));for(;;){let e=join(r,`package.json`);if(existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return typeof t.name==`string`&&t.name.length>0?t.name:void 0}catch{return}let o=dirname(r);if(o===r)return;r=o}}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let n of RESOLVE_EXTENSIONS){let r=`${e}${n}`;if(existsSync(r))return r}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(CACHED_CHANNEL_PREFIX)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
|
|
@@ -29,3 +29,7 @@ export declare function toDevelopmentSourceSnapshotPath(input: {
|
|
|
29
29
|
readonly sourcePath: string;
|
|
30
30
|
readonly sourceRoot: string;
|
|
31
31
|
}): string;
|
|
32
|
+
/** Resolves the repository/workspace boundary used for authored development sources. */
|
|
33
|
+
export declare function resolveDevelopmentSourceRoot(appRoot: string): string;
|
|
34
|
+
/** Returns whether a path is authored workspace source rather than installed dependency data. */
|
|
35
|
+
export declare function isAuthoredSourcePath(path: string, sourceRoot: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{lstat,readlink,realpath}from"node:fs/promises";import{parseTsConfigObject,readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";const DEV_RUNTIME_SOURCE_DIRECTORY=`source`,SOURCE_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WORKSPACE_METADATA_FILE_NAMES=[`package.json`,`pnpm-workspace.yaml`,`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`,`.npmrc`],PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];var DevelopmentRuntimeSourceSnapshotError=class extends Error{constructor(e){super(e),this.name=`DevelopmentRuntimeSourceSnapshotError`}};async function createDevelopmentSourceSnapshotPlan(e){let t=resolve(e.appRoot),r=resolve(e.snapshotRoot),a=resolveDevelopmentSourceRoot(t),o=join(r,DEV_RUNTIME_SOURCE_DIRECTORY),s={appRoot:t,copyFiles:new Set,copyRoots:new Set,localRootsToProcess:[t],processedLocalRoots:new Set,snapshotRoot:r,snapshotSourceRoot:o,sourceRoot:a,symlinksByLinkPath:new Map,tsconfigPaths:new Set};for(addWorkspaceMetadataFiles(s);s.localRootsToProcess.length>0;){let e=s.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);s.processedLocalRoots.has(t)||!isAuthoredSourcePath(t,a)||(s.processedLocalRoots.add(t),s.copyRoots.add(t),await addTsConfigDependenciesForRoot(s,t),await addDependencySymlinksForRoot(s,t))}let c=normalizeCopyRoots([...s.copyRoots]),l=[...s.copyFiles].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),u=[...s.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),d=[...s.symlinksByLinkPath.values()].sort((e,t)=>e.linkPath.localeCompare(t.linkPath)),f=createWatchPaths({appRoot:t,copyFiles:l,copyRoots:c,sourceRoot:a,symlinks:d,tsconfigPaths:u});return{appRoot:t,copyFiles:l,copyRoots:c,runtimeAppRoot:toSnapshotPath({sourcePath:t,sourceRoot:a,snapshotSourceRoot:o}),snapshotRoot:r,snapshotSourceRoot:o,sourceRoot:a,symlinks:d,tsconfigPaths:u,watchPaths:f}}async function resolveDevelopmentSourceSnapshotWatchPaths(e){return[...(await createDevelopmentSourceSnapshotPlan({appRoot:e,snapshotRoot:join(resolve(e),`.eve`,`dev-runtime`,`__watch-plan__`)})).watchPaths]}function toDevelopmentSourceSnapshotPath(e){return toSnapshotPath(e)}function resolveDevelopmentSourceRoot(r){let a=resolve(r);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(t=>existsSync(join(a,t))))return a;let o=dirname(a);if(o===a)return resolve(r);a=o}}function addWorkspaceMetadataFiles(t){for(let r of WORKSPACE_METADATA_FILE_NAMES){let i=join(t.sourceRoot,r);existsSync(i)&&t.copyFiles.add(i)}}async function addTsConfigDependenciesForRoot(e,t){let n=await resolveTsConfigDependencyPaths(t);for(let t of n)if(isPathInsideOrEqual(t,e.sourceRoot)){e.tsconfigPaths.add(t),e.copyFiles.add(t);for(let n of await resolveLocalTsConfigPathTargetRoots({configPath:t,sourceRoot:e.sourceRoot}))enqueueLocalRoot(e,n)}}async function addDependencySymlinksForRoot(e,t){let n=await readPackageDependencyNames(t);for(let r of n)for(let n of[t,e.sourceRoot])await addDependencySymlink(e,joinNodeModulesPackagePath(n,r))}async function addDependencySymlink(t,n){let r;try{r=await lstat(n)}catch{return}if(!r.isSymbolicLink())return;let a=await resolveSymlinkTargetPathCandidates(n),s=a.find(e=>isAuthoredSourcePath(e,t.sourceRoot));if(s!==void 0){await addLocalDependencySymlink({linkPath:n,state:t,targetPath:s});return}let c=a.find(t=>existsSync(t));c!==void 0&&t.symlinksByLinkPath.set(resolve(n),{linkPath:resolve(n),targetKind:`external`,targetPath:c})}async function addLocalDependencySymlink(e){let t=await resolveNearestPackageRoot(e.targetPath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.symlinksByLinkPath.set(resolve(e.linkPath),{linkPath:resolve(e.linkPath),targetKind:`local`,targetPath:t})}async function resolveSymlinkTargetPathCandidates(e){let n=new Set;try{let r=await readlink(e);n.add(resolve(dirname(e),r))}catch{}try{n.add(await realpath(e))}catch{}return[...n]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let t=await readTextFileIfExists(join(e,`package.json`));if(t===void 0)return[];let r;try{r=JSON.parse(t)}catch{return[]}if(!isObjectRecord(r))return[];let i=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=r[e];if(isObjectRecord(t))for(let e of Object.keys(t))i.add(e)}return[...i].sort((e,t)=>e.localeCompare(t))}async function resolveLocalTsConfigPathTargetRoots(e){let n=await readTextFileIfExists(e.configPath);if(n===void 0)return[];let r=parseTsConfigObject(n),a=isObjectRecord(r?.compilerOptions)?r.compilerOptions:void 0,o=isObjectRecord(a?.paths)?a.paths:void 0;if(a===void 0||o===void 0)return[];let s=typeof a.baseUrl==`string`?resolve(dirname(e.configPath),a.baseUrl):dirname(e.configPath),c=new Set;for(let t of Object.values(o))if(Array.isArray(t))for(let n of t){if(typeof n!=`string`||n.length===0)continue;let t=await resolveLocalTsConfigPathTargetRoot({baseDirectory:s,sourceRoot:e.sourceRoot,target:n});t!==void 0&&c.add(t)}return[...c].sort((e,t)=>e.localeCompare(t))}async function resolveLocalTsConfigPathTargetRoot(e){let t=e.target.includes(`*`),n=t?e.target.slice(0,e.target.indexOf(`*`)):e.target;if(n.length===0||n===`.`||n===`./`)return;let r=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(r,e.sourceRoot))return;let a=await resolveExistingPathOrAncestor({path:r,stopDirectory:e.sourceRoot});if(a===void 0)return;let o=await resolveNearestPackageRoot(a,e.sourceRoot);if(o!==void 0&&o!==e.sourceRoot)return o;if(!t)return a===e.sourceRoot?void 0:a}async function resolveExistingPathOrAncestor(n){let r=resolve(n.path);for(;isAuthoredSourcePath(r,n.stopDirectory);){if(existsSync(r))return r;let n=dirname(r);if(n===r)return;r=n}}async function resolveNearestPackageRoot(r,a){let s=resolve(r);try{(await lstat(s)).isDirectory()||(s=dirname(s))}catch{s=dirname(s)}for(;isAuthoredSourcePath(s,a);){if(existsSync(join(s,`package.json`)))return s;let r=dirname(s);if(r===s)return;s=r}}function normalizeCopyRoots(e){let t=[...new Set(e.map(e=>resolve(e)))].sort((e,t)=>{let n=e.length-t.length;return n===0?e.localeCompare(t):n}),n=[];for(let e of t)n.some(t=>isPathInsideOrEqual(e,t))||n.push(e);return n.sort((e,t)=>e.localeCompare(t))}function createWatchPaths(t){let r=new Set([join(t.appRoot,`package.json`),...t.copyFiles,...t.tsconfigPaths]);for(let e of t.copyRoots)e!==t.appRoot&&r.add(e);for(let e of t.symlinks)e.targetKind===`local`&&e.targetPath!==t.appRoot&&r.add(e.targetPath);if(t.sourceRoot!==t.appRoot)for(let i of WORKSPACE_METADATA_FILE_NAMES){let a=join(t.sourceRoot,i);existsSync(a)&&r.add(a)}return[...r].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,t){return join(e,`node_modules`,...t.split(`/`))}function toSnapshotPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.sourceRoot))throw new DevelopmentRuntimeSourceSnapshotError(`Cannot map source path "${e.sourcePath}" into a development runtime snapshot because it is outside source root "${e.sourceRoot}".`);return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
|
|
1
|
+
import{existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{lstat,readlink,realpath}from"node:fs/promises";import{parseTsConfigObject,readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";const DEV_RUNTIME_SOURCE_DIRECTORY=`source`,SOURCE_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WORKSPACE_METADATA_FILE_NAMES=[`package.json`,`pnpm-workspace.yaml`,`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`,`.npmrc`],PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];var DevelopmentRuntimeSourceSnapshotError=class extends Error{constructor(e){super(e),this.name=`DevelopmentRuntimeSourceSnapshotError`}};async function createDevelopmentSourceSnapshotPlan(e){let t=resolve(e.appRoot),r=resolve(e.snapshotRoot),a=resolveDevelopmentSourceRoot(t),o=join(r,DEV_RUNTIME_SOURCE_DIRECTORY),s={appRoot:t,copyFiles:new Set,copyRoots:new Set,localRootsToProcess:[t],processedLocalRoots:new Set,snapshotRoot:r,snapshotSourceRoot:o,sourceRoot:a,symlinksByLinkPath:new Map,tsconfigPaths:new Set};for(addWorkspaceMetadataFiles(s);s.localRootsToProcess.length>0;){let e=s.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);s.processedLocalRoots.has(t)||!isAuthoredSourcePath(t,a)||(s.processedLocalRoots.add(t),s.copyRoots.add(t),await addTsConfigDependenciesForRoot(s,t),await addDependencySymlinksForRoot(s,t))}let c=normalizeCopyRoots([...s.copyRoots]),l=[...s.copyFiles].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),u=[...s.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),d=[...s.symlinksByLinkPath.values()].sort((e,t)=>e.linkPath.localeCompare(t.linkPath)),f=createWatchPaths({appRoot:t,copyFiles:l,copyRoots:c,sourceRoot:a,symlinks:d,tsconfigPaths:u});return{appRoot:t,copyFiles:l,copyRoots:c,runtimeAppRoot:toSnapshotPath({sourcePath:t,sourceRoot:a,snapshotSourceRoot:o}),snapshotRoot:r,snapshotSourceRoot:o,sourceRoot:a,symlinks:d,tsconfigPaths:u,watchPaths:f}}async function resolveDevelopmentSourceSnapshotWatchPaths(e){return[...(await createDevelopmentSourceSnapshotPlan({appRoot:e,snapshotRoot:join(resolve(e),`.eve`,`dev-runtime`,`__watch-plan__`)})).watchPaths]}function toDevelopmentSourceSnapshotPath(e){return toSnapshotPath(e)}function resolveDevelopmentSourceRoot(r){let a=resolve(r);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(t=>existsSync(join(a,t))))return a;let o=dirname(a);if(o===a)return resolve(r);a=o}}function addWorkspaceMetadataFiles(t){for(let r of WORKSPACE_METADATA_FILE_NAMES){let i=join(t.sourceRoot,r);existsSync(i)&&t.copyFiles.add(i)}}async function addTsConfigDependenciesForRoot(e,t){let n=await resolveTsConfigDependencyPaths(t);for(let t of n)if(isPathInsideOrEqual(t,e.sourceRoot)){e.tsconfigPaths.add(t),e.copyFiles.add(t);for(let n of await resolveLocalTsConfigPathTargetRoots({configPath:t,sourceRoot:e.sourceRoot}))enqueueLocalRoot(e,n)}}async function addDependencySymlinksForRoot(e,t){let n=await readPackageDependencyNames(t);for(let r of n)for(let n of[t,e.sourceRoot])await addDependencySymlink(e,joinNodeModulesPackagePath(n,r))}async function addDependencySymlink(t,n){let r;try{r=await lstat(n)}catch{return}if(!r.isSymbolicLink())return;let a=await resolveSymlinkTargetPathCandidates(n),s=a.find(e=>isAuthoredSourcePath(e,t.sourceRoot));if(s!==void 0){await addLocalDependencySymlink({linkPath:n,state:t,targetPath:s});return}let c=a.find(t=>existsSync(t));c!==void 0&&t.symlinksByLinkPath.set(resolve(n),{linkPath:resolve(n),targetKind:`external`,targetPath:c})}async function addLocalDependencySymlink(e){let t=await resolveNearestPackageRoot(e.targetPath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.symlinksByLinkPath.set(resolve(e.linkPath),{linkPath:resolve(e.linkPath),targetKind:`local`,targetPath:t})}async function resolveSymlinkTargetPathCandidates(e){let n=new Set;try{let r=await readlink(e);n.add(resolve(dirname(e),r))}catch{}try{n.add(await realpath(e))}catch{}return[...n]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let t=await readTextFileIfExists(join(e,`package.json`));if(t===void 0)return[];let r;try{r=JSON.parse(t)}catch{return[]}if(!isObjectRecord(r))return[];let i=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=r[e];if(isObjectRecord(t))for(let e of Object.keys(t))i.add(e)}return[...i].sort((e,t)=>e.localeCompare(t))}async function resolveLocalTsConfigPathTargetRoots(e){let n=await readTextFileIfExists(e.configPath);if(n===void 0)return[];let r=parseTsConfigObject(n),a=isObjectRecord(r?.compilerOptions)?r.compilerOptions:void 0,o=isObjectRecord(a?.paths)?a.paths:void 0;if(a===void 0||o===void 0)return[];let s=typeof a.baseUrl==`string`?resolve(dirname(e.configPath),a.baseUrl):dirname(e.configPath),c=new Set;for(let t of Object.values(o))if(Array.isArray(t))for(let n of t){if(typeof n!=`string`||n.length===0)continue;let t=await resolveLocalTsConfigPathTargetRoot({baseDirectory:s,sourceRoot:e.sourceRoot,target:n});t!==void 0&&c.add(t)}return[...c].sort((e,t)=>e.localeCompare(t))}async function resolveLocalTsConfigPathTargetRoot(e){let t=e.target.includes(`*`),n=t?e.target.slice(0,e.target.indexOf(`*`)):e.target;if(n.length===0||n===`.`||n===`./`)return;let r=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(r,e.sourceRoot))return;let a=await resolveExistingPathOrAncestor({path:r,stopDirectory:e.sourceRoot});if(a===void 0)return;let o=await resolveNearestPackageRoot(a,e.sourceRoot);if(o!==void 0&&o!==e.sourceRoot)return o;if(!t)return a===e.sourceRoot?void 0:a}async function resolveExistingPathOrAncestor(n){let r=resolve(n.path);for(;isAuthoredSourcePath(r,n.stopDirectory);){if(existsSync(r))return r;let n=dirname(r);if(n===r)return;r=n}}async function resolveNearestPackageRoot(r,a){let s=resolve(r);try{(await lstat(s)).isDirectory()||(s=dirname(s))}catch{s=dirname(s)}for(;isAuthoredSourcePath(s,a);){if(existsSync(join(s,`package.json`)))return s;let r=dirname(s);if(r===s)return;s=r}}function normalizeCopyRoots(e){let t=[...new Set(e.map(e=>resolve(e)))].sort((e,t)=>{let n=e.length-t.length;return n===0?e.localeCompare(t):n}),n=[];for(let e of t)n.some(t=>isPathInsideOrEqual(e,t))||n.push(e);return n.sort((e,t)=>e.localeCompare(t))}function createWatchPaths(t){let r=new Set([join(t.appRoot,`package.json`),...t.copyFiles,...t.tsconfigPaths]);for(let e of t.copyRoots)e!==t.appRoot&&r.add(e);for(let e of t.symlinks)e.targetKind===`local`&&e.targetPath!==t.appRoot&&r.add(e.targetPath);if(t.sourceRoot!==t.appRoot)for(let i of WORKSPACE_METADATA_FILE_NAMES){let a=join(t.sourceRoot,i);existsSync(a)&&r.add(a)}return[...r].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,t){return join(e,`node_modules`,...t.split(`/`))}function toSnapshotPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.sourceRoot))throw new DevelopmentRuntimeSourceSnapshotError(`Cannot map source path "${e.sourcePath}" into a development runtime snapshot because it is outside source root "${e.sourceRoot}".`);return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,isAuthoredSourcePath,resolveDevelopmentSourceRoot,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import { tryReadExtensionBuildConfig, type ExtensionBuildConfig } from "#internal/nitro/host/extension-build-config.js";
|
|
2
|
+
export { tryReadExtensionBuildConfig };
|
|
3
|
+
export type { ExtensionBuildConfig };
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
export interface ExtensionBuildConfig {
|
|
6
|
-
/** Absolute path to the agent-shaped source root (`eve.extension`). */
|
|
7
|
-
readonly sourceRoot: string;
|
|
8
|
-
/** Package name from `package.json`. */
|
|
9
|
-
readonly packageName: string;
|
|
10
|
-
/** Short name a consumer mounts by (`@acme/crm` → `crm`). */
|
|
11
|
-
readonly shortName: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Reads `package.json#eve.extension` from a project root, returning the
|
|
15
|
-
* extension build inputs or `null` when the package is a regular agent app.
|
|
16
|
-
*/
|
|
17
|
-
export declare function tryReadExtensionBuildConfig(rootDir: string): Promise<ExtensionBuildConfig | null>;
|
|
18
|
-
/**
|
|
19
|
-
* Builds an extension package: emits `dist/index.mjs` (the mount factory) and
|
|
20
|
-
* `dist/tools/index.mjs` (named tool re-exports for consumer overrides), and
|
|
21
|
-
* fills the package `exports` map. Re-exports point at the authored source so the
|
|
22
|
-
* consumer's compiled tools and the mount share one handle instance.
|
|
5
|
+
* Builds a dist-only extension package. Authored modules are transformed as a
|
|
6
|
+
* path-preserving graph, declarations and assets are emitted beside them, and
|
|
7
|
+
* compatibility-only metadata is written at the agent-shaped dist root.
|
|
23
8
|
*/
|
|
24
9
|
export declare function buildExtensionPackage(rootDir: string, config: ExtensionBuildConfig): Promise<string>;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import{join,relative,resolve}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{mkdir,
|
|
2
|
-
`)}`);let
|
|
3
|
-
`);await writeFile(e.entryPath,n,`utf8`),await writeFile(e.entryPath,await bundleAuthoredModuleCode(e.entryPath,{extensionScopeNamespace:e.scopeNamespace}),`utf8`);let r=[t,``,...e.reexports.map(e=>line(e,toDeclarationSpecifier(e.specifier))),``].join(`
|
|
4
|
-
`);await writeFile(e.typesPath,r,`utf8`)}function toDeclarationSpecifier(e){return e.replace(/\.mts$/,`.mjs`).replace(/\.cts$/,`.cjs`).replace(/\.tsx?$/,`.js`)}function toolExportName(e){let t=e;for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(t.endsWith(e)){t=t.slice(0,t.length-e.length);break}return safeJsIdentifier(t.replace(/^tools\//,``))}function safeJsIdentifier(e){let t=e.replace(/[^A-Za-z0-9_$]/g,`_`);return/^[A-Za-z_$]/.test(t)?t:`_${t}`}export{buildExtensionPackage,tryReadExtensionBuildConfig};
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{join,relative,resolve}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{mkdir,mkdtemp,rm}from"node:fs/promises";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(t,n){let r=resolve(t),i=createDiskProjectSource(),{diagnostics:a,manifest:o}=await discoverAgent({agentRoot:n.sourceRoot,appRoot:r,source:i,role:`extension`}),s=a.filter(e=>e.severity===`error`);if(s.length>0)throw Error(`Cannot build extension "${n.packageName}":\n${s.map(e=>` - ${e.message}`).join(`
|
|
2
|
+
`)}`);let c=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(i,n.sourceRoot),rootPath:n.sourceRoot,slotName:`extension`}).module;if(c===void 0)throw Error(`Cannot build extension "${n.packageName}": its source root "${n.sourceRoot}" is missing an "extension.<ext>" declaration. Add \`export default defineExtension(...)\` there (with or without config).`);let l=await mkdtemp(join(r,`.eve-extension-build-`)),u=join(l,`output`),d=join(u,relative(n.outDir,n.distRoot)),f=!1;try{return await mkdir(d,{recursive:!0}),await emitExtensionDistribution({appRoot:r,declarationModule:c,declarationsRoot:join(l,`declarations`),manifest:o,runtimeDependencies:n.runtimeDependencies,shortName:n.shortName,sourceRoot:n.sourceRoot,stagedDistRoot:d,stagedOutDir:u,transactionRoot:l}),await writeExtensionCompatibilityManifest(d,{kind:EXTENSION_COMPATIBILITY_MANIFEST_KIND,formatVersion:EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,builtWithEve:resolveInstalledPackageInfo().version,requires:await deriveExtensionCapabilityRequirements({declarationModule:c,manifest:o,runtimeDependencies:n.runtimeDependencies,sourceRoot:n.sourceRoot})}),await ensureExtensionExports(r,n.outDir),await replaceExtensionBuildOutput({outDir:n.outDir,stagedOutDir:u,transactionRoot:l}),n.outDir}catch(e){throw f=e instanceof ExtensionOutputRestoreError,e}finally{f||await rm(l,{force:!0,recursive:!0})}}export{buildExtensionPackage,tryReadExtensionBuildConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative,resolve}from"node:path";import{stageDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareDevelopmentApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createDevelopmentNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{buildDevelopmentHostCandidate}from"#internal/nitro/host/dev-host-candidate.js";import{computeDevelopmentHostFingerprint}from"#internal/nitro/host/dev-host-fingerprint.js";import{removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import"#internal/nitro/host/drained-nitro-dev-server.js";import{activateDevelopmentGeneration,discardDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";var PostCommitDevelopmentRebuildError=class extends Error{constructor(e){super(`The development worker was replaced but its generation failed to activate. The server keeps serving the previous generation; the next rebuild retries activation.`,{cause:e}),this.name=`PostCommitDevelopmentRebuildError`}},DevelopmentWorkflowWorldChangeRequiresRestartError=class extends Error{constructor(){super(`Changing experimental.workflow.world between the parent-owned local World and a custom World requires restarting eve dev.`),this.name=`DevelopmentWorkflowWorldChangeRequiresRestartError`}};async function createDevelopmentAuthoredRebuildCoordinator(e){return new TransactionalDevelopmentAuthoredRebuildCoordinator({currentHostFingerprint:await computeDevelopmentHostFingerprint(e.initialHost),currentRuntimeFingerprint:e.initialHost.generation.fingerprint,devServer:e.devServer,initialHost:e.initialHost})}var TransactionalDevelopmentAuthoredRebuildCoordinator=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.initialHost,this.#t=e.currentHostFingerprint,this.#n=e.currentRuntimeFingerprint,this.#r=e.devServer,this.#i=usesParentDevelopmentWorkflowWorld(e.initialHost.compileResult.manifest.config.experimental?.workflow?.world)}async rebuild(e){let t=this.#e,r=stageDevelopmentEnvironmentFiles(t.appRoot),a;try{if(a=await prepareDevelopmentApplicationHost(t.appRoot),usesParentDevelopmentWorkflowWorld(a.compileResult.manifest.config.experimental?.workflow?.world)!==this.#i)throw new DevelopmentWorkflowWorldChangeRequiresRestartError;let n=await computeDevelopmentHostFingerprint(a),o=a.generation.fingerprint,s=n!==this.#t,c=o!==this.#n;if(!s&&!c)return await discardPreparedHost(a),a=void 0,r.commit(),{host:
|
|
1
|
+
import{relative,resolve}from"node:path";import{stageDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createDevelopmentApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareDevelopmentApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createDevelopmentNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{buildDevelopmentHostCandidate}from"#internal/nitro/host/dev-host-candidate.js";import{computeDevelopmentHostFingerprint}from"#internal/nitro/host/dev-host-fingerprint.js";import{removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import"#internal/nitro/host/drained-nitro-dev-server.js";import{activateDevelopmentGeneration,discardDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";var PostCommitDevelopmentRebuildError=class extends Error{constructor(e){super(`The development worker was replaced but its generation failed to activate. The server keeps serving the previous generation; the next rebuild retries activation.`,{cause:e}),this.name=`PostCommitDevelopmentRebuildError`}},DevelopmentWorkflowWorldChangeRequiresRestartError=class extends Error{constructor(){super(`Changing experimental.workflow.world between the parent-owned local World and a custom World requires restarting eve dev.`),this.name=`DevelopmentWorkflowWorldChangeRequiresRestartError`}};async function createDevelopmentAuthoredRebuildCoordinator(e){return new TransactionalDevelopmentAuthoredRebuildCoordinator({currentHostFingerprint:await computeDevelopmentHostFingerprint(e.initialHost),currentRuntimeFingerprint:e.initialHost.generation.fingerprint,devServer:e.devServer,initialHost:e.initialHost})}var TransactionalDevelopmentAuthoredRebuildCoordinator=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.initialHost,this.#t=e.currentHostFingerprint,this.#n=e.currentRuntimeFingerprint,this.#r=e.devServer,this.#i=usesParentDevelopmentWorkflowWorld(e.initialHost.compileResult.manifest.config.experimental?.workflow?.world)}async rebuild(e){let t=this.#e,r=stageDevelopmentEnvironmentFiles(t.appRoot),a;try{if(a=await prepareDevelopmentApplicationHost(t.appRoot,{changedPaths:e.changedPaths,previousExtensions:t.workspaceExtensions}),usesParentDevelopmentWorkflowWorld(a.compileResult.manifest.config.experimental?.workflow?.world)!==this.#i)throw new DevelopmentWorkflowWorldChangeRequiresRestartError;let n=await computeDevelopmentHostFingerprint(a),o=a.generation.fingerprint,s=n!==this.#t,c=o!==this.#n;if(!s&&!c){let e={...t,workspaceExtensions:a.workspaceExtensions};return await discardPreparedHost(a),a=void 0,this.#o(e,this.#t,this.#n),r.commit(),{host:e,kind:`unchanged`}}if(!s){await removeDevelopmentHostWorkspace(a.workspace);let i=retainActiveHostWorkspace(t,a);return await activateDevelopmentGeneration({appRoot:i.appRoot,generation:i.generation}),this.#o(i,n,o),a=void 0,r.commit(),startSandboxPrewarmAfterCommit(i,e.changedPaths),{host:i,kind:`runtime`}}let l=await this.#a({hasRuntimeChange:c,nextHost:a,nextHostFingerprint:n,nextRuntimeFingerprint:o});return a=void 0,r.commit(),startSandboxPrewarmAfterCommit(l.host,e.changedPaths),l}catch(e){throw e instanceof PostCommitDevelopmentRebuildError?(r.commit(),e):(r.rollback(),a===void 0?e:await discardFailedHost(e,a))}}async#a(e){let t=e.nextHost;e.hasRuntimeChange||(await discardDevelopmentGeneration(e.nextHost.generation),t={...e.nextHost,generation:this.#e.generation});let n=await createDevelopmentApplicationNitro(t),r=await buildDevelopmentHostCandidate({host:t,nitro:n}),i=t.workspace;if(await this.#r.replaceWorker({dispose:async()=>await removeDevelopmentHostWorkspace(i),entry:r.entry,workerData:r.workerData}),e.hasRuntimeChange)try{await activateDevelopmentGeneration({appRoot:t.appRoot,generation:t.generation})}catch(n){throw await discardDevelopmentGeneration(t.generation).catch(()=>void 0),this.#o({...t,generation:this.#e.generation},e.nextHostFingerprint,this.#n),new PostCommitDevelopmentRebuildError(n)}return this.#o(t,e.nextHostFingerprint,e.hasRuntimeChange?e.nextRuntimeFingerprint:this.#n),{host:t,kind:`structural`}}#o(e,t,n){this.#e=e,this.#t=t,this.#n=n}};function retainActiveHostWorkspace(e,t){return{...t,compiledArtifacts:e.compiledArtifacts,workflowBuildDir:e.workflowBuildDir,workspace:e.workspace}}function startSandboxPrewarmAfterCommit(e,t){if(!hasSandboxRelatedChange(e.compileResult.project.agentRoot,t))return;let n=createDevelopmentNitroArtifactsConfig({appRoot:e.appRoot,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world});startDevelopmentSandboxPrewarmInBackground({appRoot:e.appRoot,compiledArtifactsSource:resolveNitroCompiledArtifactsSource(n),log:e=>console.log(e)})}function hasSandboxRelatedChange(n,r){return r.some(r=>{let i=relative(resolve(n),resolve(r)),a=i.split(/[\\/]/u);return a[0]===`..`||i===``?!1:a[0]===`sandbox.ts`||a[0]===`sandbox`||a[0]===`workspace`||a[0]===`skills`})}async function discardPreparedHost(e){let t=(await Promise.allSettled([discardDevelopmentGeneration(e.generation),removeDevelopmentHostWorkspace(e.workspace)])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length>0)throw AggregateError(t,`Failed to discard development host "${e.workspace.rootDir}".`)}async function discardFailedHost(e,t){try{return await discardPreparedHost(t),e}catch(t){return AggregateError([e,t],`Development rebuild rollback failed.`,{cause:e})}}export{DevelopmentWorkflowWorldChangeRequiresRestartError,PostCommitDevelopmentRebuildError,createDevelopmentAuthoredRebuildCoordinator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import{dirname,join,normalize,resolve,sep}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=new Map,s=new Set,c=await resolveAuthoredWatchPaths(t),l=createWatchPathMap(c),u=watch$1(c,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:shouldIgnoreWatcherPath}),d=waitForWatcherReady(u),rebuild=async i=>{n||(r=r.then(async()=>{if(n)return;let r=[...o.values()];if(!i&&r.length===0)return;let a=[...s];o.clear(),s.clear();let c=t;r.length>0&&console.log(formatChangeDetectedLogLine(c.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:a});t=n.host,n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE),l=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:l,watcher:u})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)};return u.on(`all`,(e,t)=>{n||!a||e===`addDir`||e===`unlinkDir`||(o.set(`${e}:${t}`,{event:e,path:t}),s.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await d,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await u.close(),await r},flush,rebuild:async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0)}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let t=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),r=await resolveTsConfigWatchPaths(e.appRoot),i=await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let n of getDevelopmentEnvironmentFilePaths(e.appRoot))t.add(n);for(let e of i)t.add(e);for(let e of r)t.add(e);for(let r of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)t.add(join(r,e));return[...t].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let n=resolve(e),r=[n],a=n;for(;;){if(hasWatchRootMarker(a))return r;let e=dirname(a);if(e===a)return[n];a=e,r.push(a)}}function hasWatchRootMarker(t){return WATCH_ROOT_MARKER_NAMES.some(r=>existsSync(join(t,r)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e){return normalize(e).split(sep).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))}export{startAuthoredSourceWatcher};
|
|
1
|
+
import{existsSync}from"node:fs";import{dirname,join,normalize,resolve,sep}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=new Map,s=new Set,c=await resolveAuthoredWatchPaths(t),l=createWatchPathMap(c),u=watch$1(c,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:e=>shouldIgnoreWatcherPath(e,t.workspaceExtensions)}),d=waitForWatcherReady(u),rebuild=async i=>{n||(r=r.then(async()=>{if(n)return;let r=[...o.values()];if(!i&&r.length===0)return;let a=[...s];o.clear(),s.clear();let c=t;r.length>0&&console.log(formatChangeDetectedLogLine(c.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:a});t=n.host,n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE),l=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:l,watcher:u})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)};return u.on(`all`,(e,t)=>{n||!a||e===`addDir`||e===`unlinkDir`||(o.set(`${e}:${t}`,{event:e,path:t}),s.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await d,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await u.close(),await r},flush,rebuild:async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0)}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let t=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),r=await resolveTsConfigWatchPaths(e.appRoot),i=await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let n of e.workspaceExtensions){t.add(n.config.sourceRoot);for(let e of n.buildConfigPaths)t.add(e)}for(let n of getDevelopmentEnvironmentFilePaths(e.appRoot))t.add(n);for(let e of i)t.add(e);for(let e of r)t.add(e);for(let r of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)t.add(join(r,e));return[...t].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let n=resolve(e),r=[n],a=n;for(;;){if(hasWatchRootMarker(a))return r;let e=dirname(a);if(e===a)return[n];a=e,r.push(a)}}function hasWatchRootMarker(t){return WATCH_ROOT_MARKER_NAMES.some(r=>existsSync(join(t,r)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e,t){return normalize(e).split(sep).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))||t.some(t=>isPathInsideOrEqual(e,t.config.outDir))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{startAuthoredSourceWatcher};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ExtensionBuildConfig } from "#internal/nitro/host/build-extension.js";
|
|
2
|
+
/** Build inputs retained with a prepared dev host for path-scoped extension HMR. */
|
|
3
|
+
export interface DevelopmentWorkspaceExtension {
|
|
4
|
+
readonly config: ExtensionBuildConfig;
|
|
5
|
+
/** Canonical package root, with workspace links resolved. */
|
|
6
|
+
readonly packageRoot: string;
|
|
7
|
+
/** Non-source inputs that affect publisher output, such as tsconfig files. */
|
|
8
|
+
readonly buildConfigPaths: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds mounted source-backed workspace extensions before the consuming agent
|
|
12
|
+
* compiles and returns the inputs needed to scope the next development rebuild.
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareDevelopmentWorkspaceExtensions(input: {
|
|
15
|
+
readonly appRoot: string;
|
|
16
|
+
readonly changedPaths?: readonly string[];
|
|
17
|
+
readonly previousExtensions?: readonly DevelopmentWorkspaceExtension[];
|
|
18
|
+
}): Promise<readonly DevelopmentWorkspaceExtension[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{basename,dirname,join,resolve,sep}from"node:path";import{discoverExtensionMountDeclarations}from"#discover/discover-agent.js";import{buildExtensionPackage,tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{realpath,stat}from"node:fs/promises";import{resolveDiscoveryProject}from"#discover/project.js";import{createDiskProjectSource}from"#discover/project-source.js";import{locateExtensionMountPackage}from"#discover/extensions.js";import{isAuthoredSourcePath,resolveDevelopmentSourceRoot}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";async function prepareDevelopmentWorkspaceExtensions(e){let t=resolve(e.appRoot),n=await resolveDiscoveryProject(t),i=createDiskProjectSource(),s=await discoverExtensionMountDeclarations({agentRoot:n.agentRoot,source:i}),c=await toCanonicalPath(resolveDevelopmentSourceRoot(t)),l=new Map;for(let e of s.mounts){let r=await resolveWorkspaceExtension({appRoot:t,agentRoot:n.agentRoot,mount:e,source:i,workspaceSourceRoot:c});r!==void 0&&l.set(r.packageRoot,r)}let u=[...l.values()].sort((e,t)=>e.packageRoot.localeCompare(t.packageRoot)),d=new Map(e.previousExtensions?.map(e=>[e.packageRoot,e])),f=e.changedPaths===void 0?void 0:await Promise.all(e.changedPaths.map(async e=>await toCanonicalPath(e))),p=e.previousExtensions===void 0||f?.length===0;return await Promise.all(u.map(async e=>{let t=d.get(e.packageRoot);(p===!0||t===void 0||!sameBuildInputs(t,e)||f?.some(t=>affectsExtensionBuild(t,e))===!0)&&await buildExtensionPackage(e.packageRoot,e.config)})),u}async function resolveWorkspaceExtension(e){let t=await locateExtensionMountPackage({source:e.source,agentRoot:e.agentRoot,appRoot:e.appRoot,mount:e.mount.mountRef,namespace:e.mount.namespace});if(t.location?.authoredSourceRoot===void 0)return;let i=await realpath(t.location.packageRoot).catch(()=>void 0);if(i===void 0||!isAuthoredSourcePath(i,e.workspaceSourceRoot))return;let a=await tryReadExtensionBuildConfig(i);if(a===null||(await stat(a.sourceRoot).catch(()=>void 0))?.isDirectory()!==!0)return;let o=[join(i,`package.json`),join(i,`tsconfig.json`),...await resolveTsConfigDependencyPaths(i)];return{config:a,packageRoot:i,buildConfigPaths:[...new Set(o.map(e=>resolve(e)))].sort((e,t)=>e.localeCompare(t))}}function affectsExtensionBuild(e,t){return isPathInsideOrEqual(e,t.config.sourceRoot)||t.buildConfigPaths.includes(e)}function sameBuildConfig(e,t){return e.sourceRoot===t.sourceRoot&&e.distRoot===t.distRoot&&e.outDir===t.outDir&&e.packageName===t.packageName&&e.shortName===t.shortName&&e.runtimeDependencies.length===t.runtimeDependencies.length&&e.runtimeDependencies.every((e,n)=>e===t.runtimeDependencies[n])}function sameBuildInputs(e,t){return sameBuildConfig(e.config,t.config)&&e.buildConfigPaths.length===t.buildConfigPaths.length&&e.buildConfigPaths.every((e,n)=>e===t.buildConfigPaths[n])}function isPathInsideOrEqual(e,t){let n=resolve(e),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}async function toCanonicalPath(i){let a=resolve(i),o=[];for(;;)try{return join(await realpath(a),...o.reverse())}catch{let n=dirname(a);if(n===a)return resolve(i);o.push(basename(a)),a=n}}export{prepareDevelopmentWorkspaceExtensions};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Resolved producer inputs for an extension package. */
|
|
2
|
+
export interface ExtensionBuildConfig {
|
|
3
|
+
/** Absolute authoring root from `eve.extension.source`. */
|
|
4
|
+
readonly sourceRoot: string;
|
|
5
|
+
/** Absolute agent-shaped distribution root from `eve.extension.dist`. */
|
|
6
|
+
readonly distRoot: string;
|
|
7
|
+
/** Directory containing the dist root and generated package entrypoints. */
|
|
8
|
+
readonly outDir: string;
|
|
9
|
+
readonly packageName: string;
|
|
10
|
+
/** Short package name used for the generated named mount export. */
|
|
11
|
+
readonly shortName: string;
|
|
12
|
+
/** Packages allowed to remain as imports in the published distribution. */
|
|
13
|
+
readonly runtimeDependencies: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/** Reads and validates the extension producer contract from `package.json`. */
|
|
16
|
+
export declare function tryReadExtensionBuildConfig(rootDir: string): Promise<ExtensionBuildConfig | null>;
|
|
17
|
+
/** Ensures package exports point at the build output's generated entrypoints. */
|
|
18
|
+
export declare function ensureExtensionExports(appRoot: string, outDir: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join,relative,resolve,sep}from"node:path";import{readFile,writeFile}from"node:fs/promises";import{parseExtensionPackageRoots}from"#shared/extension-package-contract.js";async function tryReadExtensionBuildConfig(n){let o=resolve(n),c;try{c=JSON.parse(await readFile(join(o,`package.json`),`utf8`))}catch{return null}let l=parseExtensionPackageRoots(c.eve?.extension);if(l===null)return null;if(l.source===void 0)throw Error("`eve.extension.dist` is declared without `eve.extension.source`. Building an extension requires the authoring root; add `eve.extension.source` to package.json.");let u=resolve(o,l.source),d=resolve(o,l.dist),f=dirname(d);if(assertManagedPackagePath(o,u,`eve.extension.source`),assertManagedPackagePath(o,d,`eve.extension.dist`),assertManagedPackagePath(o,f,`eve.extension.dist output directory`),u===d)throw Error("`eve.extension.source` and `eve.extension.dist` must be different paths.");if(u===f||u.startsWith(`${f}${sep}`)||f.startsWith(`${u}${sep}`))throw Error("`eve.extension.source` and the managed dist output cannot overlap.");let p=typeof c.name==`string`&&c.name.length>0?c.name:`extension`;return{sourceRoot:u,distRoot:d,outDir:f,packageName:p,shortName:safeJsIdentifier(p.slice(p.lastIndexOf(`/`)+1)),runtimeDependencies:[...new Set([...Object.keys(c.dependencies??{}),...Object.keys(c.optionalDependencies??{}),...Object.keys(c.peerDependencies??{})])].sort()}}async function ensureExtensionExports(e,r){let i=join(e,`package.json`),s=await readFile(i,`utf8`),c=JSON.parse(s),l=relative(e,r).replaceAll(`\\`,`/`),u=l.startsWith(`.`)?l:`./${l}`,d={".":{types:`${u}/index.d.ts`,default:`${u}/index.mjs`},"./tools":{types:`${u}/tools/index.d.ts`,default:`${u}/tools/index.mjs`}},f=typeof c.exports==`object`&&c.exports!==null&&!Array.isArray(c.exports)?c.exports:{},p=!1;for(let[e,t]of Object.entries(d)){let n=f[e];typeof n==`object`&&n&&n.types===t.types&&n.default===t.default||(f[e]=t,p=!0)}p&&(c.exports=f,await writeFile(i,`${JSON.stringify(c,null,2)}\n`,`utf8`))}function assertManagedPackagePath(e,t,r){let a=relative(e,t);if(a===``||a===`..`||a.startsWith(`..${sep}`))throw Error(`\`${r}\` must point to a directory inside the extension package.`)}function safeJsIdentifier(e){let t=e.replace(/[^A-Za-z0-9_$]/g,`_`);return/^[A-Za-z_$]/.test(t)?t:`_${t}`}export{ensureExtensionExports,tryReadExtensionBuildConfig};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ExtensionCapabilityRequirements } from "#compiler/extension-compatibility.js";
|
|
2
|
+
import type { AgentSourceManifest } from "#discover/manifest.js";
|
|
3
|
+
import type { ModuleSourceRef } from "#shared/source-ref.js";
|
|
4
|
+
/** Derives only the extension-facing contracts used by one authored tree. */
|
|
5
|
+
export declare function deriveExtensionCapabilityRequirements(input: {
|
|
6
|
+
readonly declarationModule: ModuleSourceRef;
|
|
7
|
+
readonly manifest: AgentSourceManifest;
|
|
8
|
+
readonly runtimeDependencies: readonly string[];
|
|
9
|
+
readonly sourceRoot: string;
|
|
10
|
+
}): Promise<ExtensionCapabilityRequirements>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join}from"node:path";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{EXTENSION_CAPABILITY_VERSIONS}from"#compiler/extension-compatibility.js";import{extensionUsesState}from"#internal/nitro/host/extension-state-usage.js";async function deriveExtensionCapabilityRequirements(t){let n=new Set([`extension`]),r={externalDependencies:t.runtimeDependencies},[i,a,o,s,c]=await Promise.all([Promise.all(t.manifest.tools.map(e=>compileToolEntry(t.sourceRoot,e,r))),Promise.all(t.manifest.skills.map(e=>compileSkillSource(t.sourceRoot,e,r))),Promise.all(t.manifest.instructions.map(e=>compileInstructionsEntry(t.sourceRoot,e,r))),loadAuthoredModuleNamespace(join(t.sourceRoot,t.declarationModule.logicalPath),{externalDependencies:t.runtimeDependencies}),extensionUsesState(t.sourceRoot)]);i.length>0&&n.add(`tool`),i.some(e=>e.kind===`dynamic-tool`)&&n.add(`dynamicTool`),t.manifest.connections.length>0&&n.add(`connection`),t.manifest.hooks.length>0&&n.add(`hook`),a.length>0&&n.add(`skill`),a.some(e=>e.kind===`dynamic-skill`)&&n.add(`dynamicSkill`),o.length>0&&n.add(`instructions`),o.some(e=>e.kind===`dynamic-instructions`)&&n.add(`dynamicInstructions`);let l=s[t.declarationModule.exportName??`default`];return(typeof l==`function`||typeof l==`object`&&l)&&`schema`in l&&l.schema!==void 0&&n.add(`config`),c&&n.add(`state`),Object.fromEntries(Object.keys(EXTENSION_CAPABILITY_VERSIONS).filter(e=>n.has(e)).map(e=>[e,EXTENSION_CAPABILITY_VERSIONS[e]]))}export{deriveExtensionCapabilityRequirements};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits declarations for an extension source tree using the extension's own
|
|
3
|
+
* TypeScript installation and authored tsconfig when available.
|
|
4
|
+
*/
|
|
5
|
+
export declare function emitExtensionDeclarations(input: {
|
|
6
|
+
readonly appRoot: string;
|
|
7
|
+
readonly declarationsRoot: string;
|
|
8
|
+
readonly moduleLogicalPaths: readonly string[];
|
|
9
|
+
readonly sourceRoot: string;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire}from"node:module";import{dirname,join,relative}from"node:path";import{readFile,readdir,stat}from"node:fs/promises";import{execFile}from"node:child_process";import{promisify}from"node:util";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"#discover/filesystem.js";async function emitExtensionDeclarations(e){let t=await resolveTypeScriptBinary(e.appRoot),n=join(e.appRoot,`tsconfig.json`),r=await stat(n).then(e=>e.isFile()).catch(()=>!1),i=[`--declaration`,`--emitDeclarationOnly`,`--noEmit`,`false`,`--noEmitOnError`,`true`,`--rootDir`,e.appRoot,`--outDir`,e.declarationsRoot,`--pretty`,`false`],s=r?[`--project`,n,...i]:[...i,`--allowJs`,`--checkJs`,`false`,`--module`,`esnext`,`--moduleResolution`,`bundler`,`--target`,`ES2022`,`--skipLibCheck`,`true`,...await collectDeclarationInputs(e.sourceRoot)];try{await promisify(execFile)(process.execPath,[t,...s],{cwd:e.appRoot,maxBuffer:10*1024*1024})}catch(e){let t=declarationEmitOutput(e);throw Error(`Cannot emit extension declarations${t.length>0?`:\n${t}`:`.`}`,{cause:e})}await assertModuleDeclarationsEmitted(e)}async function assertModuleDeclarationsEmitted(e){let t=relative(e.appRoot,e.sourceRoot),r=(await Promise.all(e.moduleLogicalPaths.map(async n=>await stat(join(e.declarationsRoot,t,declarationLogicalPath(n))).then(e=>e.isFile()).catch(()=>!1)?void 0:n))).filter(e=>e!==void 0);if(r.length===0)return;if(r.length===e.moduleLogicalPaths.length)throw Error(`TypeScript emitted no declarations for "${t}". Ensure the package tsconfig.json \`include\` covers every module under \`eve.extension.source\`.`);let i=r.length===1?`module`:`modules`;throw Error(`TypeScript emitted no declaration for extension ${i} ${r.map(e=>JSON.stringify(e)).join(`, `)}. Include ${r.length===1?`it`:`them`} in the package tsconfig.json before publishing the extension.`)}function declarationLogicalPath(e){if(e.endsWith(`.mts`)||e.endsWith(`.mjs`))return`${e.slice(0,-4)}.d.mts`;if(e.endsWith(`.cts`)||e.endsWith(`.cjs`))return`${e.slice(0,-4)}.d.cts`;if(e.endsWith(`.ts`)||e.endsWith(`.js`))return`${e.slice(0,-3)}.d.ts`;throw Error(`Unsupported extension module path "${e}".`)}async function collectDeclarationInputs(e){let t=[];for(let n of await readdir(e,{withFileTypes:!0})){let r=join(e,n.name);n.isDirectory()?t.push(...await collectDeclarationInputs(r)):n.isFile()&&SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS.some(e=>n.name.endsWith(e))&&t.push(r)}return t.sort()}function declarationEmitOutput(e){if(!(e instanceof Error))return String(e);let t=e;return[t.stdout,t.stderr,t.message].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
2
|
+
`).trim()}async function resolveTypeScriptBinary(n){for(let i of[join(n,`package.json`),import.meta.url]){let n;try{n=createRequire(i).resolve(`typescript/package.json`)}catch{continue}let a=JSON.parse(await readFile(n,`utf8`)),o=typeof a.bin==`string`?a.bin:a.bin?.tsc;if(o!==void 0)return join(dirname(n),o)}throw Error("Cannot build an eve extension without TypeScript. Add `typescript` to the package's devDependencies.")}export{emitExtensionDeclarations};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentSourceManifest } from "#discover/manifest.js";
|
|
2
|
+
import type { ModuleSourceRef } from "#shared/source-ref.js";
|
|
3
|
+
/** Emits the runnable, agent-shaped tree and its package entrypoints into staging. */
|
|
4
|
+
export declare function emitExtensionDistribution(input: {
|
|
5
|
+
readonly appRoot: string;
|
|
6
|
+
readonly declarationModule: ModuleSourceRef;
|
|
7
|
+
readonly declarationsRoot: string;
|
|
8
|
+
readonly manifest: AgentSourceManifest;
|
|
9
|
+
readonly runtimeDependencies: readonly string[];
|
|
10
|
+
readonly shortName: string;
|
|
11
|
+
readonly sourceRoot: string;
|
|
12
|
+
readonly stagedDistRoot: string;
|
|
13
|
+
readonly stagedOutDir: string;
|
|
14
|
+
readonly transactionRoot: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Thrown when publishing failed and the prior output could not be moved back.
|
|
18
|
+
* The prior output survives at {@link preservedOutputPath}; callers must not
|
|
19
|
+
* delete the transaction directory that contains it.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ExtensionOutputRestoreError extends Error {
|
|
22
|
+
readonly preservedOutputPath: string;
|
|
23
|
+
constructor(preservedOutputPath: string, options: {
|
|
24
|
+
cause: unknown;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Atomically publishes a staged extension output, restoring the prior tree on failure. */
|
|
28
|
+
export declare function replaceExtensionBuildOutput(input: {
|
|
29
|
+
readonly outDir: string;
|
|
30
|
+
readonly stagedOutDir: string;
|
|
31
|
+
readonly transactionRoot: string;
|
|
32
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{dirname,join,relative}from"node:path";import{cp,mkdir,readdir,rename,writeFile}from"node:fs/promises";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"#discover/filesystem.js";import{bundleExtensionDistributionGraph}from"#internal/authored-module-loader.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FILENAME}from"#compiler/extension-compatibility.js";import{emitExtensionDeclarations}from"#internal/nitro/host/extension-declarations.js";async function emitExtensionDistribution(a){let o=await collectExtensionSourceFiles(a.sourceRoot),s=a.manifest.skills.filter(e=>e.sourceKind===`skill-package`).map(e=>relative(a.sourceRoot,e.rootPath).replaceAll(`\\`,`/`)),c=o.filter(e=>isAuthoredModule(e.logicalPath)&&!s.some(t=>e.logicalPath.startsWith(`${t}/`)));await copyDistributionDataFiles({files:o,moduleLogicalPaths:new Set(c.map(e=>e.logicalPath)),stagedDistRoot:a.stagedDistRoot});let l=await bundleExtensionDistributionGraph({entries:await createDistributionEntries({...a,moduleFiles:c}),packageRoot:a.appRoot,runtimeDependencies:a.runtimeDependencies});for(let[n,r]of l){let o=join(a.stagedOutDir,n);await mkdir(dirname(o),{recursive:!0}),await writeFile(o,r,`utf8`)}await emitExtensionDeclarations({appRoot:a.appRoot,declarationsRoot:a.declarationsRoot,moduleLogicalPaths:c.map(e=>e.logicalPath),sourceRoot:a.sourceRoot});let u=relative(a.appRoot,a.sourceRoot);try{await cp(join(a.declarationsRoot,u),a.stagedDistRoot,{recursive:!0})}catch(e){throw isFileSystemError(e,`ENOENT`)?Error(`TypeScript emitted no declarations for "${u}". Ensure the package tsconfig.json \`include\` covers every module under \`eve.extension.source\`.`,{cause:e}):e}await emitDeclarationBarrels(a)}var ExtensionOutputRestoreError=class extends Error{preservedOutputPath;constructor(e,t){super(`Publishing the extension build output failed, and the previous output could not be restored. It is preserved at "${e}".`,t),this.name=`ExtensionOutputRestoreError`,this.preservedOutputPath=e}};async function replaceExtensionBuildOutput(n){await mkdir(dirname(n.outDir),{recursive:!0});let r=join(n.transactionRoot,`previous-output`),a=!1;try{await rename(n.outDir,r),a=!0}catch(e){if(!isFileSystemError(e,`ENOENT`))throw e}try{await rename(n.stagedOutDir,n.outDir)}catch(e){if(a)try{await rename(r,n.outDir)}catch{throw new ExtensionOutputRestoreError(r,{cause:e})}throw e}}async function collectExtensionSourceFiles(e,r=e){let i=[];for(let o of await readdir(r,{withFileTypes:!0})){let a=join(r,o.name);if(o.isDirectory())i.push(...await collectExtensionSourceFiles(e,a));else if(o.isFile()){let t=relative(e,a).replaceAll(`\\`,`/`);if(t===EXTENSION_COMPATIBILITY_MANIFEST_FILENAME)throw Error(`The extension source cannot contain "${EXTENSION_COMPATIBILITY_MANIFEST_FILENAME}"; eve reserves it for generated compatibility metadata.`);i.push({absolutePath:a,logicalPath:t})}else throw Error(`Extension source entry "${a}" must be a regular file or directory.`)}return i.sort((e,t)=>e.logicalPath.localeCompare(t.logicalPath))}function isAuthoredModule(e){return!/\.d\.[cm]?ts$/.test(e)&&SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS.some(t=>e.endsWith(t))}async function copyDistributionDataFiles(n){await Promise.all(n.files.filter(e=>!n.moduleLogicalPaths.has(e.logicalPath)).map(async a=>{let o=join(n.stagedDistRoot,a.logicalPath);await mkdir(dirname(o),{recursive:!0}),await cp(a.absolutePath,o)}))}async function createDistributionEntries(e){let r=relative(e.stagedOutDir,e.stagedDistRoot).replaceAll(`\\`,`/`),i=e.moduleFiles.map(e=>({name:`${r}/${stripAuthoredModuleExtension(e.logicalPath)}`,path:e.absolutePath})),a=new Set;for(let e of i){if(a.has(e.name))throw Error(`Multiple extension modules emit the same path "${e.name}.mjs".`);a.add(e.name)}let o=join(e.transactionRoot,`barrels`);return i.push(await stageRuntimeBarrel({barrelPath:join(o,`index.mjs`),name:`index`,reexports:[{name:`default`,path:join(e.sourceRoot,e.declarationModule.logicalPath)},{name:e.shortName,path:join(e.sourceRoot,e.declarationModule.logicalPath)}]}),await stageRuntimeBarrel({barrelPath:join(o,`tools.mjs`),name:`tools/index`,reexports:e.manifest.tools.map(n=>({name:toolExportName(n.logicalPath),path:join(e.sourceRoot,n.logicalPath)}))})),i}async function stageRuntimeBarrel(t){await mkdir(dirname(t.barrelPath),{recursive:!0});let n=t.reexports.map(n=>reexportLine(n.name,relativeImport(dirname(t.barrelPath),n.path)));return await writeFile(t.barrelPath,`${n.join(`
|
|
2
|
+
`)}\n`,`utf8`),{name:t.name,path:t.barrelPath}}async function emitDeclarationBarrels(e){await mkdir(join(e.stagedOutDir,`tools`),{recursive:!0});let n=relativeImport(e.stagedOutDir,join(e.stagedDistRoot,e.declarationModule.logicalPath));await writeDeclarationBarrel({path:join(e.stagedOutDir,`index.d.ts`),reexports:[{name:`default`,specifier:n},{name:e.shortName,specifier:n}]}),await writeDeclarationBarrel({path:join(e.stagedOutDir,`tools`,`index.d.ts`),reexports:e.manifest.tools.map(n=>({name:toolExportName(n.logicalPath),specifier:relativeImport(join(e.stagedOutDir,`tools`),join(e.stagedDistRoot,n.logicalPath))}))})}async function writeDeclarationBarrel(e){let t=e.reexports.map(e=>reexportLine(e.name,toDeclarationSpecifier(e.specifier)));await writeFile(e.path,[`// Generated by eve. Do not edit by hand.`,``,...t,``].join(`
|
|
3
|
+
`),`utf8`)}function stripAuthoredModuleExtension(e){for(let t of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(t))return e.slice(0,e.length-t.length);return e}function toolExportName(e){let t=stripAuthoredModuleExtension(e).replace(/^tools\//,``).replace(/[^A-Za-z0-9_$]/g,`_`);return/^[A-Za-z_$]/.test(t)?t:`_${t}`}function relativeImport(e,t){let r=relative(e,t).replaceAll(`\\`,`/`);return r.startsWith(`.`)?r:`./${r}`}function reexportLine(e,t){return e==="default"?`export { default } from ${JSON.stringify(t)};`:`export { default as ${e} } from ${JSON.stringify(t)};`}function toDeclarationSpecifier(e){return e.replace(/\.mts$/,`.mjs`).replace(/\.cts$/,`.cjs`).replace(/\.tsx?$/,`.js`)}function isFileSystemError(e,t){return e instanceof Error&&`code`in e&&e.code===t}export{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects whether an authored extension tree calls `defineState` from
|
|
3
|
+
* `eve/context`. Usage is followed through local re-export barrels — aliased
|
|
4
|
+
* re-exports, `export *`, and import-then-re-export chains — so indirect
|
|
5
|
+
* usage still stamps the `state` capability requirement.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extensionUsesState(sourceRoot: string): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"#discover/filesystem.js";import{parseWithNitroRolldownAst}from"#internal/bundler/nitro-rolldown.js";const STATE_MODULE=`eve/context`,STATE_EXPORT=`defineState`;async function extensionUsesState(e){let t=await collectAuthoredModules(e),n=new Map;for(let e of t)n.set(e,await readFile(e,`utf8`));if(![...n.values()].some(e=>e.includes(STATE_EXPORT)))return!1;let i=new Set(t),a=new Map;for(let[e,t]of n){let n=await parseWithNitroRolldownAst(e,t);a.set(e,analyzeModule(n))}let l=computeStateExports(a,i);for(let[e,t]of a){for(let[n,r]of t.imports)if(t.calledIdentifiers.has(n)&&specifierExportsState({...r,fromModulePath:e,stateExports:l,moduleSet:i}))return!0;for(let[n,r]of t.namespaceImports){let a=t.calledMembers.get(n);if(a===void 0)continue;if(r===STATE_MODULE){if(a.has(STATE_EXPORT))return!0;continue}let o=resolveLocalSpecifier(e,r,i),u=o===null?void 0:l.get(o);if(u!==void 0&&[...a].some(e=>u.has(e)))return!0}}return!1}async function collectAuthoredModules(e){let n=[];for(let r of await readdir(e,{withFileTypes:!0})){let i=join(e,r.name);r.isDirectory()?n.push(...await collectAuthoredModules(i)):r.isFile()&&!/\.d\.[cm]?ts$/.test(r.name)&&SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS.some(e=>r.name.endsWith(e))&&n.push(i)}return n.sort()}function analyzeModule(e){let t={imports:new Map,namespaceImports:new Map,reexports:new Map,starReexportSpecifiers:[],localReexports:new Map,calledIdentifiers:new Set,calledMembers:new Map};return walkAst(e,e=>{if(e.type===`ImportDeclaration`){let n=stringValue(e.source);if(n===null)return;for(let r of e.specifiers??[]){let e=moduleName(r.local);if(e!==null){if(r.type===`ImportNamespaceSpecifier`)t.namespaceImports.set(e,n);else if(r.type===`ImportSpecifier`){let i=moduleName(r.imported);i!==null&&t.imports.set(e,{specifier:n,importedName:i})}}}}else if(e.type===`ExportNamedDeclaration`){let n=stringValue(e.source);for(let r of e.specifiers??[]){if(r.type!==`ExportSpecifier`)continue;let e=moduleName(r.local),i=moduleName(r.exported)??e;e===null||i===null||(n===null?t.localReexports.set(i,e):t.reexports.set(i,{specifier:n,importedName:e}))}}else if(e.type===`ExportAllDeclaration`){let n=stringValue(e.source);n!==null&&e.exported==null&&t.starReexportSpecifiers.push(n)}else if(e.type===`CallExpression`){let n=e.callee;if(n?.type===`Identifier`){let e=moduleName(n);e!==null&&t.calledIdentifiers.add(e)}else if(n?.type===`MemberExpression`&&n.object?.type===`Identifier`){let e=moduleName(n.object),r=moduleName(n.property);if(e!==null&&r!==null){let n=t.calledMembers.get(e)??new Set;n.add(r),t.calledMembers.set(e,n)}}}}),t}function computeStateExports(e,t){let n=new Map;for(let t of e.keys())n.set(t,new Set);let r=!0;for(;r;){r=!1;for(let[i,a]of e){let e=n.get(i),add=t=>{e.has(t)||(e.add(t),r=!0)};for(let[e,r]of a.reexports)specifierExportsState({...r,fromModulePath:i,stateExports:n,moduleSet:t})&&add(e);for(let e of a.starReexportSpecifiers){if(e===STATE_MODULE){add(STATE_EXPORT);continue}let r=resolveLocalSpecifier(i,e,t);if(r!==null)for(let e of n.get(r)??[])add(e)}for(let[e,r]of a.localReexports){let o=a.imports.get(r);o!==void 0&&specifierExportsState({...o,fromModulePath:i,stateExports:n,moduleSet:t})&&add(e)}}}return n}function specifierExportsState(e){if(e.specifier===STATE_MODULE)return e.importedName===STATE_EXPORT;let t=resolveLocalSpecifier(e.fromModulePath,e.specifier,e.moduleSet);return t!==null&&(e.stateExports.get(t)?.has(e.importedName)??!1)}function resolveLocalSpecifier(r,i,o){if(!i.startsWith(`.`))return null;let s=resolve(dirname(r),i),c=[s,...emittedExtensionVariants(s)];for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)c.push(`${s}${e}`,join(s,`index${e}`));return c.find(e=>o.has(e))??null}function emittedExtensionVariants(e){return[[`.js`,`.ts`],[`.jsx`,`.tsx`],[`.mjs`,`.mts`],[`.cjs`,`.cts`]].filter(([t])=>e.endsWith(t)).map(([t,n])=>e.slice(0,-t.length)+n)}function moduleName(e){return e==null?null:typeof e.name==`string`?e.name:typeof e.value==`string`?e.value:null}function stringValue(e){return typeof e?.value==`string`?e.value:null}function walkAst(e,t){t(e);for(let n of Object.values(e))if(Array.isArray(n))for(let e of n)typeof e==`object`&&e&&`type`in e&&walkAst(e,t);else typeof n==`object`&&n&&`type`in n&&walkAst(n,t)}export{extensionUsesState};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { ApplicationBuildWorkspace } from "#internal/application/build-workspace.js";
|
|
2
|
+
import { type DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";
|
|
2
3
|
import type { PreparedApplicationHost, PreparedDevelopmentApplicationHost } from "#internal/nitro/host/types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Compiles one authored app and stages an isolated runtime generation and host
|
|
5
6
|
* candidate without changing the active development server.
|
|
6
7
|
*/
|
|
7
|
-
export declare function prepareDevelopmentApplicationHost(appRoot: string
|
|
8
|
+
export declare function prepareDevelopmentApplicationHost(appRoot: string, options?: {
|
|
9
|
+
readonly changedPaths?: readonly string[];
|
|
10
|
+
readonly previousExtensions?: readonly DevelopmentWorkspaceExtension[];
|
|
11
|
+
}): Promise<PreparedDevelopmentApplicationHost>;
|
|
8
12
|
/**
|
|
9
13
|
* Compiles one authored app into an invocation-owned build workspace and
|
|
10
14
|
* stages the package-owned artifacts the production Nitro build needs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{createDevelopmentHostWorkspace,removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import{discardDevelopmentGeneration,stageDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{resolveSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgentInWorkspace}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";async function prepareDevelopmentApplicationHost(a){let o=await createDevelopmentHostWorkspace(a),
|
|
1
|
+
import{join}from"node:path";import{createDevelopmentHostWorkspace,removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import{discardDevelopmentGeneration,stageDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{resolveSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgentInWorkspace}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";import{prepareDevelopmentWorkspaceExtensions}from"#internal/nitro/host/dev-workspace-extensions.js";async function prepareDevelopmentApplicationHost(a,o={}){let s={appRoot:a};o.changedPaths!==void 0&&(s.changedPaths=o.changedPaths),o.previousExtensions!==void 0&&(s.previousExtensions=o.previousExtensions);let c=await prepareDevelopmentWorkspaceExtensions(s),l=await createDevelopmentHostWorkspace(a),u;try{let t=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(a,`.eve`),writeRoot:l.compilerArtifactsDir},startPath:a}),n=await resolveSchedules({manifest:t.manifest});return u=await stageDevelopmentGeneration(t),{...createPreparedApplicationHost({compileResult:t,compiledArtifacts:await writeDevelopmentCompiledArtifactsFiles({compileResult:t,outDir:l.artifactsDir,runtimeAppRoot:u.runtimeAppRoot}),schedules:n,workflowBuildDir:l.workflowBuildDir}),generation:u,workspaceExtensions:c,workspace:l}}catch(e){let t=[removeDevelopmentHostWorkspace(l)];u!==void 0&&t.push(discardDevelopmentGeneration(u));let i=(await Promise.allSettled(t)).flatMap(e=>e.status===`rejected`?[e.reason]:[]);throw i.length>0?AggregateError([e,...i],`Failed to prepare and discard a development host candidate.`,{cause:e}):e}}async function prepareProductionApplicationHost(t){let n=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(t.publication.output.finalDir,`.eve`),writeRoot:t.compiler.artifactsDir},startPath:t.appRoot}),r=await resolveSchedules({manifest:n.manifest});return createPreparedApplicationHost({compileResult:n,compiledArtifacts:await writeCompiledArtifactsFiles({compileResult:n,defaultWorkflowWorld:resolveProductionWorkflowWorldTarget(),outDir:t.host.artifactsDir}),schedules:r,workflowBuildDir:t.workflow.buildDir})}function createPreparedApplicationHost(e){return{appRoot:e.compileResult.project.appRoot,compileResult:e.compileResult,compiledArtifacts:e.compiledArtifacts,scheduleRegistrations:createScheduleRegistrations(e.schedules),schedules:e.schedules,workflowBuildDir:e.workflowBuildDir}}function resolveProductionWorkflowWorldTarget(){return process.env.VERCEL?`vercel`:`local`}export{prepareDevelopmentApplicationHost,prepareProductionApplicationHost};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}from"#protocol/routes.js";import{isLoopbackServerUrl}from"#shared/network-address.js";import{detectPackageManager}from"#setup/package-manager.js";import{eveDevArguments}from"#setup/primitives/index.js";import{toErrorMessage}from"#shared/errors.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{randomBytes}from"node:crypto";import{resolveDiscoveryProject}from"#discover/project.js";import{EVE_DEV_ENV_FLAG}from"#internal/application/optional-package-install.js";import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,
|
|
2
|
-
`))}function resolveDevelopmentServerPorts(e){let t=resolveDevelopmentServerPort(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function addDevelopmentControlHandler(n){n.devServer.setControlHandler(async r=>{let i=await n.workflowWorld?.handleRequest(r);if(i!==void 0)return i;let a=new URL(r.url);if(a.pathname===EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH&&r.method===`GET`)return handleDevRuntimeArtifactsRequest({appRoot:n.appRoot});if(a.pathname!==EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH||r.method!==`GET`)return;let o=n.getWatcher();return o===void 0?Response.json({error:`The development server is still starting.`},{status:503}):(a.searchParams.get(`force`)===`1`?await o.rebuild():await o.flush(),handleDevRuntimeArtifactsRequest({appRoot:n.appRoot}))})}async function closeDevelopmentServerResources(e){let t=[],attempt=async e=>{try{return await e(),!0}catch(e){return t.push(e),!1}},n=e.authoredSourceWatcher;n!==void 0&&await attempt(()=>n.close());let r=e.devServer,i=r===void 0?!0:await attempt(()=>r.close()),a=e.workflowWorld;a!==void 0&&await attempt(()=>a.close());let o=e.nitro;return o!==void 0&&await attempt(()=>o.close()),await attempt(()=>stopDevelopmentSandboxResources({
|
|
1
|
+
import{EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}from"#protocol/routes.js";import{isLoopbackServerUrl}from"#shared/network-address.js";import{detectPackageManager}from"#setup/package-manager.js";import{eveDevArguments}from"#setup/primitives/index.js";import{toErrorMessage}from"#shared/errors.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{randomBytes}from"node:crypto";import{resolveDiscoveryProject}from"#discover/project.js";import{EVE_DEV_ENV_FLAG}from"#internal/application/optional-package-install.js";import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,createDevelopmentSandboxRunId}from"#execution/sandbox/development-run.js";import{createDevelopmentApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareDevelopmentApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createDevelopmentNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{buildDevelopmentHostCandidate}from"#internal/nitro/host/dev-host-candidate.js";import{removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import{DrainedNitroDevServer}from"#internal/nitro/host/drained-nitro-dev-server.js";import{activateDevelopmentGeneration,discardDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{DEFAULT_DEVELOPMENT_SERVER_HOST,normalizeDevelopmentServerClientUrl}from"#internal/nitro/host/dev-server-url.js";import{createDevelopmentAuthoredRebuildCoordinator}from"#internal/nitro/host/dev-authored-rebuild-coordinator.js";import{DevelopmentServerState}from"#internal/nitro/host/dev-server-state.js";import{isEveServerHealthy}from"#shared/eve-server-health.js";import{handleDevRuntimeArtifactsRequest}from"#internal/nitro/routes/dev-runtime-artifacts.js";import{pruneLocalSandboxTemplatesInBackground,stopDevelopmentSandboxResources}from"#execution/sandbox/bindings/local.js";import{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS}from"#internal/nitro/host/ports.js";import{createDevelopmentWorkflowWorld,installWorkflowLocalQueueEnvironment,installWorkflowTransportEnvironment}from"#internal/nitro/host/dev-workflow-world-setup.js";const MAX_ALLOWED_DEVELOPMENT_SERVER_PORT=65535,PORT_ENV=`PORT`;async function isActiveDevelopmentServerForApp(e){try{let t=await new DevelopmentServerState(await resolveDiscoveryProject(e.appRoot)).read();return t===void 0||!isLoopbackServerUrl(t)||!await isEveServerHealthy(t)?!1:new URL(t).origin===new URL(normalizeDevelopmentServerClientUrl(e.serverUrl)).origin}catch{return!1}}function isAddressInUseError(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function resolveDevelopmentServerPort(e){let t=typeof e==`string`?Number(e):e??DEFAULT_DEVELOPMENT_SERVER_PORT;if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function readEnvironmentPort(){let e=process.env[PORT_ENV];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid ${PORT_ENV} environment variable "${e}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}async function detectDevelopmentCommandPackageManager(e){try{return(await detectPackageManager(e)).kind}catch{return`pnpm`}}async function formatDevelopmentServerConnectCommand(e,t){let n=await detectDevelopmentCommandPackageManager(e);return[n,...eveDevArguments(n),t].join(` `)}async function createDevelopmentServerAlreadyRunningError(e,t){let n=await formatDevelopmentServerConnectCommand(e,t);return Error([`A dev server is already running for this eve agent.`,`To connect to the existing instance, run: ${n}`].join(`
|
|
2
|
+
`))}function resolveDevelopmentServerPorts(e){let t=resolveDevelopmentServerPort(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function addDevelopmentControlHandler(n){n.devServer.setControlHandler(async r=>{let i=await n.workflowWorld?.handleRequest(r);if(i!==void 0)return i;let a=new URL(r.url);if(a.pathname===EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH&&r.method===`GET`)return handleDevRuntimeArtifactsRequest({appRoot:n.appRoot});if(a.pathname!==EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH||r.method!==`GET`)return;let o=n.getWatcher();return o===void 0?Response.json({error:`The development server is still starting.`},{status:503}):(a.searchParams.get(`force`)===`1`?await o.rebuild():await o.flush(),handleDevRuntimeArtifactsRequest({appRoot:n.appRoot}))})}async function closeDevelopmentServerResources(e){let t=[],attempt=async e=>{try{return await e(),!0}catch(e){return t.push(e),!1}},n=e.authoredSourceWatcher;n!==void 0&&await attempt(()=>n.close());let r=e.devServer,i=r===void 0?!0:await attempt(()=>r.close()),a=e.workflowWorld;a!==void 0&&await attempt(()=>a.close());let o=e.nitro;return o!==void 0&&await attempt(()=>o.close()),await attempt(()=>stopDevelopmentSandboxResources({appRoot:e.appRoot,devRunId:e.developmentSandboxRunId,log:e=>console.warn(`[eve:dev] ${e}`)})),{errors:t,listenerClosed:i}}function createDevelopmentServerCleanupError(e){if(e.length!==0){if(e.length===1){let t=e[0];return t instanceof Error?t:Error(`Failed to close the development server: ${toErrorMessage(t)}`,{cause:t})}return AggregateError(e,`Multiple development-server resources failed to close.`)}}function createDevelopmentServerStartupCleanupError(e,t){return AggregateError([e,...t],`${toErrorMessage(e)} Cleanup also failed.`,{cause:e})}async function listenForDevelopmentServer(e){let t=resolveDevelopmentServerPorts({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!isAddressInUseError(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function startNitroDevelopmentServer(e,t){process.env[EVE_DEV_ENV_FLAG]??=`1`;let r=await resolveDiscoveryProject(e);loadDevelopmentEnvironmentFiles(r.appRoot);let i=readEnvironmentPort(),a=t.port??i,m=t.host!==void 0||t.port!==void 0||i!==void 0,h=new DevelopmentServerState(r),g=await h.read();if(g!==void 0&&isLoopbackServerUrl(g)&&await isEveServerHealthy(g)){if(t.existing===`attach-if-unconfigured`&&!m)return{handle:{kind:`existing`,appRoot:r.appRoot,url:g},close:void 0};throw await createDevelopmentServerAlreadyRunningError(r.appRoot,g)}let _=process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV],v=createDevelopmentSandboxRunId();process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=v;let y,b,x,S,C,w,T,E=!1,D=!1;try{let e=await devBootPhase(`compiling agent`,()=>prepareDevelopmentApplicationHost(r.appRoot),t.onBootProgress);T=e;let n=resolveNitroCompiledArtifactsSource(createDevelopmentNitroArtifactsConfig({appRoot:e.appRoot,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world}));pruneLocalSandboxTemplatesInBackground(e.appRoot);let i=await devBootPhase(`creating dev server`,()=>createDevelopmentApplicationNitro(e),t.onBootProgress);y=i,b=new DrainedNitroDevServer(i.logger);let o=b,s=randomBytes(32).toString(`base64url`);o.setClientAddressSecret(s),S=installWorkflowTransportEnvironment(r.appRoot,s),C=createDevelopmentWorkflowWorld({appRoot:r.appRoot,preparedHost:e,transportSecret:s}),addDevelopmentControlHandler({appRoot:r.appRoot,devServer:o,getWatcher:()=>w,workflowWorld:C});let c=t.host??i.options.devServer.hostname??DEFAULT_DEVELOPMENT_SERVER_HOST,l=a===void 0,u=await devBootPhase(`binding port`,()=>listenForDevelopmentServer({devServer:o,host:c,port:a,retryOnAddressInUse:l}),t.onBootProgress);if(!u.url)throw Error(`Nitro dev server did not expose a URL.`);let d=normalizeDevelopmentServerClientUrl(u.url);x=installWorkflowLocalQueueEnvironment(d),await devBootPhase(`building dev bundle`,async()=>{let t=await buildDevelopmentHostCandidate({host:e,nitro:i});y=void 0;let n=e.workspace;D=!0,await o.replaceWorker({dispose:async()=>await removeDevelopmentHostWorkspace(n),entry:t.entry,workerData:t.workerData}),await activateDevelopmentGeneration({appRoot:e.appRoot,generation:e.generation}),E=!0},t.onBootProgress),await C?.start(),startDevelopmentSandboxPrewarmInBackground({appRoot:e.appRoot,compiledArtifactsSource:n});let f=await createDevelopmentAuthoredRebuildCoordinator({devServer:o,initialHost:e});w=await devBootPhase(`starting file watcher`,async()=>{let{startAuthoredSourceWatcher:t}=await import(`#internal/nitro/host/dev-authored-source-watcher.js`);return t({coordinator:f,preparedHost:e})},t.onBootProgress),await h.write(d);let p=x;if(p===void 0)throw Error(`Workflow local queue environment was not initialized.`);let m=w,g=b,O=C,k=S,A;return{handle:{kind:`started`,appRoot:r.appRoot,url:d},close:()=>(A??=(async()=>{let e=await closeDevelopmentServerResources({appRoot:r.appRoot,authoredSourceWatcher:m,devServer:g,developmentSandboxRunId:v,nitro:void 0,workflowWorld:O});e.listenerClosed&&await h.remove().catch(()=>{});try{let t=createDevelopmentServerCleanupError(e.errors);if(t!==void 0)throw t}finally{p(),k?.(),restoreDevelopmentSandboxRunId(_)}})(),A)}}catch(e){let t=await closeDevelopmentServerResources({appRoot:r.appRoot,authoredSourceWatcher:w,devServer:b,developmentSandboxRunId:v,nitro:y,workflowWorld:C}),n=[...t.errors];throw T!==void 0&&!E&&await discardDevelopmentGeneration(T.generation).catch(e=>{n.push(e)}),T!==void 0&&!D&&await removeDevelopmentHostWorkspace(T.workspace).catch(e=>{n.push(e)}),x?.(),S?.(),t.listenerClosed&&await h.remove().catch(()=>{}),restoreDevelopmentSandboxRunId(_),n.length>0?createDevelopmentServerStartupCleanupError(e,n):e}}function createDevelopmentServer(e,t={}){let n,r;return{start(){if(n!==void 0)throw Error(`DevelopmentServer.start() was already called.`);return n=startNitroDevelopmentServer(e,t).then(({handle:e,close:t})=>(r=t,e)),n},async close(){n!==void 0&&(await n.catch(()=>void 0),await r?.())}}}function restoreDevelopmentSandboxRunId(e){if(e===void 0){delete process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV];return}process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=e}export{createDevelopmentServer,isActiveDevelopmentServerForApp,normalizeDevelopmentServerClientUrl};
|
|
@@ -5,6 +5,7 @@ import type { GeneratedCompiledArtifactsFiles } from "#internal/application/comp
|
|
|
5
5
|
import type { DevBootProgressReporter } from "#internal/dev-boot-progress.js";
|
|
6
6
|
import type { DevelopmentGeneration } from "#internal/nitro/development-generation.js";
|
|
7
7
|
import type { DevelopmentHostWorkspace } from "#internal/nitro/host/dev-host-workspace.js";
|
|
8
|
+
import type { DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";
|
|
8
9
|
/**
|
|
9
10
|
* Route surface included in one programmatic Nitro host build.
|
|
10
11
|
*/
|
|
@@ -71,5 +72,6 @@ export interface PreparedApplicationHost {
|
|
|
71
72
|
}
|
|
72
73
|
export interface PreparedDevelopmentApplicationHost extends PreparedApplicationHost {
|
|
73
74
|
generation: DevelopmentGeneration;
|
|
75
|
+
workspaceExtensions: readonly DevelopmentWorkspaceExtension[];
|
|
74
76
|
workspace: DevelopmentHostWorkspace;
|
|
75
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{WORKFLOW_TOOL_NAME}from"#shared/workflow-sandbox.js";import{getAllFrameworkChannelNames,getFrameworkChannelDefinitions}from"#runtime/framework-channels/index.js";import{getAllFrameworkToolDefinitions,getAllFrameworkToolNames}from"#runtime/framework-tools/index.js";import{createConnectionSearchResolver}from"#runtime/framework-tools/connection-search-dynamic.js";function buildAgentInfoResponse(e,t){let
|
|
1
|
+
import{serializeInputSchema,serializeOutputSchema}from"#shared/tool-schema.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{WORKFLOW_TOOL_NAME}from"#shared/workflow-sandbox.js";import{getAllFrameworkChannelNames,getFrameworkChannelDefinitions}from"#runtime/framework-channels/index.js";import{getAllFrameworkToolDefinitions,getAllFrameworkToolNames}from"#runtime/framework-tools/index.js";import{createConnectionSearchResolver}from"#runtime/framework-tools/connection-search-dynamic.js";function buildAgentInfoResponse(e,t){let n=e.agent,r=buildToolInfo(n,getRootDelegationToolNames(e.manifest));return{agent:{agentRoot:n.metadata.agentRoot,appRoot:n.metadata.appRoot,configSource:n.config.source?toSource(n.config.source):void 0,description:n.config.description,model:{contextWindowTokens:n.config.model.contextWindowTokens,id:n.config.model.id,providerOptions:n.config.model.providerOptions,source:n.config.model.source?toSource(n.config.model.source):void 0},name:n.config.name,outputSchema:n.config.outputSchema},capabilities:{devRoutes:t.mode===`development`},channels:buildChannelInfo(n),connections:n.connections.map(e=>({...toSource(e),connectionName:e.connectionName,description:e.description,hasApproval:e.approval!==void 0,hasAuthorization:e.authorization!==void 0,hasHeaders:e.headers!==void 0,protocol:e.protocol,toolFilter:e.tools,url:e.url})),diagnostics:{discoveryErrors:n.metadata.diagnosticsSummary.errors,discoveryWarnings:n.metadata.diagnosticsSummary.warnings},hooks:n.hooks.map(e=>({...toSource(e),eventNames:Object.keys(e.events).sort(),slug:e.slug})),instructions:{dynamic:n.dynamicInstructionsResolvers.map(e=>renderDynamicResolver(e,{origin:`authored`})),static:n.instructions?{...toSource(n.instructions),markdown:n.instructions.markdown,name:n.instructions.name}:null},kind:`eve-agent-info`,mode:t.mode,sandbox:renderSandbox(n.sandbox),schedules:e.schedules.map(renderSchedule),skills:{static:n.skills.map(renderSkill),dynamic:n.dynamicSkillResolvers.map(e=>renderDynamicResolver(e,{origin:`authored`}))},subagents:{local:e.manifest.subagents.map(renderSubagent),total:e.manifest.subagents.length},tools:r,version:1,workflow:{enabled:n.workflowTool!==void 0,toolName:WORKFLOW_TOOL_NAME},workspace:{resourceRoot:n.workspaceResourceRoot,rootEntries:[...n.workspaceSpec.rootEntries]}}}function buildChannelInfo(e){let t=new Set(e.channels.map(e=>e.name)),n=new Set(e.disabledFrameworkChannels),r=getAllFrameworkChannelNames(),i=getFrameworkChannelDefinitions(),s=i.filter(e=>!t.has(e.name)&&!n.has(e.name)),c=e.channels.map(e=>renderChannel(e,{origin:`authored`})),l=i.map(e=>{let r=t.has(e.name),i=n.has(e.name),a=i?`disabled`:r?`replaced`:`active`;return{...renderChannel(e,{origin:`framework`}),disabledByAuthor:i,replacedByAuthoredChannel:r,status:a}});return{authored:c,available:[...s.map(e=>renderChannel(e,{origin:`framework`})),...c],disabledFramework:[...e.disabledFrameworkChannels],framework:l.filter(e=>r.has(e.name))}}function buildToolInfo(e,t){let n=new Set(e.tools.map(e=>e.name)),a=new Set(e.disabledFrameworkTools),o=getAllFrameworkToolNames(),s=e.connections.length>0?[createConnectionSearchResolver()]:[],u=e.tools.map(e=>renderTool(e,{origin:`authored`,replacesFrameworkTool:o.has(e.name)})),d=buildFrameworkToolInfo({authoredToolNames:n,delegationToolNames:t,disabledFrameworkToolNames:a});return{available:[...d.available,...u],authored:u,disabledFramework:[...e.disabledFrameworkTools],dynamic:[...s.map(e=>renderDynamicResolver(e,{origin:`framework`})),...e.dynamicToolResolvers.map(e=>renderDynamicResolver(e,{origin:`authored`}))],framework:d.framework,reserved:[WORKFLOW_TOOL_NAME,LOAD_SKILL_TOOL_NAME]}}function buildFrameworkToolInfo(e){let t=new Set([...e.authoredToolNames,...e.delegationToolNames]),n=[],r=[];for(let i of getAllFrameworkToolDefinitions()){let a=e.disabledFrameworkToolNames.has(i.name),o=e.authoredToolNames.has(i.name),s=a?`disabled`:t.has(i.name)?`replaced`:`active`,c=renderTool(i,{origin:`framework`,replacesFrameworkTool:!1});s===`active`&&n.push(c),r.push({...c,disabledByAuthor:a,replacedByAuthoredTool:o,status:s})}return{available:n,framework:r}}function getRootDelegationToolNames(e){let t=new Set(e.subagentEdges.filter(e=>e.parentNodeId===ROOT_COMPILED_AGENT_NODE_ID).map(e=>e.childNodeId));return new Set([...e.subagents.filter(e=>t.has(e.nodeId)).map(e=>e.name),...e.remoteAgents.map(e=>e.name)])}function renderChannel(e,t){return{...toSource(e),adapterKind:e.adapter?.kind,method:e.method,name:e.name,origin:t.origin,urlPath:e.urlPath}}function renderTool(n,r){let i=serializeInputSchema(n.inputSchema),a=serializeOutputSchema(n.outputSchema);return{...toSource(n),description:n.description,hasAuth:!1,hasExecute:n.execute!==void 0,hasModelOutputProjection:n.toModelOutput!==void 0,hasOutputSchema:a!==void 0,inputSchema:i,name:n.name,origin:r.origin,outputSchema:a,replacesFrameworkTool:r.replacesFrameworkTool,requiresApproval:n.approval!==void 0}}function renderSkill(e){return{...toSource(e),description:e.description,license:e.license,markdown:e.markdown,metadata:e.metadata,name:e.name}}function renderSchedule(e){return{...toSource(e),cron:e.cron,hasRun:e.hasRun,markdown:e.markdown,name:e.name}}function renderSandbox(e){return e===null?null:{...toSource(e),backendKind:resolveBackendKind(e.backend),description:e.description,hasBootstrap:e.bootstrap!==void 0,hasOnSession:e.onSession!==void 0,revalidationKey:e.revalidationKey,sourceHash:e.sourceHash}}function renderSubagent(e){return{...toSource(e),description:e.description,entryPath:e.entryPath,name:e.name,nodeId:e.nodeId,rootPath:e.rootPath,summary:{channels:e.agent.channels.length,connections:e.agent.connections.length,hooks:e.agent.hooks.length,instructions:e.agent.instructions!==void 0,schedules:e.agent.schedules.length,skills:e.agent.skills.length,tools:e.agent.tools.length}}}function renderDynamicResolver(e,t){return{...toSource(e),eventNames:[...e.eventNames],origin:t.origin,slug:e.slug}}function toSource(e){return{exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:e.sourceKind}}function resolveBackendKind(e){if(typeof e!=`object`||!e)return;let t=e.kind;return typeof t==`string`?t:void 0}export{buildAgentInfoResponse,buildFrameworkToolInfo,getRootDelegationToolNames,renderChannel,renderDynamicResolver,renderSchedule,renderSubagent,renderTool,toSource};
|