plugin

package
v0.0.0-...-8acab51 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScheduleWithResult

func ScheduleWithResult[T any](s *PluginScheduler, ctx context.Context, fn func(context.Context) (T, error)) (T, error)

ScheduleWithResult schedules a function for execution and returns a result

func ValidatePluginID

func ValidatePluginID(raw string) (string, error)

func WrapServiceStart

func WrapServiceStart(pluginID, serviceName string, startFn func(ctx context.Context) error, timeout time.Duration) func(ctx context.Context) error

WrapServiceStart wraps a service start with isolation

func WrapServiceStop

func WrapServiceStop(pluginID, serviceName string, stopFn func(ctx context.Context) error, timeout time.Duration) func(ctx context.Context) error

WrapServiceStop wraps a service stop with isolation

Types

type Command

type Command struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Handler     CommandHandler `json:"-"`
}

Command represents a custom command

type CommandHandler

type CommandHandler func(ctx context.Context, args []string) (string, error)

CommandHandler is the function signature for command handlers

func WrapCommandHandler

func WrapCommandHandler(pluginID string, handler CommandHandler, timeout time.Duration) CommandHandler

WrapCommandHandler wraps a command handler with isolation

type Dependency

type Dependency struct {
	ID       string `json:"id"`                 // Required plugin ID
	Version  string `json:"version,omitempty"`  // Version constraint (semver)
	Optional bool   `json:"optional,omitempty"` // If true, plugin can work without this dependency
}

Dependency represents a plugin dependency

type DependencyError

type DependencyError struct {
	PluginID     string
	DependencyID string
	Reason       string
}

DependencyError represents a dependency resolution error

func (*DependencyError) Error

func (e *DependencyError) Error() string

type DependencyResolver

type DependencyResolver struct {
	// contains filtered or unexported fields
}

DependencyResolver handles plugin dependency resolution

func NewDependencyResolver

func NewDependencyResolver(plugins map[string]*PluginInfo) *DependencyResolver

NewDependencyResolver creates a new dependency resolver

func (*DependencyResolver) CheckDependenciesSatisfied

func (r *DependencyResolver) CheckDependenciesSatisfied(pluginID string) (bool, []*DependencyError)

CheckDependenciesSatisfied checks if all dependencies of a plugin are satisfied

func (*DependencyResolver) GetDependencies

func (r *DependencyResolver) GetDependencies(pluginID string) []string

GetDependencies returns the dependencies of a plugin

func (*DependencyResolver) GetDependents

func (r *DependencyResolver) GetDependents(pluginID string) []string

GetDependents returns plugins that depend on the given plugin

func (*DependencyResolver) Resolve

func (r *DependencyResolver) Resolve() *ResolutionResult

Resolve resolves dependencies and returns a topologically sorted order

type HTTPHandler

type HTTPHandler func(ctx context.Context, req *HTTPRequest) (*HTTPResponse, error)

HTTPHandler is the function signature for HTTP handlers

func WrapHTTPHandler

func WrapHTTPHandler(pluginID string, handler HTTPHandler, timeout time.Duration) HTTPHandler

WrapHTTPHandler wraps an HTTP handler with isolation

type HTTPRequest

type HTTPRequest struct {
	Method  string
	Path    string
	Headers map[string]string
	Body    []byte
}

HTTPRequest represents an HTTP request

type HTTPResponse

type HTTPResponse struct {
	StatusCode int
	Headers    map[string]string
	Body       []byte
}

HTTPResponse represents an HTTP response

type HookHandler

type HookHandler func(ctx context.Context, data interface{}) error

HookHandler is the function signature for hook handlers

func WrapHookHandler

func WrapHookHandler(pluginID string, handler HookHandler, timeout time.Duration) HookHandler

WrapHookHandler wraps a hook handler with isolation

type IsolatedPlugin

type IsolatedPlugin struct {
	// contains filtered or unexported fields
}

IsolatedPlugin wraps a plugin with isolation

func NewIsolatedPlugin

func NewIsolatedPlugin(plugin NativePlugin, config *IsolationConfig) *IsolatedPlugin

NewIsolatedPlugin creates a new isolated plugin wrapper

func (*IsolatedPlugin) ID

func (p *IsolatedPlugin) ID() string

func (*IsolatedPlugin) Init

func (p *IsolatedPlugin) Init(ctx context.Context, api PluginAPI) error

func (*IsolatedPlugin) IsNative

func (p *IsolatedPlugin) IsNative() bool

func (*IsolatedPlugin) Manifest

func (p *IsolatedPlugin) Manifest() *Manifest

func (*IsolatedPlugin) Start

func (p *IsolatedPlugin) Start(ctx context.Context) error

func (*IsolatedPlugin) Stop

func (p *IsolatedPlugin) Stop(ctx context.Context) error

type IsolatedService

type IsolatedService struct {
	// contains filtered or unexported fields
}

IsolatedService wraps a service with isolation

func NewIsolatedService

func NewIsolatedService(service Service, pluginID string, config *IsolationConfig) *IsolatedService

NewIsolatedService creates a new isolated service wrapper

func (*IsolatedService) Name

func (s *IsolatedService) Name() string

func (*IsolatedService) Start

func (s *IsolatedService) Start(ctx context.Context) error

func (*IsolatedService) Stop

func (s *IsolatedService) Stop(ctx context.Context) error

type IsolationConfig

type IsolationConfig struct {
	// InitTimeout is the maximum time allowed for plugin initialization
	InitTimeout time.Duration
	// StartTimeout is the maximum time allowed for plugin start
	StartTimeout time.Duration
	// StopTimeout is the maximum time allowed for plugin stop
	StopTimeout time.Duration
	// ToolTimeout is the maximum time allowed for tool execution
	ToolTimeout time.Duration
	// HookTimeout is the maximum time allowed for hook execution
	HookTimeout time.Duration
	// CommandTimeout is the maximum time allowed for command execution
	CommandTimeout time.Duration
	// HTTPTimeout is the maximum time allowed for HTTP handler execution
	HTTPTimeout time.Duration
}

IsolationConfig configures plugin isolation behavior

func DefaultIsolationConfig

func DefaultIsolationConfig() *IsolationConfig

DefaultIsolationConfig returns the default isolation configuration

type JSBridge

type JSBridge struct {
	// contains filtered or unexported fields
}

JSBridge handles loading and executing JavaScript/TypeScript plugins Note: JavaScript plugin support is disabled to reduce binary size. Use native Go plugins instead.

func NewJSBridge

func NewJSBridge(registry *Registry) *JSBridge

NewJSBridge creates a new JavaScript bridge

func (*JSBridge) Close

func (b *JSBridge) Close()

Close closes all VMs

func (*JSBridge) LoadJSPlugin

func (b *JSBridge) LoadJSPlugin(ctx context.Context, pluginPath string, origin PluginOrigin) error

LoadJSPlugin loads a JavaScript plugin from a path Note: JavaScript plugin support is disabled to reduce binary size.

type Logger

type Logger interface {
	Debug(msg string, fields ...interface{})
	Info(msg string, fields ...interface{})
	Warn(msg string, fields ...interface{})
	Error(msg string, fields ...interface{})
}

Logger interface for plugin logging

type Manifest

type Manifest struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	Description  string                 `json:"description"`
	Version      string                 `json:"version"`
	Author       string                 `json:"author,omitempty"`
	Kind         PluginKind             `json:"kind,omitempty"`
	ConfigSchema map[string]interface{} `json:"configSchema"`
	Channels     []string               `json:"channels,omitempty"`
	Providers    []string               `json:"providers,omitempty"`
	Skills       []string               `json:"skills,omitempty"`
	UIHints      map[string]UIHint      `json:"uiHints,omitempty"`
	Dependencies []Dependency           `json:"dependencies,omitempty"`
}

Manifest represents the plugin manifest (clawdbot.plugin.json compatible)

type NativePlugin

type NativePlugin interface {
	Plugin

	// IsNative returns true for native Go plugins
	IsNative() bool
}

NativePlugin is the interface for Go native plugins

type Plugin

type Plugin interface {
	// ID returns the unique identifier of the plugin
	ID() string

	// Manifest returns the plugin manifest
	Manifest() *Manifest

	// Init initializes the plugin with the given API
	Init(ctx context.Context, api PluginAPI) error

	// Start starts the plugin
	Start(ctx context.Context) error

	// Stop stops the plugin
	Stop(ctx context.Context) error
}

Plugin is the interface that all plugins must implement

type PluginAPI

type PluginAPI interface {
	// Plugin metadata
	PluginID() string
	PluginConfig() map[string]interface{}

	// Tool registration
	RegisterTool(tool Tool) error

	// Hook registration
	RegisterHook(event string, handler HookHandler) error

	// Service registration
	RegisterService(service Service) error

	// Command registration
	RegisterCommand(command Command) error

	// HTTP handler registration
	RegisterHTTPHandler(path string, handler HTTPHandler) error

	// Logger
	Logger() Logger
}

PluginAPI is the API provided to plugins for registration

type PluginError

type PluginError struct {
	PluginID  string
	Operation string
	Err       error
	Panic     bool
	Stack     string
}

PluginError represents an error that occurred in a plugin

func (*PluginError) Error

func (e *PluginError) Error() string

func (*PluginError) Unwrap

func (e *PluginError) Unwrap() error

type PluginInfo

type PluginInfo struct {
	Manifest *Manifest              `json:"manifest"`
	Origin   PluginOrigin           `json:"origin"`
	Status   PluginStatus           `json:"status"`
	Path     string                 `json:"path"`
	Config   map[string]interface{} `json:"config,omitempty"`
	Error    string                 `json:"error,omitempty"`
	IsNative bool                   `json:"is_native"`
}

PluginInfo contains metadata about a loaded plugin

type PluginKind

type PluginKind string

PluginKind represents the type of plugin

const (
	PluginKindGeneral PluginKind = ""
	PluginKindMemory  PluginKind = "memory"
	PluginKindChannel PluginKind = "channel"
	PluginKindTool    PluginKind = "tool"
)

type PluginOrigin

type PluginOrigin string

PluginOrigin represents where the plugin was loaded from

const (
	OriginBundled   PluginOrigin = "bundled"
	OriginWorkspace PluginOrigin = "workspace"
	OriginConfig    PluginOrigin = "config"
	OriginNative    PluginOrigin = "native" // Go native plugins
)

type PluginRestrictions

type PluginRestrictions struct {
	// AllowNetworkAccess allows the plugin to make network requests
	AllowNetworkAccess bool `json:"allow_network_access"`
	// AllowFileAccess allows the plugin to access the filesystem
	AllowFileAccess bool `json:"allow_file_access"`
	// AllowedPaths restricts file access to specific paths
	AllowedPaths []string `json:"allowed_paths,omitempty"`
	// AllowedHosts restricts network access to specific hosts
	AllowedHosts []string `json:"allowed_hosts,omitempty"`
	// AllowExec allows the plugin to execute external commands
	AllowExec bool `json:"allow_exec"`
	// AllowedCommands restricts exec to specific commands
	AllowedCommands []string `json:"allowed_commands,omitempty"`
}

PluginRestrictions defines what a plugin is allowed to do

func DefaultPluginRestrictions

func DefaultPluginRestrictions() *PluginRestrictions

DefaultPluginRestrictions returns default plugin restrictions

func (*PluginRestrictions) CheckExec

func (r *PluginRestrictions) CheckExec(command string) error

CheckExec checks if executing a command is allowed

func (*PluginRestrictions) CheckFileAccess

func (r *PluginRestrictions) CheckFileAccess(path string) error

CheckFileAccess checks if file access to a path is allowed

func (*PluginRestrictions) CheckNetworkAccess

func (r *PluginRestrictions) CheckNetworkAccess(host string) error

CheckNetworkAccess checks if network access to a host is allowed

type PluginSandbox

type PluginSandbox struct {
	// contains filtered or unexported fields
}

PluginSandbox provides a sandboxed execution environment for plugins

func NewPluginSandbox

func NewPluginSandbox(pluginID string, limits *ResourceLimits) *PluginSandbox

NewPluginSandbox creates a new plugin sandbox

func (*PluginSandbox) GetStats

func (s *PluginSandbox) GetStats() *SandboxStats

GetStats returns sandbox statistics

func (*PluginSandbox) Go

func (s *PluginSandbox) Go(fn func()) error

Go spawns a controlled goroutine within the sandbox

func (*PluginSandbox) GoWithContext

func (s *PluginSandbox) GoWithContext(ctx context.Context, fn func(context.Context)) error

GoWithContext spawns a controlled goroutine with context

func (*PluginSandbox) GoroutineCount

func (s *PluginSandbox) GoroutineCount() int

GoroutineCount returns the current number of goroutines

type PluginScheduler

type PluginScheduler struct {
	// contains filtered or unexported fields
}

PluginScheduler controls plugin execution

func NewPluginScheduler

func NewPluginScheduler(pluginID string, maxConcurrent int) *PluginScheduler

NewPluginScheduler creates a new plugin scheduler

func (*PluginScheduler) Acquire

func (s *PluginScheduler) Acquire(ctx context.Context) error

Acquire acquires a slot in the scheduler

func (*PluginScheduler) Release

func (s *PluginScheduler) Release()

Release releases a slot in the scheduler

func (*PluginScheduler) Schedule

func (s *PluginScheduler) Schedule(ctx context.Context, fn func(context.Context) error) error

Schedule schedules a function for execution

type PluginStatus

type PluginStatus string

PluginStatus represents the current status of a plugin

const (
	StatusLoaded   PluginStatus = "loaded"
	StatusDisabled PluginStatus = "disabled"
	StatusError    PluginStatus = "error"
	StatusStopped  PluginStatus = "stopped"
)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages all loaded plugins

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry

func NewRegistryWithConfig

func NewRegistryWithConfig(config *IsolationConfig) *Registry

NewRegistryWithConfig creates a new plugin registry with custom isolation config

func (*Registry) GetCommand

func (r *Registry) GetCommand(name string) *Command

GetCommand returns a command by name

func (*Registry) GetHTTPHandler

func (r *Registry) GetHTTPHandler(path string) HTTPHandler

GetHTTPHandler returns an HTTP handler by path

func (*Registry) GetPlugin

func (r *Registry) GetPlugin(id string) *PluginInfo

GetPlugin returns plugin info by ID

func (*Registry) GetPluginDependencies

func (r *Registry) GetPluginDependencies(pluginID string) []string

GetPluginDependencies returns the dependencies of a plugin

func (*Registry) GetPluginDependents

func (r *Registry) GetPluginDependents(pluginID string) []string

GetPluginDependents returns plugins that depend on the given plugin

func (*Registry) GetTool

func (r *Registry) GetTool(name string) *Tool

GetTool returns a tool by name

func (*Registry) InitializePlugins

func (r *Registry) InitializePlugins(ctx context.Context) error

InitializePlugins initializes all loaded plugins in dependency order

func (*Registry) ListCommands

func (r *Registry) ListCommands() []*Command

ListCommands returns all registered commands

func (*Registry) ListPlugins

func (r *Registry) ListPlugins() []*PluginInfo

ListPlugins returns all loaded plugins

func (*Registry) ListTools

func (r *Registry) ListTools() []*Tool

ListTools returns all registered tools

func (*Registry) LoadPluginsFromDir

func (r *Registry) LoadPluginsFromDir(ctx context.Context, dir string) error

LoadPluginsFromDir loads plugins from a directory

func (*Registry) RegisterNativePlugin

func (r *Registry) RegisterNativePlugin(plugin NativePlugin) error

RegisterNativePlugin registers a Go native plugin

func (*Registry) ResolveDependencies

func (r *Registry) ResolveDependencies() *ResolutionResult

ResolveDependencies resolves plugin dependencies and returns the result

func (*Registry) SetPluginStatus

func (r *Registry) SetPluginStatus(id string, status PluginStatus) error

SetPluginStatus updates the status of a plugin

func (*Registry) StartPlugin

func (r *Registry) StartPlugin(ctx context.Context, id string) error

StartPlugin starts a specific plugin by ID

func (*Registry) StartPlugins

func (r *Registry) StartPlugins(ctx context.Context) error

StartPlugins starts all loaded plugins in dependency order

func (*Registry) StopPlugin

func (r *Registry) StopPlugin(ctx context.Context, id string) error

StopPlugin stops a specific plugin by ID

func (*Registry) StopPlugins

func (r *Registry) StopPlugins(ctx context.Context) error

StopPlugins stops all loaded plugins

func (*Registry) TriggerHook

func (r *Registry) TriggerHook(ctx context.Context, event string, data interface{}) error

TriggerHook triggers all handlers for a hook event

func (*Registry) UnregisterPlugin

func (r *Registry) UnregisterPlugin(id string)

UnregisterPlugin removes a plugin from the registry

type ResolutionResult

type ResolutionResult struct {
	// Order is the topologically sorted list of plugin IDs
	Order []string
	// Errors contains any dependency errors encountered
	Errors []*DependencyError
	// Warnings contains non-fatal issues (e.g., optional dependencies not found)
	Warnings []string
}

ResolutionResult contains the result of dependency resolution

type ResourceLimits

type ResourceLimits struct {
	// MaxMemoryMB is the maximum memory usage in megabytes (0 = unlimited)
	MaxMemoryMB int64 `json:"max_memory_mb"`
	// MaxCPUPercent is the maximum CPU usage percentage (0 = unlimited)
	MaxCPUPercent int `json:"max_cpu_percent"`
	// MaxGoroutines is the maximum number of goroutines (0 = unlimited)
	MaxGoroutines int `json:"max_goroutines"`
	// MaxExecutionTime is the maximum execution time for a single operation
	MaxExecutionTime time.Duration `json:"max_execution_time"`
	// MaxConcurrentOps is the maximum number of concurrent operations
	MaxConcurrentOps int `json:"max_concurrent_ops"`
}

ResourceLimits defines resource limits for a plugin

func DefaultResourceLimits

func DefaultResourceLimits() *ResourceLimits

DefaultResourceLimits returns default resource limits

type ResourceMonitor

type ResourceMonitor struct {
	// contains filtered or unexported fields
}

ResourceMonitor monitors resource usage for plugins

func NewResourceMonitor

func NewResourceMonitor(pluginID string, limits *ResourceLimits) *ResourceMonitor

NewResourceMonitor creates a new resource monitor

func (*ResourceMonitor) AcquireOperation

func (m *ResourceMonitor) AcquireOperation(ctx context.Context) error

AcquireOperation acquires a slot for an operation

func (*ResourceMonitor) CheckLimits

func (m *ResourceMonitor) CheckLimits() error

CheckLimits checks if the plugin is within resource limits

func (*ResourceMonitor) GetStats

func (m *ResourceMonitor) GetStats() *ResourceStats

GetStats returns current resource usage statistics

func (*ResourceMonitor) RecordFailure

func (m *ResourceMonitor) RecordFailure()

RecordFailure records a failed operation

func (*ResourceMonitor) ReleaseOperation

func (m *ResourceMonitor) ReleaseOperation()

ReleaseOperation releases an operation slot

type ResourceStats

type ResourceStats struct {
	PluginID       string `json:"plugin_id"`
	CurrentOps     int64  `json:"current_ops"`
	TotalOps       int64  `json:"total_ops"`
	FailedOps      int64  `json:"failed_ops"`
	GoroutineCount int64  `json:"goroutine_count"`
	Violations     int64  `json:"violations"`
}

ResourceStats contains resource usage statistics

type RestrictedPluginAPI

type RestrictedPluginAPI struct {
	// contains filtered or unexported fields
}

RestrictedPluginAPI wraps PluginAPI with resource restrictions

func NewRestrictedPluginAPI

func NewRestrictedPluginAPI(inner PluginAPI, limits *ResourceLimits) *RestrictedPluginAPI

NewRestrictedPluginAPI creates a new restricted plugin API

func (*RestrictedPluginAPI) GetResourceStats

func (a *RestrictedPluginAPI) GetResourceStats() *ResourceStats

GetResourceStats returns the resource usage statistics

func (*RestrictedPluginAPI) Logger

func (a *RestrictedPluginAPI) Logger() Logger

func (*RestrictedPluginAPI) PluginConfig

func (a *RestrictedPluginAPI) PluginConfig() map[string]interface{}

func (*RestrictedPluginAPI) PluginID

func (a *RestrictedPluginAPI) PluginID() string

func (*RestrictedPluginAPI) RegisterCommand

func (a *RestrictedPluginAPI) RegisterCommand(command Command) error

func (*RestrictedPluginAPI) RegisterHTTPHandler

func (a *RestrictedPluginAPI) RegisterHTTPHandler(path string, handler HTTPHandler) error

func (*RestrictedPluginAPI) RegisterHook

func (a *RestrictedPluginAPI) RegisterHook(event string, handler HookHandler) error

func (*RestrictedPluginAPI) RegisterService

func (a *RestrictedPluginAPI) RegisterService(service Service) error

func (*RestrictedPluginAPI) RegisterTool

func (a *RestrictedPluginAPI) RegisterTool(tool Tool) error

type SandboxStats

type SandboxStats struct {
	PluginID       string         `json:"plugin_id"`
	GoroutineCount int            `json:"goroutine_count"`
	ResourceStats  *ResourceStats `json:"resource_stats"`
}

SandboxStats contains sandbox statistics

type Service

type Service interface {
	Name() string
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

Service represents a background service

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages the plugin marketplace

func NewStore

func NewStore(config *StoreConfig, registry *Registry) *Store

NewStore creates a new plugin store

func (*Store) GetPlugin

func (s *Store) GetPlugin(ctx context.Context, id string) (*StorePlugin, error)

GetPlugin returns a specific plugin from the store

func (*Store) InstallPlugin

func (s *Store) InstallPlugin(ctx context.Context, id string) error

InstallPlugin downloads and installs a plugin

func (*Store) ListPlugins

func (s *Store) ListPlugins(ctx context.Context) ([]*StorePlugin, error)

ListPlugins returns all available plugins from all sources

func (*Store) SearchPlugins

func (s *Store) SearchPlugins(ctx context.Context, query string) ([]*StorePlugin, error)

SearchPlugins searches for plugins by query

func (*Store) UninstallPlugin

func (s *Store) UninstallPlugin(ctx context.Context, id string) error

UninstallPlugin removes an installed plugin

type StoreConfig

type StoreConfig struct {
	CacheDir       string        `json:"cache_dir"`
	CacheDuration  time.Duration `json:"cache_duration"`
	MoltbotRepo    string        `json:"moltbot_repo"`
	MoltbotBranch  string        `json:"moltbot_branch"`
	CustomSources  []string      `json:"custom_sources"`
	UseJsdelivr    bool          `json:"use_jsdelivr"`    // If true, try jsdelivr CDN first for faster access
	JsdelivrMirror string        `json:"jsdelivr_mirror"` // Custom jsdelivr mirror (e.g., "fastly.jsdelivr.net", "gcore.jsdelivr.net")
}

StoreConfig holds plugin store configuration

func DefaultStoreConfig

func DefaultStoreConfig() *StoreConfig

DefaultStoreConfig returns default store configuration

type StorePlugin

type StorePlugin struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Version     string      `json:"version"`
	Author      string      `json:"author"`
	Source      StoreSource `json:"source"`
	RepoURL     string      `json:"repo_url"`
	DownloadURL string      `json:"download_url"`
	Manifest    *Manifest   `json:"manifest,omitempty"`
	Tags        []string    `json:"tags,omitempty"`
	Downloads   int         `json:"downloads"`
	Rating      float64     `json:"rating"`
	UpdatedAt   time.Time   `json:"updated_at"`
	Installed   bool        `json:"installed"`
}

StorePlugin represents a plugin available in the store

type StoreSource

type StoreSource string

StoreSource represents a plugin source

const (
	SourceMoltbot  StoreSource = "moltbot"
	SourceClawdHub StoreSource = "clawdhub"
	SourceGitHub   StoreSource = "github"
	SourceCustom   StoreSource = "custom"
)

type Tool

type Tool struct {
	Name                string                 `json:"name"`
	Description         string                 `json:"description"`
	Parameters          map[string]interface{} `json:"parameters"`
	RiskLevel           string                 `json:"risk_level,omitempty"`
	VisibilityAllowlist []string               `json:"visibility_allowlist,omitempty"`
	Handler             ToolHandler            `json:"-"`
}

Tool represents an agent tool

type ToolHandler

type ToolHandler func(ctx context.Context, params map[string]interface{}) (interface{}, error)

ToolHandler is the function signature for tool handlers

func WrapToolHandler

func WrapToolHandler(pluginID string, handler ToolHandler, timeout time.Duration) ToolHandler

WrapToolHandler wraps a tool handler with isolation

type UIHint

type UIHint struct {
	Label     string `json:"label,omitempty"`
	Help      string `json:"help,omitempty"`
	Sensitive bool   `json:"sensitive,omitempty"`
	Advanced  bool   `json:"advanced,omitempty"`
}

UIHint provides UI hints for configuration fields

Directories

Path Synopsis
Package sdk provides a comprehensive SDK for plugin development.
Package sdk provides a comprehensive SDK for plugin development.

Jump to

Keyboard shortcuts

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