Documentation
¶
Overview ¶
Package config implements RoleMux's layered, non-secret TOML configuration. Credentials remain in provider stores or are reacquired from validated environment-variable references; they are never serialized.
Index ¶
- Constants
- Variables
- func CanonicalRole(role string) (string, error)
- func ConfigPaths(repoRoot string, environ []string) (global, project string)
- func ConfigureProfile(name, role string, profile Profile, beforeHash string) error
- func ConfigureProfilesAtomic(name string, profilesToSet map[string]Profile, beforeHash string) error
- func FileHash(name string) (string, error)
- func ImportConfigAtomic(name string, data []byte, beforeHash string) error
- func ProfileRoles() []string
- func ReadAll(r io.Reader) ([]byte, error)
- func SnapshotEnvironment(refs []string, environ []string) (map[string]string, error)
- func Validate(c Config) error
- func ValidateAuthCommand(auth AuthCommand) error
- func ValidateCustomModel(provider, name string, m CustomModel) error
- func ValidateEnvRef(name string) error
- func ValidateEnvRefOptional(value string) error
- func ValidateProfile(p Profile) error
- func ValidateProvider(name string, p Provider) error
- func WriteConfigAtomic(name string, cfg Config, beforeHash string) error
- func WriteRawAtomic(name string, raw map[string]any, beforeHash string) error
- type AuthCommand
- type Config
- type CustomModel
- type Profile
- type Provider
Constants ¶
const ( RolePlanner = "planner" RoleImplementer = "implementer" RoleReviewer = "reviewer" RolePlanReviewer = "plan_reviewer" RoleCodeReviewer = "code_reviewer" )
Variables ¶
var ( ErrUnknownRole = errors.New("unknown role") ErrConfigConflict = errors.New("configuration changed while it was being edited") ErrUnsafeConfig = errors.New("unsafe configuration") ErrUnknownProvider = errors.New("unknown provider") ErrMissingModel = errors.New("profile has no model") )
Functions ¶
func CanonicalRole ¶
func ConfigPaths ¶
func ConfigureProfile ¶
ConfigureProfile applies one named profile while preserving unrelated raw TOML tables. beforeHash must be the hash observed before the caller read the file. The compare is performed immediately before the atomic rename.
func ConfigureProfilesAtomic ¶
func ConfigureProfilesAtomic(name string, profilesToSet map[string]Profile, beforeHash string) error
ConfigureProfilesAtomic updates a set of profiles in one compare-and-swap write while preserving all unrelated TOML keys.
func FileHash ¶
FileHash returns the hash used for read/check/write conflict detection. Missing files have an empty hash; existence alone is not a conflict.
func ImportConfigAtomic ¶
ImportConfigAtomic imports only RoleMux-owned tables from a TOML fragment. Unrelated destination keys are preserved, while unknown keys nested inside RoleMux-owned tables are discarded by re-encoding the validated typed form.
func ProfileRoles ¶
func ProfileRoles() []string
func SnapshotEnvironment ¶
SnapshotEnvironment returns only values for validated references. It is intentionally generic so runner packages can use it without persisting the returned values.
func ValidateAuthCommand ¶
func ValidateAuthCommand(auth AuthCommand) error
func ValidateCustomModel ¶
func ValidateCustomModel(provider, name string, m CustomModel) error
func ValidateEnvRef ¶
func ValidateEnvRefOptional ¶
func ValidateProfile ¶
func ValidateProvider ¶
func WriteConfigAtomic ¶
WriteConfigAtomic serializes known config deterministically. Raw keys are preserved if present and the compare-and-swap happens before rename.
Types ¶
type AuthCommand ¶
type AuthCommand struct {
Command string `toml:"command,omitempty" json:"command,omitempty"`
Args []string `toml:"args,omitempty" json:"args,omitempty"`
TimeoutMS int `toml:"timeout_ms,omitempty" json:"timeout_ms,omitempty"`
RefreshIntervalMS int `toml:"refresh_interval_ms,omitempty" json:"refresh_interval_ms,omitempty"`
}
type Config ¶
type Config struct {
Profiles map[string]Profile `toml:"profiles" json:"profiles"`
Providers map[string]Provider `toml:"providers" json:"providers"`
Models map[string]map[string]CustomModel `toml:"models" json:"models"`
CatalogTTLSeconds int `toml:"catalog_ttl_seconds,omitempty" json:"catalog_ttl_seconds,omitempty"`
ProviderTurnTimeoutSeconds int `toml:"provider_turn_timeout_seconds,omitempty" json:"provider_turn_timeout_seconds,omitempty"`
Raw map[string]any `toml:"-" json:"-"`
}
Config is the merged representation. Raw preserves unknown, unrelated TOML keys during an atomic profile update; it is never sent to a provider.
func (Config) EffectiveProfiles ¶
EffectiveProfiles expands the shared reviewer profile into the two review roles, returning independent values suitable for task snapshots.
type CustomModel ¶
type CustomModel struct {
ID string `toml:"id" json:"id"`
Label string `toml:"label,omitempty" json:"label,omitempty"`
Aliases []string `toml:"aliases,omitempty" json:"aliases,omitempty"`
Efforts []string `toml:"efforts,omitempty" json:"efforts,omitempty"`
DefaultEffort string `toml:"default_effort,omitempty" json:"default_effort,omitempty"`
Availability string `toml:"availability" json:"availability"`
// Codex custom routing fields.
Name string `toml:"name,omitempty" json:"name,omitempty"`
BaseURL string `toml:"base_url,omitempty" json:"base_url,omitempty"`
WireAPI string `toml:"wire_api,omitempty" json:"wire_api,omitempty"`
EnvKey string `toml:"env_key,omitempty" json:"env_key,omitempty"`
EnvHTTPHeaders map[string]string `toml:"env_http_headers,omitempty" json:"env_http_headers,omitempty"`
QueryParams map[string]string `toml:"query_params,omitempty" json:"query_params,omitempty"`
RequestMaxRetries int `toml:"request_max_retries,omitempty" json:"request_max_retries,omitempty"`
StreamMaxRetries int `toml:"stream_max_retries,omitempty" json:"stream_max_retries,omitempty"`
StreamIdleTimeoutMS int `toml:"stream_idle_timeout_ms,omitempty" json:"stream_idle_timeout_ms,omitempty"`
SupportsStandaloneWebSearch bool `toml:"supports_standalone_web_search,omitempty" json:"supports_standalone_web_search,omitempty"`
RequiresOpenAIAuth bool `toml:"requires_openai_auth,omitempty" json:"requires_openai_auth,omitempty"`
Auth AuthCommand `toml:"auth,omitempty" json:"auth,omitempty"`
// Copilot named-provider model fields. Statically configured Copilot
// models remain fail-closed until live SDK discovery verifies them.
Provider string `toml:"provider,omitempty" json:"provider,omitempty"`
WireModel string `toml:"wire_model,omitempty" json:"wire_model,omitempty"`
ModelID string `toml:"model_id,omitempty" json:"model_id,omitempty"`
MaxPromptTokens int `toml:"max_prompt_tokens,omitempty" json:"max_prompt_tokens,omitempty"`
MaxContextWindowTokens int `toml:"max_context_window_tokens,omitempty" json:"max_context_window_tokens,omitempty"`
MaxOutputTokens int `toml:"max_output_tokens,omitempty" json:"max_output_tokens,omitempty"`
Capabilities map[string]any `toml:"capabilities,omitempty" json:"capabilities,omitempty"`
}
type Provider ¶
type Provider struct {
Name string `toml:"name,omitempty" json:"name,omitempty"`
Type string `toml:"type,omitempty" json:"type,omitempty"`
WireAPI string `toml:"wire_api,omitempty" json:"wire_api,omitempty"`
Transport string `toml:"transport,omitempty" json:"transport,omitempty"`
CLIPath string `toml:"cli_path,omitempty" json:"cli_path,omitempty"`
BaseURL string `toml:"base_url,omitempty" json:"base_url,omitempty"`
GatewayURL string `toml:"gateway_url,omitempty" json:"gateway_url,omitempty"`
Headers map[string]string `toml:"headers,omitempty" json:"headers,omitempty"`
ModelID string `toml:"model_id,omitempty" json:"model_id,omitempty"`
WireModel string `toml:"wire_model,omitempty" json:"wire_model,omitempty"`
EnvKey string `toml:"env_key,omitempty" json:"env_key,omitempty"`
BearerTokenEnv string `toml:"bearer_token_env,omitempty" json:"bearer_token_env,omitempty"`
EnvHTTPHeaders map[string]string `toml:"env_http_headers,omitempty" json:"env_http_headers,omitempty"`
QueryParams map[string]string `toml:"query_params,omitempty" json:"query_params,omitempty"`
RequestMaxRetries int `toml:"request_max_retries,omitempty" json:"request_max_retries,omitempty"`
StreamMaxRetries int `toml:"stream_max_retries,omitempty" json:"stream_max_retries,omitempty"`
StreamIdleTimeoutMS int `toml:"stream_idle_timeout_ms,omitempty" json:"stream_idle_timeout_ms,omitempty"`
SupportsStandaloneWebSearch bool `toml:"supports_standalone_web_search,omitempty" json:"supports_standalone_web_search,omitempty"`
RequiresOpenAIAuth bool `toml:"requires_openai_auth,omitempty" json:"requires_openai_auth,omitempty"`
Auth AuthCommand `toml:"auth,omitempty" json:"auth,omitempty"`
// Claude's recognized gateway/BYOK references.
APIKeyEnv string `toml:"api_key_env,omitempty" json:"api_key_env,omitempty"`
AuthTokenEnv string `toml:"auth_token_env,omitempty" json:"auth_token_env,omitempty"`
BedrockProfileEnv string `toml:"bedrock_profile_env,omitempty" json:"bedrock_profile_env,omitempty"`
BedrockRegionEnv string `toml:"bedrock_region_env,omitempty" json:"bedrock_region_env,omitempty"`
VertexProjectEnv string `toml:"vertex_project_env,omitempty" json:"vertex_project_env,omitempty"`
VertexRegionEnv string `toml:"vertex_region_env,omitempty" json:"vertex_region_env,omitempty"`
FoundryEndpointEnv string `toml:"foundry_endpoint_env,omitempty" json:"foundry_endpoint_env,omitempty"`
FoundryAPIKeyEnv string `toml:"foundry_api_key_env,omitempty" json:"foundry_api_key_env,omitempty"`
EnvRefs map[string]string `toml:"env_refs,omitempty" json:"env_refs,omitempty"`
// Copilot SDK-safe settings. Static bearer/API values are rejected.
MaxPromptTokens int `toml:"max_prompt_tokens,omitempty" json:"max_prompt_tokens,omitempty"`
MaxOutputTokens int `toml:"max_output_tokens,omitempty" json:"max_output_tokens,omitempty"`
APIVersion string `toml:"api_version,omitempty" json:"api_version,omitempty"`
SDKSettings map[string]string `toml:"sdk_settings,omitempty" json:"sdk_settings,omitempty"`
}
Provider contains only fixed, documented routing fields. The *Env fields are names, not values. Any map is validated before being sent to a provider.