重构: String→newtype 强类型 + 工程清理
- df-types: ExecutionId/ToolCallType 从 type 别名改为 newtype 结构体 - df-ai-core: 新增 ToolType newtype / MessageStatus 枚举, ChatMessage.status 从 Option<String> 改为 Option<MessageStatus> - provider: is_active() 改用 MessageStatus::Active 模式匹配 - context/chat/conversation: 构造站点更新为枚举变体 - .gitignore: 添加分析脚本排除项,清理根目录临时文件 - Batch.md: 更新最新提交与新增 Batch 37 记录
This commit is contained in:
@@ -102,10 +102,10 @@ pub async fn run_workflow_inner(
|
||||
let runtime_dag = state.registry.build_dag(&dag).map_err(err_str)?;
|
||||
|
||||
// 2. 写入执行记录(status=running)
|
||||
let execution_id = new_id();
|
||||
let execution_id: ExecutionId = new_id().into();
|
||||
let dag_json = serde_json::to_string(&dag).map_err(err_str)?;
|
||||
let record = WorkflowRecord {
|
||||
id: execution_id.clone(),
|
||||
id: execution_id.to_string(),
|
||||
name,
|
||||
dag_json,
|
||||
status: "running".to_string(),
|
||||
@@ -149,13 +149,15 @@ pub async fn run_workflow_inner(
|
||||
&event,
|
||||
WorkflowEvent::WorkflowCompleted { execution_id, .. }
|
||||
| WorkflowEvent::WorkflowFailed { execution_id, .. }
|
||||
// execution_id: WorkflowEvent 中反序列化的 ExecutionId(#[serde(default)]),
|
||||
// forward_exec_id: 本 forward 循环所属的 ExecutionId,同类型直接比较
|
||||
if execution_id == &forward_exec_id
|
||||
);
|
||||
let payload = WorkflowEventPayload {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
event,
|
||||
};
|
||||
if let Err(e) = forward_app.emit("workflow-event", &payload) {
|
||||
if let Err(e) = forward_app.emit("workflow-event", &payload) {
|
||||
tracing::warn!("工作流事件转发失败: {}", e);
|
||||
}
|
||||
if finished {
|
||||
@@ -186,21 +188,21 @@ pub async fn run_workflow_inner(
|
||||
match workflows.get_by_id(&forward_exec_id).await {
|
||||
Ok(Some(record)) => {
|
||||
let terminal = match record.status.as_str() {
|
||||
"completed" => Some(WorkflowEvent::WorkflowCompleted {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
total_duration_ms: 0,
|
||||
}),
|
||||
"failed" => Some(WorkflowEvent::WorkflowFailed {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
error: "工作流执行失败(Lagged 兜底补发,详情见 DB)"
|
||||
.to_string(),
|
||||
failed_node: String::new(),
|
||||
}),
|
||||
"cancelled" => Some(WorkflowEvent::WorkflowFailed {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
error: "工作流被取消(Lagged 兜底补发)".to_string(),
|
||||
failed_node: String::new(),
|
||||
}),
|
||||
"completed" => Some(WorkflowEvent::WorkflowCompleted {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
total_duration_ms: 0,
|
||||
}),
|
||||
"failed" => Some(WorkflowEvent::WorkflowFailed {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
error: "工作流执行失败(Lagged 兜底补发,详情见 DB)"
|
||||
.to_string(),
|
||||
failed_node: String::new(),
|
||||
}),
|
||||
"cancelled" => Some(WorkflowEvent::WorkflowFailed {
|
||||
execution_id: forward_exec_id.clone(),
|
||||
error: "工作流被取消(Lagged 兜底补发)".to_string(),
|
||||
failed_node: String::new(),
|
||||
}),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(synth_event) = terminal {
|
||||
@@ -351,7 +353,7 @@ pub async fn run_workflow_inner(
|
||||
}
|
||||
});
|
||||
|
||||
Ok(execution_id)
|
||||
Ok(execution_id.to_string())
|
||||
}
|
||||
|
||||
/// 列出全部工作流执行记录
|
||||
|
||||
Reference in New Issue
Block a user