- plugins: calculator, datetime, crypto, random, text, json, markdown - plugins: web-search (SearXNG stub), web-fetch, file, http (stubs) - main.go: full wiring — config→db→nats→plugins→voice→memory→ persona→llm→context→subsession→orchestrator→gateway→ws - 15 packages passing, 11 plugins loaded at startup
24 lines
1.1 KiB
Go
24 lines
1.1 KiB
Go
package crypto
|
|
import (
|
|
"context"; "crypto/md5"; "crypto/sha256"; "encoding/hex"
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/plugin"
|
|
)
|
|
type Plugin struct{}
|
|
func New() *Plugin { return &Plugin{} }
|
|
func (p *Plugin) Name() string { return "crypto" }
|
|
func (p *Plugin) Version() string { return "1.0.0" }
|
|
func (p *Plugin) Description() string { return "哈希加密" }
|
|
func (p *Plugin) Init(_ context.Context, _ plugin.PluginConfig) error { return nil }
|
|
func (p *Plugin) Close() error { return nil }
|
|
func (p *Plugin) Enabled() bool { return true }
|
|
func (p *Plugin) Tools() []plugin.ToolDefinition {
|
|
return []plugin.ToolDefinition{{Name:"crypto", Description:"MD5/SHA256", Parameters:map[string]any{"algo":map[string]string{"type":"string"}, "text":map[string]string{"type":"string"}}}}
|
|
}
|
|
func (p *Plugin) Execute(_ context.Context, _ string, params map[string]any) (string, error) {
|
|
text,_ := params["text"].(string)
|
|
if algo,_ := params["algo"].(string); algo == "sha256" {
|
|
h := sha256.Sum256([]byte(text)); return hex.EncodeToString(h[:]), nil
|
|
}
|
|
h := md5.Sum([]byte(text)); return hex.EncodeToString(h[:]), nil
|
|
}
|