mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-25 20:41:10 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
// Resolves plugin root directories for bundled and installed plugins.
|
|
import path from "node:path";
|
|
import { normalizeStringEntries } from "@openclaw/normalization-core/string-normalization";
|
|
import { resolveConfigDir, resolveUserPath } from "../utils.js";
|
|
import { resolveBundledPluginsDir } from "./bundled-dir.js";
|
|
|
|
export type PluginSourceRoots = {
|
|
stock?: string;
|
|
global: string;
|
|
workspace?: string;
|
|
};
|
|
|
|
type PluginCacheInputs = {
|
|
roots: PluginSourceRoots;
|
|
loadPaths: string[];
|
|
};
|
|
|
|
export function resolvePluginSourceRoots(params: {
|
|
workspaceDir?: string;
|
|
env?: NodeJS.ProcessEnv;
|
|
}): PluginSourceRoots {
|
|
const env = params.env ?? process.env;
|
|
const workspaceRoot = params.workspaceDir ? resolveUserPath(params.workspaceDir, env) : undefined;
|
|
const stock = resolveBundledPluginsDir(env);
|
|
const global = path.join(resolveConfigDir(env), "extensions");
|
|
const workspace = workspaceRoot ? path.join(workspaceRoot, ".openclaw", "extensions") : undefined;
|
|
return { stock, global, workspace };
|
|
}
|
|
|
|
// Shared env-aware key inputs for plugin loader registry reuse.
|
|
export function resolvePluginCacheInputs(params: {
|
|
workspaceDir?: string;
|
|
loadPaths?: string[];
|
|
env?: NodeJS.ProcessEnv;
|
|
}): PluginCacheInputs {
|
|
const env = params.env ?? process.env;
|
|
const roots = resolvePluginSourceRoots({
|
|
workspaceDir: params.workspaceDir,
|
|
env,
|
|
});
|
|
// Preserve caller order because load-path precedence follows input order.
|
|
const loadPaths = normalizeStringEntries(
|
|
(params.loadPaths ?? []).filter((entry): entry is string => typeof entry === "string"),
|
|
).map((entry) => resolveUserPath(entry, env));
|
|
return { roots, loadPaths };
|
|
}
|