@jayyuen66/dsh-scrapling 0.1.12 → 0.1.13
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 +29 -0
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/THIRD_PARTY_NOTICES.md +49 -13
- package/client.js +7 -3
- package/docs/DETAIL.md +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/host.js +42 -18
- package/icon.svg +13 -1
- package/package.json +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,35 @@
|
|
|
6
6
|
标准六类之外的小节(本仓的 `Boundaries` 收各版本的验证范围与能力边界,即哪些平台/档位真跑过、
|
|
7
7
|
哪些只到本地夹具为止)。
|
|
8
8
|
|
|
9
|
+
## 0.1.13
|
|
10
|
+
|
|
11
|
+
模型可见面全量双语化(中文仍是默认,跟随宿主 locale 偏好切英文);工具选型的完整指引从常驻提示词搬进按需加载的虚拟 skill;search provider 补上 `ready()`、两个 web provider 的可热改项改成取值函数;十九个工具补调用态卡片与工具级墙钟;设置页多出一级分区与官方标记。
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **模型可见面的英文**:新增 `lib/messages.ts`,`ScraplingMessages` 227 键双语(工具描述、参数说明、十五条抓取指引、问答系统提示与六条回执、截断提示、MCP search 四句)。`ToolDeps` 多一个可选 `messages`,`messagesOf(deps)` 落回中文;`host.ts` 的 `localeMessagesOf` 读官方 locale 命名空间的偏好,装配期解析一次并注入全部工具、问答与 MCP 面。此前这些文本全部硬编中文——非中文模型读到的说明与报错是另一种语言。八张工具参数表与五张共享参数表随之从 `as const` 常量改成箭头函数 + `as const`(标宽返回类型会让 `defineTool` 推不出 `ParameterSchemaSpec`)。
|
|
16
|
+
- **虚拟 skill `scrapling`**:十五条逐工具指引的**全文**经 `ctx.skills.register()` 注册,常驻 system prompt 只留一段跨工具摘要(`usageSummary`)。中文全文 2324 B 缩到常驻 505 B、英文 2869 B 缩到 699 B。正文按 `plan.ready` 现算:没装浏览器的机器那枚 skill 里不会出现 render / capture_xhr 那几句。指路句(`skillPointer`)只在 skill 真注册上时才追加——精简 profile 没有 `dsh-skill` 时把模型指向一个不存在的 skill 比不说更糟。
|
|
17
|
+
- **search provider 的 `ready()`**:按官方契约实现 `ready(llmProvider)`,只查配置不发网络——没有可用凭据时返回 false,宿主的内置 `web_search` 因此整个不出现,而不是出现后每次调用都报鉴权错。凭据判据与 `available()` 刻意分成两套:`available()` 答「本 provider 进不进 `ctx.web` 的候选」(显式指定后端时恒 true,key 缺了留给 `search()` 报 `SEARCH_AUTH`,用户才知道补哪一项),`ready()` 答「内置工具要不要露给模型」。`auto` 看全部三条发现路径,名单外的旧后端名取保守侧 false。`fetch` 侧不加 `ready()`——官方 fetch provider 也没有,它没有凭据可判。
|
|
18
|
+
- **调用态卡片**:十九个工具全部声明 `presentCall`,标题取入参里已有的值、取不到回落工具名。三个会话工具(`session_open` / `session_list` / `session_close`)此前落默认卡片,与检索类工具在时间线上分不出来。
|
|
19
|
+
- **工具级墙钟**:每处注册的 `timeoutMs` 改成 `toolTimeoutOf(settings)` = 部署的 `timeoutMs` + 60 秒余量(17 处)。此前注册级与内层取同一个数,而宿主的截止在 `execute` 之前就装好、起点更早 ⇒ 永远是宿主先到期,本包带出路说明的 `SidecarError`(`BROWSER_TIMEOUT` / `REQUEST_TIMEOUT`)没机会说话。
|
|
20
|
+
- **设置页一级分区与官方标记**:`settings.section` 注册 `id: "dsh-scrapling"`、`order: 30`(排在宿主既有的 account/general/models/plugins/agent-presets 之后),`settings.section.icon` 用同一 id 挂官方章鱼标记。图标是把官方图按「绿色高光 / 其余」拆成两张 alpha 遮罩叠出来的:本体走 `currentColor` 跟主题、眼睛与吸盘保留官方的 `#B3FB2A`,形状零改动。`plugins.bundle.config` 那一份保留,插件详情页与设置页两处显示同一张卡片;分区里显式传 `view: "page"` —— 不传时卡片会早退成空表单且不报错。
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- **可热改的部署项改成取值函数**:`SearchProviderDeps` / `WebProviderDeps` 里的后端名、四把 key、searxng 端点、publicFallback、输出预算与超时全部改成 `Reader<T> = () => T`(新增 `lib/config-reader.ts`),`host.ts` 抽出 `providerReadersOf(config)` 一处构造。原因:这些字段在设置卡上是 `.volatile()` 的,改值不会重跑 `apply`,装配时抄进闭包的那一份会永远停在旧值。一次操作只取一次快照,同一笔请求内不会出现「协议层按 30 秒等、回执里写 45 秒」。
|
|
25
|
+
- **下载回执补提示**:`scrapling_download` 的文本多一句 `downloadSavedHint`(文件落在哪、下一步通常是什么),不再只是一行字节数与 sha256。
|
|
26
|
+
- **宿主开发基线抬到 `0.2.2-rc.2`**:`devDependencies` 整组 `@deepseek-ai/dsh-*` 抬到 `0.2.2-rc.2` 并补 `@deepseek-ai/dsh-skill`;`peerDependencies` 与 `engines.dsh` 的支持窗口由 `^0.2.2-rc.1` 收到 `^0.2.2-rc.2`;`@deepseek-ai/dsh-error` 由 devDependency 改为 optional peer(`SidecarError` 继承宿主的 `HarnessError`,`instanceof` 要的是同一份类身份,内联成第二份就等于没有错误码)。
|
|
27
|
+
- **两份 README 与两份 DETAIL 的指引段叙述同步**:从「关掉某个工具时它的 system prompt 指引段一并消失」改成「常驻只有一段跨工具摘要、逐工具十五句在虚拟 skill 里」,并说明侧车没起来时既不注册 skill 也没有常驻段。
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **`MCP_SERVER_VERSION` 与包版本同步**到 `0.1.13`。
|
|
32
|
+
|
|
33
|
+
### Boundaries
|
|
34
|
+
|
|
35
|
+
- 英文面只覆盖模型可见的文案(工具描述、参数说明、指引、回执、截断提示)。装配期日志、配置错误提示与 CLI 输出仍是中文:它们给部署者看,不进模型上下文。
|
|
36
|
+
- `ctx.skills` 是可选服务。精简 profile(没装 `dsh-skill`)下插件照常装配、工具照常可用,只是十五条指引按需加载不了,常驻段也不会出现指路句。
|
|
37
|
+
|
|
9
38
|
## 0.1.12
|
|
10
39
|
|
|
11
40
|
设置卡的下拉候选与说明浮层不再漂到浏览器最左边;shared 抬到 `^0.2.8`(含运行时几何自检),CI 的 action 钉版升到最新。`MCP_SERVER_VERSION` 随包版本同步。
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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%3D24.9-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
|
|
15
|
-
<img src="https://img.shields.io/badge/dsh-%5E0.2.2--rc.
|
|
15
|
+
<img src="https://img.shields.io/badge/dsh-%5E0.2.2--rc.2-658EFF?style=flat-square" alt="dsh" />
|
|
16
16
|
<a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/powered_by_dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white" alt="powered by dsh" /></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
@@ -80,7 +80,7 @@ dsh plugin --profile web add @jayyuen66/dsh-scrapling
|
|
|
80
80
|
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.
|
|
81
81
|
|
|
82
82
|
- **Requires Node.js `>= 24.9`.** This is an ESM-only package, and the build entry points (`build-client.ts`, `build-host.ts`, `build-cli.ts`) are executed by `node` directly, so the floor has to sit where TypeScript type stripping is on by default (Node 22.18 up). The number itself is the host floor: `0.2.2` hosts declare Node `>= 24.9.0`, and a host below it never starts.
|
|
83
|
-
- **Requires host `dsh` at the `0.2.2-rc.
|
|
83
|
+
- **Requires host `dsh` at the `0.2.2-rc.2` line or later.** The requirement the host actually reads is `engines.dsh` (`^0.2.2-rc.2`), and it decides alone; a host on a later line is refused and needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against every released host version inside the window at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
|
|
84
84
|
- **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.
|
|
85
85
|
|
|
86
86
|
```sh
|
|
@@ -123,7 +123,7 @@ dsh-scrapling setup --status
|
|
|
123
123
|
- That command is the only accepted "it is in the layer stack" signal, and it is **not read-only** — it rewrites the profile's root assembly file. Read layer lines from stdout **and** check stderr separately: an unmatched patch target appears only on stderr, so the exit code alone proves nothing. Accept both `# == <layer>` and `# == <layer>, patched by <path>`.
|
|
124
124
|
2. **The startup log names the interpreter and the plan.** One line prints the probed capabilities and how many of the tools registered; the chosen interpreter path is logged at load. An interpreter that starts but lacks Scrapling is named in the log together with the pip line to copy.
|
|
125
125
|
3. **The settings card renders.** The plugin detail page carries the **scrapling** card with every user-editable field grouped by purpose; toggling a value enables Save, and the write returns 200.
|
|
126
|
-
4. **A tool round-trip.** Ask the model to fetch a JavaScript-heavy page: the result row renders in the chat through the official tool-call view. On a machine without a browser the render / capture_xhr tools are absent from the model's tool list and their
|
|
126
|
+
4. **A tool round-trip.** Ask the model to fetch a JavaScript-heavy page: the result row renders in the chat through the official tool-call view. On a machine without a browser the render / capture_xhr tools are absent from the model's tool list and their guidance is gone from the skill body too — that absence is the conditional registration working, not a failure.
|
|
127
127
|
|
|
128
128
|
## <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
|
|
129
129
|
|
|
@@ -138,7 +138,7 @@ dsh-scrapling setup --status
|
|
|
138
138
|
- The client half registers two surfaces: the settings card (on the `plugins.bundle.config` slot, keyed by the bundle package name — the host dispatches `entryKey: pkg.name`, so the card renders on this package's detail page) and one result row per tool on `tool.call.toolview`, drawn with the official tool-call view props.
|
|
139
139
|
- The settings namespace is the entry id `scrapling`; precedence is settings-card value > registration-line `config:` > schema default. Setting a field back to its default saves a **clear-override**, not a write of the same value, so a later default change still reaches you.
|
|
140
140
|
- Gate policy and the sidecar environment are snapshotted once when the plugin is applied — **settings changes take effect on the next start**.
|
|
141
|
-
- Disabling a tool also removes its
|
|
141
|
+
- Disabling a tool also removes its guidance, in two layers: the **resident section is a single summary** (cross-tool selection rules, naming no specific tool), while the fifteen per-tool lines are registered as a virtual skill `scrapling`. Both are re-read at each prompt assembly against the tools that scope can actually see — a machine without a browser loses the render / capture_xhr lines from the skill body, and a sidecar that never came up gets **neither the section nor the skill** (registering an empty skill would only put a catalog entry that opens to nothing). Without the host's skill service (a trimmed profile) the plugin still composes normally, it just lacks that skill and the summary drops its "full guidance lives in the skill" pointer. The section is placed next to the built-in `web_fetch` guidance.
|
|
142
142
|
- `scrapling_crawl` registers its own job kind, so `job_list` labels its jobs as crawls rather than shell jobs.
|
|
143
143
|
|
|
144
144
|
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The tools
|
|
@@ -428,4 +428,4 @@ pnpm run test:py # end-to-end check of the Python sidecar
|
|
|
428
428
|
|
|
429
429
|
MIT. Source at [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling). Issues go to that repository's tracker.
|
|
430
430
|
|
|
431
|
-
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 (
|
|
431
|
+
This package ships no third-party source code — Scrapling and the browser engines are runtime dependencies. The third-party content in the package is the icon (the official Scrapling mark, BSD 3-Clause) and the `zod` code inlined into the single-file CLI bundle; the host-side client bundle keeps `zod` external. [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) records that boundary.
|
package/README.zh-CN.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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%3D24.9-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
|
|
15
|
-
<img src="https://img.shields.io/badge/dsh-%5E0.2.2--rc.
|
|
15
|
+
<img src="https://img.shields.io/badge/dsh-%5E0.2.2--rc.2-658EFF?style=flat-square" alt="dsh" />
|
|
16
16
|
<a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/powered_by_dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white" alt="powered by dsh" /></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
@@ -80,7 +80,7 @@ dsh plugin --profile web add @jayyuen66/dsh-scrapling
|
|
|
80
80
|
卸载用 `dsh plugin --profile web remove @jayyuen66/dsh-scrapling`。包在公共 npm registry 上,安装不需要凭据,也不需要 scoped-registry 配置行。
|
|
81
81
|
|
|
82
82
|
- **需要 Node.js `>= 24.9`。** 本包是 ESM-only,且构建入口(`build-client.ts`、`build-host.ts`、`build-cli.ts`)由 `node` 直接执行,所以下限必须落在 TypeScript 类型剥离默认开启的那批版本上(Node 22.18 起)。数字本身取自宿主:`0.2.2` 系列宿主声明 Node `>= 24.9.0`,低于它的宿主根本起不来。
|
|
83
|
-
- **需要宿主 `dsh` 处在 `0.2.2-rc.
|
|
83
|
+
- **需要宿主 `dsh` 处在 `0.2.2-rc.2` 或更新的 `0.2.2` 版本线。** 宿主真正读的是 `engines.dsh`(`^0.2.2-rc.2`),且它**单独决定**;更新版本线的宿主会被拒,需要显式风险授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`。支持窗口是滚动的:本包在发布时把窗口内的每个已发布宿主版本逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
|
|
84
84
|
- **需要 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 时报错里带着可直接照抄的安装命令。
|
|
85
85
|
|
|
86
86
|
```sh
|
|
@@ -123,7 +123,7 @@ dsh-scrapling setup --status
|
|
|
123
123
|
- 这条命令是唯一被认的「它在层栈里」信号,而且它**不是只读的** —— 会把 profile 的根装配文件重写一遍。层行从 stdout 读,stderr **单独**查:未命中的 patch 目标只出现在 stderr,只看退出码证明不了任何事。`# == <层>` 与 `# == <层>, patched by <路径>` 两种形态都要认。
|
|
124
124
|
2. **启动日志点名解释器与注册计划。** 有一行打印探测到的能力与注册了几个工具;选中的解释器路径在装载时写进日志。解释器起得来但没装 Scrapling 时,日志点名解释器路径,并附可直接照抄的 pip 命令。
|
|
125
125
|
3. **设置卡渲染。** 插件详情页上有 **scrapling** 卡,全部用户可改字段按用途分组;改一个值后保存按钮亮起,写入返回 200。
|
|
126
|
-
4. **一次工具往返。** 让模型抓一个重 JS 的页面:结果行经官方 tool-call 视图渲染在会话里。没有浏览器的机器上,render / capture_xhr
|
|
126
|
+
4. **一次工具往返。** 让模型抓一个重 JS 的页面:结果行经官方 tool-call 视图渲染在会话里。没有浏览器的机器上,render / capture_xhr 不在模型的工具列表里,对应的指引也一并消失(skill 正文里没有那几句)—— 那是条件注册在起作用,不是故障。
|
|
127
127
|
|
|
128
128
|
## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 它不提供什么
|
|
129
129
|
|
|
@@ -138,7 +138,7 @@ dsh-scrapling setup --status
|
|
|
138
138
|
- client 半注册两处:设置卡(坐在 `plugins.bundle.config` 槽上,键是 bundle 包名 —— 宿主按 `entryKey: pkg.name` 派发,所以卡画在本包的详情页上),以及每个工具在 `tool.call.toolview` 上的一行结果,用官方 tool-call 视图 props 画。
|
|
139
139
|
- 设置命名空间就是条目 id `scrapling`;优先级为 设置卡现值 > 注册行 `config:` > schema 默认值。把一项改回默认值保存的是**清除覆盖**而不是写入同一个值,将来默认值变了你这一项也会跟着变。
|
|
140
140
|
- 闸门策略与 sidecar 环境在插件 `apply()` 时取一次快照 —— **设置卡的改动要等下次启动才生效**。
|
|
141
|
-
-
|
|
141
|
+
- 关掉某个工具时,它的指引也一并消失,但分两层看:**常驻段只有一段摘要**(跨工具的选型规则,不点名具体工具),而逐工具那十五句全文注册成一枚虚拟 skill `scrapling`。两侧都按「那个 scope 真注册着哪些工具」现取 —— 没装浏览器的机器上 skill 正文里没有 render / capture_xhr 那几句,sidecar 没起来的机器**既没有常驻段也不注册 skill**(正文为空时注册一枚点开什么都没有的条目只会污染模型的 skill 目录)。宿主没有 skill 服务(精简 profile)时插件照常装配,只是少了这枚 skill,常驻段也不追加那句「完整指引见 skill」。常驻段排在内置 `web_fetch` 指引旁边。
|
|
142
142
|
- `scrapling_crawl` 登记自己的作业类型,`job_list` 因此把它的作业标成爬虫而不是 shell 作业。
|
|
143
143
|
|
|
144
144
|
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 工具一览
|
|
@@ -428,4 +428,4 @@ pnpm run test:py # Python sidecar 的端到端验证
|
|
|
428
428
|
|
|
429
429
|
MIT。源码在 [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling),issue 走该仓库的 tracker。
|
|
430
430
|
|
|
431
|
-
本包不随包分发第三方源码 —— Scrapling 与浏览器引擎都是运行期依赖。随包的第三方内容是图标(
|
|
431
|
+
本包不随包分发第三方源码 —— Scrapling 与浏览器引擎都是运行期依赖。随包的第三方内容是图标(Scrapling 官方标记,BSD 3-Clause)与 CLI 单文件产物内联的 `zod`;host 侧 client 产物外置 zod。[`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) 记录这条边界。
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -10,21 +10,57 @@ Scrapling 及浏览器引擎都是**运行期依赖**——本包调用它们暴
|
|
|
10
10
|
`Convertor._strip_noise_tags` 与 `Convertor._sanitize_for_ai` 是上游的私有下划线方法,不在上游文档
|
|
11
11
|
里(见「机制与接口来源」)。它们不由本包分发,许可文本也随各自的包走,本文件不重复。
|
|
12
12
|
|
|
13
|
-
随包分发的第三方内容有两处:**图标**(`icon.svg
|
|
14
|
-
|
|
13
|
+
随包分发的第三方内容有两处:**图标**(`icon.svg`,Scrapling 官方标记,BSD 3-Clause)与
|
|
14
|
+
**CLI 单文件产物内联的 zod**(`bin/dsh-scrapling.mjs`,MIT)。本包在下方保留各自的版权与
|
|
15
|
+
许可声明。
|
|
15
16
|
|
|
16
|
-
## 图标:
|
|
17
|
+
## 图标:Scrapling 官方标记
|
|
17
18
|
|
|
18
|
-
- 上游项目:`
|
|
19
|
-
- 上游仓库:https://github.com/
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
- 上游项目:`Scrapling`
|
|
20
|
+
- 上游仓库:https://github.com/D4Vinci/Scrapling
|
|
21
|
+
- 上游资源:https://scrapling.readthedocs.io/zh-cn/latest/assets/logo.png(486×480 PNG,带 alpha)
|
|
22
|
+
- 上游许可:BSD 3-Clause,Copyright (c) 2024 Karim shoair
|
|
23
|
+
|
|
24
|
+
`icon.svg` 的图形**全部来自这张官方标记**:形状与 alpha 通道逐像素同源,没有重新绘制的部分。
|
|
25
|
+
本包只做了一件渲染期的事——把官方图拆成「本体」与「高光」两张遮罩分别上色:本体取
|
|
26
|
+
`currentColor`(跟随 DSH 导航行的前景色,深色主题为浅色、浅色主题为深色),高光保留官方绿
|
|
27
|
+
(`#B3FB2A`,取自官方图的眼睛与吸盘)。这样两种主题下都与官方标记一致,而形状本身一个像素
|
|
28
|
+
都没改。同一份遮罩字节也内联在 `client.js` 里,作为设置页导航图标的 `mask-image`。
|
|
29
|
+
|
|
30
|
+
BSD 3-Clause 允许再分发与修改,唯一的实质义务是保留版权声明与本许可条件——也就是这一节。
|
|
31
|
+
以下是许可正文:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
BSD 3-Clause License
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2024, Karim shoair
|
|
37
|
+
All rights reserved.
|
|
38
|
+
|
|
39
|
+
Redistribution and use in source and binary forms, with or without
|
|
40
|
+
modification, are permitted provided that the following conditions are met:
|
|
41
|
+
|
|
42
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
43
|
+
list of conditions and the following disclaimer.
|
|
44
|
+
|
|
45
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
46
|
+
this list of conditions and the following disclaimer in the documentation
|
|
47
|
+
and/or other materials provided with the distribution.
|
|
48
|
+
|
|
49
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
50
|
+
contributors may be used to endorse or promote products derived from
|
|
51
|
+
this software without specific prior written permission.
|
|
52
|
+
|
|
53
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
54
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
55
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
56
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
57
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
58
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
59
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
60
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
61
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
62
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
63
|
+
```
|
|
28
64
|
|
|
29
65
|
## CLI 单文件产物内联的 zod
|
|
30
66
|
|
package/client.js
CHANGED
|
@@ -29,7 +29,7 @@ t!==null&&(t.offsetTop<e.scrollTop?e.scrollTop=t.offsetTop:t.offsetTop+t.offsetH
|
|
|
29
29
|
/* v8 ignore next 3 -- enabled 为空已在上一条返回 */
|
|
30
30
|
if(t===void 0)return;a(t.index)}else if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),!n){T();return}E(i)}else(e.key===`Tab`||e.key===`Escape`)&&w()},k=[],A;for(let[n,r]of _.entries())r.group!==A&&(r.group!==void 0&&k.push((0,e.createElement)(`div`,{key:`group-${n}-${r.group}`,className:`dsu-optionGroup`,role:`presentation`},r.group)),A=r.group),k.push((0,e.createElement)(`button`,{key:`option-${r.value}`,type:`button`,role:`option`,id:`${d}-${n}`,className:`dsu-option`,tabIndex:-1,"aria-selected":r.value===t.value,"data-active":n===i,disabled:r.disabled===!0,onMouseDown:e=>{e.preventDefault()},onClick:()=>{E(n)},onMouseEnter:()=>{
|
|
31
31
|
/* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
|
|
32
|
-
r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElement)(`svg`,{className:`dsu-check`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M2.5 7.5l3 3 6-7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))));return(0,e.createElement)(u,{...t,controlId:f},(0,e.createElement)(`div`,{className:`dsu-selectWrap`,onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||w()}},(0,e.createElement)(`button`,{ref:c,type:`button`,id:f,style:{anchorName:p},className:`dsu-select dsu-input`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":n,"aria-controls":`${d}-list`,"aria-activedescendant":n&&S?`${d}-${i}`:void 0,"aria-describedby":m,"data-field":t.field,disabled:h===!0||_.length===0,onClick:()=>{n?w():T()},onKeyDown:O},(0,e.createElement)(`span`,{className:`dsu-selectValue`},b),(0,e.createElement)(`svg`,{className:`dsu-chevron`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M3 5l4 4 4-4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))),(0,e.createElement)(`div`,{ref:l,id:`${d}-list`,role:`listbox`,className:`dsu-menu`,style:{positionAnchor:p,positionTryFallbacks:`flip-block, flip-inline`},"aria-label":t.label,hidden:!n},...k)))}function m(t){let n=!t.writable||t.busy||!t.dirty,r;return r=t.error===null?t.writable?t.dirty?t.dirtyLabel:t.cleanLabel:t.readOnlyLabel:t.error,(0,e.createElement)(`div`,{className:`dsu-savebar`,"data-dirty":t.dirty},(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dsu-btnPrimary`,"data-field":`save`,disabled:n,onClick:t.onSave},t.busy?t.savingLabel:t.saveLabel),(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn`,"data-field":`discard`,disabled:n,onClick:t.onDiscard},t.revertLabel),(0,e.createElement)(`span`,{role:`status`,className:t.error===null?`dsu-status`:`dsu-status dsu-statusError`},r))}const h=e=>e.length>0&&!(e in Object.prototype);function g(e,t,n){n===void 0?e[t]=void 0:Object.defineProperty(e,t,n)}function _(e,t,n){if(!h(t))throw Error(`claimApply 的 flag 不得为空、也不得命中 Object.prototype 的成员(__proto__ 一类会让占位静默失灵或遮蔽全局成员):${t}`);let r=globalThis,i=Object.hasOwn(r,t)?r[t]:void 0;if(i===!0||typeof i==`symbol`)return!1;let a=Object.getOwnPropertyDescriptor(r,t),o=Symbol(t);r[t]=o;try{e.effect(()=>()=>{r[t]===o&&g(r,t,a)},n)}catch(e){throw r[t]===o&&g(r,t,a),e}return!0}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=[{id:`runtime`,title:{zh:`运行环境`,en:`Runtime`},note:{zh:`Python 与数据目录。装完 scrapling 之后这里一般不用动。`,en:`Python and the data directory. Usually untouched once scrapling is installed.`},fields:[{key:`pythonBin`,kind:`text`,label:{zh:`Python 解释器`,en:`Python interpreter`},hint:{zh:`留空:按「托管 runtime(macOS arm64,装过才用)→ 仓内 _env/.venv(装了才用)→ PATH 上的 python3(Windows 上是 python)」依次探测,卡面上的「运行环境」会显示命中的是哪一档;装了 pyenv/conda 时填绝对路径。`,en:`Empty: probed in order — managed runtime (macOS arm64, only once installed), the repo's _env/.venv when it exists, then python3 from PATH (python on Windows); the Runtime row shows which one won. Give an absolute path under pyenv/conda.`},fallback:``},{key:`failFastOnMissingPython`,kind:`boolean`,label:{zh:`Python 缺失时拒绝加载`,en:`Fail fast without Python`},hint:{zh:`开:Python 起不来就不注册任何工具并报错。关:只警告,工具全部消失。`,en:`On: register nothing and error out. Off: warn and register nothing.`},fallback:!0},{key:`dataDir`,kind:`text`,label:{zh:`数据目录`,en:`Data directory`},hint:{zh:`留空用 ~/.dsh-scrapling;选择器自愈的指纹库落在这里,需要可写。`,en:`Leave empty for ~/.dsh-scrapling; the adaptive selector store lives here and must be writable.`},fallback:``}]},{id:`tools`,title:{zh:`工具开关`,en:`Tools`},note:{zh:`关掉的工具不会注册给模型,也不会在会话提示里占位置。`,en:`A disabled tool is never registered with the model and leaves the system prompt too.`},fields:[{key:`fetchEnabled`,kind:`boolean`,label:{zh:`scrapling_fetch`,en:`scrapling_fetch`},hint:{zh:`curl_cffi 静态抓取。`,en:`Static fetching over curl_cffi.`},fallback:!0},{key:`extractEnabled`,kind:`boolean`,label:{zh:`scrapling_extract`,en:`scrapling_extract`},hint:{zh:`对给定 HTML 做选择器抽取,不发请求。`,en:`Extract from given HTML without any request.`},fallback:!0},{key:`locateEnabled`,kind:`boolean`,label:{zh:`scrapling_locate`,en:`scrapling_locate`},hint:{zh:`按文本、正则或相似元素定位,返回可复用的选择器。`,en:`Locate by text, regex, or similar elements and return reusable selectors.`},fallback:!0},{key:`linksEnabled`,kind:`boolean`,label:{zh:`scrapling_links`,en:`scrapling_links`},hint:{zh:`列出页面链接与下一页候选。`,en:`List page links and next-page candidates.`},fallback:!0},{key:`renderEnabled`,kind:`boolean`,label:{zh:`scrapling_render`,en:`scrapling_render`},hint:{zh:`Playwright 渲染,能读 SPA。`,en:`Playwright rendering; reads SPAs.`},fallback:!0},{key:`captureXhrEnabled`,kind:`boolean`,label:{zh:`scrapling_capture_xhr`,en:`scrapling_capture_xhr`},hint:{zh:`只回传 XHR 的 URL/状态/字节数;站点数据在接口里时用它找那个接口。`,en:`Returns XHR url/status/bytes only — use it to locate the JSON endpoint.`},fallback:!0},{key:`networkEnabled`,kind:`boolean`,label:{zh:`scrapling_session_network`,en:`scrapling_session_network`},hint:{zh:`读已开会话攒下的网络历史;会话需先用 recordNetwork 打开记录。`,en:`Read a session's recorded network history; the session must have recordNetwork on.`},fallback:!0},{key:`sessionEnabled`,kind:`boolean`,label:{zh:`scrapling_session_*`,en:`scrapling_session_*`},hint:{zh:`跨请求复用 cookie 与浏览器实例,只管 open / fetch / list / close 这一组;network 与 state_* 各自有独立开关。`,en:`Reuse cookies and the browser across requests; covers open / fetch / list / close only. The network and state_* groups have their own switches.`},fallback:!0},{key:`sessionStateEnabled`,kind:`boolean`,label:{zh:`scrapling_session_state_*`,en:`scrapling_session_state_*`},hint:{zh:`存/取浏览器登录态;需部署侧配好 sessionStateDir。`,en:`Save/load browser login state; needs a deployment-side sessionStateDir.`},fallback:!0},{key:`crawlEnabled`,kind:`boolean`,label:{zh:`scrapling_crawl`,en:`scrapling_crawl`},hint:{zh:`后台 Spider 作业,只守起始域;需 profile 带作业后端。`,en:`Background spider jobs confined to the start domain; needs a jobs backend.`},fallback:!0},{key:`answerEnabled`,kind:`boolean`,label:{zh:`scrapling_answer`,en:`scrapling_answer`},hint:{zh:`抓完页面交给模型问答。`,en:`Answer a question over a fetched page.`},fallback:!0},{key:`sessionReadEnabled`,kind:`boolean`,label:{zh:`scrapling_session_read`,en:`scrapling_session_read`},hint:{zh:`读浏览器会话当前页,不再发请求。`,en:`Read the current page of a browser session without another request.`},fallback:!0},{key:`sessionActionsEnabled`,kind:`boolean`,label:{zh:`scrapling_session_act`,en:`scrapling_session_act`},hint:{zh:`结构化浏览器动作;还要部署侧打开 allowBrowserActions。`,en:`Structured browser actions; the deployment must also set allowBrowserActions.`},fallback:!0},{key:`downloadEnabled`,kind:`boolean`,label:{zh:`scrapling_download`,en:`scrapling_download`},hint:{zh:`下载文件到插件目录;还要部署侧打开 allowFileDownloads。`,en:`Download files into the plugin directory; the deployment must also set allowFileDownloads.`},fallback:!0},{key:`screenshotEnabled`,kind:`boolean`,label:{zh:`scrapling_screenshot`,en:`scrapling_screenshot`},hint:{zh:`页面截图;没有 attachment 服务时不注册。`,en:`Page screenshots; not registered when no attachment service is mounted.`},fallback:!0}]},{id:`output`,title:{zh:`抽取与输出`,en:`Extraction & output`},note:{zh:`这几个数字直接决定模型每轮看到多少 token。`,en:`These numbers are the per-call token bill the model pays.`},fields:[{key:`extractionType`,kind:`enum`,label:{zh:`默认抽取形态`,en:`Default extraction`},hint:{zh:`markdown 最省 token;html 保留标签;text 只留文字。`,en:`markdown is cheapest; html keeps tags; text keeps words only.`},fallback:`markdown`,options:[`markdown`,`html`,`text`]},{key:`mainContentOnly`,kind:`boolean`,label:{zh:`只保留正文`,en:`Main content only`},hint:{zh:`去掉导航、页脚、侧栏。开:更短更干净;关:要连同导航、按钮这类页面控件一起抓时用。`,en:`Drop nav/footer/sidebar. On for shorter output; off when you need page chrome.`},fallback:!0},{key:`fetchMaxOutputChars`,kind:`number`,label:{zh:`静态抓取正文上限`,en:`fetch output cap`},hint:{zh:`预算按 UTF-8 字节计,超出部分截断并标注;同一数值也作为 sidecar 的字符上限,最终取更紧的一档。`,en:`UTF-8 bytes; the payload is clipped and flagged. The same value also caps sidecar characters, so the tighter limit wins.`},fallback:2e5},{key:`extractMaxOutputChars`,kind:`number`,label:{zh:`抽取结果上限`,en:`extract output cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:2e5},{key:`renderMaxOutputChars`,kind:`number`,label:{zh:`渲染结果上限`,en:`render output cap`},hint:{zh:`预算按 UTF-8 字节计;会话类工具共用这一档,同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the session tools share this budget, and the same value also caps sidecar characters.`},fallback:2e5},{key:`xhrMaxOutputChars`,kind:`number`,label:{zh:`XHR 快照上限`,en:`XHR snapshot cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:12e4},{key:`crawlMaxItems`,kind:`number`,label:{zh:`爬虫默认页数上限`,en:`Crawl page cap`},hint:{zh:`爬虫工具每次调用的默认上限,模型可按次调小。`,en:`Default per-call page cap; the model may lower it per call.`},fallback:1e3},{key:`stripInlineImages`,kind:`boolean`,label:{zh:`剥掉内嵌 base64 图片`,en:`Strip inline base64 images`},hint:{zh:`默认开。内嵌 data: URI 图片对模型是纯 token 噪音——模型从 base64 里读不出任何图形信息,只留 alt 文本;代码围栏内的原样保留。没有内联图的页面不受影响。要从 base64 里取配色或指纹这类原始数据时才关掉。`,en:`On by default. Inline data: URI images are pure token noise - the model cannot read a shape out of base64, so only the alt text is kept; ones inside code fences are left alone. Pages without inline images are unaffected. Turn it off to read the raw base64 (colours, fingerprints).`},fallback:!0}]},{id:`browser`,title:{zh:`浏览器行为`,en:`Browser behaviour`},note:{zh:`影响所有走浏览器的路径:渲染、XHR 快照与会话类工具。会话里「无头运行」与「拦广告」在开场时定死,中途改不了;其余几档每次抓取各自生效。`,en:`Affects every browser path: render, XHR capture and the session tools. Inside a session, Headless and Block ads are fixed at open; the rest apply per fetch.`},fields:[{key:`headless`,kind:`boolean`,label:{zh:`无头运行`,en:`Headless`},hint:{zh:`关掉会弹出浏览器窗口,反检测站点上成功率更高。`,en:`Off shows a window and beats more anti-bot checks.`},fallback:!0},{key:`networkIdle`,kind:`boolean`,label:{zh:`等网络静默`,en:`Wait for network idle`},hint:{zh:`等到没有在途请求再返回。更准,但慢;埋了长连接的站点可能一直等不到。`,en:`Wait until no requests are in flight. Slower, and pages with long-lived sockets never settle.`},fallback:!1},{key:`blockAds`,kind:`boolean`,label:{zh:`拦截广告与追踪`,en:`Block ads and trackers`},hint:{zh:`约 3500 个已知广告域。省流量,偶尔误伤。`,en:`~3,500 known ad domains. Saves bandwidth, occasionally over-blocks.`},fallback:!0},{key:`pierceShadow`,kind:`boolean`,label:{zh:`穿透 Shadow DOM`,en:`Pierce Shadow DOM`},hint:{zh:`把 open shadow root 里的内容并进正文,默认关;页面把正文封进 shadow DOM 时才打开。`,en:`Merge open shadow root content into the body; off by default. On when a page hides its content in shadow DOM.`},fallback:!1},{key:`waitSelectorState`,kind:`enum`,label:{zh:`等待选择器的状态`,en:`Wait selector state`},hint:{zh:`配 waitSelector 用;attached 最宽松。`,en:`Used with waitSelector; attached is the loosest.`},fallback:`attached`,options:[`attached`,`detached`,`hidden`,`visible`]}]},{id:`timeouts`,title:{zh:`超时与回收`,en:`Timeouts & teardown`},note:{zh:`抓取慢若不在这几项里,先看页面上要等的东西。`,en:`If a fetch is slow for a reason other than these, look at what the page waits for.`},fields:[{key:`fetchTimeoutMs`,kind:`number`,label:{zh:`单次抓取超时(毫秒)`,en:`Per-fetch timeout (ms)`},hint:{zh:`是工具调用与 sidecar 那一帧的超时预算,也当作浏览器页面的等待预算发下去。静态路径每次请求的秒数上限另有其数:部署配置里的 requestTimeoutSeconds(默认 120,这张卡上没有这一项),模型也能按次用 timeoutSeconds 调小。`,en:`The budget for the tool call and for one sidecar frame, and the wait budget sent for browser pages. Static requests have their own cap: requestTimeoutSeconds in the deployment config (120 by default; not a field on this card), which the model can also lower per call with timeoutSeconds.`},fallback:12e4},{key:`sidecarHandshakeTimeoutMs`,kind:`number`,label:{zh:`sidecar 握手超时(毫秒)`,en:`Handshake timeout (ms)`},hint:{zh:`冷启动要拉起一个 Python 进程并导入 Scrapling。`,en:`Cold start spawns a Python process and imports Scrapling.`},fallback:3e4},{key:`sidecarGraceMs`,kind:`number`,label:{zh:`退出宽限(毫秒)`,en:`Shutdown grace (ms)`},hint:{zh:`插件卸载后等 Python 收尾的时间。`,en:`How long Python gets to finish after the plugin unloads.`},fallback:5e3}]},{id:`network`,title:{zh:`网络与安全`,en:`Network & safety`},note:{zh:`通常什么都不用填:TUN 模式的代理由系统接管,环境里的 HTTPS_PROXY 与 macOS / Windows 的「系统代理」都会被自动接上。`,en:`Usually nothing to fill: a TUN-mode proxy is taken from the system, and both HTTPS_PROXY in the environment and the macOS / Windows system proxy are picked up automatically.`},fields:[{key:`proxyUrl`,kind:`text`,format:`url`,schemes:[`http:`,`https:`,`socks5:`,`socks5h:`],secret:!0,label:{zh:`代理地址`,en:`Proxy URL`},hint:{zh:`如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass@。留空=依次跟随环境变量与系统代理设置;填了就压过那两者。值按密码遮罩显示,点「显示」可查看。`,en:`e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both. Masked like a password; press Show to reveal it.`},fallback:``},{key:`proxyBypass`,kind:`text`,label:{zh:`代理绕过清单`,en:`Proxy bypass`},hint:{zh:`逗号分隔的主机名,命中即直连;内网站点要填。整台机器直连填 *。浏览器会话不逐条生效(它的代理在开场时定死)。`,en:`Comma-separated hostnames that connect directly; list your internal sites. Use * for the whole machine. Not applied per URL inside a browser session (its proxy is fixed at open).`},fallback:``},{key:`syntheticDnsRanges`,kind:`text`,label:{zh:`合成 DNS 段(兜底)`,en:`Synthetic DNS ranges (fallback)`},hint:{zh:`平时留空:fake-ip 型代理由系统自动认出,这里只用于识别失灵时。列进来的段等于放弃对它们的 SSRF 防护。`,en:`Leave empty: fake-ip resolvers are detected automatically. Only for detection failures. Listed ranges give up SSRF protection.`},fallback:``},{key:`allowedHosts`,kind:`text`,label:{zh:`额外放行的内网主机`,en:`Extra allowed hosts`},hint:{zh:`逗号分隔。指到内网等于主动放弃对那些目标的 SSRF 防护,只在真要抓自建站点时填。`,en:`Comma-separated. Pointing these at internal hosts gives up SSRF protection for them — only for self-hosted targets.`},fallback:``},{key:`nat64Prefixes`,kind:`text`,label:{zh:`额外 NAT64 前缀`,en:`Extra NAT64 prefixes`},hint:{zh:`用运营商自建 NAT64 的网络才需要,形如 2001:4860:4860::/96。`,en:`Only for carrier-grade NAT64 networks, e.g. 2001:4860:4860::/96.`},fallback:``},{key:`provideWebFetch`,kind:`boolean`,label:{zh:`接管内置 web_fetch`,en:`Provide the built-in web_fetch`},hint:{zh:`默认开;部署配置里仍要写 fetchProvider: "scrapling",否则 base bundle 那条 fetchProvider: http 仍然赢。`,en:`On by default; the deployment config still needs fetchProvider: "scrapling", otherwise the base bundle's fetchProvider: http wins.`},fallback:!0},{key:`provideWebSearch`,kind:`boolean`,label:{zh:`接管内置 web_search`,en:`Provide the built-in web_search`},hint:{zh:`默认开;部署配置里仍要写 searchProvider: "scrapling",否则不会接管。`,en:`On by default; the deployment config still needs searchProvider: "scrapling", otherwise it does not take over.`},fallback:!0},{key:`searchBackend`,kind:`enum`,options:[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`],label:{zh:`搜索发现后端`,en:`Search discovery backend`},hint:{zh:`auto 有 Tavily key 走 Tavily、配了 SearXNG 走 SearXNG;两者都没有时,只有打开「允许公共搜索回退」才走公共 Bing —— auto 不会挑 DuckDuckGo,那档只能显式选。只有 Tavily 与 Bing 打过真实端点;其余四条按文档形状实现,真实 key 未验。`,en:`auto uses Tavily when a key is set and SearXNG when an instance is configured; with neither, only "Allow public search fallback" routes to public Bing — auto never picks DuckDuckGo, that backend has to be selected explicitly. Only Tavily and Bing have been run against the real endpoints; the other four follow their documented shapes and are unverified with real keys.`},fallback:`auto`},{key:`searchPublicFallback`,kind:`boolean`,label:{zh:`允许公共搜索回退`,en:`Allow public search fallback`},hint:{zh:`默认关。打开后 auto 后端在没配 key、也没配 SearXNG 时会回落到公共 Bing —— 查询词会发给公共引擎。`,en:`Off by default. When enabled, the auto backend falls back to public Bing if no API key or SearXNG is configured — queries are then sent to a public engine.`},fallback:!1},{key:`tavilyApiKey`,kind:`text`,secret:!0,label:{zh:`Tavily API key`,en:`Tavily API key`},hint:{zh:`Tavily 后端必填;没配时 search 报 SEARCH_AUTH,不会静默换后端。`,en:`Required by the Tavily backend; without it search reports SEARCH_AUTH instead of silently switching backends.`},fallback:``},{key:`braveApiKey`,kind:`text`,secret:!0,label:{zh:`Brave Search API key`,en:`Brave Search API key`},hint:{zh:`Brave 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Brave backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`serperApiKey`,kind:`text`,secret:!0,label:{zh:`Serper API key`,en:`Serper API key`},hint:{zh:`Serper 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Serper backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`searxngEndpoint`,kind:`text`,format:`url`,schemes:[`http:`,`https:`],secret:!0,label:{zh:`SearXNG 实例地址`,en:`SearXNG instance URL`},hint:{zh:`SearXNG 后端必填,例如 https://searx.example.com;会拼上 /search?format=json。留空表示这条后端不可用。值按密码遮罩显示,点「显示」可查看。`,en:`Required by the SearXNG backend, e.g. https://searx.example.com; /search?format=json is appended. Empty means the backend is unusable. Masked like a password; press Show to reveal it.`},fallback:``}]},{id:`answer`,title:{zh:`页面问答`,en:`Page Q&A`},note:{zh:`provider 与 model 留空跟随当前会话用的模型,不额外烧一份额度;token 上限留空用默认值。`,en:`provider and model blank follow the session's own model, costing no extra quota; the token cap falls back to its default.`},fields:[{key:`answerProvider`,kind:`text`,label:{zh:`回答用 provider`,en:`Answer provider`},hint:{zh:`留空跟随会话模型。`,en:`Blank follows the session model.`},fallback:``},{key:`answerModel`,kind:`text`,label:{zh:`回答用模型 id`,en:`Answer model id`},hint:{zh:`与 provider 一起生效。`,en:`Takes effect together with the provider.`},fallback:``},{key:`answerMaxTokens`,kind:`number`,label:{zh:`单次回答 token 上限`,en:`Answer token cap`},hint:{zh:`一次回答的输出预算。`,en:`Output budget per answer.`},fallback:2e3}]}],b=y.flatMap(e=>e.fields);b.map(e=>e.key);const x=`dshScrapling`,S={zh:{save:`保存`,saving:`保存中…`,undo:`撤销`,reveal:`显示`,conceal:`隐藏`,statusLoading:`正在读取设置…`,statusReadonly:`这个连接以只读方式运行,设置改不了。`,statusClean:`没有未保存的改动`,statusChanged:`已改动 {count} 项,未保存`,statusInvalid:`有 {count} 项填得不合法,改好后才能保存`,rejected:`保存被宿主拒绝了,设置未改动。常见原因:这一条目的配置被部署 patch 或命令行 overlay 压制(此时写下的值会在下次启动被覆盖回,宿主因此拒绝),或值没有通过 schema 校验。`,stale:`设置已经被别处改过,请重新打开这张卡再保存`,failed:`保存失败:{reason}`,runtimeTitle:`运行环境`,runtimeHint:`能力包装在数据目录的 runtime/ 下;安装是后台作业,关掉这张卡也会继续。`,runtimeUnavailable:`宿主没有提供远程读面;请在终端运行:`,runtimeJobsMissing:`这个 profile 没有作业后端;请在终端运行:`,runtimeInstall:`安装`,runtimeRepair:`修复`,runtimeCancel:`取消`,runtimePython:`解释器`,runtimeDataDir:`数据目录`,runtimeJobRunning:`正在安装 {pack}…`,runtimeJobEnded:`安装结束:{status}`,runtimeError:`安装失败:{reason}`,"runtime.state.ready":`就绪`,"runtime.state.missing":`未安装`,"runtime.state.corrupt":`文件缺失`,"runtime.state.installing":`安装中`,"runtime.state.blocked":`暂不提供`,"runtime.pack.core":`核心(Python + Scrapling)`,"runtime.pack.browser":`完整 Chromium`,"runtime.pack.search":`搜索发现`,"runtime.pack.media":`截图与下载`,"runtime.pack.adaptive-redis":`自适应存储(Redis)`,"runtime.pack.mcp":`MCP(未验证)`},en:{save:`Save`,saving:`Saving…`,undo:`Undo`,reveal:`Show`,conceal:`Hide`,statusLoading:`Reading settings…`,statusReadonly:`This connection runs read-only; settings cannot be changed here.`,statusClean:`No unsaved changes`,statusChanged:`{count} change(s) not saved yet`,statusInvalid:`{count} field(s) are not valid; fix them to save`,rejected:`The host refused the save; nothing changed. Common causes: this entry's config is overridden by a deployment patch or command-line overlay (the host refuses because anything written here would be reverted on the next boot), or the value failed schema validation.`,stale:`Settings changed elsewhere; reopen this page before saving`,failed:`Save failed: {reason}`,runtimeTitle:`Runtime`,runtimeHint:`Capability packs live under runtime/ in the data directory; installs run as background jobs and keep going when this page closes.`,runtimeUnavailable:`The host offers no remote surface; run this in a terminal:`,runtimeJobsMissing:`This profile has no jobs backend; run this in a terminal:`,runtimeInstall:`Install`,runtimeRepair:`Repair`,runtimeCancel:`Cancel`,runtimePython:`Interpreter`,runtimeDataDir:`Data directory`,runtimeJobRunning:`Installing {pack}…`,runtimeJobEnded:`Install finished: {status}`,runtimeError:`Install failed: {reason}`,"runtime.state.ready":`Ready`,"runtime.state.missing":`Not installed`,"runtime.state.corrupt":`Files missing`,"runtime.state.installing":`Installing`,"runtime.state.blocked":`Unavailable`,"runtime.pack.core":`Core (Python + Scrapling)`,"runtime.pack.browser":`Full Chromium`,"runtime.pack.search":`Search discovery`,"runtime.pack.media":`Screenshots & downloads`,"runtime.pack.adaptive-redis":`Adaptive storage (Redis)`,"runtime.pack.mcp":`MCP (unverified)`}},C={zh:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`正文`,"row.matched":`匹配`,"row.sessionCount":`会话数`,"row.session":`会话`,"row.name":`名称`,"row.type":`类型`,"row.start":`起始`,"row.pageCap":`上限`,"row.job":`作业`,"row.inspect":`在轨迹里查看`,"row.truncated":`已截断`},en:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`Body`,"row.matched":`Matched`,"row.sessionCount":`Sessions`,"row.session":`Session`,"row.name":`Name`,"row.type":`Type`,"row.start":`Start`,"row.pageCap":`Page cap`,"row.job":`Job`,"row.inspect":`Inspect this call`,"row.truncated":`Truncated`}};function w(){let e={zh:{...S.zh,...C.zh},en:{...S.en,...C.en}};for(let t of y){e.zh[`group.${t.id}.title`]=t.title.zh,e.zh[`group.${t.id}.note`]=t.note.zh,e.en[`group.${t.id}.title`]=t.title.en,e.en[`group.${t.id}.note`]=t.note.en;for(let n of t.fields)e.zh[`field.${n.key}.label`]=n.label.zh,e.zh[`field.${n.key}.hint`]=n.hint.zh,e.en[`field.${n.key}.label`]=n.label.en,e.en[`field.${n.key}.hint`]=n.hint.en}return e}const T=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`];new Set(T);const E=[`ready`,`missing`,`corrupt`,`installing`,`blocked`],D=[`running`,`stopping`,`completed`,`killed`,`failed`],O=[400,404,409,500,503];function k(e){return`runtime.state.${e}`}function A(e){return`runtime.pack.${e}`}const ee={status:`loading`,writable:!1};function te(){return ee}function ne(){return()=>void 0}function j(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function re(e,t,n,r={}){let i=r[e.key];if(i!==void 0)return i;let a=n[e.key];if(a!==void 0)return j(a);let o=t?.[e.key];return o===void 0?String(e.fallback):j(o)}const ie=t.z.enum([`true`,`false`]),ae=t.z.string().regex(/^[1-9]\d*$/u).transform(Number);function oe(e,n){let r=t.z.url().safeParse(n);if(!r.success)return{kind:`invalid`};let i=e.schemes;return i!==void 0&&!i.includes(new URL(r.data).protocol)?{kind:`invalid`}:{kind:`value`,value:r.data}}function se(e,n){if(e.kind===`boolean`){let e=ie.safeParse(n);return e.success?{kind:`value`,value:e.data===`true`}:{kind:`invalid`}}let r=n.trim();if(r===``)return{kind:`clear`};if(e.kind===`number`){let e=ae.safeParse(r);return e.success?{kind:`value`,value:e.data}:{kind:`invalid`}}if(e.kind===`enum`){let n=t.z.string().refine(t=>(e.options??[]).includes(t),{error:`取值不在字段选项内`}).safeParse(r);return n.success?{kind:`value`,value:n.data}:{kind:`invalid`}}return e.format===`url`?oe(e,r):{kind:`value`,value:r}}function ce(e){return b.filter(t=>Object.hasOwn(e,t.key)).filter(t=>e[t.key]!==void 0).map(t=>{let n=e[t.key];return n===null||n===t.fallback?{op:`unset`,path:[t.key]}:{op:`set`,path:[t.key],value:n}})}const M=`dsu-btn`,N=`dsu-hint`;function le(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`head`);return typeof Reflect.get(e,`querySelector`)==`function`&&typeof Reflect.get(e,`createElement`)==`function`&&typeof t==`object`&&!!t&&typeof Reflect.get(t,`append`)==`function`}function ue(){let e=Reflect.get(globalThis,`document`);return le(e)?e:void 0}function P(e,t,n){if(e.querySelector(`#${t}`)!=null)return()=>void 0;let r=e.createElement(`style`);return r.id=t,r.textContent=n,e.head.append(r),()=>{r.remove()}}function de(e){return P(e,`dsh-scrapling-settings-css`,`
|
|
32
|
+
r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElement)(`svg`,{className:`dsu-check`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M2.5 7.5l3 3 6-7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))));return(0,e.createElement)(u,{...t,controlId:f},(0,e.createElement)(`div`,{className:`dsu-selectWrap`,onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||w()}},(0,e.createElement)(`button`,{ref:c,type:`button`,id:f,style:{anchorName:p},className:`dsu-select dsu-input`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":n,"aria-controls":`${d}-list`,"aria-activedescendant":n&&S?`${d}-${i}`:void 0,"aria-describedby":m,"data-field":t.field,disabled:h===!0||_.length===0,onClick:()=>{n?w():T()},onKeyDown:O},(0,e.createElement)(`span`,{className:`dsu-selectValue`},b),(0,e.createElement)(`svg`,{className:`dsu-chevron`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M3 5l4 4 4-4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))),(0,e.createElement)(`div`,{ref:l,id:`${d}-list`,role:`listbox`,className:`dsu-menu`,style:{positionAnchor:p,positionTryFallbacks:`flip-block, flip-inline`},"aria-label":t.label,hidden:!n},...k)))}function m(t){let n=!t.writable||t.busy||!t.dirty,r;return r=t.error===null?t.writable?t.dirty?t.dirtyLabel:t.cleanLabel:t.readOnlyLabel:t.error,(0,e.createElement)(`div`,{className:`dsu-savebar`,"data-dirty":t.dirty},(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dsu-btnPrimary`,"data-field":`save`,disabled:n,onClick:t.onSave},t.busy?t.savingLabel:t.saveLabel),(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn`,"data-field":`discard`,disabled:n,onClick:t.onDiscard},t.revertLabel),(0,e.createElement)(`span`,{role:`status`,className:t.error===null?`dsu-status`:`dsu-status dsu-statusError`},r))}const h=e=>e.length>0&&!(e in Object.prototype);function g(e,t,n){n===void 0?e[t]=void 0:Object.defineProperty(e,t,n)}function _(e,t,n){if(!h(t))throw Error(`claimApply 的 flag 不得为空、也不得命中 Object.prototype 的成员(__proto__ 一类会让占位静默失灵或遮蔽全局成员):${t}`);let r=globalThis,i=Object.hasOwn(r,t)?r[t]:void 0;if(i===!0||typeof i==`symbol`)return!1;let a=Object.getOwnPropertyDescriptor(r,t),o=Symbol(t);r[t]=o;try{e.effect(()=>()=>{r[t]===o&&g(r,t,a)},n)}catch(e){throw r[t]===o&&g(r,t,a),e}return!0}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=[{id:`runtime`,title:{zh:`运行环境`,en:`Runtime`},note:{zh:`Python 与数据目录。装完 scrapling 之后这里一般不用动。`,en:`Python and the data directory. Usually untouched once scrapling is installed.`},fields:[{key:`pythonBin`,kind:`text`,label:{zh:`Python 解释器`,en:`Python interpreter`},hint:{zh:`留空:按「托管 runtime(macOS arm64,装过才用)→ 仓内 _env/.venv(装了才用)→ PATH 上的 python3(Windows 上是 python)」依次探测,卡面上的「运行环境」会显示命中的是哪一档;装了 pyenv/conda 时填绝对路径。`,en:`Empty: probed in order — managed runtime (macOS arm64, only once installed), the repo's _env/.venv when it exists, then python3 from PATH (python on Windows); the Runtime row shows which one won. Give an absolute path under pyenv/conda.`},fallback:``},{key:`failFastOnMissingPython`,kind:`boolean`,label:{zh:`Python 缺失时拒绝加载`,en:`Fail fast without Python`},hint:{zh:`开:Python 起不来就不注册任何工具并报错。关:只警告,工具全部消失。`,en:`On: register nothing and error out. Off: warn and register nothing.`},fallback:!0},{key:`dataDir`,kind:`text`,label:{zh:`数据目录`,en:`Data directory`},hint:{zh:`留空用 ~/.dsh-scrapling;选择器自愈的指纹库落在这里,需要可写。`,en:`Leave empty for ~/.dsh-scrapling; the adaptive selector store lives here and must be writable.`},fallback:``}]},{id:`tools`,title:{zh:`工具开关`,en:`Tools`},note:{zh:`关掉的工具不会注册给模型,也不会在会话提示里占位置。`,en:`A disabled tool is never registered with the model and leaves the system prompt too.`},fields:[{key:`fetchEnabled`,kind:`boolean`,label:{zh:`scrapling_fetch`,en:`scrapling_fetch`},hint:{zh:`curl_cffi 静态抓取。`,en:`Static fetching over curl_cffi.`},fallback:!0},{key:`extractEnabled`,kind:`boolean`,label:{zh:`scrapling_extract`,en:`scrapling_extract`},hint:{zh:`对给定 HTML 做选择器抽取,不发请求。`,en:`Extract from given HTML without any request.`},fallback:!0},{key:`locateEnabled`,kind:`boolean`,label:{zh:`scrapling_locate`,en:`scrapling_locate`},hint:{zh:`按文本、正则或相似元素定位,返回可复用的选择器。`,en:`Locate by text, regex, or similar elements and return reusable selectors.`},fallback:!0},{key:`linksEnabled`,kind:`boolean`,label:{zh:`scrapling_links`,en:`scrapling_links`},hint:{zh:`列出页面链接与下一页候选。`,en:`List page links and next-page candidates.`},fallback:!0},{key:`renderEnabled`,kind:`boolean`,label:{zh:`scrapling_render`,en:`scrapling_render`},hint:{zh:`Playwright 渲染,能读 SPA。`,en:`Playwright rendering; reads SPAs.`},fallback:!0},{key:`captureXhrEnabled`,kind:`boolean`,label:{zh:`scrapling_capture_xhr`,en:`scrapling_capture_xhr`},hint:{zh:`只回传 XHR 的 URL/状态/字节数;站点数据在接口里时用它找那个接口。`,en:`Returns XHR url/status/bytes only — use it to locate the JSON endpoint.`},fallback:!0},{key:`networkEnabled`,kind:`boolean`,label:{zh:`scrapling_session_network`,en:`scrapling_session_network`},hint:{zh:`读已开会话攒下的网络历史;会话需先用 recordNetwork 打开记录。`,en:`Read a session's recorded network history; the session must have recordNetwork on.`},fallback:!0},{key:`sessionEnabled`,kind:`boolean`,label:{zh:`scrapling_session_*`,en:`scrapling_session_*`},hint:{zh:`跨请求复用 cookie 与浏览器实例,只管 open / fetch / list / close 这一组;network 与 state_* 各自有独立开关。`,en:`Reuse cookies and the browser across requests; covers open / fetch / list / close only. The network and state_* groups have their own switches.`},fallback:!0},{key:`sessionStateEnabled`,kind:`boolean`,label:{zh:`scrapling_session_state_*`,en:`scrapling_session_state_*`},hint:{zh:`存/取浏览器登录态;需部署侧配好 sessionStateDir。`,en:`Save/load browser login state; needs a deployment-side sessionStateDir.`},fallback:!0},{key:`crawlEnabled`,kind:`boolean`,label:{zh:`scrapling_crawl`,en:`scrapling_crawl`},hint:{zh:`后台 Spider 作业,只守起始域;需 profile 带作业后端。`,en:`Background spider jobs confined to the start domain; needs a jobs backend.`},fallback:!0},{key:`answerEnabled`,kind:`boolean`,label:{zh:`scrapling_answer`,en:`scrapling_answer`},hint:{zh:`抓完页面交给模型问答。`,en:`Answer a question over a fetched page.`},fallback:!0},{key:`sessionReadEnabled`,kind:`boolean`,label:{zh:`scrapling_session_read`,en:`scrapling_session_read`},hint:{zh:`读浏览器会话当前页,不再发请求。`,en:`Read the current page of a browser session without another request.`},fallback:!0},{key:`sessionActionsEnabled`,kind:`boolean`,label:{zh:`scrapling_session_act`,en:`scrapling_session_act`},hint:{zh:`结构化浏览器动作;还要部署侧打开 allowBrowserActions。`,en:`Structured browser actions; the deployment must also set allowBrowserActions.`},fallback:!0},{key:`downloadEnabled`,kind:`boolean`,label:{zh:`scrapling_download`,en:`scrapling_download`},hint:{zh:`下载文件到插件目录;还要部署侧打开 allowFileDownloads。`,en:`Download files into the plugin directory; the deployment must also set allowFileDownloads.`},fallback:!0},{key:`screenshotEnabled`,kind:`boolean`,label:{zh:`scrapling_screenshot`,en:`scrapling_screenshot`},hint:{zh:`页面截图;没有 attachment 服务时不注册。`,en:`Page screenshots; not registered when no attachment service is mounted.`},fallback:!0}]},{id:`output`,title:{zh:`抽取与输出`,en:`Extraction & output`},note:{zh:`这几个数字直接决定模型每轮看到多少 token。`,en:`These numbers are the per-call token bill the model pays.`},fields:[{key:`extractionType`,kind:`enum`,label:{zh:`默认抽取形态`,en:`Default extraction`},hint:{zh:`markdown 最省 token;html 保留标签;text 只留文字。`,en:`markdown is cheapest; html keeps tags; text keeps words only.`},fallback:`markdown`,options:[`markdown`,`html`,`text`]},{key:`mainContentOnly`,kind:`boolean`,label:{zh:`只保留正文`,en:`Main content only`},hint:{zh:`去掉导航、页脚、侧栏。开:更短更干净;关:要连同导航、按钮这类页面控件一起抓时用。`,en:`Drop nav/footer/sidebar. On for shorter output; off when you need page chrome.`},fallback:!0},{key:`fetchMaxOutputChars`,kind:`number`,label:{zh:`静态抓取正文上限`,en:`fetch output cap`},hint:{zh:`预算按 UTF-8 字节计,超出部分截断并标注;同一数值也作为 sidecar 的字符上限,最终取更紧的一档。`,en:`UTF-8 bytes; the payload is clipped and flagged. The same value also caps sidecar characters, so the tighter limit wins.`},fallback:2e5},{key:`extractMaxOutputChars`,kind:`number`,label:{zh:`抽取结果上限`,en:`extract output cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:2e5},{key:`renderMaxOutputChars`,kind:`number`,label:{zh:`渲染结果上限`,en:`render output cap`},hint:{zh:`预算按 UTF-8 字节计;会话类工具共用这一档,同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the session tools share this budget, and the same value also caps sidecar characters.`},fallback:2e5},{key:`xhrMaxOutputChars`,kind:`number`,label:{zh:`XHR 快照上限`,en:`XHR snapshot cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:12e4},{key:`crawlMaxItems`,kind:`number`,label:{zh:`爬虫默认页数上限`,en:`Crawl page cap`},hint:{zh:`爬虫工具每次调用的默认上限,模型可按次调小。`,en:`Default per-call page cap; the model may lower it per call.`},fallback:1e3},{key:`stripInlineImages`,kind:`boolean`,label:{zh:`剥掉内嵌 base64 图片`,en:`Strip inline base64 images`},hint:{zh:`默认开。内嵌 data: URI 图片对模型是纯 token 噪音——模型从 base64 里读不出任何图形信息,只留 alt 文本;代码围栏内的原样保留。没有内联图的页面不受影响。要从 base64 里取配色或指纹这类原始数据时才关掉。`,en:`On by default. Inline data: URI images are pure token noise - the model cannot read a shape out of base64, so only the alt text is kept; ones inside code fences are left alone. Pages without inline images are unaffected. Turn it off to read the raw base64 (colours, fingerprints).`},fallback:!0}]},{id:`browser`,title:{zh:`浏览器行为`,en:`Browser behaviour`},note:{zh:`影响所有走浏览器的路径:渲染、XHR 快照与会话类工具。会话里「无头运行」与「拦广告」在开场时定死,中途改不了;其余几档每次抓取各自生效。`,en:`Affects every browser path: render, XHR capture and the session tools. Inside a session, Headless and Block ads are fixed at open; the rest apply per fetch.`},fields:[{key:`headless`,kind:`boolean`,label:{zh:`无头运行`,en:`Headless`},hint:{zh:`关掉会弹出浏览器窗口,反检测站点上成功率更高。`,en:`Off shows a window and beats more anti-bot checks.`},fallback:!0},{key:`networkIdle`,kind:`boolean`,label:{zh:`等网络静默`,en:`Wait for network idle`},hint:{zh:`等到没有在途请求再返回。更准,但慢;埋了长连接的站点可能一直等不到。`,en:`Wait until no requests are in flight. Slower, and pages with long-lived sockets never settle.`},fallback:!1},{key:`blockAds`,kind:`boolean`,label:{zh:`拦截广告与追踪`,en:`Block ads and trackers`},hint:{zh:`约 3500 个已知广告域。省流量,偶尔误伤。`,en:`~3,500 known ad domains. Saves bandwidth, occasionally over-blocks.`},fallback:!0},{key:`pierceShadow`,kind:`boolean`,label:{zh:`穿透 Shadow DOM`,en:`Pierce Shadow DOM`},hint:{zh:`把 open shadow root 里的内容并进正文,默认关;页面把正文封进 shadow DOM 时才打开。`,en:`Merge open shadow root content into the body; off by default. On when a page hides its content in shadow DOM.`},fallback:!1},{key:`waitSelectorState`,kind:`enum`,label:{zh:`等待选择器的状态`,en:`Wait selector state`},hint:{zh:`配 waitSelector 用;attached 最宽松。`,en:`Used with waitSelector; attached is the loosest.`},fallback:`attached`,options:[`attached`,`detached`,`hidden`,`visible`]}]},{id:`timeouts`,title:{zh:`超时与回收`,en:`Timeouts & teardown`},note:{zh:`抓取慢若不在这几项里,先看页面上要等的东西。`,en:`If a fetch is slow for a reason other than these, look at what the page waits for.`},fields:[{key:`fetchTimeoutMs`,kind:`number`,label:{zh:`单次抓取超时(毫秒)`,en:`Per-fetch timeout (ms)`},hint:{zh:`是工具调用与 sidecar 那一帧的超时预算,也当作浏览器页面的等待预算发下去。静态路径每次请求的秒数上限另有其数:部署配置里的 requestTimeoutSeconds(默认 120,这张卡上没有这一项),模型也能按次用 timeoutSeconds 调小。`,en:`The budget for the tool call and for one sidecar frame, and the wait budget sent for browser pages. Static requests have their own cap: requestTimeoutSeconds in the deployment config (120 by default; not a field on this card), which the model can also lower per call with timeoutSeconds.`},fallback:12e4},{key:`sidecarHandshakeTimeoutMs`,kind:`number`,label:{zh:`sidecar 握手超时(毫秒)`,en:`Handshake timeout (ms)`},hint:{zh:`冷启动要拉起一个 Python 进程并导入 Scrapling。`,en:`Cold start spawns a Python process and imports Scrapling.`},fallback:3e4},{key:`sidecarGraceMs`,kind:`number`,label:{zh:`退出宽限(毫秒)`,en:`Shutdown grace (ms)`},hint:{zh:`插件卸载后等 Python 收尾的时间。`,en:`How long Python gets to finish after the plugin unloads.`},fallback:5e3}]},{id:`network`,title:{zh:`网络与安全`,en:`Network & safety`},note:{zh:`通常什么都不用填:TUN 模式的代理由系统接管,环境里的 HTTPS_PROXY 与 macOS / Windows 的「系统代理」都会被自动接上。`,en:`Usually nothing to fill: a TUN-mode proxy is taken from the system, and both HTTPS_PROXY in the environment and the macOS / Windows system proxy are picked up automatically.`},fields:[{key:`proxyUrl`,kind:`text`,format:`url`,schemes:[`http:`,`https:`,`socks5:`,`socks5h:`],secret:!0,label:{zh:`代理地址`,en:`Proxy URL`},hint:{zh:`如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass@。留空=依次跟随环境变量与系统代理设置;填了就压过那两者。值按密码遮罩显示,点「显示」可查看。`,en:`e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both. Masked like a password; press Show to reveal it.`},fallback:``},{key:`proxyBypass`,kind:`text`,label:{zh:`代理绕过清单`,en:`Proxy bypass`},hint:{zh:`逗号分隔的主机名,命中即直连;内网站点要填。整台机器直连填 *。浏览器会话不逐条生效(它的代理在开场时定死)。`,en:`Comma-separated hostnames that connect directly; list your internal sites. Use * for the whole machine. Not applied per URL inside a browser session (its proxy is fixed at open).`},fallback:``},{key:`syntheticDnsRanges`,kind:`text`,label:{zh:`合成 DNS 段(兜底)`,en:`Synthetic DNS ranges (fallback)`},hint:{zh:`平时留空:fake-ip 型代理由系统自动认出,这里只用于识别失灵时。列进来的段等于放弃对它们的 SSRF 防护。`,en:`Leave empty: fake-ip resolvers are detected automatically. Only for detection failures. Listed ranges give up SSRF protection.`},fallback:``},{key:`allowedHosts`,kind:`text`,label:{zh:`额外放行的内网主机`,en:`Extra allowed hosts`},hint:{zh:`逗号分隔。指到内网等于主动放弃对那些目标的 SSRF 防护,只在真要抓自建站点时填。`,en:`Comma-separated. Pointing these at internal hosts gives up SSRF protection for them — only for self-hosted targets.`},fallback:``},{key:`nat64Prefixes`,kind:`text`,label:{zh:`额外 NAT64 前缀`,en:`Extra NAT64 prefixes`},hint:{zh:`用运营商自建 NAT64 的网络才需要,形如 2001:4860:4860::/96。`,en:`Only for carrier-grade NAT64 networks, e.g. 2001:4860:4860::/96.`},fallback:``},{key:`provideWebFetch`,kind:`boolean`,label:{zh:`接管内置 web_fetch`,en:`Provide the built-in web_fetch`},hint:{zh:`默认开;部署配置里仍要写 fetchProvider: "scrapling",否则 base bundle 那条 fetchProvider: http 仍然赢。`,en:`On by default; the deployment config still needs fetchProvider: "scrapling", otherwise the base bundle's fetchProvider: http wins.`},fallback:!0},{key:`provideWebSearch`,kind:`boolean`,label:{zh:`接管内置 web_search`,en:`Provide the built-in web_search`},hint:{zh:`默认开;部署配置里仍要写 searchProvider: "scrapling",否则不会接管。`,en:`On by default; the deployment config still needs searchProvider: "scrapling", otherwise it does not take over.`},fallback:!0},{key:`searchBackend`,kind:`enum`,options:[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`],label:{zh:`搜索发现后端`,en:`Search discovery backend`},hint:{zh:`auto 有 Tavily key 走 Tavily、配了 SearXNG 走 SearXNG;两者都没有时,只有打开「允许公共搜索回退」才走公共 Bing —— auto 不会挑 DuckDuckGo,那档只能显式选。只有 Tavily 与 Bing 打过真实端点;其余四条按文档形状实现,真实 key 未验。`,en:`auto uses Tavily when a key is set and SearXNG when an instance is configured; with neither, only "Allow public search fallback" routes to public Bing — auto never picks DuckDuckGo, that backend has to be selected explicitly. Only Tavily and Bing have been run against the real endpoints; the other four follow their documented shapes and are unverified with real keys.`},fallback:`auto`},{key:`searchPublicFallback`,kind:`boolean`,label:{zh:`允许公共搜索回退`,en:`Allow public search fallback`},hint:{zh:`默认关。打开后 auto 后端在没配 key、也没配 SearXNG 时会回落到公共 Bing —— 查询词会发给公共引擎。`,en:`Off by default. When enabled, the auto backend falls back to public Bing if no API key or SearXNG is configured — queries are then sent to a public engine.`},fallback:!1},{key:`tavilyApiKey`,kind:`text`,secret:!0,label:{zh:`Tavily API key`,en:`Tavily API key`},hint:{zh:`Tavily 后端必填;没配时 search 报 SEARCH_AUTH,不会静默换后端。`,en:`Required by the Tavily backend; without it search reports SEARCH_AUTH instead of silently switching backends.`},fallback:``},{key:`braveApiKey`,kind:`text`,secret:!0,label:{zh:`Brave Search API key`,en:`Brave Search API key`},hint:{zh:`Brave 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Brave backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`serperApiKey`,kind:`text`,secret:!0,label:{zh:`Serper API key`,en:`Serper API key`},hint:{zh:`Serper 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Serper backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`searxngEndpoint`,kind:`text`,format:`url`,schemes:[`http:`,`https:`],secret:!0,label:{zh:`SearXNG 实例地址`,en:`SearXNG instance URL`},hint:{zh:`SearXNG 后端必填,例如 https://searx.example.com;会拼上 /search?format=json。留空表示这条后端不可用。值按密码遮罩显示,点「显示」可查看。`,en:`Required by the SearXNG backend, e.g. https://searx.example.com; /search?format=json is appended. Empty means the backend is unusable. Masked like a password; press Show to reveal it.`},fallback:``}]},{id:`answer`,title:{zh:`页面问答`,en:`Page Q&A`},note:{zh:`provider 与 model 留空跟随当前会话用的模型,不额外烧一份额度;token 上限留空用默认值。`,en:`provider and model blank follow the session's own model, costing no extra quota; the token cap falls back to its default.`},fields:[{key:`answerProvider`,kind:`text`,label:{zh:`回答用 provider`,en:`Answer provider`},hint:{zh:`留空跟随会话模型。`,en:`Blank follows the session model.`},fallback:``},{key:`answerModel`,kind:`text`,label:{zh:`回答用模型 id`,en:`Answer model id`},hint:{zh:`与 provider 一起生效。`,en:`Takes effect together with the provider.`},fallback:``},{key:`answerMaxTokens`,kind:`number`,label:{zh:`单次回答 token 上限`,en:`Answer token cap`},hint:{zh:`一次回答的输出预算。`,en:`Output budget per answer.`},fallback:2e3}]}],b=y.flatMap(e=>e.fields);b.map(e=>e.key);const x=`dshScrapling`,S={zh:{navLabel:`scrapling 抓取`,save:`保存`,saving:`保存中…`,undo:`撤销`,reveal:`显示`,conceal:`隐藏`,statusLoading:`正在读取设置…`,statusReadonly:`这个连接以只读方式运行,设置改不了。`,statusClean:`没有未保存的改动`,statusChanged:`已改动 {count} 项,未保存`,statusInvalid:`有 {count} 项填得不合法,改好后才能保存`,rejected:`保存被宿主拒绝了,设置未改动。常见原因:这一条目的配置被部署 patch 或命令行 overlay 压制(此时写下的值会在下次启动被覆盖回,宿主因此拒绝),或值没有通过 schema 校验。`,stale:`设置已经被别处改过,请重新打开这张卡再保存`,failed:`保存失败:{reason}`,runtimeTitle:`运行环境`,runtimeHint:`能力包装在数据目录的 runtime/ 下;安装是后台作业,关掉这张卡也会继续。`,runtimeUnavailable:`宿主没有提供远程读面;请在终端运行:`,runtimeJobsMissing:`这个 profile 没有作业后端;请在终端运行:`,runtimeInstall:`安装`,runtimeRepair:`修复`,runtimeCancel:`取消`,runtimePython:`解释器`,runtimeDataDir:`数据目录`,runtimeJobRunning:`正在安装 {pack}…`,runtimeJobEnded:`安装结束:{status}`,runtimeError:`安装失败:{reason}`,"runtime.state.ready":`就绪`,"runtime.state.missing":`未安装`,"runtime.state.corrupt":`文件缺失`,"runtime.state.installing":`安装中`,"runtime.state.blocked":`暂不提供`,"runtime.pack.core":`核心(Python + Scrapling)`,"runtime.pack.browser":`完整 Chromium`,"runtime.pack.search":`搜索发现`,"runtime.pack.media":`截图与下载`,"runtime.pack.adaptive-redis":`自适应存储(Redis)`,"runtime.pack.mcp":`MCP(未验证)`},en:{navLabel:`scrapling fetch`,save:`Save`,saving:`Saving…`,undo:`Undo`,reveal:`Show`,conceal:`Hide`,statusLoading:`Reading settings…`,statusReadonly:`This connection runs read-only; settings cannot be changed here.`,statusClean:`No unsaved changes`,statusChanged:`{count} change(s) not saved yet`,statusInvalid:`{count} field(s) are not valid; fix them to save`,rejected:`The host refused the save; nothing changed. Common causes: this entry's config is overridden by a deployment patch or command-line overlay (the host refuses because anything written here would be reverted on the next boot), or the value failed schema validation.`,stale:`Settings changed elsewhere; reopen this page before saving`,failed:`Save failed: {reason}`,runtimeTitle:`Runtime`,runtimeHint:`Capability packs live under runtime/ in the data directory; installs run as background jobs and keep going when this page closes.`,runtimeUnavailable:`The host offers no remote surface; run this in a terminal:`,runtimeJobsMissing:`This profile has no jobs backend; run this in a terminal:`,runtimeInstall:`Install`,runtimeRepair:`Repair`,runtimeCancel:`Cancel`,runtimePython:`Interpreter`,runtimeDataDir:`Data directory`,runtimeJobRunning:`Installing {pack}…`,runtimeJobEnded:`Install finished: {status}`,runtimeError:`Install failed: {reason}`,"runtime.state.ready":`Ready`,"runtime.state.missing":`Not installed`,"runtime.state.corrupt":`Files missing`,"runtime.state.installing":`Installing`,"runtime.state.blocked":`Unavailable`,"runtime.pack.core":`Core (Python + Scrapling)`,"runtime.pack.browser":`Full Chromium`,"runtime.pack.search":`Search discovery`,"runtime.pack.media":`Screenshots & downloads`,"runtime.pack.adaptive-redis":`Adaptive storage (Redis)`,"runtime.pack.mcp":`MCP (unverified)`}},C={zh:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`正文`,"row.matched":`匹配`,"row.sessionCount":`会话数`,"row.session":`会话`,"row.name":`名称`,"row.type":`类型`,"row.start":`起始`,"row.pageCap":`上限`,"row.job":`作业`,"row.inspect":`在轨迹里查看`,"row.truncated":`已截断`},en:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`Body`,"row.matched":`Matched`,"row.sessionCount":`Sessions`,"row.session":`Session`,"row.name":`Name`,"row.type":`Type`,"row.start":`Start`,"row.pageCap":`Page cap`,"row.job":`Job`,"row.inspect":`Inspect this call`,"row.truncated":`Truncated`}};function w(){let e={zh:{...S.zh,...C.zh},en:{...S.en,...C.en}};for(let t of y){e.zh[`group.${t.id}.title`]=t.title.zh,e.zh[`group.${t.id}.note`]=t.note.zh,e.en[`group.${t.id}.title`]=t.title.en,e.en[`group.${t.id}.note`]=t.note.en;for(let n of t.fields)e.zh[`field.${n.key}.label`]=n.label.zh,e.zh[`field.${n.key}.hint`]=n.hint.zh,e.en[`field.${n.key}.label`]=n.label.en,e.en[`field.${n.key}.hint`]=n.hint.en}return e}const T=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`];new Set(T);const E=[`ready`,`missing`,`corrupt`,`installing`,`blocked`],D=[`running`,`stopping`,`completed`,`killed`,`failed`],O=[400,404,409,500,503];function k(e){return`runtime.state.${e}`}function A(e){return`runtime.pack.${e}`}const ee={status:`loading`,writable:!1};function te(){return ee}function ne(){return()=>void 0}function j(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function re(e,t,n,r={}){let i=r[e.key];if(i!==void 0)return i;let a=n[e.key];if(a!==void 0)return j(a);let o=t?.[e.key];return o===void 0?String(e.fallback):j(o)}const ie=t.z.enum([`true`,`false`]),ae=t.z.string().regex(/^[1-9]\d*$/u).transform(Number);function oe(e,n){let r=t.z.url().safeParse(n);if(!r.success)return{kind:`invalid`};let i=e.schemes;return i!==void 0&&!i.includes(new URL(r.data).protocol)?{kind:`invalid`}:{kind:`value`,value:r.data}}function se(e,n){if(e.kind===`boolean`){let e=ie.safeParse(n);return e.success?{kind:`value`,value:e.data===`true`}:{kind:`invalid`}}let r=n.trim();if(r===``)return{kind:`clear`};if(e.kind===`number`){let e=ae.safeParse(r);return e.success?{kind:`value`,value:e.data}:{kind:`invalid`}}if(e.kind===`enum`){let n=t.z.string().refine(t=>(e.options??[]).includes(t),{error:`取值不在字段选项内`}).safeParse(r);return n.success?{kind:`value`,value:n.data}:{kind:`invalid`}}return e.format===`url`?oe(e,r):{kind:`value`,value:r}}function ce(e){return b.filter(t=>Object.hasOwn(e,t.key)).filter(t=>e[t.key]!==void 0).map(t=>{let n=e[t.key];return n===null||n===t.fallback?{op:`unset`,path:[t.key]}:{op:`set`,path:[t.key],value:n}})}const M=`dsu-btn`,N=`dsu-hint`;function le(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`head`);return typeof Reflect.get(e,`querySelector`)==`function`&&typeof Reflect.get(e,`createElement`)==`function`&&typeof t==`object`&&!!t&&typeof Reflect.get(t,`append`)==`function`}function ue(){let e=Reflect.get(globalThis,`document`);return le(e)?e:void 0}function P(e,t,n){if(e.querySelector(`#${t}`)!=null)return()=>void 0;let r=e.createElement(`style`);return r.id=t,r.textContent=n,e.head.append(r),()=>{r.remove()}}function de(e){return P(e,`dsh-scrapling-settings-css`,`
|
|
33
33
|
.dss-secret{display:flex;gap:8px;align-items:center;width:100%}
|
|
34
34
|
.dss-reveal{flex:none;white-space:nowrap}
|
|
35
35
|
.dss-packs{display:flex;flex-direction:column;gap:8px}
|
|
@@ -116,7 +116,7 @@ r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElem
|
|
|
116
116
|
@media (prefers-reduced-motion:reduce){
|
|
117
117
|
.dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
|
|
118
118
|
}
|
|
119
|
-
`)}function fe(e,t){return e.secret===!0&&!t?`password`:`text`}function pe(t){let{field:n,label:r,shown:i,disabled:a,revealed:o,onReveal:s,t:c,onChange:l}=t,u=(0,e.createElement)(`input`,{type:fe(n,o),autoComplete:`off`,spellCheck:!1,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{l(e.target.value)}}),d=(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dss-reveal`,disabled:a,"aria-pressed":o,"aria-label":r,onClick:()=>{s()}},c(o?`conceal`:`reveal`));return(0,e.createElement)(`div`,{className:`dss-secret`},u,d)}function me(t){let{field:n,label:r,shown:i,disabled:a,onChange:o}=t;return(0,e.createElement)(`input`,{type:`text`,inputMode:`numeric`,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{o(e.target.value)}})}function he(t){let{field:r,t:i,shown:a,disabled:o,revealed:s,onReveal:c,onChange:l}=t,m=i(`field.${r.key}.label`),h={label:m,...n(i(`field.${r.key}.hint`)),field:r.key,disabled:o};return r.kind===`boolean`?(0,e.createElement)(d,{...h,checked:a===`true`,onChange:e=>{l(String(e))}}):r.kind===`enum`?(0,e.createElement)(p,{...h,value:a,options:(r.options??[]).map(e=>({value:e,label:e})),onChange:l}):r.secret===!0?(0,e.createElement)(u,h,pe({field:r,label:m,shown:a,disabled:o,revealed:s,onReveal:c,t:i,onChange:l})):r.kind===`number`?(0,e.createElement)(u,h,me({field:r,label:m,shown:a,disabled:o,onChange:l})):(0,e.createElement)(f,{...h,value:a,onChange:l})}function ge(t){let{group:n,t:r,shown:a,disabled:o,revealed:s,onReveal:c,onChange:l}=t;return(0,e.createElement)(i,{title:r(`group.${n.id}.title`),hint:r(`group.${n.id}.note`)},n.fields.map(e=>he({field:e,t:r,shown:a(e),disabled:o,revealed:s(e),onReveal:()=>{c(e)},onChange:t=>{l(e,t)}})))}function _e(e,t,n,r){return t.status===`loading`?e(`statusLoading`):r>0?e(`statusInvalid`,{count:r}):t.status===`unavailable`||!t.writable?e(`statusReadonly`):n===0?e(`statusClean`):e(`statusChanged`,{count:n})}const F={values:{},baseRevision:void 0,invalid:[],invalidText:{}};function ve(e,t){let n={...e.values};for(let e of t){let[t]=e.path;Reflect.deleteProperty(n,t)}return Object.keys(n).length===0?F:{...e,values:n,baseRevision:void 0}}function ye(t){let{t:n,saving:r,editable:i,changed:a,invalid:o,onSave:s,onUndo:c}=t;return(0,e.createElement)(m,{dirty:a>0&&o===0,busy:r,writable:i,error:o>0?n(`statusInvalid`,{count:o}):null,saveLabel:n(`save`),savingLabel:n(`saving`),revertLabel:n(`undo`),dirtyLabel:n(`statusChanged`,{count:a}),cleanLabel:n(`statusClean`),readOnlyLabel:n(`statusReadonly`),onSave:s,onDiscard:c})}function be(t){let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(``),[o,s]=(0,e.useState)(``),c=(0,e.useRef)(0),l=(0,e.useCallback)(async()=>{if(t===void 0)return;c.current+=1;let e=c.current;try{let n=await t.status();if(e!==c.current)return;r(n),s(``)}catch(t){if(e!==c.current)return;s(String(t))}},[t]),u=n?.job?.status===`running`||n?.job?.status===`stopping`;return(0,e.useEffect)(()=>{t!==void 0&&l()},[t,l]),(0,e.useEffect)(()=>{let e;return t!==void 0&&u&&(e=setInterval(()=>{l()},2e3)),()=>{e!==void 0&&clearInterval(e)}},[t,u,l]),{snapshot:n,busy:i,failure:o,act:(0,e.useCallback)((e,n)=>{t!==void 0&&(a(e),s(``),(async()=>{try{let r=n===`repair`?await t.repair(e):await t.install(e);r.ok?await l():s(r.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l]),cancel:(0,e.useCallback)(()=>{let e=n?.job;t!==void 0&&e!=null&&(a(`cancel`),s(``),(async()=>{try{let n=await t.cancel(e.id);n.ok?await l():s(n.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l,n])}}function xe(t){let{pack:n,state:r,t:i,disabled:a,running:o,activePack:s,onAct:c,onCancel:l}=t,u=i(r===null?`statusLoading`:k(r)),d=i(A(n)),f=a||o||r===null||r===`blocked`||r===`installing`,p=[(0,e.createElement)(`button`,{type:`button`,className:M,key:`install`,disabled:f||r===`ready`,onClick:()=>{c(n,`install`)}},i(`runtimeInstall`)),(0,e.createElement)(`button`,{type:`button`,className:M,key:`repair`,disabled:f||r===`missing`,onClick:()=>{c(n,`repair`)}},i(`runtimeRepair`))];return o&&s===n&&p.push((0,e.createElement)(`button`,{type:`button`,className:M,key:`cancel`,disabled:a,onClick:l},i(`runtimeCancel`))),(0,e.createElement)(`div`,{className:`dss-pack`,key:n},(0,e.createElement)(`div`,null,(0,e.createElement)(`div`,{className:`dsu-label`},d),(0,e.createElement)(`p`,{className:N},u)),(0,e.createElement)(`div`,{className:`dss-packActions`},...p))}function Se(t){let{reader:n,t:r,snapshot:a,busy:o,failure:s,onAct:c,onCancel:l}=t,u=(0,e.createElement)(`code`,{className:`dss-command`},`dsh-scrapling setup --feature <pack> --apply`),d=s===``?null:(0,e.createElement)(`p`,{className:`${N} dsu-error`,role:`alert`},r(`runtimeError`,{reason:s}));if(n===void 0)return(0,e.createElement)(i,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},(0,e.createElement)(`p`,{className:N},r(`runtimeUnavailable`)),u);let f=a?.jobsReady??!1,p=a?.job??null,m=p!==null&&(p.status===`running`||p.status===`stopping`),h=a===null?null:(0,e.createElement)(`p`,{className:N},`${r(`runtimePython`)}: ${a.python.path} (${a.python.via})`,(0,e.createElement)(`br`),`${r(`runtimeDataDir`)}: ${a.dataDir}`),g=p===null?``:r(A(p.pack)),_=p===null?null:(0,e.createElement)(`p`,{className:N},m?r(`runtimeJobRunning`,{pack:g}):r(`runtimeJobEnded`,{status:p.status})),v=p===null||p.output===``?null:(0,e.createElement)(`pre`,{className:`dss-job`},p.output),y=o!==``||!f||a===null,b=T.map(e=>xe({pack:e,state:a?.packs[e]??null,t:r,disabled:y,running:m,activePack:p?.pack??null,onAct:c,onCancel:l})),x=a!==null&&!f?(0,e.createElement)(`div`,null,(0,e.createElement)(`p`,{className:N},r(`runtimeJobsMissing`)),u):null;return(0,e.createElement)(i,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},h,d,_,v,(0,e.createElement)(`div`,{className:`dss-packs`},...b),x)}async function Ce(e){let{form:t,draft:n,ops:r,state:i,t:a,setDraft:o,setFailure:s,setSaving:c}=e;c(!0),s(``);try{await t.mutate(r,n.baseRevision)?o(e=>ve(e,r)):s(n.baseRevision!==void 0&&n.baseRevision!==i.revision?a(`stale`):a(`rejected`))}catch(e){s(a(`failed`,{reason:String(e)}))}finally{c(!1)}}function we(t){let{form:n,t:i}=t,[o,s]=(0,e.useState)(F),[c,l]=(0,e.useState)(``),[u,d]=(0,e.useState)(!1),[f,p]=(0,e.useState)([]),m=(0,e.useSyncExternalStore)(n===void 0?ne:n.subscribe,n===void 0?te:n.getSnapshot),h=be(t.runtime);if(t.view!==`page`||n===void 0)return(0,e.createElement)(r,null);let g=m.writable&&m.status===`ready`,_=ce(o.values),v=async()=>{o.invalid.length>0||_.length===0||await Ce({form:n,draft:o,ops:_,state:m,t:i,setDraft:s,setFailure:l,setSaving:d})},b=(e,t)=>{l(``);let n=se(e,t);s(r=>{let i={...r.values},a={...r.invalidText},o=r.invalid.filter(t=>t!==e.key),s=r.baseRevision??m.revision;return n.kind===`invalid`?(Reflect.deleteProperty(i,e.key),a[e.key]=t,{values:i,baseRevision:s,invalid:[...o,e.key],invalidText:a}):(Reflect.deleteProperty(a,e.key),i[e.key]=n.kind===`clear`?null:n.value,{values:i,baseRevision:s,invalid:o,invalidText:a})})},x=y.map(e=>ge({group:e,t:i,shown:e=>re(e,m.value,o.values,o.invalidText),disabled:!g||u,revealed:e=>f.includes(e.key),onReveal:e=>{p(t=>t.includes(e.key)?t.filter(t=>t!==e.key):[...t,e.key])},onChange:b})),S=ye({t:i,saving:u,editable:g,changed:_.length,invalid:o.invalid.length,onSave:()=>{v()},onUndo:()=>{s(F),p([]),l(``)}}),C=(0,e.createElement)(a,{items:[_e(i,m,_.length,o.invalid.length)]}),w=c===``?null:(0,e.createElement)(`p`,{className:`dsu-error`,role:`alert`,"aria-live":`assertive`},c);return(0,e.createElement)(r,null,C,w,...x,Se({reader:t.runtime,t:i,snapshot:h.snapshot,busy:h.busy,failure:h.failure,onAct:h.act,onCancel:h.cancel}),S)}const I=`@jayyuen66/dsh-scrapling`;function L(e,t){return e[t]}const R=`scraplingRuntime`,z=`remote.${R}`;function B(e,n){let r=e.safeParse(n);if(!r.success)throw TypeError(t.z.prettifyError(r.error));return r.data}const V=`runtime request requires a known pack`,Te=t.z.object({pack:t.z.enum(T,{error:V})},{error:V}),H=`runtime cancel requires a jobId`,Ee=t.z.object({jobId:t.z.string({error:H}).trim().min(1,{error:H})},{error:H}),U={mode:`strict`,typeSymbol:`${I}#runtime-pack-request`,create:()=>({parse(e){return B(Te,e)}})},De={mode:`strict`,typeSymbol:`${I}#runtime-cancel-request`,create:()=>({parse(e){return B(Ee,e)}})},Oe=t.z.enum(E),ke=t.z.enum(D),W=t.z.enum(T),Ae=t.z.object({id:t.z.string(),pack:W,status:ke,output:t.z.string()}),je=t.z.object({ok:t.z.literal(!0),packs:t.z.partialRecord(W,Oe),python:t.z.object({path:t.z.string(),via:t.z.string(),version:t.z.string()}),dataDir:t.z.string(),jobsReady:t.z.boolean(),job:Ae.nullable()}),Me=t.z.literal(O),G=t.z.discriminatedUnion(`ok`,[t.z.object({ok:t.z.literal(!0),jobId:t.z.string()}),t.z.object({ok:t.z.literal(!1),error:t.z.string(),status:Me})]);function K(e,t){return{id:`${I}#${R}/${e}`,service:R,namespace:R,method:e,invocation:{kind:`direct`},parameters:t,result:{mode:`src-json`}}}function q(e){return[{name:`request`,wire:`request`,source:`json`,codec:e}]}const Ne=[K(`status`,[]),K(`installPack`,q(U)),K(`repairPack`,q(U)),K(`cancelJob`,q(De))];function Pe(e){return v(e)&&typeof L(e,`$mount`)==`function`}function Fe(e){return v(e)?typeof L(e,`status`)==`function`&&typeof L(e,`installPack`)==`function`&&typeof L(e,`repairPack`)==`function`&&typeof L(e,`cancelJob`)==`function`:!1}function Ie(e){return v(e)&&typeof L(e,`ok`)==`boolean`}async function J(e,t){let n=await e;if(!Ie(n))throw TypeError(`runtime remote returned a malformed envelope: ${JSON.stringify(n)}`);if(n.ok)return B(t,n.value);throw Error(`${n.error.code}: ${n.error.message}`)}function Le(e){let t,n=async()=>{let n=e.get?.(`remote`);if(!Pe(n))throw Error(`运行环境读面不可用:宿主网关没有提供 remote 服务`);try{t??=n.$mount({package:I,descriptors:Ne}),await t}catch(e){throw t=void 0,e}let r=e.get?.(z,!1);if(!Fe(r))throw Error(`${z} 未提供:宿主网关没有挂上这枚命名空间`);return r};return{async status(){return J((await n()).status(),je)},async install(e){return J((await n()).installPack({pack:e}),G)},async repair(e){return J((await n()).repairPack({pack:e}),G)},async cancel(e){return J((await n()).cancelJob({jobId:e}),G)}}}function Re(e){return typeof e.get==`function`?Le(e):void 0}const Y=`row.session`,X=[`scrapling_fetch`,`scrapling_extract`,`scrapling_locate`,`scrapling_links`,`scrapling_render`,`scrapling_capture_xhr`,`scrapling_answer`,`scrapling_session_open`,`scrapling_session_fetch`,`scrapling_session_network`,`scrapling_session_state_save`,`scrapling_session_state_load`,`scrapling_session_list`,`scrapling_session_close`,`scrapling_crawl`,`scrapling_session_read`,`scrapling_session_act`,`scrapling_download`,`scrapling_screenshot`];function Z(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function ze(...e){for(let t of e){let e=Z(t);if(e!==``)return e}return``}function Be(e,t,n){let r=Z(t.selector);return{tool:e,title:r===``?e:`${e} ${r}`,fields:[{labelKey:`row.matched`,value:Z(n.count)}]}}function Ve(e,t,n){let r=[],i=Z(t.baseUrl);return i!==``&&r.push({labelKey:`row.url`,value:i}),r.push({labelKey:`row.matched`,value:Z(n.count)}),{tool:e,title:e,fields:r}}function Q(e,t,n){let r=v(t)?t:{},i=v(n)?n:{},a=ze(i.url,r.url);if(e===`scrapling_extract`||e===`scrapling_locate`)return Be(e,r,i);if(e===`scrapling_links`)return Ve(e,r,i);if(e===`scrapling_session_list`)return{tool:e,title:e,fields:[{labelKey:`row.sessionCount`,value:Z(i.count)}]};if(e===`scrapling_session_open`)return{tool:e,title:e,fields:[{labelKey:`row.type`,value:Z(r.sessionType)},{labelKey:Y,value:Z(i.sessionId)}]};if(e===`scrapling_session_close`)return{tool:e,title:e,fields:[{labelKey:Y,value:Z(r.sessionId)}]};if(e===`scrapling_session_network`||e===`scrapling_session_state_save`||e===`scrapling_session_state_load`){let t=[{labelKey:Y,value:Z(r.sessionId)}],n=Z(r.name);return n!==``&&t.push({labelKey:`row.name`,value:n}),{tool:e,title:e,fields:t}}if(e===`scrapling_crawl`)return{tool:e,title:e,fields:[{labelKey:`row.start`,value:a},{labelKey:`row.pageCap`,value:Z(r.maxPages)},{labelKey:`row.job`,value:Z(i.jobId)}]};let o=[];a!==``&&o.push({labelKey:`row.url`,value:a});let s=i.statusCode;return typeof s==`number`&&o.push({labelKey:`row.http`,value:String(s)}),i.truncated===!0&&o.push({labelKey:`row.body`,value:``,valueKey:`row.truncated`}),{tool:e,title:e,fields:o}}const He=[`url`,`baseUrl`,`selector`,`sessionType`,`sessionId`,`name`,`maxPages`];function $(e){if(e===void 0)return{};let t={};for(let n of He){let r=e.text(n),i=r===void 0||r.length===0?e.value(n):r;i!==void 0&&(t[n]=i)}return t}function Ue(e){return e.phase===`result`?e.block.meta:void 0}function We(t){let{toolName:n,block:r,inspect:i,t:a}=t,o=Ue(t),s=Q(n,$(r.args),o),c=[(0,e.createElement)(`div`,{className:`dsh-scrapling-rowTitle`,key:`title`},s.title)];return s.fields.length>0&&c.push((0,e.createElement)(`ul`,{className:`dsh-scrapling-rowFields`,key:`fields`},s.fields.map(t=>(0,e.createElement)(`li`,{className:`dsh-scrapling-rowField`,key:t.labelKey},(0,e.createElement)(`span`,{className:`dsh-scrapling-rowLabel`},a(t.labelKey)),(0,e.createElement)(`span`,{className:`dsh-scrapling-rowValue`},t.valueKey===void 0?t.value:a(t.valueKey)))))),i!==void 0&&c.push((0,e.createElement)(`button`,{type:`button`,className:`dsh-scrapling-rowButton`,key:`inspect`,onClick:()=>{i()}},a(`row.inspect`))),(0,e.createElement)(`div`,{className:`dsh-scrapling-row`,"data-tool":n},...c)}const Ge=[`slots`,`configForms`,`locale`];function Ke(t){let n=t.locale.bind(x),r=[];for(let i of X)r.push(t.slots.register({name:`tool.call.toolview`,key:i,locale:x},t=>(0,e.createElement)(We,{...t,t:n})));return()=>{for(let e of r)e()}}function qe(t){_(t,`__dshScraplingToolviewApplied`,`dsh-scrapling toolview`)&&(t.effect(()=>{let e=ue();if(e===void 0)return()=>void 0;let t=de(e),n=P(e,`dsh-scrapling-row-css`,`
|
|
119
|
+
`)}function fe(e,t){return e.secret===!0&&!t?`password`:`text`}function pe(t){let{field:n,label:r,shown:i,disabled:a,revealed:o,onReveal:s,t:c,onChange:l}=t,u=(0,e.createElement)(`input`,{type:fe(n,o),autoComplete:`off`,spellCheck:!1,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{l(e.target.value)}}),d=(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dss-reveal`,disabled:a,"aria-pressed":o,"aria-label":r,onClick:()=>{s()}},c(o?`conceal`:`reveal`));return(0,e.createElement)(`div`,{className:`dss-secret`},u,d)}function me(t){let{field:n,label:r,shown:i,disabled:a,onChange:o}=t;return(0,e.createElement)(`input`,{type:`text`,inputMode:`numeric`,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{o(e.target.value)}})}function he(t){let{field:r,t:i,shown:a,disabled:o,revealed:s,onReveal:c,onChange:l}=t,m=i(`field.${r.key}.label`),h={label:m,...n(i(`field.${r.key}.hint`)),field:r.key,disabled:o};return r.kind===`boolean`?(0,e.createElement)(d,{...h,checked:a===`true`,onChange:e=>{l(String(e))}}):r.kind===`enum`?(0,e.createElement)(p,{...h,value:a,options:(r.options??[]).map(e=>({value:e,label:e})),onChange:l}):r.secret===!0?(0,e.createElement)(u,h,pe({field:r,label:m,shown:a,disabled:o,revealed:s,onReveal:c,t:i,onChange:l})):r.kind===`number`?(0,e.createElement)(u,h,me({field:r,label:m,shown:a,disabled:o,onChange:l})):(0,e.createElement)(f,{...h,value:a,onChange:l})}function ge(t){let{group:n,t:r,shown:a,disabled:o,revealed:s,onReveal:c,onChange:l}=t;return(0,e.createElement)(i,{title:r(`group.${n.id}.title`),hint:r(`group.${n.id}.note`)},n.fields.map(e=>he({field:e,t:r,shown:a(e),disabled:o,revealed:s(e),onReveal:()=>{c(e)},onChange:t=>{l(e,t)}})))}function _e(e,t,n,r){return t.status===`loading`?e(`statusLoading`):r>0?e(`statusInvalid`,{count:r}):t.status===`unavailable`||!t.writable?e(`statusReadonly`):n===0?e(`statusClean`):e(`statusChanged`,{count:n})}const F={values:{},baseRevision:void 0,invalid:[],invalidText:{}};function ve(e,t){let n={...e.values};for(let e of t){let[t]=e.path;Reflect.deleteProperty(n,t)}return Object.keys(n).length===0?F:{...e,values:n,baseRevision:void 0}}function ye(t){let{t:n,saving:r,editable:i,changed:a,invalid:o,onSave:s,onUndo:c}=t;return(0,e.createElement)(m,{dirty:a>0&&o===0,busy:r,writable:i,error:o>0?n(`statusInvalid`,{count:o}):null,saveLabel:n(`save`),savingLabel:n(`saving`),revertLabel:n(`undo`),dirtyLabel:n(`statusChanged`,{count:a}),cleanLabel:n(`statusClean`),readOnlyLabel:n(`statusReadonly`),onSave:s,onDiscard:c})}function be(t){let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(``),[o,s]=(0,e.useState)(``),c=(0,e.useRef)(0),l=(0,e.useCallback)(async()=>{if(t===void 0)return;c.current+=1;let e=c.current;try{let n=await t.status();if(e!==c.current)return;r(n),s(``)}catch(t){if(e!==c.current)return;s(String(t))}},[t]),u=n?.job?.status===`running`||n?.job?.status===`stopping`;return(0,e.useEffect)(()=>{t!==void 0&&l()},[t,l]),(0,e.useEffect)(()=>{let e;return t!==void 0&&u&&(e=setInterval(()=>{l()},2e3)),()=>{e!==void 0&&clearInterval(e)}},[t,u,l]),{snapshot:n,busy:i,failure:o,act:(0,e.useCallback)((e,n)=>{t!==void 0&&(a(e),s(``),(async()=>{try{let r=n===`repair`?await t.repair(e):await t.install(e);r.ok?await l():s(r.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l]),cancel:(0,e.useCallback)(()=>{let e=n?.job;t!==void 0&&e!=null&&(a(`cancel`),s(``),(async()=>{try{let n=await t.cancel(e.id);n.ok?await l():s(n.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l,n])}}function xe(t){let{pack:n,state:r,t:i,disabled:a,running:o,activePack:s,onAct:c,onCancel:l}=t,u=i(r===null?`statusLoading`:k(r)),d=i(A(n)),f=a||o||r===null||r===`blocked`||r===`installing`,p=[(0,e.createElement)(`button`,{type:`button`,className:M,key:`install`,disabled:f||r===`ready`,onClick:()=>{c(n,`install`)}},i(`runtimeInstall`)),(0,e.createElement)(`button`,{type:`button`,className:M,key:`repair`,disabled:f||r===`missing`,onClick:()=>{c(n,`repair`)}},i(`runtimeRepair`))];return o&&s===n&&p.push((0,e.createElement)(`button`,{type:`button`,className:M,key:`cancel`,disabled:a,onClick:l},i(`runtimeCancel`))),(0,e.createElement)(`div`,{className:`dss-pack`,key:n},(0,e.createElement)(`div`,null,(0,e.createElement)(`div`,{className:`dsu-label`},d),(0,e.createElement)(`p`,{className:N},u)),(0,e.createElement)(`div`,{className:`dss-packActions`},...p))}function Se(t){let{reader:n,t:r,snapshot:a,busy:o,failure:s,onAct:c,onCancel:l}=t,u=(0,e.createElement)(`code`,{className:`dss-command`},`dsh-scrapling setup --feature <pack> --apply`),d=s===``?null:(0,e.createElement)(`p`,{className:`${N} dsu-error`,role:`alert`},r(`runtimeError`,{reason:s}));if(n===void 0)return(0,e.createElement)(i,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},(0,e.createElement)(`p`,{className:N},r(`runtimeUnavailable`)),u);let f=a?.jobsReady??!1,p=a?.job??null,m=p!==null&&(p.status===`running`||p.status===`stopping`),h=a===null?null:(0,e.createElement)(`p`,{className:N},`${r(`runtimePython`)}: ${a.python.path} (${a.python.via})`,(0,e.createElement)(`br`),`${r(`runtimeDataDir`)}: ${a.dataDir}`),g=p===null?``:r(A(p.pack)),_=p===null?null:(0,e.createElement)(`p`,{className:N},m?r(`runtimeJobRunning`,{pack:g}):r(`runtimeJobEnded`,{status:p.status})),v=p===null||p.output===``?null:(0,e.createElement)(`pre`,{className:`dss-job`},p.output),y=o!==``||!f||a===null,b=T.map(e=>xe({pack:e,state:a?.packs[e]??null,t:r,disabled:y,running:m,activePack:p?.pack??null,onAct:c,onCancel:l})),x=a!==null&&!f?(0,e.createElement)(`div`,null,(0,e.createElement)(`p`,{className:N},r(`runtimeJobsMissing`)),u):null;return(0,e.createElement)(i,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},h,d,_,v,(0,e.createElement)(`div`,{className:`dss-packs`},...b),x)}async function Ce(e){let{form:t,draft:n,ops:r,state:i,t:a,setDraft:o,setFailure:s,setSaving:c}=e;c(!0),s(``);try{await t.mutate(r,n.baseRevision)?o(e=>ve(e,r)):s(n.baseRevision!==void 0&&n.baseRevision!==i.revision?a(`stale`):a(`rejected`))}catch(e){s(a(`failed`,{reason:String(e)}))}finally{c(!1)}}function I(t){let{form:n,t:i}=t,[o,s]=(0,e.useState)(F),[c,l]=(0,e.useState)(``),[u,d]=(0,e.useState)(!1),[f,p]=(0,e.useState)([]),m=(0,e.useSyncExternalStore)(n===void 0?ne:n.subscribe,n===void 0?te:n.getSnapshot),h=be(t.runtime);if(t.view!==`page`||n===void 0)return(0,e.createElement)(r,null);let g=m.writable&&m.status===`ready`,_=ce(o.values),v=async()=>{o.invalid.length>0||_.length===0||await Ce({form:n,draft:o,ops:_,state:m,t:i,setDraft:s,setFailure:l,setSaving:d})},b=(e,t)=>{l(``);let n=se(e,t);s(r=>{let i={...r.values},a={...r.invalidText},o=r.invalid.filter(t=>t!==e.key),s=r.baseRevision??m.revision;return n.kind===`invalid`?(Reflect.deleteProperty(i,e.key),a[e.key]=t,{values:i,baseRevision:s,invalid:[...o,e.key],invalidText:a}):(Reflect.deleteProperty(a,e.key),i[e.key]=n.kind===`clear`?null:n.value,{values:i,baseRevision:s,invalid:o,invalidText:a})})},x=y.map(e=>ge({group:e,t:i,shown:e=>re(e,m.value,o.values,o.invalidText),disabled:!g||u,revealed:e=>f.includes(e.key),onReveal:e=>{p(t=>t.includes(e.key)?t.filter(t=>t!==e.key):[...t,e.key])},onChange:b})),S=ye({t:i,saving:u,editable:g,changed:_.length,invalid:o.invalid.length,onSave:()=>{v()},onUndo:()=>{s(F),p([]),l(``)}}),C=(0,e.createElement)(a,{items:[_e(i,m,_.length,o.invalid.length)]}),w=c===``?null:(0,e.createElement)(`p`,{className:`dsu-error`,role:`alert`,"aria-live":`assertive`},c);return(0,e.createElement)(r,null,C,w,...x,Se({reader:t.runtime,t:i,snapshot:h.snapshot,busy:h.busy,failure:h.failure,onAct:h.act,onCancel:h.cancel}),S)}const L=`@jayyuen66/dsh-scrapling`;function R(e,t){return e[t]}const z=`scraplingRuntime`,B=`remote.${z}`;function V(e,n){let r=e.safeParse(n);if(!r.success)throw TypeError(t.z.prettifyError(r.error));return r.data}const H=`runtime request requires a known pack`,we=t.z.object({pack:t.z.enum(T,{error:H})},{error:H}),U=`runtime cancel requires a jobId`,Te=t.z.object({jobId:t.z.string({error:U}).trim().min(1,{error:U})},{error:U}),W={mode:`strict`,typeSymbol:`${L}#runtime-pack-request`,create:()=>({parse(e){return V(we,e)}})},Ee={mode:`strict`,typeSymbol:`${L}#runtime-cancel-request`,create:()=>({parse(e){return V(Te,e)}})},De=t.z.enum(E),Oe=t.z.enum(D),G=t.z.enum(T),ke=t.z.object({id:t.z.string(),pack:G,status:Oe,output:t.z.string()}),Ae=t.z.object({ok:t.z.literal(!0),packs:t.z.partialRecord(G,De),python:t.z.object({path:t.z.string(),via:t.z.string(),version:t.z.string()}),dataDir:t.z.string(),jobsReady:t.z.boolean(),job:ke.nullable()}),je=t.z.literal(O),K=t.z.discriminatedUnion(`ok`,[t.z.object({ok:t.z.literal(!0),jobId:t.z.string()}),t.z.object({ok:t.z.literal(!1),error:t.z.string(),status:je})]);function q(e,t){return{id:`${L}#${z}/${e}`,service:z,namespace:z,method:e,invocation:{kind:`direct`},parameters:t,result:{mode:`src-json`}}}function J(e){return[{name:`request`,wire:`request`,source:`json`,codec:e}]}const Me=[q(`status`,[]),q(`installPack`,J(W)),q(`repairPack`,J(W)),q(`cancelJob`,J(Ee))];function Ne(e){return v(e)&&typeof R(e,`$mount`)==`function`}function Pe(e){return v(e)?typeof R(e,`status`)==`function`&&typeof R(e,`installPack`)==`function`&&typeof R(e,`repairPack`)==`function`&&typeof R(e,`cancelJob`)==`function`:!1}function Fe(e){return v(e)&&typeof R(e,`ok`)==`boolean`}async function Y(e,t){let n=await e;if(!Fe(n))throw TypeError(`runtime remote returned a malformed envelope: ${JSON.stringify(n)}`);if(n.ok)return V(t,n.value);throw Error(`${n.error.code}: ${n.error.message}`)}function Ie(e){let t,n=async()=>{let n=e.get?.(`remote`);if(!Ne(n))throw Error(`运行环境读面不可用:宿主网关没有提供 remote 服务`);try{t??=n.$mount({package:L,descriptors:Me}),await t}catch(e){throw t=void 0,e}let r=e.get?.(B,!1);if(!Pe(r))throw Error(`${B} 未提供:宿主网关没有挂上这枚命名空间`);return r};return{async status(){return Y((await n()).status(),Ae)},async install(e){return Y((await n()).installPack({pack:e}),K)},async repair(e){return Y((await n()).repairPack({pack:e}),K)},async cancel(e){return Y((await n()).cancelJob({jobId:e}),K)}}}function Le(e){return typeof e.get==`function`?Ie(e):void 0}const X=`data:image/png;base64,${(/* @__PURE__ */ `iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAQAAAD41aSMAAATrElEQVR42u1dC3hVx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ZrKxjW53Njyzrgpj+EHcn886FHRzl907/6P475E7ku/z3qTbVd6T6A+F7oZTu3vJaEHqHhEIGBDrAJAP1o5FcNnUm840iODuB677o/Ris9M3Qi9OhZA5TuA7h8eGM/F2KDwacVy8fWTuhfEs78AjDOBf3bgamS+bc2V4JhrjleBWVfDaAbQvKl2zM9th+jTEwcxzQRk38ZQkd6DhQSr66T3IWJXpKJqPw7KW6tka7K5t/e232UF7nrAC6La/J6pVcGM71Ocw241MzGlJnTN8vjcrFiV7nY3ftHt6p175KY2YdtFQ0UKWaZ5ZV/o81jQ1le3PRXcmaqc1UfbWWQUJkJ8dtyby7I6Q0YBvYITS2PGqE+SiUIySyEbsdWiJPd0FKsGZki5nSyGjK79l4SrBwAcF0YJN4NF6z8wslTdr0+UD8vaLJJ1imHIN93JGr1prf9HaoxEYceG39cGioWFKZ9olu8IvD7R9/589RR5EYSHmdBs8j7Y6/Nn613oj22yuufydf3Kw+q9Q2Pvc4rFF+CUevlqdOp6melE+15aKR4a6J18kPnh7nqYLUTHetglofCBAAAAAIAABAAAIAAAAAEAAAgAAAAAcBo8zgT1XPHurF5F/w5AaQTe9KWIJwTQDWY/KHa0FFGAEwqkibP3kzdn7Gr7exPkwZfM8PfznUOAJvZod33jBIm/1/97292PKWHwT/VH6lMAWB3FsQA0OvTzt5veobaptr9+hAAvCh3+xTq8f2//xlT93ZtZQCA/XNA9nJM3qkbUc9U24y/L3ZoFpyvwndsFpxxnevUNfbnXOc6dIXxOdvRnTuvf5yz1VACwK5Cy5cZ0IxjHYAAAAAEAAAAABMAAAAIAABAAAAA2l//ANBt5HCfcxVrAAAAAElFTkSuQmCC`,Q=`row.session`,Re=`dsh-scrapling`,ze=[`scrapling_fetch`,`scrapling_extract`,`scrapling_locate`,`scrapling_links`,`scrapling_render`,`scrapling_capture_xhr`,`scrapling_answer`,`scrapling_session_open`,`scrapling_session_fetch`,`scrapling_session_network`,`scrapling_session_state_save`,`scrapling_session_state_load`,`scrapling_session_list`,`scrapling_session_close`,`scrapling_crawl`,`scrapling_session_read`,`scrapling_session_act`,`scrapling_download`,`scrapling_screenshot`];function $(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function Be(...e){for(let t of e){let e=$(t);if(e!==``)return e}return``}function Ve(e,t,n){let r=$(t.selector);return{tool:e,title:r===``?e:`${e} ${r}`,fields:[{labelKey:`row.matched`,value:$(n.count)}]}}function He(e,t,n){let r=[],i=$(t.baseUrl);return i!==``&&r.push({labelKey:`row.url`,value:i}),r.push({labelKey:`row.matched`,value:$(n.count)}),{tool:e,title:e,fields:r}}function Ue(e,t,n){let r=v(t)?t:{},i=v(n)?n:{},a=Be(i.url,r.url);if(e===`scrapling_extract`||e===`scrapling_locate`)return Ve(e,r,i);if(e===`scrapling_links`)return He(e,r,i);if(e===`scrapling_session_list`)return{tool:e,title:e,fields:[{labelKey:`row.sessionCount`,value:$(i.count)}]};if(e===`scrapling_session_open`)return{tool:e,title:e,fields:[{labelKey:`row.type`,value:$(r.sessionType)},{labelKey:Q,value:$(i.sessionId)}]};if(e===`scrapling_session_close`)return{tool:e,title:e,fields:[{labelKey:Q,value:$(r.sessionId)}]};if(e===`scrapling_session_network`||e===`scrapling_session_state_save`||e===`scrapling_session_state_load`){let t=[{labelKey:Q,value:$(r.sessionId)}],n=$(r.name);return n!==``&&t.push({labelKey:`row.name`,value:n}),{tool:e,title:e,fields:t}}if(e===`scrapling_crawl`)return{tool:e,title:e,fields:[{labelKey:`row.start`,value:a},{labelKey:`row.pageCap`,value:$(r.maxPages)},{labelKey:`row.job`,value:$(i.jobId)}]};let o=[];a!==``&&o.push({labelKey:`row.url`,value:a});let s=i.statusCode;return typeof s==`number`&&o.push({labelKey:`row.http`,value:String(s)}),i.truncated===!0&&o.push({labelKey:`row.body`,value:``,valueKey:`row.truncated`}),{tool:e,title:e,fields:o}}const We=[`url`,`baseUrl`,`selector`,`sessionType`,`sessionId`,`name`,`maxPages`];function Ge(e){if(e===void 0)return{};let t={};for(let n of We){let r=e.text(n),i=r===void 0||r.length===0?e.value(n):r;i!==void 0&&(t[n]=i)}return t}function Ke(e){return e.phase===`result`?e.block.meta:void 0}const qe=`
|
|
120
120
|
.dsh-scrapling-row{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
121
121
|
.dsh-scrapling-rowTitle{color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
122
122
|
.dsh-scrapling-rowFields{display:flex;flex-wrap:wrap;gap:2px 12px;margin:0;padding:0;list-style:none}
|
|
@@ -126,7 +126,11 @@ r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElem
|
|
|
126
126
|
.dsh-scrapling-rowButton{align-self:flex-start;border:0;background:0 0;padding:0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:12px;cursor:pointer}
|
|
127
127
|
.dsh-scrapling-rowButton:hover{color:var(--dsw-alias-label-primary)}
|
|
128
128
|
.dsh-scrapling-rowButton:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
129
|
-
|
|
129
|
+
.dsh-scrapling-page{padding:4px 0 8px}
|
|
130
|
+
.dsh-scrapling-icon{position:relative;display:inline-block;flex:none}
|
|
131
|
+
.dsh-scrapling-iconLayer{position:absolute;inset:0;background-color:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-image:url(${X});mask-image:url(${X})}
|
|
132
|
+
.dsh-scrapling-iconAccent{position:absolute;inset:0;background-color:#B3FB2A;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-image:url(${Z});mask-image:url(${Z})}
|
|
133
|
+
`;function Je(t){let{toolName:n,block:r,inspect:i,t:a}=t,o=Ke(t),s=Ue(n,Ge(r.args),o),c=[(0,e.createElement)(`div`,{className:`dsh-scrapling-rowTitle`,key:`title`},s.title)];return s.fields.length>0&&c.push((0,e.createElement)(`ul`,{className:`dsh-scrapling-rowFields`,key:`fields`},s.fields.map(t=>(0,e.createElement)(`li`,{className:`dsh-scrapling-rowField`,key:t.labelKey},(0,e.createElement)(`span`,{className:`dsh-scrapling-rowLabel`},a(t.labelKey)),(0,e.createElement)(`span`,{className:`dsh-scrapling-rowValue`},t.valueKey===void 0?t.value:a(t.valueKey)))))),i!==void 0&&c.push((0,e.createElement)(`button`,{type:`button`,className:`dsh-scrapling-rowButton`,key:`inspect`,onClick:()=>{i()}},a(`row.inspect`))),(0,e.createElement)(`div`,{className:`dsh-scrapling-row`,"data-tool":n},...c)}const Ye=[`slots`,`configForms`,`locale`];function Xe(t){let n=t.locale.bind(x),r=[];for(let i of ze)r.push(t.slots.register({name:`tool.call.toolview`,key:i,locale:x},t=>(0,e.createElement)(Je,{...t,t:n})));return()=>{for(let e of r)e()}}function Ze(t){let n={width:t.size,height:t.size};return(0,e.createElement)(`span`,{className:`dsh-scrapling-icon`,style:n,"aria-hidden":!0,"data-scrapling-section-icon":t.active?`active`:`idle`},(0,e.createElement)(`span`,{className:`dsh-scrapling-iconLayer`,style:n}),(0,e.createElement)(`span`,{className:`dsh-scrapling-iconAccent`,style:n}))}function Qe(t){return(0,e.createElement)(`div`,{className:`dsh-scrapling-page`},(0,e.createElement)(I,{view:`page`,t:t.t,form:t.form,runtime:t.runtime}))}function $e(t){_(t,`__dshScraplingToolviewApplied`,`dsh-scrapling toolview`)&&(t.effect(()=>{let e=ue();if(e===void 0)return()=>void 0;let t=de(e),n=P(e,`dsh-scrapling-row-css`,qe);return()=>{t(),n()}},`dsh-scrapling: client styles`),t.effect(()=>{let e=w(),n=[t.locale.register(x,`zh`,e.zh),t.locale.register(x,`en`,e.en)],r;return t.slots.inject(`tool.call.toolview`,()=>{r=Xe(t)}),()=>{r?.();for(let e of n)e()}},`dsh-scrapling: dictionaries and tool rows`),t.effect(()=>{let n=t.configForms.get(`scrapling`),r=t.locale.bind(x),i={getSnapshot:()=>n.getSnapshot(),subscribe:e=>n.subscribe(e),mutate:(e,t)=>n.mutate(e,t)},a=Le(t),o=()=>({t:r,form:i,runtime:a}),s;t.slots.inject(`plugins.bundle.config`,()=>{s=t.slots.register({name:`plugins.bundle.config`,key:`@jayyuen66/dsh-scrapling`,locale:x},t=>(0,e.createElement)(I,{...t,...o()}))});let c;t.slots.inject(`settings.section`,()=>{c=t.slots.register({name:`settings.section`,id:Re,order:30,label:()=>r(`navLabel`),locale:x,inject:o},Qe)});let l;return t.slots.inject(`settings.section.icon`,()=>{l=t.slots.register({name:`settings.section.icon`,id:Re,order:30},Ze)}),()=>{s?.(),c?.(),l?.()}},`dsh-scrapling: settings card`))}exports.ROW_TOOLS=ze,exports.apply=$e,exports.buildRow=Ue,exports.inject=Ye,exports.readArgs=Ge,exports.resultMetaOf=Ke;
|
|
130
134
|
return module.exports;
|
|
131
135
|
},
|
|
132
136
|
});
|
package/docs/DETAIL.md
CHANGED
|
@@ -7,7 +7,7 @@ Fetches and extracts web pages — JavaScript rendering, CSS/XPath extraction wi
|
|
|
7
7
|
Fifty card values grouped by purpose; most are read per call, so a change applies on the next tool call. The values read once when the plugin is assembled need it assembled again — restart the host. That set is: the fifteen tool switches, `provideWebFetch` / `provideWebSearch` together with everything the search provider snapshots alongside them (`searchBackend`, the per-vendor keys, `searxngEndpoint`, `fetchMaxOutputChars`, `fetchTimeoutMs`), plus `pythonBin`, `failFastOnMissingPython` and `dataDir`.
|
|
8
8
|
|
|
9
9
|
- **Runtime** — `pythonBin` (empty) chooses the interpreter: an explicit path wins, then the managed capability install, then this package's development venv, then `python3` on PATH (`python` on Windows). The managed leg is only tried on macOS arm64 — the one platform with a verified capability pack — and every other platform goes straight from the explicit path to the venv and PATH legs. The plugin logs which one it picked every time. `failFastOnMissingPython` (on) refuses to load when the sidecar cannot start; an interpreter that starts but lacks Scrapling always degrades to "tools unavailable" and names the path. `dataDir` is where the sidecar's state lives.
|
|
10
|
-
- **Tool switches** — fifteen of them (fetch, extract, locate, links, render, capture XHR, network history, session, session state, crawl, answer, session read, session actions, download, screenshot). Turning one off removes that tool from the model's view, and
|
|
10
|
+
- **Tool switches** — fifteen of them (fetch, extract, locate, links, render, capture XHR, network history, session, session state, crawl, answer, session read, session actions, download, screenshot). Turning one off removes that tool from the model's view, and its guidance line disappears from the skill body too; what stays resident in the system prompt is one cross-tool selection summary (naming no specific tool), while the full text is recomputed at composition time against the tools actually registered and registered as the virtual skill `scrapling`.
|
|
11
11
|
- **Extraction and output** — `extractionType` (markdown/html/text), `mainContentOnly`, `stripInlineImages` (on) and the per-tool output budgets: `fetchMaxOutputChars`, `extractMaxOutputChars` and `renderMaxOutputChars` default to 200000, `xhrMaxOutputChars` to 120000. The host trims that number as UTF-8 **bytes**; the same number goes to the sidecar as `maxContentChars`, which clips by **characters** — so the tighter of the two is what you see. `crawlMaxItems` (1000) caps pages, not output size.
|
|
12
12
|
- **Browser** — `headless` (on), `networkIdle` (off), `blockAds` (on, about 3500 domains), `pierceShadow` (off), `waitSelectorState`.
|
|
13
13
|
- **Timeouts and recycling** — `fetchTimeoutMs` (120000), `sidecarHandshakeTimeoutMs` (30000), `sidecarGraceMs` (5000).
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
卡上五十个取值按用途分组,多数每次调用现读,改完下一次调用就生效。另有几项只在装配时读一次,改完要让插件重新装配——重启宿主即可。这几项是:十五个工具开关、`provideWebFetch` / `provideWebSearch` 以及与它们一起被检索 provider 快照的 `searchBackend`、各家 key、`searxngEndpoint`、`fetchMaxOutputChars`、`fetchTimeoutMs`,再加上 `pythonBin`、`failFastOnMissingPython` 与 `dataDir`。
|
|
8
8
|
|
|
9
9
|
- **运行环境** — `pythonBin`(留空)决定用哪个解释器:显式路径优先,其次托管的能力包安装,再次本包的开发 venv,最后落回 PATH 上的 `python3`(Windows 上是 `python`)。托管那一档只在 macOS arm64 上尝试——有已验能力包的就这一个平台——其余平台从显式路径直接跳到 venv 与 PATH。每次都会播报选中的是哪一支。`failFastOnMissingPython`(默认开)让 sidecar 起不来时直接拒绝装载;而解释器起得来但没装 Scrapling 时,一律降级成「工具不可用」并在日志里点名路径。`dataDir` 是 sidecar 状态的位置。
|
|
10
|
-
- **工具开关** — 十五个(fetch、extract、locate、links、render、capture XHR、会话网络历史、session、登录态、crawl、answer、session read、页面动作、download、screenshot
|
|
10
|
+
- **工具开关** — 十五个(fetch、extract、locate、links、render、capture XHR、会话网络历史、session、登录态、crawl、answer、session read、页面动作、download、screenshot)。关掉一个就是模型看不见它,它那句指引也跟着从 skill 正文里消失;常驻 system prompt 里只留一段跨工具的选型摘要(不点名具体工具),全文按装配时真注册了哪些工具现算后注册成虚拟 skill `scrapling`。
|
|
11
11
|
- **抽取与输出** — `extractionType`(markdown/html/text)、`mainContentOnly`、`stripInlineImages`(默认开),以及各工具的输出预算:`fetchMaxOutputChars`、`extractMaxOutputChars`、`renderMaxOutputChars` 默认 200000,`xhrMaxOutputChars` 默认 120000。宿主侧按 UTF-8 **字节**裁剪,同一个数值交给 sidecar 时叫 `maxContentChars`,那边按**字符**截——两处谁更紧就按谁收。`crawlMaxItems`(1000)管的是页数,不是输出大小。
|
|
12
12
|
- **浏览器** — `headless`(默认开)、`networkIdle`(默认关)、`blockAds`(默认开,约 3500 个域名)、`pierceShadow`(默认关)、`waitSelectorState`。
|
|
13
13
|
- **超时与回收** — `fetchTimeoutMs`(120000)、`sidecarHandshakeTimeoutMs`(30000)、`sidecarGraceMs`(5000)。
|