673ff752c5
- 新增 backend/pkg/plugins/ 共享模块:SDK 接口、PluginManager、ToolRegistry(含环形缓冲区调用日志) - 13 个通用插件从 plugin-manager 迁移至共享模块(import 路径统一) - ai-core 切换至共享 ToolRegistry,进程内执行(零网络开销),包装 6 个专属工具 - plugin-manager 迁移至共享模块,保留管理 REST API - 新增 DevTools 插件管理面板(侧边栏 → 🔌 插件管理) - 移除 tool-engine 服务(从 go.work、DevTools 配置、编译系统) - 工具调用记录 API 从 Tool-Engine 迁至 AI-Core(/api/v1/tools/calls) - ai-core ContextStore 启动时从 PostgreSQL 恢复会话历史 - 清理所有过时引用和备份文件 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
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")
|
|
}
|