@copilotkit/react-ui 1.1.1-feat-runtime-remote-actions.0 → 1.1.1

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 (70) hide show
  1. package/CHANGELOG.md +8 -5
  2. package/dist/{chunk-JC7QYDYI.mjs → chunk-4Z2WDXSK.mjs} +2 -8
  3. package/dist/chunk-4Z2WDXSK.mjs.map +1 -0
  4. package/dist/{chunk-VE4TIYL6.mjs → chunk-D6QNFZXK.mjs} +2 -4
  5. package/dist/chunk-D6QNFZXK.mjs.map +1 -0
  6. package/dist/{chunk-TOCSYTIB.mjs → chunk-EJ4SJ2HU.mjs} +2 -2
  7. package/dist/chunk-EJ4SJ2HU.mjs.map +1 -0
  8. package/dist/{chunk-WCPLXRZX.mjs → chunk-KSCXPA74.mjs} +1 -1
  9. package/dist/chunk-KSCXPA74.mjs.map +1 -0
  10. package/dist/{chunk-BWXEQ7ZU.mjs → chunk-PF5HUDUP.mjs} +2 -54
  11. package/dist/chunk-PF5HUDUP.mjs.map +1 -0
  12. package/dist/{chunk-ZIZZGFE2.mjs → chunk-SWWFXRFF.mjs} +7 -32
  13. package/dist/chunk-SWWFXRFF.mjs.map +1 -0
  14. package/dist/{chunk-MNEGEFTI.mjs → chunk-UJHTRHS4.mjs} +2 -2
  15. package/dist/chunk-UJHTRHS4.mjs.map +1 -0
  16. package/dist/{chunk-6UDD2RWZ.mjs → chunk-WOPUCUQK.mjs} +3 -3
  17. package/dist/components/chat/Chat.d.ts +22 -36
  18. package/dist/components/chat/Chat.js +4 -85
  19. package/dist/components/chat/Chat.js.map +1 -1
  20. package/dist/components/chat/Chat.mjs +5 -5
  21. package/dist/components/chat/Messages.js +0 -5
  22. package/dist/components/chat/Messages.js.map +1 -1
  23. package/dist/components/chat/Messages.mjs +1 -1
  24. package/dist/components/chat/Modal.js +4 -85
  25. package/dist/components/chat/Modal.js.map +1 -1
  26. package/dist/components/chat/Modal.mjs +6 -6
  27. package/dist/components/chat/Popup.d.ts +19 -35
  28. package/dist/components/chat/Popup.js +4 -85
  29. package/dist/components/chat/Popup.js.map +1 -1
  30. package/dist/components/chat/Popup.mjs +7 -7
  31. package/dist/components/chat/Sidebar.js +4 -85
  32. package/dist/components/chat/Sidebar.js.map +1 -1
  33. package/dist/components/chat/Sidebar.mjs +7 -7
  34. package/dist/components/chat/Suggestion.js.map +1 -1
  35. package/dist/components/chat/Suggestion.mjs +1 -1
  36. package/dist/components/chat/index.js +4 -85
  37. package/dist/components/chat/index.js.map +1 -1
  38. package/dist/components/chat/index.mjs +8 -8
  39. package/dist/components/dev-console/console.js +0 -52
  40. package/dist/components/dev-console/console.js.map +1 -1
  41. package/dist/components/dev-console/console.mjs +2 -2
  42. package/dist/components/dev-console/index.js +0 -52
  43. package/dist/components/dev-console/index.js.map +1 -1
  44. package/dist/components/dev-console/index.mjs +2 -2
  45. package/dist/components/dev-console/utils.d.ts +1 -2
  46. package/dist/components/dev-console/utils.js +0 -53
  47. package/dist/components/dev-console/utils.js.map +1 -1
  48. package/dist/components/dev-console/utils.mjs +1 -3
  49. package/dist/components/index.js +4 -85
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/index.mjs +8 -8
  52. package/dist/index.js +4 -85
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +8 -8
  55. package/package.json +7 -7
  56. package/src/components/chat/Chat.tsx +24 -66
  57. package/src/components/chat/Messages.tsx +0 -26
  58. package/src/components/chat/Popup.tsx +19 -35
  59. package/src/components/chat/Sidebar.tsx +20 -35
  60. package/src/components/chat/Suggestion.tsx +0 -2
  61. package/src/components/dev-console/console.tsx +0 -6
  62. package/src/components/dev-console/utils.ts +0 -56
  63. package/dist/chunk-BWXEQ7ZU.mjs.map +0 -1
  64. package/dist/chunk-JC7QYDYI.mjs.map +0 -1
  65. package/dist/chunk-MNEGEFTI.mjs.map +0 -1
  66. package/dist/chunk-TOCSYTIB.mjs.map +0 -1
  67. package/dist/chunk-VE4TIYL6.mjs.map +0 -1
  68. package/dist/chunk-WCPLXRZX.mjs.map +0 -1
  69. package/dist/chunk-ZIZZGFE2.mjs.map +0 -1
  70. /package/dist/{chunk-6UDD2RWZ.mjs.map → chunk-WOPUCUQK.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,14 +1,17 @@
1
1
  # ui
2
2
 
3
- ## 1.1.1-feat-runtime-remote-actions.0
3
+ ## 1.1.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Remote actions preview
7
+ - - improved documentation
8
+ - center textarea popup
9
+ - show/hide dev console
10
+ - forward maxTokens, stop and force function calling
8
11
  - Updated dependencies
9
- - @copilotkit/runtime-client-gql@1.1.1-feat-runtime-remote-actions.0
10
- - @copilotkit/react-core@1.1.1-feat-runtime-remote-actions.0
11
- - @copilotkit/shared@1.1.1-feat-runtime-remote-actions.0
12
+ - @copilotkit/react-core@1.1.1
13
+ - @copilotkit/runtime-client-gql@1.1.1
14
+ - @copilotkit/shared@1.1.1
12
15
 
13
16
  ## 1.1.0
14
17
 
@@ -13,8 +13,7 @@ import {
13
13
  ActionExecutionMessage,
14
14
  ResultMessage,
15
15
  TextMessage,
16
- Role,
17
- AgentMessage
16
+ Role
18
17
  } from "@copilotkit/runtime-client-gql";
19
18
  import { jsx, jsxs } from "react/jsx-runtime";
20
19
  var Messages = ({ messages, inProgress, children }) => {
@@ -50,16 +49,11 @@ var Messages = ({ messages, inProgress, children }) => {
50
49
  }, [messages]);
51
50
  return /* @__PURE__ */ jsxs("div", { className: "copilotKitMessages", children: [
52
51
  messages.map((message, index) => {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
54
52
  const isCurrentMessage = index === messages.length - 1;
55
53
  if (message instanceof TextMessage && message.role === "user") {
56
54
  return /* @__PURE__ */ jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
57
- } else if (message instanceof AgentMessage && message.role === "user" && ((_c = (_b = (_a = message.state) == null ? void 0 : _a.coagent) == null ? void 0 : _b.execute) == null ? void 0 : _c.name) === "ask" && ((_g = (_f = (_e = (_d = message.state) == null ? void 0 : _d.coagent) == null ? void 0 : _e.execute) == null ? void 0 : _f.result) == null ? void 0 : _g.answer)) {
58
- return /* @__PURE__ */ jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: (_k = (_j = (_i = (_h = message.state) == null ? void 0 : _h.coagent) == null ? void 0 : _i.execute) == null ? void 0 : _j.result) == null ? void 0 : _k.answer }, index);
59
55
  } else if (message instanceof TextMessage && message.role == "assistant") {
60
56
  return /* @__PURE__ */ jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: isCurrentMessage && inProgress && !message.content ? context.icons.spinnerIcon : /* @__PURE__ */ jsx(Markdown, { content: message.content }) }, index);
61
- } else if (message instanceof AgentMessage && message.role === "assistant" && (((_n = (_m = (_l = message.state) == null ? void 0 : _l.coagent) == null ? void 0 : _m.execute) == null ? void 0 : _n.name) === "ask" && ((_r = (_q = (_p = (_o = message.state) == null ? void 0 : _o.coagent) == null ? void 0 : _p.execute) == null ? void 0 : _q.arguments) == null ? void 0 : _r.question) || ((_u = (_t = (_s = message.state) == null ? void 0 : _s.coagent) == null ? void 0 : _t.execute) == null ? void 0 : _u.name) === "message" && ((_y = (_x = (_w = (_v = message.state) == null ? void 0 : _v.coagent) == null ? void 0 : _w.execute) == null ? void 0 : _x.arguments) == null ? void 0 : _y.text))) {
62
- return /* @__PURE__ */ jsx("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: ((_C = (_B = (_A = (_z = message.state) == null ? void 0 : _z.coagent) == null ? void 0 : _A.execute) == null ? void 0 : _B.arguments) == null ? void 0 : _C.question) || ((_G = (_F = (_E = (_D = message.state) == null ? void 0 : _D.coagent) == null ? void 0 : _E.execute) == null ? void 0 : _F.arguments) == null ? void 0 : _G.text) }, index);
63
57
  } else if (message instanceof ActionExecutionMessage) {
64
58
  if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {
65
59
  const render = chatComponentsCache.current[message.name];
@@ -129,4 +123,4 @@ function makeInitialMessages(initial) {
129
123
  export {
130
124
  Messages
131
125
  };
132
- //# sourceMappingURL=chunk-JC7QYDYI.mjs.map
126
+ //# sourceMappingURL=chunk-4Z2WDXSK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Markdown } from \"./Markdown\";\nimport { RenderFunctionStatus, useCopilotContext } from \"@copilotkit/react-core\";\nimport {\n MessageStatusCode,\n ActionExecutionMessage,\n Message,\n ResultMessage,\n TextMessage,\n Role,\n} from \"@copilotkit/runtime-client-gql\";\n\nexport const Messages = ({ messages, inProgress, children }: MessagesProps) => {\n const { chatComponentsCache } = useCopilotContext();\n\n const context = useChatContext();\n const initialMessages = useMemo(\n () => makeInitialMessages(context.labels.initial),\n [context.labels.initial],\n );\n messages = [...initialMessages, ...messages];\n\n const functionResults: Record<string, string> = {};\n\n for (let i = 0; i < messages.length; i++) {\n if (messages[i] instanceof ActionExecutionMessage) {\n const id = messages[i].id;\n const resultMessage: ResultMessage | undefined = messages.find(\n (message) => message instanceof ResultMessage && message.actionExecutionId === id,\n ) as ResultMessage | undefined;\n\n if (resultMessage) {\n functionResults[id] = ResultMessage.decodeResult(resultMessage.result || \"\");\n }\n }\n }\n\n const messagesEndRef = React.useRef<HTMLDivElement>(null);\n\n const scrollToBottom = () => {\n if (messagesEndRef.current) {\n messagesEndRef.current.scrollIntoView({\n behavior: \"auto\",\n });\n }\n };\n\n useEffect(() => {\n scrollToBottom();\n }, [messages]);\n\n return (\n <div className=\"copilotKitMessages\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n\n if (message instanceof TextMessage && message.role === \"user\") {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitUserMessage\">\n {message.content}\n </div>\n );\n } else if (message instanceof TextMessage && message.role == \"assistant\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && !message.content ? (\n context.icons.spinnerIcon\n ) : (\n <Markdown content={message.content} />\n )}\n </div>\n );\n } else if (message instanceof ActionExecutionMessage) {\n if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {\n const render = chatComponentsCache.current[message.name];\n // render a static string\n if (typeof render === \"string\") {\n // when render is static, we show it only when in progress\n if (isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon} <span className=\"inProgressLabel\">{render}</span>\n </div>\n );\n }\n // Done - silent by default to avoid a series of \"done\" messages\n else {\n return null;\n }\n }\n // render is a function\n else {\n const args = message.arguments;\n\n let status: RenderFunctionStatus = \"inProgress\";\n\n if (functionResults[message.id] !== undefined) {\n status = \"complete\";\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n const toRender = render({\n status: status as any,\n args,\n result: functionResults[message.id],\n });\n\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n\n if (typeof toRender === \"string\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && context.icons.spinnerIcon} {toRender}\n </div>\n );\n } else {\n return (\n <div key={index} className=\"copilotKitCustomAssistantMessage\">\n {toRender}\n </div>\n );\n }\n }\n }\n // No render function found- show the default message\n else if (!inProgress || !isCurrentMessage) {\n // Done - silent by default to avoid a series of \"done\" messages\n return null;\n } else {\n // In progress\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon}\n </div>\n );\n }\n }\n })}\n <footer ref={messagesEndRef}>{children}</footer>\n </div>\n );\n};\n\nfunction makeInitialMessages(initial?: string | string[]): Message[] {\n let initialArray: string[] = [];\n if (initial) {\n if (Array.isArray(initial)) {\n initialArray.push(...initial);\n } else {\n initialArray.push(initial);\n }\n }\n\n return initialArray.map(\n (message) =>\n new TextMessage({\n role: Role.Assistant,\n content: message,\n }),\n );\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,SAAS,WAAW,eAAe;AAI1C,SAA+B,yBAAyB;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgDK,cAsBM,YAtBN;AA9CL,IAAM,WAAW,CAAC,EAAE,UAAU,YAAY,SAAS,MAAqB;AAC7E,QAAM,EAAE,oBAAoB,IAAI,kBAAkB;AAElD,QAAM,UAAU,eAAe;AAC/B,QAAM,kBAAkB;AAAA,IACtB,MAAM,oBAAoB,QAAQ,OAAO,OAAO;AAAA,IAChD,CAAC,QAAQ,OAAO,OAAO;AAAA,EACzB;AACA,aAAW,CAAC,GAAG,iBAAiB,GAAG,QAAQ;AAE3C,QAAM,kBAA0C,CAAC;AAEjD,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,QAAI,SAAS,CAAC,aAAa,wBAAwB;AACjD,YAAM,KAAK,SAAS,CAAC,EAAE;AACvB,YAAM,gBAA2C,SAAS;AAAA,QACxD,CAAC,YAAY,mBAAmB,iBAAiB,QAAQ,sBAAsB;AAAA,MACjF;AAEA,UAAI,eAAe;AACjB,wBAAgB,EAAE,IAAI,cAAc,aAAa,cAAc,UAAU,EAAE;AAAA,MAC7E;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,MAAM,OAAuB,IAAI;AAExD,QAAM,iBAAiB,MAAM;AAC3B,QAAI,eAAe,SAAS;AAC1B,qBAAe,QAAQ,eAAe;AAAA,QACpC,UAAU;AAAA,MACZ,CAAC;AAAA,IACH;AAAA,EACF;AAEA,YAAU,MAAM;AACd,mBAAe;AAAA,EACjB,GAAG,CAAC,QAAQ,CAAC;AAEb,SACE,qBAAC,SAAI,WAAU,sB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Ac,QAAQ,MAAM;AAAA,gBAAY;AAAA,gBAAE;AAAA,mBADvD,KAEV;AAAA,YAEJ,OAAO;AACL,qBACE,oBAAC,SAAgB,WAAU,oCACxB,sBADO,KAEV;AAAA,YAEJ;AAAA,UACF;AAAA,QACF,WAES,CAAC,cAAc,CAAC,kBAAkB;AAEzC,iBAAO;AAAA,QACT,OAAO;AAEL,iBACE,oBAAC,SAAgB,WAAW,gDACzB,kBAAQ,MAAM,eADP,KAEV;AAAA,QAEJ;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACD,oBAAC,YAAO,KAAK,gBAAiB,UAAS;AAAA,KACzC;AAEJ;AAEA,SAAS,oBAAoB,SAAwC;AACnE,MAAI,eAAyB,CAAC;AAC9B,MAAI,SAAS;AACX,QAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,mBAAa,KAAK,GAAG,OAAO;AAAA,IAC9B,OAAO;AACL,mBAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,aAAa;AAAA,IAClB,CAAC,YACC,IAAI,YAAY;AAAA,MACd,MAAM,KAAK;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACL;AACF;","names":[]}
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  getPublishedCopilotKitVersion,
3
3
  logActions,
4
- logMessages,
5
4
  logReadables,
6
5
  shouldShowDevConsole
7
- } from "./chunk-BWXEQ7ZU.mjs";
6
+ } from "./chunk-PF5HUDUP.mjs";
8
7
  import {
9
8
  CheckIcon,
10
9
  ChevronDownIcon,
@@ -203,7 +202,6 @@ function DebugMenuButton({
203
202
  children: [
204
203
  /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsx("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
205
204
  /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsx("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
206
- /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsx("button", { className: "copilotKitDebugMenuItem", onClick: () => logMessages(context), children: "Log Messages" }) }),
207
205
  /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsx("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
208
206
  /* @__PURE__ */ jsx("hr", {}),
209
207
  /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsx("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
@@ -217,4 +215,4 @@ export {
217
215
  CopilotDevConsole,
218
216
  DebugMenuButton
219
217
  };
220
- //# sourceMappingURL=chunk-VE4TIYL6.mjs.map
218
+ //# sourceMappingURL=chunk-D6QNFZXK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/dev-console/console.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport {\n getPublishedCopilotKitVersion,\n logActions,\n logReadables,\n shouldShowDevConsole,\n} from \"./utils\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n CheckIcon,\n ChevronDownIcon,\n CopilotKitIcon,\n ExclamationMarkIcon,\n ExclamationMarkTriangleIcon,\n} from \"./icons\";\nimport { Menu, MenuButton, MenuItem, MenuItems } from \"@headlessui/react\";\nimport { COPILOTKIT_VERSION } from \"@copilotkit/shared\";\nimport { SmallSpinnerIcon } from \"../chat/Icons\";\n\ntype VersionStatus = \"unknown\" | \"checking\" | \"latest\" | \"update-available\" | \"outdated\";\n\nexport function CopilotDevConsole() {\n const currentVersion = COPILOTKIT_VERSION;\n const context = useCopilotContext();\n\n // to prevent hydration errors, ensure that the component renders the same content\n // server-side as it does during the initial client-side render to prevent a hydration\n // mismatch\n // see: https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only\n\n const [showDevConsole, setShowDevConsole] = useState(false);\n\n useEffect(() => {\n setShowDevConsole(shouldShowDevConsole(context.showDevConsole));\n }, [context.showDevConsole]);\n\n const dontRunTwiceInDevMode = useRef(false);\n const [versionStatus, setVersionStatus] = useState<VersionStatus>(\"unknown\");\n const [latestVersion, setLatestVersion] = useState<string>(\"\");\n const consoleRef = useRef<HTMLDivElement>(null);\n const [debugButtonMode, setDebugButtonMode] = useState<\"full\" | \"compact\">(\"full\");\n\n const checkForUpdates = (force: boolean = false) => {\n setVersionStatus(\"checking\");\n\n getPublishedCopilotKitVersion(currentVersion, force)\n .then((v) => {\n setLatestVersion(v.latest);\n let versionOk = false;\n\n // match exact version or a version with a letter (e.g. 1.0.0-alpha.1)\n if (v.current === v.latest) {\n versionOk = true;\n } else if (/[a-zA-Z]/.test(v.current)) {\n versionOk = true;\n }\n\n if (versionOk) {\n setVersionStatus(\"latest\");\n } else if (v.severity !== \"low\") {\n setVersionStatus(\"outdated\");\n } else {\n setVersionStatus(\"update-available\");\n }\n })\n .catch((e) => {\n console.error(e);\n setVersionStatus(\"unknown\");\n });\n };\n\n useEffect(() => {\n if (dontRunTwiceInDevMode.current === true) {\n return;\n }\n dontRunTwiceInDevMode.current = true;\n\n checkForUpdates();\n }, []);\n\n useEffect(() => {\n const handleResize = (entries: ResizeObserverEntry[]) => {\n for (let entry of entries) {\n if (entry.target === consoleRef.current) {\n const width = entry.contentRect.width;\n if (width < 400) {\n setDebugButtonMode(\"compact\");\n } else {\n setDebugButtonMode(\"full\");\n }\n }\n }\n };\n\n const observer = new ResizeObserver(handleResize);\n if (consoleRef.current) {\n observer.observe(consoleRef.current);\n\n const initialWidth = consoleRef.current.getBoundingClientRect().width;\n if (initialWidth < 400) {\n setDebugButtonMode(\"compact\");\n } else {\n setDebugButtonMode(\"full\");\n }\n }\n\n return () => {\n if (consoleRef.current) {\n observer.unobserve(consoleRef.current);\n }\n };\n }, [consoleRef.current]);\n\n if (!showDevConsole) {\n return null;\n }\n return (\n <div\n ref={consoleRef}\n className={\n \"copilotKitDevConsole \" +\n (versionStatus === \"update-available\" ? \"copilotKitDevConsoleUpgrade\" : \"\") +\n (versionStatus === \"outdated\" ? \"copilotKitDevConsoleWarnOutdated\" : \"\")\n }\n >\n <div className=\"copilotKitDevConsoleLogo\">\n <a href=\"https://copilotkit.ai\" target=\"_blank\">\n {CopilotKitIcon}\n </a>\n </div>\n <VersionInfo\n showDevConsole={context.showDevConsole}\n versionStatus={versionStatus}\n currentVersion={currentVersion}\n latestVersion={latestVersion}\n />\n\n <DebugMenuButton\n setShowDevConsole={setShowDevConsole}\n checkForUpdates={checkForUpdates}\n mode={debugButtonMode}\n />\n </div>\n );\n}\n\nfunction VersionInfo({\n showDevConsole,\n versionStatus,\n currentVersion,\n latestVersion,\n}: {\n showDevConsole: boolean | \"auto\";\n versionStatus: VersionStatus;\n currentVersion: string;\n latestVersion: string;\n}) {\n const [copyStatus, setCopyStatus] = useState<string>(\"\");\n\n let versionLabel = \"\";\n let versionIcon: any = \"\";\n let currentVersionLabel = currentVersion;\n\n if (versionStatus === \"latest\") {\n versionLabel = \"latest\";\n versionIcon = CheckIcon;\n } else if (versionStatus === \"checking\") {\n versionLabel = \"checking\";\n versionIcon = SmallSpinnerIcon;\n } else if (versionStatus === \"update-available\") {\n versionLabel = \"update available\";\n versionIcon = ExclamationMarkIcon;\n currentVersionLabel = `${currentVersion} → ${latestVersion}`;\n } else if (versionStatus === \"outdated\") {\n versionLabel = \"outdated\";\n versionIcon = ExclamationMarkTriangleIcon;\n currentVersionLabel = `${currentVersion} → ${latestVersion}`;\n }\n\n let asideLabel = \"\";\n if (showDevConsole === \"auto\") {\n asideLabel = \"(localhost only)\";\n } else if (showDevConsole === true) {\n asideLabel = \"(always on)\";\n }\n\n const installCommand = [\n `npm install`,\n `@copilotkit/react-core@${latestVersion}`,\n `@copilotkit/react-ui@${latestVersion}`,\n `@copilotkit/react-textarea@${latestVersion}`,\n ].join(\" \");\n\n const handleCopyClick = () => {\n navigator.clipboard.writeText(installCommand.trim()).then(() => {\n setCopyStatus(\"Command copied to clipboard!\");\n setTimeout(() => setCopyStatus(\"\"), 1000);\n });\n };\n\n return (\n <div className=\"copilotKitVersionInfo\">\n <header>\n COPILOTKIT DEV CONSOLE{showDevConsole === \"auto\" && <aside>{asideLabel}</aside>}\n </header>\n <section>\n Version: {versionLabel} ({currentVersionLabel}) {versionIcon}\n </section>\n {(versionStatus === \"update-available\" || versionStatus === \"outdated\") && (\n <footer>\n <button onClick={handleCopyClick}>{copyStatus || installCommand}</button>\n </footer>\n )}\n </div>\n );\n}\nexport default function DebugMenuButton({\n setShowDevConsole,\n checkForUpdates,\n mode,\n}: {\n setShowDevConsole: (show: boolean) => void;\n checkForUpdates: (force: boolean) => void;\n mode: \"full\" | \"compact\";\n}) {\n const context = useCopilotContext();\n\n return (\n <div className=\"bg-black fixed top-24 w-52 text-right\">\n <Menu>\n <MenuButton className={`copilotKitDebugMenuButton ${mode === \"compact\" ? \"compact\" : \"\"}`}>\n {mode == \"compact\" ? \"Debug\" : <>Debug {ChevronDownIcon}</>}\n </MenuButton>\n\n <MenuItems\n transition\n anchor=\"bottom end\"\n className=\"copilotKitDebugMenu\"\n style={{ zIndex: 40 }}\n >\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => logReadables(context)}>\n Log Readables\n </button>\n </MenuItem>\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => logActions(context)}>\n Log Actions\n </button>\n </MenuItem>\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => checkForUpdates(true)}>\n Check for Updates\n </button>\n </MenuItem>\n <hr />\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => setShowDevConsole(false)}>\n Hide Dev Console\n </button>\n </MenuItem>\n </MenuItems>\n </Menu>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB;AAOlC,SAAS,WAAW,QAAQ,gBAAgB;AAQ5C,SAAS,MAAM,YAAY,UAAU,iB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WAAU,yCACb,+BAAC,QACC;AAAA,wBAAC,cAAW,WAAW,6BAA6B,SAAS,YAAY,YAAY,MAClF,kBAAQ,YAAY,UAAU,iCAAE;AAAA;AAAA,MAAO;AAAA,OAAgB,GAC1D;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,YAAU;AAAA,QACV,QAAO;AAAA,QACP,WAAU;AAAA,QACV,OAAO,EAAE,QAAQ,GAAG;AAAA,QAEpB;AAAA,8BAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,aAAa,OAAO,GAAG,2BAElF,GACF;AAAA,UACA,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,WAAW,OAAO,GAAG,yBAEhF,GACF;AAAA,UACA,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,gBAAgB,IAAI,GAAG,+BAElF,GACF;AAAA,UACA,oBAAC,QAAG;AAAA,UACJ,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,kBAAkB,KAAK,GAAG,8BAErF,GACF;AAAA;AAAA;AAAA,IACF;AAAA,KACF,GACF;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-6UDD2RWZ.mjs";
3
+ } from "./chunk-WOPUCUQK.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-TOCSYTIB.mjs.map
21
+ //# sourceMappingURL=chunk-EJ4SJ2HU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Popup.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotPopup.gif\" width=\"500\" />\n *\n * A chatbot popup component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * See [CopilotSidebar](/reference/components/CopilotSidebar) for a sidebar version of this component.\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 * ## Usage\n *\n * ```tsx\n * import { CopilotPopup } from \"@copilotkit/react-ui\";\n *\n * <CopilotPopup\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx fileName=\"YourRootComponent.tsx\" {2}\n * ...\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.\n */\n\nimport { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotPopup(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitPopup\" : \"copilotKitPopup\",\n };\n return <CopilotModal {...props}>{props.children}</CopilotModal>;\n}\n"],"mappings":";;;;;;;;;AAsDS;AALF,SAAS,aAAa,OAA0B;AACrD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,qBAAqB;AAAA,EACtE;AACA,SAAO,oBAAC,+CAAiB,QAAjB,EAAyB,gBAAM,WAAS;AAClD;","names":[]}
@@ -103,4 +103,4 @@ export {
103
103
  Suggestion,
104
104
  reloadSuggestions
105
105
  };
106
- //# sourceMappingURL=chunk-WCPLXRZX.mjs.map
106
+ //# sourceMappingURL=chunk-KSCXPA74.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\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 || \"suggestion\"}\n >\n {partial && SmallSpinnerIcon}\n <span>{title}</span>\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams,\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 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 config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions,\n data: \"Available tools: \" + tools + \"\\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"],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,OAEK;AAIP,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AAI/B,SASE,KATF;AAFG,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,aAAa;AAAA,MAEvB;AAAA,mBAAW;AAAA,QACZ,oBAAC,UAAM,iBAAM;AAAA;AAAA;AAAA,EACf;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,U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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":[]}
@@ -4,8 +4,6 @@ import {
4
4
 
5
5
  // src/components/dev-console/utils.ts
6
6
  import { defaultCopilotContextCategories } from "@copilotkit/react-core";
7
- import { ActionExecutionMessage, ResultMessage, TextMessage } from "@copilotkit/runtime-client-gql";
8
- import { AgentMessage } from "@copilotkit/runtime-client-gql";
9
7
  function shouldShowDevConsole(showDevConsole) {
10
8
  if (typeof showDevConsole === "boolean") {
11
9
  return showDevConsole;
@@ -66,7 +64,6 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
66
64
  });
67
65
  }
68
66
  function logReadables(context) {
69
- console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
70
67
  const readables = context.getContextString([], defaultCopilotContextCategories).trim();
71
68
  if (readables.length === 0) {
72
69
  console.log("No readables found");
@@ -75,7 +72,6 @@ function logReadables(context) {
75
72
  console.log(readables);
76
73
  }
77
74
  function logActions(context) {
78
- console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
79
75
  if (Object.values(context.actions).length === 0) {
80
76
  console.log("No actions found");
81
77
  return;
@@ -88,59 +84,11 @@ function logActions(context) {
88
84
  console.groupEnd();
89
85
  }
90
86
  }
91
- function logMessages(context) {
92
- console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
93
- if (context.messages.length === 0) {
94
- console.log("No messages found");
95
- return;
96
- }
97
- const tableData = context.messages.map((message) => {
98
- if (message instanceof TextMessage) {
99
- return {
100
- id: message.id,
101
- type: "TextMessage",
102
- role: message.role,
103
- name: void 0,
104
- scope: void 0,
105
- content: message.content
106
- };
107
- } else if (message instanceof ActionExecutionMessage) {
108
- return {
109
- id: message.id,
110
- type: "ActionExecutionMessage",
111
- role: void 0,
112
- name: message.name,
113
- scope: message.scope,
114
- content: message.arguments
115
- };
116
- } else if (message instanceof ResultMessage) {
117
- return {
118
- id: message.id,
119
- type: "ResultMessage",
120
- role: void 0,
121
- name: message.actionName,
122
- scope: message.actionExecutionId,
123
- content: message.result
124
- };
125
- } else if (message instanceof AgentMessage) {
126
- return {
127
- id: message.id,
128
- type: `AgentMessage (running: ${message.running})`,
129
- role: message.role,
130
- name: message.agentName,
131
- scope: message.threadId,
132
- content: message.state
133
- };
134
- }
135
- });
136
- console.table(tableData);
137
- }
138
87
 
139
88
  export {
140
89
  shouldShowDevConsole,
141
90
  getPublishedCopilotKitVersion,
142
91
  logReadables,
143
- logActions,
144
- logMessages
92
+ logActions
145
93
  };
146
- //# sourceMappingURL=chunk-BWXEQ7ZU.mjs.map
94
+ //# sourceMappingURL=chunk-PF5HUDUP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/dev-console/utils.ts"],"sourcesContent":["import { CopilotContextParams, defaultCopilotContextCategories } from \"@copilotkit/react-core\";\nimport { CopilotKitVersion } from \"./types\";\n\nexport function shouldShowDevConsole(showDevConsole: boolean | \"auto\"): boolean {\n if (typeof showDevConsole === \"boolean\") {\n return showDevConsole;\n }\n return (\n getHostname() === \"localhost\" ||\n getHostname() === \"127.0.0.1\" ||\n getHostname() === \"0.0.0.0\" ||\n getHostname() === \"::1\"\n );\n}\n\nfunction getHostname(): string {\n if (typeof window !== \"undefined\" && window.location) {\n return window.location.hostname;\n }\n return \"\";\n}\n\nexport async function getPublishedCopilotKitVersion(\n current: string,\n forceCheck: boolean = false,\n): Promise<CopilotKitVersion> {\n const LOCAL_STORAGE_KEY = \"__copilotkit_version_check__\";\n const serializedVersion = localStorage.getItem(LOCAL_STORAGE_KEY);\n if (serializedVersion && !forceCheck) {\n try {\n const parsedVersion: CopilotKitVersion = JSON.parse(serializedVersion);\n const oneHour = 60 * 60 * 1000;\n const now = new Date().getTime();\n\n if (\n parsedVersion.current === current &&\n now - new Date(parsedVersion.lastChecked).getTime() < oneHour\n ) {\n return parsedVersion;\n }\n } catch (error) {\n console.error(\"Failed to parse CopilotKitVersion from localStorage\", error);\n }\n }\n\n try {\n const response = await fetch(\"https://api.cloud.stagingcopilotkit.ai/check-for-updates\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n packages: [\n {\n packageName: \"@copilotkit/shared\",\n packageVersion: current,\n },\n ],\n }),\n });\n\n const data = await response.json();\n\n const version: CopilotKitVersion = {\n current,\n lastChecked: new Date().getTime(),\n latest: data.packages[0].latestVersion,\n severity: data.packages[0].severity,\n advisory: data.packages[0].advisory || null,\n };\n\n localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(version));\n return version;\n } catch (error) {\n console.error(\"Failed to check for updates\", error);\n throw error;\n }\n}\n\nexport function logReadables(context: CopilotContextParams) {\n const readables = context.getContextString([], defaultCopilotContextCategories).trim();\n if (readables.length === 0) {\n console.log(\"No readables found\");\n return;\n }\n console.log(readables);\n}\n\nexport function logActions(context: CopilotContextParams) {\n if (Object.values(context.actions).length === 0) {\n console.log(\"No actions found\");\n return;\n }\n for (const action of Object.values(context.actions)) {\n console.group(action.name);\n console.log(\"name\", action.name);\n console.log(\"description\", action.description);\n console.log(\"parameters\", action.parameters);\n\n console.groupEnd();\n }\n}\n"],"mappings":";;;;;AAAA,SAA+B,uCAAuC;AAG/D,SAAS,qBAAqB,gBAA2C;AAC9E,MAAI,OAAO,mBAAmB,WAAW;AACvC,WAAO;AAAA,EACT;AACA,SACE,YAAY,MAAM,eAClB,YAAY,MAAM,eAClB,YAAY,MAAM,aAClB,YAAY,MAAM;AAEtB;AAEA,SAAS,cAAsB;AAC7B,MAAI,OAAO,WAAW,eAAe,OAAO,UAAU;AACpD,WAAO,OAAO,SAAS;AAAA,EACzB;AACA,SAAO;AACT;AAEA,SAAsB,8BACpB,SACA,aAAsB,OACM;AAAA;AA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Q,IAAI,oBAAoB;AAChC;AAAA,EACF;AACA,UAAQ,IAAI,SAAS;AACvB;AAEO,SAAS,WAAW,SAA+B;AACxD,MAAI,OAAO,OAAO,QAAQ,OAAO,EAAE,WAAW,GAAG;AAC/C,YAAQ,IAAI,kBAAkB;AAC9B;AAAA,EACF;AACA,aAAW,UAAU,OAAO,OAAO,QAAQ,OAAO,GAAG;AACnD,YAAQ,MAAM,OAAO,IAAI;AACzB,YAAQ,IAAI,QAAQ,OAAO,IAAI;AAC/B,YAAQ,IAAI,eAAe,OAAO,WAAW;AAC7C,YAAQ,IAAI,cAAc,OAAO,UAAU;AAE3C,YAAQ,SAAS;AAAA,EACnB;AACF;","names":[]}
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Suggestion,
3
3
  reloadSuggestions
4
- } from "./chunk-WCPLXRZX.mjs";
4
+ } from "./chunk-KSCXPA74.mjs";
5
5
  import {
6
6
  CopilotDevConsole
7
- } from "./chunk-VE4TIYL6.mjs";
7
+ } from "./chunk-D6QNFZXK.mjs";
8
8
  import {
9
9
  Input
10
10
  } from "./chunk-U6J5DGOE.mjs";
11
11
  import {
12
12
  Messages
13
- } from "./chunk-JC7QYDYI.mjs";
13
+ } from "./chunk-4Z2WDXSK.mjs";
14
14
  import {
15
15
  ResponseButton
16
16
  } from "./chunk-XSUSSWDS.mjs";
@@ -19,14 +19,13 @@ import {
19
19
  ChatContextProvider
20
20
  } from "./chunk-BJPGMY3I.mjs";
21
21
  import {
22
- __async,
23
- __spreadValues
22
+ __async
24
23
  } from "./chunk-MRXNTQOX.mjs";
25
24
 
26
25
  // src/components/chat/Chat.tsx
27
26
  import React, { useEffect, useRef, useState } from "react";
28
27
  import { useCopilotChat, useCopilotContext } from "@copilotkit/react-core";
29
- import { Role, TextMessage, AgentMessage } from "@copilotkit/runtime-client-gql";
28
+ import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
30
29
  import { randomId } from "@copilotkit/shared";
31
30
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
32
31
  function CopilotChat({
@@ -134,7 +133,6 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
134
133
  };
135
134
  }, [isLoading, context.chatSuggestionConfiguration]);
136
135
  const sendMessage = (messageContent) => __async(void 0, null, function* () {
137
- var _a;
138
136
  abortSuggestions();
139
137
  setCurrentSuggestions([]);
140
138
  const message = new TextMessage({
@@ -149,30 +147,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
149
147
  console.error("Error in onSubmitMessage:", error);
150
148
  }
151
149
  }
152
- const [lastMessage] = visibleMessages.slice(-1);
153
- if (lastMessage instanceof AgentMessage) {
154
- const newState = __spreadValues({}, lastMessage.state);
155
- newState.coagent || (newState.coagent = {});
156
- (_a = newState.coagent).execute || (_a.execute = { name: "ask" });
157
- newState.coagent.execute.result = { answer: messageContent };
158
- const message2 = new AgentMessage({
159
- role: Role.User,
160
- agentName: lastMessage.agentName,
161
- nodeName: lastMessage.nodeName,
162
- state: newState,
163
- running: lastMessage.running,
164
- threadId: lastMessage.threadId
165
- });
166
- appendMessage(message2);
167
- return message2;
168
- } else {
169
- const message2 = new TextMessage({
170
- content: messageContent,
171
- role: Role.User
172
- });
173
- appendMessage(message2);
174
- return message2;
175
- }
150
+ return message;
176
151
  });
177
152
  return {
178
153
  visibleMessages,
@@ -189,4 +164,4 @@ export {
189
164
  WrappedCopilotChat,
190
165
  useCopilotChatLogic
191
166
  };
192
- //# sourceMappingURL=chunk-ZIZZGFE2.mjs.map
167
+ //# sourceMappingURL=chunk-SWWFXRFF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotChat.gif\" width=\"500\" />\n *\n * A chatbot panel component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\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 * ## Usage\n *\n * ```tsx\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx fileName=\"YourRootComponent.tsx\" {2}\n * ...\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.\n */\n\nimport {\n ChatContext,\n ChatContextProvider,\n CopilotChatIcons,\n CopilotChatLabels,\n} from \"./ChatContext\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { ResponseButton as DefaultResponseButton } from \"./Response\";\nimport { Suggestion } from \"./Suggestion\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SystemMessageFunction, useCopilotChat, useCopilotContext } from \"@copilotkit/react-core\";\nimport { reloadSuggestions } from \"./Suggestion\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { InputProps, MessagesProps, ResponseButtonProps } from \"./props\";\nimport { randomId } from \"@copilotkit/shared\";\n\nimport { CopilotDevConsole } from \"../dev-console\";\n\n/**\n * Props for CopilotChat component.\n */\nexport interface CopilotChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * A callback that gets called when the in progress state changes.\n */\n onInProgress?: (inProgress: boolean) => void;\n\n /**\n * A callback that gets called when a new message it submitted.\n */\n onSubmitMessage?: (message: string) => void | Promise<void>;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotChatLabels;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * Whether to show the response button.\n * @default true\n */\n showResponseButton?: boolean;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom ResponseButton component to use instead of the default.\n */\n ResponseButton?: React.ComponentType<ResponseButtonProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n\n /**\n * Children to render.\n */\n children?: React.ReactNode;\n}\n\nexport function CopilotChat({\n instructions,\n onSubmitMessage,\n makeSystemMessage,\n showResponseButton = true,\n onInProgress,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n icons,\n labels,\n}: CopilotChatProps) {\n const context = useCopilotContext();\n\n useEffect(() => {\n context.setChatInstructions(instructions || \"\");\n }, [instructions]);\n\n const {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <CopilotDevConsole />\n <Messages messages={visibleMessages} inProgress={isLoading}>\n {currentSuggestions.length > 0 && (\n <div>\n <h6>Suggested:</h6>\n <div className=\"suggestions\">\n {currentSuggestions.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={(message) => sendMessage(message)}\n />\n ))}\n </div>\n </div>\n )}\n {showResponseButton && visibleMessages.length > 0 && (\n <ResponseButton\n onClick={isLoading ? stopGeneration : reloadMessages}\n inProgress={isLoading}\n />\n )}\n </Messages>\n <Input inProgress={isLoading} onSend={sendMessage} isVisible={isVisible} />\n </WrappedCopilotChat>\n );\n}\n\nexport function WrappedCopilotChat({\n children,\n icons,\n labels,\n className,\n}: {\n children: React.ReactNode;\n icons?: CopilotChatIcons;\n labels?: CopilotChatLabels;\n className?: string;\n}) {\n const chatContext = React.useContext(ChatContext);\n if (!chatContext) {\n return (\n <ChatContextProvider icons={icons} labels={labels} open={true} setOpen={() => {}}>\n <div className={`copilotKitChat ${className}`}>{children}</div>\n </ChatContextProvider>\n );\n }\n return <>{children}</>;\n}\n\nconst SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;\n\nexport const useCopilotChatLogic = (\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => void,\n) => {\n const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } =\n useCopilotChat({\n id: randomId(),\n makeSystemMessage,\n });\n\n const [currentSuggestions, setCurrentSuggestions] = useState<CopilotChatSuggestion[]>([]);\n const suggestionsAbortControllerRef = useRef<AbortController | null>(null);\n const debounceTimerRef = useRef<any>();\n\n const abortSuggestions = () => {\n suggestionsAbortControllerRef.current?.abort();\n suggestionsAbortControllerRef.current = null;\n };\n\n const context = useCopilotContext();\n\n useEffect(() => {\n onInProgress?.(isLoading);\n\n abortSuggestions();\n\n debounceTimerRef.current = setTimeout(\n () => {\n if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {\n suggestionsAbortControllerRef.current = new AbortController();\n reloadSuggestions(\n context,\n context.chatSuggestionConfiguration,\n setCurrentSuggestions,\n suggestionsAbortControllerRef,\n );\n }\n },\n currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT,\n );\n\n return () => {\n clearTimeout(debounceTimerRef.current);\n };\n }, [isLoading, context.chatSuggestionConfiguration]);\n\n const sendMessage = async (messageContent: string) => {\n abortSuggestions();\n setCurrentSuggestions([]);\n\n const message: Message = new TextMessage({\n content: messageContent,\n role: Role.User,\n });\n\n // Append the message immediately to make it visible\n appendMessage(message);\n\n if (onSubmitMessage) {\n try {\n await onSubmitMessage(messageContent);\n } catch (error) {\n console.error(\"Error in onSubmitMessage:\", error);\n }\n }\n\n return message;\n };\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAgC,gBAAgB,yBAAyB;AAGzE,SAAkB,MAAM,mBAAmB;AAE3C,SAAS,gBAAgB;AA+GnB,SAkDG,UAlDH,KAGI,YAHJ;AAjCC,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AACnB,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,YAAQ,oBAAoB,gBAAgB,EAAE;AAAA,EAChD,GAAG,CAAC,YAAY,CAAC;AAEjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,oBAAoB,mBAAmB,cAAc,eAAe;AAExE,QAAM,cAAc,MAAM,WAAW,WAAW;AAChD,QAAM,YAAY,cAAc,YAAY,OAAO;AAEnD,SACE,qBAAC,sBAAmB,OAAc,QAAgB,WAChD;AAAA,w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QAAM,mBAAmB,OAAY;AAErC,QAAM,mBAAmB,MAAM;AAnPjC;AAoPI,wCAA8B,YAA9B,mBAAuC;AACvC,kCAA8B,UAAU;AAAA,EAC1C;AAEA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,iDAAe;AAEf,qBAAiB;AAEjB,qBAAiB,UAAU;AAAA,MACzB,MAAM;AACJ,YAAI,CAAC,aAAa,OAAO,KAAK,QAAQ,2BAA2B,EAAE,WAAW,GAAG;AAC/E,wCAA8B,UAAU,IAAI,gBAAgB;AAC5D;AAAA,YACE;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,mBAAmB,UAAU,IAAI,IAAI;AAAA,IACvC;AAEA,WAAO,MAAM;AACX,mBAAa,iBAAiB,OAAO;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,2BAA2B,CAAC;AAEnD,QAAM,cAAc,CAAO,mBAA2B;AACpD,qBAAiB;AACjB,0BAAsB,CAAC,CAAC;AAExB,UAAM,UAAmB,IAAI,YAAY;AAAA,MACvC,SAAS;AAAA,MACT,MAAM,KAAK;AAAA,IACb,CAAC;AAGD,kBAAc,OAAO;AAErB,QAAI,iBAAiB;AACnB,UAAI;AACF,cAAM,gBAAgB,cAAc;AAAA,MACtC,SAAS,OAAP;AACA,gBAAQ,MAAM,6BAA6B,KAAK;AAAA,MAClD;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["Messages","Input","ResponseButton"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-6UDD2RWZ.mjs";
3
+ } from "./chunk-WOPUCUQK.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
27
27
  export {
28
28
  CopilotSidebar
29
29
  };
30
- //# sourceMappingURL=chunk-MNEGEFTI.mjs.map
30
+ //# sourceMappingURL=chunk-UJHTRHS4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Sidebar.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotSidebar.gif\" width=\"500\" />\n *\n * A chatbot sidebar component for the CopilotKit framework. Highly customizable through various props and custom CSS.\n *\n * See [CopilotPopup](/reference/components/CopilotPopup) for a popup version of this component.\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 * ## Usage\n *\n * ```tsx\n * import { CopilotSidebar } from \"@copilotkit/react-ui\";\n *\n * <CopilotSidebar\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * >\n * <YourApp/>\n * </CopilotSidebar>\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx fileName=\"YourRootComponent.tsx\" {2}\n * ...\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.\n */\nimport React, { useState } from \"react\";\nimport { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotSidebar(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitSidebar\" : \"copilotKitSidebar\",\n };\n const [expandedClassName, setExpandedClassName] = useState(\n props.defaultOpen ? \"sidebarExpanded\" : \"\",\n );\n\n const onSetOpen = (open: boolean) => {\n props.onSetOpen?.(open);\n setExpandedClassName(open ? \"sidebarExpanded\" : \"\");\n };\n\n return (\n <div className={`copilotKitSidebarContentWrapper ${expandedClassName}`}>\n <CopilotModal {...props} {...{ onSetOpen }}>\n {props.children}\n </CopilotModal>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAgDA,SAAgB,gBAAgB;AAmB1B;AAhBC,SAAS,eAAe,OAA0B;AACvD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,uBAAuB;AAAA,EACxE;AACA,QAAM,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,MAAM,cAAc,oBAAoB;AAAA,EAC1C;AAEA,QAAM,YAAY,CAAC,SAAkB;AA5DvC;AA6DI,gBAAM,cAAN,+BAAkB;AAClB,yBAAqB,OAAO,oBAAoB,EAAE;AAAA,EACpD;AAEA,SACE,oBAAC,SAAI,WAAW,mCAAmC,qBACjD,8BAAC,8DAAiB,QAAW,EAAE,UAAU,IAAxC,EACE,gBAAM,WACT,GACF;AAEJ;","names":[]}
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-UC3Y7MWX.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-ZIZZGFE2.mjs";
12
+ } from "./chunk-SWWFXRFF.mjs";
13
13
  import {
14
14
  Input
15
15
  } from "./chunk-U6J5DGOE.mjs";
16
16
  import {
17
17
  Messages
18
- } from "./chunk-JC7QYDYI.mjs";
18
+ } from "./chunk-4Z2WDXSK.mjs";
19
19
  import {
20
20
  ResponseButton
21
21
  } from "./chunk-XSUSSWDS.mjs";
@@ -90,4 +90,4 @@ var CopilotModal = ({
90
90
  export {
91
91
  CopilotModal
92
92
  };
93
- //# sourceMappingURL=chunk-6UDD2RWZ.mjs.map
93
+ //# sourceMappingURL=chunk-WOPUCUQK.mjs.map
@@ -12,7 +12,15 @@ import { MessagesProps, InputProps, ResponseButtonProps } from './props.js';
12
12
  * A chatbot panel component for the CopilotKit framework. The component allows for a high degree
13
13
  * of customization through various props and custom CSS.
14
14
  *
15
- * ## Example
15
+ * ## Install Dependencies
16
+ *
17
+ * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
18
+ *
19
+ * ```shell npm2yarn \"@copilotkit/react-ui"\
20
+ * npm install @copilotkit/react-core @copilotkit/react-ui
21
+ * ```
22
+ *
23
+ * ## Usage
16
24
  *
17
25
  * ```tsx
18
26
  * import { CopilotChat } from "@copilotkit/react-ui";
@@ -25,44 +33,22 @@ import { MessagesProps, InputProps, ResponseButtonProps } from './props.js';
25
33
  * />
26
34
  * ```
27
35
  *
28
- * ## Usage
29
- *
30
- * ### Install Dependencies
31
- *
32
- * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
33
- *
34
- * ```shell npm2yarn \"@copilotkit/react-ui"\
35
- * npm install @copilotkit/react-core @copilotkit/react-ui
36
- * ```
37
- *
38
- * ### Custom Styles
39
- *
40
- * To opt-in for the built-in styles, make sure to import the following at the root of your application:
36
+ * ### Look & Feel
41
37
  *
42
- * ```tsx
38
+ * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
39
+ * ```tsx fileName="YourRootComponent.tsx" {2}
40
+ * ...
43
41
  * import "@copilotkit/react-ui/styles.css";
44
- * ```
45
- *
46
- * You can customize the colors of the panel by overriding the CSS variables
47
- * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).
48
42
  *
49
- * For example, to set the primary color to purple:
50
- *
51
- * ```tsx
52
- * <div style={{ "--copilot-kit-primary-color": "#7D5BA6" }}>
53
- * <CopilotPopup />
54
- * </div>
55
- * ```
56
- *
57
- * To further customize the chat window, you can override the CSS classes defined
58
- * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).
59
- *
60
- * For example:
61
- *
62
- * ```css
63
- * .copilotKitButton {
64
- * border-radius: 0;
43
+ * export function YourRootComponent() {
44
+ * return (
45
+ * <CopilotKit>
46
+ * ...
47
+ * </CopilotKit>
48
+ * );
65
49
  * }
50
+ * ```
51
+ * For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.
66
52
  */
67
53
 
68
54
  /**
@@ -134,7 +120,7 @@ declare function WrappedCopilotChat({ children, icons, labels, className, }: {
134
120
  labels?: CopilotChatLabels;
135
121
  className?: string;
136
122
  }): JSX.Element;
137
- declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: ((isLoading: boolean) => void) | undefined, onSubmitMessage?: ((messageContent: string) => Promise<void> | void) | undefined) => {
123
+ declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: ((isLoading: boolean) => void) | undefined, onSubmitMessage?: ((messageContent: string) => void) | undefined) => {
138
124
  visibleMessages: Message[];
139
125
  isLoading: boolean;
140
126
  currentSuggestions: CopilotChatSuggestion[];