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 tab 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)}" params: Dict[str, Any] = {"url": str(url)} if args.get("window_id") is not None: params["window_id"] = int(args["window_id"]) await bridge.send_to_extension(request_id, "open_new_tab", params) return [{"type": "text", "text": f"Opened new tab with {url}."}]