Documentation
¶
Overview ¶
Package agent manages Claude Code agent lifecycle: spawning, stopping, listing, attaching, and resuming background tmux sessions in devcontainers.
Index ¶
- Constants
- func AgentsDir() string
- func ContainerName(name string) string
- func DeleteMeta(name string) error
- func FetchTicketPrompt(ctx context.Context, key string, instances []tracker.Instance) (string, error)
- func FormatDuration(d time.Duration) string
- func MetaPath(name string) string
- func WriteMeta(m Meta) error
- type Manager
- func (m *Manager) Attach(_ context.Context, name string) (Meta, error)
- func (m *Manager) BuildClaudeArgs(opts StartOpts) []string
- func (m *Manager) Delete(ctx context.Context, name string) error
- func (m *Manager) Refresh(ctx context.Context) error
- func (m *Manager) Start(ctx context.Context, opts StartOpts) (Meta, error)
- func (m *Manager) Stop(ctx context.Context, name string) error
- type Meta
- type StartOpts
- type Status
Constants ¶
const ContainerPrefix = "human-agent-"
ContainerPrefix is prepended to all managed agent container names.
Variables ¶
This section is empty.
Functions ¶
func AgentsDir ¶
func AgentsDir() string
AgentsDir returns the directory where agent metadata is stored. Falls back to ./.human/agents/ when the home directory is unknown.
func ContainerName ¶
ContainerName returns the Docker container name for an agent.
func DeleteMeta ¶
DeleteMeta removes the agent metadata file from disk.
func FetchTicketPrompt ¶
func FetchTicketPrompt(ctx context.Context, key string, instances []tracker.Instance) (string, error)
FetchTicketPrompt loads the ticket identified by key from the configured tracker instances and formats its content as a prompt string suitable for sending to Claude Code.
func FormatDuration ¶
FormatDuration returns a human-readable duration string. Examples: "2m", "1h30m", "3d12h".
Types ¶
type Manager ¶
type Manager struct {
Docker devcontainer.DockerClient
}
Manager orchestrates agent lifecycle using devcontainers.
func (*Manager) BuildClaudeArgs ¶
BuildClaudeArgs constructs Claude Code CLI arguments.
func (*Manager) Delete ¶
Delete stops the container and deletes the agent metadata so no trace remains. Best-effort: always deletes metadata even if container cleanup fails. The whole sequence holds the per-name lock so a concurrent Stop cannot re-create the metadata file after DeleteMeta removes it.
type Meta ¶
type Meta struct {
Name string `json:"name"`
ContainerID string `json:"container_id"`
ContainerName string `json:"container_name"`
Cwd string `json:"cwd"`
Prompt string `json:"prompt,omitempty"`
Status Status `json:"status"`
CreatedAt time.Time `json:"created_at"`
StoppedAt time.Time `json:"stopped_at,omitempty"`
SkipPerms bool `json:"skip_perms,omitempty"`
Model string `json:"model,omitempty"`
ConfigDir string `json:"config_dir,omitempty"`
ImageName string `json:"image_name,omitempty"`
RemoteUser string `json:"remote_user,omitempty"`
}
Meta holds the persisted metadata for a single agent.
type StartOpts ¶
type StartOpts struct {
Name string
Prompt string
Model string
SkipPerms bool
ConfigDir string // where .devcontainer/devcontainer.json lives (default: cwd)
Workspace string // directory to mount into container (default: cwd)
Rebuild bool
Interactive bool // foreground TTY mode
}
StartOpts configures an agent start operation.