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
+3 -4
View File
@@ -21,15 +21,14 @@ description: "Generate videos in Gemini web via browser automation, download res
- Ensure browser session can access Gemini (`https://gemini.google.com/app`).
- If login, captcha, or MFA is required, pause and ask user to complete it manually.
- Use the shared Playwright session policy across all skills:
- `export PLAYWRIGHT_SHARED_SESSION=codex-shared`
- Invoke Playwright CLI through `/Users/xd/java/xhs/tools/pw` (do not pass `--session` manually).
- Auto session policy: `tools/pw` derives one Playwright session per `CODEX_THREAD_ID` (fallback: `PLAYWRIGHT_SESSION_OWNER` or explicit `--session`).
- Invoke Playwright CLI through `/Users/xd/java/xhs/tools/pw`; use `--session <name>` only when explicit multi-session isolation is needed.
- Decide output directory before generation, for example:
- `/Users/xd/java/xhs/output/gemini-video`
Quick run:
```bash
export PLAYWRIGHT_SHARED_SESSION=codex-shared
python3 scripts/run_video_flow.py \
--prompt "生成一段 8 秒的科幻城市夜景镜头,雨夜霓虹,电影感运镜。" \
--target /Users/xd/java/xhs/output/gemini-video \
@@ -156,6 +155,6 @@ Return:
## Scripts
- `/Users/xd/java/xhs/tools/pw`: Shared Playwright CLI entrypoint with fixed session + lock.
- `/Users/xd/java/xhs/tools/pw`: Shared Playwright CLI entrypoint with per-session lock, auto per-thread session resolution, and shared Chrome CDP defaults.
- `scripts/run_video_flow.py`: End-to-end runner (login gate, enter video tool, generate, download video, collect files).
- `scripts/collect_downloads.py`: Collect recent downloaded video files with fallback sources, dedupe, and manifest.
+1 -1
View File
@@ -1,4 +1,4 @@
interface:
display_name: "Gemini Video Web"
short_description: "Generate Gemini videos via web with login gate and manifest."
default_prompt: "Use $gemini-video-web with PLAYWRIGHT_SHARED_SESSION=codex-shared; run scripts/run_video_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate videos, prefer MP4/high-quality download, and collect deduped outputs with manifest."
default_prompt: "Use $gemini-video-web with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw; run scripts/run_video_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate videos, prefer MP4/high-quality download, and collect deduped outputs with manifest."