Documentation
¶
Overview ¶
Package agent provides core types and interfaces for AI development agents.
Index ¶
- Constants
- type Agent
- type Filter
- type InstallMethod
- type Installation
- type ListOptions
- type ObservableRegistry
- type Registry
- type RegistryEvent
- type RegistryEventType
- type RegistryObserver
- type RegistryOptions
- type Release
- type SortField
- type SortOrder
- type Status
- type UpdateInfo
- type Version
- type VersionConstraint
- type VersionRange
Constants ¶
const ( // Full form constants InstallMethodNPM InstallMethod = "npm" InstallMethodBrew InstallMethod = "brew" InstallMethodPip InstallMethod = "pip" InstallMethodPipx InstallMethod = "pipx" InstallMethodUV InstallMethod = "uv" InstallMethodScoop InstallMethod = "scoop" InstallMethodWinget InstallMethod = "winget" InstallMethodChocolatey InstallMethod = "chocolatey" InstallMethodNative InstallMethod = "native" InstallMethodCurl InstallMethod = "curl" InstallMethodBinary InstallMethod = "binary" // Short form aliases MethodNPM = InstallMethodNPM MethodBrew = InstallMethodBrew MethodPip = InstallMethodPip MethodPipx = InstallMethodPipx MethodUV = InstallMethodUV MethodScoop = InstallMethodScoop MethodWinget = InstallMethodWinget MethodChocolatey = InstallMethodChocolatey MethodNative = InstallMethodNative MethodCurl = InstallMethodCurl MethodBinary = InstallMethodBinary )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Homepage string `json:"homepage,omitempty"`
Repository string `json:"repository,omitempty"`
}
Agent represents a detected AI development agent.
type Filter ¶
type Filter struct {
// AgentID limits results to a specific agent (singular convenience).
AgentID string
// AgentIDs limits results to specific agents (multiple).
AgentIDs []string
// Method limits results to a specific installation method (singular convenience).
Method InstallMethod
// Methods limits results to specific installation methods (multiple).
Methods []InstallMethod
// HasUpdate filters to only installations with updates available.
HasUpdate *bool
// IsGlobal filters to only global or local installations.
IsGlobal *bool
// Query performs a text search across agent names and IDs.
Query string
}
Filter defines criteria for filtering installations.
func (Filter) Matches ¶
func (f Filter) Matches(inst Installation) bool
Matches returns true if the installation matches this filter.
type InstallMethod ¶
type InstallMethod string
InstallMethod represents how an agent was installed.
func (InstallMethod) DisplayName ¶
func (m InstallMethod) DisplayName() string
DisplayName returns a human-friendly name for the install method.
func (InstallMethod) String ¶
func (m InstallMethod) String() string
String returns the string representation of the install method.
type Installation ¶
type Installation struct {
AgentID string `json:"agent_id"`
AgentName string `json:"agent_name"`
Method InstallMethod `json:"install_method"`
InstalledVersion Version `json:"installed_version"`
LatestVersion *Version `json:"latest_version,omitempty"`
ExecutablePath string `json:"executable_path"`
InstallPath string `json:"install_path,omitempty"`
IsGlobal bool `json:"is_global"`
DetectedAt time.Time `json:"detected_at"`
LastChecked time.Time `json:"last_checked"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Installation represents a unique installation instance of an agent. The same agent can have multiple installations via different methods.
func (Installation) GetStatus ¶
func (i Installation) GetStatus() Status
GetStatus returns the current status of the installation.
func (Installation) HasUpdate ¶
func (i Installation) HasUpdate() bool
HasUpdate returns true if an update is available.
func (Installation) Key ¶
func (i Installation) Key() string
Key returns a unique identifier for this installation.
type ListOptions ¶
type ListOptions struct {
Filter *Filter
SortBy SortField
SortOrder SortOrder
Limit int
Offset int
}
ListOptions configures listing behavior.
func DefaultListOptions ¶
func DefaultListOptions() ListOptions
DefaultListOptions returns default listing options.
type ObservableRegistry ¶
type ObservableRegistry interface {
Registry
// Subscribe adds an observer to receive events.
Subscribe(observer RegistryObserver)
// Unsubscribe removes an observer.
Unsubscribe(observer RegistryObserver)
}
ObservableRegistry extends Registry with event observation capabilities.
type Registry ¶
type Registry interface {
// List returns all detected agent installations.
List(ctx context.Context) ([]Installation, error)
// Get returns a specific installation by unique key.
Get(ctx context.Context, key string) (*Installation, error)
// GetByAgent returns all installations of a specific agent.
GetByAgent(ctx context.Context, agentID string) ([]Installation, error)
// GetByMethod returns all installations using a specific method.
GetByMethod(ctx context.Context, method InstallMethod) ([]Installation, error)
// Register adds or updates an installation.
Register(ctx context.Context, installation Installation) error
// Unregister removes an installation.
Unregister(ctx context.Context, key string) error
// Refresh re-detects all agents.
Refresh(ctx context.Context) error
// Count returns the number of registered installations.
Count(ctx context.Context) (int, error)
// CountWithUpdates returns the number of installations with available updates.
CountWithUpdates(ctx context.Context) (int, error)
}
Registry manages the collection of detected agent installations.
type RegistryEvent ¶
type RegistryEvent struct {
Type RegistryEventType `json:"type"`
Installation *Installation `json:"installation,omitempty"`
Error error `json:"error,omitempty"`
}
RegistryEvent represents an event from the registry.
type RegistryEventType ¶
type RegistryEventType string
RegistryEventType defines types of registry events.
const ( RegistryEventAdded RegistryEventType = "added" RegistryEventUpdated RegistryEventType = "updated" RegistryEventRemoved RegistryEventType = "removed" RegistryEventRefreshed RegistryEventType = "refreshed" RegistryEventError RegistryEventType = "error" )
type RegistryObserver ¶
type RegistryObserver interface {
OnRegistryEvent(event RegistryEvent)
}
RegistryObserver receives registry events.
type RegistryOptions ¶
type RegistryOptions struct {
// AutoRefresh enables automatic periodic refresh of agent detection.
AutoRefresh bool
// RefreshInterval specifies how often to refresh when AutoRefresh is enabled.
RefreshInterval int // in seconds
// IncludeHidden includes hidden agents in listings.
IncludeHidden bool
// PlatformFilter limits detection to specific platforms.
PlatformFilter []string
}
RegistryOptions configures the registry behavior.
func DefaultRegistryOptions ¶
func DefaultRegistryOptions() RegistryOptions
DefaultRegistryOptions returns the default registry options.
type Release ¶
type Release struct {
Version Version `json:"version"`
Title string `json:"title"`
Body string `json:"body"`
Highlights []string `json:"highlights,omitempty"`
PublishedAt time.Time `json:"published_at"`
URL string `json:"url,omitempty"`
}
Release represents a single release with its notes.
type UpdateInfo ¶
type UpdateInfo struct {
Installation Installation `json:"installation"`
FromVersion Version `json:"from_version"`
ToVersion Version `json:"to_version"`
Changelog string `json:"changelog,omitempty"`
ReleaseNotes []Release `json:"release_notes,omitempty"`
PublishedAt time.Time `json:"published_at,omitempty"`
}
UpdateInfo contains information about an available update.
type Version ¶
type Version struct {
Major int `json:"major"`
Minor int `json:"minor"`
Patch int `json:"patch"`
Prerelease string `json:"prerelease,omitempty"`
Build string `json:"build,omitempty"`
Raw string `json:"raw"`
}
Version represents a semantic version.
func MustParseVersion ¶
MustParseVersion parses a version string and panics on error.
func ParseVersion ¶
ParseVersion parses a version string into a Version struct. Handles formats: v1.2.3, 1.2.3, 1.2.3-beta.1, 1.2.3+build.123
func (Version) IsNewerThan ¶
IsNewerThan returns true if this version is newer than the other.
func (Version) IsOlderThan ¶
IsOlderThan returns true if this version is older than the other.
type VersionConstraint ¶
type VersionConstraint struct {
Operator string `json:"operator"` // =, >, >=, <, <=, ~, ^
Version Version `json:"version"`
}
VersionConstraint represents a version constraint (e.g., >=1.0.0).
func (VersionConstraint) Matches ¶
func (c VersionConstraint) Matches(v Version) bool
Matches returns true if the given version matches this constraint.
type VersionRange ¶
VersionRange represents a range of versions between two endpoints.
func (VersionRange) Contains ¶
func (r VersionRange) Contains(v Version) bool
Contains returns true if the given version is within this range.