UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

43 lines (42 loc) • 2.07 kB
import { a as resolveGlobalSingleton } from "./global-singleton-D7yf05nR.mjs"; import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs"; import { t as resolveConfigDir } from "./config-dir-DMqvtq2W.mjs"; import "./utils-C8YECn2Q.mjs"; import "./paths-DAcAg5aV.mjs"; import path from "node:path"; import os from "node:os"; import { AsyncLocalStorage } from "node:async_hooks"; //#region src/plugins/install-root-context.ts const pluginInstallRootContext = resolveGlobalSingleton(Symbol.for("openclaw.pluginInstallRootContext"), () => new AsyncLocalStorage()); /** Resolve the ordinary operator-owned plugin roots before a run redirects state. */ function resolvePluginInstallRoots(e = process.env, t = os.homedir) { const n = resolveConfigDir(e, t); return Object.freeze({ extensionsDir: path.join(n, "extensions"), gitDir: path.join(n, "git"), npmDir: path.join(n, "npm"), stateDir: resolveStateDir(e, t) }); } /** Return run-pinned install roots, or resolve the caller's ordinary roots. */ function resolveActivePluginInstallRoots(e = process.env, t = os.homedir) { return pluginInstallRootContext.getStore() ?? resolvePluginInstallRoots(e, t); } /** Artifact paths do not need the state directory's legacy-location filesystem probes. */ function resolveActivePluginInstallDir(e, t = process.env, n = os.homedir) { const r = pluginInstallRootContext.getStore(); return r ? r[`${e}Dir`] : path.join(resolveConfigDir(t, n), e); } /** Return whether the current run pinned operator-owned plugin install roots. */ function hasActivePluginInstallRoots() { return pluginInstallRootContext.getStore() !== void 0; } /** * Keep plugin discovery on one operator-owned install generation while a run * redirects OPENCLAW_STATE_DIR for ephemeral sessions and runtime state. */ function withPluginInstallRoots(e, t) { return pluginInstallRootContext.run(e, t); } //#endregion export { withPluginInstallRoots as a, resolvePluginInstallRoots as i, resolveActivePluginInstallDir as n, resolveActivePluginInstallRoots as r, hasActivePluginInstallRoots as t };