mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-05 18:41:39 +00:00
* refactor(config): consolidate media model lists * refactor(config): unify memory configuration * refactor(config): consolidate TTS ownership * refactor(config): move typing policy to agents * refactor(config): retire product-level config surfaces * refactor(config): share scoped tool policy type * chore(config): refresh generated baselines * fix(config): honor agent typing overrides * fix(config): migrate sibling config consumers * refactor(infra): keep base64url decoder private * fix(config): strip invalid legacy TTS values * chore(config): refresh rebased baseline hash * fix(doctor): route legacy messages.tts.realtime voice to talk during tts move * refactor(config): polish final layout names * refactor(config): freeze retired tuning defaults * feat(config): add fast mode default symmetry * refactor(config): key agent entries by id * docs(config): update final layout reference * test(config): cover final layout migrations * chore(config): refresh final layout baselines * fix(config): align final layout runtime readers * fix(config): align remaining readers * fix(config): stabilize final layout migrations * fix(config): finalize config projection proof * fix(config): address final layout review * docs(release): preserve historical config names * fix(config): complete keyed agent migration * fix(config): close final migration gaps * fix(config): finish full-branch review * fix(config): complete runtime secret detection * fix(config): close final review findings * fix(config): finish canonical docs and heartbeat migration * fix(config): integrate latest main after rebase * refactor(env): isolate test-only controls * refactor(env): isolate build and development controls * refactor(env): collapse process identity indirection * refactor(env): remove duplicate config and temp aliases * docs(env): define the operator-facing allowlist * ci(env): ratchet production variable count * fix(env): remove stale provider helper import * fix(env): make ratchet sorting explicit * test(env): keep test seam in dead-code audit * test(env): cover ratchet growth and boundary; document surface budgets * docs(config): document tier-eval consolidations * docs(config): clarify speech preference ownership * test(memory): align retired tuning fixtures * refactor(memory): freeze engine heuristics * refactor(config): apply tier-eval tranche * refactor(tts): move persona shaping to providers * refactor(compaction): move prompt policy to providers * test(config): align hookified prompt fixtures * chore(deadcode): classify test-only exports * chore(github): remove unused spawn helper * chore(deadcode): classify queue diagnostics * chore(deadcode): remove unused lane snapshot export * chore(plugin-sdk): ratchet consolidated surface * fix(config): integrate latest main after rebase
228 lines
8.2 KiB
TypeScript
228 lines
8.2 KiB
TypeScript
/** Tests web provider fallback loading from bundled public artifacts. */
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
loadPluginMetadataSnapshot: vi.fn(),
|
|
resolvePluginMetadataSnapshot: vi.fn(),
|
|
resolveBundledExplicitWebSearchProvidersFromPublicArtifacts: vi.fn(() => null),
|
|
resolveBundledExplicitWebFetchProvidersFromPublicArtifacts: vi.fn(() => null),
|
|
loadBundledWebSearchProviderEntriesFromDir: vi.fn(),
|
|
loadBundledWebFetchProviderEntriesFromDir: vi.fn(),
|
|
readBundledDiscoveryMode: vi.fn<() => "compat" | "allowlist">(),
|
|
}));
|
|
|
|
vi.mock("./plugin-metadata-snapshot.js", () => ({
|
|
loadPluginMetadataSnapshot: mocks.loadPluginMetadataSnapshot,
|
|
resolvePluginMetadataSnapshot: mocks.resolvePluginMetadataSnapshot,
|
|
}));
|
|
|
|
vi.mock("./bundled-discovery-state.js", () => ({
|
|
readBundledDiscoveryMode: mocks.readBundledDiscoveryMode,
|
|
}));
|
|
|
|
vi.mock("./web-search-providers.shared.js", () => ({
|
|
resolveBundledWebSearchResolutionConfig: (params: { config?: unknown }) => ({
|
|
config: params.config,
|
|
}),
|
|
}));
|
|
|
|
vi.mock("./web-fetch-providers.shared.js", () => ({
|
|
resolveBundledWebFetchResolutionConfig: (params: { config?: unknown }) => ({
|
|
config: params.config,
|
|
}),
|
|
}));
|
|
|
|
vi.mock("./web-provider-public-artifacts.explicit.js", () => ({
|
|
resolveBundledExplicitWebSearchProvidersFromPublicArtifacts:
|
|
mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts,
|
|
resolveBundledExplicitWebFetchProvidersFromPublicArtifacts:
|
|
mocks.resolveBundledExplicitWebFetchProvidersFromPublicArtifacts,
|
|
loadBundledWebSearchProviderEntriesFromDir: mocks.loadBundledWebSearchProviderEntriesFromDir,
|
|
loadBundledWebFetchProviderEntriesFromDir: mocks.loadBundledWebFetchProviderEntriesFromDir,
|
|
}));
|
|
|
|
const {
|
|
resolveBundledWebFetchProvidersFromPublicArtifacts,
|
|
resolveBundledWebSearchProvidersFromPublicArtifacts,
|
|
} = await import("./web-provider-public-artifacts.js");
|
|
|
|
describe("web provider public artifact manifest fallback", () => {
|
|
beforeEach(() => {
|
|
mocks.readBundledDiscoveryMode.mockReturnValue("allowlist");
|
|
vi.clearAllMocks();
|
|
mocks.loadPluginMetadataSnapshot.mockReturnValue({
|
|
diagnostics: [],
|
|
plugins: [
|
|
{
|
|
id: "fallback-search",
|
|
origin: "bundled",
|
|
rootDir: "/tmp/fallback-search",
|
|
contracts: { webSearchProviders: ["fallback-search"] },
|
|
},
|
|
{
|
|
id: "fallback-fetch",
|
|
origin: "bundled",
|
|
rootDir: "/tmp/fallback-fetch",
|
|
contracts: { webFetchProviders: ["fallback-fetch"] },
|
|
},
|
|
],
|
|
});
|
|
mocks.resolvePluginMetadataSnapshot.mockImplementation(
|
|
(params?: { pluginMetadataSnapshot?: unknown }) =>
|
|
params?.pluginMetadataSnapshot ?? mocks.loadPluginMetadataSnapshot(params),
|
|
);
|
|
mocks.loadBundledWebSearchProviderEntriesFromDir.mockReturnValue([
|
|
{ id: "fallback-search", pluginId: "fallback-search" },
|
|
]);
|
|
mocks.loadBundledWebFetchProviderEntriesFromDir.mockReturnValue([
|
|
{ id: "fallback-fetch", pluginId: "fallback-fetch" },
|
|
]);
|
|
});
|
|
|
|
it("reuses the candidate manifest registry for bundled web-search artifact fallback", () => {
|
|
const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({ config: {} });
|
|
|
|
expect(providers).toEqual([{ id: "fallback-search", pluginId: "fallback-search" }]);
|
|
expect(mocks.loadPluginMetadataSnapshot).toHaveBeenCalledOnce();
|
|
expect(mocks.loadBundledWebSearchProviderEntriesFromDir).toHaveBeenCalledWith({
|
|
dirName: "fallback-search",
|
|
pluginId: "fallback-search",
|
|
});
|
|
});
|
|
|
|
it("reuses the candidate manifest registry for bundled web-fetch artifact fallback", () => {
|
|
const providers = resolveBundledWebFetchProvidersFromPublicArtifacts({ config: {} });
|
|
|
|
expect(providers).toEqual([{ id: "fallback-fetch", pluginId: "fallback-fetch" }]);
|
|
expect(mocks.loadPluginMetadataSnapshot).toHaveBeenCalledOnce();
|
|
expect(mocks.loadBundledWebFetchProviderEntriesFromDir).toHaveBeenCalledWith({
|
|
dirName: "fallback-fetch",
|
|
pluginId: "fallback-fetch",
|
|
});
|
|
});
|
|
|
|
it("keeps explicit bundled web-search public artifact candidates inside allowlist discovery", () => {
|
|
const resolveExplicitWebSearchProviders =
|
|
mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts as unknown as {
|
|
mockImplementation: (
|
|
implementation: (params: {
|
|
onlyPluginIds: readonly string[];
|
|
}) => { id: string; pluginId: string }[],
|
|
) => void;
|
|
};
|
|
resolveExplicitWebSearchProviders.mockImplementation((params) =>
|
|
params.onlyPluginIds.map((pluginId) => ({ id: pluginId, pluginId })),
|
|
);
|
|
|
|
const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({
|
|
config: {
|
|
plugins: {
|
|
allow: ["fallback-search"],
|
|
},
|
|
},
|
|
onlyPluginIds: ["blocked-search", "fallback-search"],
|
|
});
|
|
|
|
expect(providers).toEqual([{ id: "fallback-search", pluginId: "fallback-search" }]);
|
|
expect(mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts).toHaveBeenCalledWith({
|
|
onlyPluginIds: ["fallback-search"],
|
|
});
|
|
});
|
|
|
|
it("keeps deprecated bundledDiscovery compat discovery outside plugin allowlists", () => {
|
|
mocks.readBundledDiscoveryMode.mockReturnValue("compat");
|
|
const resolveExplicitWebSearchProviders =
|
|
mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts as unknown as {
|
|
mockImplementation: (
|
|
implementation: (params: {
|
|
onlyPluginIds: readonly string[];
|
|
}) => { id: string; pluginId: string }[],
|
|
) => void;
|
|
};
|
|
resolveExplicitWebSearchProviders.mockImplementation((params) =>
|
|
params.onlyPluginIds.map((pluginId) => ({ id: pluginId, pluginId })),
|
|
);
|
|
|
|
const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({
|
|
config: {
|
|
plugins: {
|
|
allow: ["some-other-plugin"],
|
|
},
|
|
},
|
|
onlyPluginIds: ["fallback-search"],
|
|
});
|
|
|
|
expect(providers).toEqual([{ id: "fallback-search", pluginId: "fallback-search" }]);
|
|
expect(mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts).toHaveBeenCalledWith({
|
|
onlyPluginIds: ["fallback-search"],
|
|
});
|
|
});
|
|
|
|
it("keeps manifest bundled web-fetch public artifact candidates inside allowlist discovery", () => {
|
|
mocks.loadPluginMetadataSnapshot.mockReturnValueOnce({
|
|
diagnostics: [],
|
|
plugins: [
|
|
{
|
|
id: "blocked-fetch",
|
|
origin: "bundled",
|
|
rootDir: "/tmp/blocked-fetch",
|
|
contracts: { webFetchProviders: ["blocked-fetch"] },
|
|
},
|
|
{
|
|
id: "fallback-fetch",
|
|
origin: "bundled",
|
|
rootDir: "/tmp/fallback-fetch",
|
|
contracts: { webFetchProviders: ["fallback-fetch"] },
|
|
},
|
|
],
|
|
});
|
|
|
|
const providers = resolveBundledWebFetchProvidersFromPublicArtifacts({
|
|
config: {
|
|
plugins: {
|
|
allow: ["fallback-fetch"],
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(providers).toEqual([{ id: "fallback-fetch", pluginId: "fallback-fetch" }]);
|
|
expect(mocks.loadBundledWebFetchProviderEntriesFromDir).toHaveBeenCalledOnce();
|
|
expect(mocks.loadBundledWebFetchProviderEntriesFromDir).toHaveBeenCalledWith({
|
|
dirName: "fallback-fetch",
|
|
pluginId: "fallback-fetch",
|
|
});
|
|
});
|
|
|
|
it("matches bundled web-search candidates through provider alias allowlist entries", () => {
|
|
mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts.mockReturnValueOnce(null);
|
|
mocks.loadPluginMetadataSnapshot.mockReturnValueOnce({
|
|
diagnostics: [],
|
|
plugins: [
|
|
{
|
|
id: "google",
|
|
origin: "bundled",
|
|
rootDir: "/tmp/google",
|
|
contracts: { webSearchProviders: ["gemini"] },
|
|
},
|
|
],
|
|
});
|
|
mocks.loadBundledWebSearchProviderEntriesFromDir.mockReturnValueOnce([
|
|
{ id: "gemini", pluginId: "google" },
|
|
]);
|
|
|
|
const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({
|
|
config: {
|
|
plugins: {
|
|
allow: ["google-gemini-cli"],
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(providers).toEqual([{ id: "gemini", pluginId: "google" }]);
|
|
expect(mocks.loadBundledWebSearchProviderEntriesFromDir).toHaveBeenCalledWith({
|
|
dirName: "google",
|
|
pluginId: "google",
|
|
});
|
|
});
|
|
});
|