Documentation
¶
Overview ¶
Package provider is the one place the environment is mapped onto an LLM backend. Both `whetstone` (authoring, on a developer's machine) and `skael-worker` (scoring, on a server) resolve their gateway here, so a misconfiguration is diagnosed with the same words wherever it is met.
Four provider modes, and no variable outside this file selects one:
- Anthropic direct ANTHROPIC_API_KEY
- Compatible gateway ANTHROPIC_BASE_URL + ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN
- Subscription CLI nothing set, and an agent CLI on PATH
- Split mode 2, plus CLAUDE_CODE_OAUTH_TOKEN
The judge and the eval panel share ANTHROPIC_BASE_URL. Mode 4 is the one case where they separate, and it takes both PanelModels and PanelExcludeEnv to do it. Turning it on changes model_panel, which splits a skill's score trend.
Index ¶
Constants ¶
const ( AdapterAnthropic = "anthropic" AdapterGateway = "gateway" AdapterSubscription = "subscription" )
Backend adapters the server's providers use.
const ( APIKeyEnv = "ANTHROPIC_API_KEY" AuthTokenEnv = "ANTHROPIC_AUTH_TOKEN" BaseURLEnv = "ANTHROPIC_BASE_URL" // ModelEnv is comma-separated, most capable first: the first entry serves // every judge call and the panel's primary member, the rest are the panel's // floor members. One list rather than a strong/fast pair, which could be // half-set — a panel with one working member and one that 404s is not an // error but a complete run that scores and can never release anything. ModelEnv = "LLM_MODEL" // OAuthTokenEnv selects mode 4 and nothing else. A judge call is never // authenticated with it: a subscription is neither metered nor pinned to a // model, and a released version's score must be both. OAuthTokenEnv = "CLAUDE_CODE_OAUTH_TOKEN" )
The SDK's and the CLI's own names, not Skael-specific ones: a machine set up for either needs no further configuration, and the panel is a Claude Code CLI reading the same values the worker resolved.
Variables ¶
This section is empty.
Functions ¶
func MemberEnv ¶ added in v0.19.0
MemberEnv is the credential variables a panel member's sandbox receives.
func PinnedByEnv ¶ added in v0.19.0
PinnedByEnv reports whether this process's own gateway or model settings override the server's providers.
Types ¶
type Backend ¶ added in v0.19.0
type Backend struct {
Adapter string
BaseURL string
AuthStyle string
CredentialEnv string
Model string
}
Backend is one provider and model chosen on the server. The credential is never sent: CredentialEnv names the worker's own variable that holds it.
type Config ¶
type Config struct {
Kind Kind
Detail string
Binary string
// BaseURL is the panel's gateway as much as the judge's. Empty is
// Anthropic's own API.
BaseURL string
Key string
// AuthStyle is inferred from which credential was set rather than
// configured: a bearer token is only ever presented as a bearer token.
AuthStyle api.AuthStyle
// Models is ModelEnv, split and trimmed. Empty means the shipped defaults.
Models []string
// PanelSubscription is mode 4: the judge keeps BaseURL, the panel
// authenticates with OAuthTokenEnv.
PanelSubscription bool
}
Config is data only: nothing dials anything until Gateway is called.
func APIFromEnv ¶
func APIFromEnv() Config
APIFromEnv is FromEnv with subscription detection off, for a caller whose backend must be metered and reproducible — the worker, whose judge output releases versions. An operator with both a key and a CLI is served by the key.
func FromEnv ¶
func FromEnv() Config
FromEnv resolves from this process's environment, subscription CLI included.
func Judge ¶ added in v0.19.0
Judge resolves the judge's backend. A subscription never judges: a released version's score must come from a metered backend pinned to a model.
func Resolve ¶
Resolve picks a provider. Explicit gateway configuration beats autodetection: preferring a CLI that happens to be on PATH would bill the wrong account and score against a different model. APIKeyEnv alone stays *below* the CLI — it sits on plenty of machines that also have the CLI, and treating it as an override moves them onto metered billing without anyone asking.
func (Config) PanelExcludeEnv ¶
PanelExcludeEnv names the credentials a sandbox must NOT be given, though the adapter declares them. This is the half that actually moves the panel: the adapter forwards every name it declares that is set, so without the exclusion a member asks a subscription for its alias while still pointed at the gateway. The API key goes too — forwarding it leaves the sandbox holding two competing credentials, which is the ambiguity this mode exists to remove.
func (Config) PanelModels ¶
PanelModels is what the panel asks for, empty when the shipped default is right. Gated on BaseURL, not on ModelEnv alone: naming a model to pick a cheaper judge against Anthropic's own API must not change the panel, because a changed panel splits the score trend. A subscription panel is empty for the opposite reason — it serves Anthropic's aliases, not a gateway's ids.