@capybara-hq/plugin-browser 0.1.0-rc.3 → 0.1.0-rc.5

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.3",
4
+ "version": "0.1.0-rc.5",
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,7 +17,7 @@
17
17
  "entry": "./dist/index.mjs",
18
18
  "manifest": {
19
19
  "name": "browser",
20
- "version": "0.1.0-rc.3",
20
+ "version": "0.1.0-rc.5",
21
21
  "sdk": "^0.1.0-rc.69",
22
22
  "provides": [],
23
23
  "requires": [],
package/README.md CHANGED
@@ -27,7 +27,8 @@ A real browser in the person's device for agents (browser use spec,
27
27
  extension instance), sends one `ToolRequest` and reports the hosts the device refused with
28
28
  `reportBlockedHosts` (the kernel raises the network ask and reruns the call once allowed).
29
29
  - `browser_handoff` sends the daemon a handoff notice (the panels show a banner with 完成 / 取消),
30
- then raises an `InputRequired` question `{ done: boolean }` in the conversation (a boolean, not
30
+ then raises an `InputRequired` question `{ done: boolean }` in the conversation, with `open`
31
+ naming the `browser` panel so the person's conversation page opens it (a boolean, not
31
32
  a 完成 / 取消 enum: the kernel's `answerHandoff`, which the banner uses, answers `{ done }`); on
32
33
  resume it clears the notice (with Done also handing the browser back, so a takeover the person
33
34
  still holds ends) and returns the page snapshot, or fails with "The user cancelled the handoff;
@@ -43,14 +44,40 @@ A real browser in the person's device for agents (browser use spec,
43
44
 
44
45
  ## The daemon (`daemon/`)
45
46
 
46
- - Chromium starts on the daemon's first start. A launch that fails (no download, a refused
47
- network) does not stop the daemon: every request answers the cause and launches again. When the
48
- device's proxy refuses Playwright's download hosts (`cdn.playwright.dev`,
49
- `playwright.download.prss.microsoft.com`, `storage.googleapis.com` where the CDN redirects the
50
- headless shell, or `PLAYWRIGHT_DOWNLOAD_HOST`), the reply lists them
51
- as blocked hosts, so the person is asked to allow them. A `PLAYWRIGHT_BROWSERS_PATH` in the
52
- device's environment that already holds this build's headless shell revision is used as is
53
- (a read-only image cache); otherwise the browser is installed into `<state>/browsers`.
47
+ - Chromium starts on the daemon's first start. On Linux devices (device-docker, device-e2b) it is
48
+ the full Chromium build in its new headless mode, so the browser presents as an ordinary Chrome:
49
+ Chrome's own reduced user agent for the platform (`--user-agent`, never "HeadlessChrome"), the
50
+ browser's own client hints, a window the size of the viewport, the device's locale and time zone.
51
+ On macOS (device-local) it is the headless shell in one process: the local device sandbox refuses
52
+ the full build's Mach service registrations. Nothing spoofs a fingerprint, solves a CAPTCHA or
53
+ hides automation beyond Playwright's own flags (`navigator.webdriver` stays true).
54
+ - Where the browser comes from (plugins#209: never from a place the service or an agent command
55
+ could write once it runs): the provider's install directory `CAPYBARA_SERVICE_INSTALL`
56
+ (device-local) is filled on the first start, sealed with `.sealed`, and the daemon answers
57
+ `restart` and exits, so every later start runs it read only (the plugin starts the service again
58
+ within the same tool call; an unsealed directory is always installed afresh, never trusted as
59
+ found); else a `PLAYWRIGHT_BROWSERS_PATH` the daemon cannot write, outside the workspace
60
+ (device-docker / device-e2b ship it in `/opt/capybara-browsers`, pinned to this package's
61
+ playwright-core): this build's revision, else the newest revision of the build there. Nothing
62
+ else: without such a place the browser does not start and says how to get one (update
63
+ capybara-device; recreate a cloud device on the current image). It never installs where it
64
+ could rewrite the browser itself.
65
+ - Uploads are read by the daemon (opened without following a final link, accepted only when the
66
+ resolved path lies in the workspace and names the very file opened) and handed to Chromium from
67
+ memory, at most 50 MiB; downloads are copied from Playwright's private file into an exclusively
68
+ created file in `<workspace>/downloads`, checked to be that directory's own before any byte is
69
+ written. So a link the agent plants in the workspace never makes the service read or write its
70
+ own profile.
71
+ - A launch that fails (no download, a refused network) does not stop the daemon: every request
72
+ answers the cause and launches again. When the device's proxy refuses Playwright's download
73
+ hosts (`cdn.playwright.dev`, `playwright.download.prss.microsoft.com`, `storage.googleapis.com`
74
+ where the CDN redirects the download, or `PLAYWRIGHT_DOWNLOAD_HOST`), the reply lists them as
75
+ blocked hosts, so the person is asked to allow them.
76
+ - Verification pages (bot checks, CAPTCHAs: recognised by URL, title, a visible CAPTCHA widget,
77
+ or a 418 / 429 document): every tool result while one shows starts with a note telling the agent
78
+ to call `browser_handoff` instead of solving it or switching sites, and the viewer's tab state
79
+ carries `blocker: { kind: "verification", url }` on that tab (cleared when its page changes) for
80
+ the panel's "需要你完成验证" strip.
54
81
  - The daemon stops after 15 minutes without requests and viewers. A pending handoff keeps it
55
82
  running for up to 24 hours after its notice (the person may take a while to sign in); the
56
83
  device's own idle suspension can still stop it sooner, and then the question stays open in the
@@ -59,21 +86,86 @@ A real browser in the person's device for agents (browser use spec,
59
86
  10 minutes of the last write (a provider that restarts the service for a network change, see
60
87
  device-local) reopens them; an idle stop removes the file. The profile keeps cookies and storage
61
88
  on its own.
89
+ - `<state>/cookies.json` holds the persistent cookies from the moment a stop begins until the next
90
+ start has merged the ones the profile lacks (then it is removed, so a logout while the browser
91
+ ran is never undone by an old file). It exists because the service's kill (2 s after SIGTERM)
92
+ can land while a loaded Chromium is still writing its Cookies file. It lives in the service
93
+ state directory, outside every workspace and project (core `packages/device`), mode 0600, and
94
+ holds what Chromium's own `profile/Default/Cookies` holds there. That file is not protected
95
+ either: the daemon runs Chromium with `--use-mock-keychain`, so its values are only obfuscated
96
+ with a key every Chromium shares (observed: `encrypted_value` of 51 bytes, readable by anyone
97
+ who can read the directory). The JSON therefore adds no exposure.
62
98
  - A `handoff_clear` with `handback` (the person answered Done) also ends a takeover. Dropping a
63
99
  handoff on the next agent request is device-wide: every conversation of the device is the
64
100
  owner's.
101
+ - Viewer input (mouse, keys, text, address bar, tabs) is applied only while the person holds
102
+ control: a viewer in the watch state is read-only and its input is dropped on arrival, and input
103
+ still queued when control returns to the agent is dropped too (input already running, a navigation
104
+ or a long paste, finishes). Keys and buttons the person still holds are released when control
105
+ returns to the agent or the viewer ends, each on the tab where it was pressed (a held button after
106
+ moving the pointer outside the viewport, so the release completes no click), so the agent never
107
+ inherits a held Shift or a drag. Mouse moves are coalesced (the newest position wins while one
108
+ waits). After a move, click or scroll the daemon answers the page's cursor under the pointer
109
+ (`cursor`, only when it changed), off the input queue (the newest position wins, one lookup at a
110
+ time, an answer later than 200 ms is dropped) and without page code: CDP hit-tests the point
111
+ (`DOM.getNodeForLocation`, through shadow roots and in-process frames) and a function in an
112
+ isolated world reads the computed `cursor`, resolving `auto` as Chromium does (an I-beam over
113
+ editable fields and text); `pointer-events: none` elements are skipped as Chromium does;
114
+ out-of-process frames are entered through their own session (at most 20 frames looked at, 3
115
+ levels, matched in the page's coordinates), detached with their frame or when the viewer leaves
116
+ the page.
117
+ - Frames are binary messages (`encodeFrame`: tag, seq, width, height, JPEG); every other message is
118
+ JSON. Pacing (`daemon/viewer-pacing.ts`): the daemon pings each viewer every second (the path's
119
+ own round trip) and compares each frame's ack round trip with it. While frames take longer than
120
+ 120 ms over it (a click would wait that long behind them on the slowest hop), it lowers the JPEG
121
+ quality (60, 45, 35, 25) and then the scale (down to half), allows only one frame in flight, and
122
+ steps back up after six quick frames. At most 15 frames per second; only the newest frame waits
123
+ (a stale one is replaced), and Chromium encodes the next frame at most every 500 ms while one
124
+ waits. JSON messages (state, cursor, pings, dialogs) never wait behind a held frame.
65
125
 
66
126
  ## The panel (`ui-src/panel/`)
67
127
 
68
128
  - Every viewer is the owner's: any non-compact panel is interactive (keys, pointer, Esc) while the
69
- person holds control, whichever panel took it, and asks for full-viewport frames then. Nothing
70
- is kept in storage (the sandboxed iframe has none); a remount rebuilds from the daemon's first
71
- state. Take over is offered only in the live view; handing back with a pending handoff answers
72
- it Done.
73
- - 允许 allows the blocked host, then opens the blocked page (the blocked navigation, or the page
74
- whose resource was refused), again on the next connection if the browser restarted. A 4404 is
75
- retried twice (1 s, 3 s) before "not running", which looks for the browser every 10 s while
76
- visible, for 30 minutes at most (a ticket never starts the service). A refused allow or answer
77
- shows the kernel's reason.
129
+ person holds control, whichever panel took it, and may ask for frames up to the full viewport
130
+ then. In the watch state the panel is read-only (no pointer, keys, address bar, tabs or
131
+ navigation; the cursor is the arrow). Nothing is kept in storage (the sandboxed iframe has none);
132
+ a remount rebuilds from the daemon's first state. Take over is offered only in the live view;
133
+ handing back with a pending handoff answers it Done.
134
+ - Takeover input (`ui-src/panel/input.ts`): button and wheel events at once, moves coalesced to the
135
+ newest position at most every 33 ms (hover effects, menus and tooltips render in the stream), a
136
+ drag reported until the button is released wherever that happens; the page's cursor from the
137
+ daemon on the picture (known keywords only); a press indicator at the pointer from mousedown until
138
+ the first frame after the release (1 s at most). A visually hidden textarea holds the focus while
139
+ driving: keys go as `down` / `up` (Esc hands back), IME composition (Chinese input) as one `char`
140
+ at `compositionend`, paste as `char` with the clipboard text (Cmd/Ctrl+V itself is not sent;
141
+ text is cut at 10 000 code points). Losing the window or the focus sends `up` for held keys and
142
+ the held button; the sink gives up the focus when control returns to the agent.
143
+ - Frame size: the picture's CSS box times the device pixel ratio capped at 1.25, within 640 px wide
144
+ in the side view and the full viewport while the person drives; the daemon may send smaller
145
+ frames on a slow link (see the pacing above).
146
+ - 允许 allows the blocked host; while the person drives it then opens the blocked page (the blocked
147
+ navigation, or the page whose resource was refused), again on the next connection if the browser
148
+ restarted, taking over again first (a restarted daemon starts with the agent in control); a hand
149
+ back cancels that reopen. A 4404 after a live view (a restart) is retried twice (1 s, 3 s)
150
+ before "not running"; one before any
151
+ live view is "not running" at once. "Not running" looks for the browser quietly (it stays up
152
+ until the browser answers) every 10 s while visible, for 30 minutes at most (a ticket never
153
+ starts the service). A refused allow or answer shows the kernel's reason.
154
+ - Look (browser panel design 2026-11-25): the host's panel is the one box. The tab strip, toolbar,
155
+ status line and picture are separated by space and ground, not borders. Colours come from the
156
+ host's `--cb-*` tokens (light and dark). Until the browser's state and its first frame are there,
157
+ the whole panel is one skeleton and nothing else; then it switches once to the live panel. "Not
158
+ running", offline and error show at once. The picture is contained and centred on a neutral ground
159
+ (soft shadow; a 2 px accent ring while the person is in control). The status line has a fixed
160
+ height. Take over is there at every width: below 440 px the tabs and the address merge into one
161
+ button with a tab count, and forward and reload move into a "more" menu. On a phone (a screen
162
+ under 600 px, the host's compact class) the panel only watches. A page that asks for a human check
163
+ (the active tab's `blocker` of kind `verification`, reported by the daemon) shows a warn strip with 去验证 as the one primary
164
+ action.
165
+ - Size: the host fills its panel with the embed in both panel modes. The page posts no `resize`,
166
+ and the viewer's frame size follows the shown size. The page asks for full mode with `panel-mode`
167
+ on take over, and for the side panel on hand back (here, or when control returns to the agent
168
+ elsewhere). Its layout follows only the host's `panel-mode` (sent after `init` and on every
169
+ change). The host keeps the frame mounted across the switch, so the viewer connection survives it.
78
170
  - A dialog strip hides after 10 s or when the page changes; agent clicks flash once each; a lock
79
171
  shows a secure page. The panel listens only to messages from its host page.