OoO
8a36856171
補強 Telegram callback 診斷
CD Pipeline / deploy (push) Has been cancelled
2026-05-13 11:03:37 +08:00
OoO
2068a3719d
修正 Telegram 分類按鈕預設 callback
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 09:27:34 +08:00
OoO
00591c5489
feat(ea-hitl): ADR-021 EA 升級審核 pre-fetch + 競價告警金額影響量化
...
根治 2026-05-02 統帥反映的三層 EA escalation 訊息空泛問題:
1. _escalate_to_human 對 price_drop_alert / market_opportunity /
threat_escalation 三類觸發,送 Telegram 前先 await Hermes 取具體
SKU 清單覆蓋 plan 元流程文字(5s 短超時,失敗 fallback 原 plan)
2. NemoTron 競價告警新增 _compute_business_impact helper:
過去 7 日營收流失(gap_pct>0 才算)+ 跟進競品建議價,
dispatch 主路徑 / 防線二 / Hermes rule fallback 三條全部 Python
獨裁注入,告警含「📉 NT$ X」「🎯 NT$ Y」具體金額
3. 補實 telegram_bot_service.handle_callback 的 momo:eig: prefix
handler,HITL「🛑 忽略此事件」按鈕首次有對應 audit 寫入
Critic 審查通過(5 項必修全綠):
- Critical-1: user_label HTML escape 防 Telegram username XSS
- High-1: pre-fetch 改 asyncio.wait_for(5s) 防阻塞 escalation
- High-2: 全部行缺金額時 return None 觸發 plan fallback
- Medium-2: 空 event_id callback 拒絕避免 audit 污染
- Medium-3: gap_pct≤0 時 revenue_loss_7d 強制歸 0 不誤導降價
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com >
2026-05-03 00:03:38 +08:00
OoO
673982d83b
Fix OpenClaw callback command path from NL dispatch regression
CD Pipeline / deploy (push) Successful in 4m17s
2026-05-02 15:59:54 +08:00
OoO
14195b65fd
feat(telegram): ADR-019 Phase 4 - conversation memory + chat_id propagation
...
CD Pipeline / deploy (push) Successful in 2m51s
ADR-019 Phase 4:新增 services/openclaw_session.py 管理 chat_id 級別的多輪
對話歷史與 carry-over slot。In-memory,30 分鐘 TTL,重啟清空(臨時對話 state
不該污染 ai_insights 永久記憶)。
openclaw_answer 簽章加 chat_id=None 可選參數:
- 傳入時 agent 會看到該 chat 最近 5 輪對話歷史,注入 system prompt
- Ollama / Gemini FC 兩條路徑都會在生成成功後 append_turn 寫回 session
- system prompt 加決策規則:「若歷史顯示用戶剛被問參數,優先用該答案接續執行」
Caller 全部更新傳 chat_id:
- routes/openclaw_bot_routes.py:5479 (handle_cmd 不認識指令 fallback)
- routes/openclaw_bot_routes.py:5916 (webhook NL 路徑)
- routes/openclaw_bot_routes.py:_agent_dispatch_cmd (Phase 3 hook)
- services/telegram_bot_service.py:934 (polling NL fallback)
向下相容:chat_id=None 時行為與舊版完全相同(無 multi-turn 記憶)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com >
2026-05-02 13:04:18 +08:00
OoO
1a886d962b
fix(telegram): dedupe webhook+polling updates via shared DB guard
...
CD Pipeline / deploy (push) Successful in 8m50s
Webhook (Flask) and polling (momo-telegram-bot) consumed the same
Telegram update_id, causing /menu callbacks to fire twice. Add a
shared dedup module backed by telegram_update_dedup table (300s TTL,
60s cleanup) with in-memory fallback, wired into both paths.
Polling launcher now skips startup when webhook is configured to
prevent dual-consumption at the source.
38 tests across webhook, menu keyboards, telegram_api, dedup guard,
and trend bot service.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com >
2026-05-02 12:01:04 +08:00
OoO
213216b495
fix: 優化 Telegram Bot 自然對話體驗,移除強制選單並串接 AI 引擎
CD Pipeline / deploy (push) Successful in 1m18s
2026-04-28 11:33:02 +08:00
ogt
237d3af76f
fix: Phase 2 P0 全清零 — 14 項安全與功能修復完成
...
CD Pipeline / deploy (push) Failing after 2m59s
P0-06: google_drive_service.py — pickle.load() 改 JSON token(消除 RCE 風險)
P0-07: bot_api_routes.py:30 — BOT_API_TOKEN 移除硬編碼預設值 clawdbot_momo_2026
P0-08: auto_import_index.html — showAlert innerHTML 改 createTextNode(XSS 修復)
P0-09: abc_analysis_detail.html + dashboard.html + daily_sales.html — Jinja2 | e 轉義
P0-10: openclaw_bot_routes.py:2634 — vendor PPT 補 return ppt_path(廠商報告恢復)
P0-11: telegram_bot_service.py:177-214 — cmd_start/cmd_help 補 try/except
P0-12: app.py:689-712 — 10 個 Blueprint 補齊 register(消滅 404 路由)
P0-13: auto_heal_service.py — 實作 _write_heal_log(),AIOps 稽核閉環補完
P0-14: monitoring/prometheus.yml — 取消 alert_rules comment;新增 alert_rules.yml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-27 21:11:52 +08:00
ogt
b3a7909b2b
fix: add try/except guards to all unprotected Telegram handler functions
...
CD Pipeline / deploy (push) Successful in 1m29s
- Replace 2 silent `except Exception: pass` with logger.warning in handle_callback
- Wrap _handle_await_callback, _handle_main_menu_callback with top-level try/except (query.answer on error)
- Wrap _handle_complex_ai_response, _handle_simple_ai_response, _enhanced_keyword_matching, _process_await_input with top-level try/except (update.message.reply_text on error)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-27 19:47:49 +08:00
ogt
ac56139e74
fix: translate _get_query_suggestions to zh-TW + add missing promo_range await prompt
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-27 19:45:52 +08:00
ogt
4ff291b596
fix: 修復 AI 對話無法使用 + 全面繁體中文化
...
CD Pipeline / deploy (push) Successful in 1m28s
- telegram_ai_integration.py 移至 services/ 解決 ModuleNotFoundError
(momo-telegram-bot 只掛載 services/,根目錄檔案進不了容器)
- import 路徑更新為 from services.telegram_ai_integration
- 所有英文回覆字串改為繁體中文:
· 歡迎訊息、fallback 訊息、錯誤提示
· _enhanced_keyword_matching 全英文段落
· _handle_complex_ai_response / _handle_simple_ai_response
· Cancel 按鈕改「❌ 取消」、callback 改 menu:main
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-25 09:41:55 +08:00
ogt
d5c0feab5e
fix: Telegram bot 全功能修復 — 16個await按鈕/AI對話/模型遷移/DB schema
...
CD Pipeline / deploy (push) Successful in 1m35s
## Telegram Bot 功能修復
- 補全 16 個 await: 按鈕的 handler(日期選擇/目標設定/促銷追蹤等),
新增 _handle_await_callback + _process_await_input 完整狀態機
- cmd: 按鈕加入 ⏳ 即時回饋 + try/except 防 BadRequest
- handle_callback 加頂層 try/except 錯誤兜底
- 補 momo:cmd:suggestion + momo:menu:main callback handler
- 修復 _enhanced_keyword_matching context NameError
## AI 模型遷移(hermes3@111 → qwen2.5@188)
- hermes_analyst_service: URL 192.168.0.111→188, hermes3→qwen2.5:7b-instruct
- code_review_pipeline: 改用 HERMES_URL/HERMES_MODEL 常數
- elephant_alpha_orchestrator / nemoton_dispatcher: registry/footprint 同步
- aider_heal_executor: OLLAMA_API_BASE fallback 改 188
- ai_routes: footprint display 字串改 qwen2.5:7b-instruct
## ElephantAlpha 404 修復
- elephant_service: openrouter→NVIDIA NIM, nvidia/llama-3.1-nemotron-ultra-253b-v1
- ai_provider: 模型 ID 同步更新
## TELEGRAM_CHAT_ID 環境變數修正
- cicd_routes + aider_heal_executor: 優先讀 TELEGRAM_CHAT_IDS[0],
fallback TELEGRAM_CHAT_ID,修復通知靜默失敗
## AI 對話 logging 改善
- telegram_ai_integration: Hermes 降級改 WARNING,OpenClaw 失敗加 exc_info
- hermes_analyst_service: 連線失敗 log 加 host/model context
## DB Schema 修復
- migrations/019: action_plans 補齊全欄位,DROP NOT NULL action_type
- autoheal_models: ActionPlan ORM 同步為超集 schema
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-25 03:30:14 +08:00
ogt
3f7fc0aba0
[V10.4-B] Telegram 按鈕安全強化:C2/C3/H4/H6 修復
...
修復 P9-1 全景盤點所發現的四項高優先問題:
- routes/openclaw_bot_routes.py:
C3: ALLOWED_USERS/ALLOWED_GROUP 白名單 fail-closed,阻擋非授權 chat
H4: _seen_update_ids 改用 deque(maxlen=500) LRU 防記憶體洩漏
- services/telegram_bot_service.py:
C2: 新增 momo:bpa/bpr/eig 三個 callback 分支 + handler 實作
H6: callback 滑動視窗速率限制(30次/分鐘/用戶)
- services/telegram_templates.py:
修正 decision_result / ops_action_result ImportError BLOCKER
新增 _now_taipei_hhmm / _html_escape 輔助函式
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-25 01:42:58 +08:00
ogt
e9b2dabffd
[V10.3] Telegram Bot AI integration and Traditional Chinese fix | services/telegram_bot_service.py, telegram_ai_integration.py
2026-04-22 15:03:47 +08:00
ogt
b11789db77
fix(telegram+review): 修復 PPT 按鈕無反應 + Code Review 頁面空白
...
CD Pipeline / deploy (push) Successful in 1m28s
PPT 按鈕:
- telegram_bot_service.py 新增 cmd:* handler,透過 Thread 轉發到
OpenClaw Flask 內部 API(/bot/internal/cmd)
- openclaw_bot_routes.py 新增 /bot/internal/cmd 端點,背景執行 handle_cmd()
Code Review 頁面:
- get_history() 補回 findings / openclaw_report 欄位
- code_review.html history 項目可點擊,自動載入詳細內容
- poll() 無 active pipeline 時自動顯示最新歷史記錄
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-22 08:56:10 +08:00
ogt
0099543c05
fix(security): 全域健檢 — 40 項安全/Bug/品質修復
...
CD Pipeline / deploy (push) Failing after 5m18s
🔴 Critical
- auto_heal_service: 補 import re + sqlalchemy.text + 修正 orchestrator 變數名
+ autoheal_playbook→playbooks 表名 + _alert_and_store cooldown 修復
- aider_heal_executor: shell injection 改 shell=False + list 參數
- docker-compose: DISABLE_LOGIN 改 env var + 移除密碼 fallback + POSTGRES_HOST 修正
- app.py: /api/backup /api/run_task 等 6 個管理 API 加 @login_required
- config.py + pg_sync + e2e_test: 移除 wooo_pg_2026 hardcoded 密碼 fallback
- pg_backup.sh: 移除 TELEGRAM_TOKEN= 中間變數,直接用 $TELEGRAM_BOT_TOKEN
- migration 014: trigger_pattern→match_pattern + 補 error_type NOT NULL 欄位
🟡 High
- telegram_bot_service: str(e) 改通用訊息 + session try/finally + 移除 pa:/pr: 舊 callback
- run_scheduler: ElephantAlpha thread 死亡監控 + 自動重啟 + Telegram 告警
+ agent_context 03:30 TTL 定時清理任務
- openclaw_learning_service: build_rag_context 兩路徑加 .limit(200)
- hooks: commit-quality + momo-prod-guard 空 catch 改 stderr+exit(1)
- scripts/code_review: auto_yes 預設改 false
- db_backup_service: PGPASSWORD 透過 env dict 傳遞
📦 Migrations
- 013_autoheal: 修正建表順序 playbooks→incidents(外鍵前向引用)
- 018_add_missing_indexes: heal_logs/incidents 外鍵索引 + cleanup_expired_agent_context()
🟢 Infrastructure
- requirements.txt: 加版本下界 Flask>=2.3 SQLAlchemy>=1.4 等
- cd.yaml: 新增 run_scheduler.py + run_telegram_bot.py 監聽路徑
- .gitignore: insert_playbook_local.py 加入忽略
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-22 01:12:23 +08:00
ogt
b8e6f752fa
fix: 修復 Telegram Bot /menu 指令無響應及重複訊息問題
...
CD Pipeline / deploy (push) Failing after 55s
- telegram_bot_service: 新增 /menu 指令處理器,映射到 cmd_start
- openclaw_bot_routes: 優化「今日業績資料尚未匯入」訊息邏輯
- 區分「資料載入異常」vs「確實未匯入」
- 避免在已有今日資料時仍顯示未匯入訊息
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-20 22:48:07 +08:00
ogt
1fd1622007
feat(telegram): 全面切換 HTML parse_mode + 三層式視覺分隔
...
CD Pipeline / deploy (push) Successful in 1m12s
起因:Markdown 舊版 parse_mode 導致 \[Demo] / task\_name 反斜線外漏,
且三層結構(事件資訊 / AI 加工區 / 原始技術細節)分隔線不夠明顯。
切換 HTML parse_mode(只需 escape & < >,不會有反斜線副作用):
- telegram_templates.py 全模板重寫為 HTML
* <b>粗體</b> / <code>module</code> / <pre>trace</pre>
* H_DIV (━×20) 節間強分隔 / L_DIV (─×18) 節內弱分隔
* 新增 triaged_alert() 實作 ADR-012 §④ 三層式結構
[事件資訊] → ━━━ → [🤖 AI 分析] → ━━━ → [🔍 原始技術細節]
event_router.py:
- _hermes_observe_parsed() 回結構化 dict {summary, cause, actions}
取代舊的字串版本
- _render_l1/l2_with_fallback 改用 tpl.triaged_alert() 統一格式
- _send() parse_mode 改 HTML
Call sites 同步改 HTML:
- routes/bot_api_routes.py price_decision_notify
- services/openclaw_strategist_service.py 兩個發送處
- services/telegram_bot_service.py 三個 edit_message_text
(_handle_price_approve / _handle_price_reject / _handle_ops_callback)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-19 13:54:44 +08:00
ogt
bda4edd23b
feat(ai-ops): ADR-012 Phase 2/3/4 完整實作
...
CD Pipeline / deploy (push) Successful in 1m11s
Phase 2 — Hermes L1 Observer 真實接入:
- services/event_router.py::_hermes_observe() 呼叫 hermes3:latest
@192.168.0.111:11434/api/generate,做 stack trace 翻譯
- 輸出 JSON {summary, probable_cause, actions},容錯 markdown fence
- scheduler.py run_auto_import_task / run_momo_task 兩個 outer
except 改走 event_router.dispatch(),帶完整 trace
Phase 3 — NemoTron L2 Investigator 規則式實作:
- event_router._L2_RULES: event_type → [(action, params)] 規則表
• db_connection_error → query_km + retry_task(60s backoff)
• crawler_timeout → silence_alert(30min) + retry_task(300s)
• nim_quota_exhausted → silence_alert(720min)
• embedding_failure → silence_alert(10min)
- agent_actions.retry_task 真實實作: threading.Timer + exponential
backoff (60→120→240s) + _retry_state 追蹤 + ALLOWED_RETRY_TASKS
白名單 + 非 scheduler 容器回 'deferred'
Phase 4 — L3 HITL Ops 擴充:
- agent_actions: pause_task / resume_task / force_retry_now / is_task_paused
- OPS_ACTIONS 白名單與 SAFE_ACTIONS 嚴格分離(L2 不可呼叫 L3)
- telegram_templates.ops_action_request(): 4 按鈕 inline keyboard
(暫停1h / 暫停6h / 立即重試 / 解除暫停)
- telegram_bot_service._handle_ops_callback(): 接 momo:ops:<action>:<task>
- scheduler.py run_momo_task + run_auto_import_task 開頭加
is_task_paused() 檢查(Phase 4 暫停機制生效)
安全邊界(ADR-012 §①):
- L1 Hermes 只讀 → 失敗降 L0 + 🟡 標記
- L2 NemoTron 只碰 ai_insights + 發 Telegram + SAFE_ACTIONS
- L3 OpenClaw 任意動作必經 HITL inline keyboard 批准
- 不做容器重啟按鈕(需 docker socket,風險過高)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-19 13:26:51 +08:00
ogt
528a6c0468
feat(telegram): 統一訊息格式模板(六類 + callback prefix)
...
CD Pipeline / deploy (push) Successful in 1m12s
新增 services/telegram_templates.py:
- alert() 🚨 告警 / warning() ⚠️ 警告 / info() ℹ️ 資訊
- success() ✅ 成功 / report() 📊 報告 / price_decision() 💰 決策
- decision_result() 回執(edit_message 用)
- 全訊息標 [EwoooC] 前綴(跨專案共用 bot 識別來源,見 ADR-011)
- _escape_md() 處理 user input,避免 Markdown 破版
- _tail() 取 trace 末段,避開曠日 stack trace
接入點改用模板(P2/P3):
- routes/bot_api_routes.py price_decision_notify
- services/openclaw_strategist_service.py _send_price_decision_requests
- services/telegram_bot_service.py _handle_price_approve/reject
callback_data 改用 momo: prefix(舊 pa:/pr: 向下相容)
尚未接入(待下次迭代):
- scheduler.py 各 task 錯誤通知
- _notify_telegram_group() 週報推播
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-19 12:28:23 +08:00
ogt
8d0b79cd00
feat(ops): restore Telegram chain + P2/P3 price decisions + ADR-011
...
CD Pipeline / deploy (push) Successful in 1m19s
P2 (Inline Keyboard 降價決策):
- routes/bot_api_routes.py: POST /bot/api/price-decision/notify
- services/telegram_bot_service.py: pa:/pr: callback handlers
P3 (OpenClaw 自動觸發):
- services/openclaw_strategist_service.py: Gemini 週報末尾輸出
PRICE_DECISIONS_JSON,解析後自動推送 inline keyboard 給 admin
Ops 修復(跨專案隔離與容器斷訊根因):
- ADR-011 全面規範多專案共存邊界、禁用 --remove-orphans
- .gitea/workflows/cd.yaml: sync 模式一次重啟三容器
(原本僅 momo-pro-system,scheduler/telegram-bot 靜默落伍)
- run_telegram_bot.py: 從 scripts/tools/ 複製到根目錄
(消滅 docker-compose mount 建空目錄的陷阱)
- CLAUDE.md: 補核心容器表、診斷黃金三句、緊急指令
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-19 12:25:04 +08:00
ogt
1b4f3a7bbe
feat: EwoooC 初始化 — 完整專案推版至 Gitea
...
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-04-19 01:21:13 +08:00