feat(sandbox): isolate worker/chat execution in Docker containers with lifecycle UI

- Add Docker sandbox manager, non-root sandbox image, compose isolation, and host firewall script (#217)
- Route Bash, custom commands/scripts, stdio MCP, chat sessions, MainAgent chat, and task-scoped reporter screenshots into sandbox containers with per-task browser concurrency gate
- Enforce proxy SSRF guard against loopback, metadata, internal services, and admin port
- Add dedicated /system/sandbox management page, /chat session sandbox control, and task detail sandbox popover with progressive stats loading
This commit is contained in:
ji ruo committed 2026-12-01 21:13:21 +08:00
1 parent 6bbeac588d
commit 9c43e694a3
44 files changed
+7086 -91

No files matched your search

+36
View File
@@ -118,6 +118,9 @@ import type {
TrafficResp,
UpdateCheck,
UpdateSettings,
SandboxContainerInfo,
SandboxGlobalStatus,
SandboxRuntimeOverrides,
UsageStats,
WorkspaceFile,
WorkspaceListing,
@@ -1813,4 +1816,37 @@ export const api = {
// 202 即返回,实际下载在后台跑,进度走 /api/update/stream。
applyUpdate: () => post<{ ok: boolean; target: string }>(`/update/apply`),
rollbackUpdate: () => post<{ ok: boolean }>(`/update/rollback`),
// ---- Sandbox container isolation ----
sandboxStatus: (withStats = false) =>
get<SandboxGlobalStatus>(`/sandbox/status${withStats ? "?stats=1" : ""}`),
updateSandboxSettings: (ov: SandboxRuntimeOverrides) => put<SandboxGlobalStatus>("/sandbox/settings", ov),
pruneSandboxContainers: () => post<{ removed: number }>("/sandbox/prune"),
sandboxContainer: (scope: string, ownerID: string, withStats = true) =>
get<SandboxContainerInfo>(
`/sandbox/containers/${encodeURIComponent(scope)}/${encodeURIComponent(ownerID)}${withStats ? "" : "?stats=0"}`,
),
startSandboxContainer: (scope: string, ownerID: string) =>
post<SandboxContainerInfo>(`/sandbox/containers/${encodeURIComponent(scope)}/${encodeURIComponent(ownerID)}/start`),
stopSandboxContainer: (scope: string, ownerID: string) =>
post<SandboxContainerInfo>(`/sandbox/containers/${encodeURIComponent(scope)}/${encodeURIComponent(ownerID)}/stop`),
recreateSandboxContainer: (
scope: string,
ownerID: string,
opts?: { pause_task?: boolean; clear_workspace?: boolean },
) =>
post<SandboxContainerInfo>(
`/sandbox/containers/${encodeURIComponent(scope)}/${encodeURIComponent(ownerID)}/recreate`,
opts ?? {},
),
removeSandboxContainer: (scope: string, ownerID: string) =>
del<{ removed: string }>(`/sandbox/containers/${encodeURIComponent(scope)}/${encodeURIComponent(ownerID)}`),
taskSandbox: (taskID: string, withStats = true) =>
get<SandboxContainerInfo>(`/tasks/${encodeURIComponent(taskID)}/sandbox${withStats ? "" : "?stats=0"}`),
startTaskSandbox: (taskID: string) =>
post<SandboxContainerInfo>(`/tasks/${encodeURIComponent(taskID)}/sandbox/start`),
stopTaskSandbox: (taskID: string, pauseTask = false) =>
post<SandboxContainerInfo>(`/tasks/${encodeURIComponent(taskID)}/sandbox/stop`, { pause_task: pauseTask }),
recreateTaskSandbox: (taskID: string, opts?: { pause_task?: boolean; clear_workspace?: boolean }) =>
post<SandboxContainerInfo>(`/tasks/${encodeURIComponent(taskID)}/sandbox/recreate`, opts ?? {}),
};