UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 2.35 kB
import{z}from"#compiled/zod/index.js";import{DynamicSkillManifestKey,SandboxKey}from"#context/keys.js";import{loadContext}from"#context/container.js";import{loadSkillFromSandbox}from"#runtime/skills/sandbox-access.js";import{ConnectionRegistryKey}from"#context/providers/connection-key.js";async function executeLoadSkillTool(e,t){let r=loadContext(),{skill:i}=e,a=availableDynamicSkillNames(r),o=[...new Set([...t.map(e=>e.name),...a])].sort();try{if(a.includes(i)){let e=r.get(SandboxKey);if(e===void 0)throw Error(`The dynamic skill "${i}" requires sandbox access on the runtime context.`);return await loadSkillFromSandbox(e,i,o)}let e=t.find(e=>e.name===i);if(e!==void 0)return e.markdown;throw Error(formatSkillNotFoundError(i,o))}catch(e){let t=r.get(ConnectionRegistryKey)?.getConnectionNames().find(e=>e.toLowerCase()===i.toLowerCase());if(t===void 0||o.includes(i))throw e;let n=e instanceof Error?e.message:String(e);throw Error(`${n} "${t}" is an installed connection, not a skill. Use connection_search with connection "${t}" to find its tools.`,{cause:e})}}function availableDynamicSkillNames(e){let n=Object.values(e.get(DynamicSkillManifestKey)??{}).flat().map(e=>e.name);return[...new Set(n)].sort()}function formatSkillNotFoundError(e,t){return`No skill named "${e}".${t.length>0?` Available skills: ${t.join(`, `)}.`:``}`}const SKILL_INPUT_SCHEMA=z.strictObject({skill:z.string().describe(`Available skill name or id.`)}),SKILL_OUTPUT_SCHEMA=z.string(),SKILL_TOOL_METADATA={description:[`Load the full instructions for one available skill by name or id.`,`Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.`,`This is not for MCP connections; use connection_search to access an installed connection.`,`Loading adds the skill instructions to the current turn.`,`Choose the "skill" value from the Available skills block.`].join(` `),inputSchema:SKILL_INPUT_SCHEMA,logicalPath:`eve:framework/load-skill`,name:`load_skill`,outputSchema:SKILL_OUTPUT_SCHEMA,sourceId:`eve:load-skill-tool`,sourceKind:`module`};function createSkillToolDefinition(e){return{...SKILL_TOOL_METADATA,execute:t=>executeLoadSkillTool(t,e)}}const SKILL_TOOL_DEFINITION=createSkillToolDefinition([]);export{SKILL_INPUT_SCHEMA,SKILL_OUTPUT_SCHEMA,SKILL_TOOL_DEFINITION,createSkillToolDefinition};