@copilotkit/react-core 1.9.1 → 1.9.2-next.0

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 (180) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-B5UA5G3E.mjs → chunk-2FW7HH6W.mjs} +12 -8
  3. package/dist/chunk-2FW7HH6W.mjs.map +1 -0
  4. package/dist/{chunk-ERFA53MG.mjs → chunk-6KGEF242.mjs} +2 -2
  5. package/dist/chunk-6KGEF242.mjs.map +1 -0
  6. package/dist/{chunk-2J3SMMGW.mjs → chunk-C6F6EQNA.mjs} +2 -2
  7. package/dist/chunk-CCESTGAM.mjs +102 -0
  8. package/dist/chunk-CCESTGAM.mjs.map +1 -0
  9. package/dist/chunk-GFJW4RIM.mjs +9 -0
  10. package/dist/chunk-GFJW4RIM.mjs.map +1 -0
  11. package/dist/chunk-HD2GE3DK.mjs +359 -0
  12. package/dist/chunk-HD2GE3DK.mjs.map +1 -0
  13. package/dist/{chunk-74AJEJTV.mjs → chunk-HJP2RX5R.mjs} +11 -6
  14. package/dist/chunk-HJP2RX5R.mjs.map +1 -0
  15. package/dist/{chunk-EQ4XLLT4.mjs → chunk-LDACFA2B.mjs} +3 -3
  16. package/dist/{chunk-FGBRHBRR.mjs → chunk-LZDDYZEY.mjs} +2 -2
  17. package/dist/chunk-NNSXCFQO.mjs +154 -0
  18. package/dist/chunk-NNSXCFQO.mjs.map +1 -0
  19. package/dist/{chunk-WZAEVHLK.mjs → chunk-Q5D5XQFA.mjs} +2 -2
  20. package/dist/{chunk-534J55RX.mjs → chunk-QQZLIEXK.mjs} +9 -7
  21. package/dist/chunk-QQZLIEXK.mjs.map +1 -0
  22. package/dist/chunk-RUY6MLHA.mjs +119 -0
  23. package/dist/chunk-RUY6MLHA.mjs.map +1 -0
  24. package/dist/{chunk-MDIIRGJD.mjs → chunk-SGLWMQ2J.mjs} +25 -17
  25. package/dist/chunk-SGLWMQ2J.mjs.map +1 -0
  26. package/dist/{chunk-G27C5EFO.mjs → chunk-T42PN5VN.mjs} +7 -5
  27. package/dist/{chunk-G27C5EFO.mjs.map → chunk-T42PN5VN.mjs.map} +1 -1
  28. package/dist/{chunk-VQ3VTO26.mjs → chunk-UHQMV2CE.mjs} +2 -2
  29. package/dist/{chunk-4DVPRMVH.mjs → chunk-UIT6QMUJ.mjs} +7 -7
  30. package/dist/chunk-VRXANACV.mjs +277 -0
  31. package/dist/chunk-VRXANACV.mjs.map +1 -0
  32. package/dist/{chunk-2FLZLANO.mjs → chunk-XY5BN4HZ.mjs} +19 -12
  33. package/dist/chunk-XY5BN4HZ.mjs.map +1 -0
  34. package/dist/{chunk-7HDYPEWS.mjs → chunk-YDENFEKA.mjs} +2 -2
  35. package/dist/{chunk-4VWM6JNK.mjs → chunk-YZDRMIOM.mjs} +6 -6
  36. package/dist/components/copilot-provider/copilot-messages.js +105 -11
  37. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  38. package/dist/components/copilot-provider/copilot-messages.mjs +4 -2
  39. package/dist/components/copilot-provider/copilotkit-props.d.ts +4 -3
  40. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  41. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  42. package/dist/components/copilot-provider/copilotkit.js +863 -441
  43. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  44. package/dist/components/copilot-provider/copilotkit.mjs +10 -9
  45. package/dist/components/copilot-provider/index.d.ts +1 -1
  46. package/dist/components/copilot-provider/index.js +863 -441
  47. package/dist/components/copilot-provider/index.js.map +1 -1
  48. package/dist/components/copilot-provider/index.mjs +10 -9
  49. package/dist/components/error-boundary/error-boundary.js +320 -159
  50. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  51. package/dist/components/error-boundary/error-boundary.mjs +4 -3
  52. package/dist/components/error-boundary/error-utils.js +2 -1
  53. package/dist/components/error-boundary/error-utils.js.map +1 -1
  54. package/dist/components/error-boundary/error-utils.mjs +2 -1
  55. package/dist/components/index.d.ts +1 -1
  56. package/dist/components/index.js +863 -441
  57. package/dist/components/index.js.map +1 -1
  58. package/dist/components/index.mjs +10 -9
  59. package/dist/components/toast/toast-provider.d.ts +9 -12
  60. package/dist/components/toast/toast-provider.js +218 -191
  61. package/dist/components/toast/toast-provider.js.map +1 -1
  62. package/dist/components/toast/toast-provider.mjs +1 -2
  63. package/dist/components/usage-banner.d.ts +3 -2
  64. package/dist/components/usage-banner.js +311 -153
  65. package/dist/components/usage-banner.js.map +1 -1
  66. package/dist/components/usage-banner.mjs +1 -1
  67. package/dist/context/copilot-context.d.ts +1 -1
  68. package/dist/context/copilot-context.js +1 -1
  69. package/dist/context/copilot-context.js.map +1 -1
  70. package/dist/context/copilot-context.mjs +1 -1
  71. package/dist/context/index.d.ts +1 -1
  72. package/dist/context/index.js +1 -1
  73. package/dist/context/index.js.map +1 -1
  74. package/dist/context/index.mjs +1 -1
  75. package/dist/{copilot-context-309906bb.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -1
  76. package/dist/hooks/index.d.ts +1 -1
  77. package/dist/hooks/index.js +160 -75
  78. package/dist/hooks/index.js.map +1 -1
  79. package/dist/hooks/index.mjs +33 -32
  80. package/dist/hooks/use-chat.d.ts +1 -1
  81. package/dist/hooks/use-chat.js +243 -68
  82. package/dist/hooks/use-chat.js.map +1 -1
  83. package/dist/hooks/use-chat.mjs +6 -3
  84. package/dist/hooks/use-coagent-state-render.js +10 -5
  85. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  86. package/dist/hooks/use-coagent-state-render.mjs +3 -4
  87. package/dist/hooks/use-coagent.d.ts +1 -1
  88. package/dist/hooks/use-coagent.js +148 -67
  89. package/dist/hooks/use-coagent.js.map +1 -1
  90. package/dist/hooks/use-coagent.mjs +14 -13
  91. package/dist/hooks/use-copilot-action.js +5 -4
  92. package/dist/hooks/use-copilot-action.js.map +1 -1
  93. package/dist/hooks/use-copilot-action.mjs +4 -3
  94. package/dist/hooks/use-copilot-additional-instructions.js +1 -1
  95. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  96. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  97. package/dist/hooks/use-copilot-authenticated-action.js +5 -4
  98. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  99. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -4
  100. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  101. package/dist/hooks/use-copilot-chat.js +138 -62
  102. package/dist/hooks/use-copilot-chat.js.map +1 -1
  103. package/dist/hooks/use-copilot-chat.mjs +13 -12
  104. package/dist/hooks/use-copilot-readable.js +1 -1
  105. package/dist/hooks/use-copilot-readable.js.map +1 -1
  106. package/dist/hooks/use-copilot-readable.mjs +2 -2
  107. package/dist/hooks/use-copilot-runtime-client.d.ts +5 -2
  108. package/dist/hooks/use-copilot-runtime-client.js +101 -128
  109. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  110. package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
  111. package/dist/hooks/use-langgraph-interrupt-render.js +1 -1
  112. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  113. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  114. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  115. package/dist/hooks/use-langgraph-interrupt.js +140 -64
  116. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  117. package/dist/hooks/use-langgraph-interrupt.mjs +14 -13
  118. package/dist/hooks/use-make-copilot-document-readable.js +1 -1
  119. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  120. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.js +913 -480
  123. package/dist/index.js.map +1 -1
  124. package/dist/index.mjs +35 -34
  125. package/dist/lib/copilot-task.d.ts +1 -1
  126. package/dist/lib/copilot-task.js.map +1 -1
  127. package/dist/lib/copilot-task.mjs +11 -10
  128. package/dist/lib/index.d.ts +1 -1
  129. package/dist/lib/index.js.map +1 -1
  130. package/dist/lib/index.mjs +11 -10
  131. package/dist/types/interrupt-action.d.ts +1 -1
  132. package/dist/utils/dev-console.d.ts +1 -1
  133. package/dist/utils/dev-console.js +1 -10
  134. package/dist/utils/dev-console.js.map +1 -1
  135. package/dist/utils/dev-console.mjs +1 -1
  136. package/dist/utils/extract.d.ts +1 -1
  137. package/dist/utils/extract.js.map +1 -1
  138. package/dist/utils/extract.mjs +10 -9
  139. package/dist/utils/index.d.ts +1 -1
  140. package/dist/utils/index.js +7 -14
  141. package/dist/utils/index.js.map +1 -1
  142. package/dist/utils/index.mjs +12 -11
  143. package/package.json +3 -3
  144. package/src/components/copilot-provider/copilot-messages.tsx +163 -4
  145. package/src/components/copilot-provider/copilotkit-props.tsx +3 -2
  146. package/src/components/copilot-provider/copilotkit.tsx +8 -2
  147. package/src/components/error-boundary/error-boundary.tsx +6 -5
  148. package/src/components/error-boundary/error-utils.tsx +1 -1
  149. package/src/components/toast/toast-provider.tsx +260 -93
  150. package/src/components/usage-banner.tsx +311 -131
  151. package/src/context/copilot-context.tsx +2 -2
  152. package/src/hooks/use-chat.ts +4 -0
  153. package/src/hooks/use-coagent-state-render.ts +9 -3
  154. package/src/hooks/use-coagent.ts +10 -3
  155. package/src/hooks/use-copilot-runtime-client.ts +153 -12
  156. package/src/utils/dev-console.ts +2 -17
  157. package/dist/chunk-22ENANUU.mjs +0 -250
  158. package/dist/chunk-22ENANUU.mjs.map +0 -1
  159. package/dist/chunk-2FLZLANO.mjs.map +0 -1
  160. package/dist/chunk-534J55RX.mjs.map +0 -1
  161. package/dist/chunk-6PK72HMH.mjs +0 -63
  162. package/dist/chunk-6PK72HMH.mjs.map +0 -1
  163. package/dist/chunk-74AJEJTV.mjs.map +0 -1
  164. package/dist/chunk-B5UA5G3E.mjs.map +0 -1
  165. package/dist/chunk-BKTARDXX.mjs +0 -40
  166. package/dist/chunk-BKTARDXX.mjs.map +0 -1
  167. package/dist/chunk-D34OH4VN.mjs +0 -201
  168. package/dist/chunk-D34OH4VN.mjs.map +0 -1
  169. package/dist/chunk-ERFA53MG.mjs.map +0 -1
  170. package/dist/chunk-MDIIRGJD.mjs.map +0 -1
  171. package/dist/chunk-MLAS4QUR.mjs +0 -18
  172. package/dist/chunk-MLAS4QUR.mjs.map +0 -1
  173. /package/dist/{chunk-2J3SMMGW.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
  174. /package/dist/{chunk-EQ4XLLT4.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
  175. /package/dist/{chunk-FGBRHBRR.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
  176. /package/dist/{chunk-WZAEVHLK.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
  177. /package/dist/{chunk-VQ3VTO26.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
  178. /package/dist/{chunk-4DVPRMVH.mjs.map → chunk-UIT6QMUJ.mjs.map} +0 -0
  179. /package/dist/{chunk-7HDYPEWS.mjs.map → chunk-YDENFEKA.mjs.map} +0 -0
  180. /package/dist/{chunk-4VWM6JNK.mjs.map → chunk-YZDRMIOM.mjs.map} +0 -0
@@ -135,7 +135,7 @@ var emptyCopilotContext = {
135
135
  },
136
136
  removeChatSuggestionConfiguration: () => {
137
137
  },
138
- showDevConsole: "auto",
138
+ showDevConsole: false,
139
139
  coagentStates: {},
140
140
  setCoagentStates: () => {
141
141
  },
@@ -197,7 +197,7 @@ var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
197
197
 
198
198
  // src/hooks/use-chat.ts
199
199
  var import_react6 = require("react");
200
- var import_shared2 = require("@copilotkit/shared");
200
+ var import_shared4 = require("@copilotkit/shared");
201
201
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
202
202
 
203
203
  // src/types/frontend-action.ts
@@ -229,17 +229,126 @@ function processActionsForRuntimeRequest(actions) {
229
229
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
230
230
 
231
231
  // src/components/toast/toast-provider.tsx
232
+ var import_react3 = require("react");
233
+ var import_shared2 = require("@copilotkit/shared");
234
+ var import_jsx_runtime = require("react/jsx-runtime");
235
+ var ToastContext = (0, import_react3.createContext)(void 0);
236
+ function useToast() {
237
+ const context = (0, import_react3.useContext)(ToastContext);
238
+ if (!context) {
239
+ throw new Error("useToast must be used within a ToastProvider");
240
+ }
241
+ return context;
242
+ }
243
+
244
+ // src/hooks/use-copilot-runtime-client.ts
232
245
  var import_react4 = require("react");
246
+ var import_shared3 = require("@copilotkit/shared");
247
+
248
+ // src/utils/dev-console.ts
249
+ function shouldShowDevConsole(showDevConsole) {
250
+ return showDevConsole;
251
+ }
252
+
253
+ // src/hooks/use-copilot-runtime-client.ts
254
+ var useCopilotRuntimeClient = (options) => {
255
+ const { setBannerError } = useToast();
256
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
257
+ const lastStructuredErrorRef = (0, import_react4.useRef)(null);
258
+ const runtimeClient = (0, import_react4.useMemo)(() => {
259
+ return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
260
+ handleGQLErrors: (error) => {
261
+ var _a2;
262
+ if ((_a2 = error.graphQLErrors) == null ? void 0 : _a2.length) {
263
+ const graphQLErrors = error.graphQLErrors;
264
+ const routeError = (gqlError) => {
265
+ const extensions = gqlError.extensions;
266
+ const visibility = extensions == null ? void 0 : extensions.visibility;
267
+ const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
268
+ if (visibility === import_shared3.ErrorVisibility.SILENT) {
269
+ console.error("CopilotKit Silent Error:", gqlError.message);
270
+ return;
271
+ }
272
+ if (!isDev) {
273
+ console.error("CopilotKit Error (hidden in production):", gqlError.message);
274
+ return;
275
+ }
276
+ const now = Date.now();
277
+ const errorMessage = gqlError.message;
278
+ if (lastStructuredErrorRef.current && lastStructuredErrorRef.current.message === errorMessage && now - lastStructuredErrorRef.current.timestamp < 150) {
279
+ return;
280
+ }
281
+ lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };
282
+ const ckError = createStructuredError(gqlError);
283
+ if (ckError) {
284
+ setBannerError(ckError);
285
+ } else {
286
+ const fallbackError = new import_shared3.CopilotKitError({
287
+ message: gqlError.message,
288
+ code: import_shared3.CopilotKitErrorCode.UNKNOWN
289
+ });
290
+ setBannerError(fallbackError);
291
+ }
292
+ };
293
+ graphQLErrors.forEach(routeError);
294
+ } else {
295
+ const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
296
+ if (!isDev) {
297
+ console.error("CopilotKit Error (hidden in production):", error);
298
+ } else {
299
+ const fallbackError = new import_shared3.CopilotKitError({
300
+ message: (error == null ? void 0 : error.message) || String(error),
301
+ code: import_shared3.CopilotKitErrorCode.UNKNOWN
302
+ });
303
+ setBannerError(fallbackError);
304
+ }
305
+ }
306
+ },
307
+ handleGQLWarning: (message) => {
308
+ console.warn(message);
309
+ const warningError = new import_shared3.CopilotKitError({
310
+ message,
311
+ code: import_shared3.CopilotKitErrorCode.UNKNOWN
312
+ });
313
+ setBannerError(warningError);
314
+ }
315
+ }));
316
+ }, [runtimeOptions, setBannerError, showDevConsole]);
317
+ return runtimeClient;
318
+ };
319
+ function createStructuredError(gqlError) {
320
+ var _a, _b, _c;
321
+ const extensions = gqlError.extensions;
322
+ const originalError = extensions == null ? void 0 : extensions.originalError;
323
+ const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
324
+ const code = extensions == null ? void 0 : extensions.code;
325
+ if (code) {
326
+ return new import_shared3.CopilotKitError({ message, code });
327
+ }
328
+ if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
329
+ return new import_shared3.CopilotKitApiDiscoveryError({ message });
330
+ }
331
+ if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
332
+ return new import_shared3.CopilotKitRemoteEndpointDiscoveryError({ message });
333
+ }
334
+ if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
335
+ return new import_shared3.CopilotKitAgentDiscoveryError({
336
+ agentName: "",
337
+ availableAgents: []
338
+ });
339
+ }
340
+ return null;
341
+ }
233
342
 
234
343
  // src/components/error-boundary/error-utils.tsx
235
- var import_react3 = require("react");
344
+ var import_react5 = require("react");
236
345
 
237
346
  // src/components/toast/exclamation-mark-icon.tsx
238
- var import_jsx_runtime = require("react/jsx-runtime");
347
+ var import_jsx_runtime2 = require("react/jsx-runtime");
239
348
  var ExclamationMarkIcon = ({
240
349
  className,
241
350
  style
242
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
351
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
243
352
  "svg",
244
353
  {
245
354
  xmlns: "http://www.w3.org/2000/svg",
@@ -254,23 +363,23 @@ var ExclamationMarkIcon = ({
254
363
  className: `lucide lucide-circle-alert ${className ? className : ""}`,
255
364
  style,
256
365
  children: [
257
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
258
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
259
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
366
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
367
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
368
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
260
369
  ]
261
370
  }
262
371
  );
263
372
 
264
373
  // src/components/error-boundary/error-utils.tsx
265
374
  var import_react_markdown = __toESM(require("react-markdown"));
266
- var import_jsx_runtime2 = require("react/jsx-runtime");
375
+ var import_jsx_runtime3 = require("react/jsx-runtime");
267
376
  function ErrorToast({ errors }) {
268
377
  const errorsToRender = errors.map((error, idx) => {
269
378
  var _a, _b, _c;
270
379
  const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
271
380
  const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
272
381
  const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
273
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
382
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
274
383
  "div",
275
384
  {
276
385
  style: {
@@ -278,8 +387,8 @@ function ErrorToast({ errors }) {
278
387
  marginBottom: 14
279
388
  },
280
389
  children: [
281
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
282
- code && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
390
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
391
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
283
392
  "div",
284
393
  {
285
394
  style: {
@@ -287,19 +396,19 @@ function ErrorToast({ errors }) {
287
396
  marginBottom: 4
288
397
  },
289
398
  children: [
290
- "Copilot Cloud Error:",
399
+ "Copilot Runtime Error:",
291
400
  " ",
292
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
401
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
293
402
  ]
294
403
  }
295
404
  ),
296
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_markdown.default, { children: message })
405
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
297
406
  ]
298
407
  },
299
408
  idx
300
409
  );
301
410
  });
302
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
411
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
303
412
  "div",
304
413
  {
305
414
  style: {
@@ -308,14 +417,14 @@ function ErrorToast({ errors }) {
308
417
  },
309
418
  children: [
310
419
  errorsToRender,
311
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
420
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
312
421
  ]
313
422
  }
314
423
  );
315
424
  }
316
425
  function useErrorToast() {
317
426
  const { addToast } = useToast();
318
- return (0, import_react3.useCallback)(
427
+ return (0, import_react5.useCallback)(
319
428
  (error) => {
320
429
  const errorId = error.map((err) => {
321
430
  var _a, _b;
@@ -327,7 +436,7 @@ function useErrorToast() {
327
436
  type: "error",
328
437
  id: errorId,
329
438
  // Toast libraries typically dedupe by id
330
- message: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorToast, { errors: error })
439
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
331
440
  });
332
441
  },
333
442
  [addToast]
@@ -335,7 +444,7 @@ function useErrorToast() {
335
444
  }
336
445
  function useAsyncCallback(callback, deps) {
337
446
  const addErrorToast = useErrorToast();
338
- return (0, import_react3.useCallback)((...args) => __async(this, null, function* () {
447
+ return (0, import_react5.useCallback)((...args) => __async(this, null, function* () {
339
448
  try {
340
449
  return yield callback(...args);
341
450
  } catch (error) {
@@ -346,41 +455,6 @@ function useAsyncCallback(callback, deps) {
346
455
  }), deps);
347
456
  }
348
457
 
349
- // src/components/toast/toast-provider.tsx
350
- var import_jsx_runtime3 = require("react/jsx-runtime");
351
- var ToastContext = (0, import_react4.createContext)(void 0);
352
- function useToast() {
353
- const context = (0, import_react4.useContext)(ToastContext);
354
- if (!context) {
355
- throw new Error("useToast must be used within a ToastProvider");
356
- }
357
- return context;
358
- }
359
-
360
- // src/hooks/use-copilot-runtime-client.ts
361
- var import_react5 = require("react");
362
- var useCopilotRuntimeClient = (options) => {
363
- const { addGraphQLErrorsToast } = useToast();
364
- const addErrorToast = useErrorToast();
365
- const { addToast } = useToast();
366
- const runtimeClient = (0, import_react5.useMemo)(() => {
367
- return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
368
- handleGQLErrors: (error) => {
369
- if (error.graphQLErrors.length) {
370
- addGraphQLErrorsToast(error.graphQLErrors);
371
- } else {
372
- addErrorToast([error]);
373
- }
374
- },
375
- handleGQLWarning: (message) => {
376
- console.warn(message);
377
- addToast({ type: "warning", message });
378
- }
379
- }));
380
- }, [options, addGraphQLErrorsToast, addToast]);
381
- return runtimeClient;
382
- };
383
-
384
458
  // src/hooks/use-chat.ts
385
459
  function useChat(options) {
386
460
  const {
@@ -418,12 +492,14 @@ function useChat(options) {
418
492
  const extensionsRef = (0, import_react6.useRef)(extensions);
419
493
  extensionsRef.current = extensions;
420
494
  const publicApiKey = copilotConfig.publicApiKey;
421
- const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared2.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
495
+ const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
496
+ const { showDevConsole } = useCopilotContext();
422
497
  const runtimeClient = useCopilotRuntimeClient({
423
498
  url: copilotConfig.chatApiEndpoint,
424
499
  publicApiKey: copilotConfig.publicApiKey,
425
500
  headers,
426
- credentials: copilotConfig.credentials
501
+ credentials: copilotConfig.credentials,
502
+ showDevConsole
427
503
  });
428
504
  const pendingAppendsRef = (0, import_react6.useRef)([]);
429
505
  const runChatCompletion = useAsyncCallback(
@@ -541,7 +617,7 @@ function useChat(options) {
541
617
  (metaEvents != null ? metaEvents : []).forEach((ev) => {
542
618
  if (ev.name === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent) {
543
619
  let eventValue = (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev).value;
544
- eventValue = (0, import_shared2.parseJson)(eventValue, eventValue);
620
+ eventValue = (0, import_shared4.parseJson)(eventValue, eventValue);
545
621
  setLangGraphInterruptAction({
546
622
  event: __spreadProps(__spreadValues({}, (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev)), {
547
623
  value: eventValue
@@ -615,7 +691,7 @@ function useChat(options) {
615
691
  } else {
616
692
  if (agentLock) {
617
693
  setAgentSession({
618
- threadId: (0, import_shared2.randomId)(),
694
+ threadId: (0, import_shared4.randomId)(),
619
695
  agentName: agentLock,
620
696
  nodeName: void 0
621
697
  });
@@ -676,7 +752,7 @@ function useChat(options) {
676
752
  if (pairedFeAction) {
677
753
  const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
678
754
  name: pairedFeAction.name,
679
- arguments: (0, import_shared2.parseJson)(resultMessage.result, resultMessage.result),
755
+ arguments: (0, import_shared4.parseJson)(resultMessage.result, resultMessage.result),
680
756
  status: message.status,
681
757
  createdAt: message.createdAt,
682
758
  parentMessageId: message.parentMessageId
@@ -686,7 +762,7 @@ function useChat(options) {
686
762
  } else if (message.isResultMessage() && currentResultMessagePairedFeAction) {
687
763
  const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
688
764
  name: currentResultMessagePairedFeAction.name,
689
- arguments: (0, import_shared2.parseJson)(message.result, message.result),
765
+ arguments: (0, import_shared4.parseJson)(message.result, message.result),
690
766
  status: message.status,
691
767
  createdAt: message.createdAt
692
768
  });
@@ -924,7 +1000,7 @@ function getPairedFeAction(actions, message) {
924
1000
  // src/components/copilot-provider/copilotkit.tsx
925
1001
  var import_react7 = require("react");
926
1002
  var import_react_dom = require("react-dom");
927
- var import_shared3 = require("@copilotkit/shared");
1003
+ var import_shared5 = require("@copilotkit/shared");
928
1004
  var import_jsx_runtime4 = require("react/jsx-runtime");
929
1005
  var defaultCopilotContextCategories = ["global"];
930
1006
 
@@ -1143,11 +1219,11 @@ ${additionalInstructions}` : "");
1143
1219
  }
1144
1220
 
1145
1221
  // src/hooks/use-coagent.ts
1146
- var import_shared4 = require("@copilotkit/shared");
1222
+ var import_shared6 = require("@copilotkit/shared");
1147
1223
  function useCoAgent(options) {
1148
1224
  const generalContext = useCopilotContext();
1149
1225
  const { availableAgents } = generalContext;
1150
- const { addToast } = useToast();
1226
+ const { setBannerError } = useToast();
1151
1227
  const lastLoadedThreadId = (0, import_react9.useRef)();
1152
1228
  const lastLoadedState = (0, import_react9.useRef)();
1153
1229
  const { name } = options;
@@ -1155,7 +1231,11 @@ function useCoAgent(options) {
1155
1231
  if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
1156
1232
  const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
1157
1233
  console.warn(message);
1158
- addToast({ type: "warning", message });
1234
+ const agentError = new import_shared6.CopilotKitAgentDiscoveryError({
1235
+ agentName: name,
1236
+ availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
1237
+ });
1238
+ setBannerError(agentError);
1159
1239
  }
1160
1240
  }, [availableAgents]);
1161
1241
  const messagesContext = useCopilotMessagesContext();
@@ -1167,7 +1247,8 @@ function useCoAgent(options) {
1167
1247
  url: copilotApiConfig.chatApiEndpoint,
1168
1248
  publicApiKey: copilotApiConfig.publicApiKey,
1169
1249
  headers,
1170
- credentials: copilotApiConfig.credentials
1250
+ credentials: copilotApiConfig.credentials,
1251
+ showDevConsole: context.showDevConsole
1171
1252
  });
1172
1253
  const setState = (0, import_react9.useCallback)(
1173
1254
  (newState) => {
@@ -1196,7 +1277,7 @@ function useCoAgent(options) {
1196
1277
  if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
1197
1278
  lastLoadedState.current = newState;
1198
1279
  lastLoadedThreadId.current = threadId;
1199
- const fetchedState = (0, import_shared4.parseJson)(newState, {});
1280
+ const fetchedState = (0, import_shared6.parseJson)(newState, {});
1200
1281
  isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
1201
1282
  }
1202
1283
  });