mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-05 21:01:50 +08:00
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:
1 parent
6bbeac588d
commit
9c43e694a3
44 files changed
+7086
-91
No files matched your search
+17
-3
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/Autumn-27/artex/agent"
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"github.com/Autumn-27/artex/intercept"
|
||||
"github.com/Autumn-27/artex/internal/sandbox"
|
||||
"github.com/Autumn-27/norma/harness"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
@@ -190,6 +191,9 @@ func (e *Engine) nextPlannerRound(taskID string) int {
|
||||
func (e *Engine) Pause(taskID string, cause error) {
|
||||
e.paused.Store(taskID, true)
|
||||
e.cancelExec(taskID, cause)
|
||||
if mgr := sandbox.Default(); mgr != nil && mgr.Enabled() {
|
||||
mgr.RequestIdleStop(sandbox.Target{Scope: sandbox.ScopeTask, OwnerID: taskID})
|
||||
}
|
||||
}
|
||||
|
||||
// BeginDelete installs an execution barrier before task data/files are removed.
|
||||
@@ -205,9 +209,13 @@ func (e *Engine) BeginDelete(taskID string) bool {
|
||||
e.paused.Store(taskID, true)
|
||||
e.deleteMu.Unlock()
|
||||
e.cancelExec(taskID, agent.AbortTaskDeleted)
|
||||
if mgr := sandbox.Default(); mgr != nil && mgr.Enabled() {
|
||||
sctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
_ = mgr.Stop(sctx, sandbox.Target{Scope: sandbox.ScopeTask, OwnerID: taskID})
|
||||
cancel()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Engine) AbortDelete(taskID string, keepPaused bool) {
|
||||
e.deleteMu.Lock()
|
||||
if !e.IsDeleting(taskID) {
|
||||
@@ -306,11 +314,15 @@ func (e *Engine) StopTask(taskID string) {
|
||||
}
|
||||
return true
|
||||
})
|
||||
if mgr := sandbox.Default(); mgr != nil && mgr.Enabled() {
|
||||
rctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
_ = mgr.Remove(rctx, sandbox.Target{Scope: sandbox.ScopeTask, OwnerID: taskID})
|
||||
cancel()
|
||||
}
|
||||
e.deleteMu.Lock()
|
||||
e.deleting.Delete(taskID)
|
||||
e.deleteMu.Unlock()
|
||||
}
|
||||
|
||||
// cancelExec cancels a task's current per-task exec context (any in-flight
|
||||
// planner.Plan / worker.Execute), if present. Shared by Pause and the settle
|
||||
// sequence's hard-drain backstop.
|
||||
@@ -336,10 +348,12 @@ func (e *Engine) Resume(t *Task) {
|
||||
if e.IsDeleting(t.ID) {
|
||||
return
|
||||
}
|
||||
if mgr := sandbox.Default(); mgr != nil && mgr.Enabled() {
|
||||
mgr.ClearIdleStop(sandbox.Target{Scope: sandbox.ScopeTask, OwnerID: t.ID})
|
||||
}
|
||||
e.paused.Delete(t.ID)
|
||||
t.Notify()
|
||||
}
|
||||
|
||||
// execContextFor returns a live per-task context derived from parent, recreating
|
||||
// it if a prior pause cancelled it.
|
||||
func (e *Engine) execContextFor(parent context.Context, taskID string) context.Context {
|
||||
|
||||
Reference in new issue
Block a user