eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.29 kB
JavaScript
import{canonicalSourceSlot,composeAgentModuleCandidates}from"#compiler/source-graph.js";const REQUIRED_FRAMEWORK_TOOL_SLOTS=new Set([`tools/connection_search`]);function assertFrameworkToolPolicy(e,t){let n=canonicalSourceSlot(e.logicalPath);if(n===`tools/connection_search`&&t.kind===`disabled`)throw Error(`The required "connection_search" tool cannot be disabled. Remove "agent/tools/connection_search.ts" or export a replacement tool from it.`);let r={"tools/agent":`self-agent`,"tools/task_cancel":`task-cancel`}[n];if(r!==void 0&&t.kind===`tool`&&(t.definition.behavior?.handling?.kind!==`dispatch`||t.definition.behavior.handling.action!==r)){let e=n.slice(6);throw Error(`The framework "${e}" tool cannot be overridden. Re-export it from "eve/tools/${e}" or disable it with disableTool().`)}}function applyDefaultToolPolicy(e,t){if(t.defaultTools!==!1)return;let n=new Set(e.graph.orderedCandidates.filter(e=>e.layer!==`framework-default`).map(e=>canonicalSourceSlot(e.logicalPath)));e.graph.composed=composeAgentModuleCandidates(e.graph.orderedCandidates.filter(e=>{let t=canonicalSourceSlot(e.logicalPath);return e.layer!==`framework-default`||!t.startsWith(`tools/`)||REQUIRED_FRAMEWORK_TOOL_SLOTS.has(t)||n.has(t)}))}export{applyDefaultToolPolicy,assertFrameworkToolPolicy};