@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.
Files changed (62) hide show
  1. package/CHANGELOG.md +19 -2
  2. package/dist/{chunk-EKDPRKZT.mjs → chunk-3775VM7Y.mjs} +14 -26
  3. package/dist/chunk-3775VM7Y.mjs.map +1 -0
  4. package/dist/{chunk-BLDHD6Q2.mjs → chunk-7SHWECGN.mjs} +2 -2
  5. package/dist/{chunk-QSNZUI5G.mjs → chunk-B5ELMVT7.mjs} +2 -2
  6. package/dist/{chunk-WV57GREG.mjs → chunk-FYMZKPOL.mjs} +6 -6
  7. package/dist/chunk-XDFVCQD3.mjs +27 -0
  8. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  9. package/dist/{chunk-KYY2WZSR.mjs → chunk-YJGPIN3R.mjs} +2 -2
  10. package/dist/chunk-Z6JV2LRY.mjs +37 -0
  11. package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
  12. package/dist/components/copilot-provider/copilotkit.mjs +7 -7
  13. package/dist/components/copilot-provider/index.mjs +7 -7
  14. package/dist/components/index.mjs +7 -7
  15. package/dist/hooks/index.d.ts +1 -1
  16. package/dist/hooks/index.js +146 -151
  17. package/dist/hooks/index.js.map +1 -1
  18. package/dist/hooks/index.mjs +24 -24
  19. package/dist/hooks/use-copilot-chat-headless_c.js +39 -82
  20. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  21. package/dist/hooks/use-copilot-chat-headless_c.mjs +3 -4
  22. package/dist/hooks/{use-configure-chat-suggestions.d.ts → use-copilot-chat-suggestions.d.ts} +2 -3
  23. package/dist/hooks/{use-configure-chat-suggestions.js → use-copilot-chat-suggestions.js} +10 -29
  24. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  25. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  26. package/dist/hooks/use-copilot-chat.js +37 -80
  27. package/dist/hooks/use-copilot-chat.js.map +1 -1
  28. package/dist/hooks/use-copilot-chat.mjs +3 -4
  29. package/dist/hooks/use-copilot-chat_internal.d.ts +17 -0
  30. package/dist/hooks/use-copilot-chat_internal.js +37 -80
  31. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  32. package/dist/hooks/use-copilot-chat_internal.mjs +2 -3
  33. package/dist/hooks/use-copilot-readable.d.ts +1 -1
  34. package/dist/hooks/use-copilot-readable.js +29 -6
  35. package/dist/hooks/use-copilot-readable.js.map +1 -1
  36. package/dist/hooks/use-copilot-readable.mjs +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +139 -144
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +35 -35
  41. package/dist/lib/copilot-task.mjs +8 -8
  42. package/dist/lib/index.mjs +8 -8
  43. package/dist/types/index.mjs +1 -1
  44. package/dist/utils/index.mjs +3 -3
  45. package/package.json +5 -5
  46. package/src/hooks/index.ts +2 -2
  47. package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
  48. package/src/hooks/use-copilot-chat_internal.ts +29 -29
  49. package/src/hooks/use-copilot-readable.ts +30 -13
  50. package/dist/chunk-2CYJN455.mjs +0 -14
  51. package/dist/chunk-2CYJN455.mjs.map +0 -1
  52. package/dist/chunk-EKDPRKZT.mjs.map +0 -1
  53. package/dist/chunk-FBVI3LQ6.mjs +0 -48
  54. package/dist/chunk-FBVI3LQ6.mjs.map +0 -1
  55. package/dist/hooks/use-configure-chat-suggestions.js.map +0 -1
  56. package/dist/hooks/use-configure-chat-suggestions.mjs +0 -8
  57. package/src/hooks/use-configure-chat-suggestions.tsx +0 -86
  58. /package/dist/{chunk-BLDHD6Q2.mjs.map → chunk-7SHWECGN.mjs.map} +0 -0
  59. /package/dist/{chunk-QSNZUI5G.mjs.map → chunk-B5ELMVT7.mjs.map} +0 -0
  60. /package/dist/{chunk-WV57GREG.mjs.map → chunk-FYMZKPOL.mjs.map} +0 -0
  61. /package/dist/{chunk-KYY2WZSR.mjs.map → chunk-YJGPIN3R.mjs.map} +0 -0
  62. /package/dist/hooks/{use-configure-chat-suggestions.mjs.map → use-copilot-chat-suggestions.mjs.map} +0 -0
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  useCopilotChatHeadless_c
3
- } from "../chunk-KYY2WZSR.mjs";
3
+ } from "../chunk-YJGPIN3R.mjs";
4
4
  import {
5
5
  defaultSystemMessage
6
- } from "../chunk-EKDPRKZT.mjs";
7
- import "../chunk-VV56AVPB.mjs";
6
+ } from "../chunk-3775VM7Y.mjs";
8
7
  import "../chunk-ZVF5Q6IH.mjs";
8
+ import "../chunk-VV56AVPB.mjs";
9
9
  import "../chunk-I76HKHPJ.mjs";
10
- import "../chunk-FBVI3LQ6.mjs";
11
10
  import "../chunk-6PUNP7CD.mjs";
12
11
  import "../chunk-O7ARI5CV.mjs";
13
12
  import "../chunk-QNUAXSDP.mjs";
@@ -1,4 +1,3 @@
1
- import { useSuggestions } from '@copilotkitnext/react';
2
1
  import { StaticSuggestionsConfig, Suggestion } from '@copilotkitnext/core';
3
2
 
4
3
  type StaticSuggestionInput = Omit<Suggestion, "isLoading"> & Partial<Pick<Suggestion, "isLoading">>;
@@ -31,6 +30,6 @@ type DynamicSuggestionsConfigInput = {
31
30
  className?: string;
32
31
  };
33
32
  type UseCopilotChatSuggestionsConfiguration = DynamicSuggestionsConfigInput | StaticSuggestionsConfigInput;
34
- declare function useConfigureChatSuggestions(config: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): ReturnType<typeof useSuggestions>;
33
+ declare function useCopilotChatSuggestions(config: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): void;
35
34
 
36
- export { UseCopilotChatSuggestionsConfiguration, useConfigureChatSuggestions };
35
+ export { UseCopilotChatSuggestionsConfiguration, useCopilotChatSuggestions };
@@ -34,46 +34,27 @@ var __copyProps = (to, from, except, desc) => {
34
34
  };
35
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
36
 
37
- // src/hooks/use-configure-chat-suggestions.tsx
38
- var use_configure_chat_suggestions_exports = {};
39
- __export(use_configure_chat_suggestions_exports, {
40
- useConfigureChatSuggestions: () => useConfigureChatSuggestions
37
+ // src/hooks/use-copilot-chat-suggestions.tsx
38
+ var use_copilot_chat_suggestions_exports = {};
39
+ __export(use_copilot_chat_suggestions_exports, {
40
+ useCopilotChatSuggestions: () => useCopilotChatSuggestions
41
41
  });
42
- module.exports = __toCommonJS(use_configure_chat_suggestions_exports);
42
+ module.exports = __toCommonJS(use_copilot_chat_suggestions_exports);
43
43
  var import_react = require("@copilotkitnext/react");
44
- var import_react2 = require("react");
45
- function useConfigureChatSuggestions(config, dependencies = []) {
46
- var _a;
44
+ function useCopilotChatSuggestions(config, dependencies = []) {
45
+ var _a, _b;
47
46
  const existingConfig = (0, import_react.useCopilotChatConfiguration)();
48
47
  const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
49
- const { copilotkit } = (0, import_react.useCopilotKit)();
50
- const available = config.available === "enabled" ? "always" : config.available;
48
+ const available = (_b = config.available === "enabled" ? "always" : config.available) != null ? _b : "before-first-message";
51
49
  const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
52
50
  available,
53
51
  consumerAgentId: resolvedAgentId
54
52
  // Use chatConfig.agentId here
55
53
  });
56
54
  (0, import_react.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
57
- const result = (0, import_react.useSuggestions)({ agentId: resolvedAgentId });
58
- (0, import_react2.useEffect)(() => {
59
- if (finalSuggestionConfig.available === "disabled")
60
- return;
61
- const subscription = copilotkit.subscribe({
62
- onAgentsChanged: () => {
63
- const agent = copilotkit.getAgent(resolvedAgentId);
64
- if (agent && !agent.isRunning && !result.suggestions.length) {
65
- copilotkit.reloadSuggestions(resolvedAgentId);
66
- }
67
- }
68
- });
69
- return () => {
70
- subscription.unsubscribe();
71
- };
72
- }, [resolvedAgentId]);
73
- return result;
74
55
  }
75
56
  // Annotate the CommonJS export names for ESM import in node:
76
57
  0 && (module.exports = {
77
- useConfigureChatSuggestions
58
+ useCopilotChatSuggestions
78
59
  });
79
- //# sourceMappingURL=use-configure-chat-suggestions.js.map
60
+ //# sourceMappingURL=use-copilot-chat-suggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\nimport {\n useConfigureSuggestions,\n useCopilotChatConfiguration,\n useCopilotKit,\n useSuggestions,\n} from \"@copilotkitnext/react\";\nimport { useEffect } from \"react\";\nimport { StaticSuggestionsConfig, Suggestion } from \"@copilotkitnext/core\";\n\ntype StaticSuggestionInput = Omit<Suggestion, \"isLoading\"> & Partial<Pick<Suggestion, \"isLoading\">>;\n\ntype StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, \"suggestions\"> & {\n suggestions: StaticSuggestionInput[];\n};\n\ntype DynamicSuggestionsConfigInput = {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n\n /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\" | \"always\" | \"before-first-message\" | \"after-first-message\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n};\n\nexport type UseCopilotChatSuggestionsConfiguration =\n | DynamicSuggestionsConfigInput\n | StaticSuggestionsConfigInput;\n\nexport function useCopilotChatSuggestions(\n config: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const existingConfig = useCopilotChatConfiguration();\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n\n const available =\n (config.available === \"enabled\" ? \"always\" : config.available) ?? \"before-first-message\";\n\n const finalSuggestionConfig = {\n ...config,\n available,\n consumerAgentId: resolvedAgentId, // Use chatConfig.agentId here\n };\n useConfigureSuggestions(finalSuggestionConfig, dependencies);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DA,mBAKO;AA0CA,SAAS,0BACd,QACA,eAAsB,CAAC,GACvB;AA9GF;AA+GE,QAAM,qBAAiB,0CAA4B;AACnD,QAAM,mBAAkB,sDAAgB,YAAhB,YAA2B;AAEnD,QAAM,aACH,YAAO,cAAc,YAAY,WAAW,OAAO,cAAnD,YAAiE;AAEpE,QAAM,wBAAwB,iCACzB,SADyB;AAAA,IAE5B;AAAA,IACA,iBAAiB;AAAA;AAAA,EACnB;AACA,4CAAwB,uBAAuB,YAAY;AAC7D;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ useCopilotChatSuggestions
3
+ } from "../chunk-XDFVCQD3.mjs";
4
+ import "../chunk-SKC7AJIV.mjs";
5
+ export {
6
+ useCopilotChatSuggestions
7
+ };
8
+ //# sourceMappingURL=use-copilot-chat-suggestions.mjs.map
@@ -84,7 +84,7 @@ __export(use_copilot_chat_exports, {
84
84
  module.exports = __toCommonJS(use_copilot_chat_exports);
85
85
 
86
86
  // src/hooks/use-copilot-chat_internal.ts
87
- var import_react15 = require("react");
87
+ var import_react13 = require("react");
88
88
 
89
89
  // src/context/copilot-context.tsx
90
90
  var import_react = __toESM(require("react"));
@@ -473,7 +473,7 @@ function useLangGraphInterruptRender(agent) {
473
473
  }
474
474
 
475
475
  // src/hooks/use-copilot-chat_internal.ts
476
- var import_react16 = require("@copilotkitnext/react");
476
+ var import_react14 = require("@copilotkitnext/react");
477
477
 
478
478
  // src/hooks/use-lazy-tool-renderer.tsx
479
479
  var import_react9 = require("@copilotkitnext/react");
@@ -500,40 +500,6 @@ function useLazyToolRenderer() {
500
500
  );
501
501
  }
502
502
 
503
- // src/hooks/use-configure-chat-suggestions.tsx
504
- var import_react11 = require("@copilotkitnext/react");
505
- var import_react12 = require("react");
506
- function useConfigureChatSuggestions(config, dependencies = []) {
507
- var _a;
508
- const existingConfig = (0, import_react11.useCopilotChatConfiguration)();
509
- const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
510
- const { copilotkit } = (0, import_react11.useCopilotKit)();
511
- const available = config.available === "enabled" ? "always" : config.available;
512
- const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
513
- available,
514
- consumerAgentId: resolvedAgentId
515
- // Use chatConfig.agentId here
516
- });
517
- (0, import_react11.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
518
- const result = (0, import_react11.useSuggestions)({ agentId: resolvedAgentId });
519
- (0, import_react12.useEffect)(() => {
520
- if (finalSuggestionConfig.available === "disabled")
521
- return;
522
- const subscription = copilotkit.subscribe({
523
- onAgentsChanged: () => {
524
- const agent = copilotkit.getAgent(resolvedAgentId);
525
- if (agent && !agent.isRunning && !result.suggestions.length) {
526
- copilotkit.reloadSuggestions(resolvedAgentId);
527
- }
528
- }
529
- });
530
- return () => {
531
- subscription.unsubscribe();
532
- };
533
- }, [resolvedAgentId]);
534
- return result;
535
- }
536
-
537
503
  // ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
538
504
  var import_zod = require("zod");
539
505
  var import_zod2 = require("zod");
@@ -940,8 +906,8 @@ var EventSchemas = import_zod2.z.discriminatedUnion("type", [
940
906
  ]);
941
907
 
942
908
  // src/hooks/use-coagent-state-render-bridge.tsx
943
- var import_react13 = require("@copilotkitnext/react");
944
- var import_react14 = require("react");
909
+ var import_react11 = require("@copilotkitnext/react");
910
+ var import_react12 = require("react");
945
911
  var import_shared3 = require("@copilotkit/shared");
946
912
  function getStateWithoutConstantKeys(state) {
947
913
  if (!state)
@@ -968,11 +934,11 @@ function useCoagentStateRenderBridge(agentId, props) {
968
934
  var _a;
969
935
  const { stateSnapshot, messageIndexInRun, message } = props;
970
936
  const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
971
- const { agent } = (0, import_react13.useAgent)({ agentId });
972
- const [nodeName, setNodeName] = (0, import_react14.useState)(void 0);
937
+ const { agent } = (0, import_react11.useAgent)({ agentId });
938
+ const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
973
939
  const runId = (_a = props.runId) != null ? _a : message.runId;
974
940
  const effectiveRunId = runId || "pending";
975
- (0, import_react14.useEffect)(() => {
941
+ (0, import_react12.useEffect)(() => {
976
942
  if (!agent)
977
943
  return;
978
944
  const subscriber = {
@@ -992,7 +958,7 @@ function useCoagentStateRenderBridge(agentId, props) {
992
958
  unsubscribe();
993
959
  };
994
960
  }, [agentId, nodeName]);
995
- const getStateRender = (0, import_react14.useCallback)(
961
+ const getStateRender = (0, import_react12.useCallback)(
996
962
  (messageId) => {
997
963
  return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
998
964
  if (claimsRef.current[messageId]) {
@@ -1034,7 +1000,7 @@ function useCoagentStateRenderBridge(agentId, props) {
1034
1000
  claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
1035
1001
  return true;
1036
1002
  };
1037
- return (0, import_react14.useMemo)(() => {
1003
+ return (0, import_react12.useMemo)(() => {
1038
1004
  var _a2, _b, _c;
1039
1005
  if (messageIndexInRun !== 0) {
1040
1006
  return null;
@@ -1094,35 +1060,17 @@ function CoAgentStateRenderBridge(props) {
1094
1060
  }
1095
1061
 
1096
1062
  // src/hooks/use-copilot-chat_internal.ts
1097
- function useConfigureSuggestions2(suggestions) {
1098
- let suggestionsConfig;
1099
- if (Array.isArray(suggestions)) {
1100
- suggestionsConfig = {
1101
- suggestions,
1102
- available: "always"
1103
- };
1104
- } else if (suggestions === "auto") {
1105
- suggestionsConfig = {
1106
- available: suggestions === "auto" ? "always" : "disabled",
1107
- instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls."
1108
- };
1109
- } else {
1110
- suggestionsConfig = { available: "disabled" };
1111
- }
1112
- useConfigureChatSuggestions(suggestionsConfig);
1113
- }
1114
1063
  function useCopilotChatInternal({
1115
1064
  suggestions
1116
1065
  } = {}) {
1117
1066
  var _a, _b, _c;
1118
- const { copilotkit } = (0, import_react16.useCopilotKit)();
1067
+ const { copilotkit } = (0, import_react14.useCopilotKit)();
1119
1068
  const { threadId, agentSession } = useCopilotContext();
1120
- const existingConfig = (0, import_react16.useCopilotChatConfiguration)();
1121
- const [agentAvailable, setAgentAvailable] = (0, import_react15.useState)(false);
1122
- useConfigureSuggestions2(suggestions);
1069
+ const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
1070
+ const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
1123
1071
  const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
1124
- const { agent } = (0, import_react16.useAgent)({ agentId: resolvedAgentId });
1125
- (0, import_react15.useEffect)(() => {
1072
+ const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
1073
+ (0, import_react13.useEffect)(() => {
1126
1074
  const connect = (agent2) => __async(this, null, function* () {
1127
1075
  setAgentAvailable(false);
1128
1076
  try {
@@ -1147,7 +1095,7 @@ function useCopilotChatInternal({
1147
1095
  agent == null ? void 0 : agent.setMessages([]);
1148
1096
  agent == null ? void 0 : agent.setState(null);
1149
1097
  };
1150
- const deleteMessage = (0, import_react15.useCallback)(
1098
+ const deleteMessage = (0, import_react13.useCallback)(
1151
1099
  (messageId) => {
1152
1100
  var _a2;
1153
1101
  const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
@@ -1158,13 +1106,13 @@ function useCopilotChatInternal({
1158
1106
  [agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
1159
1107
  );
1160
1108
  const latestDelete = useUpdatedRef(deleteMessage);
1161
- const latestDeleteFunc = (0, import_react15.useCallback)(
1109
+ const latestDeleteFunc = (0, import_react13.useCallback)(
1162
1110
  (messageId) => {
1163
1111
  return latestDelete.current(messageId);
1164
1112
  },
1165
1113
  [latestDelete]
1166
1114
  );
1167
- const currentSuggestions = (0, import_react16.useSuggestions)({ agentId: resolvedAgentId });
1115
+ const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
1168
1116
  const reload = useAsyncCallback(
1169
1117
  (reloadMessageId) => __async(this, null, function* () {
1170
1118
  var _a2;
@@ -1231,7 +1179,7 @@ function useCopilotChatInternal({
1231
1179
  }),
1232
1180
  [latestSendMessageFunc]
1233
1181
  );
1234
- const latestSetMessagesFunc = (0, import_react15.useCallback)(
1182
+ const latestSetMessagesFunc = (0, import_react13.useCallback)(
1235
1183
  (messages) => {
1236
1184
  var _a2, _b2;
1237
1185
  if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
@@ -1248,16 +1196,16 @@ function useCopilotChatInternal({
1248
1196
  }),
1249
1197
  [latestReload]
1250
1198
  );
1251
- const latestStopFunc = (0, import_react15.useCallback)(() => {
1199
+ const latestStopFunc = (0, import_react13.useCallback)(() => {
1252
1200
  var _a2;
1253
1201
  return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
1254
1202
  }, [agent == null ? void 0 : agent.abortRun]);
1255
1203
  const latestReset = useUpdatedRef(reset);
1256
- const latestResetFunc = (0, import_react15.useCallback)(() => {
1204
+ const latestResetFunc = (0, import_react13.useCallback)(() => {
1257
1205
  return latestReset.current();
1258
1206
  }, [latestReset]);
1259
1207
  const lazyToolRendered = useLazyToolRenderer();
1260
- const renderCustomMessage = (0, import_react16.useRenderCustomMessages)();
1208
+ const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
1261
1209
  const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
1262
1210
  copilotkit,
1263
1211
  agent,
@@ -1265,7 +1213,7 @@ function useCopilotChatInternal({
1265
1213
  threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
1266
1214
  });
1267
1215
  const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
1268
- const resolvedMessages = (0, import_react15.useMemo)(() => {
1216
+ const resolvedMessages = (0, import_react13.useMemo)(() => {
1269
1217
  let processedMessages = allMessages.map((message) => {
1270
1218
  if (message.role !== "assistant") {
1271
1219
  return message;
@@ -1302,6 +1250,15 @@ function useCopilotChatInternal({
1302
1250
  // legacyCustomMessageRenderer,
1303
1251
  resolvedAgentId
1304
1252
  ]);
1253
+ const renderedSuggestions = (0, import_react13.useMemo)(() => {
1254
+ if (Array.isArray(suggestions)) {
1255
+ return {
1256
+ suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
1257
+ isLoading: false
1258
+ };
1259
+ }
1260
+ return currentSuggestions;
1261
+ }, [suggestions, currentSuggestions]);
1305
1262
  return {
1306
1263
  messages: resolvedMessages,
1307
1264
  sendMessage: latestSendMessageFunc,
@@ -1315,21 +1272,21 @@ function useCopilotChatInternal({
1315
1272
  isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
1316
1273
  // mcpServers,
1317
1274
  // setMcpServers,
1318
- suggestions: currentSuggestions.suggestions,
1275
+ suggestions: renderedSuggestions.suggestions,
1319
1276
  setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
1320
1277
  generateSuggestions: () => __async(this, null, function* () {
1321
1278
  return copilotkit.reloadSuggestions(resolvedAgentId);
1322
1279
  }),
1323
1280
  resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
1324
- isLoadingSuggestions: currentSuggestions.isLoading,
1281
+ isLoadingSuggestions: renderedSuggestions.isLoading,
1325
1282
  interrupt,
1326
1283
  agent,
1327
1284
  threadId
1328
1285
  };
1329
1286
  }
1330
1287
  function useUpdatedRef(value) {
1331
- const ref = (0, import_react15.useRef)(value);
1332
- (0, import_react15.useEffect)(() => {
1288
+ const ref = (0, import_react13.useRef)(value);
1289
+ (0, import_react13.useEffect)(() => {
1333
1290
  ref.current = value;
1334
1291
  }, [value]);
1335
1292
  return ref;
@@ -1340,7 +1297,7 @@ function useLegacyCoagentRenderer({
1340
1297
  agentId,
1341
1298
  threadId
1342
1299
  }) {
1343
- return (0, import_react15.useMemo)(() => {
1300
+ return (0, import_react13.useMemo)(() => {
1344
1301
  if (!copilotkit || !agent) {
1345
1302
  return null;
1346
1303
  }
@@ -1363,7 +1320,7 @@ function useLegacyCoagentRenderer({
1363
1320
  agentId,
1364
1321
  stateSnapshot: message.state
1365
1322
  };
1366
- return (0, import_react15.createElement)(CoAgentStateRenderBridge, bridgeProps);
1323
+ return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
1367
1324
  };
1368
1325
  }, [agent, agentId, copilotkit, threadId]);
1369
1326
  }