AS AgentScopeAPI 手册 / API Reference
类class agentscope.workspace

AppleContainerWorkspace

class AppleContainerWorkspace(SandboxedWorkspaceBase)
源码Source agentscope/workspace/_applecontainer/_applecontainer_workspace.py:75–526

Apple 容器工作区,在隔离环境中安全执行代码和工具。位于 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 Nonestr | None工作区标识(类型 `str | None`)。Stable identifier; also used as the container name suffix.
base_imagekw默认default DEFAULT_BASE_IMAGEstr基类图像(类型 `str`)。OCI image to run. Must provide `python3`. Ubuntu/ Debian-based images are preferred for apt-get bootstrap.
gateway_portkw默认default DEFAULT_GATEWAY_PORTint网关 port(类型 `int`)。TCP port the in-container gateway listens on.
cpuskw默认default DEFAULT_CPUSintcpus(类型 `int`)。Number of virtual CPUs allocated to the container.
memorykw默认default DEFAULT_MEMORYstr记忆(类型 `str`)。Memory allocation (e.g. `"2G"`, `"512M"`).
envkw默认default Nonedict[str, str] | Noneenv(类型 `dict[str, str] | None`)。Environment variables set inside the container.
extra_pipkw默认default Nonelist[str] | Noneextra pip(类型 `list[str] | None`)。Extra Python packages installed into the gateway venv during bootstrap.
instructionskw默认default _DEFAULT_INSTRUCTIONSstr指令(类型 `str`)。System-prompt fragment template (supports `{workdir}`).
default_mcpskw默认default Nonelist[MCPClient] | None默认 mcps(类型 `list[MCPClient] | None`)。MCPs registered on first init when no persisted `.mcp` exists.
skill_pathskw默认default Nonelist[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}.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/workspace/_applecontainer/_applecontainer_workspace.py:230–232
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.