feat: Phase 1+2 架构进化 — 连续思考链/主动消息决策/情感状态机/离线自主思考 (86文件)

Phase 1 (基础设施):
- ThinkChain 思考链连续性 + 差异化思考提示词 (persistent)
- AutonomousToolPolicy 工具安全策略 (safe/unsafe/conditional)
- MessageScheduler 自适应消息节奏 (Idle/Available/Busy)
- SessionEnrichmentStore 渐进式上下文丰富 (5层)
- ConversationBus 事件总线 + ResponseCache (dedup)
- pkg/logger 统一日志 + 所有 handler 替换 fmt.Printf
- NPE 守卫/链路优化/数据库表修复/Go workspace

Phase 2 (人格交互):
- EmotionState/EmotionTracker 情感状态机 (5种心情, 情绪衰减)
- ProactiveGuard 主动消息多维决策 (静默时段/紧急度/频率/校验)
- Gateway↔ai-core 在线状态感知链路 (presence notification)
- 离线思考频率控制 + 重连问候 + 离线消息排队

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-23 15:25:12 +08:00
parent b123a36aae
commit 87214b9441
86 changed files with 3085 additions and 582 deletions
+6 -6
View File
@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/yourname/cyrene-ai/pkg/logger"
"sync"
)
@@ -52,7 +52,7 @@ func (r *Registry) Register(executor ToolExecutor) {
defer r.mu.Unlock()
def := executor.Definition()
r.tools[def.Name] = executor
log.Printf("[工具注册] 已注册工具: %s", def.Name)
logger.Printf("[工具注册] 已注册工具: %s", def.Name)
}
// GetDefinitions 获取所有工具定义(用于 LLM function calling
@@ -81,10 +81,10 @@ func (r *Registry) Execute(ctx context.Context, toolName string, arguments map[s
}, nil
}
log.Printf("[工具执行] 调用工具 %s,参数: %v", toolName, arguments)
logger.Printf("[工具执行] 调用工具 %s,参数: %v", toolName, arguments)
result, err := executor.Execute(ctx, arguments)
if err != nil {
log.Printf("[工具执行] 工具 %s 执行失败: %v", toolName, err)
logger.Printf("[工具执行] 工具 %s 执行失败: %v", toolName, err)
return &ToolResult{
ToolName: toolName,
Success: false,
@@ -93,9 +93,9 @@ func (r *Registry) Execute(ctx context.Context, toolName string, arguments map[s
}
if result.Success {
log.Printf("[工具执行] 工具 %s 执行成功 (数据长度: %d)", toolName, len(result.Data))
logger.Printf("[工具执行] 工具 %s 执行成功 (数据长度: %d)", toolName, len(result.Data))
} else {
log.Printf("[工具执行] 工具 %s 返回错误: %s", toolName, result.Error)
logger.Printf("[工具执行] 工具 %s 返回错误: %s", toolName, result.Error)
}
return result, nil