Documentation
¶
Index ¶
- Variables
- func BuildSettingsResponse(path string, exists bool, raw map[string]any, order Order) map[string]any
- func ExpandAbs(path string) string
- func GateReasoningEffort(effort string, supportsReasoning, adapterSupportsEffort bool) string
- func IsAPIKeyEnvRef(value string) string
- func MergeAPIKeys(incoming, existing map[string]any)
- func ModelsForProvider(settings Settings, resolved ResolvedProvider) []string
- func NormalizeReasoningEffort(value string) (string, error)
- func PermissionLevelOptions() []string
- func PermissionModeOptions() []string
- func ProjectDirs(cwd, project string) []string
- func ResolveHome() string
- func ResolveProject(cwd string) string
- func ResolveSessionsDir() string
- func ResolveSymlinks(path string) string
- func ResponseReasoningEffort(value string) any
- func ValidateGlobalConfig(data any) (map[string]any, error)
- func WriteSettingsFile(path string, payload map[string]any, order Order) error
- type Order
- type PermissionConfig
- type ProviderConfig
- type ResolvedProvider
- type Settings
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedReasoningEffort = errors.New("unsupported reasoning_effort")
var ReasoningEffortOptions = []string{"auto", "none", "low", "medium", "high", "xhigh"}
ReasoningEffortOptions enumerates the values exposed to the web UI; "auto" is added on top of the validated set so the UI can render the unset case.
Functions ¶
func BuildSettingsResponse ¶
func BuildSettingsResponse(path string, exists bool, raw map[string]any, order Order) map[string]any
BuildSettingsResponse renders the GET /api/settings payload. The web UI needs the saved config plus metadata about valid options / env vars to render the settings form without making extra calls.
func ExpandAbs ¶
ExpandAbs resolves "~" to the user's home directory and returns the cleaned absolute path. Empty input stays empty.
func GateReasoningEffort ¶
GateReasoningEffort returns effort only when the model supports reasoning and the adapter exposes the effort knob; otherwise it returns "".
func IsAPIKeyEnvRef ¶
func MergeAPIKeys ¶
MergeAPIKeys carries over saved api_keys for providers whose incoming payload omits them (the UI never echoes saved secrets back). Providers that explicitly clear api_key still drop it.
func ModelsForProvider ¶
func ModelsForProvider(settings Settings, resolved ResolvedProvider) []string
ModelsForProvider returns the models to expose for a resolved provider: configured models first (with their explicit order), otherwise the spec's defaults, falling back to the single resolved model when no spec matches.
func PermissionLevelOptions ¶
func PermissionLevelOptions() []string
func PermissionModeOptions ¶
func PermissionModeOptions() []string
func ProjectDirs ¶
ProjectDirs returns directories from project to cwd, inclusive.
func ResolveProject ¶
ResolveProject returns the nearest Git project root, or cwd when no .git is found.
func ResolveSessionsDir ¶
func ResolveSessionsDir() string
ResolveSessionsDir returns the persisted sessions directory.
func ResolveSymlinks ¶
ResolveSymlinks returns an absolute path with symlinks resolved for existing path components. Missing trailing components are kept as written.
func ResponseReasoningEffort ¶
func WriteSettingsFile ¶
WriteSettingsFile writes payload as pretty-printed JSON via a temp-file rename, preserving the caller-supplied provider/model ordering. The atomic rename ensures a crash mid-write cannot truncate the settings.
Types ¶
type Order ¶
func ParseConfigOrder ¶
ParseConfigOrder preserves model order lost by map unmarshalling.
func ReadRawSettings ¶
ReadRawSettings loads the global settings JSON. Returns an empty map and exists=false when the file is missing or not a regular file (e.g. a directory placeholder). Parse failures bubble up with the file path.
type PermissionConfig ¶
PermissionConfig controls automatic tool execution.
func DefaultPermissionConfig ¶
func DefaultPermissionConfig() PermissionConfig
type ProviderConfig ¶
type ProviderConfig struct {
Name string
Type string
Models map[string]mycode.ModelOverride
ModelOrder []string
APIKey string
APIKeyEnvVar string
BaseURL string
ReasoningEffort string
}
ProviderConfig defines one configured provider alias, parsed field by field from the raw settings JSON.
type ResolvedProvider ¶
type ResolvedProvider struct {
ProviderName string
ProviderType string
Model string
APIKey string
APIBase string
ReasoningEffort string
Metadata mycode.ModelMetadata
}
ResolvedProvider is the runnable provider config. Metadata is the model capability set already resolved from the bundled catalog plus any per-model config overrides.
func AvailableProviders ¶
func AvailableProviders(settings Settings) []ResolvedProvider
AvailableProviders returns currently selectable providers in stable order.
func ResolveProvider ¶
func ResolveProvider(settings Settings, providerName, model, apiKey, apiBase string) (ResolvedProvider, error)
ResolveProvider resolves one provider alias or built-in provider id.
type Settings ¶
type Settings struct {
Providers map[string]ProviderConfig
DefaultProvider string
DefaultModel string
DefaultReasoningEffort string
CompactThreshold float64
Permission PermissionConfig
Port int
CWD string
Project string
ConfigPaths []string
// contains filtered or unexported fields
}
Settings is the resolved config view for one cwd.