

























@@ -174,6 +174,10 @@ vi.mock("../config/config.js", () => ({
174174mocks.setRuntimeConfigSnapshot as typeof import("../config/config.js").setRuntimeConfigSnapshot,
175175}));
176176177+vi.mock("./command-config-resolution.js", () => ({
178+resolveCommandConfigWithSecrets: mocks.resolveCommandConfigWithSecrets,
179+}));
180+177181vi.mock("../agents/agent-scope.js", () => ({
178182resolveDefaultAgentId: () => "main",
179183resolveAgentDir: () => "/tmp/agent",
@@ -2257,6 +2261,64 @@ describe("capability cli", () => {
22572261]);
22582262});
225922632264+it("resolves plugin web search SecretRefs before running infer web search", async () => {
2265+const unresolvedConfig = {
2266+tools: { web: { search: { provider: "tavily", enabled: true } } },
2267+plugins: {
2268+entries: {
2269+tavily: {
2270+config: {
2271+webSearch: {
2272+apiKey: { source: "env", provider: "default", id: "TAVILY_API_KEY" },
2273+},
2274+},
2275+},
2276+},
2277+},
2278+};
2279+const resolvedConfig = {
2280+ ...unresolvedConfig,
2281+plugins: {
2282+entries: {
2283+tavily: {
2284+config: {
2285+webSearch: {
2286+apiKey: "resolved-tavily-key",
2287+},
2288+},
2289+},
2290+},
2291+},
2292+};
2293+mocks.loadConfig.mockReturnValue(unresolvedConfig);
2294+mocks.resolveCommandConfigWithSecrets.mockResolvedValueOnce({
2295+ resolvedConfig,
2296+effectiveConfig: resolvedConfig,
2297+diagnostics: [],
2298+});
2299+const webSearchRuntime = await import("../web-search/runtime.js");
2300+vi.mocked(webSearchRuntime.runWebSearch).mockResolvedValueOnce({
2301+provider: "tavily",
2302+result: { results: [] },
2303+} as never);
2304+2305+await runRegisteredCli({
2306+register: registerCapabilityCli as (program: Command) => void,
2307+argv: ["infer", "web", "search", "--query", "ping", "--json"],
2308+});
2309+2310+expect(mocks.resolveCommandConfigWithSecrets).toHaveBeenCalledWith(
2311+expect.objectContaining({
2312+commandName: "infer web search",
2313+}),
2314+);
2315+expect(webSearchRuntime.runWebSearch).toHaveBeenCalledWith(
2316+expect.objectContaining({
2317+config: resolvedConfig,
2318+}),
2319+);
2320+});
2321+22602322it("surfaces available, configured, and selected for web providers", async () => {
22612323mocks.loadConfig.mockReturnValue({
22622324tools: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。