import{getPromptContentText}from"#runtime/agent/bootstrap-model-utils.js";function getAvailableSkills(t){let n=new Map;for(let r of t){if(r.role!==`system`)continue;let t=getPromptContentText(r.content);if(t.startsWith(`Available skills
`))for(let e of t.split(`
`).slice(1)){let t=parseAvailableSkill(e);t!==null&&n.set(t.name,t)}}return[...n.values()]}function findRelevantSkill(e,t){let n=normalizeText(t);for(let t of e)if(n.includes(normalizeText(t.name)))return t;return/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(n)?e.find(e=>/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(normalizeText(`${e.name} ${e.description}`)))??null:null}function getActivatedSkillIds(t){return t.filter(e=>e.role===`system`).flatMap(t=>getPromptContentText(t.content).split(`
`).map(e=>e.trim()).flatMap(e=>{let t=/^Skill \((.+)\)$/.exec(e);return t?.[1]===void 0?[]:[t[1]]}))}function parseAvailableSkill(e){let t=/^- (.+?): (.+?)(?: \(path: (.+)\))?$/.exec(e.trim());return t?.[1]&&t[2]?{description:t[2],name:t[1]}:null}function normalizeText(e){return e.toLowerCase().replace(/[^a-z0-9]+/gu,` `).trim()}export{findRelevantSkill,getActivatedSkillIds,getAvailableSkills};