UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

51 lines (50 loc) 2.3 kB
import { n as registerPluginMetadataProcessMemoLifecycleClear } from "./plugin-metadata-lifecycle-C6m-q5Au.js"; import { s as resolveOpenClawStateSqlitePath } from "./openclaw-state-db-schema-version-c1ZL6JGz.js"; import { r as readConfigMachineState } from "./config-machine-state-BCereLZr.js"; import { n as resolveActivePluginInstallRoots, t as hasActivePluginInstallRoots } from "./install-root-context-BSQp2WLR.js"; //#region src/plugins/bundled-discovery-state.ts function readBundledDiscoveryMode(options = {}) { const resolvedOptions = options.path || options.database || !hasActivePluginInstallRoots() ? options : { ...options, env: { ...options.env ?? process.env, OPENCLAW_STATE_DIR: resolveActivePluginInstallRoots(options.env).stateDir } }; const value = readConfigMachineState("plugins.bundledDiscovery", resolvedOptions); return value === "compat" || value === "allowlist" ? value : void 0; } let memoizedBundledDiscoveryMode; registerPluginMetadataProcessMemoLifecycleClear(() => { memoizedBundledDiscoveryMode = void 0; }); function resolveBundledDiscoveryMemoKey(env) { const scopedEnv = hasActivePluginInstallRoots() ? { ...env, OPENCLAW_STATE_DIR: resolveActivePluginInstallRoots(env).stateDir } : env; return resolveOpenClawStateSqlitePath(scopedEnv); } /** * Callers loading a registry with an explicit env pass it so the mode comes * from that env's state root; omitting it reads the process root. Pinned * install roots win over both, matching readBundledDiscoveryMode. */ function readBundledDiscoveryModeMemoized(env = process.env) { const key = resolveBundledDiscoveryMemoKey(env); if (memoizedBundledDiscoveryMode?.key !== key) memoizedBundledDiscoveryMode = { key, value: readBundledDiscoveryMode(env === process.env ? {} : { env }) }; return memoizedBundledDiscoveryMode.value; } /** * Clears the memo after a machine-state write so same-process readers observe * the new mode. Without this, doctor's migration could cache the pre-migration * absent mode and rebuild plugin indexes against stale strict-gate decisions. */ function clearBundledDiscoveryModeMemo() { memoizedBundledDiscoveryMode = void 0; } //#endregion export { readBundledDiscoveryMode as n, readBundledDiscoveryModeMemoized as r, clearBundledDiscoveryModeMemo as t };