@jayyuen66/dsh-scrapling 0.1.16 → 0.1.17
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/CHANGELOG.md +17 -0
- package/README.md +43 -19
- package/README.zh-CN.md +44 -20
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/bin/dsh-scrapling.mjs +71 -71
- package/client.js +1 -1
- package/cordis.patch.yml +1 -1
- package/docs/DETAIL.md +16 -7
- package/docs/DETAIL.zh.md +16 -7
- package/host.js +25 -21
- package/package.json +4 -1
- package/py/adapters.py +190 -44
- package/py/bridge.py +77 -5
- package/py/cancellation.py +56 -0
- package/py/document.py +128 -0
- package/py/documents-requirements.txt +1 -0
- package/py/media.py +3 -2
- package/py/runtime-requirements.txt +1 -0
- package/py/search.py +106 -22
- package/py/session_page.py +90 -22
- package/runtime-manifest.json +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,23 @@
|
|
|
6
6
|
标准六类之外的小节(本仓的 `Boundaries` 收各版本的验证范围与能力边界,即哪些平台/档位真跑过、
|
|
7
7
|
哪些只到本地夹具为止)。
|
|
8
8
|
|
|
9
|
+
## 0.1.17
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- MCP 搜索输出契约、按需工具加载、PDF 阅读、DeepSeek Auth 搜索后端,以及 RemoteSession、ARIA 快照与选择器/坐标拖放。
|
|
14
|
+
- 搜索 URL 归一化、去重、元数据保留、offset 分页与有界 TTL 缓存;DeepSeek 直接调用按单 provider 实例每秒 5 次节流。
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- 搜索正文总预算改为可热改的 `searchMaxOutputBytes`,默认仍为 24000 字节;默认结果数对齐宿主 `web_search` 的 10 条。
|
|
19
|
+
- 官方 `web_search` / `web_fetch` 的 scrapling provider 共用静态优先策略、URL 闸门、逐请求取消与输出预算。
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- 搜索与网络历史的结构化总预算、分页锚点、截断标记和异常回包语义;普通超时不再销毁共享 sidecar。
|
|
24
|
+
- 搜索发现请求共用抓取代理策略;Bing 按中英文设置 `setlang` 并解包 `ck/a` 跳板 URL。
|
|
25
|
+
|
|
9
26
|
## 0.1.16
|
|
10
27
|
|
|
11
28
|
宿主基线切到 `dsh 0.2.3-alpha.2`(Node `^24.22.3 || >=26.13.1`),shared 经 catalog 抬到 `^0.2.13`。MCP 客户端默认钉版与 doctor 的放行名单对齐 alpha.2(rc.5 / rc.1 只留给显式 `allow-version` 的旧 profile);设置卡随 shared v3 视觉层更新,并新增 `ScraplingPanelSection` 与「就绪能力包 / 解释器」两项 KPI,客户端注册数与解释器测试同步。
|
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ python -m patchright install chromium
|
|
|
92
92
|
- **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
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
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
|
+
- **PDF reading is optional.** Install the `documents` pack for pinned pypdf 7.1.1, or install the same version into the interpreter selected by `pythonBin`. Without pypdf the sidecar still starts, `capabilities.documents` is false, and `scrapling_read_document` is not registered.
|
|
95
96
|
- **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.
|
|
96
97
|
- **The artifact is ESM-only and never committed** — `prepack` rebuilds it, so what ships is always what the current source produces.
|
|
97
98
|
|
|
@@ -109,10 +110,10 @@ dsh-scrapling setup --feature browser --apply
|
|
|
109
110
|
dsh-scrapling setup --status
|
|
110
111
|
```
|
|
111
112
|
|
|
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`.
|
|
113
|
+
- `core` installs managed Python 3.14.9, Scrapling 0.5.1 and its pinned wheels; `browser` adds the full Chromium build (not the headless shell).
|
|
114
|
+
- `search`, `media`, `documents`, `mcp` and `adaptive-redis` all ride on `core`'s venv: `documents` adds pinned pypdf 7.1.1 from its own hash-locked requirements file, `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`. All seven packs are installable; the settings card reports each as `ready`, `missing`, `corrupt` or `installing`.
|
|
114
115
|
- `--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
|
|
116
|
+
- `--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 the core set; add `-r py/documents-requirements.txt` when installing the `documents` pack. 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
117
|
- `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
118
|
- 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
119
|
- `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`).
|
|
@@ -128,7 +129,7 @@ dsh-scrapling setup --status
|
|
|
128
129
|
|
|
129
130
|
## <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
|
|
|
131
|
-
- **It is not a search engine.** Discovery
|
|
132
|
+
- **It is not a search engine.** Discovery uses one of seven backends (`searchBackend`: `auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng` / `deepseek`). Six run in the Python sidecar and use their own settings; `deepseek` runs in Host through optional `ctx.deepseekAuth` and the direct Search API. Scrapling's own `google_search` option only sets a referer header. A selected backend without credentials reports `SEARCH_AUTH` instead of silently switching.
|
|
132
133
|
- **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
134
|
- **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
135
|
- **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.
|
|
@@ -138,13 +139,13 @@ dsh-scrapling setup --status
|
|
|
138
139
|
- `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
140
|
- 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
141
|
- 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
|
|
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
|
|
142
|
+
- Most card values are read per call — extraction and browser knobs, the five 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 sixteen tool switches, `provideWebFetch` / `provideWebSearch`, `pythonBin`, `failFastOnMissingPython`, `dataDir`, `sidecarHandshakeTimeoutMs` / `sidecarGraceMs`, and the URL-gate / sidecar-environment values (`proxyUrl`, `proxyBypass`, `allowedHosts`, `nat64Prefixes`, `syntheticDnsRanges`).
|
|
143
|
+
- 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 sixteen 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.
|
|
143
144
|
- `scrapling_crawl` registers its own job kind, so `job_list` labels its jobs as crawls rather than shell jobs.
|
|
144
145
|
|
|
145
146
|
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The tools
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
Twenty tools, behind sixteen settings switches (the seven session/state tools share switches), all exercised by the test suite:
|
|
148
149
|
|
|
149
150
|
| Tool | Backend | Needs a browser | Concurrency |
|
|
150
151
|
|---|---|---|---|
|
|
@@ -155,17 +156,26 @@ Nineteen tools, behind fifteen settings switches (the seven session/state tools
|
|
|
155
156
|
| `scrapling_render` | `StealthySession` (patchright) | yes | serialised; the anti-detection switches (`solveCloudflare` / `hideCanvas` / `blockWebrtc`) live here |
|
|
156
157
|
| `scrapling_capture_xhr` | one throwaway session, page-level recording | yes | serialised |
|
|
157
158
|
| `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 |
|
|
159
|
+
| `scrapling_session_read` | current DOM text or AI-mode ARIA snapshot of a browser session page | yes | serialised |
|
|
160
|
+
| `scrapling_session_act` | structured actions, including selector/coordinate drag, on a session page (deployment gate) | yes | serialised |
|
|
160
161
|
| `scrapling_download` | byte download into `dataDir/downloads` (deployment gate) | no | concurrent |
|
|
162
|
+
| `scrapling_read_document` | streamed PDF text via optional pypdf | no | concurrent; defaults to 20 MiB / 200 pages / 200000 characters |
|
|
161
163
|
| `scrapling_screenshot` | PNG/JPEG screenshot handed to the attachment service | yes | serialised |
|
|
162
164
|
| `scrapling_crawl` | Scrapling Spider framework (`content` / `sitemap` / `feed` / `shopify`) as a job | no | serialised |
|
|
163
165
|
| `scrapling_answer` | any fetch path plus `ctx.llm` | with `render: true` | serialised |
|
|
164
166
|
|
|
165
|
-
- **Quotas.** At most 8 open sessions (3 of them browser sessions
|
|
167
|
+
- **Quotas.** At most 8 open sessions (3 of them browser sessions; `stealth` launches local Chromium while `remote` connects to CDP), 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
168
|
- **`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
169
|
- **`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.
|
|
168
170
|
|
|
171
|
+
### Browser sessions, ARIA and drag
|
|
172
|
+
|
|
173
|
+
`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; it does not need a local Chromium install. The endpoint is a strong capability and never enters model input. Closing the session releases that context and connection.
|
|
174
|
+
|
|
175
|
+
`scrapling_session_read` accepts `snapshotType: "text" | "aria"` (default `text`). ARIA uses Patchright's AI-mode accessibility snapshot and can be narrowed with `cssSelector`, which makes buttons, links and form controls easier to locate than raw DOM text.
|
|
176
|
+
|
|
177
|
+
`scrapling_session_act` adds `type: "drag"` in two exclusive forms: `{ "type": "drag", "from": "#source", "to": "#target" }` or `{ "type": "drag", "fromX": 10, "fromY": 20, "toX": 100, "toY": 80 }`. It still requires `allowBrowserActions: true`; URL guards and the action gate apply to remote and local browser sessions alike.
|
|
178
|
+
|
|
169
179
|
### Render or static
|
|
170
180
|
|
|
171
181
|
`scrapling_render` is much slower and heavier than `scrapling_fetch`, so start static. Two criteria:
|
|
@@ -182,13 +192,17 @@ The plugin registers itself as a **fetch provider** and a **search provider** on
|
|
|
182
192
|
1. leave `provideWebFetch` / `provideWebSearch` at their default (`true`);
|
|
183
193
|
2. set `fetchProvider` / `searchProvider` to `"scrapling"` in the **deployment** config.
|
|
184
194
|
|
|
195
|
+
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. A network error or malformed reply is returned as a failure, not treated as a reason to render.
|
|
196
|
+
|
|
185
197
|
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:
|
|
186
198
|
|
|
187
199
|
- **If the sidecar cannot start, the built-in `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`** rather than quietly falling back to plain HTTP.
|
|
188
200
|
- **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
201
|
- **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.
|
|
190
202
|
|
|
191
|
-
Search is split in two, because Scrapling is not a search engine:
|
|
203
|
+
Search is split in two, because Scrapling is not a search engine: an omitted `maxResults` defaults to 10, matching dsh's `web_search`; **discovery** uses `searchBackend` — Tavily, Bing HTML, Brave (API), Serper (API), DuckDuckGo HTML, SearXNG (JSON API), or DeepSeek's direct Search API through optional `ctx.deepseekAuth`; **reading** remains this plugin's — the first `searchRenderTopN` results are fetched according to `webFetchStrategy`, so one `web_search` call returns both which pages matter and what they say. `auto` keeps the existing Tavily → SearXNG → explicitly allowed public-engine order; DeepSeek is selected explicitly with `searchBackend=deepseek`. Without a configured discovery path the provider is unavailable and `web_search` reports `SEARCH_BACKEND_MISSING` instead of querying anyone. Only Tavily and Bing have been exercised against real endpoints here; the other sidecar backends use documented shapes and local stubs. DeepSeek is covered by authorization/HTTP contract tests, not a live credentialed request. Every returned URL goes through the same gate as a fetch; a page that fails to read is skipped alone.
|
|
204
|
+
|
|
205
|
+
Source URLs are canonicalized before citation: fragments and common tracking parameters are removed, query keys are sorted, and duplicate URLs keep their first result. Provider-supplied `summary` and `publishedAt` fields are preserved. MCP `search` also accepts `offset` (0–100): backends with native pagination use it, while DeepSeek has no offset parameter and the plugin requests up to 50 results before slicing locally. Successful discovery results are cached in memory for 300 seconds with at most 128 entries; cache keys include the query, page, backend and redacted endpoints, never API-key values or authorization headers. The direct DeepSeek branch paces at 5 requests per second per provider instance; other processes sharing the account are not coordinated. Every discovery backend follows the same proxy policy as fetching, including an explicit direct connection for `proxyBypass: "*"`. Bing uses `setlang=zh-hans` for Chinese queries and `setlang=en` otherwise, and unwraps its `ck/a` redirect links to the original URL.
|
|
192
206
|
|
|
193
207
|
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.
|
|
194
208
|
|
|
@@ -196,6 +210,8 @@ One consequence to know: `dsh-web`'s fetch body is a **closed** union of `html |
|
|
|
196
210
|
|
|
197
211
|
`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.
|
|
198
212
|
|
|
213
|
+
`mcpToolLoading` is deployment-only too and defaults to `eager`, which keeps the existing behavior of putting 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 system 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 `mcpManager` registration and `setup`-generated manual entries as `toolLoading`; changing it requires a restart. For a manual entry, also rerun `setup --mode <mode> --profile <profileDir> --apply` and reapply the generated patch — restarting alone does not rewrite that entry.
|
|
214
|
+
|
|
199
215
|
| Mode | What it registers |
|
|
200
216
|
|---|---|
|
|
201
217
|
| `native` (default) | the `scrapling_*` tools listed above |
|
|
@@ -206,7 +222,7 @@ In `mcp` mode the server runs inside the plugin's own host process and calls the
|
|
|
206
222
|
|
|
207
223
|
- **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
224
|
- **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
|
|
225
|
+
- **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; it accepts `query`, `maxResults` and `offset`, and returns citable URLs, snippets, optional `summary` / `publishedAt`, bounded body text and `structuredContent`. 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
226
|
- **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
227
|
- **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
228
|
|
|
@@ -229,6 +245,7 @@ In `mcp` mode the server runs inside the plugin's own host process and calls the
|
|
|
229
245
|
| `scrapling_session_read` | `session_read` |
|
|
230
246
|
| `scrapling_session_act` | `session_act` |
|
|
231
247
|
| `scrapling_download` | `download` |
|
|
248
|
+
| `scrapling_read_document` | `read_document` |
|
|
232
249
|
| `scrapling_screenshot` | `screenshot` |
|
|
233
250
|
| — (`ctx.web` only) | `search` |
|
|
234
251
|
|
|
@@ -251,6 +268,7 @@ Then add one entry to that profile's `cordis.patch.yml` — this is exactly what
|
|
|
251
268
|
transport: streamable-http
|
|
252
269
|
url: http://127.0.0.1:39217/mcp
|
|
253
270
|
failOnStartupError: false
|
|
271
|
+
toolLoading: eager
|
|
254
272
|
# only with DSH_SCRAPLING_MCP_TOKEN set:
|
|
255
273
|
# headers:
|
|
256
274
|
# Authorization: !!js '`Bearer ${process.env.DSH_SCRAPLING_MCP_TOKEN}`'
|
|
@@ -262,7 +280,7 @@ Then add one entry to that profile's `cordis.patch.yml` — this is exactly what
|
|
|
262
280
|
|
|
263
281
|
### <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> `setup --mode` and `doctor`
|
|
264
282
|
|
|
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).
|
|
283
|
+
`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). Pass `--profile <profileDir>` to derive `toolLoading` from that profile's `mcpToolLoading`; without it, setup uses the backward-compatible `eager` default rather than introducing a second command-line source of truth.
|
|
266
284
|
|
|
267
285
|
```sh
|
|
268
286
|
dsh-scrapling setup --mode mcp --port 45991 --with-auth --apply
|
|
@@ -282,10 +300,10 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
282
300
|
| --- | --- | --- | --- |
|
|
283
301
|
| `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
302
|
| `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` |
|
|
303
|
+
| `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `documentsEnabled` / `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
304
|
| `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
305
|
| `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 |
|
|
306
|
+
| `*MaxOutputChars` | natural | fetch / extract / render / document `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
307
|
| `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
308
|
| `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
309
|
| `headless` / `networkIdle` | boolean | `true` / `false` | Browser mode and whether a page must reach network idle before it is read |
|
|
@@ -295,7 +313,9 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
295
313
|
| `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
314
|
| `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
315
|
| `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
|
-
| `
|
|
316
|
+
| `webFetchStrategy` | enum | `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. Network and protocol failures do not trigger rendering |
|
|
317
|
+
| `searchMaxOutputBytes` | number | `24000` | UTF-8 byte cap across all body sections returned by one search; raising it increases context and token cost |
|
|
318
|
+
| `searchBackend` / `tavilyApiKey` | enum / secret | `auto` / `""` | Discovery backend (`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng` / `deepseek`) and the Tavily key. `deepseek` uses optional Host `ctx.deepseekAuth`; other backends keep their own credentials. `auto` retains Tavily → SearXNG → explicitly allowed public fallback |
|
|
299
319
|
| `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
320
|
| `braveApiKey` / `serperApiKey` | secret | `""` | Keys for the Brave Search and Serper.dev backends |
|
|
301
321
|
| `searxngEndpoint` | string | `""` | Base URL of a SearXNG instance (`…/search?format=json` is appended); empty means the backend is unusable and reports `SEARCH_AUTH` |
|
|
@@ -312,7 +332,9 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
312
332
|
| --- | --- | --- |
|
|
313
333
|
| `requestTimeoutSeconds` / `maxUrlLength` | `120` / `2048` | Python-side per-request ceiling; URL length cap aligned with the built-in fetch |
|
|
314
334
|
| `allowWriteMethods` | `false` | Whether the model may change state on a remote host at all — see [Security](#security) |
|
|
335
|
+
| `mcpToolLoading` | `eager` | `eager` registers MCP tools directly; `on-demand` keeps them out of each agent's tool list until `mcp__scrapling__load_tools` loads them. Passed to dynamic registration and manual entries as `toolLoading`; restart required, and manual entries must be regenerated with `setup --mode --profile` |
|
|
315
336
|
| `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 |
|
|
337
|
+
| `browserCdpUrl` | `""` | CDP endpoint for `sessionType=remote`; accepts ws/wss/http/https. Empty hides remote sessions. Deployment-only and never included in tool schemas or logs |
|
|
316
338
|
| `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
339
|
| `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
340
|
| `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 |
|
|
@@ -322,9 +344,11 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
322
344
|
| `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 |
|
|
323
345
|
| `crawlDownloadDelayMs` / `crawlConcurrentRequests` / `crawlAutothrottle` / `crawlStrategy` | `0` / `4` / `false` / `bfs` | Gap between requests, parallelism, adaptive throttling, breadth- or depth-first order |
|
|
324
346
|
| `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
|
|
347
|
+
| `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 read according to `webFetchStrategy` (`0` = link list only) |
|
|
326
348
|
| `duckduckgoEndpoint` | `https://html.duckduckgo.com/html/` | DuckDuckGo HTML endpoint; override for a mirror or a test stub |
|
|
327
|
-
| `
|
|
349
|
+
| `deepseekSearchEndpoint` | `https://api.deepseek.com/v1/tools/search` | DeepSeek direct Search API endpoint. HTTPS only, no embedded credentials; changing it requires restart |
|
|
350
|
+
| `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 |
|
|
351
|
+
| `documentMaxBytes` / `documentMaxPages` | `20971520` / `200` | Hard ceilings for PDF reads. Model arguments may only lower them; PDF bytes stream to a temporary file that is deleted on every path |
|
|
328
352
|
|
|
329
353
|
## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Proxies
|
|
330
354
|
|
|
@@ -375,7 +399,7 @@ Details worth knowing:
|
|
|
375
399
|
| Aspect | Content |
|
|
376
400
|
| --- | --- |
|
|
377
401
|
| 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
|
|
402
|
+
| Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go 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), the SearXNG instance at `searxngEndpoint`, or DeepSeek's direct Search API at `deepseekSearchEndpoint`. The first six run in the Python sidecar; DeepSeek runs in Host through optional `ctx.deepseekAuth`. A backend receives only its own credential 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 |
|
|
379
403
|
| Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
|
|
380
404
|
| In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
|
|
381
405
|
| Telemetry | None |
|
package/README.zh-CN.md
CHANGED
|
@@ -90,8 +90,9 @@ python -m patchright install chromium
|
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
- **为什么是 `rag` 而不是 `fetchers`:** `rag` 就是 `fetchers` 再加上 `markdownify`,而 `extractionType` 默认是 `markdown` —— 装成 `fetchers` 的话,第一次抓取就会在 Markdown 转换处抛 `ModuleNotFoundError`。
|
|
93
|
-
- **版本范围:** 本包在 Scrapling **0.5** 上开发与验证,依赖的 `Selector`、`Spider`、`SessionManager` 与转换器的去噪接口都不是稳定 API 面,所以上界钉在 `0.6` 之前;装到范围外时守卫照常运行,但反注入清洗与爬虫链路可能不按预期。0.5 里浏览器后端只剩 patchright(原来独立的 stealth 抓取工具随之删除,反检测参数都在 `scrapling_render` 上);`capture_xhr` 改成会话级记录(于是有了 `scrapling_session_network`);`extra_flags` 改为叠加 —— 本包一支都不发,WebRTC 防泄露由 `blockWebrtc` 开关承担。
|
|
93
|
+
- **版本范围:** 本包在 Scrapling **0.5.1** 上开发与验证,依赖的 `Selector`、`Spider`、`SessionManager` 与转换器的去噪接口都不是稳定 API 面,所以上界钉在 `0.6` 之前;装到范围外时守卫照常运行,但反注入清洗与爬虫链路可能不按预期。0.5 里浏览器后端只剩 patchright(原来独立的 stealth 抓取工具随之删除,反检测参数都在 `scrapling_render` 上);`capture_xhr` 改成会话级记录(于是有了 `scrapling_session_network`);`extra_flags` 改为叠加 —— 本包一支都不发,WebRTC 防泄露由 `blockWebrtc` 开关承担。
|
|
94
94
|
- **不用安装器时,浏览器引擎由你负责。** 可选 CLI 能装已验证的 macOS arm64 资产;插件自身在装载时不下载任何东西。没有浏览器时它只是不注册依赖浏览器的工具,模型不会浪费一轮去调用它们。
|
|
95
|
+
- **PDF 阅读是可选的。** 安装 `documents` 能力包会装入钉版 pypdf 7.1.1;也可以把同一版本装进 `pythonBin` 选中的解释器。缺 pypdf 时 sidecar 照常启动,`capabilities.documents` 为 false,模型看不到 `scrapling_read_document`。
|
|
95
96
|
- **`dependencies` 里没有 `@deepseek-ai/*`,这是契约**(`test/publish-manifest.test.ts` 钉住)。消费方 profile 以 `nodeLinker: hoisted` 与 `autoInstallPeers: false` 安装,宿主包一旦进了 `dependencies` 就会物化成真实存在的第二份副本,模块级状态与运行中的宿主裂开 —— 每次原生工具调用都抛错,而构建与测试一路绿。产物按值 import 的宿主包都是 required peer 并保持外部化;门禁会把构建产物真的载入一次、断言没有内联的宿主包正文。
|
|
96
97
|
- **产物是 ESM-only 且从不提交** —— `prepack` 重建它,发出去的永远是当前源码产出的那份。
|
|
97
98
|
|
|
@@ -109,10 +110,10 @@ dsh-scrapling setup --feature browser --apply
|
|
|
109
110
|
dsh-scrapling setup --status
|
|
110
111
|
```
|
|
111
112
|
|
|
112
|
-
- `core` 装托管 Python 3.14.9、Scrapling 0.5 与钉死的 wheel;`browser` 再加完整 Chromium(不是 headless shell)。
|
|
113
|
-
- `search`、`media`、`mcp` 与 `adaptive-redis` 都以 `core` 的 venv 为载体:`mcp` 带来 `official-mcp` 模式要的官方 `scrapling-mcp` server(随钉住的 `mcp` 包进来;它的工具集由上游决定,不是本插件的能力),`adaptive-redis` 带来 `adaptiveStorage: redis` 背后的 `redis`
|
|
113
|
+
- `core` 装托管 Python 3.14.9、Scrapling 0.5.1 与钉死的 wheel;`browser` 再加完整 Chromium(不是 headless shell)。
|
|
114
|
+
- `search`、`media`、`documents`、`mcp` 与 `adaptive-redis` 都以 `core` 的 venv 为载体:`documents` 从独立的哈希锁定 requirements 文件装入钉版 pypdf 7.1.1;`mcp` 带来 `official-mcp` 模式要的官方 `scrapling-mcp` server(随钉住的 `mcp` 包进来;它的工具集由上游决定,不是本插件的能力),`adaptive-redis` 带来 `adaptiveStorage: redis` 背后的 `redis` 客户端。七个包都可安装;设置卡把每个包报成 `ready`、`missing`、`corrupt` 或 `installing`。
|
|
114
115
|
- `--feature` 默认 dry-run;`--apply` 才写到磁盘。`--repair` 重装且不碰用户数据;`--uninstall <包> [--purge]` 删运行时文件,只有 `--purge` 才连 `elements_storage.db` 与 `downloads/` 一起删。
|
|
115
|
-
- `--offline <目录>` 全程不联网:`<目录>` 里要有 Python 归档(文件名与清单 URL 的最后一段一致,浏览器与 `curl -O` 写到磁盘的 `cpython-3.14.9+…-install_only.tar.gz` 可用,百分号转义那种写法也认),以及一个 `wheels/` 目录(每条钉版一枚 wheel,可用 `pip download --only-binary=:all: --require-hashes -r py/runtime-requirements.txt -d <目录>/wheels`
|
|
116
|
+
- `--offline <目录>` 全程不联网:`<目录>` 里要有 Python 归档(文件名与清单 URL 的最后一段一致,浏览器与 `curl -O` 写到磁盘的 `cpython-3.14.9+…-install_only.tar.gz` 可用,百分号转义那种写法也认),以及一个 `wheels/` 目录(每条钉版一枚 wheel,可用 `pip download --only-binary=:all: --require-hashes -r py/runtime-requirements.txt -d <目录>/wheels` 生成;安装 `documents` 包时再加 `-r py/documents-requirements.txt`)。Python 归档的哈希校验与联网路径一致,pip 带 `--no-index`;缺归档或缺 wheelhouse 时报 `INSTALL_OFFLINE_ASSETS`,不会悄悄退回联网。
|
|
116
117
|
- `setup --status` 打印一份 JSON:`dataDir`、`profile`、`runtime`、`packs` 与 `state`。带 `--profile <目录>` 时读该 profile 的 `cordis.patch.yml`,按本包条目里的 `pythonBin` 与 `dataDir`(宿主真正在用的那两个设置)解析解释器,`packs` 与 `state` 也改报那份目录——条目里没写 `dataDir` 时这两项回落 CLI 自己的默认目录;不带 `--profile` 时 `profile.path` 为 `null`,输出里有一句说明没读 profile,`runtime` 回落到 CLI 自己的链(托管 venv → 裸托管解释器 → 仓内 `_env/.venv` → PATH `python3`)。要拿 `--status` 和设置卡上的解释器对照,就带上 `--profile`。
|
|
117
118
|
- profile 同时有远程读取接口与作业后端时,设置卡能经 `scraplingRuntime` 发起同一套安装/修复/取消;否则显示可照抄的 CLI 命令。
|
|
118
119
|
- `integrationMode` 只在部署配置里;宿主有 `mcpManager`(rc.2 的 web 组合包)时,MCP server 在装载时自动动态注册;`setup --mode` 负责为没有该服务的 CLI/headless profile 打印或写出客户端条目,`doctor` 用来核对一份 profile —— 见 [MCP 模式](#mcp-模式)。`official-mcp` 起的是托管 venv 里的 `scrapling-mcp`,由 `mcp` 能力包装进去(`setup --feature mcp --apply`)。
|
|
@@ -128,7 +129,7 @@ dsh-scrapling setup --status
|
|
|
128
129
|
|
|
129
130
|
## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 它不提供什么
|
|
130
131
|
|
|
131
|
-
- **它不是搜索引擎。**
|
|
132
|
+
- **它不是搜索引擎。** 检索使用七条后端之一(`searchBackend`:`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng` / `deepseek`)。前六条在 Python sidecar 中运行并使用各自配置;`deepseek` 在 Host 中通过可选 `ctx.deepseekAuth` 调用直接 Search API。Scrapling 自己的 `google_search` 选项只是加 Google referer 头。选中却没配凭据的后端报 `SEARCH_AUTH`,不会静默切换。
|
|
132
133
|
- **npm tarball 里没有解释器与浏览器。** 它们来自你的机器,或来自可选的 CLI 安装器 —— 后者把已验证的 macOS arm64 资产装进 `dataDir/runtime`;装载时缺什么就少注册什么,不会临时去下载。
|
|
133
134
|
- **它不在宿主侧新增 HTTP 路由。** 设置卡是宿主的配置表单,本包没有自己的 `/api` 面。唯一真会 listen 的是 `integrationMode: mcp` 下那个 MCP server,只绑 `127.0.0.1`(`http://127.0.0.1:<mcpPort>/mcp`):非 `/mcp` 路径回 404,声明超过 1 MiB 的正文回 413、不带 `Content-Length` 的回 411,Bearer token 只从环境变量 `DSH_SCRAPLING_MCP_TOKEN` 读,没设时启动会往 stderr 打一条「无鉴权、本机任意进程可调」的告知。
|
|
134
135
|
- **它不加 dsh 子命令。** 本包自己的 `dsh-scrapling` CLI 管运行时能力包,另外管没有 `mcpManager` 的 profile 上那半套手工 MCP 接法:`setup --mode native|mcp|official-mcp` 生成客户端条目、带 `--apply` 时写到 `<dataDir>/mcp/<模式>.patch.yml`(profile 本体一个字不改),`doctor --mode` 拿那份条目与 profile 的 `cordis.patch.yml` 逐条核对。`setup --status` 给了 `--profile` 时读的也是那份文件里的 `pythonBin` 与 `dataDir`。
|
|
@@ -138,13 +139,13 @@ dsh-scrapling setup --status
|
|
|
138
139
|
- `dsh.bundle.patch` 指向 `cordis.patch.yml`,里面有一条 `- id: dsh-plugin-shared` 供应行(必须保持开启;停用后卡片会失去 shared 组件供应),再加一条 `- id: scrapling`、`name` 用**裸包名** —— 宿主只扫裸包名条目的 `dsh.client` 声明。设置卡组件来自 shared 的客户端行,以 `@jayyuen66/dsh-plugin-shared/client` 外置;宿主模块表提供 `react`、`zod` 与这条 shared 供应。
|
|
139
140
|
- client 半注册两处:设置卡(坐在 `plugins.bundle.config` 槽上,键是 bundle 包名 —— 宿主按 `entryKey: pkg.name` 派发,所以卡画在本包的详情页上),以及每个工具在 `tool.call.toolview` 上的一行结果,用官方 tool-call 视图 props 画。
|
|
140
141
|
- 设置命名空间就是条目 id `scrapling`;优先级为 设置卡现值 > 注册行 `config:` > schema 默认值。把一项改回默认值保存的是**清除覆盖**而不是写入同一个值,将来默认值变了你这一项也会跟着变。
|
|
141
|
-
- 卡上多数取值每次调用现读 ——
|
|
142
|
-
-
|
|
142
|
+
- 卡上多数取值每次调用现读 —— 抽取类与浏览器类旋钮、五个输出预算、`fetchTimeoutMs`、`answerMaxTokens`、问答路由与搜索侧设置 —— **保存后下一次工具调用就生效**。装配时读一次、改完要重启的是:十六个工具开关、`provideWebFetch` / `provideWebSearch`、`pythonBin`、`failFastOnMissingPython`、`dataDir`、`sidecarHandshakeTimeoutMs` / `sidecarGraceMs`,以及闸门与 sidecar 进程环境那几项(`proxyUrl`、`proxyBypass`、`allowedHosts`、`nat64Prefixes`、`syntheticDnsRanges`)。
|
|
143
|
+
- 关掉某个工具时,它的指引也一并消失,但分两层看:**常驻段只有一段摘要**(跨工具的选型规则,不点名具体工具),而逐工具那十六句全文注册成一枚虚拟 skill `scrapling`。两侧都按「那个 scope 真注册着哪些工具」现取 —— 没装浏览器的机器上 skill 正文里没有 render / capture_xhr 那几句,sidecar 没起来的机器**既没有常驻段也不注册 skill**(正文为空时注册一枚点开什么都没有的条目只会污染模型的 skill 目录)。宿主没有 skill 服务(精简 profile)时插件照常装配,只是少了这枚 skill,常驻段也不追加那句「完整指引见 skill」。常驻段排在内置 `web_fetch` 指引旁边。
|
|
143
144
|
- `scrapling_crawl` 登记自己的作业类型,`job_list` 因此把它的作业标成爬虫而不是 shell 作业。
|
|
144
145
|
|
|
145
146
|
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 工具一览
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
二十个工具、十六枚设置开关(七个 session/state 工具共用开关),全部有测试覆盖:
|
|
148
149
|
|
|
149
150
|
| 工具 | 后端 | 需要浏览器 | 并发 |
|
|
150
151
|
|---|---|---|---|
|
|
@@ -155,17 +156,26 @@ dsh-scrapling setup --status
|
|
|
155
156
|
| `scrapling_render` | `StealthySession`(patchright) | 是 | 串行;反检测开关(`solveCloudflare` / `hideCanvas` / `blockWebrtc`)也在这一条上 |
|
|
156
157
|
| `scrapling_capture_xhr` | 单页临时会话、页级记录 | 是 | 串行 |
|
|
157
158
|
| `scrapling_session_open` / `scrapling_session_fetch` / `scrapling_session_network` / `scrapling_session_state_save` / `scrapling_session_state_load` / `scrapling_session_list` / `scrapling_session_close` | Scrapling 会话类 | 仅浏览器会话 | 串行 |
|
|
158
|
-
| `scrapling_session_read` |
|
|
159
|
-
| `scrapling_session_act` |
|
|
159
|
+
| `scrapling_session_read` | 读浏览器会话当前页的正文或 AI 模式 ARIA 快照 | 是 | 串行 |
|
|
160
|
+
| `scrapling_session_act` | 会话页上的结构化动作,含选择器/坐标拖放(部署门禁) | 是 | 串行 |
|
|
160
161
|
| `scrapling_download` | 下载字节到 `dataDir/downloads`(部署门禁) | 否 | 可并发 |
|
|
162
|
+
| `scrapling_read_document` | 流式读取 PDF 文本,依赖可选 pypdf | 否 | 可并发;默认 20 MiB / 200 页 / 200000 字符 |
|
|
161
163
|
| `scrapling_screenshot` | PNG/JPEG 截图交给 attachment 服务 | 是 | 串行 |
|
|
162
164
|
| `scrapling_crawl` | Scrapling Spider 框架(`content` / `sitemap` / `feed` / `shopify`),作为作业运行 | 否 | 串行 |
|
|
163
165
|
| `scrapling_answer` | 任一抓取路径 + `ctx.llm` | `render: true` 时是 | 串行 |
|
|
164
166
|
|
|
165
|
-
- **配额。** 同开会话至多 8 个(其中浏览器会话 3
|
|
167
|
+
- **配额。** 同开会话至多 8 个(其中浏览器会话 3 个;`stealth` 启动本机 Chromium,`remote` 连接 CDP)、同时在跑的爬虫 2 个、单页正文按 `*MaxOutputChars` 封顶、单个协议帧 8 MB、待处理队列 16 帧。撞上限返回明确的错误码(`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`),由模型自己退避。
|
|
166
168
|
- **`scrapling_crawl` 立刻返回作业 id** —— 一次爬取是分钟级的,而工具调用有超时。用 `job_list` 看进度、`job_output` 读结果、`job_kill` 中断;这一工具要求作业后端能 attach controller,没有的 profile 干脆不注册它(单页抓取不受影响)。爬虫另有总时长上限(`crawlMaxRuntimeSeconds`),且不会爬出起始域。礼貌性默认沿用 Scrapling spider 的默认值 —— **不遵守** robots.txt、每域延迟 0、最多 4 个请求并发 —— 它是部署决定,不是某次调用的参数(见[设置项](#设置项))。
|
|
167
169
|
- **`scrapling_answer` 先抓页面,再带着问题交给模型**,直接拿结论而不是整页正文。默认跟随当前会话正在用的模型(读的是会话的活请求头,中途换模型也跟着变),不额外烧一份额度;要单独指定就用 `answerProvider` / `answerModel`。网页正文是**不可信输入** —— 提示把它显式框成数据,但这道防线是提示层面的:它降低风险,不等于消除风险。
|
|
168
170
|
|
|
171
|
+
### 浏览器会话、ARIA 与拖放
|
|
172
|
+
|
|
173
|
+
只有 sidecar 报告支持 `RemoteSession` 且部署配置填了 `browserCdpUrl` 时,`sessionType=remote` 才会出现。端点接受 `ws://`、`wss://`、`http://` 或 `https://`,连接已经运行的 Chromium 并创建独立 context,不需要本机安装 Chromium;这是强能力,绝不进入模型入参。关闭会话会释放该 context 与连接。
|
|
174
|
+
|
|
175
|
+
`scrapling_session_read` 接受 `snapshotType: "text" | "aria"`(默认 `text`)。ARIA 使用 Patchright 的 AI 模式无障碍快照,并可用 `cssSelector` 收窄范围,比原始 DOM 文本更容易定位按钮、链接与表单控件。
|
|
176
|
+
|
|
177
|
+
`scrapling_session_act` 新增 `type: "drag"`,两种写法互斥:`{ "type": "drag", "from": "#source", "to": "#target" }`,或 `{ "type": "drag", "fromX": 10, "fromY": 20, "toX": 100, "toY": 80 }`。它仍要求 `allowBrowserActions: true`;remote 与本机浏览器会话都受同一道 URL 守卫和动作门禁约束。
|
|
178
|
+
|
|
169
179
|
### 渲染还是静态
|
|
170
180
|
|
|
171
181
|
`scrapling_render` 比 `scrapling_fetch` 慢得多、也更吃内存,所以默认从静态抓取起步。两条判据:
|
|
@@ -182,13 +192,17 @@ dsh-scrapling setup --status
|
|
|
182
192
|
1. `provideWebFetch` / `provideWebSearch` 保持默认(`true`);
|
|
183
193
|
2. 在**部署配置**里把 `fetchProvider` / `searchProvider` 设为 `"scrapling"`。
|
|
184
194
|
|
|
195
|
+
两条正文读取路径共用 `webFetchStrategy`(默认 `auto`):`static` 始终静态读取;`auto` 先静态读取,正文少于 200 字符时才渲染;`browser` 直接渲染。没有浏览器时 `auto` 保持静态读取。网络错误或回包形状错误按失败返回,不把它当成渲染理由。
|
|
196
|
+
|
|
185
197
|
配了 id 就以它为准,这就是第 2 步必须做的原因 —— 而两个 provider 都可用、又没点名时,`ctx.web` 会给 `WEB_PROVIDER_AMBIGUOUS`,对应工具直接不可用。把那一行指向本插件后,有两个反向风险:
|
|
186
198
|
|
|
187
199
|
- **sidecar 起不来时,内置 `web_fetch` 报 `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`**,而不是悄悄退回纯 HTTP。
|
|
188
200
|
- **fetch provider 会真正执行输出预算**:正文超过 `fetchMaxOutputChars` 时按头尾窗口实际裁剪并标记 `truncated`,不是原样放行只打一个标记。失败保留 sidecar 的错误码前缀(`URL_BLOCKED`、`SIDECAR_TIMEOUT`、`SIDECAR_UNAVAILABLE`),策略拒绝、进程崩溃与超时可以区分。
|
|
189
201
|
- **日后卸掉插件却留着那一行**,内置工具报 `WEB_PROVIDER_CONFIGURED_MISSING` —— 要回去把 `fetchProvider` / `searchProvider` 一并撤掉。
|
|
190
202
|
|
|
191
|
-
搜索拆成两截,因为 Scrapling
|
|
203
|
+
搜索拆成两截,因为 Scrapling 自己不是搜索引擎:省略 `maxResults` 时默认取 10 条,与 dsh 的 `web_search` 一致;**检索**由 `searchBackend` 选择 —— Tavily、Bing HTML、Brave(API)、Serper(API)、DuckDuckGo HTML、SearXNG(JSON API),或通过可选 `ctx.deepseekAuth` 调用 DeepSeek 直接 Search API;**读取**仍由本插件完成 —— 前 `searchRenderTopN` 条按 `webFetchStrategy` 真的抓下来,一次 `web_search` 同时拿到「哪些页面相关」与「这些页面实际说了什么」。`auto` 保持既有 Tavily → SearXNG → 明确允许的公共引擎顺序;DeepSeek 需显式设 `searchBackend=deepseek`。没有可用发现路径时 provider 不可用,`web_search` 报 `SEARCH_BACKEND_MISSING`,不会擅自查询。本机只对 Tavily 与 Bing 打过真实端点;其余 sidecar 后端按文档形状用本地 stub 验证。DeepSeek 覆盖授权与 HTTP 契约测试,未用真实凭据发请求。返回 URL 逐条过与抓取同一道闸门;单条读不到只跳过该条。
|
|
204
|
+
|
|
205
|
+
来源 URL 在引用前归一化:去掉 fragment 与常见跟踪参数、按 key 排序查询串,重复 URL 保留第一条。后端提供的 `summary` 与 `publishedAt` 原样保留。MCP `search` 另接受 `offset`(0–100):支持原生分页的后端直接使用;DeepSeek API 没有 offset,本插件一次最多取 50 条后在本地切片。成功发现结果在内存中缓存 300 秒、最多 128 项;缓存键包含查询、页码、后端和脱敏端点,绝不包含 API key 值或授权头。DeepSeek 直接调用按每个 provider 实例每秒 5 次节流;共享同一账号的其他进程之间不做协调。所有发现后端与抓取共用同一套代理策略,`proxyBypass: "*"` 会显式直连。Bing 对中文查询使用 `setlang=zh-hans`,其余使用 `setlang=en`,并把 `ck/a` 跳板链接解包为原始 URL。
|
|
192
206
|
|
|
193
207
|
有一个后果需要知道:`dsh-web` 的抓取正文是 `html | text` 的**封闭**联合,没有 `markdown` 这一档,加一种 kind 是跨包的协同改动,不是插件能扩展的。所以 fetch provider 把 Scrapling 的 Markdown 输出报成 `text`,内置渲染路径显示完全正常。要 `html` 或 CSS 选择器时直接用 `scrapling_fetch`。
|
|
194
208
|
|
|
@@ -196,6 +210,8 @@ dsh-scrapling setup --status
|
|
|
196
210
|
|
|
197
211
|
`integrationMode` 在三种互斥的接入方式里选一种。它是部署配置(`cordis.patch.yml` 的 `config:` 块),插件装配时读一次,改完必须重启。
|
|
198
212
|
|
|
213
|
+
`mcpToolLoading` 同样只从部署配置读,默认 `eager`,保持服务器工具直接进入工具列表的既有行为。工具定义太大、不适合随每次请求发送时设成 `on-demand`:系统提示词只列每个工具的原始名称与描述首行,模型经 `mcp__scrapling__load_tools` 加载需要的工具。加载的工具只加入调用方 agent 的列表;子 agent、fork 与恢复的会话开始时都没有已加载工具。动态 `mcpManager` 注册与 `setup` 生成的手工条目都把这个值写成 `toolLoading`;改完必须重启。使用手工条目时,还要重跑 `setup --mode <模式> --profile <profile 目录> --apply` 并重新应用生成的 patch —— 只重启不会改写那条已有条目。
|
|
214
|
+
|
|
199
215
|
| 模式 | 注册什么 |
|
|
200
216
|
|---|---|
|
|
201
217
|
| `native`(默认) | 上面列出的 `scrapling_*` 工具 |
|
|
@@ -206,7 +222,7 @@ dsh-scrapling setup --status
|
|
|
206
222
|
|
|
207
223
|
- **端点** `http://127.0.0.1:<mcpPort>/mcp`(`mcpPort`,默认 `39217`)。只绑回环;声明正文超过 1 MiB 的请求直接 `413`,其他路径 `404`。server 是无会话形态:每条请求各起一份协议对象,跨请求不留状态。
|
|
208
224
|
- **鉴权**默认关。设了环境变量 `DSH_SCRAPLING_MCP_TOKEN` 之后,每个请求都必须带 `Authorization: Bearer <token>`。这一枚只从环境读、绝不从 profile 读,所以它不会落进配置文件。
|
|
209
|
-
- **工具**就是 native 注册的那批 `ToolDefinition`:同一份 JSON Schema、同一套参数校验、同一个渲染器。`scrapling_answer` 不端出去 —— 它要走宿主会话的模型路由,外部客户端没有这一层。`search` 只在 MCP 面上有,因为 MCP 客户端没有 `ctx.web`
|
|
225
|
+
- **工具**就是 native 注册的那批 `ToolDefinition`:同一份 JSON Schema、同一套参数校验、同一个渲染器。`scrapling_answer` 不端出去 —— 它要走宿主会话的模型路由,外部客户端没有这一层。`search` 只在 MCP 面上有,因为 MCP 客户端没有 `ctx.web` 那个接缝;它接受 `query`、`maxResults` 与 `offset`,返回可引用 URL、摘要、可选 `summary` / `publishedAt`、有界正文和 `structuredContent`。门禁一致:`allowBrowserActions=false` 时没有 `session_act`,`allowFileDownloads=false` 时没有 `download`,没有可用搜索后端时 `search` 也不出现。
|
|
210
226
|
- **结果**是文本内容;截图改为 MCP 的 image content,而不是宿主 attachment。工具失败回 `isError` 加可读消息,不会把连接掐断。
|
|
211
227
|
- **名字**:MCP 原始名是工具名去掉 `scrapling_` 前缀,dsh 的 MCP 客户端再显示成 `mcp__scrapling__<原始名>`。
|
|
212
228
|
|
|
@@ -229,6 +245,7 @@ dsh-scrapling setup --status
|
|
|
229
245
|
| `scrapling_session_read` | `session_read` |
|
|
230
246
|
| `scrapling_session_act` | `session_act` |
|
|
231
247
|
| `scrapling_download` | `download` |
|
|
248
|
+
| `scrapling_read_document` | `read_document` |
|
|
232
249
|
| `scrapling_screenshot` | `screenshot` |
|
|
233
250
|
| —(只在 `ctx.web`) | `search` |
|
|
234
251
|
|
|
@@ -251,6 +268,7 @@ dsh plugin --profile <名> add @deepseek-ai/dsh-mcp-client@0.2.3-alpha.2
|
|
|
251
268
|
transport: streamable-http
|
|
252
269
|
url: http://127.0.0.1:39217/mcp
|
|
253
270
|
failOnStartupError: false
|
|
271
|
+
toolLoading: eager
|
|
254
272
|
# 只有设了 DSH_SCRAPLING_MCP_TOKEN 才加:
|
|
255
273
|
# headers:
|
|
256
274
|
# Authorization: !!js '`Bearer ${process.env.DSH_SCRAPLING_MCP_TOKEN}`'
|
|
@@ -262,7 +280,7 @@ dsh plugin --profile <名> add @deepseek-ai/dsh-mcp-client@0.2.3-alpha.2
|
|
|
262
280
|
|
|
263
281
|
### <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> `setup --mode` 与 `doctor`
|
|
264
282
|
|
|
265
|
-
`setup --mode` 产出上面那段条目文本,它不改写任何 profile。不带 `--apply` 是 dry-run;带上就写到 `<dataDir>/mcp/<模式>.patch.yml` 并把路径打出来 —— 把它并进 `cordis.patch.yml` 仍是你的动作,因为宿主没有安全追加那个文件的接口(`dsh --dump-config` 会把 profile
|
|
283
|
+
`setup --mode` 产出上面那段条目文本,它不改写任何 profile。不带 `--apply` 是 dry-run;带上就写到 `<dataDir>/mcp/<模式>.patch.yml` 并把路径打出来 —— 把它并进 `cordis.patch.yml` 仍是你的动作,因为宿主没有安全追加那个文件的接口(`dsh --dump-config` 会把 profile 根配置整个重写一遍)。带 `--profile <profile 目录>` 时从该 profile 的 `mcpToolLoading` 派生 `toolLoading`;不带时用向后兼容的 `eager` 默认值,不再另开一个命令行真源。
|
|
266
284
|
|
|
267
285
|
```sh
|
|
268
286
|
dsh-scrapling setup --mode mcp --port 45991 --with-auth --apply
|
|
@@ -282,10 +300,10 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
282
300
|
| --- | --- | --- | --- |
|
|
283
301
|
| `pythonBin` | string | `""` | 解释器名或绝对路径。留空时按 `lib/runtime.ts` 的固定链走:托管 venv `dataDir/runtime/venv`(`setup --feature core --apply` 把每个 wheel 都装在这里)→ 裸托管解释器 `dataDir/runtime/python/<版本>`(装了一半的机器)→ 仓内 `_env/.venv`(可用才算,只有源码检出才有)→ `PATH` 上的 `python3`(Windows 上是 `python`) |
|
|
284
302
|
| `failFastOnMissingPython` | boolean | `true` | sidecar 进程起不来(路径错、协议对不上、握手超时)时拒绝加载。解释器起得来但没装 Scrapling 时,无论这枚开关如何都只降级为「工具不可用」,日志点名解释器路径 |
|
|
285
|
-
| `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `screenshotEnabled` | boolean | `true` | 每个工具一枚总闸。`sessionStateEnabled` 管登录态存取那一对,它们还要部署侧配好 `sessionStateDir` |
|
|
303
|
+
| `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `documentsEnabled` / `screenshotEnabled` | boolean | `true` | 每个工具一枚总闸。`sessionStateEnabled` 管登录态存取那一对,它们还要部署侧配好 `sessionStateDir` |
|
|
286
304
|
| `extractionType` | enum | `markdown` | `markdown` / `html` / `text`;三条路径过同一套反注入清洗,`html` 额外剥事件处理器属性,因此**不是字节级原始 HTML** |
|
|
287
305
|
| `mainContentOnly` | boolean | `true` | 抽取范围 |
|
|
288
|
-
| `*MaxOutputChars` | natural | fetch / extract / render `200000`,xhr `120000` | 各工具的输出封顶。sidecar 先按字符截一次,宿主再按字节预算统一处理。`scrapling_render` 与 `scrapling_capture_xhr` 在正文之外还带一份 XHR 历史,那一段按**同一档预算另外**封顶 —— 所以这类调用的一次回执可达两倍预算 |
|
|
306
|
+
| `*MaxOutputChars` | natural | fetch / extract / render / document `200000`,xhr `120000` | 各工具的输出封顶。sidecar 先按字符截一次,宿主再按字节预算统一处理。`scrapling_render` 与 `scrapling_capture_xhr` 在正文之外还带一份 XHR 历史,那一段按**同一档预算另外**封顶 —— 所以这类调用的一次回执可达两倍预算 |
|
|
289
307
|
| `crawlMaxItems` | natural | `1000` | 给模型可传的 `maxPages` 封的顶。越界的 `maxPages` 原样透传,让 sidecar 报参数错误,而不是由本包悄悄夹成看起来合法的值 |
|
|
290
308
|
| `stripInlineImages` | boolean | `true` | 剥掉正文里内嵌的 `data:` URI 图片、只留 alt 文本 —— 对模型是纯 token 噪音。代码围栏内的原样保留;不含内联图的页面逐字节不变。剥图发生在封顶**之前**。只有把内联图当**原始数据**读(配色、指纹)时才关 |
|
|
291
309
|
| `headless` / `networkIdle` | boolean | `true` / `false` | 浏览器模式,以及页面是否要等到网络空闲才被读取 |
|
|
@@ -295,7 +313,9 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
295
313
|
| `sidecarHandshakeTimeoutMs` / `fetchTimeoutMs` / `sidecarGraceMs` | natural | `30000` / `120000` / `5000` | 握手预算、单次调用的协同超时(声明在各工具的 `timeoutMs` 上)、超时后等进程退出的宽限。`scrapling_crawl` 不传超时 —— 一次爬取是分钟级的 |
|
|
296
314
|
| `dataDir` | string | `""` | sidecar 工作目录(`adaptive` 指纹库落这里);留空 = `~/.dsh-scrapling`。目录建不出来时由 `failFastOnMissingPython` 决定:拒绝加载,或降级为不注册任何工具 |
|
|
297
315
|
| `provideWebFetch` / `provideWebSearch` | boolean | `true` | 是否注册 `ctx.web` 的两个 provider —— 见[替代内置的抓取与搜索](#替代内置的抓取与搜索) |
|
|
298
|
-
| `
|
|
316
|
+
| `webFetchStrategy` | enum | `auto` | `static` 始终静态读取;`auto` 先静态读取,正文少于 200 字符时才渲染;`browser` 直接渲染。没有浏览器时 `auto` 保持静态读取。网络错误与回包形状错误按失败返回,不触发渲染 |
|
|
317
|
+
| `searchMaxOutputBytes` | number | `24000` | 一次搜索全部正文小节的 UTF-8 字节总上限;调大会增加上下文与 token 成本 |
|
|
318
|
+
| `searchBackend` / `tavilyApiKey` | enum / secret | `auto` / `""` | 发现后端(`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng` / `deepseek`)与 Tavily key。`deepseek` 使用可选 Host `ctx.deepseekAuth`;其余后端保留各自凭据。`auto` 保持 Tavily → SearXNG → 明确允许的公共回退 |
|
|
299
319
|
| `searchPublicFallback` | boolean | `false` | 允许 `auto` 在既没有 key、也没有 SearXNG 时回落到公共的 Bing —— `py/search.py` 把 `auto` 按 `tavily` → `searxng` → `bing` 定案,DuckDuckGo 不在 `auto` 的位置里,要用得显式设 `searchBackend=duckduckgo`。**默认关是刻意的**:打开就等于把查询词发给第三方公共引擎 |
|
|
300
320
|
| `braveApiKey` / `serperApiKey` | secret | `""` | Brave Search 与 Serper.dev 的 key |
|
|
301
321
|
| `searxngEndpoint` | string | `""` | SearXNG 实例的基址(会拼上 `…/search?format=json`);为空表示这条后端不可用,报 `SEARCH_AUTH` |
|
|
@@ -312,7 +332,9 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
312
332
|
| --- | --- | --- |
|
|
313
333
|
| `requestTimeoutSeconds` / `maxUrlLength` | `120` / `2048` | Python 侧单次请求的硬上限;URL 长度上限与内置抓取对齐 |
|
|
314
334
|
| `allowWriteMethods` | `false` | 模型能不能改对端状态 —— 见[安全说明](#安全说明) |
|
|
335
|
+
| `mcpToolLoading` | `eager` | `eager` 直接注册 MCP 工具;`on-demand` 让它们先不进入各 agent 的工具列表,由 `mcp__scrapling__load_tools` 按需加载。动态注册与手工条目都写成 `toolLoading`,改完必须重启;手工条目要用 `setup --mode --profile` 重新生成 |
|
|
315
336
|
| `browserExecutablePath` / `browserInitScript` | `""` | 强能力:让 Chromium 执行指定文件、往每个页面注入 JS。只从部署配置来,模型入参到不了 |
|
|
337
|
+
| `browserCdpUrl` | `""` | `sessionType=remote` 使用的 CDP 端点,接受 ws/wss/http/https;留空不显示 remote 会话。只从部署配置来,不进工具 schema 或日志 |
|
|
316
338
|
| `browserRealChrome` / `browserDnsOverHttps` | `false` | 改用本机安装的 Google Chrome;浏览器 DNS 走 DoH(配代理时防 DNS 泄露) |
|
|
317
339
|
| `recordRequests` / `maxRecordedRequests` | `false` / `100` | 浏览器会话是否默认记录网络历史(模型可在 `scrapling_session_open` 上按次用 `recordNetwork` 打开),以及一个会话最多留多少条 |
|
|
318
340
|
| `sessionStateDir` | `""` | 存放 Playwright 兼容登录态文件的目录。模型只能给**纯文件名**,目录始终是部署方的决定;留空禁用存取这一对 |
|
|
@@ -322,9 +344,11 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
322
344
|
| `crawlRespectRobots` | `false` | 遵守 robots.txt;打开后,robots.txt **取回失败**(网络异常或 HTTP 5xx)的域按禁止处理而不是当作允许,而**没有** robots.txt 的站点(HTTP 404,最常见的形态)视作允许全部 |
|
|
323
345
|
| `crawlDownloadDelayMs` / `crawlConcurrentRequests` / `crawlAutothrottle` / `crawlStrategy` | `0` / `4` / `false` / `bfs` | 请求间隔、并发数、自适应限速、广度或深度优先 |
|
|
324
346
|
| `crawlCheckpointDir` | `""` | 把爬取队列写到磁盘,重启后从断点接着走而不是回到起始 URL |
|
|
325
|
-
| `tavilyApiEndpoint` / `bingEndpoint` / `searchRenderTopN` | `https://api.tavily.com/search` / `https://www.bing.com/search` / `3` |
|
|
347
|
+
| `tavilyApiEndpoint` / `bingEndpoint` / `searchRenderTopN` | `https://api.tavily.com/search` / `https://www.bing.com/search` / `3` | 发现端点(测试或代理可覆盖),以及前几条按 `webFetchStrategy` 读取的结果条数(`0` = 只给链接列表) |
|
|
326
348
|
| `duckduckgoEndpoint` | `https://html.duckduckgo.com/html/` | DuckDuckGo HTML 端点;镜像或测试 stub 可覆盖 |
|
|
327
|
-
| `
|
|
349
|
+
| `deepseekSearchEndpoint` | `https://api.deepseek.com/v1/tools/search` | DeepSeek 直接 Search API 端点;只允许 HTTPS、禁止内嵌凭据,修改后需重启 |
|
|
350
|
+
| `allowBrowserActions` / `allowFileDownloads` / `downloadMaxBytes` | `false` / `false` / `10485760` | 部署级动作与持久下载门禁,以及单次下载的字节上限。两枚门禁默认关,关时对应工具也不注册给模型 |
|
|
351
|
+
| `documentMaxBytes` / `documentMaxPages` | `20971520` / `200` | PDF 读取的硬上限;模型参数只能往下收。PDF 字节流式写入临时文件,所有路径都会删除 |
|
|
328
352
|
|
|
329
353
|
## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 代理
|
|
330
354
|
|
|
@@ -375,7 +399,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
375
399
|
| 规则 | 内容 |
|
|
376
400
|
| --- | --- |
|
|
377
401
|
| 写盘 | sidecar 工作目录(`dataDir`,默认 `~/.dsh-scrapling`)里会有:`adaptiveStorage: sqlite`(默认)时 Scrapling `adaptive` 的指纹库、`scrapling_download` 的位置 `downloads/`、`setup --feature … --apply` 装进去的托管 Python 与 Chromium(`runtime/`)、`setup --mode … --apply` 生成的 MCP 条目(`mcp/<模式>.patch.yml`)。`adaptiveStorage: redis` 时指纹不落 `dataDir`,改按 `<前缀>:<注册域>:<sha256(identifier)>` 写进 `redisUrl` 指向的 Redis —— 默认是回环,换成别的机器就等于把这份数据交给那台机器。`crawlCheckpointDir` 配了才由上游 `Collector(crawldir=…)` 落爬取队列,留空不落。配了 `sessionStateDir` 时登录态文件写在那个目录下。截图交宿主 attachment 服务保管,落在哪里由宿主决定。设置值在宿主的设置文档里 |
|
|
378
|
-
| 网络 | 抓取发往模型给的 URL
|
|
402
|
+
| 网络 | 抓取发往模型给的 URL,配了代理就走代理。搜索查询发往 `searchBackend` 选中的那一个后端 —— Tavily(`api.tavily.com`,key 随请求体送出)、Bing(`www.bing.com`,不带凭据)、Brave(`api.search.brave.com`,走 `X-Subscription-Token`)、Serper(`google.serper.dev`,走 `X-API-KEY`)、DuckDuckGo(`html.duckduckgo.com`,不带凭据)、`searxngEndpoint` 指向的自建 SearXNG 实例,或 `deepseekSearchEndpoint` 指向的 DeepSeek 直接 Search API。前六条在 Python sidecar 中运行;DeepSeek 在 Host 中通过可选 `ctx.deepseekAuth` 运行。每个后端只收到自己的凭据与查询串,key 绝不写日志。打开 `searchPublicFallback` 时 `auto` 会把查询发给不带任何凭据的公共引擎。`scrapling_answer` 把抓到的页面正文与问题经宿主 `llm` 服务送出 —— 路由到的模型在远端时,这些内容就离开了本机 |
|
|
379
403
|
| 日志 | 选中的解释器、探测到的能力、代理摘要(`scheme://host:port` 加来自哪一档 —— 绝无凭据) |
|
|
380
404
|
| 内存 | 会话、cookie 与录下的网络历史都在 sidecar 进程里,随进程一起消失 |
|
|
381
405
|
| 遥测 | 无 |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -98,6 +98,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
98
98
|
| --- | --- | --- | --- |
|
|
99
99
|
| `@jayyuen66/dsh-plugin-shared` | catalog(根 ^0.2.13) | MIT | 设置卡的共享组件供应行与 shared 子路径 |
|
|
100
100
|
| `scrapling` | 0.5 | BSD-3-Clause | Python sidecar |
|
|
101
|
+
| `pypdf` | 7.1.1 | BSD-3-Clause | 可选 `documents` 能力包的 PDF 文本读取 |
|
|
101
102
|
| `browserforge` | 1.2.4 | MIT | Scrapling 静态抓取的浏览器头生成 |
|
|
102
103
|
| `apify-fingerprint-datapoints` | 0.15.0 | Apache-2.0 | browserforge 的指纹数据 |
|
|
103
104
|
| `playwright` | 1.64.1 | Apache-2.0(Microsoft) | 网络守卫 |
|
|
@@ -108,7 +109,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
108
109
|
| `zod` | catalog(伞根 4.6.7) | MIT | Host 侧 `lib/runtime.ts` / `lib/sidecar.ts` 的形状校验走本包 dependencies 里的 zod;设置卡 `src/runtime-reader.ts`、`src/settings-card.ts` 的 strict codec 由宿主 `PLATFORM_MODULES` 提供;CLI 单文件产物内联 |
|
|
109
110
|
|
|
110
111
|
其余随 venv 安装的固定版本(含 `click`、`protego`、`curl_cffi`、`lxml` 等)见
|
|
111
|
-
`py/runtime-requirements.txt`,每一行都带 SHA256
|
|
112
|
+
`py/runtime-requirements.txt`,每一行都带 SHA256;可选 pypdf 单独钉在
|
|
113
|
+
`py/documents-requirements.txt`,同样带 wheel 的 SHA256;本文件不复述整张表。
|
|
112
114
|
|
|
113
115
|
## 运行时下载的资产(不随 npm 分发)
|
|
114
116
|
|