@copilotkit/react-ui 1.2.0 → 1.2.2-feat-runtime-remote-actions.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.
- package/CHANGELOG.md +47 -0
- package/dist/components/chat/Chat.d.mts +1 -1
- package/dist/components/chat/Chat.d.ts +1 -1
- package/dist/components/chat/Chat.js +101 -5
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +108 -11
- package/dist/components/chat/Chat.mjs.map +1 -1
- package/dist/components/chat/Messages.js +46 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +48 -3
- package/dist/components/chat/Messages.mjs.map +1 -1
- package/dist/components/chat/Modal.js +101 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +108 -12
- package/dist/components/chat/Modal.mjs.map +1 -1
- package/dist/components/chat/Popup.js +101 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +108 -12
- package/dist/components/chat/Popup.mjs.map +1 -1
- package/dist/components/chat/Sidebar.js +101 -7
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +108 -13
- package/dist/components/chat/Sidebar.mjs.map +1 -1
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs.map +1 -1
- package/dist/components/chat/index.js +101 -7
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +108 -13
- package/dist/components/chat/index.mjs.map +1 -1
- package/dist/components/dev-console/console.js +52 -0
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +52 -0
- package/dist/components/dev-console/console.mjs.map +1 -1
- package/dist/components/dev-console/index.js +52 -0
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +52 -0
- package/dist/components/dev-console/index.mjs.map +1 -1
- package/dist/components/dev-console/utils.d.mts +2 -1
- package/dist/components/dev-console/utils.d.ts +2 -1
- package/dist/components/dev-console/utils.js +53 -0
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +52 -0
- package/dist/components/dev-console/utils.mjs.map +1 -1
- package/dist/components/index.js +101 -7
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +108 -13
- package/dist/components/index.mjs.map +1 -1
- package/dist/index.js +101 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/chat/Chat.tsx +1 -1
- package/src/components/chat/Messages.tsx +83 -2
- package/src/components/chat/Modal.tsx +0 -1
- package/src/components/chat/Sidebar.tsx +0 -1
- package/src/components/chat/Suggestion.tsx +2 -0
- package/src/components/dev-console/console.tsx +6 -0
- package/src/components/dev-console/utils.ts +56 -0
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.2.0",
|
|
12
|
+
"version": "1.2.2-feat-runtime-remote-actions.0",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"ts-jest": "^29.1.1",
|
|
49
49
|
"tsup-async-inject-style": "0.0.2",
|
|
50
50
|
"typescript": "^5.5.4",
|
|
51
|
-
"eslint-config-custom": "1.2.0",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
51
|
+
"eslint-config-custom": "1.2.2-feat-runtime-remote-actions.0",
|
|
52
|
+
"tsconfig": "1.2.2-feat-runtime-remote-actions.0",
|
|
53
|
+
"tailwind-config": "1.2.2-feat-runtime-remote-actions.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@headlessui/react": "^2.1.3",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"react-syntax-highlighter": "^15.5.0",
|
|
59
59
|
"remark-gfm": "^3.0.1",
|
|
60
60
|
"remark-math": "^5.1.1",
|
|
61
|
-
"@copilotkit/react-core": "1.2.0",
|
|
62
|
-
"@copilotkit/runtime-client-gql": "1.2.0",
|
|
63
|
-
"@copilotkit/shared": "1.2.0"
|
|
61
|
+
"@copilotkit/react-core": "1.2.2-feat-runtime-remote-actions.0",
|
|
62
|
+
"@copilotkit/runtime-client-gql": "1.2.2-feat-runtime-remote-actions.0",
|
|
63
|
+
"@copilotkit/shared": "1.2.2-feat-runtime-remote-actions.0"
|
|
64
64
|
},
|
|
65
65
|
"keywords": [
|
|
66
66
|
"copilotkit",
|
|
@@ -227,7 +227,7 @@ const SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;
|
|
|
227
227
|
export const useCopilotChatLogic = (
|
|
228
228
|
makeSystemMessage?: SystemMessageFunction,
|
|
229
229
|
onInProgress?: (isLoading: boolean) => void,
|
|
230
|
-
onSubmitMessage?: (messageContent: string) => void,
|
|
230
|
+
onSubmitMessage?: (messageContent: string) => Promise<void> | void,
|
|
231
231
|
) => {
|
|
232
232
|
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } =
|
|
233
233
|
useCopilotChat({
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
ResultMessage,
|
|
11
11
|
TextMessage,
|
|
12
12
|
Role,
|
|
13
|
+
AgentStateMessage,
|
|
13
14
|
} from "@copilotkit/runtime-client-gql";
|
|
15
|
+
import { CoagentInChatRenderFunction } from "@copilotkit/react-core/dist/context/copilot-context";
|
|
14
16
|
|
|
15
17
|
export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
16
18
|
const { chatComponentsCache } = useCopilotContext();
|
|
@@ -73,8 +75,11 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
|
73
75
|
</div>
|
|
74
76
|
);
|
|
75
77
|
} else if (message instanceof ActionExecutionMessage) {
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
+
if (
|
|
79
|
+
chatComponentsCache.current !== null &&
|
|
80
|
+
chatComponentsCache.current.actions[message.name]
|
|
81
|
+
) {
|
|
82
|
+
const render = chatComponentsCache.current.actions[message.name];
|
|
78
83
|
// render a static string
|
|
79
84
|
if (typeof render === "string") {
|
|
80
85
|
// when render is static, we show it only when in progress
|
|
@@ -140,6 +145,82 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
|
140
145
|
</div>
|
|
141
146
|
);
|
|
142
147
|
}
|
|
148
|
+
} else if (message instanceof AgentStateMessage) {
|
|
149
|
+
let render: string | CoagentInChatRenderFunction | undefined;
|
|
150
|
+
|
|
151
|
+
if (chatComponentsCache.current !== null) {
|
|
152
|
+
render =
|
|
153
|
+
chatComponentsCache.current.coagentActions[
|
|
154
|
+
`${message.agentName}-${message.nodeName}`
|
|
155
|
+
] || chatComponentsCache.current.coagentActions[`${message.agentName}-global`];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (render) {
|
|
159
|
+
// render a static string
|
|
160
|
+
if (typeof render === "string") {
|
|
161
|
+
// when render is static, we show it only when in progress
|
|
162
|
+
if (isCurrentMessage && inProgress) {
|
|
163
|
+
return (
|
|
164
|
+
<div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
|
|
165
|
+
{context.icons.spinnerIcon} <span className="inProgressLabel">{render}</span>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
170
|
+
else {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// render is a function
|
|
175
|
+
else {
|
|
176
|
+
const state = message.state;
|
|
177
|
+
|
|
178
|
+
let status = message.active ? "inProgress" : "complete";
|
|
179
|
+
|
|
180
|
+
const toRender = render({
|
|
181
|
+
status: status as any,
|
|
182
|
+
state,
|
|
183
|
+
nodeName: message.nodeName,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// No result and complete: stay silent
|
|
187
|
+
if (!toRender && status === "complete") {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (typeof toRender === "string") {
|
|
192
|
+
return (
|
|
193
|
+
<div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
|
|
194
|
+
{isCurrentMessage && inProgress && context.icons.spinnerIcon} {toRender}
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
} else {
|
|
198
|
+
return (
|
|
199
|
+
<div key={index} className="copilotKitCustomAssistantMessage">
|
|
200
|
+
{toRender}
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// No render function found- show the default message
|
|
207
|
+
else if (!inProgress || !isCurrentMessage) {
|
|
208
|
+
// Done - silent by default to avoid a series of "done" messages
|
|
209
|
+
return null;
|
|
210
|
+
} else {
|
|
211
|
+
// In progress
|
|
212
|
+
return (
|
|
213
|
+
<div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
|
|
214
|
+
{context.icons.spinnerIcon}
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
} else if (message instanceof ResultMessage && inProgress && isCurrentMessage) {
|
|
219
|
+
return (
|
|
220
|
+
<div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
|
|
221
|
+
{context.icons.spinnerIcon}
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
143
224
|
}
|
|
144
225
|
})}
|
|
145
226
|
<footer ref={messagesEndRef}>{children}</footer>
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
CopilotContextParams,
|
|
3
3
|
extract,
|
|
4
4
|
CopilotChatSuggestionConfiguration,
|
|
5
|
+
useCopilotContext,
|
|
5
6
|
} from "@copilotkit/react-core";
|
|
6
7
|
import { SuggestionsProps } from "./props";
|
|
7
8
|
import { SmallSpinnerIcon } from "./Icons";
|
|
@@ -50,6 +51,7 @@ export const reloadSuggestions = async (
|
|
|
50
51
|
? `Produce up to ${config.maxSuggestions} suggestions. ` +
|
|
51
52
|
`If there are no highly relevant suggestions you can think of, provide an empty array.`
|
|
52
53
|
: `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
54
|
+
|
|
53
55
|
const result = await extract({
|
|
54
56
|
context,
|
|
55
57
|
instructions:
|
|
@@ -4,6 +4,7 @@ import { useCopilotContext } from "@copilotkit/react-core";
|
|
|
4
4
|
import {
|
|
5
5
|
getPublishedCopilotKitVersion,
|
|
6
6
|
logActions,
|
|
7
|
+
logMessages,
|
|
7
8
|
logReadables,
|
|
8
9
|
shouldShowDevConsole,
|
|
9
10
|
} from "./utils";
|
|
@@ -250,6 +251,11 @@ export default function DebugMenuButton({
|
|
|
250
251
|
Log Actions
|
|
251
252
|
</button>
|
|
252
253
|
</MenuItem>
|
|
254
|
+
<MenuItem>
|
|
255
|
+
<button className="copilotKitDebugMenuItem" onClick={() => logMessages(context)}>
|
|
256
|
+
Log Messages
|
|
257
|
+
</button>
|
|
258
|
+
</MenuItem>
|
|
253
259
|
<MenuItem>
|
|
254
260
|
<button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
|
|
255
261
|
Check for Updates
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CopilotContextParams, defaultCopilotContextCategories } from "@copilotkit/react-core";
|
|
2
2
|
import { CopilotKitVersion } from "./types";
|
|
3
|
+
import { ActionExecutionMessage, ResultMessage, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
4
|
+
import { AgentStateMessage } from "@copilotkit/runtime-client-gql";
|
|
3
5
|
|
|
4
6
|
export function shouldShowDevConsole(showDevConsole: boolean | "auto"): boolean {
|
|
5
7
|
if (typeof showDevConsole === "boolean") {
|
|
@@ -78,6 +80,8 @@ export async function getPublishedCopilotKitVersion(
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
export function logReadables(context: CopilotContextParams) {
|
|
83
|
+
console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
|
|
84
|
+
|
|
81
85
|
const readables = context.getContextString([], defaultCopilotContextCategories).trim();
|
|
82
86
|
if (readables.length === 0) {
|
|
83
87
|
console.log("No readables found");
|
|
@@ -87,6 +91,8 @@ export function logReadables(context: CopilotContextParams) {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
export function logActions(context: CopilotContextParams) {
|
|
94
|
+
console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
|
|
95
|
+
|
|
90
96
|
if (Object.values(context.actions).length === 0) {
|
|
91
97
|
console.log("No actions found");
|
|
92
98
|
return;
|
|
@@ -100,3 +106,53 @@ export function logActions(context: CopilotContextParams) {
|
|
|
100
106
|
console.groupEnd();
|
|
101
107
|
}
|
|
102
108
|
}
|
|
109
|
+
|
|
110
|
+
export function logMessages(context: CopilotContextParams) {
|
|
111
|
+
console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
|
|
112
|
+
|
|
113
|
+
if (context.messages.length === 0) {
|
|
114
|
+
console.log("No messages found");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const tableData = context.messages.map((message) => {
|
|
119
|
+
if (message instanceof TextMessage) {
|
|
120
|
+
return {
|
|
121
|
+
id: message.id,
|
|
122
|
+
type: "TextMessage",
|
|
123
|
+
role: message.role,
|
|
124
|
+
name: undefined,
|
|
125
|
+
scope: undefined,
|
|
126
|
+
content: message.content,
|
|
127
|
+
};
|
|
128
|
+
} else if (message instanceof ActionExecutionMessage) {
|
|
129
|
+
return {
|
|
130
|
+
id: message.id,
|
|
131
|
+
type: "ActionExecutionMessage",
|
|
132
|
+
role: undefined,
|
|
133
|
+
name: message.name,
|
|
134
|
+
scope: message.scope,
|
|
135
|
+
content: message.arguments,
|
|
136
|
+
};
|
|
137
|
+
} else if (message instanceof ResultMessage) {
|
|
138
|
+
return {
|
|
139
|
+
id: message.id,
|
|
140
|
+
type: "ResultMessage",
|
|
141
|
+
role: undefined,
|
|
142
|
+
name: message.actionName,
|
|
143
|
+
scope: message.actionExecutionId,
|
|
144
|
+
content: message.result,
|
|
145
|
+
};
|
|
146
|
+
} else if (message instanceof AgentStateMessage) {
|
|
147
|
+
return {
|
|
148
|
+
id: message.id,
|
|
149
|
+
type: `AgentStateMessage (running: ${message.running})`,
|
|
150
|
+
role: message.role,
|
|
151
|
+
name: undefined,
|
|
152
|
+
scope: message.threadId,
|
|
153
|
+
content: message.state,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
console.table(tableData);
|
|
158
|
+
}
|