Pythinker webbridge

From PyModel/pythinker-code · View interactive version

Pythinker webbridge is an AI agent skill from the GitHub repository PyModel/pythinker-code. Pythinker Browser Extension lets AI control the user's real browser — navigate, click, type, read, screenshot, and interact with any website using the user's actual login sessions. Use this skill whenever the user wants to interact with websites, automate browser tasks, scrape web content, or perfor

How to use this skill

Skill file

Pythinker Browser Extension (formerly Pythinker WebBridge)

Control the user's real browser (with their login sessions) via a local daemon at http://127.0.0.1:10086 (the default address — see If a tool call fails for when it differs).

Tools

| Tool | Args | Returns | Note |

|------|------|---------|------|

| navigate | url, newTab(bool), group_title | {success, url, tabId} | First call opens a tab — see Tabs. group_title sets the group's visible label |

| find_tab | url, active(bool) | {success, url, tabId, borrowed} | Re-select a tab this session opened; active:true borrows the tab the user is viewing — see Tabs |

| snapshot | — | {url, title, tree} with @e refs | Accessibility tree (text) — use this to read page content and locate elements |

| click | selector (@e ref or CSS) | {success, tag, text} | Synthetic el.click() |

| fill | selector, value | {success, tag, mode} | Works on <input>/<textarea> AND [contenteditable] (ProseMirror/Lexical/Slate). mode is "value" or "contenteditable" |

| evaluate | code (supports async/await) | {type, value} | |

| cdp | method, params | raw CDP response | Raw chrome.debugger passthrough — what evaluate is to JS, cdp is to CDP. Low-level escape hatch for cases the tools above don't cover |

| screenshot | format(png\|jpeg), quality(0-100), optional selector (@e/CSS), optional path | {format, path, sizeBytes, mimeType} | Returns a file path, not base64 — see Screenshots |

| network | cmd(start\|stop\|list\|detail), filter, requestId | request/response data | |

| upload | selector, files(string[]) | {success, fileCount} | |

| save_as_pdf | paper_format, landscape, scale, print_background, optional path | {path, sizeBytes, mimeType, pageTitle} | Render current page → PDF, returns a file path — see Save as PDF |

| list_tabs | — | {success, tabs:[{tabId, url, title, active, groupTitle}]} | Inspect tabs in the current session |

| close_tab | — | {success, closed: bool} | Close the current tab in the session |

| close_session | — | {success, closed: int} | Close all tabs in the session — closed is the count. See Sessions for when to call |

Tabs and the current tab

Single-tab tools (snapshot, click, fill, screenshot, save_as_pdf) act on the current tab — the one you most recently opened with navigate or selected with find_tab.

curl -s -X POST http://127.0.0.1:10086/command \
  -d '{"action":"find_tab","args":{"url":"https://example.com","active":true},"session":"k26-research"}'

Call Format

Every command carries a top-level session naming the current task — see Sessions below. The examples in later sections omit it only for brevity; in real calls always include it. Every reply is an envelope: {"ok":true,"data":…} on success (the Returns column above describes data) or {"ok":false,"error":{"code","message"}} on failure. The command format depends on the user's OS.

macOS / Linux — inline JSON is fine:

curl -s -X POST http://127.0.0.1:10086/command \
  -H 'Content-Type: application/json' \
  -d '{"action":"navigate","args":{"url":"https://example.com","newTab":true,"group_title":"My task"},"session":"my-task"}'

If the inline call fails — a shell quoting/syntax error from bash, or an HTTP 400 from the daemon — do not retry the same command unchanged. Resend the request as a file body:

  1. Write the JSON body to a uniquely-named temp file with your own file-write tool — never with shell echo/heredoc, which mangles the JSON the same way. Use a fresh name per request (e.g. /tmp/webbridge-req-<random>.json).
  2. POST the file:
curl -s -X POST http://127.0.0.1:10086/command -H 'Content-Type: application/json' --data-binary @/tmp/webbridge-req-<random>.json
  1. Delete the temp file as soon as the request returns.

Windows (PowerShell / cmd) — the shell corrupts non-ASCII characters (Chinese etc.) carried inline in command arguments or pipes; they reach the daemon as ? and the text is unrecoverable. Send every request as a file body instead:

  1. Write the JSON body to a uniquely-named temp file with your own file-write tool — never with shell echo/heredoc, which corrupts non-ASCII the same way. Give every request its own filename with a random suffix (e.g. webbridge-req-<random>.json) so concurrent requests never share a file and overwrite each other.
  2. POST the file with curl.exe — always curl.exe, never bare curl, which Windows PowerShell aliases to Invoke-WebRequest:
curl.exe -s -X POST http://127.0.0.1:10086/command -H "Content-Type: application/json" --data-binary "@$env:TEMP\webbridge-req-<random>.json"
  1. Delete the temp file as soon as the request returns — don't leave request bodies on disk.

Sessions

One task = one session = one tab group. A session collects every tab the task opens into one tab group, so the user sees a single group for "what the agent is doing right now". Pass it as a top-level field of the request body (not inside args).

# First tab: set session + a human label (in the user's language)
curl -s -X POST http://127.0.0.1:10086/command \
  -d '{"action":"navigate","args":{"url":"https://example.com","newTab":true,"group_title":"K2.6 feature research"},"session":"k26-research"}'
# Another site, same task → same session → joins the same group automatically
curl -s -X POST http://127.0.0.1:10086/command \
  -d '{"action":"navigate","args":{"url":"https://www.pymodel.cn","newTab":true},"session":"k26-research"}'

Closing is always user-initiated: call close_session only when the user explicitly asks ("close those", "clear the tabs"). It clears the whole group in one call.

Screenshots

The daemon writes the image to disk and returns {format, path, sizeBytes, mimeType} — never base64, since the model can't read raw image bytes. Take the .path and open it with the Read tool to actually see it.

# Default: PNG of the visible viewport, daemon picks a temp path
curl ... -d '{"action":"screenshot","args":{}}'
# Options (each independent): JPEG quality, element-only via @e/CSS selector, custom output path
curl ... -d '{"action":"screenshot","args":{"format":"jpeg","quality":60}}'
curl ... -d '{"action":"screenshot","args":{"selector":"@e123"}}'

A caller-supplied path is honored verbatim (parent dirs created, existing file overwritten) — use a unique name to avoid clobbering. save_as_pdf follows the same rule.

Prefer snapshot over CSS/JS selectors

snapshot returns interactive elements with @e refs based on semantic role/name. Use them directly with click/fill — they survive CSS class hash changes that break manually-written selectors.

Fall back to evaluate (JS) only when:

Evaluate Tips

Text input — use `fill`

fill (selector = CSS or @e ref, plus the value) works on <input>/<textarea> (returns mode: "value") and on [contenteditable] rich editors — ProseMirror, TipTap, Lexical, Slate, Quill, etc. (returns mode: "contenteditable"), firing the right input events so the page reacts.

fill is clear-and-insert: existing content is replaced. To append, read the current value via evaluate, concatenate, then fill with the result.

Form submit / special keys

There's no separate "press Enter" tool. To submit a form, click the submit button directly (click on the @e ref or selector). To dispatch a key event programmatically (e.g. Escape to close a modal):

{"action":"evaluate","args":{"code":"document.activeElement.dispatchEvent(new KeyboardEvent('keydown',{key:'Escape',bubbles:true}))"}}

Save the current page as PDF

save_as_pdf renders the current page to PDF and returns the file path. All args optional:

path semantics match screenshot: written verbatim, parent dirs auto-created, existing files overwritten.

Decoded PDF cap is 100 MB. Above that the daemon refuses; reduce scale or split the page.

Known limitations

If a tool call fails (daemon or extension not ready)

If a tool call can't reach the daemon (connection refused), or the reply isn't the ok envelope above (another program is answering on that port), run start yourself, don't ask the user. It is safe anytime: it no-ops if the daemon is already up. The binary is not on PATH: ~/.pythinker-webbridge/bin/pythinker-webbridge (Windows: %USERPROFILE%\.pythinker-webbridge\bin\pythinker-webbridge.exe).

Where the daemon listens is always in start's output, or in ~/.pythinker-webbridge/bin/pythinker-webbridge status (port when it is running, addr when it is not). If it isn't 127.0.0.1:10086, use that address for every call in this task. The config file is only for moving the daemon, never for finding it. Then retry the tool call.

start fails with "did not come up … held by another program" → another program owns the port. Move the daemon: write {"addr":"127.0.0.1:<port>"} (a free port of your choice) to the config file the error names, run start again, then ask the user to point the extension at the new port once (Pythinker side panel → Settings → Local agent remote control → Connection address → ws://127.0.0.1:<port>/ws; it remembers).

If it still fails, the binary is missing (command not found means pythinker-webbridge isn't installed), or the browser extension won't connect — point the user to the help page instead of deep-troubleshooting:

Never run stop / restart / upgrade / uninstall automatically — those kill a running daemon. When status shows update_available or version_mismatch, tell the user and hand them its command verbatim to run; that is what the field is for. When the user asks about pythinker-webbridge itself (install, start/stop/upgrade, "is it running", what status means, moving it to another port), read references/operations.md first.

Version mismatches

If a tool returns an error containing "Please update the Pythinker Browser Extension", the user's browser extension is older than this skill. Don't try to reconcile versions yourself — just tell the user, in their language, to update the extension and retry:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.