@copilotkit/react-core 1.10.0-next.9 → 1.10.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 (118) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/{chunk-VH45SC6Z.mjs → chunk-2GRWTU7W.mjs} +2 -2
  3. package/dist/chunk-3BASANUO.mjs +170 -0
  4. package/dist/chunk-3BASANUO.mjs.map +1 -0
  5. package/dist/{chunk-PHIMGB3K.mjs → chunk-5P46WS5M.mjs} +25 -19
  6. package/dist/chunk-5P46WS5M.mjs.map +1 -0
  7. package/dist/{chunk-AWFAFFO5.mjs → chunk-6ZLPNY7X.mjs} +7 -3
  8. package/dist/chunk-6ZLPNY7X.mjs.map +1 -0
  9. package/dist/{chunk-TTI4Z6GK.mjs → chunk-BEFEBKKI.mjs} +7 -7
  10. package/dist/chunk-BEFEBKKI.mjs.map +1 -0
  11. package/dist/{chunk-VSH4JSN3.mjs → chunk-F26O2HTO.mjs} +13 -7
  12. package/dist/chunk-F26O2HTO.mjs.map +1 -0
  13. package/dist/{chunk-GRCHDHC4.mjs → chunk-JY3STRON.mjs} +22 -4
  14. package/dist/chunk-JY3STRON.mjs.map +1 -0
  15. package/dist/{chunk-ZTZJIDRJ.mjs → chunk-N4VN2B5S.mjs} +2 -2
  16. package/dist/{chunk-FTP6FDYS.mjs → chunk-NTH42BY5.mjs} +2 -2
  17. package/dist/chunk-PIF5KJYI.mjs +103 -0
  18. package/dist/chunk-PIF5KJYI.mjs.map +1 -0
  19. package/dist/chunk-WSXTUD36.mjs +759 -0
  20. package/dist/chunk-WSXTUD36.mjs.map +1 -0
  21. package/dist/chunk-YIBUNEBN.mjs +34 -0
  22. package/dist/chunk-YIBUNEBN.mjs.map +1 -0
  23. package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -1
  24. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  25. package/dist/components/copilot-provider/copilotkit.js +1052 -72
  26. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  27. package/dist/components/copilot-provider/copilotkit.mjs +6 -3
  28. package/dist/components/copilot-provider/index.js +1052 -72
  29. package/dist/components/copilot-provider/index.js.map +1 -1
  30. package/dist/components/copilot-provider/index.mjs +6 -3
  31. package/dist/components/dev-console/console-trigger.d.ts +8 -0
  32. package/dist/components/dev-console/console-trigger.js +1131 -0
  33. package/dist/components/dev-console/console-trigger.js.map +1 -0
  34. package/dist/components/dev-console/console-trigger.mjs +13 -0
  35. package/dist/components/dev-console/developer-console-modal.d.ts +10 -0
  36. package/dist/components/dev-console/developer-console-modal.js +977 -0
  37. package/dist/components/dev-console/developer-console-modal.js.map +1 -0
  38. package/dist/components/dev-console/developer-console-modal.mjs +12 -0
  39. package/dist/components/dev-console/developer-console-modal.mjs.map +1 -0
  40. package/dist/components/dev-console/icons.d.ts +9 -0
  41. package/dist/components/dev-console/icons.js +131 -0
  42. package/dist/components/dev-console/icons.js.map +1 -0
  43. package/dist/components/dev-console/icons.mjs +16 -0
  44. package/dist/components/dev-console/icons.mjs.map +1 -0
  45. package/dist/components/error-boundary/error-boundary.js +6 -2
  46. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  47. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  48. package/dist/components/index.js +1052 -72
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +6 -3
  51. package/dist/components/usage-banner.d.ts +2 -1
  52. package/dist/components/usage-banner.js +6 -2
  53. package/dist/components/usage-banner.js.map +1 -1
  54. package/dist/components/usage-banner.mjs +1 -1
  55. package/dist/hooks/index.d.ts +5 -5
  56. package/dist/hooks/index.js +58 -26
  57. package/dist/hooks/index.js.map +1 -1
  58. package/dist/hooks/index.mjs +13 -10
  59. package/dist/hooks/use-coagent.d.ts +1 -1
  60. package/dist/hooks/use-coagent.js +18 -6
  61. package/dist/hooks/use-coagent.js.map +1 -1
  62. package/dist/hooks/use-coagent.mjs +8 -5
  63. package/dist/hooks/use-copilot-chat-headless_c.d.ts +33 -0
  64. package/dist/hooks/{use-copilot-chat-light.js → use-copilot-chat-headless_c.js} +88 -19
  65. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
  66. package/dist/hooks/{use-copilot-chat-light.mjs → use-copilot-chat-headless_c.mjs} +14 -8
  67. package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
  68. package/dist/hooks/use-copilot-chat.d.ts +85 -4
  69. package/dist/hooks/use-copilot-chat.js +38 -61
  70. package/dist/hooks/use-copilot-chat.js.map +1 -1
  71. package/dist/hooks/use-copilot-chat.mjs +8 -8
  72. package/dist/hooks/use-copilot-chat_internal.d.ts +98 -12
  73. package/dist/hooks/use-copilot-chat_internal.js +13 -1
  74. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  75. package/dist/hooks/use-copilot-chat_internal.mjs +7 -4
  76. package/dist/hooks/use-langgraph-interrupt.js +13 -1
  77. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  78. package/dist/hooks/use-langgraph-interrupt.mjs +8 -5
  79. package/dist/index.d.ts +3 -3
  80. package/dist/index.js +1203 -200
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +14 -11
  83. package/dist/lib/copilot-task.js.map +1 -1
  84. package/dist/lib/copilot-task.mjs +7 -4
  85. package/dist/lib/index.js.map +1 -1
  86. package/dist/lib/index.mjs +7 -4
  87. package/dist/utils/extract.js.map +1 -1
  88. package/dist/utils/extract.mjs +6 -3
  89. package/dist/utils/index.js.map +1 -1
  90. package/dist/utils/index.mjs +6 -3
  91. package/dist/utils/suggestions.js.map +1 -1
  92. package/dist/utils/suggestions.mjs +6 -3
  93. package/package.json +3 -3
  94. package/src/components/copilot-provider/copilotkit-props.tsx +10 -1
  95. package/src/components/copilot-provider/copilotkit.tsx +25 -16
  96. package/src/components/dev-console/console-trigger.tsx +190 -0
  97. package/src/components/dev-console/developer-console-modal.tsx +866 -0
  98. package/src/components/dev-console/icons.tsx +101 -0
  99. package/src/components/usage-banner.tsx +8 -3
  100. package/src/hooks/index.ts +6 -7
  101. package/src/hooks/use-coagent.ts +6 -11
  102. package/src/hooks/use-copilot-chat-headless_c.ts +257 -0
  103. package/src/hooks/use-copilot-chat.ts +103 -154
  104. package/src/hooks/use-copilot-chat_internal.ts +122 -15
  105. package/dist/chunk-AWFAFFO5.mjs.map +0 -1
  106. package/dist/chunk-GRCHDHC4.mjs.map +0 -1
  107. package/dist/chunk-MWHILKQH.mjs +0 -18
  108. package/dist/chunk-MWHILKQH.mjs.map +0 -1
  109. package/dist/chunk-PHIMGB3K.mjs.map +0 -1
  110. package/dist/chunk-TTI4Z6GK.mjs.map +0 -1
  111. package/dist/chunk-VSH4JSN3.mjs.map +0 -1
  112. package/dist/hooks/use-copilot-chat-light.d.ts +0 -211
  113. package/dist/hooks/use-copilot-chat-light.js.map +0 -1
  114. package/src/hooks/use-copilot-chat-light.ts +0 -219
  115. /package/dist/{chunk-VH45SC6Z.mjs.map → chunk-2GRWTU7W.mjs.map} +0 -0
  116. /package/dist/{chunk-ZTZJIDRJ.mjs.map → chunk-N4VN2B5S.mjs.map} +0 -0
  117. /package/dist/{chunk-FTP6FDYS.mjs.map → chunk-NTH42BY5.mjs.map} +0 -0
  118. /package/dist/{hooks/use-copilot-chat-light.mjs.map → components/dev-console/console-trigger.mjs.map} +0 -0
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "../chunk-VSH4JSN3.mjs";
4
- import {
5
- defaultSystemMessage
6
- } from "../chunk-GRCHDHC4.mjs";
3
+ } from "../chunk-YIBUNEBN.mjs";
4
+ import "../chunk-JY3STRON.mjs";
7
5
  import "../chunk-IN7GE4NO.mjs";
8
6
  import "../chunk-KH27ZS4Y.mjs";
9
7
  import "../chunk-4CEQJ2X6.mjs";
10
- import "../chunk-PHIMGB3K.mjs";
8
+ import "../chunk-5P46WS5M.mjs";
9
+ import "../chunk-N4VN2B5S.mjs";
11
10
  import "../chunk-MUDXTKXE.mjs";
12
- import "../chunk-ZTZJIDRJ.mjs";
11
+ import "../chunk-3BASANUO.mjs";
12
+ import "../chunk-WSXTUD36.mjs";
13
+ import "../chunk-PIF5KJYI.mjs";
13
14
  import "../chunk-2IDV5OHF.mjs";
14
15
  import "../chunk-PMAFHQ7P.mjs";
15
16
  import "../chunk-5FHSUKQL.mjs";
@@ -19,13 +20,12 @@ import "../chunk-ICIK2BSB.mjs";
19
20
  import "../chunk-N4WEHORG.mjs";
20
21
  import "../chunk-O7ARI5CV.mjs";
21
22
  import "../chunk-EFL5OBKN.mjs";
22
- import "../chunk-AWFAFFO5.mjs";
23
+ import "../chunk-6ZLPNY7X.mjs";
23
24
  import "../chunk-YPSGKPDA.mjs";
24
25
  import "../chunk-TEMLWRRT.mjs";
25
26
  import "../chunk-ZLQVRPDS.mjs";
26
27
  import "../chunk-SKC7AJIV.mjs";
27
28
  export {
28
- defaultSystemMessage,
29
29
  useCopilotChat
30
30
  };
31
31
  //# sourceMappingURL=use-copilot-chat.mjs.map
@@ -1,9 +1,9 @@
1
1
  import { SystemMessageFunction } from '../types/system-message.js';
2
+ import { Message as Message$1 } from '@copilotkit/runtime-client-gql';
2
3
  import { Message } from '@copilotkit/shared';
3
4
  import { AppendMessageOptions } from './use-chat.js';
4
5
  import { S as SuggestionItem } from '../index-08c43df1.js';
5
6
  import 'react';
6
- import '@copilotkit/runtime-client-gql';
7
7
  import '../copilot-context-256f9020.js';
8
8
  import '../types/frontend-action.js';
9
9
  import './use-tree.js';
@@ -37,21 +37,102 @@ interface MCPServerConfig {
37
37
  apiKey?: string;
38
38
  }
39
39
  interface UseCopilotChatReturn {
40
- /** Array of messages currently visible in the chat interface */
41
- visibleMessages: Message[];
42
- /** Send a new message to the chat */
43
- appendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;
44
- /** Replace all messages in the chat */
45
- setMessages: (messages: Message[]) => void;
46
- /** Remove a specific message by ID */
40
+ /**
41
+ * @deprecated use `messages` instead, this is an old non ag-ui version of the messages
42
+ * Array of messages currently visible in the chat interface
43
+ *
44
+ * This is the visible messages, not the raw messages from the runtime client.
45
+ */
46
+ visibleMessages: Message$1[];
47
+ /**
48
+ * The messages that are currently in the chat in AG-UI format.
49
+ */
50
+ messages: Message[];
51
+ /** @deprecated use `sendMessage` instead */
52
+ appendMessage: (message: Message$1, options?: AppendMessageOptions) => Promise<void>;
53
+ /**
54
+ * Send a new message to the chat
55
+ *
56
+ * ```tsx
57
+ * await sendMessage({
58
+ * id: "123",
59
+ * role: "user",
60
+ * content: "Hello, process this request",
61
+ * });
62
+ * ```
63
+ */
64
+ sendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;
65
+ /**
66
+ * Replace all messages in the chat
67
+ *
68
+ * ```tsx
69
+ * setMessages([
70
+ * { id: "123", role: "user", content: "Hello, process this request" },
71
+ * { id: "456", role: "assistant", content: "Hello, I'm the assistant" },
72
+ * ]);
73
+ * ```
74
+ *
75
+ * **Deprecated** non-ag-ui version:
76
+ *
77
+ * ```tsx
78
+ * setMessages([
79
+ * new TextMessage({
80
+ * content: "Hello, process this request",
81
+ * role: gqlRole.User,
82
+ * }),
83
+ * new TextMessage({
84
+ * content: "Hello, I'm the assistant",
85
+ * role: gqlRole.Assistant,
86
+ * ]);
87
+ * ```
88
+ *
89
+ */
90
+ setMessages: (messages: Message[] | Message$1[]) => void;
91
+ /**
92
+ * Remove a specific message by ID
93
+ *
94
+ * ```tsx
95
+ * deleteMessage("123");
96
+ * ```
97
+ */
47
98
  deleteMessage: (messageId: string) => void;
48
- /** Regenerate the response for a specific message */
99
+ /**
100
+ * Regenerate the response for a specific message
101
+ *
102
+ * ```tsx
103
+ * reloadMessages("123");
104
+ * ```
105
+ */
49
106
  reloadMessages: (messageId: string) => Promise<void>;
50
- /** Stop the current message generation */
107
+ /**
108
+ * Stop the current message generation
109
+ *
110
+ * ```tsx
111
+ * if (isLoading) {
112
+ * stopGeneration();
113
+ * }
114
+ * ```
115
+ */
51
116
  stopGeneration: () => void;
52
- /** Clear all messages and reset chat state */
117
+ /**
118
+ * Clear all messages and reset chat state
119
+ *
120
+ * ```tsx
121
+ * reset();
122
+ * console.log(messages); // []
123
+ * ```
124
+ */
53
125
  reset: () => void;
54
- /** Whether the chat is currently generating a response */
126
+ /**
127
+ * Whether the chat is currently generating a response
128
+ *
129
+ * ```tsx
130
+ * if (isLoading) {
131
+ * console.log("Loading...");
132
+ * } else {
133
+ * console.log("Not loading");
134
+ * }
135
+ */
55
136
  isLoading: boolean;
56
137
  /** Manually trigger chat completion (advanced usage) */
57
138
  runChatCompletion: () => Promise<Message[]>;
@@ -73,6 +154,11 @@ interface UseCopilotChatReturn {
73
154
  * Trigger AI-powered suggestion generation
74
155
  * Uses configurations from useCopilotChatSuggestions hooks
75
156
  * Respects global debouncing - only one generation can run at a time
157
+ *
158
+ * ```tsx
159
+ * generateSuggestions();
160
+ * console.log(suggestions); // [suggestion1, suggestion2, suggestion3]
161
+ * ```
76
162
  */
77
163
  generateSuggestions: () => Promise<void>;
78
164
  /**
@@ -1635,6 +1635,13 @@ function useCopilotChat(options = {}) {
1635
1635
  }));
1636
1636
  const latestAppend = useUpdatedRef(append);
1637
1637
  const latestAppendFunc = useAsyncCallback(
1638
+ (message, options2) => __async(this, null, function* () {
1639
+ abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
1640
+ return yield latestAppend.current(message, options2);
1641
+ }),
1642
+ [latestAppend]
1643
+ );
1644
+ const latestSendMessageFunc = useAsyncCallback(
1638
1645
  (message, options2) => __async(this, null, function* () {
1639
1646
  abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
1640
1647
  return yield latestAppend.current((0, import_runtime_client_gql7.aguiToGQL)([message])[0], options2);
@@ -1662,6 +1669,9 @@ function useCopilotChat(options = {}) {
1662
1669
  const latestSetMessages = useUpdatedRef(setMessages);
1663
1670
  const latestSetMessagesFunc = (0, import_react9.useCallback)(
1664
1671
  (messages2) => {
1672
+ if (messages2.every((message) => message instanceof import_runtime_client_gql7.Message)) {
1673
+ return latestSetMessages.current(messages2);
1674
+ }
1665
1675
  return latestSetMessages.current((0, import_runtime_client_gql7.aguiToGQL)(messages2));
1666
1676
  },
1667
1677
  [latestSetMessages]
@@ -1698,7 +1708,9 @@ function useCopilotChat(options = {}) {
1698
1708
  }, [latestReset]);
1699
1709
  const interrupt = useLangGraphInterruptRender();
1700
1710
  return {
1701
- visibleMessages: (0, import_runtime_client_gql7.gqlToAGUI)(messages, actions, coAgentStateRenders),
1711
+ visibleMessages: messages,
1712
+ messages: (0, import_runtime_client_gql7.gqlToAGUI)(messages, actions, coAgentStateRenders),
1713
+ sendMessage: latestSendMessageFunc,
1702
1714
  appendMessage: latestAppendFunc,
1703
1715
  setMessages: latestSetMessagesFunc,
1704
1716
  reloadMessages: latestReloadFunc,