openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
63 lines (62 loc) • 2.07 kB
JavaScript
import { c as resolveUserPath } from "./home-dir-EKmgmdPG.mjs";
import { r as terminalText } from "./safe-text-C80HAQ2e.mjs";
import "./utils-C8YECn2Q.mjs";
import { d as pathExists } from "./fs-safe-BbWvmdVn.mjs";
import { c as extractArchive, f as resolvePackedRootDir } from "./archive-xLn9WKtS.mjs";
import { n as resolveInstallWorkTimeoutMs } from "./install-mode-options-N6t-RB8t.mjs";
import { t as withInstallActivity } from "./install-progress-DFtV5xZ5.mjs";
import { c as withInstallWorkspace } from "./install-source-utils-yGloSiaw.mjs";
import path from "node:path";
import fs from "node:fs/promises";
//#region 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);
});
}
//#endregion
export { withExtractedArchiveRoot as n, resolveExistingInstallPath as t };