@blackbelt-technology/pi-dashboard-extension 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pi/skills/browser/SKILL.md +69 -28
- package/.pi/skills/browser/UPSTREAM.md +6 -3
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/own-browser.md +7 -1
- package/.pi/skills/doctor/SKILL.md +1 -0
- package/.pi/skills/doctor/_lib/checks.ts +133 -0
- package/.pi/skills/doctor/_lib/derive-tokens.ts +4 -0
- package/.pi/skills/doctor/modules/apple-tools.md +2 -1
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +40 -27
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/package.json +19 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +21 -19
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge.ts +954 -248
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +77 -31
- package/src/connection.ts +481 -16
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +32 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +31 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +3 -0
- package/src/path-gate/decide.ts +149 -0
- package/src/path-gate/grant-cache.ts +71 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +307 -0
- package/src/path-gate/index.ts +155 -0
- package/src/path-gate/resolve.ts +126 -0
- package/src/path-gate/roots.ts +137 -0
- package/src/path-gate/suppression.ts +27 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +2 -10
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/prompt-bus.ts +13 -0
- package/src/provider-register.ts +6 -0
- package/src/retry-tracker.ts +0 -7
- package/src/role-manager.ts +22 -95
- package/src/role-model-tools.ts +6 -0
- package/src/server-auto-start.ts +192 -23
- package/src/server-launcher.ts +70 -34
- package/src/session-move.ts +4 -4
- package/src/session-sync.ts +51 -15
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/terminal-reload.ts +298 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/project-init/dox-doctrine.md +0 -146
- package/src/agent-settled.ts +0 -90
- package/src/transcript-request-guard.ts +0 -76
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: browser
|
|
3
|
-
description: 'Browser automation via the `agent-browser` CLI. Use when the user needs to drive websites or Electron
|
|
3
|
+
description: 'Browser automation via the `agent-browser` CLI. Use when the user needs to drive websites or Electron apps — navigating, forms, clicks, screenshots, data extraction, testing web apps, UI checks, the dashboard Electron shell, or the user''s own logged-in Chrome via the browser relay or Panerelay (SSO/2FA). Triggers: "open a website", "take a screenshot", "test this web app", "use my own browser".'
|
|
4
4
|
license: Apache-2.0
|
|
5
|
-
allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(npx @panerelay/setup:*)
|
|
5
|
+
allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(npx @panerelay/setup:*), Bash(curl:*)
|
|
6
6
|
metadata:
|
|
7
7
|
author: pi-dashboard
|
|
8
|
-
version: "1.
|
|
8
|
+
version: "1.2"
|
|
9
9
|
vendoredFrom: agent-browser
|
|
10
10
|
vendoredVersion: "0.27.0"
|
|
11
11
|
verifiedAgainstCli: "0.33.2"
|
|
@@ -25,28 +25,46 @@ Three recipes:
|
|
|
25
25
|
a worked example for the Pi Dashboard's own shell via `--debug-cdp`.
|
|
26
26
|
Reference: [`references/electron.md`](references/electron.md).
|
|
27
27
|
- **The user's own logged-in browser** — reach SSO/2FA-gated sites using the
|
|
28
|
-
user's real cookies
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
user's real cookies. Two paths:
|
|
29
|
+
- **Pi Dashboard browser relay** (preferred when the pi session runs on the
|
|
30
|
+
dashboard host) — pair the Playwright Chrome Extension, connect to a
|
|
31
|
+
loopback CDP URL. Reference:
|
|
32
|
+
[`references/dashboard-relay.md`](references/dashboard-relay.md).
|
|
33
|
+
- **Panerelay extension bridge** (legacy) — a native-messaging host for when
|
|
34
|
+
there is no loopback dashboard. Reference:
|
|
35
|
+
[`references/own-browser.md`](references/own-browser.md).
|
|
31
36
|
|
|
32
37
|
## Step 0a — Preflight: `agent-browser` CLI must be installed
|
|
33
38
|
|
|
34
|
-
The skill does **not** bundle the CLI.
|
|
39
|
+
The skill does **not** bundle the CLI. Verify it through the dashboard tool
|
|
40
|
+
registry — recommend-only, nothing installs without an explicit `--install`:
|
|
35
41
|
|
|
36
42
|
```bash
|
|
37
|
-
|
|
43
|
+
pi-dashboard-ensure <extension-package-root>/package.json
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
`<extension-package-root>` is the package that ships this skill — three levels
|
|
47
|
+
above this SKILL.md's `.pi/skills/browser/` directory (in a global install:
|
|
48
|
+
`$(npm root -g)/@blackbelt-technology/pi-dashboard/node_modules/@blackbelt-technology/pi-dashboard-extension`).
|
|
49
|
+
The manifest (`pi.tools`) declares `agent-browser` (resolve) and `chromium`
|
|
50
|
+
(pw-browser); the registry answers `present` / `recommended` / `blocked` per
|
|
51
|
+
tool.
|
|
52
|
+
|
|
53
|
+
- `agent-browser: present` → continue to Step 0b.
|
|
54
|
+
- `agent-browser: recommended` or `blocked` → halt and tell the user:
|
|
55
|
+
|
|
56
|
+
> The `agent-browser` CLI is not installed. Install it as a pi extension so
|
|
57
|
+
> the `browser` tool is registered in your pi session too:
|
|
58
|
+
>
|
|
59
|
+
> ```
|
|
60
|
+
> pi install npm:pi-agent-browser
|
|
61
|
+
> ```
|
|
62
|
+
>
|
|
63
|
+
> Then re-invoke the skill.
|
|
64
|
+
|
|
65
|
+
- `chromium` missing → mention the registry's Install hint
|
|
66
|
+
(`npx playwright@1.62.1 install chromium`) only when the chosen recipe needs a
|
|
67
|
+
CDP browser; the dropdown on the Settings → Tools row carries it.
|
|
50
68
|
|
|
51
69
|
Do **not** attempt `npm install`, `pi install`, or any other install command
|
|
52
70
|
on the user's behalf — they should make that choice explicitly.
|
|
@@ -62,7 +80,9 @@ else
|
|
|
62
80
|
CDP_LIVE=$(nc -z 127.0.0.1 9222 2>/dev/null && echo yes || echo no)
|
|
63
81
|
fi
|
|
64
82
|
PD_RUNNING=$(pgrep -f "Pi Dashboard|pi-dashboard" >/dev/null 2>&1 && echo yes || echo no)
|
|
65
|
-
|
|
83
|
+
# Browser relay: the dashboard's own capability probe (see dashboard-relay.md).
|
|
84
|
+
RELAY=$(curl -fsS http://localhost:8000/api/browser/status 2>/dev/null || echo unavailable)
|
|
85
|
+
echo "CDP_LIVE=$CDP_LIVE PD_RUNNING=$PD_RUNNING RELAY=$RELAY"
|
|
66
86
|
```
|
|
67
87
|
|
|
68
88
|
Routing rule:
|
|
@@ -84,16 +104,32 @@ launching any Electron app with `--remote-debugging-port`.
|
|
|
84
104
|
|
|
85
105
|
**Override (login state)**: if the target needs the user's *existing*
|
|
86
106
|
session — "use my browser", "I'm already logged in", SSO/2FA, an internal
|
|
87
|
-
tool the agent cannot sign into — route to
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
tool the agent cannot sign into — route to a login-state recipe regardless of
|
|
108
|
+
the probe. Pick by capability, in this order:
|
|
109
|
+
|
|
110
|
+
1. **`references/dashboard-relay.md`** when the pi session runs on the
|
|
111
|
+
dashboard host and the probe's `RELAY` is a JSON object with
|
|
112
|
+
`"enabled":true` and `"canOpenChrome":true`. This is the preferred path;
|
|
113
|
+
it needs no extra install and the dashboard holds the pairing token.
|
|
114
|
+
2. **`references/own-browser.md`** (legacy Panerelay bridge) only when the
|
|
115
|
+
relay is unavailable (`RELAY=unavailable`) or the session is remote.
|
|
116
|
+
|
|
117
|
+
The default bundled browser starts logged out and cannot be made to inherit
|
|
118
|
+
those logins; `--profile` copies the profile and still loses macOS
|
|
119
|
+
Keychain-encrypted cookies. Prefer the bundled browser whenever login state is
|
|
120
|
+
irrelevant — it is faster and more capable. **Never** fall back to it for a
|
|
121
|
+
login-state task.
|
|
92
122
|
|
|
93
123
|
## Step 1 — Read the matched recipe and execute
|
|
94
124
|
|
|
95
|
-
Read the reference file selected above, then follow its workflow.
|
|
96
|
-
references are self-contained; you do not need to read
|
|
125
|
+
Read the reference file selected above, then follow its workflow. All
|
|
126
|
+
references are self-contained; you do not need to read more than one.
|
|
127
|
+
|
|
128
|
+
**Challenge encountered**: if at any point the page is an interactive
|
|
129
|
+
anti-bot challenge (Cloudflare Turnstile, hCaptcha, reCAPTCHA, "Checking
|
|
130
|
+
your browser…") that withholds the content you asked for, stop and follow
|
|
131
|
+
[`references/challenge.md`](references/challenge.md). Do not retry, do not
|
|
132
|
+
switch `--session`, `--profile`, or provider, and do not run `close --all`.
|
|
97
133
|
|
|
98
134
|
## Notes
|
|
99
135
|
|
|
@@ -101,8 +137,13 @@ references are self-contained; you do not need to read both.
|
|
|
101
137
|
snapshots of upstream `agent-browser` skill content (`core` and
|
|
102
138
|
`electron`) at CLI version 0.27.0. See [`UPSTREAM.md`](UPSTREAM.md) for
|
|
103
139
|
refresh procedure and [`LICENSE`](LICENSE) for upstream attribution.
|
|
104
|
-
`references/own-browser.md`
|
|
105
|
-
|
|
140
|
+
`references/own-browser.md`, `references/dashboard-relay.md`, and
|
|
141
|
+
`references/challenge.md` are **authored, not vendored** — an upstream
|
|
142
|
+
refresh must not overwrite them.
|
|
143
|
+
- **Login-state recipes**: `references/dashboard-relay.md` is the preferred
|
|
144
|
+
path (Pi Dashboard browser relay); `references/own-browser.md` is the legacy
|
|
145
|
+
Panerelay/native-messaging path for remote sessions with no loopback
|
|
146
|
+
dashboard.
|
|
106
147
|
- **Surfaces share one browser**: the `browser` MCP tool and
|
|
107
148
|
`Bash: agent-browser …` drive the *same* daemon and *same* Chrome, with a
|
|
108
149
|
shared active page. Probing with one mid-task can silently move the page
|
|
@@ -7,8 +7,10 @@ section in `electron.md` are project-specific and not from upstream.
|
|
|
7
7
|
|
|
8
8
|
**Not vendored — do not overwrite on refresh:**
|
|
9
9
|
`references/own-browser.md` and `scripts/check-panerelay.sh` are authored
|
|
10
|
-
for this repo (the Panerelay / own-logged-in-browser recipe).
|
|
11
|
-
|
|
10
|
+
for this repo (the Panerelay / own-logged-in-browser recipe).
|
|
11
|
+
`references/challenge.md` is authored for this repo too — the pause / resume
|
|
12
|
+
discipline for interactive anti-bot challenges. None of them has an upstream
|
|
13
|
+
counterpart.
|
|
12
14
|
|
|
13
15
|
| Field | Value |
|
|
14
16
|
|------------------------|--------------------------------------------------------------------|
|
|
@@ -43,7 +45,8 @@ diff <(awk 'BEGIN{n=0} /^---$/{n++; next} n>=2{print}' /tmp/electron.md) referen
|
|
|
43
45
|
# Preserve the Pi Dashboard addenda (after the first `---` separator
|
|
44
46
|
# in web.md, and the "Worked example: Pi Dashboard" section in
|
|
45
47
|
# electron.md). Update the LICENSE file if the upstream license text
|
|
46
|
-
# has changed. Leave own-browser.md
|
|
48
|
+
# has changed. Leave own-browser.md, challenge.md and
|
|
49
|
+
# check-panerelay.sh untouched.
|
|
47
50
|
|
|
48
51
|
# 5. Re-verify the authored recipe against the new CLI, then bump
|
|
49
52
|
# `verifiedAgainstCli` in SKILL.md frontmatter:
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Interactive challenges — pause, hand off, resume
|
|
2
|
+
|
|
3
|
+
Authored for this repo, not vendored from upstream (see
|
|
4
|
+
[`UPSTREAM.md`](../UPSTREAM.md)).
|
|
5
|
+
|
|
6
|
+
An interactive anti-bot challenge is a **stop sign, not an obstacle to
|
|
7
|
+
route around**. The site is asking for a human. Your job is to hand it to
|
|
8
|
+
the user and continue on the *same* browser afterwards.
|
|
9
|
+
|
|
10
|
+
**This file takes precedence over every recipe's troubleshooting advice.**
|
|
11
|
+
`own-browser.md`'s "re-run under a fresh `--session`" row and `web.md`'s
|
|
12
|
+
`close --all` cleanup both address other problems and are *wrong* here —
|
|
13
|
+
both throw away the exact session state the site is about to trust.
|
|
14
|
+
|
|
15
|
+
## What counts as a challenge
|
|
16
|
+
|
|
17
|
+
The test is the **withheld content**: the page asks a human to prove they
|
|
18
|
+
are one *before* showing you what you asked for. Signature alone is not
|
|
19
|
+
enough — text such as "Verify you are human" on a documentation page,
|
|
20
|
+
forum post, or search result that is *still serving its content* is **not**
|
|
21
|
+
a challenge. Keep working.
|
|
22
|
+
|
|
23
|
+
A short, non-exhaustive list of signatures:
|
|
24
|
+
|
|
25
|
+
| Kind | Signature |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Cloudflare Turnstile / browser check | iframe from `challenges.cloudflare.com`; text "Checking your browser" |
|
|
28
|
+
| hCaptcha | iframe from `hcaptcha.com` |
|
|
29
|
+
| reCAPTCHA | iframe from `google.com/recaptcha` |
|
|
30
|
+
| Generic interstitial | text "Verify you are human" |
|
|
31
|
+
|
|
32
|
+
Genuine churn happens upstream in these vendors' markup — treat the list as
|
|
33
|
+
a prompt for what to look for, not a detector.
|
|
34
|
+
|
|
35
|
+
**Check more than the snapshot.** A snapshot inlines iframe *content*, not
|
|
36
|
+
its host, so it can miss the vendor entirely. Use all of:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
agent-browser --session <name> get url
|
|
40
|
+
agent-browser --session <name> get title
|
|
41
|
+
agent-browser --session <name> eval '[...document.querySelectorAll("iframe")].map(f => f.src)'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`read` and the snapshot text catch the interstitial phrasing; `get url` and
|
|
45
|
+
`get title` catch the redirect to a challenge path; the `eval` of
|
|
46
|
+
`iframe[src]` catches the vendor host. Use `Bash: agent-browser eval …`, not
|
|
47
|
+
the MCP `eval` (wrapper bug: it echoes the source instead of running it).
|
|
48
|
+
|
|
49
|
+
## Pause
|
|
50
|
+
|
|
51
|
+
Stop driving the page immediately. Do **not**:
|
|
52
|
+
|
|
53
|
+
- run `close --all` — it is not session-scoped and kills every session,
|
|
54
|
+
including unrelated ones;
|
|
55
|
+
- switch to a different `--session` name, a different `--profile`, or a
|
|
56
|
+
different provider;
|
|
57
|
+
- re-navigate to the challenged URL hoping it passes;
|
|
58
|
+
- reach for the recipe's troubleshooting table — on a challenge this file
|
|
59
|
+
wins.
|
|
60
|
+
|
|
61
|
+
Report to the user, all three:
|
|
62
|
+
|
|
63
|
+
1. the challenged URL (`get url` at pause time — not the task's start URL),
|
|
64
|
+
2. the challenge kind (Turnstile / hCaptcha / reCAPTCHA / browser check),
|
|
65
|
+
3. **the session name you have been driving** — the `--session` value your
|
|
66
|
+
own launch command passed, or `AGENT_BROWSER_SESSION` if you relied on
|
|
67
|
+
the env var, or `default` if neither.
|
|
68
|
+
|
|
69
|
+
Do not run a bare `agent-browser session` to answer #3: it prints the
|
|
70
|
+
*environment/default* session name, not the one your task passed.
|
|
71
|
+
|
|
72
|
+
## Complete — branch on the route you are already on
|
|
73
|
+
|
|
74
|
+
```mermaid
|
|
75
|
+
flowchart TD
|
|
76
|
+
A["Challenge: requested content withheld"] --> B["Pause: stop driving; report URL + kind + driven session name"]
|
|
77
|
+
B --> C{"Who can see the browser?"}
|
|
78
|
+
C -->|"relay / own-browser / Electron-CDP"| D["User completes it in the visible window"]
|
|
79
|
+
C -->|"bundled headless"| E{"Ask: are you at the machine running the browser?"}
|
|
80
|
+
E -->|"yes"| F["Session-scoped close, then relaunch original flags + --headed on the challenged URL"]
|
|
81
|
+
E -->|"no — Docker, SSH, service host"| G["Stop: human needed on a visible host; offer relay / own-browser / desktop host"]
|
|
82
|
+
D --> H["Re-snapshot the same page, continue, never switch session"]
|
|
83
|
+
F --> H
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Relay / own-browser / Electron-CDP — the user already sees the browser
|
|
87
|
+
|
|
88
|
+
(The relay recipe lives in `references/dashboard-relay.md` when that file is
|
|
89
|
+
present.) Ask the user to complete the challenge in that window. On
|
|
90
|
+
confirmation, re-snapshot the same page and continue. The session is
|
|
91
|
+
untouched — nothing to relaunch.
|
|
92
|
+
|
|
93
|
+
### Bundled headless — ask before you assume a display
|
|
94
|
+
|
|
95
|
+
The user cannot see the bundled browser, and a running daemon cannot flip
|
|
96
|
+
headless → headed in place, so the agent has to relaunch. First ask:
|
|
97
|
+
|
|
98
|
+
> Are you at the machine running the browser?
|
|
99
|
+
|
|
100
|
+
Do **not** infer this from `$DISPLAY` — it is empty on macOS and set under
|
|
101
|
+
`ssh -X`, so it is wrong in both directions.
|
|
102
|
+
|
|
103
|
+
**Yes — display available.** From Bash (the MCP `browser` tool shares the
|
|
104
|
+
same daemon and session, so Bash is the relaunch surface either way):
|
|
105
|
+
|
|
106
|
+
1. Session-scoped `close`, with the same `--session` / `--namespace` flags
|
|
107
|
+
you launched with — never `close --all`:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
agent-browser --session <name> [--namespace <namespace>] close
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Tolerate failure: if the daemon already idled out, `close` errors.
|
|
114
|
+
Ignore it and go on.
|
|
115
|
+
|
|
116
|
+
2. Relaunch with **all your original launch flags verbatim**, plus
|
|
117
|
+
`--headed`, opening the challenged URL:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
agent-browser --session <name> [<original flags>] --headed open <challenged URL>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
"Repeat the original flags" is deliberately not a list here: it keeps
|
|
124
|
+
`--restore`, `--profile`, `--state`, `--namespace`, `--cdp`, and anything
|
|
125
|
+
else in play without you having to remember them.
|
|
126
|
+
|
|
127
|
+
3. Ask the user to complete the challenge in the visible window and confirm.
|
|
128
|
+
|
|
129
|
+
**Say this out loud to the user:** a session launched without `--restore`,
|
|
130
|
+
`--profile`, or `--state` starts the headed relaunch with **empty cookies**.
|
|
131
|
+
That is by design — a task that needed login state should already have been
|
|
132
|
+
on relay / own-browser. The clearance the user just earned lives in the
|
|
133
|
+
headed browser you now keep driving, so the task still works.
|
|
134
|
+
|
|
135
|
+
**Note:** if your session is `default`, its `close` also drops the MCP
|
|
136
|
+
`browser` tool's page — both surfaces share one daemon. That affects this
|
|
137
|
+
task only.
|
|
138
|
+
|
|
139
|
+
**No — no display** (Docker harness, SSH, service context). `--headed`
|
|
140
|
+
cannot work. Stop, tell the user the site needs a human on a host with a
|
|
141
|
+
visible browser, and offer the relay / own-browser route or running the task
|
|
142
|
+
from a desktop host. Do not attempt `--headed`, a virtual display (Xvfb),
|
|
143
|
+
or any bypass.
|
|
144
|
+
|
|
145
|
+
## Resume
|
|
146
|
+
|
|
147
|
+
The headed browser under the same name **is** the working browser now.
|
|
148
|
+
Re-snapshot, continue the task, and do not close it again for the rest of
|
|
149
|
+
the task. Do not start a different session name.
|
|
150
|
+
|
|
151
|
+
If the daemon idle-timed out while the user was away, relaunch exactly as
|
|
152
|
+
above — same name, original flags + `--headed` — and resume.
|
|
153
|
+
|
|
154
|
+
## Challenge reappears after resume
|
|
155
|
+
|
|
156
|
+
Stop. Report that the site is not accepting the session. Do **not** loop on
|
|
157
|
+
retries and do **not** switch identity — a second relaunch, a new
|
|
158
|
+
`--session`, or a UA change is exactly what the challenge is testing for.
|
|
159
|
+
|
|
160
|
+
## Never
|
|
161
|
+
|
|
162
|
+
The never-list is absolute. Every item below is a bypass attempt, and a
|
|
163
|
+
challenge is a request for a human — hand it to the human instead.
|
|
164
|
+
|
|
165
|
+
Never:
|
|
166
|
+
|
|
167
|
+
- use a CAPTCHA-solving service;
|
|
168
|
+
- inject a challenge token or a clearance cookie;
|
|
169
|
+
- copy cookies between browser identities;
|
|
170
|
+
- rotate proxies;
|
|
171
|
+
- change the user-agent, request headers, or `set device` emulation in
|
|
172
|
+
response to a challenge;
|
|
173
|
+
- pass launch flags whose purpose is to hide automation — for example
|
|
174
|
+
`--args --disable-blink-features=AutomationControlled` (the CLI's own help
|
|
175
|
+
happens to show this one);
|
|
176
|
+
- inject JavaScript whose purpose is to falsify automation signals.
|
|
177
|
+
|
|
178
|
+
## Related
|
|
179
|
+
|
|
180
|
+
- Default bundled-browser workflow: [`web.md`](web.md)
|
|
181
|
+
- Electron apps: [`electron.md`](electron.md)
|
|
182
|
+
- The user's logged-in browser: [`own-browser.md`](own-browser.md)
|
|
183
|
+
- Provenance / refresh rules: [`../UPSTREAM.md`](../UPSTREAM.md)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Driving the user's real Chrome via the Pi Dashboard browser relay
|
|
2
|
+
|
|
3
|
+
Recipe for when the task needs the user's **real, logged-in Chrome** — their
|
|
4
|
+
cookies, SSO sessions, work logins, installed extensions — and the pi session
|
|
5
|
+
is running **on the same host as the Pi Dashboard**. The relay pairs the
|
|
6
|
+
Playwright Chrome Extension with the dashboard and hands back a loopback CDP
|
|
7
|
+
URL that `agent-browser connect` can attach to directly.
|
|
8
|
+
|
|
9
|
+
Authored for this repo. Unlike `web.md` / `electron.md` this is **not**
|
|
10
|
+
vendored; see [`UPSTREAM.md`](../UPSTREAM.md).
|
|
11
|
+
|
|
12
|
+
> **Legacy note.** `references/own-browser.md` (Panerelay + native-messaging
|
|
13
|
+
> host) is the older path. Prefer **this** recipe whenever the pi session runs
|
|
14
|
+
> on the dashboard host — it needs no native-messaging host install and the
|
|
15
|
+
> dashboard already holds the pairing token. Keep `own-browser.md` for the case
|
|
16
|
+
> where the agent runs elsewhere and cannot reach a loopback dashboard.
|
|
17
|
+
|
|
18
|
+
## When this recipe applies
|
|
19
|
+
|
|
20
|
+
- The target is behind a login the agent cannot perform (SSO / 2FA / internal
|
|
21
|
+
tool the user is already signed into), **and**
|
|
22
|
+
- the pi session runs on the **dashboard host** (the `cdpUrl` is loopback
|
|
23
|
+
`ws://127.0.0.1:<port>/…`; a remote session cannot dial it).
|
|
24
|
+
|
|
25
|
+
Do **not** use it for ordinary automation — the bundled browser
|
|
26
|
+
(`references/web.md`) is faster and disposable.
|
|
27
|
+
|
|
28
|
+
> **Never fall back to the bundled browser for a login-state task.** It starts
|
|
29
|
+
> logged out and `--profile` copies the profile but loses Keychain-encrypted
|
|
30
|
+
> cookies (macOS) — you would silently land logged out. If the relay is
|
|
31
|
+
> unavailable, say so; do not "try anyway".
|
|
32
|
+
|
|
33
|
+
## Prerequisites (user-facing, one time)
|
|
34
|
+
|
|
35
|
+
1. Chrome + the **Playwright Chrome Extension** installed in the profile you
|
|
36
|
+
will drive. `GET /api/browser/profiles` reports `installed` per profile.
|
|
37
|
+
2. For zero-dialog connects, a pairing token pasted in
|
|
38
|
+
**Settings → Browser Relay** (write-only; it never comes back out). Without
|
|
39
|
+
it the user gets Chrome's **Allow** prompt on each connect.
|
|
40
|
+
|
|
41
|
+
## Step 1 — Probe status
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
curl -s http://localhost:8000/api/browser/status
|
|
45
|
+
# → {"enabled":true,"canOpenChrome":true}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use the dashboard port (`8000` by default; `PI_DASHBOARD_PORT` overrides).
|
|
49
|
+
Branch on the response:
|
|
50
|
+
|
|
51
|
+
| Response | Meaning | Do |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `404` | Plugin not loaded / disabled | The relay is not usable; report it. Do **not** fall back to the bundled browser for a login-state task. |
|
|
54
|
+
| `{"enabled":false}` | Kill switch is off | Enable it (Step 1b) or ask the user to; a `connect` will `403` until then. |
|
|
55
|
+
| `{"canOpenChrome":false}` | Host has no desktop Chrome (container / headless / no `Google Chrome`) | The relay cannot open a profile; `connect` will `503`. Stop. |
|
|
56
|
+
|
|
57
|
+
### Step 1b — Enable the relay (only if `enabled:false`)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -s -X PUT http://localhost:8000/api/browser/enabled \
|
|
61
|
+
-H 'content-type: application/json' -d '{"enabled":true}'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The kill switch is safe to flip: turning it off closes every live instance
|
|
65
|
+
first (the response returns only after they are gone).
|
|
66
|
+
|
|
67
|
+
## Step 2 — Pick a profile
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
curl -s http://localhost:8000/api/browser/profiles
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Rows are keyed by `profileDirectory`. Pick one with `"installed":true`; match a
|
|
74
|
+
`label` / `email` when the user named an account. A row's `instances` lists any
|
|
75
|
+
live connection already holding that profile.
|
|
76
|
+
|
|
77
|
+
## Step 3 — Connect
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
curl -s -X POST http://localhost:8000/api/browser/connect \
|
|
81
|
+
-H 'content-type: application/json' \
|
|
82
|
+
-d '{"profileDirectory":"Default"}'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Success returns `{"cdpUrl":"ws://127.0.0.1:<port>/ws/browser-cdp/<guid>","instanceId":"inst-…"}`.
|
|
86
|
+
**Keep the `instanceId`** — it is how you disconnect, and the only public handle
|
|
87
|
+
to this instance.
|
|
88
|
+
|
|
89
|
+
Branch on failure (the HTTP status is authoritative):
|
|
90
|
+
|
|
91
|
+
| Status | `reason` | Meaning | Do |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| `403` | — | Relay disabled | Enable first (Step 1b). |
|
|
94
|
+
| `409` | `not-installed` | Extension absent in that profile | Tell the user to install it in **that** profile; the store link is in Settings → Browser Relay. |
|
|
95
|
+
| `409` | `busy` | The profile already hosts a live instance (and the dashboard is configured to allow one) | Reuse the existing `instanceId` if it is yours, or `disconnect` it first. Do not retry blindly. |
|
|
96
|
+
| `503` | — | Host cannot open Chrome | Stop; do not fall back to the bundled browser for a login-state task. |
|
|
97
|
+
| `504` | — | The extension did not connect within 60 s | Almost always the user did not click **Allow**, or the pairing token mismatched (the dashboard deliberately cannot tell these apart). Ask the user to allow / re-check the token, then retry once. |
|
|
98
|
+
|
|
99
|
+
## Step 4 — Attach the CDP client
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
agent-browser connect "<cdpUrl from Step 3>"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Then follow [`web.md`](web.md)'s workflow (`snapshot`, `click`, `type`, …). The
|
|
106
|
+
relay behaves like any CDP endpoint for the allowed surface.
|
|
107
|
+
|
|
108
|
+
## Step 5 — Disconnect when done
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl -s -X POST "http://localhost:8000/api/browser/disconnect?instanceId=<instanceId>"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Do this as soon as the task ends. A live instance holds a **tab group open in
|
|
115
|
+
the user's Chrome**; the dashboard also auto-closes it ~30 s after the CDP
|
|
116
|
+
client detaches or disconnects, but an explicit disconnect is faster.
|
|
117
|
+
|
|
118
|
+
## Behaviour you must expect
|
|
119
|
+
|
|
120
|
+
- **One tab group per instance.** The extension opens a dedicated, colour-coded
|
|
121
|
+
Chrome tab group and drives only those tabs. Do not touch the user's other
|
|
122
|
+
tabs; closing the last controlled tab ends the instance.
|
|
123
|
+
- **Policy denials are LOUD, not silent.** The relay denies a fixed set of CDP
|
|
124
|
+
verbs and unsafe navigation. A denial is a CDP error `-32000` whose message
|
|
125
|
+
reads `Denied by dashboard relay policy: <method>`:
|
|
126
|
+
- always denied: `Storage.getCookies`, `Network.getAllCookies`,
|
|
127
|
+
`Network.getCookies` (cookie exfiltration), `Browser.setDownloadBehavior`.
|
|
128
|
+
- navigation fence on `Page.navigate` / `Target.createTarget`: `file:`,
|
|
129
|
+
`javascript:`, `data:`, `blob:`, and — when the profile has
|
|
130
|
+
`allowedDomains` set — any host-less URL or a host outside the list.
|
|
131
|
+
Treat `-32000` as a hard stop: report which call was denied, do not retry it
|
|
132
|
+
in a loop, and do not try to reach the data another way.
|
|
133
|
+
- **One CDP client per instance.** A second `connect` to the same `cdpUrl` is
|
|
134
|
+
closed with `Another CDP client already connected`. Use the `instanceId` you
|
|
135
|
+
already hold.
|
|
136
|
+
- **DevTools wins.** If the user opens DevTools on a controlled tab, the relay
|
|
137
|
+
reports that tab `detached` and answers its commands with
|
|
138
|
+
`Target detached: devtools`; live-view input stops until DevTools closes.
|
|
139
|
+
- **Loopback only.** Both relay endpoints reject tunnel / non-loopback peers
|
|
140
|
+
(checking `Host` and forwarding headers). A pi session that is not on the
|
|
141
|
+
dashboard host cannot use this recipe.
|
|
142
|
+
|
|
143
|
+
## Diagnostics
|
|
144
|
+
|
|
145
|
+
- Settings → Browser Relay shows the audit trail (`GET /api/browser/audit`) —
|
|
146
|
+
`denied` rows name the refused verb, `navigate` rows name the URL.
|
|
147
|
+
- `POST /api/browser/disconnect` then reconnect to clear a wedged instance.
|
|
148
|
+
- The dashboard's live-view tiles (`content-view`) mirror the same instance; if
|
|
149
|
+
a tile shows `no-frames`, the tab simply has not repainted (idle or hidden),
|
|
150
|
+
which is normal.
|
|
@@ -7,6 +7,12 @@ Chrome for Testing that `agent-browser` launches by default.
|
|
|
7
7
|
Not vendored from upstream. Authored for this repo; see
|
|
8
8
|
[`UPSTREAM.md`](../UPSTREAM.md).
|
|
9
9
|
|
|
10
|
+
> **Legacy path.** The Pi Dashboard browser relay
|
|
11
|
+
> ([`dashboard-relay.md`](dashboard-relay.md)) is preferred whenever the pi
|
|
12
|
+
> session runs on the dashboard host — it needs no native-messaging host and
|
|
13
|
+
> the dashboard holds the pairing token. Use this Panerelay recipe only when
|
|
14
|
+
> the agent runs elsewhere and cannot reach a loopback dashboard.
|
|
15
|
+
|
|
10
16
|
## When this recipe applies
|
|
11
17
|
|
|
12
18
|
Use it when the target is behind a login the agent cannot perform: SSO /
|
|
@@ -274,7 +280,7 @@ call fails.
|
|
|
274
280
|
|---|---|
|
|
275
281
|
| `Plugin 'panerelay' returned success=false` (no detail) | Generic wrapper for any plugin error. Query the native host directly (above) or run `check-panerelay.sh` to get the real message. Most often multiple ready browsers. |
|
|
276
282
|
| `Multiple Panerelay browsers are ready` | Several browser processes carry the extension. Set `PANERELAY_BROWSER_ID` — see the section above. |
|
|
277
|
-
| Still fails right after fixing the real cause | The session daemon **sticks to the browser it first resolved**. Re-run under a fresh `--session` name. Do **not** use `close --all` to clear it — it is not session-scoped and closes every session, including unrelated ones. |
|
|
283
|
+
| Still fails right after fixing the real cause | The session daemon **sticks to the browser it first resolved**. Re-run under a fresh `--session` name (provider-resolution failures only — on a challenge follow [`challenge.md`](challenge.md)). Do **not** use `close --all` to clear it — it is not session-scoped and closes every session, including unrelated ones. |
|
|
278
284
|
| `CDP error (Target.createTarget): No current window` | That `PANERELAY_BROWSER_ID` names a registration whose window has closed. Pick another. |
|
|
279
285
|
| `Creating a new tab requires all-tabs authorization` | Panerelay defaults to **per-tab** consent. Open the side panel and authorize all tabs, or drive an already-authorized tab. Safe to grant inside a dedicated profile. |
|
|
280
286
|
| `Extension is not currently connected` | Extension not installed in the profile, or its side panel was never opened. Open the panel. |
|
|
@@ -28,6 +28,7 @@ CHECKS · FIX ROUTING · DERIVES-FROM** (+ a `<id>.knowledge.hash` sidecar).
|
|
|
28
28
|
| `model-resolution` | model:resolve handler, roles/preset, @role resolvability |
|
|
29
29
|
| `apple-tools` | iMCP (Apple PIM) provisioning state for the apple-tools plugin |
|
|
30
30
|
| `oauth-redirect-base` | which OAuth redirect base won + its tier (reverse-proxy `redirect_uri_mismatch`) |
|
|
31
|
+
| `mcp-builtin` | pi built-in MCP + per-session `pi-dashboard` registration (adapter installed, shadowing entry, non-strict `mcp.json`) |
|
|
31
32
|
|
|
32
33
|
## How to route
|
|
33
34
|
|