@capybara-hq/plugin-browser 0.1.0-rc.10 → 0.1.0-rc.12

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.10",
4
+ "version": "0.1.0-rc.12",
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.10",
21
- "sdk": "^0.1.0-rc.75",
20
+ "version": "0.1.0-rc.12",
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
@@ -154,6 +174,57 @@ A real browser in the person's device for agents (browser use spec,
154
174
  (a stale one is replaced), and Chromium encodes the next frame at most every 500 ms while one
155
175
  waits. JSON messages (state, cursor, pings, dialogs) never wait behind a held frame.
156
176
 
177
+ ## Page dialogs, HTTP sign-in, permissions
178
+
179
+ Dialogs spec, `docs/superpowers/specs/2026-11-25-browser-dialogs-and-touch-design.md` in
180
+ capybara-hq/core.
181
+
182
+ - **Held decision dialogs.** An alert is closed at once and noted (`The page showed an alert:
183
+ "…" (closed).`). A confirm, prompt or leave-page (beforeunload) dialog is held until answered,
184
+ one per tab, with no timer and no default: the request that opened it replies at once with
185
+ `reply.dialog` (and leaves its conversation's queue: its own late failure comes as a note), and
186
+ every later reply of that conversation names it (its active tab's first). While it is held the
187
+ tab's snapshot returns the dialog line instead of the tree, other actions on the tab, a
188
+ screenshot too (a modal dialog stops the page's renderer, even a capture never answers), fail at
189
+ once with `dialog_open`, and the tab is pinned (a park: no idle close, no eviction, no adopt).
190
+ Actions on other tabs go on, except in a one-process browser (the macOS headless shell), where a
191
+ held dialog stops every page: there every acting request is refused at once meanwhile (the
192
+ owner's naming its dialog, others a generic text) instead of hanging.
193
+ - **`browser_dialog`** `{ dialogId, message, action: accept | dismiss, text? }` (`ask`) answers
194
+ one dialog of the conversation's own tabs (another conversation's is refused with the adopt
195
+ text). `message` must match the dialog's quote: CRLF as LF, whitespace runs as one space,
196
+ trimmed, cut to 300 code points; the tool results quote exactly that (JSON string), so an
197
+ approval covers exactly the dialog it shows. A prompt accepted without text takes its default.
198
+ It runs beside the action queue and is refused while the person holds control.
199
+ - **HTTP Basic sign-in.** A main-frame `401` with `WWW-Authenticate: Basic` becomes an auth dialog
200
+ (origin and the page-supplied realm; not blocking: the headless shell shows the 401 body, the
201
+ full build fails the navigation, which the reply then reports as the dialog instead of an
202
+ error). The agent can only dismiss it and is told to call `browser_handoff`; another scheme is
203
+ noted as unsupported. The person signs in from the panel while holding control: the username and
204
+ password go over the viewer stream straight to the daemon (the kernel relays bytes), are kept
205
+ as the header value in the daemon's memory only (never a reply, note, log line, viewer message or
206
+ file, and gone when the daemon stops) and are added by a `context.route` only to requests to that
207
+ exact origin from pages whose top-level document has that origin, and to top-level navigations
208
+ to it that the page itself or the daemon (address bar, tool, history, reload) starts: never to a
209
+ cross-site page's request, a redirect into the origin or a service worker. A `401` to a signed
210
+ request drops the credentials and asks again. They are device-wide by origin, like the profile.
211
+ - **Permission requests.** An init script wraps `Notification.requestPermission`, the clipboard
212
+ reads, the geolocation error callbacks and `getUserMedia`, and reports a refusal through a
213
+ binding with a per-daemon random name (the page gets the very same result). Any page can call
214
+ the binding, so only a known permission name is read: the origin is the calling frame's, at most
215
+ 5 reports per page load and 50 origin–permission pairs. The owner's next reply notes it once per
216
+ pair; the tree's viewers get a `permission` strip, and the person in control may allow
217
+ notifications or clipboard reading for that origin (`grantPermissions`, for the daemon's life,
218
+ only for a pair recorded on a tab of the viewer's tree). Geolocation, camera and microphone are
219
+ reported as unavailable.
220
+ - **Phone viewport and touch.** Only the person in control switches (`viewport` `phone`: 390×844,
221
+ scale 2, mobile, touch, a mobile user agent from the browser's own version); every tab and tabs
222
+ opened meanwhile get it (a tab's first document may keep the desktop user agent until a reload).
223
+ Hand back restores the desktop profile ahead of every conversation's next request, so the agent
224
+ always acts on 1280×800. Touch input is dispatched as touch events in phone and becomes a click
225
+ (tap) or a scroll (one-finger pan) in desktop. Viewer input clamps and the screencast follow the
226
+ profile; the profile switch is ordered with the person's input.
227
+
157
228
  ## Tabs
158
229
 
159
230
  Tab ownership spec, `docs/superpowers/specs/2026-11-25-browser-tab-ownership-design.md` in
@@ -183,15 +254,28 @@ shared by every conversation, the tabs are not.
183
254
  - **Idle close.** A conversation's tabs close after 15 minutes without a request, without an open
184
255
  panel showing it and without a pending park; its per-conversation state goes with them. The
185
256
  profile is never touched.
257
+ - **Deleted conversations.** The kernel's conversation-deleted notice (a kernel request body, SDK
258
+ `parseConversationDeleted`) closes the tabs of the conversation and of its sub-agent
259
+ conversations at once, parked ones included, forgets their state and drops them from the
260
+ session file; it answers `{ ok: true, closed }` and a repeat closes nothing. The kernel keeps the
261
+ notice owed while the device is offline or the service is stopped within the restore window
262
+ (`DEVICE_SERVICE_RESTORE_MAX_AGE_MS`, also the session file's limit); the idle close is the
263
+ backstop. The profile is never touched.
186
264
  - **Takeover per device.** While the person controls the browser from any conversation's panel,
187
265
  every conversation's agent requests are refused. Afterwards only the conversations whose tabs the
188
266
  takeover concerned are told that the user had control.
189
267
 
190
268
  ## The panel (`ui-src/panel/`)
191
269
 
192
- - Every viewer is the owner's: any non-compact panel is interactive (keys, pointer, Esc) while the
270
+ - Every viewer is the owner's: any panel is interactive (keys, pointer, touch, Esc) while the
193
271
  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,
272
+ then. A phone takes over inside its drawer (no full mode) and, like a touch screen, shows a
273
+ takeover bar: 手机宽度 / 桌面宽度, 键盘 (raises the soft keyboard; its text, delete and line
274
+ break reach the page) and 交还智能体, with 44 px targets; the phone width is suggested once per
275
+ takeover, never switched for the person. A held page dialog shows as a box over the picture
276
+ (page text as text): answer controls for the person in control (确定 / 取消, a prompt field, 离开 /
277
+ 留下, username + password + 登录 / 取消; the password field is cleared after sending), read-only
278
+ 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
279
  navigation or tab open / close; the cursor is the arrow), but a click on a tab of the strip shows
196
280
  that tab, and 其他对话 / Other conversations › 移到此对话 / Move here moves another conversation's
197
281
  tab here. Nothing is kept in storage (the sandboxed iframe has none);