UNPKG

eve

Version:

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

1 lines 2.44 kB
import{stripLogicalPathExtension}from"#discover/filesystem.js";import{normalizeSkillDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition,requireModuleBackedDefinitionLoadOptions}from"#compiler/normalize-helpers.js";import{assertResolverOnlyDynamicSentinel,isDynamicSentinel}from"#dynamic/definition.js";async function compileSkillSource(e,t,n){if(t.sourceKind===`skill-package`)return{kind:`skill`,definition:compileSkillPackageSource(t,n.owner)};if(t.sourceKind===`markdown`){let e=normalizeSkillDefinition(t.definition,`Expected the compiled skill definition at "${t.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:e.description,files:e.files,license:e.license,logicalPath:t.logicalPath,owner:n.owner,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:stripLogicalPathExtension(t.logicalPath).replace(/^skills\//,``),sourceId:t.sourceId,sourceKind:t.sourceKind}}}let r=requireModuleBackedDefinitionLoadOptions(n,t.logicalPath),i=await loadModuleBackedDefinition({binding:r.binding,kind:`skill`,loadNamespace:r.loadNamespace,source:t});if(isDynamicSentinel(i)){assertResolverOnlyDynamicSentinel(i,`Expected the skill export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public eve shape.`);let e=stripLogicalPathExtension(t.logicalPath).replace(/^skills\//,``);return{kind:`dynamic-skill`,definition:{eventNames:Object.keys(i.events),exportName:t.exportName,logicalPath:t.logicalPath,slug:e,sourceId:t.sourceId,sourceKind:`module`}}}let a=normalizeSkillDefinition(i,`Expected the skill export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:a.description,files:a.files,license:a.license,logicalPath:t.logicalPath,markdown:a.markdown,metadata:a.metadata===void 0?void 0:{...a.metadata},name:stripLogicalPathExtension(t.logicalPath).replace(/^skills\//,``),sourceId:t.sourceId,sourceKind:t.sourceKind}}}function compileSkillPackageSource(e,t){return{assetsPath:e.assetsPath,description:e.description,license:e.license,logicalPath:e.logicalPath,owner:t,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name,referencesPath:e.referencesPath,rootPath:e.rootPath,scriptsPath:e.scriptsPath,skillId:e.skillId,skillFilePath:e.skillFilePath,sourceId:e.sourceId,sourceKind:`skill-package`}}export{compileSkillSource};