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(e,t){let n={moduleFileNames:[]};for(let r of e)if(r.isFile()){if(t.markdownFileName!==void 0&&r.name.toLowerCase()===t.markdownFileName.toLowerCase()){n.markdownFileName=r.name;continue}t.moduleBaseName!==void 0&&getSupportedModuleBaseName(r.name)===t.moduleBaseName&&n.moduleFileNames.push(r.name)}return n.moduleFileNames.sort((e,t)=>e.localeCompare(t)),n}function collectNamedSlotCandidates(e,t){let n=new Map;for(let r of e){if(!r.isFile())continue;let e=t.allowMarkdown?getMarkdownSlotName(r.name):null,i=t.allowModules?getSupportedModuleBaseName(r.name):null,a=e??i;if(a===null)continue;let o=n.get(a);if(o===void 0&&(o={moduleFileNames:[],slotName:a},n.set(a,o)),e!==null){o.markdownFileName=r.name;continue}i!==null&&o.moduleFileNames.push(r.name)}return[...n.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};