@copilotkit/react-ui 1.3.5 → 1.3.6

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{chunk-U7CXOZEV.mjs → chunk-HIX4HRWU.mjs} +2 -2
  3. package/dist/{chunk-3CQ72Y7E.mjs → chunk-P47XGGRX.mjs} +2 -2
  4. package/dist/{chunk-N4JRGTUJ.mjs → chunk-RF3KLUPD.mjs} +2 -2
  5. package/dist/chunk-RF3KLUPD.mjs.map +1 -0
  6. package/dist/{chunk-P4N6EWUO.mjs → chunk-SPZEI5EN.mjs} +2 -2
  7. package/dist/{chunk-FRFXYFEH.mjs → chunk-TSQVQAAC.mjs} +2 -2
  8. package/dist/{chunk-5HHVL5WK.mjs → chunk-Z2UZSN3K.mjs} +2 -2
  9. package/dist/{chunk-5HHVL5WK.mjs.map → chunk-Z2UZSN3K.mjs.map} +1 -1
  10. package/dist/components/chat/Chat.js +1 -1
  11. package/dist/components/chat/Chat.js.map +1 -1
  12. package/dist/components/chat/Chat.mjs +2 -2
  13. package/dist/components/chat/Modal.js +1 -1
  14. package/dist/components/chat/Modal.js.map +1 -1
  15. package/dist/components/chat/Modal.mjs +3 -3
  16. package/dist/components/chat/Popup.js +1 -1
  17. package/dist/components/chat/Popup.js.map +1 -1
  18. package/dist/components/chat/Popup.mjs +4 -4
  19. package/dist/components/chat/Sidebar.js +1 -1
  20. package/dist/components/chat/Sidebar.js.map +1 -1
  21. package/dist/components/chat/Sidebar.mjs +4 -4
  22. package/dist/components/chat/index.js +1 -1
  23. package/dist/components/chat/index.js.map +1 -1
  24. package/dist/components/chat/index.mjs +5 -5
  25. package/dist/components/chat/messages/RenderAgentStateMessage.js +1 -1
  26. package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
  27. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +1 -1
  28. package/dist/components/index.js +1 -1
  29. package/dist/components/index.js.map +1 -1
  30. package/dist/components/index.mjs +5 -5
  31. package/dist/hooks/index.js +1 -1
  32. package/dist/hooks/index.js.map +1 -1
  33. package/dist/hooks/index.mjs +1 -1
  34. package/dist/hooks/use-copilot-chat-suggestions.js +1 -1
  35. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  36. package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
  37. package/dist/index.js +2 -2
  38. package/dist/index.js.map +1 -1
  39. package/dist/index.mjs +6 -6
  40. package/package.json +7 -7
  41. package/src/components/chat/messages/RenderAgentStateMessage.tsx +3 -2
  42. package/src/hooks/use-copilot-chat-suggestions.tsx +1 -1
  43. package/dist/chunk-N4JRGTUJ.mjs.map +0 -1
  44. /package/dist/{chunk-U7CXOZEV.mjs.map → chunk-HIX4HRWU.mjs.map} +0 -0
  45. /package/dist/{chunk-3CQ72Y7E.mjs.map → chunk-P47XGGRX.mjs.map} +0 -0
  46. /package/dist/{chunk-P4N6EWUO.mjs.map → chunk-SPZEI5EN.mjs.map} +0 -0
  47. /package/dist/{chunk-FRFXYFEH.mjs.map → chunk-TSQVQAAC.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # ui
2
2
 
3
+ ## 1.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 1. Removes the usage of the `crypto` Node pacakge, instaed uses `uuid`. This ensures that non-Next.js React apps can use CopilotKit.
8
+ 2. Fixes Nest.js runtime docs
9
+
10
+ - Updated dependencies
11
+ - @copilotkit/react-core@1.3.6
12
+ - @copilotkit/runtime-client-gql@1.3.6
13
+ - @copilotkit/shared@1.3.6
14
+
3
15
  ## 1.3.5
4
16
 
5
17
  ### Patch Changes
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YH2STM73.mjs";
4
4
  import {
5
5
  RenderAgentStateMessage
6
- } from "./chunk-N4JRGTUJ.mjs";
6
+ } from "./chunk-RF3KLUPD.mjs";
7
7
  import {
8
8
  RenderResultMessage
9
9
  } from "./chunk-GOTHQ665.mjs";
@@ -191,4 +191,4 @@ export {
191
191
  WrappedCopilotChat,
192
192
  useCopilotChatLogic
193
193
  };
194
- //# sourceMappingURL=chunk-U7CXOZEV.mjs.map
194
+ //# sourceMappingURL=chunk-HIX4HRWU.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-P4N6EWUO.mjs";
3
+ } from "./chunk-SPZEI5EN.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
27
27
  export {
28
28
  CopilotSidebar
29
29
  };
30
- //# sourceMappingURL=chunk-3CQ72Y7E.mjs.map
30
+ //# sourceMappingURL=chunk-P47XGGRX.mjs.map
@@ -13,7 +13,7 @@ function RenderAgentStateMessage(props) {
13
13
  if (message instanceof AgentStateMessage) {
14
14
  let render;
15
15
  if (chatComponentsCache.current !== null) {
16
- render = chatComponentsCache.current.coagentActions[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coagentActions[`${message.agentName}-global`];
16
+ render = chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`];
17
17
  }
18
18
  if (render) {
19
19
  if (typeof render === "string") {
@@ -63,4 +63,4 @@ function RenderAgentStateMessage(props) {
63
63
  export {
64
64
  RenderAgentStateMessage
65
65
  };
66
- //# sourceMappingURL=chunk-N4JRGTUJ.mjs.map
66
+ //# sourceMappingURL=chunk-RF3KLUPD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/messages/RenderAgentStateMessage.tsx"],"sourcesContent":["import { AgentStateMessage } from \"@copilotkit/runtime-client-gql\";\nimport { RenderMessageProps } from \"../props\";\nimport { useChatContext } from \"../ChatContext\";\nimport { CoagentInChatRenderFunction, useCopilotContext } from \"@copilotkit/react-core\";\n\nexport function RenderAgentStateMessage(props: RenderMessageProps) {\n const { message, inProgress, index, isCurrentMessage } = props;\n const { chatComponentsCache } = useCopilotContext();\n const { icons } = useChatContext();\n\n if (message instanceof AgentStateMessage) {\n let render: string | CoagentInChatRenderFunction | undefined;\n\n if (chatComponentsCache.current !== null) {\n render =\n chatComponentsCache.current.coAgentStateRenders[\n `${message.agentName}-${message.nodeName}`\n ] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`];\n }\n\n if (render) {\n // render a static string\n if (typeof render === \"string\") {\n // when render is static, we show it only when in progress\n if (isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {icons.spinnerIcon} <span className=\"inProgressLabel\">{render}</span>\n </div>\n );\n }\n // Done - silent by default to avoid a series of \"done\" messages\n else {\n return null;\n }\n }\n // render is a function\n else {\n const state = message.state;\n\n let status = message.active ? \"inProgress\" : \"complete\";\n\n const toRender = render({\n status: status as any,\n state,\n nodeName: message.nodeName,\n });\n\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n\n if (!toRender && isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {icons.spinnerIcon}\n </div>\n );\n } else if (!toRender) {\n return null;\n }\n\n if (typeof toRender === \"string\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && icons.spinnerIcon} {toRender}\n </div>\n );\n } else {\n return (\n <div key={index} className=\"copilotKitCustomAssistantMessage\">\n {toRender}\n </div>\n );\n }\n }\n }\n // No render function found- show the default message\n else if (!inProgress || !isCurrentMessage) {\n // Done - silent by default to avoid a series of \"done\" messages\n return null;\n } else {\n // In progress\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {icons.spinnerIcon}\n </div>\n );\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,yBAAyB;AAGlC,SAAsC,yBAAyB;AAuBnD,SACsB,KADtB;AArBL,SAAS,wBAAwB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AAc,CAAC,kBAAkB;AAEzC,aAAO;AAAA,IACT,OAAO;AAEL,aACE,oBAAC,SAAgB,WAAW,gDACzB,gBAAM,eADC,KAEV;AAAA,IAEJ;AAAA,EACF;AACF;","names":[]}
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-YOH25I6N.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-U7CXOZEV.mjs";
12
+ } from "./chunk-HIX4HRWU.mjs";
13
13
  import {
14
14
  Input
15
15
  } from "./chunk-U6J5DGOE.mjs";
@@ -88,4 +88,4 @@ var CopilotModal = ({
88
88
  export {
89
89
  CopilotModal
90
90
  };
91
- //# sourceMappingURL=chunk-P4N6EWUO.mjs.map
91
+ //# sourceMappingURL=chunk-SPZEI5EN.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-P4N6EWUO.mjs";
3
+ } from "./chunk-SPZEI5EN.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-FRFXYFEH.mjs.map
21
+ //# sourceMappingURL=chunk-TSQVQAAC.mjs.map
@@ -20,10 +20,10 @@ function useCopilotChatSuggestions({
20
20
  return () => {
21
21
  context.removeChatSuggestionConfiguration(id);
22
22
  };
23
- }, dependencies);
23
+ }, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);
24
24
  }
25
25
 
26
26
  export {
27
27
  useCopilotChatSuggestions
28
28
  };
29
- //# sourceMappingURL=chunk-5HHVL5WK.mjs.map
29
+ //# sourceMappingURL=chunk-Z2UZSN3K.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, dependencies);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAuBlB,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,UAAM,KAAK,SAAS;AAEpB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,YAAY;AACjB;","names":[]}
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAuBlB,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,UAAM,KAAK,SAAS;AAEpB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,GAAG,cAAc,cAAc,gBAAgB,gBAAgB,SAAS,CAAC;AAC/E;","names":[]}
@@ -1296,7 +1296,7 @@ function RenderAgentStateMessage(props) {
1296
1296
  if (message instanceof import_runtime_client_gql6.AgentStateMessage) {
1297
1297
  let render;
1298
1298
  if (chatComponentsCache.current !== null) {
1299
- render = chatComponentsCache.current.coagentActions[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coagentActions[`${message.agentName}-global`];
1299
+ render = chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`];
1300
1300
  }
1301
1301
  if (render) {
1302
1302
  if (typeof render === "string") {