feat: 重构多轮RAG展示并完善报告协作、业务链审核与 agentfx 种子

抽出专用多轮RAG消息列表并升级会话模型;强化报告协作画布与检查器;业务链普通用户改为提交审核;扩展 agentfx 报告技能种子,并将含 admin 的用户名自动提权为管理员。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-09-03 17:34:16 +08:00
1 parent f109a95535
commit db333a4c33
30 files changed
+2878 -1482

No files matched your search

@@ -101,10 +101,10 @@ from app.gateway.routers import (
uploads,
user_preferences,
user_prompts,
workflow_data_sources,
workflow_embed,
workflow_planning,
workflow_resources,
workflow_data_sources,
workflow_embed,
workflow_planning,
workflow_resources,
workflow_runs,
workflow_studio,
workflows,
@@ -997,24 +997,24 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
logger.info(f"Starting API Gateway on {config.host}:{config.port}")
# Initialize LangGraph runtime components (StreamBridge, RunManager, checkpointer, store)
async with langgraph_runtime(app):
logger.info("LangGraph runtime initialised")
# One-time repair switch for a failed, unused Workflow Studio schema.
# The helper is intentionally MySQL-only and drops an exact allow-list
# in the configured current database; it never expands ``workflow_%``.
# Keep this opt-in so established workflow data is never cleared during
# an ordinary restart.
if os.getenv("DEER_FLOW_REBUILD_WORKFLOW_SCHEMA", "").lower() in {"1", "true", "yes"}:
from deerflow.persistence.engine import rebuild_workflow_schema_for_mysql
logger.warning(
"DEER_FLOW_REBUILD_WORKFLOW_SCHEMA is enabled; rebuilding the unused workflow schema"
)
await rebuild_workflow_schema_for_mysql()
# Run Alembic migrations before anything else touches the schema.
await _run_db_migrations()
async with langgraph_runtime(app):
logger.info("LangGraph runtime initialised")
# One-time repair switch for a failed, unused Workflow Studio schema.
# The helper is intentionally MySQL-only and drops an exact allow-list
# in the configured current database; it never expands ``workflow_%``.
# Keep this opt-in so established workflow data is never cleared during
# an ordinary restart.
if os.getenv("DEER_FLOW_REBUILD_WORKFLOW_SCHEMA", "").lower() in {"1", "true", "yes"}:
from deerflow.persistence.engine import rebuild_workflow_schema_for_mysql
logger.warning(
"DEER_FLOW_REBUILD_WORKFLOW_SCHEMA is enabled; rebuilding the unused workflow schema"
)
await rebuild_workflow_schema_for_mysql()
# Run Alembic migrations before anything else touches the schema.
await _run_db_migrations()
# Local Wiki mirror/index scans are opt-in and run outside request
# handling. Per-library database leases keep multi-worker startup safe.
@@ -1093,25 +1093,25 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
)
ensure_template_builder_agent()
except Exception:
logger.exception(
"Template-builder agent seeding failed at startup (non-fatal)"
)
# 实验性「页面研报设计师」:在 _sync_legacy_agents 前补齐 agent 目录与
# 公共页面生成技能,首次启动即可在智能体管理页和普通对话中复用。
try:
from app.gateway.routers._page_report_designer_seed import (
ensure_page_report_designer_agent,
)
ensure_page_report_designer_agent()
except Exception:
logger.exception(
"Page-report designer agent seeding failed at startup (non-fatal)"
)
# 深度研究「收集员」内置 agent(对话式信息收集)。同样必须在
except Exception:
logger.exception(
"Template-builder agent seeding failed at startup (non-fatal)"
)
# 实验性「页面研报设计师」:在 _sync_legacy_agents 前补齐 agent 目录与
# 公共页面生成技能,首次启动即可在智能体管理页和普通对话中复用。
try:
from app.gateway.routers._page_report_designer_seed import (
ensure_page_report_designer_agent,
)
ensure_page_report_designer_agent()
except Exception:
logger.exception(
"Page-report designer agent seeding failed at startup (non-fatal)"
)
# 深度研究「收集员」内置 agent(对话式信息收集)。同样必须在
# _sync_legacy_agents 之前补建目录,由后者 upsert 进 agents 表,
# 深度研究页的收集对话与智能体管理页即可直接使用。
try:
@@ -1120,26 +1120,26 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
)
ensure_deep_research_collector_agent()
except Exception:
logger.exception(
"Deep-research collector agent seeding failed at startup (non-fatal)"
)
# Workflow Studio owns a separate planning controller. It must be
# seeded before _sync_legacy_agents, so the planner is available to
# every user's candidate-workflow request on a fresh deployment.
try:
from app.gateway.routers._workflow_planner_seed import (
ensure_workflow_planner_agent,
)
ensure_workflow_planner_agent()
except Exception:
logger.exception(
"Workflow planner agent seeding failed at startup (non-fatal)"
)
# 内置「强制检索输出助手」:必须在 _sync_legacy_agents 之前补建,
except Exception:
logger.exception(
"Deep-research collector agent seeding failed at startup (non-fatal)"
)
# Workflow Studio owns a separate planning controller. It must be
# seeded before _sync_legacy_agents, so the planner is available to
# every user's candidate-workflow request on a fresh deployment.
try:
from app.gateway.routers._workflow_planner_seed import (
ensure_workflow_planner_agent,
)
ensure_workflow_planner_agent()
except Exception:
logger.exception(
"Workflow planner agent seeding failed at startup (non-fatal)"
)
# 内置「强制检索输出助手」:必须在 _sync_legacy_agents 之前补建,
# 使首次启动就能在智能体管理/广场中使用。每轮检索门禁由 harness
# 的 ForcedResearchMiddleware 执行,而不是仅依赖 SOUL 提示词。
try:
@@ -1640,13 +1640,13 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
app.include_router(light_apps.router)
# Workflow Studio: definitions / runs / SSE / data sources / embed / Coze compat.
# Static prefixes (node-types, resources, planning, runs, data-sources, embed) must be
# Static prefixes (node-types, resources, planning, runs, data-sources, embed) must be
# registered before the /{workflow_id} catch-alls in workflows.router.
app.include_router(workflow_resources.router)
app.include_router(workflow_data_sources.router)
app.include_router(workflow_embed.router)
app.include_router(workflow_planning.router)
app.include_router(workflow_runs.router)
app.include_router(workflow_resources.router)
app.include_router(workflow_data_sources.router)
app.include_router(workflow_embed.router)
app.include_router(workflow_planning.router)
app.include_router(workflow_runs.router)
app.include_router(workflow_studio.router)
app.include_router(workflows.router)
app.include_router(workflows_coze_compat.router)