Documentation
¶
Overview ¶
Package discovery provides model discovery services for the intelligence system. It wraps the existing discovery.Discoverer to provide parallel provider queries with timeout enforcement and registry writing capabilities.
Index ¶
- type DiscoveredModel
- type DiscoveryRegistry
- type ModelCapability
- type ProviderStatus
- type Service
- func (s *Service) DiscoverAll(ctx context.Context) error
- func (s *Service) GetAvailableModels() []*DiscoveredModel
- func (s *Service) GetAvailableModelsAsMap() []map[string]interface{}
- func (s *Service) GetProviderStatus() []*ProviderStatus
- func (s *Service) SetStateBox(sb *util.StateBox)
- func (s *Service) Shutdown(ctx context.Context) error
- func (s *Service) WriteRegistry(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoveredModel ¶
type DiscoveredModel struct {
ID string `json:"id"`
Provider string `json:"provider"`
DisplayName string `json:"display_name"`
Capabilities *capability.ModelCapability `json:"capabilities,omitempty"`
IsAvailable bool `json:"is_available"`
DiscoveredAt time.Time `json:"discovered_at"`
}
DiscoveredModel represents a model discovered from a provider.
type DiscoveryRegistry ¶
type DiscoveryRegistry struct {
Providers []*ProviderStatus `json:"providers"`
Models []*DiscoveredModel `json:"models"`
GeneratedAt time.Time `json:"generated_at"`
TotalModels int `json:"total_models"`
}
DiscoveryRegistry represents the complete discovery output.
type ModelCapability ¶
type ModelCapability = capability.ModelCapability
ModelCapability is re-exported from the capability package for convenience.
type ProviderStatus ¶
type ProviderStatus struct {
Provider string `json:"provider"`
IsAvailable bool `json:"is_available"`
ModelCount int `json:"model_count"`
Error string `json:"error,omitempty"`
DiscoveredAt time.Time `json:"discovered_at"`
}
ProviderStatus represents the status of a provider during discovery.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps the existing discovery.Discoverer and provides intelligence-specific functionality like parallel queries and registry writing.
func NewService ¶
NewService creates a new DiscoveryService instance.
Parameters:
- cacheDir: Directory where discovery cache and registry will be stored (deprecated, use SetStateBox)
- stateBox: StateBox instance for path resolution and read-only mode enforcement
Returns:
- *Service: A new discovery service instance
- error: Any error encountered during initialization
func (*Service) DiscoverAll ¶
DiscoverAll runs discovery for all configured providers with a 5-second timeout. It queries providers in parallel and gracefully handles failures.
Parameters:
- ctx: Context for the discovery operation
Returns:
- error: Any error encountered during discovery (non-fatal provider errors are logged)
func (*Service) GetAvailableModels ¶
func (s *Service) GetAvailableModels() []*DiscoveredModel
GetAvailableModels returns the list of discovered models.
Returns:
- []*DiscoveredModel: List of discovered models
func (*Service) GetAvailableModelsAsMap ¶
GetAvailableModelsAsMap returns discovered models as a slice of maps for Lua interop.
Returns:
- []map[string]interface{}: List of models as maps
func (*Service) GetProviderStatus ¶
func (s *Service) GetProviderStatus() []*ProviderStatus
GetProviderStatus returns the status of all providers.
Returns:
- []*ProviderStatus: List of provider statuses
func (*Service) SetStateBox ¶
SetStateBox configures the StateBox for the discovery service. This allows the service to use StateBox for path resolution and read-only mode enforcement.
Parameters:
- sb: StateBox instance to use
func (*Service) Shutdown ¶
Shutdown gracefully stops the discovery service.
Parameters:
- ctx: Context for shutdown operations
Returns:
- error: Any error encountered during shutdown
func (*Service) WriteRegistry ¶
WriteRegistry writes the discovery results to available_models.json.
Parameters:
- path: Path to write the registry file (if empty, uses cacheDir/available_models.json)
Returns:
- error: Any error encountered during writing