UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.76 kB
import{c as resolveUserPath}from"./home-dir-DEN5DisQ.mjs";import{r as terminalText}from"./safe-text-B_QTgn0s.mjs";import"./utils-Dlk0IYAa.mjs";import{l as pathExists}from"./fs-safe-Bxzu1j4h.mjs";import{c as extractArchive,f as resolvePackedRootDir}from"./archive-BAuHVLxp.mjs";import{n as resolveInstallWorkTimeoutMs}from"./install-mode-options-BriF1B9H.mjs";import{t as withInstallActivity}from"./install-progress-CGUs84DR.mjs";import{c as withInstallWorkspace}from"./install-source-utils-9ToOWGEU.mjs";import path from"node:path";import fs from"node:fs/promises"; //!src/infra/install-flow.ts async function resolveExistingInstallPath(e){const t=resolveUserPath(e);if(!await pathExists(t))return{ok:false,error:`path not found: ${t}`};return{ok:true,resolvedPath:t,stat:await fs.stat(t)}}async function withExtractedArchiveRoot(e){return await withInstallWorkspace(e.tempDirPrefix,async t=>{const n=path.join(t,`extract`);await fs.mkdir(n,{recursive:true});e.logger?.info?.(terminalText`Extracting ${e.archivePath}…`);try{await withInstallActivity(e.logger,`extract`,()=>extractArchive({archivePath:e.archivePath,destDir:n,stripComponents:0,timeoutMs:resolveInstallWorkTimeoutMs(e.workTimeoutMs,e.timeoutMs)??0,logger:e.logger,limits:e.verification?.limits??e.limits,entryFilter:e.verification?.entryFilter,durable:false}))}catch(t){if(e.verification)return e.verification.onExtractionError(t);return{ok:false,error:`failed to extract archive: ${String(t)}`}}const r=await e.verification?.verify(n);if(r)return r;let i;try{i=await resolvePackedRootDir(n,{rootMarkers:e.rootMarkers?[...e.rootMarkers]:void 0})}catch(e){return{ok:false,error:String(e)}}return await e.onExtracted(i)})}export{withExtractedArchiveRoot as n,resolveExistingInstallPath as t};