- 四组并行完成:main/wire*.go、wire_capacity|channels|runtime、channels|persona_*|emotion|observability、 voice|plugins|stream|skills|vision|subagent_tool|extractor|mcp|sessionread_tool|terminal_tool。 - 机械校验(git diff -U0 去 // 行与空行)仅剩 wire_frontend.go:84 一处行尾注释:代码前缀 「\ta.gw = gw 」经 cat -A 与 HEAD 逐字节比对一致(allow 清单已声明)。 - 验收:隔离 worktree(HEAD + 本批 patch)go build/vet 绿、全树 58 包 ok、 linux/amd64 + darwin/arm64 交叉编译绿;gofmt -l 干净。 - 备注:整树两次红均为负载敏感 flake(backthink / orchestration 的 timeout 类用例单独 -count=20 全过)。
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
|
|
)
|
|
|
|
// streamSubject 是循环的 OnStream 闭包发布每个结构化流事件所用的 bus subject。
|
|
// gateway hub 订阅 ws.>,并为该 subject 保留一条专用分支,把 model.StreamEvent
|
|
// 映射为带 seq 序号的下游强类型 WS 事件(message.*/thinking.*/tool_call.*)。
|
|
//
|
|
// 它必须与 internal/services/gateway/ws_hub.go 中的 wsStreamSubject 保持一致;
|
|
// 两个包若共用同一个 const,会把 gateway 拉进主二进制的导入图,因此该字面量
|
|
// 在此重复一份并加以说明。
|
|
const streamSubject = "ws.stream"
|
|
|
|
// streamChunk 是循环的 OnStream 回调。它把一个结构化流事件发布到 gateway 的流式
|
|
// subject,由 hub 以对应的强类型 WS 事件广播给每个客户端。未接 bus 时它为空操作,
|
|
// 且绝不阻塞循环:bus.Publish 是异步的,单个订阅缓冲写满时丢弃事件而不是让模型
|
|
// 流停摆。
|
|
func (a *app) streamChunk(ev model.StreamEvent) {
|
|
if a.bus == nil {
|
|
return
|
|
}
|
|
if err := a.bus.Publish(context.Background(), streamSubject, ev); err != nil {
|
|
a.log.Warn("stream event publish", "err", err)
|
|
}
|
|
}
|