UNPKG

eve

Version:

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

1 lines 1.72 kB
import{z}from"#compiled/zod/index.js";import{loadContext}from"#context/container.js";import{DynamicSkillManifestKey,SandboxKey}from"#context/keys.js";import{loadSkillFromSandbox}from"#runtime/skills/sandbox-access.js";import{ConnectionRegistryKey}from"#context/providers/connection-key.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";async function executeLoadSkillTool(e){let t=loadContext(),{skill:n}=e,r=t.require(BundleKey).resolvedAgent.skills,i=availableDynamicSkillNames(t),a=[...new Set([...r.map(e=>e.name),...i])].sort();try{if(i.includes(n)){let e=t.get(SandboxKey);if(e===void 0)throw Error(`The dynamic skill "${n}" requires sandbox access on the runtime context.`);return await loadSkillFromSandbox(e,n,a)}let e=r.find(e=>e.name===n);if(e!==void 0)return e.markdown;throw Error(formatSkillNotFoundError(n,a))}catch(e){let r=t.get(ConnectionRegistryKey)?.getConnectionNames().find(e=>e.toLowerCase()===n.toLowerCase());if(r===void 0||a.includes(n))throw e;let i=e instanceof Error?e.message:String(e);throw Error(`${i} "${r}" is an installed connection, not a skill. Use connection_search with connection "${r}" to find its tools.`,{cause:e})}}function availableDynamicSkillNames(e){let t=Object.values(e.get(DynamicSkillManifestKey)??{}).flat().map(e=>e.name);return[...new Set(t)].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();async function executeLoadSkill(e){return await executeLoadSkillTool(e)}export{SKILL_INPUT_SCHEMA,SKILL_OUTPUT_SCHEMA,executeLoadSkill};