feat(playwright): adopt per-thread sessions for shared Chrome automation
This commit is contained in:
@@ -21,15 +21,14 @@ description: "Generate images 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-image`
|
||||
|
||||
Quick run:
|
||||
|
||||
```bash
|
||||
export PLAYWRIGHT_SHARED_SESSION=codex-shared
|
||||
python3 scripts/run_image_flow.py \
|
||||
--prompt "生成一张电影感赛博朋克街景海报,夜晚霓虹,雨天反光,纵向构图。" \
|
||||
--target /Users/xd/java/xhs/output/gemini-image \
|
||||
@@ -155,6 +154,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_image_flow.py`: End-to-end runner (login gate, enter image tool, generate, download image, collect files).
|
||||
- `scripts/collect_downloads.py`: Collect recent downloaded images with fallback sources, dedupe, and manifest.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface:
|
||||
display_name: "Gemini Image Web"
|
||||
short_description: "Generate Gemini images via web, multi-request, dedupe, and manifest."
|
||||
default_prompt: "Use $gemini-image-web with PLAYWRIGHT_SHARED_SESSION=codex-shared; run scripts/run_image_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate images, prefer full-size download, and collect deduped outputs with manifest."
|
||||
default_prompt: "Use $gemini-image-web with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw; run scripts/run_image_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate images, prefer full-size download, and collect deduped outputs with manifest."
|
||||
|
||||
@@ -21,15 +21,14 @@ description: "Generate music in Gemini web via browser automation, download resu
|
||||
- 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-music`
|
||||
|
||||
Quick run:
|
||||
|
||||
```bash
|
||||
export PLAYWRIGHT_SHARED_SESSION=codex-shared
|
||||
python3 scripts/run_music_flow.py \
|
||||
--prompt "创作一段 90 BPM 的 lo-fi hiphop,温暖、夜晚、钢琴和刷镲,时长 30 秒。" \
|
||||
--target /Users/xd/java/xhs/output/gemini-music \
|
||||
@@ -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_music_flow.py`: End-to-end runner (login gate, enter music tool, generate, download MP3, collect files).
|
||||
- `scripts/collect_downloads.py`: Collect recent downloaded audio files with fallback sources, dedupe, and manifest.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface:
|
||||
display_name: "Gemini Music Web"
|
||||
short_description: "Generate Gemini music via web with login gate and manifest."
|
||||
default_prompt: "Use $gemini-music-web with PLAYWRIGHT_SHARED_SESSION=codex-shared; run scripts/run_music_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate music, prefer MP3 download, and collect deduped outputs with manifest."
|
||||
default_prompt: "Use $gemini-music-web with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw; run scripts/run_music_flow.py via /Users/xd/java/xhs/tools/pw-backed CLI flow to verify login, generate music, prefer MP3 download, and collect deduped outputs with manifest."
|
||||
|
||||
@@ -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,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."
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
interface:
|
||||
display_name: "XHS Engage"
|
||||
short_description: "Browse feed and engage via likes, favorites, and comments."
|
||||
default_prompt: "Use $xiaohongshu-engage with PLAYWRIGHT_SHARED_SESSION=codex-shared and execute browser steps only through /Users/xd/java/xhs/tools/pw while browsing XiaoHongShu and interacting with relevant posts through likes, favorites, and concise comments."
|
||||
default_prompt: "Use $xiaohongshu-engage with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw and execute browser steps only through /Users/xd/java/xhs/tools/pw while browsing XiaoHongShu and interacting with relevant posts through likes, favorites, and concise comments."
|
||||
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
|
||||
@@ -18,10 +18,10 @@ description: "Execute XiaoHongShu (小红书) image-note publishing workflow in
|
||||
|
||||
## 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.
|
||||
|
||||
## 1) Enter Creator Publish Page
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface:
|
||||
display_name: "XHS Publish Note"
|
||||
short_description: "Publish XHS image notes with manifest image linkage, hard gates, and publish modes"
|
||||
default_prompt: "Use $xiaohongshu-publish-note with PLAYWRIGHT_SHARED_SESSION=codex-shared and run all browser steps via /Users/xd/java/xhs/tools/pw; publish XiaoHongShu image notes by preferring user image paths, otherwise generate via $gemini-image-web and use manifest target paths, enforce hard gates (images>=1, topics>=5, no location), and run in safe_mode by default unless live_mode is explicitly requested."
|
||||
default_prompt: "Use $xiaohongshu-publish-note with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw and run all browser steps via /Users/xd/java/xhs/tools/pw; publish XiaoHongShu image notes by preferring user image paths, otherwise generate via $gemini-image-web and use manifest target paths, enforce hard gates (images>=1, topics>=5, no location), and run in safe_mode by default unless live_mode is explicitly requested."
|
||||
|
||||
@@ -18,10 +18,10 @@ description: "Execute XiaoHongShu (小红书) video-note publishing workflow in
|
||||
|
||||
## 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.
|
||||
|
||||
## 1) Enter Creator Publish Page
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface:
|
||||
display_name: "XHS Publish Video"
|
||||
short_description: "Publish XHS video notes with manifest linkage, hard gates, and publish modes"
|
||||
default_prompt: "Use $xiaohongshu-publish-video with PLAYWRIGHT_SHARED_SESSION=codex-shared and run all browser steps via /Users/xd/java/xhs/tools/pw; publish XiaoHongShu video notes by preferring user video paths, otherwise generate via $gemini-video-web and use manifest target paths, enforce hard gates (videos>=1, topics>=5, no location, video-ready=true), and run in safe_mode by default unless live_mode is explicitly requested."
|
||||
default_prompt: "Use $xiaohongshu-publish-video with auto per-thread Playwright session via /Users/xd/java/xhs/tools/pw and run all browser steps via /Users/xd/java/xhs/tools/pw; publish XiaoHongShu video notes by preferring user video paths, otherwise generate via $gemini-video-web and use manifest target paths, enforce hard gates (videos>=1, topics>=5, no location, video-ready=true), and run in safe_mode by default unless live_mode is explicitly requested."
|
||||
|
||||
Reference in New Issue
Block a user