@copilotkit/react-core 1.50.0-beta.8 → 1.50.0

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 (77) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/dist/{chunk-KYY2WZSR.mjs → chunk-5J7RRLRO.mjs} +2 -2
  3. package/dist/{chunk-ZU6ZBX4E.mjs → chunk-CO6V4G7P.mjs} +17 -9
  4. package/dist/chunk-CO6V4G7P.mjs.map +1 -0
  5. package/dist/{chunk-Y2L7KDVW.mjs → chunk-HQTDDA6V.mjs} +2 -2
  6. package/dist/chunk-LDEWO5XH.mjs +328 -0
  7. package/dist/chunk-LDEWO5XH.mjs.map +1 -0
  8. package/dist/chunk-XDFVCQD3.mjs +27 -0
  9. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  10. package/dist/{chunk-RQ6LWR6S.mjs → chunk-Z6JV2LRY.mjs} +1 -1
  11. package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
  12. package/dist/{chunk-BLDHD6Q2.mjs → chunk-ZE4JVTEP.mjs} +2 -2
  13. package/dist/components/copilot-provider/copilotkit-props.d.ts +6 -0
  14. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  15. package/dist/components/copilot-provider/copilotkit.js +127 -1150
  16. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  17. package/dist/components/copilot-provider/copilotkit.mjs +3 -6
  18. package/dist/components/copilot-provider/index.js +127 -1150
  19. package/dist/components/copilot-provider/index.js.map +1 -1
  20. package/dist/components/copilot-provider/index.mjs +3 -6
  21. package/dist/components/dev-console/console-trigger.mjs +225 -5
  22. package/dist/components/dev-console/console-trigger.mjs.map +1 -1
  23. package/dist/components/index.js +127 -1150
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/index.mjs +3 -6
  26. package/dist/hooks/index.d.ts +1 -1
  27. package/dist/hooks/index.js +124 -554
  28. package/dist/hooks/index.js.map +1 -1
  29. package/dist/hooks/index.mjs +19 -19
  30. package/dist/hooks/use-copilot-chat-headless_c.js +42 -487
  31. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  32. package/dist/hooks/use-copilot-chat-headless_c.mjs +2 -3
  33. package/dist/hooks/{use-configure-chat-suggestions.d.ts → use-copilot-chat-suggestions.d.ts} +2 -3
  34. package/dist/hooks/{use-configure-chat-suggestions.js → use-copilot-chat-suggestions.js} +10 -29
  35. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  36. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  37. package/dist/hooks/use-copilot-chat.js +40 -485
  38. package/dist/hooks/use-copilot-chat.js.map +1 -1
  39. package/dist/hooks/use-copilot-chat.mjs +2 -3
  40. package/dist/hooks/use-copilot-chat_internal.d.ts +17 -0
  41. package/dist/hooks/use-copilot-chat_internal.js +40 -485
  42. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  43. package/dist/hooks/use-copilot-chat_internal.mjs +1 -2
  44. package/dist/hooks/use-copilot-readable.d.ts +2 -3
  45. package/dist/hooks/use-copilot-readable.js.map +1 -1
  46. package/dist/hooks/use-copilot-readable.mjs +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +300 -1746
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +24 -27
  51. package/dist/lib/copilot-task.js.map +1 -1
  52. package/dist/lib/copilot-task.mjs +4 -7
  53. package/dist/lib/index.js.map +1 -1
  54. package/dist/lib/index.mjs +4 -7
  55. package/dist/types/index.mjs +1 -1
  56. package/package.json +8 -8
  57. package/src/components/copilot-provider/copilotkit-props.tsx +7 -0
  58. package/src/components/copilot-provider/copilotkit.tsx +13 -5
  59. package/src/hooks/index.ts +2 -2
  60. package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
  61. package/src/hooks/use-copilot-chat_internal.ts +29 -29
  62. package/src/hooks/use-copilot-readable.ts +2 -4
  63. package/dist/chunk-EKDPRKZT.mjs +0 -746
  64. package/dist/chunk-EKDPRKZT.mjs.map +0 -1
  65. package/dist/chunk-FBVI3LQ6.mjs +0 -48
  66. package/dist/chunk-FBVI3LQ6.mjs.map +0 -1
  67. package/dist/chunk-PMWUKW3Z.mjs +0 -231
  68. package/dist/chunk-PMWUKW3Z.mjs.map +0 -1
  69. package/dist/chunk-RQ6LWR6S.mjs.map +0 -1
  70. package/dist/chunk-ZU6ZBX4E.mjs.map +0 -1
  71. package/dist/hooks/use-configure-chat-suggestions.js.map +0 -1
  72. package/dist/hooks/use-configure-chat-suggestions.mjs +0 -8
  73. package/src/hooks/use-configure-chat-suggestions.tsx +0 -86
  74. /package/dist/{chunk-KYY2WZSR.mjs.map → chunk-5J7RRLRO.mjs.map} +0 -0
  75. /package/dist/{chunk-Y2L7KDVW.mjs.map → chunk-HQTDDA6V.mjs.map} +0 -0
  76. /package/dist/{chunk-BLDHD6Q2.mjs.map → chunk-ZE4JVTEP.mjs.map} +0 -0
  77. /package/dist/hooks/{use-configure-chat-suggestions.mjs.map → use-copilot-chat-suggestions.mjs.map} +0 -0
@@ -0,0 +1,328 @@
1
+ import {
2
+ useLangGraphInterruptRender
3
+ } from "./chunk-VV56AVPB.mjs";
4
+ import {
5
+ useLazyToolRenderer
6
+ } from "./chunk-ZVF5Q6IH.mjs";
7
+ import {
8
+ useAsyncCallback
9
+ } from "./chunk-6PUNP7CD.mjs";
10
+ import {
11
+ CoAgentStateRenderBridge
12
+ } from "./chunk-QNUAXSDP.mjs";
13
+ import {
14
+ useCopilotContext
15
+ } from "./chunk-AFNWX62Q.mjs";
16
+ import {
17
+ __async,
18
+ __spreadProps,
19
+ __spreadValues
20
+ } from "./chunk-SKC7AJIV.mjs";
21
+
22
+ // src/hooks/use-copilot-chat_internal.ts
23
+ import { useRef, useEffect, useCallback, useMemo, useState, createElement } from "react";
24
+ import { gqlToAGUI, Message as DeprecatedGqlMessage } from "@copilotkit/runtime-client-gql";
25
+ import {
26
+ useAgent,
27
+ useCopilotChatConfiguration,
28
+ useCopilotKit,
29
+ useRenderCustomMessages,
30
+ useSuggestions
31
+ } from "@copilotkitnext/react";
32
+ import { AGUIConnectNotImplementedError } from "@ag-ui/client";
33
+ function useCopilotChatInternal({
34
+ suggestions
35
+ } = {}) {
36
+ var _a, _b, _c;
37
+ const { copilotkit } = useCopilotKit();
38
+ const { threadId, agentSession } = useCopilotContext();
39
+ const existingConfig = useCopilotChatConfiguration();
40
+ const [agentAvailable, setAgentAvailable] = useState(false);
41
+ const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
42
+ const { agent } = useAgent({ agentId: resolvedAgentId });
43
+ useEffect(() => {
44
+ const connect = (agent2) => __async(this, null, function* () {
45
+ setAgentAvailable(false);
46
+ try {
47
+ yield copilotkit.connectAgent({ agent: agent2 });
48
+ setAgentAvailable(true);
49
+ } catch (error) {
50
+ if (error instanceof AGUIConnectNotImplementedError) {
51
+ } else {
52
+ throw error;
53
+ }
54
+ }
55
+ });
56
+ if (agent && (existingConfig == null ? void 0 : existingConfig.threadId) && agent.threadId !== existingConfig.threadId) {
57
+ agent.threadId = existingConfig.threadId;
58
+ connect(agent);
59
+ }
60
+ return () => {
61
+ };
62
+ }, [existingConfig == null ? void 0 : existingConfig.threadId, agent, copilotkit, resolvedAgentId]);
63
+ const interrupt = useLangGraphInterruptRender(agent);
64
+ const reset = () => {
65
+ agent == null ? void 0 : agent.setMessages([]);
66
+ agent == null ? void 0 : agent.setState(null);
67
+ };
68
+ const deleteMessage = useCallback(
69
+ (messageId) => {
70
+ var _a2;
71
+ const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
72
+ (message) => message.id !== messageId
73
+ );
74
+ agent == null ? void 0 : agent.setMessages(filteredMessages);
75
+ },
76
+ [agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
77
+ );
78
+ const latestDelete = useUpdatedRef(deleteMessage);
79
+ const latestDeleteFunc = useCallback(
80
+ (messageId) => {
81
+ return latestDelete.current(messageId);
82
+ },
83
+ [latestDelete]
84
+ );
85
+ const currentSuggestions = useSuggestions({ agentId: resolvedAgentId });
86
+ const reload = useAsyncCallback(
87
+ (reloadMessageId) => __async(this, null, function* () {
88
+ var _a2;
89
+ const messages = (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : [];
90
+ const isLoading = false;
91
+ if (isLoading || messages.length === 0) {
92
+ return;
93
+ }
94
+ const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
95
+ if (reloadMessageIndex === -1) {
96
+ console.warn(`Message with id ${reloadMessageId} not found`);
97
+ return;
98
+ }
99
+ const reloadMessageRole = messages[reloadMessageIndex].role;
100
+ if (reloadMessageRole !== "assistant") {
101
+ console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
102
+ return;
103
+ }
104
+ let historyCutoff = [messages[0]];
105
+ if (messages.length > 2 && reloadMessageIndex !== 0) {
106
+ const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find((msg) => msg.role === "user");
107
+ if (!lastUserMessageBeforeRegenerate) {
108
+ historyCutoff = [messages[0]];
109
+ } else {
110
+ const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
111
+ (msg) => msg.id === lastUserMessageBeforeRegenerate.id
112
+ );
113
+ historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
114
+ }
115
+ } else if (messages.length > 2 && reloadMessageIndex === 0) {
116
+ historyCutoff = [messages[0], messages[1]];
117
+ }
118
+ agent == null ? void 0 : agent.setMessages(historyCutoff);
119
+ if (agent) {
120
+ copilotkit.runAgent({ agent });
121
+ }
122
+ return;
123
+ }),
124
+ [agent == null ? void 0 : agent.setMessages, copilotkit == null ? void 0 : copilotkit.runAgent]
125
+ );
126
+ const latestSendMessageFunc = useAsyncCallback(
127
+ (message, options) => __async(this, null, function* () {
128
+ var _a2;
129
+ if (!agent)
130
+ return;
131
+ const followUp = (_a2 = options == null ? void 0 : options.followUp) != null ? _a2 : true;
132
+ if (options == null ? void 0 : options.clearSuggestions) {
133
+ copilotkit.clearSuggestions(resolvedAgentId);
134
+ }
135
+ agent == null ? void 0 : agent.addMessage(message);
136
+ if (followUp) {
137
+ try {
138
+ yield copilotkit.runAgent({ agent });
139
+ } catch (error) {
140
+ console.error("CopilotChat: runAgent failed", error);
141
+ }
142
+ }
143
+ }),
144
+ [agent, copilotkit, resolvedAgentId]
145
+ );
146
+ const latestAppendFunc = useAsyncCallback(
147
+ (message, options) => __async(this, null, function* () {
148
+ return latestSendMessageFunc(gqlToAGUI([message])[0], options);
149
+ }),
150
+ [latestSendMessageFunc]
151
+ );
152
+ const latestSetMessagesFunc = useCallback(
153
+ (messages) => {
154
+ var _a2, _b2;
155
+ if (messages.every((message) => message instanceof DeprecatedGqlMessage)) {
156
+ return (_a2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _a2.call(agent, gqlToAGUI(messages));
157
+ }
158
+ return (_b2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _b2.call(agent, messages);
159
+ },
160
+ [agent == null ? void 0 : agent.setMessages, agent]
161
+ );
162
+ const latestReload = useUpdatedRef(reload);
163
+ const latestReloadFunc = useAsyncCallback(
164
+ (messageId) => __async(this, null, function* () {
165
+ return yield latestReload.current(messageId);
166
+ }),
167
+ [latestReload]
168
+ );
169
+ const latestStopFunc = useCallback(() => {
170
+ var _a2;
171
+ return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
172
+ }, [agent == null ? void 0 : agent.abortRun]);
173
+ const latestReset = useUpdatedRef(reset);
174
+ const latestResetFunc = useCallback(() => {
175
+ return latestReset.current();
176
+ }, [latestReset]);
177
+ const lazyToolRendered = useLazyToolRenderer();
178
+ const renderCustomMessage = useRenderCustomMessages();
179
+ const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
180
+ copilotkit,
181
+ agent,
182
+ agentId: resolvedAgentId,
183
+ threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
184
+ });
185
+ const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
186
+ const resolvedMessages = useMemo(() => {
187
+ let processedMessages = allMessages.map((message) => {
188
+ if (message.role !== "assistant") {
189
+ return message;
190
+ }
191
+ const lazyRendered = lazyToolRendered(message, allMessages);
192
+ if (lazyRendered) {
193
+ const renderedGenUi = lazyRendered();
194
+ if (renderedGenUi) {
195
+ return __spreadProps(__spreadValues({}, message), { generativeUI: () => renderedGenUi });
196
+ }
197
+ }
198
+ const bridgeRenderer = legacyCustomMessageRenderer || renderCustomMessage ? () => {
199
+ const customRender = renderCustomMessage == null ? void 0 : renderCustomMessage({
200
+ message,
201
+ position: "before"
202
+ });
203
+ if (customRender) {
204
+ return customRender;
205
+ }
206
+ return legacyCustomMessageRenderer == null ? void 0 : legacyCustomMessageRenderer({ message, position: "before" });
207
+ } : null;
208
+ if (bridgeRenderer) {
209
+ return __spreadProps(__spreadValues({}, message), { generativeUI: bridgeRenderer });
210
+ }
211
+ return message;
212
+ });
213
+ const hasAssistantMessages = processedMessages.some((msg) => msg.role === "assistant");
214
+ return processedMessages;
215
+ }, [
216
+ agent == null ? void 0 : agent.messages,
217
+ lazyToolRendered,
218
+ allMessages,
219
+ renderCustomMessage,
220
+ // legacyCustomMessageRenderer,
221
+ resolvedAgentId
222
+ ]);
223
+ const renderedSuggestions = useMemo(() => {
224
+ if (Array.isArray(suggestions)) {
225
+ return {
226
+ suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
227
+ isLoading: false
228
+ };
229
+ }
230
+ return currentSuggestions;
231
+ }, [suggestions, currentSuggestions]);
232
+ return {
233
+ messages: resolvedMessages,
234
+ sendMessage: latestSendMessageFunc,
235
+ appendMessage: latestAppendFunc,
236
+ setMessages: latestSetMessagesFunc,
237
+ reloadMessages: latestReloadFunc,
238
+ stopGeneration: latestStopFunc,
239
+ reset: latestResetFunc,
240
+ deleteMessage: latestDeleteFunc,
241
+ isAvailable: agentAvailable,
242
+ isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
243
+ // mcpServers,
244
+ // setMcpServers,
245
+ suggestions: renderedSuggestions.suggestions,
246
+ setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
247
+ generateSuggestions: () => __async(this, null, function* () {
248
+ return copilotkit.reloadSuggestions(resolvedAgentId);
249
+ }),
250
+ resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
251
+ isLoadingSuggestions: renderedSuggestions.isLoading,
252
+ interrupt,
253
+ agent,
254
+ threadId
255
+ };
256
+ }
257
+ function useUpdatedRef(value) {
258
+ const ref = useRef(value);
259
+ useEffect(() => {
260
+ ref.current = value;
261
+ }, [value]);
262
+ return ref;
263
+ }
264
+ function useLegacyCoagentRenderer({
265
+ copilotkit,
266
+ agent,
267
+ agentId,
268
+ threadId
269
+ }) {
270
+ return useMemo(() => {
271
+ if (!copilotkit || !agent) {
272
+ return null;
273
+ }
274
+ return ({ message, position }) => {
275
+ var _a;
276
+ const effectiveThreadId = (_a = threadId != null ? threadId : agent.threadId) != null ? _a : "default";
277
+ const existingRunId = copilotkit.getRunIdForMessage(agentId, effectiveThreadId, message.id);
278
+ const runId = existingRunId || `pending:${message.id}`;
279
+ const messageIndex = Math.max(
280
+ agent.messages.findIndex((msg) => msg.id === message.id),
281
+ 0
282
+ );
283
+ const bridgeProps = {
284
+ message,
285
+ position,
286
+ runId,
287
+ messageIndex,
288
+ messageIndexInRun: 0,
289
+ numberOfMessagesInRun: 1,
290
+ agentId,
291
+ stateSnapshot: message.state
292
+ };
293
+ return createElement(CoAgentStateRenderBridge, bridgeProps);
294
+ };
295
+ }, [agent, agentId, copilotkit, threadId]);
296
+ }
297
+ function defaultSystemMessage(contextString, additionalInstructions) {
298
+ return `
299
+ Please act as an efficient, competent, conscientious, and industrious professional assistant.
300
+
301
+ Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
302
+ Always be polite and respectful, and prefer brevity over verbosity.
303
+
304
+ The user has provided you with the following context:
305
+ \`\`\`
306
+ ${contextString}
307
+ \`\`\`
308
+
309
+ They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
310
+
311
+ Please assist them as best you can.
312
+
313
+ You can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.
314
+
315
+ If you would like to call a function, call it without saying anything else.
316
+ In case of a function error:
317
+ - If this error stems from incorrect function parameters or syntax, you may retry with corrected arguments.
318
+ - If the error's source is unclear or seems unrelated to your input, do not attempt further retries.
319
+ ` + (additionalInstructions ? `
320
+
321
+ ${additionalInstructions}` : "");
322
+ }
323
+
324
+ export {
325
+ useCopilotChatInternal,
326
+ defaultSystemMessage
327
+ };
328
+ //# sourceMappingURL=chunk-LDEWO5XH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat_internal.ts"],"sourcesContent":["import { useRef, useEffect, useCallback, useMemo, useState, createElement } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { SystemMessageFunction } from \"../types\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\nimport { Message } from \"@copilotkit/shared\";\nimport { gqlToAGUI, Message as DeprecatedGqlMessage } from \"@copilotkit/runtime-client-gql\";\nimport { useLangGraphInterruptRender } from \"./use-langgraph-interrupt-render\";\nimport {\n useAgent,\n useCopilotChatConfiguration,\n useCopilotKit,\n useRenderCustomMessages,\n useSuggestions,\n} from \"@copilotkitnext/react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { useLazyToolRenderer } from \"./use-lazy-tool-renderer\";\nimport { AbstractAgent, AGUIConnectNotImplementedError } from \"@ag-ui/client\";\nimport {\n CoAgentStateRenderBridge,\n type CoAgentStateRenderBridgeProps,\n} from \"./use-coagent-state-render-bridge\";\n\n/**\n * The type of suggestions to use in the chat.\n *\n * `auto` - Suggestions are generated automatically.\n * `manual` - Suggestions are controlled programmatically.\n * `SuggestionItem[]` - Static suggestions array.\n */\nexport type ChatSuggestions = \"auto\" | \"manual\" | Omit<Suggestion, \"isLoading\">[];\n\nexport interface AppendMessageOptions {\n /**\n * Whether to run the chat completion after appending the message. Defaults to `true`.\n */\n followUp?: boolean;\n /**\n * Whether to clear the suggestions after appending the message. Defaults to `true`.\n */\n clearSuggestions?: boolean;\n}\n\nexport interface UseCopilotChatOptions {\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n\n /**\n * Initial messages to populate the chat with.\n */\n initialMessages?: Message[];\n\n /**\n * A function to generate the system message. Defaults to `defaultSystemMessage`.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * Disables inclusion of CopilotKit’s default system message. When true, no system message is sent (this also suppresses any custom message from <code>makeSystemMessage</code>).\n */\n disableSystemMessage?: boolean;\n /**\n * Controls the behavior of suggestions in the chat interface.\n *\n * `auto` (default) - Suggestions are generated automatically:\n * - When the chat is first opened (empty state)\n * - After each message exchange completes\n * - Uses configuration from `useCopilotChatSuggestions` hooks\n *\n * `manual` - Suggestions are controlled programmatically:\n * - Use `setSuggestions()` to set custom suggestions\n * - Use `generateSuggestions()` to trigger AI generation\n * - Access via `useCopilotChat` hook\n *\n * `SuggestionItem[]` - Static suggestions array:\n * - Always shows the same suggestions\n * - No AI generation involved\n */\n suggestions?: ChatSuggestions;\n}\n\nexport interface MCPServerConfig {\n endpoint: string;\n apiKey?: string;\n}\n\n// Old suggestion item interface, for returning from useCopilotChatInternal\ninterface SuggestionItem {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n}\n\nexport interface UseCopilotChatReturn {\n /**\n * @deprecated use `messages` instead, this is an old non ag-ui version of the messages\n * Array of messages currently visible in the chat interface\n *\n * This is the visible messages, not the raw messages from the runtime client.\n */\n visibleMessages: DeprecatedGqlMessage[];\n\n /**\n * The messages that are currently in the chat in AG-UI format.\n */\n messages: Message[];\n\n /** @deprecated use `sendMessage` in `useCopilotChatHeadless_c` instead. This will be removed in a future major version. */\n appendMessage: (message: DeprecatedGqlMessage, options?: AppendMessageOptions) => Promise<void>;\n\n /**\n * Send a new message to the chat\n *\n * ```tsx\n * await sendMessage({\n * id: \"123\",\n * role: \"user\",\n * content: \"Hello, process this request\",\n * });\n * ```\n */\n sendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;\n\n /**\n * Replace all messages in the chat\n *\n * ```tsx\n * setMessages([\n * { id: \"123\", role: \"user\", content: \"Hello, process this request\" },\n * { id: \"456\", role: \"assistant\", content: \"Hello, I'm the assistant\" },\n * ]);\n * ```\n *\n * **Deprecated** non-ag-ui version:\n *\n * ```tsx\n * setMessages([\n * new TextMessage({\n * content: \"Hello, process this request\",\n * role: gqlRole.User,\n * }),\n * new TextMessage({\n * content: \"Hello, I'm the assistant\",\n * role: gqlRole.Assistant,\n * ]);\n * ```\n *\n */\n setMessages: (messages: Message[] | DeprecatedGqlMessage[]) => void;\n\n /**\n * Remove a specific message by ID\n *\n * ```tsx\n * deleteMessage(\"123\");\n * ```\n */\n deleteMessage: (messageId: string) => void;\n\n /**\n * Regenerate the response for a specific message\n *\n * ```tsx\n * reloadMessages(\"123\");\n * ```\n */\n reloadMessages: (messageId: string) => Promise<void>;\n\n /**\n * Stop the current message generation\n *\n * ```tsx\n * if (isLoading) {\n * stopGeneration();\n * }\n * ```\n */\n stopGeneration: () => void;\n\n /**\n * Clear all messages and reset chat state\n *\n * ```tsx\n * reset();\n * console.log(messages); // []\n * ```\n */\n reset: () => void;\n\n /**\n * Whether the chat is currently generating a response\n *\n * ```tsx\n * if (isLoading) {\n * console.log(\"Loading...\");\n * } else {\n * console.log(\"Not loading\");\n * }\n */\n isLoading: boolean;\n\n /**\n * Whether the chat agent is available to generate responses\n *\n * ```tsx\n * if (isAvailable) {\n * console.log(\"Loading...\");\n * } else {\n * console.log(\"Not loading\");\n * }\n */\n isAvailable: boolean;\n\n /** Manually trigger chat completion (advanced usage) */\n runChatCompletion: () => Promise<Message[]>;\n\n /** MCP (Model Context Protocol) server configurations */\n mcpServers: MCPServerConfig[];\n\n /** Update MCP server configurations */\n setMcpServers: (mcpServers: MCPServerConfig[]) => void;\n\n /**\n * Current suggestions array\n * Use this to read the current suggestions or in conjunction with setSuggestions for manual control\n */\n suggestions: Suggestion[];\n\n /**\n * Manually set suggestions\n * Useful for manual mode or custom suggestion workflows\n */\n setSuggestions: (suggestions: Omit<Suggestion, \"isLoading\">[]) => void;\n\n /**\n * Trigger AI-powered suggestion generation\n * Uses configurations from useCopilotChatSuggestions hooks\n * Respects global debouncing - only one generation can run at a time\n *\n * ```tsx\n * generateSuggestions();\n * console.log(suggestions); // [suggestion1, suggestion2, suggestion3]\n * ```\n */\n generateSuggestions: () => Promise<void>;\n\n /**\n * Clear all current suggestions\n * Also resets suggestion generation state\n */\n resetSuggestions: () => void;\n\n /** Whether suggestions are currently being generated */\n isLoadingSuggestions: boolean;\n\n /** Interrupt content for human-in-the-loop workflows */\n interrupt: string | React.ReactElement | null;\n\n agent?: ReturnType<typeof useAgent>[\"agent\"];\n\n threadId?: string;\n}\n\nexport function useCopilotChatInternal({\n suggestions,\n}: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const { copilotkit } = useCopilotKit();\n const { threadId, agentSession } = useCopilotContext();\n const existingConfig = useCopilotChatConfiguration();\n const [agentAvailable, setAgentAvailable] = useState(false);\n\n // Apply priority: props > existing config > defaults\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n const { agent } = useAgent({ agentId: resolvedAgentId });\n\n useEffect(() => {\n const connect = async (agent: AbstractAgent) => {\n setAgentAvailable(false);\n try {\n await copilotkit.connectAgent({ agent });\n setAgentAvailable(true);\n } catch (error) {\n if (error instanceof AGUIConnectNotImplementedError) {\n // connect not implemented, ignore\n } else {\n throw error;\n }\n }\n };\n if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId) {\n agent.threadId = existingConfig.threadId;\n connect(agent);\n }\n return () => {};\n }, [existingConfig?.threadId, agent, copilotkit, resolvedAgentId]);\n\n const interrupt = useLangGraphInterruptRender(agent);\n\n const reset = () => {\n agent?.setMessages([]);\n agent?.setState(null);\n };\n\n const deleteMessage = useCallback(\n (messageId: string) => {\n const filteredMessages = (agent?.messages ?? []).filter(\n (message) => message.id !== messageId,\n );\n agent?.setMessages(filteredMessages);\n },\n [agent?.setMessages, agent?.messages],\n );\n\n const latestDelete = useUpdatedRef(deleteMessage);\n const latestDeleteFunc = useCallback(\n (messageId: string) => {\n return latestDelete.current(messageId);\n },\n [latestDelete],\n );\n\n const currentSuggestions = useSuggestions({ agentId: resolvedAgentId });\n\n const reload = useAsyncCallback(\n async (reloadMessageId: string): Promise<void> => {\n const messages = agent?.messages ?? [];\n // TODO: get isLoading\n const isLoading = false;\n if (isLoading || messages.length === 0) {\n return;\n }\n\n const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);\n if (reloadMessageIndex === -1) {\n console.warn(`Message with id ${reloadMessageId} not found`);\n return;\n }\n\n const reloadMessageRole = messages[reloadMessageIndex].role;\n if (reloadMessageRole !== \"assistant\") {\n console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);\n return;\n }\n let historyCutoff: Message[] = [messages[0]];\n\n if (messages.length > 2 && reloadMessageIndex !== 0) {\n // message to regenerate from is now first.\n // Work backwards to find the first the closest user message\n const lastUserMessageBeforeRegenerate = messages\n .slice(0, reloadMessageIndex)\n .reverse()\n .find((msg) => msg.role === \"user\");\n\n if (!lastUserMessageBeforeRegenerate) {\n historyCutoff = [messages[0]];\n } else {\n const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(\n (msg) => msg.id === lastUserMessageBeforeRegenerate.id,\n );\n // Include the user message, remove everything after it\n historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);\n }\n } else if (messages.length > 2 && reloadMessageIndex === 0) {\n historyCutoff = [messages[0], messages[1]];\n }\n\n agent?.setMessages(historyCutoff);\n\n if (agent) {\n copilotkit.runAgent({ agent });\n }\n return;\n },\n [agent?.setMessages, copilotkit?.runAgent],\n );\n\n const latestSendMessageFunc = useAsyncCallback(\n async (message: Message, options?: AppendMessageOptions) => {\n if (!agent) return;\n const followUp = options?.followUp ?? true;\n if (options?.clearSuggestions) {\n copilotkit.clearSuggestions(resolvedAgentId);\n }\n agent?.addMessage(message);\n if (followUp) {\n try {\n await copilotkit.runAgent({ agent });\n } catch (error) {\n console.error(\"CopilotChat: runAgent failed\", error);\n }\n }\n },\n [agent, copilotkit, resolvedAgentId],\n );\n\n const latestAppendFunc = useAsyncCallback(\n async (message: DeprecatedGqlMessage, options?: AppendMessageOptions) => {\n return latestSendMessageFunc(gqlToAGUI([message])[0], options);\n },\n [latestSendMessageFunc],\n );\n\n const latestSetMessagesFunc = useCallback(\n (messages: Message[] | DeprecatedGqlMessage[]) => {\n if (messages.every((message) => message instanceof DeprecatedGqlMessage)) {\n return agent?.setMessages?.(gqlToAGUI(messages));\n }\n return agent?.setMessages?.(messages);\n },\n [agent?.setMessages, agent],\n );\n\n const latestReload = useUpdatedRef(reload);\n const latestReloadFunc = useAsyncCallback(\n async (messageId: string) => {\n return await latestReload.current(messageId);\n },\n [latestReload],\n );\n\n const latestStopFunc = useCallback(() => {\n return agent?.abortRun?.();\n }, [agent?.abortRun]);\n\n const latestReset = useUpdatedRef(reset);\n const latestResetFunc = useCallback(() => {\n return latestReset.current();\n }, [latestReset]);\n\n const lazyToolRendered = useLazyToolRenderer();\n const renderCustomMessage = useRenderCustomMessages();\n const legacyCustomMessageRenderer = useLegacyCoagentRenderer({\n copilotkit,\n agent,\n agentId: resolvedAgentId,\n threadId: existingConfig?.threadId ?? threadId,\n });\n const allMessages = agent?.messages ?? [];\n const resolvedMessages = useMemo(() => {\n let processedMessages = allMessages.map((message) => {\n if (message.role !== \"assistant\") {\n return message;\n }\n\n const lazyRendered = lazyToolRendered(message, allMessages);\n if (lazyRendered) {\n const renderedGenUi = lazyRendered();\n if (renderedGenUi) {\n return { ...message, generativeUI: () => renderedGenUi };\n }\n }\n\n const bridgeRenderer =\n legacyCustomMessageRenderer || renderCustomMessage\n ? () => {\n const customRender = renderCustomMessage?.({\n message,\n position: \"before\",\n });\n if (customRender) {\n return customRender;\n }\n return legacyCustomMessageRenderer?.({ message, position: \"before\" });\n }\n : null;\n\n if (bridgeRenderer) {\n return { ...message, generativeUI: bridgeRenderer };\n }\n return message;\n });\n\n const hasAssistantMessages = processedMessages.some((msg) => msg.role === \"assistant\");\n\n // TODO: what is this?\n // if (legacyCustomMessageRenderer && !hasAssistantMessages) {\n // const placeholderId = `coagent-state-render-${resolvedAgentId}`;\n // const placeholderMessage: Message = {\n // id: placeholderId,\n // role: \"assistant\",\n // content: \"\",\n // name: \"coagent-state-render\",\n // };\n // processedMessages = [\n // ...processedMessages,\n // {\n // ...placeholderMessage,\n // generativeUI: () =>\n // legacyCustomMessageRenderer({\n // message: placeholderMessage,\n // position: \"before\",\n // }),\n // } as Message,\n // ];\n // }\n\n return processedMessages;\n }, [\n agent?.messages,\n lazyToolRendered,\n allMessages,\n renderCustomMessage,\n // legacyCustomMessageRenderer,\n resolvedAgentId,\n ]);\n\n const renderedSuggestions = useMemo(() => {\n if (Array.isArray(suggestions)) {\n return {\n suggestions: suggestions.map((s) => ({ ...s, isLoading: false })),\n isLoading: false,\n };\n }\n return currentSuggestions;\n }, [suggestions, currentSuggestions]);\n\n // @ts-ignore\n return {\n messages: resolvedMessages,\n sendMessage: latestSendMessageFunc,\n appendMessage: latestAppendFunc,\n setMessages: latestSetMessagesFunc,\n reloadMessages: latestReloadFunc,\n stopGeneration: latestStopFunc,\n reset: latestResetFunc,\n deleteMessage: latestDeleteFunc,\n isAvailable: agentAvailable,\n isLoading: Boolean(agent?.isRunning),\n // mcpServers,\n // setMcpServers,\n suggestions: renderedSuggestions.suggestions,\n setSuggestions: (suggestions: Omit<Suggestion, \"isLoading\">[]) =>\n copilotkit.addSuggestionsConfig({ suggestions }),\n generateSuggestions: async () => copilotkit.reloadSuggestions(resolvedAgentId),\n resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),\n isLoadingSuggestions: renderedSuggestions.isLoading,\n interrupt,\n agent,\n threadId,\n };\n}\n\n// store `value` in a ref and update\n// it whenever it changes.\nfunction useUpdatedRef<T>(value: T) {\n const ref = useRef(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\ntype LegacyRenderParams = {\n message: Message;\n position: \"before\" | \"after\";\n};\n\ntype LegacyRenderer = ((args: LegacyRenderParams) => any) | null;\n\nfunction useLegacyCoagentRenderer({\n copilotkit,\n agent,\n agentId,\n threadId,\n}: {\n copilotkit: ReturnType<typeof useCopilotKit>[\"copilotkit\"];\n agent?: AbstractAgent;\n agentId: string;\n threadId?: string;\n}): LegacyRenderer {\n return useMemo(() => {\n if (!copilotkit || !agent) {\n return null;\n }\n\n return ({ message, position }: LegacyRenderParams) => {\n const effectiveThreadId = threadId ?? agent.threadId ?? \"default\";\n const existingRunId = copilotkit.getRunIdForMessage(agentId, effectiveThreadId, message.id);\n const runId = existingRunId || `pending:${message.id}`;\n const messageIndex = Math.max(\n agent.messages.findIndex((msg) => msg.id === message.id),\n 0,\n );\n\n const bridgeProps: CoAgentStateRenderBridgeProps = {\n message: message as any,\n position,\n runId,\n messageIndex,\n messageIndexInRun: 0,\n numberOfMessagesInRun: 1,\n agentId,\n stateSnapshot: (message as any).state,\n };\n\n return createElement(CoAgentStateRenderBridge, bridgeProps) as any;\n };\n }, [agent, agentId, copilotkit, threadId]);\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\nIn case of a function error:\n- If this error stems from incorrect function parameters or syntax, you may retry with corrected arguments.\n- If the error's source is unclear or seems unrelated to your input, do not attempt further retries.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,WAAW,aAAa,SAAS,UAAU,qBAAqB;AAKjF,SAAS,WAAW,WAAW,4BAA4B;AAE3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAwB,sCAAsC;AAgQvD,SAAS,uBAAuB;AAAA,EACrC;AACF,IAA2B,CAAC,GAAyB;AAlRrD;AAmRE,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,EAAE,UAAU,aAAa,IAAI,kBAAkB;AACrD,QAAM,iBAAiB,4BAA4B;AACnD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAG1D,QAAM,mBAAkB,sDAAgB,YAAhB,YAA2B;AACnD,QAAM,EAAE,MAAM,IAAI,SAAS,EAAE,SAAS,gBAAgB,CAAC;AAEvD,YAAU,MAAM;AACd,UAAM,UAAU,CAAOA,WAAyB;AAC9C,wBAAkB,KAAK;AACvB,UAAI;AACF,cAAM,WAAW,aAAa,EAAE,OAAAA,OAAM,CAAC;AACvC,0BAAkB,IAAI;AAAA,MACxB,SAAS,OAAP;AACA,YAAI,iBAAiB,gCAAgC;AAAA,QAErD,OAAO;AACL,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,QAAI,UAAS,iDAAgB,aAAY,MAAM,aAAa,eAAe,UAAU;AACnF,YAAM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BAA2B;AAEhE;","names":["agent","_a","_b","suggestions"]}
@@ -0,0 +1,27 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "./chunk-SKC7AJIV.mjs";
5
+
6
+ // src/hooks/use-copilot-chat-suggestions.tsx
7
+ import {
8
+ useConfigureSuggestions,
9
+ useCopilotChatConfiguration
10
+ } from "@copilotkitnext/react";
11
+ function useCopilotChatSuggestions(config, dependencies = []) {
12
+ var _a, _b;
13
+ const existingConfig = useCopilotChatConfiguration();
14
+ const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
15
+ const available = (_b = config.available === "enabled" ? "always" : config.available) != null ? _b : "before-first-message";
16
+ const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
17
+ available,
18
+ consumerAgentId: resolvedAgentId
19
+ // Use chatConfig.agentId here
20
+ });
21
+ useConfigureSuggestions(finalSuggestionConfig, dependencies);
22
+ }
23
+
24
+ export {
25
+ useCopilotChatSuggestions
26
+ };
27
+ //# sourceMappingURL=chunk-XDFVCQD3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\nimport {\n useConfigureSuggestions,\n useCopilotChatConfiguration,\n useCopilotKit,\n useSuggestions,\n} from \"@copilotkitnext/react\";\nimport { useEffect } from \"react\";\nimport { StaticSuggestionsConfig, Suggestion } from \"@copilotkitnext/core\";\n\ntype StaticSuggestionInput = Omit<Suggestion, \"isLoading\"> & Partial<Pick<Suggestion, \"isLoading\">>;\n\ntype StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, \"suggestions\"> & {\n suggestions: StaticSuggestionInput[];\n};\n\ntype DynamicSuggestionsConfigInput = {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n\n /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\" | \"always\" | \"before-first-message\" | \"after-first-message\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n};\n\nexport type UseCopilotChatSuggestionsConfiguration =\n | DynamicSuggestionsConfigInput\n | StaticSuggestionsConfigInput;\n\nexport function useCopilotChatSuggestions(\n config: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const existingConfig = useCopilotChatConfiguration();\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n\n const available =\n (config.available === \"enabled\" ? \"always\" : config.available) ?? \"before-first-message\";\n\n const finalSuggestionConfig = {\n ...config,\n available,\n consumerAgentId: resolvedAgentId, // Use chatConfig.agentId here\n };\n useConfigureSuggestions(finalSuggestionConfig, dependencies);\n}\n"],"mappings":";;;;;;AA4DA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AA0CA,SAAS,0BACd,QACA,eAAsB,CAAC,GACvB;AA9GF;AA+GE,QAAM,iBAAiB,4BAA4B;AACnD,QAAM,mBAAkB,sDAAgB,YAAhB,YAA2B;AAEnD,QAAM,aACH,YAAO,cAAc,YAAY,WAAW,OAAO,cAAnD,YAAiE;AAEpE,QAAM,wBAAwB,iCACzB,SADyB;AAAA,IAE5B;AAAA,IACA,iBAAiB;AAAA;AAAA,EACnB;AACA,0BAAwB,uBAAuB,YAAY;AAC7D;","names":[]}
@@ -34,4 +34,4 @@ function useCopilotReadable({ description, value, convert, available }, dependen
34
34
  export {
35
35
  useCopilotReadable
36
36
  };
37
- //# sourceMappingURL=chunk-RQ6LWR6S.mjs.map
37
+ //# sourceMappingURL=chunk-Z6JV2LRY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-readable.ts"],"sourcesContent":["/**\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * In its most basic usage, useCopilotReadable accepts a single string argument\n * representing any piece of app state, making it available for the Copilot to use\n * as context when responding to user input.\n *\n * ```tsx\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotReadable({\n * description: \"The list of employees\",\n * value: employees,\n * });\n * }\n * ```\n *\n * ### Nested Components\n *\n * Optionally, you can maintain the hierarchical structure of information by passing\n * `parentId`. This allows you to use `useCopilotReadable` in nested components:\n *\n * ```tsx /employeeContextId/1 {17,23}\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * function Employee(props: EmployeeProps) {\n * const { employeeName, workProfile, metadata } = props;\n *\n * // propagate any information to copilot\n * const employeeContextId = useCopilotReadable({\n * description: \"Employee name\",\n * value: employeeName\n * });\n *\n * // Pass a parentID to maintain a hierarchical structure.\n * // Especially useful with child React components, list elements, etc.\n * useCopilotReadable({\n * description: \"Work profile\",\n * value: workProfile.description(),\n * parentId: employeeContextId\n * });\n *\n * useCopilotReadable({\n * description: \"Employee metadata\",\n * value: metadata.description(),\n * parentId: employeeContextId\n * });\n *\n * return (\n * // Render as usual...\n * );\n * }\n * ```\n */\nimport { useCopilotKit } from \"@copilotkitnext/react\";\nimport { useEffect, useRef } from \"react\";\n\n/**\n * Options for the useCopilotReadable hook.\n */\nexport interface UseCopilotReadableOptions {\n /**\n * The description of the information to be added to the Copilot context.\n */\n description: string;\n /**\n * The value to be added to the Copilot context. Object values are automatically stringified.\n */\n value: any;\n /**\n * The ID of the parent context, if any.\n */\n parentId?: string;\n /**\n * An array of categories to control which context are visible where. Particularly useful\n * with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n */\n categories?: string[];\n\n /**\n * Whether the context is available to the Copilot.\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * A custom conversion function to use to serialize the value to a string. If not provided, the value\n * will be serialized using `JSON.stringify`.\n */\n convert?: (description: string, value: any) => string;\n}\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n */\nexport function useCopilotReadable(\n { description, value, convert, available }: UseCopilotReadableOptions,\n dependencies?: any[],\n): string | undefined {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!copilotkit) return;\n\n const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {\n return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);\n });\n if (found) {\n ctxIdRef.current = found[0];\n if (available === \"disabled\") copilotkit.removeContext(ctxIdRef.current);\n return;\n }\n if (!found && available === \"disabled\") return;\n\n ctxIdRef.current = copilotkit.addContext({\n description,\n value: (convert ?? JSON.stringify)(value),\n });\n\n return () => {\n if (!ctxIdRef.current) return;\n copilotkit.removeContext(ctxIdRef.current);\n };\n }, [description, value, convert]);\n\n return ctxIdRef.current;\n}\n"],"mappings":";AA+DA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAuC3B,SAAS,mBACd,EAAE,aAAa,OAAO,SAAS,UAAU,GACzC,cACoB;AACpB,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,WAAW,OAA2B,MAAS;AACrD,YAAU,MAAM;AACd,QAAI,CAAC;AAAY;AAEjB,UAAM,QAAQ,OAAO,QAAQ,WAAW,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,MAAM;AACvE,aAAO,KAAK,UAAU,EAAE,aAAa,MAAM,CAAC,KAAK,KAAK,UAAU,OAAO;AAAA,IACzE,CAAC;AACD,QAAI,OAAO;AACT,eAAS,UAAU,MAAM,CAAC;AAC1B,UAAI,cAAc;AAAY,mBAAW,cAAc,SAAS,OAAO;AACvE;AAAA,IACF;AACA,QAAI,CAAC,SAAS,cAAc;AAAY;AAExC,aAAS,UAAU,WAAW,WAAW;AAAA,MACvC;AAAA,MACA,QAAQ,4BAAW,KAAK,WAAW,KAAK;AAAA,IAC1C,CAAC;AAED,WAAO,MAAM;AACX,UAAI,CAAC,SAAS;AAAS;AACvB,iBAAW,cAAc,SAAS,OAAO;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,OAAO,CAAC;AAEhC,SAAO,SAAS;AAClB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotChatInternal
3
- } from "./chunk-EKDPRKZT.mjs";
3
+ } from "./chunk-LDEWO5XH.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-chat.ts
6
6
  function useCopilotChat(options = {}) {
@@ -33,4 +33,4 @@ function useCopilotChat(options = {}) {
33
33
  export {
34
34
  useCopilotChat
35
35
  };
36
- //# sourceMappingURL=chunk-BLDHD6Q2.mjs.map
36
+ //# sourceMappingURL=chunk-ZE4JVTEP.mjs.map
@@ -149,6 +149,12 @@ interface CopilotKitProps extends Omit<CopilotKitProviderProps, "children"> {
149
149
  * ```
150
150
  */
151
151
  onError?: CopilotErrorHandler;
152
+ /**
153
+ * Enable or disable the CopilotKit Inspector, letting you inspect AG-UI events,
154
+ * view agent messages, check agent state, and visualize agent context. Defaults
155
+ * to enabled.
156
+ */
157
+ enableInspector?: boolean;
152
158
  }
153
159
 
154
160
  export { CopilotKitProps };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import { ForwardedParametersInput } from \"@copilotkit/runtime-client-gql\";\nimport { ReactNode } from \"react\";\nimport { AuthState } from \"../../context/copilot-context\";\nimport { CopilotErrorHandler } from \"@copilotkit/shared\";\nimport { CopilotKitProviderProps } from \"@copilotkitnext/react\";\n/**\n * Props for CopilotKit.\n */\n\n/**\n * We shouldn't need this `Omit` here, but using it because `CopilotKitProps`\n * and `CopilotKitProviderProps` have non-identical `children` types\n *\n * TODO: Remove this `Omit` once this is resolved.\n */\nexport interface CopilotKitProps extends Omit<CopilotKitProviderProps, \"children\"> {\n /**\n * Your Copilot Cloud API key.\n *\n * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicApiKey?: string;\n\n /**\n * Your public license key for accessing premium CopilotKit features.\n *\n * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicLicenseKey?: string;\n\n /**\n * Restrict input to a specific topic.\n * @deprecated Use `guardrails_c` instead to control input restrictions\n */\n cloudRestrictToTopic?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * Restrict input to specific topics using guardrails.\n * @remarks\n *\n * 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.\n */\n guardrails_c?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime).\n */\n runtimeUrl?: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * Additional headers to be sent with the request.\n *\n * For example:\n * ```json\n * {\n * \"Authorization\": \"Bearer X\"\n * }\n * ```\n */\n headers?: Record<string, string>;\n\n /**\n * The children to be rendered within the CopilotKit.\n */\n children: ReactNode;\n\n /**\n * Custom properties to be sent with the request.\n * Can include threadMetadata for thread creation and authorization for LangGraph Platform authentication.\n * For example:\n * ```js\n * {\n * 'user_id': 'users_id',\n * 'authorization': 'your-auth-token', // For LangGraph Platform authentication\n * threadMetadata: {\n * 'account_id': '123',\n * 'user_type': 'premium'\n * }\n * }\n * ```\n *\n * **Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/coagents/shared/guides/langgraph-platform-authentication) for details.\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Whether to show the dev console.\n *\n * Set to `true` to show error banners and toasts, `false` to hide all error UI.\n * Defaults to `false` for production safety.\n */\n showDevConsole?: boolean;\n\n /**\n * The name of the agent to use.\n */\n agent?: string;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n\n /**\n * The auth config to use for the CopilotKit.\n * @remarks\n *\n * 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.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n /**\n * The thread id to use for the CopilotKit.\n */\n threadId?: string;\n\n /**\n * Optional error handler for comprehensive debugging and observability.\n *\n * **Requires publicApiKey**: Error handling only works when publicApiKey is provided.\n * This is a premium Copilot Cloud feature.\n *\n * @param errorEvent - Structured error event with rich debugging context\n *\n * @example\n * ```typescript\n * <CopilotKit\n * publicApiKey=\"ck_pub_your_key\"\n * onError={(errorEvent) => {\n * debugDashboard.capture(errorEvent);\n * }}\n * >\n * ```\n */\n onError?: CopilotErrorHandler;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/copilot-provider/copilotkit-props.tsx"],"sourcesContent":["import { ForwardedParametersInput } from \"@copilotkit/runtime-client-gql\";\nimport { ReactNode } from \"react\";\nimport { AuthState } from \"../../context/copilot-context\";\nimport { CopilotErrorHandler } from \"@copilotkit/shared\";\nimport { CopilotKitProviderProps } from \"@copilotkitnext/react\";\n/**\n * Props for CopilotKit.\n */\n\n/**\n * We shouldn't need this `Omit` here, but using it because `CopilotKitProps`\n * and `CopilotKitProviderProps` have non-identical `children` types\n *\n * TODO: Remove this `Omit` once this is resolved.\n */\nexport interface CopilotKitProps extends Omit<CopilotKitProviderProps, \"children\"> {\n /**\n * Your Copilot Cloud API key.\n *\n * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicApiKey?: string;\n\n /**\n * Your public license key for accessing premium CopilotKit features.\n *\n * Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free.\n */\n publicLicenseKey?: string;\n\n /**\n * Restrict input to a specific topic.\n * @deprecated Use `guardrails_c` instead to control input restrictions\n */\n cloudRestrictToTopic?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * Restrict input to specific topics using guardrails.\n * @remarks\n *\n * 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.\n */\n guardrails_c?: {\n validTopics?: string[];\n invalidTopics?: string[];\n };\n\n /**\n * The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime).\n */\n runtimeUrl?: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * Additional headers to be sent with the request.\n *\n * For example:\n * ```json\n * {\n * \"Authorization\": \"Bearer X\"\n * }\n * ```\n */\n headers?: Record<string, string>;\n\n /**\n * The children to be rendered within the CopilotKit.\n */\n children: ReactNode;\n\n /**\n * Custom properties to be sent with the request.\n * Can include threadMetadata for thread creation and authorization for LangGraph Platform authentication.\n * For example:\n * ```js\n * {\n * 'user_id': 'users_id',\n * 'authorization': 'your-auth-token', // For LangGraph Platform authentication\n * threadMetadata: {\n * 'account_id': '123',\n * 'user_type': 'premium'\n * }\n * }\n * ```\n *\n * **Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/coagents/shared/guides/langgraph-platform-authentication) for details.\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Whether to show the dev console.\n *\n * Set to `true` to show error banners and toasts, `false` to hide all error UI.\n * Defaults to `false` for production safety.\n */\n showDevConsole?: boolean;\n\n /**\n * The name of the agent to use.\n */\n agent?: string;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n\n /**\n * The auth config to use for the CopilotKit.\n * @remarks\n *\n * 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.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n /**\n * The thread id to use for the CopilotKit.\n */\n threadId?: string;\n\n /**\n * Optional error handler for comprehensive debugging and observability.\n *\n * **Requires publicApiKey**: Error handling only works when publicApiKey is provided.\n * This is a premium Copilot Cloud feature.\n *\n * @param errorEvent - Structured error event with rich debugging context\n *\n * @example\n * ```typescript\n * <CopilotKit\n * publicApiKey=\"ck_pub_your_key\"\n * onError={(errorEvent) => {\n * debugDashboard.capture(errorEvent);\n * }}\n * >\n * ```\n */\n onError?: CopilotErrorHandler;\n\n /**\n * Enable or disable the CopilotKit Inspector, letting you inspect AG-UI events,\n * view agent messages, check agent state, and visualize agent context. Defaults\n * to enabled.\n */\n enableInspector?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}