@copilotkit/react-core 1.50.0-beta.7 → 1.50.0-beta.9
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 +19 -2
- package/dist/{chunk-EKDPRKZT.mjs → chunk-3775VM7Y.mjs} +14 -26
- package/dist/chunk-3775VM7Y.mjs.map +1 -0
- package/dist/{chunk-BLDHD6Q2.mjs → chunk-7SHWECGN.mjs} +2 -2
- package/dist/{chunk-QSNZUI5G.mjs → chunk-B5ELMVT7.mjs} +2 -2
- package/dist/{chunk-WV57GREG.mjs → chunk-FYMZKPOL.mjs} +6 -6
- package/dist/chunk-XDFVCQD3.mjs +27 -0
- package/dist/chunk-XDFVCQD3.mjs.map +1 -0
- package/dist/{chunk-KYY2WZSR.mjs → chunk-YJGPIN3R.mjs} +2 -2
- package/dist/chunk-Z6JV2LRY.mjs +37 -0
- package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.mjs +7 -7
- package/dist/components/copilot-provider/index.mjs +7 -7
- package/dist/components/index.mjs +7 -7
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +146 -151
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +24 -24
- package/dist/hooks/use-copilot-chat-headless_c.js +39 -82
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +3 -4
- package/dist/hooks/{use-configure-chat-suggestions.d.ts → use-copilot-chat-suggestions.d.ts} +2 -3
- package/dist/hooks/{use-configure-chat-suggestions.js → use-copilot-chat-suggestions.js} +10 -29
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat.js +37 -80
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +3 -4
- package/dist/hooks/use-copilot-chat_internal.d.ts +17 -0
- package/dist/hooks/use-copilot-chat_internal.js +37 -80
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +2 -3
- package/dist/hooks/use-copilot-readable.d.ts +1 -1
- package/dist/hooks/use-copilot-readable.js +29 -6
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +139 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -35
- package/dist/lib/copilot-task.mjs +8 -8
- package/dist/lib/index.mjs +8 -8
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +5 -5
- package/src/hooks/index.ts +2 -2
- package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
- package/src/hooks/use-copilot-chat_internal.ts +29 -29
- package/src/hooks/use-copilot-readable.ts +30 -13
- package/dist/chunk-2CYJN455.mjs +0 -14
- package/dist/chunk-2CYJN455.mjs.map +0 -1
- package/dist/chunk-EKDPRKZT.mjs.map +0 -1
- package/dist/chunk-FBVI3LQ6.mjs +0 -48
- package/dist/chunk-FBVI3LQ6.mjs.map +0 -1
- package/dist/hooks/use-configure-chat-suggestions.js.map +0 -1
- package/dist/hooks/use-configure-chat-suggestions.mjs +0 -8
- package/src/hooks/use-configure-chat-suggestions.tsx +0 -86
- /package/dist/{chunk-BLDHD6Q2.mjs.map → chunk-7SHWECGN.mjs.map} +0 -0
- /package/dist/{chunk-QSNZUI5G.mjs.map → chunk-B5ELMVT7.mjs.map} +0 -0
- /package/dist/{chunk-WV57GREG.mjs.map → chunk-FYMZKPOL.mjs.map} +0 -0
- /package/dist/{chunk-KYY2WZSR.mjs.map → chunk-YJGPIN3R.mjs.map} +0 -0
- /package/dist/hooks/{use-configure-chat-suggestions.mjs.map → use-copilot-chat-suggestions.mjs.map} +0 -0
package/dist/hooks/index.js
CHANGED
|
@@ -81,13 +81,13 @@ var hooks_exports = {};
|
|
|
81
81
|
__export(hooks_exports, {
|
|
82
82
|
useCoAgent: () => useCoAgent,
|
|
83
83
|
useCoAgentStateRender: () => useCoAgentStateRender,
|
|
84
|
-
useConfigureChatSuggestions: () => useConfigureChatSuggestions,
|
|
85
84
|
useCopilotAction: () => useCopilotAction,
|
|
86
85
|
useCopilotAdditionalInstructions: () => useCopilotAdditionalInstructions,
|
|
87
86
|
useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c,
|
|
88
87
|
useCopilotChat: () => useCopilotChat,
|
|
89
88
|
useCopilotChatHeadless_c: () => useCopilotChatHeadless_c,
|
|
90
89
|
useCopilotChatInternal: () => useCopilotChatInternal,
|
|
90
|
+
useCopilotChatSuggestions: () => useCopilotChatSuggestions,
|
|
91
91
|
useCopilotReadable: () => useCopilotReadable,
|
|
92
92
|
useCopilotRuntimeClient: () => useCopilotRuntimeClient,
|
|
93
93
|
useDefaultTool: () => useDefaultTool,
|
|
@@ -102,7 +102,7 @@ __export(hooks_exports, {
|
|
|
102
102
|
module.exports = __toCommonJS(hooks_exports);
|
|
103
103
|
|
|
104
104
|
// src/hooks/use-copilot-chat_internal.ts
|
|
105
|
-
var
|
|
105
|
+
var import_react13 = require("react");
|
|
106
106
|
|
|
107
107
|
// src/context/copilot-context.tsx
|
|
108
108
|
var import_react = __toESM(require("react"));
|
|
@@ -491,7 +491,7 @@ function useLangGraphInterruptRender(agent) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
// src/hooks/use-copilot-chat_internal.ts
|
|
494
|
-
var
|
|
494
|
+
var import_react14 = require("@copilotkitnext/react");
|
|
495
495
|
|
|
496
496
|
// src/hooks/use-lazy-tool-renderer.tsx
|
|
497
497
|
var import_react9 = require("@copilotkitnext/react");
|
|
@@ -518,40 +518,6 @@ function useLazyToolRenderer() {
|
|
|
518
518
|
);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
// src/hooks/use-configure-chat-suggestions.tsx
|
|
522
|
-
var import_react11 = require("@copilotkitnext/react");
|
|
523
|
-
var import_react12 = require("react");
|
|
524
|
-
function useConfigureChatSuggestions(config, dependencies = []) {
|
|
525
|
-
var _a;
|
|
526
|
-
const existingConfig = (0, import_react11.useCopilotChatConfiguration)();
|
|
527
|
-
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
528
|
-
const { copilotkit } = (0, import_react11.useCopilotKit)();
|
|
529
|
-
const available = config.available === "enabled" ? "always" : config.available;
|
|
530
|
-
const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
|
|
531
|
-
available,
|
|
532
|
-
consumerAgentId: resolvedAgentId
|
|
533
|
-
// Use chatConfig.agentId here
|
|
534
|
-
});
|
|
535
|
-
(0, import_react11.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
|
|
536
|
-
const result = (0, import_react11.useSuggestions)({ agentId: resolvedAgentId });
|
|
537
|
-
(0, import_react12.useEffect)(() => {
|
|
538
|
-
if (finalSuggestionConfig.available === "disabled")
|
|
539
|
-
return;
|
|
540
|
-
const subscription = copilotkit.subscribe({
|
|
541
|
-
onAgentsChanged: () => {
|
|
542
|
-
const agent = copilotkit.getAgent(resolvedAgentId);
|
|
543
|
-
if (agent && !agent.isRunning && !result.suggestions.length) {
|
|
544
|
-
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
return () => {
|
|
549
|
-
subscription.unsubscribe();
|
|
550
|
-
};
|
|
551
|
-
}, [resolvedAgentId]);
|
|
552
|
-
return result;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
521
|
// ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
|
|
556
522
|
var import_zod = require("zod");
|
|
557
523
|
var import_zod2 = require("zod");
|
|
@@ -958,8 +924,8 @@ var EventSchemas = import_zod2.z.discriminatedUnion("type", [
|
|
|
958
924
|
]);
|
|
959
925
|
|
|
960
926
|
// src/hooks/use-coagent-state-render-bridge.tsx
|
|
961
|
-
var
|
|
962
|
-
var
|
|
927
|
+
var import_react11 = require("@copilotkitnext/react");
|
|
928
|
+
var import_react12 = require("react");
|
|
963
929
|
var import_shared3 = require("@copilotkit/shared");
|
|
964
930
|
function getStateWithoutConstantKeys(state) {
|
|
965
931
|
if (!state)
|
|
@@ -986,11 +952,11 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
986
952
|
var _a;
|
|
987
953
|
const { stateSnapshot, messageIndexInRun, message } = props;
|
|
988
954
|
const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
|
|
989
|
-
const { agent } = (0,
|
|
990
|
-
const [nodeName, setNodeName] = (0,
|
|
955
|
+
const { agent } = (0, import_react11.useAgent)({ agentId });
|
|
956
|
+
const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
|
|
991
957
|
const runId = (_a = props.runId) != null ? _a : message.runId;
|
|
992
958
|
const effectiveRunId = runId || "pending";
|
|
993
|
-
(0,
|
|
959
|
+
(0, import_react12.useEffect)(() => {
|
|
994
960
|
if (!agent)
|
|
995
961
|
return;
|
|
996
962
|
const subscriber = {
|
|
@@ -1010,7 +976,7 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
1010
976
|
unsubscribe();
|
|
1011
977
|
};
|
|
1012
978
|
}, [agentId, nodeName]);
|
|
1013
|
-
const getStateRender = (0,
|
|
979
|
+
const getStateRender = (0, import_react12.useCallback)(
|
|
1014
980
|
(messageId) => {
|
|
1015
981
|
return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
|
|
1016
982
|
if (claimsRef.current[messageId]) {
|
|
@@ -1052,7 +1018,7 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
1052
1018
|
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
1053
1019
|
return true;
|
|
1054
1020
|
};
|
|
1055
|
-
return (0,
|
|
1021
|
+
return (0, import_react12.useMemo)(() => {
|
|
1056
1022
|
var _a2, _b, _c;
|
|
1057
1023
|
if (messageIndexInRun !== 0) {
|
|
1058
1024
|
return null;
|
|
@@ -1112,35 +1078,17 @@ function CoAgentStateRenderBridge(props) {
|
|
|
1112
1078
|
}
|
|
1113
1079
|
|
|
1114
1080
|
// src/hooks/use-copilot-chat_internal.ts
|
|
1115
|
-
function useConfigureSuggestions2(suggestions) {
|
|
1116
|
-
let suggestionsConfig;
|
|
1117
|
-
if (Array.isArray(suggestions)) {
|
|
1118
|
-
suggestionsConfig = {
|
|
1119
|
-
suggestions,
|
|
1120
|
-
available: "always"
|
|
1121
|
-
};
|
|
1122
|
-
} else if (suggestions === "auto") {
|
|
1123
|
-
suggestionsConfig = {
|
|
1124
|
-
available: suggestions === "auto" ? "always" : "disabled",
|
|
1125
|
-
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls."
|
|
1126
|
-
};
|
|
1127
|
-
} else {
|
|
1128
|
-
suggestionsConfig = { available: "disabled" };
|
|
1129
|
-
}
|
|
1130
|
-
useConfigureChatSuggestions(suggestionsConfig);
|
|
1131
|
-
}
|
|
1132
1081
|
function useCopilotChatInternal({
|
|
1133
1082
|
suggestions
|
|
1134
1083
|
} = {}) {
|
|
1135
1084
|
var _a, _b, _c;
|
|
1136
|
-
const { copilotkit } = (0,
|
|
1085
|
+
const { copilotkit } = (0, import_react14.useCopilotKit)();
|
|
1137
1086
|
const { threadId, agentSession } = useCopilotContext();
|
|
1138
|
-
const existingConfig = (0,
|
|
1139
|
-
const [agentAvailable, setAgentAvailable] = (0,
|
|
1140
|
-
useConfigureSuggestions2(suggestions);
|
|
1087
|
+
const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
|
|
1088
|
+
const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
|
|
1141
1089
|
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
1142
|
-
const { agent } = (0,
|
|
1143
|
-
(0,
|
|
1090
|
+
const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
|
|
1091
|
+
(0, import_react13.useEffect)(() => {
|
|
1144
1092
|
const connect = (agent2) => __async(this, null, function* () {
|
|
1145
1093
|
setAgentAvailable(false);
|
|
1146
1094
|
try {
|
|
@@ -1165,7 +1113,7 @@ function useCopilotChatInternal({
|
|
|
1165
1113
|
agent == null ? void 0 : agent.setMessages([]);
|
|
1166
1114
|
agent == null ? void 0 : agent.setState(null);
|
|
1167
1115
|
};
|
|
1168
|
-
const deleteMessage = (0,
|
|
1116
|
+
const deleteMessage = (0, import_react13.useCallback)(
|
|
1169
1117
|
(messageId) => {
|
|
1170
1118
|
var _a2;
|
|
1171
1119
|
const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
|
|
@@ -1176,13 +1124,13 @@ function useCopilotChatInternal({
|
|
|
1176
1124
|
[agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
|
|
1177
1125
|
);
|
|
1178
1126
|
const latestDelete = useUpdatedRef(deleteMessage);
|
|
1179
|
-
const latestDeleteFunc = (0,
|
|
1127
|
+
const latestDeleteFunc = (0, import_react13.useCallback)(
|
|
1180
1128
|
(messageId) => {
|
|
1181
1129
|
return latestDelete.current(messageId);
|
|
1182
1130
|
},
|
|
1183
1131
|
[latestDelete]
|
|
1184
1132
|
);
|
|
1185
|
-
const currentSuggestions = (0,
|
|
1133
|
+
const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
|
|
1186
1134
|
const reload = useAsyncCallback(
|
|
1187
1135
|
(reloadMessageId) => __async(this, null, function* () {
|
|
1188
1136
|
var _a2;
|
|
@@ -1249,7 +1197,7 @@ function useCopilotChatInternal({
|
|
|
1249
1197
|
}),
|
|
1250
1198
|
[latestSendMessageFunc]
|
|
1251
1199
|
);
|
|
1252
|
-
const latestSetMessagesFunc = (0,
|
|
1200
|
+
const latestSetMessagesFunc = (0, import_react13.useCallback)(
|
|
1253
1201
|
(messages) => {
|
|
1254
1202
|
var _a2, _b2;
|
|
1255
1203
|
if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
|
|
@@ -1266,16 +1214,16 @@ function useCopilotChatInternal({
|
|
|
1266
1214
|
}),
|
|
1267
1215
|
[latestReload]
|
|
1268
1216
|
);
|
|
1269
|
-
const latestStopFunc = (0,
|
|
1217
|
+
const latestStopFunc = (0, import_react13.useCallback)(() => {
|
|
1270
1218
|
var _a2;
|
|
1271
1219
|
return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
|
|
1272
1220
|
}, [agent == null ? void 0 : agent.abortRun]);
|
|
1273
1221
|
const latestReset = useUpdatedRef(reset);
|
|
1274
|
-
const latestResetFunc = (0,
|
|
1222
|
+
const latestResetFunc = (0, import_react13.useCallback)(() => {
|
|
1275
1223
|
return latestReset.current();
|
|
1276
1224
|
}, [latestReset]);
|
|
1277
1225
|
const lazyToolRendered = useLazyToolRenderer();
|
|
1278
|
-
const renderCustomMessage = (0,
|
|
1226
|
+
const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
|
|
1279
1227
|
const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
|
|
1280
1228
|
copilotkit,
|
|
1281
1229
|
agent,
|
|
@@ -1283,7 +1231,7 @@ function useCopilotChatInternal({
|
|
|
1283
1231
|
threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
|
|
1284
1232
|
});
|
|
1285
1233
|
const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
|
|
1286
|
-
const resolvedMessages = (0,
|
|
1234
|
+
const resolvedMessages = (0, import_react13.useMemo)(() => {
|
|
1287
1235
|
let processedMessages = allMessages.map((message) => {
|
|
1288
1236
|
if (message.role !== "assistant") {
|
|
1289
1237
|
return message;
|
|
@@ -1320,6 +1268,15 @@ function useCopilotChatInternal({
|
|
|
1320
1268
|
// legacyCustomMessageRenderer,
|
|
1321
1269
|
resolvedAgentId
|
|
1322
1270
|
]);
|
|
1271
|
+
const renderedSuggestions = (0, import_react13.useMemo)(() => {
|
|
1272
|
+
if (Array.isArray(suggestions)) {
|
|
1273
|
+
return {
|
|
1274
|
+
suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
|
|
1275
|
+
isLoading: false
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
return currentSuggestions;
|
|
1279
|
+
}, [suggestions, currentSuggestions]);
|
|
1323
1280
|
return {
|
|
1324
1281
|
messages: resolvedMessages,
|
|
1325
1282
|
sendMessage: latestSendMessageFunc,
|
|
@@ -1333,21 +1290,21 @@ function useCopilotChatInternal({
|
|
|
1333
1290
|
isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
|
|
1334
1291
|
// mcpServers,
|
|
1335
1292
|
// setMcpServers,
|
|
1336
|
-
suggestions:
|
|
1293
|
+
suggestions: renderedSuggestions.suggestions,
|
|
1337
1294
|
setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
|
|
1338
1295
|
generateSuggestions: () => __async(this, null, function* () {
|
|
1339
1296
|
return copilotkit.reloadSuggestions(resolvedAgentId);
|
|
1340
1297
|
}),
|
|
1341
1298
|
resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
|
|
1342
|
-
isLoadingSuggestions:
|
|
1299
|
+
isLoadingSuggestions: renderedSuggestions.isLoading,
|
|
1343
1300
|
interrupt,
|
|
1344
1301
|
agent,
|
|
1345
1302
|
threadId
|
|
1346
1303
|
};
|
|
1347
1304
|
}
|
|
1348
1305
|
function useUpdatedRef(value) {
|
|
1349
|
-
const ref = (0,
|
|
1350
|
-
(0,
|
|
1306
|
+
const ref = (0, import_react13.useRef)(value);
|
|
1307
|
+
(0, import_react13.useEffect)(() => {
|
|
1351
1308
|
ref.current = value;
|
|
1352
1309
|
}, [value]);
|
|
1353
1310
|
return ref;
|
|
@@ -1358,7 +1315,7 @@ function useLegacyCoagentRenderer({
|
|
|
1358
1315
|
agentId,
|
|
1359
1316
|
threadId
|
|
1360
1317
|
}) {
|
|
1361
|
-
return (0,
|
|
1318
|
+
return (0, import_react13.useMemo)(() => {
|
|
1362
1319
|
if (!copilotkit || !agent) {
|
|
1363
1320
|
return null;
|
|
1364
1321
|
}
|
|
@@ -1381,7 +1338,7 @@ function useLegacyCoagentRenderer({
|
|
|
1381
1338
|
agentId,
|
|
1382
1339
|
stateSnapshot: message.state
|
|
1383
1340
|
};
|
|
1384
|
-
return (0,
|
|
1341
|
+
return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
|
|
1385
1342
|
};
|
|
1386
1343
|
}, [agent, agentId, copilotkit, threadId]);
|
|
1387
1344
|
}
|
|
@@ -1415,7 +1372,7 @@ function useCopilotChat(options = {}) {
|
|
|
1415
1372
|
}
|
|
1416
1373
|
|
|
1417
1374
|
// src/hooks/use-copilot-chat-headless_c.ts
|
|
1418
|
-
var
|
|
1375
|
+
var import_react15 = require("react");
|
|
1419
1376
|
var import_shared4 = require("@copilotkit/shared");
|
|
1420
1377
|
var createNonFunctionalReturn = () => ({
|
|
1421
1378
|
visibleMessages: [],
|
|
@@ -1456,7 +1413,7 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
1456
1413
|
const { copilotApiConfig, setBannerError } = useCopilotContext();
|
|
1457
1414
|
const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
|
|
1458
1415
|
const internalResult = useCopilotChatInternal(options);
|
|
1459
|
-
(0,
|
|
1416
|
+
(0, import_react15.useEffect)(() => {
|
|
1460
1417
|
if (!hasPublicApiKey) {
|
|
1461
1418
|
setBannerError(
|
|
1462
1419
|
new import_shared4.CopilotKitError({
|
|
@@ -1481,13 +1438,13 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
1481
1438
|
}
|
|
1482
1439
|
|
|
1483
1440
|
// src/hooks/use-copilot-action.ts
|
|
1484
|
-
var
|
|
1441
|
+
var import_react22 = require("react");
|
|
1485
1442
|
|
|
1486
1443
|
// src/hooks/use-frontend-tool.ts
|
|
1487
|
-
var
|
|
1444
|
+
var import_react16 = __toESM(require("react"));
|
|
1488
1445
|
var import_shared5 = require("@copilotkit/shared");
|
|
1489
1446
|
var import_shared6 = require("@copilotkit/shared");
|
|
1490
|
-
var
|
|
1447
|
+
var import_react17 = require("@copilotkitnext/react");
|
|
1491
1448
|
function useFrontendTool(tool, dependencies) {
|
|
1492
1449
|
const { name, description, parameters, render, followUp } = tool;
|
|
1493
1450
|
const zodParameters = (0, import_shared5.getZodParameters)(parameters);
|
|
@@ -1497,8 +1454,8 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1497
1454
|
}
|
|
1498
1455
|
if (typeof render === "string") {
|
|
1499
1456
|
const staticRender = render;
|
|
1500
|
-
return () =>
|
|
1501
|
-
|
|
1457
|
+
return () => import_react16.default.createElement(
|
|
1458
|
+
import_react16.default.Fragment,
|
|
1502
1459
|
null,
|
|
1503
1460
|
staticRender
|
|
1504
1461
|
);
|
|
@@ -1509,12 +1466,12 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1509
1466
|
});
|
|
1510
1467
|
const rendered = render(renderArgs);
|
|
1511
1468
|
if (typeof rendered === "string") {
|
|
1512
|
-
return
|
|
1469
|
+
return import_react16.default.createElement(import_react16.default.Fragment, null, rendered);
|
|
1513
1470
|
}
|
|
1514
1471
|
return rendered != null ? rendered : null;
|
|
1515
1472
|
};
|
|
1516
1473
|
})();
|
|
1517
|
-
(0,
|
|
1474
|
+
(0, import_react17.useFrontendTool)({
|
|
1518
1475
|
name,
|
|
1519
1476
|
description,
|
|
1520
1477
|
parameters: zodParameters,
|
|
@@ -1526,23 +1483,23 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1526
1483
|
|
|
1527
1484
|
// src/hooks/use-render-tool-call.ts
|
|
1528
1485
|
var import_shared7 = require("@copilotkit/shared");
|
|
1529
|
-
var
|
|
1530
|
-
var
|
|
1486
|
+
var import_react18 = require("react");
|
|
1487
|
+
var import_react19 = require("@copilotkitnext/react");
|
|
1531
1488
|
var import_shared8 = require("@copilotkit/shared");
|
|
1532
1489
|
function useRenderToolCall2(tool, dependencies) {
|
|
1533
|
-
const { copilotkit } = (0,
|
|
1534
|
-
const hasAddedRef = (0,
|
|
1535
|
-
(0,
|
|
1490
|
+
const { copilotkit } = (0, import_react19.useCopilotKit)();
|
|
1491
|
+
const hasAddedRef = (0, import_react18.useRef)(false);
|
|
1492
|
+
(0, import_react18.useEffect)(() => {
|
|
1536
1493
|
const { name, parameters, render } = tool;
|
|
1537
1494
|
const zodParameters = (0, import_shared7.getZodParameters)(parameters);
|
|
1538
|
-
const renderToolCall = name === "*" ? (0,
|
|
1495
|
+
const renderToolCall = name === "*" ? (0, import_react19.defineToolCallRenderer)({
|
|
1539
1496
|
name: "*",
|
|
1540
1497
|
render: (args) => {
|
|
1541
1498
|
return render(__spreadProps(__spreadValues({}, args), {
|
|
1542
1499
|
result: args.result ? (0, import_shared8.parseJson)(args.result, args.result) : args.result
|
|
1543
1500
|
}));
|
|
1544
1501
|
}
|
|
1545
|
-
}) : (0,
|
|
1502
|
+
}) : (0, import_react19.defineToolCallRenderer)({
|
|
1546
1503
|
name,
|
|
1547
1504
|
args: zodParameters,
|
|
1548
1505
|
render: (args) => {
|
|
@@ -1571,18 +1528,18 @@ function useRenderToolCall2(tool, dependencies) {
|
|
|
1571
1528
|
|
|
1572
1529
|
// src/hooks/use-human-in-the-loop.ts
|
|
1573
1530
|
var import_shared9 = require("@copilotkit/shared");
|
|
1574
|
-
var
|
|
1531
|
+
var import_react20 = require("@copilotkitnext/react");
|
|
1575
1532
|
var import_core = require("@copilotkitnext/core");
|
|
1576
|
-
var
|
|
1533
|
+
var import_react21 = __toESM(require("react"));
|
|
1577
1534
|
function useHumanInTheLoop(tool, dependencies) {
|
|
1578
1535
|
const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
|
|
1579
1536
|
const { name, description, parameters, followUp } = toolRest;
|
|
1580
1537
|
const zodParameters = (0, import_shared9.getZodParameters)(parameters);
|
|
1581
|
-
const renderRef = (0,
|
|
1582
|
-
(0,
|
|
1538
|
+
const renderRef = (0, import_react21.useRef)(null);
|
|
1539
|
+
(0, import_react21.useEffect)(() => {
|
|
1583
1540
|
renderRef.current = (args) => {
|
|
1584
1541
|
if (typeof render === "string") {
|
|
1585
|
-
return
|
|
1542
|
+
return import_react21.default.createElement(import_react21.default.Fragment, null, render);
|
|
1586
1543
|
}
|
|
1587
1544
|
if (!render) {
|
|
1588
1545
|
return null;
|
|
@@ -1622,12 +1579,12 @@ function useHumanInTheLoop(tool, dependencies) {
|
|
|
1622
1579
|
})();
|
|
1623
1580
|
const rendered = render(renderProps);
|
|
1624
1581
|
if (typeof rendered === "string") {
|
|
1625
|
-
return
|
|
1582
|
+
return import_react21.default.createElement(import_react21.default.Fragment, null, rendered);
|
|
1626
1583
|
}
|
|
1627
1584
|
return rendered != null ? rendered : null;
|
|
1628
1585
|
};
|
|
1629
1586
|
}, [render, ...dependencies != null ? dependencies : []]);
|
|
1630
|
-
(0,
|
|
1587
|
+
(0, import_react20.useHumanInTheLoop)({
|
|
1631
1588
|
name,
|
|
1632
1589
|
description,
|
|
1633
1590
|
followUp,
|
|
@@ -1683,7 +1640,7 @@ function getActionConfig(action) {
|
|
|
1683
1640
|
throw new Error("Invalid action configuration");
|
|
1684
1641
|
}
|
|
1685
1642
|
function useCopilotAction(action, dependencies) {
|
|
1686
|
-
const [initialActionConfig] = (0,
|
|
1643
|
+
const [initialActionConfig] = (0, import_react22.useState)(getActionConfig(action));
|
|
1687
1644
|
const currentActionConfig = getActionConfig(action);
|
|
1688
1645
|
if (initialActionConfig.type !== currentActionConfig.type) {
|
|
1689
1646
|
throw new Error("Action configuration changed between renders");
|
|
@@ -1701,14 +1658,14 @@ function useCopilotAction(action, dependencies) {
|
|
|
1701
1658
|
}
|
|
1702
1659
|
|
|
1703
1660
|
// src/hooks/use-coagent-state-render.ts
|
|
1704
|
-
var
|
|
1661
|
+
var import_react23 = require("react");
|
|
1705
1662
|
var import_shared10 = require("@copilotkit/shared");
|
|
1706
1663
|
function useCoAgentStateRender(action, dependencies) {
|
|
1707
|
-
const { chatComponentsCache, availableAgents } = (0,
|
|
1664
|
+
const { chatComponentsCache, availableAgents } = (0, import_react23.useContext)(CopilotContext);
|
|
1708
1665
|
const { setCoAgentStateRender, removeCoAgentStateRender, coAgentStateRenders } = useCoAgentStateRenders();
|
|
1709
|
-
const idRef = (0,
|
|
1666
|
+
const idRef = (0, import_react23.useRef)((0, import_shared10.randomId)());
|
|
1710
1667
|
const { setBannerError, addToast } = useToast();
|
|
1711
|
-
(0,
|
|
1668
|
+
(0, import_react23.useEffect)(() => {
|
|
1712
1669
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
1713
1670
|
const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
|
|
1714
1671
|
const agentError = new import_shared10.CopilotKitAgentDiscoveryError({
|
|
@@ -1729,7 +1686,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1729
1686
|
}
|
|
1730
1687
|
}
|
|
1731
1688
|
}
|
|
1732
|
-
(0,
|
|
1689
|
+
(0, import_react23.useEffect)(() => {
|
|
1733
1690
|
const currentId = idRef.current;
|
|
1734
1691
|
const hasDuplicate = Object.entries(coAgentStateRenders).some(([id, otherAction]) => {
|
|
1735
1692
|
if (id === currentId)
|
|
@@ -1753,7 +1710,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1753
1710
|
});
|
|
1754
1711
|
}
|
|
1755
1712
|
}, [coAgentStateRenders]);
|
|
1756
|
-
(0,
|
|
1713
|
+
(0, import_react23.useEffect)(() => {
|
|
1757
1714
|
setCoAgentStateRender(idRef.current, action);
|
|
1758
1715
|
if (chatComponentsCache.current !== null && action.render !== void 0) {
|
|
1759
1716
|
chatComponentsCache.current.coAgentStateRenders[key] = action.render;
|
|
@@ -1773,11 +1730,11 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1773
1730
|
}
|
|
1774
1731
|
|
|
1775
1732
|
// src/hooks/use-make-copilot-document-readable.ts
|
|
1776
|
-
var
|
|
1733
|
+
var import_react24 = require("react");
|
|
1777
1734
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
1778
1735
|
const { addDocumentContext, removeDocumentContext } = useCopilotContext();
|
|
1779
|
-
const idRef = (0,
|
|
1780
|
-
(0,
|
|
1736
|
+
const idRef = (0, import_react24.useRef)(void 0);
|
|
1737
|
+
(0, import_react24.useEffect)(() => {
|
|
1781
1738
|
const id = addDocumentContext(document, categories);
|
|
1782
1739
|
idRef.current = id;
|
|
1783
1740
|
return () => {
|
|
@@ -1788,23 +1745,46 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
1788
1745
|
}
|
|
1789
1746
|
|
|
1790
1747
|
// src/hooks/use-copilot-readable.ts
|
|
1791
|
-
var
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1748
|
+
var import_react25 = require("@copilotkitnext/react");
|
|
1749
|
+
var import_react26 = require("react");
|
|
1750
|
+
function useCopilotReadable({ description, value, convert, available }, dependencies) {
|
|
1751
|
+
const { copilotkit } = (0, import_react25.useCopilotKit)();
|
|
1752
|
+
const ctxIdRef = (0, import_react26.useRef)(void 0);
|
|
1753
|
+
(0, import_react26.useEffect)(() => {
|
|
1754
|
+
if (!copilotkit)
|
|
1755
|
+
return;
|
|
1756
|
+
const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
|
|
1757
|
+
return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
|
|
1758
|
+
});
|
|
1759
|
+
if (found) {
|
|
1760
|
+
ctxIdRef.current = found[0];
|
|
1761
|
+
if (available === "disabled")
|
|
1762
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
if (!found && available === "disabled")
|
|
1766
|
+
return;
|
|
1767
|
+
ctxIdRef.current = copilotkit.addContext({
|
|
1768
|
+
description,
|
|
1769
|
+
value: (convert != null ? convert : JSON.stringify)(value)
|
|
1770
|
+
});
|
|
1771
|
+
return () => {
|
|
1772
|
+
if (!ctxIdRef.current)
|
|
1773
|
+
return;
|
|
1774
|
+
copilotkit.removeContext(ctxIdRef.current);
|
|
1775
|
+
};
|
|
1776
|
+
}, [description, value, convert]);
|
|
1777
|
+
return ctxIdRef.current;
|
|
1798
1778
|
}
|
|
1799
1779
|
|
|
1800
1780
|
// src/hooks/use-coagent.ts
|
|
1801
|
-
var
|
|
1802
|
-
var
|
|
1781
|
+
var import_react27 = require("react");
|
|
1782
|
+
var import_react28 = require("@copilotkitnext/react");
|
|
1803
1783
|
function useCoAgent(options) {
|
|
1804
|
-
const { agent } = (0,
|
|
1805
|
-
const { copilotkit } = (0,
|
|
1784
|
+
const { agent } = (0, import_react28.useAgent)({ agentId: options.name });
|
|
1785
|
+
const { copilotkit } = (0, import_react28.useCopilotKit)();
|
|
1806
1786
|
const nodeName = useAgentNodeName(options.name);
|
|
1807
|
-
const handleStateUpdate = (0,
|
|
1787
|
+
const handleStateUpdate = (0, import_react27.useCallback)(
|
|
1808
1788
|
(newState) => {
|
|
1809
1789
|
if (!agent)
|
|
1810
1790
|
return;
|
|
@@ -1817,7 +1797,7 @@ function useCoAgent(options) {
|
|
|
1817
1797
|
},
|
|
1818
1798
|
[agent == null ? void 0 : agent.state, agent == null ? void 0 : agent.setState]
|
|
1819
1799
|
);
|
|
1820
|
-
(0,
|
|
1800
|
+
(0, import_react27.useEffect)(() => {
|
|
1821
1801
|
var _a;
|
|
1822
1802
|
if (!options.config && !options.configurable)
|
|
1823
1803
|
return;
|
|
@@ -1829,22 +1809,22 @@ function useCoAgent(options) {
|
|
|
1829
1809
|
}
|
|
1830
1810
|
copilotkit.setProperties(config);
|
|
1831
1811
|
}, [options.config, options.configurable]);
|
|
1832
|
-
const externalStateStr = (0,
|
|
1812
|
+
const externalStateStr = (0, import_react27.useMemo)(
|
|
1833
1813
|
() => isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
|
|
1834
1814
|
[isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]
|
|
1835
1815
|
);
|
|
1836
|
-
(0,
|
|
1816
|
+
(0, import_react27.useEffect)(() => {
|
|
1837
1817
|
if ((agent == null ? void 0 : agent.state) && isExternalStateManagement(options) && JSON.stringify(options.state) !== JSON.stringify(agent.state)) {
|
|
1838
1818
|
handleStateUpdate(options.state);
|
|
1839
1819
|
}
|
|
1840
1820
|
}, [agent, externalStateStr, handleStateUpdate]);
|
|
1841
|
-
const hasStateValues = (0,
|
|
1821
|
+
const hasStateValues = (0, import_react27.useCallback)((value) => {
|
|
1842
1822
|
return Boolean(value && Object.keys(value).length);
|
|
1843
1823
|
}, []);
|
|
1844
|
-
const initialStateRef = (0,
|
|
1824
|
+
const initialStateRef = (0, import_react27.useRef)(
|
|
1845
1825
|
isExternalStateManagement(options) ? options.state : "initialState" in options ? options.initialState : void 0
|
|
1846
1826
|
);
|
|
1847
|
-
(0,
|
|
1827
|
+
(0, import_react27.useEffect)(() => {
|
|
1848
1828
|
if (isExternalStateManagement(options)) {
|
|
1849
1829
|
initialStateRef.current = options.state;
|
|
1850
1830
|
} else if ("initialState" in options) {
|
|
@@ -1853,7 +1833,7 @@ function useCoAgent(options) {
|
|
|
1853
1833
|
}, [
|
|
1854
1834
|
isExternalStateManagement(options) ? JSON.stringify(options.state) : "initialState" in options ? JSON.stringify(options.initialState) : void 0
|
|
1855
1835
|
]);
|
|
1856
|
-
(0,
|
|
1836
|
+
(0, import_react27.useEffect)(() => {
|
|
1857
1837
|
if (!agent)
|
|
1858
1838
|
return;
|
|
1859
1839
|
const subscriber = {
|
|
@@ -1881,7 +1861,7 @@ function useCoAgent(options) {
|
|
|
1881
1861
|
subscription.unsubscribe();
|
|
1882
1862
|
};
|
|
1883
1863
|
}, [agent, handleStateUpdate, hasStateValues]);
|
|
1884
|
-
return (0,
|
|
1864
|
+
return (0, import_react27.useMemo)(() => {
|
|
1885
1865
|
var _a, _b, _c;
|
|
1886
1866
|
if (!agent) {
|
|
1887
1867
|
const noop = () => {
|
|
@@ -1937,12 +1917,12 @@ var isExternalStateManagement = (options) => {
|
|
|
1937
1917
|
|
|
1938
1918
|
// src/hooks/use-copilot-runtime-client.ts
|
|
1939
1919
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1940
|
-
var
|
|
1920
|
+
var import_react29 = require("react");
|
|
1941
1921
|
var import_shared11 = require("@copilotkit/shared");
|
|
1942
1922
|
var useCopilotRuntimeClient = (options) => {
|
|
1943
1923
|
const { setBannerError } = useToast();
|
|
1944
1924
|
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
1945
|
-
const lastStructuredErrorRef = (0,
|
|
1925
|
+
const lastStructuredErrorRef = (0, import_react29.useRef)(null);
|
|
1946
1926
|
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
1947
1927
|
try {
|
|
1948
1928
|
const errorEvent = {
|
|
@@ -1968,7 +1948,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
1968
1948
|
console.error("Error in onError handler:", error2);
|
|
1969
1949
|
}
|
|
1970
1950
|
});
|
|
1971
|
-
const runtimeClient = (0,
|
|
1951
|
+
const runtimeClient = (0, import_react29.useMemo)(() => {
|
|
1972
1952
|
return new import_runtime_client_gql3.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
1973
1953
|
handleGQLErrors: (error) => {
|
|
1974
1954
|
var _a2;
|
|
@@ -2047,28 +2027,28 @@ function createStructuredError(gqlError) {
|
|
|
2047
2027
|
}
|
|
2048
2028
|
|
|
2049
2029
|
// src/hooks/use-copilot-authenticated-action.ts
|
|
2050
|
-
var
|
|
2051
|
-
var
|
|
2030
|
+
var import_react30 = require("react");
|
|
2031
|
+
var import_react31 = __toESM(require("react"));
|
|
2052
2032
|
function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
2053
2033
|
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
2054
|
-
const pendingActionRef = (0,
|
|
2055
|
-
const executeAction = (0,
|
|
2034
|
+
const pendingActionRef = (0, import_react30.useRef)(null);
|
|
2035
|
+
const executeAction = (0, import_react30.useCallback)(
|
|
2056
2036
|
(props) => {
|
|
2057
2037
|
if (typeof action.render === "function") {
|
|
2058
2038
|
return action.render(props);
|
|
2059
2039
|
}
|
|
2060
|
-
return action.render ||
|
|
2040
|
+
return action.render || import_react31.default.createElement(import_react30.Fragment);
|
|
2061
2041
|
},
|
|
2062
2042
|
[action]
|
|
2063
2043
|
);
|
|
2064
|
-
const wrappedRender = (0,
|
|
2044
|
+
const wrappedRender = (0, import_react30.useCallback)(
|
|
2065
2045
|
(props) => {
|
|
2066
2046
|
const isAuthenticated = Object.values(authStates_c || {}).some(
|
|
2067
2047
|
(state) => state.status === "authenticated"
|
|
2068
2048
|
);
|
|
2069
2049
|
if (!isAuthenticated) {
|
|
2070
2050
|
pendingActionRef.current = props;
|
|
2071
|
-
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ?
|
|
2051
|
+
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react31.default.createElement(authConfig_c.SignInComponent, {
|
|
2072
2052
|
onSignInComplete: (authState) => {
|
|
2073
2053
|
setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
2074
2054
|
if (pendingActionRef.current) {
|
|
@@ -2076,7 +2056,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2076
2056
|
pendingActionRef.current = null;
|
|
2077
2057
|
}
|
|
2078
2058
|
}
|
|
2079
|
-
}) :
|
|
2059
|
+
}) : import_react31.default.createElement(import_react30.Fragment);
|
|
2080
2060
|
}
|
|
2081
2061
|
return executeAction(props);
|
|
2082
2062
|
},
|
|
@@ -2091,13 +2071,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2091
2071
|
}
|
|
2092
2072
|
|
|
2093
2073
|
// src/hooks/use-langgraph-interrupt.ts
|
|
2094
|
-
var
|
|
2074
|
+
var import_react32 = require("react");
|
|
2095
2075
|
var import_shared12 = require("@copilotkit/shared");
|
|
2096
2076
|
function useLangGraphInterrupt(action, dependencies) {
|
|
2097
|
-
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0,
|
|
2077
|
+
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react32.useContext)(CopilotContext);
|
|
2098
2078
|
const { addToast } = useToast();
|
|
2099
2079
|
const actionId = (0, import_shared12.dataToUUID)(action, "lgAction");
|
|
2100
|
-
(0,
|
|
2080
|
+
(0, import_react32.useEffect)(() => {
|
|
2101
2081
|
if (!action)
|
|
2102
2082
|
return;
|
|
2103
2083
|
setInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
|
|
@@ -2108,10 +2088,10 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
2108
2088
|
}
|
|
2109
2089
|
|
|
2110
2090
|
// src/hooks/use-copilot-additional-instructions.ts
|
|
2111
|
-
var
|
|
2091
|
+
var import_react33 = require("react");
|
|
2112
2092
|
function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
|
|
2113
2093
|
const { setAdditionalInstructions } = useCopilotContext();
|
|
2114
|
-
(0,
|
|
2094
|
+
(0, import_react33.useEffect)(() => {
|
|
2115
2095
|
if (available === "disabled")
|
|
2116
2096
|
return;
|
|
2117
2097
|
setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
|
|
@@ -2127,17 +2107,32 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
|
|
|
2127
2107
|
function useDefaultTool(tool, dependencies) {
|
|
2128
2108
|
useCopilotAction(__spreadProps(__spreadValues({}, tool), { name: "*" }), dependencies);
|
|
2129
2109
|
}
|
|
2110
|
+
|
|
2111
|
+
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
2112
|
+
var import_react34 = require("@copilotkitnext/react");
|
|
2113
|
+
function useCopilotChatSuggestions(config, dependencies = []) {
|
|
2114
|
+
var _a, _b;
|
|
2115
|
+
const existingConfig = (0, import_react34.useCopilotChatConfiguration)();
|
|
2116
|
+
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
2117
|
+
const available = (_b = config.available === "enabled" ? "always" : config.available) != null ? _b : "before-first-message";
|
|
2118
|
+
const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
|
|
2119
|
+
available,
|
|
2120
|
+
consumerAgentId: resolvedAgentId
|
|
2121
|
+
// Use chatConfig.agentId here
|
|
2122
|
+
});
|
|
2123
|
+
(0, import_react34.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
|
|
2124
|
+
}
|
|
2130
2125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2131
2126
|
0 && (module.exports = {
|
|
2132
2127
|
useCoAgent,
|
|
2133
2128
|
useCoAgentStateRender,
|
|
2134
|
-
useConfigureChatSuggestions,
|
|
2135
2129
|
useCopilotAction,
|
|
2136
2130
|
useCopilotAdditionalInstructions,
|
|
2137
2131
|
useCopilotAuthenticatedAction_c,
|
|
2138
2132
|
useCopilotChat,
|
|
2139
2133
|
useCopilotChatHeadless_c,
|
|
2140
2134
|
useCopilotChatInternal,
|
|
2135
|
+
useCopilotChatSuggestions,
|
|
2141
2136
|
useCopilotReadable,
|
|
2142
2137
|
useCopilotRuntimeClient,
|
|
2143
2138
|
useDefaultTool,
|