Files
openclaw/src/plugins/runtime/metadata-registry-loader.ts
Vincent Koc 575854c096 fix(plugins): reuse cold inspect registry snapshots (#75620)
Summary:
- The PR reuses a request-scoped cold manifest registry/runtime context across plugin status and inspect report paths, threads that context through provider/setup/metadata helpers, adds targeted coverage, and adds a changelog entry.

ClawSweeper fixups:
- Included follow-up commit: fix(plugins): preserve setup auto-enable lookup

Validation:
- ClawSweeper review passed for head 4d8e8e2d24.
- Required merge gates passed before the squash merge.

Prepared head SHA: 4d8e8e2d24
Review: https://github.com/openclaw/openclaw/pull/75620#issuecomment-4359143053

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-05-01 16:00:47 +00:00

47 lines
1.8 KiB
TypeScript

import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { loadOpenClawPlugins } from "../loader.js";
import type { PluginManifestRegistry } from "../manifest-registry.js";
import { hasExplicitPluginIdScope } from "../plugin-scope.js";
import type { PluginRegistry } from "../registry.js";
import type { PluginLogger } from "../types.js";
import {
buildPluginRuntimeLoadOptions,
resolvePluginRuntimeLoadContext,
type PluginRuntimeLoadContext,
} from "./load-context.js";
export function loadPluginMetadataRegistrySnapshot(options?: {
config?: OpenClawConfig;
activationSourceConfig?: OpenClawConfig;
env?: NodeJS.ProcessEnv;
logger?: PluginLogger;
workspaceDir?: string;
onlyPluginIds?: string[];
loadModules?: boolean;
manifestRegistry?: PluginManifestRegistry;
runtimeContext?: PluginRuntimeLoadContext;
}): PluginRegistry {
const context = options?.runtimeContext ?? resolvePluginRuntimeLoadContext(options);
return loadOpenClawPlugins(
buildPluginRuntimeLoadOptions(context, {
...(options?.config !== undefined ? { config: options.config } : {}),
...(options?.activationSourceConfig !== undefined
? { activationSourceConfig: options.activationSourceConfig }
: {}),
...(options?.workspaceDir !== undefined ? { workspaceDir: options.workspaceDir } : {}),
...(options?.env !== undefined ? { env: options.env } : {}),
...(options?.logger !== undefined ? { logger: options.logger } : {}),
throwOnLoadError: true,
cache: false,
activate: false,
mode: "validate",
loadModules: options?.loadModules,
...(hasExplicitPluginIdScope(options?.onlyPluginIds)
? { onlyPluginIds: options?.onlyPluginIds }
: {}),
...(options?.manifestRegistry ? { manifestRegistry: options.manifestRegistry } : {}),
}),
);
}