agent

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package agent provides core types and interfaces for AI development agents.

Index

Constants

View Source
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 SortField

type SortField string

SortField defines fields for sorting installations.

const (
	SortByName      SortField = "name"
	SortByMethod    SortField = "method"
	SortByVersion   SortField = "version"
	SortByUpdatedAt SortField = "updated_at"
	SortByStatus    SortField = "status"
)

type SortOrder

type SortOrder string

SortOrder defines the sort direction.

const (
	SortAsc  SortOrder = "asc"
	SortDesc SortOrder = "desc"
)

type Status

type Status string

Status represents the current status of an installation.

const (
	StatusCurrent    Status = "current"
	StatusOutdated   Status = "outdated"
	StatusUnknown    Status = "unknown"
	StatusError      Status = "error"
	StatusInstalling Status = "installing"
	StatusUpdating   Status = "updating"
)

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

func MustParseVersion(s string) Version

MustParseVersion parses a version string and panics on error.

func ParseVersion

func ParseVersion(s string) (Version, error)

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) Compare

func (v Version) Compare(other Version) int

Compare returns -1, 0, or 1 for less than, equal, or greater than.

func (Version) Equals

func (v Version) Equals(other Version) bool

Equals returns true if the versions are equal.

func (Version) IsNewerThan

func (v Version) IsNewerThan(other Version) bool

IsNewerThan returns true if this version is newer than the other.

func (Version) IsOlderThan

func (v Version) IsOlderThan(other Version) bool

IsOlderThan returns true if this version is older than the other.

func (Version) IsZero

func (v Version) IsZero() bool

IsZero returns true if this is a zero/empty version.

func (Version) String

func (v Version) String() string

String returns the string representation of the version.

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

type VersionRange struct {
	From Version `json:"from"`
	To   Version `json:"to"`
}

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.

Jump to

Keyboard shortcuts

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