Commit Graph

193 Commits

Author SHA1 Message Date
AskaEth 2ec49f0779 fix: ListReminders JSON解析 — Gateway返{reminders:[...]}而非裸数组 2026-06-23 20:32:10 +08:00
AskaEth edc2e77d2f fix: internal reminder路由+user_id支持 — 修复401/404
- Gateway新增 POST/GET/DELETE /api/v1/internal/reminders
- CreateReminderRequest新增UserID字段,JWT为空时回退
- GatewayClient URL改为 /api/v1/internal/reminders

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 20:24:09 +08:00
AskaEth fea67d05eb fix: reminder工具401认证 — 路由从JWT组迁到internal组
- Gateway新增 /api/v1/internal/reminders (GET/POST/DELETE)
- 使用 X-Internal-Token 认证,不再需要JWT
- GatewayClient URL改为 /api/v1/internal/reminders

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 20:19:23 +08:00
AskaEth d38b92568b feat: 自主思考可按需查看群聊上下文 — 【查看群聊:适配器名:群号】
- 思者可在反思中输出【查看群聊:obv11-main:531082168】主动获取群聊记录
- 查找平台频道表确认adapter名称对应的platform类型
- 通过 memory-service 拉取最近5条频道记忆注入思考
- 自动追加【继续思考】以处理获取到的上下文
- 分析结果保留在思考链中

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 20:12:20 +08:00
AskaEth a2078b6662 feat: 主动消息写回对话历史 — 防止短期重复提问
- storeThought 推送主动消息后写入 convStore
- 轻量思考话题发起后也写入
- 配合提示词规则: 两小时内不重复问同类话题

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 20:01:43 +08:00
AskaEth 1eb22f5d06 fix: blocklist提前到消息处理最前端 — 拦截消息不浪费任何资源
- 移到 logging/enrichment/routing 之前
- 被拦截消息只记一条 [blocked] 日志,不调ai-core
- 时间戳/群名/昵称等富化处理不再对blocked消息执行

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:53:23 +08:00
AskaEth 4733f9c02a fix: 前端追踪时间 — 三处toISOString()全部替换为本地时间
- traceHopHtml 直接用后端格式化好的 timestamp
- llmCallToTrace 用前端 fmtLocal()
- 实时流事件用本地时间格式化
2026-06-23 19:45:16 +08:00
AskaEth f7df659c85 fix: 还原系统时区方案 — 时间戳已自带+08:00 2026-06-23 19:43:43 +08:00
AskaEth 109d427971 fix: 追踪时间强制UTC+8 — 不依赖系统时区 2026-06-23 19:41:43 +08:00
AskaEth f3b588d848 fix: 上下文恢复加24h合理性检查 — 避免用远古记忆当最近活动 2026-06-23 19:38:54 +08:00
AskaEth e0900bdd1b feat: 重启后恢复上下文 — 从记忆服务查询最近活动时间
- 新增 restoreContext() 在 Start() 时查询持久化记忆
- 取最近记忆的 CreatedAt 设为 lastUserMessage
- 避免重启后思考出现"已经一天没说话了"

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:38:08 +08:00
AskaEth 71539b5520 fix: 追踪页面回退到平铺视图,管线聚合待后续优化 2026-06-23 19:34:39 +08:00
AskaEth 87e8f97c1f fix: ethend OBv11配置界面字段丢失 — PLATFORM_FIELDS key qq→obv11
- 配置platform迁移后 PLATFORM_FIELDS['obv11'] 查不到返回空
- 新增 getPlatformFields() 归一化查找,兼容旧qq key
- PLATFORM_ICONS/LABELS/REAL 同步增加 obv11 key

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:28:12 +08:00
AskaEth 222fc5768f fix: send-proactive adapter查找 — 先按名再按平台类型回退 2026-06-23 19:26:12 +08:00
AskaEth 4326f1fc02 fix: seedIdentities 硬编码配置名导致admin身份丢失
- 迁移后配置名 qq→obv11-main,但seed用["obv11"]查不到
- 改为遍历store.List()所有配置,不再硬编码名字
- admin消息不再被当普通人处理而丢失回复

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:23:10 +08:00
AskaEth e433e94c89 fix: 全链路追踪时间显示 — UTC→UTC+8 本地时间
- 新增 formatLocalTime() 替换 toISOString()
- 追踪面板时间显示为北京时间

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:17:32 +08:00
AskaEth a47eeab808 feat: 全链路追踪系统 — ai-core追踪事件 + ethend管道视图
ai-core:
- 新增 TraceEvent 内存环形缓冲区(200条)
- GET /api/v1/trace/events 端点(支持session_id过滤)
- 预置 trace.go 追踪事件定义

ethend:
- trace/recent 聚合 platform-bridge消息日志 + ai-core追踪事件
- 消息按管线分组: msg_received→llm_call→tool_call→msg_sent
- 前端管线卡片视图: 每条消息显示完整处理步骤

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:11:55 +08:00
AskaEth a8fa64325d feat: 全链路追踪增强 + 超时修复
- ethend /api/trace/recent: 新增消息收发事件(platform-bridge日志)
- 消息按管线聚合: msg_received → llm_call → tool_call → msg_sent
- platform-bridge→ai-core超时 120s→180s

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 19:08:16 +08:00
AskaEth 3081ac38e0 fix: seed去重按platform type而非config name — 消除重复obv11 stub 2026-06-23 18:56:28 +08:00
AskaEth 0f180f17c3 fix: 旧配置自动迁移 — 补ID + qq→obv11 + platform_configs.json同步
- load() 自动为无ID旧配置生成唯一标识符
- 自动迁移 platform: qq→obv11, config名 qq→obv11
- platform_configs.json 已迁移: qq→obv11-main
- OBv11 adapter 已连接 (NapCat client模式)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 18:55:36 +08:00
AskaEth 1e2b2525f4 fix: 私聊主动消息路由修复 + 多账号自动适配
- 正则兼容 private_ 前缀: 【OBv11私聊:private_1487720750】
- prompt 显示频道时自动剥离 private_ 前缀
- extractProactiveMessage 自动查 PlatformChannel 表,
  将 target.Platform 从格式key改为adapter实例名
  多账号场景下自动路由到正确adapter

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 18:43:42 +08:00
AskaEth 73f0bf7b3e chore: 清除最后5处硬编码qq引用(注释+配置白名单) 2026-06-23 18:20:33 +08:00
AskaEth 8a3236b8bb refactor: 彻底消除硬编码 qq — 平台标识统一为 obv11
- PlatformName() 返回 "obv11"
- platformFormats key: "obv11"
- 所有 platform == "qq" 检查 → "obv11"
- session prefix: platform_qq_ → platform_obv11_
- env var PLATFORM_CHANNELS: obv11:group:xxx
- ethend 平台标识同步更新
- 注释和测试用例同步

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 18:19:52 +08:00
AskaEth c96bd23f83 feat: PlatformChannel 支持 AdapterID/AdapterName — 多账号全链路区分
- PlatformChannel 新增 AdapterID + AdapterName 字段
- AddOrUpdatePlatformChannel 接受 adapter 信息参数
- channel_sync 传递 adapter_id/adapter_name
- 消息处理路径传递 adapter_name

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 18:01:27 +08:00
AskaEth 45fac267fe feat: 平台配置唯一ID — PlatformConfig.ID + adapter全链路传播
- PlatformConfig 新增 ID 字段 (8字节hex,创建时自动生成)
- QQ adapter 新增 configID + ConfigID() 访问器
- ChannelInfo 新增 AdapterID + AdapterName
- createSingleAdapter 接受 configID 参数
- 同一个平台类型的多个配置实例通过 ID 唯一区分

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 17:59:37 +08:00
AskaEth 6bf59f7eee feat: 频道自动发现 — platform-bridge定时刷新频道路由 + ai-core周期同步
platform-bridge:
- QQ adapter: FetchGroups/FetchFriends 从NapCat API获取
- ChannelLister接口 + ChannelInfo结构体
- GET /api/v1/channels 端点 + cachedChannels缓存
- StartChannelRefresh 每10分钟自动刷新

ai-core:
- channel_sync.go: 每5分钟从platform-bridge拉取频道
- 自动更新thinker的platformChannels + botUIDs
- 不再依赖PLATFORM_CHANNELS环境变量手动配置

修复:
- SendMessage显式设AutoEscape:false
- PLATFORM_BRIDGE_URL默认端口8082→8095
- OBv11Params.AutoEscape去掉omitempty

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 13:12:54 +08:00
AskaEth c9bf839945 fix: QQ发送消息中文乱码 — SendMessage 显式设置 auto_escape=false
NapCat 在 auto_escape 未传时默认走 escape 模式,导致 UTF-8 中文被当 CQ 码处理

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 13:01:21 +08:00
AskaEth caa9bfced5 docs: 工具调用系统介绍文档
- 17个工具完整列表(共享插件 + AI-Core专属)
- 注册机制 + ToolExecutor接口
- 对话中完整调用流程(含LLM API请求/响应示例)
- 工具调用循环(最多5轮)
- 后台思考白名单机制
- 超时异步处理

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:53:23 +08:00
AskaEth 9767abae89 feat: 2.2 主动话题发起 — 轻量思考扩展【话题发起】输出
- 轻量思考 prompt 新增话题发起指引
- 检测【话题发起】标记 → 提取内容 → 通过 messagePusher 推送
- 遵循 ProactiveGuard 频率控制

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:46:51 +08:00
AskaEth bbf06da00f feat: 1.3 记忆自然引用 — 记忆标签从'数据库检索'改为'自己的回忆'
- 记忆头: '以下是关于开拓者的重要记忆' → '你记得关于开拓者的这些事'
- 分类: '★核心记忆/●常用记忆' → '你很确定的事/最近发生的事/还有点印象的事'
- 增加规则: 禁止用「根据记忆」「检索到」等说法

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:45:44 +08:00
AskaEth f9ee067674 feat: 1.2 情绪共振 — mood→行为映射替代情绪陈述
- 新增 buildMoodGuidance() 函数,5种心情各有行为描述
- 开心→话多♪多主动 | 调皮→撒娇逗人 | 沉思→安静温柔
- 担心→话少多关心 | 怀旧→提过去的故事
- 绝不陈述"你现在很开心",而是用行为让LLM自然表达

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:44:27 +08:00
AskaEth b8fd08b57c chore: WS断连日志增强 — 显示adapter名称和模式 2026-06-23 12:27:41 +08:00
AskaEth f0e8ffa2bb feat: extractProactiveMessage 单元测试 + 修复 log.Printf 格式化 bug
- 7 个测试覆盖:无标记/Web推送/OBv11群聊/私聊/@提及/否定语境/继续思考
- 修复 thinker.go:454 log.Printf %%v → %v 格式化错误

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:26:39 +08:00
AskaEth b3ce0b4f52 feat: LLM 降级策略 — 全部模型不可用时返回自然语言预设文案
- getFallbackMessage() 随机选择3条预设降级回复
- ProcessInput 失败和流式事件错误均使用降级回复
- 用户看到"开拓者…我现在好像有点恍惚…"而非错误信息

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:25:13 +08:00
AskaEth 0cd75c4dbc feat: 人性化改进 Phase 1 — 不完美感 + 日周期状态机 + 小脾气
- 1.7.7 不完美感: system prompt 追加停顿/改口/翻找回忆规则
- 1.7.8 日周期: 新增 timePeriod() 函数,时段注入思考提示词
  早晨/白天/傍晚/深夜/凌晨 五段式,自动调整语气和主动消息策略
- 1.7.9 小脾气: YAML 追加个性边界 — 深夜催睡/咖啡管控/撒娇/兴趣偏好

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 12:23:30 +08:00
AskaEth 39d62559ea fix: AdapterName JSON tag 写成了 group_name → 修正为 adapter_name 2026-06-22 21:33:31 +08:00
AskaEth 42793f9bba chore: ethend QQ→OBv11 + config.js环境变量同步 + curQQ变量重命名
- ethend: QQ_BOT_PORT→OBV11_BOT_PORT, QQ_ADMIN_UID→OBV11_ADMIN_UID
- ethend UI: QQ→OBv11 标签, 企鹅图标→🔷, 对话框文案
- platform-bridge: curQQ→curAdapter 变量名

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:32:10 +08:00
AskaEth 992d9a3515 chore: 移除已废弃的 tool-engine API 文档
tool-engine 服务已在 Phase 3 移除,工具调用整合到 pkg/plugins

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:17:46 +08:00
AskaEth c55201a03a chore: 清理不应跟踪的文档文件
gitignore 规范: 仅 docs/api/ 和 docs/deploy/ 纳入版本管理
移除: 架构分析/开发规划/备份迁移等规划类文档

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:17:14 +08:00
AskaEth 6faef5b6e5 feat: 群聊并发 — 主会话繁忙时创建协会议话
- Orchestrator 新增 per-session 处理锁 + co-session 跟踪
- 主会话处理中时,新消息自动创建协会议话(并发 LLM 调用)
- 协会议话上限 3 个,超出排队等待 500ms
- 主会话结束后自动释放锁

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:07:16 +08:00
AskaEth 489657ec08 feat: 提醒到期 → LLM生成自然提醒语 → 推送
- Gateway ReminderScheduler 到期时调用 ai-core /api/v1/internal/reminder-trigger
- ai-core 用 LLM 生成温柔俏皮的提醒语,通过 messagePusher 推送
- Thinker 新增 TriggerReminderMessage 方法
- 环境变量: AI_CORE_URL (Gateway 已有)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:04:21 +08:00
AskaEth 2b17bb5b03 feat: 同平台多账号支持 — adapter_name 贯穿全链路
- UnifiedMessage 新增 AdapterName 字段
- router 从适配器 ConfigName() 捕获 adapter 实例名
- forwardToAICore source 新增 adapter_name
- ai-core SetBotUID key 优先用 adapter_name,回退 platform
- 更新优化大纲加入 P4.1

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:53:40 +08:00
AskaEth 41f653b672 refactor: QQ → OBv11 重命名 + 平台格式统一抽象
- 所有对外称呼从 QQ 改为 OBv11(注释/提示词/日志/配置项)
- 新增 PlatformFormat 结构体,统一管理平台消息标记格式
- defaultPlatformFormats() 注册表替代硬编码 qqTargetRe
- extractProactiveMessage 改为 Thinker 方法,遍历格式注册表匹配
- 配置项重命名: QQ_BOT_PORT → OBV11_BOT_PORT, QQBotPort → OBv11BotPort
- 标记格式: 【QQ群聊】→【OBv11群聊】、【QQ私聊】→【OBv11私聊】

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:48:07 +08:00
AskaEth 70dbb23234 chore: 同步 .env.example — 补全所有代码引用的环境变量
- 新增: 后台思考分层 (LIGHT_THINK_*), 平台桥接, 知识库/人格路径, Gateway URL 等
- 移除: TOOL_ENGINE_URL (已废弃), 过时的 VECTOR_DB 相关变量
- 按分类重新组织: 服务/数据库/LLM/思考/平台/OS环境等

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:41:36 +08:00
AskaEth a46b5f6238 feat: 自主思考分层 — 轻量思考(简单)+深度思考(复杂)双模型
- 新增轻量思考循环 lightThinkLoop (默认60s间隔,快速模型)
- 轻量思考用极简 prompt 做快速状态检查
- 检测到「需要深思」时自动唤醒深度思考 performThink("light_wake")
- 环境变量: LIGHT_THINK_ENABLED / LIGHT_THINK_INTERVAL_SEC
- 轻量思考跳过活跃用户 (30s内有消息) 和重复触发 (10s内)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:39:20 +08:00
AskaEth 485d845f3e feat: LLM可自主操作提醒 — reminder_create/list/delete 工具
- 新增 GatewayClient HTTP 客户端,调用 Gateway /api/v1/reminders API
- 新增 3 个提醒工具:reminder_create / reminder_list / reminder_delete
- main.go 注册提醒工具,需 GATEWAY_URL + INTERNAL_SERVICE_TOKEN 环境变量
- AutonomousToolPolicy 白名单加入提醒工具,允许自主思考中创建提醒

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:37:27 +08:00
AskaEth 7e475bdfa6 feat: 子会话结果增加创建/结束时间戳
- SubSessionResult 新增 CreatedAt / FinishedAt 字段
- manager.Dispatch 在各路径统一设置时间戳:成功/失败/超时

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:31:48 +08:00
AskaEth 8783cadf9b feat: 思考追加机制 — 所有思考类型支持【继续思考】标记循环
- performThink 改为循环执行,最多3轮
- LLM输出含【继续思考】时自动追加一轮
- post_chat/silence/default三种提示词均告知可用此标记
- 存储前剥离控制标记,不污染思考内容

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:29:17 +08:00
AskaEth cadd5f2233 feat: QQ主动消息管道 + 戳一戳事件 + thinker提示词优化
- ProactiveTarget 结构体 + QQ目标正则解析(extractProactiveMessage 返回双值)
- storeThought 双路推送:platform消息 → platformMessagePusher,web消息 → messagePusher
- platform-bridge: SendProactive接口 + ProactiveSender + /api/v1/internal/send-proactive端点
- QQ戳一戳/notice事件 → noticeToUnified → ContentType "action"
- thinker提示词注入QQ频道上下文:群名称(群号)、活跃时间、trigger-aware引导
- SetBotUID/SetPlatformMessagePusher/AddOrUpdatePlatformChannel 方法
- ai-core source 增加 BotUID/GroupName,platform-bridge source 增加 bot_uid/group_name
- 支持 [CQ:at,qq=xxx] @提及标签自动拼接

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:26:36 +08:00
AskaEth cd053194a9 fix: RAG IngestDirectory 跳过 persona.md 和 _index.md
避免人格文档在RAG检索中重复出现,persona.md已通过系统提示注入。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:26:28 +08:00