Documentation
¶
Overview ¶
Package agents spawns and controls Claude Code sessions Caprock owns: a real `claude` process in a PTY, its output buffered for the terminal view and its exit recorded. Externally started sessions are never touched here — we only spawn, type into, pause and kill processes we started (.ai/05-orchestration.md).
Index ¶
- Variables
- func RevokeTrustGrants() (int, error)
- func TrustGrantCount() int
- type Agent
- type Manager
- func (m *Manager) ClaudeAvailable() bool
- func (m *Manager) Get(sessionID string) (*Agent, bool)
- func (m *Manager) Input(sessionID string, data []byte) error
- func (m *Manager) List() []*Agent
- func (m *Manager) Resize(sessionID string, cols, rows int) error
- func (m *Manager) Shutdown()
- func (m *Manager) Signal(sessionID string, sig ptyman.Signal) error
- func (m *Manager) Spawn(ctx context.Context, req SpawnRequest) (*Agent, error)
- type SpawnRequest
Constants ¶
This section is empty.
Variables ¶
var ErrNotOwned = errors.New("session is not owned by caprock (observe-only)")
ErrNotOwned is returned for control operations on a session Caprock did not spawn.
Functions ¶
func RevokeTrustGrants ¶ added in v0.18.0
RevokeTrustGrants removes hasTrustDialogAccepted from every folder Caprock granted it to, and clears the ledger. Grants Caprock did not create are left alone — the user may have accepted those folders themselves, and undoing a human's decision is not uninstall's job. Returns how many were revoked.
It exists because the grant was previously permanent and one-way: nothing, including `caprock hooks uninstall`, ever removed it, so a machine accumulated a trusted-project entry per worktree forever — including for worktrees long since deleted.
func TrustGrantCount ¶ added in v0.18.0
func TrustGrantCount() int
TrustGrantCount reports how many folders Caprock has granted trust to, for the uninstall command's summary line.
Types ¶
type Agent ¶
type Agent struct {
SessionID string
Cwd string
Worktree string
Command string
StartedAt time.Time
// contains filtered or unexported fields
}
Agent is a live owned session.
func (*Agent) Snapshot ¶
Snapshot returns the current terminal scrollback (for a fresh terminal connect).
type Manager ¶
type Manager struct {
OnExit func(sessionID string, code int)
OnOutput func(sessionID string) // called (throttled by caller) when new bytes arrive
// NewSessionID generates a session id; overridable in tests.
NewSessionID func() string
// contains filtered or unexported fields
}
Manager owns the set of running agents.
func NewManager ¶
NewManager builds a manager. claudePath "" resolves "claude" on PATH.
func (*Manager) ClaudeAvailable ¶
ClaudeAvailable reports whether the resolved claude binary can be launched.
func (*Manager) Shutdown ¶
func (m *Manager) Shutdown()
Shutdown kills every owned session (daemon stopping).
type SpawnRequest ¶
type SpawnRequest struct {
Cwd string `json:"cwd"`
Worktree string `json:"worktree,omitempty"` // git worktree name to create under the repo
Model string `json:"model,omitempty"` // --model
PermissionMode string `json:"permission_mode,omitempty"` // --permission-mode
Command string `json:"command,omitempty"` // default "claude"
Args []string `json:"args,omitempty"` // extra args
Cols int `json:"cols,omitempty"`
Rows int `json:"rows,omitempty"`
}
SpawnRequest describes a session to launch.