@jayyuen66/dsh-scrapling 0.1.5 → 0.1.6

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 CHANGED
@@ -3,6 +3,46 @@
3
3
  格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循
4
4
  [语义化版本](https://semver.org/lang/zh-CN/)。最新版本在最上。
5
5
 
6
+ ## 0.1.6
7
+
8
+ 一轮跨面审查修复,TS 与 Python 两侧一起收口:协议边界、安装器与 sidecar 生命周期、
9
+ Python 子命令判据;门禁脚本与发布链同步加固。
10
+
11
+ ### Changed
12
+
13
+ - **门禁脚本硬化**:`py-launcher.mjs`(usable 先判 isFile、parseArgs 严格化、`--bin` 无 venv 退 1、信号映射 128+n);`coverage-floor.mjs` / `deps-check.mjs` / `face-py.mjs`(realpath 主模块判据、地板两处互校、uv/pip 失败点名、py/ 缺失判红)。`check:py` 移除独立 `test:py` 步(coverage run 即 sidecar 端到端)。
14
+ - **构建与测试面**:`build-cli.ts` 的 bin 产物改 tmp+rename 原子写并加 `invokedDirectly` 守卫;vitest 并行化(fileParallelism + maxWorkers 50%)、coverage include 收进 `src/runtime-reader.ts`;CI 注释同步 `check:py` 新链,actionlint 改按文件豁免。
15
+ - **依赖与元数据**:`engines.node` 下限 22.12→22.18(build 脚本用 node 直接跑 .ts 需要类型剥离);peer 五个宿主包从双范围收敛为单范围 `^0.2.1-rc.3`,`@deepseek-ai/schemastery` 放宽为 `^3.18.6-alpha.1`;新增依赖 `fs-native-extensions` 1.5.3(安装锁的 OS 级实现)、devDep fast-check 4.10.2;catalog 的 shared 抬到 0.2.2;MCP server 自述版本同步 0.1.6。
16
+ - **`_env/` 四份探针脚本**改到 Scrapling 0.5 真实 API(StealthySession / network.search / wait_selector)。
17
+
18
+ ### Fixed
19
+
20
+ **TS 侧**
21
+
22
+ - **answer**(`lib/answer.ts`):URL 先过 `escapePageText` 再属性转义,`§page_end§`/`</page>` 边界不再被页面 URL 伪造;AbortError 原样重抛不再包成 ANSWER_FAILED;重复 finish 不再误判失败。
23
+ - **协议**(`lib/jsonl.ts`、`py/bridge.py`):`FrameSplitter.clear()`、单帧回调异常不再丢同 chunk 后续帧、stop 后摘除 end/error 并挂吞错监听、切行后超长帧即报 FrameError;bridge 的 stdin 改 read1 增量切帧、超长残帧弃缓冲报 BAD_FRAME(与宿主 FrameSplitter 同解)、emit 失败补发 INTERNAL 兜底帧。
24
+ - **MCP server**(`lib/mcp-server.ts`):缺 Content-Length 的 POST 回 411;token 比较改 `timingSafeEqual`;截图 sink 加 16 份/60s 上限;非回环绑定且无 token 直接拒启。
25
+ - **安装器**(`lib/installer.ts`):还原失败时保留旧 venv(`restoreFailed`);安装锁由 pid 文件改为 OS 级锁;卸载只摘被卸包的状态位,不再连带触发 browser 重下;offline 归档 URL 百分号编码防御。
26
+ - **MCP profile**(`lib/mcp-profile.ts`):兼容双引号、列表项与行尾注释,URL 端口按 scheme 默认值比对,消除 doctor 假红。
27
+ - **sidecar 稳定性**(`lib/browser-tools.ts`、`lib/tool-params.ts`、`lib/sidecar.ts`):act/screenshot 的 `timeoutMs` 夹进调用截止,单动作超时不再拆掉整个 sidecar 进程;调用级取消不再传给 spawn。
28
+ - **runtime**(`lib/runtime.ts`、`lib/runtime-remote.ts`、`lib/official-mcp.ts`):解释器候选先判 isFile、win32 PATH 名与 py-launcher 统一为 `python`、manifest 强校验 sha256/pythonVersion;用 `list()` 区分「作业已不存在」与「读失败」,修安装状态永久 500;补 Windows `Scripts/scrapling-mcp.exe` 入口;CLI 未知旗标不再吞参。
29
+
30
+ **Python 侧**
31
+
32
+ - `py/redis_storage.py`:非法端口/IPv6 补方括号,客户端按 (url, timeout) 复用,close 同步清缓存与客户端表。
33
+ - `py/session_page.py`:dialog handler 批次结束即摘;动作校验全部先 isinstance 再白名单。
34
+ - `py/media.py`:下载先 stat 后读、流式下载先判后写;非 download 异常如实上报。
35
+ - `py/extraction.py`:`queryType` 缺省不再压掉 `useXpath`;预算按 json 序列化长度二分收缩,locate 按整条载荷计预算。
36
+ - `py/adapters.py`:session.fetch 的 static 分支改 `_static_method`,PUT/DELETE/裸 body 不再静默变 GET;closed 条目持锁前复判。
37
+ - `py/crawl.py`:crawl_started 播报失败撤占位;allowed_domains 统一小写;域判定源单源化;crawl_status 快照移出全局锁;未 start 线程可 stop。
38
+ - `py/guard.py`:urlparse 包 try 返回 malformed;`NO_PROXY=*` 三路同解;NAT64 前缀配置校验;PAC 串脱敏;合成池只在单一池命中时放宽。
39
+ - 其余:`py/redact.py` 畸形 URL 按参数名兜底脱敏并扩 key 表;`py/search.py` DDG 跳板按 host 精确/后缀匹配。
40
+
41
+ ### Added
42
+
43
+ - **测试三层**:`test/gate-scripts.test.ts`、`test/mcp-contract.test.ts`、`test/platform/interpreter.platform.test.ts`、`test/property/protocol.property.test.ts`(fast-check)、`test/e2e/byte-pipe.e2e.test.ts`(真进程字节层回路)、`test/readme-parity.test.ts`;`py/tests/test_bridge.py` 加 662 行。
44
+ - **扩展点**:`lib/mcp-server.ts` 新增 `McpSessionFactory`/`McpSession` 装配缝与 `MCP_AUTH_REQUIRED` 错误码;`src/settings-fields.ts` 新增 `schemes` 协议白名单(proxyUrl、searxngEndpoint 录入期收口)。
45
+
6
46
  ## 0.1.5
7
47
 
8
48
  这一版把设置卡与读面校验统一到 shared 组件和 zod,让提示指引跟随宿主的步骤准入视图,
@@ -21,8 +61,9 @@
21
61
  - **提示指引跟随步骤准入**:宿主提供 `toolSet` 时,指引按 `view(scope)` 的实际可见集生成,受限子代理
22
62
  与条件工具不再沿用全量注册表;没有准入时退回原判据。
23
63
  - **`zod` 进入运行期依赖**:client 产物按宿主 `PLATFORM_MODULES` 外置;CLI 单文件产物包含 zod。
24
- - **宿主开发线抬到 `0.2.2-alpha.2`**:devDependencies 与 catalog/overrides 同值;`engines.dsh` 与 peer
25
- 仍写支持窗口 `^0.2.1-rc.3`,README 补滚动窗口说明;MCP server 自述版本同步到 0.1.5。
64
+ - **宿主开发线抬到 `0.2.2-alpha.2`**:devDependencies 与 catalog/overrides 同值;`engines.dsh` 与
65
+ peer 范围同为 `^0.2.1-rc.3`(见下方 Fixed),README 补滚动窗口说明;
66
+ MCP server 自述版本同步到 0.1.5。
26
67
  - **插件页展示面进包**:新增 `locale/en.json`、`locale/zh.json` 与 `docs/DETAIL.md`、`docs/DETAIL.zh.md`;
27
68
  `exports` 增加 `./locale/*.json`,`files` 收进 locale 与 docs。
28
69
  - **正则常量与迭代写法收口**:CLI、安装器、MCP profile、URL 策略与测试里的内联正则提取为命名常量,
@@ -41,7 +82,7 @@
41
82
  探针改按 devDependency 的精确版装同一宿主线,安装树回到同一档。
42
83
  - **`@deepseek-ai/dsh*` 的 peer 范围覆盖 alpha.2**:`^0.2.1-rc.3` 的预发布语义不含
43
84
  `0.2.2-alpha.2`(不是同一 patch 元组),而本包装配和测试正是对着 alpha.2;范围改为
44
- `^0.2.1-rc.3 || ^0.2.2-alpha.2`,与 README 的三版窗口一致。
85
+ `^0.2.1-rc.3`,与 README 的三版窗口一致。
45
86
 
46
87
  ## 0.1.4
47
88
 
@@ -74,7 +115,6 @@
74
115
  - **搜索 provider**:`ctx.web` 的 `web_search` 可由 Scrapling 的 Tavily/Bing 发现层接管(`searchBackend`),搜索结果可选择性渲染。
75
116
  - **浏览器与媒体工具**:`scrapling_session_read`、`scrapling_session_act`、`scrapling_download`、`scrapling_screenshot`;动作与下载有部署级门禁,截图经宿主 attachment 服务。
76
117
  - **`mcp` 模式(`integrationMode: mcp`)**:插件在宿主进程内起一个 streamable-http 的 MCP server,默认 `http://127.0.0.1:39217/mcp`(端口走部署项 `mcpPort`),端出与 native **同一份** `ToolDefinition` 表:19 个原始名去掉 `scrapling_answer`,再加 MCP 独有的 `search`。URL 闸门、会话、作业与 adaptive 存储全部复用,门禁一致(`allowBrowserActions=false` 就没有 `session_act`)。只绑回环,声明正文超过 1 MiB 判 `413`,非 `/mcp` 路径 `404`;token 只从环境变量 `DSH_SCRAPLING_MCP_TOKEN` 读,不写进 profile;截图以 MCP image content 交出而不是宿主附件。新增运行期依赖 `@modelcontextprotocol/sdk@1.32.2`,它只在真的起 server 时才动态载入,`native` 模式一行都不执行。
77
-
78
118
  - **`setup --mode` 与 `doctor`**:`dsh-scrapling setup --mode native|mcp|official-mcp [--port N] [--with-auth] [--accept-risk] [--profile 目录] [--apply]` 产出 `dsh-mcp-client` 的条目文本;不带 `--apply` 只打印,带上就写到 `<dataDir>/mcp/<模式>.patch.yml` 并打出路径,profile 本体一个字都不改(宿主没有安全追加 `cordis.patch.yml` 的接口)。`dsh-scrapling doctor --mode <模式> --profile <目录> [--port N]` 读那份 profile 自己写下的 `cordis.patch.yml` 与 `package.json`,逐条点名:同一 `serverName` 两条例目、本插件条目与官方 `stdio` 条目并存、条目类型与模式不符、条目端口与 `--port` 不一致、客户端缺失或钉的不是 `0.2.1-rc.3`/`next`、`officialMcpEnabled` 关着却留着官方条目;一致退 0、有点名退 1、参数不对退 2。`official-mcp` 需要 profile 的开关与命令行的 `--accept-risk` 两处分别表态,缺任一处只打错误码不写文件;官方二进制尚未由 `mcp` 包提供时,它额外打一行说明这条条目起不来。
79
119
  - **运行时能力包安装器与 CLI**:`core` 装托管 Python 3.14.9 + Scrapling 0.5,`browser` 装完整 Chromium;`dsh-scrapling setup --status|--feature|--repair|--uninstall|--purge` 是唯一安装入口,设置卡显示包状态并可在有 remote/作业后端时发起安装、修复与取消。
80
120
 
@@ -82,7 +122,6 @@
82
122
 
83
123
  - **两道 URL 闸门不再一边宽一边严**:Python 侧此前在每条发出请求的路径上都接受 `ws:`/`wss:`(那只有 WebSocket 握手判定该认),也不看 URL 内嵌的凭据。现在请求侧只认 `http`/`https`,内嵌凭据一律判拒 —— Host 侧 `url-policy` 的这两条在 Python 侧同样成立。放行名单只豁免「地址必须公网」这一条,不豁免这两条。
84
124
  - **crawl 的第二、第三个 URL 现在过宿主闸门**:`SidecarClient.call` 原先只筛 `params.url`,模型给的 `sitemapUrl` / `feedUrl` 原样进 payload;现在三处都筛,归一过的写进同一份新的参数对象,判否即止、不再为后面的 URL 继续解析。
85
-
86
125
  - **浏览器参数越界不再被报成一次抓取失败**:上游把会话的这两个键收在 `RetriesCount`(1..10)与 `PagesCount`(1..50)里,越界值不在 Scrapling 的参数校验里被拒,而是在它的类型层炸成 `TypeError: Invalid argument type: Expected int <= 10 - at $.retries`,本包再把它归成一次失败。现在 `retries` 与 `maxPages` 在浏览器路径上先判,超限直接 `BAD_ARGS` 并点名上限;静态抓取那一侧的 `retries` 仍不设上限(上游那张表里它是裸 `Optional[int]`)。
87
126
  - **检索后端扩到六条**:新增 Brave(API)、Serper(API)、DuckDuckGo HTML 与 SearXNG(JSON API)四条发现路径,部署面新增 `braveApiKey` / `serperApiKey` / `searxngEndpoint` / `duckduckgoEndpoint`,`searchBackend` 的取值域随之扩大;每条后端只把自己那把 key 递给 sidecar(拼错后端名不会把 Tavily 的 key 递出去),选中却没配凭据的后端报 `SEARCH_AUTH` 而不是静默换后端。四条后端按各家文档的请求/响应形状实现,用本地 stub 验证形状与错误面(命中映射、401/429、无效 JSON、DDG 的 `uddg` 跳板解码、无结果带 note);**真实端点与真实 key 未验证**。
88
127
  - **adaptive 指纹库可放 Redis**:新增 `py/redis_storage.py`(`StorageSystemMixin` 子类,按键 `<prefix>:<注册域>:<sha256(identifier)>` 落、值是该元素的 orjson 指纹;口令不进日志与错误文本),部署面新增 `adaptiveStorage`(`sqlite`/`redis`,默认 sqlite)与 `redisUrl`;`adaptive-redis` 能力包解除 blocked,`redis==8.1.0` 连同哈希钉进 `py/runtime-requirements.txt`。真机:本机 redis-server 上 save/retrieve 往返、经 sidecar 的 `select` 真的把指纹写进 Redis;连不上与缺客户端各有一条点名的 `ADAPTIVE_STORAGE_UNAVAILABLE`。
@@ -113,10 +152,12 @@
113
152
  - **sidecar 收尾不停爬虫**:`bridge` 的两条关机路径只关会话,蜘蛛线程留给进程退出带走,而那段里它们还在往 stdout 推事件帧 —— 宿主已经不读这一路了。`close_all_crawls` 现在逐只叫停、按 `SHUTDOWN_JOIN_SECONDS` 有界等地等线程退出(等不到的记一行 stderr,不拖成假关机),并接进两条收尾路径的会话关闭之前。
114
153
  - **MCP 无鉴权警告指了一处不存在的设置**:警告写「Set `DSH_SCRAPLING_MCP_TOKEN` (or the mcpToken setting)」,而本包刻意没有 `mcpToken` 这一项 —— token 只从环境读、绝不进 profile。文案改成只说环境变量。
115
154
 
116
- ### Changed
155
+ ### Removed
117
156
 
118
157
  - **协议面下线 `extract`**:`scrapling_extract` 自始至终走 `select`,离线正文归一的 `extract` 方法没有任何调用方,留着等于给「已有 HTML → 正文」多开一条可以绕开清洗的入口。清洗只剩 `to_payload` 一条口(`scrapling_session_read` 走的就是它):判据改钉在进程内的 `to_payload` 调用上,上游键名对照由 `contract_probe` 直接摆到同一处调用点,协议侧只钉「`extract` 回 `UNKNOWN_METHOD`」。
119
158
 
159
+ ### Changed
160
+
120
161
  - **门禁与 Python 启动器改成跨平台**:`py` / `py:which` 从 `sh -c` 换成 `py-launcher.mjs`(POSIX 找 `_env/.venv/bin/python`,Windows 找 `_env/.venv/Scripts/python.exe`;都没有才落 PATH 上的 `python3` / `python`),`face:py` 从 `python -c` 移到 `face-py.mjs`,覆盖率链不再用 `DSH_PY_COVERAGE=1` 这种前缀式赋值与 `mkdir -p`。CI 矩阵因此加了一格 `windows-latest`(node 24):验的是插件与门禁在 Windows 上跑得通,运行时能力包仍只在 macOS arm64 提供。
121
162
  - **`pythonBin` 留空时的回落文案说清平台**:POSIX 上的回落名是 `python3`,Windows 上是 `python`(`resolveRuntime` 交给宿主的是 `python.exe`);两份 README 与设置卡提示同步。
122
163
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 JayYuen666
3
+ Copyright (c) 2026 JayYuen (JayYuen666)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/d18m/@jayyuen66/dsh-scrapling?style=flat-square" alt="npm downloads (total)" /></a>
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
- <img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
14
+ <img src="https://img.shields.io/badge/node-%3E%3D22.18-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
15
15
  <img src="https://img.shields.io/badge/dsh-%5E0.2.1--rc.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>
@@ -38,7 +38,7 @@
38
38
  - [What it does not provide](#what-it-does-not-provide)
39
39
  - [Enabling it in dsh](#enabling-it-in-dsh)
40
40
  - [The tools](#the-tools)
41
- - [Replacing the built-in fetch and search](#replacing-the-builtin-fetch-and-search)
41
+ - [Replacing the built-in fetch and search](#replacing-the-built-in-fetch-and-search)
42
42
  - [MCP mode](#mcp-mode)
43
43
  - [Settings](#settings)
44
44
  - [Proxies](#proxies)
@@ -75,9 +75,9 @@ dsh plugin --profile web add @jayyuen66/dsh-scrapling
75
75
 
76
76
  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.
77
77
 
78
- - **Requires Node.js `>= 22.12`.** This is an ESM-only package; that Node floor is what makes `require()` of an ESM entry work at all, which is why `engines.node` is declared.
79
- - **Requires host `dsh` at the `0.2.1-rc.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.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: this package is verified against the three most recently released host versions at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
80
- - **Requires Python 3.14+ with Scrapling installed** — in the repository's `_env/.venv`, or reachable from `PATH`, or named by `pythonBin`. In an installed package the `_env/.venv` leg does not exist, so the interpreter is 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.
78
+ - **Requires Node.js `>= 22.18`.** 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; TypeScript type stripping is on by default from Node 22.18, so that is the floor that keeps `pnpm build` and `prepack` working on a declared-supported version.
79
+ - **Requires host `dsh` at the `0.2.1-rc.3` / `0.2.2-alpha.2` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.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: this package is verified against the three most recently released host versions at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
80
+ - **Requires Python 3.14+ with Scrapling installed** — named by `pythonBin`, or found by the fixed chain in `lib/runtime.ts` (managed runtime under `dataDir/runtime`, 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 that managed Python 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.
81
81
 
82
82
  ```sh
83
83
  pip install "scrapling[rag]>=0.5,<0.6"
@@ -125,8 +125,8 @@ dsh-scrapling setup --status
125
125
 
126
126
  - **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.
127
127
  - **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.
128
- - **It opens no HTTP route of its own.** The settings card is a host config form; there is no `/api` surface from this package.
129
- - **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI only manages runtime packs.
128
+ - **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.
129
+ - **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI manages runtime packs, plus the two halves of the MCP hookup: `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` from that same file.
130
130
 
131
131
  ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
132
132
 
@@ -273,7 +273,7 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
273
273
 
274
274
  | Field | Type | Default | Purpose |
275
275
  | --- | --- | --- | --- |
276
- | `pythonBin` | string | `""` | Interpreter name or absolute path. Empty = the repository `_env/.venv` when usable, otherwise `python3` on `PATH` (`python` on Windows) |
276
+ | `pythonBin` | string | `""` | Interpreter name or absolute path. Empty walks the fixed chain in `lib/runtime.ts`: the managed runtime under `dataDir` (what `setup --feature core --apply` installs), then the repository `_env/.venv` when usable (a source checkout only), then `python3` on `PATH` (`python` on Windows) |
277
277
  | `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 |
278
278
  | `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` |
279
279
  | `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,9 +287,9 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
287
287
  | `waitSelectorState` | enum | `attached` | The state a `waitSelector` element must reach (`attached` / `detached` / `hidden` / `visible`) |
288
288
  | `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 |
289
289
  | `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 |
290
- | `provideWebFetch` / `provideWebSearch` | boolean | `true` | Whether the `ctx.web` providers are registered at all — see [Replacing the built-in fetch and search](#replacing-the-builtin-fetch-and-search) |
290
+ | `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) |
291
291
  | `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` |
292
- | `searchPublicFallback` | boolean | `false` | Lets `auto` fall back to public engines (DuckDuckGo / Bing) when neither a key nor SearXNG is configured. Off by default on purpose: turning it on sends query strings to third-party public engines |
292
+ | `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 |
293
293
  | `braveApiKey` / `serperApiKey` | secret | `""` | Keys for the Brave Search and Serper.dev backends |
294
294
  | `searxngEndpoint` | string | `""` | Base URL of a SearXNG instance (`…/search?format=json` is appended); empty means the backend is unusable and reports `SEARCH_AUTH` |
295
295
  | `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" |
@@ -351,7 +351,7 @@ Details worth knowing:
351
351
 
352
352
  ## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Security
353
353
 
354
- - **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 can hand over — `url`, plus crawl's `sitemapUrl` and `feedUrl` — 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.
354
+ - **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.
355
355
  - Known gaps, stated in the open:
356
356
  - **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.
357
357
  - **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,8 +366,8 @@ Details worth knowing:
366
366
 
367
367
  | Aspect | Content |
368
368
  | --- | --- |
369
- | On disk | The sidecar working directory (`dataDir`, default `~/.dsh-scrapling`) holds Scrapling's `adaptive` fingerprint database; login-state files are written under `sessionStateDir` when it is configured. Settings values live in the host settings document. Nothing else is written |
370
- | Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go from the Python sidecar to Tavily or Bing (the configured `tavilyApiKey` is sent to Tavily and never logged). `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 |
369
+ | 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 |
370
+ | 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 |
371
371
  | Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
372
372
  | In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
373
373
  | Telemetry | None |
@@ -383,7 +383,7 @@ Registered honestly, one entry per class.
383
383
  - **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.
384
384
  - **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.
385
385
  - **`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`.
386
- - **`scrapling_locate` and `scrapling_links` are offline parsers.** Both take HTML 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. Both share `extractMaxOutputChars`.
386
+ - **`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`.
387
387
  - **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.
388
388
  - **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).
389
389
  - **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.
@@ -420,4 +420,4 @@ pnpm run test:py # end-to-end check of the Python sidecar
420
420
 
421
421
  MIT. Source at [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling). Issues go to that repository's tracker.
422
422
 
423
- This package ships no third-party source code — Scrapling and the browser engines are runtime dependencies, and the only third-party content in the package is the icon (Tabler Icons). [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) records that boundary.
423
+ 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 (Tabler Icons) 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.
package/README.zh-CN.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/d18m/@jayyuen66/dsh-scrapling?style=flat-square" alt="npm downloads (total)" /></a>
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
- <img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
14
+ <img src="https://img.shields.io/badge/node-%3E%3D22.18-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
15
15
  <img src="https://img.shields.io/badge/dsh-%5E0.2.1--rc.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>
@@ -75,9 +75,9 @@ dsh plugin --profile web add @jayyuen66/dsh-scrapling
75
75
 
76
76
  卸载用 `dsh plugin --profile web remove @jayyuen66/dsh-scrapling`。包在公共 npm registry 上,安装不需要凭据,也不需要 scoped-registry 配置行。
77
77
 
78
- - **需要 Node.js `>= 22.12`。** 本包是 ESM-only;正是这条 Node 下限让 `require()` 一个 ESM 入口得以工作,`engines.node` 因此声明。
79
- - **需要宿主 `dsh` 处在 `0.2.1-rc.3` 版本线。** 宿主真正读的是 `engines.dsh`(`^0.2.1-rc.3`),且它**单独决定**;更新版本线的宿主会被拒,需要显式风险授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`。支持窗口是滚动的:本包在发布时最近的三个已发布宿主版本上逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
80
- - **需要 Python 3.14+ 且装好 Scrapling** —— 在仓内 `_env/.venv` 里、能从 `PATH` 找到、或由 `pythonBin` 指定。装出去的包里没有 `_env/.venv` 这一档,解释器就是你 `PATH` 上的 `python3`(Windows 上是 `python`);选中哪一支会在装载时写进日志,缺 Scrapling 时报错里带着可直接照抄的安装命令。
78
+ - **需要 Node.js `>= 22.18`。** 本包是 ESM-only,且构建入口(`build-client.ts`、`build-host.ts`、`build-cli.ts`)由 `node` 直接执行;TypeScript 的类型剥离自 Node 22.18 起默认开启,这条下限保证 `pnpm build` 与 `prepack` 在声明支持的版本上能跑通。
79
+ - **需要宿主 `dsh` 处在 `0.2.1-rc.3` / `0.2.2-alpha.2` 版本线。** 宿主真正读的是 `engines.dsh`(`^0.2.1-rc.3`),且它**单独决定**;更新版本线的宿主会被拒,需要显式风险授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`。支持窗口是滚动的:本包在发布时最近的三个已发布宿主版本上逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
80
+ - **需要 Python 3.14+ 且装好 Scrapling** —— 由 `pythonBin` 指定,或按 `lib/runtime.ts` 的固定链找到:`dataDir/runtime` 下的托管 runtime → 仓内 `_env/.venv` → `PATH`。装出去的包里没有 `_env/.venv` 这一档,所以跑过 `setup --feature core --apply` 的机器用的是那支托管解释器,没装过就是你 `PATH` 上的 `python3`(Windows 上是 `python`);选中哪一支会在装载时写进日志,缺 Scrapling 时报错里带着可直接照抄的安装命令。
81
81
 
82
82
  ```sh
83
83
  pip install "scrapling[rag]>=0.5,<0.6"
@@ -125,8 +125,8 @@ dsh-scrapling setup --status
125
125
 
126
126
  - **它不是搜索引擎。** 检索由 Python sidecar 走六条后端之一(`searchBackend`:`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng`);Scrapling 自己的 `google_search` 选项只是加一个 Google referer 头。每条后端都要自己的配置(`tavilyApiKey`、`braveApiKey`、`serperApiKey`、`searxngEndpoint`)—— 选中却没配的后端报 `SEARCH_AUTH`,不会静默换到别的后端。
127
127
  - **npm tarball 里没有解释器与浏览器。** 它们来自你的机器,或来自可选的 CLI 安装器 —— 后者把已验证的 macOS arm64 资产装进 `dataDir/runtime`;装载时缺什么就少注册什么,不会临时去下载。
128
- - **它不自开 HTTP 路由。** 设置卡是宿主的配置表单;本包没有自己的 `/api` 面。
129
- - **它不加 dsh 子命令。** 本包自己的 `dsh-scrapling` CLI 只管理运行时能力包。
128
+ - **它不在宿主侧新增 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 打一条「无鉴权、本机任意进程可调」的告知。
129
+ - **它不加 dsh 子命令。** 本包自己的 `dsh-scrapling` CLI 管运行时能力包,另外管 MCP 接法的两件事:`setup --mode native|mcp|official-mcp` 生成客户端条目、带 `--apply` 时写到 `<dataDir>/mcp/<模式>.patch.yml`(profile 本体一个字不改),`doctor --mode` 拿那份条目与 profile 的 `cordis.patch.yml` 逐条核对。`setup --status` 给了 `--profile` 时读的也是那份文件里的 `pythonBin`。
130
130
 
131
131
  ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 在 dsh 里启用
132
132
 
@@ -273,7 +273,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
273
273
 
274
274
  | 字段 | 类型 | 默认值 | 作用 |
275
275
  | --- | --- | --- | --- |
276
- | `pythonBin` | string | `""` | 解释器名或绝对路径。留空 = 仓内 `_env/.venv` 可用就用它,否则用 `PATH` 上的 `python3`(Windows 上是 `python`) |
276
+ | `pythonBin` | string | `""` | 解释器名或绝对路径。留空时按 `lib/runtime.ts` 的固定链走:`dataDir` 下的托管 runtime(`setup --feature core --apply` 装的就是它)→ 仓内 `_env/.venv`(可用才算,只有源码检出才有)→ `PATH` 上的 `python3`(Windows 上是 `python`) |
277
277
  | `failFastOnMissingPython` | boolean | `true` | sidecar 进程起不来(路径错、协议对不上、握手超时)时拒绝加载。解释器起得来但没装 Scrapling 时,无论这枚开关如何都只降级为「工具不可用」,日志点名解释器路径 |
278
278
  | `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `screenshotEnabled` | boolean | `true` | 每个工具一枚总闸。`sessionStateEnabled` 管登录态存取那一对,它们还要部署侧配好 `sessionStateDir` |
279
279
  | `extractionType` | enum | `markdown` | `markdown` / `html` / `text`;三条路径过同一套反注入清洗,`html` 额外剥事件处理器属性,因此**不是字节级原始 HTML** |
@@ -289,7 +289,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
289
289
  | `dataDir` | string | `""` | sidecar 工作目录(`adaptive` 指纹库落这里);留空 = `~/.dsh-scrapling`。目录建不出来时由 `failFastOnMissingPython` 决定:拒绝加载,或降级为不注册任何工具 |
290
290
  | `provideWebFetch` / `provideWebSearch` | boolean | `true` | 是否注册 `ctx.web` 的两个 provider —— 见[替代内置的抓取与搜索](#替代内置的抓取与搜索) |
291
291
  | `searchBackend` / `tavilyApiKey` | enum / secret | `auto` / `""` | 发现后端(`auto` / `tavily` / `bing` / `brave` / `serper` / `duckduckgo` / `searxng`)与 Tavily key。`auto` 有 key 走 Tavily、配了 `searxngEndpoint` 走 SearXNG;两者都没有时只有打开 `searchPublicFallback` 才回落公共引擎(否则报 `SEARCH_BACKEND_MISSING`);选中却没配自家 key(或实例)的后端报 `SEARCH_AUTH` |
292
- | `searchPublicFallback` | boolean | `false` | 允许 `auto` 在既没有 key、也没有 SearXNG 时回落到公共引擎(DuckDuckGo / Bing)。**默认关是刻意的**:打开就等于把查询词发给第三方公共引擎 |
292
+ | `searchPublicFallback` | boolean | `false` | 允许 `auto` 在既没有 key、也没有 SearXNG 时回落到公共的 Bing —— `py/search.py` 把 `auto` 按 `tavily` → `searxng` → `bing` 定案,DuckDuckGo 不在 `auto` 的落点里,要用得显式设 `searchBackend=duckduckgo`。**默认关是刻意的**:打开就等于把查询词发给第三方公共引擎 |
293
293
  | `braveApiKey` / `serperApiKey` | secret | `""` | Brave Search 与 Serper.dev 的 key |
294
294
  | `searxngEndpoint` | string | `""` | SearXNG 实例的基址(会拼上 `…/search?format=json`);为空表示这条后端不可用,报 `SEARCH_AUTH` |
295
295
  | `answerProvider` / `answerModel` / `answerMaxTokens` | string / natural | `""` / `""` / `2000` | `scrapling_answer` 走哪条模型路由与单次回答的 token 上限。provider 与 model 都留空表示「跟随当前会话的模型」 |
@@ -351,7 +351,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
351
351
 
352
352
  ## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 安全说明
353
353
 
354
- - **SSRF。** Scrapling 自身没有任何 SSRF 防护。本包在 Host 侧加一层 URL 策略 —— scheme 白名单、拒绝 URL 内嵌凭据、长度上限、authority 里有反斜杠或控制字符即拒、DNS 解析后按**整个答案集**判定是否全为公网、IPv4-mapped 与 NAT64 地址按内嵌 IPv4 重判 —— 并在 Python 侧把 scheme、内嵌凭据与地址这三条再强制一次(长度上限留在 Host 侧策略里,因为它是一项部署设置)。发出请求的路径只认 `http`/`https`,内嵌凭据一律判拒;`ws`/`wss` 只在 WebSocket 握手那一处按地址判。**判的和发出去的是同一个地址**:闸门判的是 WHATWG 归一后的结果,sidecar 转发的也是这个归一串,否则「判的是 A、连的是 B」本身就会成为绕过面。Host 侧那道策略由 `SidecarClient.call` 统一执行,而它把模型能交进来的每一处 URL 都筛一遍 —— `url`,加上 crawl 的 `sitemapUrl` 与 `feedUrl` —— 因此覆盖每一个工具与 `web_fetch` provider,判否时抛 `URL_BLOCKED`、请求根本不会写进管道;`web_search` provider 对它准备交回的 URL 跑同一道闸门,被拒的命中不会成为可引用的 source。浏览器侧的守卫覆盖主导航、子资源、XHR 与 WebSocket 握手。
354
+ - **SSRF。** Scrapling 自身没有任何 SSRF 防护。本包在 Host 侧加一层 URL 策略 —— scheme 白名单、拒绝 URL 内嵌凭据、长度上限、authority 里有反斜杠或控制字符即拒、DNS 解析后按**整个答案集**判定是否全为公网、IPv4-mapped 与 NAT64 地址按内嵌 IPv4 重判 —— 并在 Python 侧把 scheme、内嵌凭据与地址这三条再强制一次(长度上限留在 Host 侧策略里,因为它是一项部署设置)。发出请求的路径只认 `http`/`https`,内嵌凭据一律判拒;`ws`/`wss` 只在 WebSocket 握手那一处按地址判。**判的和发出去的是同一个地址**:闸门判的是 WHATWG 归一后的结果,sidecar 转发的也是这个归一串,否则「判的是 A、连的是 B」本身就会成为绕过面。Host 侧那道策略由 `SidecarClient.call` 统一执行,而它把模型交进来**要拿去取回内容**的每一处 URL 都筛一遍 —— `url`,加上 crawl 的 `sitemapUrl` 与 `feedUrl` —— 只留一处刻意的例外:三个离线解析器(`scrapling_extract`、`scrapling_locate`、`scrapling_links`)的 `url` 只作相对地址的解析基准,不会拿它向任何地方发请求,因此 `lib/sidecar.ts` 的 `BASE_ONLY_METHODS` 不放它过闸 —— 除此之外覆盖每一个工具与 `web_fetch` provider,判否时抛 `URL_BLOCKED`、请求根本不会写进管道;`web_search` provider 对它准备交回的 URL 跑同一道闸门,被拒的命中不会成为可引用的 source。浏览器侧的守卫覆盖主导航、子资源、XHR 与 WebSocket 握手。
355
355
  - 已知缺口,写在明处:
356
356
  - **连接钉扎**(undici 层技术)对非 Node 传输不可用;校验与真正建连之间有 TOCTOU 窗口。静态抓取由 curl_cffi 的 `follow_redirects="safe"` 兜住重定向,浏览器抓取由 Python 侧的 route handler 兜住。
357
357
  - **NAT64 前缀不做动态探测。** 两个标准化前缀已覆盖;运营商自建的要用 `nat64Prefixes` 声明,否则藏在 IPv6 里的私网 IPv4 会被当成普通公网 IPv6 放行。
@@ -366,8 +366,8 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
366
366
 
367
367
  | 口径 | 内容 |
368
368
  | --- | --- |
369
- | 写盘 | sidecar 工作目录(`dataDir`,默认 `~/.dsh-scrapling`)里是 Scrapling `adaptive` 的指纹库;配了 `sessionStateDir` 时登录态文件写在那个目录下。设置值在宿主的设置文档里。其余什么都不写 |
370
- | 网络 | 抓取发往模型给的 URL,配了代理就走代理。搜索查询由 Python sidecar 发往 Tavily 或 Bing(`tavilyApiKey` 只发给 Tavily,绝不写日志)。`scrapling_answer` 把抓到的页面正文与问题经宿主 `llm` 服务送出 —— 路由到的模型在远端时,这些内容就离开了本机 |
369
+ | 写盘 | 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 服务保管,落在哪里由宿主决定。设置值在宿主的设置文档里 |
370
+ | 网络 | 抓取发往模型给的 URL,配了代理就走代理。搜索查询由 Python sidecar 发往 `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 实例。每个后端只收到自己那把凭据(`tavilyApiKey` / `braveApiKey` / `serperApiKey`)与查询串,key 绝不写日志。打开 `searchPublicFallback` 时 `auto` 会把查询发给不带任何凭据的公共引擎。`scrapling_answer` 把抓到的页面正文与问题经宿主 `llm` 服务送出 —— 路由到的模型在远端时,这些内容就离开了本机 |
371
371
  | 日志 | 选中的解释器、探测到的能力、代理摘要(`scheme://host:port` 加来自哪一档 —— 绝无凭据) |
372
372
  | 内存 | 会话、cookie 与录下的网络历史都在 sidecar 进程里,随进程一起消失 |
373
373
  | 遥测 | 无 |
@@ -383,7 +383,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
383
383
  - **浏览器身份类的旋钮只开在真能用上它的工具上。** `useragent` / `locale` / `timezoneId` / `headless` 摆在一次性的浏览器工具与 `scrapling_session_open` 上 —— 它们只在会话构造期生效,会话内传过去会被上游静默丢掉。
384
384
  - **网络历史是会话级的。** 记录是构造期设置(部署默认 `recordRequests`,或每次 `scrapling_session_open` 上的 `recordNetwork`);没开记录的会话报错,而不是回一个空列表。
385
385
  - **`scrapling_screenshot` 绕过文本清洗。** 截图拍的是页面在视口里真正渲染出来的东西 —— 包括 token、私信、登录后才可见的数据等从未出现在 DOM 文本里的视觉秘密。截图经宿主 attachment 服务落库,只有该服务挂载时才注册。 交回的是该服务**归一化之后**的引用:声明为 PNG 的字节可能被存成 `image/jpeg` 且尺寸更小,而 `originalDimensions` 记的是页面真正产出的那一份(宿主契约:`@deepseek-ai/dsh-attachment` 的 `saveImage`)。`scrapling_download` 把字节写进 `dataDir/downloads`,绝不覆盖已有文件,`filename` 里带路径成分会被拒绝。
386
- - **`scrapling_locate` 与 `scrapling_links` 是离线解析器。** 两者只读调用方给的 HTML,不发网络请求;`scrapling_links` 只在给了 `baseUrl` 时才保留相对链接 —— `baseUrl` 为空时返回空链接,而不是猜绝对地址。两者共用 `extractMaxOutputChars`。
386
+ - **`scrapling_extract`、`scrapling_locate` 与 `scrapling_links` 是离线解析器。** 三者只读调用方给的 HTML,不发网络请求;`scrapling_links` 只在给了 `baseUrl` 时才保留相对链接 —— `baseUrl` 为空时返回空链接,而不是猜绝对地址。三者共用 `extractMaxOutputChars`。
387
387
  - **adaptive 重定位是尽力而为。** Scrapling 只保存第一个命中元素;原属性变化后,可能选中一个高度相似的兄弟元素。把重定位结果当作线索并自行核对;`scrapling_locate` 不保存指纹。
388
388
  - **运行时能力包只在 macOS arm64 上验证过。** Windows、Linux 与 macOS x64 的所有包都报 `blocked`;安装器直接拒绝,不猜资产路径(B1/B2)。
389
389
  - **`adaptive-redis` 包是客户端,不是存储引擎。** 上游只发 `SQLiteStorageSystem`;这里的 Redis 后端是本插件的 `py/redis_storage.py`,一个按注册域分桶的 `StorageSystemMixin` 子类。启用它改变的是指纹存哪儿,属于部署决定而不是逐次开关。本插件自己的 MCP server 是另一件事 —— 它跑在宿主进程内,不需要能力包。
@@ -420,4 +420,4 @@ pnpm run test:py # Python sidecar 的端到端验证
420
420
 
421
421
  MIT。源码在 [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling),issue 走该仓库的 tracker。
422
422
 
423
- 本包不随包分发第三方源码 —— Scrapling 与浏览器引擎都是运行期依赖,随包的第三方内容只有图标(Tabler Icons)。[`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 记录这条边界。
423
+ 本包不随包分发第三方源码 —— Scrapling 与浏览器引擎都是运行期依赖。随包的第三方内容是图标(Tabler Icons)与 CLI 单文件产物内联的 `zod`;host 侧 client 产物外置 zod。[`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 记录这条边界。
@@ -3,14 +3,15 @@
3
3
  本包自身编写的代码以 MIT 发布,见 [`LICENSE`](./LICENSE)。本文件记录**与第三方的边界**:
4
4
  哪一部分来自第三方、在什么意义上「来自」,以及本包自身代码与第三方代码的分界在哪里。
5
5
 
6
- ## 结论:随包分发的第三方内容只有一处
6
+ ## 结论:随包分发的第三方内容有两处
7
7
 
8
8
  `py/`、`lib/`、`host.ts`、`src/` 下全部是本仓原创代码,不含任何第三方源码、词表或文案。
9
- Scrapling 及浏览器引擎都是**运行期依赖**——本包通过它们的公开 API 调用它们,它们不由本包
10
- 分发,许可文本也随各自的包走,本文件不重复。
9
+ Scrapling 及浏览器引擎都是**运行期依赖**——本包调用它们暴露的接口,其中反注入清洗用的
10
+ `Convertor._strip_noise_tags` 与 `Convertor._sanitize_for_ai` 是上游的私有下划线方法,不在上游文档面
11
+ 里(见「机制与接口来源」)。它们不由本包分发,许可文本也随各自的包走,本文件不重复。
11
12
 
12
- 唯一随包分发的第三方内容是**图标**(`icon.svg`),见下节。它是一段路径数据,MIT 允许再分发,
13
- 且本包已在下方保留其版权与许可声明。
13
+ 随包分发的第三方内容有两处:**图标**(`icon.svg`)与**CLI 单文件产物内联的 zod**
14
+ (`bin/dsh-scrapling.mjs`)。两者都是 MIT,且本包在下方保留各自的版权与许可声明。
14
15
 
15
16
  ## 图标:Tabler Icons
16
17
 
@@ -20,9 +21,21 @@ Scrapling 及浏览器引擎都是**运行期依赖**——本包通过它们的
20
21
  - 取用图标:`spider`
21
22
  - 来源:https://icones.js.org/icons/tabler/spider
22
23
 
23
- `icon.svg` 中的形状路径取自该图标的 `spider`。改动仅有两处,都不涉及形状本身:把
24
- `currentColor` 换成本包插件图标配色(`#658EFF` 主色 + `#54ECE7` 底衬),以及把外层 `<g>` 与
25
- 画布尺寸对齐本族插件统一的 `36×36` / `viewBox 0 0 24 24` 规格。路径数据未作改动。
24
+ `icon.svg` 中的形状路径取自该图标的 `spider`。改动有三处:把 `<g>` 上的 `currentColor` 换成本包
25
+ 插件图标主色 `#658EFF`;把外层 `<g>` 与画布尺寸对齐本族插件统一的 `36×36` / `viewBox 0 0 24 24`
26
+ 规格;以及把腹部与头部两条路径各复制一份,加上 `fill="#54ECE7"`、`opacity=".2"` 与同色 `stroke`
27
+ 作底衬。三份源路径的 `d` 数据与上游一致,未作改动;底衬复用同一条 `d`,只是多了填充与描边颜色。
28
+
29
+ ## CLI 单文件产物内联的 zod
30
+
31
+ - 上游项目:`zod`
32
+ - 上游仓库:https://github.com/colinhacks/zod
33
+ - 上游许可:MIT,Copyright (c) 2020 Colin McDonnell
34
+ - 版本:伞根 catalog 4.6.7(`package.json` 写作 `catalog:`)
35
+
36
+ `bin/dsh-scrapling.mjs` 由 `build-cli.ts` 用 rolldown 打成单文件、只外置 `node:` 内置模块,
37
+ 因此 zod 的实现被内联进该产物;host 侧的 `client.js` 按宿主 `PLATFORM_MODULES` 外置 zod。
38
+ 所以 zod 既是运行期依赖,也是 CLI 产物里的一份第三方代码,此处保留其版权与许可声明。
26
39
 
27
40
  ## 机制与接口来源:Scrapling
28
41
 
@@ -52,8 +65,10 @@ Scrapling 及浏览器引擎都是**运行期依赖**——本包通过它们的
52
65
  | `apify-fingerprint-datapoints` | 0.15.0 | Apache-2.0 | browserforge 的指纹数据 |
53
66
  | `playwright` | 1.64.1 | Apache-2.0(Microsoft) | 网络守卫 |
54
67
  | `patchright` | 1.64.2 | Apache-2.0(Microsoft,patch 由 Kaliiiiiiiiii-Vinyzu 提供) | 浏览器渲染与网络守卫 |
68
+ | `@modelcontextprotocol/sdk` | 1.32.2 | MIT | `lib/mcp-server.ts` 的 MCP server 实现 |
55
69
  | `ipaddr.js` | 2.5.0 | MIT | Host 侧 URL 策略的地址分类 |
56
- | `zod` | catalog(伞根 4.6.7) | MIT | 设置卡 `src/runtime-reader.ts` 的 strict codec 形状校验;client 产物由宿主 `PLATFORM_MODULES` 提供 |
70
+ | `fs-native-extensions` | 1.5.3 | Apache-2.0 | `lib/installer.ts` 的安装锁:OS 级 `flock`/`LockFileEx` 互斥,进程退出自动释放 |
71
+ | `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 单文件产物内联 |
57
72
 
58
73
  其余随 venv 安装的固定版本(含 `click`、`protego`、`curl_cffi`、`lxml` 等)见
59
74
  `py/runtime-requirements.txt`,每一行都带 SHA256;本文件不复述整张表。
@@ -61,7 +76,9 @@ Scrapling 及浏览器引擎都是**运行期依赖**——本包通过它们的
61
76
  ## 运行时下载的资产(不随 npm 分发)
62
77
 
63
78
  安装器按需下载下面两项到 `dataDir/runtime`,它们**不在 npm tarball 内**,因此不属于本包
64
- 分发的第三方内容:
79
+ 分发的第三方内容。这条下载路径只在 macOS arm64 上走到:`lib/installer.ts` 的
80
+ `installCapabilityPack` 先判平台,其余平台在任何下载之前抛 `INSTALL_PACK_BLOCKED`;
81
+ `runtime-manifest.json` 也只收录 `darwinArm64` 一份资产,另列出不支持的三种平台。
65
82
 
66
83
  - **Python 3.14.9**:来自 `astral-sh/python-build-standalone` 的
67
84
  `cpython-3.14.9+20261021-aarch64-apple-darwin-install_only.tar.gz`;URL、体积与 SHA256
@@ -74,4 +91,8 @@ Scrapling 及浏览器引擎都是**运行期依赖**——本包通过它们的
74
91
  `patchright` 是 Playwright 的补丁分支,与 `playwright` 并存安装:两者是不同的 Python 包,
75
92
  本包按能力探测判断浏览器抓取能不能用。
76
93
 
77
- dsh 宿主包(`@deepseek-ai/dsh` 及其子包)是 peer 依赖,由宿主提供、不随本包分发。
94
+ dsh 宿主族包里本仓声明为 peer 的只有 `@deepseek-ai/dsh`、`@deepseek-ai/dsh-output-retention`、
95
+ `@deepseek-ai/dsh-tools`、`@deepseek-ai/dsh-typert-protocol`、`@deepseek-ai/dsh-web` 与
96
+ `@deepseek-ai/schemastery`,由宿主提供、不随本包分发。产物里运行期 import 到的是除
97
+ `@deepseek-ai/dsh` 之外的那五个(`host.js`),`client.js` 只外置 `react` 与 `zod`。其余
98
+ `@deepseek-ai/*` 是本仓 devDependencies,只用于类型检查与客户端构建,产物里没有对它们的运行期 import。