fix(plugins): cold-load partial tool registries

Fix plugin tool discovery when a selected wildcard plugin set is resolved against a partial active registry.\n\nRequire scoped registries to cover every requested plugin owner, force cold-load incomplete tool discovery registries without replacing active plugin runtime state, and add regression coverage for the partial-registry path.\n\nFixes #76780.\nThanks @lilesjtu.
This commit is contained in:
Edionwheels
2026-05-04 02:09:34 +08:00
committed by GitHub
parent ee6052a169
commit 66ffb29679
4 changed files with 208 additions and 26 deletions

View File

@@ -50,23 +50,30 @@ function installStandaloneRegistry(
export function ensureStandaloneRuntimePluginRegistryLoaded(params: {
loadOptions: PluginLoadOptions;
forceLoad?: boolean;
installRegistry?: boolean;
requiredPluginIds?: readonly string[];
surface?: ActiveRuntimePluginRegistrySurface;
}): PluginRegistry | undefined {
const requiredPluginIds = params.requiredPluginIds ?? params.loadOptions.onlyPluginIds;
const surface = params.surface ?? "active";
const existing = getLoadedRuntimePluginRegistry({
env: params.loadOptions.env,
loadOptions: params.loadOptions,
workspaceDir: params.loadOptions.workspaceDir,
requiredPluginIds,
surface,
});
if (existing) {
return existing;
if (!params.forceLoad) {
const existing = getLoadedRuntimePluginRegistry({
env: params.loadOptions.env,
loadOptions: params.loadOptions,
workspaceDir: params.loadOptions.workspaceDir,
requiredPluginIds,
surface,
});
if (existing) {
return existing;
}
}
const registry = loadOpenClawPlugins(params.loadOptions);
const effectiveLoadOptions = params.forceLoad
? { ...params.loadOptions, cache: false }
: params.loadOptions;
const registry = loadOpenClawPlugins(effectiveLoadOptions);
if (params.loadOptions.activate !== false) {
switch (surface) {
case "active":
@@ -81,6 +88,10 @@ export function ensureStandaloneRuntimePluginRegistryLoaded(params: {
return registry;
}
if (params.installRegistry === false) {
return registry;
}
installStandaloneRegistry(registry, {
loadOptions: params.loadOptions,
surface,