类class
agentscope.workspaceDaytonaWorkspace
class DaytonaWorkspace(SandboxedWorkspaceBase)
源码Source
agentscope/workspace/_daytona/_daytona_workspace.py:69–479Daytona 工作区,在隔离环境中安全执行代码和工具。位于 agentscope.workspace 包,继承自 SandboxedWorkspaceBase。核心成员包括 get_instructions、sandbox_id。
default_mcps and skill_paths are seed-time inputs and are
not interpreted until :meth:initialize, after the Daytona backend
has been provisioned and the shared sandbox lifecycle can restore
persisted state.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(*, workspace_id: str | None = None, api_key: str = '', api_url: str = '', target: str = '', timeout_second… | 初始化 `DaytonaWorkspace` 实例。 Construct a :class:`DaytonaWorkspace`. |
属性摘要Property Summary
| 属性Property | 说明Description |
|---|---|
sandbox_id | 获取沙箱标识。 Daytona sandbox id, or ``None`` if not started. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def get_instructions() -> strasync | 获取指令。 Return the system-prompt fragment for this workspace. |
构造器详情Constructor Detail
DaytonaWorkspace
def __init__(*, workspace_id: str | None = None, api_key: str = '', api_url: str = '', target: str = '', timeout_seconds: int = DEFAULT_TIMEOUT, gateway_port: int = DEFAULT_GATEWAY_PORT, env: dict[str, str] | None = None, sandbox_metadata: dict[str, str] | None = None, extra_pip: list[str] | None = None, instructions: str = DEFAULT_WORKSPACE_INSTRUCTIONS, default_mcps: list[MCPClient] | None = None, skill_paths: list[str] | None = None, os_user: str | None = None) -> None
初始化 DaytonaWorkspace 实例。
The sandbox is not started here — call :meth:initialize (or use the workspace as an async context manager).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspace_idkw默认default None | str | None | 工作区标识(类型 `str | None`)。Stable identifier; also stored in Daytona labels for reattachment. `None` generates a fresh UUID. |
api_keykw默认default '' | str | API 密钥(类型 `str`)。Daytona API key. `""` lets the SDK read credentials from its normal environment. |
api_urlkw默认default '' | str | API URL(类型 `str`)。Optional Daytona API URL for self-hosted deployments. Empty string defers to SDK defaults. |
targetkw默认default '' | str | 目标(类型 `str`)。Optional Daytona target / region. Empty string defers to SDK defaults. |
timeout_secondskw默认default DEFAULT_TIMEOUT | int | 超时秒数(类型 `int`)。Timeout forwarded to Daytona create/start/recover/stop calls. |
gateway_portkw默认default DEFAULT_GATEWAY_PORT | int | 网关 port(类型 `int`)。TCP port the in-sandbox gateway listens on. |
envkw默认default None | dict[str, str] | None | env(类型 `dict[str, str] | None`)。Environment variables passed to Daytona create params as `env_vars`. |
sandbox_metadatakw默认default None | dict[str, str] | None | 沙箱元数据(类型 `dict[str, str] | None`)。Extra labels merged with the workspace-id label. Useful for dashboard filtering by user / agent. |
extra_pipkw默认default None | list[str] | None | extra pip(类型 `list[str] | None`)。Extra Python packages installed into the gateway venv during bootstrap. |
instructionskw默认default DEFAULT_WORKSPACE_INSTRUCTIONS | str | 指令(类型 `str`)。System-prompt fragment template (supports `{workdir}`). |
default_mcpskw默认default None | list[MCPClient] | None | 默认 mcps(类型 `list[MCPClient] | None`)。MCPs registered on first init when no persisted `.mcp` exists. |
skill_pathskw默认default None | list[str] | None | 技能 paths(类型 `list[str] | None`)。Local skill dirs seeded into `skills/` on first init. |
os_userkw默认default None | str | None | os 用户(类型 `str | None`)。Optional Daytona OS user. `None` means AgentScope lets Daytona and the selected snapshot decide. |
源码Source
agentscope/workspace/_daytona/_daytona_workspace.py:83–169属性详情Property Detail
sandbox_id
def sandbox_id() -> str | None
获取沙箱标识。
Daytona sandbox id, or None if not started.
str | None
返回str|None。Returns str none.
源码Source
agentscope/workspace/_daytona/_daytona_workspace.py:174–176方法详情Method Detail
get_instructions
async def get_instructions() -> str
async
获取指令。
Substitutes {workdir} in the configured template with the SDK-reported sandbox workdir.
str
返回字符串结果。Returns a string.
源码Source
agentscope/workspace/_daytona/_daytona_workspace.py:220–230