@copilotkit/react-core 1.4.1-pre.2 → 1.4.1-pre.6
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 +45 -3
- package/dist/chunk-2KCEHGSI.mjs +192 -0
- package/dist/chunk-2KCEHGSI.mjs.map +1 -0
- package/dist/{chunk-MX2OYLRS.mjs → chunk-DT52QX4H.mjs} +4 -4
- package/dist/{chunk-TRXKPXDE.mjs → chunk-H4VZMKR6.mjs} +2 -2
- package/dist/{chunk-G2K6T2QU.mjs → chunk-JDQCJCAQ.mjs} +38 -11
- package/dist/chunk-JDQCJCAQ.mjs.map +1 -0
- package/dist/chunk-L34MHAXR.mjs +1 -0
- package/dist/{chunk-7DFHFZJT.mjs → chunk-LMFSB5D5.mjs} +2 -2
- package/dist/chunk-LMFSB5D5.mjs.map +1 -0
- package/dist/{chunk-2MPUQRAY.mjs → chunk-LODRWFMB.mjs} +2 -1
- package/dist/chunk-LODRWFMB.mjs.map +1 -0
- package/dist/chunk-MLAS4QUR.mjs +18 -0
- package/dist/chunk-MLAS4QUR.mjs.map +1 -0
- package/dist/{chunk-7LKXEJXM.mjs → chunk-MWZO6TUR.mjs} +3 -2
- package/dist/chunk-MWZO6TUR.mjs.map +1 -0
- package/dist/chunk-O7ARI5CV.mjs +31 -0
- package/dist/chunk-O7ARI5CV.mjs.map +1 -0
- package/dist/chunk-ODN4H66E.mjs +31 -0
- package/dist/chunk-ODN4H66E.mjs.map +1 -0
- package/dist/{chunk-6YEMNWKE.mjs → chunk-P6VS7ST4.mjs} +177 -5
- package/dist/chunk-P6VS7ST4.mjs.map +1 -0
- package/dist/{chunk-ANOG3W5S.mjs → chunk-QDGDXRRJ.mjs} +2 -2
- package/dist/{chunk-K4HZL7SA.mjs → chunk-V22C3DOQ.mjs} +3 -3
- package/dist/{chunk-27IPQFJP.mjs → chunk-XINZBP3J.mjs} +2 -2
- package/dist/chunk-XINZBP3J.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.js +283 -26
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +8 -2
- package/dist/components/copilot-provider/index.js +281 -26
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +6 -3
- package/dist/components/index.js +281 -26
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -4
- package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
- package/dist/components/toast/exclamation-mark-icon.js +55 -0
- package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
- package/dist/components/toast/toast-provider.d.ts +29 -0
- package/dist/components/toast/toast-provider.js +255 -0
- package/dist/components/toast/toast-provider.js.map +1 -0
- package/dist/components/toast/toast-provider.mjs +11 -0
- package/dist/context/copilot-context.d.ts +2 -0
- package/dist/context/copilot-context.js +1 -0
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +118 -62
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +17 -12
- package/dist/hooks/use-chat.js +78 -26
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +4 -1
- package/dist/hooks/use-coagent-state-render.d.ts +1 -1
- package/dist/hooks/use-coagent-state-render.js +1 -0
- 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.js +96 -43
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +9 -7
- package/dist/hooks/use-copilot-action.d.ts +1 -1
- package/dist/hooks/use-copilot-action.js +2 -0
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-chat.js +98 -45
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +8 -6
- package/dist/hooks/use-copilot-readable.js +1 -0
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.d.ts +5 -0
- package/dist/hooks/use-copilot-runtime-client.js +76 -0
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.mjs +10 -0
- package/dist/hooks/use-make-copilot-document-readable.js +1 -0
- 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 -0
- package/dist/index.js +513 -240
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -19
- package/dist/lib/copilot-task.d.ts +2 -5
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +7 -5
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -5
- package/dist/types/frontend-action.d.ts +8 -1
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/utils/dev-console.d.ts +3 -0
- package/dist/utils/dev-console.js +42 -0
- package/dist/utils/dev-console.js.map +1 -0
- package/dist/utils/dev-console.mjs +8 -0
- package/dist/utils/dev-console.mjs.map +1 -0
- package/dist/utils/extract.js +4 -26
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +6 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +22 -28
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +10 -7
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +32 -1
- package/src/components/toast/exclamation-mark-icon.tsx +27 -0
- package/src/components/toast/toast-provider.tsx +209 -0
- package/src/context/copilot-context.tsx +5 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-chat.ts +36 -12
- package/src/hooks/use-coagent-state-render.ts +1 -1
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-copilot-runtime-client.ts +24 -0
- package/src/lib/copilot-task.ts +1 -5
- package/src/types/frontend-action.ts +8 -0
- package/src/utils/dev-console.ts +18 -0
- package/src/utils/extract.ts +2 -16
- package/src/utils/index.ts +1 -0
- package/dist/chunk-27IPQFJP.mjs.map +0 -1
- package/dist/chunk-2MPUQRAY.mjs.map +0 -1
- package/dist/chunk-6YEMNWKE.mjs.map +0 -1
- package/dist/chunk-7DFHFZJT.mjs.map +0 -1
- package/dist/chunk-7LKXEJXM.mjs.map +0 -1
- package/dist/chunk-BWYAGPEF.mjs +0 -1
- package/dist/chunk-G2K6T2QU.mjs.map +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -1
- package/dist/chunk-SPCZTZCY.mjs +0 -1
- package/dist/chunk-YJLRG5U3.mjs +0 -1
- package/dist/chunk-ZM6HV22S.mjs +0 -164
- package/dist/chunk-ZM6HV22S.mjs.map +0 -1
- /package/dist/{chunk-MX2OYLRS.mjs.map → chunk-DT52QX4H.mjs.map} +0 -0
- /package/dist/{chunk-TRXKPXDE.mjs.map → chunk-H4VZMKR6.mjs.map} +0 -0
- /package/dist/{chunk-BWYAGPEF.mjs.map → chunk-L34MHAXR.mjs.map} +0 -0
- /package/dist/{chunk-ANOG3W5S.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
- /package/dist/{chunk-K4HZL7SA.mjs.map → chunk-V22C3DOQ.mjs.map} +0 -0
- /package/dist/{chunk-JD7BAH7U.mjs.map → components/toast/exclamation-mark-icon.mjs.map} +0 -0
- /package/dist/{chunk-SPCZTZCY.mjs.map → components/toast/toast-provider.mjs.map} +0 -0
- /package/dist/{chunk-YJLRG5U3.mjs.map → hooks/use-copilot-runtime-client.mjs.map} +0 -0
|
@@ -82,7 +82,7 @@ __export(use_coagent_exports, {
|
|
|
82
82
|
useCoAgent: () => useCoAgent
|
|
83
83
|
});
|
|
84
84
|
module.exports = __toCommonJS(use_coagent_exports);
|
|
85
|
-
var
|
|
85
|
+
var import_react8 = require("react");
|
|
86
86
|
|
|
87
87
|
// src/context/copilot-context.tsx
|
|
88
88
|
var import_react = __toESM(require("react"));
|
|
@@ -112,6 +112,7 @@ var emptyCopilotContext = {
|
|
|
112
112
|
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
113
113
|
removeDocumentContext: () => {
|
|
114
114
|
},
|
|
115
|
+
runtimeClient: {},
|
|
115
116
|
copilotApiConfig: new class {
|
|
116
117
|
get chatApiEndpoint() {
|
|
117
118
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
@@ -167,13 +168,44 @@ function useCopilotMessagesContext() {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
// src/hooks/use-copilot-chat.ts
|
|
171
|
+
var import_react7 = require("react");
|
|
172
|
+
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
173
|
+
|
|
174
|
+
// src/hooks/use-chat.ts
|
|
170
175
|
var import_react5 = require("react");
|
|
176
|
+
var import_shared = require("@copilotkit/shared");
|
|
171
177
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
172
178
|
|
|
173
|
-
// src/
|
|
179
|
+
// src/components/toast/toast-provider.tsx
|
|
174
180
|
var import_react3 = require("react");
|
|
175
|
-
var
|
|
181
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
182
|
+
var ToastContext = (0, import_react3.createContext)(void 0);
|
|
183
|
+
function useToast() {
|
|
184
|
+
const context = (0, import_react3.useContext)(ToastContext);
|
|
185
|
+
if (!context) {
|
|
186
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
187
|
+
}
|
|
188
|
+
return context;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/hooks/use-copilot-runtime-client.ts
|
|
176
192
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
193
|
+
var import_react4 = require("react");
|
|
194
|
+
var useCopilotRuntimeClient = (options) => {
|
|
195
|
+
const { addGraphQLErrorsToast } = useToast();
|
|
196
|
+
const runtimeClient = (0, import_react4.useMemo)(() => {
|
|
197
|
+
return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
|
|
198
|
+
handleGQLErrors: (error) => {
|
|
199
|
+
if (error.graphQLErrors.length) {
|
|
200
|
+
addGraphQLErrorsToast(error.graphQLErrors);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}));
|
|
204
|
+
}, [options, addGraphQLErrorsToast]);
|
|
205
|
+
return runtimeClient;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/hooks/use-chat.ts
|
|
177
209
|
function useChat(options) {
|
|
178
210
|
const {
|
|
179
211
|
messages,
|
|
@@ -191,17 +223,18 @@ function useChat(options) {
|
|
|
191
223
|
agentSession,
|
|
192
224
|
setAgentSession
|
|
193
225
|
} = options;
|
|
194
|
-
const abortControllerRef = (0,
|
|
195
|
-
const threadIdRef = (0,
|
|
196
|
-
const runIdRef = (0,
|
|
197
|
-
const
|
|
198
|
-
const
|
|
226
|
+
const abortControllerRef = (0, import_react5.useRef)();
|
|
227
|
+
const threadIdRef = (0, import_react5.useRef)(null);
|
|
228
|
+
const runIdRef = (0, import_react5.useRef)(null);
|
|
229
|
+
const { addGraphQLErrorsToast } = useToast();
|
|
230
|
+
const runChatCompletionRef = (0, import_react5.useRef)();
|
|
231
|
+
const coagentStatesRef = (0, import_react5.useRef)(coagentStates);
|
|
199
232
|
coagentStatesRef.current = coagentStates;
|
|
200
|
-
const agentSessionRef = (0,
|
|
233
|
+
const agentSessionRef = (0, import_react5.useRef)(agentSession);
|
|
201
234
|
agentSessionRef.current = agentSession;
|
|
202
235
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
203
236
|
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
204
|
-
const runtimeClient =
|
|
237
|
+
const runtimeClient = useCopilotRuntimeClient({
|
|
205
238
|
url: copilotConfig.chatApiEndpoint,
|
|
206
239
|
publicApiKey: copilotConfig.publicApiKey,
|
|
207
240
|
headers,
|
|
@@ -211,9 +244,9 @@ function useChat(options) {
|
|
|
211
244
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
212
245
|
setIsLoading(true);
|
|
213
246
|
let newMessages = [
|
|
214
|
-
new
|
|
247
|
+
new import_runtime_client_gql2.TextMessage({
|
|
215
248
|
content: "",
|
|
216
|
-
role:
|
|
249
|
+
role: import_runtime_client_gql2.Role.Assistant
|
|
217
250
|
})
|
|
218
251
|
];
|
|
219
252
|
const abortController = new AbortController();
|
|
@@ -221,20 +254,33 @@ function useChat(options) {
|
|
|
221
254
|
setMessages([...previousMessages, ...newMessages]);
|
|
222
255
|
const systemMessage = makeSystemMessageCallback();
|
|
223
256
|
const messagesWithContext = [systemMessage, ...initialMessages || [], ...previousMessages];
|
|
224
|
-
const stream =
|
|
257
|
+
const stream = runtimeClient.asStream(
|
|
225
258
|
runtimeClient.generateCopilotResponse({
|
|
226
259
|
data: __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
227
260
|
frontend: {
|
|
228
|
-
actions: actions.filter(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
261
|
+
actions: actions.filter(
|
|
262
|
+
(action) => action.available !== import_runtime_client_gql2.ActionInputAvailability.Disabled || !action.disabled
|
|
263
|
+
).map((action) => {
|
|
264
|
+
let available = import_runtime_client_gql2.ActionInputAvailability.Enabled;
|
|
265
|
+
if (action.disabled) {
|
|
266
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Disabled;
|
|
267
|
+
} else if (action.available === "disabled") {
|
|
268
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Disabled;
|
|
269
|
+
} else if (action.available === "remote") {
|
|
270
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Remote;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
name: action.name,
|
|
274
|
+
description: action.description || "",
|
|
275
|
+
jsonSchema: JSON.stringify((0, import_shared.actionParametersToJsonSchema)(action.parameters || [])),
|
|
276
|
+
available
|
|
277
|
+
};
|
|
278
|
+
}),
|
|
233
279
|
url: window.location.href
|
|
234
280
|
},
|
|
235
281
|
threadId: threadIdRef.current,
|
|
236
282
|
runId: runIdRef.current,
|
|
237
|
-
messages: (0,
|
|
283
|
+
messages: (0, import_runtime_client_gql2.convertMessagesToGqlInput)((0, import_runtime_client_gql2.filterAgentStateMessages)(messagesWithContext))
|
|
238
284
|
}, copilotConfig.cloud ? {
|
|
239
285
|
cloud: __spreadValues({}, ((_c = (_b = (_a = copilotConfig.cloud.guardrails) == null ? void 0 : _a.input) == null ? void 0 : _b.restrictToTopic) == null ? void 0 : _c.enabled) ? {
|
|
240
286
|
guardrails: {
|
|
@@ -246,7 +292,7 @@ function useChat(options) {
|
|
|
246
292
|
} : {})
|
|
247
293
|
} : {}), {
|
|
248
294
|
metadata: {
|
|
249
|
-
requestType:
|
|
295
|
+
requestType: import_runtime_client_gql2.CopilotRequestType.Chat
|
|
250
296
|
}
|
|
251
297
|
}), agentSessionRef.current ? {
|
|
252
298
|
agentSession: agentSessionRef.current
|
|
@@ -267,7 +313,14 @@ function useChat(options) {
|
|
|
267
313
|
let followUp = void 0;
|
|
268
314
|
try {
|
|
269
315
|
while (true) {
|
|
270
|
-
|
|
316
|
+
let done, value;
|
|
317
|
+
try {
|
|
318
|
+
const readResult = yield reader.read();
|
|
319
|
+
done = readResult.done;
|
|
320
|
+
value = readResult.value;
|
|
321
|
+
} catch (readError) {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
271
324
|
if (done) {
|
|
272
325
|
break;
|
|
273
326
|
}
|
|
@@ -276,8 +329,8 @@ function useChat(options) {
|
|
|
276
329
|
}
|
|
277
330
|
threadIdRef.current = value.generateCopilotResponse.threadId || null;
|
|
278
331
|
runIdRef.current = value.generateCopilotResponse.runId || null;
|
|
279
|
-
const messages2 = (0,
|
|
280
|
-
(0,
|
|
332
|
+
const messages2 = (0, import_runtime_client_gql2.convertGqlOutputToMessages)(
|
|
333
|
+
(0, import_runtime_client_gql2.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
|
|
281
334
|
);
|
|
282
335
|
if (messages2.length === 0) {
|
|
283
336
|
continue;
|
|
@@ -285,15 +338,15 @@ function useChat(options) {
|
|
|
285
338
|
newMessages = [];
|
|
286
339
|
if (((_h = value.generateCopilotResponse.status) == null ? void 0 : _h.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
|
|
287
340
|
newMessages = [
|
|
288
|
-
new
|
|
289
|
-
role:
|
|
341
|
+
new import_runtime_client_gql2.TextMessage({
|
|
342
|
+
role: import_runtime_client_gql2.MessageRole.Assistant,
|
|
290
343
|
content: ((_i = value.generateCopilotResponse.status.details) == null ? void 0 : _i.guardrailsReason) || ""
|
|
291
344
|
})
|
|
292
345
|
];
|
|
293
346
|
} else {
|
|
294
347
|
for (const message of messages2) {
|
|
295
348
|
newMessages.push(message);
|
|
296
|
-
if (message.isActionExecutionMessage() && message.status.code !==
|
|
349
|
+
if (message.isActionExecutionMessage() && message.status.code !== import_runtime_client_gql2.MessageStatusCode.Pending && message.scope === "client" && onFunctionCall) {
|
|
297
350
|
if (!(message.id in actionResults)) {
|
|
298
351
|
if (guardrailsEnabled && value.generateCopilotResponse.status === void 0) {
|
|
299
352
|
break;
|
|
@@ -316,8 +369,8 @@ function useChat(options) {
|
|
|
316
369
|
}
|
|
317
370
|
}
|
|
318
371
|
newMessages.push(
|
|
319
|
-
new
|
|
320
|
-
result:
|
|
372
|
+
new import_runtime_client_gql2.ResultMessage({
|
|
373
|
+
result: import_runtime_client_gql2.ResultMessage.encodeResult(actionResults[message.id]),
|
|
321
374
|
actionExecutionId: message.id,
|
|
322
375
|
actionName: message.name
|
|
323
376
|
})
|
|
@@ -414,10 +467,10 @@ function useChat(options) {
|
|
|
414
467
|
}
|
|
415
468
|
|
|
416
469
|
// src/components/copilot-provider/copilotkit.tsx
|
|
417
|
-
var
|
|
470
|
+
var import_react6 = require("react");
|
|
418
471
|
var import_react_dom = require("react-dom");
|
|
419
472
|
var import_shared2 = require("@copilotkit/shared");
|
|
420
|
-
var
|
|
473
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
421
474
|
var defaultCopilotContextCategories = ["global"];
|
|
422
475
|
|
|
423
476
|
// src/hooks/use-copilot-chat.ts
|
|
@@ -443,21 +496,21 @@ function useCopilotChat(_a = {}) {
|
|
|
443
496
|
} = useCopilotContext();
|
|
444
497
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
445
498
|
const latestGetContextString = useUpdatedRef(getContextString);
|
|
446
|
-
const deleteMessage = (0,
|
|
499
|
+
const deleteMessage = (0, import_react7.useCallback)(
|
|
447
500
|
(messageId) => {
|
|
448
501
|
setMessages((prev) => prev.filter((message) => message.id !== messageId));
|
|
449
502
|
},
|
|
450
503
|
[setMessages]
|
|
451
504
|
);
|
|
452
|
-
const makeSystemMessageCallback = (0,
|
|
505
|
+
const makeSystemMessageCallback = (0, import_react7.useCallback)(() => {
|
|
453
506
|
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
454
507
|
const contextString = latestGetContextString.current([], defaultCopilotContextCategories);
|
|
455
|
-
return new
|
|
508
|
+
return new import_runtime_client_gql3.TextMessage({
|
|
456
509
|
content: systemMessageMaker(contextString, chatInstructions),
|
|
457
|
-
role:
|
|
510
|
+
role: import_runtime_client_gql3.Role.System
|
|
458
511
|
});
|
|
459
512
|
}, [getContextString, makeSystemMessage, chatInstructions]);
|
|
460
|
-
const onCoAgentStateRender = (0,
|
|
513
|
+
const onCoAgentStateRender = (0, import_react7.useCallback)(
|
|
461
514
|
(args) => __async(this, null, function* () {
|
|
462
515
|
var _a2;
|
|
463
516
|
const { name, nodeName, state } = args;
|
|
@@ -492,29 +545,29 @@ function useCopilotChat(_a = {}) {
|
|
|
492
545
|
setAgentSession
|
|
493
546
|
}));
|
|
494
547
|
const latestAppend = useUpdatedRef(append);
|
|
495
|
-
const latestAppendFunc = (0,
|
|
548
|
+
const latestAppendFunc = (0, import_react7.useCallback)(
|
|
496
549
|
(message) => {
|
|
497
550
|
return latestAppend.current(message);
|
|
498
551
|
},
|
|
499
552
|
[latestAppend]
|
|
500
553
|
);
|
|
501
554
|
const latestReload = useUpdatedRef(reload);
|
|
502
|
-
const latestReloadFunc = (0,
|
|
555
|
+
const latestReloadFunc = (0, import_react7.useCallback)(() => {
|
|
503
556
|
return latestReload.current();
|
|
504
557
|
}, [latestReload]);
|
|
505
558
|
const latestStop = useUpdatedRef(stop);
|
|
506
|
-
const latestStopFunc = (0,
|
|
559
|
+
const latestStopFunc = (0, import_react7.useCallback)(() => {
|
|
507
560
|
return latestStop.current();
|
|
508
561
|
}, [latestStop]);
|
|
509
562
|
const latestDelete = useUpdatedRef(deleteMessage);
|
|
510
|
-
const latestDeleteFunc = (0,
|
|
563
|
+
const latestDeleteFunc = (0, import_react7.useCallback)(
|
|
511
564
|
(messageId) => {
|
|
512
565
|
return latestDelete.current(messageId);
|
|
513
566
|
},
|
|
514
567
|
[latestDelete]
|
|
515
568
|
);
|
|
516
569
|
const latestSetMessages = useUpdatedRef(setMessages);
|
|
517
|
-
const latestSetMessagesFunc = (0,
|
|
570
|
+
const latestSetMessagesFunc = (0, import_react7.useCallback)(
|
|
518
571
|
(messages2) => {
|
|
519
572
|
return latestSetMessages.current(messages2);
|
|
520
573
|
},
|
|
@@ -531,8 +584,8 @@ function useCopilotChat(_a = {}) {
|
|
|
531
584
|
};
|
|
532
585
|
}
|
|
533
586
|
function useUpdatedRef(value) {
|
|
534
|
-
const ref = (0,
|
|
535
|
-
(0,
|
|
587
|
+
const ref = (0, import_react7.useRef)(value);
|
|
588
|
+
(0, import_react7.useEffect)(() => {
|
|
536
589
|
ref.current = value;
|
|
537
590
|
}, [value]);
|
|
538
591
|
return ref;
|
|
@@ -603,7 +656,7 @@ function useCoAgent(options) {
|
|
|
603
656
|
};
|
|
604
657
|
const coagentState = getCoagentState(coagentStates, name);
|
|
605
658
|
const state = isExternalStateManagement(options) ? options.state : coagentState.state;
|
|
606
|
-
(0,
|
|
659
|
+
(0, import_react8.useEffect)(() => {
|
|
607
660
|
if (isExternalStateManagement(options)) {
|
|
608
661
|
setState(options.state);
|
|
609
662
|
} else if (coagentStates[name] === void 0) {
|