mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-26 01:11:37 +00:00
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
import {
|
|
withBundledPluginAllowlistCompat,
|
|
withBundledPluginEnablementCompat,
|
|
} from "./bundled-compat.js";
|
|
import { loadOpenClawPlugins, type PluginLoadOptions } from "./loader.js";
|
|
import { createPluginLoaderLogger } from "./logger.js";
|
|
import {
|
|
resolveBundledProviderCompatPluginIds,
|
|
withBundledProviderVitestCompat,
|
|
} from "./providers.js";
|
|
import type { ProviderPlugin } from "./types.js";
|
|
|
|
const log = createSubsystemLogger("plugins");
|
|
|
|
export function resolvePluginProviders(params: {
|
|
config?: PluginLoadOptions["config"];
|
|
workspaceDir?: string;
|
|
/** Use an explicit env when plugin roots should resolve independently from process.env. */
|
|
env?: PluginLoadOptions["env"];
|
|
bundledProviderAllowlistCompat?: boolean;
|
|
bundledProviderVitestCompat?: boolean;
|
|
onlyPluginIds?: string[];
|
|
activate?: boolean;
|
|
cache?: boolean;
|
|
}): ProviderPlugin[] {
|
|
const env = params.env ?? process.env;
|
|
const bundledProviderCompatPluginIds =
|
|
params.bundledProviderAllowlistCompat || params.bundledProviderVitestCompat
|
|
? resolveBundledProviderCompatPluginIds({
|
|
config: params.config,
|
|
workspaceDir: params.workspaceDir,
|
|
env,
|
|
onlyPluginIds: params.onlyPluginIds,
|
|
})
|
|
: [];
|
|
const maybeAllowlistCompat = params.bundledProviderAllowlistCompat
|
|
? withBundledPluginAllowlistCompat({
|
|
config: params.config,
|
|
pluginIds: bundledProviderCompatPluginIds,
|
|
})
|
|
: params.config;
|
|
const maybeVitestCompat = params.bundledProviderVitestCompat
|
|
? withBundledProviderVitestCompat({
|
|
config: maybeAllowlistCompat,
|
|
pluginIds: bundledProviderCompatPluginIds,
|
|
env: params.env,
|
|
})
|
|
: maybeAllowlistCompat;
|
|
const config =
|
|
params.bundledProviderAllowlistCompat || params.bundledProviderVitestCompat
|
|
? withBundledPluginEnablementCompat({
|
|
config: maybeVitestCompat,
|
|
pluginIds: bundledProviderCompatPluginIds,
|
|
})
|
|
: maybeVitestCompat;
|
|
const registry = loadOpenClawPlugins({
|
|
config,
|
|
workspaceDir: params.workspaceDir,
|
|
env,
|
|
onlyPluginIds: params.onlyPluginIds,
|
|
cache: params.cache ?? false,
|
|
activate: params.activate ?? false,
|
|
logger: createPluginLoaderLogger(log),
|
|
});
|
|
|
|
return registry.providers.map((entry) => ({
|
|
...entry.provider,
|
|
pluginId: entry.pluginId,
|
|
}));
|
|
}
|