Files
multica/server/internal/daemon/terminal/errors.go
Jiayuan Zhang 6758feba05 feat(daemon): add terminal Manager + PTY session (Phase 1, MUL-2295)
Daemon-side foundation for the Issue → Terminal feature. Manager owns
the lifecycle of all live PtySessions; sessions spawn a shell on a real
PTY via creack/pty (unix-only — Windows returns ErrUnsupportedOS until
ConPty support lands).

Open enforces the cross-workspace ACL — a client acting in workspace A
cannot attach to a task that belongs to workspace B. Each session
injects CLAUDE_SESSION_ID + MULTICA_{WORKSPACE,ISSUE,TASK,USER}_ID into
the child env so `claude --resume $CLAUDE_SESSION_ID` continues the
same session the agent run was using.

Adds the terminal.* WebSocket message types to server/pkg/protocol so
Phase 2 (daemonws routing) and Phase 3 (CLI) can land without touching
the manager.

Tests cover open, data round-trip, resize, explicit close, idle timeout
sweep, manager shutdown, cross-workspace rejection, and unknown task.
A fake Spawner backed by channels lets tests exercise lifecycle without
forking a real shell.

Co-authored-by: multica-agent <github@multica.ai>
2026-05-16 16:32:39 +08:00

15 lines
607 B
Go

package terminal
import "errors"
// Sentinel errors returned by Manager. Callers map these to the
// protocol.TerminalErrorCode* constants when reporting to clients.
var (
ErrTaskNotFound = errors.New("terminal: task not found")
ErrWorkspaceMismatch = errors.New("terminal: task belongs to a different workspace")
ErrSessionNotFound = errors.New("terminal: session not found")
ErrUnsupportedOS = errors.New("terminal: PTY not supported on this OS")
ErrSpawnFailed = errors.New("terminal: failed to spawn shell")
ErrManagerClosed = errors.New("terminal: manager is shut down")
)