@jayyuen66/dsh-scrapling 0.1.5 → 0.1.7
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 +81 -7
- package/LICENSE +1 -1
- package/README.md +20 -19
- package/README.zh-CN.md +18 -17
- package/THIRD_PARTY_NOTICES.md +32 -11
- package/bin/dsh-scrapling.mjs +68 -71
- package/client.js +9 -9
- package/cordis.patch.yml +7 -3
- package/docs/DETAIL.md +6 -6
- package/docs/DETAIL.zh.md +6 -6
- package/host.js +19 -33
- package/package.json +53 -47
- package/py/adapters.py +30 -8
- package/py/bridge.py +137 -30
- package/py/crawl.py +69 -27
- package/py/extraction.py +70 -24
- package/py/guard.py +55 -24
- package/py/media.py +30 -9
- package/py/redact.py +20 -2
- package/py/redis_storage.py +92 -31
- package/py/search.py +9 -2
- package/py/session_page.py +57 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,80 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循
|
|
4
|
-
[语义化版本](https://semver.org/lang/zh-CN/)
|
|
4
|
+
[语义化版本](https://semver.org/lang/zh-CN/)。最新版本在最上。这里的偏离是刻意的:版本标题
|
|
5
|
+
不写发布日期(各版发布时间以 npm registry 为准,`npm view <包名> time` 取得到),并按需增设
|
|
6
|
+
标准六类之外的小节(本仓的 `Boundaries` 收各版本的验证范围与能力边界,即哪些平台/档位真跑过、
|
|
7
|
+
哪些只到本地夹具为止)。
|
|
8
|
+
|
|
9
|
+
## 0.1.7
|
|
10
|
+
|
|
11
|
+
宿主支持窗口抬到 `0.2.1-rc.5 || 0.2.2-alpha.3`,MCP 客户端钉版、设置卡取值面与输出预算
|
|
12
|
+
一起收口;构建与门禁补齐产物新鲜度、行尾与 lint 偏差三条判据,Python 侧补上有界关机。
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **宿主与发布元数据**:devDependencies 全族抬到 `0.2.2-alpha.3`(cordis `4.0.6-alpha.2`、schemastery `3.18.6-alpha.2`);`engines.dsh` 与 dsh 家族 peer 写 `^0.2.1-rc.5 || ^0.2.2-alpha.3`;MCP 客户端默认钉版改为 `0.2.2-alpha.3`,`doctor` 同时放行 rc 线的 `0.2.1-rc.5`;MCP server 自述版本同步 0.1.7。
|
|
17
|
+
- **搜索后端**:名单收进 `lib/search-backends.ts` 单一定义(CLI 判配置与设置卡 enum 同源),Brave/Serper 端点与 `auto` 的分流提示一起显式化;`searxngEndpoint` 改为遮罩输入。
|
|
18
|
+
- **输出预算**:浏览器抓取的网络历史单独封顶;正文被对端 `maxContentChars` 截断而本地未再截时也给出恢复指引,`scrapling_answer` 的截断落到同一条尾巴。
|
|
19
|
+
- **会话参数**:`cookies` / `blockedDomains` 给了非数组时报 `ToolArgsError`;`sessionType=static` 时递进来的浏览器档旋钮直接报错,不再静默丢掉;网络历史的方法名与说明常量收成单一定义。
|
|
20
|
+
- **运行环境与配置**:托管 runtime 只在 macOS arm64 尝试,其余平台报 `INSTALL_PACK_BLOCKED`;Windows 解释器名与根脚本统一为 `python`;`setup` / `doctor` 的 MCP 端口改为显式 `--port`;`nat64Prefixes` 非法时拒绝装载(`CONFIG_INVALID`),`stripInlineImages` 进卡;逗号串统一去空白,空列表不交空数组。
|
|
21
|
+
- **构建与门禁**:`build-helpers.ts` 收拢三份构建脚本的入口判定、原子写与「宿主包被内联」断言;新增 `eol-gate.mjs`、`test/artifact-freshness.test.ts`、`test/build-helpers.test.ts`、`test/lint-deviations.test.ts`,`check` 串上 `gate:eol`;oxlint 的每处规则收窄逐条登记理由并由测试双向核对。
|
|
22
|
+
- **Python 门禁**:ruff 开 RUF100(失效的 `noqa` 判红);mypy 去掉全局 `ignore_missing_imports`,只对 `lxml` 与可选依赖 `redis` 逐模块放行;coverage 开分支统计,地板仍由 `coverage-floor.mjs` 施加。
|
|
23
|
+
- **CI**:pnpm 钉到 `12.11.2`(与伞根 `packageManager` 同源);工作树改写判据先打印再判红;产物探针按 tarball 声明的 peer 范围解析 `dsh-tools`。
|
|
24
|
+
- **文档**:双语 README 与 DETAIL 对齐现量(49 个卡上取值、19 个工具、15 个开关、MCP 端口显式 `--port`、官方 MCP 工具集归上游)。
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Python 关机**:`close-crawls` / `close-sessions` 放进有界线程(10 秒),超时只留日志;drain 超时时把队列里还排着的帧逐条点名,不再静默丢。
|
|
29
|
+
- **协议与运行时**:`runtime-reader` 的 pack/job/拒绝码枚举改从 `runtime-shape.ts` 派生,四个 typert 描述符共用骨架;网关回包先判「对象且带布尔 `ok`」,坏形状报协议错误而不是读属性崩溃;空白 jobId 不再上网关。
|
|
30
|
+
- **错误与路径**:`sidecarErrorWithCode` 把 `details` 排在 `options` 之前,避免把 details 当成 cause 静默吞掉;runtime manifest 的定位以实际文件所在目录为准,`repoPythonPath` 单独抽出。
|
|
31
|
+
- **抽取**:`_query_type` 去掉不使用的 selector 参数,显式 `queryType` 优先于 `useXpath` 的语义写进函数本身。
|
|
32
|
+
- **探针**:`_env` 六份脚本同步到当前 Scrapling 0.5 API,失败按「缺依赖 / 抓取失败 / 探针自身」分类并汇总,不再一条异常中断整份探针。
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- `lib/search-backends.ts`、`eol-gate.mjs`、`test/artifact-freshness.test.ts`、`test/build-helpers.test.ts`、`test/lint-deviations.test.ts`。
|
|
37
|
+
- `py/tests/test_bridge.py` 补爬虫 worker 收尾与关机边界的用例;`contract_probe.py` 跟随新 API。
|
|
38
|
+
|
|
39
|
+
## 0.1.6
|
|
40
|
+
|
|
41
|
+
一轮跨面审查修复,TS 与 Python 两侧一起收口:协议边界、安装器与 sidecar 生命周期、
|
|
42
|
+
Python 子命令判据;门禁脚本与发布链同步加固。
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **门禁脚本硬化**:`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 端到端)。
|
|
47
|
+
- **构建与测试面**:`build-cli.ts` 的 bin 产物改 tmp+rename 原子写并加 `invokedDirectly` 守卫;vitest 并行化(fileParallelism + maxWorkers 50%)、coverage include 收进 `src/runtime-reader.ts`;CI 注释同步 `check:py` 新链,actionlint 改按文件豁免。
|
|
48
|
+
- **依赖与元数据**:`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。
|
|
49
|
+
- **`_env/` 四份探针脚本**改到 Scrapling 0.5 真实 API(StealthySession / network.search / wait_selector)。
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
**TS 侧**
|
|
54
|
+
|
|
55
|
+
- **answer**(`lib/answer.ts`):URL 先过 `escapePageText` 再属性转义,`§page_end§`/`</page>` 边界不再被页面 URL 伪造;AbortError 原样重抛不再包成 ANSWER_FAILED;重复 finish 不再误判失败。
|
|
56
|
+
- **协议**(`lib/jsonl.ts`、`py/bridge.py`):`FrameSplitter.clear()`、单帧回调异常不再丢同 chunk 后续帧、stop 后摘除 end/error 并挂吞错监听、切行后超长帧即报 FrameError;bridge 的 stdin 改 read1 增量切帧、超长残帧弃缓冲报 BAD_FRAME(与宿主 FrameSplitter 同解)、emit 失败补发 INTERNAL 兜底帧。
|
|
57
|
+
- **MCP server**(`lib/mcp-server.ts`):缺 Content-Length 的 POST 回 411;token 比较改 `timingSafeEqual`;截图 sink 加 16 份/60s 上限;非回环绑定且无 token 直接拒启。
|
|
58
|
+
- **安装器**(`lib/installer.ts`):还原失败时保留旧 venv(`restoreFailed`);安装锁由 pid 文件改为 OS 级锁;卸载只摘被卸包的状态位,不再连带触发 browser 重下;offline 归档 URL 百分号编码防御。
|
|
59
|
+
- **MCP profile**(`lib/mcp-profile.ts`):兼容双引号、列表项与行尾注释,URL 端口按 scheme 默认值比对,消除 doctor 假红。
|
|
60
|
+
- **sidecar 稳定性**(`lib/browser-tools.ts`、`lib/tool-params.ts`、`lib/sidecar.ts`):act/screenshot 的 `timeoutMs` 夹进调用截止,单动作超时不再拆掉整个 sidecar 进程;调用级取消不再传给 spawn。
|
|
61
|
+
- **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 未知旗标不再吞参。
|
|
62
|
+
|
|
63
|
+
**Python 侧**
|
|
64
|
+
|
|
65
|
+
- `py/redis_storage.py`:非法端口/IPv6 补方括号,客户端按 (url, timeout) 复用,close 同步清缓存与客户端表。
|
|
66
|
+
- `py/session_page.py`:dialog handler 批次结束即摘;动作校验全部先 isinstance 再白名单。
|
|
67
|
+
- `py/media.py`:下载先 stat 后读、流式下载先判后写;非 download 异常如实上报。
|
|
68
|
+
- `py/extraction.py`:`queryType` 缺省不再压掉 `useXpath`;预算按 json 序列化长度二分收缩,locate 按整条载荷计预算。
|
|
69
|
+
- `py/adapters.py`:session.fetch 的 static 分支改 `_static_method`,PUT/DELETE/裸 body 不再静默变 GET;closed 条目持锁前复判。
|
|
70
|
+
- `py/crawl.py`:crawl_started 播报失败撤占位;allowed_domains 统一小写;域判定源单源化;crawl_status 快照移出全局锁;未 start 线程可 stop。
|
|
71
|
+
- `py/guard.py`:urlparse 包 try 返回 malformed;`NO_PROXY=*` 三路同解;NAT64 前缀配置校验;PAC 串脱敏;合成池只在单一池命中时放宽。
|
|
72
|
+
- 其余:`py/redact.py` 畸形 URL 按参数名兜底脱敏并扩 key 表;`py/search.py` DDG 跳板按 host 精确/后缀匹配。
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- **测试三层**:`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 行。
|
|
77
|
+
- **扩展点**:`lib/mcp-server.ts` 新增 `McpSessionFactory`/`McpSession` 装配缝与 `MCP_AUTH_REQUIRED` 错误码;`src/settings-fields.ts` 新增 `schemes` 协议白名单(proxyUrl、searxngEndpoint 录入期收口)。
|
|
5
78
|
|
|
6
79
|
## 0.1.5
|
|
7
80
|
|
|
@@ -21,8 +94,9 @@
|
|
|
21
94
|
- **提示指引跟随步骤准入**:宿主提供 `toolSet` 时,指引按 `view(scope)` 的实际可见集生成,受限子代理
|
|
22
95
|
与条件工具不再沿用全量注册表;没有准入时退回原判据。
|
|
23
96
|
- **`zod` 进入运行期依赖**:client 产物按宿主 `PLATFORM_MODULES` 外置;CLI 单文件产物包含 zod。
|
|
24
|
-
- **宿主开发线抬到 `0.2.2-alpha.2`**:devDependencies 与 catalog/overrides 同值;`engines.dsh` 与
|
|
25
|
-
|
|
97
|
+
- **宿主开发线抬到 `0.2.2-alpha.2`**:devDependencies 与 catalog/overrides 同值;`engines.dsh` 与
|
|
98
|
+
peer 范围同为 `^0.2.1-rc.3`(见下方 Fixed),README 补滚动窗口说明;
|
|
99
|
+
MCP server 自述版本同步到 0.1.5。
|
|
26
100
|
- **插件页展示面进包**:新增 `locale/en.json`、`locale/zh.json` 与 `docs/DETAIL.md`、`docs/DETAIL.zh.md`;
|
|
27
101
|
`exports` 增加 `./locale/*.json`,`files` 收进 locale 与 docs。
|
|
28
102
|
- **正则常量与迭代写法收口**:CLI、安装器、MCP profile、URL 策略与测试里的内联正则提取为命名常量,
|
|
@@ -41,7 +115,7 @@
|
|
|
41
115
|
探针改按 devDependency 的精确版装同一宿主线,安装树回到同一档。
|
|
42
116
|
- **`@deepseek-ai/dsh*` 的 peer 范围覆盖 alpha.2**:`^0.2.1-rc.3` 的预发布语义不含
|
|
43
117
|
`0.2.2-alpha.2`(不是同一 patch 元组),而本包装配和测试正是对着 alpha.2;范围改为
|
|
44
|
-
`^0.2.1-rc.3
|
|
118
|
+
`^0.2.1-rc.3`,与 README 的三版窗口一致。
|
|
45
119
|
|
|
46
120
|
## 0.1.4
|
|
47
121
|
|
|
@@ -74,7 +148,6 @@
|
|
|
74
148
|
- **搜索 provider**:`ctx.web` 的 `web_search` 可由 Scrapling 的 Tavily/Bing 发现层接管(`searchBackend`),搜索结果可选择性渲染。
|
|
75
149
|
- **浏览器与媒体工具**:`scrapling_session_read`、`scrapling_session_act`、`scrapling_download`、`scrapling_screenshot`;动作与下载有部署级门禁,截图经宿主 attachment 服务。
|
|
76
150
|
- **`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
151
|
- **`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
152
|
- **运行时能力包安装器与 CLI**:`core` 装托管 Python 3.14.9 + Scrapling 0.5,`browser` 装完整 Chromium;`dsh-scrapling setup --status|--feature|--repair|--uninstall|--purge` 是唯一安装入口,设置卡显示包状态并可在有 remote/作业后端时发起安装、修复与取消。
|
|
80
153
|
|
|
@@ -82,7 +155,6 @@
|
|
|
82
155
|
|
|
83
156
|
- **两道 URL 闸门不再一边宽一边严**:Python 侧此前在每条发出请求的路径上都接受 `ws:`/`wss:`(那只有 WebSocket 握手判定该认),也不看 URL 内嵌的凭据。现在请求侧只认 `http`/`https`,内嵌凭据一律判拒 —— Host 侧 `url-policy` 的这两条在 Python 侧同样成立。放行名单只豁免「地址必须公网」这一条,不豁免这两条。
|
|
84
157
|
- **crawl 的第二、第三个 URL 现在过宿主闸门**:`SidecarClient.call` 原先只筛 `params.url`,模型给的 `sitemapUrl` / `feedUrl` 原样进 payload;现在三处都筛,归一过的写进同一份新的参数对象,判否即止、不再为后面的 URL 继续解析。
|
|
85
|
-
|
|
86
158
|
- **浏览器参数越界不再被报成一次抓取失败**:上游把会话的这两个键收在 `RetriesCount`(1..10)与 `PagesCount`(1..50)里,越界值不在 Scrapling 的参数校验里被拒,而是在它的类型层炸成 `TypeError: Invalid argument type: Expected int <= 10 - at $.retries`,本包再把它归成一次失败。现在 `retries` 与 `maxPages` 在浏览器路径上先判,超限直接 `BAD_ARGS` 并点名上限;静态抓取那一侧的 `retries` 仍不设上限(上游那张表里它是裸 `Optional[int]`)。
|
|
87
159
|
- **检索后端扩到六条**:新增 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
160
|
- **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 +185,12 @@
|
|
|
113
185
|
- **sidecar 收尾不停爬虫**:`bridge` 的两条关机路径只关会话,蜘蛛线程留给进程退出带走,而那段里它们还在往 stdout 推事件帧 —— 宿主已经不读这一路了。`close_all_crawls` 现在逐只叫停、按 `SHUTDOWN_JOIN_SECONDS` 有界等地等线程退出(等不到的记一行 stderr,不拖成假关机),并接进两条收尾路径的会话关闭之前。
|
|
114
186
|
- **MCP 无鉴权警告指了一处不存在的设置**:警告写「Set `DSH_SCRAPLING_MCP_TOKEN` (or the mcpToken setting)」,而本包刻意没有 `mcpToken` 这一项 —— token 只从环境读、绝不进 profile。文案改成只说环境变量。
|
|
115
187
|
|
|
116
|
-
###
|
|
188
|
+
### Removed
|
|
117
189
|
|
|
118
190
|
- **协议面下线 `extract`**:`scrapling_extract` 自始至终走 `select`,离线正文归一的 `extract` 方法没有任何调用方,留着等于给「已有 HTML → 正文」多开一条可以绕开清洗的入口。清洗只剩 `to_payload` 一条口(`scrapling_session_read` 走的就是它):判据改钉在进程内的 `to_payload` 调用上,上游键名对照由 `contract_probe` 直接摆到同一处调用点,协议侧只钉「`extract` 回 `UNKNOWN_METHOD`」。
|
|
119
191
|
|
|
192
|
+
### Changed
|
|
193
|
+
|
|
120
194
|
- **门禁与 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
195
|
- **`pythonBin` 留空时的回落文案说清平台**:POSIX 上的回落名是 `python3`,Windows 上是 `python`(`resolveRuntime` 交给宿主的是 `python.exe`);两份 README 与设置卡提示同步。
|
|
122
196
|
|
package/LICENSE
CHANGED
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.
|
|
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-
|
|
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.
|
|
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
|
|
80
|
-
- **Requires Python 3.14+ with Scrapling installed** — in the repository's `_env/.venv`,
|
|
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.5` or `0.2.2-alpha.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.5 || ^0.2.2-alpha.3`), and it decides alone; a host on a later line is refused and needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against every released host version inside the window at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
|
|
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"
|
|
@@ -105,7 +105,7 @@ dsh-scrapling setup --status
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
- `core` installs managed Python 3.14.9, Scrapling 0.5 and its pinned wheels; `browser` adds the full Chromium build (not the headless shell).
|
|
108
|
-
- `search`, `media`, `mcp` and `adaptive-redis` all ride on `core`'s venv: `mcp` brings the official `scrapling-mcp` server (the `mcp` package,
|
|
108
|
+
- `search`, `media`, `mcp` and `adaptive-redis` all ride on `core`'s venv: `mcp` brings the official `scrapling-mcp` server (the pinned `mcp` package; its tool set is the upstream's, not this plugin's) that `official-mcp` mode needs, and `adaptive-redis` brings the `redis` client behind `adaptiveStorage: redis`. Every pack is installable; the settings card reports each as `ready`, `missing`, `corrupt` or `installing`.
|
|
109
109
|
- `--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/`.
|
|
110
110
|
- `--offline <dir>` installs with no network at all: `<dir>` must hold the Python archive named exactly as the manifest URL's last segment (browser and `curl -O` both keep `cpython-3.14.9+…-install_only.tar.gz`, and the percent-encoded spelling is accepted too) plus a `wheels/` directory with one wheel per pinned requirement - `pip download --only-binary=:all: --require-hashes -r py/runtime-requirements.txt -d <dir>/wheels` produces it. The hash check on the Python archive is the same one the networked path runs, and pip is invoked with `--no-index`; a missing archive or wheelhouse fails as `INSTALL_OFFLINE_ASSETS` instead of silently going online.
|
|
111
111
|
- `setup --status` prints one JSON document: `dataDir`, `profile`, `runtime`, `packs` and `state`. With `--profile <dir>` it reads that profile's `cordis.patch.yml` and resolves the interpreter from this package's `pythonBin` (the setting the host actually uses); without it, `profile.path` is `null`, a note says the profile was not read, and `runtime` falls back to the CLI's own chain (managed runtime → repo `_env/.venv` → PATH `python3`). Pass `--profile` whenever you compare the card's interpreter with what `--status` reports.
|
|
@@ -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
|
|
129
|
-
- **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI
|
|
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
|
|
|
@@ -230,7 +230,8 @@ In `mcp` mode the server runs inside the plugin's own host process and calls the
|
|
|
230
230
|
Connecting dsh needs `@deepseek-ai/dsh-mcp-client`, which this plugin deliberately does not depend on. Pin the build that matches the current host — npm `latest` is older than the host's own line and the host rejects the mismatch:
|
|
231
231
|
|
|
232
232
|
```bash
|
|
233
|
-
dsh plugin --profile <name> add @deepseek-ai/dsh-mcp-client@0.2.
|
|
233
|
+
dsh plugin --profile <name> add @deepseek-ai/dsh-mcp-client@0.2.2-alpha.3
|
|
234
|
+
# host on the 0.2.1-rc.5 line: @deepseek-ai/dsh-mcp-client@0.2.1-rc.5
|
|
234
235
|
```
|
|
235
236
|
|
|
236
237
|
Then add one entry to that profile's `cordis.patch.yml` — this is exactly what `dsh-scrapling setup --mode mcp` prints, so you can also let the CLI write it (drop `headers` when no token is configured):
|
|
@@ -263,7 +264,7 @@ dsh-scrapling setup --mode native --apply # a file that deliberately contain
|
|
|
263
264
|
dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
264
265
|
```
|
|
265
266
|
|
|
266
|
-
`doctor` reads what the profile actually says - `cordis.patch.yml` plus that profile's `package.json` - and prints one line per problem: two entries under `serverName: scrapling`, this plugin's entry next to an official `stdio` one, entries that do not match the mode, an entry whose port disagrees with `--port`, a profile without `@deepseek-ai/dsh-mcp-client` or with it pinned to something other than `0.2.1-rc.
|
|
267
|
+
`doctor` reads what the profile actually says - `cordis.patch.yml` plus that profile's `package.json` - and prints one line per problem: two entries under `serverName: scrapling`, this plugin's entry next to an official `stdio` one, entries that do not match the mode, an entry whose port disagrees with `--port`, a profile without `@deepseek-ai/dsh-mcp-client` or with it pinned to something other than `0.2.2-alpha.3` / `0.2.1-rc.5` / `next`, and an official entry while `officialMcpEnabled` is off. Exit `0` is "consistent", `1` names at least one problem, `2` is a bad argument. `integrationMode` itself is a plugin setting the CLI cannot read, so `--mode` is the claim being checked and has to match the deployment.
|
|
267
268
|
|
|
268
269
|
`official-mcp` asks for two separate statements before it produces anything: `officialMcpEnabled: true` in the profile and `--accept-risk` on the command line; missing either one prints `OFFICIAL_MCP_DISABLED` / `RISK_NOT_ACCEPTED` and writes nothing. The entry it generates starts `<dataDir>/runtime/venv/bin/scrapling-mcp`, so run `setup --feature mcp --apply` first - see [Runtime packs](#runtime-packs-macos-arm64). When that binary is missing, `setup` prints a line saying so.
|
|
269
270
|
|
|
@@ -273,7 +274,7 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
273
274
|
|
|
274
275
|
| Field | Type | Default | Purpose |
|
|
275
276
|
| --- | --- | --- | --- |
|
|
276
|
-
| `pythonBin` | string | `""` | Interpreter name or absolute path. Empty
|
|
277
|
+
| `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
278
|
| `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
279
|
| `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
280
|
| `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 +288,9 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
287
288
|
| `waitSelectorState` | enum | `attached` | The state a `waitSelector` element must reach (`attached` / `detached` / `hidden` / `visible`) |
|
|
288
289
|
| `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
290
|
| `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-
|
|
291
|
+
| `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
292
|
| `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
|
|
293
|
+
| `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
294
|
| `braveApiKey` / `serperApiKey` | secret | `""` | Keys for the Brave Search and Serper.dev backends |
|
|
294
295
|
| `searxngEndpoint` | string | `""` | Base URL of a SearXNG instance (`…/search?format=json` is appended); empty means the backend is unusable and reports `SEARCH_AUTH` |
|
|
295
296
|
| `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" |
|
|
@@ -297,7 +298,7 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
297
298
|
| `syntheticDnsRanges` | string | `""` | Manual fallback for synthetic DNS: a comma-separated CIDR list of your proxy's fake-IP pool, for resolvers that mix synthetic and real answers. Invalid entries are dropped — a broken fallback degrades to "stay strict", not to a crash |
|
|
298
299
|
| `proxyUrl` | string | `""` | Where fetches go out (`http://…` / `socks5://…`, optionally `user:pass@`). Empty = follow the environment; see [Proxies](#proxies). Masked on the card, never enters a tool schema |
|
|
299
300
|
| `proxyBypass` | string | `""` | Host names that connect directly, mirroring `NO_PROXY`; `*` means the whole machine goes direct |
|
|
300
|
-
| `nat64Prefixes` | string | `""` | Extra NAT64 prefixes (comma-separated
|
|
301
|
+
| `nat64Prefixes` | string | `""` | Extra NAT64 prefixes (comma-separated `<IPv6 prefix>/<32\|40\|48\|56\|64\|96>`) for operator-specific networks. A declared prefix is consulted for every IPv6 answer and applies to the addresses inside it. A malformed entry makes the plugin **refuse to load** (`CONFIG_INVALID`), unlike `syntheticDnsRanges` below: dropping a prefix would let a private IPv4 embedded in IPv6 through as ordinary public IPv6 |
|
|
301
302
|
|
|
302
303
|
**Deployment-only knobs** (not on the card; set them in the `config:` block of `cordis.patch.yml`):
|
|
303
304
|
|
|
@@ -351,7 +352,7 @@ Details worth knowing:
|
|
|
351
352
|
|
|
352
353
|
## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Security
|
|
353
354
|
|
|
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
|
|
355
|
+
- **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
356
|
- Known gaps, stated in the open:
|
|
356
357
|
- **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
358
|
- **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 +367,8 @@ Details worth knowing:
|
|
|
366
367
|
|
|
367
368
|
| Aspect | Content |
|
|
368
369
|
| --- | --- |
|
|
369
|
-
| On disk |
|
|
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
|
|
370
|
+
| 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 |
|
|
371
|
+
| 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
372
|
| Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
|
|
372
373
|
| In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
|
|
373
374
|
| Telemetry | None |
|
|
@@ -383,7 +384,7 @@ Registered honestly, one entry per class.
|
|
|
383
384
|
- **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
385
|
- **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
386
|
- **`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.**
|
|
387
|
+
- **`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
388
|
- **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
389
|
- **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
390
|
- **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 +421,4 @@ pnpm run test:py # end-to-end check of the Python sidecar
|
|
|
420
421
|
|
|
421
422
|
MIT. Source at [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling). Issues go to that repository's tracker.
|
|
422
423
|
|
|
423
|
-
This package ships no third-party source code — Scrapling and the browser engines are runtime dependencies
|
|
424
|
+
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.
|
|
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.
|
|
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** ——
|
|
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.5` 或 `0.2.2-alpha.3` 版本线。** 宿主真正读的是 `engines.dsh`(`^0.2.1-rc.5 || ^0.2.2-alpha.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"
|
|
@@ -105,7 +105,7 @@ dsh-scrapling setup --status
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
- `core` 装托管 Python 3.14.9、Scrapling 0.5 与钉死的 wheel;`browser` 再加完整 Chromium(不是 headless shell)。
|
|
108
|
-
- `search`、`media`、`mcp` 与 `adaptive-redis` 都以 `core` 的 venv 为载体:`mcp` 带来 `official-mcp` 模式要的官方 `scrapling-mcp` server
|
|
108
|
+
- `search`、`media`、`mcp` 与 `adaptive-redis` 都以 `core` 的 venv 为载体:`mcp` 带来 `official-mcp` 模式要的官方 `scrapling-mcp` server(随钉住的 `mcp` 包进来;它的工具集由上游决定,不是本插件的面),`adaptive-redis` 带来 `adaptiveStorage: redis` 背后的 `redis` 客户端。六个包都可安装;设置卡把每个包报成 `ready`、`missing`、`corrupt` 或 `installing`。
|
|
109
109
|
- `--feature` 默认 dry-run;`--apply` 才落盘。`--repair` 重装且不碰用户数据;`--uninstall <包> [--purge]` 删运行时文件,只有 `--purge` 才连 `elements_storage.db` 与 `downloads/` 一起删。
|
|
110
110
|
- `--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` 生成)。Python 归档的哈希校验与联网路径一致,pip 带 `--no-index`;缺归档或缺 wheelhouse 时报 `INSTALL_OFFLINE_ASSETS`,不会悄悄退回联网。
|
|
111
111
|
- `setup --status` 打印一份 JSON:`dataDir`、`profile`、`runtime`、`packs` 与 `state`。带 `--profile <目录>` 时读该 profile 的 `cordis.patch.yml`,按本包条目里的 `pythonBin`(宿主真正在用的那个设置)解析解释器;不带时 `profile.path` 为 `null`,输出里有一句说明没读 profile,`runtime` 回落到 CLI 自己的链(托管 runtime → 仓内 `_env/.venv` → PATH `python3`)。要拿 `--status` 和设置卡上的解释器对照,就带上 `--profile`。
|
|
@@ -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
|
-
-
|
|
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
|
|
|
@@ -230,7 +230,8 @@ dsh-scrapling setup --status
|
|
|
230
230
|
要接进 dsh 需要 `@deepseek-ai/dsh-mcp-client`,本插件刻意不依赖它。装与当期宿主同一条线的版本 —— npm 的 `latest` 比宿主还旧,宿主对不匹配的对端是直接拒绝:
|
|
231
231
|
|
|
232
232
|
```bash
|
|
233
|
-
dsh plugin --profile <名> add @deepseek-ai/dsh-mcp-client@0.2.
|
|
233
|
+
dsh plugin --profile <名> add @deepseek-ai/dsh-mcp-client@0.2.2-alpha.3
|
|
234
|
+
# 宿主在 0.2.1-rc.5 线时改用 @deepseek-ai/dsh-mcp-client@0.2.1-rc.5
|
|
234
235
|
```
|
|
235
236
|
|
|
236
237
|
再往那个 profile 的 `cordis.patch.yml` 加一条(没配 token 就不写 `headers`):
|
|
@@ -263,7 +264,7 @@ dsh-scrapling setup --mode native --apply # 写出的文件里一条条目
|
|
|
263
264
|
dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
264
265
|
```
|
|
265
266
|
|
|
266
|
-
`doctor` 读的是 profile 自己写下的东西 —— `cordis.patch.yml` 加那份 `package.json` —— 每处问题打一行:`serverName: scrapling` 下有两条例目、本插件的条目与官方 `stdio` 那条并存、条目类型与模式不符、条目的端口与 `--port` 说的不一致、profile 里没有 `@deepseek-ai/dsh-mcp-client` 或它钉的不是 `0.2.1-rc.
|
|
267
|
+
`doctor` 读的是 profile 自己写下的东西 —— `cordis.patch.yml` 加那份 `package.json` —— 每处问题打一行:`serverName: scrapling` 下有两条例目、本插件的条目与官方 `stdio` 那条并存、条目类型与模式不符、条目的端口与 `--port` 说的不一致、profile 里没有 `@deepseek-ai/dsh-mcp-client` 或它钉的不是 `0.2.2-alpha.3` / `0.2.1-rc.5` / `next`、以及 `officialMcpEnabled` 关着却留着官方条目。退 `0` 是一致,`1` 是至少点出一处,`2` 是参数不对。`integrationMode` 本身是插件设置,CLI 读不到,所以 `--mode` 就是被核对的那一句声明,它必须和部署配置说的是同一件事。
|
|
267
268
|
|
|
268
269
|
`official-mcp` 要两处分开表态才会产出:profile 里的 `officialMcpEnabled: true`,以及命令行的 `--accept-risk`;缺任何一处只打 `OFFICIAL_MCP_DISABLED` / `RISK_NOT_ACCEPTED`,一个字节都不写。它生成的条目起的是 `<dataDir>/runtime/venv/bin/scrapling-mcp`,所以要先跑 `setup --feature mcp --apply` —— 见[运行时能力包](#运行时能力包macos-arm64)。那枚二进制不存在时,`setup` 会额外打一行说明这条条目现在起不来。
|
|
269
270
|
|
|
@@ -273,7 +274,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
273
274
|
|
|
274
275
|
| 字段 | 类型 | 默认值 | 作用 |
|
|
275
276
|
| --- | --- | --- | --- |
|
|
276
|
-
| `pythonBin` | string | `""` |
|
|
277
|
+
| `pythonBin` | string | `""` | 解释器名或绝对路径。留空时按 `lib/runtime.ts` 的固定链走:`dataDir` 下的托管 runtime(`setup --feature core --apply` 装的就是它)→ 仓内 `_env/.venv`(可用才算,只有源码检出才有)→ `PATH` 上的 `python3`(Windows 上是 `python`) |
|
|
277
278
|
| `failFastOnMissingPython` | boolean | `true` | sidecar 进程起不来(路径错、协议对不上、握手超时)时拒绝加载。解释器起得来但没装 Scrapling 时,无论这枚开关如何都只降级为「工具不可用」,日志点名解释器路径 |
|
|
278
279
|
| `fetchEnabled` / `extractEnabled` / `locateEnabled` / `linksEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` / `sessionReadEnabled` / `sessionActionsEnabled` / `downloadEnabled` / `screenshotEnabled` | boolean | `true` | 每个工具一枚总闸。`sessionStateEnabled` 管登录态存取那一对,它们还要部署侧配好 `sessionStateDir` |
|
|
279
280
|
| `extractionType` | enum | `markdown` | `markdown` / `html` / `text`;三条路径过同一套反注入清洗,`html` 额外剥事件处理器属性,因此**不是字节级原始 HTML** |
|
|
@@ -289,7 +290,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
289
290
|
| `dataDir` | string | `""` | sidecar 工作目录(`adaptive` 指纹库落这里);留空 = `~/.dsh-scrapling`。目录建不出来时由 `failFastOnMissingPython` 决定:拒绝加载,或降级为不注册任何工具 |
|
|
290
291
|
| `provideWebFetch` / `provideWebSearch` | boolean | `true` | 是否注册 `ctx.web` 的两个 provider —— 见[替代内置的抓取与搜索](#替代内置的抓取与搜索) |
|
|
291
292
|
| `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
|
|
293
|
+
| `searchPublicFallback` | boolean | `false` | 允许 `auto` 在既没有 key、也没有 SearXNG 时回落到公共的 Bing —— `py/search.py` 把 `auto` 按 `tavily` → `searxng` → `bing` 定案,DuckDuckGo 不在 `auto` 的落点里,要用得显式设 `searchBackend=duckduckgo`。**默认关是刻意的**:打开就等于把查询词发给第三方公共引擎 |
|
|
293
294
|
| `braveApiKey` / `serperApiKey` | secret | `""` | Brave Search 与 Serper.dev 的 key |
|
|
294
295
|
| `searxngEndpoint` | string | `""` | SearXNG 实例的基址(会拼上 `…/search?format=json`);为空表示这条后端不可用,报 `SEARCH_AUTH` |
|
|
295
296
|
| `answerProvider` / `answerModel` / `answerMaxTokens` | string / natural | `""` / `""` / `2000` | `scrapling_answer` 走哪条模型路由与单次回答的 token 上限。provider 与 model 都留空表示「跟随当前会话的模型」 |
|
|
@@ -297,7 +298,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
297
298
|
| `syntheticDnsRanges` | string | `""` | 合成 DNS 的手动兜底:填代理 fake-IP 池的 CIDR(逗号分隔),留给把合成地址与真地址混着返回的解析器。写错的段直接丢掉 —— 兜底坏了退化成「维持最严」,不该崩 |
|
|
298
299
|
| `proxyUrl` | string | `""` | 抓取从哪儿出去(`http://…` / `socks5://…`,可带 `user:pass@`)。留空 = 跟随环境,见[代理](#代理)。卡上遮罩显示,绝不进入工具 schema |
|
|
299
300
|
| `proxyBypass` | string | `""` | 直连、不走代理的主机名,对应 `NO_PROXY`;填 `*` 表示整台机器直连 |
|
|
300
|
-
| `nat64Prefixes` | string | `""` | 额外的 NAT64 前缀(逗号分隔的
|
|
301
|
+
| `nat64Prefixes` | string | `""` | 额外的 NAT64 前缀(逗号分隔的 `<IPv6 前缀>/<32\|40\|48\|56\|64\|96>`),给运营商自建网络用。每个 IPv6 应答都会查这张表,声明的前缀对它覆盖范围内的地址生效。写错的项会让插件**拒绝装载**(`CONFIG_INVALID`),与下面 `syntheticDnsRanges` 的「丢掉」不同:丢掉一个前缀等于把藏在 IPv6 里的私网 IPv4 当成普通公网 IPv6 放行 |
|
|
301
302
|
|
|
302
303
|
**部署级旋钮**(不在卡上,只走 `cordis.patch.yml` 的 `config:` 块):
|
|
303
304
|
|
|
@@ -351,7 +352,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
351
352
|
|
|
352
353
|
## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 安全说明
|
|
353
354
|
|
|
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`
|
|
355
|
+
- **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
356
|
- 已知缺口,写在明处:
|
|
356
357
|
- **连接钉扎**(undici 层技术)对非 Node 传输不可用;校验与真正建连之间有 TOCTOU 窗口。静态抓取由 curl_cffi 的 `follow_redirects="safe"` 兜住重定向,浏览器抓取由 Python 侧的 route handler 兜住。
|
|
357
358
|
- **NAT64 前缀不做动态探测。** 两个标准化前缀已覆盖;运营商自建的要用 `nat64Prefixes` 声明,否则藏在 IPv6 里的私网 IPv4 会被当成普通公网 IPv6 放行。
|
|
@@ -366,8 +367,8 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
366
367
|
|
|
367
368
|
| 口径 | 内容 |
|
|
368
369
|
| --- | --- |
|
|
369
|
-
| 写盘 | sidecar 工作目录(`dataDir`,默认 `~/.dsh-scrapling
|
|
370
|
-
| 网络 | 抓取发往模型给的 URL,配了代理就走代理。搜索查询由 Python sidecar 发往 Tavily
|
|
370
|
+
| 写盘 | 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 服务保管,落在哪里由宿主决定。设置值在宿主的设置文档里 |
|
|
371
|
+
| 网络 | 抓取发往模型给的 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
372
|
| 日志 | 选中的解释器、探测到的能力、代理摘要(`scheme://host:port` 加来自哪一档 —— 绝无凭据) |
|
|
372
373
|
| 内存 | 会话、cookie 与录下的网络历史都在 sidecar 进程里,随进程一起消失 |
|
|
373
374
|
| 遥测 | 无 |
|
|
@@ -383,7 +384,7 @@ dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
|
383
384
|
- **浏览器身份类的旋钮只开在真能用上它的工具上。** `useragent` / `locale` / `timezoneId` / `headless` 摆在一次性的浏览器工具与 `scrapling_session_open` 上 —— 它们只在会话构造期生效,会话内传过去会被上游静默丢掉。
|
|
384
385
|
- **网络历史是会话级的。** 记录是构造期设置(部署默认 `recordRequests`,或每次 `scrapling_session_open` 上的 `recordNetwork`);没开记录的会话报错,而不是回一个空列表。
|
|
385
386
|
- **`scrapling_screenshot` 绕过文本清洗。** 截图拍的是页面在视口里真正渲染出来的东西 —— 包括 token、私信、登录后才可见的数据等从未出现在 DOM 文本里的视觉秘密。截图经宿主 attachment 服务落库,只有该服务挂载时才注册。 交回的是该服务**归一化之后**的引用:声明为 PNG 的字节可能被存成 `image/jpeg` 且尺寸更小,而 `originalDimensions` 记的是页面真正产出的那一份(宿主契约:`@deepseek-ai/dsh-attachment` 的 `saveImage`)。`scrapling_download` 把字节写进 `dataDir/downloads`,绝不覆盖已有文件,`filename` 里带路径成分会被拒绝。
|
|
386
|
-
- **`scrapling_locate` 与 `scrapling_links` 是离线解析器。**
|
|
387
|
+
- **`scrapling_extract`、`scrapling_locate` 与 `scrapling_links` 是离线解析器。** 三者只读调用方给的 HTML,不发网络请求;`scrapling_links` 只在给了 `baseUrl` 时才保留相对链接 —— `baseUrl` 为空时返回空链接,而不是猜绝对地址。三者共用 `extractMaxOutputChars`。
|
|
387
388
|
- **adaptive 重定位是尽力而为。** Scrapling 只保存第一个命中元素;原属性变化后,可能选中一个高度相似的兄弟元素。把重定位结果当作线索并自行核对;`scrapling_locate` 不保存指纹。
|
|
388
389
|
- **运行时能力包只在 macOS arm64 上验证过。** Windows、Linux 与 macOS x64 的所有包都报 `blocked`;安装器直接拒绝,不猜资产路径(B1/B2)。
|
|
389
390
|
- **`adaptive-redis` 包是客户端,不是存储引擎。** 上游只发 `SQLiteStorageSystem`;这里的 Redis 后端是本插件的 `py/redis_storage.py`,一个按注册域分桶的 `StorageSystemMixin` 子类。启用它改变的是指纹存哪儿,属于部署决定而不是逐次开关。本插件自己的 MCP server 是另一件事 —— 它跑在宿主进程内,不需要能力包。
|
|
@@ -420,4 +421,4 @@ pnpm run test:py # Python sidecar 的端到端验证
|
|
|
420
421
|
|
|
421
422
|
MIT。源码在 [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling),issue 走该仓库的 tracker。
|
|
422
423
|
|
|
423
|
-
本包不随包分发第三方源码 —— Scrapling
|
|
424
|
+
本包不随包分发第三方源码 —— Scrapling 与浏览器引擎都是运行期依赖。随包的第三方内容是图标(Tabler Icons)与 CLI 单文件产物内联的 `zod`;host 侧 client 产物外置 zod。[`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 记录这条边界。
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -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
|
|
10
|
-
|
|
9
|
+
Scrapling 及浏览器引擎都是**运行期依赖**——本包调用它们暴露的接口,其中反注入清洗用的
|
|
10
|
+
`Convertor._strip_noise_tags` 与 `Convertor._sanitize_for_ai` 是上游的私有下划线方法,不在上游文档面
|
|
11
|
+
里(见「机制与接口来源」)。它们不由本包分发,许可文本也随各自的包走,本文件不重复。
|
|
11
12
|
|
|
12
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
| `
|
|
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
|
|
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。
|