setup

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package setup wires catalog-backed deployment routing for hawk and eyrie CLIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneStringMap

func CloneStringMap(in map[string]string) map[string]string

CloneStringMap returns a shallow copy of m.

func ConfiguredDeploymentAdapters

func ConfiguredDeploymentAdapters(cfg *config.ProviderConfig) map[string]router.DeploymentAdapter

ConfiguredDeploymentAdapters maps deployment IDs to live provider clients.

func ConfiguredDeployments

func ConfiguredDeployments(cfg *config.ProviderConfig) map[string]config.DeploymentConfig

ConfiguredDeployments merges explicit deployments with legacy single-provider config.

func DefaultDeploymentForProvider

func DefaultDeploymentForProvider(provider string) string

DefaultDeploymentForProvider maps a logical provider name to a deployment ID.

func DeploymentProvider

func DeploymentProvider(ctx context.Context, cfg *config.ProviderConfig) (client.Provider, error)

DeploymentProvider builds a catalog-aware router over configured deployments.

func DiscoverModelCatalog

func DiscoverModelCatalog(ctx context.Context, creds catalog.Credentials) (*catalog.RefreshResult, error)

DiscoverModelCatalog refreshes the remote eyrie catalog and enriches it using the supplied API keys. Pass config.DiscoveryCredentials(ctx) or explicit keys; eyrie owns all model metadata.

func DiscoverModelCatalogWithOptions

func DiscoverModelCatalogWithOptions(ctx context.Context, creds catalog.Credentials, opts DiscoverModelCatalogOptions) (*catalog.RefreshResult, error)

DiscoverModelCatalogWithOptions runs discover with optional force refresh (manual hawk models refresh).

func DiscoverProviderCatalog

func DiscoverProviderCatalog(ctx context.Context, providerID string, creds catalog.Credentials) (*catalog.RefreshResult, error)

DiscoverProviderCatalog fetches live models for one provider after API key setup.

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

FirstNonEmpty returns the first non-empty trimmed string.

func FormatStatus

func FormatStatus(report StatusReport) string

FormatStatus renders StatusReport for terminal output.

func LegacyDeploymentConfig

func LegacyDeploymentConfig(cfg *config.ProviderConfig, provider string) config.DeploymentConfig

LegacyDeploymentConfig reads API keys from flat provider.json fields.

func LoadCompiledCatalog

func LoadCompiledCatalog(ctx context.Context) (*catalog.CompiledCatalogV1, error)

LoadCompiledCatalog returns the compiled catalog from cache/embedded data without network refresh.

func ProviderForDeployment

func ProviderForDeployment(id string, deployment config.DeploymentConfig) (client.Provider, bool)

ProviderForDeployment constructs the API client for a catalog deployment ID.

func ProviderIDForDeployment

func ProviderIDForDeployment(compiled *catalog.CompiledCatalogV1, deploymentID string) string

ProviderIDForDeployment resolves catalog provider id for a deployment id.

func RouterRoutingPolicy

func RouterRoutingPolicy(policy *config.RoutingPolicy) router.RoutingPolicy

RouterRoutingPolicy converts config routing JSON into router policy.

func RouterRoutingStageMap

func RouterRoutingStageMap(in map[string][]config.RoutingStage) map[string][]router.RoutingStage

RouterRoutingStageMap converts per-key routing stages.

func RouterRoutingStages

func RouterRoutingStages(stages []config.RoutingStage) []router.RoutingStage

RouterRoutingStages converts config stages to router stages.

func RoutingPreview

func RoutingPreview(ctx context.Context, model string) (string, error)

RoutingPreview returns JSON describing effective routing for a model ID.

func SaveProviderConfigV2

func SaveProviderConfigV2(cfg *config.ProviderConfig) error

SaveProviderConfigV2 writes migrated provider config when upgraded in memory.

func UseDeploymentRouting

func UseDeploymentRouting(cfg *config.ProviderConfig) bool

UseDeploymentRouting mirrors eyrie CLI behavior: env override, then provider.json shape.

Types

type ApplyCredentialsResult

type ApplyCredentialsResult struct {
	Catalog            *catalog.RefreshResult
	ProviderConfig     *config.ProviderConfig
	ProviderConfigPath string
	RoutingJSON        string
	Setup              *SetupUI
}

ApplyCredentialsResult is the full eyrie response after API keys are applied: refreshed catalog, provider.json (deployments + routing), and paths.

func ApplyCredentials

func ApplyCredentials(ctx context.Context, creds catalog.Credentials) (*ApplyCredentialsResult, error)

ApplyCredentials discovers the model catalog from env API keys, then writes ~/.hawk/provider.json deployments and routing derived from the catalog.

func ApplyCredentialsForProvider

func ApplyCredentialsForProvider(ctx context.Context, providerID string, creds catalog.Credentials) (*ApplyCredentialsResult, error)

ApplyCredentialsForProvider discovers models for one provider after key setup, then updates routing.

type DiscoverModelCatalogOptions

type DiscoverModelCatalogOptions struct {
	// ForceRefresh re-fetches the published remote catalog and all live provider APIs.
	ForceRefresh bool
}

DiscoverModelCatalogOptions controls catalog discovery behavior.

type ModelUI

type ModelUI struct {
	CanonicalID string `json:"canonical_id"`
	DisplayName string `json:"display_name"`
	Source      string `json:"source,omitempty"` // "remote", "live", or "remote+live"
}

ModelUI is one selectable model for host /config UIs.

type ProviderUI

type ProviderUI struct {
	ID          string    `json:"id"`
	DisplayName string    `json:"display_name"`
	Models      []ModelUI `json:"models"`
}

ProviderUI is a provider and its models after credential apply.

type SetupUI

type SetupUI struct {
	Providers []ProviderUI `json:"providers"`
}

SetupUI is JSON-safe metadata returned to hawk (no secrets).

func BuildSetupUI

func BuildSetupUI(compiled *catalog.CompiledCatalogV1, providerFilter string) *SetupUI

BuildSetupUI lists models per provider from the compiled catalog. If providerFilter is non-empty, only that provider is included.

type StatusReport

type StatusReport struct {
	DeploymentRouting  bool
	ProviderConfig     string
	ConfigVersion      int
	Configured         []string
	CatalogCache       string
	CatalogExists      bool
	CatalogModified    time.Time
	CatalogStale       bool
	CatalogModels      int
	CatalogDeployments int
	CatalogOfferings   int
	ActiveModel        string
	RoutingSource      string
	RoutingStages      int
}

StatusReport summarizes deployment routing readiness (eyrie provider status).

func DeploymentStatus

func DeploymentStatus(ctx context.Context, activeModel string) (StatusReport, error)

DeploymentStatus builds a status report for CLI and agent diagnostics.

Jump to

Keyboard shortcuts

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