feat: add fixed questions and improve authentication

This commit is contained in:
吉鑫升 committed 2026-08-21 17:58:39 +08:00
1 parent 8af4fed89d
commit 4c9f75f31e
42 files changed
+4008 -200

No files matched your search

@@ -41,10 +41,29 @@ DeerFlow is a LangGraph-based AI super agent with sandbox execution, persistent
Health probes are always unauthenticated, even when API authentication is enabled: `GET|HEAD /health`, `/api/health`, and `/api/langgraph/health` all return the Gateway health status without requiring a cookie or bearer token.
Browser authentication is page-context aware. Normal application tabs share the account stored in `localStorage`; `embed=1` and `isolate=1` pages intentionally keep their own account in per-tab `sessionStorage`. Frontend API calls send that selected account as an explicit `Authorization: Bearer` token, and both Gateway and LangGraph authentication give the header priority over the origin-wide session cookie. This prevents a login in another tab or iframe from making the current page query threads as the wrong account. Reissuing a token for the same normalized username is not treated as an account switch; a real switch clears account-scoped frontend state, opens a fresh chat when necessary, and does not reload the whole browser page. Bare username login is domain-agnostic and deterministically reuses the oldest matching account if legacy synthetic email domains coexist; an explicitly supplied email still selects that exact address.
---
## Core Components
### Administrator fixed questions
Administrators can manage exact-match question/answer pairs from the frontend
「问题配置」 page. Each pair has its own enabled switch and configurable fixed-answer
streaming speed (`1–1000 token/s`, default `100 token/s`). For an enabled pair,
a plain-text external chat turn whose text exactly equals the configured
question is answered by a local streaming graph and never sent to a model
provider. The normal LangGraph SSE protocol and checkpoint persistence are
preserved, so the fixed response appears in live chat and conversation history.
Multimodal/file turns, AI Writing/Canvas flows, and internal orchestration child
runs bypass this lookup and continue through their normal model pipeline.
The admin-only configuration API is `GET|PUT /api/fixed-questions`; `PUT`
atomically replaces the full set. Rows are stored in `fixed_questions` (Alembic
revisions `20260821_01` and `20260821_02`) and are looked up with a SHA-256 index plus an exact
original-text comparison.
### Lead Agent
The single LangGraph agent (`lead_agent`) is the runtime entry point, created via `make_lead_agent(config)`. It combines: