mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
feat: files built-in plugin, doc rewrite, architecture cleanup
- Add files plugin as built-in (internal/plugins/files/) with read/write/edit/ls tools, supporting overwrite/append/insert/create modes and offset/limit segmented reading - Rewrite README.md with core domain separation and three-layer memory highlights - Rewrite docs/OVERVIEW.md with per-subsystem file path references - Rewrite docs/ARCHITECTURE.md (783→~300 lines), merge redundant sections - Clean docs/PLUGIN_DEV.md: remove emoji, simplify SDK examples - Fix provider Model pollution in LuaAdaptedProvider.Chat() - Fix executeToolCall to return actual error vs quiet not-found - Fix plugin.Open path caching with SHA256 temp-path workaround - Add knowledge/homeagent_architecture demo entry - Add config/personal/personal.md identity configuration
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
@ -51,9 +53,23 @@ func tryLoadSO(dir, name string, config map[string]interface{}) (sdk.Plugin, err
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
p, err := plugin.Open(soPath)
|
||||
// 复制到临时路径以绕过 Go plugin.Open 的路径缓存
|
||||
data, err := os.ReadFile(soPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("plugin.Open %s: %w", soPath, err)
|
||||
return nil, fmt.Errorf("read %s: %w", soPath, err)
|
||||
}
|
||||
h := sha256.Sum256(data)
|
||||
cacheKey := fmt.Sprintf("plugin_%s_%s.so", name, hex.EncodeToString(h[:8]))
|
||||
cachePath := filepath.Join(os.TempDir(), cacheKey)
|
||||
if _, err := os.Stat(cachePath); os.IsNotExist(err) {
|
||||
if err := os.WriteFile(cachePath, data, 0644); err != nil {
|
||||
return nil, fmt.Errorf("write cache %s: %w", cachePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
p, err := plugin.Open(cachePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("plugin.Open %s: %w", cachePath, err)
|
||||
}
|
||||
|
||||
sym, err := p.Lookup("NewPlugin")
|
||||
|
||||
Reference in New Issue
Block a user