eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 6.48 kB
JavaScript
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,reasoning:n.config.reasoning,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};