@jayyuen66/dsh-scrapling 0.1.16 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,14 +12,10 @@
12
12
  <a href="https://github.com/JayYuen666/dsh-scrapling/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/JayYuen666/dsh-scrapling/ci.yml?branch=main&style=flat-square&label=ci" alt="ci" /></a>
13
13
  <img src="https://img.shields.io/badge/license-MIT-4c1?style=flat-square" alt="MIT" />
14
14
  <img src="https://img.shields.io/badge/node-%5E24.22.3%7C%7C%3E%3D26.13.1-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
15
- <img src="https://img.shields.io/badge/dsh-%5E0.2.3--alpha.2-658EFF?style=flat-square" alt="dsh" />
15
+ <img src="https://img.shields.io/badge/dsh-%5E0.2.3--alpha.3-658EFF?style=flat-square" alt="dsh" />
16
16
  <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/powered_by_dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white" alt="powered by dsh" /></a>
17
17
  </p>
18
18
 
19
- <p align="center">
20
- <img src="https://skillicons.dev/icons?i=typescript,python,react,nodejs,vitest,githubactions" alt="tech stack" />
21
- </p>
22
-
23
19
  <p align="center">
24
20
  <a href="https://github.com/JayYuen666"><img src="https://img.shields.io/badge/GitHub-JayYuen666-181717?style=flat-square&logo=github&logoColor=white" alt="GitHub" /></a>
25
21
  <a href="mailto:cqwkkj@gmail.com"><img src="https://img.shields.io/badge/Email-cqwkkj@gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white" alt="Email" /></a>
@@ -29,34 +25,29 @@
29
25
 
30
26
  **A web-scraping extension for [dsh](https://github.com/deepseek-ai/deepseek-harness): [Scrapling](https://github.com/D4Vinci/Scrapling) as agent tools — JavaScript rendering, CSS/XPath extraction with self-healing selectors, sessions with login state, a background crawler and page Q&A. You supply the interpreter and the browser engine; everything runs in one resident Python process.**
31
27
 
32
- ## <img src="https://api.iconify.design/lucide/file-text.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Contents
28
+ ## Contents
33
29
 
34
- - [ Contents](#-contents)
35
- - [ What it does](#-what-it-does)
36
- - [ Install](#-install)
37
- - [ Shared version floor](#-shared-version-floor)
30
+ - [What it does](#what-it-does)
31
+ - [Install](#install)
38
32
  - [Runtime packs (macOS arm64)](#runtime-packs-macos-arm64)
39
- - [ Verify it is live](#-verify-it-is-live)
40
- - [ What it does not provide](#-what-it-does-not-provide)
41
- - [ Enabling it in dsh](#-enabling-it-in-dsh)
42
- - [ The tools](#-the-tools)
43
- - [Render or static](#render-or-static)
44
- - [ Replacing the built-in fetch and search](#-replacing-the-built-in-fetch-and-search)
45
- - [ MCP mode](#-mcp-mode)
46
- - [ `setup --mode` and `doctor`](#-setup---mode-and-doctor)
47
- - [ Settings](#-settings)
48
- - [ Proxies](#-proxies)
49
- - [ Security](#-security)
50
- - [ Data and privacy](#-data-and-privacy)
51
- - [ Known boundaries](#-known-boundaries)
52
- - [ FAQ](#-faq)
53
- - [ Development](#-development)
54
- - [ Feedback](#feedback)
55
- - [ License](#-license)
56
-
57
- ## <img src="https://api.iconify.design/lucide/shield.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does
58
-
59
- dsh ships `web_fetch` and `web_search`. The built-in `web_fetch` is deliberately honest and minimal: a plain HTTP(S) GET with no JavaScript execution and an honest User-Agent. That is a good default — and it means a single-page application yields only its loading shell, and there is no way to ask for "just the product table". Measured on a page whose content exists only after JavaScript runs:
33
+ - [Verify it is live](#verify-it-is-live)
34
+ - [What it does not provide](#what-it-does-not-provide)
35
+ - [Enabling it in dsh](#enabling-it-in-dsh)
36
+ - [The tools](#the-tools)
37
+ - [Replacing the built-in fetch and search](#replacing-the-built-in-fetch-and-search)
38
+ - [MCP mode](#mcp-mode)
39
+ - [Settings](#settings)
40
+ - [Proxies](#proxies)
41
+ - [Security](#security)
42
+ - [Data and privacy](#data-and-privacy)
43
+ - [Known boundaries](#known-boundaries)
44
+ - [Development](#development)
45
+ - [Feedback](#feedback)
46
+ - [License](#license)
47
+
48
+ ## What it does
49
+
50
+ dsh ships `web_fetch` and `web_search`. The built-in `web_fetch` is deliberately honest and minimal: a plain HTTP(S) GET with no JavaScript execution and an honest User-Agent. That is a good default — and it means a single-page application yields only its loading shell. Measured on a page whose content exists only after JavaScript runs:
60
51
 
61
52
  | Pipeline | Text obtained |
62
53
  |---|---|
@@ -64,15 +55,17 @@ dsh ships `web_fetch` and `web_search`. The built-in `web_fetch` is deliberately
64
55
  | `Fetcher` (curl_cffi, still no JS) | `SPA Shell / LOADING_PLACEHOLDER` |
65
56
  | browser render (patchright) | full rendered DOM, Markdown table, structured rows |
66
57
 
58
+ ![Architecture: dsh host — plugin — resident Python sidecar — SSRF-gated fetch](docs/images/architecture.svg)
59
+
67
60
  This package adds what the built-ins structurally cannot do:
68
61
 
69
62
  - **Browser rendering** — JavaScript execution via patchright.
70
63
  - **Structured extraction** — CSS/XPath selection returning data, not a wall of Markdown.
71
64
  - **Self-healing selectors** — Scrapling's `adaptive` mode relocates an element after the site's markup changes; a selector that returns `None` after a class rename returns the relocated element with `adaptive` on.
72
65
 
73
- Everything runs against **one long-lived Python process**. That is not an optimisation: Scrapling's session classes keep cookies, the browser engines keep a page pool, and `adaptive` keeps a SQLite fingerprint database — a process per call would throw all of that away. Tools are registered **conditionally**: the plugin probes what the environment can actually do at startup and registers only what will work, so the model never burns a turn on a tool that was guaranteed to fail. Every tool renders its result row through the official tool-call view slot. `scrapling_answer` is the only tool that spends **another model call** — see [The tools](#the-tools).
66
+ Everything runs against **one long-lived Python process**. That is not an optimisation: Scrapling's session classes keep cookies, the browser engines keep a page pool, and `adaptive` keeps a SQLite fingerprint database — a process per call would throw all of that away. Tools are registered **conditionally**: the plugin probes what the environment can actually do at startup and registers only what will work, so the model never burns a turn on a tool that was guaranteed to fail. Every tool renders its result row through the official tool-call view slot. `scrapling_answer` is the only tool that spends **another model call**.
74
67
 
75
- ## <img src="https://api.iconify.design/lucide/package.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Install
68
+ ## Install
76
69
 
77
70
  ```sh
78
71
  dsh plugin --profile web add @jayyuen66/dsh-scrapling
@@ -80,9 +73,9 @@ dsh plugin --profile web add @jayyuen66/dsh-scrapling
80
73
 
81
74
  Remove with `dsh plugin --profile web remove @jayyuen66/dsh-scrapling`. The package is on the public npm registry, so installation needs no credentials and no scoped-registry line.
82
75
 
83
- - **Requires Node.js `^24.22.3 || >=26.13.1`.** This is an ESM-only package, and the build entry points (`build-client.ts`, `build-host.ts`, `build-cli.ts`) are executed by `node` directly, so the floor has to sit where TypeScript type stripping is on by default (Node 22.18 up). The range itself is the host floor: `0.2.3` hosts from `alpha.2` declare Node `^24.22.3 || >=26.13.1` (Node 25 sits outside it), and a host below it never starts.
84
- - **Requires host `dsh` at the `0.2.3-alpha.2` line or later.** The requirement the host actually reads is `engines.dsh` (`^0.2.3-alpha.2`), and it decides alone; a host on a later line is refused and needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against every released host version inside the window at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
85
- - **Requires Python 3.14+ with Scrapling installed** — named by `pythonBin`, or found by the fixed chain in `lib/runtime.ts` (the managed venv `dataDir/runtime/venv`, then the bare managed interpreter `dataDir/runtime/python/<version>`, then the repository's `_env/.venv`, then `PATH`). In an installed package the `_env/.venv` leg does not exist, so after `setup --feature core --apply` the interpreter is the managed venv and otherwise the `python3` on your `PATH` (`python` on Windows); whichever one is chosen is logged at load time, and a missing Scrapling reports an error carrying the install line to copy. The two managed legs are not interchangeable: the installer drops a managed CPython and then creates `runtime/venv` from it, and every wheel (Scrapling, patchright, the official MCP server) goes into the venv — the bare interpreter has no packages at all, so using it would fail every import while the logged path still looked right.
76
+ - **Requires Node.js `^24.22.3 || >=26.13.1`.** The declared range is the host floor, not the Node 22.18 type-stripping line: `0.2.3` hosts declare that range (Node 25 sits outside it), and a host below it never starts.
77
+ - **Requires host `dsh` at the `0.2.3-alpha.3` line or later.** The requirement the host actually reads is `engines.dsh` (`^0.2.3-alpha.3`), and it decides alone; a host on a later line is refused and needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls, so the version number in this bullet is not a standing promise.
78
+ - **Requires Python 3.14+ with Scrapling installed** — named by `pythonBin`, or found by the fixed chain (managed venv on macOS arm64 → repository `_env/.venv` in a source checkout → `python3`/`python` on `PATH`). Whichever one is chosen is logged at load time, and a missing Scrapling reports an error carrying the install line to copy:
86
79
 
87
80
  ```sh
88
81
  pip install "scrapling[rag]>=0.5,<0.6"
@@ -90,14 +83,11 @@ python -m patchright install chromium
90
83
  ```
91
84
 
92
85
  - **Why `rag` and not `fetchers`:** `rag` is `fetchers` plus `markdownify`, and the default `extractionType` is `markdown` — with plain `fetchers` the first fetch raises `ModuleNotFoundError` at the Markdown conversion.
93
- - **Version range:** developed and verified against Scrapling **0.5**, through interfaces that are not stable API surface (`Selector`, `Spider`, `SessionManager`, and the converter's noise-stripping helpers). The upper bound is pinned below `0.6`; outside the range the guards still run, but the anti-injection cleaning and the crawl path may not behave as documented. In 0.5 the browser backend is patchright only (the old standalone stealth fetch is gone; its anti-detection arguments live on `scrapling_render`), `capture_xhr` became session-level recording (hence `scrapling_session_network`), and `extra_flags` became additive — this package sends none, and WebRTC leak protection is carried by the `blockWebrtc` switch.
94
- - **Without the installer, the browser engine is yours.** The optional CLI can install the verified macOS arm64 set; the plugin itself downloads nothing at load time. Without a browser it simply does not register the browser-dependent tools, so the model never wastes a turn calling them.
95
- - **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts` enforces it). Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package there becomes a real second copy whose module-level state splits from the running host's — every native tool call then throws while build and tests stay green. The host packages the artifact imports for value are required peers and stay externalized; the gate imports the built artifact and asserts that no host package body is inlined.
86
+ - **Version range:** developed and verified against Scrapling **0.5.1**, through interfaces that are not stable API surface (`Selector`, `Spider`, `SessionManager`, and the converter's noise-stripping helpers). The upper bound is pinned below `0.6`.
87
+ - **Without the installer, the browser engine is yours.** The optional CLI can install the verified macOS arm64 set; the plugin itself downloads nothing at load time. Without a browser it simply does not register the browser-dependent tools.
88
+ - **No `@deepseek-ai/*` under `dependencies`.** Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package there becomes a real second copy whose module-level state splits from the running host's. The host packages the artifact imports for value are required peers and stay externalized; `test/publish-manifest.test.ts` asserts that no host package body is inlined.
96
89
  - **The artifact is ESM-only and never committed** — `prepack` rebuilds it, so what ships is always what the current source produces.
97
-
98
- ### <img src="https://api.iconify.design/lucide/arrow-down-to-line.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Shared version floor
99
-
100
- If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the version this package declares. A lower pin installs a copy without the names the sources use, and the host then reports `N entries did not activate` together with `does not provide an export named ...` at boot - the package installs fine and never loads, and no per-repository CI run can see it.
90
+ - If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the version this package declares: a lower pin installs a copy without the names the sources use, and the host reports `N entries did not activate` with `does not provide an export named ...` at boot — the package installs fine and never loads.
101
91
 
102
92
  ## Runtime packs (macOS arm64)
103
93
 
@@ -109,42 +99,37 @@ dsh-scrapling setup --feature browser --apply
109
99
  dsh-scrapling setup --status
110
100
  ```
111
101
 
112
- - `core` installs managed Python 3.14.9, Scrapling 0.5 and its pinned wheels; `browser` adds the full Chromium build (not the headless shell).
113
- - `search`, `media`, `mcp` and `adaptive-redis` all ride on `core`'s venv: `mcp` brings the official `scrapling-mcp` server (the pinned `mcp` package; its tool set is the upstream's, not this plugin's) that `official-mcp` mode needs, and `adaptive-redis` brings the `redis` client behind `adaptiveStorage: redis`. Every pack is installable; the settings card reports each as `ready`, `missing`, `corrupt` or `installing`.
114
- - `--feature` is a dry run by default; `--apply` writes. `--repair` re-installs without touching user data, and `--uninstall <pack> [--purge]` removes runtime files; only `--purge` removes `elements_storage.db` and `downloads/`.
115
- - `--offline <dir>` installs with no network at all: `<dir>` must hold the Python archive named exactly as the manifest URL's last segment (browser and `curl -O` both keep `cpython-3.14.9+…-install_only.tar.gz`, and the percent-encoded spelling is accepted too) plus a `wheels/` directory with one wheel per pinned requirement - `pip download --only-binary=:all: --require-hashes -r py/runtime-requirements.txt -d <dir>/wheels` produces it. The hash check on the Python archive is the same one the networked path runs, and pip is invoked with `--no-index`; a missing archive or wheelhouse fails as `INSTALL_OFFLINE_ASSETS` instead of silently going online.
116
- - `setup --status` prints one JSON document: `dataDir`, `profile`, `runtime`, `packs` and `state`. With `--profile <dir>` it reads that profile's `cordis.patch.yml`, resolves the interpreter from this package's `pythonBin` and the data directory from `dataDir` (the two settings the host actually uses); `packs` and `state` are then reported for that directory — when the entry carries no `dataDir`, both fall back to the CLI's own default. Without `--profile`, `profile.path` is `null`, a note says the profile was not read, and `runtime` falls back to the CLI's own chain (managed venv → bare managed interpreter → repo `_env/.venv` → PATH `python3`). Pass `--profile` whenever you compare the card's interpreter with what `--status` reports.
117
- - The settings card can start the same install/repair/cancel actions through the `scraplingRuntime` remote when the profile has both a remote surface and a jobs backend; otherwise it prints the CLI command.
118
- - `integrationMode` is deployment-only; on a host that exposes `mcpManager` (the rc.2 web bundle) the MCP server is registered dynamically at load, while `setup --mode` prints or writes the client entry for CLI/headless profiles and `doctor` checks a profile against it — see [MCP mode](#mcp-mode). `official-mcp` starts `scrapling-mcp` from the managed venv, which the `mcp` pack provisions (`setup --feature mcp --apply`).
119
- - Only **macOS arm64** is verified. Windows, Linux and macOS x64 are blocked (B1/B2): every pack reports `blocked` and the installer refuses rather than guessing an asset path.
120
-
121
- ## <img src="https://api.iconify.design/lucide/circle-check.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Verify it is live
122
-
123
- 1. **The layer is mounted.** `dsh --profile web --dump-config` shows this package's layer line.
124
- - That command is the only accepted "it is in the layer stack" signal, and it is **not read-only** — it rewrites the profile's root assembly file. Read layer lines from stdout **and** check stderr separately: an unmatched patch target appears only on stderr, so the exit code alone proves nothing. Accept both `# == <layer>` and `# == <layer>, patched by <path>`.
125
- 2. **The startup log names the interpreter and the plan.** One line prints the probed capabilities and how many of the tools registered; the chosen interpreter path is logged at load. An interpreter that starts but lacks Scrapling is named in the log together with the pip line to copy.
126
- 3. **The settings card renders.** The plugin detail page carries the **scrapling** card with every user-editable field grouped by purpose; toggling a value enables Save, and the write returns 200.
127
- 4. **A tool round-trip.** Ask the model to fetch a JavaScript-heavy page: the result row renders in the chat through the official tool-call view. On a machine without a browser the render / capture_xhr tools are absent from the model's tool list and their guidance is gone from the skill body too — that absence is the conditional registration working, not a failure.
128
-
129
- ## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does not provide
130
-
131
- - **It is not a search engine.** Discovery runs in the Python sidecar against one of six backends (`searchBackend`: `auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng`); Scrapling's own `google_search` option only sets a referer header. Each backend needs its own setting (`tavilyApiKey`, `braveApiKey`, `serperApiKey`, `searxngEndpoint`) — a backend that is selected but not configured reports `SEARCH_AUTH` instead of silently switching to another one.
132
- - **The npm tarball bundles no interpreter or browser.** They come from your machine or from the optional CLI installer, which downloads the verified macOS arm64 set into `dataDir/runtime`; missing pieces remove the matching tools instead of being fetched at load time.
133
- - **It adds no HTTP route on the host side.** The settings card is a host config form and this package exposes no `/api` surface. The one socket that really listens is the MCP server under `integrationMode: mcp`, bound to `127.0.0.1` (`http://127.0.0.1:<mcpPort>/mcp`): any other path gets 404, a declared body over 1 MiB gets 413, a request without `Content-Length` gets 411, and the bearer token is read only from `DSH_SCRAPLING_MCP_TOKEN` — with no token set, startup prints a stderr notice that the endpoint is unauthenticated and reachable from any local process.
134
- - **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI manages runtime packs, plus the manual half of the MCP hookup for profiles without `mcpManager`: `setup --mode native|mcp|official-mcp` generates the client entry and, with `--apply`, writes it to `<dataDir>/mcp/<mode>.patch.yml` (the profile itself is never touched), while `doctor --mode` compares that entry against the profile's `cordis.patch.yml` item by item. Given `--profile`, `setup --status` reads `pythonBin` and `dataDir` from that same file.
135
-
136
- ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
137
-
138
- - `dsh.bundle.patch` points at `cordis.patch.yml`, which carries a `- id: dsh-plugin-shared` supplier row (keep it enabled; disabling it removes the cards' shared component supply) plus the `- id: scrapling` entry with the **bare package name** — the host scans `dsh.client` on bare package-name entries only. The card components come from the shared client row, externalized as `@jayyuen66/dsh-plugin-shared/client`; the host module table provides `react`, `zod` and that shared row.
139
- - The client half registers two surfaces: the settings card (on the `plugins.bundle.config` slot, keyed by the bundle package name — the host dispatches `entryKey: pkg.name`, so the card renders on this package's detail page) and one result row per tool on `tool.call.toolview`, drawn with the official tool-call view props.
140
- - The settings namespace is the entry id `scrapling`; precedence is settings-card value > registration-line `config:` > schema default. Setting a field back to its default saves a **clear-override**, not a write of the same value, so a later default change still reaches you.
141
- - Most card values are read per call — extraction and browser knobs, the four output budgets, `fetchTimeoutMs`, `answerMaxTokens`, the answer route and the search-provider settings — so a saved change reaches the **next tool call**. The assembly-time set needs a restart: the fifteen tool switches, `provideWebFetch` / `provideWebSearch`, `pythonBin`, `failFastOnMissingPython`, `dataDir`, `sidecarHandshakeTimeoutMs` / `sidecarGraceMs`, and the URL-gate / sidecar-environment values (`proxyUrl`, `proxyBypass`, `allowedHosts`, `nat64Prefixes`, `syntheticDnsRanges`).
142
- - Disabling a tool also removes its guidance, in two layers: the **resident section is a single summary** (cross-tool selection rules, naming no specific tool), while the fifteen per-tool lines are registered as a virtual skill `scrapling`. Both are re-read at each prompt assembly against the tools that scope can actually see — a machine without a browser loses the render / capture_xhr lines from the skill body, and a sidecar that never came up gets **neither the section nor the skill** (registering an empty skill would only put a catalog entry that opens to nothing). Without the host's skill service (a trimmed profile) the plugin still composes normally, it just lacks that skill and the summary drops its "full guidance lives in the skill" pointer. The section is placed next to the built-in `web_fetch` guidance.
102
+ - `core` installs managed Python 3.14.9, Scrapling 0.5.1 and its pinned wheels; `browser` adds the full Chromium build. `search`, `media`, `documents`, `mcp` and `adaptive-redis` ride on `core`'s venv: `documents` adds pinned pypdf 7.2.0, `mcp` brings the official `scrapling-mcp` server that `official-mcp` mode needs, and `adaptive-redis` brings the `redis` client. The settings card reports each pack as `ready`, `missing`, `corrupt` or `installing` and can start the same install / repair / cancel actions as a background job.
103
+ - `--feature` is a dry run by default; `--apply` writes. `--repair` re-installs without touching user data, and `--uninstall <pack> [--purge]` removes runtime files.
104
+ - `--offline <dir>` installs with no network at all (Python archive + a hash-locked `wheels/` directory); a missing asset fails as `INSTALL_OFFLINE_ASSETS` instead of silently going online. `setup --status --profile <dir>` reads that profile's `pythonBin` / `dataDir` and reports the packs for that directory.
105
+ - Only **macOS arm64** is verified. Windows, Linux and macOS x64 are blocked: every pack reports `blocked` and the installer refuses rather than guessing an asset path.
106
+
107
+ ## Verify it is live
108
+
109
+ 1. **The layer is mounted.** `dsh --profile web --dump-config` shows this package's layer line. That command is **not read-only** (it rewrites the profile's root assembly file); read stdout **and** stderr separately, and accept both `# == <layer>` and `# == <layer>, patched by <path>`.
110
+ 2. **The startup log names the interpreter and the plan.** One line prints the probed capabilities and how many of the tools registered; the chosen interpreter path is logged at load.
111
+ 3. **The settings card renders** on the plugin detail page, grouped by purpose; toggling a value enables Save, and the write returns 200.
112
+ 4. **A tool round-trip.** Ask the model to fetch a JavaScript-heavy page: the result row renders in the chat through the official tool-call view. On a machine without a browser the render / capture_xhr tools are absent from the model's tool list and their guidance is gone from the skill body too — that absence is the conditional registration working, not a failure. If **every** tool is missing, the sidecar did not start: the startup log names the chosen interpreter, and a missing Scrapling carries the `pip install` line to copy.
113
+
114
+ ## What it does not provide
115
+
116
+ - **It is not a search engine.** Discovery uses one of seven concrete backends, or `searchBackend: auto` to pick from the configured discovery paths. Six run in the Python sidecar; `deepseek` runs in Host through optional `ctx.deepseekAuth`. A selected backend without credentials reports `SEARCH_AUTH` instead of silently switching.
117
+ - **The npm tarball bundles no interpreter or browser.** They come from your machine or from the optional CLI installer; missing pieces remove the matching tools instead of being fetched at load time.
118
+ - **It adds no HTTP route on the host side.** The one socket that really listens is the MCP server under `integrationMode: mcp`, bound to `127.0.0.1`: any other path gets 404, a declared body over 1 MiB gets 411/413, and the bearer token is read only from `DSH_SCRAPLING_MCP_TOKEN` — with no token set, startup prints a stderr notice that the endpoint is unauthenticated and reachable from any local process.
119
+ - **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI manages runtime packs and the manual half of the MCP hookup (`setup --mode native|mcp|official-mcp`, `doctor --mode`).
120
+
121
+ ## Enabling it in dsh
122
+
123
+ - `dsh.bundle.patch` points at `cordis.patch.yml`, which carries a `- id: dsh-plugin-shared` supplier row (keep it enabled; disabling it removes the cards' shared component supply) plus the `- id: scrapling` entry with the **bare package name**. The card components come from the shared client row, externalized as `@jayyuen66/dsh-plugin-shared/client`; the host module table provides `react`, `zod` and that shared row.
124
+ - The client half registers two surfaces: the settings card (keyed by the bundle package name) and one result row per tool on `tool.call.toolview`, drawn with the official tool-call view props.
125
+ - The settings namespace is the entry id `scrapling`; precedence is settings-card value > registration-line `config:` > schema default. Setting a field back to its default saves a **clear-override**, not a write of the same value.
126
+ - Most card values are read per call, so a saved change reaches the **next tool call**. The assembly-time set needs a restart: the sixteen tool switches, `provideWebFetch` / `provideWebSearch`, `pythonBin`, `failFastOnMissingPython`, `dataDir`, the timeout pair, and the URL-gate / sidecar-environment values.
127
+ - Disabling a tool also removes its guidance, in two layers: the **resident section is a single summary** carried as `guidance` on every tool definition, while the sixteen per-tool lines are registered as a virtual skill `scrapling`. The host renders the section only while the viewing scope still resolves at least one of those definitions — which covers native declarations, PTC program bindings, `restrict()` and shadowing alike. In `mcp` and `official-mcp` the plugin registers the same summary as a plain section itself.
143
128
  - `scrapling_crawl` registers its own job kind, so `job_list` labels its jobs as crawls rather than shell jobs.
144
129
 
145
- ## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The tools
130
+ ## The tools
146
131
 
147
- Nineteen tools, behind fifteen settings switches (the seven session/state tools share switches), all exercised by the test suite:
132
+ Twenty tools, behind sixteen settings switches (the nine session tools share five of those switches), all exercised by the test suite:
148
133
 
149
134
  | Tool | Backend | Needs a browser | Concurrency |
150
135
  |---|---|---|---|
@@ -155,93 +140,73 @@ Nineteen tools, behind fifteen settings switches (the seven session/state tools
155
140
  | `scrapling_render` | `StealthySession` (patchright) | yes | serialised; the anti-detection switches (`solveCloudflare` / `hideCanvas` / `blockWebrtc`) live here |
156
141
  | `scrapling_capture_xhr` | one throwaway session, page-level recording | yes | serialised |
157
142
  | `scrapling_session_open` / `scrapling_session_fetch` / `scrapling_session_network` / `scrapling_session_state_save` / `scrapling_session_state_load` / `scrapling_session_list` / `scrapling_session_close` | Scrapling session classes | browser sessions only | serialised |
158
- | `scrapling_session_read` | current DOM of a browser session page | yes | serialised |
159
- | `scrapling_session_act` | structured actions on a session page (deployment gate) | yes | serialised |
143
+ | `scrapling_session_read` | current DOM text or AI-mode ARIA snapshot of a browser session page | yes | serialised |
144
+ | `scrapling_session_act` | structured actions, including selector/coordinate drag, on a session page (deployment gate) | yes | serialised |
160
145
  | `scrapling_download` | byte download into `dataDir/downloads` (deployment gate) | no | concurrent |
146
+ | `scrapling_read_document` | streamed PDF text via optional pypdf | no | concurrent; defaults to 20 MiB / 200 pages / 200000 characters |
161
147
  | `scrapling_screenshot` | PNG/JPEG screenshot handed to the attachment service | yes | serialised |
162
148
  | `scrapling_crawl` | Scrapling Spider framework (`content` / `sitemap` / `feed` / `shopify`) as a job | no | serialised |
163
149
  | `scrapling_answer` | any fetch path plus `ctx.llm` | with `render: true` | serialised |
164
150
 
165
- - **Quotas.** At most 8 open sessions (3 of them browser sessions, each a real Chromium process), 2 crawls in flight, per-page bodies clipped by `*MaxOutputChars`, 8 MB per protocol frame, 16 queued frames. A ceiling answers with a specific code (`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from.
166
- - **`scrapling_crawl` returns a job id immediately** — a crawl takes minutes and a tool call has a timeout. Watch it with `job_list`, read it with `job_output`, stop it with `job_kill`; the tool needs a jobs registry that can attach a controller, and a profile without one simply does not register it (single-page fetching is unaffected). The crawl has a wall-clock ceiling (`crawlMaxRuntimeSeconds`) and never leaves the start domain. Politeness defaults follow Scrapling's spider defaults — robots.txt is **not** obeyed, per-domain delay is 0, up to 4 requests run in parallel — and is a deployment decision, not a per-call one (see [Settings](#settings)).
167
- - **`scrapling_answer` fetches the page first, then hands the text plus your question to a model** and returns the conclusion instead of the whole page. It follows the model the current session is already using by default (read from the session's live request header, so a mid-session model switch is picked up), which burns no separate quota; pin `answerProvider` / `answerModel` to route page-reading elsewhere. Page text is **untrusted input** — the prompt frames it explicitly as data, but that defence is prompt-level: it lowers the risk, it does not remove it.
151
+ ![Tool selection: static first, render on demand, and six special cases](docs/images/tool-selection.svg)
152
+
153
+ - **Quotas.** At most 8 open sessions (3 of them browser sessions), 2 crawls in flight, per-page bodies clipped by `*MaxOutputChars`, 8 MB per protocol frame, 16 queued frames. A ceiling answers with a specific code (`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from.
154
+ - **`scrapling_crawl` returns a job id immediately.** Watch it with `job_list`, read it with `job_output`, stop it with `job_kill`; a profile without a jobs registry simply does not register it. The crawl has a wall-clock ceiling (`crawlMaxRuntimeSeconds`) and never leaves the start domain.
155
+ - **`scrapling_answer` fetches the page first, then hands the text plus your question to a model.** It follows the model the current session is already using by default; pin `answerProvider` / `answerModel` to route page-reading elsewhere. When the host exposes a model catalog and that catalog is non-empty without your pinned route, the call is refused up front with `ANSWER_MODEL_UNKNOWN` naming the provider and model; an empty, unreachable or throwing catalog never blocks a request. Page text is **untrusted input** — the prompt frames it explicitly as data, but that defence is prompt-level: it lowers the risk, it does not remove it.
156
+
157
+ ### Browser sessions, ARIA and drag
158
+
159
+ `sessionType=remote` appears only when the sidecar reports `RemoteSession` support and deployment config sets `browserCdpUrl` to a `ws://`, `wss://`, `http://` or `https://` endpoint. It connects to an already-running Chromium and creates an isolated context; the endpoint is a strong capability and never enters model input.
160
+
161
+ `scrapling_session_read` accepts `snapshotType: "text" | "aria"` (default `text`). ARIA uses Patchright's AI-mode accessibility snapshot and can be narrowed with `cssSelector`.
162
+
163
+ `scrapling_session_act` adds `type: "drag"` in two exclusive forms: selectors (`from`/`to`) or coordinates (`fromX`/`fromY`/`toX`/`toY`). It still requires `allowBrowserActions: true`.
168
164
 
169
165
  ### Render or static
170
166
 
171
167
  `scrapling_render` is much slower and heavier than `scrapling_fetch`, so start static. Two criteria:
172
168
 
173
- - **If the rendered result is shorter than the static fetch, go back to static.** Plenty of sites ship readable text from the server and then have their own script empty those containers and swap in canvas / Lottie animation — for those pages rendering can only lose content, and no wait setting brings it back. That is site behaviour, not a plugin defect.
174
- - **`waitSelector` waits for an element to appear, not for content to settle.** The element can be removed after it matched, so "the selector matched" does not mean the content is in the result.
169
+ - **If the rendered result is shorter than the static fetch, go back to static.** Sites that ship readable text and then swap it for canvas / Lottie animation can only lose content through rendering — that is site behaviour, not a plugin defect.
170
+ - **`waitSelector` waits for an element to appear, not for content to settle.** The element can be removed after it matched.
175
171
 
176
- One thing that is not a criterion but worth knowing: axis ticks inside SVG **cannot be fetched at all** — the Markdown conversion emits no `<svg>` / `<text>` nodes, so chart numbers are out of reach whichever tool you use. For actual values, go through `scrapling_capture_xhr` to locate the JSON endpoint.
172
+ One thing that is not a criterion but worth knowing: axis ticks inside SVG **cannot be fetched at all** — the Markdown conversion emits no `<svg>` / `<text>` nodes. For actual values, go through `scrapling_capture_xhr` to locate the JSON endpoint.
177
173
 
178
- ## <img src="https://api.iconify.design/lucide/arrow-right-left.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Replacing the built-in fetch and search
174
+ ## Replacing the built-in fetch and search
179
175
 
180
- The plugin registers itself as a **fetch provider** and a **search provider** on `ctx.web`, so the built-in `web_fetch` / `web_search` tools actually run on Scrapling instead of dsh's plain-HTTP implementation. The model still calls `web_fetch` / `web_search` — tool names cannot be swapped (same-name registration throws), the provider seam is the supported channel. Both providers are registered by default (`provideWebFetch` / `provideWebSearch`), but that alone displaces nothing:
176
+ The plugin registers itself as a **fetch provider** and a **search provider** on `ctx.web`, so the built-in tools can run on Scrapling instead of dsh's plain-HTTP implementation. Both providers stay registered even while the sidecar is down (the host's provider list does not filter by availability, and its ambiguity check only counts usable providers), and both declare `title` / `description` for the provider picker.
181
177
 
182
178
  1. leave `provideWebFetch` / `provideWebSearch` at their default (`true`);
183
179
  2. set `fetchProvider` / `searchProvider` to `"scrapling"` in the **deployment** config.
184
180
 
185
- A configured id wins over auto-selection, which is why step 2 is required — and with two usable providers and no id named, `ctx.web` answers `WEB_PROVIDER_AMBIGUOUS` and the tool becomes unavailable outright. Two consequences of pointing that line at this plugin:
181
+ Both content-reading paths share `webFetchStrategy` (default `auto`): `static` always reads statically; `auto` reads statically first and renders only when the body is under 200 characters; `browser` renders directly. Without a browser, `auto` stays static.
186
182
 
187
- - **If the sidecar cannot start, the built-in `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`** rather than quietly falling back to plain HTTP.
188
- - **If you later remove the plugin but leave the line in**, the built-in tools report `WEB_PROVIDER_CONFIGURED_MISSING` — go back and remove `fetchProvider` / `searchProvider` too.
189
- - **The fetch provider really applies the output budget**: a body over `fetchMaxOutputChars` is cut to a head/tail window and flagged `truncated`, not passed through with a flag. Failures keep the sidecar code prefix (`URL_BLOCKED`, `SIDECAR_TIMEOUT`, `SIDECAR_UNAVAILABLE`), so a policy refusal is distinguishable from a crash or a timeout.
183
+ A configured id wins over auto-selection, which is why step 2 is required — with two usable providers and no id named, `ctx.web` answers `WEB_PROVIDER_AMBIGUOUS` and the tool becomes unavailable outright. Two consequences of pointing that line at this plugin:
190
184
 
191
- Search is split in two, because Scrapling is not a search engine: **discovery** runs in the Python sidecar against the backend `searchBackend` names — Tavily, Bing HTML, Brave (API), Serper (API), DuckDuckGo HTML or SearXNG (JSON API); **reading** is this plugin's — the first `searchRenderTopN` results are actually fetched and, with a browser, rendered, so one `web_search` call returns both which pages matter and what they say. `auto` uses Tavily when `tavilyApiKey` is set, SearXNG when `searxngEndpoint` is set, and with neither configured it only goes to a public engine (Bing; DuckDuckGo when that backend is named explicitly) if `searchPublicFallback` is on — otherwise the provider is unavailable and `web_search` reports `SEARCH_BACKEND_MISSING` instead of querying anyone. Only Tavily and Bing have been exercised against the real endpoints here; Brave, Serper, DuckDuckGo and SearXNG are implemented to their documented request/response shapes and verified against local stubs, with real keys and real instances still unverified. Every returned URL goes through the same gate as a fetch; a page that fails to read is skipped alone, because search results routinely contain dead links.
185
+ - **If the sidecar cannot start, the built-in `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`** rather than quietly falling back to plain HTTP; if you remove the plugin but leave the line in, the built-in tools report `WEB_PROVIDER_CONFIGURED_MISSING` — go back and remove `fetchProvider` / `searchProvider` too.
186
+ - **The fetch provider really applies the output budget** and carries the sidecar error-code prefix (`URL_BLOCKED`, `SIDECAR_TIMEOUT`, `SIDECAR_UNAVAILABLE`), so a policy refusal is distinguishable from a crash or a timeout.
192
187
 
193
- One consequence to know: `dsh-web`'s fetch body is a **closed** union of `html | text` with no `markdown` kind, and adding one is a cross-package change a plugin cannot make. The fetch provider therefore reports Scrapling's Markdown as `text`, which the built-in renderer displays normally. Use `scrapling_fetch` directly when you need `html` or a CSS selector.
188
+ Search is split in two: **discovery** uses `searchBackend` (Tavily, Bing HTML, Brave, Serper, DuckDuckGo HTML, SearXNG, or DeepSeek's direct Search API through optional `ctx.deepseekAuth`); **reading** stays this plugin's — the first `searchRenderTopN` results are fetched according to `webFetchStrategy`. `auto` keeps the Tavily → SearXNG → explicitly allowed public-engine order. Source URLs are canonicalized (fragments and tracking parameters removed) and deduplicated before citation, successful discovery is cached in memory for 300 seconds with at most 128 entries (cache keys never contain key values), and every returned URL goes through the same gate as a fetch; a page that fails to read is skipped alone.
194
189
 
195
- ## <img src="https://api.iconify.design/lucide/plug-zap.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> MCP mode
190
+ ## MCP mode
196
191
 
197
- `integrationMode` selects one of three mutually exclusive tool surfaces. It is deployment configuration (the `config:` block of `cordis.patch.yml`), it is read once when the plugin is assembled, and changing it requires a restart.
192
+ `integrationMode` selects one of three mutually exclusive tool surfaces. It is deployment configuration, read once when the plugin is assembled, and changing it requires a restart.
198
193
 
199
194
  | Mode | What it registers |
200
195
  |---|---|
201
196
  | `native` (default) | the `scrapling_*` tools listed above |
202
197
  | `mcp` | no native tools; the plugin serves the same tool table over MCP |
203
- | `official-mcp` | no native tools and no server from this plugin; on a host that exposes `mcpManager` it registers the official `scrapling-mcp` dynamically, otherwise `setup` generates the `dsh-mcp-client` entry for it - it runs in its own process, with its own sessions, and **without this plugin's URL guard** |
198
+ | `official-mcp` | no native tools and no server from this plugin; it hooks the official `scrapling-mcp` — dynamically via `mcpManager` where mounted, otherwise a `dsh-mcp-client` entry. Its own process, its own sessions, **no URL guard from this plugin** |
204
199
 
205
- In `mcp` mode the server runs inside the plugin's own host process and calls the same sidecar, so the URL guard, sessions, jobs and adaptive storage are the same ones the native tools use — there is no second implementation to drift.
200
+ `mcpToolLoading` is deployment-only and defaults to `eager`, which puts the server's tools directly into the tool list. Set it to `on-demand` when those definitions are too large to send with every request: the prompt then lists each raw tool name with the first line of its description, and the model loads what it needs through `mcp__scrapling__load_tools`. Loaded tools join only the calling agent's list; subagents, forks and resumed sessions start empty. The value is passed to both dynamic registration and manual entries as `toolLoading`; changing it requires a restart, and manual entries must be regenerated with `setup --mode <mode> --profile <profileDir> --apply`.
206
201
 
207
- - **Endpoint** `http://127.0.0.1:<mcpPort>/mcp` (`mcpPort`, default `39217`). Only loopback is bound; a request whose declared body exceeds 1 MiB is refused with `413`, and any other path gets `404`. The server is stateless: each request gets its own protocol instance, so nothing survives across them.
208
- - **Auth** off by default. Set the environment variable `DSH_SCRAPLING_MCP_TOKEN` and every request must then carry `Authorization: Bearer <token>`. The token is only ever read from the environment, never from the profile, so it does not land in a config file.
209
- - **Tools** are the same `ToolDefinition` objects native registers: same JSON Schema, same argument validation, same renderers. `scrapling_answer` is not served — it routes through the model of the hosting session, which an external client does not have. `search` exists only on this surface, because an MCP client has no `ctx.web` seam. The gates are identical: with `allowBrowserActions=false` there is no `session_act`, with `allowFileDownloads=false` there is no `download`, and `search` is absent when no search backend is available.
210
- - **Results** are text content; a screenshot comes back as MCP image content instead of a host attachment. A failing tool returns `isError` with a readable message rather than dropping the connection.
211
- - **Names**: the MCP raw name is the tool name without the `scrapling_` prefix, and dsh's MCP client shows it as `mcp__scrapling__<raw>`.
212
-
213
- | Native tool | MCP raw name |
214
- |---|---|
215
- | `scrapling_fetch` | `fetch` |
216
- | `scrapling_extract` | `extract` |
217
- | `scrapling_locate` | `locate` |
218
- | `scrapling_links` | `links` |
219
- | `scrapling_render` | `render` |
220
- | `scrapling_capture_xhr` | `capture_xhr` |
221
- | `scrapling_session_open` | `session_open` |
222
- | `scrapling_session_fetch` | `session_fetch` |
223
- | `scrapling_session_network` | `session_network` |
224
- | `scrapling_session_state_save` | `session_state_save` |
225
- | `scrapling_session_state_load` | `session_state_load` |
226
- | `scrapling_session_list` | `session_list` |
227
- | `scrapling_session_close` | `session_close` |
228
- | `scrapling_crawl` | `crawl` |
229
- | `scrapling_session_read` | `session_read` |
230
- | `scrapling_session_act` | `session_act` |
231
- | `scrapling_download` | `download` |
232
- | `scrapling_screenshot` | `screenshot` |
233
- | — (`ctx.web` only) | `search` |
234
-
235
- On a host that exposes the `mcpManager` service (the rc.2 web/desktop bundle) the plugin registers its server there at load: no `dsh-mcp-client` install and no profile entry are needed, and `mcpPort` alone decides the endpoint. The manual entry below is for CLI/headless profiles, where that service is absent. If an upgraded profile still carries the manual entry, remove it when relying on dynamic registration - otherwise the manager refuses the duplicate server name and the old entry keeps serving.
236
-
237
- Connecting dsh needs `@deepseek-ai/dsh-mcp-client`, which this plugin deliberately does not depend on. Pin the exact build matching the host version - npm `latest` is older than the host's own line, and the client's peer versions are literal, so one prerelease off installs but never activates. `0.2.3-alpha.2` is the default; a host still on rc.1 takes `0.2.2-rc.1`, and `next` tracks the official beta line:
202
+ - **`mcp` mode** runs the server inside the plugin's own host process and calls the same sidecar — the URL guard, sessions, jobs and adaptive storage are the same ones the native tools use. Endpoint `http://127.0.0.1:<mcpPort>/mcp` (default `39217`), loopback only; a declared body over 1 MiB gets `413`, any other path gets `404`. Auth: set `DSH_SCRAPLING_MCP_TOKEN` and every request must carry `Authorization: Bearer <token>`; the token is only ever read from the environment. Tools are the same `ToolDefinition` objects native registers; `scrapling_answer` is not served (an external client has no session model), and a `search` tool exists only on this surface. MCP raw names drop the `scrapling_` prefix (`mcp__scrapling__fetch`, …).
203
+ - **On a host exposing `mcpManager`** (mounted by the `web-app` and `sdk-app` bundles) the plugin registers its server at load: no `dsh-mcp-client` install and no profile entry needed. If an upgraded profile still carries a manual entry, remove it when relying on dynamic registration — otherwise the manager refuses the duplicate server name.
204
+ - **Manual hookup (CLI/headless)** needs `@deepseek-ai/dsh-mcp-client` pinned to the host's exact build (`0.2.3-alpha.3` by default; `0.2.2-rc.5` / `0.2.2-rc.1` for exempted old hosts, `next` tracks the beta line):
238
205
 
239
206
  ```bash
240
- dsh plugin --profile <name> add @deepseek-ai/dsh-mcp-client@0.2.3-alpha.2
207
+ dsh plugin --profile <name> add @deepseek-ai/dsh-mcp-client@0.2.3-alpha.3
241
208
  ```
242
209
 
243
- Then add one entry to that profile's `cordis.patch.yml` — this is exactly what `dsh-scrapling setup --mode mcp` prints, so you can also let the CLI write it (drop `headers` when no token is configured):
244
-
245
210
  ```yaml
246
211
  - insert:
247
212
  - id: scrapling-mcp
@@ -251,92 +216,60 @@ Then add one entry to that profile's `cordis.patch.yml` — this is exactly what
251
216
  transport: streamable-http
252
217
  url: http://127.0.0.1:39217/mcp
253
218
  failOnStartupError: false
254
- # only with DSH_SCRAPLING_MCP_TOKEN set:
255
- # headers:
256
- # Authorization: !!js '`Bearer ${process.env.DSH_SCRAPLING_MCP_TOKEN}`'
219
+ toolLoading: eager
257
220
  ```
258
221
 
259
- `mcpPort` and that URL have to say the same thing; after changing the port, re-apply the entry.
222
+ `failOnStartupError` is `false` on purpose: the port only starts listening once the plugin has handshaked with the Python sidecar, so the first connect at host startup is bound to fail and the client's reconnect absorbs it. `mcpPort` and the URL have to say the same thing; after changing the port, re-apply the entry.
260
223
 
261
- `failOnStartupError` is `false` here on purpose: the port only starts listening once the plugin has finished handshaking with the Python sidecar, and the client throws its fiber on the **first** failed connect (`Version negotiation probe failed: connect ECONNREFUSED` → the host reports `1 entry did not activate`). Its own reconnect is on by default (500ms backoff, 10 attempts), so a first-attempt refusal is meant to be absorbed - setting this to `true` would let fiber start order decide whether the mode works. The official `stdio` entry keeps `true`: there the client spawns the server itself, so a failed connect is a real failure and should be loud.
224
+ ### `setup --mode` and `doctor`
262
225
 
263
- ### <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> `setup --mode` and `doctor`
226
+ `dsh-scrapling setup --mode mcp [--port <port>] [--with-auth] [--apply]` prints or writes the entry text to `<dataDir>/mcp/<mode>.patch.yml` (the profile itself is never touched — applying it stays your action); `dsh-scrapling doctor --mode mcp --profile <profileDir>` reads what the profile actually says and prints one line per problem (duplicate `serverName`, mode mismatches, port disagreement, a missing or wrongly pinned `dsh-mcp-client`, an official entry while `officialMcpEnabled` is off). Exit `0` is consistent, `1` names a problem, `2` is a bad argument.
264
227
 
265
- `setup --mode` writes that entry text; it never edits a profile. Without `--apply` it is a dry run, and with `--apply` it drops the text in `<dataDir>/mcp/<mode>.patch.yml` and prints the path - applying it to `cordis.patch.yml` stays your action, because the host offers no safe append API for that file (`dsh --dump-config` rewrites the profile's root config).
228
+ `setup` for `official-mcp` asks for two separate statements before it writes anything: `officialMcpEnabled: true` in the profile and `--accept-risk` on the command line (`OFFICIAL_MCP_DISABLED` / `RISK_NOT_ACCEPTED` otherwise). Both generated and dynamically registered official entries carry `startupTimeoutMs: 60000` (`OFFICIAL_MCP_STARTUP_TIMEOUT_MS`): the managed server is a Python process that imports the scrapling dependency chain on first start, so the host default of 30s can expire on a slow machine. The binary comes from the `mcp` pack (`setup --feature mcp --apply`).
266
229
 
267
- ```sh
268
- dsh-scrapling setup --mode mcp --port 45991 --with-auth --apply
269
- dsh-scrapling setup --mode native --apply # a file that deliberately contains no entry
270
- dsh-scrapling doctor --mode mcp --profile <profileDir>
271
- ```
230
+ ## Settings
231
+
232
+ Settings live on the **scrapling** card in the plugin detail page, and the card is their documentation: every field is grouped by purpose and carries a one-line "what changes if you edit this" in the host's language, so there is no second knob list in this README to drift out of date. The card's language follows the host locale; values are validated by the same schema that renders the card.
272
233
 
273
- `doctor` reads what the profile actually says - `cordis.patch.yml` plus that profile's `package.json` - and prints one line per problem: two entries under `serverName: scrapling`, this plugin's entry next to an official `stdio` one, entries that do not match the mode, an entry whose port disagrees with `--port`, a profile without `@deepseek-ai/dsh-mcp-client` or with it pinned to something other than `0.2.3-alpha.2` / `0.2.2-rc.1` / `next`, and an official entry while `officialMcpEnabled` is off. Exit `0` is "consistent", `1` names at least one problem, `2` is a bad argument. `integrationMode` itself is a plugin setting the CLI cannot read, so `--mode` is the claim being checked and has to match the deployment.
274
-
275
- `setup` for `official-mcp` asks for two separate statements before it writes anything: `officialMcpEnabled: true` in the profile and `--accept-risk` on the command line; missing either one prints `OFFICIAL_MCP_DISABLED` / `RISK_NOT_ACCEPTED` and writes nothing. At load time the host-side path is gated by `officialMcpEnabled` alone: a host exposing `mcpManager` registers the managed `scrapling-mcp` directly, while the `setup`-generated `dsh-mcp-client` entry is the fallback for CLI/headless profiles. Either path starts `<dataDir>/runtime/venv/bin/scrapling-mcp`, so run `setup --feature mcp --apply` first - see [Runtime packs](#runtime-packs-macos-arm64). When that binary is missing, `setup` prints a line saying so.
276
-
277
- ## <img src="https://api.iconify.design/lucide/sliders-horizontal.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Settings
278
-
279
- Settings live on the **scrapling** card in the plugin detail page, grouped by purpose, each field with a one-line "what changes if you edit this". The card's language follows the host locale. Values marked below live on the card; the deployment table after them is only settable through the `config:` block of `cordis.patch.yml`.
280
-
281
- | Field | Type | Default | Purpose |
282
- | --- | --- | --- | --- |
283
- | `pythonBin` | string | `""` | Interpreter name or absolute path. Empty walks the fixed chain in `lib/runtime.ts`: the managed venv `dataDir/runtime/venv` (where `setup --feature core --apply` installs every wheel), then the bare managed interpreter `dataDir/runtime/python/<version>` (an install that stopped halfway), then the repository `_env/.venv` when usable (a source checkout only), then `python3` on `PATH` (`python` on Windows) |
284
- | `failFastOnMissingPython` | boolean | `true` | Refuses to load when the sidecar process cannot start (wrong path, protocol mismatch, handshake timeout). An interpreter that starts but lacks Scrapling always degrades to "tools unavailable" with the path named in the log, whatever this switch says |
285
- | `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `screenshotEnabled` | boolean | `true` | One kill switch per tool or tool pair. `sessionStateEnabled` gates the state save / load pair, which also needs a deployment-side `sessionStateDir` |
286
- | `extractionType` | enum | `markdown` | `markdown` / `html` / `text`; all three run the same anti-injection cleaning, and `html` additionally strips event-handler attributes, so it is not byte-for-byte raw HTML |
287
- | `mainContentOnly` | boolean | `true` | Extraction scope |
288
- | `*MaxOutputChars` | natural | fetch / extract / render `200000`, xhr `120000` | Per-tool output caps. The sidecar clips by characters, the host then trims to a byte budget. `scrapling_render` and `scrapling_capture_xhr` carry XHR history **in addition** to the body, and that section is capped by the same budget separately — so one such call can return up to twice the budget |
289
- | `crawlMaxItems` | natural | `1000` | Ceiling over the model-supplied `maxPages`. An out-of-range `maxPages` is passed through so the sidecar reports the parameter error rather than this plugin silently clamping it |
290
- | `stripInlineImages` | boolean | `true` | Drops inline `data:` URI images from the body, keeping only alt text — pure token noise for the model. Code fences are left untouched; pages without inline images come back byte-identical. Stripping happens before the cap. Turn off only when the raw base64 **is** the data (colours, fingerprints) |
291
- | `headless` / `networkIdle` | boolean | `true` / `false` | Browser mode and whether a page must reach network idle before it is read |
292
- | `blockAds` | boolean | `true` | Stacks **on top of** the SSRF guard rather than competing with it: the guard is registered last (so the engine runs it first) and yields with `route.fallback()` |
293
- | `pierceShadow` | boolean | `false` | Merges open shadow roots into the body — the switch for pages that hide their text in shadow DOM. The model can also override it per call on the browser tools |
294
- | `waitSelectorState` | enum | `attached` | The state a `waitSelector` element must reach (`attached` / `detached` / `hidden` / `visible`) |
295
- | `sidecarHandshakeTimeoutMs` / `fetchTimeoutMs` / `sidecarGraceMs` | natural | `30000` / `120000` / `5000` | Handshake budget, per-call cooperative timeout (declared on the tools' `timeoutMs`), and how long the client waits for the process to exit before forcing it down. `scrapling_crawl` passes no timeout — a crawl is measured in minutes |
296
- | `dataDir` | string | `""` | Sidecar working directory (the `adaptive` fingerprint database lands here); empty = `~/.dsh-scrapling`. If it cannot be created, `failFastOnMissingPython` decides whether the plugin refuses to load or degrades to no tools |
297
- | `provideWebFetch` / `provideWebSearch` | boolean | `true` | Whether the `ctx.web` providers are registered at all — see [Replacing the built-in fetch and search](#replacing-the-built-in-fetch-and-search) |
298
- | `searchBackend` / `tavilyApiKey` | enum / secret | `auto` / `""` | Discovery backend (`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng`) and the Tavily key. `auto` uses Tavily when a key is set, SearXNG when `searxngEndpoint` is set, and only falls back to public engines when `searchPublicFallback` is on (otherwise it reports `SEARCH_BACKEND_MISSING`); a backend selected without its own key (or instance) reports `SEARCH_AUTH` |
299
- | `searchPublicFallback` | boolean | `false` | Lets `auto` fall back to the public Bing engine when neither a key nor SearXNG is configured — `py/search.py` resolves `auto` in the order `tavily` → `searxng` → `bing`. DuckDuckGo is not reachable through `auto` at all; name `searchBackend=duckduckgo` to use it. Off by default on purpose: turning it on sends query strings to a third-party public engine |
300
- | `braveApiKey` / `serperApiKey` | secret | `""` | Keys for the Brave Search and Serper.dev backends |
301
- | `searxngEndpoint` | string | `""` | Base URL of a SearXNG instance (`…/search?format=json` is appended); empty means the backend is unusable and reports `SEARCH_AUTH` |
302
- | `answerProvider` / `answerModel` / `answerMaxTokens` | string / natural | `""` / `""` / `2000` | The model `scrapling_answer` routes to and the per-reply token cap. Provider and model left empty mean "follow the model the current session is already using" |
303
- | `allowedHosts` | string | `""` | Extra host names that skip the public-address check (comma-separated). Pointing it at an intranet address means giving up SSRF protection for those targets on purpose |
304
- | `syntheticDnsRanges` | string | `""` | Manual fallback for synthetic DNS: a comma-separated CIDR list of your proxy's fake-IP pool, for resolvers that mix synthetic and real answers. Invalid entries are dropped — a broken fallback degrades to "stay strict", not to a crash |
305
- | `proxyUrl` | string | `""` | Where fetches go out (`http://…` / `socks5://…`, optionally `user:pass@`). Empty = follow the environment; see [Proxies](#proxies). Masked on the card, never enters a tool schema |
306
- | `proxyBypass` | string | `""` | Host names that connect directly, mirroring `NO_PROXY`; `*` means the whole machine goes direct |
307
- | `nat64Prefixes` | string | `""` | Extra NAT64 prefixes (comma-separated `<IPv6 prefix>/<32\|40\|48\|56\|64\|96>`) for operator-specific networks. A declared prefix is consulted for every IPv6 answer and applies to the addresses inside it. A malformed entry makes the plugin **refuse to load** (`CONFIG_INVALID`), unlike `syntheticDnsRanges` below: dropping a prefix would let a private IPv4 embedded in IPv6 through as ordinary public IPv6 |
234
+ What the card cannot tell you is the **split that decides when a change takes effect**: most values are read on every call and reach the next tool call; the values read once at assembly (the sixteen tool switches, `provideWebFetch` / `provideWebSearch`, `pythonBin`, `failFastOnMissingPython`, `dataDir`, the timeout pair, and the URL-gate / sidecar-environment values) need the host assembled again. A few switches also pair with a deployment-side setting — see [Replacing the built-in fetch and search](#replacing-the-built-in-fetch-and-search) and the deployment table below.
308
235
 
309
236
  **Deployment-only knobs** (not on the card; set them in the `config:` block of `cordis.patch.yml`):
310
237
 
311
238
  | Field | Default | Purpose |
312
239
  | --- | --- | --- |
240
+ | `integrationMode` | `native` | Tool surface selector — see [MCP mode](#mcp-mode) |
241
+ | `mcpPort` | `39217` | Port of the plugin's MCP server; must equal the URL in a manual client entry |
242
+ | `officialMcpEnabled` | `false` | Gate for hooking the upstream `scrapling-mcp` server |
243
+ | `mcpToolLoading` | `eager` | `eager` registers MCP tools directly; `on-demand` loads them via `mcp__scrapling__load_tools`. Restart required |
313
244
  | `requestTimeoutSeconds` / `maxUrlLength` | `120` / `2048` | Python-side per-request ceiling; URL length cap aligned with the built-in fetch |
314
245
  | `allowWriteMethods` | `false` | Whether the model may change state on a remote host at all — see [Security](#security) |
315
246
  | `browserExecutablePath` / `browserInitScript` | `""` | Strong capabilities: they hand Chromium a file to execute, or inject a JS file into every page. Deployment config only, unreachable from model input |
247
+ | `browserCdpUrl` | `""` | CDP endpoint for `sessionType=remote`; accepts ws/wss/http/https. Empty hides remote sessions |
316
248
  | `browserRealChrome` / `browserDnsOverHttps` | `false` | Use the locally installed Google Chrome; route the browser's DNS over HTTPS (useful with a proxy to avoid DNS leaks) |
317
- | `recordRequests` / `maxRecordedRequests` | `false` / `100` | Whether browser sessions record network history by default (the model can turn it on per session with `recordNetwork`), and how many entries a session keeps |
318
- | `sessionStateDir` | `""` | Directory for Playwright-compatible login-state files. The model can only pass a **plain file name**, so the directory stays a deployment decision; empty disables the state save / load pair |
319
- | `adaptiveStorage` | `sqlite` | Where `adaptive` fingerprints live: `sqlite` (one file under `dataDir`) or `redis` (one keyspace, shareable across processes and hosts). Deployment-only - the model only ever says "save" or "relocate" |
320
- | `redisUrl` | `redis://127.0.0.1:6379/0` | Connection string read when `adaptiveStorage: redis`. The password never reaches logs or error text; an unreachable server fails as `ADAPTIVE_STORAGE_UNAVAILABLE` |
249
+ | `recordRequests` / `maxRecordedRequests` | `false` / `100` | Whether browser sessions record network history by default, and how many entries a session keeps |
250
+ | `sessionStateDir` | `""` | Directory for Playwright-compatible login-state files. The model can only pass a **plain file name**; empty disables the state save / load pair |
251
+ | `adaptiveStorage` | `sqlite` | Where `adaptive` fingerprints live: `sqlite` (one file under `dataDir`) or `redis` (shareable across processes and hosts) |
252
+ | `redisUrl` | `redis://127.0.0.1:6379/0` | Connection string read when `adaptiveStorage: redis`. The password never reaches logs; an unreachable server degrades extraction to non-adaptive with an `ADAPTIVE_STORAGE_FAILED` notice |
321
253
  | `crawlMaxRuntimeSeconds` | `1800` | Wall-clock ceiling of one crawl — the page cap says nothing about a site that takes a minute per page |
322
- | `crawlRespectRobots` | `false` | Obey robots.txt; with it on, a domain whose robots.txt fetch **fails** (network error or HTTP 5xx) is blocked rather than assumed permitted, while a **missing** robots.txt (HTTP 404, the common case) is treated as allowing everything |
254
+ | `crawlRespectRobots` | `false` | Obey robots.txt; a domain whose robots.txt fetch **fails** is blocked, a **missing** one (HTTP 404) is treated as allowing everything |
323
255
  | `crawlDownloadDelayMs` / `crawlConcurrentRequests` / `crawlAutothrottle` / `crawlStrategy` | `0` / `4` / `false` / `bfs` | Gap between requests, parallelism, adaptive throttling, breadth- or depth-first order |
324
256
  | `crawlCheckpointDir` | `""` | Persist the crawl queue so a restarted crawl resumes instead of going back to the start URL |
325
- | `tavilyApiEndpoint` / `bingEndpoint` / `searchRenderTopN` | `https://api.tavily.com/search` / `https://www.bing.com/search` / `3` | Discovery endpoints (overridable for tests or proxies), and how many results are actually fetched and rendered (`0` = link list only) |
326
- | `duckduckgoEndpoint` | `https://html.duckduckgo.com/html/` | DuckDuckGo HTML endpoint; override for a mirror or a test stub |
327
- | `allowBrowserActions` / `allowFileDownloads` / `downloadMaxBytes` | `false` / `false` / `10485760` | Deployment-only gates for structured actions and downloads, plus the per-download byte cap. Both gates default off and also hide their tools from the model |
257
+ | `tavilyApiEndpoint` / `bingEndpoint` / `duckduckgoEndpoint` / `deepseekSearchEndpoint` | vendor defaults | Discovery endpoints, overridable for tests or proxies; HTTPS only |
258
+ | `searchRenderTopN` | `3` | How many search results are actually read according to `webFetchStrategy` (`0` = link list only) |
259
+ | `allowBrowserActions` / `allowFileDownloads` / `downloadMaxBytes` | `false` / `false` / `10485760` | Deployment-only gates for structured actions and persistent downloads, plus the per-download byte cap. Both gates default off and also hide their tools from the model |
260
+ | `documentMaxBytes` / `documentMaxPages` | `20971520` / `200` | Hard ceilings for PDF reads. Model arguments may only lower them |
328
261
 
329
- ## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Proxies
262
+ ## Proxies
330
263
 
331
264
  Where a fetch goes out, resolved in this order — **first hit wins**:
332
265
 
333
266
  1. `proxyBypass` or the environment's `NO_PROXY` matches this host -> direct.
334
267
  2. `proxyUrl` on the settings card is non-empty -> use it.
335
- 3. `http_proxy` / `https_proxy` / `all_proxy` in the environment (upper case works too) -> use the matching slot.
336
- 4. The operating system's proxy settings (`scutil --proxy` on macOS, Internet Settings on Windows) -> use them.
268
+ 3. `http_proxy` / `https_proxy` / `all_proxy` in the environment -> use the matching slot.
269
+ 4. The operating system's proxy settings (macOS `scutil --proxy`, Windows Internet Settings) -> use them.
337
270
  5. Neither -> direct.
338
271
 
339
- What that looks like in practice — **with or without a proxy, the tools just work, with no setting to fill in**:
272
+ **With or without a proxy, the tools just work, with no setting to fill in** — the resolved proxy is handed to the browser engine explicitly, because Chromium does not read `HTTP_PROXY`. What is worth knowing:
340
273
 
341
274
  | Your setup | Static fetching | Render / XHR |
342
275
  | --- | --- | --- |
@@ -347,84 +280,60 @@ What that looks like in practice — **with or without a proxy, the tools just w
347
280
  | Intranet targets / internal Git | exclude with `proxyBypass` | exclude with `proxyBypass` |
348
281
  | PAC (auto-config script) | not followed; stderr says to set `proxyUrl` | followed natively by the browser |
349
282
 
350
- Details worth knowing:
351
-
352
- - **The resolved proxy is handed to the browser engine explicitly.** Chromium does not read `HTTP_PROXY` / `ALL_PROXY`, so a proxy that is only exported in a shell would cover static fetches but not the browser — this package closes that gap by passing the resolved proxy on every browser fetch. A **browser session** still picks its proxy once, at `scrapling_session_open`: switching it means a new browser context, which throws away the session's cookies and login state — precisely the reason a session exists. Static sessions decide per request.
353
- - **PAC is the one shape that needs a hand-filled `proxyUrl`.** Evaluating a PAC script means downloading it and running JavaScript, and the dialects differ per platform, so this package does not guess; static fetching says so on stderr, and the browser follows PAC natively through its own system settings.
354
- - **A proxy and synthetic DNS are two different problems.** A fake-IP proxy resolves **every** domain into `198.18.0.0/15` (TUN clients often `100.64.0.0/10`); neither is public unicast, so the gate would reject every URL — turning a proxy on would stop the plugin from working. The gate detects that class of resolver on its own (three control names unrelated to any target, all landing in one non-public pool while staying distinct) and then relaxes to the **whole** of the known pools. The control names only trigger the verdict, never size the pool — three hashed answers carry no size information. Private, loopback and link-local ranges are in neither pool, so intranet and metadata addresses stay blocked on a proxied machine. `syntheticDnsRanges` is the manual fallback for a self-built pool outside the two ranges; when detection does not fire, the gate **stays strict**.
355
- - **Through a proxy, a host name this machine cannot resolve is no longer rejected.** The proxy resolves it, and on a network with DNS filtered by region those are exactly the sites that need a proxy. IP literals, private answers the local resolver *can* produce, and single-label host names (`intranet`, `router`) stay rejected.
356
- - **WebRTC leaks are closed whenever a proxy is in play.** Chromium's WebRTC can send UDP around an HTTP/SOCKS proxy, and one STUN call in a page is enough to learn the visitor's real exit address; `blockWebrtc` is forced on with a proxy, no model input involved.
357
- - **Credentials never reach a log or the capability frame.** The report echoes `scheme://host:port` only, with a `source` field (`settings` / `environment` / `system` / `none`) — the first column to read when someone reports that fetching does not work. A malformed proxy address is logged to stderr and treated as "not configured" rather than failing the load.
358
- - **The installer's stderr and download URLs go through the same redaction gate.** When pip fails it echoes the index URL back verbatim (measured: `WARNING: The index url "ht!tp://user:TOKEN@host/simple" seems invalid` and `InvalidURL: … 'https://user:TOKEN@/requests/'` are both **cleartext**), while putting a token into `PIP_INDEX_URL` is routine for corporate mirrors and `spawn` passes the parent environment straight through. `lib/installer.ts` routes all six stderr channels (curl / HTTP status / tar / venv / pip / chromium) and both download URLs through `safeStderr()` → `redactUrlSecrets()`, replacing the whole userinfo segment with `***@`; `lib/url-policy.ts` no longer anchors its match at line start, so a URL sitting mid-sentence is recognised too. Only the credential is masked — the diagnostic text survives, so the failure reason still reads.
359
-
360
- ## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Security
361
-
362
- - **SSRF.** Scrapling itself has no SSRF protection. This package adds a URL policy on the host side — scheme allowlist, rejection of URLs with embedded credentials, length cap, rejection of an authority containing a backslash or control characters, DNS resolution with a whole-answer-set public-address check, IPv4-mapped and NAT64 addresses reclassified by their embedded IPv4 — and enforces the scheme, credential and address rules again on the Python side (the length cap stays with the host policy, because it is a deployment setting). Outbound paths accept only `http`/`https` and reject embedded credentials; `ws`/`wss` are judged by address alone in the WebSocket-handshake check. **What is judged is what gets sent**: the gate decides on the WHATWG-normalised form and the sidecar forwards that same string, otherwise "judged A, connected to B" would be a bypass in its own right. The host-side policy is enforced in one place (`SidecarClient.call`), and that one place screens every URL the model hands over **as something to fetch** — `url`, plus crawl's `sitemapUrl` and `feedUrl` — with one deliberate exclusion: the three offline parsers (`scrapling_extract`, `scrapling_locate`, `scrapling_links`) send their `url` to the sidecar as nothing but the base for resolving relative links, so `lib/sidecar.ts` (`BASE_ONLY_METHODS`) does not screen it and no request is made with it — so it covers every tool and the `web_fetch` provider alike, with a rejection throwing `URL_BLOCKED` before the request reaches the pipe; the `web_search` provider runs the same gate over the URLs it is about to return, so a hit the gate rejects never becomes a citeable source. The browser-side guard covers navigation, subresources, XHR and WebSocket handshakes.
363
- - Known gaps, stated in the open:
364
- - **Connection pinning** (an undici-level technique) is unavailable for a non-Node transport, leaving a TOCTOU window between validation and connect. Static fetches are covered by curl_cffi's `follow_redirects="safe"`; browser fetches by a route handler on the Python side.
365
- - **NAT64 prefixes are not discovered dynamically.** The two standardized prefixes are covered; operator-specific ones must be declared via `nat64Prefixes`, otherwise a private IPv4 hidden inside IPv6 is judged as an ordinary public IPv6.
366
- - **No port allowlist** (any port allowed by default), matching dsh's own built-in fetch provider.
367
- - **The crawl re-checks every page twice** before it enters the result set — once against the guard (the final URL may still have landed somewhere private) and once against the start domain, because Scrapling's `allow_domains` is a string comparison over links found in the page, not redirect targets. The crawl session uses `follow_redirects="safe"` so curl_cffi refuses a jump into a private range.
368
- - **WebSocket coverage depends on the Playwright version.** The guard intercepts handshakes via `route_web_socket`; older builds lack that method, WebSocket is then outside the guard, and the plugin reports that as `websocketGuard` in the handshake capabilities (the startup log prints the probed capabilities) rather than degrading silently.
369
- - **No code execution from model input.** `page_action`, `page_setup`, `selector_config`, `proxy` and `executablePath` never appear in any tool schema, and the browser-side network guard is installed by plugin code. The strong browser capabilities and `allowWriteMethods` come only from deployment config.
370
- - **Write verbs are off by default.** With `allowWriteMethods` off, `method` and `body` are absent from `scrapling_fetch`'s parameter surface, and the sidecar independently refuses a non-GET with `WRITE_DISABLED` — two halves that do not rely on each other. The gate, the proxy decision and `follow_redirects="safe"` bound **where** a request goes, not **what it does once there**; prompt-injected page text can ask for a POST, so turn it on only where the task really is to submit data. `headers` and `cookies` stay available either way — anything handed to them lands in the model context by design.
283
+ - **A proxy and synthetic DNS are two different problems.** A fake-IP proxy resolves every domain into a non-public range, which the gate would reject; the gate detects that class of resolver on its own and relaxes to the whole of the known pools, while private, loopback and link-local addresses stay blocked on a proxied machine. `syntheticDnsRanges` is the manual fallback for a self-built pool outside them.
284
+ - **A browser session's proxy is fixed at `scrapling_session_open`** — switching it means a new context, which discards the session's cookies and login state. Static sessions decide per request.
285
+ - **WebRTC leaks are closed whenever a proxy is in play** (`blockWebrtc` forced on, no model input involved).
286
+ - **Credentials never reach a log or the capability frame**: the proxy summary echoes `scheme://host:port` plus which rung answered, and the installer's stderr and download URLs go through the same redaction gate.
287
+
288
+ ## Security
289
+
290
+ - **SSRF.** Scrapling itself has no SSRF protection; this package adds a URL policy on the host side — scheme allowlist, embedded-credential rejection, length cap, DNS resolution with a whole-answer-set public-address check, IPv4-mapped and NAT64 addresses reclassified — and enforces it again on the Python side. **What is judged is what gets sent**: the gate decides on the WHATWG-normalised form and the sidecar forwards that same string. It screens every URL the model hands over as something to fetch, across every tool and the `web_fetch` provider alike, with a rejection throwing `URL_BLOCKED` before the request reaches the pipe; the `web_search` provider runs the same gate over the URLs it is about to return. The browser-side guard covers navigation, subresources, XHR and WebSocket handshakes. Known gaps, stated in the open: connection pinning is unavailable (a TOCTOU window remains, mitigated by curl_cffi's safe redirects and the Python route handler), NAT64 prefixes beyond the two standard ones must be declared via `nat64Prefixes`, there is no port allowlist (matching dsh's own provider), and WebSocket coverage depends on the Playwright version (reported as `websocketGuard` in the handshake capabilities rather than degrading silently).
291
+ - **No code execution from model input.** `page_action`, `page_setup`, `selector_config`, `proxy` and `executablePath` never appear in any tool schema, and the browser-side network guard is installed by plugin code.
292
+ - **Write verbs are off by default.** With `allowWriteMethods` off, `method` and `body` are absent from `scrapling_fetch`'s parameter surface, and the sidecar independently refuses a non-GET with `WRITE_DISABLED` — two halves that do not rely on each other. The gate bounds **where** a request goes, not **what it does once there**; turn it on only where the task really is to submit data.
371
293
  - **Prompt-injection scrubbing runs unconditionally** on all three extraction paths; there is no model-facing switch to turn it off.
372
294
 
373
- ## <img src="https://api.iconify.design/lucide/lock.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Data and privacy
295
+ ## Data and privacy
374
296
 
375
297
  | Aspect | Content |
376
298
  | --- | --- |
377
- | On disk | Under the sidecar working directory (`dataDir`, default `~/.dsh-scrapling`): Scrapling's `adaptive` fingerprint database when `adaptiveStorage: sqlite` (the default), `scrapling_download`'s output in `downloads/`, the managed Python and Chromium installed by `setup --feature … --apply` (`runtime/`), and the MCP entry written by `setup --mode … --apply` (`mcp/<mode>.patch.yml`). With `adaptiveStorage: redis` the fingerprints are not written under `dataDir` at all — they go to the Redis at `redisUrl`, keyed `<prefix>:<registrable-domain>:<sha256(identifier)>`; that URL defaults to loopback, and pointing it at another machine hands this data to that machine. The crawl queue lands only when `crawlCheckpointDir` is set (the upstream `Collector(crawldir=…)` writes it); an empty value writes nothing. Login-state files go under `sessionStateDir` when it is configured. Screenshots are handed to the host attachment service, which decides where they live. Settings values live in the host settings document |
378
- | Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go from the Python sidecar to the single backend `searchBackend` selects — Tavily (`api.tavily.com`, key in the request body), Bing (`www.bing.com`, no key), Brave (`api.search.brave.com`, `X-Subscription-Token`), Serper (`google.serper.dev`, `X-API-KEY`), DuckDuckGo (`html.duckduckgo.com`, no key) or the SearXNG instance at `searxngEndpoint`. A backend receives only its own credential (`tavilyApiKey` / `braveApiKey` / `serperApiKey`) plus the query string; keys are never logged. Turning on `searchPublicFallback` lets `auto` send queries to a public engine with no credential at all. `scrapling_answer` sends the fetched page text and the question through the host `llm` service — that content leaves the machine when the routed model is remote |
299
+ | On disk | Under the sidecar working directory (`dataDir`, default `~/.dsh-scrapling`): the `adaptive` fingerprint database (SQLite by default; with `adaptiveStorage: redis` it goes to the Redis at `redisUrl` instead), `downloads/`, the managed runtime installed by `setup`, and the MCP entry written by `setup --mode … --apply`. Crawl queue only when `crawlCheckpointDir` is set; login-state files under `sessionStateDir`; screenshots go to the host attachment service |
300
+ | Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go to the one backend `searchBackend` selects — Tavily (`api.tavily.com`, key in the request body), Bing (`www.bing.com`, no key), Brave (`api.search.brave.com`, `X-Subscription-Token`), Serper (`google.serper.dev`, `X-API-KEY`), DuckDuckGo (`html.duckduckgo.com`, no key), the SearXNG instance at `searxngEndpoint`, or DeepSeek's direct Search API at `deepseekSearchEndpoint`. A backend receives only its own credential plus the query string; keys are never logged. `scrapling_answer` sends page text and the question through the host `llm` service — that content leaves the machine when the routed model is remote |
379
301
  | Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
380
302
  | In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
381
303
  | Telemetry | None |
382
304
 
383
- ## <img src="https://api.iconify.design/lucide/triangle-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Known boundaries
305
+ ## Known boundaries
384
306
 
385
307
  Registered honestly, one entry per class.
386
308
 
387
- - **Rendering can only lose content on pages that ship readable text and then swap it out.** Sites that serve text for search engines and no-JS users, then empty those containers into canvas / Lottie animation, come back emptier after rendering — see [Render or static](#render-or-static).
388
- - **Axis ticks inside SVG are unreachable in every tool**: the Markdown conversion emits no `<svg>` / `<text>` nodes. For chart values, locate the JSON endpoint with `scrapling_capture_xhr`.
389
- - **A browser session's proxy is fixed at `session_open`**, and `proxyBypass` does not apply per URL inside it (a context switch would discard the cookies and login state that are the point of a session). Static sessions decide per request.
390
- - **`headers` and `retries` on `scrapling_session_fetch` belong to static sessions.** Upstream silently drops both for browser sessions, so this package refuses them with `BAD_ARGS` naming the knob to use instead — a silent no-op is the failure mode it exists to eliminate.
391
- - **Browser identity knobs only live on the tools that can apply them.** `useragent` / `locale` / `timezoneId` / `headless` are model-visible on the one-shot browser tools and on `scrapling_session_open` — they take effect at session construction, and passing them per request is silently dropped upstream.
392
- - **Network history is session-level.** Recording is a construction-time setting (`recordRequests` deployment default, or `recordNetwork` per `scrapling_session_open`); a session that is not recording answers an error, not an empty list.
393
- - **`scrapling_screenshot` bypasses text cleaning.** Screenshots capture whatever the page renders in the viewport — including visual secrets (tokens, private messages, data behind a login) that never appear in the DOM text the other tools clean. They are stored through the host attachment service and are only available when that service is mounted. What comes back is the service's **normalized** reference: a declared PNG can be persisted as `image/jpeg` at a smaller raster, with `originalDimensions` carrying what the page actually produced (host contract: `saveImage` in `@deepseek-ai/dsh-attachment`). `scrapling_download` writes bytes under `dataDir/downloads`, never overwrites an existing file, and refuses path components in `filename`.
394
- - **`scrapling_extract`, `scrapling_locate` and `scrapling_links` are offline parsers.** All three take HTML from the caller and never fetch; `scrapling_links` keeps relative links only when `baseUrl` is supplied — with an empty `baseUrl` it returns no links rather than guessing absolute URLs. All three share `extractMaxOutputChars`.
395
- - **Adaptive relocation is best-effort.** Scrapling saves only the first matching element, and a near-identical sibling can be chosen when the original attributes change. Treat a relocated match as a hint and verify it; `scrapling_locate` never saves fingerprints.
396
- - **TLS trust comes from certifi, not the bare managed interpreter's OpenSSL defaults.** The managed CPython has no OpenSSL configuration of its own, so on macOS `ssl.get_default_verify_paths()` resolves to the system store `/private/etc/ssl/cert.pem`, which is missing several public roots — measured on `example.com`, whose SSL.com chain fails there (`verify error:num=20`) and verifies cleanly against certifi's bundle. The bridge therefore points `SSL_CERT_FILE` and `CURL_CA_BUNDLE` at `certifi.where()` **only when neither is already set**, so a corporate MITM proxy or a private root you pin yourself still wins. The symptom this removes reads `FETCH_FAILED ... unable to get local issuer certificate` on sites whose chain the system store cannot complete.
397
- - **Runtime packs are verified on macOS arm64 only.** Windows, Linux and macOS x64 report every pack as `blocked`; the installer refuses rather than guessing an asset path (B1/B2).
398
- - **The `adaptive-redis` pack is a client, not a storage engine.** Upstream ships only `SQLiteStorageSystem`; the Redis backend here is this plugin's `py/redis_storage.py`, a `StorageSystemMixin` subclass keyed by registered domain. Enabling it changes where fingerprints live, so treat it as a deployment decision, not a per-call switch. The plugin's own MCP server is separate — it runs in-process and needs no pack.
399
- - **Shopify crawl mode walks the store's JSON API.** `mode=shopify` uses the store's `/collections.json` and each collection's `/products.json` (upstream's `ShopifySpider`) and yields one row per variant — `name` (product + variant, minus `Default Title`), `price`, `sku`, `stock` (`null` when available, `0` when not), `identifier`, `brand`, `category`, `image_url`, `url`, `barcode`, `old_price`, `description`. It never scrapes product HTML, and it obeys the same URL gate, robots setting, delay and concurrency knobs as the other crawl modes. Verified against a local fixture store; a real Shopify store has not been exercised (B11).
400
- - **`maxPages` caps the pages collected, not the requests the spider makes.** The link discovery layer keeps requesting queued pages (one measured `maxPages=3` crawl issued about 680 requests while collecting 3). Politeness toward the target site is governed by the deployment knobs: `crawlRespectRobots`, `crawlDownloadDelayMs`, `crawlConcurrentRequests`, `crawlAutothrottle`.
401
- - **Heavy pages can keep the browser path from ever settling.** When resources stay in flight past the default 30-second page timeout, `scrapling_session_fetch` / `scrapling_render` fail while a static fetch of the same URL succeeds. Mitigations: `waitSelector` (wait for a key element) or `disableResources` (block images and fonts), both per-call parameters the model can pass.
402
- - **`official-mcp` connects the upstream server.** `integrationMode=official-mcp` registers no native tool and starts no server from this plugin; on a host that exposes `mcpManager` (the rc.2 web bundle) the managed `scrapling-mcp` is registered dynamically, and where that service is absent (CLI/headless) `setup --mode official-mcp --accept-risk` produces the `dsh-mcp-client` entry instead. The binary comes from the `mcp` pack (B10 is the risk decision that entry stands on).
403
-
404
- ## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> FAQ
405
-
406
- | Question | Answer |
407
- | --- | --- |
408
- | The model says the render / capture_xhr tools do not exist | No browser engine on this machine — the plugin registers only what works. Run `python -m patchright install chromium` and restart. If **every** tool is missing, the sidecar did not start: the startup log names the chosen interpreter, and a missing Scrapling carries the pip line to copy |
409
- | After enabling a proxy, every fetch is blocked | A fake-IP proxy resolves every domain into a non-public range; the gate auto-detects that class and relaxes to the known pools. A self-built pool outside them goes into `syntheticDnsRanges`. Private and loopback addresses stay blocked on purpose |
410
- | `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE` / `_MISSING` | The deployment line points at this plugin: either the sidecar is down (interpreter or Scrapling — see the startup log), or the plugin was removed and the `fetchProvider` / `searchProvider` line is still there. Remove the line too |
411
- | The model cannot POST a form | `allowWriteMethods` is off by default and deployment-only — it decides whether the model may change state on a remote host |
412
- | `web_search` reports `SEARCH_AUTH` | The selected backend has no credential: Tavily/Brave/Serper need their key, SearXNG needs `searxngEndpoint`. Set it, or switch `searchBackend`. With `searchBackend=auto` and no key and no `searxngEndpoint`, the plugin reports `SEARCH_BACKEND_MISSING` — set a key / endpoint, or turn on `searchPublicFallback` to allow public engines |
413
- | The numbers on a chart are missing | SVG tick labels do not survive the Markdown conversion in any tool. Use `scrapling_capture_xhr` to find the JSON endpoint behind the chart |
414
-
415
- ## <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Development
309
+ - **Rendering can only lose content on pages that ship readable text and then swap it out** — see [Render or static](#render-or-static).
310
+ - **Axis ticks inside SVG are unreachable in every tool**; locate the JSON endpoint with `scrapling_capture_xhr`.
311
+ - **A browser session's proxy is fixed at `session_open`**, and `proxyBypass` does not apply per URL inside it.
312
+ - **`headers` and `retries` on `scrapling_session_fetch` belong to static sessions**; upstream silently drops both for browser sessions, so this package refuses them with `BAD_ARGS` naming the knob to use instead.
313
+ - **Browser identity knobs only live on the tools that can apply them** (`useragent` / `locale` / `timezoneId` / `headless` take effect at session construction).
314
+ - **Network history is session-level**: a session that is not recording answers an error, not an empty list.
315
+ - **`scrapling_screenshot` bypasses text cleaning** — it captures whatever the page renders, including visual secrets that never appear in the DOM text the other tools clean.
316
+ - **`scrapling_extract`, `scrapling_locate` and `scrapling_links` are offline parsers.** `scrapling_links` keeps relative links only when `baseUrl` is supplied — with an empty `baseUrl` it returns no links rather than guessing absolute URLs.
317
+ - **Adaptive relocation is best-effort.** A near-identical sibling can be chosen when the original attributes change; treat a relocated match as a hint and verify it — `scrapling_locate` never saves fingerprints.
318
+ - **TLS trust comes from certifi, not the bare managed interpreter's OpenSSL defaults** (`SSL_CERT_FILE` / `CURL_CA_BUNDLE` are pointed at `certifi.where()` only when neither is already set, so a corporate MITM proxy or a private root you pin yourself still wins).
319
+ - **`maxPages` caps the pages collected, not the requests the spider makes**; politeness toward the target site is governed by the deployment knobs (`crawlRespectRobots`, `crawlDownloadDelayMs`, `crawlConcurrentRequests`, `crawlAutothrottle`).
320
+ - **Heavy pages can keep the browser path from ever settling**; mitigations are per-call parameters (`waitSelector`, `disableResources`).
321
+ - **Runtime packs are verified on macOS arm64 only**; other platforms report every pack as `blocked`.
322
+
323
+ ## Development
416
324
 
417
325
  ```sh
418
326
  pnpm install
419
- pnpm run check # typecheck → lint → client build → host build → tests → format, then the Python chain
327
+ pnpm run check # typecheck → lint → client build → host build → tests → EOL gate → format, then the Python chain
420
328
  pnpm run test:py # end-to-end check of the Python sidecar
421
329
  ```
422
330
 
423
- - **The Python half is gated like the TypeScript half.** `check` ends with `check:py`: an interpreter report, a face count (the shipped `.py` files and the test directory must both be there — a missing test directory makes "clean" and "untested" indistinguishable), a dependency consistency check, ruff check, ruff format, mypy, the sidecar end-to-end, bandit (all severities; `# nosec` only for justified false positives), and a coverage floor measured **only over the modules that ship**. Dev tools: `pip install -r py/requirements-dev.txt` into the interpreter `test:py` uses.
424
- - **The Python 3.14 floor is one fact in four places:** both READMEs, the ruff and mypy targets, and a runtime gate in `py/bridge.py` that exits before any Scrapling import with a clean stdout — stdout is protocol frames, so an old interpreter shows the exit code and a stderr line instead of garbage.
425
- - **mypy checks untyped bodies and rejects unannotated defs and unused ignores.** Playwright's `page` / `route` / `websocket` objects have no shape until runtime, so `ignore_missing_imports` and `ANN401` stay off; those three checks are on, not the full `strict` profile.
426
- - Sources are TypeScript. `host.js` and `client.js` are **build artifacts** and deliberately `.js`: Node refuses to strip types for packages inside `node_modules`, which is exactly where dsh loads the plugin from. The artifact is ESM-only; `require()` will not get you the plugin, and that is deliberate.
427
- - Gates that pin the published shape: `test/publish-manifest.test.ts` (entry targets covered by `files`, no source file as an entry point, `dsh-*` pins exact and uniform, no host package body inlined, no dates or bad bytes in comments or documents) and `test/readme-parity.test.ts` (the two READMEs name every tool and every settings-card knob, and their section structures match).
331
+ - **The Python half is gated like the TypeScript half.** `check` ends with `check:py`: an interpreter report, a face count, a dependency consistency check, ruff check/format, mypy, bandit (all severities), and a coverage floor measured **only over the modules that ship**.
332
+ - **The Python 3.14 floor is one fact stated in several places:** both READMEs, the ruff target, the mypy target, a runtime gate in `py/bridge.py` (exits before any Scrapling import — stdout is protocol frames), plus the `python-version` pin in CI.
333
+ - Sources are TypeScript. `host.js` and `client.js` are **build artifacts** and deliberately `.js`: Node refuses to strip types for packages inside `node_modules`, which is exactly where dsh loads the plugin from.
334
+ - **The build orchestration lives in shared's four facets; this repository keeps three thin scripts.** All three artifacts (`host.js`, `client.js`, `bin/dsh-scrapling.mjs`) are **not tracked**; `test/artifact-freshness.test.ts` compares existing artifacts byte for byte and skips explicitly when absent.
335
+ - `host.js` keeps shared **external**; `bin/dsh-scrapling.mjs` inlines the whole dependency set (a CLI must be self-contained), with a structural assertion that no `@deepseek-ai/*` package ends up inside.
336
+ - Gates that pin the published shape: `test/publish-manifest.test.ts` and `test/readme-parity.test.ts` (the two READMEs name every tool and every deployment knob, keep their section structures in step, and the detail document's images all exist).
428
337
  - Publishing runs through [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) (manual, OIDC trusted publishing plus `--provenance`).
429
338
 
430
339
  ## Feedback
@@ -433,8 +342,8 @@ Issues and pull requests are welcome: [https://github.com/JayYuen666/dsh-scrapli
433
342
 
434
343
  If a plugin fails to boot, include the dsh host version, the profile install shape, and the browser console line. The `missed the module table` line is especially useful: it tells us whether the shared client row was materialized.
435
344
 
436
- ## <img src="https://api.iconify.design/lucide/scale.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> License
345
+ ## License
437
346
 
438
347
  MIT. Source at [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling). Issues go to that repository's tracker.
439
348
 
440
- This package ships no third-party source code — Scrapling and the browser engines are runtime dependencies. The third-party content in the package is the icon (the official Scrapling mark, BSD 3-Clause) and the `zod` code inlined into the single-file CLI bundle; the host-side client bundle keeps `zod` external. [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) records that boundary.
349
+ This package vendors no third-party source outside the single-file CLI bundle: Scrapling and the browser engines are runtime dependencies, while the CLI inlines `zod` and `ipaddr.js` (the host-side bundles keep `zod` external). The third-party content in the package is the icon (the official Scrapling mark, BSD 3-Clause) plus those two inlined libraries. [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) records that boundary and the licenses.