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

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 (136) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{chunk-PUNALT2S.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-C3SYYVMR.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-HJP2RX5R.mjs → chunk-JXF732XG.mjs} +3 -3
  11. package/dist/{chunk-3XXVDQ7Z.mjs → chunk-RN3ZRHI7.mjs} +8 -6
  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-2XSUXRGG.mjs → chunk-VF6UPRKM.mjs} +3 -3
  17. package/dist/{chunk-QRGDQSGZ.mjs → chunk-VJCHRQ7Q.mjs} +2 -2
  18. package/dist/{chunk-6KGEF242.mjs → chunk-XFOTNHYA.mjs} +3 -2
  19. package/dist/chunk-XFOTNHYA.mjs.map +1 -0
  20. package/dist/{chunk-IVXB3GYK.mjs → chunk-ZHEEHGLS.mjs} +4 -4
  21. package/dist/components/copilot-provider/copilot-messages.js +2 -1
  22. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  23. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  24. package/dist/components/copilot-provider/copilotkit-props.d.ts +21 -2
  25. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  26. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  27. package/dist/components/copilot-provider/copilotkit.js +38 -5
  28. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  29. package/dist/components/copilot-provider/copilotkit.mjs +4 -4
  30. package/dist/components/copilot-provider/index.d.ts +1 -1
  31. package/dist/components/copilot-provider/index.js +38 -5
  32. package/dist/components/copilot-provider/index.js.map +1 -1
  33. package/dist/components/copilot-provider/index.mjs +4 -4
  34. package/dist/components/index.d.ts +1 -1
  35. package/dist/components/index.js +38 -5
  36. package/dist/components/index.js.map +1 -1
  37. package/dist/components/index.mjs +4 -4
  38. package/dist/context/copilot-context.d.ts +1 -1
  39. package/dist/context/copilot-context.js +2 -1
  40. package/dist/context/copilot-context.js.map +1 -1
  41. package/dist/context/copilot-context.mjs +1 -1
  42. package/dist/context/index.d.ts +1 -1
  43. package/dist/context/index.js +2 -1
  44. package/dist/context/index.js.map +1 -1
  45. package/dist/context/index.mjs +1 -1
  46. package/dist/{copilot-context-f9b2b4c3.d.ts → copilot-context-3da805ab.d.ts} +5 -1
  47. package/dist/hooks/index.d.ts +1 -1
  48. package/dist/hooks/index.js +34 -3
  49. package/dist/hooks/index.js.map +1 -1
  50. package/dist/hooks/index.mjs +15 -15
  51. package/dist/hooks/use-chat.d.ts +1 -1
  52. package/dist/hooks/use-chat.js +34 -3
  53. package/dist/hooks/use-chat.js.map +1 -1
  54. package/dist/hooks/use-chat.mjs +3 -3
  55. package/dist/hooks/use-coagent-state-render.js +2 -1
  56. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  57. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  58. package/dist/hooks/use-coagent.d.ts +1 -1
  59. package/dist/hooks/use-coagent.js +34 -3
  60. package/dist/hooks/use-coagent.js.map +1 -1
  61. package/dist/hooks/use-coagent.mjs +7 -7
  62. package/dist/hooks/use-copilot-action.js +2 -1
  63. package/dist/hooks/use-copilot-action.js.map +1 -1
  64. package/dist/hooks/use-copilot-action.mjs +2 -2
  65. package/dist/hooks/use-copilot-additional-instructions.js +2 -1
  66. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  67. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  68. package/dist/hooks/use-copilot-authenticated-action.js +2 -1
  69. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  70. package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
  71. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  72. package/dist/hooks/use-copilot-chat.js +34 -3
  73. package/dist/hooks/use-copilot-chat.js.map +1 -1
  74. package/dist/hooks/use-copilot-chat.mjs +6 -6
  75. package/dist/hooks/use-copilot-readable.js +2 -1
  76. package/dist/hooks/use-copilot-readable.js.map +1 -1
  77. package/dist/hooks/use-copilot-readable.mjs +2 -2
  78. package/dist/hooks/use-copilot-runtime-client.d.ts +2 -0
  79. package/dist/hooks/use-copilot-runtime-client.js +52 -2
  80. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  81. package/dist/hooks/use-copilot-runtime-client.mjs +1 -1
  82. package/dist/hooks/use-langgraph-interrupt-render.js +2 -1
  83. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  84. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  85. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  86. package/dist/hooks/use-langgraph-interrupt.js +34 -3
  87. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  88. package/dist/hooks/use-langgraph-interrupt.mjs +7 -7
  89. package/dist/hooks/use-make-copilot-document-readable.js +2 -1
  90. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  91. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +38 -5
  94. package/dist/index.js.map +1 -1
  95. package/dist/index.mjs +16 -16
  96. package/dist/lib/copilot-task.d.ts +1 -1
  97. package/dist/lib/copilot-task.js.map +1 -1
  98. package/dist/lib/copilot-task.mjs +5 -5
  99. package/dist/lib/index.d.ts +1 -1
  100. package/dist/lib/index.js.map +1 -1
  101. package/dist/lib/index.mjs +5 -5
  102. package/dist/types/interrupt-action.d.ts +1 -1
  103. package/dist/utils/extract.d.ts +1 -1
  104. package/dist/utils/extract.js.map +1 -1
  105. package/dist/utils/extract.mjs +4 -4
  106. package/dist/utils/index.d.ts +1 -1
  107. package/dist/utils/index.js.map +1 -1
  108. package/dist/utils/index.mjs +4 -4
  109. package/package.json +3 -3
  110. package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +74 -0
  111. package/src/components/copilot-provider/copilotkit-props.tsx +21 -0
  112. package/src/components/copilot-provider/copilotkit.tsx +2 -0
  113. package/src/context/copilot-context.tsx +7 -1
  114. package/src/hooks/use-copilot-runtime-client.ts +41 -2
  115. package/tsup.config.ts +6 -6
  116. package/dist/chunk-3XXVDQ7Z.mjs.map +0 -1
  117. package/dist/chunk-6KGEF242.mjs.map +0 -1
  118. package/dist/chunk-RUY6MLHA.mjs.map +0 -1
  119. package/dist/utils/utils.test.d.ts +0 -2
  120. package/dist/utils/utils.test.js +0 -9
  121. package/dist/utils/utils.test.js.map +0 -1
  122. package/dist/utils/utils.test.mjs +0 -7
  123. package/dist/utils/utils.test.mjs.map +0 -1
  124. /package/dist/{chunk-PUNALT2S.mjs.map → chunk-7G6RR4HE.mjs.map} +0 -0
  125. /package/dist/{chunk-Q5D5XQFA.mjs.map → chunk-CMQV4XNY.mjs.map} +0 -0
  126. /package/dist/{chunk-UHQMV2CE.mjs.map → chunk-ERXWDCY6.mjs.map} +0 -0
  127. /package/dist/{chunk-C3SYYVMR.mjs.map → chunk-I4JPQECN.mjs.map} +0 -0
  128. /package/dist/{chunk-T42PN5VN.mjs.map → chunk-JHIZ5HAI.mjs.map} +0 -0
  129. /package/dist/{chunk-C6F6EQNA.mjs.map → chunk-JPMIAGI6.mjs.map} +0 -0
  130. /package/dist/{chunk-HJP2RX5R.mjs.map → chunk-JXF732XG.mjs.map} +0 -0
  131. /package/dist/{chunk-LDACFA2B.mjs.map → chunk-S4BOATBG.mjs.map} +0 -0
  132. /package/dist/{chunk-2FW7HH6W.mjs.map → chunk-T4ZKC4X4.mjs.map} +0 -0
  133. /package/dist/{chunk-LZDDYZEY.mjs.map → chunk-UBNRUXEK.mjs.map} +0 -0
  134. /package/dist/{chunk-2XSUXRGG.mjs.map → chunk-VF6UPRKM.mjs.map} +0 -0
  135. /package/dist/{chunk-QRGDQSGZ.mjs.map → chunk-VJCHRQ7Q.mjs.map} +0 -0
  136. /package/dist/{chunk-IVXB3GYK.mjs.map → chunk-ZHEEHGLS.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # ui
2
2
 
3
+ ## 1.9.2-next.5
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/runtime-client-gql@1.9.2-next.5
8
+ - @copilotkit/shared@1.9.2-next.5
9
+
10
+ ## 1.9.2-next.4
11
+
12
+ ### Patch Changes
13
+
14
+ - 9169ad7: - feat: add onTrace handler for runtime and UI error/event tracking
15
+ - 9169ad7: - feat: add onTrace handler for comprehensive debugging and observability - Add CopilotTraceEvent interfaces with rich debugging context, implement runtime-side tracing with publicApiKey gating, add UI-side error tracing, include comprehensive test coverage, and fix tsup build config to exclude test files
16
+ - fix: extract publicApiKey for all requests + trace GraphQL errors
17
+ - Updated dependencies [9169ad7]
18
+ - Updated dependencies [9169ad7]
19
+ - @copilotkit/shared@1.9.2-next.4
20
+ - @copilotkit/runtime-client-gql@1.9.2-next.4
21
+
3
22
  ## 1.9.2-next.3
4
23
 
5
24
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-3XXVDQ7Z.mjs";
3
+ } from "./chunk-RN3ZRHI7.mjs";
4
4
  import {
5
5
  processActionsForRuntimeRequest
6
6
  } from "./chunk-4CEQJ2X6.mjs";
@@ -117,4 +117,4 @@ ${instructions}
117
117
  export {
118
118
  CopilotTask
119
119
  };
120
- //# sourceMappingURL=chunk-PUNALT2S.mjs.map
120
+ //# sourceMappingURL=chunk-7G6RR4HE.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-6KGEF242.mjs";
3
+ } from "./chunk-XFOTNHYA.mjs";
4
4
 
5
5
  // src/hooks/use-langgraph-interrupt-render.ts
6
6
  import React, { useCallback } from "react";
@@ -44,4 +44,4 @@ function useLangGraphInterruptRender() {
44
44
  export {
45
45
  useLangGraphInterruptRender
46
46
  };
47
- //# sourceMappingURL=chunk-Q5D5XQFA.mjs.map
47
+ //# sourceMappingURL=chunk-CMQV4XNY.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-6KGEF242.mjs";
3
+ } from "./chunk-XFOTNHYA.mjs";
4
4
 
5
5
  // src/hooks/use-make-copilot-document-readable.ts
6
6
  import { useEffect, useRef } from "react";
@@ -20,4 +20,4 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
20
20
  export {
21
21
  useMakeCopilotDocumentReadable
22
22
  };
23
- //# sourceMappingURL=chunk-UHQMV2CE.mjs.map
23
+ //# sourceMappingURL=chunk-ERXWDCY6.mjs.map
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-3XXVDQ7Z.mjs";
3
+ } from "./chunk-RN3ZRHI7.mjs";
4
4
  import {
5
5
  useCopilotMessagesContext
6
6
  } from "./chunk-DCTJZ742.mjs";
7
7
  import {
8
8
  useChat
9
- } from "./chunk-HJP2RX5R.mjs";
9
+ } from "./chunk-JXF732XG.mjs";
10
10
  import {
11
11
  useAsyncCallback
12
12
  } from "./chunk-CCESTGAM.mjs";
13
13
  import {
14
14
  useCopilotContext
15
- } from "./chunk-6KGEF242.mjs";
15
+ } from "./chunk-XFOTNHYA.mjs";
16
16
  import {
17
17
  __async,
18
18
  __objRest,
@@ -240,4 +240,4 @@ export {
240
240
  useCopilotChat,
241
241
  defaultSystemMessage
242
242
  };
243
- //# sourceMappingURL=chunk-C3SYYVMR.mjs.map
243
+ //# sourceMappingURL=chunk-I4JPQECN.mjs.map
@@ -5,6 +5,7 @@ import {
5
5
  useToast
6
6
  } from "./chunk-VRXANACV.mjs";
7
7
  import {
8
+ __async,
8
9
  __objRest,
9
10
  __spreadProps,
10
11
  __spreadValues
@@ -26,8 +27,35 @@ import {
26
27
  } from "@copilotkit/shared";
27
28
  var useCopilotRuntimeClient = (options) => {
28
29
  const { setBannerError } = useToast();
29
- const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
30
+ const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
30
31
  const lastStructuredErrorRef = useRef(null);
32
+ const traceUIError = (error, originalError) => __async(void 0, null, function* () {
33
+ if (!onTrace || !runtimeOptions.publicApiKey)
34
+ return;
35
+ try {
36
+ const traceEvent = {
37
+ type: "error",
38
+ timestamp: Date.now(),
39
+ context: {
40
+ source: "ui",
41
+ request: {
42
+ operation: "runtimeClient",
43
+ url: runtimeOptions.url,
44
+ startTime: Date.now()
45
+ },
46
+ technical: {
47
+ environment: process.env.NODE_ENV,
48
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
49
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
50
+ }
51
+ },
52
+ error
53
+ };
54
+ yield onTrace(traceEvent);
55
+ } catch (traceError) {
56
+ console.error("Error in onTrace handler:", traceError);
57
+ }
58
+ });
31
59
  const runtimeClient = useMemo(() => {
32
60
  return new CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
33
61
  handleGQLErrors: (error) => {
@@ -55,12 +83,14 @@ var useCopilotRuntimeClient = (options) => {
55
83
  const ckError = createStructuredError(gqlError);
56
84
  if (ckError) {
57
85
  setBannerError(ckError);
86
+ traceUIError(ckError, gqlError);
58
87
  } else {
59
88
  const fallbackError = new CopilotKitError({
60
89
  message: gqlError.message,
61
90
  code: CopilotKitErrorCode.UNKNOWN
62
91
  });
63
92
  setBannerError(fallbackError);
93
+ traceUIError(fallbackError, gqlError);
64
94
  }
65
95
  };
66
96
  graphQLErrors.forEach(routeError);
@@ -74,6 +104,7 @@ var useCopilotRuntimeClient = (options) => {
74
104
  code: CopilotKitErrorCode.UNKNOWN
75
105
  });
76
106
  setBannerError(fallbackError);
107
+ traceUIError(fallbackError, error);
77
108
  }
78
109
  }
79
110
  },
@@ -86,7 +117,7 @@ var useCopilotRuntimeClient = (options) => {
86
117
  setBannerError(warningError);
87
118
  }
88
119
  }));
89
- }, [runtimeOptions, setBannerError, showDevConsole]);
120
+ }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
90
121
  return runtimeClient;
91
122
  };
92
123
  function createStructuredError(gqlError) {
@@ -116,4 +147,4 @@ function createStructuredError(gqlError) {
116
147
  export {
117
148
  useCopilotRuntimeClient
118
149
  };
119
- //# sourceMappingURL=chunk-RUY6MLHA.mjs.map
150
+ //# sourceMappingURL=chunk-ISYBUDL4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-runtime-client.ts"],"sourcesContent":["import {\n CopilotRuntimeClient,\n CopilotRuntimeClientOptions,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useMemo, useRef } from \"react\";\nimport {\n ErrorVisibility,\n CopilotKitApiDiscoveryError,\n CopilotKitRemoteEndpointDiscoveryError,\n CopilotKitAgentDiscoveryError,\n CopilotKitError,\n CopilotKitErrorCode,\n ERROR_CONFIG,\n CopilotTraceHandler,\n CopilotTraceEvent,\n} from \"@copilotkit/shared\";\nimport { shouldShowDevConsole } from \"../utils/dev-console\";\n\nexport interface CopilotRuntimeClientHookOptions extends CopilotRuntimeClientOptions {\n showDevConsole?: boolean;\n onTrace?: CopilotTraceHandler;\n}\n\nexport const useCopilotRuntimeClient = (options: CopilotRuntimeClientHookOptions) => {\n const { setBannerError } = useToast();\n const { showDevConsole, onTrace, ...runtimeOptions } = options;\n\n // Deduplication state for structured errors\n const lastStructuredErrorRef = useRef<{ message: string; timestamp: number } | null>(null);\n\n // Helper function to trace UI errors\n const traceUIError = async (error: CopilotKitError, originalError?: any) => {\n if (!onTrace || !runtimeOptions.publicApiKey) return;\n\n try {\n const traceEvent: CopilotTraceEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"ui\",\n request: {\n operation: \"runtimeClient\",\n url: runtimeOptions.url,\n startTime: Date.now(),\n },\n technical: {\n environment: process.env.NODE_ENV,\n userAgent: typeof navigator !== \"undefined\" ? navigator.userAgent : undefined,\n stackTrace: originalError instanceof Error ? originalError.stack : undefined,\n },\n },\n error,\n };\n\n await onTrace(traceEvent);\n } catch (traceError) {\n console.error(\"Error in onTrace handler:\", traceError);\n }\n };\n\n const runtimeClient = useMemo(() => {\n return new CopilotRuntimeClient({\n ...runtimeOptions,\n handleGQLErrors: (error) => {\n if ((error as any).graphQLErrors?.length) {\n const graphQLErrors = (error as any).graphQLErrors as GraphQLError[];\n\n // Route all errors to banners for consistent UI\n const routeError = (gqlError: GraphQLError) => {\n const extensions = gqlError.extensions;\n const visibility = extensions?.visibility as ErrorVisibility;\n const isDev = shouldShowDevConsole(showDevConsole ?? false);\n\n // Silent errors - just log\n if (visibility === ErrorVisibility.SILENT) {\n console.error(\"CopilotKit Silent Error:\", gqlError.message);\n return;\n }\n\n // Respect showDevConsole setting for ALL errors\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", gqlError.message);\n return;\n }\n\n // All errors (including DEV_ONLY) show as banners for consistency\n // Deduplicate to prevent spam\n const now = Date.now();\n const errorMessage = gqlError.message;\n if (\n lastStructuredErrorRef.current &&\n lastStructuredErrorRef.current.message === errorMessage &&\n now - lastStructuredErrorRef.current.timestamp < 150\n ) {\n return; // Skip duplicate\n }\n lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };\n\n const ckError = createStructuredError(gqlError);\n if (ckError) {\n setBannerError(ckError);\n // Trace the error\n traceUIError(ckError, gqlError);\n } else {\n // Fallback for unstructured errors\n const fallbackError = new CopilotKitError({\n message: gqlError.message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the fallback error\n traceUIError(fallbackError, gqlError);\n }\n };\n\n // Process all errors as banners\n graphQLErrors.forEach(routeError);\n } else {\n const isDev = shouldShowDevConsole(showDevConsole ?? false);\n if (!isDev) {\n console.error(\"CopilotKit Error (hidden in production):\", error);\n } else {\n // Route non-GraphQL errors to banner as well\n const fallbackError = new CopilotKitError({\n message: error?.message || String(error),\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the non-GraphQL error\n traceUIError(fallbackError, error);\n }\n }\n },\n handleGQLWarning: (message: string) => {\n console.warn(message);\n // Show warnings as banners too for consistency\n const warningError = new CopilotKitError({\n message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(warningError);\n },\n });\n }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);\n\n return runtimeClient;\n};\n\n// Helper to determine if error should show as banner based on structured error system\nfunction shouldShowAsBanner(gqlError: GraphQLError): boolean {\n const extensions = gqlError.extensions;\n if (!extensions) return false;\n\n // Primary: Check error code and use structured config\n const code = extensions.code as CopilotKitErrorCode;\n if (code && ERROR_CONFIG[code]?.visibility === ErrorVisibility.BANNER) {\n return true;\n }\n\n // Fallback: Check for API key errors which should always be banners\n const errorMessage = gqlError.message.toLowerCase();\n if (\n errorMessage.includes(\"api key\") ||\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"unauthorized\") ||\n errorMessage.includes(\"authentication\") ||\n errorMessage.includes(\"incorrect api key\")\n ) {\n return true;\n }\n\n // Legacy: Check by stack trace for discovery errors (for backward compatibility)\n const originalError = extensions.originalError as any;\n if (originalError?.stack) {\n return (\n originalError.stack.includes(\"CopilotApiDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitRemoteEndpointDiscoveryError\") ||\n originalError.stack.includes(\"CopilotKitAgentDiscoveryError\")\n );\n }\n\n return false;\n}\n\n// Create appropriate structured error from GraphQL error\nfunction createStructuredError(gqlError: GraphQLError): CopilotKitError | null {\n const extensions = gqlError.extensions;\n const originalError = extensions?.originalError as any;\n const message = originalError?.message || gqlError.message;\n const code = extensions?.code as CopilotKitErrorCode;\n\n if (code) {\n return new CopilotKitError({ message, code });\n }\n\n // Legacy error detection by stack trace\n if (originalError?.stack?.includes(\"CopilotApiDiscoveryError\")) {\n return new CopilotKitApiDiscoveryError({ message });\n }\n if (originalError?.stack?.includes(\"CopilotKitRemoteEndpointDiscoveryError\")) {\n return new CopilotKitRemoteEndpointDiscoveryError({ message });\n }\n if (originalError?.stack?.includes(\"CopilotKitAgentDiscoveryError\")) {\n return new CopilotKitAgentDiscoveryError({\n agentName: \"\",\n availableAgents: [],\n });\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,SAAS,cAAc;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAQA,IAAM,0BAA0B,CAAC,YAA6C;AACnF,QAAM,EAAE,eAAe,IAAI,SAAS;AACpC,QAAuD,cAA/C,kBAAgB,QA3B1B,IA2ByD,IAAnB,2BAAmB,IAAnB,CAA5B,kBAAgB;AAGxB,QAAM,yBAAyB,OAAsD,IAAI;AAGzF,QAAM,eAAe,CAAO,OAAwB,kBAAwB;AAC1E,QAAI,CAAC,WAAW,CAAC,eAAe;AAAc;AA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9D,WAAO,IAAI,4BAA4B,EAAE,QAAQ,CAAC;AAAA,EACpD;AACA,OAAI,oDAAe,UAAf,mBAAsB,SAAS,2CAA2C;AAC5E,WAAO,IAAI,uCAAuC,EAAE,QAAQ,CAAC;AAAA,EAC/D;AACA,OAAI,oDAAe,UAAf,mBAAsB,SAAS,kCAAkC;AACnE,WAAO,IAAI,8BAA8B;AAAA,MACvC,WAAW;AAAA,MACX,iBAAiB,CAAC;AAAA,IACpB,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":["_a"]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-VRXANACV.mjs";
7
7
  import {
8
8
  useCopilotContext
9
- } from "./chunk-6KGEF242.mjs";
9
+ } from "./chunk-XFOTNHYA.mjs";
10
10
  import {
11
11
  __async,
12
12
  __spreadValues
@@ -120,4 +120,4 @@ function isFrontendAction(action) {
120
120
  export {
121
121
  useCopilotAction
122
122
  };
123
- //# sourceMappingURL=chunk-T42PN5VN.mjs.map
123
+ //# sourceMappingURL=chunk-JHIZ5HAI.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-6KGEF242.mjs";
3
+ } from "./chunk-XFOTNHYA.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-additional-instructions.ts
6
6
  import { useEffect } from "react";
@@ -21,4 +21,4 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
21
21
  export {
22
22
  useCopilotAdditionalInstructions
23
23
  };
24
- //# sourceMappingURL=chunk-C6F6EQNA.mjs.map
24
+ //# sourceMappingURL=chunk-JPMIAGI6.mjs.map
@@ -7,10 +7,10 @@ import {
7
7
  } from "./chunk-CCESTGAM.mjs";
8
8
  import {
9
9
  useCopilotRuntimeClient
10
- } from "./chunk-RUY6MLHA.mjs";
10
+ } from "./chunk-ISYBUDL4.mjs";
11
11
  import {
12
12
  useCopilotContext
13
- } from "./chunk-6KGEF242.mjs";
13
+ } from "./chunk-XFOTNHYA.mjs";
14
14
  import {
15
15
  __async,
16
16
  __spreadProps,
@@ -585,4 +585,4 @@ function getPairedFeAction(actions, message) {
585
585
  export {
586
586
  useChat
587
587
  };
588
- //# sourceMappingURL=chunk-HJP2RX5R.mjs.map
588
+ //# sourceMappingURL=chunk-JXF732XG.mjs.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-QQZLIEXK.mjs";
4
4
  import {
5
5
  CopilotMessages
6
- } from "./chunk-QRGDQSGZ.mjs";
6
+ } from "./chunk-VJCHRQ7Q.mjs";
7
7
  import {
8
8
  use_flat_category_store_default
9
9
  } from "./chunk-5FHSUKQL.mjs";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-PMAFHQ7P.mjs";
16
16
  import {
17
17
  useCopilotRuntimeClient
18
- } from "./chunk-RUY6MLHA.mjs";
18
+ } from "./chunk-ISYBUDL4.mjs";
19
19
  import {
20
20
  shouldShowDevConsole
21
21
  } from "./chunk-GFJW4RIM.mjs";
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-VRXANACV.mjs";
25
25
  import {
26
26
  CopilotContext
27
- } from "./chunk-6KGEF242.mjs";
27
+ } from "./chunk-XFOTNHYA.mjs";
28
28
  import {
29
29
  __async,
30
30
  __objRest,
@@ -221,7 +221,8 @@ ${nonDocumentStrings}`;
221
221
  publicApiKey: copilotApiConfig.publicApiKey,
222
222
  headers,
223
223
  credentials: copilotApiConfig.credentials,
224
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false
224
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
225
+ onTrace: props.onTrace
225
226
  });
226
227
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState({});
227
228
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -364,7 +365,8 @@ ${nonDocumentStrings}`;
364
365
  setExtensions,
365
366
  langGraphInterruptAction,
366
367
  setLangGraphInterruptAction,
367
- removeLangGraphInterruptAction
368
+ removeLangGraphInterruptAction,
369
+ onTrace: props.onTrace
368
370
  },
369
371
  children: /* @__PURE__ */ jsx(CopilotMessages, { children: memoizedChildren })
370
372
  }
@@ -552,4 +554,4 @@ export {
552
554
  CopilotKitInternal,
553
555
  defaultCopilotContextCategories
554
556
  };
555
- //# sourceMappingURL=chunk-3XXVDQ7Z.mjs.map
557
+ //# sourceMappingURL=chunk-RN3ZRHI7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/extract.ts","../src/components/copilot-provider/copilotkit.tsx"],"sourcesContent":["import {\n Action,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n MappedParameterTypes,\n Parameter,\n actionParametersToJsonSchema,\n} from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessage,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n CopilotRequestType,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { CopilotContextParams, CopilotMessagesContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { CopilotRuntimeClient } from \"@copilotkit/runtime-client-gql\";\nimport {\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n} from \"@copilotkit/runtime-client-gql\";\n\ninterface InitialState<T extends Parameter[] | [] = []> {\n status: \"initial\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface InProgressState<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface CompleteState<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n}\n\ntype StreamHandlerArgs<T extends Parameter[] | [] = []> =\n | InitialState<T>\n | InProgressState<T>\n | CompleteState<T>;\n\ninterface ExtractOptions<T extends Parameter[]> {\n context: CopilotContextParams & CopilotMessagesContextParams;\n instructions: string;\n parameters: T;\n include?: IncludeOptions;\n data?: any;\n abortSignal?: AbortSignal;\n stream?: (args: StreamHandlerArgs<T>) => void;\n requestType?: CopilotRequestType;\n forwardedParameters?: ForwardedParametersInput;\n}\n\ninterface IncludeOptions {\n readable?: boolean;\n messages?: boolean;\n}\n\nexport async function extract<const T extends Parameter[]>({\n context,\n instructions,\n parameters,\n include,\n data,\n abortSignal,\n stream,\n requestType = CopilotRequestType.Task,\n forwardedParameters,\n}: ExtractOptions<T>): Promise<MappedParameterTypes<T>> {\n const { messages } = context;\n\n const action: Action<any> = {\n name: \"extract\",\n description: instructions,\n parameters,\n handler: (args: any) => {},\n };\n\n const includeReadable = include?.readable ?? false;\n const includeMessages = include?.messages ?? false;\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (includeReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage: Message = new TextMessage({\n content: makeSystemMessage(contextString, instructions),\n role: Role.System,\n });\n\n const instructionsMessage: Message = new TextMessage({\n content: makeInstructionsMessage(instructions),\n role: Role.User,\n });\n\n const response = context.runtimeClient.asStream(\n context.runtimeClient.generateCopilotResponse({\n data: {\n frontend: {\n actions: [\n {\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n },\n ],\n url: window.location.href,\n },\n\n messages: convertMessagesToGqlInput(\n includeMessages\n ? [systemMessage, instructionsMessage, ...filterAgentStateMessages(messages)]\n : [systemMessage, instructionsMessage],\n ),\n metadata: {\n requestType: requestType,\n },\n forwardedParameters: {\n ...(forwardedParameters ?? {}),\n toolChoice: \"function\",\n toolChoiceFunctionName: action.name,\n },\n },\n properties: context.copilotApiConfig.properties,\n signal: abortSignal,\n }),\n );\n\n const reader = response.getReader();\n\n let isInitial = true;\n\n let actionExecutionMessage: ActionExecutionMessage | undefined = undefined;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n break;\n }\n\n if (abortSignal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n actionExecutionMessage = convertGqlOutputToMessages(\n value.generateCopilotResponse.messages,\n ).find((msg) => msg.isActionExecutionMessage()) as ActionExecutionMessage | undefined;\n\n if (!actionExecutionMessage) {\n continue;\n }\n\n stream?.({\n status: isInitial ? \"initial\" : \"inProgress\",\n args: actionExecutionMessage.arguments as Partial<MappedParameterTypes<T>>,\n });\n\n isInitial = false;\n }\n\n if (!actionExecutionMessage) {\n throw new Error(\"extract() failed: No function call occurred\");\n }\n\n stream?.({\n status: \"complete\",\n args: actionExecutionMessage.arguments as MappedParameterTypes<T>,\n });\n\n return actionExecutionMessage.arguments as MappedParameterTypes<T>;\n}\n\n// We need to put this in a user message since some LLMs need\n// at least one user message to function\nfunction makeInstructionsMessage(instructions: string): string {\n return `\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n\nAny additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.\n`;\n}\n\nfunction makeSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with a function called extract you MUST call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call the function without saying anything else.\n`;\n}\n","/**\n * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.\n *\n * ## Example\n *\n * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).\n *\n * ```tsx\n * import { CopilotKit } from \"@copilotkit/react-core\";\n *\n * <CopilotKit runtimeUrl=\"<your-runtime-url>\">\n * // ... your app ...\n * </CopilotKit>\n * ```\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState, SetStateAction } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n ChatComponentsCache,\n AgentSession,\n AuthState,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { CopilotChatSuggestionConfiguration, DocumentPointer } from \"../../types\";\nimport { flushSync } from \"react-dom\";\nimport {\n COPILOT_CLOUD_CHAT_URL,\n CopilotCloudConfig,\n FunctionCallHandler,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n randomUUID,\n ConfigurationError,\n MissingPublicApiKeyError,\n} from \"@copilotkit/shared\";\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { CoAgentStateRender } from \"../../types/coagent-action\";\nimport { CoagentState } from \"../../types/coagent-state\";\nimport { CopilotMessages } from \"./copilot-messages\";\nimport { ToastProvider } from \"../toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"../../hooks/use-copilot-runtime-client\";\nimport { shouldShowDevConsole } from \"../../utils\";\nimport { CopilotErrorBoundary } from \"../error-boundary/error-boundary\";\nimport { Agent, ExtensionsInput } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetterArgs,\n} from \"../../types/interrupt-action\";\nimport { StatusChecker } from \"../../lib/status-checker\";\n\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n const showDevConsole = props.showDevConsole ?? false;\n const enabled = shouldShowDevConsole(showDevConsole);\n\n return (\n <ToastProvider enabled={enabled}>\n <CopilotErrorBoundary publicApiKey={props.publicApiKey} showUsageBanner={enabled}>\n <CopilotKitInternal {...props}>{children}</CopilotKitInternal>\n </CopilotErrorBoundary>\n </ToastProvider>\n );\n}\n\nexport function CopilotKitInternal(cpkProps: CopilotKitProps) {\n const { children, ...props } = cpkProps;\n\n /**\n * This will throw an error if the props are invalid.\n */\n validateProps(cpkProps);\n\n const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;\n\n const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});\n const [coAgentStateRenders, setCoAgentStateRenders] = useState<\n Record<string, CoAgentStateRender<any>>\n >({});\n\n const chatComponentsCache = useRef<ChatComponentsCache>({\n actions: {},\n coAgentStateRenders: {},\n });\n\n const { addElement, removeElement, printTree, getAllElements } = useTree();\n const [isLoading, setIsLoading] = useState(false);\n const [chatInstructions, setChatInstructions] = useState(\"\");\n const [authStates, setAuthStates] = useState<Record<string, AuthState>>({});\n const [extensions, setExtensions] = useState<ExtensionsInput>({});\n const [additionalInstructions, setAdditionalInstructions] = useState<string[]>([]);\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const statusChecker = useMemo(() => new StatusChecker(), []);\n\n const [usageBannerStatus, setUsageBannerStatus] = useState<any>(null);\n\n // Compute all the functions and properties that we need to pass\n\n const setAction = useCallback((id: string, action: FrontendAction<any>) => {\n setActions((prevPoints) => {\n return {\n ...prevPoints,\n [id]: action,\n };\n });\n }, []);\n\n const removeAction = useCallback((id: string) => {\n setActions((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {\n setCoAgentStateRenders((prevPoints) => {\n return {\n ...prevPoints,\n [id]: stateRender,\n };\n });\n }, []);\n\n const removeCoAgentStateRender = useCallback((id: string) => {\n setCoAgentStateRenders((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getAllContext = useCallback(() => {\n return getAllElements();\n }, [getAllElements]);\n\n const getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));\n },\n [actions],\n );\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = useMemo(() => {\n let cloud: CopilotCloudConfig | undefined = undefined;\n if (props.publicApiKey) {\n cloud = {\n guardrails: {\n input: {\n restrictToTopic: {\n enabled: Boolean(props.guardrails_c),\n validTopics: props.guardrails_c?.validTopics || [],\n invalidTopics: props.guardrails_c?.invalidTopics || [],\n },\n },\n },\n };\n }\n\n return {\n publicApiKey: props.publicApiKey,\n ...(cloud ? { cloud } : {}),\n chatApiEndpoint: chatApiEndpoint,\n headers: props.headers || {},\n properties: props.properties || {},\n transcribeAudioUrl: props.transcribeAudioUrl,\n textToSpeechUrl: props.textToSpeechUrl,\n credentials: props.credentials,\n };\n }, [\n props.publicApiKey,\n props.headers,\n props.properties,\n props.transcribeAudioUrl,\n props.textToSpeechUrl,\n props.credentials,\n props.cloudRestrictToTopic,\n props.guardrails_c,\n ]);\n\n const headers = useMemo(() => {\n const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {\n if (state.status === \"authenticated\" && state.authHeaders) {\n return {\n ...acc,\n ...Object.entries(state.authHeaders).reduce(\n (headers, [key, value]) => ({\n ...headers,\n [key.startsWith(\"X-Custom-\") ? key : `X-Custom-${key}`]: value,\n }),\n {},\n ),\n };\n }\n return acc;\n }, {});\n\n return {\n ...(copilotApiConfig.headers || {}),\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n ...authHeaders,\n };\n }, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n showDevConsole: props.showDevConsole ?? false,\n onTrace: props.onTrace,\n });\n\n const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{\n [key: string]: CopilotChatSuggestionConfiguration;\n }>({});\n\n const addChatSuggestionConfiguration = (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => {\n setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));\n };\n\n const removeChatSuggestionConfiguration = (id: string) => {\n setChatSuggestionConfiguration((prev) => {\n const { [id]: _, ...rest } = prev;\n return rest;\n });\n };\n\n const [availableAgents, setAvailableAgents] = useState<Agent[]>([]);\n const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});\n const coagentStatesRef = useRef<Record<string, CoagentState>>({});\n const setCoagentStatesWithRef = useCallback(\n (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => {\n const newValue = typeof value === \"function\" ? value(coagentStatesRef.current) : value;\n coagentStatesRef.current = newValue;\n setCoagentStates((prev) => {\n return newValue;\n });\n },\n [],\n );\n const hasLoadedAgents = useRef(false);\n\n useEffect(() => {\n if (hasLoadedAgents.current) return;\n\n const fetchData = async () => {\n const result = await runtimeClient.availableAgents();\n if (result.data?.availableAgents) {\n setAvailableAgents(result.data.availableAgents.agents);\n }\n hasLoadedAgents.current = true;\n };\n void fetchData();\n }, []);\n\n let initialAgentSession: AgentSession | null = null;\n if (props.agent) {\n initialAgentSession = {\n agentName: props.agent,\n };\n }\n\n const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);\n\n // Update agentSession when props.agent changes\n useEffect(() => {\n if (props.agent) {\n setAgentSession({\n agentName: props.agent,\n });\n } else {\n setAgentSession(null);\n }\n }, [props.agent]);\n\n const [internalThreadId, setInternalThreadId] = useState<string>(props.threadId || randomUUID());\n const setThreadId = useCallback(\n (value: SetStateAction<string>) => {\n if (props.threadId) {\n throw new Error(\"Cannot call setThreadId() when threadId is provided via props.\");\n }\n setInternalThreadId(value);\n },\n [props.threadId],\n );\n\n // update the internal threadId if the props.threadId changes\n useEffect(() => {\n if (props.threadId !== undefined) {\n setInternalThreadId(props.threadId);\n }\n }, [props.threadId]);\n\n const [runId, setRunId] = useState<string | null>(null);\n\n const chatAbortControllerRef = useRef<AbortController | null>(null);\n\n const showDevConsole = props.showDevConsole ?? false;\n\n const [langGraphInterruptAction, _setLangGraphInterruptAction] =\n useState<LangGraphInterruptAction | null>(null);\n const setLangGraphInterruptAction = useCallback((action: LangGraphInterruptActionSetterArgs) => {\n _setLangGraphInterruptAction((prev) => {\n if (prev == null) return action as LangGraphInterruptAction;\n if (action == null) return null;\n let event = prev.event;\n if (action.event) {\n // @ts-ignore\n event = { ...prev.event, ...action.event };\n }\n return { ...prev, ...action, event };\n });\n }, []);\n const removeLangGraphInterruptAction = useCallback((): void => {\n setLangGraphInterruptAction(null);\n }, []);\n\n const memoizedChildren = useMemo(() => children, [children]);\n\n return (\n <CopilotContext.Provider\n value={{\n actions,\n chatComponentsCache,\n getFunctionCallHandler,\n setAction,\n removeAction,\n coAgentStateRenders,\n setCoAgentStateRender,\n removeCoAgentStateRender,\n getContextString,\n addContext,\n removeContext,\n getAllContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n isLoading,\n setIsLoading,\n chatSuggestionConfiguration,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n chatInstructions,\n setChatInstructions,\n additionalInstructions,\n setAdditionalInstructions,\n showDevConsole,\n coagentStates,\n setCoagentStates,\n coagentStatesRef,\n setCoagentStatesWithRef,\n agentSession,\n setAgentSession,\n runtimeClient,\n forwardedParameters: props.forwardedParameters || {},\n agentLock: props.agent || null,\n threadId: internalThreadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n availableAgents,\n authConfig_c: props.authConfig_c,\n authStates_c: authStates,\n setAuthStates_c: setAuthStates,\n extensions,\n setExtensions,\n langGraphInterruptAction,\n setLangGraphInterruptAction,\n removeLangGraphInterruptAction,\n onTrace: props.onTrace,\n }}\n >\n <CopilotMessages>{memoizedChildren}</CopilotMessages>\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async ({ name, args }) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[name];\n let result: any = undefined;\n if (action) {\n await new Promise<void>((resolve, reject) => {\n flushSync(async () => {\n try {\n result = await action.handler?.(args);\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n });\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n return result;\n };\n}\n\nfunction formatFeatureName(featureName: string): string {\n return featureName\n .replace(/_c$/, \"\")\n .split(\"_\")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \");\n}\n\nfunction validateProps(props: CopilotKitProps): never | void {\n const cloudFeatures = Object.keys(props).filter((key) => key.endsWith(\"_c\"));\n\n if (!props.runtimeUrl && !props.publicApiKey) {\n throw new ConfigurationError(\"Missing required prop: 'runtimeUrl' or 'publicApiKey'\");\n }\n\n if (cloudFeatures.length > 0 && !props.publicApiKey) {\n throw new MissingPublicApiKeyError(\n `Missing required prop: 'publicApiKey' to use cloud features: ${cloudFeatures\n .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C,QAAI,YAAY;AAEhB,QAAI,yBAA6D;AAEjE,WAAO,MAAM;AACX,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,UAAI,MAAM;AACR;AAAA,MACF;AAEA,UAAI,2CAAa,SAAS;AACxB,cAAM,IAAI,MAAM,SAAS;AAAA,MAC3B;AAEA,+BAAyB;AAAA,QACvB,MAAM,wBAAwB;AAAA,MAChC,EAAE,KAAK,CAAC,QAAQ,IAAI,yBAAyB,CAAC;AAE9C,UAAI,CAAC,wBAAwB;AAC3B;AAAA,MACF;AAEA,uCAAS;AAAA,QACP,QAAQ,YAAY,YAAY;AAAA,QAChC,MAAM,uBAAuB;AAAA,MAC/B;AAEA,kBAAY;AAAA,IACd;AAEA,QAAI,CAAC,wBAAwB;AAC3B,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,qCAAS;AAAA,MACP,QAAQ;AAAA,MACR,MAAM,uBAAuB;AAAA,IAC/B;AAEA,WAAO,uBAAuB;AAAA,EAChC;AAAA;AAIA,SAAS,wBAAwB,cAA8B;AAC7D,SAAO;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA;AAAA;AAAA;AAAA;AAKF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;","names":["_a","_b","headers","action"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  useCopilotAction
3
- } from "./chunk-T42PN5VN.mjs";
3
+ } from "./chunk-JHIZ5HAI.mjs";
4
4
  import {
5
5
  useCopilotContext
6
- } from "./chunk-6KGEF242.mjs";
6
+ } from "./chunk-XFOTNHYA.mjs";
7
7
  import {
8
8
  __spreadProps,
9
9
  __spreadValues
@@ -56,4 +56,4 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
56
56
  export {
57
57
  useCopilotAuthenticatedAction_c
58
58
  };
59
- //# sourceMappingURL=chunk-LDACFA2B.mjs.map
59
+ //# sourceMappingURL=chunk-S4BOATBG.mjs.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VRXANACV.mjs";
4
4
  import {
5
5
  CopilotContext
6
- } from "./chunk-6KGEF242.mjs";
6
+ } from "./chunk-XFOTNHYA.mjs";
7
7
 
8
8
  // src/hooks/use-coagent-state-render.ts
9
9
  import { useRef, useContext, useEffect } from "react";
@@ -85,4 +85,4 @@ function useCoAgentStateRender(action, dependencies) {
85
85
  export {
86
86
  useCoAgentStateRender
87
87
  };
88
- //# sourceMappingURL=chunk-2FW7HH6W.mjs.map
88
+ //# sourceMappingURL=chunk-T4ZKC4X4.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-6KGEF242.mjs";
3
+ } from "./chunk-XFOTNHYA.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-readable.ts
6
6
  import { useEffect, useRef } from "react";
@@ -34,4 +34,4 @@ function useCopilotReadable({
34
34
  export {
35
35
  useCopilotReadable
36
36
  };
37
- //# sourceMappingURL=chunk-LZDDYZEY.mjs.map
37
+ //# sourceMappingURL=chunk-UBNRUXEK.mjs.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "./chunk-C3SYYVMR.mjs";
3
+ } from "./chunk-I4JPQECN.mjs";
4
4
  import {
5
5
  useToast
6
6
  } from "./chunk-VRXANACV.mjs";
7
7
  import {
8
8
  CopilotContext
9
- } from "./chunk-6KGEF242.mjs";
9
+ } from "./chunk-XFOTNHYA.mjs";
10
10
  import {
11
11
  __spreadProps,
12
12
  __spreadValues
@@ -62,4 +62,4 @@ function useLangGraphInterrupt(action, dependencies) {
62
62
  export {
63
63
  useLangGraphInterrupt
64
64
  };
65
- //# sourceMappingURL=chunk-2XSUXRGG.mjs.map
65
+ //# sourceMappingURL=chunk-VF6UPRKM.mjs.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-VRXANACV.mjs";
10
10
  import {
11
11
  useCopilotContext
12
- } from "./chunk-6KGEF242.mjs";
12
+ } from "./chunk-XFOTNHYA.mjs";
13
13
  import {
14
14
  __async
15
15
  } from "./chunk-SKC7AJIV.mjs";
@@ -152,4 +152,4 @@ function CopilotMessages({ children }) {
152
152
  export {
153
153
  CopilotMessages
154
154
  };
155
- //# sourceMappingURL=chunk-QRGDQSGZ.mjs.map
155
+ //# sourceMappingURL=chunk-VJCHRQ7Q.mjs.map
@@ -75,7 +75,8 @@ var emptyCopilotContext = {
75
75
  },
76
76
  langGraphInterruptAction: null,
77
77
  setLangGraphInterruptAction: () => null,
78
- removeLangGraphInterruptAction: () => null
78
+ removeLangGraphInterruptAction: () => null,
79
+ onTrace: void 0
79
80
  };
80
81
  var CopilotContext = React.createContext(emptyCopilotContext);
81
82
  function useCopilotContext() {
@@ -93,4 +94,4 @@ export {
93
94
  CopilotContext,
94
95
  useCopilotContext
95
96
  };
96
- //# sourceMappingURL=chunk-6KGEF242.mjs.map
97
+ //# sourceMappingURL=chunk-XFOTNHYA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["import { CopilotCloudConfig, FunctionCallHandler, CopilotTraceHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId, Tree } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetter,\n} from \"../types/interrupt-action\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Optional configuration for connecting to Model Context Protocol (MCP) servers.\n * This is typically derived from the CopilotKitProps and used internally.\n * @experimental\n */\n mcpServers?: Array<{ endpoint: string; apiKey?: string }>;\n}\n\nexport type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =\n (props: TProps) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\nexport type ContextTree = Tree;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getAllContext: () => Tree;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n additionalInstructions?: string[];\n setAdditionalInstructions: React.Dispatch<React.SetStateAction<string[]>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean;\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n langGraphInterruptAction: LangGraphInterruptAction | null;\n setLangGraphInterruptAction: LangGraphInterruptActionSetter;\n removeLangGraphInterruptAction: () => void;\n\n /**\n * Optional trace handler for comprehensive debugging and observability.\n */\n onTrace?: CopilotTraceHandler;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n getAllContext: () => [],\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n additionalInstructions: [],\n setAdditionalInstructions: () => returnAndThrowInDebug([]),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: false,\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n langGraphInterruptAction: null,\n setLangGraphInterruptAction: () => null,\n removeLangGraphInterruptAction: () => null,\n onTrace: undefined,\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;AAMA,OAAO,WAAW;AA6NlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAA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AO;AAAA,EACP,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,wBAAwB,EAAE,SAAS,KAAK;AAAA,EACxC,iBAAiB,CAAC;AAAA,EAClB,YAAY,CAAC;AAAA,EACb,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,0BAA0B;AAAA,EAC1B,6BAA6B,MAAM;AAAA,EACnC,gCAAgC,MAAM;AAAA,EACtC,SAAS;AACX;AAEO,IAAM,iBAAiB,MAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,MAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,QAAc;AAC9C,QAAM,IAAI,MAAM,uEAAuE;AACzF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "./chunk-C3SYYVMR.mjs";
3
+ } from "./chunk-I4JPQECN.mjs";
4
4
  import {
5
5
  useCopilotMessagesContext
6
6
  } from "./chunk-DCTJZ742.mjs";
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-CCESTGAM.mjs";
10
10
  import {
11
11
  useCopilotRuntimeClient
12
- } from "./chunk-RUY6MLHA.mjs";
12
+ } from "./chunk-ISYBUDL4.mjs";
13
13
  import {
14
14
  useToast
15
15
  } from "./chunk-VRXANACV.mjs";
16
16
  import {
17
17
  useCopilotContext
18
- } from "./chunk-6KGEF242.mjs";
18
+ } from "./chunk-XFOTNHYA.mjs";
19
19
  import {
20
20
  __async,
21
21
  __spreadProps,
@@ -207,4 +207,4 @@ export {
207
207
  stopAgent,
208
208
  runAgent
209
209
  };
210
- //# sourceMappingURL=chunk-IVXB3GYK.mjs.map
210
+ //# sourceMappingURL=chunk-ZHEEHGLS.mjs.map
@@ -139,7 +139,8 @@ var emptyCopilotContext2 = {
139
139
  },
140
140
  langGraphInterruptAction: null,
141
141
  setLangGraphInterruptAction: () => null,
142
- removeLangGraphInterruptAction: () => null
142
+ removeLangGraphInterruptAction: () => null,
143
+ onTrace: void 0
143
144
  };
144
145
  var CopilotContext = import_react2.default.createContext(emptyCopilotContext2);
145
146
  function useCopilotContext() {