Documentation
¶
Overview ¶
Package endpoint owns the set of model endpoints nib can talk to — the config.yaml default, the named endpoints config.yaml declares, and the built-in provider registry — and the rule that decides which one a new session starts on. It holds no session state and makes no request, so the precedence rule is testable on its own.
Index ¶
Constants ¶
const DefaultID = "config"
DefaultID is the ID of config.yaml's top-level block.
const DefaultName = "config.yaml"
DefaultName is how the default endpoint is shown.
const NamedPrefix = "@"
NamedPrefix marks a config.yaml named endpoint, so no yaml name can ever shadow (or be shadowed by) a registry provider ID.
Variables ¶
This section is empty.
Functions ¶
func WriteSaved ¶
WriteSaved records the pick atomically, creating the directory if needed. An empty path is a no-op, mirroring LoadSaved's treatment of "": a Session built without a state directory (as some low-level tests do) has nowhere to persist to, and must not go writing a stray file into the process's working directory instead.
Types ¶
type Entry ¶
type Entry struct {
ID string // DefaultID, "@name", or a registry provider ID
Name string // display name
Kind Kind
// Model is what this entry would run, empty when it must be picked.
Model string
// Status is a short human description: an address, or a login state.
Status string
// Ready means requests can authenticate right now.
Ready bool
// Stored means a /login credential exists (so /logout can remove it).
Stored bool
// NeedsBaseURL means logging in must also collect an endpoint.
NeedsBaseURL bool
// EnvVar is the environment variable that can hold the key instead.
EnvVar string
// Def is the registry definition; the zero value for yaml entries.
Def provider.Definition
}
Entry is one row of the endpoint picker.
type Saved ¶
type Saved struct {
ID string `json:"id"`
Model string `json:"model"`
// Provider is the pre-endpoints field name, read for backward
// compatibility and never written. An install saved before named
// endpoints carries a registry ID here.
Provider string `json:"provider,omitempty"`
}
Saved is the endpoint a previous session picked, kept next to credentials.json so the next session starts on it. It is nib-managed state rather than a config.yaml edit: config.yaml keeps describing its own endpoints, and nib never writes to it.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the resolved collection of endpoints for one config.
func New ¶
New builds the set. The returned errors are the rejected yaml endpoints, for the caller to show; the set itself is always usable.
func (*Set) Config ¶
func (s *Set) Config(id string) (types.ModelProviderConfig, error)
Config resolves an entry to the connection config a client is built from.
func (*Set) List ¶
List returns the default endpoint, the named endpoints in file order, then the provider registry in its display order.
func (*Set) Startup ¶
Startup resolves the endpoint a new session starts on: the saved pick when it still resolves, otherwise the config.yaml default. The third return is a user-visible note, non-empty only when a saved pick had to be dropped — silently changing the model between sessions is what this replaces.