shell: restore detach field for autonomous background processes

Re-adds the detach boolean to the shell tool args. When true, the
process is immediately backgrounded and its PID returned. This was
removed in the simplification commit 2c36c02 but is needed for
long-running commands (builds, servers, etc).
This commit is contained in:
Levi Neely 2026-07-29 09:19:03 +02:00
parent 12e3338b69
commit 0e1c0f199d
1 changed files with 3 additions and 2 deletions

View File

@ -143,6 +143,7 @@ func dispatchShell(ctx context.Context, e *Server, args json.RawMessage) (string
Timeout int `json:"timeout"`
Sandbox string `json:"sandbox"`
Elevated bool `json:"elevated"`
Detach bool `json:"detach"`
}
if err := json.Unmarshal(args, &a); err != nil {
return "", fmt.Errorf("shell: bad args: %w", err)
@ -158,13 +159,13 @@ func dispatchShell(ctx context.Context, e *Server, args json.RawMessage) (string
e.wdMu.RLock()
workDir := e.cwd
e.wdMu.RUnlock()
return e.executeElevated(ctx, a.Cmd, workDir, timeout)
return e.executeElevated(ctx, a.Cmd, workDir, timeout, a.Detach)
}
sandboxName := a.Sandbox
if sandboxName == "" {
sandboxName = "default"
}
return e.executeWithStdin(ctx, a.Cmd, "bash", timeout, sandboxName, false, "")
return e.executeWithStdin(ctx, a.Cmd, "bash", timeout, sandboxName, false, "", a.Detach)
}
// dispatchToolList lists all available tools from the global registry.