Documentation
¶
Overview ¶
Package agents implements infrastructure adapters for AI agent integration.
The agents package provides concrete implementations of the AgentProvider and AgentRegistry ports defined in the domain layer, enabling workflow steps to invoke AI agents (Claude, Gemini, Codex, OpenCode, and OpenAI-compatible endpoints) for code generation, analysis, and decision-making tasks. Each provider wraps a CLI executor and handles model-specific invocation patterns, streaming output, and error mapping.
Architecture Role ¶
In the hexagonal architecture:
- Implements domain/ports.AgentProvider (per-provider adapters)
- Implements domain/ports.AgentRegistry (provider registration and lookup)
- Implements domain/ports.CLIExecutor (CLI command execution)
- Application layer orchestrates agent steps via these port interfaces
- Domain layer defines agent contracts without implementation coupling
All agent providers delegate CLI execution to an injected CLIExecutor, allowing test isolation via mock executors. The registry supports runtime provider registration and enables workflow steps to reference agents by name (e.g., "claude", "gemini").
Agent Providers ¶
## ClaudeProvider (claude_provider.go)
Anthropic Claude provider:
- Execute: Single-shot prompt execution via Claude CLI
- ExecuteConversation: Multi-turn conversation with context preservation
- Name: Returns "claude" for registry lookup
- Validate: Checks required options (model, temperature)
Supported models: claude-3-opus, claude-3-sonnet, claude-3-haiku, claude-2.1, claude-2
## GeminiProvider (gemini_provider.go)
Google Gemini provider:
- Execute: Single-shot prompt execution via Gemini CLI
- ExecuteConversation: Multi-turn conversation support
- Name: Returns "gemini"
- Validate: Checks model and API key configuration
## CodexProvider (codex_provider.go)
OpenAI Codex provider (code-focused GPT models):
- Execute: Single-shot code generation via OpenAI CLI
- ExecuteConversation: Not supported (returns error)
- Name: Returns "codex"
- Validate: Checks API key and model configuration
## OpenCodeProvider (opencode_provider.go)
Open-source code generation models (StarCoder, CodeLlama, etc.):
- Execute: Single-shot execution via custom CLI wrapper
- ExecuteConversation: Limited support (model-dependent)
- Name: Returns "opencode"
- Validate: Checks CLI tool availability
## OpenAICompatibleProvider (openai_compatible_provider.go)
HTTP adapter for any OpenAI-compatible API endpoint (Ollama, LM Studio, vLLM, etc.):
- Execute: Single-shot prompt via Chat Completions API
- ExecuteConversation: Multi-turn conversation with history
- Name: Returns "openai_compatible" for registry lookup
- Validate: Checks base_url and model configuration
Configuration via agent options: base_url, api_key, model, temperature. Falls back to OPENAI_BASE_URL / OPENAI_MODEL / OPENAI_API_KEY env vars.
Registry and Discovery ¶
## AgentRegistry (registry.go)
Provider registration and lookup:
- Register: Add provider by name (thread-safe)
- Get: Retrieve provider by name
- List: Enumerate registered provider names
- Has: Check if provider exists
- RegisterDefaults: Pre-populate with built-in providers
CLI Execution ¶
## ExecCLIExecutor (cli_executor.go)
External binary execution:
- Run: Execute command with streaming stdout/stderr, context cancellation
- Process cleanup: Kills descendant processes on cancellation
- Signal propagation: Forwards SIGINT/SIGTERM to child processes
Used by all agent providers to invoke CLI tools (claude, gemini, gpt, etc.).
Provider Options ¶
## Functional Options Pattern (options.go)
Provider configuration via option functions:
- WithClaudeExecutor: Inject custom executor for Claude provider
- WithGeminiExecutor: Inject custom executor for Gemini provider
- WithCodexExecutor: Inject custom executor for Codex provider
- WithOpenCodeExecutor: Inject custom executor for OpenCode provider
- WithHTTPClient: Inject custom HTTP client for OpenAICompatible provider
Each provider accepts zero or more options at construction time for dependency injection.
Index ¶
- Constants
- func ClaudeToContentBlocks(line []byte) []transcript.ContentBlock
- func CodexToContentBlocks(line []byte) []transcript.ContentBlock
- func CopilotToContentBlocks(line []byte) []transcript.ContentBlock
- func GeminiToContentBlocks(line []byte) []transcript.ContentBlock
- func OpenAICompatibleToContentBlocks(line []byte) []transcript.ContentBlock
- func PurgeOrphanMCPRegistrations(ctx context.Context, exec ports.CommandExecutor, logger ports.Logger) error
- type AgentRegistry
- func (r *AgentRegistry) Get(name string) (ports.AgentProvider, error)
- func (r *AgentRegistry) Has(name string) bool
- func (r *AgentRegistry) List() []string
- func (r *AgentRegistry) Register(provider ports.AgentProvider) error
- func (r *AgentRegistry) RegisterDefaults(cmdExec ports.CommandExecutor) error
- type ClaudeProvider
- func (p *ClaudeProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *ClaudeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *ClaudeProvider) Name() string
- func (p *ClaudeProvider) Validate() error
- type ClaudeProviderOption
- type CodexProvider
- func (p *CodexProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *CodexProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *CodexProvider) Name() string
- func (p *CodexProvider) Validate() error
- type CodexProviderOption
- type ContentBlockNormalizer
- type CopilotProvider
- func (p *CopilotProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *CopilotProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *CopilotProvider) Name() string
- func (p *CopilotProvider) Validate() error
- type CopilotProviderOption
- type DisplayEvent
- type DisplayEventParser
- type DisplayEventRenderer
- type DisplayMode
- type EventKind
- type ExecCLIExecutor
- func (e *ExecCLIExecutor) Run(ctx context.Context, name string, stdoutW, stderrW io.Writer, args ...string) (stdout, stderr []byte, err error)
- func (e *ExecCLIExecutor) RunWithEnv(ctx context.Context, name string, env map[string]string, ...) (stdout, stderr []byte, err error)
- func (e *ExecCLIExecutor) Start(ctx context.Context, name string, args ...string) (ports.CLIProcess, error)
- type GeminiProvider
- func (p *GeminiProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *GeminiProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *GeminiProvider) Name() string
- func (p *GeminiProvider) Validate() error
- type GeminiProviderOption
- func WithGeminiCommandExecutor(executor ports.CommandExecutor) GeminiProviderOption
- func WithGeminiDenyAllPolicy(policyPath string) GeminiProviderOption
- func WithGeminiExecutor(executor ports.CLIExecutor) GeminiProviderOption
- func WithGeminiLogger(l ports.Logger) GeminiProviderOption
- func WithGeminiTokenizer(tok ports.Tokenizer) GeminiProviderOption
- type MistralVibeProvider
- func (p *MistralVibeProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *MistralVibeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *MistralVibeProvider) Name() string
- func (p *MistralVibeProvider) Validate() error
- type MistralVibeProviderOption
- type MockCall
- type MockProvider
- func (m *MockProvider) CallCount() int
- func (m *MockProvider) Calls() []MockCall
- func (m *MockProvider) ConversationCallCount() int
- func (m *MockProvider) Execute(ctx context.Context, prompt string, options map[string]any, _, _ io.Writer) (*workflow.AgentResult, error)
- func (m *MockProvider) ExecuteCallCount() int
- func (m *MockProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (m *MockProvider) Name() string
- func (m *MockProvider) Reset()
- func (m *MockProvider) Validate() error
- func (m *MockProvider) WithConversationResponse(pattern string, result *workflow.ConversationResult) *MockProvider
- func (m *MockProvider) WithDefaultConversationResponse(result *workflow.ConversationResult) *MockProvider
- func (m *MockProvider) WithDefaultResponse(result *workflow.AgentResult) *MockProvider
- func (m *MockProvider) WithDelay(d time.Duration) *MockProvider
- func (m *MockProvider) WithResponse(pattern string, result *workflow.AgentResult) *MockProvider
- func (m *MockProvider) WithValidateError(err error) *MockProvider
- type OpenAICompatibleProvider
- func (p *OpenAICompatibleProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *OpenAICompatibleProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *OpenAICompatibleProvider) Name() string
- func (p *OpenAICompatibleProvider) SetToolRouter(r ports.ToolRouter)
- func (p *OpenAICompatibleProvider) Validate() error
- type OpenAICompatibleProviderOption
- type OpenCodeProvider
- func (p *OpenCodeProvider) Execute(ctx context.Context, prompt string, options map[string]any, ...) (*workflow.AgentResult, error)
- func (p *OpenCodeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, ...) (*workflow.ConversationResult, error)
- func (p *OpenCodeProvider) Name() string
- func (p *OpenCodeProvider) Validate() error
- type OpenCodeProviderOption
- type StreamFilterWriter
- type ToolCall
- type ToolCallDelta
- type ToolDefinition
Constants ¶
const ( EventText = display.EventText EventToolUse = display.EventToolUse )
const ( DisplayModeDefault = display.DisplayModeDefault DisplayModeVerbose = display.DisplayModeVerbose )
Variables ¶
This section is empty.
Functions ¶
func ClaudeToContentBlocks ¶ added in v0.11.2
func ClaudeToContentBlocks(line []byte) []transcript.ContentBlock
func CodexToContentBlocks ¶ added in v0.11.2
func CodexToContentBlocks(line []byte) []transcript.ContentBlock
CodexToContentBlocks maps a single Codex NDJSON line to transcript ContentBlocks. Raw NUL bytes (0x00) are escaped to the six-byte JSON unicode sequence before unmarshal, matching the behavior in codex_provider.go:343.
func CopilotToContentBlocks ¶ added in v0.11.2
func CopilotToContentBlocks(line []byte) []transcript.ContentBlock
CopilotToContentBlocks maps a single Copilot NDJSON line to transcript ContentBlocks. Mirrors the event-typed shape consumed by parseCopilotDisplayEvents in copilot_provider.go.
func GeminiToContentBlocks ¶ added in v0.11.2
func GeminiToContentBlocks(line []byte) []transcript.ContentBlock
func OpenAICompatibleToContentBlocks ¶ added in v0.11.2
func OpenAICompatibleToContentBlocks(line []byte) []transcript.ContentBlock
OpenAICompatibleToContentBlocks maps a single OpenAI-compatible NDJSON line to transcript ContentBlocks. Mirrors the delta/message shape consumed by translateOpenAICompatibleDisplayEvents in openai_compatible_provider.go.
func PurgeOrphanMCPRegistrations ¶ added in v0.11.2
func PurgeOrphanMCPRegistrations(ctx context.Context, exec ports.CommandExecutor, logger ports.Logger) error
PurgeOrphanMCPRegistrations removes any persistent MCP server registration whose name starts with mcpProxyNamePrefix from Gemini and OpenCode CLIs.
Both CLIs are queried via `<cli> mcp list`; matching entries are removed via `<cli> mcp remove <name>`. Each failure mode is classified and logged distinctly (see purgeForCLI) and none block startup — the function always returns nil because purge is best-effort.
Environment variables:
- AWF_MCP_PROXY_NO_PURGE: when set to any non-empty value, returns immediately without executing any commands (for users who intentionally keep awf-proxy- prefixed registrations).
- AWF_MCP_PROXY_LIST_TIMEOUT: overrides the per-CLI `mcp list` timeout (Go duration, e.g. "10s"). Defaults to mcpListDefaultTimeout.
Types ¶
type AgentRegistry ¶
type AgentRegistry struct {
// contains filtered or unexported fields
}
AgentRegistry manages registered agent providers.
func NewAgentRegistry ¶
func NewAgentRegistry() *AgentRegistry
func (*AgentRegistry) Get ¶
func (r *AgentRegistry) Get(name string) (ports.AgentProvider, error)
func (*AgentRegistry) Has ¶
func (r *AgentRegistry) Has(name string) bool
func (*AgentRegistry) List ¶
func (r *AgentRegistry) List() []string
func (*AgentRegistry) Register ¶
func (r *AgentRegistry) Register(provider ports.AgentProvider) error
func (*AgentRegistry) RegisterDefaults ¶
func (r *AgentRegistry) RegisterDefaults(cmdExec ports.CommandExecutor) error
RegisterDefaults registers all default providers. It continues registering even if individual providers fail, collecting all errors and returning them aggregated.
Pass nil for cmdExec to disable MCP proxy support for providers that require a CommandExecutor (Gemini); attempting to use mcp_proxy with such a provider will fail at step startup with a clear error rather than a nil-pointer panic. OpenCode MCP proxy uses workspace file config and does not require a CommandExecutor.
type ClaudeProvider ¶
type ClaudeProvider struct {
// contains filtered or unexported fields
}
ClaudeProvider implements AgentProvider for Claude CLI. Invokes: claude -p "prompt" --output-format stream-json
func NewClaudeProvider ¶
func NewClaudeProvider(l ...ports.Logger) *ClaudeProvider
func NewClaudeProviderWithOptions ¶
func NewClaudeProviderWithOptions(opts ...ClaudeProviderOption) *ClaudeProvider
func (*ClaudeProvider) ExecuteConversation ¶
func (p *ClaudeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
ExecuteConversation invokes the Claude CLI with conversation history for multi-turn interactions.
func (*ClaudeProvider) Name ¶
func (p *ClaudeProvider) Name() string
func (*ClaudeProvider) Validate ¶
func (p *ClaudeProvider) Validate() error
type ClaudeProviderOption ¶
type ClaudeProviderOption func(*ClaudeProvider)
func WithClaudeExecutor ¶
func WithClaudeExecutor(executor ports.CLIExecutor) ClaudeProviderOption
func WithClaudeLogger ¶ added in v0.11.2
func WithClaudeLogger(l ports.Logger) ClaudeProviderOption
func WithClaudeTokenizer ¶ added in v0.11.2
func WithClaudeTokenizer(tok ports.Tokenizer) ClaudeProviderOption
type CodexProvider ¶
type CodexProvider struct {
// contains filtered or unexported fields
}
CodexProvider implements AgentProvider for Codex CLI. Invokes: codex exec --json "prompt"
func NewCodexProvider ¶
func NewCodexProvider() *CodexProvider
func NewCodexProviderWithOptions ¶
func NewCodexProviderWithOptions(opts ...CodexProviderOption) *CodexProvider
func (*CodexProvider) ExecuteConversation ¶
func (p *CodexProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
func (*CodexProvider) Name ¶
func (p *CodexProvider) Name() string
func (*CodexProvider) Validate ¶
func (p *CodexProvider) Validate() error
type CodexProviderOption ¶
type CodexProviderOption func(*CodexProvider)
func WithCodexExecutor ¶
func WithCodexExecutor(executor ports.CLIExecutor) CodexProviderOption
func WithCodexLogger ¶
func WithCodexLogger(l ports.Logger) CodexProviderOption
func WithCodexTokenizer ¶ added in v0.11.2
func WithCodexTokenizer(tok ports.Tokenizer) CodexProviderOption
type ContentBlockNormalizer ¶ added in v0.11.2
type ContentBlockNormalizer struct{}
ContentBlockNormalizer is the infrastructure implementation of ports.AgentOutputNormalizer. It dispatches a provider's raw CLI output to the matching per-provider line normalizer (the *ToContentBlocks functions), absorbing provider divergence in this single layer (F106 SC-002).
func NewContentBlockNormalizer ¶ added in v0.11.2
func NewContentBlockNormalizer() ContentBlockNormalizer
NewContentBlockNormalizer returns a ready-to-use normalizer. It is stateless, so the zero value works too; the constructor exists for wiring symmetry.
func (ContentBlockNormalizer) Normalize ¶ added in v0.11.2
func (ContentBlockNormalizer) Normalize(provider string, rawOutput []byte) []transcript.ContentBlock
Normalize scans the provider's raw NDJSON output line-by-line and concatenates the blocks produced for each line. It returns nil for an unknown provider, empty output, or output that yields no blocks. It never panics on malformed input — each line normalizer tolerates unparseable lines by returning no blocks.
type CopilotProvider ¶ added in v0.11.2
type CopilotProvider struct {
// contains filtered or unexported fields
}
CopilotProvider implements AgentProvider for GitHub Copilot CLI. Invokes: copilot -p "prompt" --output-format=json --silent
func NewCopilotProvider ¶ added in v0.11.2
func NewCopilotProvider() *CopilotProvider
func NewCopilotProviderWithOptions ¶ added in v0.11.2
func NewCopilotProviderWithOptions(opts ...CopilotProviderOption) *CopilotProvider
func (*CopilotProvider) ExecuteConversation ¶ added in v0.11.2
func (p *CopilotProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
func (*CopilotProvider) Name ¶ added in v0.11.2
func (p *CopilotProvider) Name() string
func (*CopilotProvider) Validate ¶ added in v0.11.2
func (p *CopilotProvider) Validate() error
type CopilotProviderOption ¶ added in v0.11.2
type CopilotProviderOption func(*CopilotProvider)
func WithCopilotExecutor ¶ added in v0.11.2
func WithCopilotExecutor(executor ports.CLIExecutor) CopilotProviderOption
func WithCopilotLogger ¶ added in v0.11.2
func WithCopilotLogger(l ports.Logger) CopilotProviderOption
func WithCopilotTokenizer ¶ added in v0.11.2
func WithCopilotTokenizer(tok ports.Tokenizer) CopilotProviderOption
type DisplayEvent ¶ added in v0.11.2
type DisplayEvent = display.DisplayEvent
Type aliases re-export display types for internal use within the agents package. External consumers should import pkg/display directly.
type DisplayEventParser ¶ added in v0.11.2
type DisplayEventParser = display.DisplayEventParser
Type aliases re-export display types for internal use within the agents package. External consumers should import pkg/display directly.
type DisplayEventRenderer ¶ added in v0.11.2
type DisplayEventRenderer func(events []DisplayEvent)
DisplayEventRenderer receives parsed DisplayEvents for rendering to output.
type DisplayMode ¶ added in v0.11.2
type DisplayMode = display.DisplayMode
Type aliases re-export display types for internal use within the agents package. External consumers should import pkg/display directly.
type EventKind ¶ added in v0.11.2
Type aliases re-export display types for internal use within the agents package. External consumers should import pkg/display directly.
type ExecCLIExecutor ¶
type ExecCLIExecutor struct{}
ExecCLIExecutor implements CLIExecutor using os/exec for direct binary execution. Unlike shell execution via detected shell ($SHELL), this executes binaries directly without shell interpretation, making it suitable for invoking external CLI tools like claude, gemini, codex, etc.
func NewExecCLIExecutor ¶
func NewExecCLIExecutor() *ExecCLIExecutor
func (*ExecCLIExecutor) RunWithEnv ¶ added in v0.11.2
func (*ExecCLIExecutor) Start ¶ added in v0.11.2
func (e *ExecCLIExecutor) Start(ctx context.Context, name string, args ...string) (ports.CLIProcess, error)
Start launches a binary without blocking. A background goroutine drives cmd.Wait so that Done() is closed when the process exits.
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider implements AgentProvider for Gemini CLI. Invokes: gemini -p "prompt"
func NewGeminiProvider ¶
func NewGeminiProvider() *GeminiProvider
func NewGeminiProviderWithOptions ¶
func NewGeminiProviderWithOptions(opts ...GeminiProviderOption) *GeminiProvider
func (*GeminiProvider) ExecuteConversation ¶
func (p *GeminiProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
func (*GeminiProvider) Validate ¶
func (p *GeminiProvider) Validate() error
type GeminiProviderOption ¶
type GeminiProviderOption func(*GeminiProvider)
func WithGeminiCommandExecutor ¶ added in v0.11.2
func WithGeminiCommandExecutor(executor ports.CommandExecutor) GeminiProviderOption
func WithGeminiDenyAllPolicy ¶ added in v0.11.2
func WithGeminiDenyAllPolicy(policyPath string) GeminiProviderOption
func WithGeminiExecutor ¶
func WithGeminiExecutor(executor ports.CLIExecutor) GeminiProviderOption
func WithGeminiLogger ¶ added in v0.11.2
func WithGeminiLogger(l ports.Logger) GeminiProviderOption
func WithGeminiTokenizer ¶ added in v0.11.2
func WithGeminiTokenizer(tok ports.Tokenizer) GeminiProviderOption
type MistralVibeProvider ¶ added in v0.11.2
type MistralVibeProvider struct {
// contains filtered or unexported fields
}
func NewMistralVibeProvider ¶ added in v0.11.2
func NewMistralVibeProvider() *MistralVibeProvider
func NewMistralVibeProviderWithOptions ¶ added in v0.11.2
func NewMistralVibeProviderWithOptions(opts ...MistralVibeProviderOption) *MistralVibeProvider
func (*MistralVibeProvider) ExecuteConversation ¶ added in v0.11.2
func (p *MistralVibeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
func (*MistralVibeProvider) Name ¶ added in v0.11.2
func (p *MistralVibeProvider) Name() string
func (*MistralVibeProvider) Validate ¶ added in v0.11.2
func (p *MistralVibeProvider) Validate() error
type MistralVibeProviderOption ¶ added in v0.11.2
type MistralVibeProviderOption func(*MistralVibeProvider)
func WithMistralVibeExecutor ¶ added in v0.11.2
func WithMistralVibeExecutor(executor ports.CLIExecutor) MistralVibeProviderOption
func WithMistralVibeLogger ¶ added in v0.11.2
func WithMistralVibeLogger(l ports.Logger) MistralVibeProviderOption
func WithMistralVibeTokenizer ¶ added in v0.11.2
func WithMistralVibeTokenizer(tok ports.Tokenizer) MistralVibeProviderOption
type MockCall ¶
type MockCall struct {
Method string
Prompt string
Options map[string]any
State *workflow.ConversationState
}
MockCall records a call made to the mock provider.
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider provides deterministic responses for testing without external CLI calls. It implements ports.AgentProvider interface.
func NewMockProvider ¶
func NewMockProvider(name string) *MockProvider
NewMockProvider creates a new mock provider with the given name.
func (*MockProvider) CallCount ¶
func (m *MockProvider) CallCount() int
CallCount returns the number of calls made.
func (*MockProvider) Calls ¶
func (m *MockProvider) Calls() []MockCall
Calls returns all recorded calls.
func (*MockProvider) ConversationCallCount ¶
func (m *MockProvider) ConversationCallCount() int
ConversationCallCount returns the number of ExecuteConversation calls.
func (*MockProvider) Execute ¶
func (m *MockProvider) Execute(ctx context.Context, prompt string, options map[string]any, _, _ io.Writer) (*workflow.AgentResult, error)
Execute implements ports.AgentProvider.
func (*MockProvider) ExecuteCallCount ¶
func (m *MockProvider) ExecuteCallCount() int
ExecuteCallCount returns the number of Execute calls.
func (*MockProvider) ExecuteConversation ¶
func (m *MockProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, _, _ io.Writer) (*workflow.ConversationResult, error)
ExecuteConversation implements ports.AgentProvider.
func (*MockProvider) Name ¶
func (m *MockProvider) Name() string
Name implements ports.AgentProvider.
func (*MockProvider) Validate ¶
func (m *MockProvider) Validate() error
Validate implements ports.AgentProvider.
func (*MockProvider) WithConversationResponse ¶
func (m *MockProvider) WithConversationResponse(pattern string, result *workflow.ConversationResult) *MockProvider
WithConversationResponse configures a conversation response for prompts containing the pattern.
func (*MockProvider) WithDefaultConversationResponse ¶
func (m *MockProvider) WithDefaultConversationResponse(result *workflow.ConversationResult) *MockProvider
WithDefaultConversationResponse sets the default conversation response.
func (*MockProvider) WithDefaultResponse ¶
func (m *MockProvider) WithDefaultResponse(result *workflow.AgentResult) *MockProvider
WithDefaultResponse sets the default response when no pattern matches.
func (*MockProvider) WithDelay ¶
func (m *MockProvider) WithDelay(d time.Duration) *MockProvider
WithDelay sets the simulated processing delay.
func (*MockProvider) WithResponse ¶
func (m *MockProvider) WithResponse(pattern string, result *workflow.AgentResult) *MockProvider
WithResponse configures a response for prompts containing the given pattern.
func (*MockProvider) WithValidateError ¶
func (m *MockProvider) WithValidateError(err error) *MockProvider
WithValidateError configures the provider to return an error on Validate().
type OpenAICompatibleProvider ¶
type OpenAICompatibleProvider struct {
// contains filtered or unexported fields
}
OpenAICompatibleProvider implements AgentProvider via the Chat Completions HTTP API. Compatible with OpenAI, Ollama, vLLM, Groq, and any OpenAI-compatible backend.
MCP proxy integration — divergence from CLI providers:
The CLI providers (Claude, Codex, Gemini, Opencode) wire MCP through a `mcpInjector` hook on baseCLIProvider, which appends provider-specific flags to the subprocess invocation (e.g. `--mcp-config <path>`). That path does not apply here: this provider speaks the Chat Completions HTTP API directly and has no child process to inject flags into.
Instead, MCP integration is HTTP-native and lives entirely in this file:
- SetToolRouter installs an application/tools.Router implementation;
- buildToolList reads the MCPProxyConfig from options and advertises tools (respecting cfg.InterceptBuiltins) in the `tools` request field;
- dispatchToolCall routes the model's tool_calls back through the Router and feeds tool results into the next turn.
This is the documented HTTP-native MCP path; the absence of an mcpInjector here is intentional, not a missing implementation.
func NewOpenAICompatibleProvider ¶
func NewOpenAICompatibleProvider(opts ...OpenAICompatibleProviderOption) *OpenAICompatibleProvider
func (*OpenAICompatibleProvider) ExecuteConversation ¶
func (p *OpenAICompatibleProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, _ io.Writer) (*workflow.ConversationResult, error)
func (*OpenAICompatibleProvider) Name ¶
func (p *OpenAICompatibleProvider) Name() string
func (*OpenAICompatibleProvider) SetToolRouter ¶ added in v0.11.2
func (p *OpenAICompatibleProvider) SetToolRouter(r ports.ToolRouter)
func (*OpenAICompatibleProvider) Validate ¶
func (p *OpenAICompatibleProvider) Validate() error
type OpenAICompatibleProviderOption ¶
type OpenAICompatibleProviderOption func(*OpenAICompatibleProvider)
func WithHTTPClient ¶
func WithHTTPClient(client *httpx.Client) OpenAICompatibleProviderOption
type OpenCodeProvider ¶
type OpenCodeProvider struct {
// contains filtered or unexported fields
}
OpenCodeProvider implements AgentProvider for OpenCode CLI. Invokes: opencode run "prompt"
func NewOpenCodeProvider ¶
func NewOpenCodeProvider() *OpenCodeProvider
func NewOpenCodeProviderWithOptions ¶
func NewOpenCodeProviderWithOptions(opts ...OpenCodeProviderOption) *OpenCodeProvider
func (*OpenCodeProvider) Execute ¶
func (p *OpenCodeProvider) Execute(ctx context.Context, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.AgentResult, error)
Execute invokes the OpenCode CLI with the given prompt and options.
func (*OpenCodeProvider) ExecuteConversation ¶
func (p *OpenCodeProvider) ExecuteConversation(ctx context.Context, state *workflow.ConversationState, prompt string, options map[string]any, stdout, stderr io.Writer) (*workflow.ConversationResult, error)
ExecuteConversation invokes the OpenCode CLI with conversation history for multi-turn interactions.
func (*OpenCodeProvider) Name ¶
func (p *OpenCodeProvider) Name() string
Name returns the provider identifier.
func (*OpenCodeProvider) Validate ¶
func (p *OpenCodeProvider) Validate() error
Validate checks if the OpenCode CLI is installed and accessible.
type OpenCodeProviderOption ¶
type OpenCodeProviderOption func(*OpenCodeProvider)
func WithOpenCodeExecutor ¶
func WithOpenCodeExecutor(executor ports.CLIExecutor) OpenCodeProviderOption
func WithOpenCodeLogger ¶ added in v0.11.2
func WithOpenCodeLogger(l ports.Logger) OpenCodeProviderOption
func WithOpenCodeTokenizer ¶ added in v0.11.2
func WithOpenCodeTokenizer(tok ports.Tokenizer) OpenCodeProviderOption
type StreamFilterWriter ¶ added in v0.11.2
type StreamFilterWriter struct {
// contains filtered or unexported fields
}
StreamFilterWriter buffers NDJSON lines and filters them. Lines exceeding 10 MB are dumped raw to prevent unbounded memory growth.
func NewStreamFilterWriter ¶ added in v0.11.2
func NewStreamFilterWriter(inner io.Writer, extract func(line []byte) string, logger ...ports.Logger) *StreamFilterWriter
NewStreamFilterWriter decorates inner with line filtering. If extract is nil, data passes through unfiltered.
func NewStreamFilterWriterWithParser ¶ added in v0.11.2
func NewStreamFilterWriterWithParser(inner io.Writer, parser DisplayEventParser, renderer DisplayEventRenderer, logger ...ports.Logger) *StreamFilterWriter
NewStreamFilterWriterWithParser decorates inner with event-aware filtering. Parsed events are forwarded to renderer; if renderer is nil events are discarded.
func (*StreamFilterWriter) Flush ¶ added in v0.11.2
func (w *StreamFilterWriter) Flush() error
Flush emits any buffered partial line.
type ToolCall ¶ added in v0.11.2
ToolCall is a fully assembled tool call derived from one or more SSE deltas.
type ToolCallDelta ¶ added in v0.11.2
type ToolCallDelta struct {
Index int `json:"index"`
ID string `json:"id"`
Type string `json:"type"`
Function struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
} `json:"function"`
}
ToolCallDelta is one SSE chunk contributing to a streamed tool call. Multiple deltas with the same index form a single tool call; their function.arguments fields must be concatenated in order before parsing.
type ToolDefinition ¶ added in v0.11.2
type ToolDefinition struct {
Type string `json:"type"`
Function toolFunctionSchema `json:"function"`
}
ToolDefinition is the JSON representation of a tool for the Chat Completions API.
Source Files
¶
- base_cli_provider.go
- claude_provider.go
- claude_to_content_blocks.go
- cli_executor.go
- codex_provider.go
- codex_to_content_blocks.go
- content_block_normalizer.go
- copilot_provider.go
- copilot_to_content_blocks.go
- display_event.go
- doc.go
- gemini_provider.go
- gemini_to_content_blocks.go
- helpers.go
- mcp_proxy_name.go
- mcp_proxy_purge.go
- mistral_vibe_provider.go
- mock_provider.go
- openai_compatible_provider.go
- openai_compatible_to_content_blocks.go
- openai_compatible_tools.go
- opencode_provider.go
- opencode_workspace_config.go
- options.go
- registry.go
- stream_filter.go