类class
agentscope.workspaceAppleContainerWorkspace
class AppleContainerWorkspace(SandboxedWorkspaceBase)
源码Source
agentscope/workspace/_applecontainer/_applecontainer_workspace.py:75–526Apple 容器工作区,在隔离环境中安全执行代码和工具。位于 agentscope.workspace 包,继承自 SandboxedWorkspaceBase。核心成员包括 get_instructions。
default_mcps and skill_paths are seed-time inputs and are
not retained as instance state past :meth:initialize.
Requires:
- macOS 26+ with Apple silicon
- container CLI installed and container system start running
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(*, workspace_id: str | None = None, base_image: str = DEFAULT_BASE_IMAGE, gateway_port: int = DEFAULT_GATE… | 初始化 `AppleContainerWorkspace` 实例。 Construct an :class:`AppleContainerWorkspace`. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def get_instructions() -> strasync | 获取指令。 Return the system-prompt fragment, formatted with ``{workdir}``. |
构造器详情Constructor Detail
AppleContainerWorkspace
def __init__(*, workspace_id: str | None = None, base_image: str = DEFAULT_BASE_IMAGE, gateway_port: int = DEFAULT_GATEWAY_PORT, cpus: int = DEFAULT_CPUS, memory: str = DEFAULT_MEMORY, env: dict[str, str] | None = None, extra_pip: list[str] | None = None, instructions: str = _DEFAULT_INSTRUCTIONS, default_mcps: list[MCPClient] | None = None, skill_paths: list[str] | None = None) -> None
初始化 AppleContainerWorkspace 实例。
The container 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 used as the container name suffix. |
base_imagekw默认default DEFAULT_BASE_IMAGE | str | 基类图像(类型 `str`)。OCI image to run. Must provide `python3`. Ubuntu/ Debian-based images are preferred for apt-get bootstrap. |
gateway_portkw默认default DEFAULT_GATEWAY_PORT | int | 网关 port(类型 `int`)。TCP port the in-container gateway listens on. |
cpuskw默认default DEFAULT_CPUS | int | cpus(类型 `int`)。Number of virtual CPUs allocated to the container. |
memorykw默认default DEFAULT_MEMORY | str | 记忆(类型 `str`)。Memory allocation (e.g. `"2G"`, `"512M"`). |
envkw默认default None | dict[str, str] | None | env(类型 `dict[str, str] | None`)。Environment variables set inside the container. |
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_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. |
源码Source
agentscope/workspace/_applecontainer/_applecontainer_workspace.py:89–153方法详情Method Detail
get_instructions
async def get_instructions() -> str
async
获取指令。
Return the system-prompt fragment, formatted with {workdir}.
str
返回字符串结果。Returns a string.
源码Source
agentscope/workspace/_applecontainer/_applecontainer_workspace.py:230–232