Documentation
¶
Index ¶
- func CreateDefaultPluginsDir(workingDir string) error
- type AgentDef
- type HookDef
- type Loader
- func (l *Loader) Discover() ([]*Manifest, error)
- func (l *Loader) FilterByType(pluginType PluginType) []*Plugin
- func (l *Loader) Get(name string) (*Plugin, bool)
- func (l *Loader) GetAgents() []*Plugin
- func (l *Loader) GetHooks() []*Plugin
- func (l *Loader) GetTools() []*Plugin
- func (l *Loader) Install(sourceDir string) (*Manifest, error)
- func (l *Loader) List() []*Plugin
- func (l *Loader) LoadAll() ([]*Plugin, error)
- func (l *Loader) LoadPlugin(manifest *Manifest) (*Plugin, error)
- func (l *Loader) Uninstall(name string) error
- func (l *Loader) Unload(name string) error
- func (l *Loader) UnloadAll()
- type Manifest
- func (m *Manifest) CheckCompatibility() error
- func (m *Manifest) EntryPath() string
- func (m *Manifest) HasPermission(perm string) bool
- func (m *Manifest) IsCommandAllowed(cmd string) bool
- func (m *Manifest) IsPathAllowed(path string) bool
- func (m *Manifest) MaxMemoryBytes() int64
- func (m *Manifest) TimeoutDuration() time.Duration
- func (m *Manifest) Validate() error
- type Permissions
- type Plugin
- type PluginType
- type Runtime
- type ToolDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDefaultPluginsDir ¶
CreateDefaultPluginsDir creates the default plugins directory if it doesn't exist.
Types ¶
type AgentDef ¶
type AgentDef struct {
Name string `json:"name"`
Description string `json:"description"`
SystemPrompt string `json:"system_prompt,omitempty"`
Model string `json:"model,omitempty"`
Tools []string `json:"tools,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
AgentDef defines an agent provided by a plugin.
type HookDef ¶
type HookDef struct {
Name string `json:"name"`
Trigger string `json:"trigger"`
Script string `json:"script,omitempty"`
}
HookDef defines a hook that a plugin can register.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader discovers, validates, and manages plugins.
func NewLoaderWithDir ¶
NewLoaderWithDir creates a new plugin loader with a custom plugins directory.
func (*Loader) FilterByType ¶
func (l *Loader) FilterByType(pluginType PluginType) []*Plugin
FilterByType returns plugins of a specific type.
func (*Loader) LoadPlugin ¶
LoadPlugin loads a single plugin from its manifest.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
License string `json:"license,omitempty"`
Homepage string `json:"homepage,omitempty"`
Type PluginType `json:"type"`
Icon string `json:"icon,omitempty"`
// Entry points
Main string `json:"main,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
// Runtime configuration
Runtime string `json:"runtime,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
// Permissions
Permissions Permissions `json:"permissions,omitempty"`
// Hooks (for hook-type plugins)
Hooks []HookDef `json:"hooks,omitempty"`
// Tool definition (for tool-type plugins)
ToolDef *ToolDef `json:"tool,omitempty"`
// Agent definition (for agent-type plugins)
AgentDef *AgentDef `json:"agent,omitempty"`
// Dependencies
Dependencies map[string]string `json:"dependencies,omitempty"`
// Compatibility
MinGhostVersion string `json:"min_ghost_version,omitempty"`
MaxGhostVersion string `json:"max_ghost_version,omitempty"`
OS []string `json:"os,omitempty"`
Arch []string `json:"arch,omitempty"`
// Internal state
InstallPath string `json:"-"`
Enabled bool `json:"-"`
Loaded bool `json:"-"`
LoadError string `json:"-"`
}
Manifest defines the plugin metadata and configuration.
func LoadManifest ¶
LoadManifest reads and validates a plugin manifest from the given directory.
func (*Manifest) CheckCompatibility ¶
CheckCompatibility checks if the plugin is compatible with the current environment.
func (*Manifest) HasPermission ¶
HasPermission checks if the plugin has a specific permission.
func (*Manifest) IsCommandAllowed ¶
IsCommandAllowed checks if a command is in the plugin's allowed commands.
func (*Manifest) IsPathAllowed ¶
IsPathAllowed checks if a file path is within the plugin's allowed paths.
func (*Manifest) MaxMemoryBytes ¶
MaxMemory returns the plugin's memory limit in bytes.
func (*Manifest) TimeoutDuration ¶
Timeout returns the plugin's execution timeout with a default fallback.
type Permissions ¶
type Permissions struct {
Network bool `json:"network,omitempty"`
FileSystem bool `json:"filesystem,omitempty"`
AllowedPaths []string `json:"allowed_paths,omitempty"`
EnvVars []string `json:"allowed_env,omitempty"`
Commands []string `json:"allowed_commands,omitempty"`
MaxMemoryMB int `json:"max_memory_mb,omitempty"`
MaxTimeout time.Duration `json:"max_timeout,omitempty"`
}
Permissions defines what a plugin is allowed to do.
type PluginType ¶
type PluginType string
PluginType defines the type of plugin.
const ( PluginTypeTool PluginType = "tool" PluginTypeHook PluginType = "hook" PluginTypeTheme PluginType = "theme" PluginTypeScript PluginType = "script" PluginTypeAgent PluginType = "agent" )
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime manages the execution environment for a plugin.
func NewRuntime ¶
NewRuntime creates a new runtime for a plugin.
func (*Runtime) ExecuteScript ¶
func (r *Runtime) ExecuteScript(ctx context.Context, scriptPath string, args ...string) (string, error)
ExecuteScript runs an arbitrary script from the plugin directory.