Files
sci-gui-agent-benchmark/mm_agents/autoglm/tools/package/google_chrome.py
Adam Yanxiao Zhao aa05f6cc26 Add AutoGLM-OS agent (#309)
* autoglm-os initialize

* clean code

* chore: use proxy for download setup

* feat(autoglm-os): add parameter to toggle images

* fix: use temporary directory for files pulled from the vm to prevent potential collision when running multiple instances of the same task in parallel

* update

* add client_password

* update multienv

* fix

* fix prompt

* fix prompt

* fix prompt

* fix sys prompt

* feat: use proxy in file evaluator

* fix client_password

* fix note_prompt

* fix autoglm agent cmd type

* fix

* revert: fix: use temporary directory for files pulled from the vm to prevent potential collision when running multiple instances of the same task in parallel

reverts commit bab5473eea1de0e61b0e1d68b23ce324a5b0ee57

* feat(autoglm): setup tools

* fix(autoglm): remove second time of get a11y tree

* add osworld server restart

* Revert "add osworld server restart"

This reverts commit 7bd9d84122e246ce2a26de0e49c25494244c2b3d.

* fix _launch_setup

* fix autoglm agent tools & xml tree

* fix desktop_env

* fix bug for tool name capitalization

* fix: always use proxy for setup download

* add fail after exceeding max turns

* fix(autoglm): avoid adding image to message when screenshot is empty

* fix maximize_window

* fix maximize_window

* fix maximize_window

* fix import browsertools module bug

* fix task proxy config bug

* restore setup

* refactor desktop env

* restore image in provider

* restore file.py

* refactor desktop_env

* quick fix

* refactor desktop_env.step

* fix our env reset

* add max truns constraint

* clean run script

* clean lib_run_single.py

---------

Co-authored-by: hanyullai <hanyullai@outlook.com>
Co-authored-by: JingBh <jingbohao@yeah.net>
2025-08-17 12:08:40 +08:00

108 lines
3.5 KiB
Python

class BrowserTools:
ret = ""
@classmethod
def print_result(cls):
print(cls.ret)
@classmethod
def env_info(cls):
cls.ret = "None"
# @classmethod
# def show_all_tabs(cls):
# cls.ret = "Browser not found"
# for attempt in range(3):
# with sync_playwright() as p:
# try:
# browser = p.chromium.connect_over_cdp(cls.remote_debugging_url)
# if not browser:
# continue
# context = browser.contexts[0]
# # 获取所有窗口名称
# cls.ret = 'Browser Tabs: '
# for idx, page in enumerate(context.pages):
# cls.ret += f"{idx}. {page.title()} ({page.url})" + '\n'
# return cls.ret
# except TimeoutError:
# cls.ret = 'Failed to get browser tabs'
# return None
# return None
@classmethod
def open_profile_settings(cls):
"""
Open the profile settings page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://settings/people"]}}
@classmethod
def open_password_settings(cls):
"""
Open the password settings page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://settings/autofill"]}}
@classmethod
def open_privacy_settings(cls):
"""
Open the privacy settings page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://settings/privacy"]}}
@classmethod
def open_appearance_settings(cls):
"""
Open the appearance settings page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://settings/appearance"]}}
@classmethod
def open_search_engine_settings(cls):
"""
Open the search engine settings page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://settings/search"]}}
@classmethod
def bring_back_last_tab(cls):
"""
Bring back the last tab in the browser.
"""
return f"import pyautogui; pyautogui.hotkey('ctrl', 'shift', 't'); print('Brought back last tab')"
@classmethod
def print(cls):
"""
Open the print option in current page.
"""
return f"import pyautogui; pyautogui.hotkey('ctrl', 'p'); print('Opened print option')"
@classmethod
def delete_browsing_data(cls):
"""
Delete browsing data in the browser.
"""
return f"import pyautogui; pyautogui.hotkey('ctrl', 'shift', 'del'); print('Deleted browsing data')"
@classmethod
def open_extensions(cls):
"""
open the extensions page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://extensions"]}}
@classmethod
def bookmark_page(cls):
"""
Bookmark the current page in the browser.
"""
return f"import pyautogui; pyautogui.hotkey('ctrl', 'd'); print('Bookmarked page')"
@classmethod
def open_bookmarks(cls):
"""
Open the bookmarks page in the browser.
"""
return {"action_type": "OPEN_CHROME_TAB", "parameters": {"urls_to_open": ["chrome://bookmarks"]}}