provider

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claude

type Claude struct{}

Claude is a Provider implementation for the Claude Code CLI.

func (*Claude) CanEmbed

func (c *Claude) CanEmbed() bool

CanEmbed returns true because Claude's TUI works inside an embedded PTY.

func (*Claude) Discover

func (c *Claude) Discover() ([]agent.Agent, error)

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) FindSessionFile

func (c *Claude) FindSessionFile(a agent.Agent) string

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) Name

func (c *Claude) Name() string

func (*Claude) OTELEnv

func (c *Claude) OTELEnv(endpoint string) string

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) ParseTrace

func (c *Claude) ParseTrace(filePath string) ([]trace.Turn, error)

ParseTrace reads a Claude JSONL session file and parses it into trace turns.

func (*Claude) RecentDirs

func (c *Claude) RecentDirs(max int) []RecentDir

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) ResumeCommand

func (c *Claude) ResumeCommand(a agent.Agent) *exec.Cmd

func (*Claude) SpawnArgs

func (c *Claude) SpawnArgs() SpawnArgs

SpawnArgs returns the available models and modes for launching Claude.

func (*Claude) SpawnCommand

func (c *Claude) SpawnCommand(dir, model, mode string) *exec.Cmd

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"

type Codex

type Codex struct{}

Codex is a Provider implementation for the OpenAI Codex CLI.

func (*Codex) CanEmbed

func (c *Codex) CanEmbed() bool

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

func (c *Codex) Discover() ([]agent.Agent, error)

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) FindSessionFile

func (c *Codex) FindSessionFile(a agent.Agent) string

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) Name

func (c *Codex) Name() string

func (*Codex) OTELEnv

func (c *Codex) OTELEnv(endpoint string) string

OTELEnv returns env vars to enable Codex CLI's OTEL tracing. Codex exports both traces (session spans) and log events.

func (*Codex) ParseTrace

func (c *Codex) ParseTrace(filePath string) ([]trace.Turn, error)

ParseTrace reads a Codex JSONL session file and parses it into trace turns.

func (*Codex) RecentDirs

func (c *Codex) RecentDirs(max int) []RecentDir

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) ResumeCommand

func (c *Codex) ResumeCommand(a agent.Agent) *exec.Cmd

func (*Codex) SpawnArgs

func (c *Codex) SpawnArgs() SpawnArgs

SpawnArgs returns the available models and modes for launching Codex.

func (*Codex) SpawnCommand

func (c *Codex) SpawnCommand(dir, model, mode string) *exec.Cmd

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"

type Gemini

type Gemini struct{}

Gemini is a Provider implementation for the Google Gemini CLI.

func (*Gemini) CanEmbed

func (g *Gemini) CanEmbed() bool

CanEmbed returns false because Gemini's TUI cannot run inside an embedded PTY.

func (*Gemini) Discover

func (g *Gemini) Discover() ([]agent.Agent, error)

Discover finds running Gemini CLI processes and enriches them with session data from ~/.gemini/tmp/<project>/chats/.

func (*Gemini) FindSessionFile

func (g *Gemini) FindSessionFile(a agent.Agent) string

FindSessionFile resolves the session file for a Gemini agent. If the agent has a SessionID, it finds the matching session-*.json in chats/. Otherwise it falls back to the newest session file.

func (*Gemini) Name

func (g *Gemini) Name() string

func (*Gemini) OTELEnv

func (g *Gemini) OTELEnv(endpoint string) string

OTELEnv returns env vars to enable Gemini CLI's OTEL tracing. Gemini exports traces, metrics, and logs.

func (*Gemini) ParseTrace

func (g *Gemini) ParseTrace(filePath string) ([]trace.Turn, error)

ParseTrace reads a Gemini session file and parses it into trace turns. Supports both logs.json (array of log entries) and session-*.json (session object with messages array) formats.

func (*Gemini) RecentDirs

func (g *Gemini) RecentDirs(max int) []RecentDir

RecentDirs returns recently-used project directories from Gemini's projects.json, sorted by most recent session activity.

func (*Gemini) ResumeCommand

func (g *Gemini) ResumeCommand(a agent.Agent) *exec.Cmd

ResumeCommand builds the command to resume the latest Gemini session.

func (*Gemini) SpawnArgs

func (g *Gemini) SpawnArgs() SpawnArgs

SpawnArgs returns the available models and modes for launching Gemini.

func (*Gemini) SpawnCommand

func (g *Gemini) SpawnCommand(dir, model, mode string) *exec.Cmd

SpawnCommand builds the exec.Cmd to launch a new Gemini session.

Flags:

  • --model <model> if model is set and not "default"
  • --yolo if mode == "yolo"
  • --approval-mode plan if mode == "plan"

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, Gemini JSON).
	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
}

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 RecentDir

type RecentDir struct {
	Path     string
	LastUsed time.Time
}

RecentDir is a recently-used project directory from a provider's session history.

type Role

type Role int

Role identifies who produced a conversation segment.

const (
	RoleUser Role = iota
	RoleAssistant
	RoleTool
	RoleSystem
)

func (Role) String

func (r Role) String() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL