eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.15 kB
JavaScript
import{getSupportedModuleBaseName}from"#discover/filesystem.js";function collectFlatSlotCandidates(t,n){let r={moduleFileNames:[]};for(let i of t)if(i.isFile()){if(n.markdownFileName!==void 0&&i.name.toLowerCase()===n.markdownFileName.toLowerCase()){r.markdownFileName=i.name;continue}n.moduleBaseName!==void 0&&getSupportedModuleBaseName(i.name)===n.moduleBaseName&&r.moduleFileNames.push(i.name)}return r.moduleFileNames.sort((e,t)=>e.localeCompare(t)),r}function collectNamedSlotCandidates(t,n){let r=new Map;for(let i of t){if(!i.isFile())continue;let t=n.allowMarkdown?getMarkdownSlotName(i.name):null,a=n.allowModules?getSupportedModuleBaseName(i.name):null,o=t??a;if(o===null)continue;let s=r.get(o);if(s===void 0&&(s={moduleFileNames:[],slotName:o},r.set(o,s)),t!==null){s.markdownFileName=i.name;continue}a!==null&&s.moduleFileNames.push(i.name)}return[...r.values()].map(e=>(e.moduleFileNames.sort((e,t)=>e.localeCompare(t)),e)).sort((e,t)=>e.slotName.localeCompare(t.slotName))}function getMarkdownSlotName(e){return!e.toLowerCase().endsWith(`.md`)||e.length<=3?null:e.slice(0,-3)}export{collectFlatSlotCandidates,collectNamedSlotCandidates};