- Introduce a new WorkflowEngine class to manage workflow graphs, enabling dynamic node-based interactions. - Update AssistantConfig to include a graph field for workflow definitions, allowing for flexible configuration. - Modify pipeline execution to support workflow-driven dialogue, integrating node transitions and system prompts based on active nodes. - Enhance frontend components to visualize active nodes and provide debugging capabilities, including highlighting the current node during interactions. - Refactor existing components to accommodate new workflow functionalities and improve overall user experience.
27 lines
874 B
TypeScript
27 lines
874 B
TypeScript
"use client";
|
|
|
|
/**
|
|
* 画布内共享上下文。GenericNode / ConditionEdge 由 ReactFlow 渲染,拿不到外层
|
|
* 回调,统一通过这些 context 取节点规格与编辑/删除动作。
|
|
*/
|
|
|
|
import { createContext } from "react";
|
|
|
|
import type { NodeSpecMap } from "./specs";
|
|
|
|
/** 节点类型 → 运行期规格(来自 /api/node-types) */
|
|
export const NodeSpecsContext = createContext<NodeSpecMap>({});
|
|
|
|
export type ElementActions = {
|
|
edit: (id: string) => void;
|
|
remove: (id: string) => void;
|
|
};
|
|
|
|
const noop: ElementActions = { edit: () => {}, remove: () => {} };
|
|
|
|
export const NodeActionContext = createContext<ElementActions>(noop);
|
|
export const EdgeActionContext = createContext<ElementActions>(noop);
|
|
|
|
/** 调试通话中当前激活的节点 id(画布据此高亮),无激活为 null。 */
|
|
export const ActiveNodeContext = createContext<string | null>(null);
|