@copilotkit/react-ui 1.10.0-next.0 → 1.10.0-next.10

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 (117) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/dist/{chunk-O7KTFUAN.mjs → chunk-226ZMOE3.mjs} +2 -2
  3. package/dist/{chunk-WHDNKXMP.mjs → chunk-BJHJBS5M.mjs} +46 -6
  4. package/dist/chunk-BJHJBS5M.mjs.map +1 -0
  5. package/dist/{chunk-Z4XPPVZT.mjs → chunk-EYRKZDP5.mjs} +1 -1
  6. package/dist/chunk-EYRKZDP5.mjs.map +1 -0
  7. package/dist/{chunk-SGFUVPDB.mjs → chunk-FFJHOZX6.mjs} +2 -2
  8. package/dist/{chunk-WPVTPQ7X.mjs → chunk-GBP47ONN.mjs} +2 -2
  9. package/dist/chunk-GBP47ONN.mjs.map +1 -0
  10. package/dist/{chunk-GVKA7RQQ.mjs → chunk-GDSZGYCE.mjs} +2 -2
  11. package/dist/{chunk-LXCD3K7B.mjs → chunk-GJ4SX4JE.mjs} +152 -36
  12. package/dist/chunk-GJ4SX4JE.mjs.map +1 -0
  13. package/dist/{chunk-VLNT34X3.mjs → chunk-J5ZZR6YB.mjs} +2 -2
  14. package/dist/chunk-J5ZZR6YB.mjs.map +1 -0
  15. package/dist/{chunk-QN7T3GWI.mjs → chunk-JY2CSDKN.mjs} +4 -6
  16. package/dist/chunk-JY2CSDKN.mjs.map +1 -0
  17. package/dist/chunk-MIVUCSGO.mjs +126 -0
  18. package/dist/chunk-MIVUCSGO.mjs.map +1 -0
  19. package/dist/{chunk-JHUTTP5C.mjs → chunk-T5QU6KSB.mjs} +5 -1
  20. package/dist/chunk-T5QU6KSB.mjs.map +1 -0
  21. package/dist/{chunk-Q2467VHZ.mjs → chunk-W26XFBEG.mjs} +2 -2
  22. package/dist/chunk-W26XFBEG.mjs.map +1 -0
  23. package/dist/chunk-Y44VLEUH.mjs +222 -0
  24. package/dist/chunk-Y44VLEUH.mjs.map +1 -0
  25. package/dist/components/chat/Chat.d.ts +52 -15
  26. package/dist/components/chat/Chat.js +1136 -869
  27. package/dist/components/chat/Chat.js.map +1 -1
  28. package/dist/components/chat/Chat.mjs +9 -8
  29. package/dist/components/chat/Header.js +6 -8
  30. package/dist/components/chat/Header.js.map +1 -1
  31. package/dist/components/chat/Header.mjs +3 -3
  32. package/dist/components/chat/Messages.d.ts +1 -1
  33. package/dist/components/chat/Messages.js +984 -23
  34. package/dist/components/chat/Messages.js.map +1 -1
  35. package/dist/components/chat/Messages.mjs +9 -1
  36. package/dist/components/chat/Modal.d.ts +2 -2
  37. package/dist/components/chat/Modal.js +1267 -931
  38. package/dist/components/chat/Modal.js.map +1 -1
  39. package/dist/components/chat/Modal.mjs +13 -12
  40. package/dist/components/chat/Popup.d.ts +1 -1
  41. package/dist/components/chat/Popup.js +1269 -933
  42. package/dist/components/chat/Popup.js.map +1 -1
  43. package/dist/components/chat/Popup.mjs +14 -13
  44. package/dist/components/chat/Sidebar.d.ts +1 -1
  45. package/dist/components/chat/Sidebar.js +1269 -933
  46. package/dist/components/chat/Sidebar.js.map +1 -1
  47. package/dist/components/chat/Sidebar.mjs +14 -13
  48. package/dist/components/chat/Suggestion.js +1 -1
  49. package/dist/components/chat/Suggestion.js.map +1 -1
  50. package/dist/components/chat/Suggestion.mjs +1 -1
  51. package/dist/components/chat/Suggestions.js +1 -1
  52. package/dist/components/chat/Suggestions.js.map +1 -1
  53. package/dist/components/chat/Suggestions.mjs +2 -2
  54. package/dist/components/chat/index.d.ts +2 -2
  55. package/dist/components/chat/index.js +1271 -935
  56. package/dist/components/chat/index.js.map +1 -1
  57. package/dist/components/chat/index.mjs +20 -19
  58. package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
  59. package/dist/components/chat/messages/LegacyRenderMessage.js +980 -0
  60. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
  61. package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
  62. package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
  63. package/dist/components/chat/messages/RenderMessage.js +4 -0
  64. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  65. package/dist/components/chat/messages/RenderMessage.mjs +1 -1
  66. package/dist/components/chat/props.d.ts +94 -2
  67. package/dist/components/chat/props.js.map +1 -1
  68. package/dist/components/dev-console/console.d.ts +1 -0
  69. package/dist/components/dev-console/console.js +6 -8
  70. package/dist/components/dev-console/console.js.map +1 -1
  71. package/dist/components/dev-console/console.mjs +2 -2
  72. package/dist/components/dev-console/index.d.ts +1 -3
  73. package/dist/components/dev-console/index.js +7 -9
  74. package/dist/components/dev-console/index.js.map +1 -1
  75. package/dist/components/dev-console/index.mjs +2 -2
  76. package/dist/components/dev-console/utils.d.ts +2 -2
  77. package/dist/components/dev-console/utils.js +2 -4
  78. package/dist/components/dev-console/utils.js.map +1 -1
  79. package/dist/components/dev-console/utils.mjs +1 -1
  80. package/dist/components/index.d.ts +3 -5
  81. package/dist/components/index.js +1272 -936
  82. package/dist/components/index.js.map +1 -1
  83. package/dist/components/index.mjs +20 -19
  84. package/dist/hooks/index.js.map +1 -1
  85. package/dist/hooks/index.mjs +1 -1
  86. package/dist/hooks/use-copilot-chat-suggestions.d.ts +1 -1
  87. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  88. package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
  89. package/dist/index.d.ts +3 -5
  90. package/dist/index.js +1303 -967
  91. package/dist/index.js.map +1 -1
  92. package/dist/index.mjs +21 -20
  93. package/package.json +6 -6
  94. package/src/components/chat/Chat.tsx +242 -24
  95. package/src/components/chat/Messages.tsx +58 -5
  96. package/src/components/chat/Modal.tsx +128 -41
  97. package/src/components/chat/Popup.tsx +21 -1
  98. package/src/components/chat/Sidebar.tsx +23 -1
  99. package/src/components/chat/Suggestion.tsx +1 -1
  100. package/src/components/chat/messages/LegacyRenderMessage.tsx +143 -0
  101. package/src/components/chat/messages/RenderMessage.tsx +3 -0
  102. package/src/components/chat/props.ts +110 -1
  103. package/src/components/dev-console/utils.ts +1 -6
  104. package/src/hooks/use-copilot-chat-suggestions.tsx +1 -1
  105. package/dist/chunk-GJ3MFNBX.mjs +0 -144
  106. package/dist/chunk-GJ3MFNBX.mjs.map +0 -1
  107. package/dist/chunk-JHUTTP5C.mjs.map +0 -1
  108. package/dist/chunk-LXCD3K7B.mjs.map +0 -1
  109. package/dist/chunk-Q2467VHZ.mjs.map +0 -1
  110. package/dist/chunk-QN7T3GWI.mjs.map +0 -1
  111. package/dist/chunk-VLNT34X3.mjs.map +0 -1
  112. package/dist/chunk-WHDNKXMP.mjs.map +0 -1
  113. package/dist/chunk-WPVTPQ7X.mjs.map +0 -1
  114. package/dist/chunk-Z4XPPVZT.mjs.map +0 -1
  115. /package/dist/{chunk-O7KTFUAN.mjs.map → chunk-226ZMOE3.mjs.map} +0 -0
  116. /package/dist/{chunk-SGFUVPDB.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
  117. /package/dist/{chunk-GVKA7RQQ.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
@@ -2,30 +2,42 @@ import "../chunk-MMVDU6DF.mjs";
2
2
  import "../chunk-SC6JRFAJ.mjs";
3
3
  import {
4
4
  CopilotSidebar
5
- } from "../chunk-WPVTPQ7X.mjs";
5
+ } from "../chunk-GBP47ONN.mjs";
6
6
  import "../chunk-WB3YULQ4.mjs";
7
7
  import {
8
8
  CopilotPopup
9
- } from "../chunk-VLNT34X3.mjs";
10
- import "../chunk-GJ3MFNBX.mjs";
9
+ } from "../chunk-J5ZZR6YB.mjs";
10
+ import "../chunk-Y44VLEUH.mjs";
11
11
  import "../chunk-C3GSYRC3.mjs";
12
- import "../chunk-GVKA7RQQ.mjs";
12
+ import "../chunk-GDSZGYCE.mjs";
13
13
  import "../chunk-V7W6IM2V.mjs";
14
14
  import {
15
15
  CopilotDevConsole
16
- } from "../chunk-SGFUVPDB.mjs";
16
+ } from "../chunk-FFJHOZX6.mjs";
17
17
  import "../chunk-Q5V6S67N.mjs";
18
18
  import {
19
19
  shouldShowDevConsole
20
- } from "../chunk-QN7T3GWI.mjs";
20
+ } from "../chunk-JY2CSDKN.mjs";
21
21
  import "../chunk-KXE2JCUH.mjs";
22
22
  import "../chunk-NRA3CFEE.mjs";
23
23
  import "../chunk-BH6PCAAL.mjs";
24
24
  import "../chunk-UFN2VWSR.mjs";
25
25
  import {
26
26
  CopilotChat
27
- } from "../chunk-LXCD3K7B.mjs";
28
- import "../chunk-JHUTTP5C.mjs";
27
+ } from "../chunk-GJ4SX4JE.mjs";
28
+ import {
29
+ Suggestions
30
+ } from "../chunk-226ZMOE3.mjs";
31
+ import {
32
+ Suggestion
33
+ } from "../chunk-W26XFBEG.mjs";
34
+ import "../chunk-PLHTVHUW.mjs";
35
+ import "../chunk-DTRPPNSA.mjs";
36
+ import "../chunk-CGEAG65D.mjs";
37
+ import "../chunk-QIOJXTIQ.mjs";
38
+ import "../chunk-BJHJBS5M.mjs";
39
+ import "../chunk-MIVUCSGO.mjs";
40
+ import "../chunk-T5QU6KSB.mjs";
29
41
  import {
30
42
  AssistantMessage
31
43
  } from "../chunk-GCKKSSBU.mjs";
@@ -35,20 +47,9 @@ import {
35
47
  import {
36
48
  UserMessage
37
49
  } from "../chunk-VVL6JFCJ.mjs";
38
- import {
39
- Suggestions
40
- } from "../chunk-O7KTFUAN.mjs";
41
- import {
42
- Suggestion
43
- } from "../chunk-Q2467VHZ.mjs";
44
- import "../chunk-PLHTVHUW.mjs";
45
- import "../chunk-DTRPPNSA.mjs";
46
- import "../chunk-CGEAG65D.mjs";
47
- import "../chunk-QIOJXTIQ.mjs";
48
50
  import {
49
51
  Markdown
50
52
  } from "../chunk-E6MQUIZW.mjs";
51
- import "../chunk-WHDNKXMP.mjs";
52
53
  import {
53
54
  useChatContext
54
55
  } from "../chunk-IEMQ2SQW.mjs";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/index.ts","../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["export * from \"./use-copilot-chat-suggestions\";\n","/**\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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\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, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;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,WAAW,SAAS,CAAC;AAC1F;","names":[]}
1
+ {"version":3,"sources":["../../src/hooks/index.ts","../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["export * from \"./use-copilot-chat-suggestions\";\n","/**\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=\"https://cdn.copilotkit.ai/docs/copilotkit/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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\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, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;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,WAAW,SAAS,CAAC;AAC1F;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import "../chunk-T26KLXLH.mjs";
2
2
  import {
3
3
  useCopilotChatSuggestions
4
- } from "../chunk-Z4XPPVZT.mjs";
4
+ } from "../chunk-EYRKZDP5.mjs";
5
5
  import "../chunk-MRXNTQOX.mjs";
6
6
  export {
7
7
  useCopilotChatSuggestions
@@ -9,7 +9,7 @@
9
9
  * application, passing these parent-child relationships to the Copilot.
10
10
  *
11
11
  * <br/>
12
- * <img src="/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif" width="500" />
12
+ * <img src="https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif" width="500" />
13
13
  *
14
14
  * ## Usage
15
15
  *
@@ -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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\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, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;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,WAAW,SAAS,CAAC;AAC1F;","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=\"https://cdn.copilotkit.ai/docs/copilotkit/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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\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, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;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,WAAW,SAAS,CAAC;AAC1F;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotChatSuggestions
3
- } from "../chunk-Z4XPPVZT.mjs";
3
+ } from "../chunk-EYRKZDP5.mjs";
4
4
  import "../chunk-MRXNTQOX.mjs";
5
5
  export {
6
6
  useCopilotChatSuggestions
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AssistantMessageProps, ButtonProps, ComponentsMap, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
1
+ export { AssistantMessageProps, ButtonProps, ComponentsMap, CopilotObservabilityHooks, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
2
2
  export { CopilotPopup } from './components/chat/Popup.js';
3
3
  export { CopilotSidebar } from './components/chat/Sidebar.js';
4
4
  export { CopilotChat } from './components/chat/Chat.js';
@@ -9,7 +9,7 @@ export { ImageRenderer } from './components/chat/messages/ImageRenderer.js';
9
9
  export { useChatContext } from './components/chat/ChatContext.js';
10
10
  export { Suggestions as RenderSuggestionsList } from './components/chat/Suggestions.js';
11
11
  export { Suggestion as RenderSuggestion } from './components/chat/Suggestion.js';
12
- export { shouldShowDevConsole } from './components/dev-console/utils.js';
12
+ export { shouldShowDevConsole } from '@copilotkit/react-core';
13
13
  export { CopilotDevConsole } from './components/dev-console/console.js';
14
14
  export { useCopilotChatSuggestions } from './hooks/use-copilot-chat-suggestions.js';
15
15
  export { CopilotKitCSSProperties } from './types/css.js';
@@ -20,9 +20,7 @@ import 'react/jsx-runtime';
20
20
  import './components/chat/Modal.js';
21
21
  import '@copilotkit/react-core/dist/types/coagent-state';
22
22
  import '@copilotkit/react-core/dist/hooks/use-tree';
23
- import '@copilotkit/react-core/dist/copilot-context-bd88d30d';
23
+ import '@copilotkit/react-core/dist/copilot-context-256f9020';
24
24
  import '@copilotkit/react-core/dist/types/coagent-action';
25
- import '@copilotkit/react-core';
26
25
  import '@copilotkit/runtime-client-gql';
27
26
  import 'react-markdown';
28
- import './components/dev-console/types.js';