Sandbox 模块¶
Sandbox模块提供了隔离环境以安全地运行代码。
公共接口¶
用户通常直接从agentscope_runtime.sandbox
包导入的主要类:
BaseSandbox¶
BrowserSandbox¶
- class agentscope_runtime.sandbox.BrowserSandbox(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None)[source]
Bases:
Sandbox
- __init__(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None)[source]
Initialize the sandbox interface.
- property browser_ws
- browser_close()[source]
- browser_console_messages()[source]
- browser_navigate_back()[source]
- browser_navigate_forward()[source]
- browser_network_requests()[source]
- browser_take_screenshot(raw=False, filename='', element='', ref='')[source]
- browser_snapshot()[source]
- browser_drag(start_element, start_ref, end_element, end_ref)[source]
- browser_type(element, ref, text, submit=False, slowly=False)[source]
- browser_select_option(element, ref, values)[source]
- browser_tab_list()[source]
FilesystemSandbox¶
- class agentscope_runtime.sandbox.FilesystemSandbox(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None)[source]
Bases:
Sandbox
- __init__(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None)[source]
Initialize the sandbox interface.
- search_files(path, pattern, exclude_patterns=[])[source]
- list_allowed_directories()[source]
TrainingSandbox¶
- class agentscope_runtime.sandbox.TrainingSandbox(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None, box_type=SandboxType.APPWORLD)[source]
Bases:
Sandbox
Training Sandbox class for managing and executing training-related tasks.
This class provides methods to create, manage, and interact with training environment instances using specialized tool calls.
- Parameters:
- __init__(sandbox_id=None, timeout=3000, base_url=None, bearer_token=None, box_type=SandboxType.APPWORLD)[source]
Initialize the Training Sandbox.
- create_instance(env_type, task_id, instance_id=None, params=None)[source]
Create a new instance of a training environment.
- get_task_ids(env_type, split='train', params=None)[source]
Retrieve task identifiers for a specific environment.
- get_env_profile(env_type, split='train', params=None)[source]
Retrieve the environment profile.
- step(instance_id, action=None, params=None)[source]
Execute a step in the training environment.
- evaluate(instance_id, messages=None, params=None)[source]
Evaluate the performance of a training environment instance.
- Parameters:
instance_id (str) – Identifier of the environment instance.
messages (Dict, optional) – Evaluation-related messages.
params (Dict, optional) – Additional evaluation parameters.
- Returns:
Evaluation results.