mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
- Separate built-in plugin interface from external plugin interface - Route dynamic plugin loading through homeagent-sdk/sdk using reflection - Turn internal/sdk into an enhanced wrapper over canonical SDK types - Vendor SDK repo snapshot under third_party/homeagent-sdk for stable builds - Keep internal constructors/adapters for memory, knowledge, llm, settings - Align dynamic QQ loading with canonical SDK chain
55 lines
1.0 KiB
Cheetah
55 lines
1.0 KiB
Cheetah
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"gitcode.com/JianFeeeee/homeagent-sdk/sdk"
|
|
)
|
|
|
|
type Plugin struct {
|
|
name string
|
|
sdk *sdk.PluginSDK
|
|
}
|
|
|
|
func NewPlugin(name string, config map[string]interface{}) (sdk.Plugin, error) {
|
|
return &Plugin{
|
|
name: name,
|
|
}, nil
|
|
}
|
|
|
|
func (p *Plugin) Name() string { return p.name }
|
|
|
|
func (p *Plugin) Start(s *sdk.PluginSDK) error {
|
|
p.sdk = s
|
|
|
|
tp := p.name + "_"
|
|
|
|
s.RegisterTool(tp+"example", sdk.ToolDef{
|
|
Name: tp + "example",
|
|
Description: "示例工具 - 请替换为实现",
|
|
Parameters: map[string]interface{}{
|
|
"type": "object",
|
|
"properties": map[string]interface{}{
|
|
"input": map[string]interface{}{"type": "string", "description": "输入参数"},
|
|
},
|
|
"required": []string{"input"},
|
|
},
|
|
}, p.handleExample)
|
|
|
|
log.Printf("[%s] plugin started", p.name)
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) Stop() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) handleExample(args map[string]interface{}) (interface{}, error) {
|
|
input, _ := args["input"].(string)
|
|
return map[string]interface{}{
|
|
"echo": input,
|
|
}, nil
|
|
}
|
|
|
|
func main() {}
|