Documentation
¶
Overview ¶
Package agentconfig defines runtime provider and MCP configuration schemas.
It provides validation for user-facing configuration documents and normalization helpers that turn schema objects into runtime-ready settings. Applications typically decode config into Config, call Config.Validate, and then convert it to ResolvedConfig with NormalizeConfig.
Index ¶
- Constants
- func IsACPType(agentType string) bool
- func IsPlannerSupportedType(agentType string) bool
- func IsPoolType(agentType string) bool
- func IsValidAgentType(agentType string) bool
- func IsValidMCPServerType(serverType MCPServerType) bool
- func NormalizeACPConfigs(cfgs map[string]Config, executablePath string) (map[string]ResolvedConfig, error)
- func NormalizeConfigs(cfgs map[string]Config, executablePath string) (map[string]ResolvedConfig, error)
- func SupportedAgentTypes() []string
- func ValidateMCPServerConfig(cfg MCPServerConfig) error
- type ACPConfig
- type Config
- type LocalAPIConfig
- type MCPServerConfig
- type MCPServerType
- type PoolConfig
- type ResolvedConfig
Examples ¶
Constants ¶
const ( // AgentTypeGenericACP is the type for custom ACP CLI executables. AgentTypeGenericACP = "generic_acp" // AgentTypeGeminiACP is the alias for Gemini CLI ACP mode. AgentTypeGeminiACP = "gemini_acp" // AgentTypeCodexACP is the alias for Codex ACP bridge mode. AgentTypeCodexACP = "codex_acp" // AgentTypeOpenCodeACP is the alias for OpenCode CLI ACP mode. AgentTypeOpenCodeACP = "opencode_acp" // AgentTypeCopilotACP is the alias for Copilot CLI ACP mode. AgentTypeCopilotACP = "copilot_acp" // AgentTypeClaudeCodeACP is the alias for Claude Code ACP mode. AgentTypeClaudeCodeACP = "claude_code_acp" // AgentTypeOpenAI is the type for local OpenAI-backed providers. AgentTypeOpenAI = "openai" // AgentTypeAIStudio is the type for local Google AI Studio-backed providers. AgentTypeAIStudio = "aistudio" // AgentTypePool is the pool type with ordered failover. AgentTypePool = "pool" )
Variables ¶
This section is empty.
Functions ¶
func IsPlannerSupportedType ¶
IsPlannerSupportedType reports whether planner mode supports the agent type.
func IsPoolType ¶
IsPoolType reports whether an agent type is a pool.
func IsValidAgentType ¶
IsValidAgentType reports whether the given type is a valid agent type.
func IsValidMCPServerType ¶
func IsValidMCPServerType(serverType MCPServerType) bool
IsValidMCPServerType reports whether the given type is a valid MCP server type.
func NormalizeACPConfigs ¶
func NormalizeACPConfigs(cfgs map[string]Config, executablePath string) (map[string]ResolvedConfig, error)
NormalizeACPConfigs is kept for compatibility and delegates to NormalizeConfigs.
func NormalizeConfigs ¶
func NormalizeConfigs(cfgs map[string]Config, executablePath string) (map[string]ResolvedConfig, error)
NormalizeConfigs canonicalizes agent configs for a map of named config blocks.
func SupportedAgentTypes ¶
func SupportedAgentTypes() []string
SupportedAgentTypes returns all supported agent types.
func ValidateMCPServerConfig ¶
func ValidateMCPServerConfig(cfg MCPServerConfig) error
ValidateMCPServerConfig validates an MCP server configuration.
Types ¶
type ACPConfig ¶
type ACPConfig struct {
// Cmd is the ACP executable argv prefix before any alias-specific defaults.
Cmd []string `json:"cmd,omitempty" yaml:"cmd,omitempty" mapstructure:"cmd" validate:"omitempty,dive,notblank"`
// ExtraArgs appends CLI arguments after the resolved ACP command.
ExtraArgs []string `json:"extra_args,omitempty" yaml:"extra_args,omitempty" mapstructure:"extra_args" validate:"omitempty,dive,notblank"`
// Model selects the runtime model identifier when the backend supports it.
Model string `json:"model,omitempty" yaml:"model,omitempty" mapstructure:"model" validate:"omitempty,notblank"`
// Mode selects the runtime session mode when the backend supports it.
Mode string `json:"mode,omitempty" yaml:"mode,omitempty" mapstructure:"mode" validate:"omitempty,notblank"`
}
ACPConfig is an ACP runtime configuration block used by generic and alias types.
type Config ¶
type Config struct {
// Type selects the runtime backend implementation.
Type string `` /* 244-byte string literal not displayed */
// MCPServers lists MCP server IDs resolved by higher-level registries.
MCPServers []string `` /* 145-byte string literal not displayed */
// SystemInstructions defines provider-level instructions applied by default.
SystemInstructions string `` /* 140-byte string literal not displayed */
// GenericACP configures a custom ACP executable.
GenericACP *ACPConfig `json:"generic_acp,omitempty" yaml:"generic_acp,omitempty" mapstructure:"generic_acp"`
// GeminiACP configures the Gemini ACP alias.
GeminiACP *ACPConfig `json:"gemini_acp,omitempty" yaml:"gemini_acp,omitempty" mapstructure:"gemini_acp"`
// CodexACP configures the Codex ACP alias.
CodexACP *ACPConfig `json:"codex_acp,omitempty" yaml:"codex_acp,omitempty" mapstructure:"codex_acp"`
// OpenCodeACP configures the OpenCode ACP alias.
OpenCodeACP *ACPConfig `json:"opencode_acp,omitempty" yaml:"opencode_acp,omitempty" mapstructure:"opencode_acp"`
// CopilotACP configures the Copilot ACP alias.
CopilotACP *ACPConfig `json:"copilot_acp,omitempty" yaml:"copilot_acp,omitempty" mapstructure:"copilot_acp"`
// ClaudeCodeACP configures the Claude Code ACP alias.
ClaudeCodeACP *ACPConfig `json:"claude_code_acp,omitempty" yaml:"claude_code_acp,omitempty" mapstructure:"claude_code_acp"`
// OpenAI configures a local OpenAI-backed hosted agent.
OpenAI *LocalAPIConfig `json:"openai,omitempty" yaml:"openai,omitempty" mapstructure:"openai"`
// AIStudio configures a local Google AI Studio-backed hosted agent.
AIStudio *LocalAPIConfig `json:"aistudio,omitempty" yaml:"aistudio,omitempty" mapstructure:"aistudio"`
// PoolConfig configures an ordered failover pool.
PoolConfig *PoolConfig `json:"pool,omitempty" yaml:"pool,omitempty" mapstructure:"pool"`
}
Config describes how to run an agent.
The schema is strict and discriminated by type:
type: <agent_type> <agent_type>: ...type-specific config...
func (Config) Description ¶
Description returns a human-readable description of the agent config. Format: "name: type=<type> model=<model> mode=<mode>" with missing parts omitted.
type LocalAPIConfig ¶
type LocalAPIConfig struct {
// APIKey authenticates requests to the hosted provider API.
APIKey string `json:"api_key,omitempty" yaml:"api_key,omitempty" mapstructure:"api_key"`
// Model selects the hosted provider model identifier.
Model string `json:"model,omitempty" yaml:"model,omitempty" mapstructure:"model" validate:"omitempty,notblank"`
}
LocalAPIConfig is a local API-backed runtime configuration block.
type MCPServerConfig ¶
type MCPServerConfig struct {
// Type selects the MCP transport implementation.
Type MCPServerType `` /* 150-byte string literal not displayed */
// Cmd is the stdio server executable path or argv prefix.
Cmd []string `` /* 127-byte string literal not displayed */
// Args appends additional stdio server arguments after Cmd.
Args []string `` /* 127-byte string literal not displayed */
// Env defines environment variables for stdio server execution.
Env map[string]string `json:"env,omitempty" yaml:"env,omitempty" mapstructure:"env"`
// WorkingDir sets the stdio server process working directory.
WorkingDir string `json:"working_dir,omitempty" yaml:"working_dir,omitempty" mapstructure:"working_dir" validate:"omitempty,notblank"`
// URL is the base endpoint for HTTP and SSE MCP transports.
URL string `json:"url,omitempty" yaml:"url,omitempty" mapstructure:"url"`
// Headers provides additional request headers for HTTP and SSE transports.
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty" mapstructure:"headers"`
}
MCPServerConfig describes how to connect to an MCP server.
type MCPServerType ¶
type MCPServerType string
MCPServerType represents the transport type for an MCP server.
const ( // MCPServerTypeStdio is the stdio transport type. MCPServerTypeStdio MCPServerType = "stdio" // MCPServerTypeHTTP is the HTTP transport type. MCPServerTypeHTTP MCPServerType = "http" // MCPServerTypeSSE is the SSE (Server-Sent Events) transport type. MCPServerTypeSSE MCPServerType = "sse" )
func SupportedMCPServerTypes ¶
func SupportedMCPServerTypes() []MCPServerType
SupportedMCPServerTypes returns all supported MCP server types.
type PoolConfig ¶
type PoolConfig struct {
// Members lists provider IDs in ordered failover order.
Members []string `json:"members,omitempty" yaml:"members,omitempty" mapstructure:"members" validate:"omitempty,dive,notblank"`
}
PoolConfig is the pool runtime configuration block.
type ResolvedConfig ¶
type ResolvedConfig struct {
// Type is the normalized runtime backend type.
Type string
// MCPServers are the resolved MCP server IDs referenced by the runtime.
MCPServers []string
// SystemInstructions are the normalized provider-level instructions.
SystemInstructions string
// Command is the runtime command argv for ACP-backed agents.
Command []string
// APIKey is the resolved hosted-provider credential.
APIKey string
// Model is the resolved runtime model identifier.
Model string
// Mode is the resolved runtime mode identifier.
Mode string
// PoolMembers are the resolved provider IDs in pool failover order.
PoolMembers []string
}
ResolvedConfig is a runtime-ready agent configuration produced from Config normalization.
func NormalizeACPConfig ¶
func NormalizeACPConfig(cfg Config, executablePath string) (ResolvedConfig, error)
NormalizeACPConfig is kept for compatibility and delegates to NormalizeConfig.
func NormalizeConfig ¶
func NormalizeConfig(cfg Config, executablePath string) (ResolvedConfig, error)
NormalizeConfig canonicalizes aliases and returns a runtime-ready configuration.
Example ¶
resolved, err := NormalizeConfig(Config{
Type: AgentTypeOpenAI,
OpenAI: &LocalAPIConfig{
APIKey: "test-key",
Model: "gpt-5",
},
}, "")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(resolved.Type)
fmt.Println(resolved.Model)
Output: openai gpt-5
func (ResolvedConfig) Description ¶
func (c ResolvedConfig) Description(name string) string
Description returns a human-readable description of the resolved runtime config.