Files
collective-memory-repo/shared/long-term/decisions/browser-endpoints-mac5-mac7.md
2026-03-18 15:12:23 +08:00

108 lines
3.9 KiB
Markdown

# Browser endpoints registry for mac-5 takeover and mac-7 automation
Date: 2026-03-18
Status: accepted
## Purpose
Record the currently validated browser control endpoints so future automation and browser takeover tasks can reuse the right path without re-discovering ports.
## mac-5 local intelligent browser takeover
Use OpenClaw local browser attach on mac-5 for takeover of the real local Chrome session.
### Validated profile
- OpenClaw browser profile: `user`
- Driver/transport: `existing-session` via `chrome-mcp`
### Validation result
Validated on 2026-03-18:
- `openclaw browser --browser-profile user status` returned `running: true`
- `openclaw browser --browser-profile user tabs` listed live local tabs
### Operational meaning
This is the preferred path for smart takeover of the browser running on mac-5 itself.
## mac-7 browser automation service
mac-7 hosts the dedicated automation Chrome instance.
### Persistent local CDP service
- LaunchAgent plist:
- `~/Library/LaunchAgents/com.lingyuzeng.chrome-cdp-mac7.plist`
- Chrome executable:
- `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`
- Dedicated profile dir:
- `~/.openclaw/browser/mac7-automation-profile`
- Persistent local CDP listen address:
- `127.0.0.1:9333`
- Validation:
- `http://127.0.0.1:9333/json/version` returns standard CDP metadata and `webSocketDebuggerUrl`
### Persistent tailnet-facing listener
Validated on 2026-03-18:
- Tailscale IP on mac-7: `100.64.0.23`
- Persistent tailnet listener: `100.64.0.23:9223`
- Forward target: `127.0.0.1:9333`
- LaunchAgent:
- `~/Library/LaunchAgents/com.lingyuzeng.chrome-cdp-tailnet-proxy-mac7.plist`
- Proxy script:
- `~/.openclaw/bin/chrome_cdp_tailnet_proxy.py`
- Validation:
- `http://100.64.0.23:9223/json/version` returns `200 OK`
- returned `webSocketDebuggerUrl` is reachable on the tailnet-facing endpoint
### Important caveat
`tailscale serve` is not the active solution here.
Observed status:
- `tailscale serve status` => `No serve config`
The durable implementation is instead LaunchAgent + Python TCP proxy.
So future tasks should treat the endpoints as:
- **stable local automation endpoint on mac-7:** `127.0.0.1:9333`
- **stable tailnet remote endpoint on mac-7:** `100.64.0.23:9223`
## Usage guidance
- For mac-5 intelligent browser takeover: use OpenClaw local `user` profile.
- For mac-7 automation on the same machine: use CDP on `127.0.0.1:9333`.
- For mac-5 controlling mac-7 across the tailnet: use the stable remote CDP endpoint `http://100.64.0.23:9223`.
## LaunchAgent correction after blank-tab loop incident
Validated on 2026-03-18 later the same day:
- The original `com.lingyuzeng.chrome-cdp-mac7` LaunchAgent caused repeated blank tabs.
- Root cause: the plist directly executed Chrome with `KeepAlive=true` and `about:blank` in `ProgramArguments`.
- On macOS, Chrome detected the existing browser session, printed `正在现有的浏览器会话中打开。`, exited with code `0`, and launchd immediately re-ran it.
- This created a loop that kept injecting new `about:blank` tabs into the same automation profile.
### Corrected durable implementation
- LaunchAgent remains:
- `~/Library/LaunchAgents/com.lingyuzeng.chrome-cdp-mac7.plist`
- It should no longer use `KeepAlive=true` to re-exec Chrome directly.
- It should launch a wrapper script instead:
- `~/.openclaw/bin/start_chrome_cdp_mac7.sh`
- Wrapper behavior:
- check whether `127.0.0.1:9333` is already listening
- if yes, exit without launching another Chrome instance
- if no, start the dedicated automation Chrome profile once
### Operational takeaway
- If future symptoms show many new `about:blank` tabs appearing on mac-7, first inspect `com.lingyuzeng.chrome-cdp-mac7.plist` for accidental reintroduction of `KeepAlive` or direct Chrome execution with `about:blank`.
- The repeated-tab issue was caused by LaunchAgent semantics, not by the remote CDP profile on mac-5.