mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-07 01:37:34 +00:00
feat(security,device): security 成为独立内核模块(闸门+策略+限式),device 接管内置工具路由
security(新模块 internal/kernelmod/security)
- 凭据闸门:出向拦截成 @{别名}、入向清洗、执行前回填(internal/security/{gate,runtime}.go)
- 工具黑白名单 + 沙箱(读写根、网络、.. 逃逸):internal/security/policy.go
- 敏感词过滤 + 提示词注入预警(Finding 不带原文):internal/security/content.go
- 按主体授权(hard-private 对非内部主体永久拒绝):internal/security/principal.go
- 插件命名限式(可选档位,插件声明/内核执行,只能收窄):internal/security/profile.go
- 启动装配从 cmd/homed 迁入模块;启动顺序判据改盯真实装配点
device(新模块)
- 正式内核模块,Provides FacDevice,KernelState.Device
- 内置工具路由表下沉到 internal/toolroute(避免 core↔kernelboot 环),
device 保留对外入口;agent 未挂载时退化本地 switch
- Agent 侧只留 api.ToolHost/DeviceSurface 适配层
SDK
- InjectOptions.SecurityProfile:插件按 inputch 声明本轮安全档位(可选)
- InjectOptions.TurnHint:插件注入**本轮事实**,内核以独立 system 消息注入,
不混进用户正文(人设负责怎么说话,TurnHint 只放这一轮成立的事实)
- FacilitySecurity / FacilityDevice
提示词
- 内核自带 prompt/skill/工具返回全面英文化(中文提示会让模型行为漂移)
- 机制解释下沉到 4 个内置 skill(memory/output/tool-order/plugins),
skill 描述压到 80 runes 内(原来 94–108 全被索引截断)
- 默认人格模板英文化;[Voice] 段删除,规则并入 persona 块(单一段落)
- 历史记忆工具改名 coldcontext_query/commit,图记忆语义改称 stable memory
修复
- tracker: exec mount → unix.Mount(降权运行 + AmbientCapabilities 下才能挂)、
区分 EPERM 与不支持;启动日志说明后果与恢复方式
- healthcheck_kernel 输出瘦身:status.Tools 只给摘要(原 98,989 tokens/151% 预算)
- plugin_list 描述讲清 auto_start(按需)与 alive(此刻是否在跑),
明确不能由 alive=false 推断能力不存在
- pluginmgr/webui 去掉写死的 /home/newqqagent 回退路径(env → pluginDir 反推 → 报错)
- lua: 盘上适配器与内置版本不一致且无基线时响亮告警(deepseek 流式丢失
tool_calls 导致'模型不调工具'的真因)
测试:go build ./... 通过;go test ./... 60 包全绿
This commit is contained in:
@ -124,7 +124,7 @@ func (a *Agent) modalFallbackPrompt(kind string) string {
|
||||
if s := strings.TrimSpace(a.inputCfg.Image.DescribePrompt); s != "" {
|
||||
return s
|
||||
}
|
||||
return "请详细描述这张图片的内容,包括其中的文字、物体、人物、场景等信息。"
|
||||
return "Describe this image in detail: text, objects, people and scene."
|
||||
case "audio":
|
||||
if s := strings.TrimSpace(a.inputCfg.Audio.DescribePrompt); s != "" {
|
||||
return s
|
||||
@ -191,20 +191,19 @@ func (a *Agent) transcribeBlocksForFallback(blocks []agentAPI.ContentBlock) moda
|
||||
if len(imgURLs) > 0 {
|
||||
p, srcName := a.resolveModalFallback("image")
|
||||
if p == nil {
|
||||
notices = append(notices, "当前模型不支持图片,且没有可用的视觉回退源"+
|
||||
"(配置 core.input_processing.image.fallback_provider,"+
|
||||
"并在该源上设置 core.llm.sources.<name>.vision=true)")
|
||||
notices = append(notices, "The current model does not support images and no vision fallback source is available "+
|
||||
"(set core.input_processing.image.fallback_provider and core.llm.sources.<name>.vision=true on that source)")
|
||||
} else if text, err := a.chatModalFallbackBatch(p, "image", imgURLs, imgDetails); err != nil {
|
||||
// 转写失败必须说出来。静默跳过会让模型以为「图里没内容」,
|
||||
// 而事实是没人看过这些图。
|
||||
notices = append(notices, fmt.Sprintf("图片转写失败(源 %s): %v", srcName, err))
|
||||
notices = append(notices, fmt.Sprintf("image transcription failed (source %s): %v", srcName, err))
|
||||
log.Printf("[agent] modal fallback image(%d) via %s failed: %v", len(imgURLs), srcName, err)
|
||||
} else {
|
||||
label := "图片内容"
|
||||
label := "image content"
|
||||
if len(imgURLs) > 1 {
|
||||
label = fmt.Sprintf("%d 张图片/视频帧内容", len(imgURLs))
|
||||
label = fmt.Sprintf("%d images/video frames", len(imgURLs))
|
||||
}
|
||||
converted = append(converted, fmt.Sprintf("[%s · 由 %s 转写,非当前模型直接感知]\n%s", label, srcName, text))
|
||||
converted = append(converted, fmt.Sprintf("[%s · transcribed by %s, not directly perceived by the current model]\n%s", label, srcName, text))
|
||||
res.Converted += len(imgURLs)
|
||||
}
|
||||
}
|
||||
@ -213,11 +212,10 @@ func (a *Agent) transcribeBlocksForFallback(blocks []agentAPI.ContentBlock) moda
|
||||
if len(audURLs) > 0 {
|
||||
p, srcName := a.resolveModalFallback("audio")
|
||||
if p == nil {
|
||||
notices = append(notices, "当前模型不支持音频,且没有可用的音频回退源"+
|
||||
"(配置 core.input_processing.audio.fallback_provider,"+
|
||||
"并在该源上设置 core.llm.sources.<name>.audio=true)")
|
||||
notices = append(notices, "The current model does not support audio and no audio fallback source is available "+
|
||||
"(set core.input_processing.audio.fallback_provider and core.llm.sources.<name>.audio=true on that source)")
|
||||
} else if text, err := a.chatModalFallbackBatch(p, "audio", audURLs, nil); err != nil {
|
||||
notices = append(notices, fmt.Sprintf("音频转写失败(源 %s): %v", srcName, err))
|
||||
notices = append(notices, fmt.Sprintf("audio transcription failed (source %s): %v", srcName, err))
|
||||
log.Printf("[agent] modal fallback audio(%d) via %s failed: %v", len(audURLs), srcName, err)
|
||||
} else {
|
||||
converted = append(converted, fmt.Sprintf("[音频内容 · 由 %s 转写,非当前模型直接感知]\n%s", srcName, text))
|
||||
@ -356,7 +354,7 @@ func (a *Agent) chatModalFallbackBatch(p agentAPI.Provider, kind string, urls, d
|
||||
if out == "" {
|
||||
// 空回复不能当成功。上游剥掉媒体块后模型往往回一句「我没看到图片」
|
||||
// 或干脆空串——两种都说明这条回退链也没真看到。
|
||||
return "", fmt.Errorf("回退源返回空内容(该源可能同样不支持此模态)")
|
||||
return "", fmt.Errorf("fallback source returned empty content (it may not support this modality either)")
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user