feat(emotion): A1 情绪系统接线 + refactor: 拆分 channelbridge.go
A1 情绪接线: - loop 回合边界钩子(TurnEnd/OnTurnEnd/settleTurn, Result.Mood); 每轮一次非每步 - persona/emotion: React(valence五档) + Machine.Move(BFS最短合法路径一步) + Observer(observe/decay/好感度,仅变化才emit); 好感度步长读角色配置(cyrene delta=10, 0..700) - 落库 Mood(web session_persist.res.Mood + IM channelbridge/persist; user消息不带mood); WS mood事件(BroadcastMood,仅变化); per-persona隔离; 群聊/陌生人只读不写不发 - cmd/cyrene/emotion.go 生产接线 + wire.go 注入 loop.Options.OnTurnEnd - 22 测试(状态机被loop调用/Mood非空落库/mood帧shape/只变化才发/群聊只读) + 真二进制冒烟 - Docs: api-client v0.32 §3.7 情绪事件 + 开源对照清单(companion 应用对照) - 诚实: 本机无LLM凭据→未活体验证'模型返回后完整轮次'一环 拆分 channelbridge.go 816→257(纯搬移零逻辑): connect/inbound/outbound/blacklist/helpers.go; A1 的 IM mood 调用点落在新 inbound.go, 故与本提交同批 回滚 6 个 gofmt 顺手格式化文件(capacity_loop_test/flow/source_test/findchannel_test/admin_channels_platform_test/history) 缩 diff, 含 history.go 注释被转弯引号
This commit is contained in:
1 parent
610b330025
commit
1a85de555d
27 files changed
+1946
-594
No files matched your search
@@ -23,6 +23,7 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/db"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/iot"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/persona/emotion"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/persona/loader"
|
||||
personareg "git.yeij.top/AskaEth/Cyrene_v2/internal/persona/registry"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/platform"
|
||||
@@ -108,6 +109,14 @@ type app struct {
|
||||
// §5). It is satisfied by *gateway.Server (BroadcastCapacityAwaken); held as an
|
||||
// interface so the composition root is unit-testable with a fake sink.
|
||||
capacitySink capacityEmitter
|
||||
// emotion applies each settled turn to the bound persona's emotion machine and
|
||||
// affection (design/01 §2) and hands the changes to moodSink. Nil when no
|
||||
// persona was registered, in which case no mood is tracked or persisted.
|
||||
emotion *emotion.Observer
|
||||
// moodSink broadcasts a mood change to the Web UI (design/07 §3). It is
|
||||
// satisfied by *gateway.Server (BroadcastMood); held as an interface so the
|
||||
// composition root is unit-testable with a fake sink.
|
||||
moodSink moodEmitter
|
||||
}
|
||||
|
||||
// capacityEmitter is the gateway-facing sink for capacity_awaken broadcasts.
|
||||
@@ -389,6 +398,11 @@ func (a *app) wireRuntime() error {
|
||||
)
|
||||
|
||||
capDecider := a.buildCapacity()
|
||||
// The persona emotion observer (design/01 §2) is built here because it is the
|
||||
// loop's turn-boundary dependency: after every settled turn the bound persona's
|
||||
// emotion machine and affection move, and the returned mood label is written
|
||||
// onto Result.Mood and the assistant message (design/16 §3.3).
|
||||
a.emotion = a.buildEmotionObserver()
|
||||
|
||||
a.loop = loop.New(loop.Options{
|
||||
Agent: ag,
|
||||
@@ -396,6 +410,7 @@ func (a *app) wireRuntime() error {
|
||||
Capacity: capDecider,
|
||||
OnCapacity: a.onCapacity,
|
||||
OnAudit: a.onToolAudit,
|
||||
OnTurnEnd: a.onTurnEnd,
|
||||
Memory: store,
|
||||
Retriever: a.retriever,
|
||||
Extractor: memory.NewManualExtractor(personaID, "owner"),
|
||||
@@ -736,6 +751,7 @@ func (a *app) wireFrontend() error {
|
||||
})
|
||||
}
|
||||
a.capacitySink = gw
|
||||
a.moodSink = gw
|
||||
|
||||
// Wire the backthink proactive sinks now that the gateway hub (active-client
|
||||
// route) and the channel bridge (IM fallback) both exist. They were absent when
|
||||
|
||||
Reference in new issue
Block a user