@copilotkit/react-core 1.54.1 → 1.55.0-next.8

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 (183) hide show
  1. package/CHANGELOG.md +127 -116
  2. package/dist/copilotkit-B3Mb1yVE.cjs +7975 -0
  3. package/dist/copilotkit-B3Mb1yVE.cjs.map +1 -0
  4. package/dist/copilotkit-DBzgOMby.d.cts +2182 -0
  5. package/dist/copilotkit-DBzgOMby.d.cts.map +1 -0
  6. package/dist/copilotkit-DNYSFuz5.mjs +7562 -0
  7. package/dist/copilotkit-DNYSFuz5.mjs.map +1 -0
  8. package/dist/copilotkit-Dy5w3qEV.d.mts +2182 -0
  9. package/dist/copilotkit-Dy5w3qEV.d.mts.map +1 -0
  10. package/dist/index.cjs +27 -28
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +3 -3
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +3 -3
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +4 -5
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/index.umd.js +1941 -35
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/v2/index.cjs +77 -7
  21. package/dist/v2/index.css +1 -2
  22. package/dist/v2/index.d.cts +6 -4
  23. package/dist/v2/index.d.mts +6 -4
  24. package/dist/v2/index.mjs +7 -4
  25. package/dist/v2/index.umd.js +5725 -24
  26. package/dist/v2/index.umd.js.map +1 -1
  27. package/package.json +37 -9
  28. package/scripts/scope-preflight.mjs +101 -0
  29. package/src/components/CopilotListeners.tsx +2 -6
  30. package/src/components/copilot-provider/copilot-messages.tsx +1 -1
  31. package/src/components/copilot-provider/copilotkit-props.tsx +1 -1
  32. package/src/components/copilot-provider/copilotkit.tsx +4 -4
  33. package/src/context/copilot-messages-context.tsx +1 -1
  34. package/src/hooks/__tests__/use-coagent-config.test.ts +2 -2
  35. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +2 -2
  36. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +3 -7
  37. package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +1 -1
  38. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +4 -4
  39. package/src/hooks/use-agent-nodename.ts +1 -1
  40. package/src/hooks/use-coagent-state-render-bridge.tsx +1 -4
  41. package/src/hooks/use-coagent.ts +1 -1
  42. package/src/hooks/use-configure-chat-suggestions.tsx +2 -2
  43. package/src/hooks/use-copilot-chat-suggestions.tsx +2 -2
  44. package/src/hooks/use-copilot-chat_internal.ts +2 -2
  45. package/src/hooks/use-copilot-readable.ts +1 -1
  46. package/src/hooks/use-frontend-tool.ts +2 -2
  47. package/src/hooks/use-human-in-the-loop.ts +2 -2
  48. package/src/hooks/use-langgraph-interrupt.ts +2 -5
  49. package/src/hooks/use-lazy-tool-renderer.tsx +1 -1
  50. package/src/hooks/use-render-tool-call.ts +1 -1
  51. package/src/lib/copilot-task.ts +1 -1
  52. package/src/setupTests.ts +18 -14
  53. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +176 -0
  54. package/src/v2/__tests__/globalSetup.ts +14 -0
  55. package/src/v2/__tests__/setup.ts +93 -0
  56. package/src/v2/__tests__/utils/test-helpers.tsx +470 -0
  57. package/src/v2/a2ui/A2UIMessageRenderer.tsx +206 -0
  58. package/src/v2/components/CopilotKitInspector.tsx +50 -0
  59. package/src/v2/components/MCPAppsActivityRenderer.tsx +785 -0
  60. package/src/v2/components/WildcardToolCallRender.tsx +86 -0
  61. package/src/v2/components/__tests__/license-warning-banner.test.tsx +46 -0
  62. package/src/v2/components/chat/CopilotChat.tsx +431 -0
  63. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +375 -0
  64. package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +350 -0
  65. package/src/v2/components/chat/CopilotChatInput.tsx +1302 -0
  66. package/src/v2/components/chat/CopilotChatMessageView.tsx +556 -0
  67. package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +252 -0
  68. package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +59 -0
  69. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +133 -0
  70. package/src/v2/components/chat/CopilotChatToggleButton.tsx +171 -0
  71. package/src/v2/components/chat/CopilotChatToolCallsView.tsx +40 -0
  72. package/src/v2/components/chat/CopilotChatUserMessage.tsx +388 -0
  73. package/src/v2/components/chat/CopilotChatView.tsx +598 -0
  74. package/src/v2/components/chat/CopilotModalHeader.tsx +129 -0
  75. package/src/v2/components/chat/CopilotPopup.tsx +81 -0
  76. package/src/v2/components/chat/CopilotPopupView.tsx +317 -0
  77. package/src/v2/components/chat/CopilotSidebar.tsx +76 -0
  78. package/src/v2/components/chat/CopilotSidebarView.tsx +255 -0
  79. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +1113 -0
  80. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +73 -0
  81. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +432 -0
  82. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +150 -0
  83. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +624 -0
  84. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +702 -0
  85. package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +107 -0
  86. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +929 -0
  87. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +986 -0
  88. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +1004 -0
  89. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +169 -0
  90. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +530 -0
  91. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +782 -0
  92. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +2413 -0
  93. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +621 -0
  94. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +853 -0
  95. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +1050 -0
  96. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +484 -0
  97. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +612 -0
  98. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +502 -0
  99. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +1011 -0
  100. package/src/v2/components/chat/__tests__/setup.ts +1 -0
  101. package/src/v2/components/chat/index.ts +79 -0
  102. package/src/v2/components/index.ts +7 -0
  103. package/src/v2/components/license-warning-banner.tsx +198 -0
  104. package/src/v2/components/ui/button.tsx +123 -0
  105. package/src/v2/components/ui/dropdown-menu.tsx +258 -0
  106. package/src/v2/components/ui/tooltip.tsx +60 -0
  107. package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +152 -0
  108. package/src/v2/hooks/__tests__/standard-schema.test.tsx +282 -0
  109. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +132 -0
  110. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +401 -0
  111. package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +44 -0
  112. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +205 -0
  113. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +148 -0
  114. package/src/v2/hooks/__tests__/use-component.test.tsx +123 -0
  115. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +696 -0
  116. package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +153 -0
  117. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +167 -0
  118. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +2129 -0
  119. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +1261 -0
  120. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +397 -0
  121. package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +56 -0
  122. package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +192 -0
  123. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +259 -0
  124. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +524 -0
  125. package/src/v2/hooks/__tests__/use-threads.test.tsx +433 -0
  126. package/src/v2/hooks/__tests__/zod-regression.test.tsx +311 -0
  127. package/src/v2/hooks/index.ts +18 -0
  128. package/src/v2/hooks/use-agent-context.tsx +45 -0
  129. package/src/v2/hooks/use-agent.tsx +155 -0
  130. package/src/v2/hooks/use-component.tsx +89 -0
  131. package/src/v2/hooks/use-configure-suggestions.tsx +187 -0
  132. package/src/v2/hooks/use-default-render-tool.tsx +254 -0
  133. package/src/v2/hooks/use-frontend-tool.tsx +43 -0
  134. package/src/v2/hooks/use-human-in-the-loop.tsx +81 -0
  135. package/src/v2/hooks/use-interrupt.tsx +305 -0
  136. package/src/v2/hooks/use-keyboard-height.tsx +67 -0
  137. package/src/v2/hooks/use-render-activity-message.tsx +73 -0
  138. package/src/v2/hooks/use-render-custom-messages.tsx +93 -0
  139. package/src/v2/hooks/use-render-tool-call.tsx +175 -0
  140. package/src/v2/hooks/use-render-tool.tsx +181 -0
  141. package/src/v2/hooks/use-suggestions.tsx +91 -0
  142. package/src/v2/hooks/use-threads.tsx +256 -0
  143. package/src/v2/hooks/useKatexStyles.ts +27 -0
  144. package/src/v2/index.css +1 -1
  145. package/src/v2/index.ts +18 -2
  146. package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +495 -0
  147. package/src/v2/lib/__tests__/renderSlot.test.tsx +588 -0
  148. package/src/v2/lib/react-core.ts +156 -0
  149. package/src/v2/lib/slots.tsx +143 -0
  150. package/src/v2/lib/transcription-client.ts +184 -0
  151. package/src/v2/lib/utils.ts +8 -0
  152. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +162 -0
  153. package/src/v2/providers/CopilotKitProvider.tsx +600 -0
  154. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +546 -0
  155. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +101 -0
  156. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +69 -0
  157. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +881 -0
  158. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +740 -0
  159. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +642 -0
  160. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +294 -0
  161. package/src/v2/providers/index.ts +14 -0
  162. package/src/v2/styles/globals.css +230 -0
  163. package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +525 -0
  164. package/src/v2/types/defineToolCallRenderer.ts +65 -0
  165. package/src/v2/types/frontend-tool.ts +8 -0
  166. package/src/v2/types/human-in-the-loop.ts +33 -0
  167. package/src/v2/types/index.ts +7 -0
  168. package/src/v2/types/interrupt.ts +15 -0
  169. package/src/v2/types/react-activity-message-renderer.ts +27 -0
  170. package/src/v2/types/react-custom-message-renderer.ts +17 -0
  171. package/src/v2/types/react-tool-call-renderer.ts +32 -0
  172. package/tsdown.config.ts +34 -10
  173. package/vitest.config.mjs +4 -3
  174. package/LICENSE +0 -21
  175. package/dist/copilotkit-BRPQ2sqS.d.cts +0 -670
  176. package/dist/copilotkit-BRPQ2sqS.d.cts.map +0 -1
  177. package/dist/copilotkit-C94ayZbs.cjs +0 -2161
  178. package/dist/copilotkit-C94ayZbs.cjs.map +0 -1
  179. package/dist/copilotkit-CwZMFmSK.d.mts +0 -670
  180. package/dist/copilotkit-CwZMFmSK.d.mts.map +0 -1
  181. package/dist/copilotkit-Yh_Ld_FX.mjs +0 -2031
  182. package/dist/copilotkit-Yh_Ld_FX.mjs.map +0 -1
  183. package/dist/v2/index.css.map +0 -1
@@ -0,0 +1,2182 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import { Agent, ExtensionsInput, ForwardedParametersInput, LangGraphInterruptEvent } from "@copilotkit/runtime-client-gql";
3
+ import * as react from "react";
4
+ import React$1, { ComponentType, ReactNode } from "react";
5
+ import { Action, CopilotCloudConfig, CopilotErrorHandler, CopilotKitError, FunctionCallHandler, InferSchemaOutput, MappedParameterTypes, Parameter, StandardSchemaV1 } from "@copilotkit/shared";
6
+ import { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreErrorCode, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus, ɵThread } from "@copilotkit/core";
7
+ import { AbstractAgent } from "@ag-ui/client";
8
+ import { ActivityMessage, AssistantMessage, Message as Message$2, ReasoningMessage, ToolCall, ToolMessage, UserMessage } from "@ag-ui/core";
9
+ import { Streamdown } from "streamdown";
10
+ import { z } from "zod";
11
+ import { Theme } from "@copilotkit/a2ui-renderer";
12
+
13
+ //#region src/types/frontend-action.d.ts
14
+ interface InProgressState<T extends Parameter[] | [] = []> {
15
+ status: "inProgress";
16
+ args: Partial<MappedParameterTypes<T>>;
17
+ result: undefined;
18
+ }
19
+ interface ExecutingState<T extends Parameter[] | [] = []> {
20
+ status: "executing";
21
+ args: MappedParameterTypes<T>;
22
+ result: undefined;
23
+ }
24
+ interface CompleteState<T extends Parameter[] | [] = []> {
25
+ status: "complete";
26
+ args: MappedParameterTypes<T>;
27
+ result: any;
28
+ }
29
+ interface InProgressStateNoArgs<T extends Parameter[] | [] = []> {
30
+ status: "inProgress";
31
+ args: Partial<MappedParameterTypes<T>>;
32
+ result: undefined;
33
+ }
34
+ interface ExecutingStateNoArgs<T extends Parameter[] | [] = []> {
35
+ status: "executing";
36
+ args: MappedParameterTypes<T>;
37
+ result: undefined;
38
+ }
39
+ interface CompleteStateNoArgs<T extends Parameter[] | [] = []> {
40
+ status: "complete";
41
+ args: MappedParameterTypes<T>;
42
+ result: any;
43
+ }
44
+ interface InProgressStateWait<T extends Parameter[] | [] = []> {
45
+ status: "inProgress";
46
+ args: Partial<MappedParameterTypes<T>>;
47
+ /** @deprecated use respond instead */
48
+ handler: undefined;
49
+ respond: undefined;
50
+ result: undefined;
51
+ }
52
+ interface ExecutingStateWait<T extends Parameter[] | [] = []> {
53
+ status: "executing";
54
+ args: MappedParameterTypes<T>;
55
+ /** @deprecated use respond instead */
56
+ handler: (result: any) => void;
57
+ respond: (result: any) => void;
58
+ result: undefined;
59
+ }
60
+ interface CompleteStateWait<T extends Parameter[] | [] = []> {
61
+ status: "complete";
62
+ args: MappedParameterTypes<T>;
63
+ /** @deprecated use respond instead */
64
+ handler: undefined;
65
+ respond: undefined;
66
+ result: any;
67
+ }
68
+ interface InProgressStateNoArgsWait<T extends Parameter[] | [] = []> {
69
+ status: "inProgress";
70
+ args: Partial<MappedParameterTypes<T>>;
71
+ /** @deprecated use respond instead */
72
+ handler: undefined;
73
+ respond: undefined;
74
+ result: undefined;
75
+ }
76
+ interface ExecutingStateNoArgsWait<T extends Parameter[] | [] = []> {
77
+ status: "executing";
78
+ args: MappedParameterTypes<T>;
79
+ /** @deprecated use respond instead */
80
+ handler: (result: any) => void;
81
+ respond: (result: any) => void;
82
+ result: undefined;
83
+ }
84
+ interface CompleteStateNoArgsWait<T extends Parameter[] | [] = []> {
85
+ status: "complete";
86
+ args: MappedParameterTypes<T>;
87
+ /** @deprecated use respond instead */
88
+ handler: undefined;
89
+ respond: undefined;
90
+ }
91
+ type ActionRenderProps<T extends Parameter[] | [] = []> = CompleteState<T> | ExecutingState<T> | InProgressState<T>;
92
+ type ActionRenderPropsNoArgs<T extends Parameter[] | [] = []> = CompleteStateNoArgs<T> | ExecutingStateNoArgs<T> | InProgressStateNoArgs<T>;
93
+ type ActionRenderPropsWait<T extends Parameter[] | [] = []> = CompleteStateWait<T> | ExecutingStateWait<T> | InProgressStateWait<T>;
94
+ type ActionRenderPropsNoArgsWait<T extends Parameter[] | [] = []> = CompleteStateNoArgsWait<T> | ExecutingStateNoArgsWait<T> | InProgressStateNoArgsWait<T>;
95
+ type CatchAllActionRenderProps<T extends Parameter[] | [] = []> = (CompleteState<T> & {
96
+ name: string;
97
+ }) | (ExecutingState<T> & {
98
+ name: string;
99
+ }) | (InProgressState<T> & {
100
+ name: string;
101
+ });
102
+ type FrontendActionAvailability = "disabled" | "enabled" | "remote" | "frontend";
103
+ type FrontendAction<T extends Parameter[] | [] = [], N extends string = string> = Action<T> & {
104
+ name: Exclude<N, "*">;
105
+ /**
106
+ * @deprecated Use `available` instead.
107
+ */
108
+ disabled?: boolean;
109
+ available?: FrontendActionAvailability;
110
+ pairedAction?: string;
111
+ followUp?: boolean;
112
+ } & ({
113
+ render?: string | (T extends [] ? (props: ActionRenderPropsNoArgs<T>) => string | React$1.ReactElement : (props: ActionRenderProps<T>) => string | React$1.ReactElement); /** @deprecated use renderAndWaitForResponse instead */
114
+ renderAndWait?: never;
115
+ renderAndWaitForResponse?: never;
116
+ } | {
117
+ render?: never; /** @deprecated use renderAndWaitForResponse instead */
118
+ renderAndWait?: T extends [] ? (props: ActionRenderPropsNoArgsWait<T>) => React$1.ReactElement : (props: ActionRenderPropsWait<T>) => React$1.ReactElement;
119
+ renderAndWaitForResponse?: T extends [] ? (props: ActionRenderPropsNoArgsWait<T>) => React$1.ReactElement : (props: ActionRenderPropsWait<T>) => React$1.ReactElement;
120
+ handler?: never;
121
+ });
122
+ type CatchAllFrontendAction = {
123
+ name: "*";
124
+ render: (props: CatchAllActionRenderProps<any>) => React$1.ReactElement;
125
+ };
126
+ type RenderFunctionStatus = ActionRenderProps<any>["status"];
127
+ //#endregion
128
+ //#region src/hooks/use-tree.d.ts
129
+ type TreeNodeId = string;
130
+ interface TreeNode {
131
+ id: TreeNodeId;
132
+ value: string;
133
+ children: TreeNode[];
134
+ parentId?: TreeNodeId;
135
+ categories: Set<string>;
136
+ }
137
+ type Tree = TreeNode[];
138
+ //#endregion
139
+ //#region src/types/document-pointer.d.ts
140
+ interface DocumentPointer {
141
+ id: string;
142
+ name: string;
143
+ sourceApplication: string;
144
+ iconImageUri: string;
145
+ getContents: () => string;
146
+ }
147
+ //#endregion
148
+ //#region src/types/system-message.d.ts
149
+ type SystemMessageFunction = (contextString: string, additionalInstructions?: string) => string;
150
+ //#endregion
151
+ //#region src/types/chat-suggestion-configuration.d.ts
152
+ interface CopilotChatSuggestionConfiguration {
153
+ /**
154
+ * A prompt or instructions for the GPT to generate suggestions.
155
+ */
156
+ instructions: string;
157
+ /**
158
+ * The minimum number of suggestions to generate. Defaults to `1`.
159
+ * @default 1
160
+ */
161
+ minSuggestions?: number;
162
+ /**
163
+ * The maximum number of suggestions to generate. Defaults to `3`.
164
+ * @default 1
165
+ */
166
+ maxSuggestions?: number;
167
+ /**
168
+ * An optional class name to apply to the suggestions.
169
+ */
170
+ className?: string;
171
+ }
172
+ //#endregion
173
+ //#region src/types/crew.d.ts
174
+ /**
175
+ * Status of a response or action that requires user input
176
+ */
177
+ type CrewsResponseStatus = "inProgress" | "complete" | "executing";
178
+ /**
179
+ * Response data structure for the ResponseRenderer
180
+ */
181
+ interface CrewsResponse {
182
+ /**
183
+ * Unique identifier for the response
184
+ */
185
+ id: string;
186
+ /**
187
+ * The content of the response to display
188
+ */
189
+ content: string;
190
+ /**
191
+ * Optional metadata for the response
192
+ */
193
+ metadata?: Record<string, any>;
194
+ }
195
+ /**
196
+ * Base state item interface for agent state items
197
+ */
198
+ interface CrewsStateItem {
199
+ /**
200
+ * Unique identifier for the item
201
+ */
202
+ id: string;
203
+ /**
204
+ * Timestamp when the item was created
205
+ */
206
+ timestamp: string;
207
+ }
208
+ /**
209
+ * Tool execution state item
210
+ */
211
+ interface CrewsToolStateItem extends CrewsStateItem {
212
+ /**
213
+ * Name of the tool that was executed
214
+ */
215
+ tool: string;
216
+ /**
217
+ * Optional thought process for the tool execution
218
+ */
219
+ thought?: string;
220
+ /**
221
+ * Result of the tool execution
222
+ */
223
+ result?: any;
224
+ }
225
+ /**
226
+ * Task state item
227
+ */
228
+ interface CrewsTaskStateItem extends CrewsStateItem {
229
+ /**
230
+ * Name of the task
231
+ */
232
+ name: string;
233
+ /**
234
+ * Description of the task
235
+ */
236
+ description?: string;
237
+ }
238
+ /**
239
+ * AgentState containing information about steps and tasks
240
+ */
241
+ interface CrewsAgentState {
242
+ /**
243
+ * Array of tool execution steps
244
+ */
245
+ steps?: CrewsToolStateItem[];
246
+ /**
247
+ * Array of tasks
248
+ */
249
+ tasks?: CrewsTaskStateItem[];
250
+ }
251
+ //#endregion
252
+ //#region src/types/interrupt-action.d.ts
253
+ interface LangGraphInterruptRenderHandlerProps<TEventValue = any> {
254
+ event: LangGraphInterruptEvent<TEventValue>;
255
+ resolve: (resolution: string) => void;
256
+ }
257
+ interface LangGraphInterruptRenderProps<TEventValue = any> {
258
+ result: unknown;
259
+ event: LangGraphInterruptEvent<TEventValue>;
260
+ resolve: (resolution: string) => void;
261
+ }
262
+ interface LangGraphInterruptRender<TEventValue = any> {
263
+ id: string;
264
+ /**
265
+ * The handler function to handle the event.
266
+ */
267
+ handler?: (props: LangGraphInterruptRenderHandlerProps<TEventValue>) => any | Promise<any>;
268
+ /**
269
+ * The render function to handle the event.
270
+ */
271
+ render?: (props: LangGraphInterruptRenderProps<TEventValue>) => string | React.ReactElement;
272
+ /**
273
+ * Method that returns a boolean, indicating if the interrupt action should run
274
+ * Useful when using multiple interrupts
275
+ */
276
+ enabled?: (args: {
277
+ eventValue: TEventValue;
278
+ agentMetadata: AgentSession;
279
+ }) => boolean;
280
+ /**
281
+ * Optional agent ID to scope this interrupt to a specific agent.
282
+ * Defaults to the agent configured in the CopilotKit chat configuration.
283
+ */
284
+ agentId?: string;
285
+ }
286
+ type LangGraphInterruptAction = LangGraphInterruptRender & {
287
+ event?: LangGraphInterruptEvent;
288
+ };
289
+ type LangGraphInterruptActionSetterArgs = Partial<LangGraphInterruptRender> | null;
290
+ type LangGraphInterruptActionSetter = (action: LangGraphInterruptActionSetterArgs) => void;
291
+ interface QueuedInterruptEvent {
292
+ eventId: string;
293
+ threadId: string;
294
+ event: LangGraphInterruptEvent;
295
+ }
296
+ //#endregion
297
+ //#region src/types/coagent-action.d.ts
298
+ type CoAgentStateRenderProps<T> = {
299
+ state: T;
300
+ nodeName: string;
301
+ status: "inProgress" | "complete";
302
+ };
303
+ type CoAgentStateRenderHandlerArguments<T> = {
304
+ nodeName: string;
305
+ state: T;
306
+ };
307
+ interface CoAgentStateRender<T = any> {
308
+ /**
309
+ * The name of the coagent.
310
+ */
311
+ name: string;
312
+ /**
313
+ * The node name of the coagent.
314
+ */
315
+ nodeName?: string;
316
+ /**
317
+ * The handler function to handle the state of the agent.
318
+ */
319
+ handler?: (props: CoAgentStateRenderHandlerArguments<T>) => void | Promise<void>;
320
+ /**
321
+ * The render function to handle the state of the agent.
322
+ */
323
+ render?: ((props: CoAgentStateRenderProps<T>) => string | React.ReactElement | undefined | null) | string;
324
+ }
325
+ //#endregion
326
+ //#region src/types/coagent-state.d.ts
327
+ interface CoagentState {
328
+ name: string;
329
+ state: any;
330
+ running: boolean;
331
+ active: boolean;
332
+ threadId?: string;
333
+ config?: {
334
+ configurable?: Record<string, any>;
335
+ [key: string]: any;
336
+ };
337
+ nodeName?: string;
338
+ runId?: string;
339
+ }
340
+ //#endregion
341
+ //#region src/context/copilot-context.d.ts
342
+ /**
343
+ * Interface for the configuration of the Copilot API.
344
+ */
345
+ interface CopilotApiConfig {
346
+ /**
347
+ * The public API key for Copilot Cloud.
348
+ */
349
+ publicApiKey?: string;
350
+ /**
351
+ * The configuration for Copilot Cloud.
352
+ */
353
+ cloud?: CopilotCloudConfig;
354
+ /**
355
+ * The endpoint for the chat API.
356
+ */
357
+ chatApiEndpoint: string;
358
+ /**
359
+ * The endpoint for the Copilot transcribe audio service.
360
+ */
361
+ transcribeAudioUrl?: string;
362
+ /**
363
+ * The endpoint for the Copilot text to speech service.
364
+ */
365
+ textToSpeechUrl?: string;
366
+ /**
367
+ * additional headers to be sent with the request
368
+ * @default {}
369
+ * @example
370
+ * ```
371
+ * {
372
+ * 'Authorization': 'Bearer your_token_here'
373
+ * }
374
+ * ```
375
+ */
376
+ headers: Record<string, string>;
377
+ /**
378
+ * Custom properties to be sent with the request
379
+ * @default {}
380
+ * @example
381
+ * ```
382
+ * {
383
+ * 'user_id': 'user_id'
384
+ * }
385
+ * ```
386
+ */
387
+ properties?: Record<string, any>;
388
+ /**
389
+ * Indicates whether the user agent should send or receive cookies from the other domain
390
+ * in the case of cross-origin requests.
391
+ */
392
+ credentials?: RequestCredentials;
393
+ /**
394
+ * Optional configuration for connecting to Model Context Protocol (MCP) servers.
395
+ * This is typically derived from the CopilotKitProps and used internally.
396
+ * @experimental
397
+ */
398
+ mcpServers?: Array<{
399
+ endpoint: string;
400
+ apiKey?: string;
401
+ }>;
402
+ }
403
+ type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> = (props: TProps) => string | React$1.JSX.Element;
404
+ type CoagentInChatRenderFunction = (props: CoAgentStateRenderProps<any>) => string | React$1.JSX.Element | undefined | null;
405
+ interface ChatComponentsCache {
406
+ actions: Record<string, InChatRenderFunction | string>;
407
+ coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;
408
+ }
409
+ interface AgentSession {
410
+ agentName: string;
411
+ threadId?: string;
412
+ nodeName?: string;
413
+ }
414
+ interface AuthState {
415
+ status: "authenticated" | "unauthenticated";
416
+ authHeaders: Record<string, string>;
417
+ userId?: string;
418
+ metadata?: Record<string, any>;
419
+ }
420
+ type ActionName = string;
421
+ interface CopilotContextParams {
422
+ actions: Record<string, FrontendAction<any>>;
423
+ setAction: (id: string, action: FrontendAction<any>) => void;
424
+ removeAction: (id: string) => void;
425
+ setRegisteredActions: (actionConfig: any) => string;
426
+ removeRegisteredAction: (actionKey: string) => void;
427
+ chatComponentsCache: React$1.RefObject<ChatComponentsCache>;
428
+ getFunctionCallHandler: (customEntryPoints?: Record<string, FrontendAction<any>>) => FunctionCallHandler;
429
+ addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;
430
+ removeContext: (id: TreeNodeId) => void;
431
+ getAllContext: () => Tree;
432
+ getContextString: (documents: DocumentPointer[], categories: string[]) => string;
433
+ addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;
434
+ removeDocumentContext: (documentId: string) => void;
435
+ getDocumentsContext: (categories: string[]) => DocumentPointer[];
436
+ isLoading: boolean;
437
+ setIsLoading: React$1.Dispatch<React$1.SetStateAction<boolean>>;
438
+ chatSuggestionConfiguration: {
439
+ [key: string]: CopilotChatSuggestionConfiguration;
440
+ };
441
+ addChatSuggestionConfiguration: (id: string, suggestion: CopilotChatSuggestionConfiguration) => void;
442
+ removeChatSuggestionConfiguration: (id: string) => void;
443
+ chatInstructions: string;
444
+ setChatInstructions: React$1.Dispatch<React$1.SetStateAction<string>>;
445
+ additionalInstructions?: string[];
446
+ setAdditionalInstructions: React$1.Dispatch<React$1.SetStateAction<string[]>>;
447
+ copilotApiConfig: CopilotApiConfig;
448
+ showDevConsole: boolean;
449
+ coagentStates: Record<string, CoagentState>;
450
+ setCoagentStates: React$1.Dispatch<React$1.SetStateAction<Record<string, CoagentState>>>;
451
+ coagentStatesRef: React$1.RefObject<Record<string, CoagentState>>;
452
+ setCoagentStatesWithRef: (value: Record<string, CoagentState> | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>)) => void;
453
+ agentSession: AgentSession | null;
454
+ setAgentSession: React$1.Dispatch<React$1.SetStateAction<AgentSession | null>>;
455
+ agentLock: string | null;
456
+ threadId: string;
457
+ setThreadId: React$1.Dispatch<React$1.SetStateAction<string>>;
458
+ runId: string | null;
459
+ setRunId: React$1.Dispatch<React$1.SetStateAction<string | null>>;
460
+ chatAbortControllerRef: React$1.MutableRefObject<AbortController | null>;
461
+ /**
462
+ * The forwarded parameters to use for the task.
463
+ */
464
+ forwardedParameters?: Partial<Pick<ForwardedParametersInput, "temperature">>;
465
+ availableAgents: Agent[];
466
+ /**
467
+ * The auth states for the CopilotKit.
468
+ */
469
+ authStates_c?: Record<ActionName, AuthState>;
470
+ setAuthStates_c?: React$1.Dispatch<React$1.SetStateAction<Record<ActionName, AuthState>>>;
471
+ /**
472
+ * The auth config for the CopilotKit.
473
+ */
474
+ authConfig_c?: {
475
+ SignInComponent: React$1.ComponentType<{
476
+ onSignInComplete: (authState: AuthState) => void;
477
+ }>;
478
+ };
479
+ extensions: ExtensionsInput;
480
+ setExtensions: React$1.Dispatch<React$1.SetStateAction<ExtensionsInput>>;
481
+ interruptActions: Record<string, LangGraphInterruptRender>;
482
+ setInterruptAction: LangGraphInterruptActionSetter;
483
+ removeInterruptAction: (actionId: string) => void;
484
+ interruptEventQueue: Record<string, QueuedInterruptEvent[]>;
485
+ addInterruptEvent: (queuedEvent: QueuedInterruptEvent) => void;
486
+ resolveInterruptEvent: (threadId: string, eventId: string, response: string) => void;
487
+ /**
488
+ * Optional trace handler for comprehensive debugging and observability.
489
+ */
490
+ onError: CopilotErrorHandler;
491
+ bannerError: CopilotKitError | null;
492
+ setBannerError: React$1.Dispatch<React$1.SetStateAction<CopilotKitError | null>>;
493
+ internalErrorHandlers: Record<string, CopilotErrorHandler>;
494
+ setInternalErrorHandler: (handler: Record<string, CopilotErrorHandler>) => void;
495
+ removeInternalErrorHandler: (id: string) => void;
496
+ }
497
+ declare const CopilotContext: React$1.Context<CopilotContextParams>;
498
+ declare function useCopilotContext(): CopilotContextParams;
499
+ //#endregion
500
+ //#region src/v2/components/chat/CopilotChatAudioRecorder.d.ts
501
+ /** Finite-state machine for every recorder implementation */
502
+ type AudioRecorderState = "idle" | "recording" | "processing";
503
+ /** Error subclass so callers can `instanceof`-guard recorder failures */
504
+ declare class AudioRecorderError extends Error {
505
+ constructor(message: string);
506
+ }
507
+ interface AudioRecorderRef {
508
+ state: AudioRecorderState;
509
+ start: () => Promise<void>;
510
+ stop: () => Promise<Blob>;
511
+ dispose: () => void;
512
+ }
513
+ declare const CopilotChatAudioRecorder: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLDivElement> & react.RefAttributes<AudioRecorderRef>>;
514
+ //#endregion
515
+ //#region src/v2/providers/CopilotChatConfigurationProvider.d.ts
516
+ declare const CopilotChatDefaultLabels: {
517
+ chatInputPlaceholder: string;
518
+ chatInputToolbarStartTranscribeButtonLabel: string;
519
+ chatInputToolbarCancelTranscribeButtonLabel: string;
520
+ chatInputToolbarFinishTranscribeButtonLabel: string;
521
+ chatInputToolbarAddButtonLabel: string;
522
+ chatInputToolbarToolsButtonLabel: string;
523
+ assistantMessageToolbarCopyCodeLabel: string;
524
+ assistantMessageToolbarCopyCodeCopiedLabel: string;
525
+ assistantMessageToolbarCopyMessageLabel: string;
526
+ assistantMessageToolbarThumbsUpLabel: string;
527
+ assistantMessageToolbarThumbsDownLabel: string;
528
+ assistantMessageToolbarReadAloudLabel: string;
529
+ assistantMessageToolbarRegenerateLabel: string;
530
+ userMessageToolbarCopyMessageLabel: string;
531
+ userMessageToolbarEditMessageLabel: string;
532
+ chatDisclaimerText: string;
533
+ chatToggleOpenLabel: string;
534
+ chatToggleCloseLabel: string;
535
+ modalHeaderTitle: string;
536
+ welcomeMessageText: string;
537
+ };
538
+ type CopilotChatLabels = typeof CopilotChatDefaultLabels;
539
+ interface CopilotChatConfigurationValue {
540
+ labels: CopilotChatLabels;
541
+ agentId: string;
542
+ threadId: string;
543
+ isModalOpen: boolean;
544
+ setModalOpen: (open: boolean) => void;
545
+ }
546
+ interface CopilotChatConfigurationProviderProps {
547
+ children: ReactNode;
548
+ labels?: Partial<CopilotChatLabels>;
549
+ agentId?: string;
550
+ threadId?: string;
551
+ isModalDefaultOpen?: boolean;
552
+ }
553
+ declare const CopilotChatConfigurationProvider: React$1.FC<CopilotChatConfigurationProviderProps>;
554
+ declare const useCopilotChatConfiguration: () => CopilotChatConfigurationValue | null;
555
+ //#endregion
556
+ //#region src/v2/lib/slots.d.ts
557
+ /** Existing union (unchanged) */
558
+ type SlotValue<C extends React$1.ComponentType<any>> = C | string | Partial<React$1.ComponentProps<C>>;
559
+ /** Utility: concrete React elements for every slot */
560
+ type SlotElements<S> = { [K in keyof S]: React$1.ReactElement };
561
+ type WithSlots<S extends Record<string, React$1.ComponentType<any>>, Rest = {}> = { [K in keyof S]?: SlotValue<S[K]> } & {
562
+ children?: (props: SlotElements<S> & Rest) => React$1.ReactNode;
563
+ } & Omit<Rest, "children">;
564
+ //#endregion
565
+ //#region src/v2/components/chat/CopilotChatInput.d.ts
566
+ type CopilotChatInputMode = "input" | "transcribe" | "processing";
567
+ type ToolsMenuItem = {
568
+ label: string;
569
+ } & ({
570
+ action: () => void;
571
+ items?: never;
572
+ } | {
573
+ action?: never;
574
+ items: (ToolsMenuItem | "-")[];
575
+ });
576
+ type CopilotChatInputSlots = {
577
+ textArea: typeof CopilotChatInput.TextArea;
578
+ sendButton: typeof CopilotChatInput.SendButton;
579
+ startTranscribeButton: typeof CopilotChatInput.StartTranscribeButton;
580
+ cancelTranscribeButton: typeof CopilotChatInput.CancelTranscribeButton;
581
+ finishTranscribeButton: typeof CopilotChatInput.FinishTranscribeButton;
582
+ addMenuButton: typeof CopilotChatInput.AddMenuButton;
583
+ audioRecorder: typeof CopilotChatAudioRecorder;
584
+ disclaimer: typeof CopilotChatInput.Disclaimer;
585
+ };
586
+ type CopilotChatInputRestProps = {
587
+ mode?: CopilotChatInputMode;
588
+ toolsMenu?: (ToolsMenuItem | "-")[];
589
+ autoFocus?: boolean;
590
+ onSubmitMessage?: (value: string) => void;
591
+ onStop?: () => void;
592
+ isRunning?: boolean;
593
+ onStartTranscribe?: () => void;
594
+ onCancelTranscribe?: () => void;
595
+ onFinishTranscribe?: () => void;
596
+ onFinishTranscribeWithAudio?: (audioBlob: Blob) => Promise<void>;
597
+ onAddFile?: () => void;
598
+ value?: string;
599
+ onChange?: (value: string) => void; /** Positioning mode for the input container. Default: 'static' */
600
+ positioning?: "static" | "absolute"; /** Keyboard height in pixels for mobile keyboard handling */
601
+ keyboardHeight?: number; /** Ref for the outer positioning container */
602
+ containerRef?: React$1.Ref<HTMLDivElement>; /** Whether to show the disclaimer. Default: true for absolute positioning, false for static */
603
+ showDisclaimer?: boolean;
604
+ } & Omit<React$1.HTMLAttributes<HTMLDivElement>, "onChange">;
605
+ type CopilotChatInputBaseProps = WithSlots<CopilotChatInputSlots, CopilotChatInputRestProps>;
606
+ type CopilotChatInputChildrenArgs = CopilotChatInputBaseProps extends {
607
+ children?: infer C;
608
+ } ? C extends ((props: infer P) => React$1.ReactNode) ? P : never : never;
609
+ type CopilotChatInputProps = Omit<CopilotChatInputBaseProps, "children"> & {
610
+ children?: (props: CopilotChatInputChildrenArgs) => React$1.ReactNode;
611
+ };
612
+ declare function CopilotChatInput({
613
+ mode,
614
+ onSubmitMessage,
615
+ onStop,
616
+ isRunning,
617
+ onStartTranscribe,
618
+ onCancelTranscribe,
619
+ onFinishTranscribe,
620
+ onFinishTranscribeWithAudio,
621
+ onAddFile,
622
+ onChange,
623
+ value,
624
+ toolsMenu,
625
+ autoFocus,
626
+ positioning,
627
+ keyboardHeight,
628
+ containerRef,
629
+ showDisclaimer,
630
+ textArea,
631
+ sendButton,
632
+ startTranscribeButton,
633
+ cancelTranscribeButton,
634
+ finishTranscribeButton,
635
+ addMenuButton,
636
+ audioRecorder,
637
+ disclaimer,
638
+ children,
639
+ className,
640
+ ...props
641
+ }: CopilotChatInputProps): react_jsx_runtime0.JSX.Element;
642
+ declare namespace CopilotChatInput {
643
+ const SendButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
644
+ const ToolbarButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
645
+ icon: React$1.ReactNode;
646
+ labelKey: keyof CopilotChatLabels;
647
+ defaultClassName?: string;
648
+ }>;
649
+ const StartTranscribeButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
650
+ const CancelTranscribeButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
651
+ const FinishTranscribeButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
652
+ const AddMenuButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement> & {
653
+ toolsMenu?: (ToolsMenuItem | "-")[];
654
+ onAddFile?: () => void;
655
+ }>;
656
+ type TextAreaProps = React$1.TextareaHTMLAttributes<HTMLTextAreaElement>;
657
+ const TextArea: React$1.ForwardRefExoticComponent<TextAreaProps & React$1.RefAttributes<HTMLTextAreaElement>>;
658
+ const AudioRecorder: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<AudioRecorderRef>>;
659
+ const Disclaimer: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
660
+ }
661
+ //#endregion
662
+ //#region src/v2/components/chat/CopilotChatToolCallsView.d.ts
663
+ type CopilotChatToolCallsViewProps = {
664
+ message: AssistantMessage;
665
+ messages?: Message$2[];
666
+ };
667
+ declare function CopilotChatToolCallsView({
668
+ message,
669
+ messages
670
+ }: CopilotChatToolCallsViewProps): react_jsx_runtime0.JSX.Element | null;
671
+ //#endregion
672
+ //#region src/v2/components/chat/CopilotChatAssistantMessage.d.ts
673
+ type CopilotChatAssistantMessageProps = WithSlots<{
674
+ markdownRenderer: typeof CopilotChatAssistantMessage.MarkdownRenderer;
675
+ toolbar: typeof CopilotChatAssistantMessage.Toolbar;
676
+ copyButton: typeof CopilotChatAssistantMessage.CopyButton;
677
+ thumbsUpButton: typeof CopilotChatAssistantMessage.ThumbsUpButton;
678
+ thumbsDownButton: typeof CopilotChatAssistantMessage.ThumbsDownButton;
679
+ readAloudButton: typeof CopilotChatAssistantMessage.ReadAloudButton;
680
+ regenerateButton: typeof CopilotChatAssistantMessage.RegenerateButton;
681
+ toolCallsView: typeof CopilotChatToolCallsView;
682
+ }, {
683
+ onThumbsUp?: (message: AssistantMessage) => void;
684
+ onThumbsDown?: (message: AssistantMessage) => void;
685
+ onReadAloud?: (message: AssistantMessage) => void;
686
+ onRegenerate?: (message: AssistantMessage) => void;
687
+ message: AssistantMessage;
688
+ messages?: Message$2[];
689
+ isRunning?: boolean;
690
+ additionalToolbarItems?: React.ReactNode;
691
+ toolbarVisible?: boolean;
692
+ } & React.HTMLAttributes<HTMLDivElement>>;
693
+ declare function CopilotChatAssistantMessage({
694
+ message,
695
+ messages,
696
+ isRunning,
697
+ onThumbsUp,
698
+ onThumbsDown,
699
+ onReadAloud,
700
+ onRegenerate,
701
+ additionalToolbarItems,
702
+ toolbarVisible,
703
+ markdownRenderer,
704
+ toolbar,
705
+ copyButton,
706
+ thumbsUpButton,
707
+ thumbsDownButton,
708
+ readAloudButton,
709
+ regenerateButton,
710
+ toolCallsView,
711
+ children,
712
+ className,
713
+ ...props
714
+ }: CopilotChatAssistantMessageProps): react_jsx_runtime0.JSX.Element;
715
+ declare namespace CopilotChatAssistantMessage {
716
+ const MarkdownRenderer: React.FC<Omit<React.ComponentProps<typeof Streamdown>, "children"> & {
717
+ content: string;
718
+ }>;
719
+ const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
720
+ const ToolbarButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
721
+ title: string;
722
+ children: React.ReactNode;
723
+ }>;
724
+ const CopyButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
725
+ const ThumbsUpButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
726
+ const ThumbsDownButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
727
+ const ReadAloudButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
728
+ const RegenerateButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
729
+ }
730
+ //#endregion
731
+ //#region src/v2/components/chat/CopilotChatUserMessage.d.ts
732
+ interface CopilotChatUserMessageOnEditMessageProps {
733
+ message: UserMessage;
734
+ }
735
+ interface CopilotChatUserMessageOnSwitchToBranchProps {
736
+ message: UserMessage;
737
+ branchIndex: number;
738
+ numberOfBranches: number;
739
+ }
740
+ type CopilotChatUserMessageProps = WithSlots<{
741
+ messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;
742
+ toolbar: typeof CopilotChatUserMessage.Toolbar;
743
+ copyButton: typeof CopilotChatUserMessage.CopyButton;
744
+ editButton: typeof CopilotChatUserMessage.EditButton;
745
+ branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;
746
+ }, {
747
+ onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;
748
+ onSwitchToBranch?: (props: CopilotChatUserMessageOnSwitchToBranchProps) => void;
749
+ message: UserMessage;
750
+ branchIndex?: number;
751
+ numberOfBranches?: number;
752
+ additionalToolbarItems?: React.ReactNode;
753
+ } & React.HTMLAttributes<HTMLDivElement>>;
754
+ declare function CopilotChatUserMessage({
755
+ message,
756
+ onEditMessage,
757
+ branchIndex,
758
+ numberOfBranches,
759
+ onSwitchToBranch,
760
+ additionalToolbarItems,
761
+ messageRenderer,
762
+ toolbar,
763
+ copyButton,
764
+ editButton,
765
+ branchNavigation,
766
+ children,
767
+ className,
768
+ ...props
769
+ }: CopilotChatUserMessageProps): react_jsx_runtime0.JSX.Element;
770
+ declare namespace CopilotChatUserMessage {
771
+ const Container: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>>;
772
+ const MessageRenderer: React.FC<{
773
+ content: string;
774
+ className?: string;
775
+ }>;
776
+ const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
777
+ const ToolbarButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
778
+ title: string;
779
+ children: React.ReactNode;
780
+ }>;
781
+ const CopyButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
782
+ copied?: boolean;
783
+ }>;
784
+ const EditButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
785
+ const BranchNavigation: React.FC<React.HTMLAttributes<HTMLDivElement> & {
786
+ currentBranch?: number;
787
+ numberOfBranches?: number;
788
+ onSwitchToBranch?: (props: CopilotChatUserMessageOnSwitchToBranchProps) => void;
789
+ message: UserMessage;
790
+ }>;
791
+ }
792
+ //#endregion
793
+ //#region src/v2/components/chat/CopilotChatReasoningMessage.d.ts
794
+ type CopilotChatReasoningMessageProps = WithSlots<{
795
+ header: typeof CopilotChatReasoningMessage.Header;
796
+ contentView: typeof CopilotChatReasoningMessage.Content;
797
+ toggle: typeof CopilotChatReasoningMessage.Toggle;
798
+ }, {
799
+ message: ReasoningMessage;
800
+ messages?: Message$2[];
801
+ isRunning?: boolean;
802
+ } & React.HTMLAttributes<HTMLDivElement>>;
803
+ declare function CopilotChatReasoningMessage({
804
+ message,
805
+ messages,
806
+ isRunning,
807
+ header,
808
+ contentView,
809
+ toggle,
810
+ children,
811
+ className,
812
+ ...props
813
+ }: CopilotChatReasoningMessageProps): react_jsx_runtime0.JSX.Element;
814
+ declare namespace CopilotChatReasoningMessage {
815
+ const Header: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
816
+ isOpen?: boolean;
817
+ label?: string;
818
+ hasContent?: boolean;
819
+ isStreaming?: boolean;
820
+ }>;
821
+ const Content: React.FC<React.HTMLAttributes<HTMLDivElement> & {
822
+ isStreaming?: boolean;
823
+ hasContent?: boolean;
824
+ }>;
825
+ const Toggle: React.FC<React.HTMLAttributes<HTMLDivElement> & {
826
+ isOpen?: boolean;
827
+ }>;
828
+ }
829
+ //#endregion
830
+ //#region src/v2/components/chat/CopilotChatSuggestionPill.d.ts
831
+ interface CopilotChatSuggestionPillProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
832
+ /** Optional icon to render on the left side when not loading. */
833
+ icon?: React$1.ReactNode;
834
+ /** Whether the pill should display a loading spinner. */
835
+ isLoading?: boolean;
836
+ }
837
+ declare const CopilotChatSuggestionPill: React$1.ForwardRefExoticComponent<CopilotChatSuggestionPillProps & React$1.RefAttributes<HTMLButtonElement>>;
838
+ //#endregion
839
+ //#region src/v2/components/chat/CopilotChatSuggestionView.d.ts
840
+ declare const DefaultContainer: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
841
+ type CopilotChatSuggestionViewProps = WithSlots<{
842
+ container: typeof DefaultContainer;
843
+ suggestion: typeof CopilotChatSuggestionPill;
844
+ }, {
845
+ suggestions: Suggestion[];
846
+ onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;
847
+ loadingIndexes?: ReadonlyArray<number>;
848
+ } & React$1.HTMLAttributes<HTMLDivElement>>;
849
+ declare const CopilotChatSuggestionView: React$1.ForwardRefExoticComponent<{
850
+ container?: SlotValue<React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>> | undefined;
851
+ suggestion?: SlotValue<React$1.ForwardRefExoticComponent<CopilotChatSuggestionPillProps & React$1.RefAttributes<HTMLButtonElement>>> | undefined;
852
+ } & {
853
+ children?: ((props: {
854
+ container: React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
855
+ suggestion: React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
856
+ } & {
857
+ suggestions: Suggestion[];
858
+ onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;
859
+ loadingIndexes?: ReadonlyArray<number>;
860
+ } & React$1.HTMLAttributes<HTMLDivElement>) => React$1.ReactNode) | undefined;
861
+ } & Omit<{
862
+ suggestions: Suggestion[];
863
+ onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;
864
+ loadingIndexes?: ReadonlyArray<number>;
865
+ } & React$1.HTMLAttributes<HTMLDivElement>, "children"> & React$1.RefAttributes<HTMLDivElement>>;
866
+ //#endregion
867
+ //#region src/v2/components/chat/CopilotChatMessageView.d.ts
868
+ type CopilotChatMessageViewProps = Omit<WithSlots<{
869
+ assistantMessage: typeof CopilotChatAssistantMessage;
870
+ userMessage: typeof CopilotChatUserMessage;
871
+ reasoningMessage: typeof CopilotChatReasoningMessage;
872
+ cursor: typeof CopilotChatMessageView.Cursor;
873
+ }, {
874
+ isRunning?: boolean;
875
+ messages?: Message$2[];
876
+ } & React$1.HTMLAttributes<HTMLDivElement>>, "children"> & {
877
+ children?: (props: {
878
+ isRunning: boolean;
879
+ messages: Message$2[];
880
+ messageElements: React$1.ReactElement[];
881
+ interruptElement: React$1.ReactElement | null;
882
+ }) => React$1.ReactElement;
883
+ };
884
+ declare function CopilotChatMessageView({
885
+ messages,
886
+ assistantMessage,
887
+ userMessage,
888
+ reasoningMessage,
889
+ cursor,
890
+ isRunning,
891
+ children,
892
+ className,
893
+ ...props
894
+ }: CopilotChatMessageViewProps): react_jsx_runtime0.JSX.Element;
895
+ declare namespace CopilotChatMessageView {
896
+ var Cursor: ({
897
+ className,
898
+ ...props
899
+ }: React$1.HTMLAttributes<HTMLDivElement>) => react_jsx_runtime0.JSX.Element;
900
+ }
901
+ //#endregion
902
+ //#region src/v2/components/chat/CopilotChatView.d.ts
903
+ type WelcomeScreenProps = WithSlots<{
904
+ welcomeMessage: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
905
+ }, {
906
+ input: React$1.ReactElement;
907
+ suggestionView: React$1.ReactElement;
908
+ } & React$1.HTMLAttributes<HTMLDivElement>>;
909
+ type CopilotChatViewProps = WithSlots<{
910
+ messageView: typeof CopilotChatMessageView;
911
+ scrollView: typeof CopilotChatView.ScrollView;
912
+ input: typeof CopilotChatInput;
913
+ suggestionView: typeof CopilotChatSuggestionView;
914
+ }, {
915
+ messages?: Message$2[];
916
+ autoScroll?: boolean;
917
+ isRunning?: boolean;
918
+ suggestions?: Suggestion[];
919
+ suggestionLoadingIndexes?: ReadonlyArray<number>;
920
+ onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;
921
+ welcomeScreen?: SlotValue<React$1.FC<WelcomeScreenProps>> | boolean;
922
+ onSubmitMessage?: (value: string) => void;
923
+ onStop?: () => void;
924
+ inputMode?: CopilotChatInputMode;
925
+ inputValue?: string;
926
+ onInputChange?: (value: string) => void;
927
+ onStartTranscribe?: () => void;
928
+ onCancelTranscribe?: () => void;
929
+ onFinishTranscribe?: () => void;
930
+ onFinishTranscribeWithAudio?: (audioBlob: Blob) => Promise<void>;
931
+ /**
932
+ * @deprecated Use the `input` slot's `disclaimer` prop instead:
933
+ * ```tsx
934
+ * <CopilotChat input={{ disclaimer: MyDisclaimer }} />
935
+ * ```
936
+ */
937
+ disclaimer?: SlotValue<React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>>;
938
+ } & React$1.HTMLAttributes<HTMLDivElement>>;
939
+ declare function CopilotChatView({
940
+ messageView,
941
+ input,
942
+ scrollView,
943
+ suggestionView,
944
+ welcomeScreen,
945
+ messages,
946
+ autoScroll,
947
+ isRunning,
948
+ suggestions,
949
+ suggestionLoadingIndexes,
950
+ onSelectSuggestion,
951
+ onSubmitMessage,
952
+ onStop,
953
+ inputMode,
954
+ inputValue,
955
+ onInputChange,
956
+ onStartTranscribe,
957
+ onCancelTranscribe,
958
+ onFinishTranscribe,
959
+ onFinishTranscribeWithAudio,
960
+ disclaimer,
961
+ children,
962
+ className,
963
+ ...props
964
+ }: CopilotChatViewProps): react_jsx_runtime0.JSX.Element;
965
+ declare namespace CopilotChatView {
966
+ const ScrollView: React$1.FC<React$1.HTMLAttributes<HTMLDivElement> & {
967
+ autoScroll?: boolean;
968
+ scrollToBottomButton?: SlotValue<React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>>;
969
+ feather?: SlotValue<React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>>;
970
+ inputContainerHeight?: number;
971
+ isResizing?: boolean;
972
+ }>;
973
+ const ScrollToBottomButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
974
+ const Feather: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
975
+ const WelcomeMessage: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
976
+ const WelcomeScreen: React$1.FC<WelcomeScreenProps>;
977
+ }
978
+ //#endregion
979
+ //#region src/v2/components/chat/CopilotChat.d.ts
980
+ type CopilotChatProps = Omit<CopilotChatViewProps, "messages" | "isRunning" | "suggestions" | "suggestionLoadingIndexes" | "onSelectSuggestion"> & {
981
+ agentId?: string;
982
+ threadId?: string;
983
+ labels?: Partial<CopilotChatLabels>;
984
+ chatView?: SlotValue<typeof CopilotChatView>;
985
+ isModalDefaultOpen?: boolean;
986
+ /**
987
+ * Error handler scoped to this chat's agent. Fires in addition to the
988
+ * provider-level onError (does not suppress it). Receives only errors
989
+ * whose context.agentId matches this chat's agent.
990
+ */
991
+ onError?: (event: {
992
+ error: Error;
993
+ code: CopilotKitCoreErrorCode;
994
+ context: Record<string, any>;
995
+ }) => void | Promise<void>;
996
+ };
997
+ declare function CopilotChat({
998
+ agentId,
999
+ threadId,
1000
+ labels,
1001
+ chatView,
1002
+ isModalDefaultOpen,
1003
+ onError,
1004
+ ...props
1005
+ }: CopilotChatProps): react_jsx_runtime0.JSX.Element;
1006
+ declare namespace CopilotChat {
1007
+ const View: typeof CopilotChatView;
1008
+ }
1009
+ //#endregion
1010
+ //#region src/v2/components/chat/CopilotChatToggleButton.d.ts
1011
+ declare const DefaultOpenIcon: React$1.FC<React$1.SVGProps<SVGSVGElement>>;
1012
+ declare const DefaultCloseIcon: React$1.FC<React$1.SVGProps<SVGSVGElement>>;
1013
+ interface CopilotChatToggleButtonProps extends Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
1014
+ /** Optional slot override for the chat (closed) icon. */
1015
+ openIcon?: SlotValue<typeof DefaultOpenIcon>;
1016
+ /** Optional slot override for the close icon. */
1017
+ closeIcon?: SlotValue<typeof DefaultCloseIcon>;
1018
+ }
1019
+ declare const CopilotChatToggleButton: React$1.ForwardRefExoticComponent<CopilotChatToggleButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
1020
+ //#endregion
1021
+ //#region src/v2/components/chat/CopilotModalHeader.d.ts
1022
+ type HeaderSlots = {
1023
+ titleContent: typeof CopilotModalHeader.Title;
1024
+ closeButton: typeof CopilotModalHeader.CloseButton;
1025
+ };
1026
+ type HeaderRestProps = {
1027
+ title?: string;
1028
+ } & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children">;
1029
+ type CopilotModalHeaderProps = WithSlots<HeaderSlots, HeaderRestProps>;
1030
+ declare function CopilotModalHeader({
1031
+ title,
1032
+ titleContent,
1033
+ closeButton,
1034
+ children,
1035
+ className,
1036
+ ...rest
1037
+ }: CopilotModalHeaderProps): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | null | undefined;
1038
+ declare namespace CopilotModalHeader {
1039
+ var displayName: string;
1040
+ }
1041
+ declare namespace CopilotModalHeader {
1042
+ const Title: React$1.FC<React$1.HTMLAttributes<HTMLDivElement>>;
1043
+ const CloseButton: React$1.FC<React$1.ButtonHTMLAttributes<HTMLButtonElement>>;
1044
+ }
1045
+ //#endregion
1046
+ //#region src/v2/components/chat/CopilotSidebarView.d.ts
1047
+ type CopilotSidebarViewProps = CopilotChatViewProps & {
1048
+ header?: SlotValue<typeof CopilotModalHeader>;
1049
+ toggleButton?: SlotValue<typeof CopilotChatToggleButton>;
1050
+ width?: number | string;
1051
+ defaultOpen?: boolean;
1052
+ };
1053
+ declare function CopilotSidebarView({
1054
+ header,
1055
+ toggleButton,
1056
+ width,
1057
+ defaultOpen,
1058
+ ...props
1059
+ }: CopilotSidebarViewProps): react_jsx_runtime0.JSX.Element;
1060
+ declare namespace CopilotSidebarView {
1061
+ var displayName: string;
1062
+ }
1063
+ declare namespace CopilotSidebarView {
1064
+ /**
1065
+ * Sidebar-specific welcome screen layout:
1066
+ * - Suggestions at the top
1067
+ * - Welcome message in the middle
1068
+ * - Input fixed at the bottom (like normal chat)
1069
+ */
1070
+ const WelcomeScreen: React$1.FC<WelcomeScreenProps>;
1071
+ }
1072
+ //#endregion
1073
+ //#region src/v2/components/chat/CopilotPopupView.d.ts
1074
+ type CopilotPopupViewProps = CopilotChatViewProps & {
1075
+ header?: SlotValue<typeof CopilotModalHeader>;
1076
+ toggleButton?: SlotValue<typeof CopilotChatToggleButton>;
1077
+ width?: number | string;
1078
+ height?: number | string;
1079
+ clickOutsideToClose?: boolean;
1080
+ defaultOpen?: boolean;
1081
+ };
1082
+ declare function CopilotPopupView({
1083
+ header,
1084
+ toggleButton,
1085
+ width,
1086
+ height,
1087
+ clickOutsideToClose,
1088
+ defaultOpen,
1089
+ className,
1090
+ ...restProps
1091
+ }: CopilotPopupViewProps): react_jsx_runtime0.JSX.Element;
1092
+ declare namespace CopilotPopupView {
1093
+ var displayName: string;
1094
+ }
1095
+ declare namespace CopilotPopupView {
1096
+ /**
1097
+ * Popup-specific welcome screen layout:
1098
+ * - Welcome message centered vertically
1099
+ * - Suggestions just above input
1100
+ * - Input fixed at the bottom
1101
+ */
1102
+ const WelcomeScreen: React$1.FC<WelcomeScreenProps>;
1103
+ }
1104
+ //#endregion
1105
+ //#region src/v2/components/chat/CopilotSidebar.d.ts
1106
+ type CopilotSidebarProps = Omit<CopilotChatProps, "chatView"> & {
1107
+ header?: CopilotSidebarViewProps["header"];
1108
+ toggleButton?: CopilotSidebarViewProps["toggleButton"];
1109
+ defaultOpen?: boolean;
1110
+ width?: number | string;
1111
+ };
1112
+ declare function CopilotSidebar({
1113
+ header,
1114
+ toggleButton,
1115
+ defaultOpen,
1116
+ width,
1117
+ ...chatProps
1118
+ }: CopilotSidebarProps): react_jsx_runtime0.JSX.Element;
1119
+ declare namespace CopilotSidebar {
1120
+ var displayName: string;
1121
+ }
1122
+ //#endregion
1123
+ //#region src/v2/components/chat/CopilotPopup.d.ts
1124
+ type CopilotPopupProps = Omit<CopilotChatProps, "chatView"> & {
1125
+ header?: CopilotPopupViewProps["header"];
1126
+ toggleButton?: CopilotPopupViewProps["toggleButton"];
1127
+ defaultOpen?: boolean;
1128
+ width?: CopilotPopupViewProps["width"];
1129
+ height?: CopilotPopupViewProps["height"];
1130
+ clickOutsideToClose?: CopilotPopupViewProps["clickOutsideToClose"];
1131
+ };
1132
+ declare function CopilotPopup({
1133
+ header,
1134
+ toggleButton,
1135
+ defaultOpen,
1136
+ width,
1137
+ height,
1138
+ clickOutsideToClose,
1139
+ ...chatProps
1140
+ }: CopilotPopupProps): react_jsx_runtime0.JSX.Element;
1141
+ declare namespace CopilotPopup {
1142
+ var displayName: string;
1143
+ }
1144
+ //#endregion
1145
+ //#region src/v2/components/WildcardToolCallRender.d.ts
1146
+ declare const WildcardToolCallRender: ReactToolCallRenderer<any>;
1147
+ //#endregion
1148
+ //#region src/v2/components/CopilotKitInspector.d.ts
1149
+ type CopilotKitInspectorBaseProps = {
1150
+ core?: CopilotKitCore | null;
1151
+ [key: string]: unknown;
1152
+ };
1153
+ interface CopilotKitInspectorProps extends CopilotKitInspectorBaseProps {}
1154
+ declare const CopilotKitInspector: react.FC<CopilotKitInspectorProps>;
1155
+ //#endregion
1156
+ //#region src/v2/components/MCPAppsActivityRenderer.d.ts
1157
+ /**
1158
+ * Activity type for MCP Apps events - must match the middleware's MCPAppsActivityType
1159
+ */
1160
+ declare const MCPAppsActivityType = "mcp-apps";
1161
+ declare const MCPAppsActivityContentSchema: z.ZodObject<{
1162
+ result: z.ZodObject<{
1163
+ content: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1164
+ structuredContent: z.ZodOptional<z.ZodAny>;
1165
+ isError: z.ZodOptional<z.ZodBoolean>;
1166
+ }, "strip", z.ZodTypeAny, {
1167
+ content?: any[] | undefined;
1168
+ structuredContent?: any;
1169
+ isError?: boolean | undefined;
1170
+ }, {
1171
+ content?: any[] | undefined;
1172
+ structuredContent?: any;
1173
+ isError?: boolean | undefined;
1174
+ }>;
1175
+ resourceUri: z.ZodString;
1176
+ serverHash: z.ZodString;
1177
+ serverId: z.ZodOptional<z.ZodString>;
1178
+ toolInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1179
+ }, "strip", z.ZodTypeAny, {
1180
+ result: {
1181
+ content?: any[] | undefined;
1182
+ structuredContent?: any;
1183
+ isError?: boolean | undefined;
1184
+ };
1185
+ resourceUri: string;
1186
+ serverHash: string;
1187
+ serverId?: string | undefined;
1188
+ toolInput?: Record<string, unknown> | undefined;
1189
+ }, {
1190
+ result: {
1191
+ content?: any[] | undefined;
1192
+ structuredContent?: any;
1193
+ isError?: boolean | undefined;
1194
+ };
1195
+ resourceUri: string;
1196
+ serverHash: string;
1197
+ serverId?: string | undefined;
1198
+ toolInput?: Record<string, unknown> | undefined;
1199
+ }>;
1200
+ type MCPAppsActivityContent = z.infer<typeof MCPAppsActivityContentSchema>;
1201
+ /**
1202
+ * Props for the activity renderer component
1203
+ */
1204
+ interface MCPAppsActivityRendererProps {
1205
+ activityType: string;
1206
+ content: MCPAppsActivityContent;
1207
+ message: unknown;
1208
+ agent: AbstractAgent | undefined;
1209
+ }
1210
+ /**
1211
+ * MCP Apps Extension Activity Renderer
1212
+ *
1213
+ * Renders MCP Apps UI in a sandboxed iframe with full protocol support.
1214
+ * Fetches resource content on-demand via proxied MCP requests.
1215
+ */
1216
+ declare const MCPAppsActivityRenderer: React$1.FC<MCPAppsActivityRendererProps>;
1217
+ //#endregion
1218
+ //#region src/v2/hooks/use-render-tool-call.d.ts
1219
+ interface UseRenderToolCallProps {
1220
+ toolCall: ToolCall;
1221
+ toolMessage?: ToolMessage;
1222
+ }
1223
+ /**
1224
+ * Hook that returns a function to render tool calls based on the render functions
1225
+ * defined in CopilotKitProvider.
1226
+ *
1227
+ * @returns A function that takes a tool call and optional tool message and returns the rendered component
1228
+ */
1229
+ declare function useRenderToolCall(): ({
1230
+ toolCall,
1231
+ toolMessage
1232
+ }: UseRenderToolCallProps) => React$1.ReactElement | null;
1233
+ //#endregion
1234
+ //#region src/v2/types/react-custom-message-renderer.d.ts
1235
+ type ReactCustomMessageRendererPosition = "before" | "after";
1236
+ interface ReactCustomMessageRenderer {
1237
+ agentId?: string;
1238
+ render: React.ComponentType<{
1239
+ message: Message$2;
1240
+ position: ReactCustomMessageRendererPosition;
1241
+ runId: string;
1242
+ messageIndex: number;
1243
+ messageIndexInRun: number;
1244
+ numberOfMessagesInRun: number;
1245
+ agentId: string;
1246
+ stateSnapshot: any;
1247
+ }> | null;
1248
+ }
1249
+ //#endregion
1250
+ //#region src/v2/hooks/use-render-custom-messages.d.ts
1251
+ interface UseRenderCustomMessagesParams {
1252
+ message: Message$2;
1253
+ position: ReactCustomMessageRendererPosition;
1254
+ }
1255
+ declare function useRenderCustomMessages(): ((params: UseRenderCustomMessagesParams) => react_jsx_runtime0.JSX.Element | null) | null;
1256
+ //#endregion
1257
+ //#region src/v2/types/react-tool-call-renderer.d.ts
1258
+ interface ReactToolCallRenderer<T = unknown> {
1259
+ name: string;
1260
+ args: StandardSchemaV1<any, T>;
1261
+ /**
1262
+ * Optional agent ID to constrain this tool renderer to a specific agent.
1263
+ * If specified, this renderer will only be used for the specified agent.
1264
+ */
1265
+ agentId?: string;
1266
+ render: React.ComponentType<{
1267
+ name: string;
1268
+ args: Partial<T>;
1269
+ status: ToolCallStatus.InProgress;
1270
+ result: undefined;
1271
+ } | {
1272
+ name: string;
1273
+ args: T;
1274
+ status: ToolCallStatus.Executing;
1275
+ result: undefined;
1276
+ } | {
1277
+ name: string;
1278
+ args: T;
1279
+ status: ToolCallStatus.Complete;
1280
+ result: string;
1281
+ }>;
1282
+ }
1283
+ //#endregion
1284
+ //#region src/v2/types/react-activity-message-renderer.d.ts
1285
+ interface ReactActivityMessageRenderer<TActivityContent> {
1286
+ /**
1287
+ * Activity type to match when rendering. Use "*" as a wildcard renderer.
1288
+ */
1289
+ activityType: string;
1290
+ /**
1291
+ * Optional agent ID to scope the renderer to a particular agent.
1292
+ */
1293
+ agentId?: string;
1294
+ /**
1295
+ * Schema describing the activity content payload.
1296
+ */
1297
+ content: StandardSchemaV1<any, TActivityContent>;
1298
+ /**
1299
+ * React component invoked to render the activity message.
1300
+ */
1301
+ render: React.ComponentType<{
1302
+ activityType: string;
1303
+ content: TActivityContent;
1304
+ message: ActivityMessage;
1305
+ agent: AbstractAgent | undefined;
1306
+ }>;
1307
+ }
1308
+ //#endregion
1309
+ //#region src/v2/types/frontend-tool.d.ts
1310
+ type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
1311
+ render?: ReactToolCallRenderer<T>["render"];
1312
+ };
1313
+ //#endregion
1314
+ //#region src/v2/types/human-in-the-loop.d.ts
1315
+ type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>> = Omit<FrontendTool<T>, "handler"> & {
1316
+ render: React$1.ComponentType<{
1317
+ name: string;
1318
+ description: string;
1319
+ args: Partial<T>;
1320
+ status: ToolCallStatus.InProgress;
1321
+ result: undefined;
1322
+ respond: undefined;
1323
+ } | {
1324
+ name: string;
1325
+ description: string;
1326
+ args: T;
1327
+ status: ToolCallStatus.Executing;
1328
+ result: undefined;
1329
+ respond: (result: unknown) => Promise<void>;
1330
+ } | {
1331
+ name: string;
1332
+ description: string;
1333
+ args: T;
1334
+ status: ToolCallStatus.Complete;
1335
+ result: string;
1336
+ respond: undefined;
1337
+ }>;
1338
+ };
1339
+ //#endregion
1340
+ //#region src/v2/types/defineToolCallRenderer.d.ts
1341
+ /**
1342
+ * Helper to define a type-safe tool call renderer entry.
1343
+ * - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
1344
+ * - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
1345
+ * - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
1346
+ * - For wildcard tools (name: "*"), args is optional and defaults to z.any()
1347
+ */
1348
+ type RenderProps<T> = {
1349
+ name: string;
1350
+ args: Partial<T>;
1351
+ status: ToolCallStatus.InProgress;
1352
+ result: undefined;
1353
+ } | {
1354
+ name: string;
1355
+ args: T;
1356
+ status: ToolCallStatus.Executing;
1357
+ result: undefined;
1358
+ } | {
1359
+ name: string;
1360
+ args: T;
1361
+ status: ToolCallStatus.Complete;
1362
+ result: string;
1363
+ };
1364
+ declare function defineToolCallRenderer(def: {
1365
+ name: "*";
1366
+ render: (props: RenderProps<any>) => React$1.ReactElement;
1367
+ agentId?: string;
1368
+ }): ReactToolCallRenderer<any>;
1369
+ declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
1370
+ name: string;
1371
+ args: S;
1372
+ render: (props: RenderProps<InferSchemaOutput<S>>) => React$1.ReactElement;
1373
+ agentId?: string;
1374
+ }): ReactToolCallRenderer<InferSchemaOutput<S>>;
1375
+ //#endregion
1376
+ //#region src/v2/types/interrupt.d.ts
1377
+ interface InterruptEvent<TValue = unknown> {
1378
+ name: string;
1379
+ value: TValue;
1380
+ }
1381
+ interface InterruptHandlerProps<TValue = unknown> {
1382
+ event: InterruptEvent<TValue>;
1383
+ resolve: (response: unknown) => void;
1384
+ }
1385
+ interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
1386
+ event: InterruptEvent<TValue>;
1387
+ result: TResult;
1388
+ resolve: (response: unknown) => void;
1389
+ }
1390
+ //#endregion
1391
+ //#region src/v2/hooks/use-render-activity-message.d.ts
1392
+ declare function useRenderActivityMessage(): {
1393
+ renderActivityMessage: (message: ActivityMessage) => React.ReactElement | null;
1394
+ findRenderer: (activityType: string) => ReactActivityMessageRenderer<unknown> | null;
1395
+ };
1396
+ //#endregion
1397
+ //#region src/v2/hooks/use-frontend-tool.d.ts
1398
+ declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>): void;
1399
+ //#endregion
1400
+ //#region src/v2/hooks/use-component.d.ts
1401
+ type InferRenderProps<T> = T extends StandardSchemaV1 ? InferSchemaOutput<T> : any;
1402
+ /**
1403
+ * Registers a React component as a frontend tool renderer in chat.
1404
+ *
1405
+ * This hook is a convenience wrapper around `useFrontendTool` that:
1406
+ * - builds a model-facing tool description,
1407
+ * - forwards optional schema parameters (any Standard Schema V1 compatible library),
1408
+ * - renders your component with tool call parameters.
1409
+ *
1410
+ * Use this when you want to display a typed visual component for a tool call
1411
+ * without manually wiring a full frontend tool object.
1412
+ *
1413
+ * When `parameters` is provided, render props are inferred from the schema.
1414
+ * When omitted, the render component may accept any props.
1415
+ *
1416
+ * @typeParam TSchema - Schema describing tool parameters, or `undefined` when no schema is given.
1417
+ * @param config - Tool registration config.
1418
+ * @param deps - Optional dependencies to refresh registration (same semantics as `useEffect`).
1419
+ *
1420
+ * @example
1421
+ * ```tsx
1422
+ * // Without parameters — render accepts any props
1423
+ * useComponent({
1424
+ * name: "showGreeting",
1425
+ * render: ({ message }: { message: string }) => <div>{message}</div>,
1426
+ * });
1427
+ * ```
1428
+ *
1429
+ * @example
1430
+ * ```tsx
1431
+ * // With parameters — render props inferred from schema
1432
+ * useComponent({
1433
+ * name: "showWeatherCard",
1434
+ * parameters: z.object({ city: z.string() }),
1435
+ * render: ({ city }) => <div>{city}</div>,
1436
+ * });
1437
+ * ```
1438
+ *
1439
+ * @example
1440
+ * ```tsx
1441
+ * useComponent(
1442
+ * {
1443
+ * name: "renderProfile",
1444
+ * parameters: z.object({ userId: z.string() }),
1445
+ * render: ProfileCard,
1446
+ * agentId: "support-agent",
1447
+ * },
1448
+ * [selectedAgentId],
1449
+ * );
1450
+ * ```
1451
+ */
1452
+ declare function useComponent<TSchema extends StandardSchemaV1 | undefined = undefined>(config: {
1453
+ name: string;
1454
+ description?: string;
1455
+ parameters?: TSchema;
1456
+ render: ComponentType<NoInfer<InferRenderProps<TSchema>>>;
1457
+ agentId?: string;
1458
+ }, deps?: ReadonlyArray<unknown>): void;
1459
+ //#endregion
1460
+ //#region src/v2/hooks/use-render-tool.d.ts
1461
+ interface RenderToolInProgressProps<S extends StandardSchemaV1> {
1462
+ name: string;
1463
+ parameters: Partial<InferSchemaOutput<S>>;
1464
+ status: "inProgress";
1465
+ result: undefined;
1466
+ }
1467
+ interface RenderToolExecutingProps<S extends StandardSchemaV1> {
1468
+ name: string;
1469
+ parameters: InferSchemaOutput<S>;
1470
+ status: "executing";
1471
+ result: undefined;
1472
+ }
1473
+ interface RenderToolCompleteProps<S extends StandardSchemaV1> {
1474
+ name: string;
1475
+ parameters: InferSchemaOutput<S>;
1476
+ status: "complete";
1477
+ result: string;
1478
+ }
1479
+ type RenderToolProps<S extends StandardSchemaV1> = RenderToolInProgressProps<S> | RenderToolExecutingProps<S> | RenderToolCompleteProps<S>;
1480
+ /**
1481
+ * Registers a wildcard (`"*"`) renderer for tool calls.
1482
+ *
1483
+ * The wildcard renderer is used as a fallback when no exact name-matched
1484
+ * renderer is registered for a tool call.
1485
+ *
1486
+ * @param config - Wildcard renderer configuration.
1487
+ * @param deps - Optional dependencies to refresh registration.
1488
+ *
1489
+ * @example
1490
+ * ```tsx
1491
+ * useRenderTool(
1492
+ * {
1493
+ * name: "*",
1494
+ * render: ({ name, status }) => (
1495
+ * <div>
1496
+ * {status === "complete" ? "✓" : "⏳"} {name}
1497
+ * </div>
1498
+ * ),
1499
+ * },
1500
+ * [],
1501
+ * );
1502
+ * ```
1503
+ */
1504
+ declare function useRenderTool(config: {
1505
+ name: "*";
1506
+ render: (props: any) => React.ReactElement;
1507
+ agentId?: string;
1508
+ }, deps?: ReadonlyArray<unknown>): void;
1509
+ /**
1510
+ * Registers a name-scoped renderer for tool calls.
1511
+ *
1512
+ * The provided `parameters` schema defines the typed shape of `props.parameters`
1513
+ * in `render` for `executing` and `complete` states. Accepts any Standard Schema V1
1514
+ * compatible library (Zod, Valibot, ArkType, etc.).
1515
+ *
1516
+ * @typeParam S - Schema type describing tool call parameters.
1517
+ * @param config - Named renderer configuration.
1518
+ * @param deps - Optional dependencies to refresh registration.
1519
+ *
1520
+ * @example
1521
+ * ```tsx
1522
+ * useRenderTool(
1523
+ * {
1524
+ * name: "searchDocs",
1525
+ * parameters: z.object({ query: z.string() }),
1526
+ * render: ({ status, parameters, result }) => {
1527
+ * if (status === "inProgress") return <div>Preparing...</div>;
1528
+ * if (status === "executing") return <div>Searching {parameters.query}</div>;
1529
+ * return <div>{result}</div>;
1530
+ * },
1531
+ * },
1532
+ * [],
1533
+ * );
1534
+ * ```
1535
+ */
1536
+ declare function useRenderTool<S extends StandardSchemaV1>(config: {
1537
+ name: string;
1538
+ parameters: S;
1539
+ render: (props: RenderToolProps<S>) => React.ReactElement;
1540
+ agentId?: string;
1541
+ }, deps?: ReadonlyArray<unknown>): void;
1542
+ //#endregion
1543
+ //#region src/v2/hooks/use-default-render-tool.d.ts
1544
+ type DefaultRenderProps = {
1545
+ /** The name of the tool being called. */name: string; /** The parsed parameters passed to the tool call. */
1546
+ parameters: unknown; /** Current execution status of the tool call. */
1547
+ status: "inProgress" | "executing" | "complete"; /** The tool call result string, available only when `status` is `"complete"`. */
1548
+ result: string | undefined;
1549
+ };
1550
+ /**
1551
+ * Registers a wildcard (`"*"`) tool-call renderer via `useRenderTool`.
1552
+ *
1553
+ * - Call with no config to use CopilotKit's built-in default tool-call card.
1554
+ * - Pass `config.render` to replace the default UI with your own fallback renderer.
1555
+ *
1556
+ * This is useful when you want a generic renderer for tools that do not have a
1557
+ * dedicated `useRenderTool({ name: "..." })` registration.
1558
+ *
1559
+ * @param config - Optional custom wildcard render function.
1560
+ * @param deps - Optional dependencies to refresh registration.
1561
+ *
1562
+ * @example
1563
+ * ```tsx
1564
+ * useDefaultRenderTool();
1565
+ * ```
1566
+ *
1567
+ * @example
1568
+ * ```tsx
1569
+ * useDefaultRenderTool({
1570
+ * render: ({ name, status }) => <div>{name}: {status}</div>,
1571
+ * });
1572
+ * ```
1573
+ *
1574
+ * @example
1575
+ * ```tsx
1576
+ * useDefaultRenderTool(
1577
+ * {
1578
+ * render: ({ name, result }) => (
1579
+ * <ToolEventRow title={name} payload={result} compact={compactMode} />
1580
+ * ),
1581
+ * },
1582
+ * [compactMode],
1583
+ * );
1584
+ * ```
1585
+ */
1586
+ declare function useDefaultRenderTool(config?: {
1587
+ render?: (props: DefaultRenderProps) => React$1.ReactElement;
1588
+ }, deps?: ReadonlyArray<unknown>): void;
1589
+ //#endregion
1590
+ //#region src/v2/hooks/use-human-in-the-loop.d.ts
1591
+ declare function useHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>): void;
1592
+ //#endregion
1593
+ //#region src/v2/hooks/use-agent.d.ts
1594
+ declare enum UseAgentUpdate {
1595
+ OnMessagesChanged = "OnMessagesChanged",
1596
+ OnStateChanged = "OnStateChanged",
1597
+ OnRunStatusChanged = "OnRunStatusChanged"
1598
+ }
1599
+ interface UseAgentProps {
1600
+ agentId?: string;
1601
+ updates?: UseAgentUpdate[];
1602
+ }
1603
+ declare function useAgent({
1604
+ agentId,
1605
+ updates
1606
+ }?: UseAgentProps): {
1607
+ agent: AbstractAgent;
1608
+ };
1609
+ //#endregion
1610
+ //#region src/v2/hooks/use-agent-context.d.ts
1611
+ /**
1612
+ * Represents any value that can be serialized to JSON.
1613
+ */
1614
+ type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
1615
+ [key: string]: JsonSerializable;
1616
+ };
1617
+ /**
1618
+ * Context configuration for useAgentContext.
1619
+ * Accepts any JSON-serializable value which will be converted to a string.
1620
+ */
1621
+ interface AgentContextInput {
1622
+ /** A human-readable description of what this context represents */
1623
+ description: string;
1624
+ /** The context value - will be converted to a JSON string if not already a string */
1625
+ value: JsonSerializable;
1626
+ }
1627
+ declare function useAgentContext(context: AgentContextInput): void;
1628
+ //#endregion
1629
+ //#region src/v2/hooks/use-suggestions.d.ts
1630
+ interface UseSuggestionsOptions {
1631
+ agentId?: string;
1632
+ }
1633
+ interface UseSuggestionsResult {
1634
+ suggestions: Suggestion[];
1635
+ reloadSuggestions: () => void;
1636
+ clearSuggestions: () => void;
1637
+ isLoading: boolean;
1638
+ }
1639
+ declare function useSuggestions({
1640
+ agentId
1641
+ }?: UseSuggestionsOptions): UseSuggestionsResult;
1642
+ //#endregion
1643
+ //#region src/v2/hooks/use-configure-suggestions.d.ts
1644
+ type StaticSuggestionInput = Omit<Suggestion, "isLoading"> & Partial<Pick<Suggestion, "isLoading">>;
1645
+ type StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, "suggestions"> & {
1646
+ suggestions: StaticSuggestionInput[];
1647
+ };
1648
+ type SuggestionsConfigInput = DynamicSuggestionsConfig | StaticSuggestionsConfigInput;
1649
+ declare function useConfigureSuggestions(config: SuggestionsConfigInput | null | undefined, deps?: ReadonlyArray<unknown>): void;
1650
+ //#endregion
1651
+ //#region src/v2/hooks/use-interrupt.d.ts
1652
+ type InterruptHandlerFn<TValue, TResult> = (props: InterruptHandlerProps<TValue>) => TResult | PromiseLike<TResult>;
1653
+ type InterruptResultFromHandler<THandler> = THandler extends ((...args: never[]) => infer TResult) ? TResult extends PromiseLike<infer TResolved> ? TResolved | null : TResult | null : null;
1654
+ type InterruptResult<TValue, TResult> = InterruptResultFromHandler<InterruptHandlerFn<TValue, TResult>>;
1655
+ type InterruptRenderInChat = boolean | undefined;
1656
+ type UseInterruptReturn<TRenderInChat extends InterruptRenderInChat> = TRenderInChat extends false ? React$1.ReactElement | null : TRenderInChat extends true | undefined ? void : React$1.ReactElement | null | void;
1657
+ /**
1658
+ * Configuration options for `useInterrupt`.
1659
+ */
1660
+ interface UseInterruptConfigBase<TValue = unknown, TResult = never> {
1661
+ /**
1662
+ * Render function for the interrupt UI.
1663
+ *
1664
+ * This is called once an interrupt is finalized and accepted by `enabled` (if provided).
1665
+ * Use `resolve` from render props to resume the agent run with user input.
1666
+ */
1667
+ render: (props: InterruptRenderProps<TValue, InterruptResult<TValue, TResult>>) => React$1.ReactElement;
1668
+ /**
1669
+ * Optional pre-render handler invoked when an interrupt is received.
1670
+ *
1671
+ * Return either a sync value or an async value to pass into `render` as `result`.
1672
+ * Rejecting/throwing falls back to `result = null`.
1673
+ */
1674
+ handler?: InterruptHandlerFn<TValue, TResult>;
1675
+ /**
1676
+ * Optional predicate to filter which interrupts should be handled by this hook.
1677
+ * Return `false` to ignore an interrupt.
1678
+ */
1679
+ enabled?: (event: InterruptEvent<TValue>) => boolean;
1680
+ /** Optional agent id. Defaults to the current configured chat agent. */
1681
+ agentId?: string;
1682
+ }
1683
+ type UseInterruptConfig<TValue = unknown, TResult = never, TRenderInChat extends InterruptRenderInChat = undefined> = UseInterruptConfigBase<TValue, TResult> & {
1684
+ /** When true (default), the interrupt UI renders inside `<CopilotChat>` automatically. Set to false to render it yourself. */renderInChat?: TRenderInChat;
1685
+ };
1686
+ /**
1687
+ * Handles agent interrupts (`on_interrupt`) with optional filtering, preprocessing, and resume behavior.
1688
+ *
1689
+ * The hook listens to custom events on the active agent, stores interrupt payloads per run,
1690
+ * and surfaces a render callback once the run finalizes. Call `resolve` from your UI to resume
1691
+ * execution with user-provided data.
1692
+ *
1693
+ * - `renderInChat: true` (default): the element is published into `<CopilotChat>` and this hook returns `void`.
1694
+ * - `renderInChat: false`: the hook returns the interrupt element so you can place it anywhere in your component tree.
1695
+ *
1696
+ * `event.value` is typed as `any` since the interrupt payload shape depends on your agent.
1697
+ * Type-narrow it in your callbacks (e.g. `handler`, `enabled`, `render`) as needed.
1698
+ *
1699
+ * @typeParam TResult - Inferred from `handler` return type. Exposed as `result` in `render`.
1700
+ * @param config - Interrupt configuration (renderer, optional handler/filter, and render mode).
1701
+ * @returns When `renderInChat` is `false`, returns the interrupt element (or `null` when idle).
1702
+ * Otherwise returns `void` and publishes the element into chat. In `render`, `result` is always
1703
+ * either the handler's resolved return value or `null` (including when no handler is provided,
1704
+ * when filtering skips the interrupt, or when handler execution fails).
1705
+ *
1706
+ * @example
1707
+ * ```tsx
1708
+ * import { useInterrupt } from "@copilotkit/react-core/v2";
1709
+ *
1710
+ * function InterruptUI() {
1711
+ * useInterrupt({
1712
+ * render: ({ event, resolve }) => (
1713
+ * <div>
1714
+ * <p>{event.value.question}</p>
1715
+ * <button onClick={() => resolve({ approved: true })}>Approve</button>
1716
+ * <button onClick={() => resolve({ approved: false })}>Reject</button>
1717
+ * </div>
1718
+ * ),
1719
+ * });
1720
+ *
1721
+ * return null;
1722
+ * }
1723
+ * ```
1724
+ *
1725
+ * @example
1726
+ * ```tsx
1727
+ * import { useInterrupt } from "@copilotkit/react-core/v2";
1728
+ *
1729
+ * function CustomPanel() {
1730
+ * const interruptElement = useInterrupt({
1731
+ * renderInChat: false,
1732
+ * enabled: (event) => event.value.startsWith("approval:"),
1733
+ * handler: async ({ event }) => ({ label: event.value.toUpperCase() }),
1734
+ * render: ({ event, result, resolve }) => (
1735
+ * <aside>
1736
+ * <strong>{result?.label ?? ""}</strong>
1737
+ * <button onClick={() => resolve({ value: event.value })}>Continue</button>
1738
+ * </aside>
1739
+ * ),
1740
+ * });
1741
+ *
1742
+ * return <>{interruptElement}</>;
1743
+ * }
1744
+ * ```
1745
+ */
1746
+ declare function useInterrupt<TResult = never, TRenderInChat extends InterruptRenderInChat = undefined>(config: UseInterruptConfig<any, TResult, TRenderInChat>): UseInterruptReturn<TRenderInChat>;
1747
+ //#endregion
1748
+ //#region src/v2/hooks/use-threads.d.ts
1749
+ /**
1750
+ * A conversation thread managed by the Intelligence platform.
1751
+ *
1752
+ * Each thread has a unique `id`, an optional human-readable `name`, and
1753
+ * timestamp fields tracking creation and update times.
1754
+ */
1755
+ interface Thread extends ɵThread {}
1756
+ /**
1757
+ * Configuration for the {@link useThreads} hook.
1758
+ *
1759
+ * Thread operations are scoped to the runtime-authenticated user and the
1760
+ * provided agent on the Intelligence platform.
1761
+ */
1762
+ interface UseThreadsInput {
1763
+ /** The ID of the agent whose threads to list and manage. */
1764
+ agentId: string;
1765
+ /** When `true`, archived threads are included in the list. Defaults to `false`. */
1766
+ includeArchived?: boolean;
1767
+ /** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */
1768
+ limit?: number;
1769
+ }
1770
+ /**
1771
+ * Return value of the {@link useThreads} hook.
1772
+ *
1773
+ * The `threads` array is kept in sync with the platform via a realtime
1774
+ * WebSocket subscription (when available) and is sorted most-recently-updated
1775
+ * first. Mutations reject with an `Error` if the platform request fails.
1776
+ */
1777
+ interface UseThreadsResult {
1778
+ /**
1779
+ * Threads for the current user/agent pair, sorted by most recently
1780
+ * updated first. Updated in realtime when the platform pushes metadata
1781
+ * events. Includes archived threads only when `includeArchived` is set.
1782
+ */
1783
+ threads: Thread[];
1784
+ /**
1785
+ * `true` while the initial thread list is being fetched from the platform.
1786
+ * Subsequent realtime updates do not re-enter the loading state.
1787
+ */
1788
+ isLoading: boolean;
1789
+ /**
1790
+ * The most recent error from fetching threads or executing a mutation,
1791
+ * or `null` when there is no error. Reset to `null` on the next
1792
+ * successful fetch.
1793
+ */
1794
+ error: Error | null;
1795
+ /**
1796
+ * `true` when there are more threads available to fetch via
1797
+ * {@link fetchNextPage}. Only meaningful when `limit` is set.
1798
+ */
1799
+ hasNextPage: boolean;
1800
+ /**
1801
+ * `true` while a subsequent page of threads is being fetched.
1802
+ */
1803
+ isFetchingNextPage: boolean;
1804
+ /**
1805
+ * Fetch the next page of threads. No-op when {@link hasNextPage} is
1806
+ * `false` or a page fetch is already in progress.
1807
+ */
1808
+ fetchNextPage: () => void;
1809
+ /**
1810
+ * Rename a thread on the platform.
1811
+ * Resolves when the server confirms the update; rejects on failure.
1812
+ */
1813
+ renameThread: (threadId: string, name: string) => Promise<void>;
1814
+ /**
1815
+ * Archive a thread on the platform.
1816
+ * Archived threads are excluded from subsequent list results.
1817
+ * Resolves when the server confirms the update; rejects on failure.
1818
+ */
1819
+ archiveThread: (threadId: string) => Promise<void>;
1820
+ /**
1821
+ * Permanently delete a thread from the platform.
1822
+ * This is irreversible. Resolves when the server confirms deletion;
1823
+ * rejects on failure.
1824
+ */
1825
+ deleteThread: (threadId: string) => Promise<void>;
1826
+ }
1827
+ /**
1828
+ * React hook for listing and managing Intelligence platform threads.
1829
+ *
1830
+ * On mount the hook fetches the thread list for the runtime-authenticated user
1831
+ * and the given `agentId`. When the Intelligence platform exposes a WebSocket
1832
+ * URL, it also opens a realtime subscription so the `threads` array stays
1833
+ * current without polling — thread creates, renames, archives, and deletes
1834
+ * from any client are reflected immediately.
1835
+ *
1836
+ * Mutation methods (`renameThread`, `archiveThread`, `deleteThread`) return
1837
+ * promises that resolve once the platform confirms the operation and reject
1838
+ * with an `Error` on failure.
1839
+ *
1840
+ * @param input - Agent identifier and optional list controls.
1841
+ * @returns Thread list state and stable mutation callbacks.
1842
+ *
1843
+ * @example
1844
+ * ```tsx
1845
+ * import { useThreads } from "@copilotkit/react-core";
1846
+ *
1847
+ * function ThreadList() {
1848
+ * const { threads, isLoading, renameThread, deleteThread } = useThreads({
1849
+ * agentId: "agent-1",
1850
+ * });
1851
+ *
1852
+ * if (isLoading) return <p>Loading…</p>;
1853
+ *
1854
+ * return (
1855
+ * <ul>
1856
+ * {threads.map((t) => (
1857
+ * <li key={t.id}>
1858
+ * {t.name ?? "Untitled"}
1859
+ * <button onClick={() => renameThread(t.id, "New name")}>Rename</button>
1860
+ * <button onClick={() => deleteThread(t.id)}>Delete</button>
1861
+ * </li>
1862
+ * ))}
1863
+ * </ul>
1864
+ * );
1865
+ * }
1866
+ * ```
1867
+ */
1868
+ declare function useThreads({
1869
+ agentId,
1870
+ includeArchived,
1871
+ limit
1872
+ }: UseThreadsInput): UseThreadsResult;
1873
+ //#endregion
1874
+ //#region src/v2/lib/react-core.d.ts
1875
+ interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {
1876
+ renderToolCalls?: ReactToolCallRenderer<any>[];
1877
+ renderActivityMessages?: ReactActivityMessageRenderer<any>[];
1878
+ renderCustomMessages?: ReactCustomMessageRenderer[];
1879
+ }
1880
+ interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {
1881
+ onRenderToolCallsChanged?: (event: {
1882
+ copilotkit: CopilotKitCore;
1883
+ renderToolCalls: ReactToolCallRenderer<any>[];
1884
+ }) => void | Promise<void>;
1885
+ onInterruptElementChanged?: (event: {
1886
+ copilotkit: CopilotKitCore;
1887
+ interruptElement: React$1.ReactElement | null;
1888
+ }) => void | Promise<void>;
1889
+ }
1890
+ declare class CopilotKitCoreReact extends CopilotKitCore {
1891
+ private _renderToolCalls;
1892
+ private _hookRenderToolCalls;
1893
+ private _cachedMergedRenderToolCalls;
1894
+ private _renderCustomMessages;
1895
+ private _renderActivityMessages;
1896
+ private _interruptElement;
1897
+ constructor(config: CopilotKitCoreReactConfig);
1898
+ get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]>;
1899
+ get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[];
1900
+ get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[];
1901
+ setRenderActivityMessages(renderers: ReactActivityMessageRenderer<any>[]): void;
1902
+ setRenderCustomMessages(renderers: ReactCustomMessageRenderer[]): void;
1903
+ setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void;
1904
+ addHookRenderToolCall(entry: ReactToolCallRenderer<any>): void;
1905
+ removeHookRenderToolCall(name: string, agentId?: string): void;
1906
+ private _notifyRenderToolCallsChanged;
1907
+ get interruptElement(): React$1.ReactElement | null;
1908
+ setInterruptElement(element: React$1.ReactElement | null): void;
1909
+ subscribe(subscriber: CopilotKitCoreReactSubscriber): CopilotKitCoreSubscription;
1910
+ /**
1911
+ * Wait for pending React state updates before the follow-up agent run.
1912
+ *
1913
+ * When a frontend tool handler calls setState(), React 18 batches the update
1914
+ * and schedules a commit via its internal scheduler (MessageChannel). The
1915
+ * useAgentContext hook registers context via useLayoutEffect, which runs
1916
+ * synchronously after React commits that batch.
1917
+ *
1918
+ * Awaiting a zero-delay timeout yields to the macrotask queue. React's
1919
+ * MessageChannel task runs first, committing the pending state and running
1920
+ * useLayoutEffect (which updates the context store). The follow-up runAgent
1921
+ * call then reads fresh context.
1922
+ */
1923
+ waitForPendingFrameworkUpdates(): Promise<void>;
1924
+ }
1925
+ //#endregion
1926
+ //#region src/v2/providers/CopilotKitProvider.d.ts
1927
+ interface CopilotKitContextValue {
1928
+ copilotkit: CopilotKitCoreReact;
1929
+ /**
1930
+ * Set of tool call IDs currently being executed.
1931
+ * This is tracked at the provider level to ensure tool execution events
1932
+ * are captured even before child components mount.
1933
+ */
1934
+ executingToolCallIds: ReadonlySet<string>;
1935
+ }
1936
+ interface CopilotKitProviderProps {
1937
+ children: ReactNode;
1938
+ runtimeUrl?: string;
1939
+ headers?: Record<string, string>;
1940
+ /**
1941
+ * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
1942
+ */
1943
+ credentials?: RequestCredentials;
1944
+ /**
1945
+ * The Copilot Cloud public API key.
1946
+ */
1947
+ publicApiKey?: string;
1948
+ /**
1949
+ * Alias for `publicApiKey`
1950
+ **/
1951
+ publicLicenseKey?: string;
1952
+ /**
1953
+ * Signed license token for offline verification of premium features.
1954
+ * Obtain from https://cloud.copilotkit.ai.
1955
+ */
1956
+ licenseToken?: string;
1957
+ properties?: Record<string, unknown>;
1958
+ useSingleEndpoint?: boolean;
1959
+ agents__unsafe_dev_only?: Record<string, AbstractAgent>;
1960
+ selfManagedAgents?: Record<string, AbstractAgent>;
1961
+ renderToolCalls?: ReactToolCallRenderer<any>[];
1962
+ renderActivityMessages?: ReactActivityMessageRenderer<any>[];
1963
+ renderCustomMessages?: ReactCustomMessageRenderer[];
1964
+ frontendTools?: ReactFrontendTool[];
1965
+ humanInTheLoop?: ReactHumanInTheLoop[];
1966
+ showDevConsole?: boolean | "auto";
1967
+ /**
1968
+ * Error handler called when CopilotKit encounters an error.
1969
+ * Fires for all error types (runtime connection failures, agent errors, tool errors).
1970
+ */
1971
+ onError?: (event: {
1972
+ error: Error;
1973
+ code: CopilotKitCoreErrorCode;
1974
+ context: Record<string, any>;
1975
+ }) => void | Promise<void>;
1976
+ /**
1977
+ * Configuration for the A2UI (Agent-to-UI) renderer.
1978
+ * The built-in A2UI renderer is activated automatically when the runtime reports
1979
+ * that `a2ui` is configured in `CopilotRuntime`. This prop is optional and only
1980
+ * needed if you want to override the default theme.
1981
+ *
1982
+ * @example
1983
+ * ```tsx
1984
+ * <CopilotKit runtimeUrl="/api/copilotkit" a2ui={{ theme: myCustomTheme }}>
1985
+ * {children}
1986
+ * </CopilotKit>
1987
+ * ```
1988
+ */
1989
+ a2ui?: {
1990
+ /**
1991
+ * Override the default A2UI viewer theme.
1992
+ * When omitted, the built-in `viewerTheme` from `@copilotkit/a2ui-renderer` is used.
1993
+ */
1994
+ theme?: Theme;
1995
+ };
1996
+ }
1997
+ declare const CopilotKitProvider: React$1.FC<CopilotKitProviderProps>;
1998
+ declare const useCopilotKit: () => CopilotKitContextValue;
1999
+ //#endregion
2000
+ //#region src/v2/a2ui/A2UIMessageRenderer.d.ts
2001
+ type A2UIMessageRendererOptions = {
2002
+ theme: Theme;
2003
+ };
2004
+ declare function createA2UIMessageRenderer(options: A2UIMessageRendererOptions): ReactActivityMessageRenderer<any>;
2005
+ //#endregion
2006
+ //#region src/components/copilot-provider/copilotkit-props.d.ts
2007
+ /**
2008
+ * Props for CopilotKit.
2009
+ */
2010
+ /**
2011
+ * We shouldn't need this `Omit` here, but using it because `CopilotKitProps`
2012
+ * and `CopilotKitProviderProps` have non-identical `children` types
2013
+ *
2014
+ * TODO: Remove this `Omit` once this is resolved.
2015
+ */
2016
+ interface CopilotKitProps extends Omit<CopilotKitProviderProps, "children"> {
2017
+ /**
2018
+ * Your Copilot Cloud API key.
2019
+ *
2020
+ * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.
2021
+ */
2022
+ publicApiKey?: string;
2023
+ /**
2024
+ * Your public license key for accessing premium CopilotKit features.
2025
+ *
2026
+ * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.
2027
+ */
2028
+ publicLicenseKey?: string;
2029
+ /**
2030
+ * Restrict input to a specific topic.
2031
+ * @deprecated Use `guardrails_c` instead to control input restrictions
2032
+ */
2033
+ cloudRestrictToTopic?: {
2034
+ validTopics?: string[];
2035
+ invalidTopics?: string[];
2036
+ };
2037
+ /**
2038
+ * Restrict input to specific topics using guardrails.
2039
+ * @remarks
2040
+ *
2041
+ * This feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics.
2042
+ */
2043
+ guardrails_c?: {
2044
+ validTopics?: string[];
2045
+ invalidTopics?: string[];
2046
+ };
2047
+ /**
2048
+ * The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime).
2049
+ */
2050
+ runtimeUrl?: string;
2051
+ /**
2052
+ * The endpoint for the Copilot transcribe audio service.
2053
+ */
2054
+ transcribeAudioUrl?: string;
2055
+ /**
2056
+ * The endpoint for the Copilot text to speech service.
2057
+ */
2058
+ textToSpeechUrl?: string;
2059
+ /**
2060
+ * Additional headers to be sent with the request.
2061
+ *
2062
+ * For example:
2063
+ * ```json
2064
+ * {
2065
+ * "Authorization": "Bearer X"
2066
+ * }
2067
+ * ```
2068
+ */
2069
+ headers?: Record<string, string>;
2070
+ /**
2071
+ * The children to be rendered within the CopilotKit.
2072
+ */
2073
+ children: ReactNode;
2074
+ /**
2075
+ * Custom properties to be sent with the request.
2076
+ * Can include threadMetadata for thread creation and authorization for LangGraph Platform authentication.
2077
+ * For example:
2078
+ * ```js
2079
+ * {
2080
+ * 'user_id': 'users_id',
2081
+ * 'authorization': 'your-auth-token', // For LangGraph Platform authentication
2082
+ * threadMetadata: {
2083
+ * 'account_id': '123',
2084
+ * 'user_type': 'premium'
2085
+ * }
2086
+ * }
2087
+ * ```
2088
+ *
2089
+ * **Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/coagents/shared/guides/langgraph-platform-authentication) for details.
2090
+ */
2091
+ properties?: Record<string, any>;
2092
+ /**
2093
+ * Indicates whether the user agent should send or receive cookies from the other domain
2094
+ * in the case of cross-origin requests.
2095
+ *
2096
+ * To enable HTTP-only cookie authentication, set `credentials="include"` and configure
2097
+ * CORS on your runtime endpoint:
2098
+ *
2099
+ * ```tsx
2100
+ * // Frontend (https://myapp.com)
2101
+ * <CopilotKit runtimeUrl="https://api.myapp.com/copilotkit" credentials="include">
2102
+ * {children}
2103
+ * </CopilotKit>
2104
+ *
2105
+ * // Backend (https://api.myapp.com)
2106
+ * copilotRuntimeNextJSAppRouterEndpoint({
2107
+ * runtime,
2108
+ * endpoint: "/copilotkit",
2109
+ * cors: {
2110
+ * origin: "https://myapp.com",
2111
+ * credentials: true,
2112
+ * },
2113
+ * });
2114
+ * ```
2115
+ */
2116
+ credentials?: RequestCredentials;
2117
+ /**
2118
+ * Whether to show the dev console.
2119
+ *
2120
+ * Set to `true` to show error banners and toasts, `false` to hide all error UI.
2121
+ * Defaults to `false` for production safety.
2122
+ */
2123
+ showDevConsole?: boolean;
2124
+ /**
2125
+ * The name of the agent to use.
2126
+ */
2127
+ agent?: string;
2128
+ /**
2129
+ * The forwarded parameters to use for the task.
2130
+ */
2131
+ forwardedParameters?: Pick<ForwardedParametersInput, "temperature">;
2132
+ /**
2133
+ * The auth config to use for the CopilotKit.
2134
+ * @remarks
2135
+ *
2136
+ * This feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics.
2137
+ */
2138
+ authConfig_c?: {
2139
+ SignInComponent: React.ComponentType<{
2140
+ onSignInComplete: (authState: AuthState) => void;
2141
+ }>;
2142
+ };
2143
+ /**
2144
+ * The thread id to use for the CopilotKit.
2145
+ */
2146
+ threadId?: string;
2147
+ /**
2148
+ * Optional error handler for comprehensive debugging and observability.
2149
+ *
2150
+ * **Requires publicApiKey**: Error handling only works when publicApiKey is provided.
2151
+ * This is a premium Copilot Cloud feature.
2152
+ *
2153
+ * @param errorEvent - Structured error event with rich debugging context
2154
+ *
2155
+ * @example
2156
+ * ```typescript
2157
+ * <CopilotKit
2158
+ * publicApiKey="ck_pub_your_key"
2159
+ * onError={(errorEvent) => {
2160
+ * debugDashboard.capture(errorEvent);
2161
+ * }}
2162
+ * >
2163
+ * ```
2164
+ */
2165
+ onError?: CopilotErrorHandler;
2166
+ /**
2167
+ * Enable or disable the CopilotKit Inspector, letting you inspect AG-UI events,
2168
+ * view agent messages, check agent state, and visualize agent context. Defaults
2169
+ * to enabled.
2170
+ */
2171
+ enableInspector?: boolean;
2172
+ }
2173
+ //#endregion
2174
+ //#region src/components/copilot-provider/copilotkit.d.ts
2175
+ declare function CopilotKit({
2176
+ children,
2177
+ ...props
2178
+ }: CopilotKitProps): react_jsx_runtime0.JSX.Element;
2179
+ declare const defaultCopilotContextCategories: string[];
2180
+ //#endregion
2181
+ export { CopilotSidebar as $, CrewsAgentState as $t, useFrontendTool as A, CopilotChatInputProps as At, useRenderCustomMessages as B, CoagentInChatRenderFunction as Bt, useAgentContext as C, CopilotChatUserMessage as Ct, useDefaultRenderTool as D, CopilotChatToolCallsView as Dt, useHumanInTheLoop as E, CopilotChatAssistantMessageProps as Et, defineToolCallRenderer as F, CopilotChatLabels as Ft, MCPAppsActivityContentSchema as G, CoAgentStateRender as Gt, ReactCustomMessageRendererPosition as H, CopilotContext as Ht, ReactHumanInTheLoop as I, useCopilotChatConfiguration as It, CopilotKitInspector as J, LangGraphInterruptActionSetterArgs as Jt, MCPAppsActivityRenderer as K, LangGraphInterruptAction as Kt, ReactFrontendTool as L, AudioRecorderError as Lt, InterruptEvent as M, CopilotChatConfigurationProvider as Mt, InterruptHandlerProps as N, CopilotChatConfigurationProviderProps as Nt, useRenderTool as O, CopilotChatToolCallsViewProps as Ot, InterruptRenderProps as P, CopilotChatConfigurationValue as Pt, CopilotPopupProps as Q, QueuedInterruptEvent as Qt, ReactActivityMessageRenderer as R, AudioRecorderState as Rt, JsonSerializable as S, CopilotChatReasoningMessageProps as St, useAgent as T, CopilotChatAssistantMessage as Tt, useRenderToolCall as U, CopilotContextParams as Ut, ReactCustomMessageRenderer as V, CopilotApiConfig as Vt, MCPAppsActivityContent as W, useCopilotContext as Wt, WildcardToolCallRender as X, LangGraphInterruptRenderHandlerProps as Xt, CopilotKitInspectorProps as Y, LangGraphInterruptRender as Yt, CopilotPopup as Z, LangGraphInterruptRenderProps as Zt, UseInterruptConfig as _, FrontendActionAvailability as _n, CopilotChatSuggestionView as _t, createA2UIMessageRenderer as a, CopilotChatSuggestionConfiguration as an, CopilotModalHeader as at, useSuggestions as b, CopilotChatSuggestionPillProps as bt, CopilotKitProviderProps as c, Tree as cn, CopilotChatToggleButtonProps as ct, CopilotKitCoreReactConfig as d, ActionRenderPropsNoArgs as dn, CopilotChat as dt, CrewsResponse as en, CopilotSidebarProps as et, CopilotKitCoreReactSubscriber as f, ActionRenderPropsNoArgsWait as fn, CopilotChatProps as ft, useThreads as g, FrontendAction as gn, CopilotChatMessageViewProps as gt, UseThreadsResult as h, CatchAllFrontendAction as hn, CopilotChatMessageView as ht, A2UIMessageRendererOptions as i, CrewsToolStateItem as in, CopilotSidebarViewProps as it, useRenderActivityMessage as j, ToolsMenuItem as jt, useComponent as k, CopilotChatInput as kt, useCopilotKit as l, TreeNode as ln, DefaultCloseIcon as lt, UseThreadsInput as m, CatchAllActionRenderProps as mn, CopilotChatViewProps as mt, defaultCopilotContextCategories as n, CrewsStateItem as nn, CopilotPopupViewProps as nt, CopilotKitContextValue as o, SystemMessageFunction as on, CopilotModalHeaderProps as ot, Thread as p, ActionRenderPropsWait as pn, CopilotChatView as pt, MCPAppsActivityType as q, LangGraphInterruptActionSetter as qt, CopilotKitProps as r, CrewsTaskStateItem as rn, CopilotSidebarView as rt, CopilotKitProvider as s, DocumentPointer as sn, CopilotChatToggleButton as st, CopilotKit as t, CrewsResponseStatus as tn, CopilotPopupView as tt, CopilotKitCoreReact as u, ActionRenderProps as un, DefaultOpenIcon as ut, useInterrupt as v, RenderFunctionStatus as vn, CopilotChatSuggestionViewProps as vt, UseAgentUpdate as w, CopilotChatUserMessageProps as wt, AgentContextInput as x, CopilotChatReasoningMessage as xt, useConfigureSuggestions as y, CopilotChatSuggestionPill as yt, ReactToolCallRenderer as z, CopilotChatAudioRecorder as zt };
2182
+ //# sourceMappingURL=copilotkit-DBzgOMby.d.cts.map