From 2873da3c84222dc56cfc92bf939341f11f5c8e68 Mon Sep 17 00:00:00 2001 From: moosecrap Date: Sun, 22 Nov 2026 17:22:50 -0800 Subject: [PATCH] Open new window --- bridge/tools/__init__.py | 13 +++++++++++++ bridge/tools/open_new_window.py | 16 ++++++++++++++++ extension/background.js | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 bridge/tools/open_new_window.py diff --git a/bridge/tools/__init__.py b/bridge/tools/__init__.py index ba0987a..8b7ae4d 100644 --- a/bridge/tools/__init__.py +++ b/bridge/tools/__init__.py @@ -29,6 +29,7 @@ from .list_tabs import handle as list_tabs_handler from .switch_tab import handle as switch_tab_handler from .navigate_to import handle as navigate_to_handler from .open_new_tab import handle as open_new_tab_handler +from .open_new_window import handle as open_new_window_handler from .get_current_url import handle as get_current_url_handler from .get_page_cookies import handle as get_page_cookies_handler @@ -233,4 +234,16 @@ TOOL_REGISTRY = [ }, handler=get_page_cookies_handler ), + Tool( + name="open_new_window", + description="Opens a new Firefox window with the specified URL.", + schema={ + "type": "object", + "properties": { + "url": {"type": "string", "description": "The URL to open in the new window"} + }, + "required": ["url"], + }, + handler=open_new_window_handler + ), ] diff --git a/bridge/tools/open_new_window.py b/bridge/tools/open_new_window.py new file mode 100644 index 0000000..6fc7c33 --- /dev/null +++ b/bridge/tools/open_new_window.py @@ -0,0 +1,16 @@ +import asyncio +from typing import Any, Dict +from tools.utils import ToolError + +async def handle(args: Dict[str, Any], bridge: Any) -> list: + """ + Opens a new Firefox window with the specified URL. + """ + url = args.get("url") + if not url: + raise ToolError("Missing required argument: 'url'") + + request_id = f"req_{asyncio.get_event_loop().time()}_{id(args)}" + await bridge.send_to_extension(request_id, "open_new_window", {"url": str(url)}) + + return [{"type": "text", "text": f"Opened new window with {url}."}] diff --git a/extension/background.js b/extension/background.js index 93e74ba..6a68718 100644 --- a/extension/background.js +++ b/extension/background.js @@ -225,6 +225,10 @@ async function handleRequest(msg) { result = await openNewTab(params.url, params.window_id); break; + case "open_new_window": + result = await openNewWindow(params.url); + break; + default: throw new Error(`Unknown action: ${action}`); } @@ -307,6 +311,11 @@ async function openNewTab(url, windowId) { return { success: true }; } +async function openNewWindow(url) { + await browser.windows.create({ url: url }); + return { success: true }; +} + // ------------------------------------------------------------------ // Initialize connection // ------------------------------------------------------------------