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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/dist/{chunk-YVBDAURK.mjs → chunk-2TSNHEIS.mjs} +6 -6
  3. package/dist/chunk-2TSNHEIS.mjs.map +1 -0
  4. package/dist/{chunk-DF4YG4PF.mjs → chunk-3RHHNUVV.mjs} +2 -2
  5. package/dist/{chunk-LNAQ7JG3.mjs → chunk-6EKLRL7B.mjs} +2 -2
  6. package/dist/{chunk-O5KV32S5.mjs → chunk-ADZDXHVC.mjs} +2 -2
  7. package/dist/{chunk-4CFY3CON.mjs → chunk-CLMDRYEN.mjs} +2 -2
  8. package/dist/{chunk-G35QHAQ6.mjs → chunk-COEUPDRL.mjs} +20 -21
  9. package/dist/chunk-COEUPDRL.mjs.map +1 -0
  10. package/dist/{chunk-RGKZCCPA.mjs → chunk-DLEXVOQE.mjs} +5 -5
  11. package/dist/{chunk-YAF2LATQ.mjs → chunk-EFL5OBKN.mjs} +1 -1
  12. package/dist/chunk-EFL5OBKN.mjs.map +1 -0
  13. package/dist/{chunk-JWAXDYOW.mjs → chunk-FAUNHSQU.mjs} +3 -3
  14. package/dist/chunk-ICIK2BSB.mjs +17 -0
  15. package/dist/chunk-ICIK2BSB.mjs.map +1 -0
  16. package/dist/chunk-IHAZJF3V.mjs +34 -0
  17. package/dist/chunk-IHAZJF3V.mjs.map +1 -0
  18. package/dist/{chunk-Q6FZZJ5A.mjs → chunk-IN7GE4NO.mjs} +2 -2
  19. package/dist/{chunk-YSQ5I2AE.mjs → chunk-JBLMXZ3O.mjs} +7 -7
  20. package/dist/{chunk-PZXTDFMX.mjs → chunk-JJDXTTEN.mjs} +3 -3
  21. package/dist/chunk-KDAZGZ24.mjs +1 -0
  22. package/dist/{chunk-LIGLZ53V.mjs → chunk-L6HQIJ74.mjs} +29 -13
  23. package/dist/chunk-L6HQIJ74.mjs.map +1 -0
  24. package/dist/{chunk-NAM55D5I.mjs → chunk-LVWV62JZ.mjs} +39 -26
  25. package/dist/chunk-LVWV62JZ.mjs.map +1 -0
  26. package/dist/{chunk-3OQM3NEK.mjs → chunk-N4WEHORG.mjs} +2 -2
  27. package/dist/chunk-OKRZF3DD.mjs +225 -0
  28. package/dist/chunk-OKRZF3DD.mjs.map +1 -0
  29. package/dist/{chunk-SJJNFYGQ.mjs → chunk-Q42NJFXR.mjs} +9 -14
  30. package/dist/chunk-Q42NJFXR.mjs.map +1 -0
  31. package/dist/chunk-QGE7U4NV.mjs +85 -0
  32. package/dist/chunk-QGE7U4NV.mjs.map +1 -0
  33. package/dist/{chunk-XGRBCWK6.mjs → chunk-TEMLWRRT.mjs} +3 -3
  34. package/dist/chunk-TEMLWRRT.mjs.map +1 -0
  35. package/dist/{chunk-YBDRISKO.mjs → chunk-TWYUYC4F.mjs} +43 -9
  36. package/dist/chunk-TWYUYC4F.mjs.map +1 -0
  37. package/dist/{chunk-LU5JPZ24.mjs → chunk-X2DNXTME.mjs} +6 -6
  38. package/dist/chunk-X2DNXTME.mjs.map +1 -0
  39. package/dist/{chunk-DCTJZ742.mjs → chunk-ZLQVRPDS.mjs} +5 -2
  40. package/dist/chunk-ZLQVRPDS.mjs.map +1 -0
  41. package/dist/components/copilot-provider/copilot-messages.d.ts +17 -1
  42. package/dist/components/copilot-provider/copilot-messages.js +46 -7
  43. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  44. package/dist/components/copilot-provider/copilot-messages.mjs +11 -7
  45. package/dist/components/copilot-provider/copilotkit-props.d.ts +5 -3
  46. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  47. package/dist/components/copilot-provider/copilotkit.d.ts +1 -2
  48. package/dist/components/copilot-provider/copilotkit.js +337 -555
  49. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  50. package/dist/components/copilot-provider/copilotkit.mjs +11 -11
  51. package/dist/components/copilot-provider/index.d.ts +1 -2
  52. package/dist/components/copilot-provider/index.js +337 -555
  53. package/dist/components/copilot-provider/index.js.map +1 -1
  54. package/dist/components/copilot-provider/index.mjs +11 -11
  55. package/dist/components/error-boundary/error-boundary.js +176 -323
  56. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  57. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  58. package/dist/components/error-boundary/error-utils.js.map +1 -1
  59. package/dist/components/error-boundary/error-utils.mjs +2 -2
  60. package/dist/components/index.d.ts +1 -2
  61. package/dist/components/index.js +337 -555
  62. package/dist/components/index.js.map +1 -1
  63. package/dist/components/index.mjs +11 -11
  64. package/dist/components/toast/toast-provider.js.map +1 -1
  65. package/dist/components/toast/toast-provider.mjs +1 -1
  66. package/dist/components/usage-banner.d.ts +10 -4
  67. package/dist/components/usage-banner.js +176 -302
  68. package/dist/components/usage-banner.js.map +1 -1
  69. package/dist/components/usage-banner.mjs +3 -1
  70. package/dist/context/copilot-context.d.ts +1 -2
  71. package/dist/context/copilot-context.js +2 -2
  72. package/dist/context/copilot-context.js.map +1 -1
  73. package/dist/context/copilot-context.mjs +1 -1
  74. package/dist/context/copilot-messages-context.d.ts +11 -15
  75. package/dist/context/copilot-messages-context.js +4 -1
  76. package/dist/context/copilot-messages-context.js.map +1 -1
  77. package/dist/context/copilot-messages-context.mjs +1 -1
  78. package/dist/context/index.d.ts +2 -2
  79. package/dist/context/index.js +6 -3
  80. package/dist/context/index.js.map +1 -1
  81. package/dist/context/index.mjs +2 -2
  82. package/dist/{copilot-context-bd88d30d.d.ts → copilot-context-256f9020.d.ts} +4 -22
  83. package/dist/hooks/index.d.ts +7 -5
  84. package/dist/hooks/index.js +250 -122
  85. package/dist/hooks/index.js.map +1 -1
  86. package/dist/hooks/index.mjs +32 -24
  87. package/dist/hooks/use-chat.d.ts +1 -2
  88. package/dist/hooks/use-chat.js +11 -3
  89. package/dist/hooks/use-chat.js.map +1 -1
  90. package/dist/hooks/use-chat.mjs +6 -6
  91. package/dist/hooks/use-coagent-state-render.js +2 -2
  92. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  93. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  94. package/dist/hooks/use-coagent.d.ts +4 -5
  95. package/dist/hooks/use-coagent.js +114 -81
  96. package/dist/hooks/use-coagent.js.map +1 -1
  97. package/dist/hooks/use-coagent.mjs +15 -15
  98. package/dist/hooks/use-copilot-action.d.ts +1 -1
  99. package/dist/hooks/use-copilot-action.js +2 -2
  100. package/dist/hooks/use-copilot-action.js.map +1 -1
  101. package/dist/hooks/use-copilot-action.mjs +4 -4
  102. package/dist/hooks/use-copilot-additional-instructions.js +2 -2
  103. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  104. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  105. package/dist/hooks/use-copilot-authenticated-action.js +2 -2
  106. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  107. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  108. package/dist/hooks/use-copilot-chat-headless_c.d.ts +33 -0
  109. package/dist/hooks/use-copilot-chat-headless_c.js +1837 -0
  110. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
  111. package/dist/hooks/use-copilot-chat-headless_c.mjs +31 -0
  112. package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
  113. package/dist/hooks/use-copilot-chat.d.ts +52 -82
  114. package/dist/hooks/use-copilot-chat.js +60 -13
  115. package/dist/hooks/use-copilot-chat.js.map +1 -1
  116. package/dist/hooks/use-copilot-chat.mjs +15 -16
  117. package/dist/hooks/use-copilot-chat_internal.d.ts +177 -0
  118. package/dist/hooks/use-copilot-chat_internal.js +1770 -0
  119. package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
  120. package/dist/hooks/use-copilot-chat_internal.mjs +29 -0
  121. package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
  122. package/dist/hooks/use-copilot-readable.js +2 -2
  123. package/dist/hooks/use-copilot-readable.js.map +1 -1
  124. package/dist/hooks/use-copilot-readable.mjs +2 -2
  125. package/dist/hooks/use-copilot-runtime-client.js +9 -1
  126. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  127. package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
  128. package/dist/hooks/use-langgraph-interrupt-render.js +2 -2
  129. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  130. package/dist/hooks/use-langgraph-interrupt-render.mjs +3 -3
  131. package/dist/hooks/use-langgraph-interrupt.d.ts +3 -4
  132. package/dist/hooks/use-langgraph-interrupt.js +32 -11
  133. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  134. package/dist/hooks/use-langgraph-interrupt.mjs +15 -15
  135. package/dist/hooks/use-make-copilot-document-readable.js +2 -2
  136. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  137. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  138. package/dist/index-08c43df1.d.ts +36 -0
  139. package/dist/index.d.ts +5 -3
  140. package/dist/index.js +460 -471
  141. package/dist/index.js.map +1 -1
  142. package/dist/index.mjs +34 -26
  143. package/dist/lib/copilot-task.d.ts +1 -2
  144. package/dist/lib/copilot-task.js.map +1 -1
  145. package/dist/lib/copilot-task.mjs +12 -12
  146. package/dist/lib/index.d.ts +1 -2
  147. package/dist/lib/index.js.map +1 -1
  148. package/dist/lib/index.mjs +12 -12
  149. package/dist/types/interrupt-action.d.ts +2 -3
  150. package/dist/utils/dev-console.d.ts +1 -1
  151. package/dist/utils/dev-console.js +9 -1
  152. package/dist/utils/dev-console.js.map +1 -1
  153. package/dist/utils/dev-console.mjs +1 -1
  154. package/dist/utils/extract.d.ts +2 -2
  155. package/dist/utils/extract.js.map +1 -1
  156. package/dist/utils/extract.mjs +11 -11
  157. package/dist/utils/index.d.ts +3 -3
  158. package/dist/utils/index.js +9 -1
  159. package/dist/utils/index.js.map +1 -1
  160. package/dist/utils/index.mjs +11 -11
  161. package/dist/utils/suggestions.d.ts +2 -2
  162. package/dist/utils/suggestions.js.map +1 -1
  163. package/dist/utils/suggestions.mjs +11 -11
  164. package/package.json +3 -3
  165. package/src/components/copilot-provider/copilot-messages.tsx +57 -1
  166. package/src/components/copilot-provider/copilotkit-props.tsx +4 -1
  167. package/src/components/copilot-provider/copilotkit.tsx +20 -10
  168. package/src/components/error-boundary/error-boundary.tsx +5 -15
  169. package/src/components/toast/toast-provider.tsx +1 -3
  170. package/src/components/usage-banner.tsx +193 -316
  171. package/src/context/copilot-context.tsx +12 -6
  172. package/src/context/copilot-messages-context.tsx +7 -1
  173. package/src/hooks/__tests__/use-coagent-config.test.ts +8 -1
  174. package/src/hooks/index.ts +7 -2
  175. package/src/hooks/use-coagent.ts +18 -20
  176. package/src/hooks/use-copilot-action.ts +1 -1
  177. package/src/hooks/use-copilot-chat-headless_c.ts +187 -0
  178. package/src/hooks/use-copilot-chat.ts +64 -495
  179. package/src/hooks/use-copilot-chat_internal.ts +543 -0
  180. package/src/hooks/use-langgraph-interrupt.ts +1 -1
  181. package/src/utils/dev-console.ts +18 -2
  182. package/dist/chunk-57K2ZJ5F.mjs +0 -348
  183. package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
  184. package/dist/chunk-CQPYJIBH.mjs +0 -1
  185. package/dist/chunk-DCTJZ742.mjs.map +0 -1
  186. package/dist/chunk-G35QHAQ6.mjs.map +0 -1
  187. package/dist/chunk-GFJW4RIM.mjs +0 -9
  188. package/dist/chunk-GFJW4RIM.mjs.map +0 -1
  189. package/dist/chunk-LIGLZ53V.mjs.map +0 -1
  190. package/dist/chunk-LU5JPZ24.mjs.map +0 -1
  191. package/dist/chunk-NAM55D5I.mjs.map +0 -1
  192. package/dist/chunk-SJJNFYGQ.mjs.map +0 -1
  193. package/dist/chunk-XGRBCWK6.mjs.map +0 -1
  194. package/dist/chunk-YAF2LATQ.mjs.map +0 -1
  195. package/dist/chunk-YBDRISKO.mjs.map +0 -1
  196. package/dist/chunk-YVBDAURK.mjs.map +0 -1
  197. /package/dist/{chunk-DF4YG4PF.mjs.map → chunk-3RHHNUVV.mjs.map} +0 -0
  198. /package/dist/{chunk-LNAQ7JG3.mjs.map → chunk-6EKLRL7B.mjs.map} +0 -0
  199. /package/dist/{chunk-O5KV32S5.mjs.map → chunk-ADZDXHVC.mjs.map} +0 -0
  200. /package/dist/{chunk-4CFY3CON.mjs.map → chunk-CLMDRYEN.mjs.map} +0 -0
  201. /package/dist/{chunk-RGKZCCPA.mjs.map → chunk-DLEXVOQE.mjs.map} +0 -0
  202. /package/dist/{chunk-JWAXDYOW.mjs.map → chunk-FAUNHSQU.mjs.map} +0 -0
  203. /package/dist/{chunk-Q6FZZJ5A.mjs.map → chunk-IN7GE4NO.mjs.map} +0 -0
  204. /package/dist/{chunk-YSQ5I2AE.mjs.map → chunk-JBLMXZ3O.mjs.map} +0 -0
  205. /package/dist/{chunk-PZXTDFMX.mjs.map → chunk-JJDXTTEN.mjs.map} +0 -0
  206. /package/dist/{chunk-CQPYJIBH.mjs.map → chunk-KDAZGZ24.mjs.map} +0 -0
  207. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-N4WEHORG.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -98,7 +98,9 @@ __export(src_exports, {
98
98
  useCopilotAction: () => useCopilotAction,
99
99
  useCopilotAdditionalInstructions: () => useCopilotAdditionalInstructions,
100
100
  useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c,
101
- useCopilotChat: () => useCopilotChat,
101
+ useCopilotChat: () => useCopilotChat2,
102
+ useCopilotChatHeadless_c: () => useCopilotChatHeadless_c,
103
+ useCopilotChatInternal: () => useCopilotChat,
102
104
  useCopilotContext: () => useCopilotContext,
103
105
  useCopilotMessagesContext: () => useCopilotMessagesContext,
104
106
  useCopilotReadable: () => useCopilotReadable,
@@ -187,8 +189,8 @@ var emptyCopilotContext = {
187
189
  setLangGraphInterruptAction: () => null,
188
190
  removeLangGraphInterruptAction: () => null,
189
191
  onError: void 0,
190
- suggestions: [],
191
- setSuggestions: () => {
192
+ bannerError: null,
193
+ setBannerError: () => {
192
194
  }
193
195
  };
194
196
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
@@ -414,7 +416,10 @@ var import_react6 = require("react");
414
416
  var import_react4 = __toESM(require("react"));
415
417
  var emptyCopilotContext2 = {
416
418
  messages: [],
417
- setMessages: () => []
419
+ setMessages: () => [],
420
+ // suggestions state
421
+ suggestions: [],
422
+ setSuggestions: () => []
418
423
  };
419
424
  var CopilotMessagesContext = import_react4.default.createContext(emptyCopilotContext2);
420
425
  function useCopilotMessagesContext() {
@@ -731,18 +736,44 @@ function ToastProvider({
731
736
  }
732
737
 
733
738
  // src/utils/dev-console.ts
739
+ function isLocalhost() {
740
+ if (typeof window === "undefined")
741
+ return false;
742
+ return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0";
743
+ }
734
744
  function shouldShowDevConsole(showDevConsole) {
735
- return showDevConsole;
745
+ if (showDevConsole !== void 0) {
746
+ return showDevConsole;
747
+ }
748
+ return isLocalhost();
736
749
  }
737
750
 
738
751
  // src/components/copilot-provider/copilot-messages.tsx
739
752
  var import_shared4 = require("@copilotkit/shared");
740
753
  var import_jsx_runtime2 = require("react/jsx-runtime");
754
+ var MessagesTapContext = (0, import_react6.createContext)(null);
755
+ function useMessagesTap() {
756
+ const tap = (0, import_react6.useContext)(MessagesTapContext);
757
+ if (!tap)
758
+ throw new Error("useMessagesTap must be used inside <MessagesTapProvider>");
759
+ return tap;
760
+ }
761
+ function MessagesTapProvider({ children }) {
762
+ const messagesRef = (0, import_react6.useRef)([]);
763
+ const tapRef = (0, import_react6.useRef)({
764
+ getMessagesFromTap: () => messagesRef.current,
765
+ updateTapMessages: (messages) => {
766
+ messagesRef.current = messages;
767
+ }
768
+ });
769
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MessagesTapContext.Provider, { value: tapRef.current, children });
770
+ }
741
771
  function CopilotMessages({ children }) {
742
772
  const [messages, setMessages] = (0, import_react6.useState)([]);
743
773
  const lastLoadedThreadId = (0, import_react6.useRef)();
744
774
  const lastLoadedAgentName = (0, import_react6.useRef)();
745
775
  const lastLoadedMessages = (0, import_react6.useRef)();
776
+ const { updateTapMessages } = useMessagesTap();
746
777
  const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
747
778
  const { setBannerError } = useToast();
748
779
  const traceUIError = (0, import_react6.useCallback)(
@@ -879,23 +910,230 @@ function CopilotMessages({ children }) {
879
910
  });
880
911
  void fetchMessages();
881
912
  }, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
913
+ (0, import_react6.useEffect)(() => {
914
+ updateTapMessages(messages);
915
+ }, [messages, updateTapMessages]);
882
916
  const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
917
+ const [suggestions, setSuggestions] = (0, import_react6.useState)([]);
883
918
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
884
919
  CopilotMessagesContext.Provider,
885
920
  {
886
921
  value: {
887
922
  messages,
888
- setMessages
923
+ setMessages,
924
+ suggestions,
925
+ setSuggestions
889
926
  },
890
927
  children: memoizedChildren
891
928
  }
892
929
  );
893
930
  }
894
931
 
932
+ // src/components/usage-banner.tsx
933
+ var import_shared5 = require("@copilotkit/shared");
934
+ var import_jsx_runtime3 = require("react/jsx-runtime");
935
+ function UsageBanner({
936
+ severity = import_shared5.Severity.CRITICAL,
937
+ message = "",
938
+ onClose,
939
+ actions
940
+ }) {
941
+ if (!message || !severity) {
942
+ return null;
943
+ }
944
+ const themes = {
945
+ [import_shared5.Severity.INFO]: {
946
+ bg: "#f8fafc",
947
+ border: "#e2e8f0",
948
+ text: "#475569",
949
+ accent: "#3b82f6"
950
+ },
951
+ [import_shared5.Severity.WARNING]: {
952
+ bg: "#fffbeb",
953
+ border: "#fbbf24",
954
+ text: "#92400e",
955
+ accent: "#f59e0b"
956
+ },
957
+ [import_shared5.Severity.CRITICAL]: {
958
+ bg: "#fef2f2",
959
+ border: "#fecaca",
960
+ text: "#dc2626",
961
+ accent: "#ef4444"
962
+ }
963
+ };
964
+ const theme = themes[severity];
965
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
966
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
967
+ @keyframes slideUp {
968
+ from { opacity: 0; transform: translateX(-50%) translateY(8px); }
969
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
970
+ }
971
+
972
+ .usage-banner {
973
+ position: fixed;
974
+ bottom: 24px;
975
+ left: 50%;
976
+ transform: translateX(-50%);
977
+ width: min(600px, calc(100vw - 32px));
978
+ z-index: 10000;
979
+ animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
980
+ }
981
+
982
+ .banner-content {
983
+ background: linear-gradient(135deg, ${theme.bg} 0%, ${theme.bg}f5 100%);
984
+ border: 1px solid ${theme.border};
985
+ border-radius: 12px;
986
+ padding: 18px 20px;
987
+ box-shadow:
988
+ 0 4px 24px rgba(0, 0, 0, 0.08),
989
+ 0 2px 8px rgba(0, 0, 0, 0.04),
990
+ inset 0 1px 0 rgba(255, 255, 255, 0.7);
991
+ display: flex;
992
+ align-items: center;
993
+ gap: 16px;
994
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
995
+ backdrop-filter: blur(12px);
996
+ position: relative;
997
+ overflow: hidden;
998
+ }
999
+
1000
+ .banner-content::before {
1001
+ content: '';
1002
+ position: absolute;
1003
+ top: 0;
1004
+ left: 0;
1005
+ right: 0;
1006
+ height: 1px;
1007
+ background: linear-gradient(90deg, transparent, ${theme.accent}40, transparent);
1008
+ }
1009
+
1010
+ .banner-message {
1011
+ color: ${theme.text};
1012
+ font-size: 14px;
1013
+ line-height: 1.5;
1014
+ font-weight: 500;
1015
+ flex: 1;
1016
+ letter-spacing: -0.01em;
1017
+ }
1018
+
1019
+ .close-btn {
1020
+ background: rgba(0, 0, 0, 0.05);
1021
+ border: none;
1022
+ color: ${theme.text};
1023
+ cursor: pointer;
1024
+ padding: 0;
1025
+ border-radius: 6px;
1026
+ opacity: 0.6;
1027
+ transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
1028
+ font-size: 14px;
1029
+ line-height: 1;
1030
+ flex-shrink: 0;
1031
+ width: 24px;
1032
+ height: 24px;
1033
+ display: flex;
1034
+ align-items: center;
1035
+ justify-content: center;
1036
+ }
1037
+
1038
+ .close-btn:hover {
1039
+ opacity: 1;
1040
+ background: rgba(0, 0, 0, 0.08);
1041
+ transform: scale(1.05);
1042
+ }
1043
+
1044
+ .btn-primary {
1045
+ background: linear-gradient(135deg, ${theme.accent} 0%, ${theme.accent}e6 100%);
1046
+ color: white;
1047
+ border: none;
1048
+ border-radius: 8px;
1049
+ padding: 10px 18px;
1050
+ font-size: 13px;
1051
+ font-weight: 600;
1052
+ cursor: pointer;
1053
+ transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
1054
+ font-family: inherit;
1055
+ flex-shrink: 0;
1056
+ box-shadow:
1057
+ 0 2px 8px ${theme.accent}30,
1058
+ inset 0 1px 0 rgba(255, 255, 255, 0.2);
1059
+ letter-spacing: -0.01em;
1060
+ }
1061
+
1062
+ .btn-primary:hover {
1063
+ transform: translateY(-1px) scale(1.02);
1064
+ box-shadow:
1065
+ 0 4px 12px ${theme.accent}40,
1066
+ inset 0 1px 0 rgba(255, 255, 255, 0.25);
1067
+ }
1068
+
1069
+ .btn-primary:active {
1070
+ transform: translateY(0) scale(0.98);
1071
+ transition: all 0.08s cubic-bezier(0.16, 1, 0.3, 1);
1072
+ }
1073
+
1074
+ @media (max-width: 640px) {
1075
+ .usage-banner {
1076
+ width: calc(100vw - 24px);
1077
+ }
1078
+
1079
+ .banner-content {
1080
+ padding: 16px;
1081
+ gap: 12px;
1082
+ }
1083
+
1084
+ .banner-message {
1085
+ font-size: 13px;
1086
+ line-height: 1.45;
1087
+ }
1088
+
1089
+ .btn-primary {
1090
+ padding: 8px 14px;
1091
+ font-size: 12px;
1092
+ }
1093
+
1094
+ .close-btn {
1095
+ width: 22px;
1096
+ height: 22px;
1097
+ font-size: 12px;
1098
+ }
1099
+ }
1100
+ ` }),
1101
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "usage-banner", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "banner-content", children: [
1102
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "banner-message", children: message }),
1103
+ (actions == null ? void 0 : actions.primary) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "btn-primary", onClick: actions.primary.onClick, children: actions.primary.label }),
1104
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "close-btn", onClick: onClose, title: "Close", children: "\xD7" })
1105
+ ] }) })
1106
+ ] });
1107
+ }
1108
+ var getErrorActions = (error) => {
1109
+ switch (error.code) {
1110
+ case import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR:
1111
+ return {
1112
+ primary: {
1113
+ label: "Show me how",
1114
+ onClick: () => window.open(
1115
+ "https://docs.copilotkit.ai/docs/guides/subscription",
1116
+ "_blank",
1117
+ "noopener,noreferrer"
1118
+ )
1119
+ }
1120
+ };
1121
+ case import_shared5.CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR:
1122
+ return {
1123
+ primary: {
1124
+ label: "Upgrade",
1125
+ onClick: () => window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer")
1126
+ }
1127
+ };
1128
+ default:
1129
+ return void 0;
1130
+ }
1131
+ };
1132
+
895
1133
  // src/hooks/use-copilot-runtime-client.ts
896
1134
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
897
1135
  var import_react7 = require("react");
898
- var import_shared5 = require("@copilotkit/shared");
1136
+ var import_shared6 = require("@copilotkit/shared");
899
1137
  var useCopilotRuntimeClient = (options) => {
900
1138
  const { setBannerError } = useToast();
901
1139
  const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
@@ -937,7 +1175,7 @@ var useCopilotRuntimeClient = (options) => {
937
1175
  const extensions = gqlError.extensions;
938
1176
  const visibility = extensions == null ? void 0 : extensions.visibility;
939
1177
  const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
940
- if (visibility === import_shared5.ErrorVisibility.SILENT) {
1178
+ if (visibility === import_shared6.ErrorVisibility.SILENT) {
941
1179
  console.error("CopilotKit Silent Error:", gqlError.message);
942
1180
  return;
943
1181
  }
@@ -956,9 +1194,9 @@ var useCopilotRuntimeClient = (options) => {
956
1194
  setBannerError(ckError);
957
1195
  traceUIError(ckError, gqlError);
958
1196
  } else {
959
- const fallbackError = new import_shared5.CopilotKitError({
1197
+ const fallbackError = new import_shared6.CopilotKitError({
960
1198
  message: gqlError.message,
961
- code: import_shared5.CopilotKitErrorCode.UNKNOWN
1199
+ code: import_shared6.CopilotKitErrorCode.UNKNOWN
962
1200
  });
963
1201
  setBannerError(fallbackError);
964
1202
  traceUIError(fallbackError, gqlError);
@@ -970,9 +1208,9 @@ var useCopilotRuntimeClient = (options) => {
970
1208
  if (!isDev) {
971
1209
  console.error("CopilotKit Error (hidden in production):", error);
972
1210
  } else {
973
- const fallbackError = new import_shared5.CopilotKitError({
1211
+ const fallbackError = new import_shared6.CopilotKitError({
974
1212
  message: (error == null ? void 0 : error.message) || String(error),
975
- code: import_shared5.CopilotKitErrorCode.UNKNOWN
1213
+ code: import_shared6.CopilotKitErrorCode.UNKNOWN
976
1214
  });
977
1215
  setBannerError(fallbackError);
978
1216
  traceUIError(fallbackError, error);
@@ -981,9 +1219,9 @@ var useCopilotRuntimeClient = (options) => {
981
1219
  },
982
1220
  handleGQLWarning: (message) => {
983
1221
  console.warn(message);
984
- const warningError = new import_shared5.CopilotKitError({
1222
+ const warningError = new import_shared6.CopilotKitError({
985
1223
  message,
986
- code: import_shared5.CopilotKitErrorCode.UNKNOWN
1224
+ code: import_shared6.CopilotKitErrorCode.UNKNOWN
987
1225
  });
988
1226
  setBannerError(warningError);
989
1227
  }
@@ -998,16 +1236,16 @@ function createStructuredError(gqlError) {
998
1236
  const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
999
1237
  const code = extensions == null ? void 0 : extensions.code;
1000
1238
  if (code) {
1001
- return new import_shared5.CopilotKitError({ message, code });
1239
+ return new import_shared6.CopilotKitError({ message, code });
1002
1240
  }
1003
1241
  if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
1004
- return new import_shared5.CopilotKitApiDiscoveryError({ message });
1242
+ return new import_shared6.CopilotKitApiDiscoveryError({ message });
1005
1243
  }
1006
1244
  if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
1007
- return new import_shared5.CopilotKitRemoteEndpointDiscoveryError({ message });
1245
+ return new import_shared6.CopilotKitRemoteEndpointDiscoveryError({ message });
1008
1246
  }
1009
1247
  if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
1010
- return new import_shared5.CopilotKitAgentDiscoveryError({
1248
+ return new import_shared6.CopilotKitAgentDiscoveryError({
1011
1249
  agentName: "",
1012
1250
  availableAgents: []
1013
1251
  });
@@ -1016,7 +1254,7 @@ function createStructuredError(gqlError) {
1016
1254
  }
1017
1255
 
1018
1256
  // src/utils/extract.ts
1019
- var import_shared6 = require("@copilotkit/shared");
1257
+ var import_shared7 = require("@copilotkit/shared");
1020
1258
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
1021
1259
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
1022
1260
  function extract(_0) {
@@ -1065,7 +1303,7 @@ function extract(_0) {
1065
1303
  {
1066
1304
  name: action.name,
1067
1305
  description: action.description || "",
1068
- jsonSchema: JSON.stringify((0, import_shared6.actionParametersToJsonSchema)(action.parameters || []))
1306
+ jsonSchema: JSON.stringify((0, import_shared7.actionParametersToJsonSchema)(action.parameters || []))
1069
1307
  }
1070
1308
  ],
1071
1309
  url: window.location.href
@@ -1150,7 +1388,7 @@ This is not a conversation, so please do not ask questions. Just call the functi
1150
1388
  }
1151
1389
 
1152
1390
  // src/utils/suggestions.ts
1153
- var import_shared7 = require("@copilotkit/shared");
1391
+ var import_shared8 = require("@copilotkit/shared");
1154
1392
  var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
1155
1393
  var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
1156
1394
  const abortController = abortControllerRef.current;
@@ -1167,7 +1405,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
1167
1405
  Object.values(context.actions).map((action) => ({
1168
1406
  name: action.name,
1169
1407
  description: action.description,
1170
- jsonSchema: JSON.stringify((0, import_shared7.actionParametersToJsonSchema)(action.parameters))
1408
+ jsonSchema: JSON.stringify((0, import_shared8.actionParametersToJsonSchema)(action.parameters))
1171
1409
  }))
1172
1410
  );
1173
1411
  const allSuggestions = [];
@@ -1294,7 +1532,7 @@ var import_react9 = __toESM(require("react"));
1294
1532
  var import_shared10 = require("@copilotkit/shared");
1295
1533
 
1296
1534
  // src/lib/status-checker.ts
1297
- var import_shared8 = require("@copilotkit/shared");
1535
+ var import_shared9 = require("@copilotkit/shared");
1298
1536
  var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
1299
1537
  var StatusChecker = class {
1300
1538
  constructor() {
@@ -1312,10 +1550,10 @@ var StatusChecker = class {
1312
1550
  clearInterval(this.intervalId);
1313
1551
  const checkStatus = () => __async(this, null, function* () {
1314
1552
  try {
1315
- const response = yield fetch(`${import_shared8.COPILOT_CLOUD_API_URL}/ciu`, {
1553
+ const response = yield fetch(`${import_shared9.COPILOT_CLOUD_API_URL}/ciu`, {
1316
1554
  method: "GET",
1317
1555
  headers: {
1318
- [import_shared8.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
1556
+ [import_shared9.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
1319
1557
  }
1320
1558
  }).then((response2) => response2.json());
1321
1559
  this.lastResponse = response;
@@ -1347,349 +1585,6 @@ var StatusChecker = class {
1347
1585
  }
1348
1586
  };
1349
1587
 
1350
- // src/components/usage-banner.tsx
1351
- var import_shared9 = require("@copilotkit/shared");
1352
- var import_jsx_runtime3 = require("react/jsx-runtime");
1353
- var defaultIcons = {
1354
- [import_shared9.Severity.CRITICAL]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1355
- "svg",
1356
- {
1357
- viewBox: "0 0 24 24",
1358
- width: "16",
1359
- height: "16",
1360
- stroke: "currentColor",
1361
- strokeWidth: "2.5",
1362
- fill: "none",
1363
- strokeLinecap: "round",
1364
- strokeLinejoin: "round",
1365
- children: [
1366
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1367
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
1368
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
1369
- ]
1370
- }
1371
- ),
1372
- [import_shared9.Severity.WARNING]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1373
- "svg",
1374
- {
1375
- viewBox: "0 0 24 24",
1376
- width: "16",
1377
- height: "16",
1378
- stroke: "currentColor",
1379
- strokeWidth: "2.5",
1380
- fill: "none",
1381
- strokeLinecap: "round",
1382
- strokeLinejoin: "round",
1383
- children: [
1384
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
1385
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
1386
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
1387
- ]
1388
- }
1389
- ),
1390
- [import_shared9.Severity.INFO]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1391
- "svg",
1392
- {
1393
- viewBox: "0 0 24 24",
1394
- width: "16",
1395
- height: "16",
1396
- stroke: "currentColor",
1397
- strokeWidth: "2.5",
1398
- fill: "none",
1399
- strokeLinecap: "round",
1400
- strokeLinejoin: "round",
1401
- children: [
1402
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1403
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
1404
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
1405
- ]
1406
- }
1407
- )
1408
- };
1409
- function UsageBanner({
1410
- severity = import_shared9.Severity.CRITICAL,
1411
- message = "",
1412
- icon,
1413
- onClose,
1414
- actions
1415
- }) {
1416
- if (!message || !severity) {
1417
- return null;
1418
- }
1419
- const parseMessage = (rawMessage) => {
1420
- if (rawMessage.toLowerCase().includes("authentication") || rawMessage.toLowerCase().includes("api key")) {
1421
- return "Authentication failed. Please check your API key.";
1422
- }
1423
- if (rawMessage.toLowerCase().includes("rate limit")) {
1424
- return "Rate limit exceeded. Please try again later.";
1425
- }
1426
- if (rawMessage.toLowerCase().includes("checkpointer")) {
1427
- return "Agent configuration error. Please check your setup.";
1428
- }
1429
- let cleanMessage2 = rawMessage;
1430
- cleanMessage2 = cleanMessage2.split(" - ")[0];
1431
- cleanMessage2 = cleanMessage2.split(": Error code")[0];
1432
- cleanMessage2 = cleanMessage2.split(": 401")[0];
1433
- cleanMessage2 = cleanMessage2.split(": 403")[0];
1434
- cleanMessage2 = cleanMessage2.split(": 404")[0];
1435
- cleanMessage2 = cleanMessage2.split(": 500")[0];
1436
- cleanMessage2 = cleanMessage2.replace(/See more:.*$/g, "").trim();
1437
- if (cleanMessage2.includes("{") || cleanMessage2.includes("'") || cleanMessage2.length > 60) {
1438
- return "Configuration error. Please check your setup.";
1439
- }
1440
- return cleanMessage2 || "An error occurred. Please check your configuration.";
1441
- };
1442
- const cleanMessage = parseMessage(message);
1443
- const Icon = icon || defaultIcons[severity];
1444
- const themeConfigs = {
1445
- [import_shared9.Severity.INFO]: {
1446
- bg: "rgba(239, 246, 255, 0.95)",
1447
- border: "#93c5fd",
1448
- text: "#1e40af",
1449
- icon: "#3b82f6",
1450
- primaryBtn: "#3b82f6",
1451
- primaryBtnHover: "#2563eb"
1452
- },
1453
- [import_shared9.Severity.WARNING]: {
1454
- bg: "rgba(255, 251, 235, 0.95)",
1455
- border: "#fbbf24",
1456
- text: "#92400e",
1457
- icon: "#f59e0b",
1458
- primaryBtn: "#f59e0b",
1459
- primaryBtnHover: "#d97706"
1460
- },
1461
- [import_shared9.Severity.CRITICAL]: {
1462
- bg: "rgba(254, 242, 242, 0.95)",
1463
- border: "#f87171",
1464
- text: "#991b1b",
1465
- icon: "#ef4444",
1466
- primaryBtn: "#ef4444",
1467
- primaryBtnHover: "#dc2626"
1468
- }
1469
- };
1470
- const themeConfig = themeConfigs[severity] || themeConfigs[import_shared9.Severity.CRITICAL];
1471
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1472
- "div",
1473
- {
1474
- style: {
1475
- position: "fixed",
1476
- bottom: "24px",
1477
- left: "50%",
1478
- transform: "translateX(-50%)",
1479
- width: "400px",
1480
- maxWidth: "90vw",
1481
- zIndex: 1e4,
1482
- animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
1483
- },
1484
- children: [
1485
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1486
- @keyframes bannerSlideIn {
1487
- from {
1488
- opacity: 0;
1489
- transform: translateX(-50%) translateY(20px);
1490
- scale: 0.95;
1491
- }
1492
- to {
1493
- opacity: 1;
1494
- transform: translateX(-50%) translateY(0);
1495
- scale: 1;
1496
- }
1497
- }
1498
- ` }),
1499
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1500
- "div",
1501
- {
1502
- style: {
1503
- borderRadius: "12px",
1504
- border: `1px solid ${themeConfig.border}`,
1505
- background: themeConfig.bg,
1506
- padding: "14px",
1507
- boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
1508
- position: "relative",
1509
- backdropFilter: "blur(12px)",
1510
- WebkitBackdropFilter: "blur(12px)",
1511
- boxSizing: "border-box",
1512
- overflow: "hidden"
1513
- },
1514
- children: [
1515
- onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1516
- "button",
1517
- {
1518
- onClick: onClose,
1519
- style: {
1520
- position: "absolute",
1521
- top: "8px",
1522
- right: "8px",
1523
- background: "rgba(255, 255, 255, 0.9)",
1524
- border: "none",
1525
- color: themeConfig.text,
1526
- cursor: "pointer",
1527
- fontSize: "16px",
1528
- lineHeight: "1",
1529
- padding: "4px",
1530
- borderRadius: "4px",
1531
- width: "20px",
1532
- height: "20px",
1533
- display: "flex",
1534
- alignItems: "center",
1535
- justifyContent: "center"
1536
- },
1537
- title: "Close",
1538
- children: "\xD7"
1539
- }
1540
- ),
1541
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1542
- "div",
1543
- {
1544
- style: {
1545
- fontSize: "14px",
1546
- fontWeight: 500,
1547
- color: themeConfig.text,
1548
- lineHeight: "1.4",
1549
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
1550
- paddingRight: onClose ? "30px" : "0",
1551
- marginBottom: actions ? "12px" : "0",
1552
- wordBreak: "break-word",
1553
- overflow: "hidden",
1554
- textOverflow: "ellipsis",
1555
- display: "-webkit-box",
1556
- WebkitLineClamp: 2,
1557
- WebkitBoxOrient: "vertical"
1558
- },
1559
- children: cleanMessage
1560
- }
1561
- ),
1562
- actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1563
- "div",
1564
- {
1565
- style: {
1566
- display: "flex",
1567
- gap: "8px",
1568
- flexWrap: "wrap"
1569
- },
1570
- children: [
1571
- actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1572
- "button",
1573
- {
1574
- onClick: actions.secondary.onClick,
1575
- style: {
1576
- borderRadius: "8px",
1577
- padding: "6px 12px",
1578
- fontSize: "13px",
1579
- fontWeight: 500,
1580
- color: themeConfig.text,
1581
- backgroundColor: "rgba(255, 255, 255, 0.9)",
1582
- border: `1px solid ${themeConfig.border}`,
1583
- cursor: "pointer",
1584
- transition: "all 0.2s ease",
1585
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1586
- },
1587
- onMouseOver: (e) => {
1588
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1589
- e.currentTarget.style.transform = "translateY(-1px)";
1590
- },
1591
- onMouseOut: (e) => {
1592
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
1593
- e.currentTarget.style.transform = "translateY(0)";
1594
- },
1595
- children: actions.secondary.label
1596
- }
1597
- ),
1598
- actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1599
- "button",
1600
- {
1601
- onClick: actions.primary.onClick,
1602
- style: {
1603
- borderRadius: "8px",
1604
- padding: "6px 12px",
1605
- fontSize: "13px",
1606
- fontWeight: 600,
1607
- color: "#fff",
1608
- backgroundColor: themeConfig.primaryBtn,
1609
- border: "none",
1610
- cursor: "pointer",
1611
- transition: "all 0.2s ease",
1612
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
1613
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1614
- },
1615
- onMouseOver: (e) => {
1616
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1617
- e.currentTarget.style.transform = "translateY(-1px)";
1618
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.2)";
1619
- },
1620
- onMouseOut: (e) => {
1621
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1622
- e.currentTarget.style.transform = "translateY(0)";
1623
- e.currentTarget.style.boxShadow = "0 2px 8px rgba(0, 0, 0, 0.15)";
1624
- },
1625
- children: actions.primary.label
1626
- }
1627
- )
1628
- ]
1629
- }
1630
- )
1631
- ]
1632
- }
1633
- )
1634
- ]
1635
- }
1636
- );
1637
- }
1638
- function renderCopilotKitUsage(error, onClose) {
1639
- if (error.visibility !== import_shared9.ErrorVisibility.BANNER) {
1640
- return null;
1641
- }
1642
- const extractUrlFromMessage = (message) => {
1643
- const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
1644
- const match = linkRegex.exec(message);
1645
- return match ? match[2] : null;
1646
- };
1647
- const getErrorActions = (error2) => {
1648
- switch (error2.name) {
1649
- case import_shared9.ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR:
1650
- return {
1651
- primary: {
1652
- label: "Sign In",
1653
- onClick: () => window.location.href = "https://cloud.copilotkit.ai"
1654
- }
1655
- };
1656
- case import_shared9.ERROR_NAMES.UPGRADE_REQUIRED_ERROR:
1657
- return {
1658
- primary: {
1659
- label: "Upgrade",
1660
- onClick: () => window.location.href = "https://copilotkit.ai/"
1661
- }
1662
- };
1663
- case import_shared9.ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR:
1664
- case import_shared9.ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR:
1665
- case import_shared9.ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR:
1666
- return {
1667
- primary: {
1668
- label: "View Docs",
1669
- onClick: () => {
1670
- var _a;
1671
- const urlFromMessage = extractUrlFromMessage(error2.message);
1672
- const urlFromExtensions = (_a = error2.extensions) == null ? void 0 : _a.troubleshootingUrl;
1673
- const url = urlFromMessage || urlFromExtensions || "https://docs.copilotkit.ai/troubleshooting/common-issues";
1674
- window.open(url, "_blank");
1675
- }
1676
- }
1677
- };
1678
- default:
1679
- return void 0;
1680
- }
1681
- };
1682
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1683
- UsageBanner,
1684
- {
1685
- severity: error.severity || import_shared9.Severity.CRITICAL,
1686
- message: error.message,
1687
- onClose,
1688
- actions: getErrorActions(error)
1689
- }
1690
- );
1691
- }
1692
-
1693
1588
  // src/components/error-boundary/error-utils.tsx
1694
1589
  var import_react8 = require("react");
1695
1590
 
@@ -1838,22 +1733,17 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
1838
1733
  console.error("CopilotKit Error:", error, errorInfo);
1839
1734
  }
1840
1735
  render() {
1841
- var _a, _b;
1736
+ var _a, _b, _c, _d;
1842
1737
  if (this.state.hasError) {
1843
1738
  if (this.state.error instanceof import_shared10.CopilotKitError) {
1844
- if (this.state.error.visibility === import_shared10.ErrorVisibility.BANNER) {
1845
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorToast2, { error: this.state.error, children: renderCopilotKitUsage(
1846
- this.state.error,
1847
- () => this.setState({ hasError: false, error: void 0 })
1848
- ) });
1849
- }
1850
1739
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1851
1740
  this.props.children,
1852
1741
  this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1853
1742
  UsageBanner,
1854
1743
  {
1855
- severity: (_a = this.state.status) == null ? void 0 : _a.severity,
1856
- message: (_b = this.state.status) == null ? void 0 : _b.message
1744
+ severity: (_b = (_a = this.state.status) == null ? void 0 : _a.severity) != null ? _b : this.state.error.severity,
1745
+ message: (_d = (_c = this.state.status) == null ? void 0 : _c.message) != null ? _d : this.state.error.message,
1746
+ actions: getErrorActions(this.state.error)
1857
1747
  }
1858
1748
  )
1859
1749
  ] });
@@ -1863,29 +1753,15 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
1863
1753
  return this.props.children;
1864
1754
  }
1865
1755
  };
1866
- function ErrorToast2({ error, children }) {
1867
- const addErrorToast = useErrorToast();
1868
- (0, import_react9.useEffect)(() => {
1869
- if (error) {
1870
- addErrorToast([error]);
1871
- }
1872
- }, [error, addErrorToast]);
1873
- if (!error)
1874
- throw error;
1875
- return children;
1876
- }
1877
1756
 
1878
1757
  // src/components/copilot-provider/copilotkit.tsx
1879
1758
  var import_jsx_runtime7 = require("react/jsx-runtime");
1880
1759
  function CopilotKit(_a) {
1881
1760
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1882
- var _a2;
1883
- const showDevConsole = (_a2 = props.showDevConsole) != null ? _a2 : false;
1884
- const enabled = shouldShowDevConsole(showDevConsole);
1761
+ const enabled = shouldShowDevConsole(props.showDevConsole);
1885
1762
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotErrorBoundary, { publicApiKey: props.publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
1886
1763
  }
1887
1764
  function CopilotKitInternal(cpkProps) {
1888
- var _b, _c;
1889
1765
  const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
1890
1766
  validateProps(cpkProps);
1891
1767
  const chatApiEndpoint = props.runtimeUrl || import_shared11.COPILOT_CLOUD_CHAT_URL;
@@ -1989,7 +1865,7 @@ ${nonDocumentStrings}`;
1989
1865
  [removeDocument]
1990
1866
  );
1991
1867
  const copilotApiConfig = (0, import_react10.useMemo)(() => {
1992
- var _a2, _b2;
1868
+ var _a2, _b;
1993
1869
  let cloud = void 0;
1994
1870
  if (props.publicApiKey) {
1995
1871
  cloud = {
@@ -1998,7 +1874,7 @@ ${nonDocumentStrings}`;
1998
1874
  restrictToTopic: {
1999
1875
  enabled: Boolean(props.guardrails_c),
2000
1876
  validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
2001
- invalidTopics: ((_b2 = props.guardrails_c) == null ? void 0 : _b2.invalidTopics) || []
1877
+ invalidTopics: ((_b = props.guardrails_c) == null ? void 0 : _b.invalidTopics) || []
2002
1878
  }
2003
1879
  }
2004
1880
  }
@@ -2043,7 +1919,7 @@ ${nonDocumentStrings}`;
2043
1919
  publicApiKey: copilotApiConfig.publicApiKey,
2044
1920
  headers,
2045
1921
  credentials: copilotApiConfig.credentials,
2046
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1922
+ showDevConsole: shouldShowDevConsole(props.showDevConsole),
2047
1923
  onError: props.onError
2048
1924
  });
2049
1925
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
@@ -2122,7 +1998,7 @@ ${nonDocumentStrings}`;
2122
1998
  }, [props.threadId]);
2123
1999
  const [runId, setRunId] = (0, import_react10.useState)(null);
2124
2000
  const chatAbortControllerRef = (0, import_react10.useRef)(null);
2125
- const showDevConsole = (_c = props.showDevConsole) != null ? _c : false;
2001
+ const showDevConsole = shouldShowDevConsole(props.showDevConsole);
2126
2002
  const [langGraphInterruptAction, _setLangGraphInterruptAction] = (0, import_react10.useState)(null);
2127
2003
  const setLangGraphInterruptAction = (0, import_react10.useCallback)((action) => {
2128
2004
  _setLangGraphInterruptAction((prev) => {
@@ -2141,7 +2017,7 @@ ${nonDocumentStrings}`;
2141
2017
  setLangGraphInterruptAction(null);
2142
2018
  }, []);
2143
2019
  const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
2144
- const [suggestions, setSuggestions] = (0, import_react10.useState)([]);
2020
+ const [bannerError, setBannerError] = (0, import_react10.useState)(null);
2145
2021
  const agentLock = (0, import_react10.useMemo)(() => {
2146
2022
  var _a2;
2147
2023
  return (_a2 = props.agent) != null ? _a2 : null;
@@ -2177,7 +2053,7 @@ ${nonDocumentStrings}`;
2177
2053
  },
2178
2054
  [setAuthStates]
2179
2055
  );
2180
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2056
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2181
2057
  CopilotContext.Provider,
2182
2058
  {
2183
2059
  value: {
@@ -2231,10 +2107,21 @@ ${nonDocumentStrings}`;
2231
2107
  setLangGraphInterruptAction,
2232
2108
  removeLangGraphInterruptAction,
2233
2109
  onError: props.onError,
2234
- suggestions,
2235
- setSuggestions
2110
+ bannerError,
2111
+ setBannerError
2236
2112
  },
2237
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
2113
+ children: [
2114
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MessagesTapProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren }) }),
2115
+ bannerError && showDevConsole && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2116
+ UsageBanner,
2117
+ {
2118
+ severity: bannerError.severity,
2119
+ message: bannerError.message,
2120
+ onClose: () => setBannerError(null),
2121
+ actions: getErrorActions(bannerError)
2122
+ }
2123
+ )
2124
+ ]
2238
2125
  }
2239
2126
  );
2240
2127
  }
@@ -2279,7 +2166,7 @@ function validateProps(props) {
2279
2166
  }
2280
2167
  }
2281
2168
 
2282
- // src/hooks/use-copilot-chat.ts
2169
+ // src/hooks/use-copilot-chat_internal.ts
2283
2170
  var import_react13 = require("react");
2284
2171
 
2285
2172
  // src/hooks/use-chat.ts
@@ -2970,7 +2857,7 @@ function getPairedFeAction(actions, message) {
2970
2857
  );
2971
2858
  }
2972
2859
 
2973
- // src/hooks/use-copilot-chat.ts
2860
+ // src/hooks/use-copilot-chat_internal.ts
2974
2861
  var import_runtime_client_gql8 = require("@copilotkit/runtime-client-gql");
2975
2862
 
2976
2863
  // src/hooks/use-langgraph-interrupt-render.ts
@@ -3012,7 +2899,7 @@ function useLangGraphInterruptRender() {
3012
2899
  });
3013
2900
  }
3014
2901
 
3015
- // src/hooks/use-copilot-chat.ts
2902
+ // src/hooks/use-copilot-chat_internal.ts
3016
2903
  var globalSuggestionPromise = null;
3017
2904
  function useCopilotChat(options = {}) {
3018
2905
  var _a;
@@ -3042,11 +2929,9 @@ function useCopilotChat(options = {}) {
3042
2929
  langGraphInterruptAction,
3043
2930
  setLangGraphInterruptAction,
3044
2931
  chatSuggestionConfiguration,
3045
- suggestions,
3046
- setSuggestions,
3047
2932
  runtimeClient
3048
2933
  } = useCopilotContext();
3049
- const { messages, setMessages } = useCopilotMessagesContext();
2934
+ const { messages, setMessages, suggestions, setSuggestions } = useCopilotMessagesContext();
3050
2935
  const [mcpServers, setLocalMcpServers] = (0, import_react13.useState)([]);
3051
2936
  const suggestionsAbortControllerRef = (0, import_react13.useRef)(null);
3052
2937
  const isLoadingSuggestionsRef = (0, import_react13.useRef)(false);
@@ -3179,6 +3064,13 @@ function useCopilotChat(options = {}) {
3179
3064
  }));
3180
3065
  const latestAppend = useUpdatedRef(append);
3181
3066
  const latestAppendFunc = useAsyncCallback(
3067
+ (message, options2) => __async(this, null, function* () {
3068
+ abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
3069
+ return yield latestAppend.current(message, options2);
3070
+ }),
3071
+ [latestAppend]
3072
+ );
3073
+ const latestSendMessageFunc = useAsyncCallback(
3182
3074
  (message, options2) => __async(this, null, function* () {
3183
3075
  abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
3184
3076
  return yield latestAppend.current((0, import_runtime_client_gql8.aguiToGQL)([message])[0], options2);
@@ -3206,6 +3098,9 @@ function useCopilotChat(options = {}) {
3206
3098
  const latestSetMessages = useUpdatedRef(setMessages);
3207
3099
  const latestSetMessagesFunc = (0, import_react13.useCallback)(
3208
3100
  (messages2) => {
3101
+ if (messages2.every((message) => message instanceof import_runtime_client_gql8.Message)) {
3102
+ return latestSetMessages.current(messages2);
3103
+ }
3209
3104
  return latestSetMessages.current((0, import_runtime_client_gql8.aguiToGQL)(messages2));
3210
3105
  },
3211
3106
  [latestSetMessages]
@@ -3242,7 +3137,9 @@ function useCopilotChat(options = {}) {
3242
3137
  }, [latestReset]);
3243
3138
  const interrupt = useLangGraphInterruptRender();
3244
3139
  return {
3245
- visibleMessages: (0, import_runtime_client_gql8.gqlToAGUI)(messages, actions, coAgentStateRenders),
3140
+ visibleMessages: messages,
3141
+ messages: (0, import_runtime_client_gql8.gqlToAGUI)(messages, actions, coAgentStateRenders),
3142
+ sendMessage: latestSendMessageFunc,
3246
3143
  appendMessage: latestAppendFunc,
3247
3144
  setMessages: latestSetMessagesFunc,
3248
3145
  reloadMessages: latestReloadFunc,
@@ -3295,14 +3192,105 @@ In case of a function error:
3295
3192
  ${additionalInstructions}` : "");
3296
3193
  }
3297
3194
 
3298
- // src/hooks/use-copilot-action.ts
3299
- var import_shared14 = require("@copilotkit/shared");
3195
+ // src/hooks/use-copilot-chat.ts
3196
+ function useCopilotChat2(options = {}) {
3197
+ const {
3198
+ visibleMessages,
3199
+ appendMessage,
3200
+ reloadMessages,
3201
+ stopGeneration,
3202
+ reset,
3203
+ isLoading,
3204
+ runChatCompletion,
3205
+ mcpServers,
3206
+ setMcpServers
3207
+ } = useCopilotChat(options);
3208
+ return {
3209
+ visibleMessages,
3210
+ appendMessage,
3211
+ reloadMessages,
3212
+ stopGeneration,
3213
+ reset,
3214
+ isLoading,
3215
+ runChatCompletion,
3216
+ mcpServers,
3217
+ setMcpServers
3218
+ };
3219
+ }
3220
+
3221
+ // src/hooks/use-copilot-chat-headless_c.ts
3300
3222
  var import_react14 = require("react");
3223
+ var import_shared14 = require("@copilotkit/shared");
3224
+ var createNonFunctionalReturn = () => ({
3225
+ visibleMessages: [],
3226
+ messages: [],
3227
+ sendMessage: () => __async(void 0, null, function* () {
3228
+ }),
3229
+ appendMessage: () => __async(void 0, null, function* () {
3230
+ }),
3231
+ setMessages: () => {
3232
+ },
3233
+ deleteMessage: () => {
3234
+ },
3235
+ reloadMessages: () => __async(void 0, null, function* () {
3236
+ }),
3237
+ stopGeneration: () => {
3238
+ },
3239
+ reset: () => {
3240
+ },
3241
+ isLoading: false,
3242
+ runChatCompletion: () => __async(void 0, null, function* () {
3243
+ return [];
3244
+ }),
3245
+ mcpServers: [],
3246
+ setMcpServers: () => {
3247
+ },
3248
+ suggestions: [],
3249
+ setSuggestions: () => {
3250
+ },
3251
+ generateSuggestions: () => __async(void 0, null, function* () {
3252
+ }),
3253
+ resetSuggestions: () => {
3254
+ },
3255
+ isLoadingSuggestions: false,
3256
+ interrupt: null
3257
+ });
3258
+ function useCopilotChatHeadless_c(options = {}) {
3259
+ const { copilotApiConfig, setBannerError } = useCopilotContext();
3260
+ const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
3261
+ const internalResult = useCopilotChat(options);
3262
+ (0, import_react14.useEffect)(() => {
3263
+ if (!hasPublicApiKey) {
3264
+ setBannerError(
3265
+ new import_shared14.CopilotKitError({
3266
+ message: (
3267
+ // add link to documentation here
3268
+ "You're using useCopilotChatHeadless_c, a subscription-only feature, which offers extensive headless chat capabilities. To continue, you'll need to provide a free subscription key."
3269
+ ),
3270
+ code: import_shared14.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
3271
+ severity: import_shared14.Severity.WARNING,
3272
+ visibility: import_shared14.ErrorVisibility.BANNER
3273
+ })
3274
+ );
3275
+ import_shared14.styledConsole.logCopilotKitPlatformMessage();
3276
+ } else {
3277
+ setBannerError(null);
3278
+ }
3279
+ }, [hasPublicApiKey]);
3280
+ if (hasPublicApiKey) {
3281
+ return internalResult;
3282
+ }
3283
+ return createNonFunctionalReturn();
3284
+ }
3285
+
3286
+ // src/hooks/use-copilot-action.ts
3287
+ var import_shared15 = require("@copilotkit/shared");
3288
+ var import_react15 = require("react");
3301
3289
  function useCopilotAction(action, dependencies) {
3302
3290
  const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
3303
- const idRef = (0, import_react14.useRef)((0, import_shared14.randomId)());
3304
- const renderAndWaitRef = (0, import_react14.useRef)(null);
3305
- const activatingMessageIdRef = (0, import_react14.useRef)(null);
3291
+ const idRef = (0, import_react15.useRef)((0, import_shared15.randomId)());
3292
+ const renderAndWaitRef = (0, import_react15.useRef)(null);
3293
+ const activatingMessageIdRef = (0, import_react15.useRef)(null);
3306
3294
  const { addToast } = useToast();
3307
3295
  action = __spreadValues({}, action);
3308
3296
  if (
@@ -3364,7 +3352,7 @@ function useCopilotAction(action, dependencies) {
3364
3352
  return renderAndWait(waitProps);
3365
3353
  }
3366
3354
  }
3367
- return (0, import_react14.createElement)(import_react14.Fragment);
3355
+ return (0, import_react15.createElement)(import_react15.Fragment);
3368
3356
  };
3369
3357
  }
3370
3358
  if (dependencies === void 0) {
@@ -3379,7 +3367,7 @@ function useCopilotAction(action, dependencies) {
3379
3367
  }
3380
3368
  }
3381
3369
  }
3382
- (0, import_react14.useEffect)(() => {
3370
+ (0, import_react15.useEffect)(() => {
3383
3371
  const hasDuplicate = Object.values(actions).some(
3384
3372
  (otherAction) => otherAction.name === action.name && otherAction !== actions[idRef.current]
3385
3373
  );
@@ -3391,7 +3379,7 @@ function useCopilotAction(action, dependencies) {
3391
3379
  });
3392
3380
  }
3393
3381
  }, [actions]);
3394
- (0, import_react14.useEffect)(() => {
3382
+ (0, import_react15.useEffect)(() => {
3395
3383
  setAction(idRef.current, action);
3396
3384
  if (chatComponentsCache.current !== null && action.render !== void 0) {
3397
3385
  chatComponentsCache.current.actions[action.name] = action.render;
@@ -3420,8 +3408,8 @@ function isFrontendAction(action) {
3420
3408
  }
3421
3409
 
3422
3410
  // src/hooks/use-coagent-state-render.ts
3423
- var import_react15 = require("react");
3424
- var import_shared15 = require("@copilotkit/shared");
3411
+ var import_react16 = require("react");
3412
+ var import_shared16 = require("@copilotkit/shared");
3425
3413
  function useCoAgentStateRender(action, dependencies) {
3426
3414
  const {
3427
3415
  setCoAgentStateRender,
@@ -3429,13 +3417,13 @@ function useCoAgentStateRender(action, dependencies) {
3429
3417
  coAgentStateRenders,
3430
3418
  chatComponentsCache,
3431
3419
  availableAgents
3432
- } = (0, import_react15.useContext)(CopilotContext);
3433
- const idRef = (0, import_react15.useRef)((0, import_shared15.randomId)());
3420
+ } = (0, import_react16.useContext)(CopilotContext);
3421
+ const idRef = (0, import_react16.useRef)((0, import_shared16.randomId)());
3434
3422
  const { setBannerError, addToast } = useToast();
3435
- (0, import_react15.useEffect)(() => {
3423
+ (0, import_react16.useEffect)(() => {
3436
3424
  if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
3437
3425
  const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
3438
- const agentError = new import_shared15.CopilotKitAgentDiscoveryError({
3426
+ const agentError = new import_shared16.CopilotKitAgentDiscoveryError({
3439
3427
  agentName: action.name,
3440
3428
  availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
3441
3429
  });
@@ -3453,7 +3441,7 @@ function useCoAgentStateRender(action, dependencies) {
3453
3441
  }
3454
3442
  }
3455
3443
  }
3456
- (0, import_react15.useEffect)(() => {
3444
+ (0, import_react16.useEffect)(() => {
3457
3445
  const currentId = idRef.current;
3458
3446
  const hasDuplicate = Object.entries(coAgentStateRenders).some(([id, otherAction]) => {
3459
3447
  if (id === currentId)
@@ -3477,7 +3465,7 @@ function useCoAgentStateRender(action, dependencies) {
3477
3465
  });
3478
3466
  }
3479
3467
  }, [coAgentStateRenders]);
3480
- (0, import_react15.useEffect)(() => {
3468
+ (0, import_react16.useEffect)(() => {
3481
3469
  setCoAgentStateRender(idRef.current, action);
3482
3470
  if (chatComponentsCache.current !== null && action.render !== void 0) {
3483
3471
  chatComponentsCache.current.coAgentStateRenders[key] = action.render;
@@ -3497,11 +3485,11 @@ function useCoAgentStateRender(action, dependencies) {
3497
3485
  }
3498
3486
 
3499
3487
  // src/hooks/use-make-copilot-document-readable.ts
3500
- var import_react16 = require("react");
3488
+ var import_react17 = require("react");
3501
3489
  function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
3502
3490
  const { addDocumentContext, removeDocumentContext } = useCopilotContext();
3503
- const idRef = (0, import_react16.useRef)();
3504
- (0, import_react16.useEffect)(() => {
3491
+ const idRef = (0, import_react17.useRef)();
3492
+ (0, import_react17.useEffect)(() => {
3505
3493
  const id = addDocumentContext(document, categories);
3506
3494
  idRef.current = id;
3507
3495
  return () => {
@@ -3512,7 +3500,7 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
3512
3500
  }
3513
3501
 
3514
3502
  // src/hooks/use-copilot-readable.ts
3515
- var import_react17 = require("react");
3503
+ var import_react18 = require("react");
3516
3504
  function convertToJSON(description, value) {
3517
3505
  return `${description}: ${typeof value === "string" ? value : JSON.stringify(value)}`;
3518
3506
  }
@@ -3525,10 +3513,10 @@ function useCopilotReadable({
3525
3513
  available = "enabled"
3526
3514
  }, dependencies) {
3527
3515
  const { addContext, removeContext } = useCopilotContext();
3528
- const idRef = (0, import_react17.useRef)();
3516
+ const idRef = (0, import_react18.useRef)();
3529
3517
  convert = convert || convertToJSON;
3530
3518
  const information = convert(description, value);
3531
- (0, import_react17.useEffect)(() => {
3519
+ (0, import_react18.useEffect)(() => {
3532
3520
  if (available === "disabled")
3533
3521
  return;
3534
3522
  const id = addContext(information, parentId, categories);
@@ -3541,30 +3529,29 @@ function useCopilotReadable({
3541
3529
  }
3542
3530
 
3543
3531
  // src/hooks/use-coagent.ts
3544
- var import_react18 = require("react");
3545
- var import_shared16 = require("@copilotkit/shared");
3532
+ var import_react19 = require("react");
3533
+ var import_shared17 = require("@copilotkit/shared");
3546
3534
  function useCoAgent(options) {
3547
- const generalContext = useCopilotContext();
3548
- const { availableAgents } = generalContext;
3535
+ const context = useCopilotContext();
3536
+ const { availableAgents } = context;
3549
3537
  const { setBannerError } = useToast();
3550
- const lastLoadedThreadId = (0, import_react18.useRef)();
3551
- const lastLoadedState = (0, import_react18.useRef)();
3538
+ const lastLoadedThreadId = (0, import_react19.useRef)();
3539
+ const lastLoadedState = (0, import_react19.useRef)();
3552
3540
  const { name } = options;
3553
- (0, import_react18.useEffect)(() => {
3541
+ (0, import_react19.useEffect)(() => {
3554
3542
  if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
3555
3543
  const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
3556
3544
  console.warn(message);
3557
- const agentError = new import_shared16.CopilotKitAgentDiscoveryError({
3545
+ const agentError = new import_shared17.CopilotKitAgentDiscoveryError({
3558
3546
  agentName: name,
3559
3547
  availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
3560
3548
  });
3561
3549
  setBannerError(agentError);
3562
3550
  }
3563
3551
  }, [availableAgents]);
3564
- const messagesContext = useCopilotMessagesContext();
3565
- const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
3552
+ const { getMessagesFromTap } = useMessagesTap();
3566
3553
  const { coagentStates, coagentStatesRef, setCoagentStatesWithRef, threadId, copilotApiConfig } = context;
3567
- const { appendMessage, runChatCompletion } = useCopilotChat();
3554
+ const { sendMessage, runChatCompletion } = useCopilotChat();
3568
3555
  const headers = __spreadValues({}, copilotApiConfig.headers || {});
3569
3556
  const runtimeClient = useCopilotRuntimeClient({
3570
3557
  url: copilotApiConfig.chatApiEndpoint,
@@ -3573,7 +3560,7 @@ function useCoAgent(options) {
3573
3560
  credentials: copilotApiConfig.credentials,
3574
3561
  showDevConsole: context.showDevConsole
3575
3562
  });
3576
- const setState = (0, import_react18.useCallback)(
3563
+ const setState = (0, import_react19.useCallback)(
3577
3564
  (newState) => {
3578
3565
  let coagentState = getCoagentState({ coagentStates, name, options });
3579
3566
  const updatedState = typeof newState === "function" ? newState(coagentState.state) : newState;
@@ -3585,7 +3572,7 @@ function useCoAgent(options) {
3585
3572
  },
3586
3573
  [coagentStates, name]
3587
3574
  );
3588
- (0, import_react18.useEffect)(() => {
3575
+ (0, import_react19.useEffect)(() => {
3589
3576
  const fetchAgentState = () => __async(this, null, function* () {
3590
3577
  var _a, _b, _c, _d;
3591
3578
  if (!threadId || threadId === lastLoadedThreadId.current)
@@ -3603,13 +3590,13 @@ function useCoAgent(options) {
3603
3590
  if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
3604
3591
  lastLoadedState.current = newState;
3605
3592
  lastLoadedThreadId.current = threadId;
3606
- const fetchedState = (0, import_shared16.parseJson)(newState, {});
3593
+ const fetchedState = (0, import_shared17.parseJson)(newState, {});
3607
3594
  isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
3608
3595
  }
3609
3596
  });
3610
3597
  void fetchAgentState();
3611
3598
  }, [threadId]);
3612
- (0, import_react18.useEffect)(() => {
3599
+ (0, import_react19.useEffect)(() => {
3613
3600
  if (isExternalStateManagement(options)) {
3614
3601
  setState(options.state);
3615
3602
  } else if (coagentStates[name] === void 0) {
@@ -3620,7 +3607,7 @@ function useCoAgent(options) {
3620
3607
  // reset initialstate on reset
3621
3608
  coagentStates[name] === void 0
3622
3609
  ]);
3623
- (0, import_react18.useEffect)(() => {
3610
+ (0, import_react19.useEffect)(() => {
3624
3611
  const newConfig = options.config ? options.config : options.configurable ? { configurable: options.configurable } : void 0;
3625
3612
  if (newConfig === void 0)
3626
3613
  return;
@@ -3648,11 +3635,11 @@ function useCoAgent(options) {
3648
3635
  }, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);
3649
3636
  const runAgentCallback = useAsyncCallback(
3650
3637
  (hint) => __async(this, null, function* () {
3651
- yield runAgent(name, context, appendMessage, runChatCompletion, hint);
3638
+ yield runAgent(name, context, getMessagesFromTap(), sendMessage, runChatCompletion, hint);
3652
3639
  }),
3653
- [name, context, appendMessage, runChatCompletion]
3640
+ [name, context, sendMessage, runChatCompletion]
3654
3641
  );
3655
- return (0, import_react18.useMemo)(() => {
3642
+ return (0, import_react19.useMemo)(() => {
3656
3643
  const coagentState = getCoagentState({ coagentStates, name, options });
3657
3644
  return {
3658
3645
  name,
@@ -3692,7 +3679,7 @@ function stopAgent(name, context) {
3692
3679
  console.warn(`No agent session found for ${name}`);
3693
3680
  }
3694
3681
  }
3695
- function runAgent(name, context, appendMessage, runChatCompletion, hint) {
3682
+ function runAgent(name, context, messages, sendMessage, runChatCompletion, hint) {
3696
3683
  return __async(this, null, function* () {
3697
3684
  var _a, _b;
3698
3685
  const { agentSession, setAgentSession } = context;
@@ -3702,8 +3689,8 @@ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
3702
3689
  });
3703
3690
  }
3704
3691
  let previousState = null;
3705
- for (let i = context.messages.length - 1; i >= 0; i--) {
3706
- const message = context.messages[i];
3692
+ for (let i = messages.length - 1; i >= 0; i--) {
3693
+ const message = messages[i];
3707
3694
  if (message.isAgentStateMessage() && message.agentName === name) {
3708
3695
  previousState = message.state;
3709
3696
  }
@@ -3712,7 +3699,7 @@ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
3712
3699
  if (hint) {
3713
3700
  const hintMessage = hint({ previousState, currentState: state });
3714
3701
  if (hintMessage) {
3715
- yield appendMessage(hintMessage);
3702
+ yield sendMessage(hintMessage);
3716
3703
  } else {
3717
3704
  yield runChatCompletion();
3718
3705
  }
@@ -3749,28 +3736,28 @@ var getCoagentState = ({
3749
3736
  };
3750
3737
 
3751
3738
  // src/hooks/use-copilot-authenticated-action.ts
3752
- var import_react19 = require("react");
3753
- var import_react20 = __toESM(require("react"));
3739
+ var import_react20 = require("react");
3740
+ var import_react21 = __toESM(require("react"));
3754
3741
  function useCopilotAuthenticatedAction_c(action, dependencies) {
3755
3742
  const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
3756
- const pendingActionRef = (0, import_react19.useRef)(null);
3757
- const executeAction2 = (0, import_react19.useCallback)(
3743
+ const pendingActionRef = (0, import_react20.useRef)(null);
3744
+ const executeAction2 = (0, import_react20.useCallback)(
3758
3745
  (props) => {
3759
3746
  if (typeof action.render === "function") {
3760
3747
  return action.render(props);
3761
3748
  }
3762
- return action.render || import_react20.default.createElement(import_react19.Fragment);
3749
+ return action.render || import_react21.default.createElement(import_react20.Fragment);
3763
3750
  },
3764
3751
  [action]
3765
3752
  );
3766
- const wrappedRender = (0, import_react19.useCallback)(
3753
+ const wrappedRender = (0, import_react20.useCallback)(
3767
3754
  (props) => {
3768
3755
  const isAuthenticated = Object.values(authStates_c || {}).some(
3769
3756
  (state) => state.status === "authenticated"
3770
3757
  );
3771
3758
  if (!isAuthenticated) {
3772
3759
  pendingActionRef.current = props;
3773
- return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react20.default.createElement(authConfig_c.SignInComponent, {
3760
+ return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react21.default.createElement(authConfig_c.SignInComponent, {
3774
3761
  onSignInComplete: (authState) => {
3775
3762
  setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
3776
3763
  if (pendingActionRef.current) {
@@ -3778,7 +3765,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
3778
3765
  pendingActionRef.current = null;
3779
3766
  }
3780
3767
  }
3781
- }) : import_react20.default.createElement(import_react19.Fragment);
3768
+ }) : import_react21.default.createElement(import_react20.Fragment);
3782
3769
  }
3783
3770
  return executeAction2(props);
3784
3771
  },
@@ -3793,29 +3780,29 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
3793
3780
  }
3794
3781
 
3795
3782
  // src/hooks/use-langgraph-interrupt.ts
3796
- var import_react21 = require("react");
3797
- var import_shared17 = require("@copilotkit/shared");
3783
+ var import_react22 = require("react");
3784
+ var import_shared18 = require("@copilotkit/shared");
3798
3785
  function useLangGraphInterrupt(action, dependencies) {
3799
3786
  var _a;
3800
- const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react21.useContext)(CopilotContext);
3787
+ const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react22.useContext)(CopilotContext);
3801
3788
  const { runChatCompletion } = useCopilotChat();
3802
3789
  const { addToast } = useToast();
3803
- const actionId = (0, import_shared17.dataToUUID)(JSON.stringify(action), "lgAction");
3804
- const hasAction = (0, import_react21.useMemo)(
3790
+ const actionId = (0, import_shared18.dataToUUID)(JSON.stringify(action), "lgAction");
3791
+ const hasAction = (0, import_react22.useMemo)(
3805
3792
  () => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
3806
3793
  [langGraphInterruptAction]
3807
3794
  );
3808
- const isCurrentAction = (0, import_react21.useMemo)(
3795
+ const isCurrentAction = (0, import_react22.useMemo)(
3809
3796
  () => (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) && (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) === actionId,
3810
3797
  [langGraphInterruptAction]
3811
3798
  );
3812
- (0, import_react21.useEffect)(() => {
3799
+ (0, import_react22.useEffect)(() => {
3813
3800
  var _a2;
3814
3801
  if (hasAction && isCurrentAction && ((_a2 = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a2.response)) {
3815
3802
  runChatCompletion();
3816
3803
  }
3817
3804
  }, [(_a = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a.response, runChatCompletion, hasAction, isCurrentAction]);
3818
- (0, import_react21.useEffect)(() => {
3805
+ (0, import_react22.useEffect)(() => {
3819
3806
  if (!action)
3820
3807
  return;
3821
3808
  if (hasAction && !isCurrentAction && !action.enabled) {
@@ -3840,10 +3827,10 @@ function useLangGraphInterrupt(action, dependencies) {
3840
3827
  }
3841
3828
 
3842
3829
  // src/hooks/use-copilot-additional-instructions.ts
3843
- var import_react22 = require("react");
3830
+ var import_react23 = require("react");
3844
3831
  function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
3845
3832
  const { setAdditionalInstructions } = useCopilotContext();
3846
- (0, import_react22.useEffect)(() => {
3833
+ (0, import_react23.useEffect)(() => {
3847
3834
  if (available === "disabled")
3848
3835
  return;
3849
3836
  setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
@@ -3971,6 +3958,8 @@ ${instructions}
3971
3958
  useCopilotAdditionalInstructions,
3972
3959
  useCopilotAuthenticatedAction_c,
3973
3960
  useCopilotChat,
3961
+ useCopilotChatHeadless_c,
3962
+ useCopilotChatInternal,
3974
3963
  useCopilotContext,
3975
3964
  useCopilotMessagesContext,
3976
3965
  useCopilotReadable,