Documentation
¶
Index ¶
- Constants
- func ApplyOAuthSlotDefaults(p *Provider)
- func ClearUnavailablePreferredDefaults(p *Provider, availableModels []string)
- func ContextPresetValues(preset ContextPreset) (maxContext, compactWindow, compactPct string, ok bool)
- func HasManagedContextEnv(env map[string]string) bool
- func InferOAuthProvider(providerName, endpoint string) string
- func IsAnthropicType(providerType string) bool
- func IsBalancedContextPreset(env map[string]string) bool
- func IsCommandCodeType(providerType string) bool
- func IsModelsDevType(providerType string) bool
- func IsOpenAICompatibleType(providerType string) bool
- func IsOpenAIResponsesType(providerType string) bool
- func ManagedContextEnvKeys() []string
- func OAuthRuntimeType(oauthProvider string) (string, bool)
- func PreferredOAuthSlotDefaults(oauthProvider string) (custom, opus, sonnet, haiku string, ok bool)
- func ProtocolForAISdkNPM(npm string) (string, bool)
- func ProtocolLabel(providerType string) string
- func ProtocolLabelForProvider(p Provider) string
- func RuntimeModelSpec(p Provider) string
- type Config
- type ContextPreset
- type Provider
- type SlotModel
Constants ¶
const ( // EnvMaxContextTokens is the fallback context size Claude Code assumes for a // model it does not recognize. EnvMaxContextTokens = "CLAUDE_CODE_MAX_CONTEXT_TOKENS" // EnvAutoCompactWindow is the window Claude Code uses as the basis for its // auto-compact threshold. EnvAutoCompactPct selects the percentage of it. EnvAutoCompactWindow = "CLAUDE_CODE_AUTO_COMPACT_WINDOW" // EnvContextBudgetMode is a retired ccl directive kept only so old provider // env maps can remove it instead of forwarding it to Claude Code. EnvContextBudgetMode = "CCL_CONTEXT_BUDGET" // EnvAutoCompactPct is Claude Code's percentage-based auto-compact threshold. // It only ever lowers the trigger point, and Claude Code has repeatedly // ignored it when it arrives through the settings file, so ccl also exports it // to the child process environment. EnvAutoCompactPct = "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE" Balanced500KMaxContextTokens = "500000" Balanced500KAutoCompactWindow = "500000" Balanced500KAutoCompactPct = "80" Balanced800KMaxContextTokens = "800000" Balanced800KAutoCompactWindow = "800000" Balanced800KAutoCompactPct = "80" // BalancedMaxContextTokens and companions retain the original 500K names for // callers that do not need to distinguish the two supported Balanced tiers. BalancedMaxContextTokens = Balanced500KMaxContextTokens BalancedAutoCompactWindow = Balanced500KAutoCompactWindow BalancedAutoCompactPct = Balanced500KAutoCompactPct )
Claude Code env vars that ccl manages through Provider.Env. They live here so the launcher, the config TUI and the diagnostics all agree on the spelling.
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 ContextPresetValues ¶ added in v1.5.4
func ContextPresetValues(preset ContextPreset) (maxContext, compactWindow, compactPct string, ok bool)
ContextPresetValues returns the exact managed environment values for a supported Balanced tier. Default has no values and returns ok=false.
func HasManagedContextEnv ¶ added in v1.5.0
HasManagedContextEnv reports whether any Claude Code context variable is set.
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 IsBalancedContextPreset ¶ added in v1.5.0
IsBalancedContextPreset reports whether env contains either exact Balanced tier managed by ccl.
func IsCommandCodeType ¶ added in v1.5.4
IsCommandCodeType reports whether the provider is the Command Code API-key gateway, served by ccl's own /alpha/generate data plane.
func IsModelsDevType ¶ added in v1.5.3
IsModelsDevType reports whether the provider is a mixed-protocol models.dev gateway, whose per-model protocols live in ModelProtocols rather than a single provider-level Type.
func IsOpenAICompatibleType ¶ added in v1.2.4
func IsOpenAIResponsesType ¶ added in v1.2.4
func ManagedContextEnvKeys ¶ added in v1.3.16
func ManagedContextEnvKeys() []string
ManagedContextEnvKeys are the context-sizing variables ccl forwards. They are exported to the Claude Code process as well as written to the settings file, because the settings-file channel has proven unreliable for them.
func OAuthRuntimeType ¶ added in v1.4.0
OAuthRuntimeType returns the internal compatibility type ccl persists for an OAuth backend. Copilot is represented by openai_responses for local dispatch, but its actual upstream protocol is selected per model. ok is false when the backend is empty or unknown.
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 ProtocolForAISdkNPM ¶ added in v1.5.3
ProtocolForAISdkNPM maps a models.dev AI SDK package to ccl's provider Type protocol. ok is false for an unknown package, in which case the model should be skipped by the caller.
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 ProtocolLabelForProvider ¶ added in v1.4.0
ProtocolLabelForProvider reports the user-facing protocol, including OAuth backends whose real behavior cannot be inferred from the internal Type field.
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"`
// LogLevel is the threshold for ccl's per-session slog files: debug, info,
// warn, error, or off. Config loading normalizes an omitted value to off.
LogLevel string `yaml:"log_level,omitempty" mapstructure:"log_level,omitempty"`
// DebugMode and DebugVerbose remain readable only to migrate configurations
// written before `ccl debug` was renamed to `ccl log`.
DebugMode bool `yaml:"debug_mode,omitempty" mapstructure:"debug_mode,omitempty"`
DebugVerbose bool `yaml:"debug_verbose,omitempty" mapstructure:"debug_verbose,omitempty"`
Providers map[string]Provider `yaml:"providers" mapstructure:"providers"`
}
type ContextPreset ¶ added in v1.5.4
type ContextPreset uint8
ContextPreset identifies a provider-wide context configuration managed by ccl.
const ( ContextPresetDefault ContextPreset = iota ContextPresetBalanced500K ContextPresetBalanced800K )
func ContextPresetFromEnv ¶ added in v1.5.4
func ContextPresetFromEnv(env map[string]string) ContextPreset
ContextPresetFromEnv recognizes the exact provider-wide context triplets that ccl supports. Missing, partial, legacy, and hand-written combinations resolve to Default; HasManagedContextEnv distinguishes those unsupported overrides from a genuinely empty Default configuration.
type Provider ¶
type Provider struct {
Name string `yaml:"name" mapstructure:"name"`
// Type selects the upstream protocol for a manual gateway. For OAuth
// subscriptions it is only the local adapter compatibility type; the real
// backend and authentication flow are selected by OAuthProvider.
Type string `yaml:"type" mapstructure:"type"`
// Endpoint is an HTTP API base for manual gateways and an oauth:// descriptor
// for persisted subscriptions. Provider Session replaces the latter with a
// loopback address only in its runtime copy.
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 also supplies the
// local runtime routes and 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 subscription runtime. Supported
// values are gpt, gemini, grok, copilot, qoder, kimi, kiro, workbuddy, and
// commandcode. The legacy chatgpt and codex values remain 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). Subscription runtimes require
// this binding and load only that account.
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 the GPT/Codex Responses
// OAuth backend. Empty/zero leaves Claude Code's own setting.
FastMode bool `yaml:"fastMode,omitempty" mapstructure:"fastMode,omitempty"`
// ModelProtocols maps a lowercase model ID to its upstream protocol
// ("anthropic", "openai", or "openai_responses"). It is only used by the
// mixed-protocol gateway (Type == "modelsdev"), whose single endpoint serves
// models over different wire protocols. Empty means provider-level single
// protocol, selected by Type as before.
ModelProtocols map[string]string `yaml:"modelProtocols,omitempty" mapstructure:"modelProtocols,omitempty"`
}
type SlotModel ¶ added in v1.3.16
SlotModel pairs a Claude Code model slot with the model mapped to it.
func SlotModels ¶ added in v1.3.16
SlotModels lists the models mapped to Claude Code's slots, in menu order, skipping empty slots and stripping display-only markers such as [1m].