mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
refactor: let provider discovery reuse plugin metadata
This commit is contained in:
@@ -179,6 +179,40 @@ describe("resolvePluginDiscoveryProvidersRuntime", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("uses a provided plugin metadata snapshot without rebuilding registry metadata", () => {
|
||||
const registry = { plugins: [] };
|
||||
const manifestRegistry = {
|
||||
plugins: [createManifestPlugin("deepseek")],
|
||||
diagnostics: [],
|
||||
};
|
||||
mocks.loadSource.mockReturnValue(createProvider({ id: "deepseek", mode: "catalog" }));
|
||||
|
||||
expect(
|
||||
resolvePluginDiscoveryProvidersRuntime({
|
||||
config: {},
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
pluginMetadataSnapshot: {
|
||||
index: registry as never,
|
||||
manifestRegistry,
|
||||
},
|
||||
}),
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "deepseek",
|
||||
pluginId: "deepseek",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(mocks.loadPluginRegistrySnapshot).not.toHaveBeenCalled();
|
||||
expect(mocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled();
|
||||
expect(mocks.resolveDiscoveredProviderPluginIds).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
registry,
|
||||
manifestRegistry,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns static-only discovery entries for callers that explicitly request them", () => {
|
||||
const staticProvider = createProvider({ id: "deepseek", mode: "static" });
|
||||
mocks.loadSource.mockReturnValue(staticProvider);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry-installed.js";
|
||||
import type { PluginManifestRecord } from "./manifest-registry.js";
|
||||
import type { PluginMetadataSnapshot } from "./plugin-metadata-snapshot.js";
|
||||
import { loadPluginRegistrySnapshot } from "./plugin-registry.js";
|
||||
import { resolveDiscoveredProviderPluginIds } from "./providers.js";
|
||||
import { resolvePluginProviders } from "./providers.runtime.js";
|
||||
@@ -76,15 +77,18 @@ function resolveProviderDiscoveryEntryPlugins(params: {
|
||||
includeUntrustedWorkspacePlugins?: boolean;
|
||||
requireCompleteDiscoveryEntryCoverage?: boolean;
|
||||
discoveryEntriesOnly?: boolean;
|
||||
pluginMetadataSnapshot?: Pick<PluginMetadataSnapshot, "index" | "manifestRegistry">;
|
||||
}): ProviderDiscoveryEntryResult {
|
||||
const registry = loadPluginRegistrySnapshot(params);
|
||||
const manifestRegistry = loadPluginManifestRegistryForInstalledIndex({
|
||||
index: registry,
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
includeDisabled: true,
|
||||
});
|
||||
const registry = params.pluginMetadataSnapshot?.index ?? loadPluginRegistrySnapshot(params);
|
||||
const manifestRegistry =
|
||||
params.pluginMetadataSnapshot?.manifestRegistry ??
|
||||
loadPluginManifestRegistryForInstalledIndex({
|
||||
index: registry,
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
includeDisabled: true,
|
||||
});
|
||||
const pluginIds = resolveDiscoveredProviderPluginIds({
|
||||
...params,
|
||||
registry,
|
||||
@@ -144,6 +148,7 @@ export function resolvePluginDiscoveryProvidersRuntime(params: {
|
||||
includeUntrustedWorkspacePlugins?: boolean;
|
||||
requireCompleteDiscoveryEntryCoverage?: boolean;
|
||||
discoveryEntriesOnly?: boolean;
|
||||
pluginMetadataSnapshot?: Pick<PluginMetadataSnapshot, "index" | "manifestRegistry">;
|
||||
}): ProviderPlugin[] {
|
||||
const env = params.env ?? process.env;
|
||||
const entryResult = resolveProviderDiscoveryEntryPlugins(params);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { normalizeProviderId } from "../agents/model-selection.js";
|
||||
import type { ModelProviderConfig } from "../config/types.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type { PluginMetadataSnapshot } from "./plugin-metadata-snapshot.js";
|
||||
import {
|
||||
listPluginContributionIds,
|
||||
loadPluginRegistrySnapshot,
|
||||
@@ -42,6 +43,7 @@ export type ResolveRuntimePluginDiscoveryProvidersParams = {
|
||||
includeUntrustedWorkspacePlugins?: boolean;
|
||||
requireCompleteDiscoveryEntryCoverage?: boolean;
|
||||
discoveryEntriesOnly?: boolean;
|
||||
pluginMetadataSnapshot?: Pick<PluginMetadataSnapshot, "index" | "manifestRegistry">;
|
||||
};
|
||||
|
||||
export type ResolveInstalledPluginProviderContributionIdsParams = LoadPluginRegistryParams & {
|
||||
|
||||
Reference in New Issue
Block a user