717ad65b05
- Plugin SDK: Plugin/Tool/ComplexTool/HostAPI 标准化接口 - Plugin Manager: 插件生命周期管理 (Install/Enable/Disable/Uninstall/Reload) - Tool Registry: 聚合工具注册表 (Register/Execute/Dispatch) - 13 个内置插件: 将原有硬编码工具迁移为标准插件格式 - REST API: 11 个端点 (net/http, 零外部依赖) - ai-core 集成: PluginManagerClient 替代本地工具调用 - plugin.json 元数据: 每个插件含完整 author/version/category/permissions Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/yourname/cyrene-ai/plugin-manager/internal/manager"
|
|
"github.com/yourname/cyrene-ai/plugin-manager/internal/sdk"
|
|
)
|
|
|
|
type hostAPI struct {
|
|
registry *manager.ToolRegistry
|
|
}
|
|
|
|
func newHostAPI(registry *manager.ToolRegistry) *hostAPI {
|
|
return &hostAPI{registry: registry}
|
|
}
|
|
|
|
func (h *hostAPI) CallLLM(_ context.Context, _ []sdk.LLMMessage) (*sdk.LLMResponse, error) {
|
|
return nil, fmt.Errorf("LLM call not available in plugin host")
|
|
}
|
|
|
|
func (h *hostAPI) SearchMemory(_ context.Context, _, _ string, _ int) ([]sdk.MemoryEntry, error) {
|
|
return nil, fmt.Errorf("memory search not available in plugin host")
|
|
}
|
|
|
|
func (h *hostAPI) StoreMemory(_ context.Context, _ sdk.MemoryEntry) error {
|
|
return fmt.Errorf("memory store not available in plugin host")
|
|
}
|
|
|
|
func (h *hostAPI) Logger() sdk.Logger {
|
|
return log.Default()
|
|
}
|
|
|
|
func (h *hostAPI) GetConfig(key string) (string, error) {
|
|
return "", fmt.Errorf("config key not found: %s", key)
|
|
}
|
|
|
|
func (h *hostAPI) SetConfig(_, _ string) error {
|
|
return nil
|
|
}
|
|
|
|
func (h *hostAPI) PublishEvent(_ context.Context, _ map[string]interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
func (h *hostAPI) HTTPClient() *http.Client {
|
|
return http.DefaultClient
|
|
}
|