feat:统一节点进度事件

This commit is contained in:
2026-09-29 00:47:57 +08:00
parent 437fcd74b1
commit 2b029b4bc7
6 changed files with 141 additions and 9 deletions
+20
View File
@@ -0,0 +1,20 @@
"""节点进度事件"""
from typing import Literal
from pydantic import BaseModel, Field
NodeProgressStatus = Literal[
"started", "completed", "waiting_for_input", "failed", "cancelled"
]
class NodeProgress(BaseModel):
type: Literal["node_progress"] = "node_progress" # 用于区分流中的事件类型
thread_id: str | None = None # 任务 ID,独立运行节点时可以为空
message_id: str | None = None # 当前用户输入 ID
execution_id: str # 单次节点执行 ID,开始和结束共用
node: str # 稳定的技术标识,供程序处理和排查
label: str | None = None # 用户进度提示,缺省时不展示该节点
status: NodeProgressStatus # 节点执行状态,不代表任务总体状态
duration_ms: float | None = Field(default=None, ge=0) # 结束时的执行耗时