eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.15 kB
JavaScript
import{stripLogicalPathExtension}from"#discover/filesystem.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{normalizeChannelDefinition}from"#internal/authored-definition/channel.js";import{isDisabledRouteSentinel}from"#public/definitions/channel.js";async function compileChannelDefinition(n,r,i={}){let a=await loadModuleBackedDefinition({agentRoot:n,externalDependencies:i.externalDependencies,kind:`channel`,source:r}),o=stripLogicalPathExtension(r.logicalPath).replace(/^channels\//,``);if(isDisabledRouteSentinel(a))return{kind:`disabled`,name:o,logicalPath:r.logicalPath};let s=normalizeChannelDefinition(a,`Expected the channel export "${r.exportName??`default`}" from "${r.logicalPath}" to match the public eve shape.`);return s.routes.map(e=>({kind:`channel`,name:o,logicalPath:r.logicalPath,method:e.method.toUpperCase(),urlPath:e.path,sourceId:r.sourceId,sourceKind:`module`,exportName:r.exportName,adapterKind:extractAdapterKind(s.adapter)}))}function extractAdapterKind(e){if(typeof e!=`object`||!e)return;let t=e.kind;return typeof t==`string`&&t.length>0?t:void 0}export{compileChannelDefinition};