agent

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPathTraversal = errors.New("path traversal attempt detected")

Security error for path traversal attempts

Functions

func AllowUnsafeAgents

func AllowUnsafeAgents() bool

func AnthropicAPIKey

func AnthropicAPIKey() string

AnthropicAPIKey returns the configured Anthropic API key, or empty string if not set

func Available

func Available() []string

Available returns the names of all registered agents

func CanonicalName added in v0.34.0

func CanonicalName(name string) string

CanonicalName resolves an agent alias to its canonical name. Returns the name unchanged if it is not an alias.

func CodexSandboxDisabled added in v0.51.0

func CodexSandboxDisabled() bool

CodexSandboxDisabled returns true when the Codex bwrap sandbox should be skipped (e.g. on machines without unprivileged user namespace support). When true, Codex runs with --full-auto instead of --sandbox read-only.

func ExtractSessionID added in v0.44.0

func ExtractSessionID(line string) string

ExtractSessionID returns the agent session/thread identifier carried by a streamed JSONL event. For Codex, thread_id is treated as the session ID.

func IsAvailable

func IsAvailable(name string) bool

IsAvailable checks if an agent's command is installed on the system Supports aliases like "claude" for "claude-code"

func IsValidResumeSessionID added in v0.45.0

func IsValidResumeSessionID(sessionID string) bool

IsValidResumeSessionID reports whether a persisted session ID is safe to forward back to a CLI resume command.

func ReasoningLevels added in v0.36.0

func ReasoningLevels() []string

ReasoningLevels returns the canonical reasoning level names.

func Register

func Register(a Agent)

Register adds an agent to the registry

func ResolveWorkflowModelForAgent added in v0.44.1

func ResolveWorkflowModelForAgent(
	selectedAgent, cliModel, repoPath string,
	globalCfg *config.Config,
	workflow, level string,
) string

ResolveWorkflowModelForAgent resolves a workflow model for the actual agent that will run. If that agent differs from the generic default agent and no explicit model was provided, generic default_model is skipped so the selected agent can keep its own built-in default unless a workflow-specific model override exists.

func SetAllowUnsafeAgents

func SetAllowUnsafeAgents(allow bool)

func SetAnthropicAPIKey

func SetAnthropicAPIKey(key string)

SetAnthropicAPIKey sets the Anthropic API key for Claude Code

func SetCodexSandboxDisabled added in v0.51.0

func SetCodexSandboxDisabled(v bool)

func Unregister added in v0.37.0

func Unregister(name string)

Unregister removes an agent from the registry (useful for testing)

Types

type ACPAgent added in v0.40.0

type ACPAgent struct {
	Command         string   // ACP agent command (configured via TOML)
	Args            []string // Additional arguments for the agent
	Model           string   // Model to use
	Mode            string   // Mode to use
	ReadOnlyMode    string
	AutoApproveMode string
	Reasoning       ReasoningLevel // Reasoning level
	Agentic         bool           // Agentic mode
	Timeout         time.Duration  // Command timeout
	SessionID       string         // Current ACP session ID
	// contains filtered or unexported fields
}

ACPAgent runs code reviews using the Agent Client Protocol via acp-go-sdk

func NewACPAgent added in v0.40.0

func NewACPAgent(command string) *ACPAgent

func NewACPAgentFromConfig added in v0.40.0

func NewACPAgentFromConfig(config *config.ACPAgentConfig) *ACPAgent

func (*ACPAgent) CommandLine added in v0.40.0

func (a *ACPAgent) CommandLine() string

func (*ACPAgent) CommandName added in v0.40.0

func (a *ACPAgent) CommandName() string

func (*ACPAgent) Name added in v0.40.0

func (a *ACPAgent) Name() string

func (*ACPAgent) Review added in v0.40.0

func (a *ACPAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

Review implements the main review functionality using ACP SDK

func (*ACPAgent) WithAgentic added in v0.40.0

func (a *ACPAgent) WithAgentic(agentic bool) Agent

func (*ACPAgent) WithModel added in v0.40.0

func (a *ACPAgent) WithModel(model string) Agent

func (*ACPAgent) WithReasoning added in v0.40.0

func (a *ACPAgent) WithReasoning(level ReasoningLevel) Agent

type Agent

type Agent interface {
	// Name returns the agent identifier (e.g., "codex", "claude-code")
	Name() string

	// Review runs a code review and returns the output.
	// If output is non-nil, agent progress is streamed to it in real-time.
	Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (result string, err error)

	// WithReasoning returns a copy of the agent configured with the specified reasoning level.
	// Agents that don't support reasoning levels may return themselves unchanged.
	WithReasoning(level ReasoningLevel) Agent

	// WithAgentic returns a copy of the agent configured for agentic mode.
	// In agentic mode, agents can edit files and run commands.
	// If false, agents operate in read-only review mode.
	WithAgentic(agentic bool) Agent

	// WithModel returns a copy of the agent configured to use the specified model.
	// If model is empty, the agent is returned unchanged (preserving any built-in default).
	// Agents that don't support model selection may return themselves unchanged.
	// For opencode, the model format is "provider/model" (e.g., "anthropic/claude-sonnet-4-20250514").
	WithModel(model string) Agent

	// CommandLine returns a representative command line for this agent (binary + flags).
	// Runtime-specific arguments (repo path, output file, prompt) are excluded.
	// Useful for debugging which binary, model, and flags were used.
	CommandLine() string
}

Agent defines the interface for code review agents

func Get

func Get(name string) (Agent, error)

Get returns an agent by name (supports aliases like "claude" for "claude-code")

func GetAvailable

func GetAvailable(preferred string, backups ...string) (Agent, error)

GetAvailable returns an available agent, trying the requested one first, then falling back to alternatives. Returns error only if no agents available. Supports aliases like "claude" for "claude-code".

Optional backup agent names are tried after the preferred agent but before the hardcoded fallback chain. This lets callers honor default_backup_agent config without changing the global chain order.

func GetAvailableWithConfig added in v0.40.0

func GetAvailableWithConfig(preferred string, cfg *config.Config, backups ...string) (Agent, error)

GetAvailableWithConfig resolves an available agent while honoring runtime ACP config. It treats cfg.ACP.Name as an alias for "acp" and applies cfg.ACP command/mode/model at resolution time instead of package-init time. It also applies command overrides for other agents (codex, claude, cursor, pi).

Optional backup agent names are tried after the preferred agent but before the hardcoded fallback chain (see GetAvailable).

type ClaudeAgent

type ClaudeAgent struct {
	Command   string         // The claude command to run (default: "claude")
	Model     string         // Model to use (e.g., "opus", "sonnet", or full name)
	Reasoning ReasoningLevel // Reasoning level mapped to --effort flag
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
	SessionID string         // Existing session ID to resume
}

ClaudeAgent runs code reviews using Claude Code CLI

func NewClaudeAgent

func NewClaudeAgent(command string) *ClaudeAgent

NewClaudeAgent creates a new Claude Code agent

func (*ClaudeAgent) CommandLine added in v0.28.0

func (a *ClaudeAgent) CommandLine() string

func (*ClaudeAgent) CommandName

func (a *ClaudeAgent) CommandName() string

func (*ClaudeAgent) Name

func (a *ClaudeAgent) Name() string

func (*ClaudeAgent) Review

func (a *ClaudeAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*ClaudeAgent) WithAgentic

func (a *ClaudeAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*ClaudeAgent) WithModel added in v0.17.0

func (a *ClaudeAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*ClaudeAgent) WithReasoning

func (a *ClaudeAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level.

func (*ClaudeAgent) WithSessionID added in v0.45.0

func (a *ClaudeAgent) WithSessionID(sessionID string) Agent

WithSessionID returns a copy of the agent configured to resume a prior session.

type CodexAgent

type CodexAgent struct {
	Command   string         // The codex command to run (default: "codex")
	Model     string         // Model to use (e.g., "o3", "o4-mini")
	Reasoning ReasoningLevel // Reasoning level for the agent
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
	SessionID string         // Existing session/thread ID to resume
}

CodexAgent runs code reviews using the Codex CLI

func NewCodexAgent

func NewCodexAgent(command string) *CodexAgent

NewCodexAgent creates a new Codex agent with standard reasoning

func (*CodexAgent) CommandLine added in v0.28.0

func (a *CodexAgent) CommandLine() string

func (*CodexAgent) CommandName

func (a *CodexAgent) CommandName() string

func (*CodexAgent) Name

func (a *CodexAgent) Name() string

func (*CodexAgent) Review

func (a *CodexAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*CodexAgent) WithAgentic

func (a *CodexAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*CodexAgent) WithModel added in v0.17.0

func (a *CodexAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*CodexAgent) WithReasoning

func (a *CodexAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

func (*CodexAgent) WithSessionID added in v0.45.0

func (a *CodexAgent) WithSessionID(sessionID string) Agent

WithSessionID returns a copy of the agent configured to resume a prior session.

type CommandAgent

type CommandAgent interface {
	Agent
	// CommandName returns the executable command name
	CommandName() string
}

CommandAgent is an agent that uses an external command

type CopilotAgent

type CopilotAgent struct {
	Command   string         // The copilot command to run (default: "copilot")
	Model     string         // Model to use
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (controls --deny-tool flags)
}

CopilotAgent runs code reviews using the GitHub Copilot CLI

func NewCopilotAgent

func NewCopilotAgent(command string) *CopilotAgent

NewCopilotAgent creates a new Copilot agent

func (*CopilotAgent) CommandLine added in v0.28.0

func (a *CopilotAgent) CommandLine() string

func (*CopilotAgent) CommandName

func (a *CopilotAgent) CommandName() string

func (*CopilotAgent) Name

func (a *CopilotAgent) Name() string

func (*CopilotAgent) Review

func (a *CopilotAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*CopilotAgent) WithAgentic

func (a *CopilotAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode. In agentic mode, all tools are allowed without restriction. In review mode (default), destructive tools are denied via --deny-tool flags.

func (*CopilotAgent) WithModel added in v0.17.0

func (a *CopilotAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*CopilotAgent) WithReasoning

func (a *CopilotAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the model preserved (reasoning not yet supported).

type CursorAgent added in v0.21.0

type CursorAgent struct {
	Command   string         // The agent command to run (default: "agent")
	Model     string         // Model to use
	Reasoning ReasoningLevel // Reasoning level
	Agentic   bool           // Whether agentic mode is enabled
}

CursorAgent runs code reviews using the Cursor agent CLI

func NewCursorAgent added in v0.21.0

func NewCursorAgent(command string) *CursorAgent

NewCursorAgent creates a new Cursor agent

func (*CursorAgent) CommandLine added in v0.28.0

func (a *CursorAgent) CommandLine() string

func (*CursorAgent) CommandName added in v0.21.0

func (a *CursorAgent) CommandName() string

func (*CursorAgent) Name added in v0.21.0

func (a *CursorAgent) Name() string

func (*CursorAgent) Review added in v0.21.0

func (a *CursorAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*CursorAgent) WithAgentic added in v0.21.0

func (a *CursorAgent) WithAgentic(agentic bool) Agent

func (*CursorAgent) WithModel added in v0.21.0

func (a *CursorAgent) WithModel(model string) Agent

func (*CursorAgent) WithReasoning added in v0.21.0

func (a *CursorAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy with the reasoning level stored. The agent CLI has no reasoning flag; callers can map reasoning to model selection instead.

type DroidAgent added in v0.15.0

type DroidAgent struct {
	Command   string         // The droid command to run (default: "droid")
	Reasoning ReasoningLevel // Reasoning level for the agent
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

DroidAgent runs code reviews using Factory's Droid CLI

func NewDroidAgent added in v0.15.0

func NewDroidAgent(command string) *DroidAgent

NewDroidAgent creates a new Droid agent with standard reasoning

func (*DroidAgent) CommandLine added in v0.28.0

func (a *DroidAgent) CommandLine() string

func (*DroidAgent) CommandName added in v0.15.0

func (a *DroidAgent) CommandName() string

func (*DroidAgent) Name added in v0.15.0

func (a *DroidAgent) Name() string

func (*DroidAgent) Review added in v0.15.0

func (a *DroidAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*DroidAgent) WithAgentic added in v0.15.0

func (a *DroidAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*DroidAgent) WithModel added in v0.17.0

func (a *DroidAgent) WithModel(model string) Agent

WithModel returns the agent unchanged (model selection not supported for droid).

func (*DroidAgent) WithReasoning added in v0.15.0

func (a *DroidAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

type FakeAgent added in v0.37.0

type FakeAgent struct {
	NameStr  string
	ReviewFn func(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)
}

FakeAgent implements Agent for tests outside the agent package.

func (*FakeAgent) CommandLine added in v0.37.0

func (a *FakeAgent) CommandLine() string

func (*FakeAgent) Name added in v0.37.0

func (a *FakeAgent) Name() string

func (*FakeAgent) Review added in v0.37.0

func (a *FakeAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*FakeAgent) WithAgentic added in v0.37.0

func (a *FakeAgent) WithAgentic(agentic bool) Agent

func (*FakeAgent) WithModel added in v0.37.0

func (a *FakeAgent) WithModel(model string) Agent

func (*FakeAgent) WithReasoning added in v0.37.0

func (a *FakeAgent) WithReasoning(level ReasoningLevel) Agent

type GeminiAgent

type GeminiAgent struct {
	Command   string         // The gemini command to run (default: "gemini")
	Model     string         // Model to use (e.g., "gemini-3.1-pro-preview")
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

GeminiAgent runs code reviews using the Gemini CLI

func NewGeminiAgent

func NewGeminiAgent(command string) *GeminiAgent

NewGeminiAgent creates a new Gemini agent

func (*GeminiAgent) CommandLine added in v0.28.0

func (a *GeminiAgent) CommandLine() string

func (*GeminiAgent) CommandName

func (a *GeminiAgent) CommandName() string

func (*GeminiAgent) Name

func (a *GeminiAgent) Name() string

func (*GeminiAgent) Review

func (a *GeminiAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*GeminiAgent) WithAgentic

func (a *GeminiAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*GeminiAgent) WithModel added in v0.17.0

func (a *GeminiAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*GeminiAgent) WithReasoning

func (a *GeminiAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the model preserved (reasoning not yet supported).

type KiloAgent added in v0.38.0

type KiloAgent struct {
	Command   string         // The kilo command to run (default: "kilo")
	Model     string         // Model to use (provider/model format, e.g., "anthropic/claude-sonnet-4-20250514")
	Reasoning ReasoningLevel // Reasoning level mapped to --variant flag
	Agentic   bool           // Whether agentic mode is enabled (uses --auto)
	SessionID string         // Existing session ID to resume
}

KiloAgent runs code reviews using the Kilo CLI (https://kilo.ai). This implementation is intentionally cloned from OpenCodeAgent rather than sharing a base struct, because kilo may drift from opencode in the future.

func NewKiloAgent added in v0.38.0

func NewKiloAgent(command string) *KiloAgent

NewKiloAgent creates a new Kilo agent

func (*KiloAgent) CommandLine added in v0.38.0

func (a *KiloAgent) CommandLine() string

func (*KiloAgent) CommandName added in v0.38.0

func (a *KiloAgent) CommandName() string

func (*KiloAgent) Name added in v0.38.0

func (a *KiloAgent) Name() string

func (*KiloAgent) Review added in v0.38.0

func (a *KiloAgent) Review(
	ctx context.Context,
	repoPath, commitSHA, prompt string,
	output io.Writer,
) (string, error)

Review runs kilo with --format json and parses the JSONL stream (same envelope as opencode: {"type":"...","part":{"type":"text","text":"..."}}).

func (*KiloAgent) WithAgentic added in v0.38.0

func (a *KiloAgent) WithAgentic(agentic bool) Agent

func (*KiloAgent) WithModel added in v0.38.0

func (a *KiloAgent) WithModel(model string) Agent

func (*KiloAgent) WithReasoning added in v0.38.0

func (a *KiloAgent) WithReasoning(level ReasoningLevel) Agent

func (*KiloAgent) WithSessionID added in v0.45.0

func (a *KiloAgent) WithSessionID(sessionID string) Agent

WithSessionID returns a copy of the agent configured to resume a prior session.

type KiroAgent added in v0.40.0

type KiroAgent struct {
	Command   string         // The kiro-cli command to run (default: "kiro-cli")
	Reasoning ReasoningLevel // Reasoning level (stored; kiro-cli has no reasoning flag)
	Agentic   bool           // Whether agentic mode is enabled (uses --trust-all-tools)
}

KiroAgent runs code reviews using the Kiro CLI (kiro-cli)

func NewKiroAgent added in v0.40.0

func NewKiroAgent(command string) *KiroAgent

NewKiroAgent creates a new Kiro agent with standard reasoning

func (*KiroAgent) CommandLine added in v0.40.0

func (a *KiroAgent) CommandLine() string

func (*KiroAgent) CommandName added in v0.40.0

func (a *KiroAgent) CommandName() string

func (*KiroAgent) Name added in v0.40.0

func (a *KiroAgent) Name() string

func (*KiroAgent) Review added in v0.40.0

func (a *KiroAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*KiroAgent) WithAgentic added in v0.40.0

func (a *KiroAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode. In agentic mode, --trust-all-tools is passed so kiro can use tools without confirmation.

func (*KiroAgent) WithModel added in v0.40.0

func (a *KiroAgent) WithModel(model string) Agent

WithModel returns the agent unchanged; kiro-cli does not expose a --model CLI flag.

func (*KiroAgent) WithReasoning added in v0.40.0

func (a *KiroAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy with the reasoning level stored. kiro-cli has no reasoning flag; callers can map reasoning to agent selection instead.

type OpenCodeAgent

type OpenCodeAgent struct {
	Command   string         // The opencode command to run (default: "opencode")
	Model     string         // Model to use (provider/model format, e.g., "anthropic/claude-sonnet-4-20250514")
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (OpenCode auto-approves in non-interactive mode)
	SessionID string         // Existing session ID to resume
}

OpenCodeAgent runs code reviews using the OpenCode CLI

func NewOpenCodeAgent

func NewOpenCodeAgent(command string) *OpenCodeAgent

NewOpenCodeAgent creates a new OpenCode agent

func (*OpenCodeAgent) CommandLine added in v0.28.0

func (a *OpenCodeAgent) CommandLine() string

func (*OpenCodeAgent) CommandName

func (a *OpenCodeAgent) CommandName() string

func (*OpenCodeAgent) Name

func (a *OpenCodeAgent) Name() string

func (*OpenCodeAgent) Review

func (a *OpenCodeAgent) Review(
	ctx context.Context,
	repoPath, commitSHA, prompt string,
	output io.Writer,
) (string, error)

func (*OpenCodeAgent) WithAgentic

func (a *OpenCodeAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode. Note: OpenCode's `run` command auto-approves all permissions in non-interactive mode, so agentic mode is effectively always enabled when running through roborev.

func (*OpenCodeAgent) WithModel added in v0.17.0

func (a *OpenCodeAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*OpenCodeAgent) WithReasoning

func (a *OpenCodeAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the model preserved (reasoning not yet supported).

func (*OpenCodeAgent) WithSessionID added in v0.45.0

func (a *OpenCodeAgent) WithSessionID(sessionID string) Agent

WithSessionID returns a copy of the agent configured to resume a prior session.

type PiAgent added in v0.42.0

type PiAgent struct {
	Command   string         // The pi command to run (default: "pi")
	Model     string         // Model to use (provider/model format or just model)
	Provider  string         // Explicit provider (optional)
	Reasoning ReasoningLevel // Reasoning level
	Agentic   bool           // Agentic mode
	SessionID string         // Existing session ID to resume
}

PiAgent runs code reviews using the pi CLI

func NewPiAgent added in v0.42.0

func NewPiAgent(command string) *PiAgent

NewPiAgent creates a new pi agent

func (*PiAgent) CommandLine added in v0.42.0

func (a *PiAgent) CommandLine() string

func (*PiAgent) CommandName added in v0.42.0

func (a *PiAgent) CommandName() string

func (*PiAgent) Name added in v0.42.0

func (a *PiAgent) Name() string

func (*PiAgent) Review added in v0.42.0

func (a *PiAgent) Review(
	ctx context.Context,
	repoPath, commitSHA, prompt string,
	output io.Writer,
) (string, error)

func (*PiAgent) WithAgentic added in v0.42.0

func (a *PiAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*PiAgent) WithModel added in v0.42.0

func (a *PiAgent) WithModel(model string) Agent

WithModel returns a copy of the agent configured to use the specified model.

func (*PiAgent) WithProvider added in v0.42.0

func (a *PiAgent) WithProvider(provider string) Agent

WithProvider returns a copy of the agent configured to use the specified provider.

func (*PiAgent) WithReasoning added in v0.42.0

func (a *PiAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent configured with the specified reasoning level.

func (*PiAgent) WithSessionID added in v0.45.0

func (a *PiAgent) WithSessionID(sessionID string) Agent

WithSessionID returns a copy of the agent configured to resume a prior session.

type ReasoningLevel

type ReasoningLevel string

ReasoningLevel controls how much reasoning/thinking an agent uses

const (
	// ReasoningMaximum uses the highest available reasoning (e.g., codex xhigh, claude max)
	ReasoningMaximum ReasoningLevel = "maximum"
	// ReasoningThorough uses deep reasoning for thorough analysis (slower)
	ReasoningThorough ReasoningLevel = "thorough"
	// ReasoningMedium uses moderate reasoning (e.g., claude --effort medium)
	ReasoningMedium ReasoningLevel = "medium"
	// ReasoningStandard uses the model's default reasoning (no effort override)
	ReasoningStandard ReasoningLevel = "standard"
	// ReasoningFast uses minimal reasoning for quick responses
	ReasoningFast ReasoningLevel = "fast"
)

func ParseReasoningLevel

func ParseReasoningLevel(s string) ReasoningLevel

ParseReasoningLevel converts a string to ReasoningLevel, defaulting to standard

type SessionAgent added in v0.45.0

type SessionAgent interface {
	WithSessionID(sessionID string) Agent
}

SessionAgent is implemented by agents that can resume an existing session.

type TestAgent

type TestAgent struct {
	Delay     time.Duration  // Simulated processing delay
	Output    string         // Fixed output to return
	Fail      bool           // If true, returns an error
	Reasoning ReasoningLevel // Reasoning level (for testing)
}

TestAgent is a mock agent for testing that returns predictable output

func NewTestAgent

func NewTestAgent() *TestAgent

NewTestAgent creates a new test agent

func (*TestAgent) CommandLine added in v0.28.0

func (a *TestAgent) CommandLine() string

func (*TestAgent) Name

func (a *TestAgent) Name() string

func (*TestAgent) Review

func (a *TestAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*TestAgent) WithAgentic

func (a *TestAgent) WithAgentic(agentic bool) Agent

WithAgentic returns the agent unchanged (agentic mode not applicable for test agent)

func (*TestAgent) WithModel added in v0.17.0

func (a *TestAgent) WithModel(model string) Agent

WithModel returns the agent unchanged (model selection not supported for test agent).

func (*TestAgent) WithReasoning

func (a *TestAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

type UnknownAgentError added in v0.42.0

type UnknownAgentError struct {
	Name  string
	Known []string
}

UnknownAgentError is returned when a requested agent name is not in the registry and is not a recognized alias.

func (*UnknownAgentError) Error added in v0.42.0

func (e *UnknownAgentError) Error() string

type WorkflowConfig added in v0.50.0

type WorkflowConfig struct {
	RepoPath       string
	GlobalConfig   *config.Config
	Workflow       string
	Reasoning      string
	PreferredAgent string
	BackupAgent    string
}

WorkflowConfig captures the workflow-specific agent resolution context shared by CLI, daemon, and batch review callers.

func ResolveWorkflowConfig added in v0.50.0

func ResolveWorkflowConfig(
	cliAgent, repoPath string,
	globalCfg *config.Config,
	workflow, reasoning string,
) (WorkflowConfig, error)

ResolveWorkflowConfig resolves the preferred and backup agents for a workflow while retaining the workflow and reasoning context needed to resolve the final model after an agent has been selected.

This helper intentionally does not validate repo config. Callers that must fail fast on malformed .roborev.toml should call config.ValidateRepoConfig before invoking it.

func (WorkflowConfig) AgentMatches added in v0.50.0

func (w WorkflowConfig) AgentMatches(left, right string) bool

AgentMatches reports whether two agent names refer to the same logical agent after alias and ACP-name normalization.

func (WorkflowConfig) BackupModel added in v0.50.0

func (w WorkflowConfig) BackupModel() string

BackupModel returns the workflow backup model override, if any.

func (WorkflowConfig) ModelForSelectedAgent added in v0.50.0

func (w WorkflowConfig) ModelForSelectedAgent(
	selectedAgent, cliModel string,
) string

ModelForSelectedAgent resolves the model for the actual selected agent. Backup agents use the workflow backup model when no explicit CLI model was provided; otherwise the workflow/default precedence used by ResolveWorkflowModelForAgent is preserved.

func (WorkflowConfig) UsesBackupAgent added in v0.50.0

func (w WorkflowConfig) UsesBackupAgent(selectedAgent string) bool

UsesBackupAgent reports whether the selected agent is the configured backup rather than the preferred primary for this workflow.

Jump to

Keyboard shortcuts

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