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.
This commit is contained in:
yetone
2026-11-02 06:40:03 +08:00
parent da23fcb169
commit 7e201ce20d
6 changed files with 436 additions and 16 deletions
+50 -7
View File
@@ -323,7 +323,7 @@ func (s *Server) browserMCPCall(r *http.Request, m mcpMessage) (any, map[string]
case "ping":
return map[string]any{}, nil
case "tools/list":
return map[string]any{"tools": browserTools()}, nil
return map[string]any{"tools": []any{browserOneTool()}}, nil
case "tools/call":
var p struct {
Name string `json:"name"`
@@ -332,27 +332,40 @@ func (s *Server) browserMCPCall(r *http.Request, m mcpMessage) (any, map[string]
if err := json.Unmarshal(m.Params, &p); err != nil {
return nil, map[string]any{"code": -32602, "message": "invalid params: " + err.Error()}
}
if !browserToolNamed(p.Name) {
one, shot := p.Name == "browser", false
if one {
tool, args, wants, err := browserUnfold(p.Arguments)
if err != nil {
return toolResult(err.Error(), true), nil
}
p.Name, p.Arguments, shot = tool, args, wants
} else if !browserToolNamed(p.Name) {
return nil, map[string]any{"code": -32602, "message": "unknown tool " + p.Name}
}
said := func(r map[string]any) map[string]any {
if one {
browserSays(r)
}
return r
}
session := browserSession(r)
var tabs struct{ Action, Browser string }
if p.Name == "browser_tabs" {
json.Unmarshal(p.Arguments, &tabs)
switch tabs.Action {
case "browsers":
return toolResult(s.browser.list(session), false), nil
return said(toolResult(s.browser.list(session), false)), nil
case "use":
c, err := s.browser.choose(session, tabs.Browser)
if err != nil {
return toolResult(err.Error(), true), nil
return said(toolResult(err.Error(), true)), nil
}
return toolResult("Calls now go to "+c.id+" ("+c.name()+"). browser_tabs lists its tabs.", false), nil
return said(toolResult("Calls now go to "+c.id+" ("+c.name()+"). browser_tabs lists its tabs.", false)), nil
}
}
out, err := s.browser.call(r.Context(), session, p.Name, p.Arguments)
if err != nil {
return toolResult(err.Error(), true), nil
return said(toolResult(err.Error(), true)), nil
}
var result map[string]any
if json.Unmarshal(out, &result) != nil || result["content"] == nil {
@@ -368,11 +381,41 @@ func (s *Server) browserMCPCall(r *http.Request, m mcpMessage) (any, map[string]
}
}
}
return result, nil
if shot && result["isError"] != true {
s.browserShot(r, session, result)
}
return said(result), nil
}
return nil, map[string]any{"code": -32601, "message": "method not found: " + m.Method}
}
// browserShot adds a small picture of the window to an action's result.
// One that can't be taken says so; the action still happened.
func (s *Server) browserShot(r *http.Request, session string, result map[string]any) {
content, _ := result["content"].([]any)
out, err := s.browser.call(r.Context(), session, "browser_screenshot", nil)
var shot struct {
Content []struct{ Type, Data string }
IsError bool
}
if err == nil && json.Unmarshal(out, &shot) == nil && !shot.IsError {
for _, c := range shot.Content {
if c.Type != "image" {
continue
}
if small, ok := browserSmall(c.Data); ok {
result["content"] = append(content, map[string]any{"type": "image", "data": small, "mimeType": "image/jpeg"})
return
}
}
}
why := "it didn't answer with a picture"
if err != nil {
why = err.Error()
}
result["content"] = append(content, map[string]any{"type": "text", "text": "(no screenshot: " + why + ")"})
}
// list is the connected browsers, the one session's calls go to marked *.
func (b *browserRelay) list(session string) string {
all := b.all()
+30
View File
@@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"html"
"image/jpeg"
"io"
"net/http"
"net/http/httptest"
@@ -403,3 +404,32 @@ func TestBrowserSessionsApartInARealBrowser(t *testing.T) {
t.Fatalf("b's list doesn't have its tab in %s and a's in %s:\n%s", gb, ga, list)
}
}
// The one browser tool in a real Chromium: actions open, act and go back,
// and screenshot: true brings a picture of the window no wider than
// browserShotWidth.
func TestBrowserToolActionsInARealBrowser(t *testing.T) {
srv, site := realBrowser(t)
call, ok := browserCaller(t, srv, "e2e-one")
ok("browser", map[string]any{"action": "tab_new", "url": site.URL + "/frames?src=about:blank"}, "Opened t", "Frames fixture")
m := call("browser", map[string]any{"action": "snapshot", "interactive": true, "screenshot": true})
if m.Result.IsError || len(m.Result.Content) != 2 || m.Result.Content[1].Type != "image" {
t.Fatalf("snapshot with screenshot: %+v", m.Result.Content)
}
b, _ := base64.StdEncoding.DecodeString(m.Result.Content[1].Data)
cfg, err := jpeg.DecodeConfig(bytes.NewReader(b))
if err != nil || cfg.Width == 0 || cfg.Width > browserShotWidth {
t.Fatalf("the picture: %+v %v", cfg, err)
}
page := m.Result.Content[0].Text
r := regexp.MustCompile(`button "Works a while" \[ref=(e\d+)\]`).FindStringSubmatch(page)
if r == nil {
t.Fatalf("no button in:\n%s", page)
}
ok("browser", map[string]any{"action": "click", "ref": r[1]}, "done")
ok("browser", map[string]any{"action": "navigate", "url": site.URL + "/two"})
if out := ok("browser", map[string]any{"action": "back"}, "Frames fixture"); strings.Contains(out, "browser_") {
t.Fatalf("an answer names the eighteen:\n%s", out)
}
ok("browser", map[string]any{"action": "tab_close"}, "Closed t")
}
+200
View File
@@ -0,0 +1,200 @@
package gateway
import (
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"image"
"image/jpeg"
_ "image/png"
"regexp"
"strings"
"golang.org/x/image/draw"
)
// The browser MCP server lists one tool, browser, whose action names what
// to do: one schema to read instead of eighteen, each with its own copy of
// the tab argument. The gateway turns a call into the extension's own tool
// (browser_click and the rest), so any extension version carries it out,
// and the eighteen names are still taken from a client that listed them
// before.
type browserAction struct {
tool string
set map[string]any // arguments the action stands for
}
var browserActions = map[string]browserAction{
"tabs": {"browser_tabs", nil},
"tab_new": {"browser_tabs", map[string]any{"action": "new"}},
"tab_select": {"browser_tabs", map[string]any{"action": "select"}},
"tab_close": {"browser_tabs", map[string]any{"action": "close"}},
"browsers": {"browser_tabs", map[string]any{"action": "browsers"}},
"use_browser": {"browser_tabs", map[string]any{"action": "use"}},
"navigate": {"browser_navigate", nil},
"back": {"browser_navigate", map[string]any{"go": "back"}},
"forward": {"browser_navigate", map[string]any{"go": "forward"}},
"reload": {"browser_navigate", map[string]any{"go": "reload"}},
"snapshot": {"browser_snapshot", nil},
"click": {"browser_click", nil},
"type": {"browser_type", nil},
"press": {"browser_press", nil},
"hover": {"browser_hover", nil},
"select": {"browser_select", nil},
"scroll": {"browser_scroll", nil},
"drag": {"browser_drag", nil},
"upload": {"browser_upload", nil},
"wait": {"browser_wait", nil},
"screenshot": {"browser_screenshot", nil},
"evaluate": {"browser_evaluate", nil},
"text": {"browser_text", nil},
"console": {"browser_console", nil},
"dialog": {"browser_dialog", nil},
}
// browserActionOrder is the order the schema lists them in.
var browserActionOrder = []string{"tabs", "tab_new", "tab_select", "tab_close", "browsers", "use_browser", "navigate", "back", "forward", "reload", "snapshot", "click", "type", "press", "hover", "select", "scroll", "drag", "upload", "wait", "screenshot", "evaluate", "text", "console", "dialog"}
func browserOneTool() map[string]any {
str := func(desc string) map[string]any { return map[string]any{"type": "string", "description": desc} }
boolean := func(desc string) map[string]any { return map[string]any{"type": "boolean", "description": desc} }
num := func(desc string) map[string]any { return map[string]any{"type": "number", "description": desc} }
strs := func(desc string) map[string]any {
return map[string]any{"type": "array", "items": map[string]any{"type": "string"}, "description": desc}
}
return map[string]any{
"name": "browser",
"title": "Browser",
"description": "Act in the user's own browser. Actions, with the arguments each takes:\n" +
"tabs: list them. tab_new [url, background]. tab_select [tab]. tab_close [tab]. browsers: the connected ones. use_browser [browser].\n" +
"navigate [url]. back. forward. reload.\n" +
"snapshot [interactive, ref, maxChars]: the page as an accessibility tree, a ref on each element you can act on.\n" +
"click [ref, double, button, modifiers]. type [ref, text, clear, submit, slowly]. press [key, ref]. hover [ref]. select [ref, values]. scroll [direction, amount, ref]. drag [from, to]. upload [ref, paths].\n" +
"wait [text, textGone, url, seconds, timeout]. screenshot [ref, fullPage, png]. evaluate [script, ref]. text [maxChars]: the visible text. console [level, limit]. dialog [accept, promptText].\n" +
"Every action takes tab, and screenshot: true to add a small picture of the window to its answer.",
"inputSchema": map[string]any{
"type": "object",
"properties": map[string]any{
"action": map[string]any{"type": "string", "enum": browserActionOrder},
"tab": str("t123, from tabs. Default: this session's tab, else the user's current one."),
"ref": str("An element's ref from the latest snapshot (e12)."),
"url": str("navigate, tab_new: the address; wait: until the address contains this."),
"text": str("type: what to type; wait: until the page shows this."),
"background": boolean("tab_new: don't bring it to the front."),
"browser": str("use_browser: its id from browsers (b2) or name (Edge)."),
"interactive": boolean("snapshot: only what you can act on, and headings."),
"maxChars": num("snapshot, text: the most characters back."),
"double": boolean("click: double-click."),
"button": map[string]any{"type": "string", "enum": []string{"left", "right", "middle"}},
"modifiers": map[string]any{"type": "array", "items": map[string]any{"type": "string", "enum": []string{"Alt", "Control", "Meta", "Shift"}}},
"clear": boolean("type: replace what the field holds (default true)."),
"submit": boolean("type: press Enter after."),
"slowly": boolean("type: a key at a time, for an autocomplete."),
"key": str("press: a key or chord (Enter, Control+a)."),
"values": strs("select: the options, by value or label."),
"direction": map[string]any{"type": "string", "enum": []string{"down", "up", "left", "right"}, "description": "scroll; with a ref and no direction, into view."},
"amount": num("scroll: pixels."),
"from": str("drag: the ref to drag."),
"to": str("drag: the ref to drop on."),
"paths": strs("upload: full paths of files on this computer."),
"textGone": str("wait: until the page no longer shows this."),
"seconds": num("wait: just this long (at most 60)."),
"timeout": num("wait: give up after (default 10, at most 60)."),
"fullPage": boolean("screenshot: the whole page."),
"png": boolean("screenshot: PNG, not JPEG."),
"script": str("evaluate: an expression, or a function (called with the ref's element)."),
"level": map[string]any{"type": "string", "enum": []string{"all", "errors", "network"}},
"limit": num("console: the most recent messages."),
"accept": boolean("dialog: accept (default true) or dismiss."),
"promptText": str("dialog: a prompt's answer."),
"screenshot": boolean("Add a small picture of the window to the answer."),
},
"required": []string{"action"},
},
"annotations": map[string]any{"readOnlyHint": false, "openWorldHint": true},
}
}
// browserUnfold turns a browser call into the extension's tool and its
// arguments, and says whether a picture is wanted after it.
func browserUnfold(raw json.RawMessage) (tool string, args json.RawMessage, shot bool, err error) {
m := map[string]any{}
if len(raw) > 0 && string(raw) != "null" {
if err := json.Unmarshal(raw, &m); err != nil {
return "", nil, false, errors.New("BAD_ARGS: the arguments aren't a JSON object: " + err.Error())
}
}
name, _ := m["action"].(string)
a, ok := browserActions[name]
if !ok {
return "", nil, false, errors.New("BAD_ARGS: action is one of " + strings.Join(browserActionOrder, ", "))
}
shot, _ = m["screenshot"].(bool)
delete(m, "action")
delete(m, "screenshot")
for k, v := range a.set {
m[k] = v
}
args, _ = json.Marshal(m)
return a.tool, args, shot, nil
}
// the extension's answers name its own tools; through browser they are
// actions
var browserNameRe = regexp.MustCompile(`browser_(tabs|navigate|snapshot|click|type|press|hover|select|scroll|drag|upload|wait|screenshot|evaluate|text|console|dialog)\b`)
var browserNameSay = strings.NewReplacer(
"browser_tabs with action new", "the tab_new action",
"browser_tabs with action browsers", "the browsers action",
"browser_tabs with action use and browser", "the use_browser action with browser",
"browser_tabs with action use", "the use_browser action",
"browser_tabs select", "the tab_select action",
"browser_navigate", "the navigate action",
)
func browserSay(s string) string {
return browserNameRe.ReplaceAllString(browserNameSay.Replace(s), "the $1 action")
}
// browserSays rewrites the text of a result's content for browser.
func browserSays(result map[string]any) {
content, _ := result["content"].([]any)
for _, c := range content {
if m, ok := c.(map[string]any); ok && m["type"] == "text" {
if s, ok := m["text"].(string); ok {
m["text"] = browserSay(s)
}
}
}
}
// browserShotWidth is the widest picture added to an answer: about a
// thousand tokens for a window, where a Retina one is several times that.
const browserShotWidth = 1024
// browserSmall is a screenshot made small enough to come with every
// answer: no wider than browserShotWidth, a JPEG.
func browserSmall(data string) (string, bool) {
b, err := base64.StdEncoding.DecodeString(data)
if err != nil {
return "", false
}
img, _, err := image.Decode(bytes.NewReader(b))
if err != nil {
return "", false
}
r := img.Bounds()
if r.Dx() > browserShotWidth {
h := r.Dy() * browserShotWidth / r.Dx()
dst := image.NewRGBA(image.Rect(0, 0, browserShotWidth, max(1, h)))
draw.ApproxBiLinear.Scale(dst, dst.Bounds(), img, r, draw.Src, nil)
img = dst
}
var out bytes.Buffer
if jpeg.Encode(&out, img, &jpeg.Options{Quality: 70}) != nil {
return "", false
}
return base64.StdEncoding.EncodeToString(out.Bytes()), true
}
+146
View File
@@ -0,0 +1,146 @@
package gateway
import (
"bytes"
"encoding/base64"
"encoding/json"
"image"
"image/color"
"image/jpeg"
"image/png"
"net/http/httptest"
"strings"
"testing"
"github.com/yetone/magpie/internal/browserext"
)
// Every action is one of the extension's tools, and the one schema names
// every argument the eighteen take, so none is lost in the merge.
func TestBrowserActionsCoverTheTools(t *testing.T) {
src, err := browserext.File("background.js")
if err != nil {
t.Fatal(err)
}
if len(browserActionOrder) != len(browserActions) {
t.Fatalf("%d actions listed, %d known", len(browserActionOrder), len(browserActions))
}
used := map[string]bool{}
for _, name := range browserActionOrder {
a, ok := browserActions[name]
if !ok {
t.Fatalf("%s is listed but unknown", name)
}
if !strings.Contains(string(src), " async "+a.tool+"(session, args) {") {
t.Errorf("%s's %s isn't in background.js", name, a.tool)
}
used[a.tool] = true
}
props := browserOneTool()["inputSchema"].(map[string]any)["properties"].(map[string]any)
desc := browserOneTool()["description"].(string)
for _, tl := range browserTools() {
m := tl.(map[string]any)
name := m["name"].(string)
if !used[name] {
t.Errorf("no action carries out %s", name)
}
for arg := range m["inputSchema"].(map[string]any)["properties"].(map[string]any) {
if arg == "action" || arg == "go" { // they are actions of their own
continue
}
if props[arg] == nil {
t.Errorf("%s's %s isn't in browser's schema", name, arg)
}
}
}
for _, name := range browserActionOrder {
if !strings.Contains(desc, name) {
t.Errorf("browser's description doesn't name %s", name)
}
}
}
// The point of one tool: its listing is a fraction of the eighteen's.
func TestBrowserToolListIsSmall(t *testing.T) {
one, _ := json.Marshal([]any{browserOneTool()})
all, _ := json.Marshal(browserTools())
if len(one)*2 > len(all) {
t.Fatalf("browser's listing is %d bytes, the eighteen's %d: no saving", len(one), len(all))
}
t.Logf("browser: %d bytes, the eighteen: %d", len(one), len(all))
}
// A browser call reaches the extension as its own tool with the arguments
// the action stands for; its answer names actions, not the eighteen; and
// screenshot: true adds a small picture of the window.
func TestBrowserToolCallsTheExtensionsTool(t *testing.T) {
fresh(t)
s := New()
srv := httptest.NewServer(lanGuard(s.Handler()))
t.Cleanup(srv.Close)
type got struct {
tool string
args map[string]any
}
calls := make(chan got, 8)
big := image.NewRGBA(image.Rect(0, 0, 2880, 1800)) // a Retina window
for i := range big.Pix {
big.Pix[i] = 0xff
}
big.Set(10, 10, color.Black)
var raw bytes.Buffer
png.Encode(&raw, big)
fakeExtension(t, srv.URL, func(_, _, tool string, args map[string]any) any {
calls <- got{tool, args}
if tool == "browser_screenshot" {
return map[string]any{"content": []any{map[string]any{"type": "image", "data": base64.StdEncoding.EncodeToString(raw.Bytes()), "mimeType": "image/png"}}}
}
return map[string]any{"content": []any{map[string]any{"type": "text", "text": "Opened t1. Answer it with browser_dialog; call browser_tabs with action new."}}}
})
browserConnected(t, s)
h := lanGuard(s.Handler())
m := readImageReply(t, browserPost(h, "127.0.0.1:5000", imageToolCall("browser", map[string]any{"action": "tab_new", "url": "example.com"})))
c := <-calls
if c.tool != "browser_tabs" || c.args["action"] != "new" || c.args["url"] != "example.com" || m.Result.IsError {
t.Fatalf("tab_new reached the extension as %+v: %+v", c, m)
}
if say := m.Result.Content[0].Text; strings.Contains(say, "browser_") || !strings.Contains(say, "the dialog action") || !strings.Contains(say, "the tab_new action") {
t.Fatalf("the answer names the eighteen: %q", say)
}
if len(m.Result.Content) != 1 {
t.Fatalf("a picture nobody asked for: %+v", m.Result.Content)
}
m = readImageReply(t, browserPost(h, "127.0.0.1:5000", imageToolCall("browser", map[string]any{"action": "back", "screenshot": true})))
c = <-calls
if c.tool != "browser_navigate" || c.args["go"] != "back" || c.args["screenshot"] != nil || c.args["action"] != nil {
t.Fatalf("back reached the extension as %+v", c)
}
if c = <-calls; c.tool != "browser_screenshot" {
t.Fatalf("then %+v, not a screenshot", c)
}
if len(m.Result.Content) != 2 || m.Result.Content[1].Type != "image" || m.Result.Content[1].MimeType != "image/jpeg" {
t.Fatalf("no picture with the answer: %+v", m.Result.Content)
}
b, _ := base64.StdEncoding.DecodeString(m.Result.Content[1].Data)
cfg, err := jpeg.DecodeConfig(bytes.NewReader(b))
if err != nil || cfg.Width != browserShotWidth || cfg.Height != 640 {
t.Fatalf("the picture is %+v (%v), want %dx640", cfg, err, browserShotWidth)
}
m = readImageReply(t, browserPost(h, "127.0.0.1:5000", imageToolCall("browser", map[string]any{"action": "format_disk"})))
if !m.Result.IsError || !strings.HasPrefix(m.Result.Content[0].Text, "BAD_ARGS: action is one of tabs,") {
t.Fatalf("an unknown action: %+v", m)
}
// a client that listed the eighteen before still calls them
readImageReply(t, browserPost(h, "127.0.0.1:5000", imageToolCall("browser_snapshot", nil)))
if c = <-calls; c.tool != "browser_snapshot" {
t.Fatalf("browser_snapshot reached the extension as %+v", c)
}
select {
case c = <-calls:
t.Fatalf("an extra call %+v", c)
default:
}
}
+1 -1
View File
@@ -144,7 +144,7 @@ func TestBrowserMCPSaysWhenNoBrowser(t *testing.T) {
var list struct {
Result struct{ Tools []struct{ Name string } }
}
if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &list) != nil || len(list.Result.Tools) != len(browserTools()) {
if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &list) != nil || len(list.Result.Tools) != 1 || list.Result.Tools[0].Name != "browser" {
t.Fatalf("tools/list: %d %s", w.Code, w.Body.String())
}
m := readImageReply(t, browserPost(h, "127.0.0.1:5000", imageToolCall("browser_snapshot", nil)))
+9 -8
View File
@@ -1,17 +1,18 @@
package gateway
// The browser MCP server's tools, carried out by the extension
// (internal/browserext/ext/background.js), whose argument names these
// schemas give.
// The extension's tools (internal/browserext/ext/background.js), whose
// argument names these schemas give. The server lists one tool, browser
// (browser_one.go), whose actions are these; their names are still taken
// from a client that listed them before.
const browserInstructions = `These tools use the user's own browser (Chrome, Edge or another Chromium browser with Magpie Browser installed): its real tabs, signed in to the sites the user is signed in to. Use it when a task needs the user's sessions or a real browser.
const browserInstructions = `The browser tool uses the user's own browser (Chrome, Edge or another Chromium browser with Magpie Browser installed): its real tabs, signed in to the sites the user is signed in to. Use it when a task needs the user's sessions or a real browser.
How to work:
- Start with browser_tabs or browser_snapshot. Calls go to the tab the user is looking at until you open or select another (to a new tab of your own when another agent works in that one); tabs you open go in your own tab group ("Magpie", or "Magpie 2" and on beside other agents). Leave the tabs browser_tabs marks ~ to the agents working in them.
- With two browsers connected (Chrome and Edge, or two profiles), calls go to the last to connect: browser_tabs with action browsers lists them, and action use picks one.
- browser_snapshot shows the page as an accessibility tree. Elements you can act on carry a ref (e12); pass it to browser_click, browser_type and the rest. Refs stay the element's while the page keeps it. Every action answers with the page after it, so you rarely need another snapshot.
- Start with action tabs or snapshot. Calls go to the tab the user is looking at until you open or select another (to a new tab of your own when another agent works in that one); tabs you open go in your own tab group ("Magpie", or "Magpie 2" and on beside other agents). Leave the tabs that tabs marks ~ to the agents working in them.
- With two browsers connected (Chrome and Edge, or two profiles), calls go to the last to connect: action browsers lists them, and use_browser picks one.
- snapshot shows the page as an accessibility tree. Elements you can act on carry a ref (e12); pass it to click, type and the rest. Refs stay the element's while the page keeps it. Every action answers with the page after it, so you rarely need another snapshot.
- Frames from other sites (a payment form, a sign-in box, an embedded editor) are read and acted on like the rest of the page.
- A failure starts with its kind and says whether trying again can help: STALE_REF and AMBIGUOUS (take a snapshot, use a ref from it), UNACTIONABLE (the page must change first), BAD_ARGS, WAIT_TIMEOUT, SITE_REFUSED (the site turned the browser away: tell the user), LOAD_FAILED, PAGE_BLOCKED, USER_STOPPED, DIALOG_OPEN, SCRIPT_ERROR, and OUTCOME_UNKNOWN (the page changed mid-action: snapshot before doing it again). A click answered NO_EFFECT changed nothing on the page: check before clicking again.
- Prefer refs to browser_evaluate. Use browser_screenshot when the layout or an image matters.
- Prefer refs to evaluate. When the layout or an image matters, add screenshot: true to an action (a small picture of the window comes with its answer), or take a screenshot.
- This is the user's browser: don't close tabs you didn't open, don't change their settings, and ask before sending, buying, posting or deleting anything on their behalf. When a site wants a sign-in, a captcha or a 2FA code, ask the user to do it in the tab, then go on.`
func browserTabArg() map[string]any {