@copilotkit/react-ui 1.8.13-next.2 → 1.8.13

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 (80) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-3R6CEFJE.mjs → chunk-FWKHST6I.mjs} +67 -33
  3. package/dist/chunk-FWKHST6I.mjs.map +1 -0
  4. package/dist/{chunk-ZRW27A32.mjs → chunk-IAHSHPRJ.mjs} +12 -13
  5. package/dist/chunk-IAHSHPRJ.mjs.map +1 -0
  6. package/dist/{chunk-XZNY26GH.mjs → chunk-IMBPSLL4.mjs} +3 -3
  7. package/dist/chunk-IMBPSLL4.mjs.map +1 -0
  8. package/dist/{chunk-756IINQI.mjs → chunk-JU3HNL5N.mjs} +2 -2
  9. package/dist/{chunk-IQ7DDXDA.mjs → chunk-QEZ3YYLO.mjs} +2 -2
  10. package/dist/chunk-QGSPTXOV.mjs +24 -0
  11. package/dist/chunk-QGSPTXOV.mjs.map +1 -0
  12. package/dist/chunk-SC6JRFAJ.mjs +1 -0
  13. package/dist/components/chat/Button.d.ts +1 -0
  14. package/dist/components/chat/Chat.d.ts +6 -2
  15. package/dist/components/chat/Chat.js +39 -24
  16. package/dist/components/chat/Chat.js.map +1 -1
  17. package/dist/components/chat/Chat.mjs +3 -2
  18. package/dist/components/chat/Header.d.ts +1 -0
  19. package/dist/components/chat/Input.d.ts +1 -0
  20. package/dist/components/chat/Messages.d.ts +1 -0
  21. package/dist/components/chat/Modal.d.ts +2 -2
  22. package/dist/components/chat/Modal.js +106 -62
  23. package/dist/components/chat/Modal.js.map +1 -1
  24. package/dist/components/chat/Modal.mjs +4 -3
  25. package/dist/components/chat/Popup.d.ts +1 -1
  26. package/dist/components/chat/Popup.js +108 -64
  27. package/dist/components/chat/Popup.js.map +1 -1
  28. package/dist/components/chat/Popup.mjs +5 -4
  29. package/dist/components/chat/Sidebar.d.ts +1 -1
  30. package/dist/components/chat/Sidebar.js +108 -64
  31. package/dist/components/chat/Sidebar.js.map +1 -1
  32. package/dist/components/chat/Sidebar.mjs +5 -4
  33. package/dist/components/chat/Suggestion.d.ts +8 -4
  34. package/dist/components/chat/Suggestion.js +2 -2
  35. package/dist/components/chat/Suggestion.js.map +1 -1
  36. package/dist/components/chat/Suggestion.mjs +1 -1
  37. package/dist/components/chat/Suggestions.d.ts +9 -0
  38. package/dist/components/chat/Suggestions.js +73 -0
  39. package/dist/components/chat/Suggestions.js.map +1 -0
  40. package/dist/components/chat/Suggestions.mjs +10 -0
  41. package/dist/components/chat/Suggestions.mjs.map +1 -0
  42. package/dist/components/chat/Window.d.ts +1 -0
  43. package/dist/components/chat/index.d.ts +4 -2
  44. package/dist/components/chat/index.js +114 -66
  45. package/dist/components/chat/index.js.map +1 -1
  46. package/dist/components/chat/index.mjs +14 -7
  47. package/dist/components/chat/messages/AssistantMessage.d.ts +1 -0
  48. package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +1 -0
  49. package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +1 -0
  50. package/dist/components/chat/messages/RenderImageMessage.d.ts +1 -0
  51. package/dist/components/chat/messages/RenderResultMessage.d.ts +1 -0
  52. package/dist/components/chat/messages/RenderTextMessage.d.ts +1 -0
  53. package/dist/components/chat/messages/UserMessage.d.ts +1 -0
  54. package/dist/components/chat/props.d.ts +6 -1
  55. package/dist/components/chat/props.js.map +1 -1
  56. package/dist/components/index.d.ts +4 -2
  57. package/dist/components/index.js +114 -66
  58. package/dist/components/index.js.map +1 -1
  59. package/dist/components/index.mjs +14 -7
  60. package/dist/index.d.ts +4 -2
  61. package/dist/index.js +114 -66
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +14 -7
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/index.js.map +1 -1
  66. package/package.json +4 -4
  67. package/src/components/chat/Chat.tsx +12 -14
  68. package/src/components/chat/Modal.tsx +2 -0
  69. package/src/components/chat/Suggestion.tsx +10 -3
  70. package/src/components/chat/Suggestions.tsx +20 -0
  71. package/src/components/chat/index.tsx +2 -0
  72. package/src/components/chat/props.ts +6 -0
  73. package/src/types/index.ts +1 -0
  74. package/dist/chunk-3R6CEFJE.mjs.map +0 -1
  75. package/dist/chunk-PXEVB7IK.mjs +0 -1
  76. package/dist/chunk-XZNY26GH.mjs.map +0 -1
  77. package/dist/chunk-ZRW27A32.mjs.map +0 -1
  78. /package/dist/{chunk-756IINQI.mjs.map → chunk-JU3HNL5N.mjs.map} +0 -0
  79. /package/dist/{chunk-IQ7DDXDA.mjs.map → chunk-QEZ3YYLO.mjs.map} +0 -0
  80. /package/dist/{chunk-PXEVB7IK.mjs.map → chunk-SC6JRFAJ.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-756IINQI.mjs";
4
- import "../../chunk-3R6CEFJE.mjs";
3
+ } from "../../chunk-JU3HNL5N.mjs";
4
+ import "../../chunk-FWKHST6I.mjs";
5
5
  import "../../chunk-TIDV74OE.mjs";
6
6
  import "../../chunk-UH2UFL5W.mjs";
7
7
  import "../../chunk-V7W6IM2V.mjs";
@@ -12,7 +12,7 @@ import "../../chunk-KXE2JCUH.mjs";
12
12
  import "../../chunk-NRA3CFEE.mjs";
13
13
  import "../../chunk-BH6PCAAL.mjs";
14
14
  import "../../chunk-UFN2VWSR.mjs";
15
- import "../../chunk-ZRW27A32.mjs";
15
+ import "../../chunk-IAHSHPRJ.mjs";
16
16
  import "../../chunk-MPZAMNCN.mjs";
17
17
  import "../../chunk-ALWZ35SI.mjs";
18
18
  import "../../chunk-UKWBNVMQ.mjs";
@@ -20,7 +20,8 @@ import "../../chunk-6VUDBDUN.mjs";
20
20
  import "../../chunk-5INP2EWU.mjs";
21
21
  import "../../chunk-XMNTLIK5.mjs";
22
22
  import "../../chunk-HWMFMBJC.mjs";
23
- import "../../chunk-XZNY26GH.mjs";
23
+ import "../../chunk-QGSPTXOV.mjs";
24
+ import "../../chunk-IMBPSLL4.mjs";
24
25
  import "../../chunk-PLHTVHUW.mjs";
25
26
  import "../../chunk-EMIYIMQ6.mjs";
26
27
  import "../../chunk-CGEAG65D.mjs";
@@ -1,10 +1,14 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CopilotContextParams, CopilotMessagesContextParams, CopilotChatSuggestionConfiguration } from '@copilotkit/react-core';
3
- import { SuggestionsProps } from './props.js';
4
- import '@copilotkit/runtime-client-gql';
5
- import 'react';
6
3
 
7
- declare function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps): react_jsx_runtime.JSX.Element;
4
+ interface SuggestionsProps {
5
+ title: string;
6
+ message: string;
7
+ partial?: boolean;
8
+ className?: string;
9
+ onClick: () => void;
10
+ }
11
+ declare function Suggestion({ title, onClick, partial, className }: SuggestionsProps): react_jsx_runtime.JSX.Element;
8
12
  declare const reloadSuggestions: (context: CopilotContextParams & CopilotMessagesContextParams, chatSuggestionConfiguration: {
9
13
  [key: string]: CopilotChatSuggestionConfiguration;
10
14
  }, setCurrentSuggestions: (suggestions: {
@@ -54,14 +54,14 @@ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { cla
54
54
  var import_shared = require("@copilotkit/shared");
55
55
  var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
56
56
  var import_jsx_runtime2 = require("react/jsx-runtime");
57
- function Suggestion({ title, message, onClick, partial, className }) {
57
+ function Suggestion({ title, onClick, partial, className }) {
58
58
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
59
59
  "button",
60
60
  {
61
61
  disabled: partial,
62
62
  onClick: (e) => {
63
63
  e.preventDefault();
64
- onClick(message);
64
+ onClick();
65
65
  },
66
66
  className: className || (partial ? "suggestion loading" : "suggestion"),
67
67
  "data-test-id": "suggestion",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SuggestionsProps } from \"./props\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\nexport function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick(message);\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 19V5m0 0l-7 7m7-7l7 7\" />\n </svg>\n);\n\nexport const MicrophoneIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z\"\n />\n </svg>\n);\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z\"\n />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99\"\n />\n </svg>\n);\n\nexport const CopyIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75\"\n />\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"13px\", height: \"13px\" }}></span>\n);\n\nexport const SpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"24px\", height: \"24px\" }}></span>\n);\n\nexport const ActivityIcon = (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.2s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.4s\" }}></span>\n </div>\n);\n\nexport const ThumbsUpIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z\"\n />\n </svg>\n);\n\nexport const ThumbsDownIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384\"\n />\n </svg>\n);\n\nexport const DownloadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3\"\n />\n </svg>\n);\n\nexport const UploadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 4.5v15m7.5-7.5h-15\" />\n </svg>\n);\n\nexport const CheckIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\" />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKO;;;ACMD;AA6HC,IAAM,mBACX,4CAAC,UAAK,WAAU,qBAAoB,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,GAAG;;;ADhIhF,oBAA6C;AAC7C,gCAAmC;AAaC,IAAAA,sBAAA;AAX7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,SAAS,UAAU,GAAqB;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ,OAAO;AAAA,MACjB;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,6CAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;AAEO,IAAM,oBAAoB,CAC/B,SACA,6BACA,uBACA,uBACG;AACH,QAAM,kBAAkB,mBAAmB;AAE3C,QAAM,QAAQ,KAAK;AAAA,IACjB,OAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,MAC9C,MAAM,OAAO;AAAA,MACb,aAAa,OAAO;AAAA,MACpB,YAAY,KAAK,cAAU,4CAA6B,OAAO,UAAU,CAAC;AAAA,IAC5E,EAAE;AAAA,EACJ;AAEA,QAAM,iBAA0C,CAAC;AAEjD,aAAW,UAAU,OAAO,OAAO,2BAA2B,GAAG;AAC/D,QAAI;AACF,YAAM,+BACJ,OAAO,mBAAmB,IACtB,iBAAiB,OAAO,sHAExB,mBAAmB,OAAO,sBAAsB,OAAO;AAE7D,YAAM,SAAS,UAAM,2BAAQ;AAAA,QAC3B;AAAA,QACA,cACE;AAAA,QACF,MACE,OAAO,eACP,SACA,+BACA,0BAEA,QACA;AAAA,QACF,aAAa,6CAAmB;AAAA,QAChC,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV;AAAA,gBACE,MAAM;AAAA,gBACN,aACE;AAAA,gBACF,MAAM;AAAA,cACR;AAAA,cACA;AAAA,gBACE,MAAM;AAAA,gBACN,aACE;AAAA,gBACF,MAAM;AAAA,cACR;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UACP,UAAU;AAAA,UACV,UAAU;AAAA,QACZ;AAAA,QACA,aAAa,mDAAiB;AAAA,QAC9B,QAAQ,CAAC,EAAE,QAAQ,KAAK,MAAM;AAC5B,gBAAM,cAAc,KAAK,eAAe,CAAC;AACzC,gBAAM,iBAA0C,CAAC;AACjD,mBAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAE3C,gBAAI,OAAO,mBAAmB,UAAa,KAAK,OAAO,gBAAgB;AACrE;AAAA,YACF;AACA,kBAAM,EAAE,OAAO,QAAQ,IAAI,YAAY,CAAC;AAGxC,kBAAM,UAAU,KAAK,YAAY,SAAS,KAAK,WAAW;AAE1D,2BAAe,KAAK;AAAA,cAClB;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW,OAAO;AAAA,YACpB,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":["import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\ninterface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: () => void;\n}\n\nexport function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick();\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 19V5m0 0l-7 7m7-7l7 7\" />\n </svg>\n);\n\nexport const MicrophoneIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z\"\n />\n </svg>\n);\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z\"\n />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99\"\n />\n </svg>\n);\n\nexport const CopyIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75\"\n />\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"13px\", height: \"13px\" }}></span>\n);\n\nexport const SpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"24px\", height: \"24px\" }}></span>\n);\n\nexport const ActivityIcon = (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.2s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.4s\" }}></span>\n </div>\n);\n\nexport const ThumbsUpIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z\"\n />\n </svg>\n);\n\nexport const ThumbsDownIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384\"\n />\n </svg>\n);\n\nexport const DownloadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3\"\n />\n </svg>\n);\n\nexport const UploadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 4.5v15m7.5-7.5h-15\" />\n </svg>\n);\n\nexport const CheckIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\" />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKO;;;ACMD;AA6HC,IAAM,mBACX,4CAAC,UAAK,WAAU,qBAAoB,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,GAAG;;;ADjIhF,oBAA6C;AAC7C,gCAAmC;AAqBC,IAAAA,sBAAA;AAX7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,UAAU,GAAqB;AACnF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,6CAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;AAEO,IAAM,oBAAoB,CAC/B,SACA,6BACA,uBACA,uBACG;AACH,QAAM,kBAAkB,mBAAmB;AAE3C,QAAM,QAAQ,KAAK;AAAA,IACjB,OAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,MAC9C,MAAM,OAAO;AAAA,MACb,aAAa,OAAO;AAAA,MACpB,YAAY,KAAK,cAAU,4CAA6B,OAAO,UAAU,CAAC;AAAA,IAC5E,EAAE;AAAA,EACJ;AAEA,QAAM,iBAA0C,CAAC;AAEjD,aAAW,UAAU,OAAO,OAAO,2BAA2B,GAAG;AAC/D,QAAI;AACF,YAAM,+BACJ,OAAO,mBAAmB,IACtB,iBAAiB,OAAO,sHAExB,mBAAmB,OAAO,sBAAsB,OAAO;AAE7D,YAAM,SAAS,UAAM,2BAAQ;AAAA,QAC3B;AAAA,QACA,cACE;AAAA,QACF,MACE,OAAO,eACP,SACA,+BACA,0BAEA,QACA;AAAA,QACF,aAAa,6CAAmB;AAAA,QAChC,YAAY;AAAA,UACV;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV;AAAA,gBACE,MAAM;AAAA,gBACN,aACE;AAAA,gBACF,MAAM;AAAA,cACR;AAAA,cACA;AAAA,gBACE,MAAM;AAAA,gBACN,aACE;AAAA,gBACF,MAAM;AAAA,cACR;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UACP,UAAU;AAAA,UACV,UAAU;AAAA,QACZ;AAAA,QACA,aAAa,mDAAiB;AAAA,QAC9B,QAAQ,CAAC,EAAE,QAAQ,KAAK,MAAM;AAC5B,gBAAM,cAAc,KAAK,eAAe,CAAC;AACzC,gBAAM,iBAA0C,CAAC;AACjD,mBAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAE3C,gBAAI,OAAO,mBAAmB,UAAa,KAAK,OAAO,gBAAgB;AACrE;AAAA,YACF;AACA,kBAAM,EAAE,OAAO,QAAQ,IAAI,YAAY,CAAC;AAGxC,kBAAM,UAAU,KAAK,YAAY,SAAS,KAAK,WAAW;AAE1D,2BAAe,KAAK;AAAA,cAClB;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW,OAAO;AAAA,YACpB,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":["import_jsx_runtime"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Suggestion,
3
3
  reloadSuggestions
4
- } from "../../chunk-XZNY26GH.mjs";
4
+ } from "../../chunk-IMBPSLL4.mjs";
5
5
  import "../../chunk-XWG3L6QC.mjs";
6
6
  import "../../chunk-MRXNTQOX.mjs";
7
7
  export {
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { RenderSuggestionsListProps } from './props.js';
3
+ import '@copilotkit/runtime-client-gql';
4
+ import '../../types/suggestions.js';
5
+ import 'react';
6
+
7
+ declare function Suggestions({ suggestions, onSuggestionClick }: RenderSuggestionsListProps): react_jsx_runtime.JSX.Element;
8
+
9
+ export { Suggestions };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/chat/Suggestions.tsx
21
+ var Suggestions_exports = {};
22
+ __export(Suggestions_exports, {
23
+ Suggestions: () => Suggestions
24
+ });
25
+ module.exports = __toCommonJS(Suggestions_exports);
26
+
27
+ // src/components/chat/Suggestion.tsx
28
+ var import_react_core = require("@copilotkit/react-core");
29
+
30
+ // src/components/chat/Icons.tsx
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "13px", height: "13px" } });
33
+
34
+ // src/components/chat/Suggestion.tsx
35
+ var import_shared = require("@copilotkit/shared");
36
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
37
+ var import_jsx_runtime2 = require("react/jsx-runtime");
38
+ function Suggestion({ title, onClick, partial, className }) {
39
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
40
+ "button",
41
+ {
42
+ disabled: partial,
43
+ onClick: (e) => {
44
+ e.preventDefault();
45
+ onClick();
46
+ },
47
+ className: className || (partial ? "suggestion loading" : "suggestion"),
48
+ "data-test-id": "suggestion",
49
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: title })
50
+ }
51
+ );
52
+ }
53
+
54
+ // src/components/chat/Suggestions.tsx
55
+ var import_jsx_runtime3 = require("react/jsx-runtime");
56
+ function Suggestions({ suggestions, onSuggestionClick }) {
57
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
58
+ Suggestion,
59
+ {
60
+ title: suggestion.title,
61
+ message: suggestion.message,
62
+ partial: suggestion.partial,
63
+ className: suggestion.className,
64
+ onClick: () => onSuggestionClick(suggestion.message)
65
+ },
66
+ index
67
+ )) });
68
+ }
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ Suggestions
72
+ });
73
+ //# sourceMappingURL=Suggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/chat/Suggestions.tsx","../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import { Suggestion } from \"./Suggestion\";\nimport React from \"react\";\nimport { RenderSuggestionsListProps } from \"./props\";\n\nexport function Suggestions({ suggestions, onSuggestionClick }: RenderSuggestionsListProps) {\n return (\n <div className=\"suggestions\">\n {suggestions.map((suggestion, index) => (\n <Suggestion\n key={index}\n title={suggestion.title}\n message={suggestion.message}\n partial={suggestion.partial}\n className={suggestion.className}\n onClick={() => onSuggestionClick(suggestion.message)}\n />\n ))}\n </div>\n );\n}\n","import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\ninterface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: () => void;\n}\n\nexport function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick();\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 19V5m0 0l-7 7m7-7l7 7\" />\n </svg>\n);\n\nexport const MicrophoneIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z\"\n />\n </svg>\n);\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z\"\n />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99\"\n />\n </svg>\n);\n\nexport const CopyIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75\"\n />\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"13px\", height: \"13px\" }}></span>\n);\n\nexport const SpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"24px\", height: \"24px\" }}></span>\n);\n\nexport const ActivityIcon = (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.2s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.4s\" }}></span>\n </div>\n);\n\nexport const ThumbsUpIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z\"\n />\n </svg>\n);\n\nexport const ThumbsDownIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384\"\n />\n </svg>\n);\n\nexport const DownloadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3\"\n />\n </svg>\n);\n\nexport const UploadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 4.5v15m7.5-7.5h-15\" />\n </svg>\n);\n\nexport const CheckIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\" />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAKO;;;ACMD;AA6HC,IAAM,mBACX,4CAAC,UAAK,WAAU,qBAAoB,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,GAAG;;;ADjIhF,oBAA6C;AAC7C,gCAAmC;AAqBC,IAAAA,sBAAA;AAX7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,UAAU,GAAqB;AACnF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,6CAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;;;ADzBQ,IAAAC,sBAAA;AAJD,SAAS,YAAY,EAAE,aAAa,kBAAkB,GAA+B;AAC1F,SACE,6CAAC,SAAI,WAAU,eACZ,sBAAY,IAAI,CAAC,YAAY,UAC5B;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO,WAAW;AAAA,MAClB,SAAS,WAAW;AAAA,MACpB,SAAS,WAAW;AAAA,MACpB,WAAW,WAAW;AAAA,MACtB,SAAS,MAAM,kBAAkB,WAAW,OAAO;AAAA;AAAA,IAL9C;AAAA,EAMP,CACD,GACH;AAEJ;","names":["import_jsx_runtime","import_jsx_runtime"]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ Suggestions
3
+ } from "../../chunk-QGSPTXOV.mjs";
4
+ import "../../chunk-IMBPSLL4.mjs";
5
+ import "../../chunk-XWG3L6QC.mjs";
6
+ import "../../chunk-MRXNTQOX.mjs";
7
+ export {
8
+ Suggestions
9
+ };
10
+ //# sourceMappingURL=Suggestions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { WindowProps } from './props.js';
3
3
  import '@copilotkit/runtime-client-gql';
4
+ import '../../types/suggestions.js';
4
5
  import 'react';
5
6
 
6
7
  declare const Window: ({ children, clickOutsideToClose, shortcut, hitEscapeToClose, }: WindowProps) => react_jsx_runtime.JSX.Element;
@@ -1,4 +1,4 @@
1
- export { AssistantMessageProps, ButtonProps, ComponentsMap, HeaderProps, InputProps, MessagesProps, RenderMessageProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
1
+ export { AssistantMessageProps, ButtonProps, ComponentsMap, HeaderProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
2
2
  export { CopilotPopup } from './Popup.js';
3
3
  export { CopilotSidebar } from './Sidebar.js';
4
4
  export { CopilotChat } from './Chat.js';
@@ -7,10 +7,12 @@ export { AssistantMessage } from './messages/AssistantMessage.js';
7
7
  export { UserMessage } from './messages/UserMessage.js';
8
8
  export { useChatContext } from './ChatContext.js';
9
9
  export { RenderImageMessage } from './messages/RenderImageMessage.js';
10
+ export { Suggestions as RenderSuggestionsList } from './Suggestions.js';
11
+ export { Suggestion as RenderSuggestion } from './Suggestion.js';
10
12
  import '@copilotkit/runtime-client-gql';
13
+ import '../../types/suggestions.js';
11
14
  import 'react';
12
15
  import 'react/jsx-runtime';
13
16
  import './Modal.js';
14
17
  import '@copilotkit/react-core';
15
- import '../../types/suggestions.js';
16
18
  import 'react-markdown';
@@ -85,6 +85,8 @@ __export(chat_exports, {
85
85
  CopilotSidebar: () => CopilotSidebar,
86
86
  Markdown: () => Markdown,
87
87
  RenderImageMessage: () => RenderImageMessage,
88
+ RenderSuggestion: () => Suggestion,
89
+ RenderSuggestionsList: () => Suggestions,
88
90
  UserMessage: () => UserMessage,
89
91
  useChatContext: () => useChatContext
90
92
  });
@@ -2493,19 +2495,23 @@ function RenderImageMessage(_a) {
2493
2495
  return null;
2494
2496
  }
2495
2497
 
2498
+ // src/components/chat/Chat.tsx
2499
+ var import_react13 = __toESM(require("react"));
2500
+ var import_react_core10 = require("@copilotkit/react-core");
2501
+
2496
2502
  // src/components/chat/Suggestion.tsx
2497
2503
  var import_react_core9 = require("@copilotkit/react-core");
2498
2504
  var import_shared2 = require("@copilotkit/shared");
2499
2505
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
2500
2506
  var import_jsx_runtime23 = require("react/jsx-runtime");
2501
- function Suggestion({ title, message, onClick, partial, className }) {
2507
+ function Suggestion({ title, onClick, partial, className }) {
2502
2508
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2503
2509
  "button",
2504
2510
  {
2505
2511
  disabled: partial,
2506
2512
  onClick: (e) => {
2507
2513
  e.preventDefault();
2508
- onClick(message);
2514
+ onClick();
2509
2515
  },
2510
2516
  className: className || (partial ? "suggestion loading" : "suggestion"),
2511
2517
  "data-test-id": "suggestion",
@@ -2584,8 +2590,6 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
2584
2590
  });
2585
2591
 
2586
2592
  // src/components/chat/Chat.tsx
2587
- var import_react13 = __toESM(require("react"));
2588
- var import_react_core10 = require("@copilotkit/react-core");
2589
2593
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
2590
2594
  var import_shared3 = require("@copilotkit/shared");
2591
2595
  var import_react_core11 = require("@copilotkit/react-core");
@@ -2668,8 +2672,24 @@ var ImageUploadQueue = ({
2668
2672
  );
2669
2673
  };
2670
2674
 
2671
- // src/components/chat/Chat.tsx
2675
+ // src/components/chat/Suggestions.tsx
2672
2676
  var import_jsx_runtime25 = require("react/jsx-runtime");
2677
+ function Suggestions({ suggestions, onSuggestionClick }) {
2678
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2679
+ Suggestion,
2680
+ {
2681
+ title: suggestion.title,
2682
+ message: suggestion.message,
2683
+ partial: suggestion.partial,
2684
+ className: suggestion.className,
2685
+ onClick: () => onSuggestionClick(suggestion.message)
2686
+ },
2687
+ index
2688
+ )) });
2689
+ }
2690
+
2691
+ // src/components/chat/Chat.tsx
2692
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2673
2693
  function CopilotChat({
2674
2694
  instructions,
2675
2695
  onSubmitMessage,
@@ -2688,6 +2708,7 @@ function CopilotChat({
2688
2708
  RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
2689
2709
  RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
2690
2710
  RenderImageMessage: RenderImageMessage2 = RenderImageMessage,
2711
+ RenderSuggestionsList = Suggestions,
2691
2712
  Input: Input2 = Input,
2692
2713
  className,
2693
2714
  icons,
@@ -2827,8 +2848,8 @@ function CopilotChat({
2827
2848
  const removeSelectedImage = (index) => {
2828
2849
  setSelectedImages((prev) => prev.filter((_, i) => i !== index));
2829
2850
  };
2830
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2831
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2851
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2852
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2832
2853
  Messages2,
2833
2854
  {
2834
2855
  AssistantMessage: AssistantMessage2,
@@ -2845,22 +2866,18 @@ function CopilotChat({
2845
2866
  onThumbsUp,
2846
2867
  onThumbsDown,
2847
2868
  markdownTagRenderers,
2848
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2849
- Suggestion,
2869
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2870
+ RenderSuggestionsList,
2850
2871
  {
2851
- title: suggestion.title,
2852
- message: suggestion.message,
2853
- partial: suggestion.partial,
2854
- className: suggestion.className,
2855
- onClick: (message) => handleSendMessage(message)
2856
- },
2857
- index
2858
- )) })
2872
+ onSuggestionClick: handleSendMessage,
2873
+ suggestions: currentSuggestions
2874
+ }
2875
+ )
2859
2876
  }
2860
2877
  ),
2861
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2862
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2863
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2878
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
2879
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2880
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2864
2881
  "input",
2865
2882
  {
2866
2883
  type: "file",
@@ -2872,7 +2889,7 @@ function CopilotChat({
2872
2889
  }
2873
2890
  )
2874
2891
  ] }),
2875
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2892
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2876
2893
  Input2,
2877
2894
  {
2878
2895
  inProgress: isLoading,
@@ -2895,10 +2912,10 @@ function WrappedCopilotChat({
2895
2912
  }) {
2896
2913
  const chatContext = import_react13.default.useContext(ChatContext);
2897
2914
  if (!chatContext) {
2898
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2899
- }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2915
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2916
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2900
2917
  }
2901
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
2918
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
2902
2919
  }
2903
2920
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2904
2921
  var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
@@ -3083,56 +3100,85 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
3083
3100
  };
3084
3101
 
3085
3102
  // src/components/chat/Modal.tsx
3086
- var import_jsx_runtime26 = require("react/jsx-runtime");
3087
- var CopilotModal = ({
3088
- instructions,
3089
- defaultOpen = false,
3090
- clickOutsideToClose = true,
3091
- hitEscapeToClose = true,
3092
- onSetOpen,
3093
- onSubmitMessage,
3094
- onStopGeneration,
3095
- onReloadMessages,
3096
- shortcut = "/",
3097
- icons,
3098
- labels,
3099
- makeSystemMessage,
3100
- onInProgress,
3101
- Window: Window2 = Window,
3102
- Button: Button2 = Button,
3103
- Header: Header2 = Header,
3104
- Messages: Messages2 = Messages,
3105
- Input: Input2 = Input,
3106
- AssistantMessage: AssistantMessage2 = AssistantMessage,
3107
- UserMessage: UserMessage2 = UserMessage,
3108
- onThumbsUp,
3109
- onThumbsDown,
3110
- onCopy,
3111
- onRegenerate,
3112
- markdownTagRenderers,
3113
- className,
3114
- children
3115
- }) => {
3103
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3104
+ var CopilotModal = (_a) => {
3105
+ var _b = _a, {
3106
+ instructions,
3107
+ defaultOpen = false,
3108
+ clickOutsideToClose = true,
3109
+ hitEscapeToClose = true,
3110
+ onSetOpen,
3111
+ onSubmitMessage,
3112
+ onStopGeneration,
3113
+ onReloadMessages,
3114
+ shortcut = "/",
3115
+ icons,
3116
+ labels,
3117
+ makeSystemMessage,
3118
+ onInProgress,
3119
+ Window: Window2 = Window,
3120
+ Button: Button2 = Button,
3121
+ Header: Header2 = Header,
3122
+ Messages: Messages2 = Messages,
3123
+ Input: Input2 = Input,
3124
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
3125
+ UserMessage: UserMessage2 = UserMessage,
3126
+ onThumbsUp,
3127
+ onThumbsDown,
3128
+ onCopy,
3129
+ onRegenerate,
3130
+ markdownTagRenderers,
3131
+ className,
3132
+ children
3133
+ } = _b, props = __objRest(_b, [
3134
+ "instructions",
3135
+ "defaultOpen",
3136
+ "clickOutsideToClose",
3137
+ "hitEscapeToClose",
3138
+ "onSetOpen",
3139
+ "onSubmitMessage",
3140
+ "onStopGeneration",
3141
+ "onReloadMessages",
3142
+ "shortcut",
3143
+ "icons",
3144
+ "labels",
3145
+ "makeSystemMessage",
3146
+ "onInProgress",
3147
+ "Window",
3148
+ "Button",
3149
+ "Header",
3150
+ "Messages",
3151
+ "Input",
3152
+ "AssistantMessage",
3153
+ "UserMessage",
3154
+ "onThumbsUp",
3155
+ "onThumbsDown",
3156
+ "onCopy",
3157
+ "onRegenerate",
3158
+ "markdownTagRenderers",
3159
+ "className",
3160
+ "children"
3161
+ ]);
3116
3162
  const [openState, setOpenState] = import_react14.default.useState(defaultOpen);
3117
3163
  const setOpen = (open) => {
3118
3164
  onSetOpen == null ? void 0 : onSetOpen(open);
3119
3165
  setOpenState(open);
3120
3166
  };
3121
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
3167
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
3122
3168
  children,
3123
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
3124
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
3125
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3169
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className, children: [
3170
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button2, {}),
3171
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3126
3172
  Window2,
3127
3173
  {
3128
3174
  clickOutsideToClose,
3129
3175
  shortcut,
3130
3176
  hitEscapeToClose,
3131
3177
  children: [
3132
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}),
3133
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3178
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Header2, {}),
3179
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3134
3180
  CopilotChat,
3135
- {
3181
+ __spreadProps(__spreadValues({}, props), {
3136
3182
  instructions,
3137
3183
  onSubmitMessage,
3138
3184
  onStopGeneration,
@@ -3148,7 +3194,7 @@ var CopilotModal = ({
3148
3194
  onCopy,
3149
3195
  onRegenerate,
3150
3196
  markdownTagRenderers
3151
- }
3197
+ })
3152
3198
  )
3153
3199
  ]
3154
3200
  }
@@ -3158,17 +3204,17 @@ var CopilotModal = ({
3158
3204
  };
3159
3205
 
3160
3206
  // src/components/chat/Popup.tsx
3161
- var import_jsx_runtime27 = require("react/jsx-runtime");
3207
+ var import_jsx_runtime28 = require("react/jsx-runtime");
3162
3208
  function CopilotPopup(props) {
3163
3209
  props = __spreadProps(__spreadValues({}, props), {
3164
3210
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
3165
3211
  });
3166
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3212
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3167
3213
  }
3168
3214
 
3169
3215
  // src/components/chat/Sidebar.tsx
3170
3216
  var import_react15 = require("react");
3171
- var import_jsx_runtime28 = require("react/jsx-runtime");
3217
+ var import_jsx_runtime29 = require("react/jsx-runtime");
3172
3218
  function CopilotSidebar(props) {
3173
3219
  props = __spreadProps(__spreadValues({}, props), {
3174
3220
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
@@ -3181,7 +3227,7 @@ function CopilotSidebar(props) {
3181
3227
  (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
3182
3228
  setExpandedClassName(open ? "sidebarExpanded" : "");
3183
3229
  };
3184
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3230
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3185
3231
  }
3186
3232
  // Annotate the CommonJS export names for ESM import in node:
3187
3233
  0 && (module.exports = {
@@ -3191,6 +3237,8 @@ function CopilotSidebar(props) {
3191
3237
  CopilotSidebar,
3192
3238
  Markdown,
3193
3239
  RenderImageMessage,
3240
+ RenderSuggestion,
3241
+ RenderSuggestionsList,
3194
3242
  UserMessage,
3195
3243
  useChatContext
3196
3244
  });