@axiom-lattice/react-sdk 2.1.31 → 2.1.32

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.
package/dist/index.mjs CHANGED
@@ -2169,6 +2169,8 @@ var DEFAULT_CONFIG = {
2169
2169
  enableThreadCreation: true,
2170
2170
  enableThreadList: true,
2171
2171
  showSideMenu: true,
2172
+ enableAssistantCreation: true,
2173
+ enableAssistantEditing: true,
2172
2174
  availableMiddlewareTypes: DEFAULT_MIDDLEWARE_TYPES
2173
2175
  };
2174
2176
  var LatticeChatShellContext = createContext4({
@@ -7392,22 +7394,23 @@ import { useContext as useContext8 } from "react";
7392
7394
  import { useState as useState31 } from "react";
7393
7395
  import { Modal as Modal5 } from "antd";
7394
7396
  import {
7395
- SettingOutlined as SettingOutlined3,
7396
- ApartmentOutlined,
7397
- StarOutlined as StarOutlined2,
7398
- ToolOutlined as ToolOutlined4
7399
- } from "@ant-design/icons";
7397
+ Bot,
7398
+ BrainCircuit,
7399
+ Wrench,
7400
+ Settings
7401
+ } from "lucide-react";
7400
7402
  import { createStyles as createStyles13 } from "antd-style";
7401
7403
 
7402
7404
  // src/components/Chat/AssistantFlow.tsx
7403
- import { useMemo as useMemo12, useEffect as useEffect18, useState as useState26, useCallback as useCallback16 } from "react";
7405
+ import { useMemo as useMemo12, useEffect as useEffect18, useState as useState26, useCallback as useCallback16, useRef as useRef14 } from "react";
7404
7406
  import {
7405
7407
  ReactFlow,
7406
7408
  Background,
7407
7409
  Controls,
7408
7410
  useNodesState,
7409
7411
  useEdgesState,
7410
- ReactFlowProvider
7412
+ ReactFlowProvider,
7413
+ useReactFlow as useReactFlow2
7411
7414
  } from "@xyflow/react";
7412
7415
  import "@xyflow/react/dist/style.css";
7413
7416
 
@@ -7898,7 +7901,7 @@ var AssistantNode = ({
7898
7901
  e.currentTarget.style.boxShadow = `0 1px 4px rgba(0, 0, 0, 0.08)`;
7899
7902
  },
7900
7903
  children: [
7901
- /* @__PURE__ */ jsx47(
7904
+ onConfigure && /* @__PURE__ */ jsx47(
7902
7905
  "div",
7903
7906
  {
7904
7907
  onClick: (e) => {
@@ -8301,7 +8304,8 @@ import {
8301
8304
  GlobalOutlined as GlobalOutlined2,
8302
8305
  DatabaseOutlined,
8303
8306
  FolderOutlined as FolderOutlined2,
8304
- StarOutlined
8307
+ StarOutlined,
8308
+ DeleteOutlined
8305
8309
  } from "@ant-design/icons";
8306
8310
  import { Fragment as Fragment7, jsx as jsx48, jsxs as jsxs27 } from "react/jsx-runtime";
8307
8311
  var { TextArea } = Input;
@@ -8741,13 +8745,16 @@ var AgentConfigPanel = ({
8741
8745
  allAssistants,
8742
8746
  visible,
8743
8747
  onClose,
8744
- onSave
8748
+ onSave,
8749
+ onDelete
8745
8750
  }) => {
8746
8751
  const [form] = Form.useForm();
8747
8752
  const { token } = theme3.useToken();
8748
8753
  const { config } = useLatticeChatShellContext();
8749
8754
  const [toolsLoading, setToolsLoading] = useState24(false);
8750
8755
  const [saving, setSaving] = useState24(false);
8756
+ const [deleting, setDeleting] = useState24(false);
8757
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState24(false);
8751
8758
  const [tools, setTools] = useState24([]);
8752
8759
  const [selectedTools, setSelectedTools] = useState24([]);
8753
8760
  const [selectedSubAgents, setSelectedSubAgents] = useState24([]);
@@ -8863,6 +8870,20 @@ var AgentConfigPanel = ({
8863
8870
  setSaving(false);
8864
8871
  }
8865
8872
  };
8873
+ const handleDelete = async () => {
8874
+ if (!assistant) return;
8875
+ setDeleting(true);
8876
+ try {
8877
+ await onDelete?.(assistant);
8878
+ setIsDeleteModalOpen(false);
8879
+ onClose();
8880
+ } catch (error) {
8881
+ setIsDeleteModalOpen(false);
8882
+ message5.error(error instanceof Error ? error.message : "Failed to delete assistant");
8883
+ } finally {
8884
+ setDeleting(false);
8885
+ }
8886
+ };
8866
8887
  const handleMiddlewareToggle = (middlewareId) => {
8867
8888
  setMiddleware(
8868
8889
  (prev) => prev.map((m) => {
@@ -9013,15 +9034,27 @@ var AgentConfigPanel = ({
9013
9034
  /* @__PURE__ */ jsx48(Text16, { strong: true, style: { fontSize: 14 }, children: assistant.name }),
9014
9035
  /* @__PURE__ */ jsx48(Tag7, { color: "blue", style: { margin: 0, fontSize: 10 }, children: "Config" })
9015
9036
  ] }),
9016
- /* @__PURE__ */ jsx48(
9017
- Button19,
9018
- {
9019
- type: "text",
9020
- size: "small",
9021
- icon: /* @__PURE__ */ jsx48(CloseOutlined2, {}),
9022
- onClick: onClose
9023
- }
9024
- )
9037
+ /* @__PURE__ */ jsxs27(Space18, { children: [
9038
+ onDelete && /* @__PURE__ */ jsx48(Tooltip10, { title: "Delete Assistant", children: /* @__PURE__ */ jsx48(
9039
+ Button19,
9040
+ {
9041
+ type: "text",
9042
+ size: "small",
9043
+ danger: true,
9044
+ icon: /* @__PURE__ */ jsx48(DeleteOutlined, {}),
9045
+ onClick: () => setIsDeleteModalOpen(true)
9046
+ }
9047
+ ) }),
9048
+ /* @__PURE__ */ jsx48(
9049
+ Button19,
9050
+ {
9051
+ type: "text",
9052
+ size: "small",
9053
+ icon: /* @__PURE__ */ jsx48(CloseOutlined2, {}),
9054
+ onClick: onClose
9055
+ }
9056
+ )
9057
+ ] })
9025
9058
  ]
9026
9059
  }
9027
9060
  ),
@@ -9300,10 +9333,10 @@ var AgentConfigPanel = ({
9300
9333
  alignItems: "center"
9301
9334
  },
9302
9335
  children: [
9303
- /* @__PURE__ */ jsx48(Text16, { type: "secondary", style: { fontSize: 12 }, children: "Changes will be saved to the agent" }),
9336
+ /* @__PURE__ */ jsx48(Text16, { type: "secondary", style: { fontSize: 12 }, children: onSave ? "Changes will be saved to the agent" : "Viewing agent configuration" }),
9304
9337
  /* @__PURE__ */ jsxs27(Space18, { children: [
9305
9338
  /* @__PURE__ */ jsx48(Button19, { onClick: onClose, size: "small", children: "Close" }),
9306
- /* @__PURE__ */ jsx48(
9339
+ onSave && /* @__PURE__ */ jsx48(
9307
9340
  Button19,
9308
9341
  {
9309
9342
  type: "primary",
@@ -9392,6 +9425,33 @@ var AgentConfigPanel = ({
9392
9425
  )
9393
9426
  ]
9394
9427
  }
9428
+ ),
9429
+ /* @__PURE__ */ jsx48(
9430
+ Modal,
9431
+ {
9432
+ title: "Delete Assistant",
9433
+ open: isDeleteModalOpen,
9434
+ onCancel: () => setIsDeleteModalOpen(false),
9435
+ footer: [
9436
+ /* @__PURE__ */ jsx48(Button19, { onClick: () => setIsDeleteModalOpen(false), children: "Cancel" }, "cancel"),
9437
+ /* @__PURE__ */ jsx48(
9438
+ Button19,
9439
+ {
9440
+ type: "primary",
9441
+ danger: true,
9442
+ loading: deleting,
9443
+ onClick: handleDelete,
9444
+ children: "Delete"
9445
+ },
9446
+ "delete"
9447
+ )
9448
+ ],
9449
+ children: /* @__PURE__ */ jsxs27(Text16, { children: [
9450
+ "Are you sure you want to delete ",
9451
+ /* @__PURE__ */ jsx48(Text16, { strong: true, children: assistant.name }),
9452
+ "? This action cannot be undone."
9453
+ ] })
9454
+ }
9395
9455
  )
9396
9456
  ]
9397
9457
  }
@@ -9463,7 +9523,7 @@ var CreateAssistantModal = ({
9463
9523
  description: "Assistant created successfully"
9464
9524
  });
9465
9525
  form.resetFields();
9466
- onSuccess?.();
9526
+ onSuccess?.(data.data);
9467
9527
  onCancel();
9468
9528
  } else {
9469
9529
  message6.error(data.message || "Failed to create assistant");
@@ -9597,6 +9657,7 @@ import { Button as Button21, message as message7, notification as notification2,
9597
9657
  import { PlusOutlined as PlusOutlined3 } from "@ant-design/icons";
9598
9658
  import { jsx as jsx50, jsxs as jsxs29 } from "react/jsx-runtime";
9599
9659
  var AssistantFlowInner = ({ onChat }) => {
9660
+ const { setCenter, fitView } = useReactFlow2();
9600
9661
  const [nodes, setNodes, onNodesChange] = useNodesState([]);
9601
9662
  const [edges, setEdges, onEdgesChange] = useEdgesState([]);
9602
9663
  const [assistants, setAssistants] = useState26([]);
@@ -9606,6 +9667,7 @@ var AssistantFlowInner = ({ onChat }) => {
9606
9667
  const [isCreateModalOpen, setIsCreateModalOpen] = useState26(false);
9607
9668
  const { config } = useLatticeChatShellContext();
9608
9669
  const { token } = theme5.useToken();
9670
+ const { enableAssistantCreation = true, enableAssistantEditing = true } = config;
9609
9671
  const nodeTypes = useMemo12(
9610
9672
  () => ({
9611
9673
  assistant: AssistantNode_default
@@ -9618,6 +9680,7 @@ var AssistantFlowInner = ({ onChat }) => {
9618
9680
  }, []);
9619
9681
  const handleClosePanel = useCallback16(() => {
9620
9682
  setConfigPanelVisible(false);
9683
+ setSelectedAssistant(null);
9621
9684
  }, []);
9622
9685
  const fetchAssistants = async () => {
9623
9686
  setAssistantsLoading(true);
@@ -9796,7 +9859,7 @@ var AssistantFlowInner = ({ onChat }) => {
9796
9859
  type: "assistant",
9797
9860
  data: {
9798
9861
  assistant,
9799
- onConfigure: () => handleConfigure(assistant),
9862
+ onConfigure: enableAssistantEditing ? () => handleConfigure(assistant) : void 0,
9800
9863
  onChat
9801
9864
  },
9802
9865
  position: { x, y }
@@ -9826,7 +9889,7 @@ var AssistantFlowInner = ({ onChat }) => {
9826
9889
  type: "assistant",
9827
9890
  data: {
9828
9891
  assistant,
9829
- onConfigure: () => handleConfigure(assistant),
9892
+ onConfigure: enableAssistantEditing ? () => handleConfigure(assistant) : void 0,
9830
9893
  onChat
9831
9894
  },
9832
9895
  position: { x, y }
@@ -9887,9 +9950,82 @@ var AssistantFlowInner = ({ onChat }) => {
9887
9950
  throw error;
9888
9951
  }
9889
9952
  };
9890
- const handleAssistantCreated = async () => {
9891
- await fetchAssistants();
9953
+ const handleDeleteAssistant = async (assistant) => {
9954
+ try {
9955
+ const headers = {};
9956
+ if (config.apiKey) {
9957
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
9958
+ }
9959
+ const response = await fetch(
9960
+ `${config.baseURL}/api/assistants/${assistant.id}`,
9961
+ {
9962
+ method: "DELETE",
9963
+ headers,
9964
+ body: JSON.stringify({})
9965
+ }
9966
+ );
9967
+ const data = await response.json();
9968
+ if (response.ok && data.success) {
9969
+ setAssistants((prev) => prev.filter((a) => a.id !== assistant.id));
9970
+ if (selectedAssistant?.id === assistant.id) {
9971
+ setSelectedAssistant(null);
9972
+ setConfigPanelVisible(false);
9973
+ }
9974
+ notification2.success({
9975
+ message: "Deleted",
9976
+ description: "Assistant deleted successfully"
9977
+ });
9978
+ } else {
9979
+ message7.error(data.message || "Failed to delete assistant");
9980
+ throw new Error(data.message || "Failed to delete assistant");
9981
+ }
9982
+ } catch (error) {
9983
+ console.error("Failed to delete assistant:", error);
9984
+ message7.error(error instanceof Error ? error.message : "Failed to delete assistant");
9985
+ throw error;
9986
+ }
9987
+ };
9988
+ const handleAssistantCreated = (createdAssistant) => {
9989
+ setAssistants((prev) => {
9990
+ const exists = prev.some((a) => a.id === createdAssistant.id);
9991
+ if (exists) {
9992
+ return prev.map((a) => a.id === createdAssistant.id ? createdAssistant : a);
9993
+ }
9994
+ return [...prev, createdAssistant];
9995
+ });
9996
+ lastCreatedAssistantRef.current = createdAssistant;
9892
9997
  };
9998
+ useEffect18(() => {
9999
+ if (selectedAssistant) {
10000
+ const node = nodes.find((n) => n.id === selectedAssistant.id);
10001
+ if (node) {
10002
+ setCenter(node.position.x + 140, node.position.y + 100, { zoom: 1, duration: 800 });
10003
+ }
10004
+ }
10005
+ }, [selectedAssistant, nodes, setCenter]);
10006
+ useEffect18(() => {
10007
+ if (assistants.length > 0 && selectedAssistant) {
10008
+ const assistant = assistants.find((a) => a.id === selectedAssistant.id);
10009
+ if (assistant && !configPanelVisible) {
10010
+ setConfigPanelVisible(true);
10011
+ }
10012
+ }
10013
+ }, [assistants, selectedAssistant, configPanelVisible]);
10014
+ const lastCreatedAssistantRef = useRef14(null);
10015
+ useEffect18(() => {
10016
+ if (lastCreatedAssistantRef.current && !assistants.find((a) => a.id === lastCreatedAssistantRef.current?.id)) {
10017
+ lastCreatedAssistantRef.current = null;
10018
+ }
10019
+ if (lastCreatedAssistantRef.current) {
10020
+ const node = nodes.find((n) => n.id === lastCreatedAssistantRef.current.id);
10021
+ if (node) {
10022
+ setCenter(node.position.x + 140, node.position.y + 100, { zoom: 1, duration: 800 });
10023
+ setSelectedAssistant(lastCreatedAssistantRef.current);
10024
+ setConfigPanelVisible(true);
10025
+ lastCreatedAssistantRef.current = null;
10026
+ }
10027
+ }
10028
+ }, [nodes, setCenter]);
9893
10029
  if (assistantsLoading) {
9894
10030
  return /* @__PURE__ */ jsx50(
9895
10031
  "div",
@@ -9932,7 +10068,7 @@ var AssistantFlowInner = ({ onChat }) => {
9932
10068
  ]
9933
10069
  }
9934
10070
  ),
9935
- /* @__PURE__ */ jsx50(
10071
+ enableAssistantCreation && /* @__PURE__ */ jsx50(
9936
10072
  "div",
9937
10073
  {
9938
10074
  style: {
@@ -9972,7 +10108,8 @@ var AssistantFlowInner = ({ onChat }) => {
9972
10108
  assistant: selectedAssistant,
9973
10109
  allAssistants: assistants,
9974
10110
  onClose: handleClosePanel,
9975
- onSave: handleSaveConfig
10111
+ onSave: handleSaveConfig,
10112
+ onDelete: handleDeleteAssistant
9976
10113
  }
9977
10114
  ),
9978
10115
  /* @__PURE__ */ jsx50(
@@ -12035,8 +12172,9 @@ var useStyles4 = createStyles13(({ token, css }) => ({
12035
12172
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
12036
12173
  }
12037
12174
 
12038
- .anticon {
12039
- font-size: 22px;
12175
+ .lucide {
12176
+ width: 22px;
12177
+ height: 22px;
12040
12178
  }
12041
12179
  `
12042
12180
  }));
@@ -12071,7 +12209,7 @@ var ChatSidebar = ({
12071
12209
  onClick: handleAssistantFlowClick,
12072
12210
  title: "Assistant Flow Canvas",
12073
12211
  "aria-label": "Assistant Flow Canvas",
12074
- children: /* @__PURE__ */ jsx55(ApartmentOutlined, {})
12212
+ children: /* @__PURE__ */ jsx55(Bot, {})
12075
12213
  }
12076
12214
  ),
12077
12215
  /* @__PURE__ */ jsx55(
@@ -12081,7 +12219,7 @@ var ChatSidebar = ({
12081
12219
  onClick: handleSkillFlowClick,
12082
12220
  title: "Skill Flow Canvas",
12083
12221
  "aria-label": "Skill Flow Canvas",
12084
- children: /* @__PURE__ */ jsx55(StarOutlined2, {})
12222
+ children: /* @__PURE__ */ jsx55(BrainCircuit, {})
12085
12223
  }
12086
12224
  ),
12087
12225
  /* @__PURE__ */ jsx55(
@@ -12091,7 +12229,7 @@ var ChatSidebar = ({
12091
12229
  onClick: handleToolsClick,
12092
12230
  title: "Tools List",
12093
12231
  "aria-label": "Tools List",
12094
- children: /* @__PURE__ */ jsx55(ToolOutlined4, {})
12232
+ children: /* @__PURE__ */ jsx55(Wrench, {})
12095
12233
  }
12096
12234
  ),
12097
12235
  /* @__PURE__ */ jsx55(
@@ -12101,7 +12239,7 @@ var ChatSidebar = ({
12101
12239
  onClick: handleSettingsClick,
12102
12240
  title: "Settings",
12103
12241
  "aria-label": "Settings",
12104
- children: /* @__PURE__ */ jsx55(SettingOutlined3, {})
12242
+ children: /* @__PURE__ */ jsx55(Settings, {})
12105
12243
  }
12106
12244
  )
12107
12245
  ] }) }),
@@ -12215,11 +12353,11 @@ var LatticeChatView = (props) => {
12215
12353
  };
12216
12354
 
12217
12355
  // src/components/Chat/SettingsModal.tsx
12218
- import { useState as useState32, useEffect as useEffect22, useRef as useRef14 } from "react";
12356
+ import { useState as useState32, useEffect as useEffect22, useRef as useRef15 } from "react";
12219
12357
  import {
12220
12358
  Modal as Modal6,
12221
12359
  Input as Input5,
12222
- Button as Button27,
12360
+ Button as Button26,
12223
12361
  message as message10,
12224
12362
  notification as notification5,
12225
12363
  Typography as Typography22,
@@ -12629,7 +12767,7 @@ var SettingsModal = ({
12629
12767
  return [];
12630
12768
  });
12631
12769
  const [serverConfigs, setServerConfigs] = useState32({});
12632
- const connectionsRef = useRef14(connections);
12770
+ const connectionsRef = useRef15(connections);
12633
12771
  useEffect22(() => {
12634
12772
  connectionsRef.current = connections;
12635
12773
  }, [connections]);
@@ -13191,7 +13329,7 @@ QUEUE_NAME=tasks`,
13191
13329
  )
13192
13330
  ] }),
13193
13331
  config.models.length > 1 && /* @__PURE__ */ jsx57(
13194
- Button27,
13332
+ Button26,
13195
13333
  {
13196
13334
  type: "text",
13197
13335
  danger: true,
@@ -13327,7 +13465,7 @@ QUEUE_NAME=tasks`,
13327
13465
  ] })
13328
13466
  ] }, index)),
13329
13467
  /* @__PURE__ */ jsx57(
13330
- Button27,
13468
+ Button26,
13331
13469
  {
13332
13470
  type: "dashed",
13333
13471
  onClick: handleAddModel,
@@ -13405,9 +13543,9 @@ QUEUE_NAME=tasks`,
13405
13543
  ] })
13406
13544
  ] }),
13407
13545
  /* @__PURE__ */ jsxs35("div", { className: styles.contentHeaderRight, children: [
13408
- /* @__PURE__ */ jsx57(Button27, { onClick: onClose, children: "Cancel" }),
13546
+ /* @__PURE__ */ jsx57(Button26, { onClick: onClose, children: "Cancel" }),
13409
13547
  /* @__PURE__ */ jsx57(
13410
- Button27,
13548
+ Button26,
13411
13549
  {
13412
13550
  type: "primary",
13413
13551
  icon: /* @__PURE__ */ jsx57(SaveOutlined2, {}),
@@ -13451,7 +13589,7 @@ QUEUE_NAME=tasks`,
13451
13589
  }
13452
13590
  ),
13453
13591
  /* @__PURE__ */ jsx57(
13454
- Button27,
13592
+ Button26,
13455
13593
  {
13456
13594
  type: "primary",
13457
13595
  icon: /* @__PURE__ */ jsx57(LinkOutlined, {}),
@@ -13585,11 +13723,21 @@ var AgentServerSetting = () => {
13585
13723
  // src/components/Chat/LatticeChatShell.tsx
13586
13724
  import { jsx as jsx59, jsxs as jsxs36 } from "react/jsx-runtime";
13587
13725
  var LatticeChatShell = (props) => {
13588
- const { initialConfig } = props;
13589
- return /* @__PURE__ */ jsxs36(LatticeChatShellContextProvider, { ...props, children: [
13590
- /* @__PURE__ */ jsx59(AssistantContextProvider, { autoLoad: true, initialAssistantId: initialConfig?.assistantId, children: /* @__PURE__ */ jsx59(ConversationContextProvider, { children: /* @__PURE__ */ jsx59(LatticeChatView, {}) }) }),
13591
- /* @__PURE__ */ jsx59(AgentServerSetting, {})
13592
- ] });
13726
+ const { enableAssistantCreation, enableAssistantEditing, ...restProps } = props;
13727
+ return /* @__PURE__ */ jsxs36(
13728
+ LatticeChatShellContextProvider,
13729
+ {
13730
+ initialConfig: {
13731
+ enableAssistantCreation,
13732
+ enableAssistantEditing,
13733
+ ...restProps.initialConfig
13734
+ },
13735
+ children: [
13736
+ /* @__PURE__ */ jsx59(AssistantContextProvider, { autoLoad: true, initialAssistantId: restProps.initialConfig?.assistantId, children: /* @__PURE__ */ jsx59(ConversationContextProvider, { children: /* @__PURE__ */ jsx59(LatticeChatView, {}) }) }),
13737
+ /* @__PURE__ */ jsx59(AgentServerSetting, {})
13738
+ ]
13739
+ }
13740
+ );
13593
13741
  };
13594
13742
  export {
13595
13743
  AgentConversations,