@jayyuen66/dsh-scrapling 0.1.2 → 0.1.4
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 +83 -0
- package/README.md +141 -19
- package/README.zh-CN.md +141 -19
- package/THIRD_PARTY_NOTICES.md +20 -2
- package/bin/dsh-scrapling.mjs +13 -0
- package/client.js +11 -3
- package/cordis.patch.yml +1 -1
- package/host.js +40 -36
- package/package.json +26 -9
- package/py/adapters.py +763 -267
- package/py/bridge.py +27 -4
- package/py/crawl.py +640 -90
- package/py/extraction.py +400 -0
- package/py/guard.py +120 -27
- package/py/media.py +474 -0
- package/py/redact.py +118 -0
- package/py/redis_storage.py +129 -0
- package/py/runtime-requirements.txt +49 -0
- package/py/search.py +404 -0
- package/py/session_page.py +240 -0
- package/runtime-manifest.json +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,89 @@
|
|
|
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.4
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **`scrapling_fetch` 的 `form` / `json` 不再静默落地**:`allowWriteMethods=false` 时这两个参数与 `method` / `body` 走同一道闸,模型参数面里根本不出现;写方法开启时,给了 `form` / `json` 而没给 `method` 会隐含 `POST`(与静态会话抓取一致),显式 `GET` 配请求体判 `BAD_ARGS`。此前请求照发、对端收到空体,而回包上没有任何一行能看出这件事。
|
|
11
|
+
- **离线解析器的 `url` 不再被出站闸门误拦**:`scrapling_extract` / `scrapling_locate` / `scrapling_links` 的 `url` 只作相对地址基准,不做 DNS 解析也不连网;此前它被当成取回目标,给一个内网基准地址就会报 `URL_BLOCKED`。
|
|
12
|
+
- **URL 守卫错误文案不再回显凭据**:`https://user:pass@host` 在 `URL_BLOCKED` 里脱敏成 `***@`,判定与连接仍用原串。
|
|
13
|
+
- **`sessionStateDir` 未配置时不再注册登录态存取工具**:`scrapling_session_state_save` / `scrapling_session_state_load` 现在与 jobs / attachments 同一种门,目录为空时那两只注定回 `SESSION_STATE_DISABLED` 的工具不会出现在工具目录里,并给一条点名修法的告警。
|
|
14
|
+
- **模型可见渲染补齐**:`includeHtml` 真正输出每条匹配的 `html`;`scrapling_locate` 的 `attributes`、`ancestors`、`full css` / `full xpath` 与 `truncated` / 截断提示进入模型文本;`session_network` 印出 `id` 与(`includeHeaders` 时)`headers`,`requestId` / `afterId` / `includeHeaders` 不再是无可见效果的旋钮;`capture_xhr` 零捕获时给一条「页面可能没有 XHR,也可能抓早了」的提示。
|
|
15
|
+
- **原生工具错误带回错误码**:sidecar 的错误不再只剩 `Error: <message>`,模型能看到 `BAD_ARGS: …` / `URL_BLOCKED: …` 前缀。
|
|
16
|
+
- **非法 `impersonate` 报 `BAD_ARGS`**:curl_cffi 在请求时才校验浏览器预设,过去把 `ImpersonateError` 泄漏成一次抓取失败;现在点名可用预设。
|
|
17
|
+
- **爬虫作业结算行保留错误码并区分取消与失败**:`BAD_ARGS` / `URL_BLOCKED` 以 `CODE: message` 进入作业最终 detail;`job_kill` 落 `killed` + `cancelled`,异常落 `failed`,不再一律 `killed`。
|
|
18
|
+
- **爬虫结果里的 `notice` 能到模型眼前**:`mode=shopify` 遇到 404 / 非 JSON / 非店铺 JSON、`mode=sitemap` 发现期被 `maxPages` 截断时,作业输出多一行 `crawl notice:`(此前 Python 侧有这份原因、JS 侧从不读)。
|
|
19
|
+
- **`sitemapFollow` 不再放大抓取**:发现期抓子 sitemap 与 sitemap URL 各自按 `maxPages` 封顶,`maxPages=2` 不会再打出几百次请求。
|
|
20
|
+
- **浏览器页面超时与工具调用预算解耦**:`scrapling_render` / `scrapling_capture_xhr` / 会话抓取 / `session_act` 在模型未给 `timeoutMs` 时不再下发页面超时(交给 Python 的 30s),显式值只按 `min(调用值, pageTimeoutMs)` 下发;坏选择器与永不 idle 的页面因此能返回 `ACTION_FAILED` / 结构化超时,而不是把整次调用拖到宿主外层 120s。
|
|
21
|
+
- **静态会话的 `extraHeaders` 生效**:此前只有浏览器会话合并它、静态路径静默丢掉;现在与 `headers` 合并,同名以 `extraHeaders` 为准。
|
|
22
|
+
- **浏览器下载走附件回退**:`useBrowser=true` 抓二进制响应时 Chromium 会报 `Page.goto: Download is starting`,现在改为先开会话取 URL、再经附件链路落盘;`DOWNLOAD_FAILED` 也补回原始原因。
|
|
23
|
+
- **登录态文件错误不再泄漏宿主绝对路径**:`state_load` 的 `FileNotFoundError` / JSON 解析错误只点名模型自己给的文件名。
|
|
24
|
+
- **文档与 CLI 同步**:随包 `cordis.patch.yml` 的工具数从 13 改到 19;`setup --status --profile <目录>` 读该 profile 的 `pythonBin`(不再永远回 `python3/path/unknown`);README 设置卡表把 `duckduckgoEndpoint` 从 volatile 栏移出,并新增 README 与 config schema 的一致性测试。
|
|
25
|
+
|
|
26
|
+
## 0.1.3
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- **新增 `scrapling_locate` 与 `scrapling_links`**:前者按文本、正则或相似元素定位并返回生成的 CSS/XPath 选择器,后者列出链接与下一页候选。两者只解析调用方给的 HTML,不发网络请求;对应设置开关 `locateEnabled` / `linksEnabled` 默认开启。
|
|
31
|
+
- **抓取参数与响应元数据**:`scrapling_fetch` / `scrapling_render` / 会话抓取支持查询参数、表单/JSON 请求体、HTTP/3、编码回退、重试间隔、安全响应元数据与 `extractionType=json`;网络历史支持方法、状态、类型、静态资源与时间窗过滤。
|
|
32
|
+
- **爬虫 sitemap / feed / Shopify 模式**:`mode=sitemap` 只抓 sitemap(或匹配 `sitemapFollow` 的子 sitemap)里的 loc,不跟随页面内链接;`mode=feed` 读 XML/CSV feed 并按 `fields` 映射出结构化行。三种模式沿用 content 模式的 URL/域闸门与部署级待站策略。`mode=shopify` 走店铺的 `/collections.json` + `/products.json`(上游 `ShopifySpider`)按变体出行;本地夹具店已跑通,真实 Shopify 店铺未验。
|
|
33
|
+
- **爬虫内容选项与统计**:`scrapling_crawl` 支持 CSS 选择器与内容规则、`mainContentOnly`、页数/时长上限;作业状态带已抓页数与跳过原因。
|
|
34
|
+
- **搜索 provider**:`ctx.web` 的 `web_search` 可由 Scrapling 的 Tavily/Bing 发现层接管(`searchBackend`),搜索结果可选择性渲染。
|
|
35
|
+
- **浏览器与媒体工具**:`scrapling_session_read`、`scrapling_session_act`、`scrapling_download`、`scrapling_screenshot`;动作与下载有部署级门禁,截图经宿主 attachment 服务。
|
|
36
|
+
- **`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` 模式一行都不执行。
|
|
37
|
+
|
|
38
|
+
- **`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` 包提供时,它额外打一行说明这条条目起不来。
|
|
39
|
+
- **运行时能力包安装器与 CLI**:`core` 装托管 Python 3.14.9 + Scrapling 0.5,`browser` 装完整 Chromium;`dsh-scrapling setup --status|--feature|--repair|--uninstall|--purge` 是唯一安装入口,设置卡显示包状态并可在有 remote/作业后端时发起安装、修复与取消。
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **两道 URL 闸门不再一边宽一边严**:Python 侧此前在每条发出请求的路径上都接受 `ws:`/`wss:`(那只有 WebSocket 握手判定该认),也不看 URL 内嵌的凭据。现在请求侧只认 `http`/`https`,内嵌凭据一律判拒 —— Host 侧 `url-policy` 的这两条在 Python 侧同样成立。放行名单只豁免「地址必须公网」这一条,不豁免这两条。
|
|
44
|
+
- **crawl 的第二、第三个 URL 现在过宿主闸门**:`SidecarClient.call` 原先只筛 `params.url`,模型给的 `sitemapUrl` / `feedUrl` 原样进 payload;现在三处都筛,归一过的写进同一份新的参数对象,判否即止、不再为后面的 URL 继续解析。
|
|
45
|
+
|
|
46
|
+
- **浏览器参数越界不再被报成一次抓取失败**:上游把会话的这两个键收在 `RetriesCount`(1..10)与 `PagesCount`(1..50)里,越界值不在 Scrapling 的参数校验里被拒,而是在它的类型层炸成 `TypeError: Invalid argument type: Expected int <= 10 - at $.retries`,本包再把它归成一次失败。现在 `retries` 与 `maxPages` 在浏览器路径上先判,超限直接 `BAD_ARGS` 并点名上限;静态抓取那一侧的 `retries` 仍不设上限(上游那张表里它是裸 `Optional[int]`)。
|
|
47
|
+
- **检索后端扩到六条**:新增 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 未验证**。
|
|
48
|
+
- **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`。
|
|
49
|
+
- **离线安装可用**:`setup --feature <包> --offline <目录> --apply` 全程不联网完成安装 —— 目录里放 Python 归档(名字同清单 URL 最后一段,解码与转义两种写法都认)与 `wheels/`(每条钉版一枚 wheel)。归档哈希照旧按清单校验,pip 带 `--no-index --find-links`;缺归档或缺 wheelhouse 报 `INSTALL_OFFLINE_ASSETS`,不再是一句「未验证」。真机:在代理指向死端口的进程里用 130 MB 资产包装出 core,venv 里 `scrapling` 与 `mcp` 可导入、`scrapling-mcp --help` 可跑。
|
|
50
|
+
- **`mcp` 能力包上线**:安装器过去只装 `scrapling==0.5`,而官方 server 的依赖挂在 Scrapling 的 `ai` extra 上(`mcp>=2.0.0`),托管 venv 里因此没有可跑的 `scrapling-mcp`。现在把 `mcp==2.3.0` 及 22 个传递依赖连同哈希钉进 `py/runtime-requirements.txt`,`setup --feature mcp --apply` 走与 `core` 同一条安装/卸载路径。真机验证:CLI 装出的 venv 里 `scrapling-mcp --help` 可用、stdio `tools/list` 回 16 枚工具,宿主在 `integrationMode=official-mcp` 下按本插件生成的条目把 16 枚全部注册成 `mcp__scrapling__*`。
|
|
51
|
+
- **venv 里的 console script 不再因为暂存目录改名而失效**:venv 建在 `runtime/.tmp/venv-<uuid>` 再整体 rename 到 `runtime/venv`,而 pip 把解释器绝对路径写进入口脚本的 shebang,于是 `scrapling-mcp` 一跑就是 `bad interpreter: .../.tmp/venv-…/bin/python3`(装 `mcp` 包时真机撞到)。安装后现在会把 `bin/` 下以暂存路径开头的 shebang 改到最终路径;判据是一条用假 pip 写出暂存 shebang 的单测。
|
|
52
|
+
- **`mcp` 模式的客户端条目首装不再会被启动顺序打死**:真宿主沙箱实测,`failOnStartupError: true` 时客户端在第一趟 `connect ECONNREFUSED 127.0.0.1:<mcpPort>` 就抛掉 fiber,宿主报「1 entry did not activate」—— 而端口要等插件与 sidecar 握手完成才 listen。`setup --mode mcp` 生成的条目与两份 README 的示例都改成 `false`,让宿主 MCP 客户端自带的重连(默认开启,500ms 起退避、上限 10 次)去吸收这一次竞态;官方 `stdio` 那条相反,server 由客户端自己 spawn,连不上是真坏,仍留 `true`。
|
|
53
|
+
- **设置卡的安装 / 修复 / 取消按钮点了必报 `arguments-invalid`**:宿主 gateway 对源码态 Remote 描述符按**参数名**组包(`methodParameterNames` 读方法的形参表),而 `build-host.ts` 用 `minify: true` 把 `installPack(request)` 的形参压成了单字母,线上名字与客户端描述符声明的 `request` 对不上,`assertExactArguments` 直接拒。现在改为 `minify: { compress: true, mangle: false }`(体积 +25%,注释里写明原因),新增 `test/build-signature.test.ts` 对内存构建产物断言四个方法的形参名与 `src/runtime-reader.ts` 的 `RUNTIME_DESCRIPTORS` 逐字一致,防止将来重新打开标识符压缩又静默坏掉。
|
|
54
|
+
- **MCP server 可以被伪造 Host / Origin 打到**:`streamable-http` 默认不校验来源,本机浏览器里的任意页面都能对本机端口发请求。现在按绑定地址推导 `allowedHosts` / `allowedOrigins`(通配绑定时列回环三枚 + 各网卡非 internal 地址;显式绑定只认该字面量),并在 transport 上开 `enableDnsRebindingProtection`;没设 `DSH_SCRAPLING_MCP_TOKEN` 时往 stderr 打一行「无鉴权」警告,但不阻断(回环可达性是既有契约)。
|
|
55
|
+
- **`uninstall` 没有 dry-run、也不走安装锁**:现在默认只打印计划,必须显式 `--apply` 才落地,且落地在 `withInstallLock` 里做——安装进行中撤包会拿到 `INSTALL_BUSY` 而不是把 venv 从安装器脚下抽走。
|
|
56
|
+
- **安装锁按「写了一小时」判陈旧会接管活进程**:一次正常 pip 安装要下载几百 MB,跑过一小时很常见;接管一把活进程持有的锁等于让两个安装同时写同一个 venv。判据改成 pid 优先(本进程、`kill(pid, 0)` 成功、EPERM 都算活,ESRCH 才算死),锁里读不出 pid 时才退回 mtime 宽限;释放时也只在锁里写的是本进程 pid 时才删,避免把别人的新锁删掉。
|
|
57
|
+
- **venv 安装过程中有一段「没有解释器」的窗口,state.json 也可能留下半截**:旧实现先删旧 venv 再 rename 暂存目录,中途失败就两头空。现在先把暂存的 `bin/` shebang 改到最终路径,再把旧 venv 挪到 `.tmp/venv-previous-<uuid>`、暂存目录 rename 进正位;**「落地」以 `state.json` 写成功为准**——rename 之后、状态还没写成就失败时,`finally` 会把新 venv 撤掉、把旧 venv 搬回原位(以前这种半完成状态会留下「新 venv + 旧状态」,且旧 venv 已被删)。`state.json` 改成同目录临时文件 + `rename` 原子替换,内容坏掉时报 `INSTALL_STATE_CORRUPT` 并点名文件(以前当成空态,下一次写入会把 `browser: ready` 抹掉)。
|
|
58
|
+
- **runtime 目录权限**:`dataDir/runtime` 建出来即 `0700`、已存在也重收(早期按 umask 建成的 0755 因此能修好),Windows 上跳过;登录态文件保存后 `0600`。见 spec §11.6。
|
|
59
|
+
- **会话抓取会替调用方决定浏览器参数**:`session_fetch` 此前把 `blocked_domains` / `disable_resources` 以空值发下去,等于强制覆盖上游默认;现在只有调用方显式给了才出现在 payload 里。浏览器下载补上 `page_setup` 与 `guard.browser_proxy(url)`(后者在配了代理的机器上防止下载走直连泄露出口 IP)。
|
|
60
|
+
- **下载上限可以被调用方绕过**:部署的 `downloadMaxBytes` 现在与调用值取 `min`,浏览器路径也按同一上限夹取;部署项本身不是正整数时报 `BAD_ARGS` 并点名键。`crawl` 超预算时不再丢掉已经抓到的页(已收页与 `more=true` 一起回);`mode=shopify` 的 `sitemapUrl` 现在同样过 URL 闸门,并按 `sitemapUrl` 的源主机解析店铺(以前只按 `url` 主机,跨主机必然抓空)。
|
|
61
|
+
- **MCP 条目文本与 profile 读取的边界**:`setup --mode` 写的 `command` 行改成双引号标量 + 转义(含空格、`#`、冒号、引号、换行),往返 `JSON.parse === command`;`mcp-profile` 读 `cordis.patch.yml` 时认 `\r\n` 行尾,开关只认 `true` / `True` / `TRUE`,不再把裸 `yes`/`on` 当开启。
|
|
62
|
+
- **日志与错误文本里仍有可用的凭据碎片**:无 scheme 的 `user:pass@host` 形式此前被 `urlsplit` 读成 scheme、authority 落进 path,脱敏正则抓不到;现在单独处理这一段。`py/guard.py` 里一段重复的死块也已删掉(真正的分支仍在,日志过 `redact_url_secrets`)。
|
|
63
|
+
- **Redis 超时是死参数,feed / Shopify 到点不暂停**:`_default_client` 以前收了 `timeout_seconds` 却从不使用,现在同时设 `socket_timeout` 与 `socket_connect_timeout`(默认 2.0s);sitemap / feed / shopify 收集行时按 `crawlMaxRuntimeSeconds` / 每页 `pause` 到点停下,不再在一个不响应的端点上把预算烧完。
|
|
64
|
+
- **读不到上次安装作业时被当成「没有作业」**:`runtime-remote` 的状态读取改成 fail-closed——读失败回 500 并说明读不出什么,不再静默显示「无作业」让用户以为可以重装。`web-provider` 的 `describeRaw` 兜住 `JSON.stringify` 返回 `undefined`(循环引用、`undefined`)时 `.slice` 抛 `TypeError`。
|
|
65
|
+
- **`includeHtml` 被 `oneMatch` 路径丢掉**:抽取命中单条时结果对象不带 HTML,调用方要原文只能再抓一次;现在按参数透传。
|
|
66
|
+
- **旧代 sidecar 的退出回调会拆掉新一代**:上一代进程延迟触发的 `error` / `done` 事件会把刚起来的进程收尾掉(表现为工具偶发 `SIDECAR_CLOSED`)。`#teardown` 增加第三参 `origin` 做代际判定,非当前句柄的事件记一行 `[sidecar] ignoring stale teardown` 后返回。
|
|
67
|
+
- **搜索的公共回退默认被打开**(D10):`searchPublicFallback` 现在默认 `false`,`auto` 在既没有 Tavily key、也没有 SearXNG 端点、又没开回退时抛 `SEARCH_BACKEND_MISSING`,不再擅自把查询词发给公共引擎;`available()` 同步把这个开关当作发现路径的输入。打开时只发 Bing(两级 DDG → Bing 链等 B4 真实端点验证后再接,见 spec §6.2)。
|
|
68
|
+
- **adaptive 存储故障连正文一起失败**:指纹库写/读失败现在返回正文并附 `ADAPTIVE_STORAGE_FAILED: <异常类型>: <原因>` notice,与 spec §7.2 对齐;`extractionType=json` 的结果先剥 `data:` URI 再按 `maxContentChars` 截断(内嵌 base64 之前会把预算吃光)。
|
|
69
|
+
- **`scrapling_locate` 参数面与 spec A14 对齐**:新增 `by`(`text`/`regex`/`similar`,与旧名 `queryType` 互认)与 `query`,两者都缺时报 `BAD_ARGS`;抓取 / 渲染 / 抽取 / 定位支持每次调用的 `timeoutSeconds` / `timeoutMs` / `maxContentChars`(仍受设置里的上限封顶);`session_list` 透传 `alive` / `settings` / `poolStats`。
|
|
70
|
+
- **`doctor` 不提示搜索接管**:现在按 spec §6.4 检查 `searchProvider`:未设时提示 `SEARCH_PROVIDER_NOT_CONFIGURED`;设成 `scrapling` 但 `auto` 没有任何发现路径(或显式后端缺凭据)时给 `SEARCH_BACKEND_MISSING` / `SEARCH_AUTH` 与修法;发现「指向 scrapling 但能力包未就绪 / 后端不可用」时计入退出码(`WEB_PROVIDER_CONFIGURED_UNAVAILABLE`)。
|
|
71
|
+
- **测试基建:探针起不来时给的是裸 spawn 错误**:`test/probe.ts` 现在先做两道路径预检、再 `await once(child, "close")`,失败转成「探针起不来:<python>(<message>)」并带 `cause`;`test/probe.test.ts` 用假 python 路径钉住这条拒绝。`py/tests/test_bridge.py` 里那条超长 `# nosec` 注释按 bandit 要求拆行。
|
|
72
|
+
- **能力报告缺 WebSocket 覆盖面**:两份 README 承诺「日志与能力报告都如实标出」,实际只有 `guard.install` 往 stderr 记的那一行 —— 握手时的 `capabilities` 里根本没有这一位,装载阶段的日志看不出这台机器到底拦不拦得住握手。现在报 `websocketGuard`(不启浏览器,按 Page 类上有没有 `route_web_socket` 判),`install` 与能力报告共用同一条判据。
|
|
73
|
+
- **sidecar 收尾不停爬虫**:`bridge` 的两条关机路径只关会话,蜘蛛线程留给进程退出带走,而那段里它们还在往 stdout 推事件帧 —— 宿主已经不读这一路了。`close_all_crawls` 现在逐只叫停、按 `SHUTDOWN_JOIN_SECONDS` 有界等地等线程退出(等不到的记一行 stderr,不拖成假关机),并接进两条收尾路径的会话关闭之前。
|
|
74
|
+
- **MCP 无鉴权警告指了一处不存在的设置**:警告写「Set `DSH_SCRAPLING_MCP_TOKEN` (or the mcpToken setting)」,而本包刻意没有 `mcpToken` 这一项 —— token 只从环境读、绝不进 profile。文案改成只说环境变量。
|
|
75
|
+
|
|
76
|
+
### Changed
|
|
77
|
+
|
|
78
|
+
- **协议面下线 `extract`**:`scrapling_extract` 自始至终走 `select`,离线正文归一的 `extract` 方法没有任何调用方,留着等于给「已有 HTML → 正文」多开一条可以绕开清洗的入口。清洗只剩 `to_payload` 一条口(`scrapling_session_read` 走的就是它):判据改钉在进程内的 `to_payload` 调用上,上游键名对照由 `contract_probe` 直接摆到同一处调用点,协议侧只钉「`extract` 回 `UNKNOWN_METHOD`」。
|
|
79
|
+
|
|
80
|
+
- **门禁与 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 提供。
|
|
81
|
+
- **`pythonBin` 留空时的回落文案说清平台**:POSIX 上的回落名是 `python3`,Windows 上是 `python`(`resolveRuntime` 交给宿主的是 `python.exe`);两份 README 与设置卡提示同步。
|
|
82
|
+
|
|
83
|
+
### Boundaries
|
|
84
|
+
|
|
85
|
+
- 运行时能力包只在 **macOS arm64** 验证;Windows、Linux 与 macOS x64 的包状态为 `blocked`。
|
|
86
|
+
- `adaptive-redis` 与 `mcp` 包均已可用:`redis==8.1.0` 与 `mcp==2.3.0` 连同传递依赖(带哈希)钉在 `py/runtime-requirements.txt`,装进与 `core` 同一个 venv,官方 `scrapling-mcp` 由此可起。`integrationMode` 有 `native` / `mcp` / `official-mcp` 三档:前两档直接可用;`official-mcp` 只由 `setup` 生成条目配置,设成它既不注册原生工具也不起本插件的 server(B10 是这条条目背后的风险确认)。
|
|
87
|
+
- Shopify 档只在本地夹具店上验过,真实店铺未跑;official-mcp 的条目文本可生成,依赖 `mcp` 包。
|
|
88
|
+
|
|
6
89
|
## 0.1.2
|
|
7
90
|
|
|
8
91
|
这一版收口协议边界、sidecar 生命周期与 Windows 路径/编码三类只在真实部署里才暴露的缺陷;工具面与设置项未增。
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/v/@jayyuen66/dsh-scrapling?style=flat-square&logo=npm&logoColor=white" alt="npm version" /></a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/
|
|
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
14
|
<img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
- [What it does](#what-it-does)
|
|
35
35
|
- [Install](#install)
|
|
36
|
+
- [Runtime packs (macOS arm64)](#runtime-packs-macos-arm64)
|
|
36
37
|
- [Verify it is live](#verify-it-is-live)
|
|
37
38
|
- [What it does not provide](#what-it-does-not-provide)
|
|
38
39
|
- [Enabling it in dsh](#enabling-it-in-dsh)
|
|
39
40
|
- [The tools](#the-tools)
|
|
40
41
|
- [Replacing the built-in fetch and search](#replacing-the-builtin-fetch-and-search)
|
|
42
|
+
- [MCP mode](#mcp-mode)
|
|
41
43
|
- [Settings](#settings)
|
|
42
44
|
- [Proxies](#proxies)
|
|
43
45
|
- [Security](#security)
|
|
@@ -75,7 +77,7 @@ Remove with `dsh plugin --profile web remove @jayyuen66/dsh-scrapling`. The pack
|
|
|
75
77
|
|
|
76
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.
|
|
77
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`.
|
|
78
|
-
- **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
|
|
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.
|
|
79
81
|
|
|
80
82
|
```sh
|
|
81
83
|
pip install "scrapling[rag]>=0.5,<0.6"
|
|
@@ -84,7 +86,7 @@ python -m patchright install chromium
|
|
|
84
86
|
|
|
85
87
|
- **Why `rag` and not `fetchers`:** `rag` is `fetchers` plus `markdownify`, and the default `extractionType` is `markdown` — with plain `fetchers` the first fetch raises `ModuleNotFoundError` at the Markdown conversion.
|
|
86
88
|
- **Version range:** developed and verified against Scrapling **0.5**, through interfaces that are not stable API surface (`Selector`, `Spider`, `SessionManager`, and the converter's noise-stripping helpers). The upper bound is pinned below `0.6`; outside the range the guards still run, but the anti-injection cleaning and the crawl path may not behave as documented. In 0.5 the browser backend is patchright only (the old standalone stealth fetch is gone; its anti-detection arguments live on `scrapling_render`), `capture_xhr` became session-level recording (hence `scrapling_session_network`), and `extra_flags` became additive — this package sends none, and WebRTC leak protection is carried by the `blockWebrtc` switch.
|
|
87
|
-
- **
|
|
89
|
+
- **Without the installer, the browser engine is yours.** The optional CLI can install the verified macOS arm64 set; the plugin itself downloads nothing at load time. Without a browser it simply does not register the browser-dependent tools, so the model never wastes a turn calling them.
|
|
88
90
|
- **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts` enforces it). Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package there becomes a real second copy whose module-level state splits from the running host's — every native tool call then throws while build and tests stay green. The host packages the artifact imports for value are required peers and stay externalized; the gate imports the built artifact and asserts that no host package body is inlined.
|
|
89
91
|
- **The artifact is ESM-only and never committed** — `prepack` rebuilds it, so what ships is always what the current source produces.
|
|
90
92
|
|
|
@@ -92,6 +94,25 @@ python -m patchright install chromium
|
|
|
92
94
|
|
|
93
95
|
If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the version this package declares. A lower pin installs a copy without the names the sources use, and the host then reports `N entries did not activate` together with `does not provide an export named ...` at boot - the package installs fine and never loads, and no per-repository CI run can see it.
|
|
94
96
|
|
|
97
|
+
## Runtime packs (macOS arm64)
|
|
98
|
+
|
|
99
|
+
The package ships `bin/dsh-scrapling.mjs`. It installs the ability packs into `dataDir/runtime` (default `~/.dsh-scrapling`) — never into system Python and never into the user's Playwright cache. There is **no `postinstall`**; nothing is downloaded when the plugin loads.
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
dsh-scrapling setup --feature core --apply
|
|
103
|
+
dsh-scrapling setup --feature browser --apply
|
|
104
|
+
dsh-scrapling setup --status
|
|
105
|
+
```
|
|
106
|
+
|
|
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, 16 tools) 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
|
+
- `--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
|
+
- `--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
|
+
- `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.
|
|
112
|
+
- The settings card can start the same install/repair/cancel actions through the `scraplingRuntime` remote when the profile has both a remote surface and a jobs backend; otherwise it prints the CLI command.
|
|
113
|
+
- `integrationMode` is deployment-only; `setup --mode` prints or writes the client entry for the two MCP shapes and `doctor` checks a profile against it — see [MCP mode](#mcp-mode). `official-mcp` starts `scrapling-mcp` from the managed venv, which the `mcp` pack provisions (`setup --feature mcp --apply`).
|
|
114
|
+
- Only **macOS arm64** is verified. Windows, Linux and macOS x64 are blocked (B1/B2): every pack reports `blocked` and the installer refuses rather than guessing an asset path.
|
|
115
|
+
|
|
95
116
|
## <img src="https://api.iconify.design/lucide/circle-check.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Verify it is live
|
|
96
117
|
|
|
97
118
|
1. **The layer is mounted.** `dsh --profile web --dump-config` shows this package's layer line.
|
|
@@ -102,10 +123,10 @@ If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entr
|
|
|
102
123
|
|
|
103
124
|
## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does not provide
|
|
104
125
|
|
|
105
|
-
- **It is not a search engine.**
|
|
106
|
-
- **
|
|
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
|
+
- **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.
|
|
107
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.
|
|
108
|
-
- **It adds no
|
|
129
|
+
- **It adds no dsh subcommand.** The package's own `dsh-scrapling` CLI only manages runtime packs.
|
|
109
130
|
|
|
110
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
|
|
111
132
|
|
|
@@ -118,16 +139,22 @@ If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entr
|
|
|
118
139
|
|
|
119
140
|
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The tools
|
|
120
141
|
|
|
121
|
-
|
|
142
|
+
Nineteen tools, behind fifteen settings switches (the seven session/state tools share switches), all exercised by the test suite:
|
|
122
143
|
|
|
123
144
|
| Tool | Backend | Needs a browser | Concurrency |
|
|
124
145
|
|---|---|---|---|
|
|
125
146
|
| `scrapling_fetch` | `Fetcher` (curl_cffi) | no | concurrent; write verbs are serialised once `allowWriteMethods` is on |
|
|
126
147
|
| `scrapling_extract` | `Selector` + CSS/XPath + `adaptive` | no | concurrent |
|
|
148
|
+
| `scrapling_locate` | text / regex / similar-element lookup; returns generated selectors | no | concurrent |
|
|
149
|
+
| `scrapling_links` | `LinkExtractor` plus next-page candidates | no | concurrent |
|
|
127
150
|
| `scrapling_render` | `StealthySession` (patchright) | yes | serialised; the anti-detection switches (`solveCloudflare` / `hideCanvas` / `blockWebrtc`) live here |
|
|
128
151
|
| `scrapling_capture_xhr` | one throwaway session, page-level recording | yes | serialised |
|
|
129
152
|
| `scrapling_session_open` / `scrapling_session_fetch` / `scrapling_session_network` / `scrapling_session_state_save` / `scrapling_session_state_load` / `scrapling_session_list` / `scrapling_session_close` | Scrapling session classes | browser sessions only | serialised |
|
|
130
|
-
| `
|
|
153
|
+
| `scrapling_session_read` | current DOM of a browser session page | yes | serialised |
|
|
154
|
+
| `scrapling_session_act` | structured actions on a session page (deployment gate) | yes | serialised |
|
|
155
|
+
| `scrapling_download` | byte download into `dataDir/downloads` (deployment gate) | no | concurrent |
|
|
156
|
+
| `scrapling_screenshot` | PNG/JPEG screenshot handed to the attachment service | yes | serialised |
|
|
157
|
+
| `scrapling_crawl` | Scrapling Spider framework (`content` / `sitemap` / `feed` / `shopify`) as a job | no | serialised |
|
|
131
158
|
| `scrapling_answer` | any fetch path plus `ctx.llm` | with `render: true` | serialised |
|
|
132
159
|
|
|
133
160
|
- **Quotas.** At most 8 open sessions (3 of them browser sessions, each a real Chromium process), 2 crawls in flight, per-page bodies clipped by `*MaxOutputChars`, 8 MB per protocol frame, 16 queued frames. A ceiling answers with a specific code (`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from.
|
|
@@ -156,19 +183,99 @@ A configured id wins over auto-selection, which is why step 2 is required — an
|
|
|
156
183
|
- **If you later remove the plugin but leave the line in**, the built-in tools report `WEB_PROVIDER_CONFIGURED_MISSING` — go back and remove `fetchProvider` / `searchProvider` too.
|
|
157
184
|
- **The fetch provider really applies the output budget**: a body over `fetchMaxOutputChars` is cut to a head/tail window and flagged `truncated`, not passed through with a flag. Failures keep the sidecar code prefix (`URL_BLOCKED`, `SIDECAR_TIMEOUT`, `SIDECAR_UNAVAILABLE`), so a policy refusal is distinguishable from a crash or a timeout.
|
|
158
185
|
|
|
159
|
-
Search is split in two, because Scrapling is not a search engine: **discovery**
|
|
186
|
+
Search is split in two, because Scrapling is not a search engine: **discovery** runs in the Python sidecar against the backend `searchBackend` names — Tavily, Bing HTML, Brave (API), Serper (API), DuckDuckGo HTML or SearXNG (JSON API); **reading** is this plugin's — the first `searchRenderTopN` results are actually fetched and, with a browser, rendered, so one `web_search` call returns both which pages matter and what they say. `auto` uses Tavily when `tavilyApiKey` is set, SearXNG when `searxngEndpoint` is set, and with neither configured it only goes to a public engine (Bing; DuckDuckGo when that backend is named explicitly) if `searchPublicFallback` is on — otherwise the provider is unavailable and `web_search` reports `SEARCH_BACKEND_MISSING` instead of querying anyone. Only Tavily and Bing have been exercised against the real endpoints here; Brave, Serper, DuckDuckGo and SearXNG are implemented to their documented request/response shapes and verified against local stubs, with real keys and real instances still unverified. Every returned URL goes through the same gate as a fetch; a page that fails to read is skipped alone, because search results routinely contain dead links.
|
|
160
187
|
|
|
161
188
|
One consequence to know: `dsh-web`'s fetch body is a **closed** union of `html | text` with no `markdown` kind, and adding one is a cross-package change a plugin cannot make. The fetch provider therefore reports Scrapling's Markdown as `text`, which the built-in renderer displays normally. Use `scrapling_fetch` directly when you need `html` or a CSS selector.
|
|
162
189
|
|
|
190
|
+
## <img src="https://api.iconify.design/lucide/plug-zap.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> MCP mode
|
|
191
|
+
|
|
192
|
+
`integrationMode` selects one of three mutually exclusive tool surfaces. It is deployment configuration (the `config:` block of `cordis.patch.yml`), it is read once when the plugin is assembled, and changing it requires a restart.
|
|
193
|
+
|
|
194
|
+
| Mode | What it registers |
|
|
195
|
+
|---|---|
|
|
196
|
+
| `native` (default) | the `scrapling_*` tools listed above |
|
|
197
|
+
| `mcp` | no native tools; the plugin serves the same tool table over MCP |
|
|
198
|
+
| `official-mcp` | no native tools and no server from this plugin; `setup` only generates the `dsh-mcp-client` entry for the official `scrapling-mcp`, which runs in its own process, with its own sessions, and **without this plugin's URL guard** |
|
|
199
|
+
|
|
200
|
+
In `mcp` mode the server runs inside the plugin's own host process and calls the same sidecar, so the URL guard, sessions, jobs and adaptive storage are the same ones the native tools use — there is no second implementation to drift.
|
|
201
|
+
|
|
202
|
+
- **Endpoint** `http://127.0.0.1:<mcpPort>/mcp` (`mcpPort`, default `39217`). Only loopback is bound; a request whose declared body exceeds 1 MiB is refused with `413`, and any other path gets `404`. The server is stateless: each request gets its own protocol instance, so nothing survives across them.
|
|
203
|
+
- **Auth** off by default. Set the environment variable `DSH_SCRAPLING_MCP_TOKEN` and every request must then carry `Authorization: Bearer <token>`. The token is only ever read from the environment, never from the profile, so it does not land in a config file.
|
|
204
|
+
- **Tools** are the same `ToolDefinition` objects native registers: same JSON Schema, same argument validation, same renderers. `scrapling_answer` is not served — it routes through the model of the hosting session, which an external client does not have. `search` exists only on this surface, because an MCP client has no `ctx.web` seam. The gates are identical: with `allowBrowserActions=false` there is no `session_act`, with `allowFileDownloads=false` there is no `download`, and `search` is absent when no search backend is available.
|
|
205
|
+
- **Results** are text content; a screenshot comes back as MCP image content instead of a host attachment. A failing tool returns `isError` with a readable message rather than dropping the connection.
|
|
206
|
+
- **Names**: the MCP raw name is the tool name without the `scrapling_` prefix, and dsh's MCP client shows it as `mcp__scrapling__<raw>`.
|
|
207
|
+
|
|
208
|
+
| Native tool | MCP raw name |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `scrapling_fetch` | `fetch` |
|
|
211
|
+
| `scrapling_extract` | `extract` |
|
|
212
|
+
| `scrapling_locate` | `locate` |
|
|
213
|
+
| `scrapling_links` | `links` |
|
|
214
|
+
| `scrapling_render` | `render` |
|
|
215
|
+
| `scrapling_capture_xhr` | `capture_xhr` |
|
|
216
|
+
| `scrapling_session_open` | `session_open` |
|
|
217
|
+
| `scrapling_session_fetch` | `session_fetch` |
|
|
218
|
+
| `scrapling_session_network` | `session_network` |
|
|
219
|
+
| `scrapling_session_state_save` | `session_state_save` |
|
|
220
|
+
| `scrapling_session_state_load` | `session_state_load` |
|
|
221
|
+
| `scrapling_session_list` | `session_list` |
|
|
222
|
+
| `scrapling_session_close` | `session_close` |
|
|
223
|
+
| `scrapling_crawl` | `crawl` |
|
|
224
|
+
| `scrapling_session_read` | `session_read` |
|
|
225
|
+
| `scrapling_session_act` | `session_act` |
|
|
226
|
+
| `scrapling_download` | `download` |
|
|
227
|
+
| `scrapling_screenshot` | `screenshot` |
|
|
228
|
+
| — (`ctx.web` only) | `search` |
|
|
229
|
+
|
|
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
|
+
|
|
232
|
+
```bash
|
|
233
|
+
dsh plugin --profile <name> add @deepseek-ai/dsh-mcp-client@0.2.1-rc.3
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
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):
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
- insert:
|
|
240
|
+
- id: scrapling-mcp
|
|
241
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
242
|
+
config:
|
|
243
|
+
serverName: scrapling
|
|
244
|
+
transport: streamable-http
|
|
245
|
+
url: http://127.0.0.1:39217/mcp
|
|
246
|
+
failOnStartupError: false
|
|
247
|
+
# only with DSH_SCRAPLING_MCP_TOKEN set:
|
|
248
|
+
# headers:
|
|
249
|
+
# Authorization: !!js '`Bearer ${process.env.DSH_SCRAPLING_MCP_TOKEN}`'
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`mcpPort` and that URL have to say the same thing; after changing the port, re-apply the entry.
|
|
253
|
+
|
|
254
|
+
`failOnStartupError` is `false` here on purpose: the port only starts listening once the plugin has finished handshaking with the Python sidecar, and the client throws its fiber on the **first** failed connect (`Version negotiation probe failed: connect ECONNREFUSED` → the host reports `1 entry did not activate`). Its own reconnect is on by default (500ms backoff, 10 attempts), so a first-attempt refusal is meant to be absorbed - setting this to `true` would let fiber start order decide whether the mode works. The official `stdio` entry keeps `true`: there the client spawns the server itself, so a failed connect is a real failure and should be loud.
|
|
255
|
+
|
|
256
|
+
### <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> `setup --mode` and `doctor`
|
|
257
|
+
|
|
258
|
+
`setup --mode` writes that entry text; it never edits a profile. Without `--apply` it is a dry run, and with `--apply` it drops the text in `<dataDir>/mcp/<mode>.patch.yml` and prints the path - applying it to `cordis.patch.yml` stays your action, because the host offers no safe append API for that file (`dsh --dump-config` rewrites the profile's root config).
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
dsh-scrapling setup --mode mcp --port 45991 --with-auth --apply
|
|
262
|
+
dsh-scrapling setup --mode native --apply # a file that deliberately contains no entry
|
|
263
|
+
dsh-scrapling doctor --mode mcp --profile <profileDir>
|
|
264
|
+
```
|
|
265
|
+
|
|
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.3` / `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
|
+
`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
|
+
|
|
163
270
|
## <img src="https://api.iconify.design/lucide/sliders-horizontal.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Settings
|
|
164
271
|
|
|
165
272
|
Settings live on the **scrapling** card in the plugin detail page, grouped by purpose, each field with a one-line "what changes if you edit this". The card's language follows the host locale. Values marked below live on the card; the deployment table after them is only settable through the `config:` block of `cordis.patch.yml`.
|
|
166
273
|
|
|
167
274
|
| Field | Type | Default | Purpose |
|
|
168
275
|
| --- | --- | --- | --- |
|
|
169
|
-
| `pythonBin` | string | `""` | Interpreter name or absolute path. Empty = the repository `_env/.venv` when
|
|
276
|
+
| `pythonBin` | string | `""` | Interpreter name or absolute path. Empty = the repository `_env/.venv` when usable, otherwise `python3` on `PATH` (`python` on Windows) |
|
|
170
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 |
|
|
171
|
-
| `fetchEnabled` / `extractEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` | boolean | `true` | One kill switch per tool or tool pair. `sessionStateEnabled` gates the state save / load pair, which also needs a deployment-side `sessionStateDir` |
|
|
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` |
|
|
172
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 |
|
|
173
280
|
| `mainContentOnly` | boolean | `true` | Extraction scope |
|
|
174
281
|
| `*MaxOutputChars` | natural | fetch / extract / render `200000`, xhr `120000` | Per-tool output caps. The sidecar clips by characters, the host then trims to a byte budget |
|
|
@@ -181,6 +288,10 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
181
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 |
|
|
182
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 |
|
|
183
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) |
|
|
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 |
|
|
293
|
+
| `braveApiKey` / `serperApiKey` | secret | `""` | Keys for the Brave Search and Serper.dev backends |
|
|
294
|
+
| `searxngEndpoint` | string | `""` | Base URL of a SearXNG instance (`…/search?format=json` is appended); empty means the backend is unusable and reports `SEARCH_AUTH` |
|
|
184
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" |
|
|
185
296
|
| `allowedHosts` | string | `""` | Extra host names that skip the public-address check (comma-separated). Pointing it at an intranet address means giving up SSRF protection for those targets on purpose |
|
|
186
297
|
| `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 |
|
|
@@ -198,11 +309,15 @@ Settings live on the **scrapling** card in the plugin detail page, grouped by pu
|
|
|
198
309
|
| `browserRealChrome` / `browserDnsOverHttps` | `false` | Use the locally installed Google Chrome; route the browser's DNS over HTTPS (useful with a proxy to avoid DNS leaks) |
|
|
199
310
|
| `recordRequests` / `maxRecordedRequests` | `false` / `100` | Whether browser sessions record network history by default (the model can turn it on per session with `recordNetwork`), and how many entries a session keeps |
|
|
200
311
|
| `sessionStateDir` | `""` | Directory for Playwright-compatible login-state files. The model can only pass a **plain file name**, so the directory stays a deployment decision; empty disables the state save / load pair |
|
|
312
|
+
| `adaptiveStorage` | `sqlite` | Where `adaptive` fingerprints live: `sqlite` (one file under `dataDir`) or `redis` (one keyspace, shareable across processes and hosts). Deployment-only - the model only ever says "save" or "relocate" |
|
|
313
|
+
| `redisUrl` | `redis://127.0.0.1:6379/0` | Connection string read when `adaptiveStorage: redis`. The password never reaches logs or error text; an unreachable server fails as `ADAPTIVE_STORAGE_UNAVAILABLE` |
|
|
201
314
|
| `crawlMaxRuntimeSeconds` | `1800` | Wall-clock ceiling of one crawl — the page cap says nothing about a site that takes a minute per page |
|
|
202
|
-
| `crawlRespectRobots` | `false` | Obey robots.txt; with it on, a domain whose robots.txt
|
|
315
|
+
| `crawlRespectRobots` | `false` | Obey robots.txt; with it on, a domain whose robots.txt fetch **fails** (network error or HTTP 5xx) is blocked rather than assumed permitted, while a **missing** robots.txt (HTTP 404, the common case) is treated as allowing everything |
|
|
203
316
|
| `crawlDownloadDelayMs` / `crawlConcurrentRequests` / `crawlAutothrottle` / `crawlStrategy` | `0` / `4` / `false` / `bfs` | Gap between requests, parallelism, adaptive throttling, breadth- or depth-first order |
|
|
204
317
|
| `crawlCheckpointDir` | `""` | Persist the crawl queue so a restarted crawl resumes instead of going back to the start URL |
|
|
205
|
-
| `
|
|
318
|
+
| `tavilyApiEndpoint` / `bingEndpoint` / `searchRenderTopN` | `https://api.tavily.com/search` / `https://www.bing.com/search` / `3` | Discovery endpoints (overridable for tests or proxies), and how many results are actually fetched and rendered (`0` = link list only) |
|
|
319
|
+
| `duckduckgoEndpoint` | `https://html.duckduckgo.com/html/` | DuckDuckGo HTML endpoint; override for a mirror or a test stub |
|
|
320
|
+
| `allowBrowserActions` / `allowFileDownloads` / `downloadMaxBytes` | `false` / `false` / `10485760` | Deployment-only gates for structured actions and downloads, plus the per-download byte cap. Both gates default off and also hide their tools from the model |
|
|
206
321
|
|
|
207
322
|
## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Proxies
|
|
208
323
|
|
|
@@ -236,13 +351,13 @@ Details worth knowing:
|
|
|
236
351
|
|
|
237
352
|
## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Security
|
|
238
353
|
|
|
239
|
-
- **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
|
|
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.
|
|
240
355
|
- Known gaps, stated in the open:
|
|
241
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.
|
|
242
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.
|
|
243
358
|
- **No port allowlist** (any port allowed by default), matching dsh's own built-in fetch provider.
|
|
244
359
|
- **The crawl re-checks every page twice** before it enters the result set — once against the guard (the final URL may still have landed somewhere private) and once against the start domain, because Scrapling's `allow_domains` is a string comparison over links found in the page, not redirect targets. The crawl session uses `follow_redirects="safe"` so curl_cffi refuses a jump into a private range.
|
|
245
|
-
- **WebSocket coverage depends on the Playwright version.** The guard intercepts handshakes via `route_web_socket`; older builds lack that method, WebSocket is then outside the guard, and the plugin
|
|
360
|
+
- **WebSocket coverage depends on the Playwright version.** The guard intercepts handshakes via `route_web_socket`; older builds lack that method, WebSocket is then outside the guard, and the plugin reports that as `websocketGuard` in the handshake capabilities (the startup log prints the probed capabilities) rather than degrading silently.
|
|
246
361
|
- **No code execution from model input.** `page_action`, `page_setup`, `selector_config`, `proxy`, `executablePath` and `cdpUrl` never appear in any tool schema, and the browser-side network guard is installed by plugin code. The strong browser capabilities and `allowWriteMethods` come only from deployment config.
|
|
247
362
|
- **Write verbs are off by default.** With `allowWriteMethods` off, `method` and `body` are absent from `scrapling_fetch`'s parameter surface, and the sidecar independently refuses a non-GET with `WRITE_DISABLED` — two halves that do not rely on each other. The gate, the proxy decision and `follow_redirects="safe"` bound **where** a request goes, not **what it does once there**; prompt-injected page text can ask for a POST, so turn it on only where the task really is to submit data. `headers` and `cookies` stay available either way — anything handed to them lands in the model context by design.
|
|
248
363
|
- **Prompt-injection scrubbing runs unconditionally** on all three extraction paths; there is no model-facing switch to turn it off.
|
|
@@ -252,7 +367,7 @@ Details worth knowing:
|
|
|
252
367
|
| Aspect | Content |
|
|
253
368
|
| --- | --- |
|
|
254
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 |
|
|
255
|
-
| Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go to the
|
|
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 |
|
|
256
371
|
| Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
|
|
257
372
|
| In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
|
|
258
373
|
| Telemetry | None |
|
|
@@ -267,6 +382,13 @@ Registered honestly, one entry per class.
|
|
|
267
382
|
- **`headers` and `retries` on `scrapling_session_fetch` belong to static sessions.** Upstream silently drops both for browser sessions, so this package refuses them with `BAD_ARGS` naming the knob to use instead — a silent no-op is the failure mode it exists to eliminate.
|
|
268
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.
|
|
269
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
|
+
- **`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`.
|
|
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
|
+
- **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
|
+
- **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.
|
|
390
|
+
- **Shopify crawl mode walks the store's JSON API.** `mode=shopify` uses the store's `/collections.json` and each collection's `/products.json` (upstream's `ShopifySpider`) and yields one row per variant — `name` (product + variant, minus `Default Title`), `price`, `sku`, `stock` (`null` when available, `0` when not), `identifier`, `brand`, `category`, `image_url`, `url`, `barcode`, `old_price`, `description`. It never scrapes product HTML, and it obeys the same URL gate, robots setting, delay and concurrency knobs as the other crawl modes. Verified against a local fixture store; a real Shopify store has not been exercised (B11).
|
|
391
|
+
- **`official-mcp` generates configuration only.** `integrationMode=official-mcp` registers no native tool and starts no server from this plugin; `setup --mode official-mcp --accept-risk` produces the `dsh-mcp-client` entry for the official server, whose binary comes from the `mcp` pack (B10 is the risk decision that entry stands on).
|
|
270
392
|
|
|
271
393
|
## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> FAQ
|
|
272
394
|
|
|
@@ -276,7 +398,7 @@ Registered honestly, one entry per class.
|
|
|
276
398
|
| After enabling a proxy, every fetch is blocked | A fake-IP proxy resolves every domain into a non-public range; the gate auto-detects that class and relaxes to the known pools. A self-built pool outside them goes into `syntheticDnsRanges`. Private and loopback addresses stay blocked on purpose |
|
|
277
399
|
| `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE` / `_MISSING` | The deployment line points at this plugin: either the sidecar is down (interpreter or Scrapling — see the startup log), or the plugin was removed and the `fetchProvider` / `searchProvider` line is still there. Remove the line too |
|
|
278
400
|
| The model cannot POST a form | `allowWriteMethods` is off by default and deployment-only — it decides whether the model may change state on a remote host |
|
|
279
|
-
| `web_search`
|
|
401
|
+
| `web_search` reports `SEARCH_AUTH` | The selected backend has no credential: Tavily/Brave/Serper need their key, SearXNG needs `searxngEndpoint`. Set it, or switch `searchBackend`. With `searchBackend=auto` and no key and no `searxngEndpoint`, the plugin reports `SEARCH_BACKEND_MISSING` — set a key / endpoint, or turn on `searchPublicFallback` to allow public engines |
|
|
280
402
|
| The numbers on a chart are missing | SVG tick labels do not survive the Markdown conversion in any tool. Use `scrapling_capture_xhr` to find the JSON endpoint behind the chart |
|
|
281
403
|
|
|
282
404
|
## <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Development
|
|
@@ -287,9 +409,9 @@ pnpm run check # typecheck → lint → client build → host build → test
|
|
|
287
409
|
pnpm run test:py # end-to-end check of the Python sidecar
|
|
288
410
|
```
|
|
289
411
|
|
|
290
|
-
- **The Python half is gated like the TypeScript half.** `check` ends with `check:py`: an interpreter report, a face count (the shipped `.py` files and the test directory must both be there — a missing test directory makes "clean" and "untested" indistinguishable), ruff check, ruff format, mypy, the sidecar end-to-end, bandit (
|
|
412
|
+
- **The Python half is gated like the TypeScript half.** `check` ends with `check:py`: an interpreter report, a face count (the shipped `.py` files and the test directory must both be there — a missing test directory makes "clean" and "untested" indistinguishable), a dependency consistency check, ruff check, ruff format, mypy, the sidecar end-to-end, bandit (all severities; `# nosec` only for justified false positives), and a coverage floor measured **only over the modules that ship**. Dev tools: `pip install -r py/requirements-dev.txt` into the interpreter `test:py` uses.
|
|
291
413
|
- **The Python 3.14 floor is one fact in four places:** both READMEs, the ruff and mypy targets, and a runtime gate in `py/bridge.py` that exits before any Scrapling import with a clean stdout — stdout is protocol frames, so an old interpreter shows the exit code and a stderr line instead of garbage.
|
|
292
|
-
- **mypy
|
|
414
|
+
- **mypy checks untyped bodies and rejects unannotated defs and unused ignores.** Playwright's `page` / `route` / `websocket` objects have no shape until runtime, so `ignore_missing_imports` and `ANN401` stay off; those three checks are on, not the full `strict` profile.
|
|
293
415
|
- Sources are TypeScript. `host.js` and `client.js` are **build artifacts** and deliberately `.js`: Node refuses to strip types for packages inside `node_modules`, which is exactly where dsh loads the plugin from. The artifact is ESM-only; `require()` will not get you the plugin, and that is deliberate.
|
|
294
416
|
- Gates that pin the published shape: `test/publish-manifest.test.ts` (entry targets covered by `files`, no source file as an entry point, `dsh-*` pins exact and uniform, no host package body inlined, no dates or bad bytes in comments or documents) and `test/readme-parity.test.ts` (the two READMEs name every tool and every settings-card knob, and their section structures match).
|
|
295
417
|
- Publishing runs through [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) (manual, OIDC trusted publishing plus `--provenance`).
|