config

package
v0.20260527.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvOpenAIBaseURL = "OPENAI_BASE_URL"
	EnvOpenAIAPIKey  = "OPENAI_API_KEY"
	EnvModelID       = "MODEL_ID"
)
View Source
const (
	ProviderNameChatGPTSub  = "ChatGPT Sub"
	ProviderNameClaudeSub   = "Claude Sub"
	ProviderNameCursorAPI   = "Cursor API"
	CursorAPIDefaultModelID = "composer-2.5"
	OpenAIPlatformBase      = "https://api.openai.com"
	AnthropicPlatformBase   = "https://api.anthropic.com"

	AuthKindAPIKey       = "api_key"
	AuthKindOAuthChatGPT = "oauth_chatgpt"
	AuthKindOAuthClaude  = "oauth_claude"
	AuthKindCursorAPI    = "cursor_api"

	ClaudeSubExpectedDate = "2026-06-15"
)
View Source
const APIProtocolAnthropic = "anthropic"
View Source
const APIProtocolOpenAI = "openai"
View Source
const DefaultAPIBaseDelayMS = 1000
View Source
const DefaultAPICircuitOpenSec = 60
View Source
const DefaultAPIConnectTimeoutSec = 30
View Source
const DefaultAPIMaxDelayMS = 30000
View Source
const DefaultAPIMaxRetries = 3
View Source
const DefaultCompactionThresholdTokens int64 = 131072
View Source
const DefaultResponseLanguage = "English"
View Source
const DefaultSkillSearchMinNormalizedScore = 0.05
View Source
const DefaultSubagentTimeoutMinutes = 20
View Source
const DefaultToolOutputMaxBytes = 65536
View Source
const DefaultToolOutputMaxLines = 2048
View Source
const DefaultWebSearchEngine = "duckduckgo"
View Source
const MaxModelPickerEntries = 25
View Source
const MinCompactionThresholdTokens int64 = 32768

Variables

This section is empty.

Functions

func AllDigits

func AllDigits(s string) bool

func AppendOrUpdateProvider added in v0.20260521.1

func AppendOrUpdateProvider(r *Root, p Provider)

func ApplyOAuthTokens added in v0.20260521.1

func ApplyOAuthTokens(p *Provider, t codex.TokenSet)

func ApplyOnboardMerge

func ApplyOnboardMerge(dst *Root, res *OnboardResult)

func BackupConfig

func BackupConfig() (string, error)

func ClampTimeoutMinutes

func ClampTimeoutMinutes(n int) error

func ConfigExists

func ConfigExists() (bool, error)

func ConfirmOnboardRerun

func ConfirmOnboardRerun(pio PromptIO) (bool, error)

func EffectiveCompactionThresholdTokens

func EffectiveCompactionThresholdTokens(r *Root) int64

func EffectiveSkillSearchMinNorm

func EffectiveSkillSearchMinNorm(r *Root) float64

func EnsureChatGPTSubBaseURL added in v0.20260521.1

func EnsureChatGPTSubBaseURL(p *Provider)

func EnsureClaudeSubBaseURL added in v0.20260521.2

func EnsureClaudeSubBaseURL(p *Provider)

func FastModeSupportedByProvider added in v0.20260526.3

func FastModeSupportedByProvider(p *Provider) bool

func FirstProviderName added in v0.20260521.2

func FirstProviderName(r *Root) string

func IsOAuthAuthKind added in v0.20260521.2

func IsOAuthAuthKind(kind string) bool

func ModelPassesChatGPTSubFilter added in v0.20260521.1

func ModelPassesChatGPTSubFilter(modelID string) bool

func ModelPassesChatGPTSubPickerFilter added in v0.20260526.3

func ModelPassesChatGPTSubPickerFilter(modelID string) bool

func ModelPassesClaudeSubFilter added in v0.20260521.2

func ModelPassesClaudeSubFilter(modelID string) bool

func NeedsOnboard

func NeedsOnboard(r *Root) bool

func NormalizeAPIBase

func NormalizeAPIBase(raw string) (string, error)

func NormalizeAnthropicBase added in v0.20260521.2

func NormalizeAnthropicBase(raw string) (string, error)

func NoteRecentModelUse

func NoteRecentModelUse(r *Root, providerName, modelID string)

func ParseReasoningEffortToken

func ParseReasoningEffortToken(s string) (string, error)

func PickModelInteractive

func PickModelInteractive(pio PromptIO, p *Provider, providerLabel string, ids []string, allowSkip bool) (string, error)

func PrintConfigSkipHint

func PrintConfigSkipHint(out io.Writer, topic string)

func ProviderCredentialsReady added in v0.20260521.1

func ProviderCredentialsReady(p *Provider) bool

func ReadPromptLine added in v0.20260521.2

func ReadPromptLine(p PromptIO, prompt string) (string, error)

func ResolveExecConfig

func ResolveExecConfig(existing *Root, opts ExecResolveOpts) (*Root, *Provider, error)

func ResolveProviderBearer added in v0.20260521.1

func ResolveProviderBearer(ctx context.Context, r *Root, p *Provider) (string, error)

func RunInitialSetup

func RunInitialSetup(pio PromptIO, errOut io.Writer, cfg *Root, configExists bool) error

func Save

func Save(r *Root) error

func SubagentTimeout

func SubagentTimeout(r *Root) int

func WriteConfigSetupWarning

func WriteConfigSetupWarning(w io.Writer, r *Root)

Types

type APIResilienceConfig added in v0.20260523.0

type APIResilienceConfig struct {
	MaxRetries        int   `toml:"max_retries,omitempty"`
	BaseDelayMS       int   `toml:"base_delay_ms,omitempty"`
	MaxDelayMS        int   `toml:"max_delay_ms,omitempty"`
	Jitter            *bool `toml:"jitter,omitempty"`
	ConnectTimeoutSec int   `toml:"connect_timeout_sec,omitempty"`
	ReadTimeoutSec    int   `toml:"read_timeout_sec,omitempty"`
	CircuitOpenSec    int   `toml:"circuit_open_sec,omitempty"`
}

type APIResiliencePolicy added in v0.20260523.0

type APIResiliencePolicy struct {
	MaxRetries     int
	BaseDelay      time.Duration
	MaxDelay       time.Duration
	Jitter         bool
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	CircuitOpen    time.Duration
}

func EffectiveAPIResilience added in v0.20260523.0

func EffectiveAPIResilience(r *Root) APIResiliencePolicy

type Current

type Current struct {
	Provider string `toml:"provider"`
	Model    string `toml:"model"`
}

type ExecResolveOpts

type ExecResolveOpts struct {
	EnvFile string
}

type ModelPickChoice

type ModelPickChoice struct {
	ProviderName string
	ModelID      string
	Changed      bool
}

func PickModelAfterAdd

func PickModelAfterAdd(pio PromptIO, prevProv, prevModel, newProvName string, newIDs []string, allowSkip bool) (ModelPickChoice, error)

type OAuthTokenSet added in v0.20260521.2

type OAuthTokenSet struct {
	AccessToken  string
	RefreshToken string
	ExpiresAt    time.Time
	AccountID    string
}

type OnboardOpts

type OnboardOpts struct {
	RequireProvider bool
}

type OnboardResult

type OnboardResult struct {
	UserName                  string
	ResponseLanguage          string
	SubagentTimeoutMinutes    int
	CompactionThresholdTokens int64
	NewProvider               *Provider
	SwitchCurrent             bool
	CurrentProvider           string
	CurrentModel              string
}

func RunOnboardWizard

func RunOnboardWizard(pio PromptIO, existing *Root, opts OnboardOpts) (*OnboardResult, error)

type PromptIO added in v0.20260521.2

type PromptIO struct {
	Stdin    io.Reader
	Out      io.Writer
	ReadLine func(prompt string) (string, error)
}

type Provider

type Provider struct {
	Name              string `toml:"-"`
	BaseURL           string `toml:"base_url"`
	APIKey            string `toml:"api_key"`
	APIProtocol       string `toml:"api_protocol,omitempty"`
	AuthKind          string `toml:"auth_kind,omitempty"`
	OAuthAccessToken  string `toml:"oauth_access_token,omitempty"`
	OAuthRefreshToken string `toml:"oauth_refresh_token,omitempty"`
	OAuthExpiresAt    string `toml:"oauth_expires_at,omitempty"`
	OAuthAccountID    string `toml:"oauth_account_id,omitempty"`
}

func NewChatGPTSubProvider added in v0.20260521.1

func NewChatGPTSubProvider(baseURL string, tokens codex.TokenSet) (Provider, error)

func ProviderByName added in v0.20260521.2

func ProviderByName(r *Root, name string) *Provider

func ProviderList added in v0.20260521.2

func ProviderList(r *Root) []Provider

func ResolveProvider

func ResolveProvider(r *Root) (*Provider, error)

func (*Provider) EffectiveAPIProtocol added in v0.20260521.2

func (p *Provider) EffectiveAPIProtocol() string

func (*Provider) EffectiveAuthKind added in v0.20260521.1

func (p *Provider) EffectiveAuthKind() string

func (*Provider) IsAnthropic added in v0.20260521.2

func (p *Provider) IsAnthropic() bool

func (*Provider) IsChatGPTSub added in v0.20260521.1

func (p *Provider) IsChatGPTSub() bool

func (*Provider) IsClaudeSub added in v0.20260521.2

func (p *Provider) IsClaudeSub() bool

func (*Provider) IsCursorAPI added in v0.20260525.0

func (p *Provider) IsCursorAPI() bool

func (*Provider) IsOAuthProvider added in v0.20260521.2

func (p *Provider) IsOAuthProvider() bool

func (*Provider) UsesAnthropicOAuthBearer added in v0.20260521.2

func (p *Provider) UsesAnthropicOAuthBearer() bool

type RecentModelUse

type RecentModelUse struct {
	Provider string `toml:"provider"`
	Model    string `toml:"model"`
}

func RecentModelUseEntries added in v0.20260521.2

func RecentModelUseEntries(r *Root, preferProvider string) []RecentModelUse

type Root

type Root struct {
	UserName                  string               `toml:"user_name"`
	Providers                 map[string]*Provider `toml:"-"`
	Current                   Current              `toml:"current"`
	RecentModels              map[string][]string  `toml:"recent_models,omitempty"`
	SubagentTimeoutMinutes    int                  `toml:"subagent_timeout_minutes"`
	ReasoningEffort           string               `toml:"reasoning_effort"`
	FastMode                  *bool                `toml:"fast_mode,omitempty"`
	LogLevel                  string               `toml:"log_level"`
	MaxResponseTokens         int                  `toml:"max_response_tokens"`
	ShowThinking              bool                 `toml:"show_thinking"`
	Tools                     Tools                `toml:"tools,omitempty"`
	ShowUsageStats            *bool                `toml:"show_usage_stats"`
	ResponseLanguage          string               `toml:"response_language"`
	CompactionThresholdTokens int64                `toml:"compaction_threshold_tokens"`
	SkillSearchMinNorm        *float64             `toml:"skill_search_min_normalized_score,omitempty"`
	WebSearchEngine           string               `toml:"web_search_engine,omitempty"`
	WebSearchAPIKey           string               `toml:"web_search_api_key,omitempty"`
	WebSearchBaseURL          string               `toml:"web_search_base_url,omitempty"`
	WebSearchCX               string               `toml:"web_search_cx,omitempty"`
	ToolOutput                ToolOutput           `toml:"tool_output,omitempty"`
	APIResilience             APIResilienceConfig  `toml:"api_resilience,omitempty"`
}

func EmptyRoot

func EmptyRoot() *Root

func Load

func Load() (*Root, error)

func LoadOptional

func LoadOptional() (*Root, error)

func RunWizardIfNeeded

func RunWizardIfNeeded(stdin io.Reader) (*Root, error)

func (*Root) EffectiveFastMode added in v0.20260526.3

func (r *Root) EffectiveFastMode() bool

func (*Root) EffectiveResponseLanguage

func (r *Root) EffectiveResponseLanguage() string

func (*Root) EffectiveWebSearchEngine

func (r *Root) EffectiveWebSearchEngine() string

func (*Root) FastModeEnabledForProvider added in v0.20260526.3

func (r *Root) FastModeEnabledForProvider(p *Provider) bool

func (*Root) GlobalReasoningEffort

func (r *Root) GlobalReasoningEffort() shared.ReasoningEffort

func (*Root) LegacyToolsEnabled added in v0.20260523.0

func (r *Root) LegacyToolsEnabled() bool

func (*Root) LegacyToolsForceEnabled added in v0.20260523.0

func (r *Root) LegacyToolsForceEnabled() bool

func (*Root) ModelDisplayName added in v0.20260526.3

func (r *Root) ModelDisplayName(p *Provider, model string) string

func (*Root) ReasoningEffortDisplayLabel added in v0.20260526.3

func (r *Root) ReasoningEffortDisplayLabel() string

func (*Root) ReasoningEffortIsNone

func (r *Root) ReasoningEffortIsNone() bool

func (*Root) ReasoningEffortLabel

func (r *Root) ReasoningEffortLabel() string

func (*Root) UsageStatsEnabled

func (r *Root) UsageStatsEnabled() bool

type ToolOutput added in v0.20260522.0

type ToolOutput struct {
	MaxBytes int `toml:"max_bytes,omitempty"`
	MaxLines int `toml:"max_lines,omitempty"`
}

type Tools added in v0.20260523.0

type Tools struct {
	Legacy      bool `toml:"legacy,omitempty"`
	LegacyForce bool `toml:"legacy_force,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL