mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-08 08:36:57 +00:00
fix: cap distiller startup scan and switch to formal SDK module dependency
- replace vendored third_party/homeagent-sdk with formal module dependency - keep canonical SDK via go.mod pinned commit - optimize distiller startup loading to stream recent raw records only - parse timestamps correctly and cap startup load to 5000 records - remove quadratic string building in raw record parsing - restore fast startup while preserving memory pipeline
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
# Build external Go plugin for HomeAgent
|
||||
# Usage: make # build plugin.so
|
||||
# make clean # remove plugin.so
|
||||
|
||||
PLUGIN_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
SDK_ROOT := $(realpath $(PLUGIN_DIR)../..)
|
||||
PLUGIN_NAME := $(notdir $(realpath $(PLUGIN_DIR)))
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: plugin.so
|
||||
|
||||
plugin.so:
|
||||
cd $(SDK_ROOT) && go build -buildmode=plugin -o $(PLUGIN_DIR)plugin.so $(PLUGIN_DIR)
|
||||
|
||||
clean:
|
||||
rm -f $(PLUGIN_DIR)plugin.so
|
||||
@ -1,2 +0,0 @@
|
||||
plugin.so
|
||||
*.hmap
|
||||
@ -1,54 +0,0 @@
|
||||
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() {}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "{{.Name}}",
|
||||
"version": "{{.Version}}",
|
||||
"description": "{{.Description}}",
|
||||
"author": "{{.Author}}",
|
||||
"license": "MIT",
|
||||
"entry": "plugin.so",
|
||||
"min_version": "1.0.0",
|
||||
"tags": ["{{.Name}}"]
|
||||
}
|
||||
Reference in New Issue
Block a user