Skip to content

Commit 963b3c4

Browse files
committed
Add get_system_info tool to browser tools for platform-aware keyboard shortcuts
Agent can call this to know which modifier key to use (Meta on macOS, Control on Windows/Linux) before pressing keyboard shortcuts.
1 parent 3b52641 commit 963b3c4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

connectonion/useful_tools/browser_tools/browser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import os
2525
import base64
26+
import platform
2627
from pathlib import Path
2728
from datetime import datetime
2829
from typing import Optional, List, Dict, Any
@@ -286,6 +287,15 @@ def keyboard_press(self, key: str) -> str:
286287
self.page.keyboard.press(key)
287288
return f"Pressed: '{key}'"
288289

290+
def get_system_info(self) -> str:
291+
"""Get the operating system info. Call this before using keyboard shortcuts so you know which modifier key to use (Meta on macOS, Control on Windows/Linux)."""
292+
system = platform.system()
293+
if system == "Darwin":
294+
return "OS: macOS. Use Meta for shortcuts (Meta+a select all, Meta+c copy, Meta+v paste, Meta+z undo)."
295+
elif system == "Windows":
296+
return "OS: Windows. Use Control for shortcuts (Control+a select all, Control+c copy, Control+v paste, Control+z undo)."
297+
return "OS: Linux. Use Control for shortcuts (Control+a select all, Control+c copy, Control+v paste, Control+z undo)."
298+
289299
def get_text(self) -> str:
290300
"""Get all visible text from the page."""
291301
if not self.page:

0 commit comments

Comments
 (0)