@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.
@@ -254,6 +254,48 @@ var useWorkflowStore = create((set, get) => ({
254
254
  });
255
255
  }
256
256
  }));
257
+ var useDrawerStore = create((set) => ({
258
+ activeDrawer: null,
259
+ agentData: null,
260
+ subworkflowData: null,
261
+ logicNodeData: null,
262
+ pipelineSettingsData: null,
263
+ openAgentDrawer: (agent, models, isCreateMode = false) => set({
264
+ activeDrawer: "agent",
265
+ agentData: { agent, models, isCreateMode },
266
+ subworkflowData: null,
267
+ logicNodeData: null,
268
+ pipelineSettingsData: null
269
+ }),
270
+ openSubworkflowDrawer: (tool) => set({
271
+ activeDrawer: "subworkflow",
272
+ subworkflowData: { tool },
273
+ agentData: null,
274
+ logicNodeData: null,
275
+ pipelineSettingsData: null
276
+ }),
277
+ openLogicNodeDrawer: (nodeId, nodeLabel, config) => set({
278
+ activeDrawer: "logic-node",
279
+ logicNodeData: { nodeId, nodeLabel, config },
280
+ agentData: null,
281
+ subworkflowData: null,
282
+ pipelineSettingsData: null
283
+ }),
284
+ openPipelineSettingsDrawer: (name, description) => set({
285
+ activeDrawer: "pipeline-settings",
286
+ pipelineSettingsData: { name, description },
287
+ agentData: null,
288
+ subworkflowData: null,
289
+ logicNodeData: null
290
+ }),
291
+ closeDrawer: () => set({
292
+ activeDrawer: null,
293
+ agentData: null,
294
+ subworkflowData: null,
295
+ logicNodeData: null,
296
+ pipelineSettingsData: null
297
+ })
298
+ }));
257
299
  var GRAPH_ACTIVE_EDGE_COLOR = "#14b8a6";
258
300
  var GRAPH_TRUE_EDGE_COLOR = "#22c55e";
259
301
  var GRAPH_FALSE_EDGE_COLOR = "#ef4444";
@@ -8131,8 +8173,15 @@ var NODE_TITLE_KEYS = {
8131
8173
  entity: "entityNodeConfig",
8132
8174
  group: "groupNodeConfig"
8133
8175
  };
8134
- function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, entities = [] }) {
8176
+ function LogicNodeDrawer({ onSave, entities = [] }) {
8135
8177
  const t = useTranslations("agents.workflow");
8178
+ const activeDrawer = useDrawerStore((s) => s.activeDrawer);
8179
+ const logicNodeData = useDrawerStore((s) => s.logicNodeData);
8180
+ const closeDrawer = useDrawerStore((s) => s.closeDrawer);
8181
+ const open = activeDrawer === "logic-node";
8182
+ const nodeId = logicNodeData?.nodeId ?? null;
8183
+ const nodeLabel = logicNodeData?.nodeLabel ?? "";
8184
+ const config = logicNodeData?.config ?? null;
8136
8185
  if (!config || !nodeId) return null;
8137
8186
  const entityMasterId = config.type === "entity" ? config.entityMasterId : void 0;
8138
8187
  const IconComponent = entityMasterId ? getEntityIcon(entityMasterId) : LOGIC_ICON_MAP[config.type];
@@ -8145,41 +8194,41 @@ function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, ent
8145
8194
  const renderForm = () => {
8146
8195
  switch (config.type) {
8147
8196
  case "start":
8148
- return /* @__PURE__ */ jsx(StartNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8197
+ return /* @__PURE__ */ jsx(StartNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8149
8198
  case "end":
8150
- return /* @__PURE__ */ jsx(EndNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8199
+ return /* @__PURE__ */ jsx(EndNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8151
8200
  case "if_else":
8152
- return /* @__PURE__ */ jsx(IfElseNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8201
+ return /* @__PURE__ */ jsx(IfElseNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8153
8202
  case "code":
8154
- return /* @__PURE__ */ jsx(CodeNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8203
+ return /* @__PURE__ */ jsx(CodeNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8155
8204
  case "http_request":
8156
- return /* @__PURE__ */ jsx(HttpRequestNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8205
+ return /* @__PURE__ */ jsx(HttpRequestNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8157
8206
  case "template_transform":
8158
- return /* @__PURE__ */ jsx(TemplateTransformNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8207
+ return /* @__PURE__ */ jsx(TemplateTransformNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8159
8208
  case "iteration":
8160
- return /* @__PURE__ */ jsx(IterationNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8209
+ return /* @__PURE__ */ jsx(IterationNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8161
8210
  case "knowledge_base":
8162
- return /* @__PURE__ */ jsx(KnowledgeBaseNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8211
+ return /* @__PURE__ */ jsx(KnowledgeBaseNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8163
8212
  case "answer":
8164
- return /* @__PURE__ */ jsx(AnswerNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8213
+ return /* @__PURE__ */ jsx(AnswerNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8165
8214
  case "question_classifier":
8166
- return /* @__PURE__ */ jsx(QuestionClassifierNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8215
+ return /* @__PURE__ */ jsx(QuestionClassifierNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8167
8216
  case "parameter_extractor":
8168
- return /* @__PURE__ */ jsx(ParameterExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8217
+ return /* @__PURE__ */ jsx(ParameterExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8169
8218
  case "variable_assigner":
8170
- return /* @__PURE__ */ jsx(VariableAssignerNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8219
+ return /* @__PURE__ */ jsx(VariableAssignerNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8171
8220
  case "variable_aggregator":
8172
- return /* @__PURE__ */ jsx(VariableAggregatorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8221
+ return /* @__PURE__ */ jsx(VariableAggregatorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8173
8222
  case "document_extractor":
8174
- return /* @__PURE__ */ jsx(DocumentExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8223
+ return /* @__PURE__ */ jsx(DocumentExtractorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8175
8224
  case "list_operator":
8176
- return /* @__PURE__ */ jsx(ListOperatorNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8225
+ return /* @__PURE__ */ jsx(ListOperatorNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8177
8226
  case "iteration_start":
8178
- return /* @__PURE__ */ jsx(IterationStartNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8227
+ return /* @__PURE__ */ jsx(IterationStartNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8179
8228
  case "entity":
8180
- return /* @__PURE__ */ jsx(EntityNodeConfigForm, { config, entities, onSave: handleSave, onCancel: onClose });
8229
+ return /* @__PURE__ */ jsx(EntityNodeConfigForm, { config, entities, onSave: handleSave, onCancel: closeDrawer });
8181
8230
  case "group":
8182
- return /* @__PURE__ */ jsx(GroupNodeConfigForm, { config, onSave: handleSave, onCancel: onClose });
8231
+ return /* @__PURE__ */ jsx(GroupNodeConfigForm, { config, onSave: handleSave, onCancel: closeDrawer });
8183
8232
  default:
8184
8233
  return null;
8185
8234
  }
@@ -8188,7 +8237,7 @@ function LogicNodeDrawer({ nodeId, nodeLabel, config, open, onClose, onSave, ent
8188
8237
  WorkspaceDrawer,
8189
8238
  {
8190
8239
  open,
8191
- onClose,
8240
+ onClose: closeDrawer,
8192
8241
  title,
8193
8242
  subtitle: nodeLabel,
8194
8243
  icon: IconComponent ? /* @__PURE__ */ jsx(IconComponent, { className: "h-5 w-5 text-white" }) : void 0,
@@ -8617,23 +8666,26 @@ function WorkflowCanvasInner({
8617
8666
  isCreatingAgent = false,
8618
8667
  nodeTypes: externalNodeTypes,
8619
8668
  renderAgentDrawer,
8620
- renderLogicNodeDrawer
8669
+ renderLogicNodeDrawer: _renderLogicNodeDrawer
8621
8670
  }) {
8622
8671
  const { screenToFlowPosition, getNode, toObject, fitView, zoomIn, zoomOut, zoomTo } = useReactFlow();
8623
8672
  const tWorkflow = useTranslations("agents.workflow");
8624
8673
  const sortedAgents = useMemo(() => [...agents].sort((agentA, agentB) => (agentA.order ?? 0) - (agentB.order ?? 0)), [agents]);
8625
8674
  const [selectedAgentId, setSelectedAgentId] = useState(null);
8626
- const [drawerOpen, setDrawerOpen] = useState(false);
8627
- const closeAllDrawers = useCallback(() => {
8628
- setEditingLogicNodeId(null);
8629
- setDrawerOpen(false);
8630
- setSelectedAgentId(null);
8631
- }, []);
8632
- const openAgentDrawer = useCallback((agent, _agentModels, _isCreate = false) => {
8633
- setEditingLogicNodeId(null);
8634
- setDrawerOpen(true);
8635
- setSelectedAgentId(agent.agentId);
8636
- }, []);
8675
+ const openAgentDrawerAction = useDrawerStore((s) => s.openAgentDrawer);
8676
+ const openLogicNodeDrawerAction = useDrawerStore((s) => s.openLogicNodeDrawer);
8677
+ const closeDrawerAction = useDrawerStore((s) => s.closeDrawer);
8678
+ const activeDrawer = useDrawerStore((s) => s.activeDrawer);
8679
+ const drawerOpen = activeDrawer === "agent";
8680
+ useEffect(() => {
8681
+ if (isCreatingAgent) {
8682
+ openAgentDrawerAction(
8683
+ { agentId: "", name: "", order: 0, enabled: true, temperature: 0.7, maxTokens: 4096 },
8684
+ models,
8685
+ true
8686
+ );
8687
+ }
8688
+ }, [isCreatingAgent]);
8637
8689
  const graphChangeTimerRef = useRef(null);
8638
8690
  const insertNodeOnEdgeRef = useRef(() => {
8639
8691
  });
@@ -8670,9 +8722,16 @@ function WorkflowCanvasInner({
8670
8722
  const setLayoutDirection = useWorkflowStore((s) => s.setLayoutDirection);
8671
8723
  const [editingLogicNodeId, setEditingLogicNodeId] = useState(null);
8672
8724
  const handleEditLogicNode = useCallback((nodeId) => {
8673
- closeAllDrawers();
8674
8725
  setEditingLogicNodeId(nodeId);
8675
- }, [closeAllDrawers]);
8726
+ const node = getNode(nodeId);
8727
+ if (node) {
8728
+ const nodeData = node.data;
8729
+ const config = nodeData.config;
8730
+ if (config) {
8731
+ openLogicNodeDrawerAction(nodeId, nodeData.label ?? "", config);
8732
+ }
8733
+ }
8734
+ }, [getNode, openLogicNodeDrawerAction]);
8676
8735
  const agentMap = useMemo(() => {
8677
8736
  const map = /* @__PURE__ */ new Map();
8678
8737
  for (const agent of agents) {
@@ -8755,9 +8814,9 @@ function WorkflowCanvasInner({
8755
8814
  order: agent.order ?? 0,
8756
8815
  selected: selectedAgentId === savedNode.id,
8757
8816
  onSelect: () => {
8817
+ console.log("[Canvas] onSelect agent:", agent.name, agent.agentId);
8758
8818
  setSelectedAgentId(agent.agentId);
8759
- setDrawerOpen(true);
8760
- openAgentDrawer(agent, models);
8819
+ openAgentDrawerAction(agent, models);
8761
8820
  },
8762
8821
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
8763
8822
  }
@@ -9106,11 +9165,9 @@ function WorkflowCanvasInner({
9106
9165
  if (!targetNode) return;
9107
9166
  if (targetNode.type === "agent") {
9108
9167
  const agent = targetNode.data?.agent;
9109
- const agentId = agent?.id || agent?.agentId;
9110
- if (agentId && agent) {
9111
- setSelectedAgentId(agentId);
9112
- setDrawerOpen(true);
9113
- openAgentDrawer(agent, models);
9168
+ if (agent) {
9169
+ setSelectedAgentId(agent.agentId ?? agent.id ?? null);
9170
+ openAgentDrawerAction(agent, models);
9114
9171
  }
9115
9172
  } else if (targetNode.type === "tool") {
9116
9173
  const tool = targetNode.data?.tool;
@@ -9120,7 +9177,7 @@ function WorkflowCanvasInner({
9120
9177
  } else {
9121
9178
  handleEditLogicNode(nodeId);
9122
9179
  }
9123
- }, [nodes, setSelectedAgentId, setDrawerOpen, onEditTool, onEditRule, handleEditLogicNode]);
9180
+ }, [nodes, setSelectedAgentId, openAgentDrawerAction, models, onEditTool, onEditRule, handleEditLogicNode]);
9124
9181
  const DUPLICATE_OFFSET = 40;
9125
9182
  const contextMenuDuplicateNode = useCallback((nodeId) => {
9126
9183
  storeTakeSnapshot();
@@ -9601,8 +9658,7 @@ function WorkflowCanvasInner({
9601
9658
  selected: false,
9602
9659
  onSelect: () => {
9603
9660
  setSelectedAgentId(agent.agentId);
9604
- setDrawerOpen(true);
9605
- openAgentDrawer(agent, models);
9661
+ openAgentDrawerAction(agent, models);
9606
9662
  },
9607
9663
  onRemoveFromCanvas: handleRemoveNodeFromCanvas
9608
9664
  }
@@ -9897,7 +9953,7 @@ function WorkflowCanvasInner({
9897
9953
  const handleEdgeClick = useCallback(() => {
9898
9954
  closeContextMenu();
9899
9955
  }, [closeContextMenu]);
9900
- const editingLogicNode = useMemo(() => {
9956
+ useMemo(() => {
9901
9957
  if (!editingLogicNodeId) return null;
9902
9958
  const node = nodes.find((matchingNode) => matchingNode.id === editingLogicNodeId);
9903
9959
  if (!node) return null;
@@ -10050,28 +10106,28 @@ function WorkflowCanvasInner({
10050
10106
  open: drawerOpen || isCreatingAgent,
10051
10107
  isCreateMode: isCreatingAgent,
10052
10108
  onClose: () => {
10053
- closeAllDrawers();
10054
- if (isCreatingAgent) {
10055
- onCancelCreateAgent?.();
10056
- }
10109
+ closeDrawerAction();
10110
+ setSelectedAgentId(null);
10111
+ if (isCreatingAgent) onCancelCreateAgent?.();
10057
10112
  },
10058
10113
  onSaved: () => {
10059
- closeAllDrawers();
10060
- if (isCreatingAgent) {
10061
- onCancelCreateAgent?.();
10062
- }
10114
+ closeDrawerAction();
10115
+ setSelectedAgentId(null);
10116
+ if (isCreatingAgent) onCancelCreateAgent?.();
10063
10117
  onAgentSaved?.();
10064
10118
  }
10065
10119
  }),
10066
- (renderLogicNodeDrawer ?? ((drawerProps) => /* @__PURE__ */ jsx(LogicNodeDrawer, { ...drawerProps })))({
10067
- nodeId: editingLogicNode?.nodeId ?? null,
10068
- nodeLabel: editingLogicNode?.label ?? "",
10069
- config: editingLogicNode?.config ?? null,
10070
- open: editingLogicNodeId !== null,
10071
- onClose: () => setEditingLogicNodeId(null),
10072
- onSave: handleSaveLogicNodeConfig,
10073
- entities: allEntities
10074
- })
10120
+ /* @__PURE__ */ jsx(
10121
+ LogicNodeDrawer,
10122
+ {
10123
+ onSave: (nodeId, config) => {
10124
+ handleSaveLogicNodeConfig(nodeId, config);
10125
+ closeDrawerAction();
10126
+ setEditingLogicNodeId(null);
10127
+ },
10128
+ entities: allEntities
10129
+ }
10130
+ )
10075
10131
  ] });
10076
10132
  }
10077
10133
  function WorkflowCanvas(props) {