mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-09-22 01:48:03 +00:00
refactor(plugindev): 模板改用内核独占共享槽池 + ContextPolicy 字段
共享内存是内核内部实现,不对插件开发者暴露。模板不再维护任何分配 游标(历史上 bump 游标 / 模板内位图 CAS 两版都因把可变分配状态放在 共享内存里而出竞态),改为通过内核 RPC 申请/归还: - 删除 arenaWrite 本地 bump 分配器与 arenaOff/arenaUsed 全局变量 - 新增 arenaAlloc/arenaFree:走 arena.alloc / arena.free RPC - 新增 putInArena/callWithText:按 payload 大小自动选择共享槽或内联 JSON(inlinePayloadLimit=512),SDK 公开 API 仍是普通字符串/Map, 插件开发者无感 - cleaner.invoke 改为读 TextRef/内联 Text、写 RespRef/内联 Text; 插件不做任何分配(内核预分配请求槽 + 响应槽) - 同步 handshake:不再解析 arena 槽池布局(偏移与大小由 arena.alloc 的应答下发) 测试: - 新增 TestProcTemplate_UsesKernelArenaRPC:模板必须调用 arena.alloc/ arena.free,且不得再出现 arenaUsed/arenaWrite(回归保护) - TestProcTemplate_RejectsVersionMismatch 更新为 §13.1 后的「统一区域 魔数不匹配」文案 - 修正模板与 sdk/plugin.go 的 gofmt 对齐(含补上 ContextPolicy 字段)
This commit is contained in:
@ -100,12 +100,13 @@ type ToolResult struct {
|
||||
|
||||
// ToolDef describes a tool that the plugin exposes.
|
||||
type ToolDef struct {
|
||||
Name string `json:"name"`
|
||||
Plugin string `json:"plugin,omitempty"`
|
||||
Description string `json:"description"`
|
||||
Parameters map[string]interface{} `json:"parameters"`
|
||||
NoMemory bool `json:"no_memory,omitempty"` // 此工具输出不参与记忆计算,但原文保留
|
||||
Cleaner func(string) string `json:"-"` // 计算层过滤函数,不改原文;仅在向量化/jieba/蒸馏时调用
|
||||
Name string `json:"name"`
|
||||
Plugin string `json:"plugin,omitempty"`
|
||||
Description string `json:"description"`
|
||||
Parameters map[string]interface{} `json:"parameters"`
|
||||
NoMemory bool `json:"no_memory,omitempty"` // 此工具输出不参与记忆计算,但原文保留
|
||||
Cleaner func(string) string `json:"-"` // 计算层过滤函数,不改原文;仅在向量化/jieba/蒸馏时调用
|
||||
ContextPolicy string `json:"context_policy,omitempty"` // 工具上下文策略:"none"(默认) / "prune"
|
||||
}
|
||||
|
||||
// IOInjector provides methods for injecting input and interrupts into the agent pipeline.
|
||||
|
||||
Reference in New Issue
Block a user