
















@@ -14,105 +14,107 @@ vi.mock("../plugin-sdk/telegram-command-config.js", () => ({
1414resolveTelegramCustomCommands: () => ({ commands: [], issues: [] }),
1515}));
161617-const getScopedWebSearchCredential = (key: string) => (search?: Record<string, unknown>) =>
18-(search?.[key] as { apiKey?: unknown } | undefined)?.apiKey;
19-const getConfiguredPluginWebSearchConfig =
20-(pluginId: string) => (config?: Record<string, unknown>) =>
21-(
22-config?.plugins as
23-| {
24-entries?: Record<
25-string,
26-{ config?: { webSearch?: { apiKey?: unknown; baseUrl?: unknown } } }
27->;
28-}
29-| undefined
30-)?.entries?.[pluginId]?.config?.webSearch;
31-const getConfiguredPluginWebSearchCredential =
32-(pluginId: string) => (config?: Record<string, unknown>) =>
33-getConfiguredPluginWebSearchConfig(pluginId)(config)?.apiKey;
34-35-const mockWebSearchProviders = [
36-{
37-id: "brave",
38-pluginId: "brave",
39-envVars: ["BRAVE_API_KEY"],
40-credentialPath: "plugins.entries.brave.config.webSearch.apiKey",
41-getCredentialValue: (search?: Record<string, unknown>) => search?.apiKey,
42-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("brave"),
43-},
44-{
45-id: "firecrawl",
46-pluginId: "firecrawl",
47-envVars: ["FIRECRAWL_API_KEY"],
48-credentialPath: "plugins.entries.firecrawl.config.webSearch.apiKey",
49-getCredentialValue: getScopedWebSearchCredential("firecrawl"),
50-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("firecrawl"),
51-},
52-{
53-id: "gemini",
54-pluginId: "google",
55-envVars: ["GEMINI_API_KEY"],
56-credentialPath: "plugins.entries.google.config.webSearch.apiKey",
57-getCredentialValue: getScopedWebSearchCredential("gemini"),
58-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("google"),
59-},
60-{
61-id: "grok",
62-pluginId: "xai",
63-envVars: ["XAI_API_KEY"],
64-credentialPath: "plugins.entries.xai.config.webSearch.apiKey",
65-getCredentialValue: getScopedWebSearchCredential("grok"),
66-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("xai"),
67-},
68-{
69-id: "kimi",
70-pluginId: "moonshot",
71-envVars: ["KIMI_API_KEY", "MOONSHOT_API_KEY"],
72-credentialPath: "plugins.entries.moonshot.config.webSearch.apiKey",
73-getCredentialValue: getScopedWebSearchCredential("kimi"),
74-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("moonshot"),
75-},
76-{
77-id: "minimax",
78-pluginId: "minimax",
79-envVars: [
80-"MINIMAX_CODE_PLAN_KEY",
81-"MINIMAX_CODING_API_KEY",
82-"MINIMAX_OAUTH_TOKEN",
83-"MINIMAX_API_KEY",
84-],
85-credentialPath: "plugins.entries.minimax.config.webSearch.apiKey",
86-getCredentialValue: getScopedWebSearchCredential("minimax"),
87-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("minimax"),
88-},
89-{
90-id: "perplexity",
91-pluginId: "perplexity",
92-envVars: ["PERPLEXITY_API_KEY", "OPENROUTER_API_KEY"],
93-credentialPath: "plugins.entries.perplexity.config.webSearch.apiKey",
94-getCredentialValue: getScopedWebSearchCredential("perplexity"),
95-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("perplexity"),
96-},
97-{
98-id: "searxng",
99-pluginId: "searxng",
100-envVars: ["SEARXNG_BASE_URL"],
101-credentialPath: "plugins.entries.searxng.config.webSearch.baseUrl",
102-getCredentialValue: (search?: Record<string, unknown>) =>
103-(search?.searxng as { baseUrl?: unknown } | undefined)?.baseUrl,
104-getConfiguredCredentialValue: (config?: Record<string, unknown>) =>
105-getConfiguredPluginWebSearchConfig("searxng")(config)?.baseUrl,
106-},
107-{
108-id: "tavily",
109-pluginId: "tavily",
110-envVars: ["TAVILY_API_KEY"],
111-credentialPath: "plugins.entries.tavily.config.webSearch.apiKey",
112-getCredentialValue: getScopedWebSearchCredential("tavily"),
113-getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("tavily"),
114-},
115-] as const;
17+const mockWebSearchProviders = vi.hoisted(() => {
18+const getScopedWebSearchCredential = (key: string) => (search?: Record<string, unknown>) =>
19+(search?.[key] as { apiKey?: unknown } | undefined)?.apiKey;
20+const getConfiguredPluginWebSearchConfig =
21+(pluginId: string) => (config?: Record<string, unknown>) =>
22+(
23+config?.plugins as
24+| {
25+entries?: Record<
26+string,
27+{ config?: { webSearch?: { apiKey?: unknown; baseUrl?: unknown } } }
28+>;
29+}
30+| undefined
31+)?.entries?.[pluginId]?.config?.webSearch;
32+const getConfiguredPluginWebSearchCredential =
33+(pluginId: string) => (config?: Record<string, unknown>) =>
34+getConfiguredPluginWebSearchConfig(pluginId)(config)?.apiKey;
35+36+return [
37+{
38+id: "brave",
39+pluginId: "brave",
40+envVars: ["BRAVE_API_KEY"],
41+credentialPath: "plugins.entries.brave.config.webSearch.apiKey",
42+getCredentialValue: (search?: Record<string, unknown>) => search?.apiKey,
43+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("brave"),
44+},
45+{
46+id: "firecrawl",
47+pluginId: "firecrawl",
48+envVars: ["FIRECRAWL_API_KEY"],
49+credentialPath: "plugins.entries.firecrawl.config.webSearch.apiKey",
50+getCredentialValue: getScopedWebSearchCredential("firecrawl"),
51+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("firecrawl"),
52+},
53+{
54+id: "gemini",
55+pluginId: "google",
56+envVars: ["GEMINI_API_KEY"],
57+credentialPath: "plugins.entries.google.config.webSearch.apiKey",
58+getCredentialValue: getScopedWebSearchCredential("gemini"),
59+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("google"),
60+},
61+{
62+id: "grok",
63+pluginId: "xai",
64+envVars: ["XAI_API_KEY"],
65+credentialPath: "plugins.entries.xai.config.webSearch.apiKey",
66+getCredentialValue: getScopedWebSearchCredential("grok"),
67+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("xai"),
68+},
69+{
70+id: "kimi",
71+pluginId: "moonshot",
72+envVars: ["KIMI_API_KEY", "MOONSHOT_API_KEY"],
73+credentialPath: "plugins.entries.moonshot.config.webSearch.apiKey",
74+getCredentialValue: getScopedWebSearchCredential("kimi"),
75+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("moonshot"),
76+},
77+{
78+id: "minimax",
79+pluginId: "minimax",
80+envVars: [
81+"MINIMAX_CODE_PLAN_KEY",
82+"MINIMAX_CODING_API_KEY",
83+"MINIMAX_OAUTH_TOKEN",
84+"MINIMAX_API_KEY",
85+],
86+credentialPath: "plugins.entries.minimax.config.webSearch.apiKey",
87+getCredentialValue: getScopedWebSearchCredential("minimax"),
88+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("minimax"),
89+},
90+{
91+id: "perplexity",
92+pluginId: "perplexity",
93+envVars: ["PERPLEXITY_API_KEY", "OPENROUTER_API_KEY"],
94+credentialPath: "plugins.entries.perplexity.config.webSearch.apiKey",
95+getCredentialValue: getScopedWebSearchCredential("perplexity"),
96+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("perplexity"),
97+},
98+{
99+id: "searxng",
100+pluginId: "searxng",
101+envVars: ["SEARXNG_BASE_URL"],
102+credentialPath: "plugins.entries.searxng.config.webSearch.baseUrl",
103+getCredentialValue: (search?: Record<string, unknown>) =>
104+(search?.searxng as { baseUrl?: unknown } | undefined)?.baseUrl,
105+getConfiguredCredentialValue: (config?: Record<string, unknown>) =>
106+getConfiguredPluginWebSearchConfig("searxng")(config)?.baseUrl,
107+},
108+{
109+id: "tavily",
110+pluginId: "tavily",
111+envVars: ["TAVILY_API_KEY"],
112+credentialPath: "plugins.entries.tavily.config.webSearch.apiKey",
113+getCredentialValue: getScopedWebSearchCredential("tavily"),
114+getConfiguredCredentialValue: getConfiguredPluginWebSearchCredential("tavily"),
115+},
116+] as const;
117+});
116118117119vi.mock("../plugins/web-search-providers.runtime.js", () => {
118120return {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。