@datatechsolutions/ui 2.7.114 → 2.7.116

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) {
@@ -8785,9 +8844,9 @@ function WorkflowCanvasInner({
8785
8844
  order: agent.order ?? 0,
8786
8845
  selected: selectedAgentId === savedNode.id,
8787
8846
  onSelect: () => {
8847
+ console.log("[Canvas] onSelect agent:", agent.name, agent.agentId);
8788
8848
  setSelectedAgentId(agent.agentId);
8789
- setDrawerOpen(true);
8790
- openAgentDrawer(agent, models);
8849
+ openAgentDrawerAction(agent, models);
8791
8850
  },
8792
8851
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
8793
8852
  }
@@ -9136,11 +9195,9 @@ function WorkflowCanvasInner({
9136
9195
  if (!targetNode) return;
9137
9196
  if (targetNode.type === "agent") {
9138
9197
  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);
9198
+ if (agent) {
9199
+ setSelectedAgentId(agent.agentId ?? agent.id ?? null);
9200
+ openAgentDrawerAction(agent, models);
9144
9201
  }
9145
9202
  } else if (targetNode.type === "tool") {
9146
9203
  const tool = targetNode.data?.tool;
@@ -9150,7 +9207,7 @@ function WorkflowCanvasInner({
9150
9207
  } else {
9151
9208
  handleEditLogicNode(nodeId);
9152
9209
  }
9153
- }, [nodes, setSelectedAgentId, setDrawerOpen, onEditTool, onEditRule, handleEditLogicNode]);
9210
+ }, [nodes, setSelectedAgentId, openAgentDrawerAction, models, onEditTool, onEditRule, handleEditLogicNode]);
9154
9211
  const DUPLICATE_OFFSET = 40;
9155
9212
  const contextMenuDuplicateNode = React8.useCallback((nodeId) => {
9156
9213
  storeTakeSnapshot();
@@ -9631,8 +9688,7 @@ function WorkflowCanvasInner({
9631
9688
  selected: false,
9632
9689
  onSelect: () => {
9633
9690
  setSelectedAgentId(agent.agentId);
9634
- setDrawerOpen(true);
9635
- openAgentDrawer(agent, models);
9691
+ openAgentDrawerAction(agent, models);
9636
9692
  },
9637
9693
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
9638
9694
  }
@@ -9927,7 +9983,7 @@ function WorkflowCanvasInner({
9927
9983
  const handleEdgeClick = React8.useCallback(() => {
9928
9984
  closeContextMenu();
9929
9985
  }, [closeContextMenu]);
9930
- const editingLogicNode = React8.useMemo(() => {
9986
+ React8.useMemo(() => {
9931
9987
  if (!editingLogicNodeId) return null;
9932
9988
  const node = nodes.find((matchingNode) => matchingNode.id === editingLogicNodeId);
9933
9989
  if (!node) return null;
@@ -10080,28 +10136,28 @@ function WorkflowCanvasInner({
10080
10136
  open: drawerOpen || isCreatingAgent,
10081
10137
  isCreateMode: isCreatingAgent,
10082
10138
  onClose: () => {
10083
- closeAllDrawers();
10084
- if (isCreatingAgent) {
10085
- onCancelCreateAgent?.();
10086
- }
10139
+ closeDrawerAction();
10140
+ setSelectedAgentId(null);
10141
+ if (isCreatingAgent) onCancelCreateAgent?.();
10087
10142
  },
10088
10143
  onSaved: () => {
10089
- closeAllDrawers();
10090
- if (isCreatingAgent) {
10091
- onCancelCreateAgent?.();
10092
- }
10144
+ closeDrawerAction();
10145
+ setSelectedAgentId(null);
10146
+ if (isCreatingAgent) onCancelCreateAgent?.();
10093
10147
  onAgentSaved?.();
10094
10148
  }
10095
10149
  }),
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
- })
10150
+ /* @__PURE__ */ jsxRuntime.jsx(
10151
+ LogicNodeDrawer,
10152
+ {
10153
+ onSave: (nodeId, config) => {
10154
+ handleSaveLogicNodeConfig(nodeId, config);
10155
+ closeDrawerAction();
10156
+ setEditingLogicNodeId(null);
10157
+ },
10158
+ entities: allEntities
10159
+ }
10160
+ )
10105
10161
  ] });
10106
10162
  }
10107
10163
  function WorkflowCanvas(props) {