feat(brain): botBrowser tool drives the bot's own Chrome over CDP

open, read, click (label or [n]), type (optionally Enter) and back; page content comes back fenced
as untrusted data; only http(s) addresses; no LLM call. Offered only when the app started the bot
browser (JARVIS_BROWSER_CDP) and the browser feature is on; meanwhile fetchWebPage, which has no
address guard, is not offered. Eval evals/test_bot_browser_tool.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 22:18:05 +09:00
parent 55d19364a0
commit 077db5031c
9 changed files with 672 additions and 7 deletions

View File

@@ -0,0 +1,46 @@
# botBrowser tool spec (v2 M6)
Lets the assistant use the bot's own Chrome (`app/src/admin.spec.md`, "Bot browser"): open a page,
read it, click a link or button, type into a field, go back. Product rules: `docs/v2/pc-features.md`
("백그라운드 크로미움으로 정보 수집").
## Principles
- **Only with the bot browser.** The tool is offered only when the worker got `JARVIS_BROWSER_CDP`
(the app started the bot browser, feature `browser` on) and it is not in `disabled_tools`.
Without it the tool is not in the catalogue and refuses if called. While it is offered,
`fetchWebPage` is not: one tool reads pages, and this one goes through the app's proxy (public
addresses only), which `fetchWebPage` does not have.
- **Web pages are data.** Everything read from a page (title, text, link and button labels) is
returned inside an untrusted-data fence. A request written on a page is never a reason to act.
- **Only http(s).** `open` takes only `http://` and `https://` addresses (a bare host gets
`https://`); `file:`, `chrome:`, `data:`, `javascript:` and the rest are refused. The browser's
own network rules (public addresses only) are the app's proxy's job.
- **Raw data, no LLM call.** The tool returns plain text for the reply model.
- **Bounded.** Each action waits at most 15 s for the page; text is cut at 6,000 characters and the
list of links and buttons at 40.
- **Logs** carry the action and timings, never the address, the typed text or page content.
## Schema
One tool, `action` picks the operation (read as its first known word, so `open_page` works):
| action | needs | does |
|---|---|---|
| `open` | `url` | opens the address in the bot browser's tab |
| `read` | | reads the current page again (with a `url`, opens it) |
| `click` | `target` | clicks the link or button whose label is `target` (an exact label first, else the one containing it; `[n]` from the last list also works) |
| `type` | `text` (`field`, `submit`) | types into the field whose label, placeholder or name contains `field` (else the focused field, else the first search or text box); `submit` presses Enter |
| `back` | | goes back one page |
Every action answers with the page after it: title, address, text, and the numbered links and
buttons, all inside the fence. Failures come back as `Error: ...` with `success=False`.
## Backend
`BrowserSession(cdp_url)` speaks CDP over the first page target's WebSocket (`websockets` sync
client): `Page.navigate`, `Runtime.evaluate` (reading, finding and clicking elements),
`Input.insertText` and `Input.dispatchKeyEvent` (typing, Enter). The tool keeps one session per
process and makes a new one when the old one fails. Tests and evals replace `session_factory`.
Eval: `evals/test_bot_browser_tool.py`.