modelcatalog

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLiveDiscoveryTimeout allows cold ACP subprocess initialization.
	DefaultLiveDiscoveryTimeout = 60 * time.Second
	// DefaultLiveDiscoveryTTL is the refresh interval for dynamic provider and extension discovery.
	DefaultLiveDiscoveryTTL = 5 * time.Minute
)
View Source
const (
	// ReasoningEffortNone disables model reasoning explicitly.
	ReasoningEffortNone = reasoning.EffortNone
	// ReasoningEffortMinimal is the smallest non-zero reasoning level.
	ReasoningEffortMinimal = reasoning.EffortMinimal
	// ReasoningEffortLow is the low reasoning level.
	ReasoningEffortLow = reasoning.EffortLow
	// ReasoningEffortMedium is the medium reasoning level.
	ReasoningEffortMedium = reasoning.EffortMedium
	// ReasoningEffortHigh is the high reasoning level.
	ReasoningEffortHigh = reasoning.EffortHigh
	// ReasoningEffortXHigh is the extra-high reasoning level.
	ReasoningEffortXHigh = reasoning.EffortXHigh
	// ReasoningEffortMax requests the provider's maximum supported reasoning level.
	ReasoningEffortMax = reasoning.EffortMax
	// ReasoningEffortUltra requests the provider's ultra reasoning level when advertised.
	ReasoningEffortUltra = reasoning.EffortUltra
)
View Source
const (
	// SourceIDBuiltin is Compozy's offline bootstrap catalog source.
	SourceIDBuiltin = "builtin"
	// SourceIDConfig is the operator-authored provider config source.
	SourceIDConfig = "config"
	// SourceIDModelsDev is the models.dev catalog source.
	SourceIDModelsDev = "models_dev"
)
View Source
const (
	// PriorityConfig lets explicit operator config win source conflicts.
	PriorityConfig = 120
	// PriorityProviderLive ranks live provider data above extension rows.
	PriorityProviderLive = 110
	// PriorityExtension ranks extension-provided rows above catalog enrichment.
	PriorityExtension = 100
	// PriorityModelsDev ranks models.dev as catalog enrichment.
	PriorityModelsDev = 50
	// PriorityBuiltin ranks offline bootstrap rows last.
	PriorityBuiltin = 10
)

Variables

View Source
var (
	// ErrAllSourcesFailed reports that refresh could not produce usable rows.
	ErrAllSourcesFailed = errors.New("model catalog: all usable sources failed")
	// ErrSourceDisabled reports that a source is intentionally disabled.
	ErrSourceDisabled = errors.New("model catalog: source disabled")
	// ErrSourceNotRegistered reports that a requested source id is not registered.
	ErrSourceNotRegistered = errors.New("model catalog: source not registered")
)

Functions

func CatalogExecutionFingerprint

func CatalogExecutionFingerprint(parts ...string) string

CatalogExecutionFingerprint hashes non-secret execution inputs without persisting their contents.

func CostSourceValues

func CostSourceValues() []string

CostSourceValues returns the closed public cost-source enum.

func CostStatusValues

func CostStatusValues() []string

CostStatusValues returns the closed public cost-status enum.

func HasFreshTransportBinding

func HasFreshTransportBinding(model Model, now time.Time) bool

HasFreshTransportBinding applies the admission cache's ten-minute reuse window.

func IsPermanentSourceFailure

func IsPermanentSourceFailure(err error) bool

IsPermanentSourceFailure identifies failures requiring a config, credential, binary, or login change.

func IsValidEffort

func IsValidEffort(value string) bool

IsValidEffort reports whether value is a well-formed explicit effort identifier. Empty is deliberately invalid here: it is the separate provider-default sentinel.

func NormalizeExtensionSourceSlug

func NormalizeExtensionSourceSlug(extensionName string) (string, error)

NormalizeExtensionSourceSlug converts an extension name into the dynamic source-id slug.

func NormalizeReleaseDate

func NormalizeReleaseDate(value string) (*string, error)

NormalizeReleaseDate validates and normalizes YYYY-MM or YYYY-MM-DD metadata.

func ReasoningEffortValues

func ReasoningEffortValues() []string

ReasoningEffortValues returns the canonical explicit effort vocabulary in display order.

func ReasoningSourceValues

func ReasoningSourceValues() []string

ReasoningSourceValues returns the canonical reasoning provenance vocabulary.

func RedactString

func RedactString(value string) string

RedactString removes secret-shaped values from catalog errors.

func RequiresLiveTransportBinding

func RequiresLiveTransportBinding(runtimeProvider, modelID string) bool

RequiresLiveTransportBinding keeps catalog selection aligned with session admission.

func SourceKindExtensionID

func SourceKindExtensionID(extensionName string) (string, error)

SourceKindExtensionID returns the stable source id for an extension model source.

func SourceKindProviderLiveID

func SourceKindProviderLiveID(providerID string) string

SourceKindProviderLiveID returns the stable source id for a live provider source.

func ValidateModelOptionSelection

func ValidateModelOptionSelection(selection ModelOptionSelection) error

ValidateModelOptionSelection enforces the typed selection invariant.

func ValidateSourceID

func ValidateSourceID(sourceID string) error

ValidateSourceID checks a stable catalog source identity.

func ValidateSourceIdentity

func ValidateSourceIdentity(sourceID string, kind SourceKind) error

ValidateSourceIdentity checks that a source id and kind describe the same source family.

Types

type ACPModelProbe

type ACPModelProbe interface {
	InspectModels(context.Context, ACPModelProbeRequest) (acp.SessionModelInspection, error)
}

ACPModelProbe reads model options advertised by a short-lived ACP session.

type ACPModelProbeRequest

type ACPModelProbeRequest struct {
	ProviderID string
	Command    string
	Cwd        string
	Env        []string
	Timeout    time.Duration
}

ACPModelProbeRequest captures one provider ACP discovery invocation.

type AppServerCodexModelProbe

type AppServerCodexModelProbe struct{}

AppServerCodexModelProbe uses a short-lived app server without creating a thread.

func (AppServerCodexModelProbe) InspectCodexModels

func (AppServerCodexModelProbe) InspectCodexModels(
	ctx context.Context, req DiscoveryCommandRequest,
) (_ []CodexModelMetadata, err error)

InspectCodexModels reads every page and joins the managed subprocess on every exit.

type AvailabilityState

type AvailabilityState string

AvailabilityState identifies how reliable the merged availability signal is.

const (
	// AvailabilityStateAvailableLive means a fresh live source reports availability.
	AvailabilityStateAvailableLive AvailabilityState = "available_live"
	// AvailabilityStateAvailableStale means a stale live source reports availability.
	AvailabilityStateAvailableStale AvailabilityState = "available_stale"
	// AvailabilityStateUnavailableLive means a fresh live source reports unavailability.
	AvailabilityStateUnavailableLive AvailabilityState = "unavailable_live"
	// AvailabilityStateUnavailableStale means a stale live source reports unavailability.
	AvailabilityStateUnavailableStale AvailabilityState = "unavailable_stale"
	// AvailabilityStateUnknown means no live or extension source reported availability.
	AvailabilityStateUnknown AvailabilityState = "unknown"
)

type CatalogExecutionContext

type CatalogExecutionContext struct {
	Scope              ExecutionScope
	ProfileID          string
	WorkspaceID        string
	CommandFingerprint string
}

CatalogExecutionContext isolates catalog observations produced by one runtime environment. CommandFingerprint is required for non-global contexts before persistence.

func GlobalCatalogExecutionContext

func GlobalCatalogExecutionContext() CatalogExecutionContext

GlobalCatalogExecutionContext returns the sole context for provider-independent sources.

func NormalizeCatalogExecutionScope

func NormalizeCatalogExecutionScope(value CatalogExecutionContext) (CatalogExecutionContext, error)

NormalizeCatalogExecutionScope validates an execution scope before source-specific fingerprinting.

func NormalizePersistedExecutionContext

func NormalizePersistedExecutionContext(value CatalogExecutionContext) (CatalogExecutionContext, error)

NormalizePersistedExecutionContext validates a source context that is ready for persistence.

func (CatalogExecutionContext) ID

ID returns a stable, non-sensitive database key for the normalized context.

func (CatalogExecutionContext) WithCommandFingerprint

func (c CatalogExecutionContext) WithCommandFingerprint(fingerprint string) (CatalogExecutionContext, error)

WithCommandFingerprint binds a source fingerprint to a profile or workspace scope.

type CatalogService

type CatalogService struct {
	// contains filtered or unexported fields
}

CatalogService refreshes sources and projects stored model catalog rows.

func NewService

func NewService(store Store, sources []Source, mergeOptions MergeOptions) (*CatalogService, error)

NewService creates a model catalog service from a store and source list.

func (*CatalogService) CommitRefreshPlan

func (s *CatalogService) CommitRefreshPlan(ctx context.Context, plan *RefreshPlan) error

CommitRefreshPlan atomically publishes every staged source replacement.

func (*CatalogService) ListModels

func (s *CatalogService) ListModels(ctx context.Context, opts ListOptions) ([]Model, error)

ListModels returns the merged catalog projection.

func (*CatalogService) ListSourceStatus

func (s *CatalogService) ListSourceStatus(ctx context.Context, opts StatusOptions) ([]SourceStatus, error)

ListSourceStatus returns provider-scoped source health rows.

func (*CatalogService) NewRefreshPlan

func (s *CatalogService) NewRefreshPlan() (*RefreshPlan, error)

NewRefreshPlan creates an isolated, read-through refresh generation.

func (*CatalogService) Refresh

func (s *CatalogService) Refresh(ctx context.Context, opts RefreshOptions) ([]SourceStatus, error)

Refresh updates registered sources and returns their latest statuses.

func (*CatalogService) SetDefaultExecutionContext

func (s *CatalogService) SetDefaultExecutionContext(value CatalogExecutionContext) error

SetDefaultExecutionContext defines the profile or workspace scope used when an internal caller omits an explicit catalog execution context.

func (*CatalogService) UpdateMergeOptions

func (s *CatalogService) UpdateMergeOptions(options MergeOptions)

UpdateMergeOptions replaces provider capability inputs for subsequent projections.

type CatalogView

type CatalogView string

CatalogView identifies the public catalog projection to return.

const (
	// CatalogViewCurated returns the default operator-facing model set.
	CatalogViewCurated CatalogView = "curated"
	// CatalogViewAll returns every current model, including hidden and deprecated rows.
	CatalogViewAll CatalogView = "all"
)

type CodexModelMetadata

type CodexModelMetadata struct {
	ID                        string `json:"id"`
	Model                     string `json:"model"`
	DisplayName               string `json:"displayName"`
	Hidden                    bool   `json:"hidden"`
	IsDefault                 bool   `json:"isDefault"`
	SupportedReasoningEfforts []struct {
		ReasoningEffort string `json:"reasoningEffort"`
	} `json:"supportedReasoningEfforts"`
	DefaultReasoningEffort string `json:"defaultReasoningEffort"`
}

CodexModelMetadata is the capability subset of the Codex model/list response.

type CodexModelProbe

type CodexModelProbe interface {
	InspectCodexModels(context.Context, DiscoveryCommandRequest) ([]CodexModelMetadata, error)
}

CodexModelProbe reads account-scoped model capabilities from the native Codex CLI.

type CostResult

type CostResult struct {
	Amount   float64
	Currency string
	Status   CostStatus
	Source   CostSource
}

CostResult is one truthful monetary projection for a usage update.

func EstimateCost

func EstimateCost(model *Model, usage TokenBuckets) (CostResult, bool)

EstimateCost joins usage with independent merged catalog rates for every token bucket.

type CostSource

type CostSource string

CostSource identifies the authority behind a cost result.

const (
	CostSourceAgentReported CostSource = "agent_reported"
	CostSourceCatalogConfig CostSource = "catalog_config"
	CostSourceModelsDev     CostSource = "models_dev"
	CostSourceBuiltin       CostSource = "builtin"
	CostSourceNone          CostSource = "none"
)

type CostStatus

type CostStatus string

CostStatus identifies how Compozy obtained a cost result.

const (
	CostStatusActual    CostStatus = "actual"
	CostStatusEstimated CostStatus = "estimated"
	CostStatusIncluded  CostStatus = "included"
	CostStatusUnknown   CostStatus = "unknown"
)

type DiscoveryCommandExecutor

type DiscoveryCommandExecutor interface {
	RunDiscoveryCommand(ctx context.Context, req DiscoveryCommandRequest) (DiscoveryCommandResult, error)
}

DiscoveryCommandExecutor runs a provider discovery command.

type DiscoveryCommandRequest

type DiscoveryCommandRequest struct {
	ProviderID string
	Command    string
	Args       []string
	Dir        string
	Env        []string
	Timeout    time.Duration
}

DiscoveryCommandRequest describes one timeout-bound discovery subprocess.

type DiscoveryCommandResult

type DiscoveryCommandResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

DiscoveryCommandResult captures safe subprocess output for parsing.

type EnvSecretResolver

type EnvSecretResolver struct {
	LookupEnv func(string) (string, bool)
}

EnvSecretResolver resolves env: secret refs from an environment lookup.

func (EnvSecretResolver) ResolveRef

func (r EnvSecretResolver) ResolveRef(ctx context.Context, ref string) (string, error)

ResolveRef resolves one env-backed provider credential ref.

type ExecDiscoveryCommandExecutor

type ExecDiscoveryCommandExecutor struct{}

ExecDiscoveryCommandExecutor runs discovery commands as subprocesses.

func (ExecDiscoveryCommandExecutor) RunDiscoveryCommand

RunDiscoveryCommand runs one subprocess with the caller-supplied deadline.

type ExecutionScope

type ExecutionScope string

ExecutionScope identifies the owner boundary for persisted catalog observations.

const (
	// ExecutionScopeGlobal owns provider-independent catalog data.
	ExecutionScopeGlobal ExecutionScope = "global"
	// ExecutionScopeProfile owns observations derived from one provider profile.
	ExecutionScopeProfile ExecutionScope = "profile"
	// ExecutionScopeWorkspace owns observations derived from one workspace runtime.
	ExecutionScopeWorkspace ExecutionScope = "workspace"
)

type InvalidReasoningEffortError

type InvalidReasoningEffortError struct {
	ProviderID string
	ModelID    string
	Field      string
	Effort     string
}

InvalidReasoningEffortError reports a non-canonical effort at a catalog source boundary.

func (*InvalidReasoningEffortError) Error

type InvalidViewError

type InvalidViewError struct {
	View string
}

InvalidViewError reports an unsupported public catalog view.

func (*InvalidViewError) Error

func (e *InvalidViewError) Error() string

type ListOptions

type ListOptions struct {
	ProviderID       string
	SourceID         string
	ExecutionContext CatalogExecutionContext
	// SourceContexts owns the resolved execution scope for each selected source ID.
	SourceContexts     map[string]CatalogExecutionContext
	View               CatalogView
	Refresh            bool
	SkipRefreshIfEmpty bool
	IncludeAll         bool
	IncludeStale       bool
	Now                time.Time
}

ListOptions filters persisted catalog source rows.

type LiveProviderSource

type LiveProviderSource struct {
	// contains filtered or unexported fields
}

LiveProviderSource performs provider model discovery for one provider.

func NewLiveProviderSource

func NewLiveProviderSource(
	providerID string,
	provider compozyconfig.ProviderConfig,
	cfg *LiveProviderSourcesConfig,
) (*LiveProviderSource, error)

NewLiveProviderSource creates one provider_live source.

func (*LiveProviderSource) BootstrapOnList

func (s *LiveProviderSource) BootstrapOnList() bool

BootstrapOnList reports whether the source should discover once before its first catalog projection.

func (*LiveProviderSource) CatalogExecutionFingerprint

func (s *LiveProviderSource) CatalogExecutionFingerprint() (string, error)

CatalogExecutionFingerprint identifies the effective live discovery invocation without storing secrets.

func (*LiveProviderSource) CloneWithProvider

func (s *LiveProviderSource) CloneWithProvider(
	provider compozyconfig.ProviderConfig,
) (*LiveProviderSource, bool, error)

CloneWithProvider copies a live source with a staged provider configuration.

func (*LiveProviderSource) DiscoveryPreflight

func (s *LiveProviderSource) DiscoveryPreflight(ctx context.Context) error

DiscoveryPreflight checks the effective discovery prerequisites without starting it or writing state.

func (*LiveProviderSource) DiscoveryTimeout

func (s *LiveProviderSource) DiscoveryTimeout() time.Duration

DiscoveryTimeout returns the configured deadline for this provider's live probe.

func (*LiveProviderSource) ID

func (s *LiveProviderSource) ID() string

ID returns the provider_live source id.

func (*LiveProviderSource) Kind

func (s *LiveProviderSource) Kind() SourceKind

Kind returns provider_live.

func (*LiveProviderSource) ListModels

func (s *LiveProviderSource) ListModels(ctx context.Context, opts ListOptions) ([]ModelRow, error)

ListModels discovers live provider models. ACP-capable native providers use the model options advertised by the same bridge command used for launch.

func (*LiveProviderSource) Priority

func (s *LiveProviderSource) Priority() int

Priority returns the provider_live merge priority.

func (*LiveProviderSource) ProviderIDs

func (s *LiveProviderSource) ProviderIDs() []string

ProviderIDs returns the single CompozyOS provider id this source owns.

func (*LiveProviderSource) ReplaceProvider

func (s *LiveProviderSource) ReplaceProvider(provider compozyconfig.ProviderConfig) bool

ReplaceProvider atomically applies the provider config used by subsequent discovery calls.

func (*LiveProviderSource) RetainContextPartitions

func (s *LiveProviderSource) RetainContextPartitions() bool

RetainContextPartitions keeps invocation-local history for adapters that forbid stale transfer.

func (*LiveProviderSource) TTL

func (s *LiveProviderSource) TTL() time.Duration

TTL returns the interval after which a catalog read should revalidate this live source in the background.

type LiveProviderSourcesConfig

type LiveProviderSourcesConfig struct {
	Providers       map[string]compozyconfig.ProviderConfig
	HomePaths       compozyconfig.HomePaths
	BaseEnv         []string
	SecretResolver  ProviderSecretResolver
	HTTPClient      *http.Client
	CommandExecutor DiscoveryCommandExecutor
	ACPProbe        ACPModelProbe
	CodexProbe      CodexModelProbe
	DefaultTimeout  time.Duration
	RefreshTTL      time.Duration
	WorkingDir      string
}

LiveProviderSourcesConfig configures built-in provider live discovery sources.

type MergeOptions

type MergeOptions struct {
	ReasoningApply map[string]bool
}

MergeOptions supplies provider capabilities needed to keep catalog claims truthful.

type Model

type Model struct {
	ProviderID               string
	ModelID                  string
	DisplayName              string
	Sources                  []SourceRef
	Available                *bool
	AvailabilityState        AvailabilityState
	Stale                    bool
	RefreshedAt              time.Time
	ContextWindow            *int64
	MaxInputTokens           *int64
	MaxOutputTokens          *int64
	SupportsTools            *bool
	SupportsReasoning        *bool
	ReasoningEfforts         []ReasoningEffort
	DefaultReasoningEffort   *ReasoningEffort
	ConfigOptions            []ModelOptionDescriptor
	TransportBindings        []ModelTransportBinding
	CostInputPerMillion      *float64
	CostOutputPerMillion     *float64
	CostCacheReadPerMillion  *float64
	CostCacheWritePerMillion *float64
	CostReasoningPerMillion  *float64
	CostInputSource          SourceKind
	CostOutputSource         SourceKind
	CostCacheReadSource      SourceKind
	CostCacheWriteSource     SourceKind
	CostReasoningSource      SourceKind
	ExplicitlyCurated        bool
	Curated                  bool
	Deprecated               bool
	Hidden                   bool
	Featured                 bool
	ReleaseDate              *string
	ReasoningSource          ReasoningSource
	ReasoningKnown           bool
	ReasoningApply           string
	LastError                string
}

Model is the deterministic merged projection for one provider/model key.

func MergeRows

func MergeRows(rows []ModelRow, opts MergeOptions) []Model

MergeRows computes deterministic model projections from source rows.

type ModelOptionDescriptor

type ModelOptionDescriptor struct {
	ID             string
	Label          string
	Description    string
	Category       string
	Kind           ModelOptionKind
	CurrentValueID string
	CurrentBool    *bool
	Values         []ModelOptionValue
}

ModelOptionDescriptor describes one provider model option and its current value.

func CloneModelOptionDescriptors

func CloneModelOptionDescriptors(options []ModelOptionDescriptor) []ModelOptionDescriptor

CloneModelOptionDescriptors returns an ownership-safe copy of model option descriptors.

type ModelOptionKind

type ModelOptionKind string

ModelOptionKind identifies the shape of a provider model option.

const (
	// ModelOptionKindSelect identifies an option with one selected value.
	ModelOptionKindSelect ModelOptionKind = "select"
	// ModelOptionKindBoolean identifies an option with a true or false value.
	ModelOptionKindBoolean ModelOptionKind = "boolean"
)

type ModelOptionSelection

type ModelOptionSelection struct {
	ID        string
	ValueID   string
	BoolValue *bool
}

ModelOptionSelection captures one typed option value associated with a model binding.

func CloneModelOptionSelections

func CloneModelOptionSelections(selections []ModelOptionSelection) []ModelOptionSelection

CloneModelOptionSelections returns an ownership-safe copy of model option selections.

type ModelOptionValue

type ModelOptionValue struct {
	ValueID     string
	Label       string
	Description string
	GroupID     string
	GroupLabel  string
	Order       int
}

ModelOptionValue describes one value advertised by a selectable model option.

type ModelRow

type ModelRow struct {
	ProviderID               string
	ModelID                  string
	DisplayName              string
	SourceID                 string
	SourceKind               SourceKind
	Priority                 int
	Available                *bool
	Stale                    bool
	RefreshedAt              time.Time
	ExpiresAt                time.Time
	ContextWindow            *int64
	MaxInputTokens           *int64
	MaxOutputTokens          *int64
	SupportsTools            *bool
	SupportsReasoning        *bool
	ReasoningEfforts         []ReasoningEffort
	DefaultReasoningEffort   *ReasoningEffort
	ConfigOptions            []ModelOptionDescriptor
	TransportBindings        []ModelTransportBinding
	CostInputPerMillion      *float64
	CostOutputPerMillion     *float64
	CostCacheReadPerMillion  *float64
	CostCacheWritePerMillion *float64
	CostReasoningPerMillion  *float64
	ExplicitlyCurated        bool
	Deprecated               *bool
	Hidden                   *bool
	Featured                 *bool
	ReleaseDate              *string
	LastError                string
}

ModelRow is one provider/model record contributed by one catalog source.

type ModelTransportBinding

type ModelTransportBinding struct {
	TransportModelID string
	Label            string
	ReasoningEffort  *ReasoningEffort
	Fast             *bool
	Thinking         *bool
	OptionSelections []ModelOptionSelection
	// ConfigOptions is the complete inspected snapshot for this transport, not a union.
	// Nil means unobserved; an empty non-nil slice means observed with no adjustable options.
	ConfigOptions []ModelOptionDescriptor
}

ModelTransportBinding maps one logical model configuration to its provider-owned identifier.

func PreferredTransportBinding

func PreferredTransportBinding(bindings []ModelTransportBinding) (ModelTransportBinding, bool)

PreferredTransportBinding uses the same stable route for catalog presentation and session launch. Provider defaults sort last; explicit configured transport IDs remain separate logical rows.

type ModelsDevSource

type ModelsDevSource struct {
	// contains filtered or unexported fields
}

ModelsDevSource fetches catalog enrichment from models.dev.

func NewModelsDevSource

func NewModelsDevSource(
	providers map[string]compozyconfig.ProviderConfig,
	cfg compozyconfig.ModelsDevSourceConfig,
	options ...ModelsDevSourceOption,
) (*ModelsDevSource, error)

NewModelsDevSource creates a configured models.dev source.

func (*ModelsDevSource) ID

func (s *ModelsDevSource) ID() string

func (*ModelsDevSource) Kind

func (s *ModelsDevSource) Kind() SourceKind

func (*ModelsDevSource) ListModels

func (s *ModelsDevSource) ListModels(ctx context.Context, opts ListOptions) ([]ModelRow, error)

func (*ModelsDevSource) Priority

func (s *ModelsDevSource) Priority() int

func (*ModelsDevSource) ProviderIDs

func (s *ModelsDevSource) ProviderIDs() []string

func (*ModelsDevSource) TTL

func (s *ModelsDevSource) TTL() time.Duration

func (*ModelsDevSource) Timeout

func (s *ModelsDevSource) Timeout() time.Duration

Timeout returns the explicit HTTP timeout used by the source.

type ModelsDevSourceOption

type ModelsDevSourceOption func(*ModelsDevSource)

ModelsDevSourceOption customizes models.dev source construction.

func WithModelsDevHTTPClient

func WithModelsDevHTTPClient(client *http.Client) ModelsDevSourceOption

WithModelsDevHTTPClient injects the explicit-timeout HTTP client used for models.dev fetches.

type ProviderConfigSource

type ProviderConfigSource struct {
	// contains filtered or unexported fields
}

ProviderConfigSource projects one replaceable provider-config snapshot.

func NewConfigSource

func NewConfigSource(providers map[string]compozyconfig.ProviderConfig) *ProviderConfigSource

NewConfigSource creates the operator config model source.

func (*ProviderConfigSource) ID

func (s *ProviderConfigSource) ID() string

func (*ProviderConfigSource) Kind

func (s *ProviderConfigSource) Kind() SourceKind

func (*ProviderConfigSource) ListModels

func (s *ProviderConfigSource) ListModels(
	_ context.Context,
	opts ListOptions,
) ([]ModelRow, error)

func (*ProviderConfigSource) Priority

func (s *ProviderConfigSource) Priority() int

func (*ProviderConfigSource) ProviderIDs

func (s *ProviderConfigSource) ProviderIDs() []string

func (*ProviderConfigSource) ReplaceProviders

func (s *ProviderConfigSource) ReplaceProviders(providers map[string]compozyconfig.ProviderConfig)

ReplaceProviders atomically replaces the source snapshot used by subsequent refreshes.

type ProviderSecretResolver

type ProviderSecretResolver interface {
	ResolveRef(ctx context.Context, ref string) (string, error)
}

ProviderSecretResolver resolves provider credential refs for live discovery.

type ReasoningEffort

type ReasoningEffort = reasoning.Effort

ReasoningEffort identifies one provider-advertised model reasoning level.

type ReasoningProfile

type ReasoningProfile struct {
	Supported bool
	Efforts   []ReasoningEffort
	Default   ReasoningEffort
	Source    ReasoningSource
}

ReasoningProfile is one model's effective reasoning capability.

type ReasoningSource

type ReasoningSource string

ReasoningSource identifies where a selectable reasoning profile came from.

const (
	// ReasoningSourceACP identifies an active ACP session observation.
	ReasoningSourceACP ReasoningSource = "acp"
	// ReasoningSourceCatalog identifies static or provider-discovery catalog data.
	ReasoningSourceCatalog ReasoningSource = "catalog"
)

type RefreshOptions

type RefreshOptions struct {
	ProviderID               string
	SourceID                 string
	ExecutionContext         CatalogExecutionContext
	PreviousExecutionContext CatalogExecutionContext
	SourceContexts           map[string]CatalogExecutionContext
	Force                    bool
	RequestID                string
	Now                      time.Time
}

RefreshOptions controls a model catalog refresh request.

type RefreshPlan

type RefreshPlan struct {
	// contains filtered or unexported fields
}

RefreshPlan buffers source replacements until a whole catalog generation is ready.

func (*RefreshPlan) Refresh

func (p *RefreshPlan) Refresh(
	ctx context.Context,
	source Source,
	opts RefreshOptions,
) ([]SourceStatus, error)

Refresh stages one source refresh without publishing it to the durable store.

func (*RefreshPlan) SetLiveSources

func (p *RefreshPlan) SetLiveSources(live []*LiveProviderSource) error

SetLiveSources stages the complete live source registry with its durable generation.

type RefreshState

type RefreshState string

RefreshState identifies one source refresh lifecycle state.

const (
	// RefreshStateIdle indicates a source has no active refresh state.
	RefreshStateIdle RefreshState = "idle"
	// RefreshStateRefreshing indicates a source refresh is currently running.
	RefreshStateRefreshing RefreshState = "refreshing"
	// RefreshStateSucceeded indicates the last source refresh succeeded.
	RefreshStateSucceeded RefreshState = "succeeded"
	// RefreshStateFailed indicates the last source refresh failed.
	RefreshStateFailed RefreshState = "failed"
	// RefreshStateDisabled indicates a configured source is disabled.
	RefreshStateDisabled RefreshState = "disabled"
)

type Service

type Service interface {
	ListModels(ctx context.Context, opts ListOptions) ([]Model, error)
	Refresh(ctx context.Context, opts RefreshOptions) ([]SourceStatus, error)
	ListSourceStatus(ctx context.Context, opts StatusOptions) ([]SourceStatus, error)
}

Service exposes merged model catalog projections.

type SessionACPModelProbe

type SessionACPModelProbe struct{}

SessionACPModelProbe reads advertised model options through ACP.

func (SessionACPModelProbe) InspectModels

InspectModels selects each model in a disposable ACP session to read its options.

type Source

type Source interface {
	ID() string
	Kind() SourceKind
	Priority() int
	ListModels(ctx context.Context, opts ListOptions) ([]ModelRow, error)
}

Source produces model rows for one catalog source.

func NewBuiltinSource

func NewBuiltinSource() Source

NewBuiltinSource creates the offline bootstrap source from Compozy built-ins.

func NewLiveProviderSources

func NewLiveProviderSources(cfg *LiveProviderSourcesConfig) ([]Source, error)

NewLiveProviderSources creates provider_live sources for known provider adapters.

type SourceKind

type SourceKind string

SourceKind identifies the provenance family for a catalog source row.

const (
	// SourceKindBuiltin identifies Compozy's offline bootstrap catalog.
	SourceKindBuiltin SourceKind = "builtin"
	// SourceKindConfig identifies operator-authored provider model config.
	SourceKindConfig SourceKind = "config"
	// SourceKindModelsDev identifies enrichment from models.dev.
	SourceKindModelsDev SourceKind = "models_dev"
	// SourceKindProviderLive identifies live provider discovery.
	SourceKindProviderLive SourceKind = "provider_live"
	// SourceKindExtension identifies extension-provided model source rows.
	SourceKindExtension SourceKind = "extension"
	// SourceKindACPSession identifies session-scoped ACP observations.
	SourceKindACPSession SourceKind = "acp_session"
)

type SourceProviderKey

type SourceProviderKey struct {
	SourceID   string
	ProviderID string
}

SourceProviderKey identifies one source/provider pair that owns stored rows.

type SourceRef

type SourceRef struct {
	SourceID    string
	SourceKind  SourceKind
	Priority    int
	RefreshedAt time.Time
	Stale       bool
	LastError   string
}

SourceRef identifies one source participating in a merged catalog projection.

type SourceRowsReplacement

type SourceRowsReplacement struct {
	// RemoveSource deletes the live source for this provider across all execution contexts.
	RemoveSource     bool
	ExecutionContext CatalogExecutionContext
	SourceID         string
	ProviderID       string
	Rows             []ModelRow
	Status           SourceStatus
}

SourceRowsReplacement is one provider-scoped source publication.

type SourceStatus

type SourceStatus struct {
	SourceID     string
	SourceKind   SourceKind
	ProviderID   string
	Priority     int
	LastRefresh  time.Time
	NextRefresh  time.Time
	LastSuccess  time.Time
	LastError    string
	RefreshState RefreshState
	RowCount     int
	Stale        bool
	// RetainContextPartitions is a write-time policy, not persisted source health.
	RetainContextPartitions bool `json:"-"`
}

SourceStatus reports provider-scoped source health and row counts.

func (SourceStatus) FailureReason

func (s SourceStatus) FailureReason() string

FailureReason classifies persisted diagnostics without changing their storage format.

func (SourceStatus) FreshAt

func (s SourceStatus) FreshAt(now time.Time) bool

FreshAt reports whether a settled source status still defers its next refresh past now.

func (SourceStatus) HeldCauseUnchanged

func (s SourceStatus) HeldCauseUnchanged(preflightErr error) bool

HeldCauseUnchanged compares cold-start preflight with the persisted reason; login needs an explicit refresh.

func (SourceStatus) PermanentFailureHeld

func (s SourceStatus) PermanentFailureHeld() bool

PermanentFailureHeld identifies failed TTL sources parked without a scheduled refresh.

type StaleFallbackError

type StaleFallbackError struct {
	SourceID string
	Err      error
}

StaleFallbackError reports a refresh failure that returned stale fallback rows.

func (*StaleFallbackError) Error

func (e *StaleFallbackError) Error() string

func (*StaleFallbackError) Unwrap

func (e *StaleFallbackError) Unwrap() error

type StatusOptions

type StatusOptions struct {
	ProviderID       string
	ExecutionContext CatalogExecutionContext
	SourceContexts   map[string]CatalogExecutionContext
}

StatusOptions filters source health by provider and execution context.

type Store

type Store interface {
	ReplaceSourceRows(
		ctx context.Context,
		executionContext CatalogExecutionContext,
		sourceID string,
		providerID string,
		rows []ModelRow,
		status SourceStatus,
	) error
	// ReplaceSourceRowsBatch publishes every replacement atomically.
	ReplaceSourceRowsBatch(ctx context.Context, replacements []SourceRowsReplacement) error
	ListRows(ctx context.Context, opts ListOptions) ([]ModelRow, error)
	// ListRowOwners returns the distinct source/provider pairs of rows matching opts without hydrating rows.
	ListRowOwners(ctx context.Context, opts ListOptions) ([]SourceProviderKey, error)
	ListSourceStatus(ctx context.Context, opts StatusOptions) ([]SourceStatus, error)
}

Store persists source rows and provider-scoped source status.

type TokenBuckets

type TokenBuckets struct {
	Input      *int64
	Output     *int64
	CacheRead  *int64
	CacheWrite *int64
	Reasoning  *int64
}

TokenBuckets carries the usage buckets priced by the merged model catalog.

Jump to

Keyboard shortcuts

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