Initial commit: Cyrene Plugins SDK + Plugin Manager
Extracted from Cyrene main repo (backend/pkg/plugins + backend/plugin-manager). Contains SDK interfaces (Plugin/Tool/HostAPI), 13 built-in plugins, ToolRegistry with call log ring buffer, and Plugin Manager REST API service. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// BasePlugin provides default implementations for optional Plugin methods.
|
||||
type BasePlugin struct{}
|
||||
|
||||
func (BasePlugin) Init(_ context.Context, _ PluginConfig) error { return nil }
|
||||
|
||||
func (BasePlugin) Start(_ context.Context, _ HostAPI) error { return nil }
|
||||
|
||||
func (BasePlugin) Stop(_ context.Context) error { return nil }
|
||||
|
||||
func (BasePlugin) Health(_ context.Context) error { return nil }
|
||||
|
||||
// BaseTool provides a Validate default that checks required parameters.
|
||||
type BaseTool struct {
|
||||
Def ToolDefinition
|
||||
Required []string
|
||||
}
|
||||
|
||||
func (b BaseTool) Definition() ToolDefinition { return b.Def }
|
||||
|
||||
func (b BaseTool) Complexity() ToolComplexity { return ComplexitySimple }
|
||||
|
||||
func (b BaseTool) Validate(args map[string]interface{}) error {
|
||||
for _, key := range b.Required {
|
||||
if _, ok := args[key]; !ok {
|
||||
return fmt.Errorf("missing required parameter: %s", key)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b BaseTool) Execute(_ context.Context, _ map[string]interface{}) (*ToolResult, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
}
|
||||
Reference in New Issue
Block a user