eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 2.65 kB
JavaScript
import{resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{projectDiscoverDiagnostic}from"#compiler/diagnostics.js";import{mountRefNamespace}from"#discover/extensions.js";import{createAgentSourceRegistry,createProgrammaticModuleCandidates}from"#compiler/source-graph.js";import{createBundledExtensionMount}from"#compiler/bundled-extension.js";import{discoverBundledExtension}from"#discover/bundled-extension.js";const DEVELOPMENT_EXTENSION_IDS=[`self-modification`];let bundledExtensionById,developmentSourceRegistry;function getBundledExtensionById(){return bundledExtensionById===void 0&&(bundledExtensionById=new Map([{namespace:`self-modification`,sourceDirectory:resolvePackageSourceDirectoryPath(`src/self-modification/extension`),loadMount:async()=>{let{default:e}=await import(`#self-modification/extension/extension.js`);return e({local:{enabled:!0}})}}].map(createBundledExtensionMount).map(e=>[e.namespace,e]))),bundledExtensionById}function getDevelopmentExtensionSourceRegistry(){return developmentSourceRegistry??=createAgentSourceRegistry([],{extensionDeclarations:[...getBundledExtensionById().values()].map(e=>e.declaration)}),developmentSourceRegistry}const DEFAULT_DEVELOPMENT_EXTENSION_IDS=DEVELOPMENT_EXTENSION_IDS,NO_DEVELOPMENT_EXTENSION_IDS=[];function defaultDevelopmentExtensions(){return{enabled:DEFAULT_DEVELOPMENT_EXTENSION_IDS}}function noDevelopmentExtensions(){return{enabled:NO_DEVELOPMENT_EXTENSION_IDS}}async function prepareDevelopmentExtensions(e){let t=new Set([...e.manifest.extensions.map(e=>mountRefNamespace(e.logicalPath)),...e.manifest.resolvedExtensions.map(e=>e.namespace)]),n=new Map,r=e.selection.enabled.length===0?void 0:getBundledExtensionById();for(let i of new Set(e.selection.enabled)){let e=r?.get(i);if(e===void 0)throw Error(`Unknown development extension "${i}".`);let a=n.get(e.namespace);if(a!==void 0&&a!==e)throw Error(`Development extensions use namespace "${e.namespace}" more than once.`);t.has(e.namespace)||(t.add(e.namespace),n.set(e.namespace,e))}let i=[...e.manifest.resolvedExtensions],a=[];for(let t of n.values()){let n=await discoverBundledExtension({mount:t});e.diagnostics.push(...n.diagnostics.map(t=>projectDiscoverDiagnostic(t,e.nodeId))),i.push(n.mount),a.push(...createProgrammaticModuleCandidates({layer:`framework-default`,nodeId:e.nodeId,owner:{feature:t.declaration.id,kind:`framework`},registration:{applyTo:`root`,source:t.declaration}}))}return{candidates:a,manifest:{...e.manifest,resolvedExtensions:i}}}export{defaultDevelopmentExtensions,getDevelopmentExtensionSourceRegistry,noDevelopmentExtensions,prepareDevelopmentExtensions};