runtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package runtime is the **recommended entry point** for host applications (e.g. hawk). Start by calling runtime.Load to get a *Runtime, then rt.ChatProvider to obtain a client.Provider that you can hand to your agent loop.

Note: the "stable" surface of eyrie is actually a set of cooperating subpackages, not just this one. The full list hawk (and other host applications) actually import is:

github.com/GrayCodeAI/eyrie/runtime          (this package — bootstrap facade)
github.com/GrayCodeAI/eyrie/client           (Provider interface, message/response types)
github.com/GrayCodeAI/eyrie/catalog         (model catalog: pricing, capabilities, registry)
github.com/GrayCodeAI/eyrie/catalog/registry (ProviderSpec catalog: 16 registered providers)
github.com/GrayCodeAI/eyrie/catalog/xiaomi  (Xiaomi-specific catalog helpers)
github.com/GrayCodeAI/eyrie/config          (provider config + env var resolution)
github.com/GrayCodeAI/eyrie/credentials     (OS keyring + OIDC keyless CI auth)
github.com/GrayCodeAI/eyrie/setup           (CLI/setup wiring, RoutingPreviewJSON)
github.com/GrayCodeAI/eyrie/storage         (conversation DAG persistence)

They are all considered part of the public API; changes to exported names are gated by semver. Anything under internal/ is implementation detail and may change without notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveModel

func ActiveModel(ctx context.Context) string

ActiveModel returns the selected model from provider.json.

func ActiveProvider

func ActiveProvider(ctx context.Context) string

ActiveProvider returns the selected provider from provider.json.

func AllModelIDs

func AllModelIDs(ctx context.Context) ([]string, error)

AllModelIDs returns every canonical model ID in the catalog (sorted).

func ClearActiveSelection

func ClearActiveSelection(ctx context.Context) error

ClearActiveSelection removes active provider/model from provider.json.

func CommitCredential

func CommitCredential(ctx context.Context, inference CredentialInference, secret string) error

CommitCredential runs format + provider validation + probe (no persistence).

func DefaultModelProviderFilter

func DefaultModelProviderFilter(ctx context.Context) string

DefaultModelProviderFilter returns the catalog provider id to use when listing models with no explicit provider (e.g. /config model picker after paste-key). Order: provider.json default → first configured deployment (stable sort by id).

func DefaultPaths

func DefaultPaths() (catalogPath, providerPath string)

DefaultPaths reports standard eyrie paths on disk.

func FormatPreflightReport

func FormatPreflightReport(r PreflightReport) string

FormatPreflightReport returns human-readable preflight output.

func FormatSetupError

func FormatSetupError(providerID string, err error) error

FormatSetupError maps provider setup failures to user-facing hints.

func ModelsForProvider

func ModelsForProvider(ctx context.Context, provider string) ([]catalog.ModelCatalogEntry, error)

ModelsForProvider loads the catalog cache and returns models for provider. Prefer ListModels for host UIs (registry-aware live vs cache).

func PrimaryAPIKeyEnv

func PrimaryAPIKeyEnv(deploymentID string) string

PrimaryAPIKeyEnv returns the main env var for a deployment ID from the catalog.

func ProbeCredential

func ProbeCredential(ctx context.Context, envKey, secret string) error

ProbeCredential validates a key against the provider HTTP API.

func ProviderIDForDeployment

func ProviderIDForDeployment(deploymentID string) string

ProviderIDForDeployment maps a deployment id to catalog provider id.

func SaveCredential

func SaveCredential(ctx context.Context, inference CredentialInference, secret string) error

SaveCredential validates, stores in the OS secret store, then probes the provider API. The key is persisted before the probe so a network or auth failure does not discard user input.

func SetActiveModel

func SetActiveModel(ctx context.Context, modelID string) error

SetActiveModel persists the user's model choice to provider.json.

func SetActiveProvider

func SetActiveProvider(ctx context.Context, provider string) error

SetActiveProvider persists active_provider to provider.json.

func SetCredential

func SetCredential(ctx context.Context, envKey, secret string) error

SetCredential stores a provider secret (env var name + value). Never log the secret argument.

func SetupUIFromCatalog

func SetupUIFromCatalog(ctx context.Context, providerFilter string) (*setup.SetupUI, error)

SetupUIFromCatalog builds provider/model picker rows from the current catalog cache.

func ValidateKeyFormat

func ValidateKeyFormat(secret string) error

ValidateKeyFormat rejects empty/placeholder keys before provider selection.

Types

type ApplyResult

type ApplyResult struct {
	Catalog      *catalog.RefreshResult
	Provider     *config.ProviderConfig
	ProviderPath string
	RoutingJSON  string
	Setup        *setup.SetupUI
}

ApplyResult summarizes an Apply call.

func Apply

func Apply(ctx context.Context, creds catalog.Credentials) (*ApplyResult, error)

Apply discovers the model catalog and writes ~/.eyrie/provider.json (routing only; secrets stay in env).

func Discover

func Discover(ctx context.Context) (*ApplyResult, error)

Discover runs a full catalog refresh then reloads runtime state.

type CredentialInference

type CredentialInference = config.CredentialInference

Credential types re-exported for host apps.

func InferCredentialsFromAPIKey

func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference

InferCredentialsFromAPIKey is deprecated; use InferenceForProvider after gateway selection.

func InferenceForProvider

func InferenceForProvider(providerID string) (CredentialInference, error)

InferenceForProvider returns save metadata for a gateway selected in setup UI.

func LocalCredentialInference

func LocalCredentialInference(providerID string) (CredentialInference, error)

LocalCredentialInference returns setup metadata for no-key providers.

type CredentialProviderOption

type CredentialProviderOption = config.CredentialProviderOption

Credential types re-exported for host apps.

func ListCredentialProviders

func ListCredentialProviders() []CredentialProviderOption

ListCredentialProviders returns all registry providers for setup UIs.

type CredentialResolveResult

type CredentialResolveResult = config.CredentialResolveResult

Credential types re-exported for host apps.

func ResolveCredential

func ResolveCredential(ctx context.Context, secret string) CredentialResolveResult

ResolveCredential validates format and lists registered providers (gateway must be chosen first).

type CredentialTarget

type CredentialTarget struct {
	ProviderID   string
	DeploymentID string
	EnvVar       string
	Set          bool
}

CredentialTarget is one API key slot in a host /config UI.

type DeploymentRow

type DeploymentRow struct {
	ID         string
	Name       string
	ProviderID string
	Configured bool
	Status     string
	PrimaryEnv string
}

DeploymentRow is a deployment plus env credential status.

type ListModelSource

type ListModelSource string

ListModelSource selects cache vs live model listing.

const (
	ListSourceAuto  ListModelSource = "auto"
	ListSourceCache ListModelSource = "cache"
	ListSourceLive  ListModelSource = "live"
)

type ListModelsOpts

type ListModelsOpts struct {
	ProviderID string
	Source     ListModelSource
	Refresh    bool
}

ListModelsOpts configures unified model listing for host UIs.

type ModelEntry

type ModelEntry struct {
	ID               string  `json:"id"`
	DisplayName      string  `json:"display_name"`
	Owner            string  `json:"owner,omitempty"`
	ProviderID       string  `json:"provider_id"`
	ContextWindow    int     `json:"context_window,omitempty"`
	InputPricePer1M  float64 `json:"input_price_per_1m,omitempty"`
	OutputPricePer1M float64 `json:"output_price_per_1m,omitempty"`
	Source           string  `json:"source"`
	Installed        bool    `json:"installed,omitempty"`
}

ModelEntry is one row for host model pickers.

func ListModels

func ListModels(ctx context.Context, opts ListModelsOpts) ([]ModelEntry, error)

ListModels returns models for a provider using registry-driven source selection.

type PreflightCheck

type PreflightCheck struct {
	Name   string          `json:"name"`
	Status PreflightStatus `json:"status"`
	Detail string          `json:"detail"`
}

PreflightCheck is one readiness row.

type PreflightReport

type PreflightReport struct {
	Ready  bool             `json:"ready"`
	Checks []PreflightCheck `json:"checks"`
}

PreflightReport summarizes whether hawk can chat.

func Preflight

func Preflight(ctx context.Context) PreflightReport

Preflight evaluates catalog, credentials, model selection, and optional live model access.

type PreflightStatus

type PreflightStatus string

PreflightStatus is ok, warn, or fail.

const (
	PreflightOK   PreflightStatus = "ok"
	PreflightWarn PreflightStatus = "warn"
	PreflightFail PreflightStatus = "fail"
)

type ProviderSetupOption

type ProviderSetupOption struct {
	Action string `json:"action"`
	Label  string `json:"label"`
}

ProviderSetupOption is one hub row in host /config.

func ListProviderSetupOptions

func ListProviderSetupOptions(ctx context.Context) []ProviderSetupOption

ListProviderSetupOptions returns hub rows for host /config UIs.

type Runtime

type Runtime struct {
	Catalog      *catalog.CompiledCatalogV1
	Provider     *config.ProviderConfig
	ProviderPath string
}

Runtime is a loaded eyrie control plane: catalog cache + routing + env-backed credentials.

func Load

func Load(ctx context.Context) (*Runtime, error)

Load reads the on-disk catalog and provider config without network refresh.

func (*Runtime) ChatProvider

func (r *Runtime) ChatProvider(ctx context.Context) (client.Provider, error)

ChatProvider builds the LLM client (deployment router when configured).

func (*Runtime) CredentialTargets

func (r *Runtime) CredentialTargets() []CredentialTarget

CredentialTargets lists provider-facing API key env vars for simple UIs.

func (*Runtime) DeploymentRows

func (r *Runtime) DeploymentRows() ([]DeploymentRow, error)

DeploymentRows lists deployments with credential status from env (not from provider.json secrets).

func (*Runtime) ModelEntriesForProvider

func (r *Runtime) ModelEntriesForProvider(provider string) []catalog.ModelCatalogEntry

ModelEntriesForProvider returns models for a provider from this runtime's catalog snapshot.

func (*Runtime) ModelIDs

func (r *Runtime) ModelIDs() []string

ModelIDs returns sorted canonical model IDs from the catalog.

func (*Runtime) ProviderConfigJSON

func (r *Runtime) ProviderConfigJSON() (string, error)

ProviderConfigJSON returns provider.json as indented JSON.

func (*Runtime) RoutingPreviewJSON

func (r *Runtime) RoutingPreviewJSON(model string) (string, error)

RoutingPreviewJSON returns effective routing for a model ID.

Jump to

Keyboard shortcuts

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