@copilotkit/react-core 1.9.2-next.10 → 1.9.2-next.3

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 (168) hide show
  1. package/CHANGELOG.md +0 -56
  2. package/dist/{chunk-3YHYWAHK.mjs → chunk-2FW7HH6W.mjs} +3 -3
  3. package/dist/{chunk-OF4SZTLL.mjs → chunk-2XSUXRGG.mjs} +4 -4
  4. package/dist/{chunk-WOGURSAL.mjs → chunk-3XXVDQ7Z.mjs} +8 -10
  5. package/dist/chunk-3XXVDQ7Z.mjs.map +1 -0
  6. package/dist/{chunk-XFOTNHYA.mjs → chunk-6KGEF242.mjs} +2 -3
  7. package/dist/chunk-6KGEF242.mjs.map +1 -0
  8. package/dist/{chunk-EXU7GWLC.mjs → chunk-C3SYYVMR.mjs} +5 -5
  9. package/dist/{chunk-JPMIAGI6.mjs → chunk-C6F6EQNA.mjs} +2 -2
  10. package/dist/{chunk-3OQM3NEK.mjs → chunk-CCESTGAM.mjs} +2 -2
  11. package/dist/chunk-HD2GE3DK.mjs +359 -0
  12. package/dist/chunk-HD2GE3DK.mjs.map +1 -0
  13. package/dist/{chunk-G7LYGERN.mjs → chunk-HJP2RX5R.mjs} +14 -81
  14. package/dist/chunk-HJP2RX5R.mjs.map +1 -0
  15. package/dist/{chunk-ADIITPD2.mjs → chunk-IVXB3GYK.mjs} +6 -9
  16. package/dist/{chunk-ADIITPD2.mjs.map → chunk-IVXB3GYK.mjs.map} +1 -1
  17. package/dist/{chunk-EF5BNM34.mjs → chunk-LDACFA2B.mjs} +3 -3
  18. package/dist/{chunk-UBNRUXEK.mjs → chunk-LZDDYZEY.mjs} +2 -2
  19. package/dist/{chunk-FXK6RQIN.mjs → chunk-PUNALT2S.mjs} +2 -2
  20. package/dist/{chunk-CMQV4XNY.mjs → chunk-Q5D5XQFA.mjs} +2 -2
  21. package/dist/{chunk-SJJNFYGQ.mjs → chunk-QQZLIEXK.mjs} +3 -3
  22. package/dist/{chunk-JDEWNLNP.mjs → chunk-QRGDQSGZ.mjs} +5 -38
  23. package/dist/chunk-QRGDQSGZ.mjs.map +1 -0
  24. package/dist/{chunk-55QZ2SVJ.mjs → chunk-RUY6MLHA.mjs} +6 -36
  25. package/dist/chunk-RUY6MLHA.mjs.map +1 -0
  26. package/dist/{chunk-NQVCZQ5T.mjs → chunk-T42PN5VN.mjs} +4 -4
  27. package/dist/{chunk-ERXWDCY6.mjs → chunk-UHQMV2CE.mjs} +2 -2
  28. package/dist/chunk-VRXANACV.mjs +277 -0
  29. package/dist/chunk-VRXANACV.mjs.map +1 -0
  30. package/dist/components/copilot-provider/copilot-messages.js +3 -37
  31. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  32. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  33. package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -21
  34. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  35. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  36. package/dist/components/copilot-provider/copilotkit.js +238 -326
  37. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  38. package/dist/components/copilot-provider/copilotkit.mjs +8 -8
  39. package/dist/components/copilot-provider/index.d.ts +1 -1
  40. package/dist/components/copilot-provider/index.js +238 -326
  41. package/dist/components/copilot-provider/index.js.map +1 -1
  42. package/dist/components/copilot-provider/index.mjs +8 -8
  43. package/dist/components/error-boundary/error-boundary.js +146 -135
  44. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  45. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  46. package/dist/components/error-boundary/error-utils.js.map +1 -1
  47. package/dist/components/error-boundary/error-utils.mjs +2 -2
  48. package/dist/components/index.d.ts +1 -1
  49. package/dist/components/index.js +238 -326
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/index.mjs +8 -8
  52. package/dist/components/toast/toast-provider.js +85 -118
  53. package/dist/components/toast/toast-provider.js.map +1 -1
  54. package/dist/components/toast/toast-provider.mjs +1 -1
  55. package/dist/components/usage-banner.js +146 -135
  56. package/dist/components/usage-banner.js.map +1 -1
  57. package/dist/components/usage-banner.mjs +1 -1
  58. package/dist/context/copilot-context.d.ts +1 -1
  59. package/dist/context/copilot-context.js +1 -2
  60. package/dist/context/copilot-context.js.map +1 -1
  61. package/dist/context/copilot-context.mjs +1 -1
  62. package/dist/context/index.d.ts +1 -1
  63. package/dist/context/index.js +1 -2
  64. package/dist/context/index.js.map +1 -1
  65. package/dist/context/index.mjs +1 -1
  66. package/dist/{copilot-context-3da805ab.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -5
  67. package/dist/hooks/index.d.ts +1 -1
  68. package/dist/hooks/index.js +12 -108
  69. package/dist/hooks/index.js.map +1 -1
  70. package/dist/hooks/index.mjs +19 -19
  71. package/dist/hooks/use-chat.d.ts +1 -1
  72. package/dist/hooks/use-chat.js +12 -105
  73. package/dist/hooks/use-chat.js.map +1 -1
  74. package/dist/hooks/use-chat.mjs +5 -5
  75. package/dist/hooks/use-coagent-state-render.js +1 -2
  76. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  77. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  78. package/dist/hooks/use-coagent.d.ts +1 -1
  79. package/dist/hooks/use-coagent.js +12 -108
  80. package/dist/hooks/use-coagent.js.map +1 -1
  81. package/dist/hooks/use-coagent.mjs +11 -11
  82. package/dist/hooks/use-copilot-action.js +1 -2
  83. package/dist/hooks/use-copilot-action.js.map +1 -1
  84. package/dist/hooks/use-copilot-action.mjs +4 -4
  85. package/dist/hooks/use-copilot-additional-instructions.js +1 -2
  86. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  87. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  88. package/dist/hooks/use-copilot-authenticated-action.js +1 -2
  89. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  90. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  91. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  92. package/dist/hooks/use-copilot-chat.js +12 -105
  93. package/dist/hooks/use-copilot-chat.js.map +1 -1
  94. package/dist/hooks/use-copilot-chat.mjs +10 -10
  95. package/dist/hooks/use-copilot-readable.js +1 -2
  96. package/dist/hooks/use-copilot-readable.js.map +1 -1
  97. package/dist/hooks/use-copilot-readable.mjs +2 -2
  98. package/dist/hooks/use-copilot-runtime-client.d.ts +0 -2
  99. package/dist/hooks/use-copilot-runtime-client.js +2 -52
  100. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  101. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  102. package/dist/hooks/use-langgraph-interrupt-render.js +1 -2
  103. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  104. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  105. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  106. package/dist/hooks/use-langgraph-interrupt.js +12 -105
  107. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  108. package/dist/hooks/use-langgraph-interrupt.mjs +11 -11
  109. package/dist/hooks/use-make-copilot-document-readable.js +1 -2
  110. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  111. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  112. package/dist/index.d.ts +1 -1
  113. package/dist/index.js +247 -400
  114. package/dist/index.js.map +1 -1
  115. package/dist/index.mjs +20 -20
  116. package/dist/lib/copilot-task.d.ts +1 -1
  117. package/dist/lib/copilot-task.js.map +1 -1
  118. package/dist/lib/copilot-task.mjs +9 -9
  119. package/dist/lib/index.d.ts +1 -1
  120. package/dist/lib/index.js.map +1 -1
  121. package/dist/lib/index.mjs +9 -9
  122. package/dist/types/interrupt-action.d.ts +1 -1
  123. package/dist/utils/extract.d.ts +1 -1
  124. package/dist/utils/extract.js.map +1 -1
  125. package/dist/utils/extract.mjs +8 -8
  126. package/dist/utils/index.d.ts +1 -1
  127. package/dist/utils/index.js.map +1 -1
  128. package/dist/utils/index.mjs +8 -8
  129. package/dist/utils/utils.test.d.ts +2 -0
  130. package/dist/utils/utils.test.js +9 -0
  131. package/dist/utils/utils.test.js.map +1 -0
  132. package/dist/utils/utils.test.mjs +7 -0
  133. package/dist/utils/utils.test.mjs.map +1 -0
  134. package/jest.config.js +3 -7
  135. package/package.json +3 -4
  136. package/src/components/copilot-provider/copilot-messages.tsx +3 -42
  137. package/src/components/copilot-provider/copilotkit-props.tsx +0 -21
  138. package/src/components/copilot-provider/copilotkit.tsx +0 -2
  139. package/src/components/toast/toast-provider.tsx +24 -49
  140. package/src/components/usage-banner.tsx +147 -144
  141. package/src/context/copilot-context.tsx +1 -7
  142. package/src/hooks/use-chat.ts +6 -106
  143. package/src/hooks/use-coagent.ts +0 -5
  144. package/src/hooks/use-copilot-runtime-client.ts +39 -41
  145. package/tsconfig.json +8 -1
  146. package/tsup.config.ts +6 -6
  147. package/dist/chunk-55QZ2SVJ.mjs.map +0 -1
  148. package/dist/chunk-57K2ZJ5F.mjs +0 -348
  149. package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
  150. package/dist/chunk-G7LYGERN.mjs.map +0 -1
  151. package/dist/chunk-JDEWNLNP.mjs.map +0 -1
  152. package/dist/chunk-WOGURSAL.mjs.map +0 -1
  153. package/dist/chunk-XFOTNHYA.mjs.map +0 -1
  154. package/dist/chunk-YAF2LATQ.mjs +0 -310
  155. package/dist/chunk-YAF2LATQ.mjs.map +0 -1
  156. package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +0 -75
  157. /package/dist/{chunk-3YHYWAHK.mjs.map → chunk-2FW7HH6W.mjs.map} +0 -0
  158. /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-2XSUXRGG.mjs.map} +0 -0
  159. /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-C3SYYVMR.mjs.map} +0 -0
  160. /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
  161. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-CCESTGAM.mjs.map} +0 -0
  162. /package/dist/{chunk-EF5BNM34.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
  163. /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
  164. /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-PUNALT2S.mjs.map} +0 -0
  165. /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
  166. /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-QQZLIEXK.mjs.map} +0 -0
  167. /package/dist/{chunk-NQVCZQ5T.mjs.map → chunk-T42PN5VN.mjs.map} +0 -0
  168. /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
@@ -1,56 +1,56 @@
1
1
  import "../chunk-CQPYJIBH.mjs";
2
2
  import {
3
3
  useLangGraphInterruptRender
4
- } from "../chunk-CMQV4XNY.mjs";
4
+ } from "../chunk-Q5D5XQFA.mjs";
5
5
  import {
6
6
  useLangGraphInterrupt
7
- } from "../chunk-OF4SZTLL.mjs";
7
+ } from "../chunk-2XSUXRGG.mjs";
8
8
  import {
9
9
  useMakeCopilotDocumentReadable
10
- } from "../chunk-ERXWDCY6.mjs";
10
+ } from "../chunk-UHQMV2CE.mjs";
11
11
  import {
12
12
  useCoAgentStateRender
13
- } from "../chunk-3YHYWAHK.mjs";
13
+ } from "../chunk-2FW7HH6W.mjs";
14
14
  import {
15
15
  runAgent,
16
16
  startAgent,
17
17
  stopAgent,
18
18
  useCoAgent
19
- } from "../chunk-ADIITPD2.mjs";
19
+ } from "../chunk-IVXB3GYK.mjs";
20
20
  import {
21
21
  useCopilotAdditionalInstructions
22
- } from "../chunk-JPMIAGI6.mjs";
22
+ } from "../chunk-C6F6EQNA.mjs";
23
23
  import {
24
24
  useCopilotAuthenticatedAction_c
25
- } from "../chunk-EF5BNM34.mjs";
25
+ } from "../chunk-LDACFA2B.mjs";
26
26
  import {
27
27
  useCopilotAction
28
- } from "../chunk-NQVCZQ5T.mjs";
28
+ } from "../chunk-T42PN5VN.mjs";
29
29
  import {
30
30
  useCopilotChat
31
- } from "../chunk-EXU7GWLC.mjs";
31
+ } from "../chunk-C3SYYVMR.mjs";
32
32
  import {
33
33
  useCopilotReadable
34
- } from "../chunk-UBNRUXEK.mjs";
35
- import "../chunk-WOGURSAL.mjs";
36
- import "../chunk-SJJNFYGQ.mjs";
37
- import "../chunk-JDEWNLNP.mjs";
34
+ } from "../chunk-LZDDYZEY.mjs";
35
+ import "../chunk-3XXVDQ7Z.mjs";
36
+ import "../chunk-QQZLIEXK.mjs";
37
+ import "../chunk-QRGDQSGZ.mjs";
38
38
  import "../chunk-5FHSUKQL.mjs";
39
39
  import "../chunk-RKTVJRK7.mjs";
40
40
  import "../chunk-PMAFHQ7P.mjs";
41
- import "../chunk-57K2ZJ5F.mjs";
41
+ import "../chunk-HD2GE3DK.mjs";
42
42
  import "../chunk-YPSGKPDA.mjs";
43
43
  import "../chunk-DCTJZ742.mjs";
44
- import "../chunk-G7LYGERN.mjs";
44
+ import "../chunk-HJP2RX5R.mjs";
45
45
  import "../chunk-4CEQJ2X6.mjs";
46
- import "../chunk-3OQM3NEK.mjs";
46
+ import "../chunk-CCESTGAM.mjs";
47
47
  import "../chunk-O7ARI5CV.mjs";
48
48
  import {
49
49
  useCopilotRuntimeClient
50
- } from "../chunk-55QZ2SVJ.mjs";
50
+ } from "../chunk-RUY6MLHA.mjs";
51
51
  import "../chunk-GFJW4RIM.mjs";
52
- import "../chunk-YAF2LATQ.mjs";
53
- import "../chunk-XFOTNHYA.mjs";
52
+ import "../chunk-VRXANACV.mjs";
53
+ import "../chunk-6KGEF242.mjs";
54
54
  import "../chunk-SKC7AJIV.mjs";
55
55
  export {
56
56
  runAgent,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FunctionCallHandler, CoAgentStateRenderHandler } from '@copilotkit/shared';
3
3
  import { Message, TextMessage, ForwardedParametersInput, ExtensionsInput } from '@copilotkit/runtime-client-gql';
4
- import { c as CopilotApiConfig, A as AgentSession, L as LangGraphInterruptAction, d as LangGraphInterruptActionSetter } from '../copilot-context-3da805ab.js';
4
+ import { c as CopilotApiConfig, A as AgentSession, L as LangGraphInterruptAction, d as LangGraphInterruptActionSetter } from '../copilot-context-f9b2b4c3.js';
5
5
  import { FrontendAction } from '../types/frontend-action.js';
6
6
  import { CoagentState } from '../types/coagent-state.js';
7
7
  import './use-tree.js';
@@ -139,35 +139,8 @@ function shouldShowDevConsole(showDevConsole) {
139
139
  // src/hooks/use-copilot-runtime-client.ts
140
140
  var useCopilotRuntimeClient = (options) => {
141
141
  const { setBannerError } = useToast();
142
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
142
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
143
143
  const lastStructuredErrorRef = (0, import_react2.useRef)(null);
144
- const traceUIError = (error, originalError) => __async(void 0, null, function* () {
145
- if (!onTrace || !runtimeOptions.publicApiKey)
146
- return;
147
- try {
148
- const traceEvent = {
149
- type: "error",
150
- timestamp: Date.now(),
151
- context: {
152
- source: "ui",
153
- request: {
154
- operation: "runtimeClient",
155
- url: runtimeOptions.url,
156
- startTime: Date.now()
157
- },
158
- technical: {
159
- environment: "browser",
160
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
161
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
162
- }
163
- },
164
- error
165
- };
166
- yield onTrace(traceEvent);
167
- } catch (traceError) {
168
- console.error("Error in onTrace handler:", traceError);
169
- }
170
- });
171
144
  const runtimeClient = (0, import_react2.useMemo)(() => {
172
145
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
173
146
  handleGQLErrors: (error) => {
@@ -195,14 +168,12 @@ var useCopilotRuntimeClient = (options) => {
195
168
  const ckError = createStructuredError(gqlError);
196
169
  if (ckError) {
197
170
  setBannerError(ckError);
198
- traceUIError(ckError, gqlError);
199
171
  } else {
200
172
  const fallbackError = new import_shared3.CopilotKitError({
201
173
  message: gqlError.message,
202
174
  code: import_shared3.CopilotKitErrorCode.UNKNOWN
203
175
  });
204
176
  setBannerError(fallbackError);
205
- traceUIError(fallbackError, gqlError);
206
177
  }
207
178
  };
208
179
  graphQLErrors.forEach(routeError);
@@ -216,7 +187,6 @@ var useCopilotRuntimeClient = (options) => {
216
187
  code: import_shared3.CopilotKitErrorCode.UNKNOWN
217
188
  });
218
189
  setBannerError(fallbackError);
219
- traceUIError(fallbackError, error);
220
190
  }
221
191
  }
222
192
  },
@@ -229,7 +199,7 @@ var useCopilotRuntimeClient = (options) => {
229
199
  setBannerError(warningError);
230
200
  }
231
201
  }));
232
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
202
+ }, [runtimeOptions, setBannerError, showDevConsole]);
233
203
  return runtimeClient;
234
204
  };
235
205
  function createStructuredError(gqlError) {
@@ -329,8 +299,7 @@ var emptyCopilotContext = {
329
299
  },
330
300
  langGraphInterruptAction: null,
331
301
  setLangGraphInterruptAction: () => null,
332
- removeLangGraphInterruptAction: () => null,
333
- onTrace: void 0
302
+ removeLangGraphInterruptAction: () => null
334
303
  };
335
304
  var CopilotContext = import_react3.default.createContext(emptyCopilotContext);
336
305
  function useCopilotContext() {
@@ -489,35 +458,6 @@ function useChat(options) {
489
458
  } = options;
490
459
  const runChatCompletionRef = (0, import_react5.useRef)();
491
460
  const addErrorToast = useErrorToast();
492
- const { setBannerError } = useToast();
493
- const { onTrace } = useCopilotContext();
494
- const traceUIError = (error, originalError) => __async(this, null, function* () {
495
- if (!onTrace || !(copilotConfig == null ? void 0 : copilotConfig.publicApiKey))
496
- return;
497
- try {
498
- const traceEvent = {
499
- type: "error",
500
- timestamp: Date.now(),
501
- context: {
502
- source: "ui",
503
- request: {
504
- operation: "useChatCompletion",
505
- url: copilotConfig.chatApiEndpoint,
506
- startTime: Date.now()
507
- },
508
- technical: {
509
- environment: "browser",
510
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
511
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
512
- }
513
- },
514
- error
515
- };
516
- yield onTrace(traceEvent);
517
- } catch (traceError) {
518
- console.error("Error in use-chat onTrace handler:", traceError);
519
- }
520
- });
521
461
  const agentSessionRef = (0, import_react5.useRef)(agentSession);
522
462
  agentSessionRef.current = agentSession;
523
463
  const runIdRef = (0, import_react5.useRef)(runId);
@@ -537,7 +477,7 @@ function useChat(options) {
537
477
  const pendingAppendsRef = (0, import_react5.useRef)([]);
538
478
  const runChatCompletion = useAsyncCallback(
539
479
  (previousMessages) => __async(this, null, function* () {
540
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
480
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
541
481
  setIsLoading(true);
542
482
  const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
543
483
  if ((interruptEvent == null ? void 0 : interruptEvent.name) === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent && (interruptEvent == null ? void 0 : interruptEvent.value) && !(interruptEvent == null ? void 0 : interruptEvent.response) && agentSessionRef.current) {
@@ -669,53 +609,20 @@ function useChat(options) {
669
609
  messages2 = (0, import_runtime_client_gql3.convertGqlOutputToMessages)(
670
610
  (0, import_runtime_client_gql3.filterAdjacentAgentStateMessages)(rawMessagesResponse)
671
611
  );
612
+ if (messages2.length === 0) {
613
+ continue;
614
+ }
672
615
  newMessages = [];
673
616
  if (((_k = value.generateCopilotResponse.status) == null ? void 0 : _k.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
674
- const guardrailsReason = ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || "";
675
617
  newMessages = [
676
618
  new import_runtime_client_gql3.TextMessage({
677
619
  role: import_runtime_client_gql3.MessageRole.Assistant,
678
- content: guardrailsReason
620
+ content: ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || ""
679
621
  })
680
622
  ];
681
- const guardrailsError = new import_shared4.CopilotKitError({
682
- message: `Guardrails validation failed: ${guardrailsReason}`,
683
- code: import_shared4.CopilotKitErrorCode.MISUSE
684
- });
685
- yield traceUIError(guardrailsError, {
686
- statusReason: value.generateCopilotResponse.status.reason,
687
- statusDetails: value.generateCopilotResponse.status.details
688
- });
689
623
  setMessages([...previousMessages, ...newMessages]);
690
624
  break;
691
- }
692
- if (((_m = value.generateCopilotResponse.status) == null ? void 0 : _m.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "UNKNOWN_ERROR") {
693
- const errorMessage = ((_n = value.generateCopilotResponse.status.details) == null ? void 0 : _n.description) || "An unknown error occurred";
694
- const statusDetails = value.generateCopilotResponse.status.details;
695
- const originalError = (statusDetails == null ? void 0 : statusDetails.originalError) || (statusDetails == null ? void 0 : statusDetails.error);
696
- const originalCode = (originalError == null ? void 0 : originalError.code) || ((_o = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _o.code);
697
- const originalSeverity = (originalError == null ? void 0 : originalError.severity) || ((_p = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _p.severity);
698
- const originalVisibility = (originalError == null ? void 0 : originalError.visibility) || ((_q = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _q.visibility);
699
- let errorCode = import_shared4.CopilotKitErrorCode.NETWORK_ERROR;
700
- if (originalCode && Object.values(import_shared4.CopilotKitErrorCode).includes(originalCode)) {
701
- errorCode = originalCode;
702
- }
703
- const structuredError = new import_shared4.CopilotKitError({
704
- message: errorMessage,
705
- code: errorCode,
706
- severity: originalSeverity,
707
- visibility: originalVisibility
708
- });
709
- setBannerError(structuredError);
710
- yield traceUIError(structuredError, {
711
- statusReason: value.generateCopilotResponse.status.reason,
712
- statusDetails: value.generateCopilotResponse.status.details,
713
- originalErrorCode: originalCode,
714
- preservedStructure: !!originalCode
715
- });
716
- setIsLoading(false);
717
- break;
718
- } else if (messages2.length > 0) {
625
+ } else {
719
626
  newMessages = [...messages2];
720
627
  for (const message of messages2) {
721
628
  if (message.isAgentStateMessage() && !message.active && !executedCoAgentStateRenders.includes(message.id) && onCoAgentStateRender) {
@@ -846,11 +753,11 @@ function useChat(options) {
846
753
  followUp !== false && // and we executed an action
847
754
  (didExecuteAction || // the last message is a server side result
848
755
  !isAgentRun && finalMessages.length && finalMessages[finalMessages.length - 1].isResultMessage()) && // the user did not stop generation
849
- !((_r = chatAbortControllerRef.current) == null ? void 0 : _r.signal.aborted)
756
+ !((_m = chatAbortControllerRef.current) == null ? void 0 : _m.signal.aborted)
850
757
  ) {
851
758
  yield new Promise((resolve) => setTimeout(resolve, 10));
852
759
  return yield runChatCompletionRef.current(finalMessages);
853
- } else if ((_s = chatAbortControllerRef.current) == null ? void 0 : _s.signal.aborted) {
760
+ } else if ((_n = chatAbortControllerRef.current) == null ? void 0 : _n.signal.aborted) {
854
761
  const repairedMessages = finalMessages.filter((message, actionExecutionIndex) => {
855
762
  if (message.isActionExecutionMessage()) {
856
763
  return finalMessages.find(
@@ -861,7 +768,7 @@ function useChat(options) {
861
768
  });
862
769
  const repairedMessageIds = repairedMessages.map((message) => message.id);
863
770
  setMessages(repairedMessages);
864
- if ((_t = agentSessionRef.current) == null ? void 0 : _t.nodeName) {
771
+ if ((_o = agentSessionRef.current) == null ? void 0 : _o.nodeName) {
865
772
  setAgentSession({
866
773
  threadId: agentSessionRef.current.threadId,
867
774
  agentName: agentSessionRef.current.agentName,