Documentation
¶
Overview ¶
Package plugins – installer.go implements plugin installation from multiple sources: GitHub repositories and local paths.
Supported sources:
- GitHub shorthand: "user/repo" or "github:user/repo"
- GitHub URL: "https://github.com/user/repo"
- Local path: "./path/to/plugin" or "/absolute/path"
Package plugins implements the unified YAML-first plugin system for DevClaw. Plugins extend the runtime with agents, tools, hooks, services, channels, and skills — all declared in a plugin.yaml manifest.
Legacy .so plugins (without plugin.yaml) are supported via synthetic PluginInstance wrappers for backward compatibility.
Package plugins implements the unified YAML-first plugin system for DevClaw. Plugins extend the runtime with agents, tools, hooks, services, channels, and skills.
A plugin is a directory containing a plugin.yaml manifest and optional supporting files (prompts, skills, native .so libraries).
Index ¶
- func ResolveConfig(schema *PluginConfigSchema, overrides map[string]any, vault VaultReader) (map[string]any, error)
- func ValidateConfig(schema *PluginConfigSchema, resolved map[string]any) error
- type AgentDef
- type AgentRegistrar
- type AgentToolProfile
- type ChannelDef
- type ChannelRegistrar
- type Config
- type EscalationConfig
- type FollowupEnqueuer
- type HookDef
- type HookRegistrar
- type Loader
- func (l *Loader) All() []*PluginInstance
- func (l *Loader) Channels() []channels.Channel
- func (l *Loader) Count() int
- func (l *Loader) Discover() ([]*PluginInstance, error)
- func (l *Loader) Get(id string) *PluginInstance
- func (l *Loader) LoadAll(ctx context.Context, vault VaultReader) error
- func (l *Loader) RegisterChannels(mgr *channels.Manager) error
- func (l *Loader) Shutdown()
- type ManifestProvider
- func (p *ManifestProvider) Agents() []AgentDef
- func (p *ManifestProvider) Channels() []ChannelDef
- func (p *ManifestProvider) ConfigSchema() *PluginConfigSchema
- func (p *ManifestProvider) Hooks() []HookDef
- func (p *ManifestProvider) ID() string
- func (p *ManifestProvider) Init(ctx context.Context, config map[string]any) error
- func (p *ManifestProvider) Metadata() PluginMetadata
- func (p *ManifestProvider) Services() []ServiceDef
- func (p *ManifestProvider) SetInitFunc(fn func(ctx context.Context, config map[string]any) error)
- func (p *ManifestProvider) SetShutdownFunc(fn func() error)
- func (p *ManifestProvider) Shutdown() error
- func (p *ManifestProvider) Skills() []SkillDef
- func (p *ManifestProvider) Tools() []ToolDef
- func (p *ManifestProvider) UIConfig() *PluginUIConfig
- type Plugin
- type PluginAgentSummary
- type PluginConfigField
- type PluginConfigSchema
- type PluginInfo
- type PluginInstallResult
- type PluginInstaller
- type PluginInstance
- type PluginManifest
- type PluginMetadata
- type PluginProvider
- type PluginRequirements
- type PluginState
- type PluginUIConfig
- type PluginsConfig
- type Registry
- func (r *Registry) AddLoadedPlugins(loader *Loader)
- func (r *Registry) ConfigurePlugin(id string, updates map[string]any) error
- func (r *Registry) Disable(id string) error
- func (r *Registry) Enable(id string) error
- func (r *Registry) Get(id string) *PluginInstance
- func (r *Registry) GetResolvedAgent(pluginID, agentID string) *resolvedAgent
- func (r *Registry) HasPlugins() bool
- func (r *Registry) List() []PluginInfo
- func (r *Registry) ListAgentSummaries() []PluginAgentSummary
- func (r *Registry) MatchTrigger(content, channel string) *TriggerMatch
- func (r *Registry) RegisterAll() error
- func (r *Registry) SendToMainAgent(parentSessionID string, agent *resolvedAgent, reason, summary string)
- func (r *Registry) SetAgentRegistrar(ar AgentRegistrar)
- func (r *Registry) SetChannelRegistrar(cr ChannelRegistrar)
- func (r *Registry) SetFollowupEnqueuer(fe FollowupEnqueuer)
- func (r *Registry) SetHookRegistrar(hr HookRegistrar)
- func (r *Registry) SetSkillRegistrar(sr SkillRegistrar)
- func (r *Registry) SetToolRegistrar(tr ToolRegistrar)
- func (r *Registry) StartAll(ctx context.Context) error
- func (r *Registry) StopAll()
- type ServiceDef
- type SkillDef
- type SkillRegistrar
- type SubagentSpawner
- type ToolDef
- type ToolHandlerFunc
- type ToolRegistrar
- type ToolRegistration
- type TriggerMatch
- type UIAction
- type UISection
- type VaultReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveConfig ¶ added in v1.16.0
func ResolveConfig(schema *PluginConfigSchema, overrides map[string]any, vault VaultReader) (map[string]any, error)
ResolveConfig resolves the final configuration for a plugin by merging sources in precedence order: overrides > vault > env > defaults.
func ValidateConfig ¶ added in v1.16.0
func ValidateConfig(schema *PluginConfigSchema, resolved map[string]any) error
ValidateConfig validates resolved config against the schema.
Types ¶
type AgentDef ¶ added in v1.16.0
type AgentDef struct {
// ID is the agent identifier (unique within the plugin).
ID string `yaml:"id" json:"id"`
// Name is the human-readable agent name.
Name string `yaml:"name" json:"name"`
// Description explains the agent's purpose.
Description string `yaml:"description" json:"description,omitempty"`
// Instructions is inline system prompt text or a path to a .md file
// (relative to plugin directory).
Instructions string `yaml:"instructions" json:"instructions"`
// Model overrides the LLM model for this agent (empty = use plugin/core default).
Model string `yaml:"model" json:"model,omitempty"`
// Triggers are keywords that activate this agent (matched against message content).
Triggers []string `yaml:"triggers" json:"triggers,omitempty"`
// Tools defines the tool allow/deny profile for this agent.
Tools AgentToolProfile `yaml:"tools" json:"tools,omitzero"`
// MaxTurns limits the agent loop turns (0 = unlimited).
MaxTurns int `yaml:"max_turns" json:"max_turns,omitempty"`
// TimeoutSec is the max execution time in seconds (0 = default).
TimeoutSec int `yaml:"timeout_sec" json:"timeout_sec,omitempty"`
// SessionMode controls session isolation ("isolated" or "shared").
SessionMode string `yaml:"session_mode" json:"session_mode,omitempty"`
// Escalation configures when/how the agent escalates to the main agent.
Escalation *EscalationConfig `yaml:"escalation" json:"escalation,omitempty"`
// Channels limits which channels this agent can be triggered from.
Channels []string `yaml:"channels" json:"channels,omitempty"`
}
AgentDef defines a plugin-provided agent.
type AgentRegistrar ¶ added in v1.16.0
type AgentRegistrar interface {
AddProfile(p any)
}
AgentRegistrar registers agent profiles at runtime.
type AgentToolProfile ¶ added in v1.16.0
type AgentToolProfile struct {
// Allow lists tools the agent can use (empty = all available).
Allow []string `yaml:"allow" json:"allow,omitempty"`
// Deny lists tools the agent cannot use.
Deny []string `yaml:"deny" json:"deny,omitempty"`
}
AgentToolProfile defines which tools an agent can access.
type ChannelDef ¶ added in v1.16.0
type ChannelDef struct {
// Name is the channel name.
Name string `yaml:"name" json:"name"`
// Handler is a Go symbol name for the channel implementation.
Handler string `yaml:"handler" json:"handler"`
}
ChannelDef defines a plugin-provided channel implementation.
type ChannelRegistrar ¶ added in v1.16.0
ChannelRegistrar registers channels with the channel manager.
type Config ¶
type Config = PluginsConfig
Config is a type alias for backward compatibility with copilot/config.go.
type EscalationConfig ¶ added in v1.16.0
type EscalationConfig struct {
// Enabled turns escalation on/off.
Enabled bool `yaml:"enabled" json:"enabled"`
// Keywords are phrases that trigger automatic escalation.
Keywords []string `yaml:"keywords" json:"keywords,omitempty"`
// MaxTurns triggers escalation after this many turns without resolution.
MaxTurns int `yaml:"max_turns" json:"max_turns,omitempty"`
// OnFailure controls behavior on escalation failure ("retry", "drop").
OnFailure string `yaml:"on_failure" json:"on_failure,omitempty"`
// ExplicitOnly when true, only escalates via explicit escalate_to_main tool call.
ExplicitOnly bool `yaml:"explicit_only" json:"explicit_only,omitempty"`
}
EscalationConfig configures agent-to-main escalation.
type FollowupEnqueuer ¶ added in v1.16.0
type FollowupEnqueuer interface {
Enqueue(sessionID, content, channel, chatID string)
}
FollowupEnqueuer injects messages into a session's follow-up queue.
type HookDef ¶ added in v1.16.0
type HookDef struct {
// Name is the hook identifier.
Name string `yaml:"name" json:"name"`
// Description explains the hook's purpose.
Description string `yaml:"description" json:"description,omitempty"`
// Events lists the events this hook listens to.
Events []string `yaml:"events" json:"events"`
// Priority controls execution order (lower = earlier, default: 100).
Priority int `yaml:"priority" json:"priority,omitempty"`
// Handler is a Go symbol name for native hook handlers.
Handler string `yaml:"handler" json:"handler,omitempty"`
// Script is inline bash script for script-based hook handlers.
Script string `yaml:"script" json:"script,omitempty"`
}
HookDef defines a plugin-provided hook.
type HookRegistrar ¶ added in v1.16.0
type HookRegistrar interface {
RegisterPluginHook(pluginID string, events []string, priority int, handler func(event string, data map[string]any)) error
}
HookRegistrar registers hooks with the hook system.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader discovers, loads, and manages plugin instances.
func NewLoader ¶
func NewLoader(cfg PluginsConfig, logger *slog.Logger) *Loader
NewLoader creates a new plugin loader.
func (*Loader) All ¶
func (l *Loader) All() []*PluginInstance
All returns all loaded plugin instances.
func (*Loader) Discover ¶ added in v1.16.0
func (l *Loader) Discover() ([]*PluginInstance, error)
Discover scans all configured directories for plugin.yaml files and returns discovered PluginInstance entries (state = Discovered).
func (*Loader) Get ¶ added in v1.16.0
func (l *Loader) Get(id string) *PluginInstance
Get returns a plugin instance by ID.
func (*Loader) LoadAll ¶
func (l *Loader) LoadAll(ctx context.Context, vault VaultReader) error
LoadAll discovers and loads all plugins. Config is resolved using the vault and any overrides from cfg.Overrides.
func (*Loader) RegisterChannels ¶
RegisterChannels registers all loaded native channel plugins with a Manager.
type ManifestProvider ¶ added in v1.16.0
type ManifestProvider struct {
// contains filtered or unexported fields
}
ManifestProvider wraps a PluginManifest to satisfy the PluginProvider interface. This is the default provider for YAML-based plugins.
func NewManifestProvider ¶ added in v1.16.0
func NewManifestProvider(m *PluginManifest, dir string) *ManifestProvider
NewManifestProvider creates a provider from a parsed manifest.
func (*ManifestProvider) Agents ¶ added in v1.16.0
func (p *ManifestProvider) Agents() []AgentDef
func (*ManifestProvider) Channels ¶ added in v1.16.0
func (p *ManifestProvider) Channels() []ChannelDef
func (*ManifestProvider) ConfigSchema ¶ added in v1.16.0
func (p *ManifestProvider) ConfigSchema() *PluginConfigSchema
func (*ManifestProvider) Hooks ¶ added in v1.16.0
func (p *ManifestProvider) Hooks() []HookDef
func (*ManifestProvider) ID ¶ added in v1.16.0
func (p *ManifestProvider) ID() string
func (*ManifestProvider) Metadata ¶ added in v1.16.0
func (p *ManifestProvider) Metadata() PluginMetadata
func (*ManifestProvider) Services ¶ added in v1.16.0
func (p *ManifestProvider) Services() []ServiceDef
func (*ManifestProvider) SetInitFunc ¶ added in v1.16.0
SetInitFunc sets a custom init function (used for native plugins).
func (*ManifestProvider) SetShutdownFunc ¶ added in v1.16.0
func (p *ManifestProvider) SetShutdownFunc(fn func() error)
SetShutdownFunc sets a custom shutdown function (used for native plugins).
func (*ManifestProvider) Shutdown ¶ added in v1.16.0
func (p *ManifestProvider) Shutdown() error
func (*ManifestProvider) Skills ¶ added in v1.16.0
func (p *ManifestProvider) Skills() []SkillDef
func (*ManifestProvider) Tools ¶ added in v1.16.0
func (p *ManifestProvider) Tools() []ToolDef
func (*ManifestProvider) UIConfig ¶ added in v1.16.0
func (p *ManifestProvider) UIConfig() *PluginUIConfig
type Plugin ¶
type Plugin interface {
Name() string
Version() string
Init(ctx context.Context, config map[string]any) error
Shutdown() error
}
Plugin is the interface for generic DevClaw native plugins (.so). Channel plugins can also implement this for lifecycle hooks, but it's not required — exporting var Channel is enough.
type PluginAgentSummary ¶ added in v1.16.0
type PluginAgentSummary struct {
PluginID string
AgentID string
Name string
Description string
Triggers []string
}
PluginAgentSummary holds minimal info about a plugin agent for prompt injection.
type PluginConfigField ¶ added in v1.16.0
type PluginConfigField struct {
// Key is the configuration key (used in resolved config map).
Key string `yaml:"key" json:"key"`
// Name is the human-readable field name.
Name string `yaml:"name" json:"name"`
// Description explains the field's purpose.
Description string `yaml:"description" json:"description,omitempty"`
// Type is the field type ("string", "int", "bool", "secret").
Type string `yaml:"type" json:"type"`
// Required indicates whether the field must be provided.
Required bool `yaml:"required" json:"required,omitempty"`
// Default is the default value if not provided.
Default any `yaml:"default" json:"default,omitempty"`
// EnvVar is the environment variable to read the value from.
EnvVar string `yaml:"env_var" json:"env_var,omitempty"`
// VaultKey is the vault key to read the value from.
VaultKey string `yaml:"vault_key" json:"vault_key,omitempty"`
}
PluginConfigField defines a single configuration field.
type PluginConfigSchema ¶ added in v1.16.0
type PluginConfigSchema struct {
// Fields is the list of configuration fields.
Fields []PluginConfigField `yaml:"fields" json:"fields,omitempty"`
}
PluginConfigSchema defines the configuration schema for a plugin.
type PluginInfo ¶ added in v1.16.0
type PluginInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Author string `json:"author"`
State PluginState `json:"state"`
Enabled bool `json:"enabled"`
ErrorMsg string `json:"error,omitempty"`
Dir string `json:"dir"`
Tools []string `json:"tools,omitempty"`
Hooks []string `json:"hooks,omitempty"`
Agents []string `json:"agents,omitempty"`
Channels []string `json:"channels,omitempty"`
Skills []string `json:"skills,omitempty"`
// UI configuration for the settings panel.
UI *PluginUIConfig `json:"ui,omitempty"`
// ConfigSchema describes the plugin's configurable fields (for form generation).
ConfigSchema *PluginConfigSchema `json:"config_schema,omitempty"`
// ConfigValues holds the current resolved config values (secrets redacted).
ConfigValues map[string]any `json:"config_values,omitempty"`
LoadedAt time.Time `json:"loaded_at"`
StartedAt time.Time `json:"started_at,omitzero"`
}
PluginInfo is a JSON-serializable summary of a plugin instance.
type PluginInstallResult ¶ added in v1.16.0
type PluginInstallResult struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Source string `json:"source"`
Path string `json:"path"`
IsNew bool `json:"is_new"`
}
PluginInstallResult holds the result of a plugin installation.
type PluginInstaller ¶ added in v1.16.0
type PluginInstaller struct {
// contains filtered or unexported fields
}
PluginInstaller handles plugin installation from various sources.
func NewPluginInstaller ¶ added in v1.16.0
func NewPluginInstaller(pluginsDir string, logger *slog.Logger) *PluginInstaller
NewPluginInstaller creates a new plugin installer.
func (*PluginInstaller) Install ¶ added in v1.16.0
func (inst *PluginInstaller) Install(ctx context.Context, source string) (*PluginInstallResult, error)
Install installs a plugin from the given source string. Supported formats:
- "user/repo" or "github:user/repo" — GitHub repository
- "https://github.com/user/repo" — GitHub URL
- "./path/to/plugin" or "/absolute/path" — local path
func (*PluginInstaller) Remove ¶ added in v1.16.0
func (inst *PluginInstaller) Remove(name string) error
Remove removes an installed plugin by ID or directory name.
type PluginInstance ¶ added in v1.16.0
type PluginInstance struct {
// Manifest is the parsed plugin.yaml.
Manifest *PluginManifest
// Provider is the unified interface for this plugin.
Provider PluginProvider
// Dir is the plugin directory path.
Dir string
// State is the current lifecycle state.
State PluginState
// Enabled indicates whether the plugin is enabled.
Enabled bool
// ErrorMsg holds the error message when State == StateError.
ErrorMsg string
// Config is the resolved configuration (after merging defaults, env, vault, overrides).
Config map[string]any
// RegisteredTools tracks the names of tools registered by this plugin.
RegisteredTools []string
// RegisteredHooks tracks the names of hooks registered by this plugin.
RegisteredHooks []string
// RegisteredAgents tracks the IDs of agents registered by this plugin.
RegisteredAgents []string
// RegisteredChannels tracks the names of channels registered by this plugin.
RegisteredChannels []string
// RegisteredSkills tracks the names of skills registered by this plugin.
RegisteredSkills []string
// LoadedAt is when the plugin was loaded.
LoadedAt time.Time
// StartedAt is when the plugin services were started.
StartedAt time.Time
// contains filtered or unexported fields
}
PluginInstance holds the runtime state of a loaded plugin.
func (*PluginInstance) Info ¶ added in v1.16.0
func (pi *PluginInstance) Info() PluginInfo
Info returns a JSON-serializable summary of the plugin instance.
type PluginManifest ¶ added in v1.16.0
type PluginManifest struct {
// ID is the unique plugin identifier (used for namespacing).
ID string `yaml:"id" json:"id"`
// Name is the human-readable plugin name.
Name string `yaml:"name" json:"name"`
// Version is the plugin version (semver recommended).
Version string `yaml:"version" json:"version"`
// Description is a short description of the plugin.
Description string `yaml:"description" json:"description"`
// Author is the plugin author or organization.
Author string `yaml:"author" json:"author"`
// License is the plugin license (e.g. "MIT", "Apache-2.0").
License string `yaml:"license" json:"license,omitempty"`
// MinDevclaw is the minimum DevClaw version required.
MinDevclaw string `yaml:"min_devclaw" json:"min_devclaw,omitempty"`
// Requires specifies external requirements (binaries, env vars, OS).
Requires *PluginRequirements `yaml:"requires" json:"requires,omitempty"`
// Config defines the plugin's configuration schema.
Config *PluginConfigSchema `yaml:"config" json:"config,omitempty"`
// Agents defines plugin-provided agent definitions.
Agents []AgentDef `yaml:"agents" json:"agents,omitempty"`
// Tools defines plugin-provided tool definitions.
Tools []ToolDef `yaml:"tools" json:"tools,omitempty"`
// Hooks defines plugin-provided hook definitions.
Hooks []HookDef `yaml:"hooks" json:"hooks,omitempty"`
// Services defines plugin-provided HTTP service endpoints.
Services []ServiceDef `yaml:"services" json:"services,omitempty"`
// Channels defines plugin-provided channel implementations.
Channels []ChannelDef `yaml:"channels" json:"channels,omitempty"`
// Skills defines plugin-provided skill definitions.
Skills []SkillDef `yaml:"skills" json:"skills,omitempty"`
// UI defines the plugin's settings panel layout (optional).
UI *PluginUIConfig `yaml:"ui" json:"ui,omitempty"`
// NativeLib is the path to an optional native .so library (relative to plugin dir).
NativeLib string `yaml:"native_lib" json:"native_lib,omitempty"`
}
PluginManifest is the top-level struct parsed from plugin.yaml.
func ParseManifest ¶ added in v1.16.0
func ParseManifest(path string) (*PluginManifest, error)
ParseManifest reads and parses a plugin.yaml file.
type PluginMetadata ¶ added in v1.16.0
type PluginMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Author string `json:"author"`
License string `json:"license,omitempty"`
}
PluginMetadata holds identity and descriptive information about a plugin.
type PluginProvider ¶ added in v1.16.0
type PluginProvider interface {
// Identity.
ID() string
Metadata() PluginMetadata
// Configuration schema for UI generation.
ConfigSchema() *PluginConfigSchema
// UI configuration for the settings panel (nil = no custom UI).
UIConfig() *PluginUIConfig
// Capabilities — what the plugin provides.
Tools() []ToolDef
Hooks() []HookDef
Agents() []AgentDef
Skills() []SkillDef
Channels() []ChannelDef
Services() []ServiceDef
// Lifecycle.
Init(ctx context.Context, config map[string]any) error
Shutdown() error
}
PluginProvider is the unified interface that all plugin types must satisfy. YAML-based plugins use ManifestProvider (auto-generated from plugin.yaml). Native plugins can implement this directly for full lifecycle control.
type PluginRequirements ¶ added in v1.16.0
type PluginRequirements struct {
// Bins lists required binaries that must be in PATH (all required).
Bins []string `yaml:"bins" json:"bins,omitempty"`
// AnyBins lists binaries where at least one must be in PATH.
AnyBins []string `yaml:"any_bins" json:"any_bins,omitempty"`
// Env lists required environment variables.
Env []string `yaml:"env" json:"env,omitempty"`
// OS lists supported operating systems (e.g. "linux", "darwin").
OS []string `yaml:"os" json:"os,omitempty"`
}
PluginRequirements specifies external requirements for a plugin.
func (*PluginRequirements) IsEligible ¶ added in v1.16.0
func (r *PluginRequirements) IsEligible() bool
IsEligible returns true if the current environment satisfies all requirements.
type PluginState ¶ added in v1.16.0
type PluginState string
PluginState represents the lifecycle state of a plugin instance.
const ( StateDiscovered PluginState = "discovered" StateLoaded PluginState = "loaded" StateRegistered PluginState = "registered" StateStarted PluginState = "started" StateStopped PluginState = "stopped" StateError PluginState = "error" )
type PluginUIConfig ¶ added in v1.16.0
type PluginUIConfig struct {
// Icon is a Lucide icon name for the plugin card (e.g. "bot", "globe", "zap").
Icon string `yaml:"icon" json:"icon,omitempty"`
// Category groups the plugin in the UI (e.g. "communication", "productivity").
Category string `yaml:"category" json:"category,omitempty"`
// Color is a hex accent color for the plugin card (e.g. "#3B82F6").
Color string `yaml:"color" json:"color,omitempty"`
// Sections defines the configuration form layout.
// Each section references config field keys by name.
Sections []UISection `yaml:"sections" json:"sections,omitempty"`
// Actions defines quick-action buttons shown in the plugin detail view.
Actions []UIAction `yaml:"actions" json:"actions,omitempty"`
}
PluginUIConfig defines how the plugin's settings panel is rendered. Declared in plugin.yaml under the `ui` key.
type PluginsConfig ¶ added in v1.16.0
type PluginsConfig struct {
// Dirs lists directories to scan for plugins (YAML-based).
Dirs []string `yaml:"dirs"`
// Dir is the legacy single-directory config (for backward compatibility with .so loader).
Dir string `yaml:"dir"`
// Enabled lists plugin IDs to load (empty = load all found).
Enabled []string `yaml:"enabled"`
// Disabled lists plugin IDs to skip.
Disabled []string `yaml:"disabled"`
// Overrides maps plugin ID to config overrides.
Overrides map[string]map[string]any `yaml:"overrides"`
}
PluginsConfig holds configuration for the plugin system.
func (PluginsConfig) EffectiveDirs ¶ added in v1.16.0
func (c PluginsConfig) EffectiveDirs() []string
EffectiveDirs returns the merged list of directories to scan. Combines Dirs and the legacy Dir field, deduplicating entries.
type Registry ¶ added in v1.16.0
type Registry struct {
// contains filtered or unexported fields
}
Registry is the central plugin registry that coordinates registration of all plugin-provided components (tools, hooks, skills, channels, agents).
func NewRegistry ¶ added in v1.16.0
NewRegistry creates a new plugin registry.
func (*Registry) AddLoadedPlugins ¶ added in v1.16.0
AddLoadedPlugins imports all loaded plugins from the Loader into the registry.
func (*Registry) ConfigurePlugin ¶ added in v1.16.0
ConfigurePlugin updates the resolved config for a plugin. Secret fields sent as the redaction placeholder are preserved from the original.
func (*Registry) Get ¶ added in v1.16.0
func (r *Registry) Get(id string) *PluginInstance
Get returns a plugin instance by ID.
func (*Registry) GetResolvedAgent ¶ added in v1.16.0
GetResolvedAgent returns the resolved agent for a given plugin/agent ID pair.
func (*Registry) HasPlugins ¶ added in v1.16.0
HasPlugins returns true if any plugins are loaded.
func (*Registry) List ¶ added in v1.16.0
func (r *Registry) List() []PluginInfo
List returns info for all plugins.
func (*Registry) ListAgentSummaries ¶ added in v1.16.0
func (r *Registry) ListAgentSummaries() []PluginAgentSummary
ListAgentSummaries returns summaries of all registered plugin agents.
func (*Registry) MatchTrigger ¶ added in v1.16.0
func (r *Registry) MatchTrigger(content, channel string) *TriggerMatch
MatchTrigger evaluates all plugin agent triggers against message content and channel. Returns the best match or nil if no triggers fire.
func (*Registry) RegisterAll ¶ added in v1.16.0
RegisterAll registers tools, hooks, skills, and channels from all loaded plugins.
func (*Registry) SendToMainAgent ¶ added in v1.16.0
func (r *Registry) SendToMainAgent(parentSessionID string, agent *resolvedAgent, reason, summary string)
SendToMainAgent sends an escalation message to the main agent's session.
func (*Registry) SetAgentRegistrar ¶ added in v1.16.0
func (r *Registry) SetAgentRegistrar(ar AgentRegistrar)
SetAgentRegistrar wires the agent registrar.
func (*Registry) SetChannelRegistrar ¶ added in v1.16.0
func (r *Registry) SetChannelRegistrar(cr ChannelRegistrar)
SetChannelRegistrar wires the channel registrar.
func (*Registry) SetFollowupEnqueuer ¶ added in v1.16.0
func (r *Registry) SetFollowupEnqueuer(fe FollowupEnqueuer)
SetFollowupEnqueuer wires the follow-up message enqueuer.
func (*Registry) SetHookRegistrar ¶ added in v1.16.0
func (r *Registry) SetHookRegistrar(hr HookRegistrar)
SetHookRegistrar wires the hook registrar.
func (*Registry) SetSkillRegistrar ¶ added in v1.16.0
func (r *Registry) SetSkillRegistrar(sr SkillRegistrar)
SetSkillRegistrar wires the skill registrar.
func (*Registry) SetToolRegistrar ¶ added in v1.16.0
func (r *Registry) SetToolRegistrar(tr ToolRegistrar)
SetToolRegistrar wires the tool registrar (typically the ToolExecutor).
type ServiceDef ¶ added in v1.16.0
type ServiceDef struct {
// ID is the service identifier.
ID string `yaml:"id" json:"id"`
// Name is the human-readable service name.
Name string `yaml:"name" json:"name"`
// Description explains the service's purpose.
Description string `yaml:"description" json:"description,omitempty"`
// Handler is a Go symbol name for native service handlers.
Handler string `yaml:"handler" json:"handler,omitempty"`
// Path is the HTTP path prefix (e.g. "/webhooks/myplugin").
Path string `yaml:"path" json:"path,omitempty"`
// Method is the HTTP method (GET, POST, etc.).
Method string `yaml:"method" json:"method,omitempty"`
}
ServiceDef defines a plugin-provided HTTP service endpoint.
type SkillDef ¶ added in v1.16.0
type SkillDef struct {
// Name is the skill name.
Name string `yaml:"name" json:"name"`
// Description explains the skill's purpose.
Description string `yaml:"description" json:"description,omitempty"`
// SkillMD is the relative path to the SKILL.md file within the plugin directory.
SkillMD string `yaml:"skill_md" json:"skill_md"`
}
SkillDef defines a plugin-provided skill.
type SkillRegistrar ¶ added in v1.16.0
SkillRegistrar registers skills.
type SubagentSpawner ¶ added in v1.16.0
type SubagentSpawner interface {
SpawnPluginAgent(ctx context.Context, executor any, llmClient any, prompt, task string, params any) (string, error)
}
SubagentSpawner spawns subagents with custom executors and prompts.
type ToolDef ¶ added in v1.16.0
type ToolDef struct {
// Name is the tool name (will be namespaced as pluginID_name).
Name string `yaml:"name" json:"name"`
// Description explains what the tool does.
Description string `yaml:"description" json:"description"`
// Parameters is the JSON Schema for the tool's parameters.
Parameters map[string]any `yaml:"parameters" json:"parameters,omitempty"`
// Permission is the required access level ("owner", "admin", "user").
Permission string `yaml:"permission" json:"permission,omitempty"`
// Hidden excludes the tool from the LLM tool schema.
Hidden bool `yaml:"hidden" json:"hidden,omitempty"`
// Handler is a Go symbol name for native tool handlers (requires NativeLib).
Handler string `yaml:"handler" json:"handler,omitempty"`
// Endpoint is the HTTP URL for HTTP-based tool handlers.
Endpoint string `yaml:"endpoint" json:"endpoint,omitempty"`
// Method is the HTTP method (GET, POST, etc.) for HTTP-based tools.
Method string `yaml:"method" json:"method,omitempty"`
// Headers are additional HTTP headers for HTTP-based tools.
Headers map[string]string `yaml:"headers" json:"headers,omitempty"`
// Script is inline bash script for script-based tool handlers.
Script string `yaml:"script" json:"script,omitempty"`
}
ToolDef defines a plugin-provided tool.
type ToolHandlerFunc ¶ added in v1.16.0
ToolHandlerFunc is the signature for plugin tool handlers.
func BuildToolHandler ¶ added in v1.16.0
func BuildToolHandler(def ToolDef, instance *PluginInstance) (ToolHandlerFunc, error)
BuildToolHandler creates a tool handler function for a ToolDef. It dispatches to the appropriate handler type (script, HTTP, or native).
type ToolRegistrar ¶ added in v1.16.0
type ToolRegistrar interface {
RegisterPluginTool(reg ToolRegistration)
UnregisterTool(name string) bool
}
ToolRegistrar registers and unregisters tools with the executor.
type ToolRegistration ¶ added in v1.16.0
type ToolRegistration struct {
Name string
Description string
Parameters json.RawMessage
Hidden bool
Permission string
Handler func(ctx context.Context, args map[string]any) (any, error)
}
ToolRegistration describes a tool to register with the executor.
type TriggerMatch ¶ added in v1.16.0
TriggerMatch represents a matched trigger for a plugin agent.
type UIAction ¶ added in v1.16.0
type UIAction struct {
// Label is the button text.
Label string `yaml:"label" json:"label"`
// Description is shown as a tooltip.
Description string `yaml:"description" json:"description,omitempty"`
// Tool is the namespaced tool name to invoke (e.g. "hello-world_greet").
Tool string `yaml:"tool" json:"tool"`
// Confirm shows a confirmation dialog before executing.
Confirm bool `yaml:"confirm" json:"confirm,omitempty"`
// Icon is a Lucide icon name for the button.
Icon string `yaml:"icon" json:"icon,omitempty"`
}
UIAction defines a quick-action button in the plugin detail view.
type UISection ¶ added in v1.16.0
type UISection struct {
// Title is the section heading.
Title string `yaml:"title" json:"title"`
// Description is an optional subtitle.
Description string `yaml:"description" json:"description,omitempty"`
// Fields references config field keys (from config.fields[].key).
Fields []string `yaml:"fields" json:"fields"`
// Collapsible makes the section collapsible in the UI.
Collapsible bool `yaml:"collapsible" json:"collapsible,omitempty"`
}
UISection groups related config fields in the settings form.