feat(playwright): adopt per-thread sessions for shared Chrome automation

This commit is contained in:
2026-03-05 18:33:36 +08:00
parent aec5bcbfab
commit 8f9fc6d7f7
15 changed files with 180 additions and 78 deletions
+11 -3
View File
@@ -15,10 +15,18 @@ description: "Browse XiaoHongShu (小红书) with Playwright and execute account
## Shared Session Policy
- Reuse a single Playwright CLI session across all web-automation skills:
- `export PLAYWRIGHT_SHARED_SESSION=codex-shared`
- Use per-thread Playwright CLI sessions across all web-automation skills:
- Auto session policy: `tools/pw` derives one Playwright session per `CODEX_THREAD_ID` (fallback: `PLAYWRIGHT_SESSION_OWNER` or explicit `--session`).
- Use `/Users/xd/java/xhs/tools/pw` as the only Playwright CLI entrypoint.
- Do not pass `--session` directly in skill-specific commands.
- Prefer the default auto session; pass `--session <name>` only when explicit isolation is required.
## Network Preflight Gate (Required)
- Before first browser step, run:
- `tools/pw --help`
- If it fails with network sandbox signatures (`ENOTFOUND`, `EAI_AGAIN`, `ETIMEDOUT`, `ECONNREFUSED`, or `registry.npmjs.org` fetch failure):
- rerun the same command with escalation (`sandbox_permissions=require_escalated`).
- Do not continue browsing/点赞/收藏/评论 until this preflight succeeds.
## 1) Confirm Login State