ac4af582301a4e8a29245dbba767eba31334ddf9
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3379ebc423 |
browser: let a tab go 20s after its last call, CDP as Claude in Chrome uses it, input a person sends
Discord again took Magpie Browser for a bot. This lines the extension
up with Claude in Chrome 1.0.105 (fcoeoabgfenejglbffodgkkbkcdhcgfn), read
from its assets/mcpPermissions-*.js, and with what a real mouse and
keyboard send:
- A tab is let go 20s after the last call in it ends (Claude's qC=2e4),
not 5 minutes after it was last attached. Before it goes, focus
emulation is turned off, as Claude's detachDebugger does. A page behind
the user's tab no longer goes on for minutes saying it has focus while
its window reports 0x0. A tab no call used is left on its clock, so
another session's calls don't hold it; typing that goes on after its
call keeps its tab (re-armed every 10s) and lets it go when it ends.
- Attach turns on Page, Network (the page can't see it; settle needs it)
and Runtime only where it was already (a dev host or browser_console),
then focus emulation once. DOM.enable and Accessibility.enable are gone:
Claude turns neither on, nothing listened to their events, and the
calls magpie makes (getFullAXTree, resolveNode, getContentQuads, ...)
work without them.
- A pressed button has pressure 0.5 (was 0; Claude sends force 0.5 when
buttons != 0). Shift, Control, Alt and Meta have location 1 (left), as
a real keyboard's; Claude passes the key's location too.
- No nativeVirtualKeyCode: it took the Windows code, and on macOS it is
read as a Mac key code. Claude doesn't send it.
- Long text keeps a person's pace (~165ms a character, quickened only
past 4 minutes) instead of fitting 35s, which reached 20+ characters a
second. browser_type answers after 40s with how far it got; the typing
goes on, and the tab's next call waits for it (BUSY after 60s).
- manifest 0.1.8.
Run on mote, headful Chrome for Testing (MAGPIE_BROWSER_HEADFUL=1):
go test ./internal/gateway -run TestBrowser -v: all 27 pass, among them
the new TestBrowserLetsATabGoAfterItsCalls (23.7s; the page's own
document.hasFocus() is on during calls and off within 15-45s after),
TestBrowserTypesALongTextAtAPersonsPace (66s, <= 9 chars/s, Enter after
the whole text) and TestBrowserActsLikeAPerson (pressure 0.5, Shift
location 1). Snapshots, frames from other sites, uploads and drags pass
without DOM/Accessibility enabled.
Broken by hand: IDLE_MS back to 5 minutes, TestBrowserLetsATabGoAfterItsCalls
is red ("still has emulated focus 45s after the last call"). Without force 0.5
on a click, TestBrowserActsLikeAPerson is red ("pressure 0: a mouse's is
0.5"); without location 1 on human.js's Shift, red ("location 0"),
once the test checks every Shift down, not only the last, which came
from keys.js's Shift+Enter.
go vet (darwin, windows, linux) ./internal/gateway ./internal/browserext:
ok. go test ./internal/browserext ./internal/gateway -timeout 45m
(headless): ok, gateway 866s.
Not tried: a real Discord account. Per the 11-08 limit nothing scripted
touches it. Not fixed: a background tab's outerWidth/outerHeight/screenX
are 0 while focus is emulated (Claude in Chrome has the same; the device
metrics override broke availHeight), and a page's own window.open from
the agent's tab still comes to the front for a moment.
|
||
|
|
8f69ca29c4 |
browser: Magpie Browser acts like a person and stays out of the user's tabs
The owner, 11-05: Magpie Browser interrupts the user's own browsing, and driving Discord with it gets the account flagged by Discord's bot check, which never happened under Claude's Chrome extension. What a site could see, and what changed (extension 0.1.6): - CDP's Runtime domain was on in every tab, which bot checks look for. It is now off until browser_console is asked for (on localhost, 127.x, [::1], *.localhost and *.test it is on from the start, as before). The first console call says it reads the console from then on. - Every read and helper (the clickable scan's getComputedStyle and querySelectorAll on each element, focus, readyState, innerText, scroll position) ran in the page's own world, where a page's patched functions see each call. They now run in an isolated world of the extension's (Page.createIsolatedWorld, DOM.resolveNode in it). browser_evaluate stays in the page's world, since the agent's script is for the page's JavaScript. - A click jumped to an element's exact middle. The mouse now moves along a curved, eased path to a spot drawn around the middle, then presses and lets go at uneven timings. Hover and drag go the same way. - Text went in with Input.insertText, with no key events. It is now typed a key at a time with US key codes, Shift held for capitals and symbols, at a typist's uneven rhythm (35s at most for a whole text). Chinese, Japanese and Korean come through an IME composition, emoji through insertText, and a newline as Shift+Enter so a chat box doesn't send early. A field's old text is cleared with Backspace only when it has some, and submit waits a moment before Enter. - A scroll was one wheel event. It is several notches now. - Actions follow each other at a person's pace (350 to 1600ms apart), and the debugger stays attached for 5 minutes idle, not 2, so Chrome's bar doesn't come and go between calls. The user's tabs: - A call naming one of the user's own tabs (one outside every Magpie group) now opens that page in a background tab of the agent's own, in its group, and the agent is told so; naming it again goes on in that copy. This is how Claude's extension keeps to its own group. - tab_close refuses a tab of the user's. - A tab an action opens always goes in the agent's group, and a page that opens a window of its own gives focus back to the window the user was in. - The tool's instructions said calls go to the tab the user is looking at. They now say the agent works in tabs of its own, that naming the user's tab copies it, that steps take a person's time, and how the console starts. Run at this head (rebased on |
||
|
|
e928b57f0e |
browser: the user's tab is never put behind, not even for a moment
The owner (11-03, again 11-04: "你到底彻底修复了没啊"): Magpie Browser disturbs the user's browsing. v0.1.2864 moved agents into tabs of their own, behind the user's, in a Magpie tab group, but two paths still took the user's tab from under them: - A screenshot that took over 8s brought the agent's tab forward for ~300ms and gave the user's back. With a recording on (v0.1.2865) every action takes one. Measured on mote, headful Chrome for Testing 1234: Chrome draws a background tab for Page.captureScreenshot (first ~5s, then 50-250ms), so the tab is never brought forward now; after 20s the call fails SCREENSHOT_FAILED instead. - A link with target=_blank, clicked in the agent's background tab, opened its new tab in front, and the user's tab came back only after the new page settled (up to ~2.5s). Now such a link is clicked with Cmd (Ctrl off macOS) held, as a person opens one in the background, and a tab that still comes up in front (window.open, Enter on a link) is given back the moment it is created. Extension 0.1.5. Test: TestBrowserLeavesTheUsersTabAlone starts Chrome on a user page the extension never attaches to (attaching turns on focus emulation, which keeps a page "visible"); its title counts every visibilitychange to hidden. Headless Chrome keeps every tab visible, so the moment-long case is caught only with MAGPIE_BROWSER_HEADFUL=1 (a window on the screen); the test says so in its log when headless. Run on mote at this tree: - gofmt clean; GOOS=darwin/linux/windows go vet ./internal/gateway clean - go test ./internal/gateway -count=1 -timeout 45m: ok (1114s) - MAGPIE_BROWSER_HEADFUL=1 go test ./internal/gateway -run TestBrowser: all 20 pass; TestBrowserLeavesTheUsersTabAlone -count=3 headful ok Broken by hand, headful: the old screenshot dance fails "after a screenshot ... Watch 1"; the click without Cmd fails "after a link opened a tab ... Watch 1"; the fix before the Cmd click (restore on create only) still failed at the link, which is why the Cmd click is in. Headless, both breaks pass: that is the limit named above. Not tried: Edge, Arc, Windows and Linux Chrome; a real site's window.open popup (it is given back at once, a flash remains). |
||
|
|
51fa4b7eb0 |
browser: agents work in tabs of their own, behind the user's
The owner: Magpie Browser "老是会代替掉用户正在浏览的网页". A call that
named no tab, from a session with none, took the tab the user had in
front and navigated it away under them. Now:
- such a call opens a new tab of the session's (about:blank), behind the
shown one, in its Magpie tab group, in the window used last, or an
unfocused window of its own when none is open (open() in background.js);
- browser_tabs new / tab_new open behind too; front: true shows the tab,
for when the user asked to see it (background is still taken, and is
now the default);
- a screenshot of a tab behind shows it for the picture, then gives the
window back the tab the user had in front;
- a link with target=_blank clicked in a tab behind: Chrome shows the new
tab and names the user's shown tab as its opener. It is still followed,
grouped in the session's group, and the user's tab is put back in front.
- the tool descriptions say so; the user's tabs are acted in only when a
call names one.
Extension 0.1.4. When an older one connects, the gateway writes this
magpie's over its folders (browserext.Refresh; only folders already
written, never a newer one's: browserext.Older), so the browser picks it
up when it starts again or on the extension's reload in
chrome://extensions. Before, only opening Library's Browser page did. The
dir helpers moved from gui to browserext for it.
Tried and dropped: telling the extension to chrome.runtime.reload()
itself. In Chrome for Testing 1234 on mote an unpacked extension that
calls it never comes back (headless and headful, --load-extension and
CDP Extensions.loadUnpacked, with an onInstalled listener), which would
leave the user with none until a restart.
Run on mote at
|
||
|
|
7e201ce20d |
browser: one tool, browser, whose action says what to do
magpie-browser listed 17 tools (11,483 bytes of schema in every request); it now lists one, browser, whose action picks what to do (4,087 bytes). The old tool names are still accepted on tools/call, and text the extension writes about browser_X now says "the X action". Any action takes screenshot: true and returns the page after it, as a 1024px-wide JPEG (q70), so an agent sees the page without a second call. Run on mote at this head: go test -tags nogui -run Browser ./internal/gateway/ with a real Chromium: ok, including TestBrowserToolActionsInARealBrowser. TestBrowserToolCallsTheExtensionsTool went red with the name rewrite taken out by hand and with the downscale taken out (2880x1800 stays 2880x1800). gofmt clean; go vet -tags nogui for darwin, linux and windows ok. Not tried: Claude Code and Codex using the one tool against a live gateway. |
||
|
|
da23fcb169 |
browser: frames from other sites are read and acted on; failures say their kind
A page's cross-site iframes (out-of-process frames) were missing from the
snapshot: Page.getFrameTree on the parent doesn't list them, so a checkout
form or a login inside such a frame couldn't be read or clicked. The
snapshot now adds each frame whose session was auto-attached under its
parent (t.frameOf), and actions on its refs go to that frame's session.
A failed action now says its kind (STALE_REF, DIALOG_OPEN, LOAD_FAILED,
PAGE_BLOCKED, WAIT_TIMEOUT, OUTCOME_UNKNOWN, BAD_ARGS ...) with what to try next, and an action
settles on the DOM going quiet before it says done. Extension 0.1.3.
Run on mote at this head: go test -tags nogui -run Browser
./internal/gateway/ ./internal/browserext/ with a real Chromium
(MAGPIE_BROWSER_CHROME, Chrome for Testing 1234): ok, including
TestBrowserFramesAndFailuresInARealBrowser. Red on the old code ("no
textbox Card"); the settle taken out by hand made it red ("doesn't say
done"). gofmt clean; go vet -tags nogui for darwin, linux and windows ok.
Not tried: a real site's payment iframe in the owner's own Chrome.
|
||
|
|
de7953e3b8 |
browser: browser_evaluate calls an async()=> function and awaits it
The check that tells a function from an expression wanted a space after
async, so `async()=>{…}` was evaluated as an expression: the function
itself came back, serialized as {}, and its body never ran. And a
parameter list could hold parentheses, so `(async()=>{…})()` counted as
a function and its promise was called ("is not a function"). async may
now touch its parameters, and a parameter list holds no parentheses.
The extension goes to 0.1.2.
Found driving X through magpie-browser from Claude Code.
Run on mote (Chrome for Testing 1234):
- MAGPIE_BROWSER_CHROME=… go test ./internal/gateway -run
'TestBrowser.*InARealBrowser' -count=1: ok (46.5s). Five new evaluate
cases: async()=>, async () =>, async function, an async IIFE and
Promise.resolve, each answering "awaited".
- Broken by hand: with origin/main's background.js the test is red at
the first case (async()=>… doesn't say "awaited").
- go test ./internal/browserext: ok. gofmt -l: clean.
Not run: the full suite; not tried in Edge or Firefox.
|
||
|
|
3cb8b17312 |
browser: two agents at once each work in a tab and tab group of their own
Magpie Browser kept a tab per session, but a session with no tab took the
tab the user was looking at, so two agents started together worked in one
tab, and every agent's tabs went in one "Magpie" group
(packinggoodsllc_07668 on Discord).
- A session whose first call finds the shown tab held by another session
gets a new background tab of its own.
- Each session's tabs go in a group of its own: "Magpie", then "Magpie 2",
"Magpie 3" beside other live sessions (session → group kept in
storage.session with the tabs).
- browser_tabs list marks another session's tab ~ and names each tab's group.
- A link that opens a tab moves the session that clicked it (t.by), not the
first session found holding the old tab.
- Instructions and the popup's hint say so; extension 0.1.1.
Run (mote-run, MAGPIE_BROWSER_CHROME = Playwright's Chrome for Testing
1234): TestBrowserToolsInARealBrowser and the new
TestBrowserSessionsApartInARealBrowser (two sessions, real tabs and groups)
ok; go test ./internal/browserext; ./internal/gateway -run
'Browser|MCP|Hub'; GOOS=linux and windows go vet of gateway, library,
browsermcp, browserext ok.
Broken by hand: the new test against the old background.js is red ("both
sessions work in t803211511").
Not tried: real Chrome/Edge with a user profile, a person watching the
groups; t.by with two sessions (the click test has one).
|
||
|
|
0e90572274 |
browser: Magpie Browser, agents use the user's own browser and its sign-ins
The owner asked for a browser-use MCP of magpie's own, so an agent's browser keeps working when Claude Code switches accounts, and asked that it act in the browser the user uses every day: a fresh Playwright profile is signed in to nothing. Magpie Browser is an MV3 extension (internal/browserext, ID dmlhojidlfnkgamkekjhacgkpanbkeko, pinned by its key) that the user loads once in Chrome, Edge, Arc, Brave or another Chromium browser. It holds a WebSocket to the gateway's /v1/magpie/browser/extension and carries out each tool call with chrome.debugger (the DevTools protocol) in the user's own tabs. The socket is taken only from this computer, with a loopback Host (no DNS rebinding) and the extension's own Origin; a page or another extension that connected in its place would be handed every call. Agents reach it at /mcp/magpie/browser (Streamable HTTP) or through `magpie mcp browser` (stdio), and the Library's MCP market lists it as Magpie Browser, opt-in. Like the image server it is magpie's own, but it is never served to another computer, shared and with a key or not, and never to a web page, since it acts as the user wherever they are signed in. 17 tools: navigate (url, back, forward, reload), snapshot (an accessibility tree with refs, interactive-only on ask), click, type, press, select, hover, drag, upload, scroll, wait (text, gone, seconds), dialog, evaluate, text, screenshot (page, full page, element; JPEG or PNG), console and tabs (list, new, select, close). Each agent session goes on in its own tab; a link that opens a tab is followed, and a dialog a click opens is said in the reply. The Library's sheet for it has Set up the extension…, which writes the extension to ~/.config/magpie/browser-extension pointed at this gateway and shows the folder, the three steps to load it, and whether the browser is connected, polled while the sheet is open. Run: - TestBrowserToolsInARealBrowser: the extension magpie writes, loaded in a real Chrome for Testing 141 (Playwright's chromium-1234, headless=new) with --load-extension, connects, and all 17 tools act in a real tab of a fixture site. Green on mote (macOS 27), on xiaomi-gpu (Windows 11, win-run) and in magpie-desktop (Ubuntu 24.04, wsl-run). Under a test HOME Chrome needs --use-mock-keychain / --password-store=basic, or the extension's storage waits on a keychain and it never connects. - go test ./internal/gateway -run 'Browser|ReadOnly|Image', ./internal/ browserext, ./internal/browsermcp, ./internal/library, ./internal/gui -run 'Library|Browser', ./internal/cli on mote. - GUI: library-browser-setup.test.cjs (new) in Chromium and WebKit, en, zh, zh-TW, ja, de, at 1100 and 420 wide: 22/22. With i18n-keys and every library*.test.cjs: 915 pass, 1 fail, i18n-keys' "Unmarked", red on main since |