Workspace Runtime
概覽
Workspace Runtime 是運行在每個開發工作區容器內的服務,提供 Agent 執行整合、檔案管理與 local history、Git、Thread event WebSocket 及 Automation 執行等功能。Claude Code、Codex 與 OpenCode 都透過這個 runtime 執行。
核心功能
Agent 執行整合
- 設定管理:Claude Code、Codex、OpenCode 設定的讀取與更新
- Hooks 管理:自訂 hooks 設定與管理
- MCP 整合:MCP 伺服器設定管理
- 子代理管理:Claude Code 子代理設定
- 斜線命令:自訂斜線命令管理
從前端送出訊息、三種 Agent 事件正規化、Thread 持久化、WebSocket 到前端 timeline 的完整邊界,請見 AI Chat 前後端架構。
檔案系統管理
- 檔案操作:目錄樹、搜尋、讀寫、上傳、複製、搬移、archive 與 extract
- Local history:列出 檔案異動歷史並還原指定版本
- 版本控制:Git 整合和操作
- Knowledge Base:將Workspace attachment以
/knowledge/{alias}零複製唯讀提供; Runtime不能把KB切換成可寫模式
Automation 執行
- Claim/complete:以instance-scoped control token向Manager claim工作並回報結果
- Lease/heartbeat:執行期間更新lease,讓Manager可辨識失聯execution
- 狀態保存:Automation execution與Thread state保存在Workspace-scoped Runtime PostgreSQL schema
WebSocket 通訊
- Thread event channel:向前端推送Thread invalidation與執行狀態事件
- 重新連線:Frontend在斷線重連後重新取得authoritative timeline
- 認證:Browser以WebSocket subprotocol攜帶Bearer credential,不把token放入URL
授權與 Generation
- Action gate:HTTP 與 WebSocket 依封閉 route inventory 映射成
runtime_read、runtime_write、workspace_settings、terminal、agent、automation或browser_automation。一般使用者 request 會把原始 bearer credential、Workspace、instance 與 exact action 送到 Manager/runtime-access逐次驗證;Reader 只允許安全 read projection,其他 action 需要 Manager、 Owner 或 Platform Admin - Instance fence:驗證
runtimeInstanceId、Runtime lifecycle與access observed revision;Manager無法確認時fail closed。KB mount observed revision只由KB相依操作檢查, 不封鎖一般Runtime API - 共置Terminal:Terminal與agent都在Runtime workload內;Runtime identity消失即 同時fence這些程序
- Signed drain 與 pairing:只接受 Manager 的短效 Ed25519 assertion,並驗證
audience、user/Workspace/instance、generation、action、期限、single-use
jti與 replay state
Runtime route classifier 使用 machine-readable route × method inventory。精確敏感 route 與敏感 wildcard 優先於一般 mutation/read;Claude、Codex、OpenCode raw settings 與 MCP env/headers 都歸入 workspace_settings。未知或多重命中、Manager timeout/不可達時,middleware 在呼叫 handler 前拒絕。
Direct/group share、群組成員、帳號狀態、Owner 或 Platform Admin access 發生變更時,Manager 提升 generation;Runtime 立即拒絕已失效的 internal assertion,並終止不再允許的 Terminal、Agent、Automation、Browser 與其他 execution session。Runtime 不接受由前端傳入的角色或 operation list。
完整的component revision收斂、drain與fencing流程請見Execution-Plane 生命週期與安全機制。