- Introduce a new workflow editor component for visualizing and managing workflows, allowing users to add nodes and define connections. - Implement backend support for node types, including validation and constraints for workflow graphs. - Add new API endpoints for retrieving node types and their specifications. - Enhance the AssistantPage to integrate the workflow editor, enabling users to create and edit workflows directly. - Update frontend components to support new workflow functionalities, including condition edges and generic nodes. - Refactor existing code to accommodate the new workflow features and improve overall structure.
24 lines
716 B
TypeScript
24 lines
716 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);
|