dsh-web-discovery 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +56 -2
- package/cordis.patch.yml +6 -0
- package/lib/client.js +33 -0
- package/lib/client.js.map +7 -0
- package/lib/discovery.mjs +410 -0
- package/lib/discovery.mjs.map +7 -0
- package/lib/index.js +542 -0
- package/lib/index.js.map +7 -0
- package/package.json +66 -4
package/lib/index.js
ADDED
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
// src/shared/types.ts
|
|
2
|
+
var PLUGIN = "dsh-web-discovery";
|
|
3
|
+
var VERSION = "1.0.0";
|
|
4
|
+
|
|
5
|
+
// src/host/tools.ts
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { join as join3 } from "node:path";
|
|
8
|
+
|
|
9
|
+
// src/host/config.ts
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
var CONFIG_DIR = "web-discovery";
|
|
13
|
+
var CONFIG_FILENAME = "config.json";
|
|
14
|
+
var DEFAULT_SEARXNG_ENDPOINT = "http://127.0.0.1:8888/searxng";
|
|
15
|
+
var DEFAULT_BROWSER39_BIN = "browser39";
|
|
16
|
+
var DEFAULT_CONFIG = {
|
|
17
|
+
searxngEndpoint: DEFAULT_SEARXNG_ENDPOINT,
|
|
18
|
+
browser39Bin: DEFAULT_BROWSER39_BIN
|
|
19
|
+
};
|
|
20
|
+
var DiscoveryConfigError = class extends Error {
|
|
21
|
+
constructor(code, message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.name = "DiscoveryConfigError";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var FIELDS = [
|
|
28
|
+
{ key: "searxngEndpoint", kind: "string" },
|
|
29
|
+
{ key: "browser39Bin", kind: "string" }
|
|
30
|
+
];
|
|
31
|
+
function configPath(cwd) {
|
|
32
|
+
return join(cwd, ".dsh", CONFIG_DIR, CONFIG_FILENAME);
|
|
33
|
+
}
|
|
34
|
+
function readDiscoveryConfig(cwd, env = process.env) {
|
|
35
|
+
let file = {};
|
|
36
|
+
const path = configPath(cwd);
|
|
37
|
+
try {
|
|
38
|
+
const raw = readFileSync(path, "utf8");
|
|
39
|
+
const parsed = JSON.parse(raw);
|
|
40
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
41
|
+
throw new DiscoveryConfigError("config_corrupt", `${path} must be a JSON object`);
|
|
42
|
+
}
|
|
43
|
+
file = parsed;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (error.code === "ENOENT") {
|
|
46
|
+
} else if (error instanceof DiscoveryConfigError) {
|
|
47
|
+
throw error;
|
|
48
|
+
} else {
|
|
49
|
+
throw new DiscoveryConfigError(
|
|
50
|
+
"config_corrupt",
|
|
51
|
+
`${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const config = { ...DEFAULT_CONFIG };
|
|
56
|
+
for (const spec of FIELDS) {
|
|
57
|
+
if (spec.key in file) {
|
|
58
|
+
const value = file[spec.key];
|
|
59
|
+
if (typeof value !== "string") {
|
|
60
|
+
throw new DiscoveryConfigError(
|
|
61
|
+
"config_corrupt",
|
|
62
|
+
`${path}: ${spec.key} must be a string`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
config[spec.key] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const endpoint = env.SEARXNG_ENDPOINT;
|
|
69
|
+
if (endpoint !== void 0) config.searxngEndpoint = endpoint;
|
|
70
|
+
const bin = env.BROWSER39_BIN;
|
|
71
|
+
if (bin !== void 0) config.browser39Bin = bin;
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
function enginesForConfig(config) {
|
|
75
|
+
return {
|
|
76
|
+
searxng: config.searxngEndpoint.trim() !== "",
|
|
77
|
+
browser39: config.browser39Bin.trim() !== ""
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/host/engines/browser39.ts
|
|
82
|
+
import { execFile } from "node:child_process";
|
|
83
|
+
|
|
84
|
+
// src/host/discovery-port.ts
|
|
85
|
+
var DISCOVERY_ENGINES = ["searxng", "browser39"];
|
|
86
|
+
var DiscoveryEngineError = class extends Error {
|
|
87
|
+
constructor(code, message) {
|
|
88
|
+
super(message);
|
|
89
|
+
this.code = code;
|
|
90
|
+
this.name = "DiscoveryEngineError";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/host/engines/browser39.ts
|
|
95
|
+
function defaultRunner(timeoutMs) {
|
|
96
|
+
return (bin, args) => new Promise((resolve) => {
|
|
97
|
+
execFile(
|
|
98
|
+
bin,
|
|
99
|
+
args,
|
|
100
|
+
{ timeout: timeoutMs, maxBuffer: 8 * 1024 * 1024, windowsHide: true },
|
|
101
|
+
(error, stdout, stderr) => {
|
|
102
|
+
if (error) {
|
|
103
|
+
const status = error.status;
|
|
104
|
+
resolve({
|
|
105
|
+
code: typeof status === "number" ? status : -1,
|
|
106
|
+
stdout: String(stdout ?? ""),
|
|
107
|
+
stderr: String(stderr ?? ""),
|
|
108
|
+
spawnError: error.code ?? (error instanceof Error ? error.name : void 0)
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
resolve({ code: 0, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
118
|
+
var DEFAULT_LIMIT = 10;
|
|
119
|
+
var SERP_CHROME_HOST = "duckduckgo.com";
|
|
120
|
+
function unwrapSerpHref(href) {
|
|
121
|
+
let u;
|
|
122
|
+
try {
|
|
123
|
+
u = new URL(href);
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (u.protocol !== "http:" && u.protocol !== "https:") return null;
|
|
128
|
+
if (u.hostname.toLowerCase() !== SERP_CHROME_HOST) return u.toString();
|
|
129
|
+
if (u.pathname !== "/l/") return null;
|
|
130
|
+
const target = u.searchParams.get("uddg");
|
|
131
|
+
if (!target) return null;
|
|
132
|
+
let t;
|
|
133
|
+
try {
|
|
134
|
+
t = new URL(target);
|
|
135
|
+
} catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
if (t.protocol !== "http:" && t.protocol !== "https:") return null;
|
|
139
|
+
if (t.hostname.toLowerCase() === SERP_CHROME_HOST) return null;
|
|
140
|
+
return t.toString();
|
|
141
|
+
}
|
|
142
|
+
function mapSerpPage(page, limit) {
|
|
143
|
+
const links = Array.isArray(page.links) ? page.links : [];
|
|
144
|
+
const seen = /* @__PURE__ */ new Set();
|
|
145
|
+
const hits = [];
|
|
146
|
+
for (const link of links) {
|
|
147
|
+
if (hits.length >= limit) break;
|
|
148
|
+
const href = typeof link.href === "string" ? link.href : "";
|
|
149
|
+
const url = unwrapSerpHref(href);
|
|
150
|
+
if (!url) continue;
|
|
151
|
+
const key = url.toLowerCase();
|
|
152
|
+
if (seen.has(key)) continue;
|
|
153
|
+
seen.add(key);
|
|
154
|
+
const hit = { url };
|
|
155
|
+
const title = typeof link.text === "string" && link.text.trim() !== "" ? link.text.trim() : void 0;
|
|
156
|
+
if (title) hit.title = title;
|
|
157
|
+
hits.push(hit);
|
|
158
|
+
}
|
|
159
|
+
return hits;
|
|
160
|
+
}
|
|
161
|
+
function createBrowser39Engine(opts) {
|
|
162
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
163
|
+
const runner = opts.runner ?? defaultRunner(timeoutMs);
|
|
164
|
+
return {
|
|
165
|
+
kind: "browser39",
|
|
166
|
+
async search(query, searchOpts = {}) {
|
|
167
|
+
const limit = searchOpts.limit ?? DEFAULT_LIMIT;
|
|
168
|
+
let result;
|
|
169
|
+
try {
|
|
170
|
+
result = await runner(opts.bin, ["search", query, "--output", "json", "--no-persist"]);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
throw new DiscoveryEngineError(
|
|
173
|
+
"browser39_missing",
|
|
174
|
+
`browser39 search failed to run: ${error instanceof Error ? error.message : String(error)}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
const spawnError = result.spawnError;
|
|
178
|
+
if (spawnError === "ENOENT" || spawnError === void 0 && result.code === -1 && result.stdout === "" && result.stderr !== "" && /ENOENT/.test(result.stderr)) {
|
|
179
|
+
throw new DiscoveryEngineError("browser39_missing", `browser39 binary not found: ${opts.bin}`);
|
|
180
|
+
}
|
|
181
|
+
if (result.code !== 0) {
|
|
182
|
+
const tail = result.stderr.trim().split("\n").slice(-3).join(" ");
|
|
183
|
+
throw new DiscoveryEngineError("browser39_failed", `browser39 search exited ${result.code}: ${tail || "no stderr"}`);
|
|
184
|
+
}
|
|
185
|
+
let page;
|
|
186
|
+
try {
|
|
187
|
+
page = JSON.parse(result.stdout);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
throw new DiscoveryEngineError(
|
|
190
|
+
"browser39_failed",
|
|
191
|
+
`browser39 search returned non-JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (page === null || typeof page !== "object") {
|
|
195
|
+
throw new DiscoveryEngineError("browser39_failed", "browser39 search returned a non-object reply");
|
|
196
|
+
}
|
|
197
|
+
const status = typeof page.status === "number" ? page.status : 200;
|
|
198
|
+
if (status === 202 || status < 200 || status >= 300) {
|
|
199
|
+
throw new DiscoveryEngineError(
|
|
200
|
+
"browser39_blocked",
|
|
201
|
+
`browser39 search blocked by the search engine (HTTP ${status} \u2014 bot challenge or rate limit); retry later or use another engine`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return mapSerpPage(page, limit);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/host/engines/searxng.ts
|
|
210
|
+
var DEFAULT_TIMEOUT_MS2 = 1e4;
|
|
211
|
+
var DEFAULT_LIMIT2 = 10;
|
|
212
|
+
function asString(v) {
|
|
213
|
+
return typeof v === "string" && v.trim() !== "" ? v : void 0;
|
|
214
|
+
}
|
|
215
|
+
function mapSearxngRow(row) {
|
|
216
|
+
const url = asString(row.url);
|
|
217
|
+
if (!url) return null;
|
|
218
|
+
let isHttp = false;
|
|
219
|
+
try {
|
|
220
|
+
const u = new URL(url);
|
|
221
|
+
isHttp = u.protocol === "http:" || u.protocol === "https:";
|
|
222
|
+
} catch {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
if (!isHttp) return null;
|
|
226
|
+
const hit = { url };
|
|
227
|
+
const title = asString(row.title);
|
|
228
|
+
if (title) hit.title = title;
|
|
229
|
+
const snippet = asString(row.content);
|
|
230
|
+
if (snippet) hit.snippet = snippet;
|
|
231
|
+
return hit;
|
|
232
|
+
}
|
|
233
|
+
function createSearxngEngine(opts) {
|
|
234
|
+
const endpoint = opts.endpoint.replace(/\/+$/, "");
|
|
235
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
236
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
237
|
+
return {
|
|
238
|
+
kind: "searxng",
|
|
239
|
+
async search(query, searchOpts = {}) {
|
|
240
|
+
if (!endpoint) {
|
|
241
|
+
throw new DiscoveryEngineError("searxng_unreachable", "searxng endpoint is not configured");
|
|
242
|
+
}
|
|
243
|
+
const limit = searchOpts.limit ?? DEFAULT_LIMIT2;
|
|
244
|
+
const qs = new URLSearchParams({ q: query, format: "json" });
|
|
245
|
+
const res = await fetchImpl(`${endpoint}/search?${qs.toString()}`, {
|
|
246
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
247
|
+
headers: { accept: "application/json" }
|
|
248
|
+
}).catch((error) => {
|
|
249
|
+
throw new DiscoveryEngineError(
|
|
250
|
+
"searxng_unreachable",
|
|
251
|
+
`searxng unreachable at ${endpoint}: ${error instanceof Error ? error.message : String(error)}`
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
if (!res.ok) {
|
|
255
|
+
throw new DiscoveryEngineError("searxng_unreachable", `searxng ${res.status} at ${endpoint}`);
|
|
256
|
+
}
|
|
257
|
+
let body;
|
|
258
|
+
try {
|
|
259
|
+
body = await res.json();
|
|
260
|
+
} catch (error) {
|
|
261
|
+
throw new DiscoveryEngineError(
|
|
262
|
+
"searxng_unreachable",
|
|
263
|
+
`searxng replied non-JSON from ${endpoint}: ${error instanceof Error ? error.message : String(error)}`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const results = body?.results;
|
|
267
|
+
if (!Array.isArray(results)) {
|
|
268
|
+
throw new DiscoveryEngineError("searxng_unreachable", `searxng reply has no results[] from ${endpoint}`);
|
|
269
|
+
}
|
|
270
|
+
const hits = [];
|
|
271
|
+
for (const row of results) {
|
|
272
|
+
const hit = mapSearxngRow(row);
|
|
273
|
+
if (hit) hits.push(hit);
|
|
274
|
+
if (hits.length >= limit) break;
|
|
275
|
+
}
|
|
276
|
+
return hits;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/host/discovery-store.ts
|
|
282
|
+
import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
283
|
+
import { dirname, join as join2 } from "node:path";
|
|
284
|
+
var DISCOVERY_FILENAME = "discovery.json";
|
|
285
|
+
var DiscoveryStoreError = class extends Error {
|
|
286
|
+
constructor(code, message) {
|
|
287
|
+
super(message);
|
|
288
|
+
this.code = code;
|
|
289
|
+
this.name = "DiscoveryStoreError";
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
function discoveryPath(missionDir) {
|
|
293
|
+
return join2(missionDir, DISCOVERY_FILENAME);
|
|
294
|
+
}
|
|
295
|
+
function readDiscoveryFile(missionDir) {
|
|
296
|
+
const path = discoveryPath(missionDir);
|
|
297
|
+
let raw;
|
|
298
|
+
try {
|
|
299
|
+
raw = readFileSync2(path, "utf8");
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (error.code === "ENOENT") return null;
|
|
302
|
+
throw new DiscoveryStoreError("discovery_unwritable", `cannot read ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
const parsed = JSON.parse(raw);
|
|
306
|
+
if (parsed === null || typeof parsed !== "object" || !Array.isArray(parsed.urls) || typeof parsed.updated_at !== "string") {
|
|
307
|
+
throw new Error("bad shape");
|
|
308
|
+
}
|
|
309
|
+
return parsed;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
throw new DiscoveryStoreError("discovery_corrupt", `${path} is not valid discovery.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function recordDiscovery(missionDir, hits, via) {
|
|
315
|
+
const at = via.at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
316
|
+
if (typeof at !== "string" || at.length === 0) {
|
|
317
|
+
throw new DiscoveryStoreError("bad_provenance", `via.at must be an ISO timestamp string (got ${String(via.at)})`);
|
|
318
|
+
}
|
|
319
|
+
const file = readDiscoveryFile(missionDir) ?? { updated_at: at, urls: [] };
|
|
320
|
+
const seen = new Set(file.urls.map((u) => u.url.toLowerCase()));
|
|
321
|
+
for (const hit of hits) {
|
|
322
|
+
const key = hit.url.toLowerCase();
|
|
323
|
+
if (seen.has(key)) continue;
|
|
324
|
+
seen.add(key);
|
|
325
|
+
file.urls.push({ ...hit, via: { ...via, at } });
|
|
326
|
+
}
|
|
327
|
+
file.updated_at = at;
|
|
328
|
+
const path = discoveryPath(missionDir);
|
|
329
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
330
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
331
|
+
try {
|
|
332
|
+
writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
|
|
333
|
+
renameSync(tmp, path);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
throw new DiscoveryStoreError("discovery_unwritable", `cannot write ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
336
|
+
}
|
|
337
|
+
return file;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/host/discovery-tool.ts
|
|
341
|
+
function engineReason(kind, error) {
|
|
342
|
+
switch (error.code) {
|
|
343
|
+
case "searxng_unreachable":
|
|
344
|
+
return "searxng not running at the configured endpoint";
|
|
345
|
+
case "browser39_missing":
|
|
346
|
+
return "browser39 search binary not found";
|
|
347
|
+
case "browser39_blocked":
|
|
348
|
+
return "browser39 blocked by the search engine (bot challenge / rate limit)";
|
|
349
|
+
default:
|
|
350
|
+
return `${kind} engine error (${error.code})`;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async function runDiscoverySearch(deps, rawQuery, opts = {}) {
|
|
354
|
+
const query = rawQuery.trim();
|
|
355
|
+
if (!query) {
|
|
356
|
+
return { ok: false, error: "query_required: pass a non-empty search query" };
|
|
357
|
+
}
|
|
358
|
+
const limit = opts.limit ?? 10;
|
|
359
|
+
const candidates = opts.engine ? [opts.engine] : DISCOVERY_ENGINES.filter((k) => deps.engines[k] !== void 0);
|
|
360
|
+
if (candidates.length === 0) {
|
|
361
|
+
return {
|
|
362
|
+
ok: false,
|
|
363
|
+
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)"
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const failures = [];
|
|
367
|
+
for (const kind of candidates) {
|
|
368
|
+
const engine = deps.engines[kind];
|
|
369
|
+
if (!engine) {
|
|
370
|
+
failures.push(
|
|
371
|
+
kind === "searxng" ? "searxng endpoint not configured" : "browser39 search not configured"
|
|
372
|
+
);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
const urls = await engine.search(query, { limit });
|
|
377
|
+
return { ok: true, query, engine: engine.kind, count: urls.length, urls };
|
|
378
|
+
} catch (error) {
|
|
379
|
+
if (error instanceof DiscoveryEngineError && (error.code === "searxng_unreachable" || error.code === "browser39_missing" || error.code === "browser39_blocked")) {
|
|
380
|
+
failures.push(engineReason(engine.kind, error));
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (error instanceof DiscoveryEngineError && error.code === "browser39_failed") {
|
|
384
|
+
return { ok: false, error: `search_failed: ${error.message}` };
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
ok: false,
|
|
388
|
+
error: `search_failed: ${error instanceof Error ? error.message : String(error)}`
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const reason = candidates.length === 1 && opts.engine ? `${opts.engine}: ${failures[0] ?? "unavailable"}` : failures.join("; ");
|
|
393
|
+
return { ok: false, error: `no_engine: ${reason} \u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)` };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// src/host/tools.ts
|
|
397
|
+
var MISSION_STORE_DIR = join3(".dsh", "web-missions");
|
|
398
|
+
function resolveCwd(args, exec) {
|
|
399
|
+
const fromArg = args.cwd?.trim();
|
|
400
|
+
if (fromArg) return fromArg;
|
|
401
|
+
const fromAgent = exec.agent?.session?.header?.cwd?.trim();
|
|
402
|
+
if (fromAgent) return fromAgent;
|
|
403
|
+
throw new Error("cwd required (pass cwd or run from an agent session with a workspace cwd)");
|
|
404
|
+
}
|
|
405
|
+
var CWD_PARAM = {
|
|
406
|
+
type: "string",
|
|
407
|
+
description: "Working directory holding the .dsh store (defaults to the agent session cwd)."
|
|
408
|
+
};
|
|
409
|
+
function buildEngines(cwd) {
|
|
410
|
+
const config = readDiscoveryConfig(cwd);
|
|
411
|
+
const presence = enginesForConfig(config);
|
|
412
|
+
const engines = {};
|
|
413
|
+
if (presence.searxng) engines.searxng = createSearxngEngine({ endpoint: config.searxngEndpoint });
|
|
414
|
+
if (presence.browser39) engines.browser39 = createBrowser39Engine({ bin: config.browser39Bin });
|
|
415
|
+
return engines;
|
|
416
|
+
}
|
|
417
|
+
function registerDiscoveryTools(ctx) {
|
|
418
|
+
const disposers = [];
|
|
419
|
+
const unregisterSearch = ctx.tools.register({
|
|
420
|
+
name: "discovery_search",
|
|
421
|
+
description: "Discover candidate URLs from a local search engine (SearXNG or the browser39 search CLI) \u2014 the mission core only sees URLs in / URLs out. Engines are optional: when none is available the result is no_engine (a supported state \u2014 supply URLs directly instead). Results are candidates: they pass the mission allowlist gate when fetched. With mission_id, hits are recorded into that mission\u2019s discovery.json (surfaced by mission_status; not ledger rows until fetched).",
|
|
422
|
+
parameters: {
|
|
423
|
+
type: "object",
|
|
424
|
+
additionalProperties: false,
|
|
425
|
+
required: ["query"],
|
|
426
|
+
properties: {
|
|
427
|
+
query: { type: "string", description: "Search query (non-empty)." },
|
|
428
|
+
engine: {
|
|
429
|
+
type: "string",
|
|
430
|
+
enum: [...DISCOVERY_ENGINES],
|
|
431
|
+
description: "Pin one engine; omit to auto-select (searxng first, then browser39)."
|
|
432
|
+
},
|
|
433
|
+
limit: { type: "number", description: "Max results (default 10, clamped to 1..50)." },
|
|
434
|
+
mission_id: {
|
|
435
|
+
type: "string",
|
|
436
|
+
description: "Mission id to record hits into (its discovery.json). Omit to search without recording."
|
|
437
|
+
},
|
|
438
|
+
cwd: CWD_PARAM
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
output: {
|
|
442
|
+
schema: {
|
|
443
|
+
type: "object",
|
|
444
|
+
additionalProperties: true,
|
|
445
|
+
properties: {
|
|
446
|
+
ok: { type: "boolean" },
|
|
447
|
+
error: { type: "string" },
|
|
448
|
+
query: { type: "string" },
|
|
449
|
+
engine: { type: "string" },
|
|
450
|
+
count: { type: "number" },
|
|
451
|
+
urls: {
|
|
452
|
+
type: "array",
|
|
453
|
+
items: {
|
|
454
|
+
type: "object",
|
|
455
|
+
additionalProperties: true,
|
|
456
|
+
properties: {
|
|
457
|
+
url: { type: "string" },
|
|
458
|
+
title: { type: "string" },
|
|
459
|
+
snippet: { type: "string" }
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
recorded: { type: "string" }
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
execute: async (args, exec) => {
|
|
468
|
+
let cwd;
|
|
469
|
+
try {
|
|
470
|
+
cwd = resolveCwd(args, exec);
|
|
471
|
+
} catch (error) {
|
|
472
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
473
|
+
}
|
|
474
|
+
const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? Math.min(50, Math.max(1, Math.round(args.limit))) : 10;
|
|
475
|
+
let result;
|
|
476
|
+
try {
|
|
477
|
+
const engines = buildEngines(cwd);
|
|
478
|
+
result = await runDiscoverySearch({ engines }, args.query ?? "", {
|
|
479
|
+
engine: args.engine,
|
|
480
|
+
limit
|
|
481
|
+
});
|
|
482
|
+
} catch (error) {
|
|
483
|
+
return { ok: false, error: `internal_error: ${error instanceof Error ? error.message : String(error)}` };
|
|
484
|
+
}
|
|
485
|
+
if (!result.ok) return result;
|
|
486
|
+
if (!args.mission_id || !args.mission_id.trim()) {
|
|
487
|
+
return { ok: true, query: result.query, engine: result.engine, count: result.count, urls: result.urls };
|
|
488
|
+
}
|
|
489
|
+
const missionDir = join3(cwd, MISSION_STORE_DIR, args.mission_id.trim());
|
|
490
|
+
if (!existsSync(missionDir)) {
|
|
491
|
+
return { ok: false, error: `unknown_mission: no such mission: ${args.mission_id.trim()}` };
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
recordDiscovery(missionDir, result.urls, {
|
|
495
|
+
query: result.query,
|
|
496
|
+
engine: result.engine,
|
|
497
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
498
|
+
});
|
|
499
|
+
} catch (error) {
|
|
500
|
+
if (error instanceof DiscoveryStoreError) {
|
|
501
|
+
return { ok: false, error: `${error.code}: ${error.message}` };
|
|
502
|
+
}
|
|
503
|
+
return { ok: false, error: `record_failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
ok: true,
|
|
507
|
+
query: result.query,
|
|
508
|
+
engine: result.engine,
|
|
509
|
+
count: result.count,
|
|
510
|
+
urls: result.urls,
|
|
511
|
+
recorded: join3(args.mission_id.trim(), "discovery.json")
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
disposers.push(unregisterSearch);
|
|
516
|
+
return () => {
|
|
517
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// src/host/index.ts
|
|
522
|
+
var name = PLUGIN;
|
|
523
|
+
var inject = ["tools"];
|
|
524
|
+
function errorMessage(error) {
|
|
525
|
+
return error instanceof Error ? error.message : String(error);
|
|
526
|
+
}
|
|
527
|
+
function apply(ctx) {
|
|
528
|
+
try {
|
|
529
|
+
const disposeTools = registerDiscoveryTools(ctx);
|
|
530
|
+
ctx.effect(() => disposeTools, "web-discovery: tools");
|
|
531
|
+
} catch (error) {
|
|
532
|
+
ctx.logger?.(PLUGIN).warn("tool registration failed (continuing without it): %s", errorMessage(error));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
export {
|
|
536
|
+
PLUGIN,
|
|
537
|
+
VERSION,
|
|
538
|
+
apply,
|
|
539
|
+
inject,
|
|
540
|
+
name
|
|
541
|
+
};
|
|
542
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/shared/types.ts", "../src/host/tools.ts", "../src/host/config.ts", "../src/host/engines/browser39.ts", "../src/host/discovery-port.ts", "../src/host/engines/searxng.ts", "../src/host/discovery-store.ts", "../src/host/discovery-tool.ts", "../src/host/index.ts"],
|
|
4
|
+
"sourcesContent": ["/** Companion identity (M7). The package is `dsh-web-discovery`; the\n * plugin id / Loader row id mirrors the package name (sibling convention). */\nexport const PLUGIN = 'dsh-web-discovery'\nexport const VERSION = '1.0.0'\n", "/**\n * Agent tool for discovery (M7): `discovery_search`.\n *\n * Contract (mirrors the core's tools, C1):\n * - results are JSON-serializable;\n * - errors return `{ ok: false, error: '<code>: <msg>' }` \u2014 never throw into\n * the tool layer;\n * - JSON Schema scar (dsh \u2265 0.1.7): no `required: true` on scalar property\n * nodes \u2014 object-level `required: ['field', \u2026]` arrays only;\n * - cwd resolves per tool call via resolveCwd (args.cwd \u2192 agent session\n * header cwd \u2192 error). Never process.cwd().\n *\n * `discovery_search`:\n * query (required) + engine? + limit? + mission_id? + cwd?\n * \u2192 { ok: true, query, engine, count, urls: [{url,title?,snippet?}],\n * recorded: \"<mission_id>/discovery.json\" | null }\n * | { ok: false, error: 'no_engine: \u2026' | 'search_failed: \u2026' | \u2026 }\n *\n * With `mission_id`, hits are recorded into that mission's discovery.json\n * (the one-way bridge the core surfaces; D-M7.4: not ledger rows). Unknown\n * mission dir \u2192 `unknown_mission` (the companion never creates mission dirs).\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { enginesForConfig, readDiscoveryConfig } from './config.ts'\nimport { createBrowser39Engine } from './engines/browser39.ts'\nimport { createSearxngEngine } from './engines/searxng.ts'\nimport { DiscoveryStoreError, recordDiscovery } from './discovery-store.ts'\nimport {\n DISCOVERY_ENGINES,\n type DiscoveryEngine,\n type DiscoveryEngineKind,\n} from './discovery-port.ts'\nimport { runDiscoverySearch } from './discovery-tool.ts'\n\n/** The mission store root under cwd \u2014 the file convention the core surfaces\n * (discovery.json in the mission dir). Documented coupling: if the core\n * moves its root, this companion follows (V5: no engine code/config in the\n * core, one file convention in the companion). */\nexport const MISSION_STORE_DIR = join('.dsh', 'web-missions')\n\ninterface ExecLike {\n agent?: { session?: { header?: { cwd?: string } } }\n}\n\n/** Verbatim core pattern (C1 review #4). */\nexport function resolveCwd(args: { cwd?: string }, exec: ExecLike): string {\n const fromArg = args.cwd?.trim()\n if (fromArg) return fromArg\n const fromAgent = exec.agent?.session?.header?.cwd?.trim()\n if (fromAgent) return fromAgent\n throw new Error('cwd required (pass cwd or run from an agent session with a workspace cwd)')\n}\n\nconst CWD_PARAM = {\n type: 'string',\n description: 'Working directory holding the .dsh store (defaults to the agent session cwd).',\n}\n\nfunction buildEngines(cwd: string): Partial<Record<DiscoveryEngineKind, DiscoveryEngine>> {\n const config = readDiscoveryConfig(cwd)\n const presence = enginesForConfig(config)\n const engines: Partial<Record<DiscoveryEngineKind, DiscoveryEngine>> = {}\n if (presence.searxng) engines.searxng = createSearxngEngine({ endpoint: config.searxngEndpoint })\n if (presence.browser39) engines.browser39 = createBrowser39Engine({ bin: config.browser39Bin })\n return engines\n}\n\ntype ToolErrorResult = { ok: false; error: string }\ntype ToolSuccessResult = Record<string, unknown>\n\nexport function registerDiscoveryTools(ctx: Context): () => void {\n const disposers: (() => void)[] = []\n\n const unregisterSearch = ctx.tools.register({\n name: 'discovery_search',\n description:\n 'Discover candidate URLs from a local search engine (SearXNG or the ' +\n 'browser39 search CLI) \u2014 the mission core only sees URLs in / URLs out. ' +\n 'Engines are optional: when none is available the result is ' +\n 'no_engine (a supported state \u2014 supply URLs directly instead). ' +\n 'Results are candidates: they pass the mission allowlist gate when fetched. ' +\n 'With mission_id, hits are recorded into that mission\\u2019s discovery.json ' +\n '(surfaced by mission_status; not ledger rows until fetched).',\n parameters: {\n type: 'object',\n additionalProperties: false,\n required: ['query'],\n properties: {\n query: { type: 'string', description: 'Search query (non-empty).' },\n engine: {\n type: 'string',\n enum: [...DISCOVERY_ENGINES],\n description: 'Pin one engine; omit to auto-select (searxng first, then browser39).',\n },\n limit: { type: 'number', description: 'Max results (default 10, clamped to 1..50).' },\n mission_id: {\n type: 'string',\n description:\n 'Mission id to record hits into (its discovery.json). Omit to search without recording.',\n },\n cwd: CWD_PARAM,\n },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: true,\n properties: {\n ok: { type: 'boolean' },\n error: { type: 'string' },\n query: { type: 'string' },\n engine: { type: 'string' },\n count: { type: 'number' },\n urls: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n url: { type: 'string' },\n title: { type: 'string' },\n snippet: { type: 'string' },\n },\n },\n },\n recorded: { type: 'string' },\n },\n },\n },\n execute: async (\n args: { query?: string; engine?: DiscoveryEngineKind; limit?: number; mission_id?: string; cwd?: string },\n exec: ExecLike,\n ): Promise<ToolSuccessResult | ToolErrorResult> => {\n let cwd: string\n try {\n cwd = resolveCwd(args, exec)\n } catch (error) {\n return { ok: false, error: error instanceof Error ? error.message : String(error) }\n }\n const limit =\n typeof args.limit === 'number' && Number.isFinite(args.limit)\n ? Math.min(50, Math.max(1, Math.round(args.limit)))\n : 10\n let result\n try {\n const engines = buildEngines(cwd)\n result = await runDiscoverySearch({ engines }, args.query ?? '', {\n engine: args.engine,\n limit,\n })\n } catch (error) {\n return { ok: false, error: `internal_error: ${error instanceof Error ? error.message : String(error)}` }\n }\n if (!result.ok) return result\n\n if (!args.mission_id || !args.mission_id.trim()) {\n // Omit `recorded` when not writing (avoid null vs string schema scars).\n return { ok: true, query: result.query, engine: result.engine, count: result.count, urls: result.urls }\n }\n const missionDir = join(cwd, MISSION_STORE_DIR, args.mission_id.trim())\n if (!existsSync(missionDir)) {\n return { ok: false, error: `unknown_mission: no such mission: ${args.mission_id.trim()}` }\n }\n try {\n recordDiscovery(missionDir, result.urls, {\n query: result.query,\n engine: result.engine,\n at: new Date().toISOString(),\n })\n } catch (error) {\n if (error instanceof DiscoveryStoreError) {\n return { ok: false, error: `${error.code}: ${error.message}` }\n }\n return { ok: false, error: `record_failed: ${error instanceof Error ? error.message : String(error)}` }\n }\n return {\n ok: true,\n query: result.query,\n engine: result.engine,\n count: result.count,\n urls: result.urls,\n recorded: join(args.mission_id.trim(), 'discovery.json'),\n }\n },\n })\n disposers.push(unregisterSearch)\n\n return () => {\n for (const dispose of disposers.splice(0)) dispose()\n }\n}\n", "/**\n * Discovery config (companion's own knobs \u2014 the mission core carries NO\n * engine config; V5 encapsulation check).\n *\n * Source order (per cwd, resolved at tool-call time like the core):\n * 1. defaults below;\n * 2. `<cwd>/.dsh/web-discovery/config.json` \u2014 OPTIONAL file; every field\n * optional, merges over defaults; corrupt \u2192 fail loud (same discipline\n * as the core's config); unknown keys ignored;\n * 3. env overrides: SEARXNG_ENDPOINT, BROWSER39_BIN (same names the core\n * honors \u2014 one mechanism across the pair).\n *\n * A knob set to the EMPTY STRING disables that engine (the tool layer then\n * reports it as absent \u2192 no_engine).\n */\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { DiscoveryEngineKind } from './discovery-port.ts'\n\nexport interface DiscoveryConfig {\n /** SearXNG instance base incl. path prefix. NOT :8080 \u2014 that port is llama. */\n searxngEndpoint: string\n /** browser39 binary (path or PATH name). Empty = engine disabled. */\n browser39Bin: string\n}\n\nexport const CONFIG_DIR = 'web-discovery'\nexport const CONFIG_FILENAME = 'config.json'\n\n/** Plan default: self-hosted instance on this box (operator hand-sets in ENV.md). */\nexport const DEFAULT_SEARXNG_ENDPOINT = 'http://127.0.0.1:8888/searxng'\n/** Plan default: `browser39` on PATH (the core's BROWSER39_BIN override wins). */\nexport const DEFAULT_BROWSER39_BIN = 'browser39'\n\nexport const DEFAULT_CONFIG: DiscoveryConfig = {\n searxngEndpoint: DEFAULT_SEARXNG_ENDPOINT,\n browser39Bin: DEFAULT_BROWSER39_BIN,\n}\n\nexport class DiscoveryConfigError extends Error {\n constructor(\n readonly code: 'config_corrupt',\n message: string,\n ) {\n super(message)\n this.name = 'DiscoveryConfigError'\n }\n}\n\ntype FieldSpec =\n | { key: 'searxngEndpoint'; kind: 'string' }\n | { key: 'browser39Bin'; kind: 'string' }\n\nconst FIELDS: readonly FieldSpec[] = [\n { key: 'searxngEndpoint', kind: 'string' },\n { key: 'browser39Bin', kind: 'string' },\n]\n\nexport function configPath(cwd: string): string {\n return join(cwd, '.dsh', CONFIG_DIR, CONFIG_FILENAME)\n}\n\nexport function readDiscoveryConfig(cwd: string, env: NodeJS.ProcessEnv = process.env): DiscoveryConfig {\n let file: Record<string, unknown> = {}\n const path = configPath(cwd)\n try {\n const raw = readFileSync(path, 'utf8')\n const parsed: unknown = JSON.parse(raw)\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new DiscoveryConfigError('config_corrupt', `${path} must be a JSON object`)\n }\n file = parsed as Record<string, unknown>\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n // absent file = all defaults\n } else if (error instanceof DiscoveryConfigError) {\n throw error\n } else {\n throw new DiscoveryConfigError(\n 'config_corrupt',\n `${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n const config: DiscoveryConfig = { ...DEFAULT_CONFIG }\n for (const spec of FIELDS) {\n if (spec.key in file) {\n const value = file[spec.key]\n if (typeof value !== 'string') {\n throw new DiscoveryConfigError(\n 'config_corrupt',\n `${path}: ${spec.key} must be a string`,\n )\n }\n config[spec.key] = value\n }\n }\n // env overrides win over the file (operator can redirect without touching disk).\n const endpoint = env.SEARXNG_ENDPOINT\n if (endpoint !== undefined) config.searxngEndpoint = endpoint\n const bin = env.BROWSER39_BIN\n if (bin !== undefined) config.browser39Bin = bin\n return config\n}\n\nexport interface EnginePresence {\n searxng: boolean\n browser39: boolean\n}\n\n/** Which engines exist per config (empty string = disabled). */\nexport function enginesForConfig(config: DiscoveryConfig): EnginePresence {\n return {\n searxng: config.searxngEndpoint.trim() !== '',\n browser39: config.browser39Bin.trim() !== '',\n }\n}\n\nexport type { DiscoveryEngineKind }\n", "/**\n * browser39-search engine (D-M7.2, engine 2): the `browser39 search` CLI,\n * same JSON transport family as the fetcher (local CLI \u2192 JSON, S1).\n *\n * Probed live (2026-10-13, @aquintanar/browser39@2.0.0):\n * browser39 search <query> --output json --no-persist\n * emits ONE JSON object \u2014 a FETCH-SHAPED page of the SERP, not a structured\n * result list:\n * { url, title, status, markdown, links: [{ i, text, href }] }\n * The actual results are the SERP anchor links. With the default DuckDuckGo\n * backend the hrefs are redirect wrappers:\n * https://duckduckgo.com/l/?uddg=<urlencoded target>&rut=<token>\n * so the adapter must unwrap `uddg` to the real target URL (Eris scar: the\n * unwrap is a query-param read, never HTML scraping \u2014 D4).\n *\n * Mapping rules (deterministic):\n * - keep links with an absolute http(s) href;\n * - `duckduckgo.com/l/` (and any `duckduckgo.com` site chrome) \u2192 unwrap the\n * `uddg` param to the target; skip if the target is missing/not http(s);\n * - skip targets whose host is the SERP engine's own host (duckduckgo.com) \u2014\n * those are chrome (logo, /html/, feedback), not results;\n * - title = the anchor text (the SERP result title);\n * - snippet: the JSON reply carries none (markdown has titles + dates only)\n * \u2192 omitted;\n * - dedupe by lowercased url, first-seen wins; `limit` caps the output.\n *\n * Absence = supported state: binary missing (spawn ENOENT) \u2192\n * `browser39_missing`; present but non-zero exit / non-JSON \u2192\n * `browser39_failed` (a query failure, NOT no_engine).\n *\n * Pure: the CLI runner is injected (the smoke drives a fake binary emitting\n * the captured reply shape \u2014 no network).\n */\nimport { execFile } from 'node:child_process'\nimport {\n DiscoveryEngineError,\n type DiscoveryEngine,\n type DiscoveryHit,\n type SearchOptions,\n} from '../discovery-port.ts'\n\nexport interface Browser39CliResult {\n code: number\n stdout: string\n stderr: string\n /** Set when the SPAWN itself failed (e.g. `ENOENT` = binary missing) \u2014\n * distinct from a spawn that ran and exited non-zero. */\n spawnError?: string\n}\n\nexport type Browser39Runner = (bin: string, args: string[]) => Promise<Browser39CliResult>\n\n/** Default runner: async execFile with a timeout; spawn errors (ENOENT =\n * binary missing) resolve to `{ code: -1, spawnError }`-style results so\n * the engine can distinguish missing-binary from failed-query. */\nexport function defaultRunner(timeoutMs: number): Browser39Runner {\n return (bin, args) =>\n new Promise<Browser39CliResult>((resolve) => {\n execFile(\n bin,\n args,\n { timeout: timeoutMs, maxBuffer: 8 * 1024 * 1024, windowsHide: true },\n (error, stdout, stderr) => {\n if (error) {\n const status = (error as { status?: number }).status\n resolve({\n code: typeof status === 'number' ? status : -1,\n stdout: String(stdout ?? ''),\n stderr: String(stderr ?? ''),\n spawnError: (error as NodeJS.ErrnoException).code ?? (error instanceof Error ? error.name : undefined),\n })\n } else {\n resolve({ code: 0, stdout: String(stdout ?? ''), stderr: String(stderr ?? '') })\n }\n },\n )\n })\n}\n\nconst DEFAULT_TIMEOUT_MS = 30_000\nconst DEFAULT_LIMIT = 10\nconst SERP_CHROME_HOST = 'duckduckgo.com'\n\nexport interface Browser39EngineOptions {\n /** Binary path (default 'browser39' \u2014 resolved on PATH by execFile; the\n * core's BROWSER39_BIN convention is honored at the config layer). */\n bin: string\n runner?: Browser39Runner\n timeoutMs?: number\n}\n\ninterface SerpLink {\n i?: unknown\n text?: unknown\n href?: unknown\n}\n\ninterface SerpPage {\n url?: unknown\n title?: unknown\n status?: unknown\n links?: unknown\n}\n\n/** Unwrap a SERP href to a candidate result URL, or null when it is not one:\n * relative/non-http hrefs \u2192 null; `duckduckgo.com/l/?uddg=\u2026` \u2192 the decoded\n * target (must be http(s)); `duckduckgo.com` site chrome (incl. a target\n * that decodes back to duckduckgo.com) \u2192 null; anything else \u2192 as-is. */\nexport function unwrapSerpHref(href: string): string | null {\n let u: URL\n try {\n u = new URL(href)\n } catch {\n return null\n }\n if (u.protocol !== 'http:' && u.protocol !== 'https:') return null\n if (u.hostname.toLowerCase() !== SERP_CHROME_HOST) return u.toString()\n // DDG host: only /l/ redirect wrappers with a valid uddg target count.\n if (u.pathname !== '/l/') return null\n const target = u.searchParams.get('uddg')\n if (!target) return null\n let t: URL\n try {\n t = new URL(target)\n } catch {\n return null\n }\n if (t.protocol !== 'http:' && t.protocol !== 'https:') return null\n if (t.hostname.toLowerCase() === SERP_CHROME_HOST) return null\n return t.toString()\n}\n\n/** Map a fetch-shaped SERP page to result hits (deduped, limited). Exported\n * for the smoke (pure, no I/O). */\nexport function mapSerpPage(page: SerpPage, limit: number): DiscoveryHit[] {\n const links = Array.isArray(page.links) ? (page.links as SerpLink[]) : []\n const seen = new Set<string>()\n const hits: DiscoveryHit[] = []\n for (const link of links) {\n if (hits.length >= limit) break\n const href = typeof link.href === 'string' ? link.href : ''\n const url = unwrapSerpHref(href)\n if (!url) continue\n const key = url.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n const hit: DiscoveryHit = { url }\n const title = typeof link.text === 'string' && link.text.trim() !== '' ? link.text.trim() : undefined\n if (title) hit.title = title\n hits.push(hit)\n }\n return hits\n}\n\nexport function createBrowser39Engine(opts: Browser39EngineOptions): DiscoveryEngine {\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const runner = opts.runner ?? defaultRunner(timeoutMs)\n\n return {\n kind: 'browser39',\n async search(query: string, searchOpts: SearchOptions = {}): Promise<DiscoveryHit[]> {\n const limit = searchOpts.limit ?? DEFAULT_LIMIT\n let result: Browser39CliResult\n try {\n result = await runner(opts.bin, ['search', query, '--output', 'json', '--no-persist'])\n } catch (error) {\n throw new DiscoveryEngineError(\n 'browser39_missing',\n `browser39 search failed to run: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n const spawnError = result.spawnError\n if (spawnError === 'ENOENT' || (spawnError === undefined && result.code === -1 && result.stdout === '' && result.stderr !== '' && /ENOENT/.test(result.stderr))) {\n throw new DiscoveryEngineError('browser39_missing', `browser39 binary not found: ${opts.bin}`)\n }\n if (result.code !== 0) {\n const tail = result.stderr.trim().split('\\n').slice(-3).join(' ')\n throw new DiscoveryEngineError('browser39_failed', `browser39 search exited ${result.code}: ${tail || 'no stderr'}`)\n }\n let page: SerpPage\n try {\n page = JSON.parse(result.stdout) as SerpPage\n } catch (error) {\n throw new DiscoveryEngineError(\n 'browser39_failed',\n `browser39 search returned non-JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n if (page === null || typeof page !== 'object') {\n throw new DiscoveryEngineError('browser39_failed', 'browser39 search returned a non-object reply')\n }\n // The CLI's own structured status (the upstream engine's HTTP response).\n // A block \u2014 notably DDG's bot-challenge page, which answers HTTP 202\n // (\"select all squares containing a duck\", no result links) \u2014 must be a\n // loud failure so the tool layer falls through / reports no_engine,\n // never a silent 0-hit success. (We read the CLI's status field, not\n // the HTML.)\n const status = typeof page.status === 'number' ? page.status : 200\n if (status === 202 || status < 200 || status >= 300) {\n throw new DiscoveryEngineError(\n 'browser39_blocked',\n `browser39 search blocked by the search engine (HTTP ${status} \u2014 bot challenge or rate limit); retry later or use another engine`,\n )\n }\n return mapSerpPage(page, limit)\n },\n }\n}\n", "/**\n * DiscoveryPort (D-M7.1): the named port the companion hides both engines\n * behind. The mission core never calls an engine \u2014 it only sees URLs in /\n * URLs out (plan/M_7_discovery.md \"Companion shape\").\n *\n * Engines are OPTIONAL (D-M7.2): no SearXNG running, no `browser39 search`\n * binary \u2192 the port reports `no_engine` (D-M7.3), a supported state, not a\n * failure. The core degrades to fixtures / human-supplied URLs.\n */\n\n/** One discovered URL (D-M7.1 shape: `{url, title?, snippet?}`). */\nexport interface DiscoveryHit {\n url: string\n title?: string\n snippet?: string\n}\n\nexport type DiscoveryEngineKind = 'searxng' | 'browser39'\n\nexport const DISCOVERY_ENGINES: readonly DiscoveryEngineKind[] = ['searxng', 'browser39']\n\nexport interface SearchOptions {\n /** Max results to return (default 10). */\n limit?: number\n /** Pin one engine; absent = auto (try searxng, then browser39). */\n engine?: DiscoveryEngineKind\n}\n\n/** A concrete local engine. `search` resolves to 0..n hits (empty = no\n * results, NOT no_engine \u2014 the engine was reachable and said \"nothing\"). */\nexport interface DiscoveryEngine {\n readonly kind: DiscoveryEngineKind\n search(query: string, opts?: SearchOptions): Promise<DiscoveryHit[]>\n}\n\n/** The port shape as consumed by (future) mission-core integrations. */\nexport interface DiscoveryPort {\n search(query: string, opts?: SearchOptions): Promise<DiscoveryHit[]>\n}\n\nexport type DiscoveryErrorCode =\n /** No engine available (SearXNG unreachable / absent, browser39 binary missing). Supported state. */\n | 'no_engine'\n /** SearXNG endpoint configured but nothing answers (maps to no_engine at the tool layer). */\n | 'searxng_unreachable'\n /** browser39 binary not found (maps to no_engine at the tool layer). */\n | 'browser39_missing'\n /** browser39 binary exists but the search failed (network, engine error) \u2014 NOT no_engine. */\n | 'browser39_failed'\n /** The search engine blocked the request (e.g. DDG bot challenge \u2014 the CLI\n * reports HTTP 202 with no results). Engine-availability failure \u2192 maps to\n * no_engine at the tool layer (fall through / next engine), not search_failed. */\n | 'browser39_blocked'\n\n/** Engine-level failure with a stable code (never thrown into the tool layer\n * unrendered \u2014 the tool maps it to the `{ ok: false, error }` contract). */\nexport class DiscoveryEngineError extends Error {\n constructor(\n readonly code: DiscoveryErrorCode,\n message: string,\n ) {\n super(message)\n this.name = 'DiscoveryEngineError'\n }\n}\n", "/**\n * SearXNG engine (D-M7.2, engine 1): self-hosted SearXNG, HTTP JSON API.\n *\n * Query: GET {endpoint}/search?q=<query>&format=json\n * Reply: { query, results: [{ url, title, content, engine, category, score, \u2026 }], \u2026 }\n *\n * `endpoint` is the instance base INCLUDING any path prefix (default\n * `http://127.0.0.1:8888/searxng` \u2014 NOT :8080, that port is llama; the\n * operator hand-sets a different instance in ENV.md). The engine is *still\n * egress to upstream engines* (SearXNG fans out to Google/Bing/DDG, S6):\n * results are CANDIDATES \u2014 every candidate still passes the mission core's\n * allowlist gate when fetched.\n *\n * Absence = supported state: unreachable endpoint / non-JSON reply /\n * non-2xx \u2192 `searxng_unreachable` (the tool layer reports `no_engine`).\n * Reachable-but-empty \u2192 `[]` (the engine answered \"nothing\").\n *\n * Pure: the fetch implementation is injected (the smoke drives a local\n * stub speaking the real API shape \u2014 no network, no container).\n */\nimport { DiscoveryEngineError, type DiscoveryEngine, type DiscoveryHit, type SearchOptions } from '../discovery-port.ts'\n\nexport interface SearxngEngineOptions {\n /** Instance base incl. path prefix, e.g. `http://127.0.0.1:8888/searxng`. */\n endpoint: string\n /** Injectable fetch (default: globalThis.fetch). */\n fetchImpl?: typeof fetch\n /** Per-query timeout in ms (default 10000). */\n timeoutMs?: number\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000\nconst DEFAULT_LIMIT = 10\n\ninterface SearxngResultRow {\n url?: unknown\n title?: unknown\n content?: unknown\n}\n\nfunction asString(v: unknown): string | undefined {\n return typeof v === 'string' && v.trim() !== '' ? v : undefined\n}\n\n/** Map one SearXNG result row to the DiscoveryPort hit shape (skips rows\n * without an http(s) url). */\nexport function mapSearxngRow(row: SearxngResultRow): DiscoveryHit | null {\n const url = asString(row.url)\n if (!url) return null\n let isHttp = false\n try {\n const u = new URL(url)\n isHttp = u.protocol === 'http:' || u.protocol === 'https:'\n } catch {\n return null\n }\n if (!isHttp) return null\n const hit: DiscoveryHit = { url }\n const title = asString(row.title)\n if (title) hit.title = title\n const snippet = asString(row.content)\n if (snippet) hit.snippet = snippet\n return hit\n}\n\nexport function createSearxngEngine(opts: SearxngEngineOptions): DiscoveryEngine {\n const endpoint = opts.endpoint.replace(/\\/+$/, '')\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const fetchImpl = opts.fetchImpl ?? fetch\n\n return {\n kind: 'searxng',\n async search(query: string, searchOpts: SearchOptions = {}): Promise<DiscoveryHit[]> {\n if (!endpoint) {\n throw new DiscoveryEngineError('searxng_unreachable', 'searxng endpoint is not configured')\n }\n const limit = searchOpts.limit ?? DEFAULT_LIMIT\n const qs = new URLSearchParams({ q: query, format: 'json' })\n const res = await fetchImpl(`${endpoint}/search?${qs.toString()}`, {\n signal: AbortSignal.timeout(timeoutMs),\n headers: { accept: 'application/json' },\n }).catch((error: unknown) => {\n throw new DiscoveryEngineError(\n 'searxng_unreachable',\n `searxng unreachable at ${endpoint}: ${error instanceof Error ? error.message : String(error)}`,\n )\n })\n if (!res.ok) {\n throw new DiscoveryEngineError('searxng_unreachable', `searxng ${res.status} at ${endpoint}`)\n }\n let body: unknown\n try {\n body = await res.json()\n } catch (error) {\n throw new DiscoveryEngineError(\n 'searxng_unreachable',\n `searxng replied non-JSON from ${endpoint}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n const results = (body as { results?: unknown })?.results\n if (!Array.isArray(results)) {\n throw new DiscoveryEngineError('searxng_unreachable', `searxng reply has no results[] from ${endpoint}`)\n }\n const hits: DiscoveryHit[] = []\n for (const row of results as SearxngResultRow[]) {\n const hit = mapSearxngRow(row)\n if (hit) hits.push(hit)\n if (hits.length >= limit) break\n }\n return hits\n },\n }\n}\n", "/**\n * Discovery ledger file (the bridge to the core's optional surface).\n *\n * The companion writes `<missionRoot>/<mission_id>/discovery.json` \u2014 data the\n * mission core SURFACES (a `discovery` object on mission_status, M7 7.2).\n * The core never calls an engine; this file is the only coupling, and it is\n * one-way: companion writes, core reads.\n *\n * D-M7.4: discovered URLs are NOT ledger rows \u2014 no manifest/fetched rows, no\n * pages/ artifacts, no budget here. They become rows only when the core\n * fetches them (through the allowlist gate).\n *\n * File shape (v0):\n * {\n * \"updated_at\": \"<ISO of the last record>\",\n * \"urls\": [\n * { \"url\": \"\u2026\", \"title?\": \"\u2026\", \"snippet?\": \"\u2026\",\n * \"via\": { \"query\": \"\u2026\", \"engine\": \"searxng|browser39\", \"at\": \"<ISO>\" } }\n * ]\n * }\n *\n * Record semantics: append new URLs (deduped case-insensitively,\n * first-seen provenance wins), refresh `updated_at`, rewrite atomically\n * (temp + rename, the core's fs discipline). Absent file = nothing\n * discovered yet. Corrupt file = fail loud (never guess over operator data).\n */\nimport { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport type { DiscoveryEngineKind, DiscoveryHit } from './discovery-port.ts'\n\nexport const DISCOVERY_FILENAME = 'discovery.json'\n\nexport interface DiscoveryProvenance {\n query: string\n engine: DiscoveryEngineKind\n at: string\n}\n\nexport interface DiscoveryUrlEntry extends DiscoveryHit {\n via: DiscoveryProvenance\n}\n\nexport interface DiscoveryFile {\n updated_at: string\n urls: DiscoveryUrlEntry[]\n}\n\nexport class DiscoveryStoreError extends Error {\n constructor(\n readonly code: 'unknown_mission' | 'discovery_corrupt' | 'discovery_unwritable' | 'bad_provenance',\n message: string,\n ) {\n super(message)\n this.name = 'DiscoveryStoreError'\n }\n}\n\nexport function discoveryPath(missionDir: string): string {\n return join(missionDir, DISCOVERY_FILENAME)\n}\n\n/** Read the discovery file for a mission dir; null when absent. Corrupt \u2192\n * DiscoveryStoreError (fail loud). */\nexport function readDiscoveryFile(missionDir: string): DiscoveryFile | null {\n const path = discoveryPath(missionDir)\n let raw: string\n try {\n raw = readFileSync(path, 'utf8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null\n throw new DiscoveryStoreError('discovery_unwritable', `cannot read ${path}: ${error instanceof Error ? error.message : String(error)}`)\n }\n try {\n const parsed = JSON.parse(raw) as unknown\n if (\n parsed === null ||\n typeof parsed !== 'object' ||\n !Array.isArray((parsed as DiscoveryFile).urls) ||\n typeof (parsed as DiscoveryFile).updated_at !== 'string'\n ) {\n throw new Error('bad shape')\n }\n return parsed as DiscoveryFile\n } catch (error) {\n throw new DiscoveryStoreError('discovery_corrupt', `${path} is not valid discovery.json: ${error instanceof Error ? error.message : String(error)}`)\n }\n}\n\n/** Merge `hits` (from one query) into the mission's discovery file and\n * return the written file. `missionDir` must exist (the core owns mission\n * dirs \u2014 unknown dir = unknown_mission, never created here). */\nexport function recordDiscovery(\n missionDir: string,\n hits: DiscoveryHit[],\n via: DiscoveryProvenance,\n): DiscoveryFile {\n // `updated_at` must always land as a string: the core REJECTS a discovery\n // file without one (fail loud), so a missing `via.at` falls back to now\n // (the record moment) instead of writing a file the core cannot read.\n const at = via.at ?? new Date().toISOString()\n if (typeof at !== 'string' || at.length === 0) {\n throw new DiscoveryStoreError('bad_provenance', `via.at must be an ISO timestamp string (got ${String(via.at)})`)\n }\n const file = readDiscoveryFile(missionDir) ?? { updated_at: at, urls: [] }\n const seen = new Set(file.urls.map((u) => u.url.toLowerCase()))\n for (const hit of hits) {\n const key = hit.url.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n file.urls.push({ ...hit, via: { ...via, at } })\n }\n file.updated_at = at\n const path = discoveryPath(missionDir)\n const tmp = `${path}.tmp-${process.pid}`\n mkdirSync(dirname(path), { recursive: true })\n try {\n writeFileSync(tmp, JSON.stringify(file, null, 2) + '\\n')\n renameSync(tmp, path)\n } catch (error) {\n throw new DiscoveryStoreError('discovery_unwritable', `cannot write ${path}: ${error instanceof Error ? error.message : String(error)}`)\n }\n return file\n}\n", "/**\n * Discovery tool logic (pure): engine selection + the no_engine contract\n * (D-M7.3).\n *\n * Selection:\n * - explicit `engine` pin \u2192 that engine only; absent or unreachable \u2192\n * `no_engine` (naming the engine + why).\n * - no pin \u2192 auto: try `searxng` then `browser39` (in that order, the ones\n * present in `deps.engines`); the first engine that answers wins. ALL of\n * them absent/unreachable \u2192 `no_engine` with the combined reasons.\n *\n * `no_engine` is a SUPPORTED STATE (missing discovery is fine \u2014 the core\n * degrades to fixtures/human-supplied URLs), so it renders as a clean\n * `{ ok: false, error: 'no_engine: \u2026' }`, never a crash. A pinned or\n * auto-selected engine that EXISTS but fails a query (browser39 non-zero\n * exit) surfaces as `search_failed: \u2026` \u2014 that is a query failure, not an\n * absent engine.\n */\nimport {\n DISCOVERY_ENGINES,\n DiscoveryEngineError,\n type DiscoveryEngine,\n type DiscoveryEngineKind,\n type DiscoveryHit,\n type SearchOptions,\n} from './discovery-port.ts'\n\nexport interface DiscoveryToolDeps {\n /** Engines present by config (endpoint configured / binary expected). */\n engines: Partial<Record<DiscoveryEngineKind, DiscoveryEngine>>\n}\n\nexport type DiscoveryToolResult =\n | { ok: true; query: string; engine: DiscoveryEngineKind; count: number; urls: DiscoveryHit[] }\n | { ok: false; error: string }\n\nfunction engineReason(kind: DiscoveryEngineKind, error: DiscoveryEngineError): string {\n switch (error.code) {\n case 'searxng_unreachable':\n return 'searxng not running at the configured endpoint'\n case 'browser39_missing':\n return 'browser39 search binary not found'\n case 'browser39_blocked':\n return 'browser39 blocked by the search engine (bot challenge / rate limit)'\n default:\n return `${kind} engine error (${error.code})`\n }\n}\n\nexport async function runDiscoverySearch(\n deps: DiscoveryToolDeps,\n rawQuery: string,\n opts: SearchOptions = {},\n): Promise<DiscoveryToolResult> {\n const query = rawQuery.trim()\n if (!query) {\n return { ok: false, error: 'query_required: pass a non-empty search query' }\n }\n const limit = opts.limit ?? 10\n\n const candidates: DiscoveryEngineKind[] = opts.engine\n ? [opts.engine]\n : DISCOVERY_ENGINES.filter((k) => deps.engines[k] !== undefined)\n\n if (candidates.length === 0) {\n return {\n ok: false,\n error:\n 'no_engine: no discovery engines configured ' +\n '(searxng endpoint not configured; browser39 search not configured) ' +\n '\u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)',\n }\n }\n\n const failures: string[] = []\n for (const kind of candidates) {\n const engine = deps.engines[kind]\n if (!engine) {\n failures.push(\n kind === 'searxng' ? 'searxng endpoint not configured' : 'browser39 search not configured',\n )\n continue\n }\n try {\n const urls = await engine.search(query, { limit })\n return { ok: true, query, engine: engine.kind, count: urls.length, urls }\n } catch (error) {\n if (\n error instanceof DiscoveryEngineError &&\n (error.code === 'searxng_unreachable' || error.code === 'browser39_missing' || error.code === 'browser39_blocked')\n ) {\n failures.push(engineReason(engine.kind, error))\n continue\n }\n if (error instanceof DiscoveryEngineError && error.code === 'browser39_failed') {\n return { ok: false, error: `search_failed: ${error.message}` }\n }\n // Unexpected engine-internal error \u2014 surface it, don't loop on it.\n return {\n ok: false,\n error: `search_failed: ${error instanceof Error ? error.message : String(error)}`,\n }\n }\n }\n\n const reason =\n candidates.length === 1 && opts.engine\n ? `${opts.engine}: ${failures[0] ?? 'unavailable'}`\n : failures.join('; ')\n return { ok: false, error: `no_engine: ${reason} \u2014 missing discovery is a supported state; supply URLs directly (fixtures or manual)` }\n}\n", "/**\n * Host half of dsh-web-discovery (the M7 companion to dsh-web-missions).\n *\n * - `inject: ['tools']` \u2014 tool-only companion: `discovery_search` must work\n * in headless agent sessions (no web face; the client stub is no-op for\n * C9 shape parity).\n * - The mission core never calls an engine (V5 encapsulation): this plugin\n * owns both engines (SearXNG HTTP JSON + browser39 search CLI) behind the\n * DiscoveryPort and hands the core one-way data (discovery.json in the\n * mission dir \u2014 surfaced by mission_status in M7 7.2).\n * - apply must never throw: registration degrades to a logged error.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { PLUGIN, VERSION } from '../shared/types.ts'\nimport { registerDiscoveryTools } from './tools.ts'\n\nexport const name = PLUGIN\nexport const inject = ['tools']\n\nexport { PLUGIN, VERSION }\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nexport function apply(ctx: Context): void {\n try {\n const disposeTools = registerDiscoveryTools(ctx)\n // Cordis: return the disposer \u2014 calling disposeTools() here unregisters\n // discovery_search immediately on apply (same scar as web-missions).\n ctx.effect(() => disposeTools, 'web-discovery: tools')\n } catch (error) {\n ctx.logger?.(PLUGIN).warn('tool registration failed (continuing without it): %s', errorMessage(error))\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAEO,IAAM,SAAS;AACf,IAAM,UAAU;;;ACoBvB,SAAS,kBAAkB;AAC3B,SAAS,QAAAA,aAAY;;;ACTrB,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AAUd,IAAM,aAAa;AACnB,IAAM,kBAAkB;AAGxB,IAAM,2BAA2B;AAEjC,IAAM,wBAAwB;AAE9B,IAAM,iBAAkC;AAAA,EAC7C,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAEO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,YACW,MACT,SACA;AACA,UAAM,OAAO;AAHJ;AAIT,SAAK,OAAO;AAAA,EACd;AACF;AAMA,IAAM,SAA+B;AAAA,E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