OpenShell
OpenShell 是 OpenClaw 的託管沙箱後端。OpenClaw 不是在本地執行 Docker 容器,而是將沙箱生命週期委託給openshell CLI,
它使用基於 SSH 的命令執行來配置遠端環境。
OpenShell 外掛程式重用與通用 SSH backend 相同的核心 SSH 傳輸和遠端檔案系統
橋接。它增加 OpenShell 特定的生命週期(sandbox create/get/delete、sandbox ssh-config)
和可選的 mirror workspace mode。
先決條件
openshellCLI 已安裝並在PATH中(或通過plugins.entries.openshell.config.command設定自訂路徑)- 具有沙箱訪問的 OpenShell 帳戶
- OpenClaw Gateway 在主機上執行
快速開始
- 啟用外掛程式並設定沙箱後端:
- 重新啟動 Gateway。在下一個 agent turn,OpenClaw 建立 OpenShell 沙箱並通過它路由 tool 執行。
- 驗證:
Workspace modes
使用 OpenShell 時,這是最重要的決定。mirror
當您想要 本地 workspace 保持規範 時,使用 plugins.entries.openshell.config.mode: "mirror"。
行為:
- 在
exec前,OpenClaw 將本地 workspace 同步到 OpenShell 沙箱中。 - 在
exec後,OpenClaw 將遠端 workspace 同步回本地 workspace。 - File tools 仍通過沙箱橋接運作,但本地 workspace 在 turns 之間保持是事實來源。
- 您在 OpenClaw 外本地編輯檔案,並希望這些更改在 沙箱中自動可見。
- 您希望 OpenShell 沙箱盡可能表現得像 Docker 後端。
- 您希望主機 workspace 在每次 exec turn 後反映沙箱寫入。
remote
當您想要 OpenShell workspace 成為規範 時,使用 plugins.entries.openshell.config.mode: "remote"。
行為:
- 當沙箱首次建立時,OpenClaw 一次從 本地 workspace 播種遠端 workspace。
- 在那之後,
exec、read、write、edit和apply_patch運作 直接針對遠端 OpenShell workspace。 - OpenClaw 不會將遠端更改同步回本地 workspace。
- Prompt-time media reads 仍然有效,因為 file 和 media tools 通過 沙箱橋接讀取。
- 沙箱應主要存在於遠端。
- 您想要較低的 per-turn 同步開銷。
- 您不希望主機本地編輯在沒有提示的情況下覆蓋遠端沙箱狀態。
openclaw sandbox recreate 重新播種。
選擇 mode
mirror | remote | |
|---|---|---|
| 規範 workspace | 本地主機 | 遠端 OpenShell |
| 同步方向 | 雙向(每 exec) | 一次播種 |
| Per-turn 開銷 | 更高(上傳 + 下載) | 更低(直接遠端操作) |
| 本地編輯可見? | 是,在下一個 exec 上 | 否,直到 recreate |
| 最適合 | 開發工作流 | 長執行代理、CI |
設定參考
所有 OpenShell 設定位於plugins.entries.openshell.config 下:
| 金鑰 | 類型 | 預設值 | 說明 |
|---|---|---|---|
mode | "mirror" 或 "remote" | "mirror" | Workspace 同步 mode |
command | string | "openshell" | openshell CLI 的路徑或名稱 |
from | string | "openclaw" | 首次建立的沙箱來源 |
gateway | string | — | OpenShell gateway 名稱(--gateway) |
gatewayEndpoint | string | — | OpenShell gateway 端點 URL(--gateway-endpoint) |
policy | string | — | OpenShell policy ID 進行沙箱建立 |
providers | string[] | [] | 建立沙箱時附加的提供者名稱 |
gpu | boolean | false | 請求 GPU 資源 |
autoProviders | boolean | true | 在沙箱建立期間傳遞 --auto-providers |
remoteWorkspaceDir | string | "/sandbox" | 沙箱內的主要可寫 workspace |
remoteAgentWorkspaceDir | string | "/agent" | Agent workspace 掛載路徑(供唯讀訪問) |
timeoutSeconds | number | 120 | openshell CLI 操作的逾時 |
mode、scope、workspaceAccess)在
agents.defaults.sandbox 下設定,如任何後端。參見
Sandboxing 以了解完整矩陣。
範例
最小遠端設定
Mirror mode 搭配 GPU
Per-agent OpenShell 搭配自訂 gateway
生命週期管理
OpenShell 沙箱通過正常 sandbox CLI 管理:remote mode,recreate 特別重要:它刪除該範圍的規範
遠端 workspace。下次使用時播種一個新的遠端 workspace,來自
本地 workspace。
對於 mirror mode,recreate 主要重置遠端執行環境,因為
本地 workspace 保持規範。
何時 recreate
在更改任何這些後 recreate:agents.defaults.sandbox.backendplugins.entries.openshell.config.fromplugins.entries.openshell.config.modeplugins.entries.openshell.config.policy
當前限制
- OpenShell 後端上不支援 Sandbox browser。
sandbox.docker.binds不適用於 OpenShell。sandbox.docker.*下的 Docker 特定執行時旋鈕僅適用於 Docker 後端。
運作方式
- OpenClaw 呼叫
openshell sandbox create(帶有--from、--gateway、--policy、--providers、--gpuflags 如配置)。 - OpenClaw 呼叫
openshell sandbox ssh-config <name>獲取 SSH 連接 沙箱的詳情。 - Core 將 SSH 設定寫入臨時檔案並使用相同的遠端檔案系統橋接打開 SSH session,如通用 SSH 後端。
- 在
mirrormode:在 exec 前同步本地到遠端,執行,在 exec 後同步回。 - 在
remotemode:在建立時播種一次,然後直接在遠端 workspace 上運作。
另見
- Sandboxing — modes、scopes 和後端比較
- Sandbox vs Tool Policy vs Elevated — 調試被阻止的 tools
- Multi-Agent Sandbox and Tools — per-agent 覆蓋
- Sandbox CLI —
openclaw sandbox指令