新增: AI Chat多项增强(审批去重/编辑重发/导出/实体引用/会话置顶搜索)+任务推进链df-nodes落地
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -174,6 +175,11 @@ pub struct AppState {
|
||||
// ── LLM 并发控制 ──
|
||||
/// LLM 调用并发上限(全局 + 单对话双层 Semaphore,运行时可调)
|
||||
pub llm_concurrency: LlmConcurrency,
|
||||
// ── Agentic 循环轮次上限 ──
|
||||
/// Agentic 循环最大轮次(前端 Settings 数字配置 → AppState 字段 → 热改 command →
|
||||
/// loop 入口 load 快照透传形参;当前 loop 锁定边界,热改下次发消息生效)。
|
||||
/// 默认 10,与 agentic.rs::DEFAULT_MAX_AGENT_ITERATIONS 对齐。
|
||||
pub agent_max_iterations: Arc<AtomicUsize>,
|
||||
// ── 工作流执行状态 ──
|
||||
/// 工作流执行 → 节点状态机注册表
|
||||
///
|
||||
@@ -189,6 +195,9 @@ impl AppState {
|
||||
pub async fn init(db_path: &Path) -> Result<Self> {
|
||||
let db = Arc::new(Database::open(db_path).await?);
|
||||
let ai_tools = Arc::new(crate::commands::ai::build_ai_tool_registry(&db));
|
||||
// build_registry 需注入 Arc<Database>(TaskAdvanceNode 持 db)。
|
||||
// 在 struct 字段 `db` move 前 clone,避免 E0382。
|
||||
let registry = Arc::new(build_registry(db.clone()));
|
||||
let state = Self {
|
||||
ideas: IdeaRepo::new(&db),
|
||||
projects: ProjectRepo::new(&db),
|
||||
@@ -205,10 +214,13 @@ impl AppState {
|
||||
knowledge_config: Arc::new(Mutex::new(KnowledgeConfig::default())),
|
||||
settings: SettingsRepo::new(&db),
|
||||
llm_concurrency: LlmConcurrency::new(3, 2),
|
||||
agent_max_iterations: Arc::new(AtomicUsize::new(
|
||||
crate::commands::ai::agentic::DEFAULT_MAX_AGENT_ITERATIONS,
|
||||
)),
|
||||
workflow_state_registry: Arc::new(Mutex::new(HashMap::new())),
|
||||
db,
|
||||
event_bus: EventBus::new(),
|
||||
registry: Arc::new(build_registry()),
|
||||
registry,
|
||||
ai_tools,
|
||||
};
|
||||
// 启动恢复:重启前卡 pending 的工具审批(内存 pending_approvals 已丢)从审计表重建,
|
||||
@@ -229,7 +241,7 @@ impl AppState {
|
||||
/// 需求。需要脚本执行能力时新建独立 BuildNode(白名单 + 项目目录锚定 + 复用 AI 工具
|
||||
/// RiskLevel 审批链),而非回头启用 ScriptNode + 黑名单。
|
||||
/// 详见 docs/02-架构设计/工作流脚本执行边界-2026-06-15.md。
|
||||
fn build_registry() -> NodeRegistry {
|
||||
fn build_registry(db: Arc<Database>) -> NodeRegistry {
|
||||
let mut registry = NodeRegistry::new();
|
||||
registry.register("human", |_config| {
|
||||
Box::new(df_nodes::human_node::HumanNode)
|
||||
@@ -237,12 +249,14 @@ fn build_registry() -> NodeRegistry {
|
||||
registry.register("ai", |_config| {
|
||||
Box::new(df_nodes::ai_node::AiNode)
|
||||
});
|
||||
// 未在此注册的已实现节点:
|
||||
// - TaskAdvanceNode(df_nodes::task_advance_node, impl Node trait 已就绪):
|
||||
// 推进链 F-01~04 当前手动推进(IPC 直驱 advance_task),DAG 形态为阶段 2
|
||||
// 工作流联动(run_workflow task_id + 完成回调 advance_task + DAG 模板)预留。
|
||||
// 届时在此 register("task_advance", ...) 注入 Arc<Database>。
|
||||
// 非遗漏,勿删 task_advance_node.rs。
|
||||
// TaskAdvanceNode(df_nodes::task_advance_node, impl Node trait):
|
||||
// 推进链阶段 2 工作流联动入口 — DAG 内触发 advance_task。
|
||||
// 持有 Arc<Database> 在此构造时注入(NodeRegistry::register 工厂闭包 move 捕获 db,
|
||||
// Arc clone 廉价),Node::execute 从 NodeContext.config 读 task_id/target_status。
|
||||
// D-260616-03: 推进链/状态机/闸门走 df-nodes Node trait,非复活 df-task。
|
||||
registry.register("task_advance", move |_config| {
|
||||
Box::new(df_nodes::task_advance_node::TaskAdvanceNode::new(db.clone()))
|
||||
});
|
||||
registry
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user