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>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package sdk
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// Plugin is the main interface every plugin must implement.
|
|
type Plugin interface {
|
|
Metadata() PluginMetadata
|
|
Init(ctx context.Context, config PluginConfig) error
|
|
Start(ctx context.Context, host HostAPI) error
|
|
Stop(ctx context.Context) error
|
|
Health(ctx context.Context) error
|
|
Tools() []Tool
|
|
}
|
|
|
|
// Tool is the interface every tool must implement.
|
|
type Tool interface {
|
|
Definition() ToolDefinition
|
|
Execute(ctx context.Context, args map[string]interface{}) (*ToolResult, error)
|
|
Validate(args map[string]interface{}) error
|
|
Complexity() ToolComplexity
|
|
}
|
|
|
|
// ComplexTool extends Tool for async multi-round execution.
|
|
type ComplexTool interface {
|
|
Tool
|
|
ExecuteAsync(ctx context.Context, args map[string]interface{}) (<-chan ToolProgress, error)
|
|
Cancel(ctx context.Context, executionID string) error
|
|
}
|
|
|
|
// HostAPI gives plugins access to Cyrene core capabilities.
|
|
type HostAPI interface {
|
|
CallLLM(ctx context.Context, messages []LLMMessage) (*LLMResponse, error)
|
|
SearchMemory(ctx context.Context, userID, query string, limit int) ([]MemoryEntry, error)
|
|
StoreMemory(ctx context.Context, entry MemoryEntry) error
|
|
Logger() Logger
|
|
GetConfig(key string) (string, error)
|
|
SetConfig(key, value string) error
|
|
PublishEvent(ctx context.Context, event map[string]interface{}) error
|
|
HTTPClient() *http.Client
|
|
}
|
|
|
|
// Logger is a minimal logging interface for plugins.
|
|
type Logger interface {
|
|
Printf(format string, args ...interface{})
|
|
Println(args ...interface{})
|
|
}
|