eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 2.39 kB
JavaScript
import{createHash}from"node:crypto";import{readFile}from"node:fs/promises";import{readDevelopmentEnvironmentHostValues}from"#cli/dev/environment.js";import{resolveCompiledModuleExtensionScopeNamespace}from"#compiler/module-map.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{computeChannelRouteRegistrations}from"#internal/nitro/host/channel-routes.js";async function computeDevelopmentHostFingerprint(e){let t=e.compileResult.manifest,n=[t,...t.subagents.map(e=>e.agent)],r={agentName:t.config.name,bundler:{externalDependencies:[...new Set([...t.config.build?.externalDependencies??[],...t.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])])].sort((e,t)=>e.localeCompare(t)),extensionScopes:n.flatMap(e=>e.extensionMounts).map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})).sort((e,t)=>e.sourceRoot.localeCompare(t.sourceRoot)),sandboxBackends:[...new Set(n.map(e=>e.sandbox?.backendName).filter(e=>e!==void 0))].sort((e,t)=>e.localeCompare(t))},channels:computeChannelRouteRegistrations(e),environment:readDevelopmentEnvironmentHostValues(e.appRoot),instrumentation:await readInstrumentationSource(e),workflow:{authoredSources:e.generation.workflowSourceFingerprint??null,enabled:n.some(e=>e.workflowTool!==void 0),world:t.config.experimental?.workflow?.world??`local`}};return createHash(`sha256`).update(JSON.stringify(r)).digest(`hex`)}async function readInstrumentationSource(e){let t=e.compileResult.manifest.instrumentation;if(t!==void 0){let n=e.compileResult.manifest.bindings[t.sourceId];if(n===void 0)throw Error(`Compiled instrumentation source "${t.sourceId}" has no binding.`);return{kind:`file`,modules:[{slot:null,source:n.backing.kind===`filesystem`?await bundleAuthoredModuleForGeneration(n.backing.sourcePath,{externalDependencies:n.backing.externalDependencies,extensionScopeNamespace:resolveCompiledModuleExtensionScopeNamespace(n)}):JSON.stringify(n.backing)}]}}let n=e.compiledArtifacts.instrumentationSourcePaths,r=e.compiledArtifacts.instrumentationLayout;if(n===void 0||r===void 0)return null;let i=await Promise.all(n.map(async e=>await readFile(e,`utf8`)));return{kind:r.kind,modules:i.map((e,t)=>({slot:r.kind===`directory`?r.slots[t]??null:null,source:e}))}}export{computeDevelopmentHostFingerprint};