@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
@@ -2,20 +2,20 @@ import {
2
2
  CopilotKit,
3
3
  CopilotKitInternal,
4
4
  defaultCopilotContextCategories
5
- } from "../../chunk-L6QAOAE4.mjs";
5
+ } from "../../chunk-RN3ZRHI7.mjs";
6
6
  import "../../chunk-QQZLIEXK.mjs";
7
- import "../../chunk-NNSXCFQO.mjs";
7
+ import "../../chunk-VJCHRQ7Q.mjs";
8
+ import "../../chunk-5FHSUKQL.mjs";
8
9
  import "../../chunk-RKTVJRK7.mjs";
9
10
  import "../../chunk-PMAFHQ7P.mjs";
10
- import "../../chunk-5FHSUKQL.mjs";
11
- import "../../chunk-DCTJZ742.mjs";
12
11
  import "../../chunk-HD2GE3DK.mjs";
13
- import "../../chunk-RUY6MLHA.mjs";
14
- import "../../chunk-GFJW4RIM.mjs";
12
+ import "../../chunk-DCTJZ742.mjs";
15
13
  import "../../chunk-CCESTGAM.mjs";
16
14
  import "../../chunk-O7ARI5CV.mjs";
15
+ import "../../chunk-ISYBUDL4.mjs";
16
+ import "../../chunk-GFJW4RIM.mjs";
17
17
  import "../../chunk-VRXANACV.mjs";
18
- import "../../chunk-6KGEF242.mjs";
18
+ import "../../chunk-XFOTNHYA.mjs";
19
19
  import "../../chunk-SKC7AJIV.mjs";
20
20
  export {
21
21
  CopilotKit,
@@ -3,7 +3,7 @@ export { CopilotKitProps } from './copilotkit-props.js';
3
3
  import 'react/jsx-runtime';
4
4
  import '@copilotkit/runtime-client-gql';
5
5
  import 'react';
6
- import '../../copilot-context-f9b2b4c3.js';
6
+ import '../../copilot-context-3da805ab.js';
7
7
  import '@copilotkit/shared';
8
8
  import '../../types/frontend-action.js';
9
9
  import '../../hooks/use-tree.js';
@@ -161,7 +161,8 @@ var emptyCopilotContext = {
161
161
  },
162
162
  langGraphInterruptAction: null,
163
163
  setLangGraphInterruptAction: () => null,
164
- removeLangGraphInterruptAction: () => null
164
+ removeLangGraphInterruptAction: () => null,
165
+ onTrace: void 0
165
166
  };
166
167
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
167
168
  function useCopilotContext() {
@@ -776,6 +777,7 @@ function CopilotMessages({ children }) {
776
777
  });
777
778
  void fetchMessages();
778
779
  }, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
780
+ const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
779
781
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
780
782
  CopilotMessagesContext.Provider,
781
783
  {
@@ -783,7 +785,7 @@ function CopilotMessages({ children }) {
783
785
  messages,
784
786
  setMessages
785
787
  },
786
- children
788
+ children: memoizedChildren
787
789
  }
788
790
  );
789
791
  }
@@ -794,8 +796,35 @@ var import_react7 = require("react");
794
796
  var import_shared5 = require("@copilotkit/shared");
795
797
  var useCopilotRuntimeClient = (options) => {
796
798
  const { setBannerError } = useToast();
797
- const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
799
+ const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
798
800
  const lastStructuredErrorRef = (0, import_react7.useRef)(null);
801
+ const traceUIError = (error, originalError) => __async(void 0, null, function* () {
802
+ if (!onTrace || !runtimeOptions.publicApiKey)
803
+ return;
804
+ try {
805
+ const traceEvent = {
806
+ type: "error",
807
+ timestamp: Date.now(),
808
+ context: {
809
+ source: "ui",
810
+ request: {
811
+ operation: "runtimeClient",
812
+ url: runtimeOptions.url,
813
+ startTime: Date.now()
814
+ },
815
+ technical: {
816
+ environment: process.env.NODE_ENV,
817
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
818
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
819
+ }
820
+ },
821
+ error
822
+ };
823
+ yield onTrace(traceEvent);
824
+ } catch (traceError) {
825
+ console.error("Error in onTrace handler:", traceError);
826
+ }
827
+ });
799
828
  const runtimeClient = (0, import_react7.useMemo)(() => {
800
829
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
801
830
  handleGQLErrors: (error) => {
@@ -823,12 +852,14 @@ var useCopilotRuntimeClient = (options) => {
823
852
  const ckError = createStructuredError(gqlError);
824
853
  if (ckError) {
825
854
  setBannerError(ckError);
855
+ traceUIError(ckError, gqlError);
826
856
  } else {
827
857
  const fallbackError = new import_shared5.CopilotKitError({
828
858
  message: gqlError.message,
829
859
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
830
860
  });
831
861
  setBannerError(fallbackError);
862
+ traceUIError(fallbackError, gqlError);
832
863
  }
833
864
  };
834
865
  graphQLErrors.forEach(routeError);
@@ -842,6 +873,7 @@ var useCopilotRuntimeClient = (options) => {
842
873
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
843
874
  });
844
875
  setBannerError(fallbackError);
876
+ traceUIError(fallbackError, error);
845
877
  }
846
878
  }
847
879
  },
@@ -854,7 +886,7 @@ var useCopilotRuntimeClient = (options) => {
854
886
  setBannerError(warningError);
855
887
  }
856
888
  }));
857
- }, [runtimeOptions, setBannerError, showDevConsole]);
889
+ }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
858
890
  return runtimeClient;
859
891
  };
860
892
  function createStructuredError(gqlError) {
@@ -1634,7 +1666,8 @@ ${nonDocumentStrings}`;
1634
1666
  publicApiKey: copilotApiConfig.publicApiKey,
1635
1667
  headers,
1636
1668
  credentials: copilotApiConfig.credentials,
1637
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false
1669
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1670
+ onTrace: props.onTrace
1638
1671
  });
1639
1672
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1640
1673
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -1724,6 +1757,7 @@ ${nonDocumentStrings}`;
1724
1757
  const removeLangGraphInterruptAction = (0, import_react10.useCallback)(() => {
1725
1758
  setLangGraphInterruptAction(null);
1726
1759
  }, []);
1760
+ const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
1727
1761
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1728
1762
  CopilotContext.Provider,
1729
1763
  {
@@ -1776,9 +1810,10 @@ ${nonDocumentStrings}`;
1776
1810
  setExtensions,
1777
1811
  langGraphInterruptAction,
1778
1812
  setLangGraphInterruptAction,
1779
- removeLangGraphInterruptAction
1813
+ removeLangGraphInterruptAction,
1814
+ onTrace: props.onTrace
1780
1815
  },
1781
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children })
1816
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
1782
1817
  }
1783
1818
  );
1784
1819
  }