@copilotkit/react-core 1.9.3-next.4 → 1.10.0-next.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 +38 -0
- package/dist/chunk-2IDV5OHF.mjs +11 -0
- package/dist/chunk-2IDV5OHF.mjs.map +1 -0
- package/dist/{chunk-36MGCCPZ.mjs → chunk-4CFY3CON.mjs} +2 -2
- package/dist/{chunk-BVK7PLK6.mjs → chunk-DF4YG4PF.mjs} +2 -2
- package/dist/{chunk-ELU3VLPJ.mjs → chunk-G35QHAQ6.mjs} +8 -8
- package/dist/chunk-G35QHAQ6.mjs.map +1 -0
- package/dist/{chunk-DNHCRVE6.mjs → chunk-LIGLZ53V.mjs} +98 -26
- package/dist/chunk-LIGLZ53V.mjs.map +1 -0
- package/dist/{chunk-5BSUSFHM.mjs → chunk-LNAQ7JG3.mjs} +2 -2
- package/dist/{chunk-NJA5ZLAZ.mjs → chunk-LU5JPZ24.mjs} +2 -2
- package/dist/{chunk-GIMSRCVW.mjs → chunk-NAM55D5I.mjs} +153 -14
- package/dist/chunk-NAM55D5I.mjs.map +1 -0
- package/dist/{chunk-CUAFWKTQ.mjs → chunk-O5KV32S5.mjs} +4 -4
- package/dist/{chunk-FN3UA2ZE.mjs → chunk-PZXTDFMX.mjs} +3 -3
- package/dist/{chunk-VDADWRS3.mjs → chunk-Q6FZZJ5A.mjs} +2 -2
- package/dist/{chunk-KIXKBJUV.mjs → chunk-RGKZCCPA.mjs} +2 -2
- package/dist/{chunk-SGF6C7I6.mjs → chunk-SJJNFYGQ.mjs} +4 -4
- package/dist/{chunk-DKZTPL66.mjs → chunk-XGRBCWK6.mjs} +5 -2
- package/dist/chunk-XGRBCWK6.mjs.map +1 -0
- package/dist/{chunk-BSAVFYRQ.mjs → chunk-YBDRISKO.mjs} +5 -5
- package/dist/{chunk-QPX2JKOR.mjs → chunk-YSQ5I2AE.mjs} +6 -6
- package/dist/chunk-YSQ5I2AE.mjs.map +1 -0
- package/dist/{chunk-5B3NSTQK.mjs → chunk-YVBDAURK.mjs} +3 -3
- package/dist/components/copilot-provider/copilot-messages.js +4 -1
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.js +8 -2
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +10 -9
- package/dist/components/copilot-provider/index.d.ts +2 -1
- package/dist/components/copilot-provider/index.js +8 -2
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +10 -9
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +8 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -9
- package/dist/context/copilot-context.d.ts +2 -1
- package/dist/context/copilot-context.js +4 -1
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +4 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/{copilot-context-3ab4fdf5.d.ts → copilot-context-bd88d30d.d.ts} +21 -1
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.js +493 -154
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +32 -31
- package/dist/hooks/use-chat.d.ts +6 -1
- package/dist/hooks/use-chat.js +5 -2
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +4 -4
- package/dist/hooks/use-coagent-state-render.js +4 -1
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.d.ts +3 -3
- package/dist/hooks/use-coagent.js +427 -45
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +16 -14
- package/dist/hooks/use-copilot-action.js +4 -1
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-additional-instructions.js +4 -1
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +4 -1
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
- package/dist/hooks/use-copilot-chat.d.ts +43 -6
- package/dist/hooks/use-copilot-chat.js +443 -65
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +15 -13
- package/dist/hooks/use-copilot-readable.js +4 -1
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +4 -1
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.d.ts +4 -3
- package/dist/hooks/use-langgraph-interrupt.js +452 -72
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +16 -14
- package/dist/hooks/use-make-copilot-document-readable.js +4 -1
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +422 -201
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -36
- package/dist/lib/copilot-task.d.ts +2 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +12 -11
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +12 -11
- package/dist/types/interrupt-action.d.ts +3 -2
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +10 -9
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +144 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +16 -10
- package/dist/utils/suggestions-constants.d.ts +9 -0
- package/dist/utils/suggestions-constants.js +35 -0
- package/dist/utils/suggestions-constants.js.map +1 -0
- package/dist/utils/suggestions-constants.mjs +8 -0
- package/dist/utils/suggestions-constants.mjs.map +1 -0
- package/dist/utils/suggestions.d.ts +11 -0
- package/dist/utils/suggestions.js +343 -0
- package/dist/utils/suggestions.js.map +1 -0
- package/dist/utils/suggestions.mjs +22 -0
- package/dist/utils/suggestions.mjs.map +1 -0
- package/package.json +3 -3
- package/src/components/copilot-provider/copilotkit.tsx +4 -0
- package/src/context/copilot-context.tsx +6 -0
- package/src/hooks/use-chat.ts +6 -2
- package/src/hooks/use-coagent.ts +1 -1
- package/src/hooks/use-copilot-chat.ts +197 -21
- package/src/utils/index.ts +3 -0
- package/src/utils/suggestions-constants.ts +8 -0
- package/src/utils/suggestions.ts +208 -0
- package/dist/chunk-DKZTPL66.mjs.map +0 -1
- package/dist/chunk-DNHCRVE6.mjs.map +0 -1
- package/dist/chunk-ELU3VLPJ.mjs.map +0 -1
- package/dist/chunk-GIMSRCVW.mjs.map +0 -1
- package/dist/chunk-QPX2JKOR.mjs.map +0 -1
- /package/dist/{chunk-36MGCCPZ.mjs.map → chunk-4CFY3CON.mjs.map} +0 -0
- /package/dist/{chunk-BVK7PLK6.mjs.map → chunk-DF4YG4PF.mjs.map} +0 -0
- /package/dist/{chunk-5BSUSFHM.mjs.map → chunk-LNAQ7JG3.mjs.map} +0 -0
- /package/dist/{chunk-NJA5ZLAZ.mjs.map → chunk-LU5JPZ24.mjs.map} +0 -0
- /package/dist/{chunk-CUAFWKTQ.mjs.map → chunk-O5KV32S5.mjs.map} +0 -0
- /package/dist/{chunk-FN3UA2ZE.mjs.map → chunk-PZXTDFMX.mjs.map} +0 -0
- /package/dist/{chunk-VDADWRS3.mjs.map → chunk-Q6FZZJ5A.mjs.map} +0 -0
- /package/dist/{chunk-KIXKBJUV.mjs.map → chunk-RGKZCCPA.mjs.map} +0 -0
- /package/dist/{chunk-SGF6C7I6.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
- /package/dist/{chunk-BSAVFYRQ.mjs.map → chunk-YBDRISKO.mjs.map} +0 -0
- /package/dist/{chunk-5B3NSTQK.mjs.map → chunk-YVBDAURK.mjs.map} +0 -0
|
@@ -85,7 +85,7 @@ __export(use_coagent_exports, {
|
|
|
85
85
|
useCoAgent: () => useCoAgent
|
|
86
86
|
});
|
|
87
87
|
module.exports = __toCommonJS(use_coagent_exports);
|
|
88
|
-
var
|
|
88
|
+
var import_react10 = require("react");
|
|
89
89
|
|
|
90
90
|
// src/context/copilot-context.tsx
|
|
91
91
|
var import_react = __toESM(require("react"));
|
|
@@ -161,7 +161,10 @@ var emptyCopilotContext = {
|
|
|
161
161
|
langGraphInterruptAction: null,
|
|
162
162
|
setLangGraphInterruptAction: () => null,
|
|
163
163
|
removeLangGraphInterruptAction: () => null,
|
|
164
|
-
onError: void 0
|
|
164
|
+
onError: void 0,
|
|
165
|
+
suggestions: [],
|
|
166
|
+
setSuggestions: () => {
|
|
167
|
+
}
|
|
165
168
|
};
|
|
166
169
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
167
170
|
function useCopilotContext() {
|
|
@@ -193,8 +196,7 @@ function useCopilotMessagesContext() {
|
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
// src/hooks/use-copilot-chat.ts
|
|
196
|
-
var
|
|
197
|
-
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
199
|
+
var import_react9 = require("react");
|
|
198
200
|
|
|
199
201
|
// src/hooks/use-chat.ts
|
|
200
202
|
var import_react6 = require("react");
|
|
@@ -858,7 +860,7 @@ function useChat(options) {
|
|
|
858
860
|
const action = actions.find(
|
|
859
861
|
(action2) => action2.name === message.name
|
|
860
862
|
);
|
|
861
|
-
if (action && action.available === "
|
|
863
|
+
if (action && action.available === "frontend") {
|
|
862
864
|
continue;
|
|
863
865
|
}
|
|
864
866
|
const currentResultMessagePairedFeAction = message.isResultMessage() ? getPairedFeAction(actions, message) : null;
|
|
@@ -1147,17 +1149,326 @@ function getPairedFeAction(actions, message) {
|
|
|
1147
1149
|
// src/components/copilot-provider/copilotkit.tsx
|
|
1148
1150
|
var import_react7 = require("react");
|
|
1149
1151
|
var import_react_dom2 = require("react-dom");
|
|
1152
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
1153
|
+
|
|
1154
|
+
// src/utils/extract.ts
|
|
1150
1155
|
var import_shared5 = require("@copilotkit/shared");
|
|
1156
|
+
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
1157
|
+
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
1158
|
+
function extract(_0) {
|
|
1159
|
+
return __async(this, arguments, function* ({
|
|
1160
|
+
context,
|
|
1161
|
+
instructions,
|
|
1162
|
+
parameters,
|
|
1163
|
+
include,
|
|
1164
|
+
data,
|
|
1165
|
+
abortSignal,
|
|
1166
|
+
stream,
|
|
1167
|
+
requestType = import_runtime_client_gql4.CopilotRequestType.Task,
|
|
1168
|
+
forwardedParameters
|
|
1169
|
+
}) {
|
|
1170
|
+
var _a, _b;
|
|
1171
|
+
const { messages } = context;
|
|
1172
|
+
const action = {
|
|
1173
|
+
name: "extract",
|
|
1174
|
+
description: instructions,
|
|
1175
|
+
parameters,
|
|
1176
|
+
handler: (args) => {
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
const includeReadable = (_a = include == null ? void 0 : include.readable) != null ? _a : false;
|
|
1180
|
+
const includeMessages = (_b = include == null ? void 0 : include.messages) != null ? _b : false;
|
|
1181
|
+
let contextString = "";
|
|
1182
|
+
if (data) {
|
|
1183
|
+
contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
|
|
1184
|
+
}
|
|
1185
|
+
if (includeReadable) {
|
|
1186
|
+
contextString += context.getContextString([], defaultCopilotContextCategories);
|
|
1187
|
+
}
|
|
1188
|
+
const systemMessage = new import_runtime_client_gql4.TextMessage({
|
|
1189
|
+
content: makeSystemMessage(contextString, instructions),
|
|
1190
|
+
role: import_runtime_client_gql4.Role.System
|
|
1191
|
+
});
|
|
1192
|
+
const instructionsMessage = new import_runtime_client_gql4.TextMessage({
|
|
1193
|
+
content: makeInstructionsMessage(instructions),
|
|
1194
|
+
role: import_runtime_client_gql4.Role.User
|
|
1195
|
+
});
|
|
1196
|
+
const response = context.runtimeClient.asStream(
|
|
1197
|
+
context.runtimeClient.generateCopilotResponse({
|
|
1198
|
+
data: {
|
|
1199
|
+
frontend: {
|
|
1200
|
+
actions: [
|
|
1201
|
+
{
|
|
1202
|
+
name: action.name,
|
|
1203
|
+
description: action.description || "",
|
|
1204
|
+
jsonSchema: JSON.stringify((0, import_shared5.actionParametersToJsonSchema)(action.parameters || []))
|
|
1205
|
+
}
|
|
1206
|
+
],
|
|
1207
|
+
url: window.location.href
|
|
1208
|
+
},
|
|
1209
|
+
messages: (0, import_runtime_client_gql5.convertMessagesToGqlInput)(
|
|
1210
|
+
includeMessages ? [systemMessage, instructionsMessage, ...(0, import_runtime_client_gql5.filterAgentStateMessages)(messages)] : [systemMessage, instructionsMessage]
|
|
1211
|
+
),
|
|
1212
|
+
metadata: {
|
|
1213
|
+
requestType
|
|
1214
|
+
},
|
|
1215
|
+
forwardedParameters: __spreadProps(__spreadValues({}, forwardedParameters != null ? forwardedParameters : {}), {
|
|
1216
|
+
toolChoice: "function",
|
|
1217
|
+
toolChoiceFunctionName: action.name
|
|
1218
|
+
})
|
|
1219
|
+
},
|
|
1220
|
+
properties: context.copilotApiConfig.properties,
|
|
1221
|
+
signal: abortSignal
|
|
1222
|
+
})
|
|
1223
|
+
);
|
|
1224
|
+
const reader = response.getReader();
|
|
1225
|
+
let isInitial = true;
|
|
1226
|
+
let actionExecutionMessage = void 0;
|
|
1227
|
+
while (true) {
|
|
1228
|
+
const { done, value } = yield reader.read();
|
|
1229
|
+
if (done) {
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
1233
|
+
throw new Error("Aborted");
|
|
1234
|
+
}
|
|
1235
|
+
actionExecutionMessage = (0, import_runtime_client_gql4.convertGqlOutputToMessages)(
|
|
1236
|
+
value.generateCopilotResponse.messages
|
|
1237
|
+
).find((msg) => msg.isActionExecutionMessage());
|
|
1238
|
+
if (!actionExecutionMessage) {
|
|
1239
|
+
continue;
|
|
1240
|
+
}
|
|
1241
|
+
stream == null ? void 0 : stream({
|
|
1242
|
+
status: isInitial ? "initial" : "inProgress",
|
|
1243
|
+
args: actionExecutionMessage.arguments
|
|
1244
|
+
});
|
|
1245
|
+
isInitial = false;
|
|
1246
|
+
}
|
|
1247
|
+
if (!actionExecutionMessage) {
|
|
1248
|
+
throw new Error("extract() failed: No function call occurred");
|
|
1249
|
+
}
|
|
1250
|
+
stream == null ? void 0 : stream({
|
|
1251
|
+
status: "complete",
|
|
1252
|
+
args: actionExecutionMessage.arguments
|
|
1253
|
+
});
|
|
1254
|
+
return actionExecutionMessage.arguments;
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
function makeInstructionsMessage(instructions) {
|
|
1258
|
+
return `
|
|
1259
|
+
The user has given you the following task to complete:
|
|
1260
|
+
|
|
1261
|
+
\`\`\`
|
|
1262
|
+
${instructions}
|
|
1263
|
+
\`\`\`
|
|
1264
|
+
|
|
1265
|
+
Any additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.
|
|
1266
|
+
`;
|
|
1267
|
+
}
|
|
1268
|
+
function makeSystemMessage(contextString, instructions) {
|
|
1269
|
+
return `
|
|
1270
|
+
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
1271
|
+
|
|
1272
|
+
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.
|
|
1273
|
+
Always be polite and respectful, and prefer brevity over verbosity.
|
|
1274
|
+
|
|
1275
|
+
The user has provided you with the following context:
|
|
1276
|
+
\`\`\`
|
|
1277
|
+
${contextString}
|
|
1278
|
+
\`\`\`
|
|
1279
|
+
|
|
1280
|
+
They have also provided you with a function called extract you MUST call to initiate actions on their behalf.
|
|
1281
|
+
|
|
1282
|
+
Please assist them as best you can.
|
|
1283
|
+
|
|
1284
|
+
This is not a conversation, so please do not ask questions. Just call the function without saying anything else.
|
|
1285
|
+
`;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
// src/utils/suggestions.ts
|
|
1289
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
1290
|
+
var import_runtime_client_gql6 = require("@copilotkit/runtime-client-gql");
|
|
1291
|
+
var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
|
|
1292
|
+
const abortController = abortControllerRef.current;
|
|
1293
|
+
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
const setSuggestionsIfNotAborted = (suggestions) => {
|
|
1297
|
+
if (!(abortController == null ? void 0 : abortController.signal.aborted) && abortControllerRef.current === abortController) {
|
|
1298
|
+
setCurrentSuggestions(suggestions);
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
try {
|
|
1302
|
+
const tools = JSON.stringify(
|
|
1303
|
+
Object.values(context.actions).map((action) => ({
|
|
1304
|
+
name: action.name,
|
|
1305
|
+
description: action.description,
|
|
1306
|
+
jsonSchema: JSON.stringify((0, import_shared6.actionParametersToJsonSchema)(action.parameters))
|
|
1307
|
+
}))
|
|
1308
|
+
);
|
|
1309
|
+
const allSuggestions = [];
|
|
1310
|
+
let hasSuccessfulSuggestions = false;
|
|
1311
|
+
let hasErrors = false;
|
|
1312
|
+
let lastError = null;
|
|
1313
|
+
const enabledConfigs = Object.values(chatSuggestionConfiguration).filter(
|
|
1314
|
+
(config) => config.instructions && config.instructions.trim().length > 0
|
|
1315
|
+
);
|
|
1316
|
+
if (enabledConfigs.length === 0) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
setSuggestionsIfNotAborted([]);
|
|
1320
|
+
for (const config of enabledConfigs) {
|
|
1321
|
+
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
1322
|
+
setSuggestionsIfNotAborted([]);
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
try {
|
|
1326
|
+
const result = yield extract({
|
|
1327
|
+
context,
|
|
1328
|
+
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
1329
|
+
data: `${config.instructions}
|
|
1330
|
+
|
|
1331
|
+
Available tools: ${tools}
|
|
1332
|
+
|
|
1333
|
+
`,
|
|
1334
|
+
requestType: import_runtime_client_gql6.CopilotRequestType.Task,
|
|
1335
|
+
parameters: [
|
|
1336
|
+
{
|
|
1337
|
+
name: "suggestions",
|
|
1338
|
+
type: "object[]",
|
|
1339
|
+
attributes: [
|
|
1340
|
+
{
|
|
1341
|
+
name: "title",
|
|
1342
|
+
description: "The title of the suggestion. This is shown as a button and should be short.",
|
|
1343
|
+
type: "string"
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
name: "message",
|
|
1347
|
+
description: "The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",
|
|
1348
|
+
type: "string"
|
|
1349
|
+
}
|
|
1350
|
+
]
|
|
1351
|
+
}
|
|
1352
|
+
],
|
|
1353
|
+
include: {
|
|
1354
|
+
messages: true,
|
|
1355
|
+
readable: true
|
|
1356
|
+
},
|
|
1357
|
+
abortSignal: abortController == null ? void 0 : abortController.signal,
|
|
1358
|
+
stream: ({ status, args }) => {
|
|
1359
|
+
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
const suggestions = args.suggestions || [];
|
|
1363
|
+
const newSuggestions = [];
|
|
1364
|
+
for (let i = 0; i < suggestions.length; i++) {
|
|
1365
|
+
if (config.maxSuggestions !== void 0 && i >= config.maxSuggestions) {
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
const suggestion = suggestions[i];
|
|
1369
|
+
if (!suggestion || typeof suggestion !== "object") {
|
|
1370
|
+
continue;
|
|
1371
|
+
}
|
|
1372
|
+
const { title, message } = suggestion;
|
|
1373
|
+
const hasValidTitle = title && typeof title === "string" && title.trim().length > 0;
|
|
1374
|
+
const hasValidMessage = message && typeof message === "string" && message.trim().length > 0;
|
|
1375
|
+
if (!hasValidTitle) {
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
const partial = i === suggestions.length - 1 && status !== "complete";
|
|
1379
|
+
newSuggestions.push({
|
|
1380
|
+
title: title.trim(),
|
|
1381
|
+
message: hasValidMessage ? message.trim() : "",
|
|
1382
|
+
// Use title as fallback
|
|
1383
|
+
partial,
|
|
1384
|
+
className: config.className
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
setSuggestionsIfNotAborted([...allSuggestions, ...newSuggestions]);
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
if ((result == null ? void 0 : result.suggestions) && Array.isArray(result.suggestions)) {
|
|
1391
|
+
const validSuggestions = result.suggestions.filter(
|
|
1392
|
+
(suggestion) => suggestion && typeof suggestion.title === "string" && suggestion.title.trim().length > 0
|
|
1393
|
+
).map((suggestion) => ({
|
|
1394
|
+
title: suggestion.title.trim(),
|
|
1395
|
+
message: suggestion.message && typeof suggestion.message === "string" && suggestion.message.trim() ? suggestion.message.trim() : suggestion.title.trim()
|
|
1396
|
+
}));
|
|
1397
|
+
if (validSuggestions.length > 0) {
|
|
1398
|
+
allSuggestions.push(...validSuggestions);
|
|
1399
|
+
hasSuccessfulSuggestions = true;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
} catch (error) {
|
|
1403
|
+
hasErrors = true;
|
|
1404
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (hasSuccessfulSuggestions && allSuggestions.length > 0) {
|
|
1408
|
+
const uniqueSuggestions = allSuggestions.filter(
|
|
1409
|
+
(suggestion, index, self) => index === self.findIndex((s) => s.message === suggestion.message)
|
|
1410
|
+
);
|
|
1411
|
+
setSuggestionsIfNotAborted(uniqueSuggestions);
|
|
1412
|
+
} else if (hasErrors) {
|
|
1413
|
+
const errorMessage = lastError ? lastError.message : "Failed to generate suggestions due to API errors";
|
|
1414
|
+
throw new Error(errorMessage);
|
|
1415
|
+
}
|
|
1416
|
+
} catch (error) {
|
|
1417
|
+
throw error;
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1421
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
1151
1422
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1152
1423
|
var defaultCopilotContextCategories = ["global"];
|
|
1153
1424
|
|
|
1154
1425
|
// src/hooks/use-copilot-chat.ts
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1426
|
+
var import_runtime_client_gql7 = require("@copilotkit/runtime-client-gql");
|
|
1427
|
+
|
|
1428
|
+
// src/hooks/use-langgraph-interrupt-render.ts
|
|
1429
|
+
var import_react8 = __toESM(require("react"));
|
|
1430
|
+
var InterruptRenderer = ({ event, result, render, resolve }) => {
|
|
1431
|
+
return render({ event, result, resolve });
|
|
1432
|
+
};
|
|
1433
|
+
function useLangGraphInterruptRender() {
|
|
1434
|
+
const { langGraphInterruptAction, setLangGraphInterruptAction, agentSession } = useCopilotContext();
|
|
1435
|
+
const responseRef = import_react8.default.useRef();
|
|
1436
|
+
const resolveInterrupt = (0, import_react8.useCallback)(
|
|
1437
|
+
(response) => {
|
|
1438
|
+
responseRef.current = response;
|
|
1439
|
+
setTimeout(() => {
|
|
1440
|
+
setLangGraphInterruptAction({ event: { response } });
|
|
1441
|
+
}, 0);
|
|
1442
|
+
},
|
|
1443
|
+
[setLangGraphInterruptAction]
|
|
1444
|
+
);
|
|
1445
|
+
if (!langGraphInterruptAction || !langGraphInterruptAction.event || !langGraphInterruptAction.render)
|
|
1446
|
+
return null;
|
|
1447
|
+
const { render, handler, event, enabled } = langGraphInterruptAction;
|
|
1448
|
+
const conditionsMet = !agentSession || !enabled ? true : enabled({ eventValue: event.value, agentMetadata: agentSession });
|
|
1449
|
+
if (!conditionsMet) {
|
|
1450
|
+
return null;
|
|
1451
|
+
}
|
|
1452
|
+
let result = null;
|
|
1453
|
+
if (handler) {
|
|
1454
|
+
result = handler({
|
|
1455
|
+
event,
|
|
1456
|
+
resolve: resolveInterrupt
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
return import_react8.default.createElement(InterruptRenderer, {
|
|
1460
|
+
event,
|
|
1461
|
+
result,
|
|
1462
|
+
render,
|
|
1463
|
+
resolve: resolveInterrupt
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// src/hooks/use-copilot-chat.ts
|
|
1468
|
+
var globalSuggestionPromise = null;
|
|
1469
|
+
function useCopilotChat(options = {}) {
|
|
1470
|
+
var _a;
|
|
1471
|
+
const makeSystemMessage2 = (_a = options.makeSystemMessage) != null ? _a : defaultSystemMessage;
|
|
1161
1472
|
const {
|
|
1162
1473
|
getContextString,
|
|
1163
1474
|
getFunctionCallHandler,
|
|
@@ -1181,11 +1492,72 @@ function useCopilotChat(_a = {}) {
|
|
|
1181
1492
|
extensions,
|
|
1182
1493
|
setExtensions,
|
|
1183
1494
|
langGraphInterruptAction,
|
|
1184
|
-
setLangGraphInterruptAction
|
|
1495
|
+
setLangGraphInterruptAction,
|
|
1496
|
+
chatSuggestionConfiguration,
|
|
1497
|
+
suggestions,
|
|
1498
|
+
setSuggestions,
|
|
1499
|
+
runtimeClient
|
|
1185
1500
|
} = useCopilotContext();
|
|
1186
1501
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
1187
|
-
const [mcpServers, setLocalMcpServers] = (0,
|
|
1188
|
-
(0,
|
|
1502
|
+
const [mcpServers, setLocalMcpServers] = (0, import_react9.useState)([]);
|
|
1503
|
+
const suggestionsAbortControllerRef = (0, import_react9.useRef)(null);
|
|
1504
|
+
const isLoadingSuggestionsRef = (0, import_react9.useRef)(false);
|
|
1505
|
+
const abortSuggestions = (0, import_react9.useCallback)(
|
|
1506
|
+
(clear = true) => {
|
|
1507
|
+
var _a2;
|
|
1508
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort("suggestions aborted by user");
|
|
1509
|
+
suggestionsAbortControllerRef.current = null;
|
|
1510
|
+
if (clear) {
|
|
1511
|
+
setSuggestions([]);
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1514
|
+
[setSuggestions]
|
|
1515
|
+
);
|
|
1516
|
+
const stableContext = (0, import_react9.useMemo)(() => {
|
|
1517
|
+
return {
|
|
1518
|
+
actions,
|
|
1519
|
+
copilotApiConfig,
|
|
1520
|
+
chatSuggestionConfiguration,
|
|
1521
|
+
messages,
|
|
1522
|
+
setMessages,
|
|
1523
|
+
getContextString,
|
|
1524
|
+
runtimeClient
|
|
1525
|
+
};
|
|
1526
|
+
}, [
|
|
1527
|
+
JSON.stringify(Object.keys(actions)),
|
|
1528
|
+
copilotApiConfig.chatApiEndpoint,
|
|
1529
|
+
messages.length,
|
|
1530
|
+
Object.keys(chatSuggestionConfiguration).length
|
|
1531
|
+
]);
|
|
1532
|
+
const generateSuggestionsFunc = (0, import_react9.useCallback)(() => __async(this, null, function* () {
|
|
1533
|
+
if (globalSuggestionPromise) {
|
|
1534
|
+
return globalSuggestionPromise;
|
|
1535
|
+
}
|
|
1536
|
+
globalSuggestionPromise = (() => __async(this, null, function* () {
|
|
1537
|
+
try {
|
|
1538
|
+
abortSuggestions();
|
|
1539
|
+
isLoadingSuggestionsRef.current = true;
|
|
1540
|
+
suggestionsAbortControllerRef.current = new AbortController();
|
|
1541
|
+
setSuggestions([]);
|
|
1542
|
+
yield reloadSuggestions(
|
|
1543
|
+
stableContext,
|
|
1544
|
+
chatSuggestionConfiguration,
|
|
1545
|
+
setSuggestions,
|
|
1546
|
+
suggestionsAbortControllerRef
|
|
1547
|
+
);
|
|
1548
|
+
} catch (error) {
|
|
1549
|
+
throw error;
|
|
1550
|
+
} finally {
|
|
1551
|
+
isLoadingSuggestionsRef.current = false;
|
|
1552
|
+
globalSuggestionPromise = null;
|
|
1553
|
+
}
|
|
1554
|
+
}))();
|
|
1555
|
+
return globalSuggestionPromise;
|
|
1556
|
+
}), [stableContext, chatSuggestionConfiguration, setSuggestions, abortSuggestions]);
|
|
1557
|
+
const resetSuggestions = (0, import_react9.useCallback)(() => {
|
|
1558
|
+
setSuggestions([]);
|
|
1559
|
+
}, [setSuggestions]);
|
|
1560
|
+
(0, import_react9.useEffect)(() => {
|
|
1189
1561
|
if (mcpServers.length > 0) {
|
|
1190
1562
|
const serversCopy = [...mcpServers];
|
|
1191
1563
|
copilotApiConfig.mcpServers = serversCopy;
|
|
@@ -1195,7 +1567,7 @@ function useCopilotChat(_a = {}) {
|
|
|
1195
1567
|
copilotApiConfig.properties.mcpServers = serversCopy;
|
|
1196
1568
|
}
|
|
1197
1569
|
}, [mcpServers, copilotApiConfig]);
|
|
1198
|
-
const setMcpServers = (0,
|
|
1570
|
+
const setMcpServers = (0, import_react9.useCallback)((servers) => {
|
|
1199
1571
|
setLocalMcpServers(servers);
|
|
1200
1572
|
}, []);
|
|
1201
1573
|
const onCoAgentStateRender = useAsyncCallback(
|
|
@@ -1216,15 +1588,15 @@ function useCopilotChat(_a = {}) {
|
|
|
1216
1588
|
}),
|
|
1217
1589
|
[coAgentStateRenders]
|
|
1218
1590
|
);
|
|
1219
|
-
const makeSystemMessageCallback = (0,
|
|
1220
|
-
const systemMessageMaker =
|
|
1591
|
+
const makeSystemMessageCallback = (0, import_react9.useCallback)(() => {
|
|
1592
|
+
const systemMessageMaker = makeSystemMessage2 || defaultSystemMessage;
|
|
1221
1593
|
const contextString = getContextString([], defaultCopilotContextCategories);
|
|
1222
|
-
return new
|
|
1594
|
+
return new import_runtime_client_gql7.TextMessage({
|
|
1223
1595
|
content: systemMessageMaker(contextString, chatInstructions),
|
|
1224
|
-
role:
|
|
1596
|
+
role: import_runtime_client_gql7.Role.System
|
|
1225
1597
|
});
|
|
1226
|
-
}, [getContextString,
|
|
1227
|
-
const deleteMessage = (0,
|
|
1598
|
+
}, [getContextString, makeSystemMessage2, chatInstructions]);
|
|
1599
|
+
const deleteMessage = (0, import_react9.useCallback)(
|
|
1228
1600
|
(messageId) => {
|
|
1229
1601
|
setMessages((prev) => prev.filter((message) => message.id !== messageId));
|
|
1230
1602
|
},
|
|
@@ -1233,7 +1605,7 @@ function useCopilotChat(_a = {}) {
|
|
|
1233
1605
|
const { append, reload, stop, runChatCompletion } = useChat(__spreadProps(__spreadValues({}, options), {
|
|
1234
1606
|
actions: Object.values(actions),
|
|
1235
1607
|
copilotConfig: copilotApiConfig,
|
|
1236
|
-
initialMessages: options.initialMessages || [],
|
|
1608
|
+
initialMessages: (0, import_runtime_client_gql7.aguiToGQL)(options.initialMessages || []),
|
|
1237
1609
|
onFunctionCall: getFunctionCallHandler(),
|
|
1238
1610
|
onCoAgentStateRender,
|
|
1239
1611
|
messages,
|
|
@@ -1260,7 +1632,8 @@ function useCopilotChat(_a = {}) {
|
|
|
1260
1632
|
const latestAppend = useUpdatedRef(append);
|
|
1261
1633
|
const latestAppendFunc = useAsyncCallback(
|
|
1262
1634
|
(message, options2) => __async(this, null, function* () {
|
|
1263
|
-
|
|
1635
|
+
abortSuggestions(options2 == null ? void 0 : options2.clearSuggestions);
|
|
1636
|
+
return yield latestAppend.current((0, import_runtime_client_gql7.aguiToGQL)([message])[0], options2);
|
|
1264
1637
|
}),
|
|
1265
1638
|
[latestAppend]
|
|
1266
1639
|
);
|
|
@@ -1272,20 +1645,20 @@ function useCopilotChat(_a = {}) {
|
|
|
1272
1645
|
[latestReload]
|
|
1273
1646
|
);
|
|
1274
1647
|
const latestStop = useUpdatedRef(stop);
|
|
1275
|
-
const latestStopFunc = (0,
|
|
1648
|
+
const latestStopFunc = (0, import_react9.useCallback)(() => {
|
|
1276
1649
|
return latestStop.current();
|
|
1277
1650
|
}, [latestStop]);
|
|
1278
1651
|
const latestDelete = useUpdatedRef(deleteMessage);
|
|
1279
|
-
const latestDeleteFunc = (0,
|
|
1652
|
+
const latestDeleteFunc = (0, import_react9.useCallback)(
|
|
1280
1653
|
(messageId) => {
|
|
1281
1654
|
return latestDelete.current(messageId);
|
|
1282
1655
|
},
|
|
1283
1656
|
[latestDelete]
|
|
1284
1657
|
);
|
|
1285
1658
|
const latestSetMessages = useUpdatedRef(setMessages);
|
|
1286
|
-
const latestSetMessagesFunc = (0,
|
|
1659
|
+
const latestSetMessagesFunc = (0, import_react9.useCallback)(
|
|
1287
1660
|
(messages2) => {
|
|
1288
|
-
return latestSetMessages.current(messages2);
|
|
1661
|
+
return latestSetMessages.current((0, import_runtime_client_gql7.aguiToGQL)(messages2));
|
|
1289
1662
|
},
|
|
1290
1663
|
[latestSetMessages]
|
|
1291
1664
|
);
|
|
@@ -1293,7 +1666,7 @@ function useCopilotChat(_a = {}) {
|
|
|
1293
1666
|
const latestRunChatCompletionFunc = useAsyncCallback(() => __async(this, null, function* () {
|
|
1294
1667
|
return yield latestRunChatCompletion.current();
|
|
1295
1668
|
}), [latestRunChatCompletion]);
|
|
1296
|
-
const reset = (0,
|
|
1669
|
+
const reset = (0, import_react9.useCallback)(() => {
|
|
1297
1670
|
latestStopFunc();
|
|
1298
1671
|
setMessages([]);
|
|
1299
1672
|
setRunId(null);
|
|
@@ -1305,20 +1678,23 @@ function useCopilotChat(_a = {}) {
|
|
|
1305
1678
|
};
|
|
1306
1679
|
}
|
|
1307
1680
|
setAgentSession(initialAgentSession);
|
|
1681
|
+
resetSuggestions();
|
|
1308
1682
|
}, [
|
|
1309
1683
|
latestStopFunc,
|
|
1310
1684
|
setMessages,
|
|
1311
1685
|
setThreadId,
|
|
1312
1686
|
setCoagentStatesWithRef,
|
|
1313
1687
|
setAgentSession,
|
|
1314
|
-
agentLock
|
|
1688
|
+
agentLock,
|
|
1689
|
+
resetSuggestions
|
|
1315
1690
|
]);
|
|
1316
1691
|
const latestReset = useUpdatedRef(reset);
|
|
1317
|
-
const latestResetFunc = (0,
|
|
1692
|
+
const latestResetFunc = (0, import_react9.useCallback)(() => {
|
|
1318
1693
|
return latestReset.current();
|
|
1319
1694
|
}, [latestReset]);
|
|
1695
|
+
const interrupt = useLangGraphInterruptRender();
|
|
1320
1696
|
return {
|
|
1321
|
-
visibleMessages: messages,
|
|
1697
|
+
visibleMessages: (0, import_runtime_client_gql7.gqlToAGUI)(messages, actions, coAgentStateRenders),
|
|
1322
1698
|
appendMessage: latestAppendFunc,
|
|
1323
1699
|
setMessages: latestSetMessagesFunc,
|
|
1324
1700
|
reloadMessages: latestReloadFunc,
|
|
@@ -1328,12 +1704,18 @@ function useCopilotChat(_a = {}) {
|
|
|
1328
1704
|
runChatCompletion: latestRunChatCompletionFunc,
|
|
1329
1705
|
isLoading,
|
|
1330
1706
|
mcpServers,
|
|
1331
|
-
setMcpServers
|
|
1707
|
+
setMcpServers,
|
|
1708
|
+
suggestions,
|
|
1709
|
+
setSuggestions,
|
|
1710
|
+
generateSuggestions: generateSuggestionsFunc,
|
|
1711
|
+
resetSuggestions,
|
|
1712
|
+
isLoadingSuggestions: isLoadingSuggestionsRef.current,
|
|
1713
|
+
interrupt
|
|
1332
1714
|
};
|
|
1333
1715
|
}
|
|
1334
1716
|
function useUpdatedRef(value) {
|
|
1335
|
-
const ref = (0,
|
|
1336
|
-
(0,
|
|
1717
|
+
const ref = (0, import_react9.useRef)(value);
|
|
1718
|
+
(0, import_react9.useEffect)(() => {
|
|
1337
1719
|
ref.current = value;
|
|
1338
1720
|
}, [value]);
|
|
1339
1721
|
return ref;
|
|
@@ -1366,19 +1748,19 @@ ${additionalInstructions}` : "");
|
|
|
1366
1748
|
}
|
|
1367
1749
|
|
|
1368
1750
|
// src/hooks/use-coagent.ts
|
|
1369
|
-
var
|
|
1751
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
1370
1752
|
function useCoAgent(options) {
|
|
1371
1753
|
const generalContext = useCopilotContext();
|
|
1372
1754
|
const { availableAgents } = generalContext;
|
|
1373
1755
|
const { setBannerError } = useToast();
|
|
1374
|
-
const lastLoadedThreadId = (0,
|
|
1375
|
-
const lastLoadedState = (0,
|
|
1756
|
+
const lastLoadedThreadId = (0, import_react10.useRef)();
|
|
1757
|
+
const lastLoadedState = (0, import_react10.useRef)();
|
|
1376
1758
|
const { name } = options;
|
|
1377
|
-
(0,
|
|
1759
|
+
(0, import_react10.useEffect)(() => {
|
|
1378
1760
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
|
|
1379
1761
|
const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
|
|
1380
1762
|
console.warn(message);
|
|
1381
|
-
const agentError = new
|
|
1763
|
+
const agentError = new import_shared8.CopilotKitAgentDiscoveryError({
|
|
1382
1764
|
agentName: name,
|
|
1383
1765
|
availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
|
|
1384
1766
|
});
|
|
@@ -1397,7 +1779,7 @@ function useCoAgent(options) {
|
|
|
1397
1779
|
credentials: copilotApiConfig.credentials,
|
|
1398
1780
|
showDevConsole: context.showDevConsole
|
|
1399
1781
|
});
|
|
1400
|
-
const setState = (0,
|
|
1782
|
+
const setState = (0, import_react10.useCallback)(
|
|
1401
1783
|
(newState) => {
|
|
1402
1784
|
let coagentState = getCoagentState({ coagentStates, name, options });
|
|
1403
1785
|
const updatedState = typeof newState === "function" ? newState(coagentState.state) : newState;
|
|
@@ -1409,7 +1791,7 @@ function useCoAgent(options) {
|
|
|
1409
1791
|
},
|
|
1410
1792
|
[coagentStates, name]
|
|
1411
1793
|
);
|
|
1412
|
-
(0,
|
|
1794
|
+
(0, import_react10.useEffect)(() => {
|
|
1413
1795
|
const fetchAgentState = () => __async(this, null, function* () {
|
|
1414
1796
|
var _a, _b, _c, _d;
|
|
1415
1797
|
if (!threadId || threadId === lastLoadedThreadId.current)
|
|
@@ -1427,13 +1809,13 @@ function useCoAgent(options) {
|
|
|
1427
1809
|
if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
|
|
1428
1810
|
lastLoadedState.current = newState;
|
|
1429
1811
|
lastLoadedThreadId.current = threadId;
|
|
1430
|
-
const fetchedState = (0,
|
|
1812
|
+
const fetchedState = (0, import_shared8.parseJson)(newState, {});
|
|
1431
1813
|
isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
|
|
1432
1814
|
}
|
|
1433
1815
|
});
|
|
1434
1816
|
void fetchAgentState();
|
|
1435
1817
|
}, [threadId]);
|
|
1436
|
-
(0,
|
|
1818
|
+
(0, import_react10.useEffect)(() => {
|
|
1437
1819
|
if (isExternalStateManagement(options)) {
|
|
1438
1820
|
setState(options.state);
|
|
1439
1821
|
} else if (coagentStates[name] === void 0) {
|
|
@@ -1444,7 +1826,7 @@ function useCoAgent(options) {
|
|
|
1444
1826
|
// reset initialstate on reset
|
|
1445
1827
|
coagentStates[name] === void 0
|
|
1446
1828
|
]);
|
|
1447
|
-
(0,
|
|
1829
|
+
(0, import_react10.useEffect)(() => {
|
|
1448
1830
|
const newConfig = options.config ? options.config : options.configurable ? { configurable: options.configurable } : void 0;
|
|
1449
1831
|
if (newConfig === void 0)
|
|
1450
1832
|
return;
|
|
@@ -1476,7 +1858,7 @@ function useCoAgent(options) {
|
|
|
1476
1858
|
}),
|
|
1477
1859
|
[name, context, appendMessage, runChatCompletion]
|
|
1478
1860
|
);
|
|
1479
|
-
return (0,
|
|
1861
|
+
return (0, import_react10.useMemo)(() => {
|
|
1480
1862
|
const coagentState = getCoagentState({ coagentStates, name, options });
|
|
1481
1863
|
return {
|
|
1482
1864
|
name,
|