openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 2.15 kB
JavaScript
import { f as withPluginCache, i as createPluginCache } from "./plugin-cache-DGWspMEc.js";
import { t as formatErrorMessage } from "./errors-Db3Ymjlb.js";
import { c as tracePluginLifecyclePhaseAsync } from "./discovery-D_VDsZuY.js";
import { r as loadInstalledPluginIndexInstallRecords } from "./installed-plugin-index-record-reader-SXWwf_BU.js";
import "./installed-plugin-index-records-C06Xozeq.js";
import { t as refreshPluginRegistry } from "./plugin-registry-refresh-W0EPIfXj.js";
//#region src/plugins/registry-refresh.ts
/** Refresh persisted plugin registry and clear runtime discovery after a config mutation. */
async function refreshPluginRegistryAfterConfigMutation(params) {
try {
await withPluginCache(createPluginCache(), async () => {
const installRecords = params.installRecords ?? await tracePluginLifecyclePhaseAsync("install records load", () => loadInstalledPluginIndexInstallRecords(params.env ? { env: params.env } : {}), { command: params.traceCommand ?? "registry-refresh" });
await tracePluginLifecyclePhaseAsync("registry refresh", () => refreshPluginRegistry({
config: params.config,
reason: params.reason,
installRecords,
...params.policyPluginIds ? { policyPluginIds: params.policyPluginIds } : {},
...params.workspaceDir ? { workspaceDir: params.workspaceDir } : {},
...params.env ? { env: params.env } : {}
}), {
command: params.traceCommand ?? "registry-refresh",
reason: params.reason
});
});
} catch (error) {
params.logger?.warn?.(`Plugin registry refresh failed: ${formatErrorMessage(error)}`);
}
if (params.invalidateRuntimeCache !== false) await invalidatePluginRuntimeDiscoveryAfterConfigMutation(params);
}
async function invalidatePluginRuntimeDiscoveryAfterConfigMutation(params) {
try {
const { clearPluginRegistryLoadCache } = await import("./plugins/loader.js");
clearPluginRegistryLoadCache();
} catch (error) {
params.logger?.warn?.(`Plugin runtime cache invalidation failed: ${formatErrorMessage(error)}`);
}
}
//#endregion
export { refreshPluginRegistryAfterConfigMutation as n, invalidatePluginRuntimeDiscoveryAfterConfigMutation as t };