Documentation
¶
Overview ¶
Package setup wires catalog-backed deployment routing for hawk and graycode-router CLIs.
Index ¶
- func CloneStringMap(in map[string]string) map[string]string
- func ConfiguredDeploymentAdapters(cfg *config.ProviderConfig) map[string]router.DeploymentAdapter
- func ConfiguredDeployments(cfg *config.ProviderConfig) map[string]config.DeploymentConfig
- func DefaultDeploymentForProvider(provider string) string
- func DeploymentConfigFromProviderState(cfg *config.ProviderConfig, provider string) config.DeploymentConfig
- func DeploymentProvider(ctx context.Context, cfg *config.ProviderConfig) (client.Provider, error)
- func DeploymentProviderFromCatalog(cfg *config.ProviderConfig, compiled *catalog.CompiledCatalog) (client.Provider, error)
- func DeploymentProviderFromState(cfg *config.ProviderConfig, compiled *catalog.CompiledCatalog) (client.Provider, error)
- func DeploymentRoutingFromState(cfg *config.ProviderConfig) bool
- func DiscoverModelCatalog(ctx context.Context, creds catalog.Credentials) (*catalog.RefreshResult, error)
- func DiscoverModelCatalogWithOptions(ctx context.Context, creds catalog.Credentials, ...) (*catalog.RefreshResult, error)
- func DiscoverProviderCatalog(ctx context.Context, providerID string, creds catalog.Credentials) (*catalog.RefreshResult, error)
- func FirstNonEmpty(values ...string) string
- func FormatStatus(report StatusReport) string
- func LoadCompiledCatalog(ctx context.Context) (*catalog.CompiledCatalog, error)
- func ProviderForDeployment(id string, deployment config.DeploymentConfig) (client.Provider, bool)
- func ProviderForDeploymentFromState(id string, deployment config.DeploymentConfig, cfg *config.ProviderConfig) (client.Provider, bool)
- func ProviderIDForDeployment(compiled *catalog.CompiledCatalog, deploymentID string) string
- func RouterRoutingPolicy(policy *config.RoutingPolicy) router.RoutingPolicy
- func RouterRoutingStageMap(in map[string][]config.RoutingStage) map[string][]router.RoutingStage
- func RouterRoutingStages(stages []config.RoutingStage) []router.RoutingStage
- func RoutingPreview(ctx context.Context, model string) (string, error)
- func RoutingPreviewFromPaths(ctx context.Context, model, providerConfigPath, catalogCachePath string) (string, error)
- func SaveProviderConfigV2(cfg *config.ProviderConfig) error
- func UseDeploymentRouting(cfg *config.ProviderConfig) bool
- type ApplyCredentialsResult
- type DiscoverModelCatalogOptions
- type ModelUI
- type ProviderUI
- type SetupUI
- type StatusReport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneStringMap ¶
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 flat provider.json config.
func DefaultDeploymentForProvider ¶
DefaultDeploymentForProvider resolves the default deployment for a logical provider name from the provider registry. New providers need no setup-side mapping.
func DeploymentConfigFromProviderState ¶
func DeploymentConfigFromProviderState(cfg *config.ProviderConfig, provider string) config.DeploymentConfig
DeploymentConfigFromProviderState reads API keys and base URLs from flat provider.json fields via the provider registry.
func DeploymentProvider ¶
DeploymentProvider builds a catalog-aware router over configured deployments.
func DeploymentProviderFromCatalog ¶
func DeploymentProviderFromCatalog(cfg *config.ProviderConfig, compiled *catalog.CompiledCatalog) (client.Provider, error)
DeploymentProviderFromCatalog is the ambient compatibility constructor. It may consult the default store, process environment, and flat-config detection. Host integrations must use DeploymentProviderFromState instead.
func DeploymentProviderFromState ¶
func DeploymentProviderFromState(cfg *config.ProviderConfig, compiled *catalog.CompiledCatalog) (client.Provider, error)
DeploymentProviderFromState builds a router exclusively from the supplied provider state. It never reads the default credential store, process environment, process-default provider path, or flat-config detection. Host-facing Engine code must use this strict constructor.
func DeploymentRoutingFromState ¶
func DeploymentRoutingFromState(cfg *config.ProviderConfig) bool
DeploymentRoutingFromState reports routing state without consulting process environment. Host-facing Engine code must use this pure form.
func DiscoverModelCatalog ¶
func DiscoverModelCatalog(ctx context.Context, creds catalog.Credentials) (*catalog.RefreshResult, error)
DiscoverModelCatalog refreshes the remote graycode-router catalog and enriches it using the supplied API keys. Pass config.DiscoveryCredentials(ctx) or explicit keys; graycode-router 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 ¶
FirstNonEmpty returns the first non-empty trimmed string.
func FormatStatus ¶
func FormatStatus(report StatusReport) string
FormatStatus renders StatusReport for terminal output.
func LoadCompiledCatalog ¶
func LoadCompiledCatalog(ctx context.Context) (*catalog.CompiledCatalog, error)
LoadCompiledCatalog returns the compiled catalog from cache/embedded data without network refresh.
func ProviderForDeployment ¶
ProviderForDeployment constructs one adapter with ambient compatibility fallbacks. Host integrations must use ProviderForDeploymentFromState.
func ProviderForDeploymentFromState ¶
func ProviderForDeploymentFromState(id string, deployment config.DeploymentConfig, cfg *config.ProviderConfig) (client.Provider, bool)
ProviderForDeploymentFromState constructs exactly one adapter without any process-global credential, environment, OIDC, or provider-config fallback.
func ProviderIDForDeployment ¶
func ProviderIDForDeployment(compiled *catalog.CompiledCatalog, 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 ¶
RoutingPreview returns JSON describing effective routing for a model ID.
func RoutingPreviewFromPaths ¶
func RoutingPreviewFromPaths(ctx context.Context, model, providerConfigPath, catalogCachePath string) (string, error)
RoutingPreviewFromPaths resolves routing from host-owned state paths. Empty paths retain the process defaults for backwards compatibility.
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 graycode-router 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 graycode-router 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.CompiledCatalog, 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 (graycode-router provider status).
func DeploymentStatus ¶
func DeploymentStatus(ctx context.Context, activeModel string) (StatusReport, error)
DeploymentStatus builds a status report for CLI and agent diagnostics.
func DeploymentStatusFromPaths ¶
func DeploymentStatusFromPaths(ctx context.Context, activeModel, providerConfigPath, catalogCachePath string) (StatusReport, error)
DeploymentStatusFromPaths builds a status report from host-owned state. Empty paths retain the process defaults for backwards compatibility.