feat(scheduler): add scheduled jobs with channel-aware delivery

Introduce persisted cron/interval jobs, gateway scheduler loop, worker turns,
and admin CRUD/edit UI. Route proactive reminders via the originating chat
channel (WhatsApp vs WeChat), harden Weixin outbound with durable queue and
PG-compatible polling, and fix chat UI to show each scheduled reminder separately.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-06-26 15:56:10 +08:00
parent 5336f8835f
commit 47813f6a94
45 changed files with 4956 additions and 43 deletions

View file

@ -690,6 +690,14 @@ def _build_model_context(
)
except Exception:
pass
if str(user_text or "").strip() and str(active_turn_uuid or "").strip():
has_turn_user = any(
str(getattr(m, "role", "") or "") == "user"
and str(getattr(m, "turn_uuid", "") or "") == str(active_turn_uuid)
for m in (rows or [])
)
if not has_turn_user:
llm_messages.append({"role": "user", "content": str(user_text).strip()})
return llm_messages