import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{t}from"./subsystem-BQ1073Mu.js";import{t as n}from"./utils-D1PlBTFH.js";import{a as r,c as i,o as a,s as o}from"./env-overrides-C0vMeCeX.js";import{c as s,i as c,t as l}from"./skills-CZ7zEDmo.js";import{f as u}from"./frontmatter-BkZkwkVO.js";import{t as d}from"./entry-status-CCwwKO43.js";import f from"node:path";import{loadSkillsFromDir as p}from"@mariozechner/pi-coding-agent";const m=t(`skills`);let h=!1,g=null;function _(e={}){let t=s(e),n=new Set;if(!t)return h||(h=!0,m.warn(`Bundled skills directory could not be resolved; built-in skills may be missing.`)),{dir:t,names:n};if(g?.dir===t)return{dir:t,names:new Set(g.names)};let r=p({dir:t,source:`openclaw-bundled`});for(let e of r.skills)e.name.trim()&&n.add(e.name);return g={dir:t,names:new Set(n)},{dir:t,names:n}}var v=e({buildWorkspaceSkillStatus:()=>C});function y(e){return e.metadata?.skillKey??e.skill.name}function b(e,t){if(e.length===0)return;let n=e.map((e,t)=>({spec:e,index:t})),r=e=>n.find(t=>t.spec.kind===e),i=r(`brew`),a=r(`node`),o=r(`go`),s=r(`uv`),c=r(`download`),l=u(`brew`),d=[()=>t.preferBrew&&l?i:void 0,()=>s,()=>a,()=>l?i:void 0,()=>o,()=>c,()=>i,()=>n[0]];for(let e of d){let t=e();if(t)return t}}function x(e,t){let n=e.metadata?.os??[];if(n.length>0&&!n.includes(process.platform))return[];let r=e.metadata?.install??[];if(r.length===0)return[];let i=process.platform,a=r.filter(e=>{let t=e.os??[];return t.length===0||t.includes(i)});if(a.length===0)return[];let o=(e,n)=>{let r=(e.id??`${e.kind}-${n}`).trim(),i=e.bins??[],a=(e.label??``).trim();if(e.kind===`node`&&e.package&&(a=`Install ${e.package} (${t.nodeManager})`),!a)if(e.kind===`brew`&&e.formula)a=`Install ${e.formula} (brew)`;else if(e.kind===`node`&&e.package)a=`Install ${e.package} (${t.nodeManager})`;else if(e.kind===`go`&&e.module)a=`Install ${e.module} (go)`;else if(e.kind===`uv`&&e.package)a=`Install ${e.package} (uv)`;else if(e.kind===`download`&&e.url){let t=e.url.trim(),n=t.split(`/`).pop();a=`Download ${n&&n.length>0?n:t}`}else a=`Run installer`;return{id:r,kind:e.kind,label:a,bins:i}};if(a.every(e=>e.kind===`download`))return a.map((e,t)=>o(e,t));let s=b(a,t);return s?[o(s.spec,s.index)]:[]}function S(e,t,n,s,c){let f=y(e),p=i(t,f),m=p?.enabled===!1,h=!r(e,o(t)),g=e.metadata?.always===!0,_=t=>!!(process.env[t]||p?.env?.[t]||p?.apiKey&&e.metadata?.primaryEnv===t),v=e=>a(t,e),b=c&&c.size>0?c.has(e.skill.name):e.skill.source===`openclaw-bundled`,{emoji:S,homepage:C,required:w,missing:T,requirementsSatisfied:E,configChecks:D}=d({always:g,entry:e,hasLocalBin:u,remote:s?.remote,isEnvSatisfied:_,isConfigSatisfied:v}),O=!m&&!h&&E;return{name:e.skill.name,description:e.skill.description,source:e.skill.source,bundled:b,filePath:e.skill.filePath,baseDir:e.skill.baseDir,skillKey:f,primaryEnv:e.metadata?.primaryEnv,emoji:S,homepage:C,always:g,disabled:m,blockedByAllowlist:h,eligible:O,requirements:w,missing:T,configChecks:D,install:x(e,n??l(t))}}function C(e,t){let r=t?.managedSkillsDir??f.join(n,`skills`),i=_(),a=t?.entries??c(e,{config:t?.config,managedSkillsDir:r,bundledSkillsDir:i.dir}),o=l(t?.config);return{workspaceDir:e,managedSkillsDir:r,skills:a.map(e=>S(e,t?.config,o,t?.eligibility,i.names))}}export{v as n,C as t};
