sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -42,11 +42,16 @@ from app.gateway.routers import (
|
||||
compact_menu_overrides,
|
||||
dashboard_sessions,
|
||||
deep_research,
|
||||
direct_chat,
|
||||
external_llmwiki,
|
||||
feedback,
|
||||
fixed_questions,
|
||||
flow_extract,
|
||||
force_situation,
|
||||
gongwen_documents,
|
||||
html_images,
|
||||
html_page_favorites,
|
||||
html_runtime,
|
||||
intent,
|
||||
knowledge,
|
||||
knowledge_ingest,
|
||||
@@ -58,6 +63,7 @@ from app.gateway.routers import (
|
||||
memory,
|
||||
menu_overrides,
|
||||
model_management,
|
||||
model_exchanges,
|
||||
models,
|
||||
multi_agent,
|
||||
notifications,
|
||||
@@ -86,15 +92,20 @@ from app.gateway.routers import (
|
||||
roundtable_task_drafts,
|
||||
runs,
|
||||
scheduled_tasks,
|
||||
task_analysis,
|
||||
task_analysis_qa,
|
||||
sensitive_words,
|
||||
sentiment_agent,
|
||||
skill_addresses,
|
||||
skill_knowledge,
|
||||
skill_view_diagnostics,
|
||||
skills,
|
||||
strategy_agents,
|
||||
suggestions,
|
||||
system_settings,
|
||||
tags,
|
||||
task_buttons,
|
||||
task_deeplink_threads,
|
||||
task_reports,
|
||||
taskcop_tasks,
|
||||
thread_runs,
|
||||
@@ -102,8 +113,10 @@ from app.gateway.routers import (
|
||||
threads,
|
||||
tool_metrics,
|
||||
uploads,
|
||||
upload_policy,
|
||||
user_preferences,
|
||||
user_prompts,
|
||||
web_app_sites,
|
||||
workflow_data_sources,
|
||||
workflow_embed,
|
||||
workflow_planning,
|
||||
@@ -114,6 +127,7 @@ from app.gateway.routers import (
|
||||
workflows_coze_compat,
|
||||
writing,
|
||||
)
|
||||
from app.gateway.runtime_executor import configure_runtime_executor # noqa: E402
|
||||
from deerflow.config import app_config as deerflow_app_config
|
||||
from deerflow.config.app_config import apply_logging_level
|
||||
from deerflow.runtime.scheduler import ScheduledTaskService, set_scheduled_task_service
|
||||
@@ -322,6 +336,12 @@ async def _run_db_migrations() -> None:
|
||||
logger.info("Persistence backend=memory ? skipping Alembic migrations")
|
||||
return
|
||||
|
||||
from deerflow.persistence.gauss_mysql_compat import is_gauss_mysql_product
|
||||
|
||||
if is_gauss_mysql_product():
|
||||
logger.warning("Database product=gauss_mysql; skipping MySQL-specific Alembic migrations")
|
||||
return
|
||||
|
||||
if os.getenv("DEER_FLOW_SKIP_ALEMBIC", "").lower() in {"1", "true", "yes"}:
|
||||
logger.warning("DEER_FLOW_SKIP_ALEMBIC is set; skipping Alembic migrations")
|
||||
return
|
||||
@@ -991,6 +1011,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
try:
|
||||
app.state.config = get_app_config()
|
||||
apply_logging_level(app.state.config.log_level)
|
||||
await configure_runtime_executor(app.state.config.runtime_performance)
|
||||
logger.info("Configuration loaded successfully")
|
||||
except Exception as e:
|
||||
error_msg = f"Failed to load configuration during gateway startup: {e}"
|
||||
@@ -1019,20 +1040,16 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
# 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.
|
||||
app.state.llmwiki_index_scheduler_task = None
|
||||
local_wiki_index = app.state.config.llmwiki.local_wiki_index
|
||||
if (
|
||||
local_wiki_index.enabled
|
||||
and local_wiki_index.auto_sync
|
||||
and getattr(app.state, "llmwiki_sync_service", None) is not None
|
||||
):
|
||||
from app.gateway.llmwiki_index_scheduler import local_wiki_index_scheduler_loop
|
||||
# The lightweight Wiki coordinator always runs: it upgrades persisted
|
||||
# generation prompts and applies strict focus filters even when the
|
||||
# optional local mirror is disabled. Mirror/index scans themselves
|
||||
# remain opt-in inside the loop, with per-library database leases for
|
||||
# multi-worker safety.
|
||||
from app.gateway.llmwiki_index_scheduler import local_wiki_index_scheduler_loop
|
||||
|
||||
app.state.llmwiki_index_scheduler_task = asyncio.create_task(
|
||||
local_wiki_index_scheduler_loop(app)
|
||||
)
|
||||
app.state.llmwiki_index_scheduler_task = asyncio.create_task(
|
||||
local_wiki_index_scheduler_loop(app)
|
||||
)
|
||||
|
||||
# ?? recall_budget cache?? DB ????,? get_effective_memory_config ?????
|
||||
try:
|
||||
@@ -1087,6 +1104,21 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
"AI-writing functional agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# Strategy-selection functional agents (intent, six independent
|
||||
# analysis angles, judge, and solution editor). Seed them before
|
||||
# _sync_legacy_agents so they are immediately visible and editable in
|
||||
# the existing agent-management UI on a fresh deployment.
|
||||
try:
|
||||
from app.gateway.routers._strategy_selection_seed import (
|
||||
ensure_strategy_selection_agents,
|
||||
)
|
||||
|
||||
ensure_strategy_selection_agents()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Strategy-selection functional agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# 内置「模板数据转换器」agent(JSON → HTML 模板填充)。同样必须在
|
||||
# _sync_legacy_agents **之前**补建目录,后者把它 upsert 进 agents 表,
|
||||
# 第一次启动 /api/agents 与定时任务下拉框里就有它。
|
||||
@@ -1128,6 +1160,32 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
"Deep-research collector agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# Built-in public-document stack: agent + workflow skill + the full
|
||||
# gongwen-assistant DOCX engine skill, all version-synced into
|
||||
# skills/public/ (see _gongwen_seed.py). Seed before legacy agent
|
||||
# sync so it is immediately available to ordinary conversations.
|
||||
try:
|
||||
from app.gateway.routers._gongwen_seed import ensure_gongwen_agent
|
||||
|
||||
ensure_gongwen_agent()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Public-document agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# 内置「认知态势图」public 技能:skills/ 不随 git 快照搬运,新机器
|
||||
# 部署后技能缺失,由种子资产在首次启动时补建(目录存在则不动)。
|
||||
try:
|
||||
from app.gateway.routers._cognitive_situation_seed import (
|
||||
ensure_cognitive_situation_skills,
|
||||
)
|
||||
|
||||
ensure_cognitive_situation_skills()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Cognitive-situation skill 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.
|
||||
@@ -1156,6 +1214,41 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
"Forced-research responder agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# 内置「查询变慢排查助手」:Linux + MySQL 间歇性查询变慢。目录已存在则不覆盖。
|
||||
try:
|
||||
from app.gateway.routers._query_slowdown_diagnosis_seed import (
|
||||
ensure_query_slowdown_diagnosis_agent,
|
||||
)
|
||||
|
||||
ensure_query_slowdown_diagnosis_agent()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Query-slowdown diagnosis agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
# 内置「耗时排查助手」:根据执行记录和日志判断空等原因。目录已存在则不覆盖。
|
||||
try:
|
||||
from app.gateway.routers._latency_diagnosis_seed import (
|
||||
ensure_latency_diagnosis_agent,
|
||||
)
|
||||
|
||||
ensure_latency_diagnosis_agent()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Latency-diagnosis agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# 内置 Elasticsearch 离线运维助手:随离线包提供部署知识、只读采集脚本
|
||||
# 和规则分析器。必须在 legacy agent 同步前补建,目录存在时不覆盖现场修改。
|
||||
try:
|
||||
from app.gateway.routers._elasticsearch_offline_ops_seed import (
|
||||
ensure_elasticsearch_offline_ops_agent,
|
||||
)
|
||||
|
||||
ensure_elasticsearch_offline_ops_agent()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Elasticsearch offline operations agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
# 内置「任务研判报告助手」(agentfx 任务深链固定使用):同样必须在
|
||||
# _sync_legacy_agents 之前补建目录 + 补建配套 task-report-import 技能
|
||||
# (skills/ 被 .gitignore 排除),由后者 upsert 进 agents 表。
|
||||
@@ -1168,6 +1261,18 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
"Agentfx analyst agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# 内置「任务分析总控」(任务分析定时的专用总控:无人值守分解任务并派活)。
|
||||
try:
|
||||
from app.gateway.routers._task_analysis_seed import (
|
||||
ensure_task_analysis_functional_agents,
|
||||
)
|
||||
|
||||
ensure_task_analysis_functional_agents()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Task analysis coordinator agent seeding failed at startup (non-fatal)"
|
||||
)
|
||||
|
||||
# ?????????????????3Q/6BF/7BF/8BF??agent/chain ?????
|
||||
try:
|
||||
business_mapping_store = getattr(app.state, "business_mapping_store", None)
|
||||
@@ -1211,6 +1316,15 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
await ensure_builtin_agent_purpose_tags(agent_store, tag_store)
|
||||
except Exception:
|
||||
logger.exception("Built-in agent purpose-tag seeding failed at startup (non-fatal)")
|
||||
|
||||
# Synchronize every worker's strategy registry only after the
|
||||
# folder agents have been imported. In memory mode this also
|
||||
# restores dynamic/default angle lifecycle from sidecars.
|
||||
try:
|
||||
await strategy_agents.ensure_strategy_agent_registry(app)
|
||||
logger.info("Strategy agent registry synchronized for worker")
|
||||
except Exception:
|
||||
logger.exception("Strategy agent role seeding failed at startup (non-fatal)")
|
||||
except Exception:
|
||||
logger.exception("Legacy agent sync failed at startup (non-fatal)")
|
||||
|
||||
@@ -1268,8 +1382,33 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
except Exception:
|
||||
logger.exception("Scheduled task service failed to start")
|
||||
|
||||
# External-task chain-binding scheduler (任务分析定时)。
|
||||
task_analysis_enabled = os.environ.get("TASK_ANALYSIS_ENABLED", "true").strip().lower()
|
||||
if task_analysis_enabled in {"0", "false", "no", "off"}:
|
||||
logger.info("Task analysis service disabled by TASK_ANALYSIS_ENABLED")
|
||||
else:
|
||||
try:
|
||||
from deerflow.runtime.task_analysis import TaskAnalysisService
|
||||
|
||||
task_analysis_store = getattr(app.state, "task_analysis_store", None)
|
||||
if task_analysis_store is not None:
|
||||
ta_service = TaskAnalysisService(app, task_analysis_store)
|
||||
app.state.task_analysis_service = ta_service
|
||||
await ta_service.start()
|
||||
logger.info("Task analysis service started")
|
||||
except Exception:
|
||||
logger.exception("Task analysis service failed to start")
|
||||
|
||||
yield
|
||||
|
||||
artifact_library_tasks = list(
|
||||
getattr(app.state, "artifact_library_sync_tasks", {}).values()
|
||||
)
|
||||
for task in artifact_library_tasks:
|
||||
task.cancel()
|
||||
if artifact_library_tasks:
|
||||
await asyncio.gather(*artifact_library_tasks, return_exceptions=True)
|
||||
|
||||
llmwiki_index_scheduler_task = getattr(app.state, "llmwiki_index_scheduler_task", None)
|
||||
if llmwiki_index_scheduler_task is not None:
|
||||
llmwiki_index_scheduler_task.cancel()
|
||||
@@ -1340,6 +1479,13 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
finally:
|
||||
set_scheduled_task_service(None)
|
||||
|
||||
try:
|
||||
ta_service = getattr(app.state, "task_analysis_service", None)
|
||||
if ta_service is not None:
|
||||
await ta_service.stop()
|
||||
except Exception:
|
||||
logger.exception("Failed to stop task analysis service")
|
||||
|
||||
# Stop channel service on shutdown (bounded to prevent worker hang)
|
||||
try:
|
||||
from app.channels.service import stop_channel_service
|
||||
@@ -1590,21 +1736,31 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
from app.gateway.routers import wiki_packages
|
||||
|
||||
app.include_router(wiki_packages.router)
|
||||
|
||||
# Artifacts API is mounted at /api/threads/{thread_id}/artifacts
|
||||
app.include_router(artifacts.router)
|
||||
|
||||
# Web App site artifacts (multi-page site / flowchart / map) with signed
|
||||
# public static hosting at /api/public/site-preview/{token}/
|
||||
app.include_router(web_app_sites.router)
|
||||
|
||||
# Uploads API is mounted at /api/threads/{thread_id}/uploads
|
||||
app.include_router(uploads.router)
|
||||
# Global database-backed upload limits at /api/upload-policy.
|
||||
app.include_router(upload_policy.router)
|
||||
|
||||
# Optional Chrome-extension page capture API is mounted at /api/browser-context
|
||||
app.include_router(browser_context.router)
|
||||
|
||||
# Thread cleanup API is mounted at /api/threads/{thread_id}
|
||||
app.include_router(threads.router)
|
||||
from app.gateway.routers import analysis_projects
|
||||
|
||||
app.include_router(analysis_projects.router)
|
||||
app.include_router(threads.router)
|
||||
# Dedicated taskId + goPath history lookup for 3qfx/rwfx/xdfx single-agent chats.
|
||||
app.include_router(task_deeplink_threads.router)
|
||||
# Agents API is mounted at /api/agents
|
||||
app.include_router(agents.router)
|
||||
app.include_router(strategy_agents.router)
|
||||
|
||||
# Recommended Questions API is mounted at /api/recommended-questions
|
||||
app.include_router(recommended_questions.router)
|
||||
@@ -1671,6 +1827,9 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
# Sensitive-word map (敏感词管理 / 脱敏词) at /api/sensitive-words
|
||||
app.include_router(sensitive_words.router)
|
||||
|
||||
# Public-document workbench: durable originals, review snapshots and DOCX versions.
|
||||
app.include_router(gongwen_documents.router)
|
||||
|
||||
# Sentiment-analysis virtual agent AG-UI SSE proxy at /api/sentiment-agent
|
||||
app.include_router(sentiment_agent.router)
|
||||
|
||||
@@ -1698,6 +1857,9 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
# Task-scoped situation-report details used by dashboard drawing / task gates.
|
||||
app.include_router(task_reports.router)
|
||||
|
||||
# Force-situation task detail documents (new task type; free-form JSON).
|
||||
app.include_router(force_situation.router)
|
||||
|
||||
# Standalone parallel multi-agent panel: fan-out streaming + saved tasks
|
||||
app.include_router(parallel_agents.router)
|
||||
app.include_router(parallel_agent_tasks.router)
|
||||
@@ -1724,6 +1886,10 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
# Scheduled task API is mounted at /api/scheduled-tasks
|
||||
app.include_router(scheduled_tasks.router)
|
||||
|
||||
# External-task multi-agent scheduled analysis (/api/task-analysis)
|
||||
app.include_router(task_analysis.router)
|
||||
app.include_router(task_analysis_qa.router)
|
||||
|
||||
# Public, unauthenticated read-only scheduled task API
|
||||
# (/api/public/scheduled-tasks/*). Lets external systems query tasks and
|
||||
# surface results without a DeerFlow login.
|
||||
@@ -1735,6 +1901,8 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
# Public embed Q&A status polling (/api/public/embed/*)
|
||||
app.include_router(public_embed.router)
|
||||
app.include_router(public_config.router)
|
||||
app.include_router(html_runtime.router)
|
||||
app.include_router(html_images.router)
|
||||
app.include_router(html_page_favorites.router)
|
||||
|
||||
# Product knowledge base API is mounted at /api/knowledge
|
||||
@@ -1757,6 +1925,8 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
app.include_router(admin_users.self_router)
|
||||
|
||||
app.include_router(admin_active_runs.router)
|
||||
app.include_router(skill_view_diagnostics.router)
|
||||
app.include_router(model_exchanges.router)
|
||||
|
||||
# Admin tool / skill call metrics audit + export
|
||||
app.include_router(tool_metrics.router)
|
||||
@@ -1775,6 +1945,8 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
|
||||
# Feedback API is mounted at /api/threads/{thread_id}/runs/{run_id}/feedback
|
||||
app.include_router(feedback.router)
|
||||
# Aggregate user-feedback answer quality (not a complete capability score).
|
||||
app.include_router(feedback.agent_score_router)
|
||||
|
||||
# Notifications API is mounted at /api/notifications
|
||||
app.include_router(notifications.router)
|
||||
@@ -1803,6 +1975,9 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
|
||||
# 开放问答接口 /api/open/chat —— 无需登录,指定模型 + 智能体做问答,可关闭思考模式
|
||||
app.include_router(open_chat.router)
|
||||
|
||||
# 极速问答 /api/direct-chat/stream —— 直连大模型流式输出,不走 lead agent / 工具 / 技能
|
||||
app.include_router(direct_chat.router)
|
||||
|
||||
# 开放接口 /api/open/3qfx/ask —— 无需登录,按 taskId 直接发起 3qfx 第一次问答(后台运行,落成真实会话)
|
||||
app.include_router(open_3qfx.router)
|
||||
|
||||
|
||||
Reference in new issue
Block a user