@copilotkit/react-core 1.9.2-next.2 → 1.9.2-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 (138) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-FRZZPPIV.mjs → chunk-7G6RR4HE.mjs} +2 -2
  3. package/dist/{chunk-Q5D5XQFA.mjs → chunk-CMQV4XNY.mjs} +2 -2
  4. package/dist/{chunk-UHQMV2CE.mjs → chunk-ERXWDCY6.mjs} +2 -2
  5. package/dist/{chunk-4I7PLQF7.mjs → chunk-I4JPQECN.mjs} +4 -4
  6. package/dist/{chunk-RUY6MLHA.mjs → chunk-ISYBUDL4.mjs} +34 -3
  7. package/dist/chunk-ISYBUDL4.mjs.map +1 -0
  8. package/dist/{chunk-T42PN5VN.mjs → chunk-JHIZ5HAI.mjs} +2 -2
  9. package/dist/{chunk-C6F6EQNA.mjs → chunk-JPMIAGI6.mjs} +2 -2
  10. package/dist/{chunk-MGIXEJWG.mjs → chunk-JXF732XG.mjs} +5 -5
  11. package/dist/{chunk-L6QAOAE4.mjs → chunk-RN3ZRHI7.mjs} +13 -10
  12. package/dist/chunk-RN3ZRHI7.mjs.map +1 -0
  13. package/dist/{chunk-LDACFA2B.mjs → chunk-S4BOATBG.mjs} +3 -3
  14. package/dist/{chunk-2FW7HH6W.mjs → chunk-T4ZKC4X4.mjs} +2 -2
  15. package/dist/{chunk-LZDDYZEY.mjs → chunk-UBNRUXEK.mjs} +2 -2
  16. package/dist/{chunk-OUSWPVDT.mjs → chunk-VF6UPRKM.mjs} +3 -3
  17. package/dist/{chunk-NNSXCFQO.mjs → chunk-VJCHRQ7Q.mjs} +5 -4
  18. package/dist/chunk-VJCHRQ7Q.mjs.map +1 -0
  19. package/dist/{chunk-6KGEF242.mjs → chunk-XFOTNHYA.mjs} +3 -2
  20. package/dist/chunk-XFOTNHYA.mjs.map +1 -0
  21. package/dist/{chunk-CMKIDDQL.mjs → chunk-ZHEEHGLS.mjs} +6 -6
  22. package/dist/components/copilot-provider/copilot-messages.js +4 -2
  23. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  24. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  25. package/dist/components/copilot-provider/copilotkit-props.d.ts +21 -2
  26. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  27. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  28. package/dist/components/copilot-provider/copilotkit.js +42 -7
  29. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  30. package/dist/components/copilot-provider/copilotkit.mjs +7 -7
  31. package/dist/components/copilot-provider/index.d.ts +1 -1
  32. package/dist/components/copilot-provider/index.js +42 -7
  33. package/dist/components/copilot-provider/index.js.map +1 -1
  34. package/dist/components/copilot-provider/index.mjs +7 -7
  35. package/dist/components/index.d.ts +1 -1
  36. package/dist/components/index.js +42 -7
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/index.mjs +7 -7
  39. package/dist/context/copilot-context.d.ts +1 -1
  40. package/dist/context/copilot-context.js +2 -1
  41. package/dist/context/copilot-context.js.map +1 -1
  42. package/dist/context/copilot-context.mjs +1 -1
  43. package/dist/context/index.d.ts +1 -1
  44. package/dist/context/index.js +2 -1
  45. package/dist/context/index.js.map +1 -1
  46. package/dist/context/index.mjs +1 -1
  47. package/dist/{copilot-context-f9b2b4c3.d.ts → copilot-context-3da805ab.d.ts} +5 -1
  48. package/dist/hooks/index.d.ts +1 -1
  49. package/dist/hooks/index.js +34 -3
  50. package/dist/hooks/index.js.map +1 -1
  51. package/dist/hooks/index.mjs +30 -30
  52. package/dist/hooks/use-chat.d.ts +1 -1
  53. package/dist/hooks/use-chat.js +34 -3
  54. package/dist/hooks/use-chat.js.map +1 -1
  55. package/dist/hooks/use-chat.mjs +4 -4
  56. package/dist/hooks/use-coagent-state-render.js +2 -1
  57. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  58. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  59. package/dist/hooks/use-coagent.d.ts +1 -1
  60. package/dist/hooks/use-coagent.js +34 -3
  61. package/dist/hooks/use-coagent.js.map +1 -1
  62. package/dist/hooks/use-coagent.mjs +11 -11
  63. package/dist/hooks/use-copilot-action.js +2 -1
  64. package/dist/hooks/use-copilot-action.js.map +1 -1
  65. package/dist/hooks/use-copilot-action.mjs +2 -2
  66. package/dist/hooks/use-copilot-additional-instructions.js +2 -1
  67. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  68. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  69. package/dist/hooks/use-copilot-authenticated-action.js +2 -1
  70. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  71. package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
  72. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  73. package/dist/hooks/use-copilot-chat.js +34 -3
  74. package/dist/hooks/use-copilot-chat.js.map +1 -1
  75. package/dist/hooks/use-copilot-chat.mjs +10 -10
  76. package/dist/hooks/use-copilot-readable.js +2 -1
  77. package/dist/hooks/use-copilot-readable.js.map +1 -1
  78. package/dist/hooks/use-copilot-readable.mjs +2 -2
  79. package/dist/hooks/use-copilot-runtime-client.d.ts +2 -0
  80. package/dist/hooks/use-copilot-runtime-client.js +52 -2
  81. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  82. package/dist/hooks/use-copilot-runtime-client.mjs +1 -1
  83. package/dist/hooks/use-langgraph-interrupt-render.js +2 -1
  84. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  85. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  86. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  87. package/dist/hooks/use-langgraph-interrupt.js +34 -3
  88. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  89. package/dist/hooks/use-langgraph-interrupt.mjs +11 -11
  90. package/dist/hooks/use-make-copilot-document-readable.js +2 -1
  91. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  92. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +42 -7
  95. package/dist/index.js.map +1 -1
  96. package/dist/index.mjs +31 -31
  97. package/dist/lib/copilot-task.d.ts +1 -1
  98. package/dist/lib/copilot-task.js.map +1 -1
  99. package/dist/lib/copilot-task.mjs +8 -8
  100. package/dist/lib/index.d.ts +1 -1
  101. package/dist/lib/index.js.map +1 -1
  102. package/dist/lib/index.mjs +8 -8
  103. package/dist/types/interrupt-action.d.ts +1 -1
  104. package/dist/utils/extract.d.ts +1 -1
  105. package/dist/utils/extract.js.map +1 -1
  106. package/dist/utils/extract.mjs +7 -7
  107. package/dist/utils/index.d.ts +1 -1
  108. package/dist/utils/index.js.map +1 -1
  109. package/dist/utils/index.mjs +8 -8
  110. package/package.json +5 -5
  111. package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +74 -0
  112. package/src/components/copilot-provider/copilot-messages.tsx +4 -2
  113. package/src/components/copilot-provider/copilotkit-props.tsx +21 -0
  114. package/src/components/copilot-provider/copilotkit.tsx +5 -1
  115. package/src/context/copilot-context.tsx +7 -1
  116. package/src/hooks/use-copilot-runtime-client.ts +41 -2
  117. package/tsup.config.ts +6 -6
  118. package/dist/chunk-6KGEF242.mjs.map +0 -1
  119. package/dist/chunk-L6QAOAE4.mjs.map +0 -1
  120. package/dist/chunk-NNSXCFQO.mjs.map +0 -1
  121. package/dist/chunk-RUY6MLHA.mjs.map +0 -1
  122. package/dist/utils/utils.test.d.ts +0 -2
  123. package/dist/utils/utils.test.js +0 -9
  124. package/dist/utils/utils.test.js.map +0 -1
  125. package/dist/utils/utils.test.mjs +0 -7
  126. package/dist/utils/utils.test.mjs.map +0 -1
  127. /package/dist/{chunk-FRZZPPIV.mjs.map → chunk-7G6RR4HE.mjs.map} +0 -0
  128. /package/dist/{chunk-Q5D5XQFA.mjs.map → chunk-CMQV4XNY.mjs.map} +0 -0
  129. /package/dist/{chunk-UHQMV2CE.mjs.map → chunk-ERXWDCY6.mjs.map} +0 -0
  130. /package/dist/{chunk-4I7PLQF7.mjs.map → chunk-I4JPQECN.mjs.map} +0 -0
  131. /package/dist/{chunk-T42PN5VN.mjs.map → chunk-JHIZ5HAI.mjs.map} +0 -0
  132. /package/dist/{chunk-C6F6EQNA.mjs.map → chunk-JPMIAGI6.mjs.map} +0 -0
  133. /package/dist/{chunk-MGIXEJWG.mjs.map → chunk-JXF732XG.mjs.map} +0 -0
  134. /package/dist/{chunk-LDACFA2B.mjs.map → chunk-S4BOATBG.mjs.map} +0 -0
  135. /package/dist/{chunk-2FW7HH6W.mjs.map → chunk-T4ZKC4X4.mjs.map} +0 -0
  136. /package/dist/{chunk-LZDDYZEY.mjs.map → chunk-UBNRUXEK.mjs.map} +0 -0
  137. /package/dist/{chunk-OUSWPVDT.mjs.map → chunk-VF6UPRKM.mjs.map} +0 -0
  138. /package/dist/{chunk-CMKIDDQL.mjs.map → chunk-ZHEEHGLS.mjs.map} +0 -0
@@ -1,56 +1,56 @@
1
1
  import "../chunk-CQPYJIBH.mjs";
2
- import {
3
- useMakeCopilotDocumentReadable
4
- } from "../chunk-UHQMV2CE.mjs";
5
- import {
6
- useCopilotAdditionalInstructions
7
- } from "../chunk-C6F6EQNA.mjs";
8
- import {
9
- useCopilotAuthenticatedAction_c
10
- } from "../chunk-LDACFA2B.mjs";
11
- import {
12
- useCopilotReadable
13
- } from "../chunk-LZDDYZEY.mjs";
14
2
  import {
15
3
  useLangGraphInterruptRender
16
- } from "../chunk-Q5D5XQFA.mjs";
4
+ } from "../chunk-CMQV4XNY.mjs";
17
5
  import {
18
6
  useLangGraphInterrupt
19
- } from "../chunk-OUSWPVDT.mjs";
7
+ } from "../chunk-VF6UPRKM.mjs";
8
+ import {
9
+ useMakeCopilotDocumentReadable
10
+ } from "../chunk-ERXWDCY6.mjs";
20
11
  import {
21
12
  useCoAgentStateRender
22
- } from "../chunk-2FW7HH6W.mjs";
13
+ } from "../chunk-T4ZKC4X4.mjs";
23
14
  import {
24
15
  runAgent,
25
16
  startAgent,
26
17
  stopAgent,
27
18
  useCoAgent
28
- } from "../chunk-CMKIDDQL.mjs";
19
+ } from "../chunk-ZHEEHGLS.mjs";
20
+ import {
21
+ useCopilotAdditionalInstructions
22
+ } from "../chunk-JPMIAGI6.mjs";
23
+ import {
24
+ useCopilotAuthenticatedAction_c
25
+ } from "../chunk-S4BOATBG.mjs";
26
+ import {
27
+ useCopilotAction
28
+ } from "../chunk-JHIZ5HAI.mjs";
29
29
  import {
30
30
  useCopilotChat
31
- } from "../chunk-4I7PLQF7.mjs";
32
- import "../chunk-YPSGKPDA.mjs";
33
- import "../chunk-L6QAOAE4.mjs";
31
+ } from "../chunk-I4JPQECN.mjs";
32
+ import {
33
+ useCopilotReadable
34
+ } from "../chunk-UBNRUXEK.mjs";
35
+ import "../chunk-RN3ZRHI7.mjs";
34
36
  import "../chunk-QQZLIEXK.mjs";
35
- import "../chunk-NNSXCFQO.mjs";
37
+ import "../chunk-VJCHRQ7Q.mjs";
38
+ import "../chunk-5FHSUKQL.mjs";
36
39
  import "../chunk-RKTVJRK7.mjs";
37
40
  import "../chunk-PMAFHQ7P.mjs";
38
- import "../chunk-5FHSUKQL.mjs";
39
- import "../chunk-DCTJZ742.mjs";
40
41
  import "../chunk-HD2GE3DK.mjs";
41
- import "../chunk-MGIXEJWG.mjs";
42
+ import "../chunk-YPSGKPDA.mjs";
43
+ import "../chunk-DCTJZ742.mjs";
44
+ import "../chunk-JXF732XG.mjs";
42
45
  import "../chunk-4CEQJ2X6.mjs";
46
+ import "../chunk-CCESTGAM.mjs";
47
+ import "../chunk-O7ARI5CV.mjs";
43
48
  import {
44
49
  useCopilotRuntimeClient
45
- } from "../chunk-RUY6MLHA.mjs";
50
+ } from "../chunk-ISYBUDL4.mjs";
46
51
  import "../chunk-GFJW4RIM.mjs";
47
- import {
48
- useCopilotAction
49
- } from "../chunk-T42PN5VN.mjs";
50
- import "../chunk-CCESTGAM.mjs";
51
- import "../chunk-O7ARI5CV.mjs";
52
52
  import "../chunk-VRXANACV.mjs";
53
- import "../chunk-6KGEF242.mjs";
53
+ import "../chunk-XFOTNHYA.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-f9b2b4c3.js';
4
+ import { c as CopilotApiConfig, A as AgentSession, L as LangGraphInterruptAction, d as LangGraphInterruptActionSetter } from '../copilot-context-3da805ab.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,8 +139,35 @@ 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 } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
142
+ const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
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: process.env.NODE_ENV,
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
+ });
144
171
  const runtimeClient = (0, import_react2.useMemo)(() => {
145
172
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
146
173
  handleGQLErrors: (error) => {
@@ -168,12 +195,14 @@ var useCopilotRuntimeClient = (options) => {
168
195
  const ckError = createStructuredError(gqlError);
169
196
  if (ckError) {
170
197
  setBannerError(ckError);
198
+ traceUIError(ckError, gqlError);
171
199
  } else {
172
200
  const fallbackError = new import_shared3.CopilotKitError({
173
201
  message: gqlError.message,
174
202
  code: import_shared3.CopilotKitErrorCode.UNKNOWN
175
203
  });
176
204
  setBannerError(fallbackError);
205
+ traceUIError(fallbackError, gqlError);
177
206
  }
178
207
  };
179
208
  graphQLErrors.forEach(routeError);
@@ -187,6 +216,7 @@ var useCopilotRuntimeClient = (options) => {
187
216
  code: import_shared3.CopilotKitErrorCode.UNKNOWN
188
217
  });
189
218
  setBannerError(fallbackError);
219
+ traceUIError(fallbackError, error);
190
220
  }
191
221
  }
192
222
  },
@@ -199,7 +229,7 @@ var useCopilotRuntimeClient = (options) => {
199
229
  setBannerError(warningError);
200
230
  }
201
231
  }));
202
- }, [runtimeOptions, setBannerError, showDevConsole]);
232
+ }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
203
233
  return runtimeClient;
204
234
  };
205
235
  function createStructuredError(gqlError) {
@@ -299,7 +329,8 @@ var emptyCopilotContext = {
299
329
  },
300
330
  langGraphInterruptAction: null,
301
331
  setLangGraphInterruptAction: () => null,
302
- removeLangGraphInterruptAction: () => null
332
+ removeLangGraphInterruptAction: () => null,
333
+ onTrace: void 0
303
334
  };
304
335
  var CopilotContext = import_react3.default.createContext(emptyCopilotContext);
305
336
  function useCopilotContext() {