Documentation
¶
Overview ¶
Package config holds the router configuration: tiers, activities, routes, policy, classifiers, and the JSON file under the XDG config dir they load from. It is a leaf package: nothing in internal/ is imported here.
Index ¶
Constants ¶
const ( DirName = "codex-router" FileName = "config.json" )
File locations under the XDG config dir.
const ( APISystemOne = "system-one" APIOllama = "ollama" )
Classifier wire adapters.
Variables ¶
var Activities = []Activity{ ActivityCode, ActivityDebug, ActivityExplore, ActivityPlan, ActivityReview, ActivityOps, ActivityDocs, }
Activities lists the seven routable activities.
var Efforts = []Effort{EffortLow, EffortMedium, EffortHigh, EffortXHigh}
Efforts lists efforts weakest first.
var Tiers = []Tier{TierMicro, TierLow, TierMedium, TierHigh}
Tiers lists every tier by rank.
Functions ¶
Types ¶
type Activity ¶
type Activity string
Activity names what a turn produces. ActivityUncertain is a classifier answer, never a config key.
type Classifier ¶
type Classifier struct {
Label string `json:"label"`
API string `json:"api"`
Endpoint string `json:"endpoint"`
Model string `json:"model"`
KeyEnv string `json:"keyEnv,omitempty"`
TimeoutMs int `json:"timeoutMs"`
}
Classifier describes one classifier endpoint. API names the wire adapter ("system-one" or "ollama"). KeyEnv names the environment variable holding the bearer key; empty means no key.
type Config ¶
type Config struct {
Baseline Tier `json:"baseline"`
Routes map[Tier]Route `json:"routes"`
Activities map[Activity]map[Tier]Route `json:"activities,omitempty"`
Prices map[string]Price `json:"prices,omitempty"`
Policy Policy `json:"policy"`
Preset Preset `json:"preset"`
Classifier string `json:"classifier"`
Classifiers map[string]Classifier `json:"classifiers"`
Context Context `json:"context"`
Cache Cache `json:"cache"`
Proxy Proxy `json:"proxy"`
CodexBin string `json:"codexBin,omitempty"`
}
Config is the whole router configuration.
func Default ¶
func Default() Config
Default returns the built-in configuration: the four gpt-6 models that share one compatibility group (plan D2), classifier Jev with a local Ollama option.
func Load ¶
Load reads the config file over Default(): keys the file omits keep their defaults, a map entry the file names replaces the default entry whole. A missing file yields the defaults. Unknown keys and invalid values are errors.
func (Config) DecideTimeout ¶
DecideTimeout bounds one routing decision: the selected classifier's timeout plus a margin, so the proxy outlasts the classifier call.
func (Config) Effective ¶
Effective returns Policy with the preset applied. Balanced keeps Policy as configured; thrifty makes upgrades harder and downgrades easier; quality does the opposite. Preset fields replace the configured values. The claude-model-router has no named presets, only the policy fields these adjust, so the values are new and chosen for direction, not ported.
type Policy ¶
type Policy struct {
UpgradeVotes int `json:"upgradeVotes"`
UpgradeBase float64 `json:"upgradeBase"`
UpgradeSlope float64 `json:"upgradeSlope"`
UpgradePivotTokens int `json:"upgradePivotTokens"`
JumpConfidence float64 `json:"jumpConfidence"`
DowngradeVotes int `json:"downgradeVotes"`
DowngradeMass float64 `json:"downgradeMass"`
DowngradeSlope float64 `json:"downgradeSlope"`
DowngradePivotTokens int `json:"downgradePivotTokens"`
DowngradeHorizonTurns int `json:"downgradeHorizonTurns"`
ContinuationMass float64 `json:"continuationMass"`
EscalationHoldTurns int `json:"escalationHoldTurns"`
ReviewEveryRequests int `json:"reviewEveryRequests"`
MinDwellRequests int `json:"minDwellRequests"`
ActivityMass float64 `json:"activityMass"`
ContextFill float64 `json:"contextFill"`
}
Policy holds the switching thresholds. Taxes are in uncached tokens.
type Price ¶
type Price struct {
Input float64 `json:"input"`
CachedInput float64 `json:"cachedInput"`
Output float64 `json:"output"`
}
Price is a model's list price in USD per million tokens. Zero values mean unpriced: estimates then stay in tokens.
type Proxy ¶
type Proxy struct {
Port int `json:"port"`
}
Proxy holds listener settings. Port 0 binds an ephemeral port per session.