ac4af582301a4e8a29245dbba767eba31334ddf9
10
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4f3ec591ae |
browser: an extension older than magpie's is to be reloaded, says the sheet and the agent
magpie rewrites the extension's folder when an older one connects, but Chrome runs what it loaded until the extension is reloaded on chrome://extensions or the browser starts again, so a user who never does either stays on the old code. Now that is said: - Library → Magpie Browser: under "Connected to your browser · 0.1.8" a line says "Magpie Browser 0.1.9 is ready: reload Magpie Browser on chrome://extensions (edge://extensions in Edge)." Looked at from another computer (the zip install), it says to download it again, unzip it over the old folder and reload it. /api/library/browser has outdated. - The agent: the first browser answer on such a connection starts with a line telling it to have the user reload it (or download it again, for one connected with a gateway key). Once a connection. The extension still isn't made to reload itself: an unpacked one that calls chrome.runtime.reload() doesn't come back (the finding in browser.go's hello). The fake extension in the gateway's tests now says magpie's own version (it said 0.1.0, which every test would now be told about). Run (on mote): - internal/gateway TestBrowser* (new TestBrowserSaysTheExtensionIsOlder, TestBrowserSaysNothingOfACurrentExtension), ok. - internal/gui TestBrowser* (new TestBrowserStateOutdated), ok. - GUI: library-browser-setup, library-browser-away, library-browser-ask, browser-access, i18n-keys in Chromium and WebKit, every language, at 1100 and 420 wide: 127 of 128. The red is i18n-keys "a plugin's words are its own" for three keys this change doesn't touch, red on main and filed (#5332, #5482, #5426). - go vet for darwin, linux (nogui) and windows; gofmt -l clean. Broken by hand: - the once-a-connection check removed: TestBrowserSaysTheExtensionIsOlder red ("s1's next answer" has the note again). - the sheet's line never shown: library-browser-setup red, 20 of 20. - Outdated without Connected: TestBrowserStateOutdated red. Not tried: the whole GUI suite before this push (run next), and a real Chrome with an older extension loaded by hand. |
||
|
|
81798f7793 |
browser: a recording is an MP4, encoded in magpie (GIF on format: gif)
record_stop now makes an H.264 MP4 by default, from the same frames as
the GIF (a second a frame, the last held three, the first frame's
size). record_stop takes format: "mp4" (default) or "gif"; any other
value is refused and the recording goes on, so the agent can ask again.
internal/h264 is a small encoder with no cgo and no ffmpeg:
Constrained Baseline, CAVLC, deblocking off. The first picture is IDR.
After that a macroblock the same as before is P_Skip, and a changed one
is Intra16x16 (V/H/DC by SAD). Colour is BT.709 limited range, and an
odd size is cropped. The MP4 puts its moov before mdat, so a player can
start before it has the whole file. QP 23.
The image MCP's file route serves through http.ServeContent, so a
player's Range request gets 206. Safari plays an MP4 only when it is
served that way. extOf gives video/mp4 the extension .mp4.
Run (on mote unless named):
- internal/h264 TestDecodersMakeTheSamePicture. ffmpeg n7.1 (local;
mote has none) decodes 7 cases to the encoder's own reconstruction,
byte for byte (diff 0): 330x190 q24, 800x522 q20, 64x48 q10,
48x32 q40, 96x64 q0 (escape codes), 96x64 q51, 18x18 q23.
TestEncodeKeepsThePicture: PSNR 42-44 dB at q24.
- internal/gateway: TestBrowserMP4, TestBrowserGIF*,
TestBrowserRecordStopWithNothing, TestBrowserToolListIsSmall
(4585 bytes vs 12138), TestImageMCP*.
- TestBrowserRecordsAVideo, in a real Chrome for Testing (chromium-1234)
with the extension: the MP4 has video/mp4 and a .mp4 link, and a Range
request gets 206. Chrome opens the link and plays it: 800 wide, 5 s,
a frame read back from a canvas. format gif decodes to 3 frames, and
format webm is refused.
- All of internal/gateway's Browser and ImageMCP tests on origin/main
|
||
|
|
589680bc4c |
gateway: a browser's key watch takes its interval as the browser connects (#5569)
watchKey read the package var browserKeyCheck on its own goroutine, with nothing ordering that read before TestBrowserKeyOffClosesItsBrowser's later write (browser_key_test.go:210): under -race on a loaded runner the goroutine was still starting when the test set 20ms, a DATA RACE. The handler now reads it and hands it over, before s.browser.add, whose lock the test's count() takes, so the test's write is ordered after it. Behaviour is unchanged: the interval is the same value, read earlier. Run (mote): go test -race -run TestBrowserKey ./internal/gateway, ok; go vet darwin, GOOS=linux -tags nogui and GOOS=windows on the package. Broken by hand: with a 300ms sleep at the start of watchKey, the old code is red, DATA RACE at browser.go:422 against browser_key_test.go:210 (the CI trace); the fix with the same sleep is green, -count=3. Not tried: a real browser extension (the interval it uses is unchanged). Fixes #5569 |
||
|
|
e1eeeed734 |
browser: the extension's key connects Magpie Browser and nothing else; own needs this computer; a key turned off closes its browser
|
||
|
|
483b131ef0 |
browser: magpie in Docker uses the host's own browser, through a key the page hands out
noahhrreion ran magpie in a container and its Magpie Browser never
connected. The host's Chrome dials ws://127.0.0.1:3425/v1/magpie/browser/
extension, which reaches the container from the bridge (172.17.0.1). That
is not loopback, so the gateway refused it (403). The browser MCP also
refused every caller from elsewhere, and the hub marked the browser
HereOnly. The extension's folder under the container's HOME can't be
loaded by the host's browser either.
Nothing is opened to the network without a key:
- The extension takes a gateway key: its popup has a Gateway key field,
and config.js carries KEY (extension 0.1.7). From another computer the
extension connects only with ?key= of a gateway key that is on, and
only from the extension's own Origin (checked first). Loopback is
unchanged, and a page's origin, null, a keyless call or a rebound Host
are all still refused (TestBrowserExtensionOnlyFromItsOrigin).
- A browser that connects with a key belongs to that key. Sessions are
tagged key:<id>/... (browserOwner, keyedSession), and a remote caller's
session is forced to its own key's whatever it names. The relay filters
every lookup (forSession, all, choose) through browserConn.serves. The
browser MCP admits a remote caller only with a gateway key; a web page
is refused as before.
- The key the page makes is recorded as this magpie's own browser's: its
id goes in settings.Dir()/browser-key, written temp-and-rename. This
goes by where the key came from, not by its name. A browser connecting
with it serves this computer's sessions too, so agents inside the
container use it as they would one on loopback. A record that can't be
read names no key, so no keyed browser is this computer's.
- Router: magpie mcp browser is HubServer.Keyed. A visitor from
elsewhere gets it only with a key (HubVisitor.Key), and hubCall names
its session key:<id>/..., so it reaches only that key's browser.
- GUI: a page whose browser can't reach magpie's folders (InContainer, or
a page from another computer) is "away". The Magpie Browser sheet's
button then reads Download the extension. It does a POST to
/api/library/browser/extension with the page's origin, which answers a
zip pointed at that origin (3430 passes the gateway's routes on) and
holding the recorded key's secret. The key is made the first time and
reused while it is on. The steps (unzip, chrome://extensions, Developer
mode, Load unpacked) are shown in every language. It is a POST so that
a link from another site can't mint a key.
- Docs: reference.md (Docker), subsystems/library.md and mcp-router.md,
and site docker.html in en, zh and ja.
Run, at this tree rebased on origin/main
|
||
|
|
8e27369bd6 |
browser: record_start and record_stop make a GIF of what an agent did
Asked for in chat ("Magpie Browser MCP 也要支持录屏哦"), like
claude-in-chrome's gif_creator. The browser tool gets two actions:
- record_start: from now on, after each action that can change the page
(not tabs, snapshot, text, console, screenshot, tab_close), the gateway
takes a picture of the session's window, 800 wide, with the action and
what it was done to written in a strip under it (the url, ref, key or
drag; never what was typed).
- record_stop: the frames as an animated GIF, a second a frame and the
last three, each frame after the first only the rectangle that changed.
It is kept an hour behind the image server's tokened files link and
named in FilesMeta, so `magpie tool` saves it; the text says to curl it.
The gateway does it all through browser_screenshot, so every extension
version records and nobody has to reload theirs. At most 300 frames;
a recording nobody stops goes after 30 minutes. A picture an action's
screenshot: true asks for is the same one the frame is made from.
Run on mote (macOS, Chrome for Testing 1234 headless):
- GOOS=darwin/linux/windows go vet ./internal/gateway, gofmt -l: clean.
- MAGPIE_BROWSER_CHROME=... go test ./internal/gateway -count=1
-timeout 45m: ok (794s).
- New: TestBrowserRecordsAGIF (real Chromium: navigate, type, snapshot,
navigate → 3 frames, GIF fetched from the link, 800 wide),
TestBrowserGIFFramesHoldWhatChanged, TestBrowserRecSayKeepsTypedTextOut,
TestBrowserRecordStopWithNothing.
Broken by hand: with browserRecWorth always false, TestBrowserRecordsAGIF
is red ("no frames").
Not tried: a real headful Chrome, Edge or Arc; Windows and Linux browsers.
|
||
|
|
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. |
||
|
|
726544eed7 |
browser: with two browsers connected, an agent lists them and picks one
With Magpie Browser in two browsers (Chrome and Edge, or two profiles),
every call went to the last to connect and nothing said there was another
(packinggoodsllc_07668 on Discord: which one is controlled?).
- Each connection gets an id (b1, b2, in connect order) and a name from its
User-Agent (Edge, Opera, Vivaldi, Yandex say so; Brave, Arc and other
Chromium browsers read as Chrome).
- browser_tabs action browsers lists them, * on the one calls go to; action
use with browser (an id, or a name only one has) moves this session's
calls there. Other sessions stay where they were; a browser that
disconnects drops every session's pick of it.
- With two or more connected, browser_tabs list says whose tabs it lists.
The default is still the last to connect.
Run (mote-run): go test ./internal/gateway -run Browser ok (new
TestBrowserMCPPicksAmongBrowsers, TestBrowserName); go vet, GOOS=linux and
windows go vet ./internal/gateway ok.
Broken by hand: forSession ignoring the pick, the new test red ("s1 after
picking chrome: ... b2's tabs (Edge 141)").
Not tried: two real browsers at once; the GUI still shows only the last
connected browser.
|
||
|
|
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 |