Documentation
¶
Index ¶
- func FormatHealth(sh SystemHealth) string
- func KillLocalAgent(a agent.Agent) error
- type Claude
- func (c *Claude) CanEmbed() bool
- func (c *Claude) Discover() ([]agent.Agent, error)
- func (c *Claude) DiscoverWithSnapshot(snap *discovery.Snapshot) ([]agent.Agent, error)
- func (c *Claude) FindSessionFile(a agent.Agent) string
- func (c *Claude) Name() string
- func (c *Claude) OTELEnv(endpoint string) string
- func (c *Claude) OTELServiceName() string
- func (c *Claude) ParseTrace(filePath string) ([]trace.Turn, error)
- func (c *Claude) RecentDirs(max int) []RecentDir
- func (c *Claude) ResumeCommand(a agent.Agent) *exec.Cmd
- func (c *Claude) SpawnArgs() SpawnArgs
- func (c *Claude) SpawnCommand(dir, model, mode string) *exec.Cmd
- func (c *Claude) SubagentAttrKeys() subagent.AttrKeys
- type Codex
- func (c *Codex) CanEmbed() bool
- func (c *Codex) Discover() ([]agent.Agent, error)
- func (c *Codex) DiscoverWithSnapshot(snap *discovery.Snapshot) ([]agent.Agent, error)
- func (c *Codex) FindSessionFile(a agent.Agent) string
- func (c *Codex) Name() string
- func (c *Codex) OTELEnv(endpoint string) string
- func (c *Codex) OTELServiceName() string
- func (c *Codex) ParseTrace(filePath string) ([]trace.Turn, error)
- func (c *Codex) RecentDirs(max int) []RecentDir
- func (c *Codex) ResumeCommand(a agent.Agent) *exec.Cmd
- func (c *Codex) SpawnArgs() SpawnArgs
- func (c *Codex) SpawnCommand(dir, model, mode string) *exec.Cmd
- func (c *Codex) SubagentAttrKeys() subagent.AttrKeys
- type HealthStatus
- type K8s
- func (k *K8s) CanEmbed() bool
- func (k *K8s) Close()
- func (k *K8s) Discover() ([]agent.Agent, error)
- func (k *K8s) FindSessionFile(a agent.Agent) string
- func (k *K8s) Name() string
- func (k *K8s) OTELEnv(_ string) string
- func (k *K8s) OTELServiceName() string
- func (k *K8s) ParseTrace(filePath string) ([]trace.Turn, error)
- func (k *K8s) RecentDirs(_ int) []RecentDir
- func (k *K8s) ResumeCommand(_ agent.Agent) *exec.Cmd
- func (k *K8s) SpawnArgs() SpawnArgs
- func (k *K8s) SpawnCommand(_, _, _ string) *exec.Cmd
- func (k *K8s) SubagentAttrKeys() subagent.AttrKeys
- type K8sConfig
- type Provider
- type ProviderHealth
- type RecentDir
- type RemoteHealthConfig
- type Role
- type Segment
- type SpawnArgs
- type SystemHealth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatHealth ¶ added in v0.7.0
func FormatHealth(sh SystemHealth) string
FormatHealth renders SystemHealth as a human-readable string.
func KillLocalAgent ¶ added in v0.7.0
KillLocalAgent sends SIGTERM to the agent's process tree, waits 3 seconds, then SIGKILL if still alive. Also kills the associated tmux session if one exists. Used by all local providers (Claude, Codex). Remote providers (e.g., Kubernetes) should implement their own Kill method.
Types ¶
type Claude ¶
type Claude struct{}
Claude is a Provider implementation for the Claude Code CLI.
func (*Claude) Discover ¶
Discover finds all running Claude Code processes, then enriches each agent with CWD, tmux session, session JSONL data, and estimated cost. SDK-spawned agents sharing the same directory and model are grouped into single entries.
func (*Claude) DiscoverWithSnapshot ¶ added in v0.8.1
DiscoverWithSnapshot uses a shared ps/tmux snapshot instead of running its own subprocess calls.
func (*Claude) FindSessionFile ¶
FindSessionFile resolves the session/trace file for a Claude agent. It first tries the session ID lookup, then falls back to finding the newest JSONL in the agent's working directory.
func (*Claude) OTELEnv ¶
OTELEnv returns env vars to enable Claude Code's OTEL tracing. Sets both generic and signal-specific endpoints with explicit paths to avoid OTEL SDK path-appending issues across different Node.js SDK versions. Uses http/protobuf protocol (port 4318).
func (*Claude) OTELServiceName ¶ added in v0.5.0
func (*Claude) ParseTrace ¶
ParseTrace reads a Claude JSONL session file and parses it into trace turns.
func (*Claude) RecentDirs ¶
RecentDirs returns recently-used project directories from Claude's session history (~/.claude/projects/). Each subdirectory is a dir-key (the encoded working directory path). The newest .jsonl in each subdirectory determines LastUsed.
func (*Claude) SpawnCommand ¶
SpawnCommand builds the exec.Cmd to launch a new Claude session.
Flags:
- --model <model> if model is set and not "default"
- --dangerously-skip-permissions if mode == "bypass"
- --permission-mode plan if mode == "plan"
func (*Claude) SubagentAttrKeys ¶ added in v0.5.0
SubagentAttrKeys returns the OTEL attribute names Claude uses for subagent identity.
type Codex ¶
type Codex struct{}
Codex is a Provider implementation for the OpenAI Codex CLI.
func (*Codex) CanEmbed ¶
CanEmbed returns false — Codex's TUI hangs inside an embedded PTY even with --no-alt-screen. Use trace view + J to jump out instead.
func (*Codex) Discover ¶
Discover finds running Codex CLI processes and recent session files. Running processes are discovered via ps; recent sessions (last 24h) without a running process are shown as idle so they can be resumed.
func (*Codex) DiscoverWithSnapshot ¶ added in v0.8.1
DiscoverWithSnapshot uses a shared ps/tmux snapshot.
func (*Codex) FindSessionFile ¶
FindSessionFile resolves the session/trace file for a Codex agent. Returns "" if the agent has no WorkingDir or if the session file is stale (not modified in the last 24 hours).
func (*Codex) OTELEnv ¶
OTELEnv returns env vars to enable Codex CLI's OTEL tracing. Codex exports both traces (session spans) and log events.
func (*Codex) OTELServiceName ¶ added in v0.5.0
func (*Codex) ParseTrace ¶
ParseTrace reads a Codex JSONL session file and parses it into trace turns.
func (*Codex) RecentDirs ¶
RecentDirs returns recently-used project directories from Codex's session history (~/.codex/sessions/). Scans recursively for .jsonl files from the last 30 days, reads session_meta for CWD, deduplicates by path, sorts by newest first, and caps at max.
func (*Codex) SpawnCommand ¶
SpawnCommand builds the exec.Cmd to launch a new Codex session.
Flags:
- --no-alt-screen always
- --model <model> if model is set and not "default"
- --full-auto if mode == "full-auto"
- --sandbox workspace-write if mode is empty or "default"
func (*Codex) SubagentAttrKeys ¶ added in v0.5.0
SubagentAttrKeys returns zero AttrKeys — Codex doesn't support subagent tracking.
type HealthStatus ¶ added in v0.7.0
type HealthStatus struct {
Configured bool
CoordOK bool
CoordErr string
ComputeOK bool
ComputeErr string
Workloads []string
}
HealthStatus represents the readiness of an infrastructure backend. Used by health.go for system health reporting.
type K8s ¶ added in v0.7.0
type K8s struct {
// contains filtered or unexported fields
}
K8s is a Provider implementation for Kubernetes-hosted AI agents. Infrastructure operations (Discover, Kill, Spawn, Health) have moved to environment.K8sEnvironment. This provider retains identity methods and ParseTrace (which reads Redis task history).
func (*K8s) CanEmbed ¶ added in v0.7.0
CanEmbed returns false — K8s agents run in pods and cannot be embedded as a local PTY.
func (*K8s) Close ¶ added in v0.7.0
func (k *K8s) Close()
Close shuts down the shared Redis client if one was created.
func (*K8s) Discover ¶ added in v0.7.0
Discover returns nil — discovery has moved to K8sEnvironment. Kept to satisfy the Provider interface until Task 1.6 wires environment-based discovery into the orchestrator.
func (*K8s) FindSessionFile ¶ added in v0.7.0
FindSessionFile returns a "k8s://<sessionID>" sentinel so the trace pane can pass it to ParseTrace, which uses it to query Redis task history.
func (*K8s) OTELEnv ¶ added in v0.7.0
OTELEnv returns "" — K8s agents configure their own OTEL settings via pod environment variables managed outside aimux.
func (*K8s) OTELServiceName ¶ added in v0.7.0
OTELServiceName returns the service.name for K8s agents in OTEL telemetry.
func (*K8s) ParseTrace ¶ added in v0.7.0
ParseTrace reads completed task history from Redis using the agentID encoded in filePath as "k8s://<agentID>".
func (*K8s) RecentDirs ¶ added in v0.7.0
RecentDirs returns nil — K8s agents do not work on local directories.
func (*K8s) ResumeCommand ¶ added in v0.7.0
ResumeCommand returns nil. K8s agents cannot be resumed as local processes.
func (*K8s) SpawnArgs ¶ added in v0.7.0
SpawnArgs describes the models and modes available when launching a K8s agent.
func (*K8s) SpawnCommand ¶ added in v0.7.0
SpawnCommand returns nil — K8s agents are not spawned locally.
func (*K8s) SubagentAttrKeys ¶ added in v0.7.0
SubagentAttrKeys returns zero value — K8s agents do not emit subagent identity attributes in the format aimux's OTEL receiver understands.
type K8sConfig ¶ added in v0.7.0
type K8sConfig struct {
RedisURL string // e.g. "redis://:pass@localhost:6380"
TeamID string // e.g. "my-team"
Namespace string // K8s namespace, e.g. "agents"
Kubeconfig string // path to kubeconfig; empty = in-cluster or KUBECONFIG env
}
K8sConfig holds connection settings for the Kubernetes provider. All fields may be populated from ~/.aimux/config.yaml under the "kubernetes" key.
type Provider ¶
type Provider interface {
Name() string
Discover() ([]agent.Agent, error)
ResumeCommand(a agent.Agent) *exec.Cmd
// CanEmbed returns true if the agent's TUI can run inside an
// embedded PTY (split view). False means trace-only view with
// jump-out for interaction.
CanEmbed() bool
// FindSessionFile resolves the session/trace file for an agent.
// Each provider knows its own storage layout. Returns "" if none found.
FindSessionFile(a agent.Agent) string
// RecentDirs returns recently-used project directories from this
// provider's session history, sorted by most recent first.
RecentDirs(max int) []RecentDir
// SpawnCommand builds the exec.Cmd to launch a new agent session
// in the given directory with the specified model and mode.
SpawnCommand(dir, model, mode string) *exec.Cmd
// SpawnArgs returns the available models and modes for the launcher UI.
SpawnArgs() SpawnArgs
// ParseTrace reads a session/trace file and parses it into a
// provider-specific structured trace. Each provider knows its own
// log format (Claude JSONL, Codex JSONL).
ParseTrace(filePath string) ([]trace.Turn, error)
// OTELEnv returns the shell env var prefix needed to enable OTEL
// tracing for this provider, pointing at the given endpoint.
// Each provider knows its own OTEL activation mechanism.
OTELEnv(endpoint string) string
// OTELServiceName returns the service.name value this provider
// emits in OTEL resource attributes (e.g. "claude-code").
OTELServiceName() string
// SubagentAttrKeys returns the OTEL attribute names this provider
// uses for subagent identity. Return zero AttrKeys if the provider
// doesn't support subagent tracking.
SubagentAttrKeys() subagent.AttrKeys
}
Provider discovers and manages AI CLI agents of a specific type. Adding a new provider requires only implementing this interface and registering in app.go NewApp() — no other files need changes.
type ProviderHealth ¶ added in v0.7.0
type ProviderHealth struct {
Name string // e.g. "claude", "k8s"
Kind string // "local" or "infra"
BinaryPath string // resolved path to the binary (local only)
BinaryOK bool // true if binary is found in PATH
Version string // binary version string (local only)
Agents int // number of currently active agents
Infra *HealthStatus // infra health details (infra only, nil for local)
}
ProviderHealth describes the health of a single provider.
type RemoteHealthConfig ¶ added in v0.13.0
type RemoteHealthConfig struct {
Backend string // "openshell" or ""
Gateway string // gateway endpoint URL
}
RemoteHealthConfig carries enough info to check OpenShell gateway health without importing the config package.
type Segment ¶
type Segment struct {
Time time.Time
Role Role
Content string
Tool string // tool name if Role==RoleTool
Detail string // e.g., file path, command snippet
}
Segment is a single conversation turn, provider-agnostic.
type SpawnArgs ¶
type SpawnArgs struct {
Models []string // e.g., ["default", "opus", "sonnet", "haiku"]
Modes []string // e.g., ["default", "bypass", "plan"]
}
SpawnArgs describes the available options for launching a new agent.
type SystemHealth ¶ added in v0.7.0
type SystemHealth struct {
Providers []ProviderHealth
}
SystemHealth holds the health of all providers and infra.
func GatherHealth ¶ added in v0.7.0
func GatherHealth(providers []Provider, agentCounts map[string]int) SystemHealth
GatherHealth collects health from all providers. Each local provider's binary is checked via exec.LookPath. Agent counts come from the most recent discovery results.
func GatherHealthWithRemote ¶ added in v0.13.0
func GatherHealthWithRemote(providers []Provider, agentCounts map[string]int, remote RemoteHealthConfig) SystemHealth
GatherHealthWithRemote extends GatherHealth with OpenShell gateway status.