@capybara-hq/plugin-browser 0.1.0-rc.11 → 0.1.0-rc.13

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "browser",
4
- "version": "0.1.0-rc.11",
4
+ "version": "0.1.0-rc.13",
5
5
  "publisher": "Capybara",
6
6
  "description": {
7
7
  "en": "A real browser in the conversation owner's device for agents: navigate, read and act on pages through tools, with a live view in the conversation panel and takeover by the person",
@@ -17,8 +17,8 @@
17
17
  "entry": "./dist/index.mjs",
18
18
  "manifest": {
19
19
  "name": "browser",
20
- "version": "0.1.0-rc.11",
21
- "sdk": "^0.1.0-rc.75",
20
+ "version": "0.1.0-rc.13",
21
+ "sdk": "^0.1.0-rc.83",
22
22
  "provides": [],
23
23
  "requires": [],
24
24
  "optional": [],
@@ -38,7 +38,8 @@
38
38
  "browser_click_at",
39
39
  "browser_type_at",
40
40
  "browser_wait",
41
- "browser_handoff"
41
+ "browser_handoff",
42
+ "browser_dialog"
42
43
  ],
43
44
  "http": [
44
45
  {
package/README.md CHANGED
@@ -21,7 +21,8 @@ A real browser in the person's device for agents (browser use spec,
21
21
  - Tools (`plugin__browser__<name>`): `browser_navigate`, `browser_tabs`, `browser_snapshot`,
22
22
  `browser_screenshot`, `browser_wait` and `browser_handoff` declare `defaultPolicy: "allow"`;
23
23
  `browser_click`, `browser_type`, `browser_select`, `browser_press`, `browser_scroll`,
24
- `browser_hover`, `browser_upload`, `browser_click_at` and `browser_type_at` declare `ask`.
24
+ `browser_hover`, `browser_upload`, `browser_click_at`, `browser_type_at` and `browser_dialog`
25
+ declare `ask`.
25
26
  Each call runs only for the conversation's owner, starts the `browser` service through
26
27
  `ctx.deviceAccess.ensureService` (files: every file under `ui/service/`, read once per
27
28
  extension instance), sends one `ToolRequest` and reports the hosts the device refused with
@@ -39,6 +40,15 @@ A real browser in the person's device for agents (browser use spec,
39
40
  resume it clears the notice (with Done also handing the browser back, so a takeover the person
40
41
  still holds ends) and returns the page snapshot, or fails with "The user cancelled the handoff;
41
42
  ask the user how to continue, or try another approach.".
43
+ - `browser_wait` (browser long waits spec, `2026-11-25-browser-long-waits-design.md` in core): at
44
+ most one condition (`text`, `ref`, `urlContains`, `navigation`, `download`) and `timeoutMs` up
45
+ to 24 h. A wait of 60 s or less is one `op: "wait"` in the call. A longer one needs a condition:
46
+ the first invocation sends `watch_start` (watch id: the first 32 hex characters of the call's
47
+ idempotency key; `remainingMs`, never an absolute time) and returns a watched `InputRequired`
48
+ (one 结束等待 / End wait button, `watch.deadlineMs`). The tool's watcher (`src/wait.ts`) sends
49
+ `watch_poll` with `ifRunning` (a stopped device or service settles the wait, nothing is started
50
+ or resumed); the resumed invocation sends `watch_end` with `ifRunning` and maps the latched state
51
+ and `resume.outcome` to the result or an actionable error.
42
52
  - `browser_screenshot` asks for at most 2 MiB and retries once at half that when the reply did
43
53
  not fit in one service message. A refused host's error ends with one next step (the user is
44
54
  asked to allow it); a service start that fails has its own text.
@@ -53,6 +63,16 @@ A real browser in the person's device for agents (browser use spec,
53
63
 
54
64
  ## The daemon (`daemon/`)
55
65
 
66
+ - Long waits (`daemon/watches.ts`): `watch_start` binds a watch to the conversation's active tab
67
+ (refused without one) and latches the first outcome, checked every 500 ms: met, or ended by a
68
+ confirm / prompt dialog on the tab (`dialog`), the tab closing (`tab_closed`) or its remaining
69
+ time on the device's clock (`deadline`); a download watch is met when the owner's next download
70
+ is saved (`detail`: its path). `watch_poll` answers the state and is the heartbeat: a watch not
71
+ polled for 10 minutes is dropped. At most 16 watches (a 17th drops the oldest latched one, else
72
+ the oldest). A pending watch is the conversation's park. Watch ops bypass the takeover refusal
73
+ and never drop a pending handoff; `watch_start` and `watch_poll` take neither the hand back note
74
+ nor the unreported notes, `watch_end` does. Viewers of the tree get `state.waiting`.
75
+
56
76
  - Chromium starts on the daemon's first start. On Linux devices (device-docker, device-e2b) it is
57
77
  the full Chromium build in its new headless mode, so the browser presents as an ordinary Chrome:
58
78
  Chrome's own reduced user agent for the platform (`--user-agent`, never "HeadlessChrome"), the
@@ -63,6 +83,12 @@ A real browser in the person's device for agents (browser use spec,
63
83
  nothing larger is downloaded). First start there: one download into the install directory (about 377 MB, 16 s on a fast
64
84
  link), one restart, then about 2 s to launch. Nothing spoofs a fingerprint, solves a CAPTCHA or
65
85
  hides automation beyond Playwright's own flags (`navigator.webdriver` stays true).
86
+ - Chromium runs with `--no-sandbox` (Playwright's default, `chromiumSandbox: false`) on Linux devices.
87
+ This is a decision (plugins#286): the device container is the isolation boundary (`CapDrop: ALL`,
88
+ `no-new-privileges`, Docker's default seccomp profile, egress through the proxy), and the agent can
89
+ already run arbitrary commands in that container, so a renderer escape gains nothing beyond what
90
+ the agent has. Chromium's sandbox would need user namespaces or a custom seccomp profile for every
91
+ command in the device (rejected), or a separate browser container (not planned now).
66
92
  - Where the browser comes from (plugins#209: never from a place the service or an agent command
67
93
  could write once it runs): the provider's install directory `CAPYBARA_SERVICE_INSTALL`
68
94
  (device-local) is filled on the first start, sealed with `.sealed`, and the daemon answers
@@ -154,6 +180,57 @@ A real browser in the person's device for agents (browser use spec,
154
180
  (a stale one is replaced), and Chromium encodes the next frame at most every 500 ms while one
155
181
  waits. JSON messages (state, cursor, pings, dialogs) never wait behind a held frame.
156
182
 
183
+ ## Page dialogs, HTTP sign-in, permissions
184
+
185
+ Dialogs spec, `docs/superpowers/specs/2026-11-25-browser-dialogs-and-touch-design.md` in
186
+ capybara-hq/core.
187
+
188
+ - **Held decision dialogs.** An alert is closed at once and noted (`The page showed an alert:
189
+ "…" (closed).`). A confirm, prompt or leave-page (beforeunload) dialog is held until answered,
190
+ one per tab, with no timer and no default: the request that opened it replies at once with
191
+ `reply.dialog` (and leaves its conversation's queue: its own late failure comes as a note), and
192
+ every later reply of that conversation names it (its active tab's first). While it is held the
193
+ tab's snapshot returns the dialog line instead of the tree, other actions on the tab, a
194
+ screenshot too (a modal dialog stops the page's renderer, even a capture never answers), fail at
195
+ once with `dialog_open`, and the tab is pinned (a park: no idle close, no eviction, no adopt).
196
+ Actions on other tabs go on, except in a one-process browser (the macOS headless shell), where a
197
+ held dialog stops every page: there every acting request is refused at once meanwhile (the
198
+ owner's naming its dialog, others a generic text) instead of hanging.
199
+ - **`browser_dialog`** `{ dialogId, message, action: accept | dismiss, text? }` (`ask`) answers
200
+ one dialog of the conversation's own tabs (another conversation's is refused with the adopt
201
+ text). `message` must match the dialog's quote: CRLF as LF, whitespace runs as one space,
202
+ trimmed, cut to 300 code points; the tool results quote exactly that (JSON string), so an
203
+ approval covers exactly the dialog it shows. A prompt accepted without text takes its default.
204
+ It runs beside the action queue and is refused while the person holds control.
205
+ - **HTTP Basic sign-in.** A main-frame `401` with `WWW-Authenticate: Basic` becomes an auth dialog
206
+ (origin and the page-supplied realm; not blocking: the headless shell shows the 401 body, the
207
+ full build fails the navigation, which the reply then reports as the dialog instead of an
208
+ error). The agent can only dismiss it and is told to call `browser_handoff`; another scheme is
209
+ noted as unsupported. The person signs in from the panel while holding control: the username and
210
+ password go over the viewer stream straight to the daemon (the kernel relays bytes), are kept
211
+ as the header value in the daemon's memory only (never a reply, note, log line, viewer message or
212
+ file, and gone when the daemon stops) and are added by a `context.route` only to requests to that
213
+ exact origin from pages whose top-level document has that origin, and to top-level navigations
214
+ to it that the page itself or the daemon (address bar, tool, history, reload) starts: never to a
215
+ cross-site page's request, a redirect into the origin or a service worker. A `401` to a signed
216
+ request drops the credentials and asks again. They are device-wide by origin, like the profile.
217
+ - **Permission requests.** An init script wraps `Notification.requestPermission`, the clipboard
218
+ reads, the geolocation error callbacks and `getUserMedia`, and reports a refusal through a
219
+ binding with a per-daemon random name (the page gets the very same result). Any page can call
220
+ the binding, so only a known permission name is read: the origin is the calling frame's, at most
221
+ 5 reports per page load and 50 origin–permission pairs. The owner's next reply notes it once per
222
+ pair; the tree's viewers get a `permission` strip, and the person in control may allow
223
+ notifications or clipboard reading for that origin (`grantPermissions`, for the daemon's life,
224
+ only for a pair recorded on a tab of the viewer's tree). Geolocation, camera and microphone are
225
+ reported as unavailable.
226
+ - **Phone viewport and touch.** Only the person in control switches (`viewport` `phone`: 390×844,
227
+ scale 2, mobile, touch, a mobile user agent from the browser's own version); every tab and tabs
228
+ opened meanwhile get it (a tab's first document may keep the desktop user agent until a reload).
229
+ Hand back restores the desktop profile ahead of every conversation's next request, so the agent
230
+ always acts on 1280×800. Touch input is dispatched as touch events in phone and becomes a click
231
+ (tap) or a scroll (one-finger pan) in desktop. Viewer input clamps and the screencast follow the
232
+ profile; the profile switch is ordered with the person's input.
233
+
157
234
  ## Tabs
158
235
 
159
236
  Tab ownership spec, `docs/superpowers/specs/2026-11-25-browser-tab-ownership-design.md` in
@@ -183,15 +260,28 @@ shared by every conversation, the tabs are not.
183
260
  - **Idle close.** A conversation's tabs close after 15 minutes without a request, without an open
184
261
  panel showing it and without a pending park; its per-conversation state goes with them. The
185
262
  profile is never touched.
263
+ - **Deleted conversations.** The kernel's conversation-deleted notice (a kernel request body, SDK
264
+ `parseConversationDeleted`) closes the tabs of the conversation and of its sub-agent
265
+ conversations at once, parked ones included, forgets their state and drops them from the
266
+ session file; it answers `{ ok: true, closed }` and a repeat closes nothing. The kernel keeps the
267
+ notice owed while the device is offline or the service is stopped within the restore window
268
+ (`DEVICE_SERVICE_RESTORE_MAX_AGE_MS`, also the session file's limit); the idle close is the
269
+ backstop. The profile is never touched.
186
270
  - **Takeover per device.** While the person controls the browser from any conversation's panel,
187
271
  every conversation's agent requests are refused. Afterwards only the conversations whose tabs the
188
272
  takeover concerned are told that the user had control.
189
273
 
190
274
  ## The panel (`ui-src/panel/`)
191
275
 
192
- - Every viewer is the owner's: any non-compact panel is interactive (keys, pointer, Esc) while the
276
+ - Every viewer is the owner's: any panel is interactive (keys, pointer, touch, Esc) while the
193
277
  person holds control, whichever panel took it, and may ask for frames up to the full viewport
194
- then. In the watch state the panel takes no page input (no pointer, keys, address bar,
278
+ then. A phone takes over inside its drawer (no full mode) and, like a touch screen, shows a
279
+ takeover bar: 手机宽度 / 桌面宽度, 键盘 (raises the soft keyboard; its text, delete and line
280
+ break reach the page) and 交还智能体, with 44 px targets; the phone width is suggested once per
281
+ takeover, never switched for the person. A held page dialog shows as a box over the picture
282
+ (page text as text): answer controls for the person in control (确定 / 取消, a prompt field, 离开 /
283
+ 留下, username + password + 登录 / 取消; the password field is cleared after sending), read-only
284
+ with 接管后可回答 otherwise. Permission requests show a strip with 允许 for a grantable one. In the watch state the panel takes no page input (no pointer, keys, address bar,
195
285
  navigation or tab open / close; the cursor is the arrow), but a click on a tab of the strip shows
196
286
  that tab, and 其他对话 / Other conversations › 移到此对话 / Move here moves another conversation's
197
287
  tab here. Nothing is kept in storage (the sandboxed iframe has none);