@copilotkit/react-core 1.10.0-next.3 → 1.10.0-next.4

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 (190) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{chunk-VOMGRGWT.mjs → chunk-2JAX6WE6.mjs} +7 -7
  3. package/dist/chunk-2JAX6WE6.mjs.map +1 -0
  4. package/dist/{chunk-WUORFPJ7.mjs → chunk-2WYJIO6D.mjs} +4 -4
  5. package/dist/chunk-373NOCJI.mjs +79 -0
  6. package/dist/chunk-373NOCJI.mjs.map +1 -0
  7. package/dist/{chunk-XGRBCWK6.mjs → chunk-47GMU44Z.mjs} +4 -1
  8. package/dist/chunk-47GMU44Z.mjs.map +1 -0
  9. package/dist/{chunk-DF4YG4PF.mjs → chunk-57MBVQPX.mjs} +2 -2
  10. package/dist/{chunk-JZQOCH4A.mjs → chunk-5JL5ELUS.mjs} +2 -2
  11. package/dist/{chunk-LNAQ7JG3.mjs → chunk-AC2GVFW6.mjs} +2 -2
  12. package/dist/{chunk-RGKZCCPA.mjs → chunk-AVMA2MCW.mjs} +3 -3
  13. package/dist/chunk-AWFAFFO5.mjs +221 -0
  14. package/dist/chunk-AWFAFFO5.mjs.map +1 -0
  15. package/dist/{chunk-4XVBXDCX.mjs → chunk-BBK7LXZ6.mjs} +5 -5
  16. package/dist/{chunk-YAF2LATQ.mjs → chunk-EFL5OBKN.mjs} +1 -1
  17. package/dist/chunk-EFL5OBKN.mjs.map +1 -0
  18. package/dist/{chunk-4CFY3CON.mjs → chunk-EQQSE6KM.mjs} +2 -2
  19. package/dist/{chunk-JWAXDYOW.mjs → chunk-FAUNHSQU.mjs} +3 -3
  20. package/dist/{chunk-NXCJELW7.mjs → chunk-G7J6NY5J.mjs} +3 -3
  21. package/dist/chunk-ICIK2BSB.mjs +17 -0
  22. package/dist/chunk-ICIK2BSB.mjs.map +1 -0
  23. package/dist/{chunk-PYULBXCD.mjs → chunk-JLQZVKFX.mjs} +4 -4
  24. package/dist/chunk-KDAZGZ24.mjs +1 -0
  25. package/dist/{chunk-OMVNJ7S3.mjs → chunk-L7CWMU4O.mjs} +34 -19
  26. package/dist/chunk-L7CWMU4O.mjs.map +1 -0
  27. package/dist/{chunk-3OQM3NEK.mjs → chunk-N4WEHORG.mjs} +2 -2
  28. package/dist/{chunk-Q6FZZJ5A.mjs → chunk-OL3VRQKU.mjs} +2 -2
  29. package/dist/chunk-PQ5IXT4Z.mjs +18 -0
  30. package/dist/chunk-PQ5IXT4Z.mjs.map +1 -0
  31. package/dist/{chunk-VM7CVIET.mjs → chunk-PRKL7T7P.mjs} +6 -6
  32. package/dist/chunk-PRKL7T7P.mjs.map +1 -0
  33. package/dist/{chunk-KV25ZRMH.mjs → chunk-XIHAYU6C.mjs} +4 -4
  34. package/dist/chunk-XIHAYU6C.mjs.map +1 -0
  35. package/dist/{chunk-SGF6C7I6.mjs → chunk-ZTZJIDRJ.mjs} +9 -14
  36. package/dist/chunk-ZTZJIDRJ.mjs.map +1 -0
  37. package/dist/components/copilot-provider/copilot-messages.js +12 -1
  38. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  39. package/dist/components/copilot-provider/copilot-messages.mjs +4 -4
  40. package/dist/components/copilot-provider/copilotkit-props.d.ts +1 -1
  41. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  42. package/dist/components/copilot-provider/copilotkit.js +307 -550
  43. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  44. package/dist/components/copilot-provider/copilotkit.mjs +9 -9
  45. package/dist/components/copilot-provider/index.d.ts +1 -1
  46. package/dist/components/copilot-provider/index.js +307 -550
  47. package/dist/components/copilot-provider/index.js.map +1 -1
  48. package/dist/components/copilot-provider/index.mjs +9 -9
  49. package/dist/components/error-boundary/error-boundary.js +172 -323
  50. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  51. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  52. package/dist/components/error-boundary/error-utils.js.map +1 -1
  53. package/dist/components/error-boundary/error-utils.mjs +2 -2
  54. package/dist/components/index.d.ts +1 -1
  55. package/dist/components/index.js +307 -550
  56. package/dist/components/index.js.map +1 -1
  57. package/dist/components/index.mjs +9 -9
  58. package/dist/components/toast/toast-provider.js.map +1 -1
  59. package/dist/components/toast/toast-provider.mjs +1 -1
  60. package/dist/components/usage-banner.d.ts +8 -3
  61. package/dist/components/usage-banner.js +172 -302
  62. package/dist/components/usage-banner.js.map +1 -1
  63. package/dist/components/usage-banner.mjs +3 -1
  64. package/dist/context/copilot-context.d.ts +1 -1
  65. package/dist/context/copilot-context.js +3 -0
  66. package/dist/context/copilot-context.js.map +1 -1
  67. package/dist/context/copilot-context.mjs +1 -1
  68. package/dist/context/index.d.ts +1 -1
  69. package/dist/context/index.js +3 -0
  70. package/dist/context/index.js.map +1 -1
  71. package/dist/context/index.mjs +1 -1
  72. package/dist/{copilot-context-bd88d30d.d.ts → copilot-context-78fc727c.d.ts} +3 -1
  73. package/dist/hooks/index.d.ts +5 -3
  74. package/dist/hooks/index.js +143 -57
  75. package/dist/hooks/index.js.map +1 -1
  76. package/dist/hooks/index.mjs +32 -24
  77. package/dist/hooks/use-chat.d.ts +1 -1
  78. package/dist/hooks/use-chat.js +12 -1
  79. package/dist/hooks/use-chat.js.map +1 -1
  80. package/dist/hooks/use-chat.mjs +6 -6
  81. package/dist/hooks/use-coagent-state-render.js +3 -0
  82. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  83. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  84. package/dist/hooks/use-coagent.d.ts +1 -1
  85. package/dist/hooks/use-coagent.js +15 -4
  86. package/dist/hooks/use-coagent.js.map +1 -1
  87. package/dist/hooks/use-coagent.mjs +13 -13
  88. package/dist/hooks/use-copilot-action.js +3 -0
  89. package/dist/hooks/use-copilot-action.js.map +1 -1
  90. package/dist/hooks/use-copilot-action.mjs +4 -4
  91. package/dist/hooks/use-copilot-additional-instructions.js +3 -0
  92. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  93. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  94. package/dist/hooks/use-copilot-authenticated-action.js +3 -0
  95. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  96. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  97. package/dist/hooks/use-copilot-chat-light.d.ts +211 -0
  98. package/dist/hooks/use-copilot-chat-light.js +1770 -0
  99. package/dist/hooks/use-copilot-chat-light.js.map +1 -0
  100. package/dist/hooks/use-copilot-chat-light.mjs +28 -0
  101. package/dist/hooks/use-copilot-chat-light.mjs.map +1 -0
  102. package/dist/hooks/use-copilot-chat.d.ts +9 -81
  103. package/dist/hooks/use-copilot-chat.js +77 -5
  104. package/dist/hooks/use-copilot-chat.js.map +1 -1
  105. package/dist/hooks/use-copilot-chat.mjs +15 -13
  106. package/dist/hooks/use-copilot-chat_internal.d.ts +91 -0
  107. package/dist/hooks/use-copilot-chat_internal.js +1760 -0
  108. package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
  109. package/dist/hooks/use-copilot-chat_internal.mjs +29 -0
  110. package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
  111. package/dist/hooks/use-copilot-readable.js +3 -0
  112. package/dist/hooks/use-copilot-readable.js.map +1 -1
  113. package/dist/hooks/use-copilot-readable.mjs +2 -2
  114. package/dist/hooks/use-copilot-runtime-client.js +9 -1
  115. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  116. package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
  117. package/dist/hooks/use-langgraph-interrupt-render.js +3 -0
  118. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  119. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  120. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  121. package/dist/hooks/use-langgraph-interrupt.js +15 -4
  122. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  123. package/dist/hooks/use-langgraph-interrupt.mjs +13 -13
  124. package/dist/hooks/use-make-copilot-document-readable.js +3 -0
  125. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  126. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  127. package/dist/index.d.ts +4 -2
  128. package/dist/index.js +384 -449
  129. package/dist/index.js.map +1 -1
  130. package/dist/index.mjs +34 -26
  131. package/dist/lib/copilot-task.d.ts +1 -1
  132. package/dist/lib/copilot-task.js.map +1 -1
  133. package/dist/lib/copilot-task.mjs +10 -10
  134. package/dist/lib/index.d.ts +1 -1
  135. package/dist/lib/index.js.map +1 -1
  136. package/dist/lib/index.mjs +10 -10
  137. package/dist/types/interrupt-action.d.ts +1 -1
  138. package/dist/utils/dev-console.d.ts +1 -1
  139. package/dist/utils/dev-console.js +9 -1
  140. package/dist/utils/dev-console.js.map +1 -1
  141. package/dist/utils/dev-console.mjs +1 -1
  142. package/dist/utils/extract.d.ts +1 -1
  143. package/dist/utils/extract.js.map +1 -1
  144. package/dist/utils/extract.mjs +9 -9
  145. package/dist/utils/index.d.ts +1 -1
  146. package/dist/utils/index.js +9 -1
  147. package/dist/utils/index.js.map +1 -1
  148. package/dist/utils/index.mjs +9 -9
  149. package/dist/utils/suggestions.d.ts +1 -1
  150. package/dist/utils/suggestions.js.map +1 -1
  151. package/dist/utils/suggestions.mjs +9 -9
  152. package/package.json +3 -3
  153. package/src/components/copilot-provider/copilotkit.tsx +16 -5
  154. package/src/components/error-boundary/error-boundary.tsx +5 -15
  155. package/src/components/toast/toast-provider.tsx +1 -3
  156. package/src/components/usage-banner.tsx +187 -315
  157. package/src/context/copilot-context.tsx +12 -1
  158. package/src/hooks/__tests__/use-coagent-config.test.ts +1 -1
  159. package/src/hooks/index.ts +6 -0
  160. package/src/hooks/use-coagent.ts +1 -1
  161. package/src/hooks/use-copilot-chat-light.ts +219 -0
  162. package/src/hooks/use-copilot-chat.ts +89 -430
  163. package/src/hooks/use-copilot-chat_internal.ts +437 -0
  164. package/src/hooks/use-langgraph-interrupt.ts +1 -1
  165. package/src/utils/dev-console.ts +18 -2
  166. package/dist/chunk-57K2ZJ5F.mjs +0 -348
  167. package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
  168. package/dist/chunk-CQPYJIBH.mjs +0 -1
  169. package/dist/chunk-GFJW4RIM.mjs +0 -9
  170. package/dist/chunk-GFJW4RIM.mjs.map +0 -1
  171. package/dist/chunk-KV25ZRMH.mjs.map +0 -1
  172. package/dist/chunk-OMVNJ7S3.mjs.map +0 -1
  173. package/dist/chunk-SGF6C7I6.mjs.map +0 -1
  174. package/dist/chunk-VM7CVIET.mjs.map +0 -1
  175. package/dist/chunk-VOMGRGWT.mjs.map +0 -1
  176. package/dist/chunk-XGRBCWK6.mjs.map +0 -1
  177. package/dist/chunk-YAF2LATQ.mjs.map +0 -1
  178. /package/dist/{chunk-WUORFPJ7.mjs.map → chunk-2WYJIO6D.mjs.map} +0 -0
  179. /package/dist/{chunk-DF4YG4PF.mjs.map → chunk-57MBVQPX.mjs.map} +0 -0
  180. /package/dist/{chunk-JZQOCH4A.mjs.map → chunk-5JL5ELUS.mjs.map} +0 -0
  181. /package/dist/{chunk-LNAQ7JG3.mjs.map → chunk-AC2GVFW6.mjs.map} +0 -0
  182. /package/dist/{chunk-RGKZCCPA.mjs.map → chunk-AVMA2MCW.mjs.map} +0 -0
  183. /package/dist/{chunk-4XVBXDCX.mjs.map → chunk-BBK7LXZ6.mjs.map} +0 -0
  184. /package/dist/{chunk-4CFY3CON.mjs.map → chunk-EQQSE6KM.mjs.map} +0 -0
  185. /package/dist/{chunk-JWAXDYOW.mjs.map → chunk-FAUNHSQU.mjs.map} +0 -0
  186. /package/dist/{chunk-NXCJELW7.mjs.map → chunk-G7J6NY5J.mjs.map} +0 -0
  187. /package/dist/{chunk-PYULBXCD.mjs.map → chunk-JLQZVKFX.mjs.map} +0 -0
  188. /package/dist/{chunk-CQPYJIBH.mjs.map → chunk-KDAZGZ24.mjs.map} +0 -0
  189. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-N4WEHORG.mjs.map} +0 -0
  190. /package/dist/{chunk-Q6FZZJ5A.mjs.map → chunk-OL3VRQKU.mjs.map} +0 -0
@@ -87,7 +87,9 @@ __export(hooks_exports, {
87
87
  useCopilotAction: () => useCopilotAction,
88
88
  useCopilotAdditionalInstructions: () => useCopilotAdditionalInstructions,
89
89
  useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c,
90
- useCopilotChat: () => useCopilotChat,
90
+ useCopilotChat: () => useCopilotChat2,
91
+ useCopilotChatInternal: () => useCopilotChat,
92
+ useCopilotChatLight: () => useCopilotChatLight,
91
93
  useCopilotReadable: () => useCopilotReadable,
92
94
  useCopilotRuntimeClient: () => useCopilotRuntimeClient,
93
95
  useLangGraphInterrupt: () => useLangGraphInterrupt,
@@ -97,7 +99,7 @@ __export(hooks_exports, {
97
99
  module.exports = __toCommonJS(hooks_exports);
98
100
 
99
101
  // src/hooks/use-copilot-chat.ts
100
- var import_react9 = require("react");
102
+ var import_react10 = require("react");
101
103
 
102
104
  // src/context/copilot-context.tsx
103
105
  var import_react = __toESM(require("react"));
@@ -175,6 +177,9 @@ var emptyCopilotContext = {
175
177
  removeLangGraphInterruptAction: () => null,
176
178
  onError: void 0,
177
179
  suggestions: [],
180
+ bannerError: null,
181
+ setBannerError: () => {
182
+ },
178
183
  setSuggestions: () => {
179
184
  }
180
185
  };
@@ -190,6 +195,9 @@ function returnAndThrowInDebug(_value) {
190
195
  throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
191
196
  }
192
197
 
198
+ // src/hooks/use-copilot-chat_internal.ts
199
+ var import_react9 = require("react");
200
+
193
201
  // src/context/copilot-messages-context.tsx
194
202
  var import_react2 = __toESM(require("react"));
195
203
  var emptyCopilotContext2 = {
@@ -259,8 +267,16 @@ var import_react4 = require("react");
259
267
  var import_shared3 = require("@copilotkit/shared");
260
268
 
261
269
  // src/utils/dev-console.ts
270
+ function isLocalhost() {
271
+ if (typeof window === "undefined")
272
+ return false;
273
+ return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0";
274
+ }
262
275
  function shouldShowDevConsole(showDevConsole) {
263
- return showDevConsole;
276
+ if (showDevConsole !== void 0) {
277
+ return showDevConsole;
278
+ }
279
+ return isLocalhost();
264
280
  }
265
281
 
266
282
  // src/hooks/use-copilot-runtime-client.ts
@@ -1431,7 +1447,7 @@ Available tools: ${tools}
1431
1447
  var import_jsx_runtime4 = require("react/jsx-runtime");
1432
1448
  var defaultCopilotContextCategories = ["global"];
1433
1449
 
1434
- // src/hooks/use-copilot-chat.ts
1450
+ // src/hooks/use-copilot-chat_internal.ts
1435
1451
  var import_runtime_client_gql7 = require("@copilotkit/runtime-client-gql");
1436
1452
 
1437
1453
  // src/hooks/use-langgraph-interrupt-render.ts
@@ -1473,7 +1489,7 @@ function useLangGraphInterruptRender() {
1473
1489
  });
1474
1490
  }
1475
1491
 
1476
- // src/hooks/use-copilot-chat.ts
1492
+ // src/hooks/use-copilot-chat_internal.ts
1477
1493
  var globalSuggestionPromise = null;
1478
1494
  function useCopilotChat(options = {}) {
1479
1495
  var _a;
@@ -1756,14 +1772,82 @@ In case of a function error:
1756
1772
  ${additionalInstructions}` : "");
1757
1773
  }
1758
1774
 
1759
- // src/hooks/use-copilot-action.ts
1775
+ // src/hooks/use-copilot-chat.ts
1760
1776
  var import_shared8 = require("@copilotkit/shared");
1761
- var import_react10 = require("react");
1777
+ var createNonFunctionalReturn = () => ({
1778
+ visibleMessages: [],
1779
+ appendMessage: () => __async(void 0, null, function* () {
1780
+ }),
1781
+ setMessages: () => {
1782
+ },
1783
+ deleteMessage: () => {
1784
+ },
1785
+ reloadMessages: () => __async(void 0, null, function* () {
1786
+ }),
1787
+ stopGeneration: () => {
1788
+ },
1789
+ reset: () => {
1790
+ },
1791
+ isLoading: false,
1792
+ runChatCompletion: () => __async(void 0, null, function* () {
1793
+ return [];
1794
+ }),
1795
+ mcpServers: [],
1796
+ setMcpServers: () => {
1797
+ },
1798
+ suggestions: [],
1799
+ setSuggestions: () => {
1800
+ },
1801
+ generateSuggestions: () => __async(void 0, null, function* () {
1802
+ }),
1803
+ resetSuggestions: () => {
1804
+ },
1805
+ isLoadingSuggestions: false,
1806
+ interrupt: null
1807
+ });
1808
+ function useCopilotChat2(options = {}) {
1809
+ const { copilotApiConfig, setBannerError } = useCopilotContext();
1810
+ const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
1811
+ const internalResult = useCopilotChat(options);
1812
+ (0, import_react10.useEffect)(() => {
1813
+ if (!hasPublicApiKey) {
1814
+ setBannerError(
1815
+ new import_shared8.CopilotKitError({
1816
+ message: "As of v1.10.0, useCopilotChat requires a publicApiKey to function.",
1817
+ code: import_shared8.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
1818
+ severity: import_shared8.Severity.CRITICAL,
1819
+ visibility: import_shared8.ErrorVisibility.BANNER
1820
+ })
1821
+ );
1822
+ import_shared8.styledConsole.logCopilotKitPlatformMessage();
1823
+ } else {
1824
+ setBannerError(null);
1825
+ }
1826
+ }, [hasPublicApiKey]);
1827
+ if (hasPublicApiKey) {
1828
+ return internalResult;
1829
+ }
1830
+ return createNonFunctionalReturn();
1831
+ }
1832
+
1833
+ // src/hooks/use-copilot-chat-light.ts
1834
+ function useCopilotChatLight(options = {}) {
1835
+ const { appendMessage, setSuggestions, generateSuggestions } = useCopilotChat(options);
1836
+ return {
1837
+ appendMessage,
1838
+ setSuggestions,
1839
+ generateSuggestions
1840
+ };
1841
+ }
1842
+
1843
+ // src/hooks/use-copilot-action.ts
1844
+ var import_shared9 = require("@copilotkit/shared");
1845
+ var import_react11 = require("react");
1762
1846
  function useCopilotAction(action, dependencies) {
1763
1847
  const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
1764
- const idRef = (0, import_react10.useRef)((0, import_shared8.randomId)());
1765
- const renderAndWaitRef = (0, import_react10.useRef)(null);
1766
- const activatingMessageIdRef = (0, import_react10.useRef)(null);
1848
+ const idRef = (0, import_react11.useRef)((0, import_shared9.randomId)());
1849
+ const renderAndWaitRef = (0, import_react11.useRef)(null);
1850
+ const activatingMessageIdRef = (0, import_react11.useRef)(null);
1767
1851
  const { addToast } = useToast();
1768
1852
  action = __spreadValues({}, action);
1769
1853
  if (
@@ -1825,7 +1909,7 @@ function useCopilotAction(action, dependencies) {
1825
1909
  return renderAndWait(waitProps);
1826
1910
  }
1827
1911
  }
1828
- return (0, import_react10.createElement)(import_react10.Fragment);
1912
+ return (0, import_react11.createElement)(import_react11.Fragment);
1829
1913
  };
1830
1914
  }
1831
1915
  if (dependencies === void 0) {
@@ -1840,7 +1924,7 @@ function useCopilotAction(action, dependencies) {
1840
1924
  }
1841
1925
  }
1842
1926
  }
1843
- (0, import_react10.useEffect)(() => {
1927
+ (0, import_react11.useEffect)(() => {
1844
1928
  const hasDuplicate = Object.values(actions).some(
1845
1929
  (otherAction) => otherAction.name === action.name && otherAction !== actions[idRef.current]
1846
1930
  );
@@ -1852,7 +1936,7 @@ function useCopilotAction(action, dependencies) {
1852
1936
  });
1853
1937
  }
1854
1938
  }, [actions]);
1855
- (0, import_react10.useEffect)(() => {
1939
+ (0, import_react11.useEffect)(() => {
1856
1940
  setAction(idRef.current, action);
1857
1941
  if (chatComponentsCache.current !== null && action.render !== void 0) {
1858
1942
  chatComponentsCache.current.actions[action.name] = action.render;
@@ -1881,8 +1965,8 @@ function isFrontendAction(action) {
1881
1965
  }
1882
1966
 
1883
1967
  // src/hooks/use-coagent-state-render.ts
1884
- var import_react11 = require("react");
1885
- var import_shared9 = require("@copilotkit/shared");
1968
+ var import_react12 = require("react");
1969
+ var import_shared10 = require("@copilotkit/shared");
1886
1970
  function useCoAgentStateRender(action, dependencies) {
1887
1971
  const {
1888
1972
  setCoAgentStateRender,
@@ -1890,13 +1974,13 @@ function useCoAgentStateRender(action, dependencies) {
1890
1974
  coAgentStateRenders,
1891
1975
  chatComponentsCache,
1892
1976
  availableAgents
1893
- } = (0, import_react11.useContext)(CopilotContext);
1894
- const idRef = (0, import_react11.useRef)((0, import_shared9.randomId)());
1977
+ } = (0, import_react12.useContext)(CopilotContext);
1978
+ const idRef = (0, import_react12.useRef)((0, import_shared10.randomId)());
1895
1979
  const { setBannerError, addToast } = useToast();
1896
- (0, import_react11.useEffect)(() => {
1980
+ (0, import_react12.useEffect)(() => {
1897
1981
  if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
1898
1982
  const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
1899
- const agentError = new import_shared9.CopilotKitAgentDiscoveryError({
1983
+ const agentError = new import_shared10.CopilotKitAgentDiscoveryError({
1900
1984
  agentName: action.name,
1901
1985
  availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
1902
1986
  });
@@ -1914,7 +1998,7 @@ function useCoAgentStateRender(action, dependencies) {
1914
1998
  }
1915
1999
  }
1916
2000
  }
1917
- (0, import_react11.useEffect)(() => {
2001
+ (0, import_react12.useEffect)(() => {
1918
2002
  const currentId = idRef.current;
1919
2003
  const hasDuplicate = Object.entries(coAgentStateRenders).some(([id, otherAction]) => {
1920
2004
  if (id === currentId)
@@ -1938,7 +2022,7 @@ function useCoAgentStateRender(action, dependencies) {
1938
2022
  });
1939
2023
  }
1940
2024
  }, [coAgentStateRenders]);
1941
- (0, import_react11.useEffect)(() => {
2025
+ (0, import_react12.useEffect)(() => {
1942
2026
  setCoAgentStateRender(idRef.current, action);
1943
2027
  if (chatComponentsCache.current !== null && action.render !== void 0) {
1944
2028
  chatComponentsCache.current.coAgentStateRenders[key] = action.render;
@@ -1958,11 +2042,11 @@ function useCoAgentStateRender(action, dependencies) {
1958
2042
  }
1959
2043
 
1960
2044
  // src/hooks/use-make-copilot-document-readable.ts
1961
- var import_react12 = require("react");
2045
+ var import_react13 = require("react");
1962
2046
  function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
1963
2047
  const { addDocumentContext, removeDocumentContext } = useCopilotContext();
1964
- const idRef = (0, import_react12.useRef)();
1965
- (0, import_react12.useEffect)(() => {
2048
+ const idRef = (0, import_react13.useRef)();
2049
+ (0, import_react13.useEffect)(() => {
1966
2050
  const id = addDocumentContext(document, categories);
1967
2051
  idRef.current = id;
1968
2052
  return () => {
@@ -1973,7 +2057,7 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
1973
2057
  }
1974
2058
 
1975
2059
  // src/hooks/use-copilot-readable.ts
1976
- var import_react13 = require("react");
2060
+ var import_react14 = require("react");
1977
2061
  function convertToJSON(description, value) {
1978
2062
  return `${description}: ${typeof value === "string" ? value : JSON.stringify(value)}`;
1979
2063
  }
@@ -1986,10 +2070,10 @@ function useCopilotReadable({
1986
2070
  available = "enabled"
1987
2071
  }, dependencies) {
1988
2072
  const { addContext, removeContext } = useCopilotContext();
1989
- const idRef = (0, import_react13.useRef)();
2073
+ const idRef = (0, import_react14.useRef)();
1990
2074
  convert = convert || convertToJSON;
1991
2075
  const information = convert(description, value);
1992
- (0, import_react13.useEffect)(() => {
2076
+ (0, import_react14.useEffect)(() => {
1993
2077
  if (available === "disabled")
1994
2078
  return;
1995
2079
  const id = addContext(information, parentId, categories);
@@ -2002,20 +2086,20 @@ function useCopilotReadable({
2002
2086
  }
2003
2087
 
2004
2088
  // src/hooks/use-coagent.ts
2005
- var import_react14 = require("react");
2006
- var import_shared10 = require("@copilotkit/shared");
2089
+ var import_react15 = require("react");
2090
+ var import_shared11 = require("@copilotkit/shared");
2007
2091
  function useCoAgent(options) {
2008
2092
  const generalContext = useCopilotContext();
2009
2093
  const { availableAgents } = generalContext;
2010
2094
  const { setBannerError } = useToast();
2011
- const lastLoadedThreadId = (0, import_react14.useRef)();
2012
- const lastLoadedState = (0, import_react14.useRef)();
2095
+ const lastLoadedThreadId = (0, import_react15.useRef)();
2096
+ const lastLoadedState = (0, import_react15.useRef)();
2013
2097
  const { name } = options;
2014
- (0, import_react14.useEffect)(() => {
2098
+ (0, import_react15.useEffect)(() => {
2015
2099
  if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
2016
2100
  const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
2017
2101
  console.warn(message);
2018
- const agentError = new import_shared10.CopilotKitAgentDiscoveryError({
2102
+ const agentError = new import_shared11.CopilotKitAgentDiscoveryError({
2019
2103
  agentName: name,
2020
2104
  availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
2021
2105
  });
@@ -2034,7 +2118,7 @@ function useCoAgent(options) {
2034
2118
  credentials: copilotApiConfig.credentials,
2035
2119
  showDevConsole: context.showDevConsole
2036
2120
  });
2037
- const setState = (0, import_react14.useCallback)(
2121
+ const setState = (0, import_react15.useCallback)(
2038
2122
  (newState) => {
2039
2123
  let coagentState = getCoagentState({ coagentStates, name, options });
2040
2124
  const updatedState = typeof newState === "function" ? newState(coagentState.state) : newState;
@@ -2046,7 +2130,7 @@ function useCoAgent(options) {
2046
2130
  },
2047
2131
  [coagentStates, name]
2048
2132
  );
2049
- (0, import_react14.useEffect)(() => {
2133
+ (0, import_react15.useEffect)(() => {
2050
2134
  const fetchAgentState = () => __async(this, null, function* () {
2051
2135
  var _a, _b, _c, _d;
2052
2136
  if (!threadId || threadId === lastLoadedThreadId.current)
@@ -2064,13 +2148,13 @@ function useCoAgent(options) {
2064
2148
  if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
2065
2149
  lastLoadedState.current = newState;
2066
2150
  lastLoadedThreadId.current = threadId;
2067
- const fetchedState = (0, import_shared10.parseJson)(newState, {});
2151
+ const fetchedState = (0, import_shared11.parseJson)(newState, {});
2068
2152
  isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
2069
2153
  }
2070
2154
  });
2071
2155
  void fetchAgentState();
2072
2156
  }, [threadId]);
2073
- (0, import_react14.useEffect)(() => {
2157
+ (0, import_react15.useEffect)(() => {
2074
2158
  if (isExternalStateManagement(options)) {
2075
2159
  setState(options.state);
2076
2160
  } else if (coagentStates[name] === void 0) {
@@ -2081,7 +2165,7 @@ function useCoAgent(options) {
2081
2165
  // reset initialstate on reset
2082
2166
  coagentStates[name] === void 0
2083
2167
  ]);
2084
- (0, import_react14.useEffect)(() => {
2168
+ (0, import_react15.useEffect)(() => {
2085
2169
  const newConfig = options.config ? options.config : options.configurable ? { configurable: options.configurable } : void 0;
2086
2170
  if (newConfig === void 0)
2087
2171
  return;
@@ -2113,7 +2197,7 @@ function useCoAgent(options) {
2113
2197
  }),
2114
2198
  [name, context, appendMessage, runChatCompletion]
2115
2199
  );
2116
- return (0, import_react14.useMemo)(() => {
2200
+ return (0, import_react15.useMemo)(() => {
2117
2201
  const coagentState = getCoagentState({ coagentStates, name, options });
2118
2202
  return {
2119
2203
  name,
@@ -2210,28 +2294,28 @@ var getCoagentState = ({
2210
2294
  };
2211
2295
 
2212
2296
  // src/hooks/use-copilot-authenticated-action.ts
2213
- var import_react15 = require("react");
2214
- var import_react16 = __toESM(require("react"));
2297
+ var import_react16 = require("react");
2298
+ var import_react17 = __toESM(require("react"));
2215
2299
  function useCopilotAuthenticatedAction_c(action, dependencies) {
2216
2300
  const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
2217
- const pendingActionRef = (0, import_react15.useRef)(null);
2218
- const executeAction2 = (0, import_react15.useCallback)(
2301
+ const pendingActionRef = (0, import_react16.useRef)(null);
2302
+ const executeAction2 = (0, import_react16.useCallback)(
2219
2303
  (props) => {
2220
2304
  if (typeof action.render === "function") {
2221
2305
  return action.render(props);
2222
2306
  }
2223
- return action.render || import_react16.default.createElement(import_react15.Fragment);
2307
+ return action.render || import_react17.default.createElement(import_react16.Fragment);
2224
2308
  },
2225
2309
  [action]
2226
2310
  );
2227
- const wrappedRender = (0, import_react15.useCallback)(
2311
+ const wrappedRender = (0, import_react16.useCallback)(
2228
2312
  (props) => {
2229
2313
  const isAuthenticated = Object.values(authStates_c || {}).some(
2230
2314
  (state) => state.status === "authenticated"
2231
2315
  );
2232
2316
  if (!isAuthenticated) {
2233
2317
  pendingActionRef.current = props;
2234
- return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react16.default.createElement(authConfig_c.SignInComponent, {
2318
+ return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react17.default.createElement(authConfig_c.SignInComponent, {
2235
2319
  onSignInComplete: (authState) => {
2236
2320
  setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
2237
2321
  if (pendingActionRef.current) {
@@ -2239,7 +2323,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
2239
2323
  pendingActionRef.current = null;
2240
2324
  }
2241
2325
  }
2242
- }) : import_react16.default.createElement(import_react15.Fragment);
2326
+ }) : import_react17.default.createElement(import_react16.Fragment);
2243
2327
  }
2244
2328
  return executeAction2(props);
2245
2329
  },
@@ -2254,29 +2338,29 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
2254
2338
  }
2255
2339
 
2256
2340
  // src/hooks/use-langgraph-interrupt.ts
2257
- var import_react17 = require("react");
2258
- var import_shared11 = require("@copilotkit/shared");
2341
+ var import_react18 = require("react");
2342
+ var import_shared12 = require("@copilotkit/shared");
2259
2343
  function useLangGraphInterrupt(action, dependencies) {
2260
2344
  var _a;
2261
- const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react17.useContext)(CopilotContext);
2345
+ const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react18.useContext)(CopilotContext);
2262
2346
  const { runChatCompletion } = useCopilotChat();
2263
2347
  const { addToast } = useToast();
2264
- const actionId = (0, import_shared11.dataToUUID)(JSON.stringify(action), "lgAction");
2265
- const hasAction = (0, import_react17.useMemo)(
2348
+ const actionId = (0, import_shared12.dataToUUID)(JSON.stringify(action), "lgAction");
2349
+ const hasAction = (0, import_react18.useMemo)(
2266
2350
  () => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
2267
2351
  [langGraphInterruptAction]
2268
2352
  );
2269
- const isCurrentAction = (0, import_react17.useMemo)(
2353
+ const isCurrentAction = (0, import_react18.useMemo)(
2270
2354
  () => (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) && (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) === actionId,
2271
2355
  [langGraphInterruptAction]
2272
2356
  );
2273
- (0, import_react17.useEffect)(() => {
2357
+ (0, import_react18.useEffect)(() => {
2274
2358
  var _a2;
2275
2359
  if (hasAction && isCurrentAction && ((_a2 = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a2.response)) {
2276
2360
  runChatCompletion();
2277
2361
  }
2278
2362
  }, [(_a = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a.response, runChatCompletion, hasAction, isCurrentAction]);
2279
- (0, import_react17.useEffect)(() => {
2363
+ (0, import_react18.useEffect)(() => {
2280
2364
  if (!action)
2281
2365
  return;
2282
2366
  if (hasAction && !isCurrentAction && !action.enabled) {
@@ -2301,10 +2385,10 @@ function useLangGraphInterrupt(action, dependencies) {
2301
2385
  }
2302
2386
 
2303
2387
  // src/hooks/use-copilot-additional-instructions.ts
2304
- var import_react18 = require("react");
2388
+ var import_react19 = require("react");
2305
2389
  function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
2306
2390
  const { setAdditionalInstructions } = useCopilotContext();
2307
- (0, import_react18.useEffect)(() => {
2391
+ (0, import_react19.useEffect)(() => {
2308
2392
  if (available === "disabled")
2309
2393
  return;
2310
2394
  setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
@@ -2326,6 +2410,8 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
2326
2410
  useCopilotAdditionalInstructions,
2327
2411
  useCopilotAuthenticatedAction_c,
2328
2412
  useCopilotChat,
2413
+ useCopilotChatInternal,
2414
+ useCopilotChatLight,
2329
2415
  useCopilotReadable,
2330
2416
  useCopilotRuntimeClient,
2331
2417
  useLangGraphInterrupt,