@datatechsolutions/ui 2.7.114 → 2.7.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -284,6 +284,48 @@ var useWorkflowStore = zustand.create((set, get) => ({
284
284
  });
285
285
  }
286
286
  }));
287
+ var useDrawerStore = zustand.create((set) => ({
288
+ activeDrawer: null,
289
+ agentData: null,
290
+ subworkflowData: null,
291
+ logicNodeData: null,
292
+ pipelineSettingsData: null,
293
+ openAgentDrawer: (agent, models, isCreateMode = false) => set({
294
+ activeDrawer: "agent",
295
+ agentData: { agent, models, isCreateMode },
296
+ subworkflowData: null,
297
+ logicNodeData: null,
298
+ pipelineSettingsData: null
299
+ }),
300
+ openSubworkflowDrawer: (tool) => set({
301
+ activeDrawer: "subworkflow",
302
+ subworkflowData: { tool },
303
+ agentData: null,
304
+ logicNodeData: null,
305
+ pipelineSettingsData: null
306
+ }),
307
+ openLogicNodeDrawer: (nodeId, nodeLabel, config) => set({
308
+ activeDrawer: "logic-node",
309
+ logicNodeData: { nodeId, nodeLabel, config },
310
+ agentData: null,
311
+ subworkflowData: null,
312
+ pipelineSettingsData: null
313
+ }),
314
+ openPipelineSettingsDrawer: (name, description) => set({
315
+ activeDrawer: "pipeline-settings",
316
+ pipelineSettingsData: { name, description },
317
+ agentData: null,
318
+ subworkflowData: null,
319
+ logicNodeData: null
320
+ }),
321
+ closeDrawer: () => set({
322
+ activeDrawer: null,
323
+ agentData: null,
324
+ subworkflowData: null,
325
+ logicNodeData: null,
326
+ pipelineSettingsData: null
327
+ })
328
+ }));
287
329
  var GRAPH_ACTIVE_EDGE_COLOR = "#14b8a6";
288
330
  var GRAPH_TRUE_EDGE_COLOR = "#22c55e";
289
331
  var GRAPH_FALSE_EDGE_COLOR = "#ef4444";
@@ -8161,8 +8203,15 @@ var NODE_TITLE_KEYS = {
8161
8203
  entity: "entityNodeConfig",
8162
8204
  group: "groupNodeConfig"
8163
8205
  };
8164
- function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, entities = [] }) {
8206
+ function LogicNodeDrawer({ onSave, entities = [] }) {
8165
8207
  const t = nextIntl.useTranslations("agents.workflow");
8208
+ const activeDrawer = useDrawerStore((s) => s.activeDrawer);
8209
+ const logicNodeData = useDrawerStore((s) => s.logicNodeData);
8210
+ const closeDrawer = useDrawerStore((s) => s.closeDrawer);
8211
+ const open = activeDrawer === "logic-node";
8212
+ const nodeId = logicNodeData?.nodeId ?? null;
8213
+ const nodeLabel = logicNodeData?.nodeLabel ?? "";
8214
+ const config = logicNodeData?.config ?? null;
8166
8215
  if (!config || !nodeId) return null;
8167
8216
  const entityMasterId = config.type === "entity" ? config.entityMasterId : void 0;
8168
8217
  const IconComponent = entityMasterId ? getEntityIcon(entityMasterId) : LOGIC_ICON_MAP[config.type];
@@ -8175,41 +8224,41 @@ function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, ent
8175
8224
  const renderForm = () => {
8176
8225
  switch (config.type) {
8177
8226
  case "start":
8178
- return /* @__PURE__ */ jsxRuntime.jsx(StartNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8227
+ return /* @__PURE__ */ jsxRuntime.jsx(StartNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8179
8228
  case "end":
8180
- return /* @__PURE__ */ jsxRuntime.jsx(EndNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8229
+ return /* @__PURE__ */ jsxRuntime.jsx(EndNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8181
8230
  case "if_else":
8182
- return /* @__PURE__ */ jsxRuntime.jsx(IfElseNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8231
+ return /* @__PURE__ */ jsxRuntime.jsx(IfElseNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8183
8232
  case "code":
8184
- return /* @__PURE__ */ jsxRuntime.jsx(CodeNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8233
+ return /* @__PURE__ */ jsxRuntime.jsx(CodeNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8185
8234
  case "http_request":
8186
- return /* @__PURE__ */ jsxRuntime.jsx(HttpRequestNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8235
+ return /* @__PURE__ */ jsxRuntime.jsx(HttpRequestNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8187
8236
  case "template_transform":
8188
- return /* @__PURE__ */ jsxRuntime.jsx(TemplateTransformNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8237
+ return /* @__PURE__ */ jsxRuntime.jsx(TemplateTransformNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8189
8238
  case "iteration":
8190
- return /* @__PURE__ */ jsxRuntime.jsx(IterationNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8239
+ return /* @__PURE__ */ jsxRuntime.jsx(IterationNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8191
8240
  case "knowledge_base":
8192
- return /* @__PURE__ */ jsxRuntime.jsx(KnowledgeBaseNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8241
+ return /* @__PURE__ */ jsxRuntime.jsx(KnowledgeBaseNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8193
8242
  case "answer":
8194
- return /* @__PURE__ */ jsxRuntime.jsx(AnswerNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8243
+ return /* @__PURE__ */ jsxRuntime.jsx(AnswerNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8195
8244
  case "question_classifier":
8196
- return /* @__PURE__ */ jsxRuntime.jsx(QuestionClassifierNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8245
+ return /* @__PURE__ */ jsxRuntime.jsx(QuestionClassifierNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8197
8246
  case "parameter_extractor":
8198
- return /* @__PURE__ */ jsxRuntime.jsx(ParameterExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8247
+ return /* @__PURE__ */ jsxRuntime.jsx(ParameterExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8199
8248
  case "variable_assigner":
8200
- return /* @__PURE__ */ jsxRuntime.jsx(VariableAssignerNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8249
+ return /* @__PURE__ */ jsxRuntime.jsx(VariableAssignerNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8201
8250
  case "variable_aggregator":
8202
- return /* @__PURE__ */ jsxRuntime.jsx(VariableAggregatorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8251
+ return /* @__PURE__ */ jsxRuntime.jsx(VariableAggregatorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8203
8252
  case "document_extractor":
8204
- return /* @__PURE__ */ jsxRuntime.jsx(DocumentExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8253
+ return /* @__PURE__ */ jsxRuntime.jsx(DocumentExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8205
8254
  case "list_operator":
8206
- return /* @__PURE__ */ jsxRuntime.jsx(ListOperatorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8255
+ return /* @__PURE__ */ jsxRuntime.jsx(ListOperatorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8207
8256
  case "iteration_start":
8208
- return /* @__PURE__ */ jsxRuntime.jsx(IterationStartNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8257
+ return /* @__PURE__ */ jsxRuntime.jsx(IterationStartNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8209
8258
  case "entity":
8210
- return /* @__PURE__ */ jsxRuntime.jsx(EntityNodeConfigForm, { config, entities, onSave: handleSave, onCancel: onClose });
8259
+ return /* @__PURE__ */ jsxRuntime.jsx(EntityNodeConfigForm, { config, entities, onSave: handleSave, onCancel: closeDrawer });
8211
8260
  case "group":
8212
- return /* @__PURE__ */ jsxRuntime.jsx(GroupNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8261
+ return /* @__PURE__ */ jsxRuntime.jsx(GroupNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8213
8262
  default:
8214
8263
  return null;
8215
8264
  }
@@ -8218,7 +8267,7 @@ function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, ent
8218
8267
  WorkspaceDrawer,
8219
8268
  {
8220
8269
  open,
8221
- onClose,
8270
+ onClose: closeDrawer,
8222
8271
  title,
8223
8272
  subtitle: nodeLabel,
8224
8273
  icon: IconComponent ? /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { className: "h-5 w-5 text-white" }) : void 0,
@@ -8647,23 +8696,26 @@ function WorkflowCanvasInner({
8647
8696
  isCreatingAgent = false,
8648
8697
  nodeTypes: externalNodeTypes,
8649
8698
  renderAgentDrawer,
8650
- renderLogicNodeDrawer
8699
+ renderLogicNodeDrawer: _renderLogicNodeDrawer
8651
8700
  }) {
8652
8701
  const { screenToFlowPosition, getNode, toObject, fitView, zoomIn, zoomOut, zoomTo } = react.useReactFlow();
8653
8702
  const tWorkflow = nextIntl.useTranslations("agents.workflow");
8654
8703
  const sortedAgents = React8.useMemo(() => [...agents].sort((agentA, agentB) => (agentA.order ?? 0) - (agentB.order ?? 0)), [agents]);
8655
8704
  const [selectedAgentId, setSelectedAgentId] = React8.useState(null);
8656
- const [drawerOpen, setDrawerOpen] = React8.useState(false);
8657
- const closeAllDrawers = React8.useCallback(() => {
8658
- setEditingLogicNodeId(null);
8659
- setDrawerOpen(false);
8660
- setSelectedAgentId(null);
8661
- }, []);
8662
- const openAgentDrawer = React8.useCallback((agent, _agentModels, _isCreate = false) => {
8663
- setEditingLogicNodeId(null);
8664
- setDrawerOpen(true);
8665
- setSelectedAgentId(agent.agentId);
8666
- }, []);
8705
+ const openAgentDrawerAction = useDrawerStore((s) => s.openAgentDrawer);
8706
+ const openLogicNodeDrawerAction = useDrawerStore((s) => s.openLogicNodeDrawer);
8707
+ const closeDrawerAction = useDrawerStore((s) => s.closeDrawer);
8708
+ const activeDrawer = useDrawerStore((s) => s.activeDrawer);
8709
+ const drawerOpen = activeDrawer === "agent";
8710
+ React8.useEffect(() => {
8711
+ if (isCreatingAgent) {
8712
+ openAgentDrawerAction(
8713
+ { agentId: "", name: "", order: 0, enabled: true, temperature: 0.7, maxTokens: 4096 },
8714
+ models,
8715
+ true
8716
+ );
8717
+ }
8718
+ }, [isCreatingAgent]);
8667
8719
  const graphChangeTimerRef = React8.useRef(null);
8668
8720
  const insertNodeOnEdgeRef = React8.useRef(() => {
8669
8721
  });
@@ -8700,9 +8752,16 @@ function WorkflowCanvasInner({
8700
8752
  const setLayoutDirection = useWorkflowStore((s) => s.setLayoutDirection);
8701
8753
  const [editingLogicNodeId, setEditingLogicNodeId] = React8.useState(null);
8702
8754
  const handleEditLogicNode = React8.useCallback((nodeId) => {
8703
- closeAllDrawers();
8704
8755
  setEditingLogicNodeId(nodeId);
8705
- }, [closeAllDrawers]);
8756
+ const node = getNode(nodeId);
8757
+ if (node) {
8758
+ const nodeData = node.data;
8759
+ const config = nodeData.config;
8760
+ if (config) {
8761
+ openLogicNodeDrawerAction(nodeId, nodeData.label ?? "", config);
8762
+ }
8763
+ }
8764
+ }, [getNode, openLogicNodeDrawerAction]);
8706
8765
  const agentMap = React8.useMemo(() => {
8707
8766
  const map = /* @__PURE__ */ new Map();
8708
8767
  for (const agent of agents) {
@@ -8786,8 +8845,7 @@ function WorkflowCanvasInner({
8786
8845
  selected: selectedAgentId === savedNode.id,
8787
8846
  onSelect: () => {
8788
8847
  setSelectedAgentId(agent.agentId);
8789
- setDrawerOpen(true);
8790
- openAgentDrawer(agent, models);
8848
+ openAgentDrawerAction(agent, models);
8791
8849
  },
8792
8850
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
8793
8851
  }
@@ -9136,11 +9194,9 @@ function WorkflowCanvasInner({
9136
9194
  if (!targetNode) return;
9137
9195
  if (targetNode.type === "agent") {
9138
9196
  const agent = targetNode.data?.agent;
9139
- const agentId = agent?.id || agent?.agentId;
9140
- if (agentId && agent) {
9141
- setSelectedAgentId(agentId);
9142
- setDrawerOpen(true);
9143
- openAgentDrawer(agent, models);
9197
+ if (agent) {
9198
+ setSelectedAgentId(agent.agentId ?? agent.id ?? null);
9199
+ openAgentDrawerAction(agent, models);
9144
9200
  }
9145
9201
  } else if (targetNode.type === "tool") {
9146
9202
  const tool = targetNode.data?.tool;
@@ -9150,7 +9206,7 @@ function WorkflowCanvasInner({
9150
9206
  } else {
9151
9207
  handleEditLogicNode(nodeId);
9152
9208
  }
9153
- }, [nodes, setSelectedAgentId, setDrawerOpen, onEditTool, onEditRule, handleEditLogicNode]);
9209
+ }, [nodes, setSelectedAgentId, openAgentDrawerAction, models, onEditTool, onEditRule, handleEditLogicNode]);
9154
9210
  const DUPLICATE_OFFSET = 40;
9155
9211
  const contextMenuDuplicateNode = React8.useCallback((nodeId) => {
9156
9212
  storeTakeSnapshot();
@@ -9631,8 +9687,7 @@ function WorkflowCanvasInner({
9631
9687
  selected: false,
9632
9688
  onSelect: () => {
9633
9689
  setSelectedAgentId(agent.agentId);
9634
- setDrawerOpen(true);
9635
- openAgentDrawer(agent, models);
9690
+ openAgentDrawerAction(agent, models);
9636
9691
  },
9637
9692
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
9638
9693
  }
@@ -9927,7 +9982,7 @@ function WorkflowCanvasInner({
9927
9982
  const handleEdgeClick = React8.useCallback(() => {
9928
9983
  closeContextMenu();
9929
9984
  }, [closeContextMenu]);
9930
- const editingLogicNode = React8.useMemo(() => {
9985
+ React8.useMemo(() => {
9931
9986
  if (!editingLogicNodeId) return null;
9932
9987
  const node = nodes.find((matchingNode) => matchingNode.id === editingLogicNodeId);
9933
9988
  if (!node) return null;
@@ -10080,28 +10135,28 @@ function WorkflowCanvasInner({
10080
10135
  open: drawerOpen || isCreatingAgent,
10081
10136
  isCreateMode: isCreatingAgent,
10082
10137
  onClose: () => {
10083
- closeAllDrawers();
10084
- if (isCreatingAgent) {
10085
- onCancelCreateAgent?.();
10086
- }
10138
+ closeDrawerAction();
10139
+ setSelectedAgentId(null);
10140
+ if (isCreatingAgent) onCancelCreateAgent?.();
10087
10141
  },
10088
10142
  onSaved: () => {
10089
- closeAllDrawers();
10090
- if (isCreatingAgent) {
10091
- onCancelCreateAgent?.();
10092
- }
10143
+ closeDrawerAction();
10144
+ setSelectedAgentId(null);
10145
+ if (isCreatingAgent) onCancelCreateAgent?.();
10093
10146
  onAgentSaved?.();
10094
10147
  }
10095
10148
  }),
10096
- (renderLogicNodeDrawer ?? ((drawerProps) => /* @__PURE__ */ jsxRuntime.jsx(LogicNodeDrawer, { ...drawerProps })))({
10097
- nodeId: editingLogicNode?.nodeId ?? null,
10098
- nodeLabel: editingLogicNode?.label ?? "",
10099
- config: editingLogicNode?.config ?? null,
10100
- open: editingLogicNodeId !== null,
10101
- onClose: () => setEditingLogicNodeId(null),
10102
- onSave: handleSaveLogicNodeConfig,
10103
- entities: allEntities
10104
- })
10149
+ /* @__PURE__ */ jsxRuntime.jsx(
10150
+ LogicNodeDrawer,
10151
+ {
10152
+ onSave: (nodeId, config) => {
10153
+ handleSaveLogicNodeConfig(nodeId, config);
10154
+ closeDrawerAction();
10155
+ setEditingLogicNodeId(null);
10156
+ },
10157
+ entities: allEntities
10158
+ }
10159
+ )
10105
10160
  ] });
10106
10161
  }
10107
10162
  function WorkflowCanvas(props) {