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

@@ -17,6 +17,7 @@ from .builtin.nutrition.log_meal import LogMealTool
from .builtin.nutrition.fetch_meals import FetchMealsTool
from .builtin.nutrition.delete_meal import DeleteMealTool
from .builtin.chat_channels import ChatChannelsTool
from .builtin.bot_browser import BotBrowserTool, CDP_ENV
from .builtin.refresh_mcp_tools import RefreshMCPToolsTool
from .builtin.weather import WeatherTool
from .builtin.stop import StopTool
@@ -47,6 +48,7 @@ BUILTIN_TOOLS = {
"controlBrowser": ControlBrowserTool(),
"setBroadcast": SetBroadcastTool(),
"chatChannels": ChatChannelsTool(),
"botBrowser": BotBrowserTool(),
}
# The on-screen browser tools work only in screen-share mode (cfg.stream_browser); without it they
@@ -57,13 +59,17 @@ _SCREEN_SHARE_TOOLS = ("controlBrowser", "browseAndPlay", "setBroadcast")
def enabled_builtin_tools(cfg) -> Dict[str, Any]:
"""The built-in tools this configuration allows: none in ``cfg.disabled_tools``, and the
screen-share tools only in screen-share mode. The router, toolSearchTool and the executor all
use this, so a turned-off tool is neither offered nor run."""
screen-share tools only in screen-share mode, and botBrowser only when the app started the bot
browser (bot_browser.spec.md). The router, toolSearchTool and the executor all use this, so a
turned-off tool is neither offered nor run."""
disabled = getattr(cfg, "disabled_tools", ())
disabled = set(disabled) if isinstance(disabled, (list, tuple, set, frozenset)) else set()
stream = getattr(cfg, "stream_browser", True)
return {k: v for k, v in BUILTIN_TOOLS.items()
if k not in disabled and (stream or k not in _SCREEN_SHARE_TOOLS)}
if k not in disabled and (stream or k not in _SCREEN_SHARE_TOOLS)
and (k != "botBrowser" or os.environ.get(CDP_ENV))
# One tool reads pages: with the bot browser offered it does (through the app's proxy).
and (k != "fetchWebPage" or "botBrowser" in disabled or not os.environ.get(CDP_ENV))}
# Global MCP tools cache