mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:50:43 +00:00
fix(plugins): scope metadata manifest reads
This commit is contained in:
@@ -207,6 +207,26 @@ describe("setup-registry getJiti", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("passes explicit plugin id scope into setup manifest reads", () => {
|
||||
const pluginRoot = makeTempDir();
|
||||
fs.writeFileSync(path.join(pluginRoot, "setup-api.js"), "export default {};\n", "utf-8");
|
||||
mocks.loadPluginManifestRegistry.mockReturnValue({
|
||||
plugins: [{ id: "test-plugin", rootDir: pluginRoot }],
|
||||
diagnostics: [],
|
||||
});
|
||||
|
||||
resolvePluginSetupRegistry({
|
||||
pluginIds: ["test-plugin"],
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginIds: ["test-plugin"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("skips setup-api loading when config has no relevant migration triggers", () => {
|
||||
const pluginRoot = makeTempDir();
|
||||
fs.writeFileSync(path.join(pluginRoot, "setup-api.js"), "export default {};\n", "utf-8");
|
||||
|
||||
@@ -380,12 +380,14 @@ function loadSetupManifestRegistry(params?: {
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
pluginIds?: readonly string[];
|
||||
}) {
|
||||
const env = params?.env ?? process.env;
|
||||
return loadPluginManifestRegistryForPluginRegistry({
|
||||
config: params?.config,
|
||||
workspaceDir: params?.workspaceDir,
|
||||
env,
|
||||
pluginIds: params?.pluginIds,
|
||||
includeDisabled: true,
|
||||
});
|
||||
}
|
||||
@@ -532,6 +534,7 @@ export function resolvePluginSetupRegistry(params?: {
|
||||
const manifestRegistry = loadSetupManifestRegistry({
|
||||
workspaceDir: params?.workspaceDir,
|
||||
env,
|
||||
pluginIds: params?.pluginIds,
|
||||
});
|
||||
|
||||
for (const record of manifestRegistry.plugins) {
|
||||
|
||||
@@ -62,6 +62,7 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
|
||||
onlyPluginIds: [],
|
||||
}),
|
||||
).toEqual([]);
|
||||
expect(mocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps runtime fallback for scoped plugins with no declared web candidates", () => {
|
||||
@@ -72,6 +73,11 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
|
||||
onlyPluginIds: ["missing-plugin"],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
expect(mocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginIds: ["missing-plugin"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("derives provider candidates from a single manifest-registry read", () => {
|
||||
|
||||
@@ -63,11 +63,13 @@ function loadInstalledWebProviderManifestRecords(params: {
|
||||
config?: PluginLoadOptions["config"];
|
||||
workspaceDir?: string;
|
||||
env?: PluginLoadOptions["env"];
|
||||
pluginIds?: readonly string[];
|
||||
}): readonly PluginManifestRecord[] {
|
||||
return loadPluginManifestRegistryForPluginRegistry({
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
pluginIds: params.pluginIds,
|
||||
includeDisabled: true,
|
||||
}).plugins;
|
||||
}
|
||||
@@ -82,11 +84,15 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
|
||||
origin?: PluginManifestRecord["origin"];
|
||||
}): string[] | undefined {
|
||||
const scopedPluginIds = normalizePluginIdScope(params.onlyPluginIds);
|
||||
if (scopedPluginIds?.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const onlyPluginIdSet = createPluginIdScopeSet(scopedPluginIds);
|
||||
const ids = loadInstalledWebProviderManifestRecords({
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
pluginIds: scopedPluginIds,
|
||||
})
|
||||
.filter(
|
||||
(plugin) =>
|
||||
@@ -99,7 +105,7 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
|
||||
if (ids.length > 0) {
|
||||
return ids;
|
||||
}
|
||||
return scopedPluginIds?.length === 0 ? [] : undefined;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveBundledWebProviderCompatPluginIds(params: {
|
||||
|
||||
Reference in New Issue
Block a user