@blackbelt-technology/pi-dashboard-extension 0.7.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 +84 -29
- package/.pi/skills/browser/UPSTREAM.md +13 -1
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +305 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +4 -9
- package/.pi/skills/doctor/_lib/checks.ts +133 -54
- package/.pi/skills/doctor/_lib/derive-tokens.ts +5 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +52 -0
- 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/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -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/references/api-reference.agent.md +69 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +41 -34
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +30 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +106 -23
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +1760 -350
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +392 -71
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +846 -17
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +253 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -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 +156 -0
- package/src/local-token-header.ts +44 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-refresh.ts +95 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +36 -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 +6 -10
- package/src/pi-retry-settings.ts +91 -0
- 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 +92 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +258 -86
- package/src/role-manager.ts +38 -91
- package/src/role-model-tools.ts +44 -3
- package/src/server-auto-start.ts +331 -20
- package/src/server-launcher.ts +70 -34
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +75 -20
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/terminal-reload.ts +298 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/.pi/skills/project-init/dox-doctrine.md +0 -104
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts +0 -72
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: browser
|
|
3
|
-
description:
|
|
4
|
-
Browser automation via the `agent-browser` CLI. Use when the user needs to
|
|
5
|
-
interact with websites or Electron desktop apps — navigating pages, filling
|
|
6
|
-
forms, clicking buttons, taking screenshots, extracting data, testing web
|
|
7
|
-
apps, automating browser actions, visual UI verification, responsive checks,
|
|
8
|
-
hunting console errors, or driving the Pi Dashboard's Electron shell (main
|
|
9
|
-
window, wizard window, doctor window, tray, native menus). Triggers include
|
|
10
|
-
"open a website", "fill out a form", "click a button", "take a screenshot",
|
|
11
|
-
"scrape data", "test this web app", "automate browser", "test responsive",
|
|
12
|
-
"debug blank page", "automate Slack app", "control VS Code", "attach to
|
|
13
|
-
Electron app", "screenshot Pi Dashboard", "drive the wizard window".
|
|
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".'
|
|
14
4
|
license: Apache-2.0
|
|
15
|
-
allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*)
|
|
5
|
+
allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(npx @panerelay/setup:*), Bash(curl:*)
|
|
16
6
|
metadata:
|
|
17
7
|
author: pi-dashboard
|
|
18
|
-
version: "1.
|
|
8
|
+
version: "1.2"
|
|
19
9
|
vendoredFrom: agent-browser
|
|
20
10
|
vendoredVersion: "0.27.0"
|
|
11
|
+
verifiedAgainstCli: "0.33.2"
|
|
21
12
|
---
|
|
22
13
|
|
|
23
14
|
# browser
|
|
@@ -25,7 +16,7 @@ metadata:
|
|
|
25
16
|
Composite skill that gives the agent eyes and hands for any browser-driven
|
|
26
17
|
task — web pages or Electron desktop apps — via the `agent-browser` CLI.
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
Three recipes:
|
|
29
20
|
|
|
30
21
|
- **Web automation** — generic web pages plus Pi Dashboard-specific helpers
|
|
31
22
|
(dashboard URL detection, responsive testing, console-error hunting).
|
|
@@ -33,25 +24,47 @@ Two recipes:
|
|
|
33
24
|
- **Electron automation** — drive any Chromium-based Electron app, including
|
|
34
25
|
a worked example for the Pi Dashboard's own shell via `--debug-cdp`.
|
|
35
26
|
Reference: [`references/electron.md`](references/electron.md).
|
|
27
|
+
- **The user's own logged-in browser** — reach SSO/2FA-gated sites using the
|
|
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).
|
|
36
36
|
|
|
37
37
|
## Step 0a — Preflight: `agent-browser` CLI must be installed
|
|
38
38
|
|
|
39
|
-
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`:
|
|
40
41
|
|
|
41
42
|
```bash
|
|
42
|
-
|
|
43
|
+
pi-dashboard-ensure <extension-package-root>/package.json
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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.
|
|
55
68
|
|
|
56
69
|
Do **not** attempt `npm install`, `pi install`, or any other install command
|
|
57
70
|
on the user's behalf — they should make that choice explicitly.
|
|
@@ -67,7 +80,9 @@ else
|
|
|
67
80
|
CDP_LIVE=$(nc -z 127.0.0.1 9222 2>/dev/null && echo yes || echo no)
|
|
68
81
|
fi
|
|
69
82
|
PD_RUNNING=$(pgrep -f "Pi Dashboard|pi-dashboard" >/dev/null 2>&1 && echo yes || echo no)
|
|
70
|
-
|
|
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"
|
|
71
86
|
```
|
|
72
87
|
|
|
73
88
|
Routing rule:
|
|
@@ -87,10 +102,34 @@ that isn't Pi Dashboard (Slack, VS Code, Figma, …), route to
|
|
|
87
102
|
`references/electron.md` even when `PD_RUNNING=no` — that recipe covers
|
|
88
103
|
launching any Electron app with `--remote-debugging-port`.
|
|
89
104
|
|
|
105
|
+
**Override (login state)**: if the target needs the user's *existing*
|
|
106
|
+
session — "use my browser", "I'm already logged in", SSO/2FA, an internal
|
|
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.
|
|
122
|
+
|
|
90
123
|
## Step 1 — Read the matched recipe and execute
|
|
91
124
|
|
|
92
|
-
Read the reference file selected above, then follow its workflow.
|
|
93
|
-
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`.
|
|
94
133
|
|
|
95
134
|
## Notes
|
|
96
135
|
|
|
@@ -98,6 +137,22 @@ references are self-contained; you do not need to read both.
|
|
|
98
137
|
snapshots of upstream `agent-browser` skill content (`core` and
|
|
99
138
|
`electron`) at CLI version 0.27.0. See [`UPSTREAM.md`](UPSTREAM.md) for
|
|
100
139
|
refresh procedure and [`LICENSE`](LICENSE) for upstream attribution.
|
|
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.
|
|
147
|
+
- **Surfaces share one browser**: the `browser` MCP tool and
|
|
148
|
+
`Bash: agent-browser …` drive the *same* daemon and *same* Chrome, with a
|
|
149
|
+
shared active page. Probing with one mid-task can silently move the page
|
|
150
|
+
out from under the other. Pick one surface per task; use
|
|
151
|
+
`--session <name>` for genuinely isolated browsers.
|
|
152
|
+
- **Known wrapper bug**: the MCP tool's `eval` echoes the JS source instead
|
|
153
|
+
of executing it (and mangles regex escapes) — still present with CLI
|
|
154
|
+
0.33.2, so it is a `pi-agent-browser` wrapper defect, not a CLI one. Use
|
|
155
|
+
`Bash: agent-browser eval …` instead.
|
|
101
156
|
- **No CLI bundled**: agents installing the bridge extension get the
|
|
102
157
|
skill text but not the CLI; install on demand per Step 0a.
|
|
103
158
|
- **User-local override**: if the user's project has its own
|
|
@@ -5,6 +5,13 @@ snapshots of upstream `agent-browser` skill content. The Pi Dashboard
|
|
|
5
5
|
addenda appended to `web.md` and the "Worked example: Pi Dashboard"
|
|
6
6
|
section in `electron.md` are project-specific and not from upstream.
|
|
7
7
|
|
|
8
|
+
**Not vendored — do not overwrite on refresh:**
|
|
9
|
+
`references/own-browser.md` and `scripts/check-panerelay.sh` are authored
|
|
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.
|
|
14
|
+
|
|
8
15
|
| Field | Value |
|
|
9
16
|
|------------------------|--------------------------------------------------------------------|
|
|
10
17
|
| Upstream repo | https://github.com/vercel-labs/agent-browser |
|
|
@@ -38,7 +45,12 @@ diff <(awk 'BEGIN{n=0} /^---$/{n++; next} n>=2{print}' /tmp/electron.md) referen
|
|
|
38
45
|
# Preserve the Pi Dashboard addenda (after the first `---` separator
|
|
39
46
|
# in web.md, and the "Worked example: Pi Dashboard" section in
|
|
40
47
|
# electron.md). Update the LICENSE file if the upstream license text
|
|
41
|
-
# has changed.
|
|
48
|
+
# has changed. Leave own-browser.md, challenge.md and
|
|
49
|
+
# check-panerelay.sh untouched.
|
|
50
|
+
|
|
51
|
+
# 5. Re-verify the authored recipe against the new CLI, then bump
|
|
52
|
+
# `verifiedAgainstCli` in SKILL.md frontmatter:
|
|
53
|
+
# bash scripts/check-panerelay.sh
|
|
42
54
|
```
|
|
43
55
|
|
|
44
56
|
The CLI version is the source of truth for the content; the upstream tag
|
|
@@ -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.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# electron.md — index
|
|
2
|
+
|
|
3
|
+
Pull-only condensed map. Source: packages/extension/.pi/skills/browser/references/electron.md. Electron app + CDP workflow → key command/fact.
|
|
4
|
+
|
|
5
|
+
## Core Workflow
|
|
6
|
+
- Loop — launch Electron with remote debugging → `agent-browser connect 9222` → `snapshot -i` → interact via `@eN` refs → re-snapshot after state change.
|
|
7
|
+
- Launch+connect — `open -a "Slack" --args --remote-debugging-port=9222`; `agent-browser connect 9222`.
|
|
8
|
+
|
|
9
|
+
## Launching Electron Apps with CDP
|
|
10
|
+
- Every Electron app supports `--remote-debugging-port` (built into Chromium).
|
|
11
|
+
- macOS — `open -a "<App>" --args --remote-debugging-port=9222`: Slack 9222, VS Code 9223, Discord 9224, Figma 9225, Notion 9226, Spotify 9227.
|
|
12
|
+
- Linux — `slack --remote-debugging-port=9222`, `code --remote-debugging-port=9223`, `discord --remote-debugging-port=9224`.
|
|
13
|
+
- Windows — full exe path: `"C:\Users\%USERNAME%\AppData\Local\slack\slack.exe" --remote-debugging-port=9222`, `...\Programs\Microsoft VS Code\Code.exe` 9223.
|
|
14
|
+
- Quit running instance first — flag must be present at launch time; relaunch with flag.
|
|
15
|
+
|
|
16
|
+
## Connecting
|
|
17
|
+
- `agent-browser connect 9222` — subsequent commands target connected app, no `--cdp` needed.
|
|
18
|
+
- `--cdp 9222` per command; `--auto-connect` discovers a running Chromium-based app.
|
|
19
|
+
|
|
20
|
+
## Tab Management
|
|
21
|
+
- `agent-browser tab` — list all targets (windows, webviews).
|
|
22
|
+
- `tab 2` switch by index; `tab --url "*settings*"` switch by URL pattern.
|
|
23
|
+
|
|
24
|
+
## Webview Support
|
|
25
|
+
- Electron `<webview>` elements auto-discovered as targets with `type: "webview"`.
|
|
26
|
+
- Switch via `agent-browser tab 1`, then interact normally (snapshot, click, screenshot).
|
|
27
|
+
- Works via raw CDP connection.
|
|
28
|
+
|
|
29
|
+
## Common Patterns
|
|
30
|
+
- Inspect+Navigate — launch, `sleep 3`, connect, snapshot, `click @eN`, re-snapshot.
|
|
31
|
+
- Screenshots — `screenshot app-state.png`, `--full`, `--annotate`.
|
|
32
|
+
- Extract data — snapshot -i, `get text @e5`, `snapshot --json > app-state.json`.
|
|
33
|
+
- Fill forms — snapshot, fill, `press Enter`, `wait 1000`.
|
|
34
|
+
- Multiple apps — `--session slack connect 9222` / `--session vscode connect 9223`; interact independently.
|
|
35
|
+
|
|
36
|
+
## Color Scheme
|
|
37
|
+
- CDP default may be `light` — `--color-scheme dark snapshot -i` or `AGENT_BROWSER_COLOR_SCHEME=dark`.
|
|
38
|
+
|
|
39
|
+
## Troubleshooting
|
|
40
|
+
- "Connection refused"/"Cannot connect" — app not launched with flag; was already running (quit + relaunch); port in use — `lsof -i :9222`.
|
|
41
|
+
- App launches but connect fails — `sleep 3` after launch; webview init takes time.
|
|
42
|
+
- Elements missing in snapshot — multiple webviews; `agent-browser tab` to list, switch to right target.
|
|
43
|
+
- Cannot type — `keyboard type "text"` at current focus (no selector) or `keyboard inserttext "text"` to bypass key events (custom input components).
|
|
44
|
+
|
|
45
|
+
## Supported Apps
|
|
46
|
+
- Any Electron app works — Slack, Discord, Teams, Signal, Telegram Desktop; VS Code, GitHub Desktop, Postman, Insomnia; Figma, Notion, Obsidian; Spotify, Tidal; Todoist, Linear, 1Password.
|
|
47
|
+
|
|
48
|
+
## Worked example: Pi Dashboard
|
|
49
|
+
- Opt-in CDP — `--debug-cdp` CLI flag or `PI_DEBUG_CDP` env var; flag takes precedence; default port 9222.
|
|
50
|
+
- Single-instance contract — must fully quit + relaunch; `--debug-cdp` on a running instance only logs a warning to stderr; Chromium stands up CDP server at browser-process init, no API to enable later.
|
|
51
|
+
- macOS — `osascript -e 'quit app "PI Dashboard"'`; `open -a "PI Dashboard" --args --debug-cdp` (default 9222); custom port `--debug-cdp=9333`.
|
|
52
|
+
- Linux/Windows — `PI_DEBUG_CDP=1 /path/to/pi-dashboard` (default 9222); `PI_DEBUG_CDP=9444` custom port.
|
|
53
|
+
- Dev (this repo) — `cd packages/electron && npm run dev:cdp`.
|
|
54
|
+
- Activation proof — stderr line `[debug-cdp] CDP listening on :9222 — local automation is enabled`; line missing = CDP not active → halt recipe, tell user to relaunch with flag.
|
|
55
|
+
- Connect + list windows — `agent-browser connect 9222`; `agent-browser tab` shows main window `http://localhost:8000/`, wizard `file:///.../wizard.html`, doctor `file:///.../doctor.html`; switch with `tab <index>`.
|
|
56
|
+
- Drive windows — `tab 0` + `screenshot pi-dashboard.png` (main); `tab 1` + `snapshot -i` → click "Launch dashboard" (wizard); `tab 2` + `screenshot doctor.png` (doctor).
|
|
57
|
+
- Cleanup — `agent-browser close` disconnects session but does NOT quit the app (CDP stays active for next connection); end CDP entirely by quitting the app.
|