Documentation
¶
Index ¶
- Constants
- func ApplyOAuthSlotDefaults(p *Provider)
- func ClearUnavailablePreferredDefaults(p *Provider, availableModels []string)
- func ContextPresetEnv(p Provider) map[string]string
- func ContextPresetValues(preset ContextPreset) (maxContext, compactWindow, compactPct string, ok bool)
- func EffectiveType(p Provider) string
- func HasManagedContextEnv(env map[string]string) bool
- func HasUnsupportedContextEnv(p Provider) bool
- func IsAnthropicType(providerType string) bool
- func IsAutoClawType(providerType string) bool
- func IsBalancedContextPreset(env map[string]string) bool
- func IsClaudeAccount(p Provider) bool
- func IsDefaultProvider(name string) bool
- func IsModelsDevType(providerType string) bool
- func IsOpenAICompatibleType(providerType string) bool
- func IsOpenAIResponsesType(providerType string) bool
- func ManagedContextEnvKeys() []string
- func ModelsDevCatalogID(p Provider) string
- func NormalizeProvider(p *Provider) bool
- func OAuthRuntimeType(oauthProvider string) (string, bool)
- func PreferredOAuthSlotDefaults(oauthProvider string) (custom, opus, sonnet, haiku, fable string, ok bool)
- func ProtocolForAISdkNPM(npm string) (string, bool)
- func ProtocolLabel(providerType string) string
- func ProtocolLabelForProvider(p Provider) string
- func RuntimeModelSpec(p Provider) string
- func SetProviderContextPreset(p *Provider, preset ContextPreset)
- func StripContextSuffix(model string) string
- type Config
- type ContextPreset
- type Provider
- type SlotModel
Constants ¶
const ( ContextPresetNameBalanced500K = "balanced-500k" ContextPresetNameBalanced800K = "balanced-800k" )
Context preset spellings persisted in Provider.ContextPreset.
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" // 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 = "85" Balanced800KMaxContextTokens = "800000" Balanced800KAutoCompactWindow = "800000" Balanced800KAutoCompactPct = "85" // 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.
const DefaultProvider = "default"
DefaultProvider is the reserved selector for Claude Code's own configuration: its claude.ai login and ~/.claude settings. Selecting it loads no provider; it is never a key of Config.Providers.
Variables ¶
This section is empty.
Functions ¶
func ApplyOAuthSlotDefaults ¶ added in v1.3.11
func ApplyOAuthSlotDefaults(p *Provider)
ApplyOAuthSlotDefaults fills empty Custom/Opus/Sonnet/Haiku/Fable 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 ContextPresetEnv ¶ added in v1.5.18
ContextPresetEnv returns the Claude Code variables a provider's preset expands to at launch (nil for Default).
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 EffectiveType ¶ added in v1.5.18
EffectiveType is the protocol type ccl dispatches p with. For an OAuth subscription it follows from the backend, never from what a file says.
func HasManagedContextEnv ¶ added in v1.5.0
HasManagedContextEnv reports whether any Claude Code context variable is set.
func HasUnsupportedContextEnv ¶ added in v1.5.18
HasUnsupportedContextEnv reports hand-written context variables that match no preset; the launcher drops them (and says so).
func IsAnthropicType ¶ added in v1.2.7
IsAnthropicType reports whether the provider speaks the Anthropic Messages protocol directly. AutoClaw has its own compatibility type because it uses the CCL Anthropic-to-OpenAI adapter; it must not be treated as a direct Anthropic endpoint.
func IsAutoClawType ¶ added in v1.5.10
IsAutoClawType reports whether the provider is AutoClaw Code (ZCode coding plan). Its credential is resolved from ~/.ccl/auth and kept inside a local runtime that adds the managed proxy's desktop-compatible headers.
func IsBalancedContextPreset ¶ added in v1.5.0
IsBalancedContextPreset reports whether env contains either exact Balanced tier managed by ccl.
func IsClaudeAccount ¶ added in v1.7.11
IsClaudeAccount identifies a native Claude subscription profile. It is launched by Claude Code itself, without an embedded OAuth proxy.
func IsDefaultProvider ¶ added in v1.6.2
IsDefaultProvider reports whether name selects Claude Code's own configuration.
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 ModelsDevCatalogID ¶ added in v1.5.16
ModelsDevCatalogID returns the models.dev catalog ID behind p.
func NormalizeProvider ¶ added in v1.5.18
NormalizeProvider derives the fields of one provider entry that are not persisted and reports whether a stored value had to change.
func OAuthRuntimeType ¶ added in v1.4.0
OAuthRuntimeType returns the internal compatibility type ccl persists for an OAuth backend. Zed 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
func PreferredOAuthSlotDefaults(oauthProvider string) (custom, opus, sonnet, haiku, fable string, ok bool)
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.
fable mirrors opus: no subscription catalog seen so far offers a Fable-family model, so the tier follows the backend's strongest model instead of inventing an upstream ID that would fail 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.
- Responses — the newer agent protocol.
ProtocolLabel renders a provider type as the protocol name shown in `ccl set`, `ccl ls`, and `ccl doctor`:
- Chat Completions — the old standard, broadest compatibility: "openai-chat".
- Responses — the newer agent protocol: "openai-responses".
- Anthropic Messages — Claude Code's native protocol: "anthropic-messages".
A backend whose real behavior is not implied by Type carries a " / " qualifier instead of a second set of parentheses: AutoClaw's CCL Anthropic-to-Chat adapter, Zed's per-model dispatch, and models.dev's per-model protocols.
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.
func SetProviderContextPreset ¶ added in v1.5.18
func SetProviderContextPreset(p *Provider, preset ContextPreset)
SetProviderContextPreset records preset on p and removes any context env the field replaces.
func StripContextSuffix ¶ added in v1.5.18
StripContextSuffix removes the [1m] context marker(s) from a model ID.
Types ¶
type Config ¶
type Config struct {
ActiveProvider string `yaml:"active_provider"`
// DefaultClaudeProvider names the account selected by `ccl use default`.
// Empty preserves Claude Code's original profile for existing installations.
DefaultClaudeProvider string `yaml:"default_claude_provider,omitempty"`
// ACPProvider is only the name selected by `ccl use --acp`. Its settings stay
// in the shared Providers map; ACP never owns a duplicate provider config.
// Empty means ACP follows ActiveProvider (see EffectiveACPProvider).
ACPProvider string `yaml:"acp_provider,omitempty"`
Lang string `yaml:"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"`
// ConfigVersion is the schema the file was last written with; see
// config.CurrentVersion.
ConfigVersion int `yaml:"config_version,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"`
// SignOn keeps Claude Code's git/PR attribution in ccl-launched sessions.
// It is off unless asked for: ccl writes Claude Code's attribution setting
// with empty texts, so commits get no Co-Authored-By trailer.
SignOn bool `yaml:"sign_on,omitempty"`
Providers map[string]Provider `yaml:"providers"`
}
func (*Config) EffectiveACPProvider ¶ added in v1.5.18
EffectiveACPProvider is the provider name ACP sessions use: the explicit `ccl use --acp` choice, or the normal-mode provider when none is pinned.
func (*Config) ResolveDefault ¶ added in v1.7.11
ResolveDefault resolves the reserved default selector. An absent account retains the original native Claude configuration; an invalid reference is an error so a removed account cannot silently switch billing identities.
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, and hand-written combinations resolve to Default; HasManagedContextEnv distinguishes those unsupported overrides from a genuinely empty Default configuration.
func ProviderContextPreset ¶ added in v1.5.18
func ProviderContextPreset(p Provider) ContextPreset
ProviderContextPreset returns p's context tier: the typed field, or — for a provider not yet normalized — an exact env triplet.
type Provider ¶
type Provider struct {
Name string `yaml:"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,omitempty"`
// 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"`
APIKey string `yaml:"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"`
Env map[string]string `yaml:"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"`
// OAuthProvider selects an embedded subscription runtime. Supported
// values are gpt, gemini, grok, qoder, kimi, kiro, workbuddy,
// workbuddycn, autoclaw, and zed. Load folds the retired chatgpt and
// codex values into gpt.
OAuthProvider string `yaml:"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"`
// Custom model configuration (Claude Code native features)
CustomModelID string `yaml:"customModelId,omitempty"` // ANTHROPIC_CUSTOM_MODEL_OPTION
OpusModel string `yaml:"opusModel,omitempty"` // ANTHROPIC_DEFAULT_OPUS_MODEL
SonnetModel string `yaml:"sonnetModel,omitempty"` // ANTHROPIC_DEFAULT_SONNET_MODEL
HaikuModel string `yaml:"haikuModel,omitempty"` // ANTHROPIC_DEFAULT_HAIKU_MODEL
FableModel string `yaml:"fableModel,omitempty"` // ANTHROPIC_DEFAULT_FABLE_MODEL
SubagentModel string `yaml:"subagentModel,omitempty"` // CLAUDE_CODE_SUBAGENT_MODEL
ModelOverrides map[string]string `yaml:"modelOverrides,omitempty"` // modelOverrides in settings.json
EffortLevel string `yaml:"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"`
// StatuslineDisabled turns off the status line ccl installs for this
// provider. ccl writes its status line through Claude Code's --settings,
// which outranks the user's own ~/.claude/settings.json, so this flag is the
// only way to keep a personal statusLine. Zero means ccl's line is used.
StatuslineDisabled bool `yaml:"statuslineDisabled,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"`
// ModelsDevProvider is the models.dev catalog ID a "modelsdev" provider was
// created from. It is separate from Name so the user can call the provider
// whatever they like; empty (configs saved before this field) falls back to
// Name, which used to be forced to the catalog ID.
ModelsDevProvider string `yaml:"modelsDevProvider,omitempty"`
// ContextPreset selects a provider-wide context tier ("balanced-500k" or
// "balanced-800k"); empty is Claude Code's default sizing. ccl derives the
// three Claude Code context variables from it at launch. Older configs
// encoded the tier as an exact env triplet, which Load converts.
ContextPreset string `yaml:"contextPreset,omitempty"`
// Ultracode turns on Claude Code's ultracode setting (a planned workflow per
// substantive task) for this provider's sessions.
Ultracode bool `yaml:"ultracode,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].