dsh-web-search-plugin 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/README.md +277 -146
- package/README.zh.md +351 -0
- package/assets/icon.svg +13 -0
- package/cordis.patch.yml +3 -1
- package/lib/brave.js +6 -4
- package/lib/client.js +315 -82
- package/lib/config.js +29 -0
- package/lib/deepseek.js +9 -6
- package/lib/index.js +32 -10
- package/lib/shared.js +1 -1
- package/lib/tavily.js +10 -8
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +10 -7
package/lib/config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Supplier-specific configuration names and their pre-prefix aliases. */
|
|
2
|
+
export const SUPPLIER_CONFIG_ALIASES = {
|
|
3
|
+
tavilyApiKey: "apiKey",
|
|
4
|
+
tavilyApiKeyEnv: "apiKeyEnv",
|
|
5
|
+
tavilyBaseURL: "baseURL",
|
|
6
|
+
tavilyMode: "mode",
|
|
7
|
+
tavilySearchDepth: "searchDepth",
|
|
8
|
+
tavilyIncludeAnswer: "includeAnswer",
|
|
9
|
+
tavilyTopic: "topic",
|
|
10
|
+
deepseekModel: "model",
|
|
11
|
+
deepseekApiVersion: "apiVersion",
|
|
12
|
+
deepseekMaxTokens: "maxTokens",
|
|
13
|
+
deepseekMaxUses: "maxUses",
|
|
14
|
+
braveCountry: "country",
|
|
15
|
+
braveSearchLang: "searchLang",
|
|
16
|
+
braveFreshness: "freshness",
|
|
17
|
+
braveProxy: "proxy",
|
|
18
|
+
scavioCountry: "country",
|
|
19
|
+
scavioSearchLang: "searchLang"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Explicit new values, including false and empty strings, override old names. */
|
|
23
|
+
export function resolveSupplierConfig(config) {
|
|
24
|
+
const resolved = { ...config };
|
|
25
|
+
for (const [field, legacy] of Object.entries(SUPPLIER_CONFIG_ALIASES)) {
|
|
26
|
+
resolved[field] = config[field] ?? config[legacy];
|
|
27
|
+
}
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
package/lib/deepseek.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @module dsh-web-search-plugin/deepseek
|
|
21
21
|
*/
|
|
22
|
+
import { resolveSupplierConfig } from "./config.js";
|
|
22
23
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
23
24
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
24
25
|
import { MAX_RESULTS_CAP, USER_AGENT, abortable, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
|
|
@@ -35,7 +36,7 @@ const DEEPSEEK_SEARCH_BASE_URL_ENV = "DEEPSEEK_SEARCH_BASE_URL";
|
|
|
35
36
|
* account quota on auxiliary search.
|
|
36
37
|
*/
|
|
37
38
|
const ACCOUNT_PROVIDER = "deepseek-account";
|
|
38
|
-
const DEFAULT_MODEL = "deepseek-
|
|
39
|
+
const DEFAULT_MODEL = "deepseek-flash";
|
|
39
40
|
const DEFAULT_API_VERSION = "2023-06-01";
|
|
40
41
|
const DEFAULT_MAX_TOKENS = 4096;
|
|
41
42
|
const DEFAULT_MAX_USES = 5;
|
|
@@ -123,7 +124,8 @@ export class DeepSeekSearchProvider {
|
|
|
123
124
|
role: "user",
|
|
124
125
|
content: [{ type: "text", text: `Perform a web search for the query: ${request.query}` }]
|
|
125
126
|
}],
|
|
126
|
-
tools: [{ type: "web_search_20250305", name: "web_search", max_uses: options.maxUses }]
|
|
127
|
+
tools: [{ type: "web_search_20250305", name: "web_search", max_uses: options.maxUses }],
|
|
128
|
+
thinking: { type: "disabled" }
|
|
127
129
|
};
|
|
128
130
|
// Record the exact secret-free request before it leaves; a throw here
|
|
129
131
|
// prevents dispatch rather than logging an unrecorded model input.
|
|
@@ -180,6 +182,7 @@ export class DeepSeekSearchProvider {
|
|
|
180
182
|
* @returns options for one search.
|
|
181
183
|
*/
|
|
182
184
|
export function resolveDeepseekOptions(ctx, config) {
|
|
185
|
+
config = resolveSupplierConfig(config);
|
|
183
186
|
return {
|
|
184
187
|
...resolveSecret(ctx, {
|
|
185
188
|
literal: config.deepseekApiKey,
|
|
@@ -195,10 +198,10 @@ export function resolveDeepseekOptions(ctx, config) {
|
|
|
195
198
|
ctx.get("agents")?.currentInitiator()?.session.append("web/deepseek-search-llm-request", request);
|
|
196
199
|
},
|
|
197
200
|
baseURL: config.deepseekBaseURL || launchEnvironmentOf(ctx).get(DEEPSEEK_SEARCH_BASE_URL_ENV)?.value || DEEPSEEK_DEFAULT_BASE_URL,
|
|
198
|
-
model: config.
|
|
199
|
-
apiVersion: config.
|
|
200
|
-
maxTokens: config.
|
|
201
|
-
maxUses: config.
|
|
201
|
+
model: config.deepseekModel ?? DEFAULT_MODEL,
|
|
202
|
+
apiVersion: config.deepseekApiVersion ?? DEFAULT_API_VERSION,
|
|
203
|
+
maxTokens: config.deepseekMaxTokens ?? DEFAULT_MAX_TOKENS,
|
|
204
|
+
maxUses: config.deepseekMaxUses ?? DEFAULT_MAX_USES,
|
|
202
205
|
maxResults: config.maxResults ?? 8
|
|
203
206
|
};
|
|
204
207
|
}
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @module dsh-web-search-plugin
|
|
22
22
|
*/
|
|
23
23
|
import z from "@deepseek-ai/schemastery";
|
|
24
|
+
import { SUPPLIER_CONFIG_ALIASES, resolveSupplierConfig } from "./config.js";
|
|
24
25
|
import { MAX_RESULTS_CAP } from "./shared.js";
|
|
25
26
|
import { TAVILY_DEFAULT_API_KEY_ENV, TAVILY_DEFAULT_BASE_URL, TavilySearchProvider, resolveTavilyOptions } from "./tavily.js";
|
|
26
27
|
import { BRAVE_DEFAULT_API_KEY_ENV, BRAVE_DEFAULT_BASE_URL, BraveSearchProvider, resolveBraveOptions } from "./brave.js";
|
|
@@ -48,6 +49,25 @@ const WEB_SEARCH_SETTINGS_NAMESPACE = "dsh-web-search-plugin";
|
|
|
48
49
|
* which makes these accessors the only way to read live configuration.
|
|
49
50
|
*/
|
|
50
51
|
const Config = z.object({
|
|
52
|
+
// No defaults here: absent prefixed fields must still inherit legacy values.
|
|
53
|
+
deepseekModel: z.string().volatile(),
|
|
54
|
+
deepseekApiVersion: z.string().volatile(),
|
|
55
|
+
deepseekMaxTokens: z.number().step(1).min(1).volatile(),
|
|
56
|
+
deepseekMaxUses: z.number().step(1).min(1).volatile(),
|
|
57
|
+
tavilyApiKey: z.string().role("secret").volatile(),
|
|
58
|
+
tavilyApiKeyEnv: z.string().role("credential-ref").volatile(),
|
|
59
|
+
tavilyBaseURL: z.string().volatile(),
|
|
60
|
+
tavilyMode: z.string().volatile(),
|
|
61
|
+
tavilySearchDepth: z.string().volatile(),
|
|
62
|
+
tavilyIncludeAnswer: z.boolean().volatile(),
|
|
63
|
+
tavilyTopic: z.string().volatile(),
|
|
64
|
+
braveCountry: z.string().volatile(),
|
|
65
|
+
braveSearchLang: z.string().volatile(),
|
|
66
|
+
braveFreshness: z.string().volatile(),
|
|
67
|
+
braveProxy: z.string().volatile(),
|
|
68
|
+
scavioCountry: z.string().volatile(),
|
|
69
|
+
scavioSearchLang: z.string().volatile(),
|
|
70
|
+
// Legacy fields remain accepted for existing profiles.
|
|
51
71
|
/** Active backend: `deepseek-official` (default), `tavily`, `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, or `firecrawl`. */
|
|
52
72
|
provider: z.string().default("deepseek-official").volatile(),
|
|
53
73
|
/** Tavily auth mode: `keyless` (default) or `keyed`. */
|
|
@@ -119,7 +139,7 @@ const Config = z.object({
|
|
|
119
139
|
/** DeepSeek Anthropic-compatible Messages base URL. `/messages` is appended. */
|
|
120
140
|
deepseekBaseURL: z.string().default("").volatile(),
|
|
121
141
|
/** Anthropic-format model name for the Messages request. */
|
|
122
|
-
model: z.string().default("deepseek-
|
|
142
|
+
model: z.string().default("deepseek-flash").volatile(),
|
|
123
143
|
/** `anthropic-version` header value. */
|
|
124
144
|
apiVersion: z.string().default("2023-06-01").volatile(),
|
|
125
145
|
/** Upper bound on generated tokens for the Messages request. */
|
|
@@ -169,6 +189,7 @@ class PluginSearchProvider {
|
|
|
169
189
|
|
|
170
190
|
/** Project one resolved section into options for each backend. */
|
|
171
191
|
function resolveOptions(ctx, config) {
|
|
192
|
+
config = resolveSupplierConfig(config);
|
|
172
193
|
const isBuiltIn = config.provider === "tavily" || config.provider === "brave" || config.provider === "deepseek-official" || BUILTIN_REST_IDS.includes(config.provider);
|
|
173
194
|
const provider = isBuiltIn ? config.provider : "deepseek-official";
|
|
174
195
|
const tavily = provider === "tavily" ? resolveTavilyOptions(ctx, config) : void 0;
|
|
@@ -176,8 +197,8 @@ function resolveOptions(ctx, config) {
|
|
|
176
197
|
// metadata row's default is not enough (self-hosted SearXNG, proxied
|
|
177
198
|
// providers, custom key refs).
|
|
178
199
|
const keySourceByProvider = {
|
|
179
|
-
brave: { literal: config.braveApiKey, envName: config.braveApiKeyEnv ?? BRAVE_DEFAULT_API_KEY_ENV, baseURL: config.braveBaseURL ?? "", proxy: config.
|
|
180
|
-
tavily: { literal: config.
|
|
200
|
+
brave: { literal: config.braveApiKey, envName: config.braveApiKeyEnv ?? BRAVE_DEFAULT_API_KEY_ENV, baseURL: config.braveBaseURL ?? "", proxy: config.braveProxy ?? "" },
|
|
201
|
+
tavily: { literal: config.tavilyApiKey, envName: config.tavilyApiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV, baseURL: tavily?.baseURL ?? "" },
|
|
181
202
|
serper: { literal: config.serperApiKey, envName: config.serperApiKeyEnv ?? "SERPER_API_KEY", baseURL: config.serperBaseURL ?? "" },
|
|
182
203
|
serpapi: { literal: config.serpapiApiKey, envName: config.serpapiApiKeyEnv ?? "SERPAPI_API_KEY", baseURL: config.serpapiBaseURL ?? "" },
|
|
183
204
|
exa: { literal: config.exaApiKey, envName: config.exaApiKeyEnv ?? "EXA_API_KEY", baseURL: config.exaBaseURL ?? "" },
|
|
@@ -186,12 +207,12 @@ function resolveOptions(ctx, config) {
|
|
|
186
207
|
firecrawl: { literal: config.firecrawlApiKey, envName: config.firecrawlApiKeyEnv ?? "FIRECRAWL_API_KEY", baseURL: config.firecrawlBaseURL ?? "" }
|
|
187
208
|
};
|
|
188
209
|
const settings = {
|
|
189
|
-
country: config.
|
|
190
|
-
searchLang: config.
|
|
191
|
-
freshness: config.
|
|
192
|
-
searchDepth: config.
|
|
193
|
-
topic: config.
|
|
194
|
-
includeAnswer: config.
|
|
210
|
+
country: provider === "scavio" ? config.scavioCountry : config.braveCountry,
|
|
211
|
+
searchLang: provider === "scavio" ? config.scavioSearchLang : config.braveSearchLang,
|
|
212
|
+
freshness: config.braveFreshness,
|
|
213
|
+
searchDepth: config.tavilySearchDepth,
|
|
214
|
+
topic: config.tavilyTopic,
|
|
215
|
+
includeAnswer: config.tavilyIncludeAnswer
|
|
195
216
|
};
|
|
196
217
|
const rest = {};
|
|
197
218
|
for (const providerId of provider === "deepseek-official" ? [] : [provider]) {
|
|
@@ -201,7 +222,7 @@ function resolveOptions(ctx, config) {
|
|
|
201
222
|
const resolved = resolveRestProvider(ctx, row, {
|
|
202
223
|
config,
|
|
203
224
|
settings,
|
|
204
|
-
keyed: providerId === "tavily" ? config.
|
|
225
|
+
keyed: providerId === "tavily" ? config.tavilyMode === "keyed" : false,
|
|
205
226
|
keySource: source
|
|
206
227
|
});
|
|
207
228
|
// Endpoint override: an explicit config baseURL wins over the row default.
|
|
@@ -262,6 +283,7 @@ function sendJson(res, statusCode, data) {
|
|
|
262
283
|
*/
|
|
263
284
|
function readSection(config) {
|
|
264
285
|
return {
|
|
286
|
+
...Object.fromEntries(Object.keys(SUPPLIER_CONFIG_ALIASES).map((field) => [field, config[field].get()])),
|
|
265
287
|
provider: config.provider.get(),
|
|
266
288
|
mode: config.mode.get(),
|
|
267
289
|
apiKey: config.apiKey.get(),
|
package/lib/shared.js
CHANGED
|
@@ -7,7 +7,7 @@ import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
|
7
7
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
8
8
|
|
|
9
9
|
/** Attribution header sent on every request. */
|
|
10
|
-
export const USER_AGENT = "dsh-web-search-plugin/0.
|
|
10
|
+
export const USER_AGENT = "dsh-web-search-plugin/0.6.0";
|
|
11
11
|
/** Shared cap: Tavily `max_results` and Brave `count` both accept 1..20. */
|
|
12
12
|
export const MAX_RESULTS_CAP = 20;
|
|
13
13
|
|
package/lib/tavily.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Tavily REST search backend (`POST {baseURL}/search`).
|
|
3
3
|
* @module dsh-web-search-plugin/tavily
|
|
4
4
|
*/
|
|
5
|
+
import { resolveSupplierConfig } from "./config.js";
|
|
5
6
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
6
7
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
7
8
|
import { MAX_RESULTS_CAP, USER_AGENT, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
|
|
@@ -64,7 +65,7 @@ export class TavilySearchProvider {
|
|
|
64
65
|
throwIfSearchAborted(signal);
|
|
65
66
|
let apiKey;
|
|
66
67
|
if (options.mode === "keyed") {
|
|
67
|
-
apiKey = await resolveApiKey(options, signal, `Tavily search has no API key for "${options.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV}"; store it through the credentials service, export it in the launching environment, or set a literal "
|
|
68
|
+
apiKey = await resolveApiKey(options, signal, `Tavily search has no API key for "${options.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV}"; store it through the credentials service, export it in the launching environment, or set a literal "tavilyApiKey" in the dsh-web-search-plugin config`);
|
|
68
69
|
throwIfSearchAborted(signal);
|
|
69
70
|
}
|
|
70
71
|
const endpoint = `${options.baseURL.replace(/\/+$/u, "")}/search`;
|
|
@@ -125,16 +126,17 @@ export class TavilySearchProvider {
|
|
|
125
126
|
|
|
126
127
|
/** Project the plugin section into Tavily backend options. */
|
|
127
128
|
export function resolveTavilyOptions(ctx, config) {
|
|
129
|
+
config = resolveSupplierConfig(config);
|
|
128
130
|
return {
|
|
129
|
-
mode: config.
|
|
131
|
+
mode: config.tavilyMode ?? "keyless",
|
|
130
132
|
...resolveSecret(ctx, {
|
|
131
|
-
literal: config.
|
|
132
|
-
envName: config.
|
|
133
|
+
literal: config.tavilyApiKey,
|
|
134
|
+
envName: config.tavilyApiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV
|
|
133
135
|
}),
|
|
134
|
-
baseURL: config.
|
|
136
|
+
baseURL: config.tavilyBaseURL || launchEnvironmentOf(ctx).get(TAVILY_BASE_URL_ENV)?.value || TAVILY_DEFAULT_BASE_URL,
|
|
135
137
|
maxResults: config.maxResults ?? 8,
|
|
136
|
-
searchDepth: config.
|
|
137
|
-
includeAnswer: config.
|
|
138
|
-
topic: config.
|
|
138
|
+
searchDepth: config.tavilySearchDepth ?? "basic",
|
|
139
|
+
includeAnswer: config.tavilyIncludeAnswer ?? true,
|
|
140
|
+
topic: config.tavilyTopic ?? "general"
|
|
139
141
|
};
|
|
140
142
|
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Web search",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Search engines and web retrieval in one page: DeepSeek Search API, Messages, eight third-party engines, local HTTP and optional DeepSeek Fetch API."
|
|
5
5
|
}
|
|
6
|
-
}
|
|
6
|
+
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "网页搜索",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "在一个页面独立配置搜索引擎与网页抓取:DeepSeek Search API、Messages、8 个第三方引擎、本地 HTTP 和可选 DeepSeek Fetch API。"
|
|
5
5
|
}
|
|
6
|
-
}
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-web-search-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Web search and retrieval settings for DeepSeek Harness: DeepSeek Search API, Messages, eight search backends, local HTTP and DeepSeek Fetch API",
|
|
5
|
+
"icon": "./assets/icon.svg",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"dsh-plugin",
|
|
7
8
|
"deepseek-harness",
|
|
@@ -17,11 +18,13 @@
|
|
|
17
18
|
"type": "module",
|
|
18
19
|
"main": "lib/index.js",
|
|
19
20
|
"files": [
|
|
21
|
+
"assets",
|
|
20
22
|
"lib",
|
|
21
23
|
"locale",
|
|
22
24
|
"cordis.patch.yml",
|
|
23
25
|
"CHANGELOG.md",
|
|
24
26
|
"README.md",
|
|
27
|
+
"README.zh.md",
|
|
25
28
|
"LICENSE"
|
|
26
29
|
],
|
|
27
30
|
"engines": {
|
|
@@ -53,17 +56,17 @@
|
|
|
53
56
|
}
|
|
54
57
|
},
|
|
55
58
|
"scripts": {
|
|
56
|
-
"check": "node --check lib/index.js && node --check lib/client.js && node --check lib/shared.js && node --check lib/providers.js && node --check lib/rest.js && node --check lib/tavily.js && node --check lib/brave.js && node --check lib/deepseek.js && node --check lib/usage.js",
|
|
59
|
+
"check": "node --check lib/config.js && node --check lib/index.js && node --check lib/client.js && node --check lib/shared.js && node --check lib/providers.js && node --check lib/rest.js && node --check lib/tavily.js && node --check lib/brave.js && node --check lib/deepseek.js && node --check lib/usage.js",
|
|
57
60
|
"test": "node --experimental-vm-modules --test test/*.test.mjs"
|
|
58
61
|
},
|
|
59
62
|
"dependencies": {
|
|
60
63
|
"undici": "^6.21.0"
|
|
61
64
|
},
|
|
62
65
|
"peerDependencies": {
|
|
63
|
-
"@deepseek-ai/dsh-web": "^0.2.0-rc.2",
|
|
64
|
-
"@deepseek-ai/dsh-credentials": "^0.2.0-rc.2",
|
|
65
|
-
"@deepseek-ai/dsh-settings": "^0.2.0-rc.2",
|
|
66
|
-
"@deepseek-ai/dsh-launch-environment": "^0.2.0-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-web": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-credentials": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-settings": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-launch-environment": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
67
70
|
"@deepseek-ai/schemastery": "~3.18.4",
|
|
68
71
|
"@deepseek-ai/cordis": "~4.0.4"
|
|
69
72
|
},
|