mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-09-05 19:23:51 +08:00
fix(web-access): 强制 Windows 隔离 Playwright 环境 (#96)
## 中文 - 将 web-access 升级到 v3.4.2。 - L3-external 必须先创建或选择 DesireCore 隔离 venv,再进行 import、固定版本安装、复检和 CDP attach。 - Windows 全流程只允许 PowerShell 与 venv 的 Scripts\\python.exe;禁止 Bash、裸 python/pip、pip --user、全局安装和 playwright install。 - 修正中英文 L3 汇总表,避免后置表格覆盖前置安全规则。 验证:完整 i18n validator、translation freshness、validator unit 均通过;独立复审无 P0-P2。 ## English - Bump web-access to v3.4.2. - Require creating or selecting the DesireCore-owned isolated venv before import checks, pinned installation, re-check, and CDP attach. - On Windows, require PowerShell and the venv Scripts\\python.exe throughout; forbid Bash, bare python/pip, pip --user, global installation, and playwright install. - Align both localized L3 summary tables so later guidance cannot override the safety contract. Validation: full i18n validation, translation freshness, and validator unit tests pass; independent review found no P0-P2 findings.
This commit is contained in:
@@ -15,7 +15,7 @@ description: >-
|
||||
新闻、网址、URL、找一下、搜一下、查一下、小红书、B站、微博、飞书、Twitter、
|
||||
推特、X、知乎、公众号、已登录、登录状态。
|
||||
license: Complete terms in LICENSE.txt
|
||||
version: 3.4.1
|
||||
version: 3.4.2
|
||||
type: procedural
|
||||
risk_level: low
|
||||
status: enabled
|
||||
@@ -54,14 +54,14 @@ metadata:
|
||||
short_desc: 联网搜索、网页抓取、内置受管浏览器登录态访问与取文、研究调研工作流
|
||||
description: 联网访问工具包——搜索公开页面、Jina 优化抓取、内置受管浏览器完成登录态访问与取文,以及用户点名时接管他自己的 Chrome/Edge/Chromium。
|
||||
body: ./SKILL.zh-CN.md
|
||||
source_hash: sha256:efcfd466dd6026a0
|
||||
source_hash: sha256:b12669d544fe2c7e
|
||||
translated_by: human
|
||||
en-US:
|
||||
name: Web Access
|
||||
short_desc: Web search, page fetching, logged-in access via the governed built-in browser, research workflows
|
||||
description: A web-access toolkit — search public pages, fetch heavy pages via Jina Reader, reach and read logged-in sites through the governed built-in browser, and drive the user's named Chrome/Edge/Chromium over CDP on request.
|
||||
body: ./SKILL.md
|
||||
source_hash: sha256:efcfd466dd6026a0
|
||||
source_hash: sha256:b12669d544fe2c7e
|
||||
translated_by: human
|
||||
market:
|
||||
icon: >-
|
||||
@@ -192,11 +192,13 @@ Only close the page you opened. Full recipes in [references/cdp-browser.md](refe
|
||||
|
||||
After a `ready` probe, identify the current OS **before** creating or running an attach script:
|
||||
|
||||
1. Check whether the selected Python interpreter can import Playwright. A missing dependency is
|
||||
separate from browser readiness: report it explicitly and do not attach yet.
|
||||
2. Keep Playwright in a DesireCore-owned isolated virtual environment. Never install it globally and
|
||||
never run `playwright install`; CDP attach reuses the browser that is already running.
|
||||
3. On Unix-like hosts, use Bash paths and shell syntax. On Windows, use the `PowerShell` tool and a
|
||||
1. **Create or select the DesireCore-owned isolated venv first.** Do not probe a global interpreter
|
||||
for Playwright. A system/bootstrap Python may only run `-m venv` when the venv does not exist.
|
||||
2. From that point onward, use only the venv interpreter for import, pinned install, re-import, and
|
||||
attach. Never use bare `python`, bare `pip`, `pip --user`, a global install, or `playwright install`.
|
||||
A missing dependency is separate from browser readiness: report it explicitly and do not attach yet.
|
||||
3. On Unix-like hosts, use Bash paths and shell syntax. On Windows, every command in this flow must use
|
||||
the `PowerShell` tool and the venv's `Scripts\python.exe`; do not call the `Bash` tool. Use a
|
||||
PowerShell here-string plus `[IO.File]::WriteAllText(...)` to create the temporary `.py` file.
|
||||
**Never send `cat <<EOF`, `/tmp/...`, or another POSIX heredoc to PowerShell.**
|
||||
4. Invoke the virtual environment's platform-specific Python (`bin/python` on Unix,
|
||||
@@ -299,7 +301,7 @@ When what they asked for and what you're giving differ, the wording has to make
|
||||
| L1 | Public, static | `WebFetch` | Low |
|
||||
| L2 | JS-heavy, long articles, token savings | `Bash curl r.jina.ai` | **Lowest** (Markdown pre-cleaned) |
|
||||
| **L3** | **Login-gated navigation, interaction & extraction (PRIMARY)** | **built-in browser (BrowserManage / BrowserAct / BrowserSnapshot / BrowserScript)** | Medium |
|
||||
| L3-external | **User named their own browser**, or explicitly accepted this route after you explained why it is needed | `BrowserExternalProbe` → `Bash + Python Playwright connect_over_cdp` (see references/cdp-browser.md) | Medium |
|
||||
| L3-external | **User named their own browser**, or explicitly accepted this route after you explained why it is needed | `BrowserExternalProbe` → platform-native shell (`PowerShell` on Windows) + DesireCore isolated venv + Playwright `connect_over_cdp` (see references/cdp-browser.md) | Medium |
|
||||
|
||||
**Default priority**: L1 for simple public pages → L2 for heavy → **L3 for login-gated (body text and in-site API data included)**.
|
||||
|
||||
|
||||
@@ -107,9 +107,9 @@ If any fetch fails, explicitly tell the user which URL failed and which fallback
|
||||
|
||||
probe 返回 `ready` 后,创建或执行 attach 脚本前**必须先确认当前操作系统**:
|
||||
|
||||
1. 先检查选定的 Python 能否 import Playwright。依赖缺失与浏览器 ready 是两件事:明确报告缺失,暂不 attach。
|
||||
2. Playwright 只能装进 DesireCore 拥有的隔离 venv;不得全局安装,也不得运行 `playwright install`,因为 CDP attach 复用已运行浏览器。
|
||||
3. Unix-like 主机使用 Bash 路径和语法;Windows 必须使用 `PowerShell` 工具,以 PowerShell here-string 和
|
||||
1. **必须先创建或选择 DesireCore 拥有的隔离 venv**,不得先用全局解释器探测 Playwright。venv 不存在时,系统/引导 Python 只能用于执行 `-m venv`。
|
||||
2. 此后 import、固定版本安装、重新 import 与 attach 全部只能调用 venv 解释器;严禁裸 `python`、裸 `pip`、`pip --user`、全局安装或 `playwright install`。依赖缺失与浏览器 ready 是两件事:明确报告缺失,暂不 attach。
|
||||
3. Unix-like 主机使用 Bash 路径和语法;Windows 的整个流程必须使用 `PowerShell` 工具和 venv 的 `Scripts\python.exe`,不得调用 `Bash` 工具。以 PowerShell here-string 和
|
||||
`[IO.File]::WriteAllText(...)` 创建临时 `.py`。**绝不能把 `cat <<EOF`、`/tmp/...` 或其他 POSIX heredoc 交给 PowerShell。**
|
||||
4. 调用 venv 对应平台的 Python(Unix 为 `bin/python`,Windows 为 `Scripts\python.exe`),只删除本轮创建的临时脚本,外部浏览器保持运行。
|
||||
|
||||
@@ -204,7 +204,7 @@ DesireCore 能驱动**两个**浏览器,它们是平级的选项:
|
||||
| L1 | Public, static | `WebFetch` | Low |
|
||||
| L2 | JS-heavy, long articles, token savings | `Bash curl r.jina.ai` | **Lowest** (Markdown pre-cleaned) |
|
||||
| **L3** | **登录态导航、交互与取文 (PRIMARY)** | **内置受管浏览器(BrowserManage / BrowserAct / BrowserSnapshot / BrowserScript)** | Medium |
|
||||
| L3-external | **用户点名要用他自己的浏览器**,或 Agent 解释原因后用户明确同意改走此路径 | `BrowserExternalProbe` → `Bash + Python Playwright connect_over_cdp`(见 references/cdp-browser.md) | Medium |
|
||||
| L3-external | **用户点名要用他自己的浏览器**,或 Agent 解释原因后用户明确同意改走此路径 | `BrowserExternalProbe` → 平台原生 shell(Windows 必须 PowerShell)+ DesireCore 隔离 venv + Playwright `connect_over_cdp`(见 references/cdp-browser.md) | Medium |
|
||||
|
||||
**Default priority**: L1 for simple public pages → L2 for heavy → **L3 for login-gated(含正文与站内接口取数)**。
|
||||
|
||||
|
||||
@@ -339,13 +339,17 @@ fi
|
||||
#### Windows hosts
|
||||
|
||||
Use the `PowerShell` tool. Resolve `<DESIRECORE_HOME>` from the current DesireCore instance; do not
|
||||
guess another instance's directory.
|
||||
guess another instance's directory. The only permitted system/bootstrap `python.exe` use is running
|
||||
`-m venv` when the isolated venv is missing. Never use the `Bash` tool, bare `python`, bare `pip`,
|
||||
`pip --user`, or a global interpreter for any Playwright import, install, re-check, or attach step;
|
||||
all of those steps must use the venv's `Scripts\python.exe`.
|
||||
|
||||
```powershell
|
||||
$venv = Join-Path '<DESIRECORE_HOME>' 'runtime\external-browser-playwright'
|
||||
$python = Join-Path $venv 'Scripts\python.exe'
|
||||
if (-not (Test-Path -LiteralPath $python)) {
|
||||
python -m venv $venv
|
||||
$bootstrapPython = (Get-Command python.exe -ErrorAction Stop).Source
|
||||
& $bootstrapPython -m venv $venv
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Failed to create the isolated Playwright venv.' }
|
||||
}
|
||||
& $python -c "import playwright"
|
||||
|
||||
Reference in New Issue
Block a user