Documentation
¶
Index ¶
- func ApplyOAuthSlotDefaults(p *Provider)
- func ClearUnavailablePreferredDefaults(p *Provider, availableModels []string)
- func FixedOAuthProtocol(oauthProvider string) (string, bool)
- func InferOAuthProvider(providerName, endpoint string) string
- func IsAnthropicType(providerType string) bool
- func IsOpenAICompatibleType(providerType string) bool
- func IsOpenAIResponsesType(providerType string) bool
- func PreferredOAuthSlotDefaults(oauthProvider string) (custom, opus, sonnet, haiku string, ok bool)
- func ProtocolLabel(providerType string) string
- func RuntimeModelSpec(p Provider) string
- type Config
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOAuthSlotDefaults ¶ added in v1.3.11
func ApplyOAuthSlotDefaults(p *Provider)
ApplyOAuthSlotDefaults fills empty Custom/Opus/Sonnet/Haiku slots with the preferred defaults for p.OAuthProvider. Existing user mappings are preserved.
func ClearUnavailablePreferredDefaults ¶ added in v1.3.11
ClearUnavailablePreferredDefaults removes preferred-default slot mappings that are absent from availableModels so the launcher can fall back to auto-discovery for those tiers. Non-preferred (user-customized) values are left untouched. availableModels is typically the live OAuth /models list; empty is a no-op. Mutates p in memory only — does not rewrite config.
func FixedOAuthProtocol ¶ added in v1.3.5
FixedOAuthProtocol returns the public protocol label ccl persists for an OAuth backend. GPT/Codex/Copilot → Responses; Gemini/Grok/Kimi → OpenAI Chat; Claude → Anthropic. ok is false when oauthProvider is empty or unknown.
func InferOAuthProvider ¶ added in v1.3.2
InferOAuthProvider restores the public OAuth provider name for configs written before oauthProvider was persisted. The oauth:// endpoint is an internal backend marker, so ordinary HTTP providers are never inferred.
func IsAnthropicType ¶ added in v1.2.7
func IsOpenAICompatibleType ¶ added in v1.2.4
func IsOpenAIResponsesType ¶ added in v1.2.4
func PreferredOAuthSlotDefaults ¶ added in v1.3.11
PreferredOAuthSlotDefaults returns the first-choice Claude slot mapping for a subscription OAuth backend. ok is false when the backend has no built-in preferences and should rely entirely on runtime model discovery.
func ProtocolLabel ¶ added in v1.2.4
ProtocolLabel returns a short, human-friendly protocol name for display purposes (e.g. in the `set` TUI, `ccl ls`, and `ccl doctor` output). It intentionally does NOT change the underlying stored provider.Type value, which remains a stable, machine-readable string ("anthropic", "openai", "openai_responses", ...) relied on throughout the codebase for dispatch logic (proxy, launcher, doctor, ...).
OpenAI exposes two distinct generation protocols behind the same "openai" umbrella:
- Chat Completions — the old standard, broadest compatibility: labeled "openai(chat)".
- Responses — the newer agent protocol: labeled "openai(responses)".
func RuntimeModelSpec ¶ added in v1.3.4
RuntimeModelSpec returns every model ID that Claude Code may send for this provider. Embedded runtimes use the list to register model routes and aliases.
Types ¶
type Config ¶
type Config struct {
ActiveProvider string `yaml:"active_provider" mapstructure:"active_provider"`
Lang string `yaml:"lang,omitempty" mapstructure:"lang,omitempty"`
// BypassMode automatically passes --dangerously-skip-permissions to Claude
// Code for every ccl-launched session. It is a global launcher setting.
BypassMode bool `yaml:"bypass_mode,omitempty" mapstructure:"bypass_mode,omitempty"`
Providers map[string]Provider `yaml:"providers" mapstructure:"providers"`
}
type Provider ¶
type Provider struct {
Name string `yaml:"name" mapstructure:"name"`
Type string `yaml:"type" mapstructure:"type"`
Endpoint string `yaml:"endpoint" mapstructure:"endpoint"`
APIKey string `yaml:"apikey" mapstructure:"apikey"`
// Model is ccl's local model pool used for TUI mapping, slot defaults, and
// availability checks. For OpenAI-family providers it is also registered as
// CLIProxyAPI model routes/aliases; direct Anthropic providers must expose
// their own /v1/models to Claude Code.
Model string `yaml:"model" mapstructure:"model"`
Env map[string]string `yaml:"env,omitempty" mapstructure:"env,omitempty"`
// AnthropicAuth controls how Claude Code authenticates direct Anthropic-compatible providers.
// Empty and "x-api-key" use ANTHROPIC_API_KEY; "bearer" uses ANTHROPIC_AUTH_TOKEN.
AnthropicAuth string `yaml:"anthropicAuth,omitempty" mapstructure:"anthropicAuth,omitempty"`
// OAuthProvider selects an embedded CLIProxyAPI OAuth backend. Supported
// values are gpt, gemini, grok, copilot, kimi, and claude. The legacy chatgpt
// codex value remains readable.
OAuthProvider string `yaml:"oauthProvider,omitempty" mapstructure:"oauthProvider,omitempty"`
// OAuthAccountCredential binds this provider to a single credential file
// (basename of the JSON under ~/.ccl/auth). The OAuth runtime loads only
// that account when set; empty falls back to all backend credentials.
OAuthAccountCredential string `yaml:"oauthAccountCredential,omitempty" mapstructure:"oauthAccountCredential,omitempty"`
// Custom model configuration (Claude Code native features)
CustomModelID string `yaml:"customModelId,omitempty" mapstructure:"customModelId,omitempty"` // ANTHROPIC_CUSTOM_MODEL_OPTION
OpusModel string `yaml:"opusModel,omitempty" mapstructure:"opusModel,omitempty"` // ANTHROPIC_DEFAULT_OPUS_MODEL
SonnetModel string `yaml:"sonnetModel,omitempty" mapstructure:"sonnetModel,omitempty"` // ANTHROPIC_DEFAULT_SONNET_MODEL
HaikuModel string `yaml:"haikuModel,omitempty" mapstructure:"haikuModel,omitempty"` // ANTHROPIC_DEFAULT_HAIKU_MODEL
SubagentModel string `yaml:"subagentModel,omitempty" mapstructure:"subagentModel,omitempty"` // CLAUDE_CODE_SUBAGENT_MODEL
ModelOverrides map[string]string `yaml:"modelOverrides,omitempty" mapstructure:"modelOverrides,omitempty"` // modelOverrides in settings.json
EffortLevel string `yaml:"effortLevel,omitempty" mapstructure:"effortLevel,omitempty"` // CLAUDE_CODE_EFFORT_LEVEL; empty means Default/follow Claude
// FastMode mirrors the Claude Code settings.json fastMode flag, the same
// toggle flipped by the `/fast` slash command. It routes ChatGPT/Codex
// subscription accounts through Codex's faster responses (≈1.5x speed) at
// the cost of higher usage; only meaningful for OpenAI Responses OAuth
// backends (gpt/copilot). Empty/zero leaves Claude Code's own setting.
FastMode bool `yaml:"fastMode,omitempty" mapstructure:"fastMode,omitempty"`
}