mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
fix(release): keep provider registry fallback behind loader
This commit is contained in:
@@ -1225,6 +1225,12 @@ export function resolveRuntimePluginRegistry(
|
||||
return loadOpenClawPlugins(options);
|
||||
}
|
||||
|
||||
export function getRuntimePluginRegistryForLoadOptions(
|
||||
options?: PluginLoadOptions,
|
||||
): PluginRegistry | undefined {
|
||||
return resolveRuntimePluginRegistry(options);
|
||||
}
|
||||
|
||||
export function resolvePluginRegistryLoadCacheKey(options: PluginLoadOptions = {}): string {
|
||||
return resolvePluginLoadCacheContext(options).cacheKey;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ import { resolveBundledPluginCompatibleActivationInputs } from "./activation-con
|
||||
import { resolveManifestActivationPluginIds } from "./activation-planner.js";
|
||||
import { getLoadedRuntimePluginRegistry } from "./active-runtime-registry.js";
|
||||
import {
|
||||
getRuntimePluginRegistryForLoadOptions,
|
||||
isPluginRegistryLoadInFlight,
|
||||
loadOpenClawPlugins,
|
||||
resolveRuntimePluginRegistry,
|
||||
type PluginLoadOptions,
|
||||
} from "./loader.js";
|
||||
import { hasExplicitPluginIdScope } from "./plugin-scope.js";
|
||||
@@ -312,13 +312,13 @@ export function resolvePluginProviders(params: {
|
||||
const loadState = resolveRuntimeProviderPluginLoadState(params, base);
|
||||
const registry =
|
||||
loadState.loadOptions.onlyPluginIds?.length === 0
|
||||
? resolveRuntimePluginRegistry(loadState.loadOptions)
|
||||
? undefined
|
||||
: (getLoadedRuntimePluginRegistry({
|
||||
env: base.env,
|
||||
loadOptions: loadState.loadOptions,
|
||||
workspaceDir: base.workspaceDir,
|
||||
requiredPluginIds: loadState.loadOptions.onlyPluginIds,
|
||||
}) ?? resolveRuntimePluginRegistry(loadState.loadOptions));
|
||||
}) ?? getRuntimePluginRegistryForLoadOptions(loadState.loadOptions));
|
||||
if (!registry) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import type { ProviderPlugin } from "./types.js";
|
||||
type ResolveRuntimePluginRegistry = typeof import("./loader.js").resolveRuntimePluginRegistry;
|
||||
type ResolveCompatibleRuntimePluginRegistry =
|
||||
typeof import("./loader.js").resolveCompatibleRuntimePluginRegistry;
|
||||
type GetRuntimePluginRegistryForLoadOptions =
|
||||
typeof import("./loader.js").getRuntimePluginRegistryForLoadOptions;
|
||||
type LoadOpenClawPlugins = typeof import("./loader.js").loadOpenClawPlugins;
|
||||
type IsPluginRegistryLoadInFlight = typeof import("./loader.js").isPluginRegistryLoadInFlight;
|
||||
type LoadPluginManifestRegistry =
|
||||
@@ -17,6 +19,7 @@ type ApplyPluginAutoEnable = typeof import("../config/plugin-auto-enable.js").ap
|
||||
type SetActivePluginRegistry = typeof import("./runtime.js").setActivePluginRegistry;
|
||||
|
||||
const resolveRuntimePluginRegistryMock = vi.fn<ResolveRuntimePluginRegistry>();
|
||||
const getRuntimePluginRegistryForLoadOptionsMock = vi.fn<GetRuntimePluginRegistryForLoadOptions>();
|
||||
const resolveCompatibleRuntimePluginRegistryMock = vi.fn<ResolveCompatibleRuntimePluginRegistry>();
|
||||
const loadOpenClawPluginsMock = vi.fn<LoadOpenClawPlugins>();
|
||||
const isPluginRegistryLoadInFlightMock = vi.fn<IsPluginRegistryLoadInFlight>((_) => false);
|
||||
@@ -375,6 +378,9 @@ describe("resolvePluginProviders", () => {
|
||||
resolveCompatibleRuntimePluginRegistry: (
|
||||
...args: Parameters<ResolveCompatibleRuntimePluginRegistry>
|
||||
) => resolveCompatibleRuntimePluginRegistryMock(...args),
|
||||
getRuntimePluginRegistryForLoadOptions: (
|
||||
...args: Parameters<GetRuntimePluginRegistryForLoadOptions>
|
||||
) => getRuntimePluginRegistryForLoadOptionsMock(...args),
|
||||
resolveRuntimePluginRegistry: (...args: Parameters<ResolveRuntimePluginRegistry>) =>
|
||||
resolveRuntimePluginRegistryMock(...args),
|
||||
}));
|
||||
@@ -446,6 +452,7 @@ describe("resolvePluginProviders", () => {
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(createEmptyPluginRegistry());
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
getRuntimePluginRegistryForLoadOptionsMock.mockReset();
|
||||
resolveCompatibleRuntimePluginRegistryMock.mockReset();
|
||||
loadOpenClawPluginsMock.mockReset();
|
||||
isPluginRegistryLoadInFlightMock.mockReset();
|
||||
@@ -458,6 +465,9 @@ describe("resolvePluginProviders", () => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.providers.push({ pluginId: "google", provider, source: "bundled" });
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue(registry);
|
||||
getRuntimePluginRegistryForLoadOptionsMock.mockImplementation((...args) =>
|
||||
resolveRuntimePluginRegistryMock(...args),
|
||||
);
|
||||
loadOpenClawPluginsMock.mockReturnValue(registry);
|
||||
loadPluginManifestRegistryMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockReset();
|
||||
@@ -1226,12 +1236,8 @@ describe("resolvePluginProviders", () => {
|
||||
});
|
||||
|
||||
expect(providers).toEqual([]);
|
||||
expect(resolveRuntimePluginRegistryMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: {},
|
||||
onlyPluginIds: [],
|
||||
}),
|
||||
);
|
||||
expect(resolveRuntimePluginRegistryMock).not.toHaveBeenCalled();
|
||||
expect(getRuntimePluginRegistryForLoadOptionsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not auto-activate workspace runtime owners by default", () => {
|
||||
@@ -1254,12 +1260,8 @@ describe("resolvePluginProviders", () => {
|
||||
});
|
||||
|
||||
expect(providers).toEqual([]);
|
||||
expect(resolveRuntimePluginRegistryMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: {},
|
||||
onlyPluginIds: [],
|
||||
}),
|
||||
);
|
||||
expect(resolveRuntimePluginRegistryMock).not.toHaveBeenCalled();
|
||||
expect(getRuntimePluginRegistryForLoadOptionsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps explicit provider requests scoped when runtime owner activation resolves nothing", () => {
|
||||
@@ -1285,16 +1287,8 @@ describe("resolvePluginProviders", () => {
|
||||
});
|
||||
|
||||
expect(providers).toEqual([]);
|
||||
expect(resolveRuntimePluginRegistryMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: {
|
||||
plugins: {
|
||||
allow: ["other-plugin"],
|
||||
},
|
||||
},
|
||||
onlyPluginIds: [],
|
||||
}),
|
||||
);
|
||||
expect(resolveRuntimePluginRegistryMock).not.toHaveBeenCalled();
|
||||
expect(getRuntimePluginRegistryForLoadOptionsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not keep explicitly trusted disabled workspace setup owners discoverable", () => {
|
||||
|
||||
Reference in New Issue
Block a user