@240xu/dsh-websearch 2.8.8 → 2.8.9
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/README.md +56 -25
- package/lib/backends/anthropic-like.js +11 -7
- package/lib/backends/brave.js +4 -2
- package/lib/backends/ddg.js +27 -11
- package/lib/backends/exa.js +3 -1
- package/lib/backends/firecrawl.js +127 -0
- package/lib/backends/mojeek.js +4 -2
- package/lib/backends/openai.js +12 -7
- package/lib/backends/parallel.js +2 -20
- package/lib/backends/searxng.js +36 -8
- package/lib/backends/serper.js +4 -2
- package/lib/backends/tavily.js +4 -2
- package/lib/backends/tinyfish.js +124 -0
- package/lib/breaker.js +25 -4
- package/lib/cache.js +30 -3
- package/lib/client.js +564 -182
- package/lib/health.js +20 -17
- package/lib/history.js +26 -36
- package/lib/index.js +157 -62
- package/lib/prompting.js +13 -3
- package/lib/provider.js +273 -78
- package/lib/rrf.js +9 -4
- package/lib/settings-api.js +44 -30
- package/lib/trust.js +6 -0
- package/lib/util/base-url.js +56 -0
- package/lib/util/egress-fetch.js +163 -12
- package/lib/util/failure-label.js +73 -12
- package/lib/util/log.js +5 -3
- package/lib/util/mcp-client.js +89 -40
- package/lib/util/namespace.js +28 -0
- package/lib/util/rank.js +6 -2
- package/lib/util/redact.js +49 -0
- package/lib/util/web-error.js +49 -0
- package/package.json +2 -2
package/lib/util/mcp-client.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
9
|
+
import { webErrorFromResponse } from "./web-error.js";
|
|
9
10
|
import { egressFetch } from "./egress-fetch.js";
|
|
10
11
|
import { describeError } from "./describe-error.js";
|
|
11
12
|
|
|
@@ -13,19 +14,30 @@ const UA = "dsh-websearch/2.3";
|
|
|
13
14
|
const PROTOCOL_VERSION = "2025-06-18";
|
|
14
15
|
const SESSION_TTL_MS = 10 * 60 * 1000; // 10 minutes
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
+
/** Session cache keyed by URL + stable auth-header digest. A session bound to
|
|
18
|
+
* one credential must never be reused after the key rotates (65 号 N4). */
|
|
17
19
|
const sessionCache = new Map();
|
|
20
|
+
function sessionCacheKey(url, extraHeaders) {
|
|
21
|
+
const auth = Object.entries(extraHeaders ?? {})
|
|
22
|
+
.filter(([k]) => /^(authorization|x-api-key|x-tinyfish-access-mode)$/i.test(k))
|
|
23
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
24
|
+
.map(([k, v]) => `${k.toLowerCase()}:${String(v)}`)
|
|
25
|
+
.join("|");
|
|
26
|
+
return `${url}\0${auth}`;
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
/**
|
|
20
30
|
* Ensure MCP session is initialized for the given URL.
|
|
21
31
|
* Performs the 3-step handshake if needed.
|
|
22
32
|
* @returns {Promise<string>} sessionId
|
|
23
33
|
*/
|
|
24
|
-
async function ensureSession(url, signal) {
|
|
34
|
+
async function ensureSession(url, signal, options = {}, extraHeaders = {}) {
|
|
25
35
|
const now = Date.now();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const key = sessionCacheKey(url, extraHeaders);
|
|
37
|
+
const cached = sessionCache.get(key);
|
|
38
|
+
|
|
39
|
+
// A rotated credential must not reuse a session bound to the old key.
|
|
40
|
+
if (!options.forceFreshSession && cached && (now - cached.initializedAt) < SESSION_TTL_MS) {
|
|
29
41
|
return cached.sessionId;
|
|
30
42
|
}
|
|
31
43
|
|
|
@@ -49,6 +61,7 @@ async function ensureSession(url, signal) {
|
|
|
49
61
|
"Content-Type": "application/json",
|
|
50
62
|
"Accept": "application/json, text/event-stream",
|
|
51
63
|
"User-Agent": UA,
|
|
64
|
+
...extraHeaders,
|
|
52
65
|
},
|
|
53
66
|
body: JSON.stringify(initBody),
|
|
54
67
|
signal,
|
|
@@ -64,7 +77,7 @@ async function ensureSession(url, signal) {
|
|
|
64
77
|
|
|
65
78
|
if (!initResponse.ok) {
|
|
66
79
|
const text = await initResponse.text().catch(() => "").then((tx) => tx.slice(0, 300));
|
|
67
|
-
throw
|
|
80
|
+
throw webErrorFromResponse(initResponse, text, "MCP initialize");
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
// Extract Mcp-Session-Id from response headers. Stateless MCP servers may
|
|
@@ -84,8 +97,10 @@ async function ensureSession(url, signal) {
|
|
|
84
97
|
method: "POST",
|
|
85
98
|
headers: {
|
|
86
99
|
"Content-Type": "application/json",
|
|
100
|
+
"MCP-Protocol-Version": PROTOCOL_VERSION,
|
|
87
101
|
...(sessionId ? { "Mcp-Session-Id": sessionId } : {}),
|
|
88
102
|
"User-Agent": UA,
|
|
103
|
+
...extraHeaders,
|
|
89
104
|
},
|
|
90
105
|
body: JSON.stringify(notifyBody),
|
|
91
106
|
signal,
|
|
@@ -100,7 +115,7 @@ async function ensureSession(url, signal) {
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
// Cache the session
|
|
103
|
-
sessionCache.set(
|
|
118
|
+
sessionCache.set(key, { sessionId, initializedAt: now });
|
|
104
119
|
return sessionId;
|
|
105
120
|
}
|
|
106
121
|
|
|
@@ -108,41 +123,62 @@ async function ensureSession(url, signal) {
|
|
|
108
123
|
* Parse MCP response envelope - handles both SSE and plain JSON.
|
|
109
124
|
* @returns {object} { id, result?, error? }
|
|
110
125
|
*/
|
|
111
|
-
function parseEnvelope(text, expectedId) {
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
export function parseEnvelope(text, expectedId) {
|
|
127
|
+
// Strip a UTF-8 BOM: some MCP servers prepend it to the first SSE line,
|
|
128
|
+
// which would otherwise make the leading `data:` invisible to the split.
|
|
129
|
+
const body = text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text;
|
|
130
|
+
// SSE: split into events on blank lines, parse each event's data lines, and
|
|
131
|
+
// pick the frame whose id matches the request and carries result/error.
|
|
132
|
+
// Joining all data lines across events produced "{...}{...}" and failed
|
|
133
|
+
// whenever a server pushed a notification before the actual response.
|
|
134
|
+
if (body.includes("data:")) {
|
|
135
|
+
for (const event of body.split(/\r?\n\r?\n/)) {
|
|
136
|
+
const joined = event
|
|
137
|
+
.split("\n")
|
|
138
|
+
.filter((l) => l.startsWith("data:"))
|
|
139
|
+
.map((l) => l.slice(5).trim())
|
|
140
|
+
.join("");
|
|
141
|
+
if (!joined) continue;
|
|
142
|
+
let frame;
|
|
143
|
+
try { frame = JSON.parse(joined); } catch { continue; }
|
|
144
|
+
const candidates = Array.isArray(frame) ? frame : [frame];
|
|
145
|
+
const match = candidates.find((r) => r && String(r.id) === String(expectedId)
|
|
146
|
+
&& (r.result !== undefined || r.error !== undefined));
|
|
147
|
+
if (match) return match;
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
|
-
|
|
128
|
-
//
|
|
150
|
+
|
|
151
|
+
// Plain JSON (single line or JSON-RPC batch). An explicit id that differs
|
|
152
|
+
// from the request is a different response and must not be handed to this
|
|
153
|
+
// caller; a missing id is tolerated for JSON-RPC notification-style replies.
|
|
154
|
+
let parsed;
|
|
129
155
|
try {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
156
|
+
parsed = JSON.parse(body);
|
|
157
|
+
} catch {
|
|
158
|
+
throw new WebError("MCP: failed to parse response envelope", "WEB_PROVIDER_ERROR");
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(parsed)) {
|
|
161
|
+
const match = parsed.find((r) => String(r.id) === String(expectedId));
|
|
162
|
+
if (match) return match;
|
|
163
|
+
// A batch that only carries frames for other requests must not hand its
|
|
164
|
+
// first frame to this caller; the object path already rejects that case.
|
|
165
|
+
if (parsed.some((r) => r && r.id !== undefined && String(r.id) !== String(expectedId))) {
|
|
166
|
+
throw new WebError("MCP: response id does not match the request", "WEB_PROVIDER_ERROR");
|
|
134
167
|
}
|
|
135
|
-
return parsed;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
168
|
+
return parsed[0];
|
|
169
|
+
}
|
|
170
|
+
if (parsed && typeof parsed === "object" && parsed.id !== undefined
|
|
171
|
+
&& String(parsed.id) !== String(expectedId)) {
|
|
172
|
+
throw new WebError("MCP: response id does not match the request", "WEB_PROVIDER_ERROR");
|
|
173
|
+
}
|
|
174
|
+
return parsed;
|
|
139
175
|
}
|
|
140
176
|
|
|
141
177
|
/**
|
|
142
178
|
* Invalidate cached session for a URL (call on 401/403/404).
|
|
143
179
|
*/
|
|
144
|
-
export function invalidateSession(url) {
|
|
145
|
-
sessionCache.delete(url);
|
|
180
|
+
export function invalidateSession(url, extraHeaders) {
|
|
181
|
+
sessionCache.delete(sessionCacheKey(url, extraHeaders));
|
|
146
182
|
}
|
|
147
183
|
|
|
148
184
|
/**
|
|
@@ -152,14 +188,25 @@ export function invalidateSession(url) {
|
|
|
152
188
|
* @param {object} args - Tool arguments
|
|
153
189
|
* @param {object} extraHeaders - Additional headers
|
|
154
190
|
* @param {AbortSignal} signal - Abort signal
|
|
191
|
+
* @param {{ skipInitialize?: boolean, forceFreshSession?: boolean }} [options] - Per-call transport options.
|
|
192
|
+
* `skipInitialize` sends a direct tools/call for stateless endpoints that
|
|
193
|
+
* do not need a session: TinyFish keyless, Exa, Parallel, Firecrawl (per
|
|
194
|
+
* the official websearch provider's single tools/call). `forceFreshSession`
|
|
195
|
+
* bypasses the URL-keyed session cache so a rotated credential cannot reuse
|
|
196
|
+
* a stale Mcp-Session-Id. Keyed calls use the handshake and a fresh session.
|
|
155
197
|
* @returns {Promise<object>} Parsed result envelope
|
|
156
198
|
*/
|
|
157
|
-
export async function mcpCall(url, toolName, args, extraHeaders = {}, signal) {
|
|
158
|
-
|
|
199
|
+
export async function mcpCall(url, toolName, args, extraHeaders = {}, signal, options = {}) {
|
|
200
|
+
// The session handshake is the default; stateless keyless servers accept a
|
|
201
|
+
// direct tools/call and skip it.
|
|
202
|
+
const sessionId = options.skipInitialize ? undefined : await ensureSession(url, signal, { forceFreshSession: options.forceFreshSession === true }, extraHeaders);
|
|
159
203
|
|
|
160
204
|
const callBody = {
|
|
161
205
|
jsonrpc: "2.0",
|
|
162
|
-
id
|
|
206
|
+
// initialize uses id 1. Keep every tools/call away from it so a shared
|
|
207
|
+
// SSE stream cannot hand an initialize-shaped frame to a search caller.
|
|
208
|
+
// Sessionful and stateless calls also use distinct ids from each other.
|
|
209
|
+
id: options.skipInitialize ? 2 : 3,
|
|
163
210
|
method: "tools/call",
|
|
164
211
|
params: { name: toolName, arguments: args },
|
|
165
212
|
};
|
|
@@ -171,6 +218,7 @@ export async function mcpCall(url, toolName, args, extraHeaders = {}, signal) {
|
|
|
171
218
|
headers: {
|
|
172
219
|
"Content-Type": "application/json",
|
|
173
220
|
"Accept": "application/json, text/event-stream",
|
|
221
|
+
"MCP-Protocol-Version": PROTOCOL_VERSION,
|
|
174
222
|
...(sessionId ? { "Mcp-Session-Id": sessionId } : {}),
|
|
175
223
|
"User-Agent": UA,
|
|
176
224
|
...extraHeaders,
|
|
@@ -187,15 +235,16 @@ export async function mcpCall(url, toolName, args, extraHeaders = {}, signal) {
|
|
|
187
235
|
// On 401/403/404 with a sessionful server, invalidate and retry once.
|
|
188
236
|
// Stateless servers (no session id) have no session to invalidate — fail loud.
|
|
189
237
|
if (sessionId && (response.status === 401 || response.status === 403 || response.status === 404)) {
|
|
190
|
-
invalidateSession(url);
|
|
191
|
-
// Retry with fresh session
|
|
192
|
-
const newSessionId = await ensureSession(url, signal);
|
|
238
|
+
invalidateSession(url, extraHeaders);
|
|
239
|
+
// Retry with fresh session, retaining the same credential headers.
|
|
240
|
+
const newSessionId = await ensureSession(url, signal, {}, extraHeaders);
|
|
193
241
|
try {
|
|
194
242
|
response = await egressFetch(url, {
|
|
195
243
|
method: "POST",
|
|
196
244
|
headers: {
|
|
197
245
|
"Content-Type": "application/json",
|
|
198
246
|
"Accept": "application/json, text/event-stream",
|
|
247
|
+
"MCP-Protocol-Version": PROTOCOL_VERSION,
|
|
199
248
|
...(newSessionId ? { "Mcp-Session-Id": newSessionId } : {}),
|
|
200
249
|
"User-Agent": UA,
|
|
201
250
|
...extraHeaders,
|
|
@@ -212,7 +261,7 @@ export async function mcpCall(url, toolName, args, extraHeaders = {}, signal) {
|
|
|
212
261
|
|
|
213
262
|
if (!response.ok) {
|
|
214
263
|
const text = await response.text().catch(() => "").then((tx) => tx.slice(0, 300));
|
|
215
|
-
throw
|
|
264
|
+
throw webErrorFromResponse(response, text, "MCP tools/call");
|
|
216
265
|
}
|
|
217
266
|
|
|
218
267
|
const text = await response.text();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locate this plugin's row in a settings `describe()` result.
|
|
3
|
+
*
|
|
4
|
+
* DSH 0.2.x keys namespaces by the profile entry id (`entry.options.id`),
|
|
5
|
+
* which for this plugin is `dsh-websearch`. Older hosts used the settings
|
|
6
|
+
* NAMESPACE `unified-search`. A host may expose several namespaces with
|
|
7
|
+
* generic field names such as `numResults`, so a shape-only match can select
|
|
8
|
+
* another plugin's row and make a write land in the wrong namespace.
|
|
9
|
+
* Prefer the exact ids; only fall back to the shape when neither id is
|
|
10
|
+
* present, and require at least two plugin-specific fields in that case.
|
|
11
|
+
*
|
|
12
|
+
* @param {unknown} rows - `settings.describe()` output.
|
|
13
|
+
* @returns {object|undefined} the matching row (with `.value`).
|
|
14
|
+
*/
|
|
15
|
+
const PROFILE_ID = "dsh-websearch";
|
|
16
|
+
const LEGACY_ID = "unified-search";
|
|
17
|
+
const SHAPE_FIELDS = ["searxngBaseURL", "enableFirecrawl", "firecrawlBaseURL", "enableTinyfish", "tinyfishBaseURL"];
|
|
18
|
+
|
|
19
|
+
export function findPluginRow(rows) {
|
|
20
|
+
if (!Array.isArray(rows)) return undefined;
|
|
21
|
+
const candidates = rows.filter((row) => row !== null && typeof row === "object" && typeof row.ns === "string");
|
|
22
|
+
const byId = candidates.find((row) => row.ns === PROFILE_ID)
|
|
23
|
+
?? candidates.find((row) => row.ns === LEGACY_ID);
|
|
24
|
+
if (byId) return byId;
|
|
25
|
+
return candidates.find((row) => row.value !== undefined && row.value !== null
|
|
26
|
+
&& typeof row.value === "object"
|
|
27
|
+
&& SHAPE_FIELDS.filter((key) => Object.hasOwn(row.value, key)).length >= 2);
|
|
28
|
+
}
|
package/lib/util/rank.js
CHANGED
|
@@ -16,8 +16,12 @@ export function tokenize(text) {
|
|
|
16
16
|
const tokens = new Set();
|
|
17
17
|
if (typeof text !== "string" || text.length === 0) return tokens;
|
|
18
18
|
const lower = text.toLowerCase();
|
|
19
|
-
// ASCII word runs of length >= 2
|
|
20
|
-
|
|
19
|
+
// ASCII word runs of length >= 2, plus every digit run: single digits are
|
|
20
|
+
// version discriminators ("GPT-4" vs "GPT-5"), and dropping them made
|
|
21
|
+
// url+title dedupe merge different versions and made rerank blind to them.
|
|
22
|
+
for (const w of lower.match(/[a-z0-9]+/g) ?? []) {
|
|
23
|
+
if (w.length >= 2 || /^\d+$/.test(w)) tokens.add(w);
|
|
24
|
+
}
|
|
21
25
|
// ... plus individual CJK chars (U+3400-U+9FFF common range covers CJK).
|
|
22
26
|
for (const ch of lower.match(/[\u3400-\u9fff]/g) ?? []) tokens.add(ch);
|
|
23
27
|
return tokens;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential redaction for text that leaves the plugin.
|
|
3
|
+
*
|
|
4
|
+
* Backends forward upstream error bodies, and providers sometimes echo the
|
|
5
|
+
* presented key back ("Incorrect API key provided: sk-live-…"). That text
|
|
6
|
+
* reaches the host log, the health/history payload, the telemetry line, and
|
|
7
|
+
* the model-visible failure message; none of those may carry a key.
|
|
8
|
+
*
|
|
9
|
+
* @module lib/util/redact
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Token shapes we can recognise without knowing the issuing vendor. */
|
|
13
|
+
const SECRET_PATTERNS = [
|
|
14
|
+
/sk-[A-Za-z0-9_-]{8,}/g,
|
|
15
|
+
/tvly-[A-Za-z0-9_-]{8,}/g,
|
|
16
|
+
/BSA[A-Za-z0-9_-]{16,}/g,
|
|
17
|
+
/exa_[A-Za-z0-9_-]{8,}/g,
|
|
18
|
+
/ghp_[A-Za-z0-9]{16,}/g,
|
|
19
|
+
/github_pat_[A-Za-z0-9_]{16,}/g,
|
|
20
|
+
/npm_[A-Za-z0-9]{16,}/g,
|
|
21
|
+
/cfut_[A-Za-z0-9_-]{16,}/g,
|
|
22
|
+
/Bearer\s+[A-Za-z0-9._-]{8,}/gi,
|
|
23
|
+
/(api[_-]?key|token|secret|password)\s*[=:]\s*["']?[^\s"',]{6,}/gi,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Replace token-like fragments with `[redacted]`.
|
|
28
|
+
*
|
|
29
|
+
* @param {unknown} value - text to sanitize; non-strings stringify first.
|
|
30
|
+
* @returns {string} redacted text.
|
|
31
|
+
*/
|
|
32
|
+
export function redact(value) {
|
|
33
|
+
let text = value instanceof Error ? value.message : String(value ?? "");
|
|
34
|
+
for (const pattern of SECRET_PATTERNS) text = text.replace(pattern, "[redacted]");
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Redact, collapse whitespace, and bound length for diagnostics/UI.
|
|
40
|
+
*
|
|
41
|
+
* @param {unknown} value - error or text to sanitize.
|
|
42
|
+
* @param {number} [maxChars] - maximum output length.
|
|
43
|
+
* @returns {string} safe, bounded text.
|
|
44
|
+
*/
|
|
45
|
+
export function sanitizeError(value, maxChars = 120) {
|
|
46
|
+
if (value === null || value === undefined) return "";
|
|
47
|
+
const text = redact(value).replace(/\s+/g, " ").trim();
|
|
48
|
+
return text.length > maxChars ? text.slice(0, maxChars) : text;
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// web-error.js — shared HTTP-failure constructor for the unified search
|
|
2
|
+
// provider. WebError (published dsh-web) extends HarnessError, whose
|
|
3
|
+
// constructor consumes only `cause`; extra fields must be assigned after
|
|
4
|
+
// construction. Keeping that in one place preserves `instanceof WebError`
|
|
5
|
+
// and the cause chain while giving the breaker machine-routable fields.
|
|
6
|
+
|
|
7
|
+
import { WebError } from "@deepseek-ai/dsh-web";
|
|
8
|
+
|
|
9
|
+
/** Canonical codes from dsh-llm/lib/types/error.js (RATE_LIMIT example, QUOTA_EXCEEDED_CODE). */
|
|
10
|
+
export const RATE_LIMIT_CODE = "RATE_LIMIT";
|
|
11
|
+
export const QUOTA_CODE = "QUOTA";
|
|
12
|
+
|
|
13
|
+
function headerValue(response, name) {
|
|
14
|
+
try { return response?.headers?.get?.(name) ?? undefined; } catch { return undefined; }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Build a WebError from a non-2xx Response. egressFetch already constructs a
|
|
19
|
+
* Response with status + full headers, so Retry-After is reachable here.
|
|
20
|
+
* @param {Response} response - the non-2xx response.
|
|
21
|
+
* @param {string} text - already-bounded upstream body.
|
|
22
|
+
* @param {string} label - backend name for the human-readable message.
|
|
23
|
+
* @param {{cause?: unknown}} [opts] - optional underlying error.
|
|
24
|
+
* @returns {WebError} error carrying status, retryAfter, rateLimited and code.
|
|
25
|
+
*/
|
|
26
|
+
export function webErrorFromResponse(response, text, label, opts = {}) {
|
|
27
|
+
const status = Number(response?.status) || 0;
|
|
28
|
+
const retryAfter = headerValue(response, "retry-after");
|
|
29
|
+
const rateLimited = status === 429;
|
|
30
|
+
// 402 is an explicit payment/quota signal. 403 is ambiguous (invalid key,
|
|
31
|
+
// forbidden, or quota) so it must NOT be classified as quota here; treating
|
|
32
|
+
// every 403 as quota would cool a backend for a bad credential.
|
|
33
|
+
const quota = status === 402;
|
|
34
|
+
const code = rateLimited ? RATE_LIMIT_CODE
|
|
35
|
+
: quota ? QUOTA_CODE
|
|
36
|
+
: "WEB_PROVIDER_ERROR";
|
|
37
|
+
const message = `${label} API error (HTTP ${status}): ${String(text ?? "").slice(0, 140)}`;
|
|
38
|
+
const err = new WebError(
|
|
39
|
+
message,
|
|
40
|
+
code,
|
|
41
|
+
opts.cause === undefined ? undefined : { cause: opts.cause },
|
|
42
|
+
);
|
|
43
|
+
// HarnessError `super(message, options)` only accepts cause; attach the rest.
|
|
44
|
+
err.status = status;
|
|
45
|
+
err.retryAfter = retryAfter;
|
|
46
|
+
err.rateLimited = rateLimited;
|
|
47
|
+
err.quota = quota;
|
|
48
|
+
return err;
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@240xu/dsh-websearch",
|
|
3
|
-
"version": "2.8.
|
|
4
|
-
"description": "Unified web search provider for DeepSeek Harness (ctx.web):
|
|
3
|
+
"version": "2.8.9",
|
|
4
|
+
"description": "Unified web search provider for DeepSeek Harness (ctx.web): 13 backends — Exa + Parallel + DDG + SearXNG (keyless), DeepSeek + Anthropic + OpenAI + Brave + Tavily + Serper + Mojeek (key-gated via Settings credentials), Firecrawl + TinyFish (metered keyless, opt-in). Registers provider id \"unified\" for zero-config web_search. 统一网页搜索聚合:13 后端并发扇出、去重合并。See CHANGELOG.md for version history.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|