惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
M
MIT News - Artificial intelligence
Vercel News
Vercel News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
L
LangChain Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
B
Blog
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(web-search): scope explicit provider runtime loading ...
vincentkoc · 2026-05-04 · via Recent Commits to openclaw:main

@@ -12,12 +12,39 @@ type TestPluginWebSearchConfig = {

1212

};

1313

};

141415-

const { resolvePluginWebSearchProvidersMock, resolveRuntimeWebSearchProvidersMock } = vi.hoisted(

16-

() => ({

17-

resolvePluginWebSearchProvidersMock: vi.fn<() => PluginWebSearchProviderEntry[]>(() => []),

18-

resolveRuntimeWebSearchProvidersMock: vi.fn<() => PluginWebSearchProviderEntry[]>(() => []),

19-

}),

20-

);

15+

type WebSearchProviderResolverParams = {

16+

bundledAllowlistCompat?: boolean;

17+

config?: OpenClawConfig;

18+

onlyPluginIds?: readonly string[];

19+

origin?: string;

20+

};

21+22+

type ManifestContractOwnerParams = {

23+

config?: OpenClawConfig;

24+

contract?: string;

25+

origin?: string;

26+

value?: string;

27+

};

28+29+

const {

30+

resolveManifestContractOwnerPluginIdMock,

31+

resolvePluginWebSearchProvidersMock,

32+

resolveRuntimeWebSearchProvidersMock,

33+

} = vi.hoisted(() => ({

34+

resolveManifestContractOwnerPluginIdMock: vi.fn(

35+

(_params: ManifestContractOwnerParams): string | undefined => undefined,

36+

),

37+

resolvePluginWebSearchProvidersMock: vi.fn(

38+

(_params?: WebSearchProviderResolverParams): PluginWebSearchProviderEntry[] => [],

39+

),

40+

resolveRuntimeWebSearchProvidersMock: vi.fn(

41+

(_params?: WebSearchProviderResolverParams): PluginWebSearchProviderEntry[] => [],

42+

),

43+

}));

44+45+

vi.mock("../plugins/plugin-registry-contributions.js", () => ({

46+

resolveManifestContractOwnerPluginId: resolveManifestContractOwnerPluginIdMock,

47+

}));

21482249

vi.mock("../plugins/web-search-providers.runtime.js", () => ({

2350

resolvePluginWebSearchProviders: resolvePluginWebSearchProvidersMock,

@@ -108,8 +135,10 @@ describe("web search runtime", () => {

108135

});

109136110137

beforeEach(() => {

138+

resolveManifestContractOwnerPluginIdMock.mockReset();

111139

resolvePluginWebSearchProvidersMock.mockReset();

112140

resolveRuntimeWebSearchProvidersMock.mockReset();

141+

resolveManifestContractOwnerPluginIdMock.mockReturnValue(undefined);

113142

resolvePluginWebSearchProvidersMock.mockReturnValue([]);

114143

resolveRuntimeWebSearchProvidersMock.mockReturnValue([]);

115144

});

@@ -533,6 +562,110 @@ describe("web search runtime", () => {

533562

).rejects.toThrow("google aborted");

534563

});

535564565+

it("scopes runtime provider loading to the configured bundled web_search provider", async () => {

566+

resolveManifestContractOwnerPluginIdMock.mockImplementation(({ value }) =>

567+

value === "duckduckgo" ? "duckduckgo" : undefined,

568+

);

569+

resolveRuntimeWebSearchProvidersMock.mockReturnValue([createDuckDuckGoSearchProvider()]);

570+571+

await expect(

572+

runWebSearch({

573+

config: {

574+

tools: {

575+

web: {

576+

search: {

577+

provider: "duckduckgo",

578+

},

579+

},

580+

},

581+

},

582+

args: { query: "configured-duck" },

583+

}),

584+

).resolves.toMatchObject({

585+

provider: "duckduckgo",

586+

});

587+588+

expect(resolveManifestContractOwnerPluginIdMock).toHaveBeenCalledWith(

589+

expect.objectContaining({

590+

contract: "webSearchProviders",

591+

origin: "bundled",

592+

value: "duckduckgo",

593+

}),

594+

);

595+

expect(resolveRuntimeWebSearchProvidersMock).toHaveBeenCalledWith(

596+

expect.objectContaining({

597+

onlyPluginIds: ["duckduckgo"],

598+

}),

599+

);

600+

});

601+602+

it("scopes runtime provider loading through manifest ownership when provider id differs from plugin id", async () => {

603+

resolveManifestContractOwnerPluginIdMock.mockImplementation(({ value }) =>

604+

value === "gemini" ? "google" : undefined,

605+

);

606+

resolveRuntimeWebSearchProvidersMock.mockReturnValue([

607+

createGoogleSearchProvider({

608+

id: "gemini",

609+

pluginId: "google",

610+

}),

611+

]);

612+613+

await expect(

614+

runWebSearch({

615+

config: {},

616+

runtimeWebSearch: {

617+

providerConfigured: "gemini",

618+

selectedProvider: "gemini",

619+

providerSource: "configured",

620+

diagnostics: [],

621+

},

622+

args: { query: "configured-gemini" },

623+

}),

624+

).resolves.toMatchObject({

625+

provider: "gemini",

626+

});

627+628+

expect(resolveRuntimeWebSearchProvidersMock).toHaveBeenCalledWith(

629+

expect.objectContaining({

630+

onlyPluginIds: ["google"],

631+

}),

632+

);

633+

});

634+635+

it("keeps runtime provider loading unscoped when configured provider ownership is unknown", async () => {

636+

resolveManifestContractOwnerPluginIdMock.mockReturnValue(undefined);

637+

resolveRuntimeWebSearchProvidersMock.mockReturnValue([

638+

createCustomSearchProvider({

639+

id: "external-search",

640+

pluginId: "external-search",

641+

requiresCredential: false,

642+

}),

643+

]);

644+645+

await expect(

646+

runWebSearch({

647+

config: {

648+

tools: {

649+

web: {

650+

search: {

651+

provider: "external-search",

652+

},

653+

},

654+

},

655+

},

656+

args: { query: "external-provider" },

657+

}),

658+

).resolves.toMatchObject({

659+

provider: "external-search",

660+

});

661+662+

expect(resolveRuntimeWebSearchProvidersMock).toHaveBeenCalledWith(

663+

expect.not.objectContaining({

664+

onlyPluginIds: expect.anything(),

665+

}),

666+

);

667+

});

668+536669

it("does not fall back when the caller explicitly selects a provider", async () => {

537670

resolveRuntimeWebSearchProvidersMock.mockReturnValue([

538671

createGoogleSearchProvider({