feat(workflow): enhance message stages and image routing

This commit is contained in:
Xin Wang
2026-08-03 12:38:02 +08:00
parent b0991f239e
commit 4c43e167db
13 changed files with 593 additions and 157 deletions

View File

@@ -16,6 +16,10 @@ export type WorkflowNodeType =
export type ContextPolicy = "inherit" | "fresh";
export type KnowledgeMode = "automatic" | "on_demand" | "disabled";
export type AgentEntryMode = "wait_user" | "generate";
export type MessageCompletionPolicy =
| "interruptible"
| "playback"
| "confirmation";
export type ActionResultAssignmentMode = "inherit" | "override" | "none";
export type ActionUserInputPolicy = "queue" | "block";
export type EdgeMode = "llm" | "expression" | "always";
@@ -54,9 +58,12 @@ export type WorkflowNodeData = {
resultAssignments?: Record<string, string>;
userInputPolicy?: ActionUserInputPolicy;
speech?: string;
/** Legacy field read only while an older graph is open in the editor. */
showMessage?: boolean;
title?: string;
confirmLabel?: string;
completionPolicy?: MessageCompletionPolicy;
/** Legacy field read only while an older graph is open in the editor. */
requireConfirmation?: boolean;
targetType?: "ai" | "human" | "queue" | "phone";
target?: string;
@@ -65,6 +72,20 @@ export type WorkflowNodeData = {
[key: string]: unknown;
};
/** Infer the new Message policy for graphs saved before it was explicit. */
export function messageCompletionPolicy(
data: WorkflowNodeData,
): MessageCompletionPolicy {
if (
data.completionPolicy === "interruptible" ||
data.completionPolicy === "playback" ||
data.completionPolicy === "confirmation"
) {
return data.completionPolicy;
}
return data.requireConfirmation === true ? "confirmation" : "playback";
}
/**
* Resolve how an Action writes tool results while preserving workflows saved
* before resultAssignmentMode existed. Those nodes explicitly passed an empty
@@ -242,11 +263,10 @@ export function defaultGraph(): WorkflowGraph {
data: {
name: "开场消息",
speech: "你好,我是 AI 视频助手,有什么可以帮你?",
showMessage: false,
title: "重要提示",
message: "",
confirmLabel: "确认",
requireConfirmation: false,
completionPolicy: "playback",
},
},
{