mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-24 19:08:10 +00:00
feat(lua): Lua 插件桥全量对齐 SDK 1.3.0(媒体/注入标志位/优先级/事件/通道注销)
内核 Lua 桥(internal/plugin/lua_plugin.go)此前停在 v0.8.0 时代能力面, 1.1/1.2/1.3 新增能力只在 Go 侧存在,而 PLUGIN_DEV.md 宣称『能力完全对齐』。 本补丁把 Lua 侧补齐到与公开 SDK 1.3.0 对齐: - 1.1 媒体:memory.commit 支持 sentence_text/media_digests; doc.insert_with_media + attachments;text_memory.append attachments; set_tool_blocks / inject_input_media(_sync) / inject_interrupt_media。 - 1.2 注入语义:inject_input_sync(_opts)、六个 *_opts 变体 (no_memory/context_policy/cleaner_name/priority); ToolDef/ChannelDef 解析 context_policy。 - 1.3 优先级与动态通道:priority 常量透传;unregister_output_channel。 - StageContext 暴露 reasoning_content/context_msgs/token_usage/memory/extra/errors。 - 新增 sdk.events.subscribe 与 sdk.plugin_mgr.*。 - sdk.lua mock 同步(单一事实源在 SDK 仓 sdk/lua/sdk.lua,内核副本由 third_party/homeagent-sdk/scripts/sync-lua-sdk.sh 同步)。 契约测试(lua_surface_test.go): - 守住内核内嵌 mock 与 SDK 仓事实源一致; - 守住 mock 承诺的每个函数都有运行时 RawSetString 绑定; - 覆盖 opts/media/attachments 解析与 context_policy 透传。 文档:中英 PLUGIN_DEV.md 的 Lua API 表补齐并改为『对齐至 SDK 1.3.0』。
This commit is contained in:
@ -15,7 +15,7 @@ import (
|
||||
type PluginType string
|
||||
|
||||
const (
|
||||
PluginTypeSKILL PluginType = "skill"
|
||||
PluginTypeSKILL PluginType = "skill"
|
||||
)
|
||||
|
||||
type IOConfig struct {
|
||||
@ -78,18 +78,28 @@ func LoadSKILL(path string) (*SKILLPlugin, error) {
|
||||
metaFile := filepath.Join(path, "skill.json")
|
||||
if data, err := os.ReadFile(metaFile); err == nil {
|
||||
var meta struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Version string `json:"version"`
|
||||
Author string `json:"author"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Version string `json:"version"`
|
||||
Author string `json:"author"`
|
||||
IO *IOConfig `json:"io,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(data, &meta); err == nil {
|
||||
if meta.Name != "" { p.name = meta.Name }
|
||||
if meta.Description != "" { p.description = meta.Description }
|
||||
if meta.Version != "" { p.version = meta.Version }
|
||||
if meta.Author != "" { p.author = meta.Author }
|
||||
if meta.IO != nil { p.ioConfig = meta.IO }
|
||||
if meta.Name != "" {
|
||||
p.name = meta.Name
|
||||
}
|
||||
if meta.Description != "" {
|
||||
p.description = meta.Description
|
||||
}
|
||||
if meta.Version != "" {
|
||||
p.version = meta.Version
|
||||
}
|
||||
if meta.Author != "" {
|
||||
p.author = meta.Author
|
||||
}
|
||||
if meta.IO != nil {
|
||||
p.ioConfig = meta.IO
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if filepath.Ext(path) == ".md" {
|
||||
@ -198,7 +208,9 @@ func extractToolDefs(content string) []ToolDef {
|
||||
inCodeBlock = !inCodeBlock
|
||||
continue
|
||||
}
|
||||
if inCodeBlock { continue }
|
||||
if inCodeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasPrefix(trimmed, "## ") && !strings.HasPrefix(trimmed, "### ") {
|
||||
if currentTool != nil && currentTool.Name != "" {
|
||||
@ -232,7 +244,9 @@ func extractToolDefs(content string) []ToolDef {
|
||||
continue
|
||||
}
|
||||
|
||||
if currentTool == nil || currentTool.Name == "" { continue }
|
||||
if currentTool == nil || currentTool.Name == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if currentTool.Description == "" && trimmed != "" &&
|
||||
!strings.HasPrefix(trimmed, "- ") && !strings.HasPrefix(trimmed, "#") {
|
||||
@ -280,7 +294,9 @@ func isNonToolSection(name string) bool {
|
||||
|
||||
func extractIOConfig(content string) *IOConfig {
|
||||
ioType := extractField(content, "io_type")
|
||||
if ioType == "" { return nil }
|
||||
if ioType == "" {
|
||||
return nil
|
||||
}
|
||||
cfg := &IOConfig{
|
||||
Type: ioType,
|
||||
InputRoute: extractField(content, "io_input_route"),
|
||||
|
||||
Reference in New Issue
Block a user