- df-ai: context 历史中毒三档自愈 sanitize_messages(AC3)+anthropic_compat tool_use_id None 跳过(AC1/AC2)+删 router/stream 死码
- df-core: events 加 select_type+decisions 多选审批契约(F-260615-01)
- df-execute: shell run_command 工具复用(F-260615-05)
- df-nodes: human_node 多选校验+2 端到端测(F-01)+取消跳 set_failed(B-03b-R1/R2/R8)
- df-workflow: executor/dag/state cancel 闭环(B-06/07/03a/b)+provider approve options(R-PD-5)
- df-storage: find_path_conflict 抽公共(R-PD-11)+COLS 常量断言
- df-ideas: 删 IdeaPromoter/PromotionPolicy 死码(R-PD-14)
- src-tauri/commands/ai: secret keyring 迁移(FR-S1/R-PD-4)+GeneratingGuard RAII+disarm(B-09/26)+newConversation 软复位(B-10)+stream 心跳/stop select/空回复判错(B-02/04/05/15)+run_command(F-05)+mask audit(AR-3)
- src-tauri/commands/{project,task,workflow,mod,lib,state}: task detail IPC(F-02)+approve decisions+task list 联动(B-29)
- Cargo.lock+Cargo.toml 依赖同步
100 lines
2.6 KiB
Rust
100 lines
2.6 KiB
Rust
//! 工作流事件定义
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::types::NodeId;
|
|
|
|
/// 人工审批选择类型(F-260615-01)
|
|
/// - Single: 单选(decision 单值),缺省值,向后兼容现有调用方
|
|
/// - Multiple: 多选(decisions 数组)
|
|
///
|
|
/// serde rename_all="snake_case" → "single"/"multiple"
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum SelectType {
|
|
#[default]
|
|
Single,
|
|
Multiple,
|
|
}
|
|
|
|
/// 人工审批响应
|
|
///
|
|
/// 兼容字段(decision 单值):仅 select_type=Single 时使用;
|
|
/// 新字段 decisions 数组:Single 时长度=1,Multiple 时长度≥1。
|
|
/// 旧调用方仍可只填 decision,HumanNode 下游兼容两者。
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct HumanApprovalResponse {
|
|
pub execution_id: String,
|
|
pub node_id: NodeId,
|
|
pub decision: String,
|
|
#[serde(default)]
|
|
pub decisions: Vec<String>,
|
|
pub comment: Option<String>,
|
|
}
|
|
|
|
/// 工作流事件
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum WorkflowEvent {
|
|
/// 节点开始执行
|
|
NodeStarted {
|
|
node_id: NodeId,
|
|
},
|
|
/// 节点执行进度更新
|
|
NodeProgress {
|
|
node_id: NodeId,
|
|
progress: f32,
|
|
message: String,
|
|
},
|
|
/// 节点产生输出
|
|
NodeOutput {
|
|
node_id: NodeId,
|
|
output: String,
|
|
},
|
|
/// 节点执行完成
|
|
NodeCompleted {
|
|
node_id: NodeId,
|
|
duration_ms: u64,
|
|
},
|
|
/// 节点执行失败
|
|
NodeFailed {
|
|
node_id: NodeId,
|
|
error: String,
|
|
},
|
|
/// 工作流暂停(等待外部输入)
|
|
WorkflowPaused {
|
|
reason: String,
|
|
waiting_node: NodeId,
|
|
},
|
|
/// 工作流执行完成
|
|
WorkflowCompleted {
|
|
total_duration_ms: u64,
|
|
},
|
|
/// 工作流执行失败
|
|
WorkflowFailed {
|
|
error: String,
|
|
failed_node: NodeId,
|
|
},
|
|
/// 人工审批请求
|
|
HumanApprovalRequest {
|
|
execution_id: String,
|
|
node_id: NodeId,
|
|
title: String,
|
|
description: String,
|
|
options: Vec<String>,
|
|
/// F-260615-01: 选择类型,缺省 Single(向后兼容)
|
|
#[serde(default)]
|
|
select_type: SelectType,
|
|
},
|
|
/// 人工审批响应
|
|
HumanApprovalResponse {
|
|
execution_id: String,
|
|
node_id: NodeId,
|
|
decision: String,
|
|
/// F-260615-01: 多选结果(Single 模式长度=1,Multiple 模式长度≥1)
|
|
#[serde(default)]
|
|
decisions: Vec<String>,
|
|
comment: Option<String>,
|
|
},
|
|
}
|