@copilotkit/react-core 1.4.1-pre.5 → 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 +15 -0
- package/dist/chunk-2KCEHGSI.mjs +192 -0
- package/dist/chunk-2KCEHGSI.mjs.map +1 -0
- package/dist/{chunk-IIGBMHZI.mjs → chunk-DT52QX4H.mjs} +4 -4
- package/dist/{chunk-TRXKPXDE.mjs → chunk-H4VZMKR6.mjs} +2 -2
- package/dist/{chunk-OQ326E7V.mjs → chunk-JDQCJCAQ.mjs} +18 -5
- package/dist/chunk-JDQCJCAQ.mjs.map +1 -0
- package/dist/chunk-L34MHAXR.mjs +1 -0
- package/dist/{chunk-HVWV4SDG.mjs → chunk-LMFSB5D5.mjs} +2 -2
- 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-K76NL2VN.mjs → chunk-MWZO6TUR.mjs} +2 -2
- 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-VE63DJCR.mjs → chunk-V22C3DOQ.mjs} +3 -3
- package/dist/{chunk-MTVKTUZD.mjs → chunk-XINZBP3J.mjs} +2 -2
- 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 +104 -62
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +17 -12
- package/dist/hooks/use-chat.js +65 -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.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 +83 -43
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +9 -7
- package/dist/hooks/use-copilot-action.js +1 -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 +85 -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 +500 -241
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -19
- package/dist/lib/copilot-task.d.ts +1 -0
- 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/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 +14 -6
- package/src/hooks/use-copilot-runtime-client.ts +24 -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-2MPUQRAY.mjs.map +0 -1
- package/dist/chunk-6YEMNWKE.mjs.map +0 -1
- package/dist/chunk-BWYAGPEF.mjs +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -1
- package/dist/chunk-OQ326E7V.mjs.map +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-IIGBMHZI.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-HVWV4SDG.mjs.map → chunk-LMFSB5D5.mjs.map} +0 -0
- /package/dist/{chunk-K76NL2VN.mjs.map → chunk-MWZO6TUR.mjs.map} +0 -0
- /package/dist/{chunk-ANOG3W5S.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
- /package/dist/{chunk-VE63DJCR.mjs.map → chunk-V22C3DOQ.mjs.map} +0 -0
- /package/dist/{chunk-MTVKTUZD.mjs.map → chunk-XINZBP3J.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,20 @@ 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
261
|
actions: actions.filter(
|
|
229
|
-
(action) => action.available !==
|
|
262
|
+
(action) => action.available !== import_runtime_client_gql2.ActionInputAvailability.Disabled || !action.disabled
|
|
230
263
|
).map((action) => {
|
|
231
|
-
let available =
|
|
264
|
+
let available = import_runtime_client_gql2.ActionInputAvailability.Enabled;
|
|
232
265
|
if (action.disabled) {
|
|
233
|
-
available =
|
|
266
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Disabled;
|
|
234
267
|
} else if (action.available === "disabled") {
|
|
235
|
-
available =
|
|
268
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Disabled;
|
|
236
269
|
} else if (action.available === "remote") {
|
|
237
|
-
available =
|
|
270
|
+
available = import_runtime_client_gql2.ActionInputAvailability.Remote;
|
|
238
271
|
}
|
|
239
272
|
return {
|
|
240
273
|
name: action.name,
|
|
@@ -247,7 +280,7 @@ function useChat(options) {
|
|
|
247
280
|
},
|
|
248
281
|
threadId: threadIdRef.current,
|
|
249
282
|
runId: runIdRef.current,
|
|
250
|
-
messages: (0,
|
|
283
|
+
messages: (0, import_runtime_client_gql2.convertMessagesToGqlInput)((0, import_runtime_client_gql2.filterAgentStateMessages)(messagesWithContext))
|
|
251
284
|
}, copilotConfig.cloud ? {
|
|
252
285
|
cloud: __spreadValues({}, ((_c = (_b = (_a = copilotConfig.cloud.guardrails) == null ? void 0 : _a.input) == null ? void 0 : _b.restrictToTopic) == null ? void 0 : _c.enabled) ? {
|
|
253
286
|
guardrails: {
|
|
@@ -259,7 +292,7 @@ function useChat(options) {
|
|
|
259
292
|
} : {})
|
|
260
293
|
} : {}), {
|
|
261
294
|
metadata: {
|
|
262
|
-
requestType:
|
|
295
|
+
requestType: import_runtime_client_gql2.CopilotRequestType.Chat
|
|
263
296
|
}
|
|
264
297
|
}), agentSessionRef.current ? {
|
|
265
298
|
agentSession: agentSessionRef.current
|
|
@@ -280,7 +313,14 @@ function useChat(options) {
|
|
|
280
313
|
let followUp = void 0;
|
|
281
314
|
try {
|
|
282
315
|
while (true) {
|
|
283
|
-
|
|
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
|
+
}
|
|
284
324
|
if (done) {
|
|
285
325
|
break;
|
|
286
326
|
}
|
|
@@ -289,8 +329,8 @@ function useChat(options) {
|
|
|
289
329
|
}
|
|
290
330
|
threadIdRef.current = value.generateCopilotResponse.threadId || null;
|
|
291
331
|
runIdRef.current = value.generateCopilotResponse.runId || null;
|
|
292
|
-
const messages2 = (0,
|
|
293
|
-
(0,
|
|
332
|
+
const messages2 = (0, import_runtime_client_gql2.convertGqlOutputToMessages)(
|
|
333
|
+
(0, import_runtime_client_gql2.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
|
|
294
334
|
);
|
|
295
335
|
if (messages2.length === 0) {
|
|
296
336
|
continue;
|
|
@@ -298,15 +338,15 @@ function useChat(options) {
|
|
|
298
338
|
newMessages = [];
|
|
299
339
|
if (((_h = value.generateCopilotResponse.status) == null ? void 0 : _h.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
|
|
300
340
|
newMessages = [
|
|
301
|
-
new
|
|
302
|
-
role:
|
|
341
|
+
new import_runtime_client_gql2.TextMessage({
|
|
342
|
+
role: import_runtime_client_gql2.MessageRole.Assistant,
|
|
303
343
|
content: ((_i = value.generateCopilotResponse.status.details) == null ? void 0 : _i.guardrailsReason) || ""
|
|
304
344
|
})
|
|
305
345
|
];
|
|
306
346
|
} else {
|
|
307
347
|
for (const message of messages2) {
|
|
308
348
|
newMessages.push(message);
|
|
309
|
-
if (message.isActionExecutionMessage() && message.status.code !==
|
|
349
|
+
if (message.isActionExecutionMessage() && message.status.code !== import_runtime_client_gql2.MessageStatusCode.Pending && message.scope === "client" && onFunctionCall) {
|
|
310
350
|
if (!(message.id in actionResults)) {
|
|
311
351
|
if (guardrailsEnabled && value.generateCopilotResponse.status === void 0) {
|
|
312
352
|
break;
|
|
@@ -329,8 +369,8 @@ function useChat(options) {
|
|
|
329
369
|
}
|
|
330
370
|
}
|
|
331
371
|
newMessages.push(
|
|
332
|
-
new
|
|
333
|
-
result:
|
|
372
|
+
new import_runtime_client_gql2.ResultMessage({
|
|
373
|
+
result: import_runtime_client_gql2.ResultMessage.encodeResult(actionResults[message.id]),
|
|
334
374
|
actionExecutionId: message.id,
|
|
335
375
|
actionName: message.name
|
|
336
376
|
})
|
|
@@ -427,10 +467,10 @@ function useChat(options) {
|
|
|
427
467
|
}
|
|
428
468
|
|
|
429
469
|
// src/components/copilot-provider/copilotkit.tsx
|
|
430
|
-
var
|
|
470
|
+
var import_react6 = require("react");
|
|
431
471
|
var import_react_dom = require("react-dom");
|
|
432
472
|
var import_shared2 = require("@copilotkit/shared");
|
|
433
|
-
var
|
|
473
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
434
474
|
var defaultCopilotContextCategories = ["global"];
|
|
435
475
|
|
|
436
476
|
// src/hooks/use-copilot-chat.ts
|
|
@@ -456,21 +496,21 @@ function useCopilotChat(_a = {}) {
|
|
|
456
496
|
} = useCopilotContext();
|
|
457
497
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
458
498
|
const latestGetContextString = useUpdatedRef(getContextString);
|
|
459
|
-
const deleteMessage = (0,
|
|
499
|
+
const deleteMessage = (0, import_react7.useCallback)(
|
|
460
500
|
(messageId) => {
|
|
461
501
|
setMessages((prev) => prev.filter((message) => message.id !== messageId));
|
|
462
502
|
},
|
|
463
503
|
[setMessages]
|
|
464
504
|
);
|
|
465
|
-
const makeSystemMessageCallback = (0,
|
|
505
|
+
const makeSystemMessageCallback = (0, import_react7.useCallback)(() => {
|
|
466
506
|
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
467
507
|
const contextString = latestGetContextString.current([], defaultCopilotContextCategories);
|
|
468
|
-
return new
|
|
508
|
+
return new import_runtime_client_gql3.TextMessage({
|
|
469
509
|
content: systemMessageMaker(contextString, chatInstructions),
|
|
470
|
-
role:
|
|
510
|
+
role: import_runtime_client_gql3.Role.System
|
|
471
511
|
});
|
|
472
512
|
}, [getContextString, makeSystemMessage, chatInstructions]);
|
|
473
|
-
const onCoAgentStateRender = (0,
|
|
513
|
+
const onCoAgentStateRender = (0, import_react7.useCallback)(
|
|
474
514
|
(args) => __async(this, null, function* () {
|
|
475
515
|
var _a2;
|
|
476
516
|
const { name, nodeName, state } = args;
|
|
@@ -505,29 +545,29 @@ function useCopilotChat(_a = {}) {
|
|
|
505
545
|
setAgentSession
|
|
506
546
|
}));
|
|
507
547
|
const latestAppend = useUpdatedRef(append);
|
|
508
|
-
const latestAppendFunc = (0,
|
|
548
|
+
const latestAppendFunc = (0, import_react7.useCallback)(
|
|
509
549
|
(message) => {
|
|
510
550
|
return latestAppend.current(message);
|
|
511
551
|
},
|
|
512
552
|
[latestAppend]
|
|
513
553
|
);
|
|
514
554
|
const latestReload = useUpdatedRef(reload);
|
|
515
|
-
const latestReloadFunc = (0,
|
|
555
|
+
const latestReloadFunc = (0, import_react7.useCallback)(() => {
|
|
516
556
|
return latestReload.current();
|
|
517
557
|
}, [latestReload]);
|
|
518
558
|
const latestStop = useUpdatedRef(stop);
|
|
519
|
-
const latestStopFunc = (0,
|
|
559
|
+
const latestStopFunc = (0, import_react7.useCallback)(() => {
|
|
520
560
|
return latestStop.current();
|
|
521
561
|
}, [latestStop]);
|
|
522
562
|
const latestDelete = useUpdatedRef(deleteMessage);
|
|
523
|
-
const latestDeleteFunc = (0,
|
|
563
|
+
const latestDeleteFunc = (0, import_react7.useCallback)(
|
|
524
564
|
(messageId) => {
|
|
525
565
|
return latestDelete.current(messageId);
|
|
526
566
|
},
|
|
527
567
|
[latestDelete]
|
|
528
568
|
);
|
|
529
569
|
const latestSetMessages = useUpdatedRef(setMessages);
|
|
530
|
-
const latestSetMessagesFunc = (0,
|
|
570
|
+
const latestSetMessagesFunc = (0, import_react7.useCallback)(
|
|
531
571
|
(messages2) => {
|
|
532
572
|
return latestSetMessages.current(messages2);
|
|
533
573
|
},
|
|
@@ -544,8 +584,8 @@ function useCopilotChat(_a = {}) {
|
|
|
544
584
|
};
|
|
545
585
|
}
|
|
546
586
|
function useUpdatedRef(value) {
|
|
547
|
-
const ref = (0,
|
|
548
|
-
(0,
|
|
587
|
+
const ref = (0, import_react7.useRef)(value);
|
|
588
|
+
(0, import_react7.useEffect)(() => {
|
|
549
589
|
ref.current = value;
|
|
550
590
|
}, [value]);
|
|
551
591
|
return ref;
|
|
@@ -616,7 +656,7 @@ function useCoAgent(options) {
|
|
|
616
656
|
};
|
|
617
657
|
const coagentState = getCoagentState(coagentStates, name);
|
|
618
658
|
const state = isExternalStateManagement(options) ? options.state : coagentState.state;
|
|
619
|
-
(0,
|
|
659
|
+
(0, import_react8.useEffect)(() => {
|
|
620
660
|
if (isExternalStateManagement(options)) {
|
|
621
661
|
setState(options.state);
|
|
622
662
|
} else if (coagentStates[name] === void 0) {
|