@jayyuen66/dsh-scrapling 0.0.0-stage → 0.0.1-rc.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JayYuen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,399 @@
1
- # Temporary Holding Version
1
+ # @jayyuen66/dsh-scrapling
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English · [中文](./README.zh-CN.md)
4
+
5
+ [Scrapling](https://github.com/D4Vinci/Scrapling) web scraping for
6
+ [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh),
7
+ exposed as agent tools backed by a long-lived Python process.
8
+
9
+ ## Why this plugin exists
10
+
11
+ dsh ships `web_fetch` and `web_search`. `web_fetch` is deliberately honest and minimal:
12
+ a plain HTTP(S) GET with no JavaScript execution, an honest `User-Agent`
13
+ (`deepseek-harness/0.2.0-rc.2`, explicitly *"never a browser disguise"*), and a
14
+ turndown-based HTML-to-markdown conversion. That is a good default, but it means a
15
+ single-page application yields only its loading shell, and there is no way to ask for
16
+ "just the product table".
17
+
18
+ Measured on a page whose content exists only after JavaScript runs:
19
+
20
+ | Pipeline | Text obtained |
21
+ |---|---|
22
+ | raw HTML to text (no JS) | `SPA Shell / LOADING_PLACEHOLDER` |
23
+ | `Fetcher` (curl_cffi, still no JS) | `SPA Shell / LOADING_PLACEHOLDER` |
24
+ | `DynamicFetcher` (Playwright) | full rendered DOM, Markdown table, structured rows |
25
+
26
+ This plugin adds exactly three things dsh's built-in tools cannot do:
27
+
28
+ 1. **Browser rendering** - JavaScript execution via Playwright / patchright.
29
+ 2. **Structured extraction** - CSS/XPath selection returning data, not a wall of Markdown.
30
+ 3. **Self-healing selectors** - Scrapling's `adaptive` mode relocates an element after
31
+ the site's markup changes. Verified working: a selector that returns `None` after a
32
+ class rename returns the relocated element when `adaptive=True`.
33
+
34
+ ## Status
35
+
36
+ All eleven tools (the session family counts as four) are implemented, registered and
37
+ exercised by the test suite. Tools
38
+ are registered **conditionally**: the plugin probes what the environment can actually
39
+ do at startup and only registers tools that will work, so the model never burns a
40
+ turn on a tool that was guaranteed to fail.
41
+
42
+ | Tool | Backend | Needs a browser | Concurrency |
43
+ |---|---|---|---|
44
+ | `scrapling_fetch` | `Fetcher` (curl_cffi) | no | safe |
45
+ | `scrapling_extract` | `Selector` + CSS/XPath + `adaptive` | no | safe |
46
+ | `scrapling_render` | `DynamicFetcher` (Playwright) | yes | serialised |
47
+ | `scrapling_capture_xhr` | `capture_xhr` | yes | serialised |
48
+ | `scrapling_stealth_fetch` | `StealthyFetcher` (patchright) | yes | serialised |
49
+ | `scrapling_session_open` / `scrapling_session_fetch` / `scrapling_session_list` / `scrapling_session_close` | Scrapling session classes | depends | serialised |
50
+ | `scrapling_crawl` | Scrapling Spider framework | no | serialised, runs as a job |
51
+ | `scrapling_answer` | any of the above, plus `ctx.llm` | no (yes with `render:true`) | serialised |
52
+
53
+ `scrapling_answer` is the only tool that spends **another model call**: it fetches the page
54
+ first, then hands the text plus your question to a model and returns the conclusion instead
55
+ of the whole page. By default it follows **the model the current session is already using**
56
+ (read from the session's live request header, so a mid-session model switch is picked up),
57
+ which means the plugin does not burn a separate quota; you can pin `answerProvider` /
58
+ `answerModel` on the settings card to route page-reading to a different model.
59
+
60
+ Page text is **untrusted input** — a page can say "ignore your previous instructions". The
61
+ answer prompt frames the text explicitly as data and forbids acting on it, but that defence
62
+ is prompt-level: it lowers the risk, it does not remove it.
63
+
64
+ Everything runs against **one long-lived Python process**. That is not an
65
+ optimisation — Scrapling's session classes keep cookies, the browser engines keep a
66
+ page pool, and `adaptive` keeps a SQLite fingerprint database. A process per call
67
+ would throw all of that away.
68
+
69
+ `scrapling_crawl` returns a **job id immediately** rather than blocking: a crawl takes
70
+ minutes, a tool call has a timeout. Watch it with `job_list`, read it with
71
+ `job_output`, stop it with `job_kill`.
72
+
73
+ ## Requirements
74
+
75
+ - **Python 3.10+** with Scrapling installed, reachable via `PATH` (or set `pythonBin`).
76
+ - **Browser engines are entirely the user's responsibility.** The plugin does not
77
+ download anything. Without a browser it simply does not register the
78
+ browser-dependent tools, so the model never wastes a turn calling them.
79
+
80
+ ```sh
81
+ pip install "scrapling[rag]>=0.4.15,<0.5"
82
+ python -m playwright install chromium
83
+ ```
84
+
85
+ > **Why `rag` and not `fetchers`?** `rag` is `fetchers` plus `markdownify`, and the
86
+ > default `extractionType` is `markdown` — with plain `fetchers` the Markdown conversion
87
+ > raises `ModuleNotFoundError` on the first fetch. The Python side then tells you exactly
88
+ > which package is missing.
89
+
90
+ > **Version range**: this plugin is developed and verified against Scrapling **0.4.15**
91
+ > and depends on its `Convertor._strip_noise_tags` / `_sanitize_for_ai`, `Selector`,
92
+ > `Spider` and `SessionManager` interfaces. None of those are stable API surface, so the
93
+ > upper bound is pinned below `0.5`; outside the range the guards still run, but the
94
+ > anti-injection cleaning and the crawl path may not behave as documented.
95
+
96
+ ## Install
97
+
98
+ ```sh
99
+ dsh plugin --profile web add @jayyuen66/dsh-scrapling
100
+ ```
101
+
102
+ The plugin is also installable from the Web UI via **Sidebar -> Plugins -> Add plugin**.
103
+
104
+ ## Replacing the built-in `web_fetch` and `web_search`
105
+
106
+ The plugin registers itself as a **fetch provider** and a **search provider** on
107
+ `ctx.web`, so the built-in `web_fetch` / `web_search` tools actually run on Scrapling
108
+ instead of dsh's plain-HTTP implementation. The model still calls `web_fetch` /
109
+ `web_search` — that is what "replacing the built-in one" means here.
110
+
111
+ > **Tool names cannot be swapped; only the backend can.** `ToolRuntime.register` ends at
112
+ > `NamedEntries.insert`, which **throws** on a duplicate name
113
+ > (`tool "X" is already registered`). Registering a same-named tool is therefore closed off;
114
+ > the `ctx.web` provider seam is the supported replacement channel.
115
+
116
+ Both must be done together, or the built-in tools break:
117
+
118
+ 1. set `provideWebFetch` / `provideWebSearch` to `true` in the plugin config;
119
+ 2. set `fetchProvider` / `searchProvider` to `"scrapling"` in the **deployment** config.
120
+
121
+ > **Why both?** `ctx.web` auto-selects only when exactly one usable provider is registered.
122
+ > A second one without naming it yields `WEB_PROVIDER_AMBIGUOUS` and the tool becomes
123
+ > unavailable outright. Hence both switches default to `false`.
124
+
125
+ When `searchEndpoint` is empty the search provider's `available()` is `false` — a second
126
+ guard: enabling `provideWebSearch` without configuring an endpoint cannot displace the
127
+ built-in `web_search`.
128
+
129
+ ### Search + render in one call
130
+
131
+ Scrapling is **not** a search engine (its `google_search` option only sets a Google referer
132
+ header), so `web_search` is split in two:
133
+
134
+ - **Discovery** → a configurable search backend (deployment-level `searchEndpoint`),
135
+ expected to be SearXNG-compatible JSON: GET `<endpoint>?q=<query>&format=json` returning
136
+ `{"results": [{"url", "title", "content"}]}`. Any backend producing that shape works.
137
+ - **Reading** → this plugin's sidecar. The first `searchRenderTopN` results (3 by default)
138
+ are actually fetched and, when a browser is available, rendered through Playwright. The
139
+ body lands in `content`, the URLs in `sources`.
140
+
141
+ One `web_search` call therefore yields both "which pages are relevant" and "what those
142
+ pages actually say" — the latter being exactly the SPA content `web_fetch` structurally
143
+ cannot read. Returned URLs are re-checked one by one by this plugin's URL gate; the parsing
144
+ layer deliberately does not duplicate that policy. A page that fails to read is skipped
145
+ alone — search results routinely contain dead links.
146
+
147
+ One consequence to know: `dsh-web`'s `WebFetchBody` is a **closed** union with only
148
+ `html | text`, no `markdown`; adding a kind is a cross-package change a plugin cannot make.
149
+ So the fetch provider reports Scrapling's Markdown as `text`, which the built-in renderer
150
+ displays normally. Use `scrapling_fetch` directly when you need `html` or a CSS selector.
151
+
152
+ ## Configuration
153
+
154
+ Settings live on the **scrapling** card in the plugin detail page (Settings → Plugins →
155
+ expand this bundle). Every field marked user-editable in [`host.ts`](./host.ts) appears
156
+ there, grouped by what it is for and with a one-line "what changes if you edit this";
157
+ deployment-level fields are only settable through the `config:` block in
158
+ [`cordis.patch.yml`](./cordis.patch.yml). Setting a field back to its default saves a
159
+ **clear-override**, not a write of the same value - so when the default changes later,
160
+ that field follows along.
161
+
162
+ Notable switches:
163
+
164
+ - `pythonBin` - interpreter name or absolute path; empty means `python3` on `PATH`.
165
+ - `fetchEnabled` / `extractEnabled` / `renderEnabled` / `captureXhrEnabled` /
166
+ `sessionEnabled` / `answerEnabled` - on by default.
167
+ - `stealthEnabled` / `crawlEnabled` - **off** by default (extra browser dependency /
168
+ long-running background job).
169
+ - `extractionType` - `markdown` (default), `html` or `text`. All three paths run the
170
+ same anti-injection cleaning; `html` additionally strips event-handler attributes
171
+ (`on*`, `srcdoc`, `formaction`) and `meta refresh`, so the result is **not**
172
+ byte-for-byte raw HTML.
173
+ - `*MaxOutputChars` - per-tool output caps. `crawlMaxItems` is the deployment-side
174
+ ceiling over the model-supplied `maxPages`; an out-of-range `maxPages` (0, negative,
175
+ NaN) is passed through unchanged so the sidecar reports the parameter error rather
176
+ than this plugin silently clamping it into a legal-looking value.
177
+ - `answerProvider` / `answerModel` / `answerMaxTokens` - the model `scrapling_answer`
178
+ routes to and the per-call token ceiling. Provider and model left empty mean "follow
179
+ the model the current session is already using"; `answerMaxTokens` caps the reply.
180
+ - `mainContentOnly` / `headless` / `networkIdle` / `captureXhrPattern` /
181
+ `waitSelectorState` / `dataDir` - extraction scope, browser mode, the XHR capture
182
+ filter, the selector state a page must reach before it is read, and the sidecar
183
+ working directory. Each is documented at its declaration in [`host.ts`](./host.ts).
184
+ - `sidecarHandshakeTimeoutMs` / `fetchTimeoutMs` / `sidecarGraceMs` - the budget for the
185
+ sidecar handshake, the per-call cooperative timeout (declared as the tools' `timeoutMs`), and
186
+ how long the client waits for the process to exit after that timeout before forcing it down.
187
+ The three are on the settings card. `scrapling_crawl` is the exception: it runs as a job and
188
+ passes no timeout, because a crawl is measured in minutes and a fixed budget would tear the
189
+ process down on every success.
190
+ - `failFastOnMissingPython` - `true` (default) refuses to load when the interpreter is
191
+ unusable, because every tool needs the sidecar and a silent degrade leaves the model
192
+ discovering "all tools are missing" several turns later. `false` degrades to "all
193
+ tools unavailable" with a warning.
194
+ - `blockAds` - on by default. It stacks **on top of** the SSRF guard rather than
195
+ competing with it: the guard is registered last (so Playwright runs it first) and
196
+ yields with `route.fallback()`, leaving Scrapling's own interception handler reachable.
197
+ - `allowedHosts` - extra host names that skip the public-address check. The same setting
198
+ feeds both layers, so an explicitly allowed intranet target is not rejected by the
199
+ host-side policy before the Python side ever sees it. Pointing it at an intranet
200
+ address means giving up SSRF protection for those targets on purpose.
201
+ - `syntheticDnsRanges` - manual fallback for synthetic DNS: a comma-separated CIDR list
202
+ of your proxy's fake-IP pool. Detection is the main path and should handle it; this is
203
+ for the case where the resolver mixes synthetic and real answers. Invalid entries are
204
+ dropped rather than refusing to load - this is a fallback, and a broken one degrades to
205
+ "stay strict", not to a crash.
206
+ - `proxyUrl` - where fetches go out, e.g. `http://127.0.0.1:7890` or
207
+ `socks5://127.0.0.1:7890`, optionally with `user:pass@`. **Empty means follow the
208
+ environment.** It is a deployment-level capability and never enters a tool schema. The
209
+ resolution order is spelled out under [Proxies](#proxies).
210
+ - `proxyBypass` - host names that should connect directly, mirroring `NO_PROXY`.
211
+
212
+ **Deployment-grade knobs** (not on the settings card; set them in the `config:` block of
213
+ `cordis.patch.yml`): `requestTimeoutSeconds`, `maxUrlLength`, `browserExecutablePath`,
214
+ `browserCdpUrl`, `searchEndpoint`, `searchRenderTopN`. The first two of the browser pair are
215
+ strong capabilities - one hands Chromium a file
216
+ to execute, the other hands the browser to a debugger endpoint - so they come only from
217
+ deployment config and are unreachable from model input.
218
+
219
+ > **Settings changes need a dsh restart.** The gate policy and the sidecar environment are
220
+ > snapshotted once when the plugin is applied; edits on the settings card take effect on the
221
+ > next start.
222
+
223
+ Disabling a tool also removes its system-prompt guidance, so the model is never told
224
+ about a capability that is not registered.
225
+
226
+ ## Proxies
227
+
228
+ Where a fetch goes out, resolved in this order - **first hit wins**:
229
+
230
+ 1. `proxyBypass` or the environment's `NO_PROXY` matches this host -> direct.
231
+ 2. `proxyUrl` on the settings card is non-empty -> use it.
232
+ 3. `http_proxy` / `https_proxy` / `all_proxy` in the environment (upper case works too) ->
233
+ use the matching slot.
234
+ 4. The operating system's proxy settings (`scutil --proxy` on macOS, Internet Settings on
235
+ Windows) -> use them.
236
+ 5. Neither -> direct.
237
+
238
+ Each rung exists because leaving it out loses a class of users. The settings card is
239
+ explicit intent; environment variables cover CI, ssh sessions and `docker exec`, where a
240
+ proxy is only ever `export`ed in the shell; the OS settings are what proxy clients default
241
+ to on macOS and Windows - flip "system proxy" on in Clash Verge or Surge and every browser
242
+ on the machine is proxied, while curl_cffi has no idea system settings exist.
243
+
244
+ An explicit `proxyUrl` makes the last two rungs irrelevant: an explicit setting should
245
+ outrank an implicit source, otherwise "I set 7890 and it still goes through 1080" has
246
+ nowhere to be debugged from. The bypass list cuts across everything above it - a hit
247
+ connects directly no matter where the proxy came from.
248
+
249
+ What that looks like in practice - **with or without a proxy, the tools just work, with no
250
+ setting to fill in**:
251
+
252
+ | Your setup | Static fetching | Render / stealth / XHR |
253
+ | --- | --- | --- |
254
+ | No proxy | direct | direct |
255
+ | TUN mode (system-wide) | direct, forwarded by the TUN | same |
256
+ | `HTTPS_PROXY` exported in the shell | follows it automatically | follows it automatically |
257
+ | macOS / Windows "system proxy" switch | **follows it automatically** | follows it automatically |
258
+ | Intranet targets / internal Git | exclude with `proxyBypass` | exclude with `proxyBypass` |
259
+ | PAC (auto-config script) | not followed; stderr says to set `proxyUrl` | followed natively by the browser |
260
+
261
+ PAC is the one shape that still needs a hand-filled setting: evaluating it means
262
+ downloading a script and running JavaScript, and the dialects differ per platform, so this
263
+ plugin does not guess. When it sees one it says so on stderr instead of quietly connecting
264
+ directly.
265
+
266
+ Details worth knowing:
267
+
268
+ - **A proxy and synthetic DNS are two different problems.** A fake-IP proxy resolves
269
+ **every** domain into `198.18.0.0/15` (TUN clients often land in `100.64.0.0/10`);
270
+ neither is a public unicast range, so the gate rejects every URL and turning a proxy on
271
+ makes the plugin stop working. The plugin **detects** that class of resolver on its
272
+ own: it resolves three control names unrelated to any target - `example.com`,
273
+ `www.iana.org`, `www.wikipedia.org` - and if all of them land in one non-public pool
274
+ while staying distinct, it treats the resolver as fake-IP and **learns that pool's
275
+ boundary from the control answers**, allowing only addresses inside it.
276
+ `syntheticDnsRanges` is the manual fallback for detection failures. When detection does
277
+ not fire, the gate **stays strict**; an IP literal written into the URL is still judged
278
+ strictly, so `http://169.254.169.254/` stays blocked either way.
279
+ - **Through a proxy, a host name this machine cannot resolve is no longer rejected.** The
280
+ request never leaves this machine's network namespace, the proxy resolves the name, and
281
+ a local resolver coming up empty says nothing - while on a network with DNS filtered by
282
+ region, those are exactly the sites that need a proxy to be reachable at all. IP
283
+ literals, private answers the local resolver *can* produce, and single-label host names
284
+ (`intranet`, `router`) stay rejected.
285
+ - **WebRTC leaks are closed when proxied.** Chromium's WebRTC can send UDP around an
286
+ HTTP/SOCKS proxy, so one STUN call in a page is enough to learn the visitor's real exit
287
+ address. patchright gets `block_webrtc`; Playwright has no equivalent switch, so it goes
288
+ in as a Chromium launch flag.
289
+ - **A browser session picks its proxy once, at `session_open`**, and the whole session
290
+ shares it. The bypass list therefore does not apply per URL inside a browser session:
291
+ Playwright's proxy lives on the BrowserContext, and switching it means a new context,
292
+ which throws away the session's cookies and login state - precisely the reason a
293
+ session exists. Static sessions have no such limit and decide per request.
294
+ - **Credentials never reach a log or the capability frame.** The capability report echoes
295
+ `scheme://host:port` only, and its `source` field names which rung answered
296
+ (`settings` / `environment` / `system` / `none`) - that column is the first thing to look
297
+ at when someone reports that fetching does not work.
298
+ - **A malformed proxy address does not stop the plugin from loading.** A scheme outside
299
+ `http` / `https` / `socks4` / `socks5` / `socks5h` is logged to stderr and treated as
300
+ "not configured", rather than thrown out as a load failure.
301
+
302
+ ## Security notes
303
+
304
+ - **SSRF.** Scrapling itself has no SSRF protection. This plugin adds a URL policy on
305
+ the host side (scheme allowlist, credential rejection, length cap, rejection of an
306
+ authority containing a backslash or control characters, DNS resolution with a
307
+ whole-answer-set public-address check, and IPv4-mapped / NAT64 addresses reclassified
308
+ by their embedded IPv4) and enforces it again on the Python side. **What is judged is
309
+ what gets sent**: the gate decides on the WHATWG-normalised form and the sidecar forwards
310
+ that same normalised string, otherwise "judged A, connected to B" becomes a bypass in
311
+ its own right. The browser-side guard is registered by the plugin's own code and covers
312
+ navigation, subresources, XHR and WebSocket handshakes.
313
+
314
+ Known gaps, all stated in the open:
315
+ - **Connection pinning** (an undici-level technique) is unavailable for a non-Node
316
+ transport, leaving a TOCTOU window between validation and connect. Static fetches are
317
+ covered by curl_cffi's `follow_redirects="safe"`; browser fetches by a route handler
318
+ on the Python side.
319
+ - **NAT64 prefixes are not discovered dynamically.** dsh's built-in probes the active
320
+ prefix via the `ipv4only.arpa` sentinel; this plugin covers the two standardized
321
+ prefixes (`64:ff9b::/96`, `64:ff9b:1::/48`). Declare any operator-specific prefix via
322
+ the `nat64Prefixes` setting, otherwise a private IPv4 hidden inside IPv6 is judged as
323
+ an ordinary public IPv6. Conversely, a declared prefix applies to **every** IPv6
324
+ address, not only the ones inside the RFC 6052 segment.
325
+ - **No port allowlist** (any port allowed by default), matching dsh's own built-in
326
+ fetch provider.
327
+ - **`scrapling_crawl` re-checks addresses itself, but redirect targets still rest on
328
+ domain consistency alone.** The start URL goes through `guard.url_allowed` (the same
329
+ implementation the browser path uses, so both layers agree), the crawl session sets
330
+ `follow_redirects="safe"` so curl_cffi refuses to follow a jump into a private range, and
331
+ each page's final URL is re-checked before it enters the result set. Scrapling's
332
+ `allow_domains`, though, is a string comparison that covers links found in the page and
333
+ not redirect targets - so on that seam the host gate's start-URL check is still the only
334
+ defence.
335
+ - **WebSocket coverage depends on the Playwright version.** The guard intercepts
336
+ handshakes via `route_web_socket`. Older builds lack that method, WebSocket is then
337
+ outside the guard, and the plugin says so in the log and in the capability report
338
+ rather than degrading silently.
339
+ - **Browser binary path and CDP endpoint are deployment-grade capabilities.** They come
340
+ only from deployment config and are unreachable from model input; pointing at them
341
+ hands over "run this file" and "attach the browser to this debugger".
342
+
343
+ The host-side policy is enforced by `SidecarClient.call`, so it covers every tool and
344
+ the `web_fetch` provider alike; a rejection throws `URL_BLOCKED` before the request is
345
+ written to the pipe.
346
+ - **Browser engines ignore proxy environment variables.** Playwright does not read
347
+ `HTTP_PROXY` / `HTTPS_PROXY`, so `scrapling_render` / `scrapling_capture_xhr` /
348
+ `scrapling_stealth_fetch` connect **directly** even when the rest of the system is
349
+ routed through a proxy — a browser-bound request leaves the tunnel. curl_cffi (behind
350
+ `scrapling_fetch` and the crawler) *does* honour those variables, so the two halves
351
+ behave differently on a proxy-bound network. This is stated rather than papered over:
352
+ routing the browser through a proxy means handing the plugin a deployment-grade
353
+ capability, and shipping that without a way to check it against a live proxy would be
354
+ worse than saying so. `allowSyntheticDns` above only fixes the *gate*; it does not
355
+ change where traffic goes.
356
+ - **There are quotas; the resident resources are not unbounded.** At most 8 concurrent
357
+ sessions (of which at most 3 may be `browser`/`stealth`, each a real Chromium process), at
358
+ most 2 crawls in flight, per-page bodies clipped at `maxContentChars`, 8 MB per protocol
359
+ frame, and 16 frames of pending queue. Hitting a ceiling yields a specific error code
360
+ (`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from, rather than
361
+ exhausting the machine.
362
+ - **No code execution from the model.** `page_action`, `page_setup`, `selector_config`,
363
+ `proxy`, `executablePath` and `cdpUrl` are never exposed in any tool schema. The
364
+ browser-side network guard is
365
+ installed by plugin code, never by model input.
366
+ - **Prompt-injection scrubbing** runs unconditionally on returned content; there is no
367
+ model-facing switch to turn it off.
368
+
369
+ ## Development
370
+
371
+ ```sh
372
+ pnpm install # install dependencies
373
+ pnpm run check # typecheck + lint + build + test + format check
374
+ pnpm run build # bundles host.ts / src/client-entry.ts into host.js / client.js
375
+ pnpm run test:py # end-to-end check of the Python sidecar (needs _env/.venv)
376
+ ```
377
+
378
+ Sources are all TypeScript. `host.js` and `client.js` are **build artifacts** and are
379
+ deliberately `.js`: Node refuses to strip types for packages inside `node_modules`,
380
+ which is exactly where dsh loads the plugin from.
381
+
382
+ The artifact is **ESM-only**: `require()` will not get you the plugin. That is deliberate
383
+ (the host loads it by package name), not a defect.
384
+
385
+ At build time every package declared in `dependencies`, `peerDependencies` **or**
386
+ `devDependencies` is externalised. The ones the host provides at runtime (cordis,
387
+ dsh-tools, dsh-subprocess, dsh-jobs) must not be inlined: the bundle would otherwise
388
+ carry its own private copy, splitting module-level state, and for packages that resolve
389
+ their own `package.json` relative to `import.meta.url` it would fail to load outright with
390
+ `MODULE_NOT_FOUND`. `test/publish-manifest.test.ts` imports the built artifact and asserts
391
+ that no host package body is inlined, so both halves stay pinned.
392
+
393
+ Publishing runs through [`.github/workflows/publish.yml`](./.github/workflows/publish.yml)
394
+ (manual, OIDC trusted publishing plus `--provenance`).
395
+
396
+ ## License
397
+
398
+ MIT — see [`LICENSE`](./LICENSE). Where this package stops and third-party code begins:
399
+ [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md).