@copilotkit/react-core 1.4.5 → 1.4.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.
Files changed (229) hide show
  1. package/CHANGELOG.md +10 -53
  2. package/README.md +0 -2
  3. package/dist/chunk-2KCEHGSI.mjs +192 -0
  4. package/dist/chunk-2KCEHGSI.mjs.map +1 -0
  5. package/dist/chunk-5FHSUKQL.mjs +70 -0
  6. package/dist/chunk-5FHSUKQL.mjs.map +1 -0
  7. package/dist/chunk-6U3UH3KO.mjs +140 -0
  8. package/dist/chunk-6U3UH3KO.mjs.map +1 -0
  9. package/dist/chunk-AG7FH7OD.mjs +28 -0
  10. package/dist/chunk-AG7FH7OD.mjs.map +1 -0
  11. package/dist/chunk-DCTJZ742.mjs +22 -0
  12. package/dist/chunk-DCTJZ742.mjs.map +1 -0
  13. package/dist/chunk-DHGXL5PC.mjs +439 -0
  14. package/dist/chunk-DHGXL5PC.mjs.map +1 -0
  15. package/dist/chunk-EFZPSZWO.mjs +1 -0
  16. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  17. package/dist/chunk-EUIBVFV6.mjs +294 -0
  18. package/dist/chunk-EUIBVFV6.mjs.map +1 -0
  19. package/dist/chunk-JHEAUB3Z.mjs +49 -0
  20. package/dist/chunk-JHEAUB3Z.mjs.map +1 -0
  21. package/dist/chunk-L34MHAXR.mjs +1 -0
  22. package/dist/chunk-L34MHAXR.mjs.map +1 -0
  23. package/dist/chunk-LUGEI4YQ.mjs +1 -0
  24. package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
  25. package/dist/chunk-MLAS4QUR.mjs +18 -0
  26. package/dist/chunk-MLAS4QUR.mjs.map +1 -0
  27. package/dist/chunk-O22KGHOQ.mjs +128 -0
  28. package/dist/chunk-O22KGHOQ.mjs.map +1 -0
  29. package/dist/chunk-O7ARI5CV.mjs +31 -0
  30. package/dist/chunk-O7ARI5CV.mjs.map +1 -0
  31. package/dist/chunk-ODN4H66E.mjs +31 -0
  32. package/dist/chunk-ODN4H66E.mjs.map +1 -0
  33. package/dist/chunk-OT67R4NB.mjs +119 -0
  34. package/dist/chunk-OT67R4NB.mjs.map +1 -0
  35. package/dist/chunk-SKC7AJIV.mjs +61 -0
  36. package/dist/chunk-SKC7AJIV.mjs.map +1 -0
  37. package/dist/chunk-UOVONDR6.mjs +23 -0
  38. package/dist/chunk-UOVONDR6.mjs.map +1 -0
  39. package/dist/chunk-XBVKTDXP.mjs +172 -0
  40. package/dist/chunk-XBVKTDXP.mjs.map +1 -0
  41. package/dist/chunk-XQFVXX6R.mjs +78 -0
  42. package/dist/chunk-XQFVXX6R.mjs.map +1 -0
  43. package/dist/chunk-XXR4QFAQ.mjs +29 -0
  44. package/dist/chunk-XXR4QFAQ.mjs.map +1 -0
  45. package/dist/chunk-Y7MI4PBB.mjs +91 -0
  46. package/dist/chunk-Y7MI4PBB.mjs.map +1 -0
  47. package/dist/chunk-YPSGKPDA.mjs +1 -0
  48. package/dist/chunk-YPSGKPDA.mjs.map +1 -0
  49. package/dist/components/copilot-provider/copilot-messages.d.ts +7 -0
  50. package/dist/components/copilot-provider/copilot-messages.js +80 -0
  51. package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
  52. package/dist/components/copilot-provider/copilot-messages.mjs +9 -0
  53. package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
  54. package/dist/components/copilot-provider/copilotkit-props.d.ts +72 -0
  55. package/dist/components/copilot-provider/copilotkit-props.js +19 -0
  56. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
  57. package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
  58. package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
  59. package/dist/components/copilot-provider/copilotkit.d.ts +9 -0
  60. package/dist/components/copilot-provider/copilotkit.js +877 -0
  61. package/dist/components/copilot-provider/copilotkit.js.map +1 -0
  62. package/dist/components/copilot-provider/copilotkit.mjs +21 -0
  63. package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
  64. package/dist/components/copilot-provider/index.d.ts +4 -0
  65. package/dist/components/copilot-provider/index.js +877 -0
  66. package/dist/components/copilot-provider/index.js.map +1 -0
  67. package/dist/components/copilot-provider/index.mjs +19 -0
  68. package/dist/components/copilot-provider/index.mjs.map +1 -0
  69. package/dist/components/index.d.ts +4 -0
  70. package/dist/components/index.js +877 -0
  71. package/dist/components/index.js.map +1 -0
  72. package/dist/components/index.mjs +19 -0
  73. package/dist/components/index.mjs.map +1 -0
  74. package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
  75. package/dist/components/toast/exclamation-mark-icon.js +55 -0
  76. package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
  77. package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
  78. package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
  79. package/dist/components/toast/toast-provider.d.ts +29 -0
  80. package/dist/components/toast/toast-provider.js +255 -0
  81. package/dist/components/toast/toast-provider.js.map +1 -0
  82. package/dist/components/toast/toast-provider.mjs +11 -0
  83. package/dist/components/toast/toast-provider.mjs.map +1 -0
  84. package/dist/context/copilot-context.d.ts +111 -0
  85. package/dist/context/copilot-context.js +129 -0
  86. package/dist/context/copilot-context.js.map +1 -0
  87. package/dist/context/copilot-context.mjs +10 -0
  88. package/dist/context/copilot-context.mjs.map +1 -0
  89. package/dist/context/copilot-messages-context.d.ts +15 -0
  90. package/dist/context/copilot-messages-context.js +57 -0
  91. package/dist/context/copilot-messages-context.js.map +1 -0
  92. package/dist/context/copilot-messages-context.mjs +10 -0
  93. package/dist/context/copilot-messages-context.mjs.map +1 -0
  94. package/dist/context/index.d.ts +11 -0
  95. package/dist/context/index.js +152 -0
  96. package/dist/context/index.js.map +1 -0
  97. package/dist/context/index.mjs +17 -0
  98. package/dist/context/index.mjs.map +1 -0
  99. package/dist/hooks/index.d.ts +19 -0
  100. package/dist/hooks/index.js +906 -0
  101. package/dist/hooks/index.js.map +1 -0
  102. package/dist/hooks/index.mjs +44 -0
  103. package/dist/hooks/index.mjs.map +1 -0
  104. package/dist/hooks/use-chat.d.ts +96 -0
  105. package/dist/hooks/use-chat.js +359 -0
  106. package/dist/hooks/use-chat.js.map +1 -0
  107. package/dist/hooks/use-chat.mjs +11 -0
  108. package/dist/hooks/use-chat.mjs.map +1 -0
  109. package/dist/hooks/use-coagent-state-render.d.ts +60 -0
  110. package/dist/hooks/use-coagent-state-render.js +163 -0
  111. package/dist/hooks/use-coagent-state-render.js.map +1 -0
  112. package/dist/hooks/use-coagent-state-render.mjs +9 -0
  113. package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
  114. package/dist/hooks/use-coagent.d.ts +186 -0
  115. package/dist/hooks/use-coagent.js +735 -0
  116. package/dist/hooks/use-coagent.js.map +1 -0
  117. package/dist/hooks/use-coagent.mjs +21 -0
  118. package/dist/hooks/use-coagent.mjs.map +1 -0
  119. package/dist/hooks/use-copilot-action.d.ts +130 -0
  120. package/dist/hooks/use-copilot-action.js +222 -0
  121. package/dist/hooks/use-copilot-action.js.map +1 -0
  122. package/dist/hooks/use-copilot-action.mjs +9 -0
  123. package/dist/hooks/use-copilot-action.mjs.map +1 -0
  124. package/dist/hooks/use-copilot-chat.d.ts +37 -0
  125. package/dist/hooks/use-copilot-chat.js +630 -0
  126. package/dist/hooks/use-copilot-chat.js.map +1 -0
  127. package/dist/hooks/use-copilot-chat.mjs +22 -0
  128. package/dist/hooks/use-copilot-chat.mjs.map +1 -0
  129. package/dist/hooks/use-copilot-readable.d.ts +33 -0
  130. package/dist/hooks/use-copilot-readable.js +149 -0
  131. package/dist/hooks/use-copilot-readable.js.map +1 -0
  132. package/dist/hooks/use-copilot-readable.mjs +9 -0
  133. package/dist/hooks/use-copilot-readable.mjs.map +1 -0
  134. package/dist/hooks/use-copilot-runtime-client.d.ts +5 -0
  135. package/dist/hooks/use-copilot-runtime-client.js +76 -0
  136. package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
  137. package/dist/hooks/use-copilot-runtime-client.mjs +10 -0
  138. package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
  139. package/dist/hooks/use-flat-category-store.d.ts +9 -0
  140. package/dist/hooks/use-flat-category-store.js +90 -0
  141. package/dist/hooks/use-flat-category-store.js.map +1 -0
  142. package/dist/hooks/use-flat-category-store.mjs +8 -0
  143. package/dist/hooks/use-flat-category-store.mjs.map +1 -0
  144. package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
  145. package/dist/hooks/use-make-copilot-document-readable.js +144 -0
  146. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
  147. package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
  148. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
  149. package/dist/hooks/use-tree.d.ts +18 -0
  150. package/dist/hooks/use-tree.js +172 -0
  151. package/dist/hooks/use-tree.js.map +1 -0
  152. package/dist/hooks/use-tree.mjs +8 -0
  153. package/dist/hooks/use-tree.mjs.map +1 -0
  154. package/dist/index.d.ts +26 -0
  155. package/dist/index.js +1832 -0
  156. package/dist/index.js.map +1 -0
  157. package/dist/index.mjs +71 -0
  158. package/dist/index.mjs.map +1 -0
  159. package/dist/lib/copilot-task.d.ts +92 -0
  160. package/dist/lib/copilot-task.js +157 -0
  161. package/dist/lib/copilot-task.js.map +1 -0
  162. package/dist/lib/copilot-task.mjs +18 -0
  163. package/dist/lib/copilot-task.mjs.map +1 -0
  164. package/dist/lib/index.d.ts +11 -0
  165. package/dist/lib/index.js +159 -0
  166. package/dist/lib/index.js.map +1 -0
  167. package/dist/lib/index.mjs +19 -0
  168. package/dist/lib/index.mjs.map +1 -0
  169. package/dist/types/chat-suggestion-configuration.d.ts +22 -0
  170. package/dist/types/chat-suggestion-configuration.js +19 -0
  171. package/dist/types/chat-suggestion-configuration.js.map +1 -0
  172. package/dist/types/chat-suggestion-configuration.mjs +1 -0
  173. package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
  174. package/dist/types/coagent-action.d.ts +29 -0
  175. package/dist/types/coagent-action.js +19 -0
  176. package/dist/types/coagent-action.js.map +1 -0
  177. package/dist/types/coagent-action.mjs +1 -0
  178. package/dist/types/coagent-action.mjs.map +1 -0
  179. package/dist/types/coagent-state.d.ts +11 -0
  180. package/dist/types/coagent-state.js +19 -0
  181. package/dist/types/coagent-state.js.map +1 -0
  182. package/dist/types/coagent-state.mjs +1 -0
  183. package/dist/types/coagent-state.mjs.map +1 -0
  184. package/dist/types/document-pointer.d.ts +9 -0
  185. package/dist/types/document-pointer.js +19 -0
  186. package/dist/types/document-pointer.js.map +1 -0
  187. package/dist/types/document-pointer.mjs +1 -0
  188. package/dist/types/document-pointer.mjs.map +1 -0
  189. package/dist/types/frontend-action.d.ts +107 -0
  190. package/dist/types/frontend-action.js +19 -0
  191. package/dist/types/frontend-action.js.map +1 -0
  192. package/dist/types/frontend-action.mjs +1 -0
  193. package/dist/types/frontend-action.mjs.map +1 -0
  194. package/dist/types/index.d.ts +6 -0
  195. package/dist/types/index.js +19 -0
  196. package/dist/types/index.js.map +1 -0
  197. package/dist/types/index.mjs +2 -0
  198. package/dist/types/index.mjs.map +1 -0
  199. package/dist/types/system-message.d.ts +3 -0
  200. package/dist/types/system-message.js +19 -0
  201. package/dist/types/system-message.js.map +1 -0
  202. package/dist/types/system-message.mjs +1 -0
  203. package/dist/types/system-message.mjs.map +1 -0
  204. package/dist/utils/dev-console.d.ts +3 -0
  205. package/dist/utils/dev-console.js +42 -0
  206. package/dist/utils/dev-console.js.map +1 -0
  207. package/dist/utils/dev-console.mjs +8 -0
  208. package/dist/utils/dev-console.mjs.map +1 -0
  209. package/dist/utils/extract.d.ts +42 -0
  210. package/dist/utils/extract.js +190 -0
  211. package/dist/utils/extract.js.map +1 -0
  212. package/dist/utils/extract.mjs +17 -0
  213. package/dist/utils/extract.mjs.map +1 -0
  214. package/dist/utils/index.d.ts +13 -0
  215. package/dist/utils/index.js +208 -0
  216. package/dist/utils/index.js.map +1 -0
  217. package/dist/utils/index.mjs +20 -0
  218. package/dist/utils/index.mjs.map +1 -0
  219. package/dist/utils/utils.d.ts +2 -0
  220. package/dist/utils/utils.js +19 -0
  221. package/dist/utils/utils.js.map +1 -0
  222. package/dist/utils/utils.mjs +1 -0
  223. package/dist/utils/utils.mjs.map +1 -0
  224. package/dist/utils/utils.test.d.ts +2 -0
  225. package/dist/utils/utils.test.js +9 -0
  226. package/dist/utils/utils.test.js.map +1 -0
  227. package/dist/utils/utils.test.mjs +7 -0
  228. package/dist/utils/utils.test.mjs.map +1 -0
  229. package/package.json +5 -5
@@ -0,0 +1,877 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __restKey = (key) => typeof key === "symbol" ? key : key + "";
26
+ var __objRest = (source, exclude) => {
27
+ var target = {};
28
+ for (var prop in source)
29
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
30
+ target[prop] = source[prop];
31
+ if (source != null && __getOwnPropSymbols)
32
+ for (var prop of __getOwnPropSymbols(source)) {
33
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
34
+ target[prop] = source[prop];
35
+ }
36
+ return target;
37
+ };
38
+ var __export = (target, all) => {
39
+ for (var name in all)
40
+ __defProp(target, name, { get: all[name], enumerable: true });
41
+ };
42
+ var __copyProps = (to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames(from))
45
+ if (!__hasOwnProp.call(to, key) && key !== except)
46
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ };
50
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
+ // If the importer is in node compatibility mode or this is not an ESM
52
+ // file that has been converted to a CommonJS file using a Babel-
53
+ // compatible transform (i.e. "__esModule" has not been set), then set
54
+ // "default" to the CommonJS "module.exports" for node compatibility.
55
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
+ mod
57
+ ));
58
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
59
+ var __async = (__this, __arguments, generator) => {
60
+ return new Promise((resolve, reject) => {
61
+ var fulfilled = (value) => {
62
+ try {
63
+ step(generator.next(value));
64
+ } catch (e) {
65
+ reject(e);
66
+ }
67
+ };
68
+ var rejected = (value) => {
69
+ try {
70
+ step(generator.throw(value));
71
+ } catch (e) {
72
+ reject(e);
73
+ }
74
+ };
75
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
76
+ step((generator = generator.apply(__this, __arguments)).next());
77
+ });
78
+ };
79
+
80
+ // src/components/copilot-provider/index.ts
81
+ var copilot_provider_exports = {};
82
+ __export(copilot_provider_exports, {
83
+ CopilotKit: () => CopilotKit,
84
+ defaultCopilotContextCategories: () => defaultCopilotContextCategories
85
+ });
86
+ module.exports = __toCommonJS(copilot_provider_exports);
87
+
88
+ // src/components/copilot-provider/copilotkit.tsx
89
+ var import_react8 = require("react");
90
+
91
+ // src/context/copilot-context.tsx
92
+ var import_react = __toESM(require("react"));
93
+ var emptyCopilotContext = {
94
+ actions: {},
95
+ setAction: () => {
96
+ },
97
+ removeAction: () => {
98
+ },
99
+ coAgentStateRenders: {},
100
+ setCoAgentStateRender: () => {
101
+ },
102
+ removeCoAgentStateRender: () => {
103
+ },
104
+ chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
105
+ getContextString: (documents, categories) => returnAndThrowInDebug(""),
106
+ addContext: () => "",
107
+ removeContext: () => {
108
+ },
109
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
110
+ })),
111
+ isLoading: false,
112
+ setIsLoading: () => returnAndThrowInDebug(false),
113
+ chatInstructions: "",
114
+ setChatInstructions: () => returnAndThrowInDebug(""),
115
+ getDocumentsContext: (categories) => returnAndThrowInDebug([]),
116
+ addDocumentContext: () => returnAndThrowInDebug(""),
117
+ removeDocumentContext: () => {
118
+ },
119
+ runtimeClient: {},
120
+ copilotApiConfig: new class {
121
+ get chatApiEndpoint() {
122
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
123
+ }
124
+ get headers() {
125
+ return {};
126
+ }
127
+ get body() {
128
+ return {};
129
+ }
130
+ }(),
131
+ chatSuggestionConfiguration: {},
132
+ addChatSuggestionConfiguration: () => {
133
+ },
134
+ removeChatSuggestionConfiguration: () => {
135
+ },
136
+ showDevConsole: "auto",
137
+ coagentStates: {},
138
+ setCoagentStates: () => {
139
+ },
140
+ coagentStatesRef: { current: {} },
141
+ setCoagentStatesWithRef: () => {
142
+ },
143
+ agentSession: null,
144
+ setAgentSession: () => {
145
+ }
146
+ };
147
+ var CopilotContext = import_react.default.createContext(emptyCopilotContext);
148
+ function returnAndThrowInDebug(value) {
149
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
150
+ return value;
151
+ }
152
+
153
+ // src/hooks/use-tree.ts
154
+ var import_shared = require("@copilotkit/shared");
155
+ var import_react2 = require("react");
156
+ var removeNode = (nodes, id) => {
157
+ return nodes.reduce((result, node) => {
158
+ if (node.id !== id) {
159
+ const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
160
+ result.push(newNode);
161
+ }
162
+ return result;
163
+ }, []);
164
+ };
165
+ var addNode = (nodes, newNode, parentId) => {
166
+ if (!parentId) {
167
+ return [...nodes, newNode];
168
+ }
169
+ return nodes.map((node) => {
170
+ if (node.id === parentId) {
171
+ return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
172
+ } else if (node.children.length) {
173
+ return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
174
+ }
175
+ return node;
176
+ });
177
+ };
178
+ var treeIndentationRepresentation = (index, indentLevel) => {
179
+ if (indentLevel === 0) {
180
+ return (index + 1).toString();
181
+ } else if (indentLevel === 1) {
182
+ return String.fromCharCode(65 + index);
183
+ } else if (indentLevel === 2) {
184
+ return String.fromCharCode(97 + index);
185
+ } else {
186
+ return "-";
187
+ }
188
+ };
189
+ var printNode = (node, prefix = "", indentLevel = 0) => {
190
+ const indent = " ".repeat(3).repeat(indentLevel);
191
+ const prefixPlusIndentLength = prefix.length + indent.length;
192
+ const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
193
+ const valueLines = node.value.split("\n");
194
+ const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
195
+ const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
196
+ let output = `${outputFirstLine}
197
+ `;
198
+ if (outputSubsequentLines) {
199
+ output += `${outputSubsequentLines}
200
+ `;
201
+ }
202
+ const childPrePrefix = " ".repeat(prefix.length);
203
+ node.children.forEach(
204
+ (child, index) => output += printNode(
205
+ child,
206
+ `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,
207
+ indentLevel + 1
208
+ )
209
+ );
210
+ return output;
211
+ };
212
+ function treeReducer(state, action) {
213
+ switch (action.type) {
214
+ case "ADD_NODE": {
215
+ const { value, parentId, id: newNodeId } = action;
216
+ const newNode = {
217
+ id: newNodeId,
218
+ value,
219
+ children: [],
220
+ categories: new Set(action.categories)
221
+ };
222
+ try {
223
+ return addNode(state, newNode, parentId);
224
+ } catch (error) {
225
+ console.error(`Error while adding node with id ${newNodeId}: ${error}`);
226
+ return state;
227
+ }
228
+ }
229
+ case "REMOVE_NODE":
230
+ return removeNode(state, action.id);
231
+ default:
232
+ return state;
233
+ }
234
+ }
235
+ var useTree = () => {
236
+ const [tree, dispatch] = (0, import_react2.useReducer)(treeReducer, []);
237
+ const addElement = (0, import_react2.useCallback)(
238
+ (value, categories, parentId) => {
239
+ const newNodeId = (0, import_shared.randomId)();
240
+ dispatch({
241
+ type: "ADD_NODE",
242
+ value,
243
+ parentId,
244
+ id: newNodeId,
245
+ categories
246
+ });
247
+ return newNodeId;
248
+ },
249
+ []
250
+ );
251
+ const removeElement = (0, import_react2.useCallback)((id) => {
252
+ dispatch({ type: "REMOVE_NODE", id });
253
+ }, []);
254
+ const printTree = (0, import_react2.useCallback)(
255
+ (categories) => {
256
+ const categoriesSet = new Set(categories);
257
+ let output = "";
258
+ tree.forEach((node, index) => {
259
+ if (!setsHaveIntersection(categoriesSet, node.categories)) {
260
+ return;
261
+ }
262
+ if (index !== 0) {
263
+ output += "\n";
264
+ }
265
+ output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
266
+ });
267
+ return output;
268
+ },
269
+ [tree]
270
+ );
271
+ return { tree, addElement, printTree, removeElement };
272
+ };
273
+ var use_tree_default = useTree;
274
+ function setsHaveIntersection(setA, setB) {
275
+ const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
276
+ for (let item of smallerSet) {
277
+ if (largerSet.has(item)) {
278
+ return true;
279
+ }
280
+ }
281
+ return false;
282
+ }
283
+
284
+ // src/components/copilot-provider/copilotkit.tsx
285
+ var import_react_dom = require("react-dom");
286
+ var import_shared3 = require("@copilotkit/shared");
287
+
288
+ // src/hooks/use-flat-category-store.ts
289
+ var import_react3 = require("react");
290
+ var import_shared2 = require("@copilotkit/shared");
291
+ var useFlatCategoryStore = () => {
292
+ const [elements, dispatch] = (0, import_react3.useReducer)(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
293
+ const addElement = (0, import_react3.useCallback)((value, categories) => {
294
+ const newId = (0, import_shared2.randomId)();
295
+ dispatch({
296
+ type: "ADD_ELEMENT",
297
+ value,
298
+ id: newId,
299
+ categories
300
+ });
301
+ return newId;
302
+ }, []);
303
+ const removeElement = (0, import_react3.useCallback)((id) => {
304
+ dispatch({ type: "REMOVE_ELEMENT", id });
305
+ }, []);
306
+ const allElements = (0, import_react3.useCallback)(
307
+ (categories) => {
308
+ const categoriesSet = new Set(categories);
309
+ const result = [];
310
+ elements.forEach((element) => {
311
+ if (setsHaveIntersection2(categoriesSet, element.categories)) {
312
+ result.push(element.value);
313
+ }
314
+ });
315
+ return result;
316
+ },
317
+ [elements]
318
+ );
319
+ return { addElement, removeElement, allElements };
320
+ };
321
+ var use_flat_category_store_default = useFlatCategoryStore;
322
+ function flatCategoryStoreReducer(state, action) {
323
+ switch (action.type) {
324
+ case "ADD_ELEMENT": {
325
+ const { value, id, categories } = action;
326
+ const newElement = {
327
+ id,
328
+ value,
329
+ categories: new Set(categories)
330
+ };
331
+ const newState = new Map(state);
332
+ newState.set(id, newElement);
333
+ return newState;
334
+ }
335
+ case "REMOVE_ELEMENT": {
336
+ const newState = new Map(state);
337
+ newState.delete(action.id);
338
+ return newState;
339
+ }
340
+ default:
341
+ return state;
342
+ }
343
+ }
344
+ function setsHaveIntersection2(setA, setB) {
345
+ const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
346
+ for (let item of smallerSet) {
347
+ if (largerSet.has(item)) {
348
+ return true;
349
+ }
350
+ }
351
+ return false;
352
+ }
353
+
354
+ // src/components/copilot-provider/copilot-messages.tsx
355
+ var import_react5 = require("react");
356
+
357
+ // src/context/copilot-messages-context.tsx
358
+ var import_react4 = __toESM(require("react"));
359
+ var emptyCopilotContext2 = {
360
+ messages: [],
361
+ setMessages: () => []
362
+ };
363
+ var CopilotMessagesContext = import_react4.default.createContext(emptyCopilotContext2);
364
+
365
+ // src/components/copilot-provider/copilot-messages.tsx
366
+ var import_jsx_runtime = require("react/jsx-runtime");
367
+ function CopilotMessages(_a) {
368
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
369
+ const [messages, setMessages] = (0, import_react5.useState)([]);
370
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
371
+ CopilotMessagesContext.Provider,
372
+ {
373
+ value: {
374
+ messages,
375
+ setMessages
376
+ },
377
+ children
378
+ }
379
+ );
380
+ }
381
+
382
+ // src/components/toast/toast-provider.tsx
383
+ var import_react6 = require("react");
384
+
385
+ // src/components/toast/exclamation-mark-icon.tsx
386
+ var import_jsx_runtime2 = require("react/jsx-runtime");
387
+ var ExclamationMarkIcon = ({
388
+ className,
389
+ style
390
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
391
+ "svg",
392
+ {
393
+ xmlns: "http://www.w3.org/2000/svg",
394
+ width: "24",
395
+ height: "24",
396
+ viewBox: "0 0 24 24",
397
+ fill: "none",
398
+ stroke: "currentColor",
399
+ strokeWidth: "2",
400
+ strokeLinecap: "round",
401
+ strokeLinejoin: "round",
402
+ className: `lucide lucide-circle-alert ${className ? className : ""}`,
403
+ style,
404
+ children: [
405
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
406
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
407
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
408
+ ]
409
+ }
410
+ );
411
+
412
+ // src/components/toast/toast-provider.tsx
413
+ var import_jsx_runtime3 = require("react/jsx-runtime");
414
+ var ToastContext = (0, import_react6.createContext)(void 0);
415
+ function useToast() {
416
+ const context = (0, import_react6.useContext)(ToastContext);
417
+ if (!context) {
418
+ throw new Error("useToast must be used within a ToastProvider");
419
+ }
420
+ return context;
421
+ }
422
+ function ToastProvider({
423
+ enabled,
424
+ children
425
+ }) {
426
+ const [toasts, setToasts] = (0, import_react6.useState)([]);
427
+ const addToast = (0, import_react6.useCallback)((toast) => {
428
+ const id = Math.random().toString(36).substring(2, 9);
429
+ setToasts((currentToasts) => [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })]);
430
+ if (toast.duration) {
431
+ setTimeout(() => {
432
+ removeToast(id);
433
+ }, toast.duration);
434
+ }
435
+ }, []);
436
+ const addGraphQLErrorsToast = (0, import_react6.useCallback)((errors) => {
437
+ const errorsToRender = errors.map((error, idx) => {
438
+ var _a;
439
+ const message = error.message;
440
+ const code = (_a = error.extensions) == null ? void 0 : _a.code;
441
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
442
+ "div",
443
+ {
444
+ style: {
445
+ marginTop: idx === 0 ? 0 : 10,
446
+ marginBottom: 14
447
+ },
448
+ children: [
449
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
450
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
451
+ "div",
452
+ {
453
+ style: {
454
+ fontWeight: "600",
455
+ marginBottom: 4
456
+ },
457
+ children: [
458
+ "Copilot Cloud Error:",
459
+ " ",
460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
461
+ ]
462
+ }
463
+ ),
464
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
465
+ ]
466
+ },
467
+ idx
468
+ );
469
+ });
470
+ addToast({
471
+ type: "error",
472
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
473
+ "div",
474
+ {
475
+ style: {
476
+ fontSize: "13px",
477
+ maxWidth: "600px"
478
+ },
479
+ children: [
480
+ errorsToRender,
481
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This is a Copilot Cloud error, and it only displays during local development." })
482
+ ]
483
+ }
484
+ )
485
+ });
486
+ }, []);
487
+ const removeToast = (0, import_react6.useCallback)((id) => {
488
+ setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
489
+ }, []);
490
+ const value = {
491
+ toasts,
492
+ addToast,
493
+ addGraphQLErrorsToast,
494
+ removeToast,
495
+ enabled
496
+ };
497
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ToastContext.Provider, { value, children: [
498
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
499
+ "div",
500
+ {
501
+ style: {
502
+ position: "fixed",
503
+ bottom: "1rem",
504
+ left: "50%",
505
+ transform: "translateX(-50%)",
506
+ zIndex: 50,
507
+ display: "flex",
508
+ flexDirection: "column",
509
+ gap: "0.5rem"
510
+ },
511
+ children: [
512
+ toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
513
+ "button",
514
+ {
515
+ onClick: () => setToasts([]),
516
+ style: {
517
+ padding: "4px 8px",
518
+ fontSize: "12px",
519
+ cursor: "pointer",
520
+ background: "white",
521
+ border: "1px solid rgba(0,0,0,0.2)",
522
+ borderRadius: "4px"
523
+ },
524
+ children: "Close All"
525
+ }
526
+ ) }),
527
+ toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
528
+ Toast,
529
+ {
530
+ message: toast.message,
531
+ type: toast.type,
532
+ onClose: () => removeToast(toast.id)
533
+ },
534
+ toast.id
535
+ ))
536
+ ]
537
+ }
538
+ ),
539
+ children
540
+ ] });
541
+ }
542
+ function Toast({
543
+ message,
544
+ type = "info",
545
+ onClose
546
+ }) {
547
+ const bgColors = {
548
+ info: "#3b82f6",
549
+ success: "#22c55e",
550
+ warning: "#eab308",
551
+ error: "#ef4444"
552
+ };
553
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
554
+ "div",
555
+ {
556
+ style: {
557
+ backgroundColor: bgColors[type],
558
+ color: "white",
559
+ padding: "0.5rem 1rem",
560
+ borderRadius: "0.25rem",
561
+ boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
562
+ position: "relative",
563
+ minWidth: "200px"
564
+ },
565
+ children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
568
+ "button",
569
+ {
570
+ onClick: onClose,
571
+ style: {
572
+ position: "absolute",
573
+ top: "0",
574
+ right: "0",
575
+ background: "none",
576
+ border: "none",
577
+ color: "white",
578
+ cursor: "pointer",
579
+ padding: "0.5rem",
580
+ fontSize: "1rem"
581
+ },
582
+ children: "\u2715"
583
+ }
584
+ )
585
+ ]
586
+ }
587
+ );
588
+ }
589
+
590
+ // src/hooks/use-copilot-runtime-client.ts
591
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
592
+ var import_react7 = require("react");
593
+ var useCopilotRuntimeClient = (options) => {
594
+ const { addGraphQLErrorsToast } = useToast();
595
+ const runtimeClient = (0, import_react7.useMemo)(() => {
596
+ return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
597
+ handleGQLErrors: (error) => {
598
+ if (error.graphQLErrors.length) {
599
+ addGraphQLErrorsToast(error.graphQLErrors);
600
+ }
601
+ }
602
+ }));
603
+ }, [options, addGraphQLErrorsToast]);
604
+ return runtimeClient;
605
+ };
606
+
607
+ // src/utils/dev-console.ts
608
+ function shouldShowDevConsole(showDevConsole) {
609
+ if (typeof showDevConsole === "boolean") {
610
+ return showDevConsole;
611
+ }
612
+ return getHostname() === "localhost" || getHostname() === "127.0.0.1" || getHostname() === "0.0.0.0" || getHostname() === "::1";
613
+ }
614
+ function getHostname() {
615
+ if (typeof window !== "undefined" && window.location) {
616
+ return window.location.hostname;
617
+ }
618
+ return "";
619
+ }
620
+
621
+ // src/components/copilot-provider/copilotkit.tsx
622
+ var import_jsx_runtime4 = require("react/jsx-runtime");
623
+ function CopilotKit(_a) {
624
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
625
+ const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
626
+ const enabled = shouldShowDevConsole(showDevConsole);
627
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) });
628
+ }
629
+ function CopilotKitInternal(_a) {
630
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
631
+ if (!props.runtimeUrl && !props.publicApiKey) {
632
+ throw new Error(
633
+ "Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component."
634
+ );
635
+ }
636
+ const chatApiEndpoint = props.runtimeUrl || import_shared3.COPILOT_CLOUD_CHAT_URL;
637
+ const [actions, setActions] = (0, import_react8.useState)({});
638
+ const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react8.useState)({});
639
+ const chatComponentsCache = (0, import_react8.useRef)({
640
+ actions: {},
641
+ coAgentStateRenders: {}
642
+ });
643
+ const { addElement, removeElement, printTree } = use_tree_default();
644
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
645
+ const [chatInstructions, setChatInstructions] = (0, import_react8.useState)("");
646
+ const {
647
+ addElement: addDocument,
648
+ removeElement: removeDocument,
649
+ allElements: allDocuments
650
+ } = use_flat_category_store_default();
651
+ const setAction = (0, import_react8.useCallback)((id, action) => {
652
+ setActions((prevPoints) => {
653
+ return __spreadProps(__spreadValues({}, prevPoints), {
654
+ [id]: action
655
+ });
656
+ });
657
+ }, []);
658
+ const removeAction = (0, import_react8.useCallback)((id) => {
659
+ setActions((prevPoints) => {
660
+ const newPoints = __spreadValues({}, prevPoints);
661
+ delete newPoints[id];
662
+ return newPoints;
663
+ });
664
+ }, []);
665
+ const setCoAgentStateRender = (0, import_react8.useCallback)((id, stateRender) => {
666
+ setCoAgentStateRenders((prevPoints) => {
667
+ return __spreadProps(__spreadValues({}, prevPoints), {
668
+ [id]: stateRender
669
+ });
670
+ });
671
+ }, []);
672
+ const removeCoAgentStateRender = (0, import_react8.useCallback)((id) => {
673
+ setCoAgentStateRenders((prevPoints) => {
674
+ const newPoints = __spreadValues({}, prevPoints);
675
+ delete newPoints[id];
676
+ return newPoints;
677
+ });
678
+ }, []);
679
+ const getContextString = (0, import_react8.useCallback)(
680
+ (documents, categories) => {
681
+ const documentsString = documents.map((document) => {
682
+ return `${document.name} (${document.sourceApplication}):
683
+ ${document.getContents()}`;
684
+ }).join("\n\n");
685
+ const nonDocumentStrings = printTree(categories);
686
+ return `${documentsString}
687
+
688
+ ${nonDocumentStrings}`;
689
+ },
690
+ [printTree]
691
+ );
692
+ const addContext = (0, import_react8.useCallback)(
693
+ (context, parentId, categories = defaultCopilotContextCategories) => {
694
+ return addElement(context, categories, parentId);
695
+ },
696
+ [addElement]
697
+ );
698
+ const removeContext = (0, import_react8.useCallback)(
699
+ (id) => {
700
+ removeElement(id);
701
+ },
702
+ [removeElement]
703
+ );
704
+ const getFunctionCallHandler = (0, import_react8.useCallback)(
705
+ (customEntryPoints) => {
706
+ return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
707
+ },
708
+ [actions]
709
+ );
710
+ const getDocumentsContext = (0, import_react8.useCallback)(
711
+ (categories) => {
712
+ return allDocuments(categories);
713
+ },
714
+ [allDocuments]
715
+ );
716
+ const addDocumentContext = (0, import_react8.useCallback)(
717
+ (documentPointer, categories = defaultCopilotContextCategories) => {
718
+ return addDocument(documentPointer, categories);
719
+ },
720
+ [addDocument]
721
+ );
722
+ const removeDocumentContext = (0, import_react8.useCallback)(
723
+ (documentId) => {
724
+ removeDocument(documentId);
725
+ },
726
+ [removeDocument]
727
+ );
728
+ if (!props.publicApiKey) {
729
+ if (props.cloudRestrictToTopic) {
730
+ throw new Error(
731
+ "To use the cloudRestrictToTopic feature, please sign up at https://copilotkit.ai and provide a publicApiKey."
732
+ );
733
+ }
734
+ }
735
+ const copilotApiConfig = (0, import_react8.useMemo)(() => {
736
+ var _a2, _b2;
737
+ let cloud = void 0;
738
+ if (props.publicApiKey) {
739
+ cloud = {
740
+ guardrails: {
741
+ input: {
742
+ restrictToTopic: {
743
+ enabled: props.cloudRestrictToTopic ? true : false,
744
+ validTopics: ((_a2 = props.cloudRestrictToTopic) == null ? void 0 : _a2.validTopics) || [],
745
+ invalidTopics: ((_b2 = props.cloudRestrictToTopic) == null ? void 0 : _b2.invalidTopics) || []
746
+ }
747
+ }
748
+ }
749
+ };
750
+ }
751
+ return __spreadProps(__spreadValues({
752
+ publicApiKey: props.publicApiKey
753
+ }, cloud ? { cloud } : {}), {
754
+ chatApiEndpoint,
755
+ headers: props.headers || {},
756
+ properties: props.properties || {},
757
+ transcribeAudioUrl: props.transcribeAudioUrl,
758
+ textToSpeechUrl: props.textToSpeechUrl,
759
+ credentials: props.credentials
760
+ });
761
+ }, [
762
+ props.publicApiKey,
763
+ props.headers,
764
+ props.properties,
765
+ props.transcribeAudioUrl,
766
+ props.textToSpeechUrl,
767
+ props.credentials,
768
+ props.cloudRestrictToTopic
769
+ ]);
770
+ const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
771
+ const runtimeClient = useCopilotRuntimeClient({
772
+ url: copilotApiConfig.chatApiEndpoint,
773
+ publicApiKey: copilotApiConfig.publicApiKey,
774
+ headers,
775
+ credentials: copilotApiConfig.credentials
776
+ });
777
+ const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react8.useState)({});
778
+ const addChatSuggestionConfiguration = (id, suggestion) => {
779
+ setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
780
+ };
781
+ const removeChatSuggestionConfiguration = (id) => {
782
+ setChatSuggestionConfiguration((prev) => {
783
+ const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
784
+ return rest;
785
+ });
786
+ };
787
+ const [coagentStates, setCoagentStates] = (0, import_react8.useState)({});
788
+ const coagentStatesRef = (0, import_react8.useRef)({});
789
+ const setCoagentStatesWithRef = (0, import_react8.useCallback)(
790
+ (value) => {
791
+ const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
792
+ coagentStatesRef.current = newValue;
793
+ setCoagentStates((prev) => {
794
+ return newValue;
795
+ });
796
+ },
797
+ []
798
+ );
799
+ let initialAgentSession = null;
800
+ if (props.agent) {
801
+ initialAgentSession = {
802
+ agentName: props.agent
803
+ };
804
+ }
805
+ const [agentSession, setAgentSession] = (0, import_react8.useState)(initialAgentSession);
806
+ const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
807
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
808
+ CopilotContext.Provider,
809
+ {
810
+ value: {
811
+ actions,
812
+ chatComponentsCache,
813
+ getFunctionCallHandler,
814
+ setAction,
815
+ removeAction,
816
+ coAgentStateRenders,
817
+ setCoAgentStateRender,
818
+ removeCoAgentStateRender,
819
+ getContextString,
820
+ addContext,
821
+ removeContext,
822
+ getDocumentsContext,
823
+ addDocumentContext,
824
+ removeDocumentContext,
825
+ copilotApiConfig,
826
+ isLoading,
827
+ setIsLoading,
828
+ chatSuggestionConfiguration,
829
+ addChatSuggestionConfiguration,
830
+ removeChatSuggestionConfiguration,
831
+ chatInstructions,
832
+ setChatInstructions,
833
+ showDevConsole,
834
+ coagentStates,
835
+ setCoagentStates,
836
+ coagentStatesRef,
837
+ setCoagentStatesWithRef,
838
+ agentSession,
839
+ setAgentSession,
840
+ runtimeClient
841
+ },
842
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotMessages, { children })
843
+ }
844
+ );
845
+ }
846
+ var defaultCopilotContextCategories = ["global"];
847
+ function entryPointsToFunctionCallHandler(actions) {
848
+ return (_0) => __async(this, [_0], function* ({ messages, name, args }) {
849
+ let actionsByFunctionName = {};
850
+ for (let action2 of actions) {
851
+ actionsByFunctionName[action2.name] = action2;
852
+ }
853
+ const action = actionsByFunctionName[name];
854
+ let result = void 0;
855
+ if (action) {
856
+ yield new Promise((resolve, reject) => {
857
+ (0, import_react_dom.flushSync)(() => __async(this, null, function* () {
858
+ var _a;
859
+ try {
860
+ result = yield (_a = action.handler) == null ? void 0 : _a.call(action, args);
861
+ resolve();
862
+ } catch (error) {
863
+ reject(error);
864
+ }
865
+ }));
866
+ });
867
+ yield new Promise((resolve) => setTimeout(resolve, 20));
868
+ }
869
+ return result;
870
+ });
871
+ }
872
+ // Annotate the CommonJS export names for ESM import in node:
873
+ 0 && (module.exports = {
874
+ CopilotKit,
875
+ defaultCopilotContextCategories
876
+ });
877
+ //# sourceMappingURL=index.js.map