openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
10 lines • 21.1 kB
JavaScript
import{c as normalizeOptionalLowercaseString}from"./string-coerce-CpTFcSwY.mjs";import{E as parseStrictNonNegativeInteger}from"./number-coercion-B3CfI447.mjs";import{c as resolveUserPath}from"./home-dir-DEN5DisQ.mjs";import{f as normalizeStringEntries}from"./string-normalization-D_oBUpO3.mjs";import{r as truncateUtf16Safe}from"./utf16-slice-DA3Mllbx.mjs";import{t as resolveConfigDir}from"./config-dir-DaqnOvHp.mjs";import{s as ensureDir}from"./utils-Dlk0IYAa.mjs";import{t as FsSafeError,x as root}from"./fs-safe-Bxzu1j4h.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{t as canAccess}from"./path-existence-BR9MXlgL.mjs";import{t as isContainerEnvironment}from"./container-environment-C0Hd9WfF.mjs";import{r as sha256File}from"./crypto-digest-T8X5EZni.mjs";import{c as safePathSegmentHashed,n as assertCanonicalPathWithinBase}from"./install-safe-path-muBIhnx6.mjs";import{n as runCommandWithTimeout}from"./exec-runner-BiCq-T1F.mjs";import"./exec-c5tqm8tb.mjs";import{t as resolveBrewExecutable}from"./brew-C9OlIcVE.mjs";import{i as getAgentWorkspaceAccess,t as WorkspaceAccessUnavailableError}from"./workspace-access-GnBgOJqh.mjs";import{r as resolveSkillFileHost}from"./skill-file-host-D4Dltnrr.mjs";import{i as fetchWithSsrFGuard}from"./fetch-guard-B_7-F5Lc.mjs";import{n as hasBinary}from"./config-eval-DjbEbFd6.mjs";import{r as resolveSkillKey}from"./frontmatter-CvGHA96F.mjs";import{t as resolveSkillSource}from"./source-BOELnZ7V.mjs";import{d as resolveSkillsInstallPreferences}from"./config-DyCaRdSv.mjs";import{t as evaluateSkillInstallPolicy}from"./install-security-scan-B80uEcmb.mjs";import{i as withTempDownloadPath}from"./temp-download-D0_Rrawz.mjs";import{i as prepareSkillBundle}from"./bundle-CzmF1asv.mjs";import{t as materializeSkillResources}from"./resources-DMaSusU6.mjs";import{i as prepareWorkspaceSkills}from"./workspace-skill-loader-OBUxHIUy.mjs";import fs from"node:fs";import path from"node:path";import fs$1 from"node:fs/promises";import os from"node:os";import{isWithinDir}from"@openclaw/fs-safe/path";import{isWindowsDrivePath}from"@openclaw/fs-safe/archive";
//!src/skills/runtime/tools-dir.ts
function resolveSkillToolsRootDir(e){const t=safePathSegmentHashed(e);return path.join(resolveConfigDir(),`tools`,t)}
//!src/skills/lifecycle/install-output.ts
function summarizeInstallOutput(e){const t=normalizeStringEntries(e.trim().split(`
`));const n=t.find(e=>/^error\b/i.test(e))??t.find(e=>/\b(err!|error:|failed)\b/i.test(e))??t.at(-1);if(!n)return;const r=n.replace(/\s+/g,` `).trim();return r.length>200?`${truncateUtf16Safe(r,199)}…`:r}function formatInstallFailureMessage(e){const t=typeof e.code===`number`?`exit ${e.code}`:`unknown exit`;const n=summarizeInstallOutput(e.stderr)??summarizeInstallOutput(e.stdout);if(!n)return`Install failed (${t})`;return`Install failed (${t}): ${n}`}
//!src/skills/lifecycle/install-download.ts
const MAX_SKILL_DOWNLOAD_BYTES=268435456;function resolveDownloadTargetDir(e,t){const n=resolveSkillToolsRootDir(e);const r=t.targetDir?.trim();if(!r)return n;const i=r.startsWith(`~`)||path.isAbsolute(r)||isWindowsDrivePath(r)?resolveUserPath(r):path.resolve(n,r);if(!isWithinDir(n,i))throw new Error(`Refusing to install outside the skill tools directory. targetDir="${r}" resolves to "${i}". Allowed root: "${n}".`);return i}function parseSkillInstallFileName(e){const t=/^[\t ]*[!#$%&'*+.^_`|~\da-z-]+[\t ]*/i.exec(e??``);if(!e||!t)return;const n=/;[\t ]*([!#$%&'*+.^_`|~\da-z-]+)[\t ]*=[\t ]*(?:"((?:[\t\x20-\x21\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\t\x20-\x7e\x80-\xff])*)"|([!#$%&'*+.^_`|~\da-z-]+))[\t ]*/giy;let r;let i;let a=t[0].length;while(a<e.length){n.lastIndex=a;const t=n.exec(e);if(!t)return;a=n.lastIndex;const o=t[1].toLowerCase();if(o===`filename`){if(r!==void 0)return;r=t[2]?.replace(/\\([\s\S])/g,`$1`)??t[3]}else if(o===`filename*`){if(i!==void 0||t[2]!==void 0)return;const e=/^utf-8'(?:[a-z]{1,8}(?:-[a-z\d]{1,8})*)?'((?:[!#$&+.^_`|~\da-z-]|%[\da-f]{2})*)$/i.exec(t[3]);if(!e)return;try{i=decodeURIComponent(e[1])}catch{return}}}return(i??r)||void 0}function detectArchiveType(e){const t=normalizeOptionalLowercaseString(e);if(!t)return;if(t.endsWith(`.tar.gz`)||t.endsWith(`.tgz`))return`tar.gz`;if(t.endsWith(`.tar.bz2`)||t.endsWith(`.tbz2`))return`tar.bz2`;if(t.endsWith(`.zip`))return`zip`}function downloadFailure(e,t={}){return{ok:false,message:e,stdout:``,stderr:t.stderr??e,code:t.code??null}}async function installDownloadSpec(e){const{skillKey:t,spec:n,timeoutMs:r}=e;const i=resolveSkillToolsRootDir(t);const a=n.url?.trim();if(!a)return downloadFailure(`missing download url`,{stderr:``});let o;try{const e=new URL(a);o=path.basename(e.pathname)}catch{o=path.basename(a)}if(!o)o=`download`;let s;let c;let l;try{await ensureDir(i);await assertCanonicalPathWithinBase({baseDir:i,candidatePath:i,boundaryLabel:`skill tools directory`});s=await fs.promises.realpath(i);l=await root(s);const e=resolveDownloadTargetDir(t,n);const r=path.relative(i,e);c=path.join(s,r)}catch(e){return downloadFailure(formatErrorMessage(e))}const u=path.join(c,o);const d=path.relative(s,u);if(!d||d===`..`||d.startsWith(`..${path.sep}`)||path.isAbsolute(d))return downloadFailure(`invalid download archive path`);return await withTempDownloadPath({prefix:`skill-download`},async e=>{let t;let i;try{const o=await(async()=>{const t=n.sha256;const i=await root(path.dirname(e));const{response:o,release:s}=await fetchWithSsrFGuard({url:a,timeoutMs:Math.max(1e3,r)});try{if(!o.ok||!o.body)throw new Error(`Download failed (${o.status} ${o.statusText})`);const n=parseSkillInstallFileName(o.headers.get(`content-disposition`));const r=normalizeOptionalLowercaseString(o.headers.get(`content-encoding`));const a=!r||r===`identity`?parseStrictNonNegativeInteger(o.headers.get(`content-length`)):void 0;if(a!==void 0&&a>MAX_SKILL_DOWNLOAD_BYTES)throw new Error(`Skill download exceeds ${MAX_SKILL_DOWNLOAD_BYTES}-byte limit (declared ${a} bytes)`);const s=o.body;let c=0;async function*chunks(){for await(const e of s.values({preventCancel:true})){c+=e.byteLength;yield e}}await i.create(path.basename(e),chunks(),{maxBytes:MAX_SKILL_DOWNLOAD_BYTES,mkdir:false,durable:false,mode:438&~process.umask()});if(t){const n=await sha256File(e);if(n!==t){const e=path.basename(d);throw new Error(`SHA-256 mismatch for ${e}: expected ${t}, actual ${n}. The download was discarded; verify the publisher checksum or update the skill manifest before retrying.`)}}await l.copyIn(d,e);return n?{bytes:c,archiveFileName:n}:{bytes:c}}catch(e){if(e instanceof FsSafeError&&e.code===`too-large`)throw new Error(`Skill download exceeds ${MAX_SKILL_DOWNLOAD_BYTES}-byte limit`,{cause:e});throw e}finally{await s()}})();t=o.bytes;i=o.archiveFileName}catch(e){return downloadFailure(formatErrorMessage(e))}const f=(()=>{const e=normalizeOptionalLowercaseString(n.archive);if(e)return e;return detectArchiveType(n.extract===true?i:void 0)??detectArchiveType(o)})();if(!(n.extract??Boolean(f)))return{ok:true,message:`Downloaded to ${u}`,stdout:`downloaded=${t}`,stderr:``,code:0};if(!f)return downloadFailure(`extract requested but archive type could not be detected`,{stderr:``});const p=path.join(path.dirname(e),`extracted`);try{await fs.promises.mkdir(p,{mode:448});const{extractSkillDownloadArchive:t}=await import(`./install-extract--gV6Xm5G.mjs`);const i=await t({archivePath:e,archiveType:f,targetDir:p,stripComponents:n.stripComponents,timeoutMs:r});if(i.code===0){const e=path.relative(s,c);if(e)await l.mkdir(e);else await l.ensureRoot();const publishDirectory=async t=>{const n=path.join(p,t);for(const r of await fs.promises.readdir(n,{withFileTypes:true})){const n=path.join(t,r.name);const i=path.join(p,n);const a=path.join(e,n);const o=await fs.promises.lstat(i);try{if(o.isDirectory()){await l.mkdir(a);await publishDirectory(n);continue}if(!o.isFile()||o.nlink!==1)throw new Error(`archive staging contains unsupported entry: ${n}`);await l.copyIn(a,i,{mode:o.mode&511,sourceHardlinks:`reject`})}catch(e){if(e instanceof FsSafeError&&(e.code===`symlink`||e.code===`path-alias`))throw new Error(`archive entry traverses symlink in destination: ${n}`,{cause:e});throw e}}};await publishDirectory(``)}const a=i.code===0;return{ok:a,message:a?`Downloaded and extracted to ${c}`:formatInstallFailureMessage(i),stdout:i.stdout.trim(),stderr:i.stderr.trim(),code:i.code}}catch(e){return downloadFailure(formatErrorMessage(e),{code:1})}})}
//!src/skills/lifecycle/install.ts
async function withSkillInstallPolicySource(e,t,n){if(!t||resolveSkillFileHost(e)===`gateway`)return await n(path.resolve(e.baseDir));if(!t.skillResources)throw new WorkspaceAccessUnavailableError(`Remote skill policy source is unavailable`);const r=await t.skillResources.readSkillFiles(e,{allowMissingRoot:false});if(!r)throw new WorkspaceAccessUnavailableError(`Remote skill policy source disappeared`);const i=prepareSkillBundle(r);const a=await materializeSkillResources({version:1,skills:[{name:e.name,description:e.description,revision:i.revision,files:r}]},()=>{});try{return await n(a.snapshot.resolvedSkills[0].baseDir)}finally{await a.cleanup()}}function withWarnings(e,t){if(t.length===0)return e;return{...e,warnings:t.slice()}}const DEFAULT_NODE_INSTALL_COMMAND=[`npm`,`install`,`-g`,`--ignore-scripts`];const NODE_INSTALL_COMMANDS=/* @__PURE__ */ new Map([[`pnpm`,[`pnpm`,`add`,`-g`,`--ignore-scripts`]],[`yarn`,[`yarn`,`global`,`add`,`--ignore-scripts`]],[`bun`,[`bun`,`add`,`-g`,`--ignore-scripts`]]]);const SAFE_BREW_FORMULA=/^[a-z0-9][a-z0-9+._@-]*(\/[a-z0-9][a-z0-9+._@-]*){0,2}$/;const SAFE_NODE_PACKAGE=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-z0-9^~>=<.*|-]+)?$/;const SAFE_GO_MODULE=/^[a-zA-Z0-9][a-zA-Z0-9._/-]*@[a-z0-9v._-]+$/;const SAFE_UV_PACKAGE=/^[a-z0-9][a-z0-9._-]*(\[[a-z0-9,._-]+\])?(([><=!~]=?|===?)[a-z0-9.*_-]+)?$/i;function buildValidatedInstallCommand(e,t,n,r){if(!e)return{error:`missing ${t}`};const i=e.trim();if(!i||i.startsWith(`-`))return{error:`${t} value is empty or starts with a dash`};if(!n.test(i))return{error:`${t} value contains invalid characters: ${i}`};return{argv:[...r,i]}}function buildInstallCommand(e,t){switch(e.kind){case`brew`:return buildValidatedInstallCommand(e.formula,`brew formula`,SAFE_BREW_FORMULA,[`brew`,`install`]);case`node`:return buildValidatedInstallCommand(e.package,`node package`,SAFE_NODE_PACKAGE,NODE_INSTALL_COMMANDS.get(t.nodeManager)??DEFAULT_NODE_INSTALL_COMMAND);case`go`:return buildValidatedInstallCommand(e.module,`go module`,SAFE_GO_MODULE,[`go`,`install`]);case`uv`:return buildValidatedInstallCommand(e.package,`uv package`,SAFE_UV_PACKAGE,[`uv`,`tool`,`install`]);default:return{error:`unsupported installer`}}}async function resolveBrewBinDir(e,t,n=[`/opt/homebrew/bin`,`/usr/local/bin`]){const r=await runCommandSafely([t,`--prefix`],{timeoutMs:Math.min(e,3e4)});if(r.code===0){const e=r.stdout.trim();if(e)return path.join(e,`bin`)}for(const e of n)if(await canAccess(e))return e}function createInstallFailure(e){return{ok:false,message:e.message,stdout:e.stdout?.trim()??``,stderr:e.stderr?.trim()??``,code:e.code??null,...e.skipReason?{skipReason:e.skipReason}:{}}}async function runCommandSafely(e,t){try{return await runCommandWithTimeout(e,t)}catch(e){return{code:null,stdout:``,stderr:formatErrorMessage(e)}}}const MIN_AUTO_GO_MAJOR=1;const MIN_AUTO_GO_MINOR=21;const MIN_AUTO_GO_VERSION=`${MIN_AUTO_GO_MAJOR}.${MIN_AUTO_GO_MINOR}`;const APT_GO_PACKAGE=`golang-go`;const APT_GO_POLICY_ARGV=[`apt-cache`,`policy`,APT_GO_PACKAGE];const APT_GO_UPDATE_ARGV=[`apt-get`,`update`,`-qq`];const APT_GO_INSTALL_ARGV=[`apt-get`,`install`,`-y`,APT_GO_PACKAGE];const SUDO_NONINTERACTIVE_PREFIX=[`sudo`,`-n`];const SUDO_APT_GO_CHECK_ARGVS=[[`sudo`,`-k`,`-n`,`-ll`,...APT_GO_UPDATE_ARGV],[`sudo`,`-k`,`-n`,`-ll`,...APT_GO_INSTALL_ARGV]];const GO_VERSION_ENV_ARGV=[`go`,`env`,`GOVERSION`];function isSupportedGoVersion(e){return e.major>MIN_AUTO_GO_MAJOR||e.major===MIN_AUTO_GO_MAJOR&&e.minor>=MIN_AUTO_GO_MINOR}function appendPathDirectory(e,t){if((e??``).split(path.delimiter).includes(t))return e??t;return e?`${e}${path.delimiter}${t}`:t}function sudoListAllowsPasswordlessCommand(e){const t=e.split(/\r?\n/).find(e=>/^\s*Options:\s*/.test(e));if(!t)return false;return t.slice(t.indexOf(`:`)+1).split(`,`).some(e=>e.trim()===`!authenticate`)}async function resolveAptCommandAccess(){if(typeof process.getuid===`function`&&process.getuid()===0)return{available:true,prefix:[]};if(!hasBinary(`sudo`))return{available:false,reason:`sudo-missing`};for(const e of SUDO_APT_GO_CHECK_ARGVS){const t=await runCommandSafely(e,{timeoutMs:5e3,env:{LC_ALL:`C`}});if(t.code!==0)return{available:false,reason:`sudo-unusable`,failure:t};if(!sudoListAllowsPasswordlessCommand(t.stdout))return{available:false,reason:`sudo-unusable`,failure:{code:1,stdout:t.stdout,stderr:t.stderr||`sudo rule requires authentication`}}}return{available:true,prefix:SUDO_NONINTERACTIVE_PREFIX}}async function installGoViaApt(e){const t=`go not installed — automatic install via apt failed. Install manually: https://go.dev/doc/install`;const n=await resolveAptCommandAccess();if(!n.available&&n.reason===`sudo-missing`)return createInstallFailure({message:`go not installed — apt-get is available but sudo is not installed. Install manually: https://go.dev/doc/install`});if(!n.available)return createInstallFailure({message:`go not installed — apt-get is available but sudo is not usable (missing or requires a password). Install manually: https://go.dev/doc/install`,...n.failure});const r=await runCommandSafely([...n.prefix,...APT_GO_UPDATE_ARGV],{timeoutMs:e});const i=await runCommandSafely(APT_GO_POLICY_ARGV,{timeoutMs:Math.min(e,1e4),env:{LC_ALL:`C`}});if(i.code!==0)return createInstallFailure({message:t,...i});const a=parseGoVersion(/Candidate:\s*(?:\d+:)?(\d+)\.(\d+)/.exec(i.stdout));if(!a&&r.code!==0)return createInstallFailure({message:t,...r});if(!a||!isSupportedGoVersion(a))return createInstallFailure({message:`go not installed — apt does not provide a usable Go ${MIN_AUTO_GO_VERSION}+ package. Install manually: https://go.dev/doc/install`,skipReason:`go`});const o=await runCommandSafely([...n.prefix,...APT_GO_INSTALL_ARGV],{timeoutMs:e});if(o.code===0)return;return createInstallFailure({message:t,...o})}function parseGoVersion(e){if(!e)return;return{major:Number(e[1]),minor:Number(e[2])}}async function isGoUsableForAutoInstall(){const e=await runCommandSafely(GO_VERSION_ENV_ARGV,{timeoutMs:5e3,env:{GOTOOLCHAIN:`local`}});if(e.code!==0)return false;const t=parseGoVersion(/\bgo(\d+)\.(\d+)(?:[.\w-]*)?\b/.exec(e.stdout));return t!==void 0&&isSupportedGoVersion(t)}function isGoToolchainPrerequisiteFailure(e){const t=`${e.message}\n${e.stdout}\n${e.stderr}`;return/requires go >= \S+ \(running go \S+(?:; GOTOOLCHAIN=[^)]+)?\)/i.test(t)||/invalid GOTOOLCHAIN/i.test(t)||/cannot find "go[^"]+" in PATH/i.test(t)}async function resolveInstallerKindReadiness(e){const t=hasBinary(`brew`);const n=t?`brew`:resolveBrewExecutable();switch(e){case`brew`:return n?{ready:true}:{ready:false,reason:`brew`};case`uv`:if(hasBinary(`uv`))return{ready:true};return t?{ready:true}:{ready:false,reason:`uv`};case`go`:{let e;if(hasBinary(`go`))e=await isGoUsableForAutoInstall();else if(t)e=true;else if(n)e=Boolean(await resolveBrewBinDir(1e4,n,[]));else e=hasBinary(`apt-get`)&&(await resolveAptCommandAccess()).available;return e?{ready:true}:{ready:false,reason:`go`}}default:return{ready:true}}}async function installSkill(e){const t=Math.min(Math.max(e.timeoutMs??3e5,1e3),9e5);const n=resolveUserPath(e.workspaceDir);const r=(await prepareWorkspaceSkills(n,{config:e.config,agentId:e.agentId,agentSkillFilter:`ignore`})).find(t=>t.skill.name===e.skillName);if(!r)return createInstallFailure({message:`Skill not found: ${e.skillName}`});const i=e.installId;const a=r.metadata?.install?.find((e,t)=>(e.id??`${e.kind}-${t}`).trim()===i);const o=[];const s=resolveSkillSource(r.skill);const c=a?{...a.id?{id:a.id}:{},kind:a.kind,...a.label?{label:a.label}:{},...a.bins?{bins:a.bins.slice()}:{},...a.os?{os:a.os.slice()}:{},...a.formula?{formula:a.formula}:{},...a.package?{package:a.package}:{},...a.module?{module:a.module}:{},...a.url?{url:a.url}:{},...a.sha256?{sha256:a.sha256}:{},...a.archive?{archive:a.archive}:{},...a.extract!==void 0?{extract:a.extract}:{},...a.stripComponents!==void 0?{stripComponents:a.stripComponents}:{},...a.targetDir?{targetDir:a.targetDir}:{}}:void 0;const l=getAgentWorkspaceAccess(n,`loadSkills`);const u=l?.loadSkills?l:void 0;if(u&&!u.installSkillDependencies)throw new WorkspaceAccessUnavailableError(`Remote skill dependency installation is unavailable`);const d=await withSkillInstallPolicySource(r.skill,u,t=>evaluateSkillInstallPolicy({config:e.config,installId:e.installId,...c?{installSpec:c}:{},logger:{warn:e=>o.push(e)},origin:{type:s,skillName:e.skillName,installId:e.installId},source:s===`openclaw-bundled`?{kind:`bundled`,authority:`openclaw`,mutable:false,network:false}:s===`openclaw-managed`||s===`openclaw-extra`?{kind:`managed`,authority:`openclaw`,mutable:false,network:false}:{kind:`workspace`,authority:`user`,mutable:true,network:false},requestedSpecifier:`${e.skillName}:${e.installId}`,skillName:e.skillName,sourceDir:t}));if(d?.blocked)return withWarnings(createInstallFailure({message:d.blocked.reason}),o);if(!(/* @__PURE__ */ new Set([`openclaw-bundled`,`openclaw-managed`,`openclaw-extra`])).has(s))o.push(`WARNING: Skill "${e.skillName}" install triggered from non-bundled source "${s}". Verify the install recipe is trusted.`);if(!a)return withWarnings(createInstallFailure({message:`Installer not found: ${e.installId}`}),o);const f={skillKey:resolveSkillKey(r),spec:a,preferences:resolveSkillsInstallPreferences(e.config),timeoutMs:t};const p=u?await u.installSkillDependencies(f):await installSkillDependencies(f);if(p.ok)try{const{refreshSkillsDiscovery:t}=await import(`./refresh-DDFbJ_aI.mjs`);await t({workspaceDir:n,config:e.config})}catch(e){o.push(`Dependencies installed, but discovery refresh failed: ${formatErrorMessage(e)}`)}return withWarnings(p,o)}async function installSkillDependencies(e){const{skillKey:t,spec:n,preferences:r}=e;const i=Math.min(Math.max(e.timeoutMs,1e3),9e5);if(n.kind===`download`)return installDownloadSpec({skillKey:t,spec:n,timeoutMs:i});const a=buildInstallCommand(n,r);if(`error`in a)return createInstallFailure({message:a.error});const o=hasBinary(`brew`)?`brew`:resolveBrewExecutable();if(n.kind===`brew`&&!o){if(process.platform===`freebsd`)return createInstallFailure({message:"brew not installed — Homebrew is not supported on FreeBSD. Install the required binaries on the Gateway host using pkg or Ports, then run `openclaw skills check` (use `--agent <id>` for a specific agent) to verify readiness."});const e=n.formula??`this package`;if(process.platform===`linux`&&isContainerEnvironment())return createInstallFailure({message:`brew not installed — Homebrew is not installed in this Linux container. Build a custom image with Homebrew or install "${e}" manually using a supported system package before enabling this skill.`});return createInstallFailure({message:`brew not installed — ${process.platform===`linux`?`Homebrew is not installed. Install it from https://brew.sh or install "${e}" manually using your system package manager (e.g. apt, dnf, pacman).`:`Homebrew is not installed. Install it from https://brew.sh`}`})}const s=n.kind===`go`&&hasBinary(`go`);if(n.kind===`uv`&&!hasBinary(`uv`)||n.kind===`go`&&!s){if(o){const e=await runCommandSafely([o,`install`,n.kind],{timeoutMs:i});if(e.code!==0)return createInstallFailure({message:`Failed to install ${n.kind} (brew)`,...e})}else if(n.kind===`go`&&hasBinary(`apt-get`)){const e=await installGoViaApt(i);if(e)return e}else return createInstallFailure({message:n.kind===`uv`?`uv not installed — install manually: https://docs.astral.sh/uv/getting-started/installation/`:`go not installed — install manually: https://go.dev/doc/install`})}const{argv:c}=a;if(n.kind===`brew`&&o&&c[0]===`brew`)c[0]=o;const l={};let u;if(n.kind===`node`&&r.nodeManager===`npm`){const e=process.platform!==`win32`&&process.getuid?.()===0?path.join(path.parse(process.cwd()).root,`var`,`lib`,`openclaw`):path.join(os.homedir(),`.openclaw`);const t=path.join(e,`tools`,`node`,`npm`);await fs$1.mkdir(t,{recursive:true,mode:448});l.NPM_CONFIG_PREFIX=t;l.npm_config_prefix=t}if(n.kind===`go`){u=(o&&!s?await resolveBrewBinDir(i,o):void 0)??path.join(os.homedir(),`.local`,`bin`);l.GOBIN=u;l.PATH=appendPathDirectory(process.env.PATH,u)}const d=await runCommandSafely(c,{timeoutMs:i,env:Object.keys(l).length>0?l:void 0});if(d.code===0){if(u&&l.PATH)process.env.PATH=l.PATH;return{ok:true,message:`Installed`,stdout:d.stdout.trim(),stderr:d.stderr.trim(),code:d.code}}const f=createInstallFailure({message:formatInstallFailureMessage(d),...d});return n.kind===`go`&&isGoToolchainPrerequisiteFailure(f)?{...f,skipReason:`go`}:f}export{resolveInstallerKindReadiness as i,installSkill as n,installSkillDependencies as r,MIN_AUTO_GO_VERSION as t};