dsh-web-discovery 1.0.0 → 1.1.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/README.md +97 -23
- package/lib/discovery.mjs +587 -91
- package/lib/discovery.mjs.map +4 -4
- package/lib/index.js +763 -129
- package/lib/index.js.map +4 -4
- package/package.json +9 -3
package/lib/discovery.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// src/host/discovery-port.ts
|
|
2
|
-
var DISCOVERY_ENGINES = ["
|
|
2
|
+
var DISCOVERY_ENGINES = ["serper", "browser39", "searxng"];
|
|
3
|
+
var MAX_DISCOVERY_MS = 45e3;
|
|
4
|
+
var MAX_BROWSER39_MS = 25e3;
|
|
5
|
+
var DEFAULT_LIMIT = 5;
|
|
6
|
+
var MAX_LIMIT = 50;
|
|
3
7
|
var DiscoveryEngineError = class extends Error {
|
|
4
8
|
constructor(code, message) {
|
|
5
9
|
super(message);
|
|
@@ -10,7 +14,6 @@ var DiscoveryEngineError = class extends Error {
|
|
|
10
14
|
|
|
11
15
|
// src/host/engines/searxng.ts
|
|
12
16
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
13
|
-
var DEFAULT_LIMIT = 10;
|
|
14
17
|
function asString(v) {
|
|
15
18
|
return typeof v === "string" && v.trim() !== "" ? v : void 0;
|
|
16
19
|
}
|
|
@@ -80,6 +83,461 @@ function createSearxngEngine(opts) {
|
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
// src/host/engines/serper.ts
|
|
87
|
+
var DEFAULT_SERPER_ENDPOINT = "https://google.serper.dev/search";
|
|
88
|
+
var DEFAULT_TIMEOUT_MS2 = 1e4;
|
|
89
|
+
function asString2(v) {
|
|
90
|
+
return typeof v === "string" && v.trim() !== "" ? v : void 0;
|
|
91
|
+
}
|
|
92
|
+
function mapSerperOrganic(row) {
|
|
93
|
+
const url = asString2(row.link);
|
|
94
|
+
if (!url) return null;
|
|
95
|
+
let isHttp = false;
|
|
96
|
+
try {
|
|
97
|
+
const u = new URL(url);
|
|
98
|
+
isHttp = u.protocol === "http:" || u.protocol === "https:";
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (!isHttp) return null;
|
|
103
|
+
const hit = { url };
|
|
104
|
+
const title = asString2(row.title);
|
|
105
|
+
if (title) hit.title = title;
|
|
106
|
+
const snippet = asString2(row.snippet);
|
|
107
|
+
if (snippet) hit.snippet = snippet;
|
|
108
|
+
return hit;
|
|
109
|
+
}
|
|
110
|
+
function createSerperEngine(opts) {
|
|
111
|
+
const apiKey = opts.apiKey.trim();
|
|
112
|
+
const endpoint = (opts.endpoint ?? DEFAULT_SERPER_ENDPOINT).replace(/\/+$/, "") || DEFAULT_SERPER_ENDPOINT;
|
|
113
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
114
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
115
|
+
return {
|
|
116
|
+
kind: "serper",
|
|
117
|
+
async search(query, searchOpts = {}) {
|
|
118
|
+
if (!apiKey) {
|
|
119
|
+
throw new DiscoveryEngineError("serper_auth", "serper API key is not configured");
|
|
120
|
+
}
|
|
121
|
+
const limit = searchOpts.limit ?? DEFAULT_LIMIT;
|
|
122
|
+
const res = await fetchImpl(endpoint, {
|
|
123
|
+
method: "POST",
|
|
124
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
125
|
+
headers: {
|
|
126
|
+
"X-API-KEY": apiKey,
|
|
127
|
+
"Content-Type": "application/json",
|
|
128
|
+
accept: "application/json"
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({ q: query, num: limit })
|
|
131
|
+
}).catch((error) => {
|
|
132
|
+
throw new DiscoveryEngineError(
|
|
133
|
+
"serper_unreachable",
|
|
134
|
+
`serper unreachable: ${error instanceof Error ? error.message : String(error)}`
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
if (res.status === 401 || res.status === 403) {
|
|
138
|
+
throw new DiscoveryEngineError(
|
|
139
|
+
"serper_auth",
|
|
140
|
+
`serper auth failed (HTTP ${res.status})`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (!res.ok) {
|
|
144
|
+
throw new DiscoveryEngineError("serper_failed", `serper HTTP ${res.status}`);
|
|
145
|
+
}
|
|
146
|
+
let body;
|
|
147
|
+
try {
|
|
148
|
+
body = await res.json();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
throw new DiscoveryEngineError(
|
|
151
|
+
"serper_failed",
|
|
152
|
+
`serper replied non-JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const organic = body?.organic;
|
|
156
|
+
if (!Array.isArray(organic)) {
|
|
157
|
+
throw new DiscoveryEngineError("serper_failed", "serper reply has no organic[]");
|
|
158
|
+
}
|
|
159
|
+
const hits = [];
|
|
160
|
+
for (const row of organic) {
|
|
161
|
+
const hit = mapSerperOrganic(row);
|
|
162
|
+
if (hit) hits.push(hit);
|
|
163
|
+
if (hits.length >= limit) break;
|
|
164
|
+
}
|
|
165
|
+
return hits;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/host/config.ts
|
|
171
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
172
|
+
import { createRequire } from "node:module";
|
|
173
|
+
import { dirname, join } from "node:path";
|
|
174
|
+
var CONFIG_DIR = "web-discovery";
|
|
175
|
+
var CONFIG_FILENAME = "config.json";
|
|
176
|
+
var DEFAULT_SEARXNG_ENDPOINT = "http://127.0.0.1:8888/searxng";
|
|
177
|
+
var DEFAULT_BROWSER39_BIN = "browser39";
|
|
178
|
+
var DEFAULT_RECEIPT_CHAR_BUDGET = 6e3;
|
|
179
|
+
var DEFAULT_CATEGORIZER_ENDPOINT = "";
|
|
180
|
+
var DEFAULT_CATEGORIZER_MODEL = "local-categorizer";
|
|
181
|
+
var DEFAULT_CATEGORIZER_API_KEY_ENV = "";
|
|
182
|
+
var DEFAULT_CATEGORIZER_TIMEOUT_MS = 5e3;
|
|
183
|
+
var DEFAULT_CONFIG = {
|
|
184
|
+
serperApiKey: "",
|
|
185
|
+
serperEndpoint: DEFAULT_SERPER_ENDPOINT,
|
|
186
|
+
searxngEndpoint: DEFAULT_SEARXNG_ENDPOINT,
|
|
187
|
+
browser39Bin: DEFAULT_BROWSER39_BIN,
|
|
188
|
+
receiptCharBudget: DEFAULT_RECEIPT_CHAR_BUDGET,
|
|
189
|
+
categorizerEndpoint: DEFAULT_CATEGORIZER_ENDPOINT,
|
|
190
|
+
categorizerModel: DEFAULT_CATEGORIZER_MODEL,
|
|
191
|
+
categorizerApiKeyEnv: DEFAULT_CATEGORIZER_API_KEY_ENV,
|
|
192
|
+
categorizerTimeoutMs: DEFAULT_CATEGORIZER_TIMEOUT_MS,
|
|
193
|
+
aliasWebSearch: false
|
|
194
|
+
};
|
|
195
|
+
function resolveBrowser39Bin(configured) {
|
|
196
|
+
const trimmed = configured.trim();
|
|
197
|
+
if (trimmed === "") return null;
|
|
198
|
+
if (trimmed !== DEFAULT_BROWSER39_BIN) {
|
|
199
|
+
return { cmd: trimmed, prefixArgs: [] };
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const require2 = createRequire(import.meta.url);
|
|
203
|
+
const pkgJson = require2.resolve("@aquintanar/browser39/package.json");
|
|
204
|
+
const binJs = join(dirname(pkgJson), "bin.js");
|
|
205
|
+
if (existsSync(binJs)) {
|
|
206
|
+
return { cmd: process.execPath, prefixArgs: [binJs] };
|
|
207
|
+
}
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
for (const dir of (process.env.PATH ?? "").split(":")) {
|
|
211
|
+
if (dir === "") continue;
|
|
212
|
+
const candidate = join(dir, "browser39");
|
|
213
|
+
try {
|
|
214
|
+
if (statSync(candidate).mode & 73) {
|
|
215
|
+
return { cmd: candidate, prefixArgs: [] };
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { cmd: "browser39", prefixArgs: [] };
|
|
221
|
+
}
|
|
222
|
+
var DiscoveryConfigError = class extends Error {
|
|
223
|
+
constructor(code, message) {
|
|
224
|
+
super(message);
|
|
225
|
+
this.code = code;
|
|
226
|
+
this.name = "DiscoveryConfigError";
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var FIELDS = [
|
|
230
|
+
{ key: "serperApiKey", kind: "string" },
|
|
231
|
+
{ key: "serperEndpoint", kind: "string" },
|
|
232
|
+
{ key: "searxngEndpoint", kind: "string" },
|
|
233
|
+
{ key: "browser39Bin", kind: "string" },
|
|
234
|
+
{ key: "categorizerEndpoint", kind: "string" },
|
|
235
|
+
{ key: "categorizerModel", kind: "string" },
|
|
236
|
+
{ key: "categorizerApiKeyEnv", kind: "string" },
|
|
237
|
+
{ key: "receiptCharBudget", kind: "number" },
|
|
238
|
+
{ key: "categorizerTimeoutMs", kind: "number" },
|
|
239
|
+
{ key: "aliasWebSearch", kind: "boolean" }
|
|
240
|
+
];
|
|
241
|
+
function configPath(cwd) {
|
|
242
|
+
return join(cwd, ".dsh", CONFIG_DIR, CONFIG_FILENAME);
|
|
243
|
+
}
|
|
244
|
+
function clampReceiptBudget(n) {
|
|
245
|
+
return Math.min(1e5, Math.max(500, Math.round(n)));
|
|
246
|
+
}
|
|
247
|
+
function clampTimeoutMs(n) {
|
|
248
|
+
return Math.min(6e4, Math.max(500, Math.round(n)));
|
|
249
|
+
}
|
|
250
|
+
function readDiscoveryConfig(cwd, env = process.env) {
|
|
251
|
+
let file = {};
|
|
252
|
+
const path = configPath(cwd);
|
|
253
|
+
try {
|
|
254
|
+
const raw = readFileSync(path, "utf8");
|
|
255
|
+
const parsed = JSON.parse(raw);
|
|
256
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
257
|
+
throw new DiscoveryConfigError("config_corrupt", `${path} must be a JSON object`);
|
|
258
|
+
}
|
|
259
|
+
file = parsed;
|
|
260
|
+
} catch (error) {
|
|
261
|
+
if (error.code === "ENOENT") {
|
|
262
|
+
} else if (error instanceof DiscoveryConfigError) {
|
|
263
|
+
throw error;
|
|
264
|
+
} else {
|
|
265
|
+
throw new DiscoveryConfigError(
|
|
266
|
+
"config_corrupt",
|
|
267
|
+
`${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const config = { ...DEFAULT_CONFIG };
|
|
272
|
+
for (const spec of FIELDS) {
|
|
273
|
+
if (!(spec.key in file)) continue;
|
|
274
|
+
const value = file[spec.key];
|
|
275
|
+
if (spec.kind === "string") {
|
|
276
|
+
if (typeof value !== "string") {
|
|
277
|
+
throw new DiscoveryConfigError("config_corrupt", `${path}: ${spec.key} must be a string`);
|
|
278
|
+
}
|
|
279
|
+
;
|
|
280
|
+
config[spec.key] = value;
|
|
281
|
+
} else if (spec.kind === "boolean") {
|
|
282
|
+
if (typeof value !== "boolean") {
|
|
283
|
+
throw new DiscoveryConfigError("config_corrupt", `${path}: ${spec.key} must be a boolean`);
|
|
284
|
+
}
|
|
285
|
+
config.aliasWebSearch = value;
|
|
286
|
+
} else {
|
|
287
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
288
|
+
throw new DiscoveryConfigError("config_corrupt", `${path}: ${spec.key} must be a finite number`);
|
|
289
|
+
}
|
|
290
|
+
if (spec.key === "categorizerTimeoutMs") config.categorizerTimeoutMs = clampTimeoutMs(value);
|
|
291
|
+
else config.receiptCharBudget = clampReceiptBudget(value);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const serperEndpoint = env.SERPER_ENDPOINT;
|
|
295
|
+
if (serperEndpoint !== void 0) config.serperEndpoint = serperEndpoint;
|
|
296
|
+
const endpoint = env.SEARXNG_ENDPOINT;
|
|
297
|
+
if (endpoint !== void 0) config.searxngEndpoint = endpoint;
|
|
298
|
+
const bin = env.BROWSER39_BIN;
|
|
299
|
+
if (bin !== void 0) config.browser39Bin = bin;
|
|
300
|
+
const budgetEnv = env.RECEIPT_CHAR_BUDGET;
|
|
301
|
+
if (budgetEnv !== void 0 && budgetEnv.trim() !== "") {
|
|
302
|
+
const n = Number(budgetEnv);
|
|
303
|
+
if (!Number.isFinite(n)) {
|
|
304
|
+
throw new DiscoveryConfigError("config_corrupt", `RECEIPT_CHAR_BUDGET must be a finite number (got ${JSON.stringify(budgetEnv)})`);
|
|
305
|
+
}
|
|
306
|
+
config.receiptCharBudget = clampReceiptBudget(n);
|
|
307
|
+
}
|
|
308
|
+
if (env.CATEGORIZER_ENDPOINT !== void 0) config.categorizerEndpoint = env.CATEGORIZER_ENDPOINT;
|
|
309
|
+
if (env.CATEGORIZER_MODEL !== void 0) config.categorizerModel = env.CATEGORIZER_MODEL;
|
|
310
|
+
if (env.CATEGORIZER_API_KEY_ENV !== void 0) config.categorizerApiKeyEnv = env.CATEGORIZER_API_KEY_ENV;
|
|
311
|
+
if (env.CATEGORIZER_TIMEOUT_MS !== void 0 && env.CATEGORIZER_TIMEOUT_MS.trim() !== "") {
|
|
312
|
+
const n = Number(env.CATEGORIZER_TIMEOUT_MS);
|
|
313
|
+
if (!Number.isFinite(n)) {
|
|
314
|
+
throw new DiscoveryConfigError("config_corrupt", `CATEGORIZER_TIMEOUT_MS must be a finite number`);
|
|
315
|
+
}
|
|
316
|
+
config.categorizerTimeoutMs = clampTimeoutMs(n);
|
|
317
|
+
}
|
|
318
|
+
if (env.ALIAS_WEB_SEARCH !== void 0) {
|
|
319
|
+
const v = env.ALIAS_WEB_SEARCH.trim().toLowerCase();
|
|
320
|
+
config.aliasWebSearch = v === "1" || v === "true" || v === "yes" || v === "on";
|
|
321
|
+
}
|
|
322
|
+
return config;
|
|
323
|
+
}
|
|
324
|
+
function resolveSerperApiKey(config, env = process.env) {
|
|
325
|
+
const fromEnv = (env.SERPER_API_KEY ?? "").trim();
|
|
326
|
+
if (fromEnv) return fromEnv;
|
|
327
|
+
return config.serperApiKey.trim();
|
|
328
|
+
}
|
|
329
|
+
function llmConfigFrom(config) {
|
|
330
|
+
if (!config.categorizerEndpoint.trim()) return null;
|
|
331
|
+
return {
|
|
332
|
+
endpoint: config.categorizerEndpoint.trim(),
|
|
333
|
+
model: config.categorizerModel.trim() || DEFAULT_CATEGORIZER_MODEL,
|
|
334
|
+
apiKeyEnv: config.categorizerApiKeyEnv.trim(),
|
|
335
|
+
timeoutMs: config.categorizerTimeoutMs
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function enginesForConfig(config, env = process.env) {
|
|
339
|
+
return {
|
|
340
|
+
serper: resolveSerperApiKey(config, env) !== "",
|
|
341
|
+
searxng: config.searxngEndpoint.trim() !== "",
|
|
342
|
+
browser39: config.browser39Bin.trim() !== ""
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/host/categorizer.ts
|
|
347
|
+
var LOGIN_RE = /login|signin|sign-in|auth|sso|paywall|subscribe|cookie/i;
|
|
348
|
+
var DOCS_HOST_RE = /^(docs|developer|dev|api|learn)\.|\.github\.io$/i;
|
|
349
|
+
var DOCS_PATH_RE = /\/docs?\/|\/reference\/|\/api\//i;
|
|
350
|
+
var FORUM_RE = /stackoverflow\.com|stackexchange\.com|reddit\.com|discourse\.|forum\./i;
|
|
351
|
+
var COMMERCIAL_RE = /\/pricing|\/cart|\/shop|amazon\.|ebay\./i;
|
|
352
|
+
var JUNK_RE = /pinterest\.|facebook\.com\/|twitter\.com\/|x\.com\//i;
|
|
353
|
+
function hostOf(url) {
|
|
354
|
+
try {
|
|
355
|
+
return new URL(url).hostname.toLowerCase();
|
|
356
|
+
} catch {
|
|
357
|
+
return "";
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function queryTokens(query) {
|
|
361
|
+
return query.toLowerCase().split(/[^a-z0-9]+/i).filter((t) => t.length >= 3);
|
|
362
|
+
}
|
|
363
|
+
function labelFor(host, url, flags) {
|
|
364
|
+
if (flags.includes("denylisted")) return "junk";
|
|
365
|
+
if (JUNK_RE.test(host) || JUNK_RE.test(url)) return "junk";
|
|
366
|
+
if (FORUM_RE.test(host)) return "forum";
|
|
367
|
+
if (COMMERCIAL_RE.test(url) || COMMERCIAL_RE.test(host)) return "commercial";
|
|
368
|
+
if (flags.includes("docs_cue") || host.endsWith(".org") || host === "github.com") return "primary";
|
|
369
|
+
if (host.endsWith(".edu") || host.endsWith(".gov")) return "reference";
|
|
370
|
+
return "reference";
|
|
371
|
+
}
|
|
372
|
+
var LABEL_RANK = {
|
|
373
|
+
primary: 0,
|
|
374
|
+
reference: 1,
|
|
375
|
+
forum: 2,
|
|
376
|
+
commercial: 3,
|
|
377
|
+
junk: 4
|
|
378
|
+
};
|
|
379
|
+
function createHeuristicCategorizer() {
|
|
380
|
+
return {
|
|
381
|
+
categorize(query, hits, opts = {}) {
|
|
382
|
+
const denylist = (opts.denylist ?? []).map((s) => s.toLowerCase());
|
|
383
|
+
const priors = (opts.priors ?? []).map((s) => s.toLowerCase());
|
|
384
|
+
const tokens = queryTokens(query);
|
|
385
|
+
const seenHosts = /* @__PURE__ */ new Set();
|
|
386
|
+
let dropped = 0;
|
|
387
|
+
const kept = [];
|
|
388
|
+
for (const hit of hits) {
|
|
389
|
+
const host = hostOf(hit.url);
|
|
390
|
+
const flags = [];
|
|
391
|
+
if (denylist.some((d) => host.includes(d) || hit.url.toLowerCase().includes(d))) {
|
|
392
|
+
dropped++;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (seenHosts.has(host)) flags.push("dup_host");
|
|
396
|
+
else seenHosts.add(host);
|
|
397
|
+
if (LOGIN_RE.test(hit.url) || LOGIN_RE.test(hit.title ?? "")) flags.push("login_cue");
|
|
398
|
+
if (DOCS_HOST_RE.test(host) || DOCS_PATH_RE.test(hit.url)) flags.push("docs_cue");
|
|
399
|
+
const blob = `${hit.title ?? ""} ${hit.snippet ?? ""}`.toLowerCase();
|
|
400
|
+
if (tokens.length > 0 && tokens.every((t) => !blob.includes(t) && !hit.url.toLowerCase().includes(t))) {
|
|
401
|
+
flags.push("token_miss");
|
|
402
|
+
}
|
|
403
|
+
const label = labelFor(host, hit.url, flags);
|
|
404
|
+
kept.push({
|
|
405
|
+
i: 0,
|
|
406
|
+
url: hit.url,
|
|
407
|
+
host,
|
|
408
|
+
...hit.title ? { title: hit.title } : {},
|
|
409
|
+
...hit.snippet ? { snippet: hit.snippet } : {},
|
|
410
|
+
flags,
|
|
411
|
+
label
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
kept.sort((a, b) => {
|
|
415
|
+
const fa = a.flags.length;
|
|
416
|
+
const fb = b.flags.length;
|
|
417
|
+
const pa = priors.some((p) => a.host.includes(p)) ? 0 : 1;
|
|
418
|
+
const pb = priors.some((p) => b.host.includes(p)) ? 0 : 1;
|
|
419
|
+
if (pa !== pb) return pa - pb;
|
|
420
|
+
if (LABEL_RANK[a.label] !== LABEL_RANK[b.label]) return LABEL_RANK[a.label] - LABEL_RANK[b.label];
|
|
421
|
+
if (fa !== fb) return fa - fb;
|
|
422
|
+
return 0;
|
|
423
|
+
});
|
|
424
|
+
return {
|
|
425
|
+
rows: kept.map((r, i) => ({ ...r, i: i + 1 })),
|
|
426
|
+
dropped,
|
|
427
|
+
categorizer: "heuristic"
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
var RECEIPT_CHAR_BUDGET = DEFAULT_RECEIPT_CHAR_BUDGET;
|
|
433
|
+
function fitReceiptChars(rows, budget = RECEIPT_CHAR_BUDGET) {
|
|
434
|
+
const out = [];
|
|
435
|
+
let used = 0;
|
|
436
|
+
for (const row of rows) {
|
|
437
|
+
const title = row.title?.slice(0, 120);
|
|
438
|
+
const snippet = row.snippet?.slice(0, 180);
|
|
439
|
+
const cost = (row.url?.length ?? 0) + (title?.length ?? 0) + (snippet?.length ?? 0) + 32;
|
|
440
|
+
if (used + cost > budget && out.length > 0) break;
|
|
441
|
+
out.push({
|
|
442
|
+
...row,
|
|
443
|
+
...title !== void 0 ? { title } : {},
|
|
444
|
+
...snippet !== void 0 ? { snippet } : {}
|
|
445
|
+
});
|
|
446
|
+
used += cost;
|
|
447
|
+
}
|
|
448
|
+
return out;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/host/llm-categorizer.ts
|
|
452
|
+
var LABELS = /* @__PURE__ */ new Set(["primary", "reference", "forum", "commercial", "junk"]);
|
|
453
|
+
function isLocalEndpoint(endpoint) {
|
|
454
|
+
try {
|
|
455
|
+
const u = new URL(endpoint);
|
|
456
|
+
return u.hostname === "127.0.0.1" || u.hostname === "localhost" || u.hostname === "::1";
|
|
457
|
+
} catch {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function modeForEndpoint(endpoint) {
|
|
462
|
+
return isLocalEndpoint(endpoint) ? "llm-local" : "llm-remote";
|
|
463
|
+
}
|
|
464
|
+
async function categorizeWithOptionalLlm(query, hits, llm, fetchImpl = fetch) {
|
|
465
|
+
const base = createHeuristicCategorizer().categorize(query, hits);
|
|
466
|
+
if (!llm || !llm.endpoint.trim()) {
|
|
467
|
+
return { ...base, categorizer: "heuristic" };
|
|
468
|
+
}
|
|
469
|
+
const apiKey = llm.apiKeyEnv ? process.env[llm.apiKeyEnv] ?? "" : "";
|
|
470
|
+
const url = llm.endpoint.replace(/\/$/, "") + "/chat/completions";
|
|
471
|
+
const payload = {
|
|
472
|
+
model: llm.model,
|
|
473
|
+
temperature: 0,
|
|
474
|
+
response_format: { type: "json_object" },
|
|
475
|
+
messages: [
|
|
476
|
+
{
|
|
477
|
+
role: "system",
|
|
478
|
+
content: 'Classify search hits. Reply JSON only: {"rows":[{"i":number,"label":"primary"|"reference"|"forum"|"commercial"|"junk"}]}. Use 1-based i matching input. Never invent URLs. Never fetch.'
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
role: "user",
|
|
482
|
+
content: JSON.stringify({
|
|
483
|
+
query,
|
|
484
|
+
rows: base.rows.slice(0, 8).map((r) => ({
|
|
485
|
+
i: r.i,
|
|
486
|
+
url: r.url,
|
|
487
|
+
host: r.host,
|
|
488
|
+
title: r.title ?? "",
|
|
489
|
+
snippet: r.snippet ?? ""
|
|
490
|
+
}))
|
|
491
|
+
})
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
};
|
|
495
|
+
try {
|
|
496
|
+
const ctrl = new AbortController();
|
|
497
|
+
const timer = setTimeout(() => ctrl.abort(), Math.max(500, llm.timeoutMs));
|
|
498
|
+
const headers = { "content-type": "application/json" };
|
|
499
|
+
if (apiKey) headers.authorization = `Bearer ${apiKey}`;
|
|
500
|
+
const res = await fetchImpl(url, {
|
|
501
|
+
method: "POST",
|
|
502
|
+
headers,
|
|
503
|
+
body: JSON.stringify(payload),
|
|
504
|
+
signal: ctrl.signal
|
|
505
|
+
});
|
|
506
|
+
clearTimeout(timer);
|
|
507
|
+
if (!res.ok) {
|
|
508
|
+
return { ...base, categorizer: "heuristic (llm unavailable)" };
|
|
509
|
+
}
|
|
510
|
+
const body = await res.json();
|
|
511
|
+
const text = body.choices?.[0]?.message?.content ?? "";
|
|
512
|
+
const parsed = JSON.parse(text);
|
|
513
|
+
if (!Array.isArray(parsed.rows)) {
|
|
514
|
+
return { ...base, categorizer: "heuristic (llm unavailable)" };
|
|
515
|
+
}
|
|
516
|
+
const byI = /* @__PURE__ */ new Map();
|
|
517
|
+
for (const row of parsed.rows) {
|
|
518
|
+
const i = typeof row.i === "number" ? row.i : Number(row.i);
|
|
519
|
+
const label = typeof row.label === "string" ? row.label : "";
|
|
520
|
+
if (Number.isFinite(i) && LABELS.has(label)) {
|
|
521
|
+
byI.set(i, label);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (byI.size === 0) {
|
|
525
|
+
return { ...base, categorizer: "heuristic (llm unavailable)" };
|
|
526
|
+
}
|
|
527
|
+
const rows = base.rows.map((r) => ({
|
|
528
|
+
...r,
|
|
529
|
+
label: byI.get(r.i) ?? r.label
|
|
530
|
+
}));
|
|
531
|
+
return {
|
|
532
|
+
rows,
|
|
533
|
+
dropped: base.dropped,
|
|
534
|
+
categorizer: modeForEndpoint(llm.endpoint)
|
|
535
|
+
};
|
|
536
|
+
} catch {
|
|
537
|
+
return { ...base, categorizer: "heuristic (llm unavailable)" };
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
83
541
|
// src/host/engines/browser39.ts
|
|
84
542
|
import { execFile } from "node:child_process";
|
|
85
543
|
function defaultRunner(timeoutMs) {
|
|
@@ -104,8 +562,7 @@ function defaultRunner(timeoutMs) {
|
|
|
104
562
|
);
|
|
105
563
|
});
|
|
106
564
|
}
|
|
107
|
-
var
|
|
108
|
-
var DEFAULT_LIMIT2 = 10;
|
|
565
|
+
var DEFAULT_TIMEOUT_MS3 = 25e3;
|
|
109
566
|
var SERP_CHROME_HOST = "duckduckgo.com";
|
|
110
567
|
function unwrapSerpHref(href) {
|
|
111
568
|
let u;
|
|
@@ -149,15 +606,16 @@ function mapSerpPage(page, limit) {
|
|
|
149
606
|
return hits;
|
|
150
607
|
}
|
|
151
608
|
function createBrowser39Engine(opts) {
|
|
152
|
-
const timeoutMs = opts.timeoutMs ??
|
|
609
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS3;
|
|
153
610
|
const runner = opts.runner ?? defaultRunner(timeoutMs);
|
|
611
|
+
const prefix = opts.binPrefixArgs ?? [];
|
|
154
612
|
return {
|
|
155
613
|
kind: "browser39",
|
|
156
614
|
async search(query, searchOpts = {}) {
|
|
157
|
-
const limit = searchOpts.limit ??
|
|
615
|
+
const limit = searchOpts.limit ?? DEFAULT_LIMIT;
|
|
158
616
|
let result;
|
|
159
617
|
try {
|
|
160
|
-
result = await runner(opts.bin, ["search", query, "--output", "json", "--no-persist"]);
|
|
618
|
+
result = await runner(opts.bin, [...prefix, "search", query, "--output", "json", "--no-persist"]);
|
|
161
619
|
} catch (error) {
|
|
162
620
|
throw new DiscoveryEngineError(
|
|
163
621
|
"browser39_missing",
|
|
@@ -197,45 +655,95 @@ function createBrowser39Engine(opts) {
|
|
|
197
655
|
}
|
|
198
656
|
|
|
199
657
|
// src/host/discovery-tool.ts
|
|
658
|
+
function clampLimit(limit) {
|
|
659
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) return DEFAULT_LIMIT;
|
|
660
|
+
return Math.min(MAX_LIMIT, Math.max(1, Math.round(limit)));
|
|
661
|
+
}
|
|
662
|
+
var FALL_THROUGH_CODES = /* @__PURE__ */ new Set([
|
|
663
|
+
"serper_unreachable",
|
|
664
|
+
"serper_auth",
|
|
665
|
+
"serper_failed",
|
|
666
|
+
"searxng_unreachable",
|
|
667
|
+
"browser39_missing",
|
|
668
|
+
"browser39_blocked",
|
|
669
|
+
"budget_exhausted"
|
|
670
|
+
]);
|
|
200
671
|
function engineReason(kind, error) {
|
|
201
672
|
switch (error.code) {
|
|
673
|
+
case "serper_unreachable":
|
|
674
|
+
case "serper_auth":
|
|
675
|
+
case "serper_failed":
|
|
676
|
+
return `serper: ${error.message}`;
|
|
202
677
|
case "searxng_unreachable":
|
|
203
678
|
return "searxng not running at the configured endpoint";
|
|
204
679
|
case "browser39_missing":
|
|
205
680
|
return "browser39 search binary not found";
|
|
206
681
|
case "browser39_blocked":
|
|
207
682
|
return "browser39 blocked by the search engine (bot challenge / rate limit)";
|
|
683
|
+
case "budget_exhausted":
|
|
684
|
+
return "discovery wall-clock budget exhausted";
|
|
208
685
|
default:
|
|
209
686
|
return `${kind} engine error (${error.code})`;
|
|
210
687
|
}
|
|
211
688
|
}
|
|
689
|
+
function absentReason(kind) {
|
|
690
|
+
switch (kind) {
|
|
691
|
+
case "serper":
|
|
692
|
+
return "serper key not set";
|
|
693
|
+
case "searxng":
|
|
694
|
+
return "searxng endpoint not configured";
|
|
695
|
+
case "browser39":
|
|
696
|
+
return "browser39 search not configured";
|
|
697
|
+
}
|
|
698
|
+
}
|
|
212
699
|
async function runDiscoverySearch(deps, rawQuery, opts = {}) {
|
|
213
700
|
const query = rawQuery.trim();
|
|
214
701
|
if (!query) {
|
|
215
702
|
return { ok: false, error: "query_required: pass a non-empty search query" };
|
|
216
703
|
}
|
|
217
|
-
const limit = opts.limit
|
|
704
|
+
const limit = clampLimit(opts.limit);
|
|
705
|
+
const now = deps.nowMs ?? (() => Date.now());
|
|
706
|
+
const started = now();
|
|
707
|
+
const maxTotal = deps.maxDiscoveryMs ?? MAX_DISCOVERY_MS;
|
|
708
|
+
const maxB39 = deps.maxBrowser39Ms ?? MAX_BROWSER39_MS;
|
|
218
709
|
const candidates = opts.engine ? [opts.engine] : DISCOVERY_ENGINES.filter((k) => deps.engines[k] !== void 0);
|
|
219
710
|
if (candidates.length === 0) {
|
|
220
711
|
return {
|
|
221
712
|
ok: false,
|
|
222
|
-
error: "no_engine: no discovery engines configured (searxng endpoint not configured; browser39 search not configured) \u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)"
|
|
713
|
+
error: "no_engine: no discovery engines configured (serper key not set; searxng endpoint not configured; browser39 search not configured) \u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)"
|
|
223
714
|
};
|
|
224
715
|
}
|
|
225
716
|
const failures = [];
|
|
226
717
|
for (const kind of candidates) {
|
|
718
|
+
const elapsed = now() - started;
|
|
719
|
+
if (elapsed >= maxTotal) {
|
|
720
|
+
return {
|
|
721
|
+
ok: false,
|
|
722
|
+
error: `budget_exhausted: discovery exceeded ${maxTotal}ms across engines (${failures.join("; ") || "no engine answered in time"})`
|
|
723
|
+
};
|
|
724
|
+
}
|
|
227
725
|
const engine = deps.engines[kind];
|
|
228
726
|
if (!engine) {
|
|
229
|
-
failures.push(
|
|
230
|
-
|
|
231
|
-
|
|
727
|
+
failures.push(absentReason(kind));
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
if (kind === "browser39" && elapsed >= maxB39) {
|
|
731
|
+
failures.push(`browser39 skipped (already ${elapsed}ms \u2265 ${maxB39}ms soft cap)`);
|
|
232
732
|
continue;
|
|
233
733
|
}
|
|
234
734
|
try {
|
|
235
735
|
const urls = await engine.search(query, { limit });
|
|
236
|
-
|
|
736
|
+
const result = {
|
|
737
|
+
ok: true,
|
|
738
|
+
query,
|
|
739
|
+
engine: engine.kind,
|
|
740
|
+
count: urls.length,
|
|
741
|
+
urls
|
|
742
|
+
};
|
|
743
|
+
if (failures.length > 0) result.notes = [...failures];
|
|
744
|
+
return result;
|
|
237
745
|
} catch (error) {
|
|
238
|
-
if (error instanceof DiscoveryEngineError && (error.code
|
|
746
|
+
if (error instanceof DiscoveryEngineError && FALL_THROUGH_CODES.has(error.code)) {
|
|
239
747
|
failures.push(engineReason(engine.kind, error));
|
|
240
748
|
continue;
|
|
241
749
|
}
|
|
@@ -251,10 +759,48 @@ async function runDiscoverySearch(deps, rawQuery, opts = {}) {
|
|
|
251
759
|
const reason = candidates.length === 1 && opts.engine ? `${opts.engine}: ${failures[0] ?? "unavailable"}` : failures.join("; ");
|
|
252
760
|
return { ok: false, error: `no_engine: ${reason} \u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)` };
|
|
253
761
|
}
|
|
762
|
+
function enginesFromConfig(config, opts = {}) {
|
|
763
|
+
const env = opts.env ?? process.env;
|
|
764
|
+
const presence = enginesForConfig(config, env);
|
|
765
|
+
const engines = {};
|
|
766
|
+
if (presence.serper) {
|
|
767
|
+
const apiKey = resolveSerperApiKey(config, env);
|
|
768
|
+
engines.serper = createSerperEngine({
|
|
769
|
+
apiKey,
|
|
770
|
+
endpoint: config.serperEndpoint,
|
|
771
|
+
...opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
if (presence.searxng) {
|
|
775
|
+
engines.searxng = createSearxngEngine({
|
|
776
|
+
endpoint: config.searxngEndpoint,
|
|
777
|
+
...opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
if (presence.browser39) {
|
|
781
|
+
const inv = resolveBrowser39Bin(config.browser39Bin);
|
|
782
|
+
if (inv) engines.browser39 = createBrowser39Engine({ bin: inv.cmd, binPrefixArgs: inv.prefixArgs });
|
|
783
|
+
}
|
|
784
|
+
return engines;
|
|
785
|
+
}
|
|
786
|
+
function createDiscoveryPort(cwd) {
|
|
787
|
+
const config = readDiscoveryConfig(cwd);
|
|
788
|
+
const engines = enginesFromConfig(config);
|
|
789
|
+
return {
|
|
790
|
+
async search(query, opts) {
|
|
791
|
+
const result = await runDiscoverySearch({ engines }, query, opts);
|
|
792
|
+
if (!result.ok) {
|
|
793
|
+
const code = result.error.startsWith("no_engine:") ? "no_engine" : result.error.startsWith("budget_exhausted:") ? "budget_exhausted" : "browser39_failed";
|
|
794
|
+
throw new DiscoveryEngineError(code, result.error);
|
|
795
|
+
}
|
|
796
|
+
return result.urls;
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
254
800
|
|
|
255
801
|
// src/host/discovery-store.ts
|
|
256
|
-
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
257
|
-
import { dirname, join } from "node:path";
|
|
802
|
+
import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
803
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
258
804
|
var DISCOVERY_FILENAME = "discovery.json";
|
|
259
805
|
var DiscoveryStoreError = class extends Error {
|
|
260
806
|
constructor(code, message) {
|
|
@@ -264,13 +810,13 @@ var DiscoveryStoreError = class extends Error {
|
|
|
264
810
|
}
|
|
265
811
|
};
|
|
266
812
|
function discoveryPath(missionDir) {
|
|
267
|
-
return
|
|
813
|
+
return join2(missionDir, DISCOVERY_FILENAME);
|
|
268
814
|
}
|
|
269
815
|
function readDiscoveryFile(missionDir) {
|
|
270
816
|
const path = discoveryPath(missionDir);
|
|
271
817
|
let raw;
|
|
272
818
|
try {
|
|
273
|
-
raw =
|
|
819
|
+
raw = readFileSync2(path, "utf8");
|
|
274
820
|
} catch (error) {
|
|
275
821
|
if (error.code === "ENOENT") return null;
|
|
276
822
|
throw new DiscoveryStoreError("discovery_unwritable", `cannot read ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -301,7 +847,7 @@ function recordDiscovery(missionDir, hits, via) {
|
|
|
301
847
|
file.updated_at = at;
|
|
302
848
|
const path = discoveryPath(missionDir);
|
|
303
849
|
const tmp = `${path}.tmp-${process.pid}`;
|
|
304
|
-
mkdirSync(
|
|
850
|
+
mkdirSync(dirname2(path), { recursive: true });
|
|
305
851
|
try {
|
|
306
852
|
writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
|
|
307
853
|
renameSync(tmp, path);
|
|
@@ -310,100 +856,50 @@ function recordDiscovery(missionDir, hits, via) {
|
|
|
310
856
|
}
|
|
311
857
|
return file;
|
|
312
858
|
}
|
|
313
|
-
|
|
314
|
-
// src/host/config.ts
|
|
315
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
316
|
-
import { join as join2 } from "node:path";
|
|
317
|
-
var CONFIG_DIR = "web-discovery";
|
|
318
|
-
var CONFIG_FILENAME = "config.json";
|
|
319
|
-
var DEFAULT_SEARXNG_ENDPOINT = "http://127.0.0.1:8888/searxng";
|
|
320
|
-
var DEFAULT_BROWSER39_BIN = "browser39";
|
|
321
|
-
var DEFAULT_CONFIG = {
|
|
322
|
-
searxngEndpoint: DEFAULT_SEARXNG_ENDPOINT,
|
|
323
|
-
browser39Bin: DEFAULT_BROWSER39_BIN
|
|
324
|
-
};
|
|
325
|
-
var DiscoveryConfigError = class extends Error {
|
|
326
|
-
constructor(code, message) {
|
|
327
|
-
super(message);
|
|
328
|
-
this.code = code;
|
|
329
|
-
this.name = "DiscoveryConfigError";
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var FIELDS = [
|
|
333
|
-
{ key: "searxngEndpoint", kind: "string" },
|
|
334
|
-
{ key: "browser39Bin", kind: "string" }
|
|
335
|
-
];
|
|
336
|
-
function configPath(cwd) {
|
|
337
|
-
return join2(cwd, ".dsh", CONFIG_DIR, CONFIG_FILENAME);
|
|
338
|
-
}
|
|
339
|
-
function readDiscoveryConfig(cwd, env = process.env) {
|
|
340
|
-
let file = {};
|
|
341
|
-
const path = configPath(cwd);
|
|
342
|
-
try {
|
|
343
|
-
const raw = readFileSync2(path, "utf8");
|
|
344
|
-
const parsed = JSON.parse(raw);
|
|
345
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
346
|
-
throw new DiscoveryConfigError("config_corrupt", `${path} must be a JSON object`);
|
|
347
|
-
}
|
|
348
|
-
file = parsed;
|
|
349
|
-
} catch (error) {
|
|
350
|
-
if (error.code === "ENOENT") {
|
|
351
|
-
} else if (error instanceof DiscoveryConfigError) {
|
|
352
|
-
throw error;
|
|
353
|
-
} else {
|
|
354
|
-
throw new DiscoveryConfigError(
|
|
355
|
-
"config_corrupt",
|
|
356
|
-
`${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const config = { ...DEFAULT_CONFIG };
|
|
361
|
-
for (const spec of FIELDS) {
|
|
362
|
-
if (spec.key in file) {
|
|
363
|
-
const value = file[spec.key];
|
|
364
|
-
if (typeof value !== "string") {
|
|
365
|
-
throw new DiscoveryConfigError(
|
|
366
|
-
"config_corrupt",
|
|
367
|
-
`${path}: ${spec.key} must be a string`
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
config[spec.key] = value;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
const endpoint = env.SEARXNG_ENDPOINT;
|
|
374
|
-
if (endpoint !== void 0) config.searxngEndpoint = endpoint;
|
|
375
|
-
const bin = env.BROWSER39_BIN;
|
|
376
|
-
if (bin !== void 0) config.browser39Bin = bin;
|
|
377
|
-
return config;
|
|
378
|
-
}
|
|
379
|
-
function enginesForConfig(config) {
|
|
380
|
-
return {
|
|
381
|
-
searxng: config.searxngEndpoint.trim() !== "",
|
|
382
|
-
browser39: config.browser39Bin.trim() !== ""
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
859
|
export {
|
|
386
860
|
CONFIG_DIR,
|
|
387
861
|
CONFIG_FILENAME,
|
|
388
862
|
DEFAULT_BROWSER39_BIN,
|
|
863
|
+
DEFAULT_CATEGORIZER_ENDPOINT,
|
|
864
|
+
DEFAULT_CATEGORIZER_MODEL,
|
|
865
|
+
DEFAULT_CATEGORIZER_TIMEOUT_MS,
|
|
389
866
|
DEFAULT_CONFIG,
|
|
867
|
+
DEFAULT_LIMIT,
|
|
868
|
+
DEFAULT_RECEIPT_CHAR_BUDGET,
|
|
390
869
|
DEFAULT_SEARXNG_ENDPOINT,
|
|
870
|
+
DEFAULT_SERPER_ENDPOINT,
|
|
391
871
|
DISCOVERY_ENGINES,
|
|
392
872
|
DISCOVERY_FILENAME,
|
|
393
873
|
DiscoveryConfigError,
|
|
394
874
|
DiscoveryEngineError,
|
|
395
875
|
DiscoveryStoreError,
|
|
876
|
+
MAX_BROWSER39_MS,
|
|
877
|
+
MAX_DISCOVERY_MS,
|
|
878
|
+
MAX_LIMIT,
|
|
879
|
+
RECEIPT_CHAR_BUDGET,
|
|
880
|
+
categorizeWithOptionalLlm,
|
|
881
|
+
clampLimit,
|
|
396
882
|
configPath,
|
|
397
883
|
createBrowser39Engine,
|
|
884
|
+
createDiscoveryPort,
|
|
885
|
+
createHeuristicCategorizer,
|
|
398
886
|
createSearxngEngine,
|
|
887
|
+
createSerperEngine,
|
|
399
888
|
defaultRunner,
|
|
400
889
|
discoveryPath,
|
|
401
890
|
enginesForConfig,
|
|
891
|
+
enginesFromConfig,
|
|
892
|
+
fitReceiptChars,
|
|
893
|
+
llmConfigFrom,
|
|
402
894
|
mapSearxngRow,
|
|
403
895
|
mapSerpPage,
|
|
896
|
+
mapSerperOrganic,
|
|
897
|
+
modeForEndpoint,
|
|
404
898
|
readDiscoveryConfig,
|
|
405
899
|
readDiscoveryFile,
|
|
406
900
|
recordDiscovery,
|
|
901
|
+
resolveBrowser39Bin,
|
|
902
|
+
resolveSerperApiKey,
|
|
407
903
|
runDiscoverySearch,
|
|
408
904
|
unwrapSerpHref
|
|
409
905
|
};
|