mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:10:42 +00:00
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { loggingState } from "../logging/state.js";
|
|
import { createLazyImportLoader } from "../shared/lazy-promise.js";
|
|
import type { CliPluginRegistryScope } from "./command-catalog.js";
|
|
|
|
const pluginRegistryModuleLoader = createLazyImportLoader(() => import("./plugin-registry.js"));
|
|
|
|
function loadPluginRegistryModule() {
|
|
return pluginRegistryModuleLoader.load();
|
|
}
|
|
|
|
export type CliPluginRegistryLoadPolicy = {
|
|
scope: CliPluginRegistryScope;
|
|
};
|
|
|
|
export async function ensureCliPluginRegistryLoaded(params: {
|
|
scope: CliPluginRegistryScope;
|
|
routeLogsToStderr?: boolean;
|
|
config?: OpenClawConfig;
|
|
activationSourceConfig?: OpenClawConfig;
|
|
}) {
|
|
const { ensurePluginRegistryLoaded } = await loadPluginRegistryModule();
|
|
const previousForceStderr = loggingState.forceConsoleToStderr;
|
|
if (params.routeLogsToStderr) {
|
|
loggingState.forceConsoleToStderr = true;
|
|
}
|
|
try {
|
|
ensurePluginRegistryLoaded({
|
|
scope: params.scope,
|
|
...(params.config ? { config: params.config } : {}),
|
|
...(params.activationSourceConfig
|
|
? { activationSourceConfig: params.activationSourceConfig }
|
|
: {}),
|
|
});
|
|
} finally {
|
|
loggingState.forceConsoleToStderr = previousForceStderr;
|
|
}
|
|
}
|