Documentation
¶
Overview ¶
Package agents is the ACP agents a user can install from ACP's registry and run as a provider (ADR 0015): the registry, read and kept for an hour; what this machine can run; installing one, when the user chose to; and what is installed, and how to start it.
Index ¶
- Constants
- Variables
- func Platform() string
- type Agent
- type Binary
- type Entry
- type Installed
- type Manager
- func (m *Manager) Agents(ctx context.Context) ([]Agent, error)
- func (m *Manager) Cached() ([]Agent, error)
- func (m *Manager) Command(id string) (Installed, bool)
- func (m *Manager) Install(ctx context.Context, id, version string) (Installed, error)
- func (m *Manager) List(ctx context.Context) ([]Entry, error)
- type Package
Constants ¶
const CacheFor = time.Hour
CacheFor is how long a registry read is used before it is read again.
const RegistryURL = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json"
RegistryURL is ACP's registry of agents.
Variables ¶
var ErrChanged = errors.New("the registry has another version now")
ErrChanged: the registry's version of the agent is not the one the user was shown.
var ErrUnknown = errors.New("no such agent in the ACP registry")
ErrUnknown: the registry has no such agent.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Distribution struct {
Npx *Package `json:"npx,omitempty"`
Uvx *Package `json:"uvx,omitempty"`
Binary map[string]Binary `json:"binary,omitempty"`
} `json:"distribution"`
}
Agent is an agent of the registry.
type Binary ¶
type Binary struct {
Archive string `json:"archive"`
Cmd string `json:"cmd"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
SHA256 string `json:"sha256"`
}
Binary is a binary distribution for one platform.
type Entry ¶
type Entry struct {
Agent
// Installed: the version installed, if any.
Installed string `json:"installed,omitempty"`
// Usable: it can be installed and run here; else Reason says why not.
Usable bool `json:"usable"`
Reason string `json:"reason,omitempty"`
// Source is what installing it fetches: a package, or an archive's URL.
Source string `json:"source,omitempty"`
}
Entry is an agent as /provider lists it.
type Installed ¶
type Installed struct {
Version string `json:"version"`
Command []string `json:"command"`
Env map[string]string `json:"env,omitempty"`
}
Installed is an agent installed here: how to start it.
type Manager ¶
type Manager struct {
Dir string
Registry string // the registry's URL
HTTP *http.Client
// LookPath finds a command (exec.LookPath; tests change it).
LookPath func(string) (string, error)
// contains filtered or unexported fields
}
Manager keeps the agents of a data directory (Dir: <data>/agents).
func New ¶
New is a manager of dir, reading the registry at url (RegistryURL for ACP's; "" reads none: only what is installed is there).
func (*Manager) Agents ¶
Agents are the registry's agents, read at most once in CacheFor; when it cannot be read, the copy kept is used.
func (*Manager) Cached ¶
Cached are the registry's agents as last read, however long ago; an error if it was never read.