webveil 0.0.0 → 0.1.1

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.
Files changed (78) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +326 -0
  3. package/dist/cli.d.ts +58 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +91 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/core/backends/custom.d.ts +15 -0
  8. package/dist/core/backends/custom.d.ts.map +1 -0
  9. package/dist/core/backends/custom.js +106 -0
  10. package/dist/core/backends/custom.js.map +1 -0
  11. package/dist/core/backends/registry.d.ts +13 -0
  12. package/dist/core/backends/registry.d.ts.map +1 -0
  13. package/dist/core/backends/registry.js +31 -0
  14. package/dist/core/backends/registry.js.map +1 -0
  15. package/dist/core/backends/searxng.d.ts +8 -0
  16. package/dist/core/backends/searxng.d.ts.map +1 -0
  17. package/dist/core/backends/searxng.js +43 -0
  18. package/dist/core/backends/searxng.js.map +1 -0
  19. package/dist/core/backends/tavily-compat.d.ts +10 -0
  20. package/dist/core/backends/tavily-compat.d.ts.map +1 -0
  21. package/dist/core/backends/tavily-compat.js +85 -0
  22. package/dist/core/backends/tavily-compat.js.map +1 -0
  23. package/dist/core/backends/types.d.ts +48 -0
  24. package/dist/core/backends/types.d.ts.map +1 -0
  25. package/dist/core/backends/types.js +5 -0
  26. package/dist/core/backends/types.js.map +1 -0
  27. package/dist/core/baseurl.d.ts +42 -0
  28. package/dist/core/baseurl.d.ts.map +1 -0
  29. package/dist/core/baseurl.js +79 -0
  30. package/dist/core/baseurl.js.map +1 -0
  31. package/dist/core/config.d.ts +39 -0
  32. package/dist/core/config.d.ts.map +1 -0
  33. package/dist/core/config.js +72 -0
  34. package/dist/core/config.js.map +1 -0
  35. package/dist/core/egress.d.ts +46 -0
  36. package/dist/core/egress.d.ts.map +1 -0
  37. package/dist/core/egress.js +113 -0
  38. package/dist/core/egress.js.map +1 -0
  39. package/dist/core/extract.d.ts +45 -0
  40. package/dist/core/extract.d.ts.map +1 -0
  41. package/dist/core/extract.js +36 -0
  42. package/dist/core/extract.js.map +1 -0
  43. package/dist/core/fetch.d.ts +42 -0
  44. package/dist/core/fetch.d.ts.map +1 -0
  45. package/dist/core/fetch.js +76 -0
  46. package/dist/core/fetch.js.map +1 -0
  47. package/dist/core/http.d.ts +8 -0
  48. package/dist/core/http.d.ts.map +1 -0
  49. package/dist/core/http.js +49 -0
  50. package/dist/core/http.js.map +1 -0
  51. package/dist/core/search.d.ts +34 -0
  52. package/dist/core/search.d.ts.map +1 -0
  53. package/dist/core/search.js +92 -0
  54. package/dist/core/search.js.map +1 -0
  55. package/dist/core/security.d.ts +35 -0
  56. package/dist/core/security.d.ts.map +1 -0
  57. package/dist/core/security.js +141 -0
  58. package/dist/core/security.js.map +1 -0
  59. package/dist/index.d.ts +22 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +40 -0
  62. package/dist/index.js.map +1 -0
  63. package/package.json +62 -2
  64. package/src/cli.ts +106 -0
  65. package/src/core/backends/custom.ts +159 -0
  66. package/src/core/backends/registry.ts +41 -0
  67. package/src/core/backends/searxng.ts +70 -0
  68. package/src/core/backends/tavily-compat.ts +156 -0
  69. package/src/core/backends/types.ts +61 -0
  70. package/src/core/baseurl.ts +104 -0
  71. package/src/core/config.ts +106 -0
  72. package/src/core/egress.ts +134 -0
  73. package/src/core/extract.ts +82 -0
  74. package/src/core/fetch.ts +132 -0
  75. package/src/core/http.ts +62 -0
  76. package/src/core/search.ts +140 -0
  77. package/src/core/security.ts +141 -0
  78. package/src/index.ts +82 -0
@@ -0,0 +1,141 @@
1
+ // SSRF guard: the security seam wrapped AROUND the egress-bound `fetch`, so it
2
+ // covers BOTH webveil's own GETs AND distilly's rule-rewritten requests (see
3
+ // docs/adr/0001: the guard lives inside the egress fetch). Adapts the range
4
+ // classification + DNS-resolve approach of leing2021/pi-search's `security.ts`.
5
+ //
6
+ // THE RELAXATION RULE (load-bearing, recorded in the task's Decisions): the
7
+ // guard BLOCKS private/loopback/link-local/etc. addresses on DIRECT egress, and
8
+ // RELAXES ENTIRELY under a proxy egress (`http` | `socks5`). Tor/Mullvad
9
+ // legitimately reach private-looking addresses (e.g. `10.64.0.1`), AND a local
10
+ // DNS lookup for a proxied request would itself be a deanonymizing leak, so
11
+ // under a proxy we neither block nor resolve locally; the proxy owns egress.
12
+ import { lookup } from 'node:dns/promises';
13
+ import { isIP } from 'node:net';
14
+ /** Thrown when the SSRF guard refuses a request to a private/blocked address. */
15
+ export class SsrfError extends Error {
16
+ constructor(message) {
17
+ super(message);
18
+ this.name = 'SsrfError';
19
+ }
20
+ }
21
+ /** A proxy egress owns egress + DNS, so the local SSRF guard relaxes for it. */
22
+ function egressIsProxy(config) {
23
+ return config.egress.mode === 'http' || config.egress.mode === 'socks5';
24
+ }
25
+ /**
26
+ * Is this LITERAL IP private / non-public? Covers the ranges that must never be
27
+ * reachable from a direct-egress web fetch:
28
+ * IPv4: 0.0.0.0/8, 10/8 (RFC1918), 127/8 (loopback), 169.254/16 (link-local,
29
+ * incl. the 169.254.169.254 cloud metadata endpoint), 172.16/12 (RFC1918),
30
+ * 192.168/16 (RFC1918), 100.64/10 (CGNAT), 192.0.0/24, 192.0.2/24,
31
+ * 198.18/15, 198.51.100/24, 203.0.113/24, 224/4 (multicast), 240/4
32
+ * (reserved).
33
+ * IPv6: ::1 (loopback), :: (unspecified), fc00::/7 (ULA), fe80::/10
34
+ * (link-local), ff00::/8 (multicast), plus IPv4-mapped (::ffff:a.b.c.d,
35
+ * re-checked as IPv4). Default-deny: anything outside global unicast
36
+ * (2000::/3) is treated as non-public.
37
+ */
38
+ export function isPrivateIp(ip) {
39
+ const kind = isIP(ip);
40
+ if (kind === 4)
41
+ return isPrivateIpv4(ip);
42
+ if (kind === 6)
43
+ return isPrivateIpv6(ip);
44
+ return false; // not a literal IP; hostname handling resolves it first
45
+ }
46
+ function isPrivateIpv4(ip) {
47
+ const parts = ip.split('.').map((p) => Number(p));
48
+ if (parts.length !== 4 ||
49
+ parts.some((n) => !Number.isInteger(n) || n < 0 || n > 255))
50
+ return true; // malformed → treat as non-public (fail closed)
51
+ const [a, b] = parts;
52
+ if (a === 0 || a === 10 || a === 127)
53
+ return true;
54
+ if (a === 169 && b === 254)
55
+ return true; // link-local incl. cloud metadata
56
+ if (a === 172 && b >= 16 && b <= 31)
57
+ return true; // 172.16/12
58
+ if (a === 192 && b === 168)
59
+ return true; // 192.168/16
60
+ if (a === 100 && b >= 64 && b <= 127)
61
+ return true; // 100.64/10 CGNAT
62
+ if (a === 192 && b === 0)
63
+ return true; // 192.0.0/24 + 192.0.2/24
64
+ if (a === 198 && (b === 18 || b === 19))
65
+ return true; // 198.18/15 benchmark
66
+ if (a === 198 && b === 51)
67
+ return true; // 198.51.100/24 TEST-NET-2
68
+ if (a === 203 && b === 0)
69
+ return true; // 203.0.113/24 TEST-NET-3
70
+ if (a >= 224)
71
+ return true; // 224/4 multicast + 240/4 reserved
72
+ return false;
73
+ }
74
+ function isPrivateIpv6(ip) {
75
+ const lower = ip.toLowerCase();
76
+ if (lower === '::1' || lower === '::')
77
+ return true; // loopback / unspecified
78
+ // IPv4-mapped (::ffff:a.b.c.d): re-check the embedded IPv4.
79
+ const mapped = lower.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
80
+ if (mapped)
81
+ return isPrivateIpv4(mapped[1]);
82
+ const head = lower.split(':')[0] ?? '';
83
+ const first = parseInt(head || '0', 16);
84
+ if (Number.isNaN(first))
85
+ return true; // fail closed on anything unparseable
86
+ if ((first & 0xfe00) === 0xfc00)
87
+ return true; // fc00::/7 ULA
88
+ if ((first & 0xffc0) === 0xfe80)
89
+ return true; // fe80::/10 link-local
90
+ if ((first & 0xff00) === 0xff00)
91
+ return true; // ff00::/8 multicast
92
+ // Default-deny: only global unicast 2000::/3 is public.
93
+ return (first & 0xe000) !== 0x2000;
94
+ }
95
+ /**
96
+ * Assert a URL is safe to fetch under THIS config's egress. Under a proxy egress
97
+ * it always passes (the proxy owns egress + DNS). Under direct egress it rejects
98
+ * a literal private IP and, for a hostname, resolves it locally and rejects if it
99
+ * maps to a private IP (so a name pointing at 127.0.0.1 / metadata is caught).
100
+ */
101
+ export async function assertPublicUrl(url, config) {
102
+ if (egressIsProxy(config))
103
+ return; // proxy owns egress + DNS; relax entirely
104
+ let parsed;
105
+ try {
106
+ parsed = new URL(url);
107
+ }
108
+ catch {
109
+ throw new SsrfError(`webveil SSRF: malformed url ${url}`);
110
+ }
111
+ const host = parsed.hostname.replace(/^\[|\]$/g, ''); // strip IPv6 brackets
112
+ if (isIP(host)) {
113
+ if (isPrivateIp(host))
114
+ throw new SsrfError(`webveil SSRF: blocked private address ${host}`);
115
+ return;
116
+ }
117
+ // A hostname: resolve it locally (safe on direct egress) and check every
118
+ // address it maps to, so a name pointing at a private IP is also blocked.
119
+ const addrs = await lookup(host, { all: true });
120
+ for (const { address } of addrs)
121
+ if (isPrivateIp(address))
122
+ throw new SsrfError(`webveil SSRF: ${host} resolves to private address ${address}`);
123
+ }
124
+ /**
125
+ * Wrap an egress-bound `fetch` with the SSRF guard. The returned fetch checks
126
+ * EVERY request URL (so it covers distilly's rule-rewritten requests too, not
127
+ * only webveil's own GET) before delegating to the underlying egress fetch.
128
+ * This is what `core.fetch()` injects into distilly. See docs/adr/0001.
129
+ */
130
+ export function guardEgressFetch(fetch, config) {
131
+ return (async (input, init) => {
132
+ const url = typeof input === 'string'
133
+ ? input
134
+ : input instanceof URL
135
+ ? input.href
136
+ : input.url;
137
+ await assertPublicUrl(url, config);
138
+ return fetch(input, init);
139
+ });
140
+ }
141
+ //# sourceMappingURL=security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/core/security.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,yEAAy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BAAsB;IAC5E,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,IAAI,WAAW,CAAC,IAAI,CAAC;YACpB,MAAM,IAAI,SAAS,CAAC,yCAAyC,IAAI,EAAE,CAAC,CAAC;QACtE,OAAO;IACR,CAAC;IACD,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;IAC9C,KAAK,MAAM,EAAC,OAAO,EAAC,IAAI,KAAK;QAC5B,IAAI,WAAW,CAAC,OAAO,CAAC;YACvB,MAAM,IAAI,SAAS,CAClB,iBAAiB,IAAI,gCAAgC,OAAO,EAAE,CAC9D,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAkB,EAClB,MAAc;IAEd,OAAO,CAAC,KAAK,EAAE,KAAwB,EAAE,IAAkB,EAAE,EAAE;QAC9D,MAAM,GAAG,GACR,OAAO,KAAK,KAAK,QAAQ;YACxB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,KAAK,YAAY,GAAG;gBACrB,CAAC,CAAC,KAAK,CAAC,IAAI;gBACZ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QACf,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,KAAc,EAAE,IAAa,CAAC,CAAC;IAC7C,CAAC,CAAgB,CAAC;AACnB,CAAC"}
@@ -0,0 +1,22 @@
1
+ export { resolveConfig } from './core/config.js';
2
+ export type { Config, Egress, FetchSize, PartialConfig, ResolveOptions, } from './core/config.js';
3
+ export { buildDispatcher, createEgressFetch, EgressError, } from './core/egress.js';
4
+ export type { Dispatcher, EgressFetch } from './core/egress.js';
5
+ export { createHttp } from './core/http.js';
6
+ export { extract } from './core/extract.js';
7
+ export type { ExtractOptions, ExtractDeps } from './core/extract.js';
8
+ export { assertPublicUrl, guardEgressFetch, isPrivateIp, SsrfError, } from './core/security.js';
9
+ export type { Backend, Http, HttpRequestOptions, SearchResult, FetchResult, SearchOptions, FetchOptions, } from './core/backends/types.js';
10
+ export { backendNames, getBackend } from './core/backends/registry.js';
11
+ export type { BackendFactory } from './core/backends/registry.js';
12
+ export { createSearxngBackend } from './core/backends/searxng.js';
13
+ export { createTavilyCompatBackend } from './core/backends/tavily-compat.js';
14
+ export { createCustomBackend } from './core/backends/custom.js';
15
+ export type { SpawnFn } from './core/backends/custom.js';
16
+ export { search } from './core/search.js';
17
+ export type { SearchCoreOptions, SearchDeps } from './core/search.js';
18
+ export { fetch, fetchAll } from './core/fetch.js';
19
+ export type { FetchCoreOptions, FetchDeps } from './core/fetch.js';
20
+ export { createCli } from './cli.js';
21
+ export type { CliDeps } from './cli.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EACX,MAAM,EACN,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,GACd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,WAAW,GACX,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,YAAY,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,SAAS,GACT,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACX,OAAO,EACP,IAAI,EACJ,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,YAAY,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAC,gBAAgB,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,YAAY,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ // webveil — anonymous-capable, self-hosted, account-free web search + fetch for agents.
2
+ //
3
+ // This is the public surface. The framework-agnostic core lives under src/core:
4
+ // - core/config.ts : config seam (per-folder .pi/webveil.json + global + env)
5
+ // - core/egress.ts : egress seam (direct | http | socks5/Tor) — dispatcher + egress fetch
6
+ // - core/http.ts : the proxied `http` helper handed to backends
7
+ // - core/extract.ts : Extractor seam (distilly/fetch + injected egress fetch)
8
+ // - core/backends/types.ts : backend seam (the Backend interface + result shapes)
9
+ // - core/backends/registry.ts : name -> Backend dispatcher
10
+ // - core/backends/searxng.ts : the keyless self-hosted SearXNG backend
11
+ // - core/backends/tavily-compat.ts : the generic Tavily-shaped backend (/search + /extract)
12
+ // - core/search.ts : the framework-agnostic search() both frontends call
13
+ // - core/security.ts : SSRF guard wrapped around the egress fetch
14
+ // - core/fetch.ts : the framework-agnostic fetch() both frontends call
15
+ // - core/backends/custom.ts : the local-command escape hatch (JSON stdin/stdout)
16
+ // - cli.ts : the incur CLI + MCP frontend (the `webveil` bin)
17
+ // pi-webveil (sibling package) wraps the SAME core functions as registerTool
18
+ // web_search / web_fetch, in-process, as an Ollama drop-in.
19
+ // config seam
20
+ export { resolveConfig } from './core/config.js';
21
+ // egress seam
22
+ export { buildDispatcher, createEgressFetch, EgressError, } from './core/egress.js';
23
+ // http helper
24
+ export { createHttp } from './core/http.js';
25
+ // Extractor seam (distilly/fetch over webveil's egress)
26
+ export { extract } from './core/extract.js';
27
+ // SSRF guard (wrapped around the egress fetch; covers distilly's requests too)
28
+ export { assertPublicUrl, guardEgressFetch, isPrivateIp, SsrfError, } from './core/security.js';
29
+ // backend registry + implementations
30
+ export { backendNames, getBackend } from './core/backends/registry.js';
31
+ export { createSearxngBackend } from './core/backends/searxng.js';
32
+ export { createTavilyCompatBackend } from './core/backends/tavily-compat.js';
33
+ export { createCustomBackend } from './core/backends/custom.js';
34
+ // core search (the framework-agnostic search() both frontends call)
35
+ export { search } from './core/search.js';
36
+ // core fetch (the framework-agnostic fetch() + list-ready fetchAll internal)
37
+ export { fetch, fetchAll } from './core/fetch.js';
38
+ // incur CLI + MCP frontend (the `webveil` bin builds and serves this)
39
+ export { createCli } from './cli.js';
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,EAAE;AACF,gFAAgF;AAChF,2FAA2F;AAC3F,uGAAuG;AACvG,+EAA+E;AAC/E,0FAA0F;AAC1F,uFAAuF;AACvF,6DAA6D;AAC7D,0EAA0E;AAC1E,8FAA8F;AAC9F,sFAAsF;AACtF,6EAA6E;AAC7E,qFAAqF;AACrF,oFAAoF;AACpF,mFAAmF;AACnF,6EAA6E;AAC7E,4DAA4D;AAE5D,cAAc;AACd,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAS/C,cAAc;AACd,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,WAAW,GACX,MAAM,kBAAkB,CAAC;AAG1B,cAAc;AACd,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE1C,wDAAwD;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAG1C,+EAA+E;AAC/E,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,SAAS,GACT,MAAM,oBAAoB,CAAC;AAa5B,qCAAqC;AACrC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAG9D,oEAAoE;AACpE,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAGxC,6EAA6E;AAC7E,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAGhD,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,4 +1,64 @@
1
1
  {
2
2
  "name": "webveil",
3
- "version": "0.0.0"
4
- }
3
+ "version": "0.1.1",
4
+ "description": "Anonymous-capable, self-hosted, account-free web search and fetch for agents. CLI + MCP (built on incur), pi-agnostic. Swappable backend and egress (direct, http proxy, socks5/Tor).",
5
+ "license": "AGPL-3.0-or-later",
6
+ "keywords": [
7
+ "web-search",
8
+ "web-fetch",
9
+ "mcp",
10
+ "cli",
11
+ "agents",
12
+ "searxng",
13
+ "tor",
14
+ "anonymous",
15
+ "self-hosted"
16
+ ],
17
+ "author": "wighawag",
18
+ "homepage": "https://github.com/wighawag/webveil/tree/main/packages/webveil#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/wighawag/webveil.git",
22
+ "directory": "packages/webveil"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/wighawag/webveil/issues"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "type": "module",
31
+ "bin": {
32
+ "webveil": "./dist/cli.js"
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "src"
43
+ ],
44
+ "dependencies": {
45
+ "@modelcontextprotocol/server": "2.0.0-alpha.2",
46
+ "distilly": "^0.1.0",
47
+ "fetch-socks": "^1.3.3",
48
+ "incur": "0.4.10",
49
+ "undici": "^7.28.0"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^25.2.0",
53
+ "as-soon": "^0.1.5",
54
+ "tsx": "^4.21.0",
55
+ "typescript": "^5.3.3",
56
+ "vitest": "^4.0.18"
57
+ },
58
+ "scripts": {
59
+ "build": "tsc",
60
+ "dev": "as-soon -w src pnpm build",
61
+ "test": "vitest run",
62
+ "test:watch": "vitest"
63
+ }
64
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ // webveil — the incur-based CLI + MCP frontend. ONE `Cli.create()` definition
3
+ // yields the CLI, an MCP server (`--mcp`), skills (`skills add`), a `--llms`
4
+ // manifest, TOON output, and token pagination for free (incur). Pi-agnostic:
5
+ // any agent (pi via pi-mcp-adapter, Claude Code, Cursor, Codex, bash) consumes
6
+ // it the same way. The `webveil` bin points at the built `dist/cli.js`.
7
+ //
8
+ // This is the THIN frontend: each command only parses argv/options and calls
9
+ // the SAME framework-agnostic core (`search()` / `fetch()`) the pi extension
10
+ // calls. The core owns config/egress/backend/extraction; this file owns no
11
+ // network logic of its own.
12
+ //
13
+ // Testability: `createCli(deps)` takes the core functions as injectable deps so
14
+ // a test wires fakes and asserts the commands call the core (via `cli.serve`
15
+ // with custom argv/stdout) WITHOUT touching the network. The bottom of the file
16
+ // builds the real CLI and serves it when run as the bin.
17
+
18
+ import {argv} from 'node:process';
19
+ import {fileURLToPath} from 'node:url';
20
+ import {Cli, z} from 'incur';
21
+ import {search as coreSearch} from './core/search.js';
22
+ import {fetch as coreFetch} from './core/fetch.js';
23
+
24
+ /**
25
+ * The two core functions the frontend wraps, seamed so tests can inject fakes.
26
+ * Defaults are the real core; a test passes spies to assert the wiring.
27
+ */
28
+ export interface CliDeps {
29
+ search?: typeof coreSearch;
30
+ fetch?: typeof coreFetch;
31
+ }
32
+
33
+ /** The size presets `fetch` accepts, mirroring the core's `FetchSize`. */
34
+ const SIZES = ['s', 'm', 'l', 'f'] as const;
35
+
36
+ /**
37
+ * Build the webveil CLI. Returns the incur `Cli` so a caller (the bin below, or
38
+ * a test) decides how to serve it. The `search`/`fetch` commands forward to the
39
+ * injected core, normalizing nothing themselves — the core already deduped,
40
+ * clamped, and size-bounded.
41
+ */
42
+ export function createCli(deps: CliDeps = {}) {
43
+ const search = deps.search ?? coreSearch;
44
+ const fetch = deps.fetch ?? coreFetch;
45
+
46
+ return Cli.create('webveil', {
47
+ description:
48
+ 'Anonymous-capable, self-hosted, account-free web search + fetch for agents.',
49
+ })
50
+ .command('search', {
51
+ description: 'Search the web via the configured backend and egress.',
52
+ args: z.object({
53
+ query: z.string().describe('The search query'),
54
+ }),
55
+ options: z.object({
56
+ maxResults: z.coerce
57
+ .number()
58
+ .optional()
59
+ .describe('Maximum number of results to return'),
60
+ }),
61
+ alias: {maxResults: 'n'},
62
+ async run(c) {
63
+ const results = await search(c.args.query, {
64
+ maxResults: c.options.maxResults,
65
+ });
66
+ return {results};
67
+ },
68
+ })
69
+ .command('fetch', {
70
+ description:
71
+ 'Fetch a URL as clean, size-bounded markdown via the configured egress.',
72
+ args: z.object({
73
+ url: z.string().describe('The URL to fetch'),
74
+ }),
75
+ options: z.object({
76
+ size: z
77
+ .enum(SIZES)
78
+ .optional()
79
+ .describe('Page-size budget preset: s | m | l | f'),
80
+ }),
81
+ alias: {size: 's'},
82
+ async run(c) {
83
+ return fetch(c.args.url, {size: c.options.size});
84
+ },
85
+ });
86
+ }
87
+
88
+ // The real CLI (also `export default` so `incur gen` can import it for typed
89
+ // CTAs). Serving is GUARDED to the bin entry below, so importing this module in
90
+ // a test never consumes `process.argv` or exits the process.
91
+ const cli = createCli();
92
+
93
+ /** True when this module is the process entry (the `webveil` bin), not imported. */
94
+ function isMain(): boolean {
95
+ const entry = argv[1];
96
+ if (!entry) return false;
97
+ try {
98
+ return fileURLToPath(import.meta.url) === entry;
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
103
+
104
+ if (isMain()) cli.serve();
105
+
106
+ export default cli;
@@ -0,0 +1,159 @@
1
+ // custom backend — the local-command escape hatch (contract lifted from
2
+ // pi-web-providers' custom-wrapper). Instead of an HTTP source, it spawns a
3
+ // configured local command, writes the request as JSON to its stdin, and parses
4
+ // `SearchResult[]` from its stdout. This lets any local script be a backend.
5
+ //
6
+ // Egress note: this backend owns its own I/O (the spawned command does whatever
7
+ // it wants), so the handed `http` helper is unused here — there is no outbound
8
+ // HTTP for webveil to proxy. It still returns the normalized SearchResult shape.
9
+ //
10
+ // Command source: the configured `baseUrl` carries the command line, parsed as a
11
+ // whitespace-separated argv (first token = executable, rest = args), matching how
12
+ // the other backends read `baseUrl` as "where results come from". (Recorded
13
+ // decision; see the task's Decisions block.)
14
+ //
15
+ // Contract:
16
+ // stdin <- JSON: {"query": string, "maxResults"?: number}
17
+ // stdout -> JSON: SearchResult[] (each {title, url, snippet?})
18
+ // Malformed stdout (non-JSON, not an array, or entries missing url/title) FAILS
19
+ // CLEARLY — it never silently returns an empty list.
20
+
21
+ import {spawn as defaultSpawn} from 'node:child_process';
22
+ import type {Config} from '../config.js';
23
+ import type {Backend, Http, SearchOptions, SearchResult} from './types.js';
24
+
25
+ /** The JSON request written to the command's stdin. */
26
+ interface CustomRequest {
27
+ query: string;
28
+ maxResults?: number;
29
+ }
30
+
31
+ /** The result of running the command: its stdout text (and exit status). */
32
+ interface CommandRun {
33
+ stdout: string;
34
+ stderr: string;
35
+ code: number | null;
36
+ }
37
+
38
+ /**
39
+ * Minimal `spawn` shape this backend needs, seamed so a test can inject a fake
40
+ * without a real subprocess. Defaults to `node:child_process` `spawn`.
41
+ */
42
+ export type SpawnFn = typeof defaultSpawn;
43
+
44
+ function str(value: unknown): string | undefined {
45
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
46
+ }
47
+
48
+ /** Parse the configured command line into [executable, ...args]. */
49
+ function parseCommand(baseUrl: string): [string, string[]] {
50
+ const parts = baseUrl.trim().split(/\s+/).filter(Boolean);
51
+ if (parts.length === 0)
52
+ throw new Error(
53
+ 'custom: no command configured (set baseUrl to the command to run)',
54
+ );
55
+ return [parts[0]!, parts.slice(1)];
56
+ }
57
+
58
+ /**
59
+ * Normalize one stdout entry into a SearchResult, FAILING CLEARLY on a malformed
60
+ * entry rather than dropping it — the custom contract is explicit, so a missing
61
+ * url/title is a contract violation the user should see, not a silent skip.
62
+ */
63
+ function toResult(entry: unknown, index: number): SearchResult {
64
+ if (typeof entry !== 'object' || entry === null)
65
+ throw new Error(
66
+ `custom: malformed output — result[${index}] is not an object`,
67
+ );
68
+ const hit = entry as Record<string, unknown>;
69
+ const url = str(hit.url);
70
+ const title = str(hit.title);
71
+ if (!url || !title)
72
+ throw new Error(
73
+ `custom: malformed output — result[${index}] is missing a url or title`,
74
+ );
75
+ const snippet = str(hit.snippet);
76
+ return snippet ? {title, url, snippet} : {title, url};
77
+ }
78
+
79
+ /** Parse the command's stdout into SearchResult[], failing clearly on garbage. */
80
+ function parseOutput(stdout: string): SearchResult[] {
81
+ const trimmed = stdout.trim();
82
+ if (trimmed.length === 0)
83
+ throw new Error('custom: command produced no output');
84
+ let parsed: unknown;
85
+ try {
86
+ parsed = JSON.parse(trimmed);
87
+ } catch (cause) {
88
+ throw new Error(
89
+ `custom: malformed output — stdout is not valid JSON: ${(cause as Error).message}`,
90
+ );
91
+ }
92
+ if (!Array.isArray(parsed))
93
+ throw new Error(
94
+ 'custom: malformed output — expected a JSON array of results',
95
+ );
96
+ return parsed.map(toResult);
97
+ }
98
+
99
+ /** Spawn the command, write the request to stdin, and collect stdout/stderr. */
100
+ function runCommand(
101
+ spawn: SpawnFn,
102
+ exe: string,
103
+ args: string[],
104
+ request: CustomRequest,
105
+ signal?: AbortSignal,
106
+ ): Promise<CommandRun> {
107
+ return new Promise<CommandRun>((resolve, reject) => {
108
+ const child = spawn(exe, args, {
109
+ stdio: ['pipe', 'pipe', 'pipe'],
110
+ signal,
111
+ });
112
+ let stdout = '';
113
+ let stderr = '';
114
+ child.stdout?.on('data', (chunk) => (stdout += String(chunk)));
115
+ child.stderr?.on('data', (chunk) => (stderr += String(chunk)));
116
+ child.on('error', (err) =>
117
+ reject(new Error(`custom: failed to spawn '${exe}': ${err.message}`)),
118
+ );
119
+ child.on('close', (code) => resolve({stdout, stderr, code}));
120
+ child.stdin?.on('error', () => {
121
+ // A command that exits before reading stdin closes the pipe; ignore the
122
+ // EPIPE here and let the close handler report via exit code/stderr.
123
+ });
124
+ child.stdin?.end(JSON.stringify(request));
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Build a custom backend bound to the configured command. The command owns its
130
+ * own I/O; webveil hands it the request as JSON on stdin and parses
131
+ * SearchResult[] from stdout, failing clearly on malformed output.
132
+ */
133
+ export function createCustomBackend(
134
+ config: Config,
135
+ spawn: SpawnFn = defaultSpawn,
136
+ ): Backend {
137
+ const [exe, args] = parseCommand(config.baseUrl);
138
+ return {
139
+ async search(
140
+ query: string,
141
+ _http: Http,
142
+ options: SearchOptions = {},
143
+ ): Promise<SearchResult[]> {
144
+ const request: CustomRequest = {query};
145
+ if (options.maxResults !== undefined)
146
+ request.maxResults = options.maxResults;
147
+ const run = await runCommand(spawn, exe, args, request, options.signal);
148
+ if (run.code !== 0)
149
+ throw new Error(
150
+ `custom: command '${exe}' exited with code ${run.code}` +
151
+ (run.stderr.trim() ? `: ${run.stderr.trim()}` : ''),
152
+ );
153
+ const results = parseOutput(run.stdout);
154
+ return options.maxResults !== undefined
155
+ ? results.slice(0, options.maxResults)
156
+ : results;
157
+ },
158
+ };
159
+ }
@@ -0,0 +1,41 @@
1
+ // backend registry — a tiny `name -> Backend` dispatcher (concept trimmed from
2
+ // pi-search-hub's registry). Each backend registers a factory keyed by its config
3
+ // `backend` name; `getBackend` resolves the name to a constructed Backend (handed
4
+ // the resolved config so it knows its instance baseUrl / apiKey) and fails clearly
5
+ // on an unknown name. Later backend tasks (tavily-compat, custom) append their own
6
+ // registrations to FACTORIES below.
7
+
8
+ import type {Config} from '../config.js';
9
+ import type {Backend} from './types.js';
10
+ import {createSearxngBackend} from './searxng.js';
11
+ import {createTavilyCompatBackend} from './tavily-compat.js';
12
+ import {createCustomBackend} from './custom.js';
13
+
14
+ /** Builds a Backend from the resolved config (knows its baseUrl / apiKey). */
15
+ export type BackendFactory = (config: Config) => Backend;
16
+
17
+ /** name -> factory. New backends add an entry here. */
18
+ const FACTORIES: Record<string, BackendFactory> = {
19
+ searxng: createSearxngBackend,
20
+ 'tavily-compat': createTavilyCompatBackend,
21
+ custom: createCustomBackend,
22
+ };
23
+
24
+ /** The backend names the registry can resolve. */
25
+ export function backendNames(): string[] {
26
+ return Object.keys(FACTORIES);
27
+ }
28
+
29
+ /**
30
+ * Resolve a backend name to a constructed Backend. Throws clearly on an unknown
31
+ * name (listing the known ones) so a misconfigured `backend` fails loud, never
32
+ * silently no-ops.
33
+ */
34
+ export function getBackend(name: string, config: Config): Backend {
35
+ const factory = FACTORIES[name];
36
+ if (!factory)
37
+ throw new Error(
38
+ `webveil: unknown backend '${name}' (known: ${backendNames().join(', ')})`,
39
+ );
40
+ return factory(config);
41
+ }
@@ -0,0 +1,70 @@
1
+ // searxng backend — the keyless, self-hosted metasearch default. Queries a
2
+ // SearXNG instance's JSON API (`/search?format=json`) THROUGH the handed `http`
3
+ // helper (never a direct fetch, so egress is not bypassable) and normalizes the
4
+ // response into SearchResult[].
5
+
6
+ import type {Config} from '../config.js';
7
+ import type {Backend, Http, SearchOptions, SearchResult} from './types.js';
8
+
9
+ /** The shape of one entry in a SearXNG JSON `results` array (subset we use). */
10
+ interface SearxngResult {
11
+ url?: unknown;
12
+ title?: unknown;
13
+ content?: unknown;
14
+ }
15
+
16
+ /** The SearXNG JSON API response (subset we use). */
17
+ interface SearxngResponse {
18
+ results?: SearxngResult[];
19
+ }
20
+
21
+ function str(value: unknown): string | undefined {
22
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
23
+ }
24
+
25
+ /** Normalize one SearXNG hit; drop entries without a usable url + title. */
26
+ function toResult(hit: SearxngResult): SearchResult | undefined {
27
+ const url = str(hit.url);
28
+ const title = str(hit.title);
29
+ if (!url || !title) return undefined;
30
+ const snippet = str(hit.content);
31
+ return snippet ? {title, url, snippet} : {title, url};
32
+ }
33
+
34
+ /** Build the SearXNG JSON search URL for a query against the instance baseUrl. */
35
+ function buildUrl(baseUrl: string, query: string): string {
36
+ const url = new URL(
37
+ 'search',
38
+ baseUrl.endsWith('/') ? baseUrl : baseUrl + '/',
39
+ );
40
+ url.searchParams.set('q', query);
41
+ url.searchParams.set('format', 'json');
42
+ return url.toString();
43
+ }
44
+
45
+ /**
46
+ * Build a SearXNG backend bound to the configured instance. The returned backend
47
+ * only ever touches the network via the injected `http` helper.
48
+ */
49
+ export function createSearxngBackend(config: Config): Backend {
50
+ const baseUrl = config.baseUrl;
51
+ return {
52
+ async search(
53
+ query: string,
54
+ http: Http,
55
+ options: SearchOptions = {},
56
+ ): Promise<SearchResult[]> {
57
+ const body = await http.fetchJson<SearxngResponse>(
58
+ buildUrl(baseUrl, query),
59
+ {headers: {accept: 'application/json'}, signal: options.signal},
60
+ );
61
+ const results = Array.isArray(body.results) ? body.results : [];
62
+ const normalized = results
63
+ .map(toResult)
64
+ .filter((r): r is SearchResult => r !== undefined);
65
+ return options.maxResults !== undefined
66
+ ? normalized.slice(0, options.maxResults)
67
+ : normalized;
68
+ },
69
+ };
70
+ }