diff --git a/example/qq/plugin.go b/example/qq/plugin.go index 16634bc..1dd7144 100644 --- a/example/qq/plugin.go +++ b/example/qq/plugin.go @@ -1435,7 +1435,12 @@ func (p *Plugin) handleWebhook(w http.ResponseWriter, r *http.Request) { if p.sdk != nil { // NoMemory:HTTP 侧来的中断提示,不是对话内容。 - p.sdk.InjectInterruptTextOpts(p.name, p.name, interrupt, sdk.InjectOptions{NoMemory: true}) + // Priority:QQ 消息是**低级别中断**——既不是时钟那样的实时工作, + // 也不是紧急工作,所以声明 L1(完全可等)。 + p.sdk.InjectInterruptTextOpts(p.name, p.name, interrupt, sdk.InjectOptions{ + NoMemory: true, + Priority: sdk.PriorityL1, + }) } w.WriteHeader(http.StatusOK) } @@ -2531,9 +2536,10 @@ func (p *Plugin) handleDownloadFile(args map[string]interface{}) (interface{}, e log.Printf("[qq] 文件下载完成: %s", savePath) if p.sdk != nil { // NoMemory:下载完成的状态通知,不是记忆内容。 + // Priority:同上,QQ 侧一律低级别中断(L1)。 p.sdk.InjectInterruptTextOpts(p.name, p.name, fmt.Sprintf("文件下载完成: %s,保存在 %s", filepath.Base(savePath), savePath), - sdk.InjectOptions{NoMemory: true}) + sdk.InjectOptions{NoMemory: true, Priority: sdk.PriorityL1}) } } else { errMsg = "下载失败,文件可能已过期" diff --git a/sdk/plugin.go b/sdk/plugin.go index f8b0c12..cf38db6 100644 --- a/sdk/plugin.go +++ b/sdk/plugin.go @@ -78,8 +78,24 @@ type InjectOptions struct { NoMemory bool ContextPolicy string CleanerName string + + // Priority 声明**中断注入**的优先级(仅 InjectInterrupt* 有意义)。 + // + // 取值 "L1"/"L2"/"L3";空等同 L1。L4 由内核独占(panic / 内核事件 selfip), + // 插件声明 L4 会被内核夹到 L3——内核的调度内部属性不接受外部越权。 + // + // 排队注入(InjectText*/InjectInputSync)没有级别:它们本就是“不需及时处理” + // 的那一类,可被任何中断打断。 + Priority string } +// 中断优先级取值(插件可用范围)。L4 不在其中:它由内核保留。 +const ( + PriorityL1 = "L1" + PriorityL2 = "L2" + PriorityL3 = "L3" +) + // ChannelDef 描述通道在记忆计算层的行为,与 ToolDef.NoMemory/Cleaner 语义一致。 // NoMemory: 此通道输入/输出不参与记忆计算(向量化/关键词提取/蒸馏),但原文保留在上下文中 // Cleaner: 计算层过滤函数,不改原文;仅在向量化/jieba/蒸馏/存档提取关键词时调用 diff --git a/tools/hmapdev/templates/proc_main.go.tmpl b/tools/hmapdev/templates/proc_main.go.tmpl index 7b18d55..272f31f 100644 --- a/tools/hmapdev/templates/proc_main.go.tmpl +++ b/tools/hmapdev/templates/proc_main.go.tmpl @@ -287,6 +287,10 @@ func applyInjectOpts(args map[string]interface{}, opts sdk.InjectOptions) { if opts.CleanerName != "" { args["cleaner_name"] = opts.CleanerName } + // priority 只对中断注入有意义(排队注入没有级别)。 + if opts.Priority != "" { + args["priority"] = opts.Priority + } } // ---- 全局状态 ----