discovery

package
v0.5.24 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

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

func NewService(cacheDir string, stateBox *util.StateBox) (*Service, error)

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

func (s *Service) DiscoverAll(ctx context.Context) error

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

func (s *Service) GetAvailableModelsAsMap() []map[string]interface{}

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

func (s *Service) SetStateBox(sb *util.StateBox)

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

func (s *Service) Shutdown(ctx context.Context) error

Shutdown gracefully stops the discovery service.

Parameters:

  • ctx: Context for shutdown operations

Returns:

  • error: Any error encountered during shutdown

func (*Service) WriteRegistry

func (s *Service) WriteRegistry(path string) error

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

Jump to

Keyboard shortcuts

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