@copilotkit/react-core 1.5.8 → 1.5.10-next.0

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 (249) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/chunk-22XKTBPF.mjs +61 -0
  3. package/dist/chunk-22XKTBPF.mjs.map +1 -0
  4. package/dist/chunk-2KT73RVG.mjs +482 -0
  5. package/dist/chunk-2KT73RVG.mjs.map +1 -0
  6. package/dist/chunk-3GQPEN4M.mjs +160 -0
  7. package/dist/chunk-3GQPEN4M.mjs.map +1 -0
  8. package/dist/chunk-5FHSUKQL.mjs +70 -0
  9. package/dist/chunk-5FHSUKQL.mjs.map +1 -0
  10. package/dist/chunk-6BQVZFNO.mjs +35 -0
  11. package/dist/chunk-6BQVZFNO.mjs.map +1 -0
  12. package/dist/chunk-6U3UH3KO.mjs +140 -0
  13. package/dist/chunk-6U3UH3KO.mjs.map +1 -0
  14. package/dist/chunk-DCTJZ742.mjs +22 -0
  15. package/dist/chunk-DCTJZ742.mjs.map +1 -0
  16. package/dist/chunk-EFZPSZWO.mjs +1 -0
  17. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  18. package/dist/chunk-EWKJMQOF.mjs +107 -0
  19. package/dist/chunk-EWKJMQOF.mjs.map +1 -0
  20. package/dist/chunk-FQ53HQYZ.mjs +28 -0
  21. package/dist/chunk-FQ53HQYZ.mjs.map +1 -0
  22. package/dist/chunk-HIUT2NLX.mjs +23 -0
  23. package/dist/chunk-HIUT2NLX.mjs.map +1 -0
  24. package/dist/chunk-LHKIIAUQ.mjs +59 -0
  25. package/dist/chunk-LHKIIAUQ.mjs.map +1 -0
  26. package/dist/chunk-LNI2Z45S.mjs +242 -0
  27. package/dist/chunk-LNI2Z45S.mjs.map +1 -0
  28. package/dist/chunk-LUGEI4YQ.mjs +1 -0
  29. package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
  30. package/dist/chunk-MLAS4QUR.mjs +18 -0
  31. package/dist/chunk-MLAS4QUR.mjs.map +1 -0
  32. package/dist/chunk-NR2BTA6Z.mjs +1 -0
  33. package/dist/chunk-NR2BTA6Z.mjs.map +1 -0
  34. package/dist/chunk-O7ARI5CV.mjs +31 -0
  35. package/dist/chunk-O7ARI5CV.mjs.map +1 -0
  36. package/dist/chunk-SKC7AJIV.mjs +61 -0
  37. package/dist/chunk-SKC7AJIV.mjs.map +1 -0
  38. package/dist/chunk-VGOFRULA.mjs +401 -0
  39. package/dist/chunk-VGOFRULA.mjs.map +1 -0
  40. package/dist/chunk-VNTDIJSG.mjs +37 -0
  41. package/dist/chunk-VNTDIJSG.mjs.map +1 -0
  42. package/dist/chunk-WXREY7UP.mjs +87 -0
  43. package/dist/chunk-WXREY7UP.mjs.map +1 -0
  44. package/dist/chunk-X36DNILG.mjs +215 -0
  45. package/dist/chunk-X36DNILG.mjs.map +1 -0
  46. package/dist/chunk-XERJQUHA.mjs +31 -0
  47. package/dist/chunk-XERJQUHA.mjs.map +1 -0
  48. package/dist/chunk-XOQMISG3.mjs +120 -0
  49. package/dist/chunk-XOQMISG3.mjs.map +1 -0
  50. package/dist/chunk-XXR4QFAQ.mjs +29 -0
  51. package/dist/chunk-XXR4QFAQ.mjs.map +1 -0
  52. package/dist/chunk-YPSGKPDA.mjs +1 -0
  53. package/dist/chunk-YPSGKPDA.mjs.map +1 -0
  54. package/dist/components/copilot-provider/copilot-messages.d.ts +16 -0
  55. package/dist/components/copilot-provider/copilot-messages.js +80 -0
  56. package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
  57. package/dist/components/copilot-provider/copilot-messages.mjs +9 -0
  58. package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
  59. package/dist/components/copilot-provider/copilotkit-props.d.ts +93 -0
  60. package/dist/components/copilot-provider/copilotkit-props.js +19 -0
  61. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
  62. package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
  63. package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
  64. package/dist/components/copilot-provider/copilotkit.d.ts +18 -0
  65. package/dist/components/copilot-provider/copilotkit.js +990 -0
  66. package/dist/components/copilot-provider/copilotkit.js.map +1 -0
  67. package/dist/components/copilot-provider/copilotkit.mjs +22 -0
  68. package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
  69. package/dist/components/copilot-provider/index.d.ts +13 -0
  70. package/dist/components/copilot-provider/index.js +990 -0
  71. package/dist/components/copilot-provider/index.js.map +1 -0
  72. package/dist/components/copilot-provider/index.mjs +20 -0
  73. package/dist/components/copilot-provider/index.mjs.map +1 -0
  74. package/dist/components/error-boundary/error-boundary.d.ts +22 -0
  75. package/dist/components/error-boundary/error-boundary.js +183 -0
  76. package/dist/components/error-boundary/error-boundary.js.map +1 -0
  77. package/dist/components/error-boundary/error-boundary.mjs +12 -0
  78. package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
  79. package/dist/components/error-boundary/error-utils.d.ts +11 -0
  80. package/dist/components/error-boundary/error-utils.js +177 -0
  81. package/dist/components/error-boundary/error-utils.js.map +1 -0
  82. package/dist/components/error-boundary/error-utils.mjs +13 -0
  83. package/dist/components/error-boundary/error-utils.mjs.map +1 -0
  84. package/dist/components/index.d.ts +13 -0
  85. package/dist/components/index.js +990 -0
  86. package/dist/components/index.js.map +1 -0
  87. package/dist/components/index.mjs +20 -0
  88. package/dist/components/index.mjs.map +1 -0
  89. package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
  90. package/dist/components/toast/exclamation-mark-icon.js +55 -0
  91. package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
  92. package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
  93. package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
  94. package/dist/components/toast/toast-provider.d.ts +30 -0
  95. package/dist/components/toast/toast-provider.js +269 -0
  96. package/dist/components/toast/toast-provider.js.map +1 -0
  97. package/dist/components/toast/toast-provider.mjs +11 -0
  98. package/dist/components/toast/toast-provider.mjs.map +1 -0
  99. package/dist/context/copilot-context.d.ts +142 -0
  100. package/dist/context/copilot-context.js +138 -0
  101. package/dist/context/copilot-context.js.map +1 -0
  102. package/dist/context/copilot-context.mjs +10 -0
  103. package/dist/context/copilot-context.mjs.map +1 -0
  104. package/dist/context/copilot-messages-context.d.ts +15 -0
  105. package/dist/context/copilot-messages-context.js +57 -0
  106. package/dist/context/copilot-messages-context.js.map +1 -0
  107. package/dist/context/copilot-messages-context.mjs +10 -0
  108. package/dist/context/copilot-messages-context.mjs.map +1 -0
  109. package/dist/context/index.d.ts +11 -0
  110. package/dist/context/index.js +161 -0
  111. package/dist/context/index.js.map +1 -0
  112. package/dist/context/index.mjs +17 -0
  113. package/dist/context/index.mjs.map +1 -0
  114. package/dist/hooks/index.d.ts +21 -0
  115. package/dist/hooks/index.js +1303 -0
  116. package/dist/hooks/index.js.map +1 -0
  117. package/dist/hooks/index.mjs +56 -0
  118. package/dist/hooks/index.mjs.map +1 -0
  119. package/dist/hooks/use-chat.d.ts +124 -0
  120. package/dist/hooks/use-chat.js +608 -0
  121. package/dist/hooks/use-chat.js.map +1 -0
  122. package/dist/hooks/use-chat.mjs +12 -0
  123. package/dist/hooks/use-chat.mjs.map +1 -0
  124. package/dist/hooks/use-coagent-state-render.d.ts +60 -0
  125. package/dist/hooks/use-coagent-state-render.js +195 -0
  126. package/dist/hooks/use-coagent-state-render.js.map +1 -0
  127. package/dist/hooks/use-coagent-state-render.mjs +11 -0
  128. package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
  129. package/dist/hooks/use-coagent.d.ts +199 -0
  130. package/dist/hooks/use-coagent.js +1064 -0
  131. package/dist/hooks/use-coagent.js.map +1 -0
  132. package/dist/hooks/use-coagent.mjs +29 -0
  133. package/dist/hooks/use-coagent.mjs.map +1 -0
  134. package/dist/hooks/use-copilot-action.d.ts +140 -0
  135. package/dist/hooks/use-copilot-action.js +369 -0
  136. package/dist/hooks/use-copilot-action.js.map +1 -0
  137. package/dist/hooks/use-copilot-action.mjs +11 -0
  138. package/dist/hooks/use-copilot-action.mjs.map +1 -0
  139. package/dist/hooks/use-copilot-authenticated-action.d.ts +8 -0
  140. package/dist/hooks/use-copilot-authenticated-action.js +418 -0
  141. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -0
  142. package/dist/hooks/use-copilot-authenticated-action.mjs +12 -0
  143. package/dist/hooks/use-copilot-authenticated-action.mjs.map +1 -0
  144. package/dist/hooks/use-copilot-chat.d.ts +38 -0
  145. package/dist/hooks/use-copilot-chat.js +928 -0
  146. package/dist/hooks/use-copilot-chat.js.map +1 -0
  147. package/dist/hooks/use-copilot-chat.mjs +24 -0
  148. package/dist/hooks/use-copilot-chat.mjs.map +1 -0
  149. package/dist/hooks/use-copilot-readable.d.ts +33 -0
  150. package/dist/hooks/use-copilot-readable.js +158 -0
  151. package/dist/hooks/use-copilot-readable.js.map +1 -0
  152. package/dist/hooks/use-copilot-readable.mjs +9 -0
  153. package/dist/hooks/use-copilot-readable.mjs.map +1 -0
  154. package/dist/hooks/use-copilot-runtime-client.d.ts +5 -0
  155. package/dist/hooks/use-copilot-runtime-client.js +182 -0
  156. package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
  157. package/dist/hooks/use-copilot-runtime-client.mjs +10 -0
  158. package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
  159. package/dist/hooks/use-flat-category-store.d.ts +9 -0
  160. package/dist/hooks/use-flat-category-store.js +90 -0
  161. package/dist/hooks/use-flat-category-store.js.map +1 -0
  162. package/dist/hooks/use-flat-category-store.mjs +8 -0
  163. package/dist/hooks/use-flat-category-store.mjs.map +1 -0
  164. package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
  165. package/dist/hooks/use-make-copilot-document-readable.js +153 -0
  166. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
  167. package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
  168. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
  169. package/dist/hooks/use-tree.d.ts +18 -0
  170. package/dist/hooks/use-tree.js +172 -0
  171. package/dist/hooks/use-tree.js.map +1 -0
  172. package/dist/hooks/use-tree.mjs +8 -0
  173. package/dist/hooks/use-tree.mjs.map +1 -0
  174. package/dist/index.d.ts +27 -0
  175. package/dist/index.js +2224 -0
  176. package/dist/index.js.map +1 -0
  177. package/dist/index.mjs +83 -0
  178. package/dist/index.mjs.map +1 -0
  179. package/dist/lib/copilot-task.d.ts +97 -0
  180. package/dist/lib/copilot-task.js +195 -0
  181. package/dist/lib/copilot-task.js.map +1 -0
  182. package/dist/lib/copilot-task.mjs +20 -0
  183. package/dist/lib/copilot-task.mjs.map +1 -0
  184. package/dist/lib/index.d.ts +11 -0
  185. package/dist/lib/index.js +197 -0
  186. package/dist/lib/index.js.map +1 -0
  187. package/dist/lib/index.mjs +21 -0
  188. package/dist/lib/index.mjs.map +1 -0
  189. package/dist/types/chat-suggestion-configuration.d.ts +22 -0
  190. package/dist/types/chat-suggestion-configuration.js +19 -0
  191. package/dist/types/chat-suggestion-configuration.js.map +1 -0
  192. package/dist/types/chat-suggestion-configuration.mjs +1 -0
  193. package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
  194. package/dist/types/coagent-action.d.ts +29 -0
  195. package/dist/types/coagent-action.js +19 -0
  196. package/dist/types/coagent-action.js.map +1 -0
  197. package/dist/types/coagent-action.mjs +1 -0
  198. package/dist/types/coagent-action.mjs.map +1 -0
  199. package/dist/types/coagent-state.d.ts +11 -0
  200. package/dist/types/coagent-state.js +19 -0
  201. package/dist/types/coagent-state.js.map +1 -0
  202. package/dist/types/coagent-state.mjs +1 -0
  203. package/dist/types/coagent-state.mjs.map +1 -0
  204. package/dist/types/document-pointer.d.ts +9 -0
  205. package/dist/types/document-pointer.js +19 -0
  206. package/dist/types/document-pointer.js.map +1 -0
  207. package/dist/types/document-pointer.mjs +1 -0
  208. package/dist/types/document-pointer.mjs.map +1 -0
  209. package/dist/types/frontend-action.d.ts +126 -0
  210. package/dist/types/frontend-action.js +53 -0
  211. package/dist/types/frontend-action.js.map +1 -0
  212. package/dist/types/frontend-action.mjs +8 -0
  213. package/dist/types/frontend-action.mjs.map +1 -0
  214. package/dist/types/index.d.ts +7 -0
  215. package/dist/types/index.js +19 -0
  216. package/dist/types/index.js.map +1 -0
  217. package/dist/types/index.mjs +2 -0
  218. package/dist/types/index.mjs.map +1 -0
  219. package/dist/types/system-message.d.ts +3 -0
  220. package/dist/types/system-message.js +19 -0
  221. package/dist/types/system-message.js.map +1 -0
  222. package/dist/types/system-message.mjs +1 -0
  223. package/dist/types/system-message.mjs.map +1 -0
  224. package/dist/utils/dev-console.d.ts +3 -0
  225. package/dist/utils/dev-console.js +42 -0
  226. package/dist/utils/dev-console.js.map +1 -0
  227. package/dist/utils/dev-console.mjs +8 -0
  228. package/dist/utils/dev-console.mjs.map +1 -0
  229. package/dist/utils/extract.d.ts +43 -0
  230. package/dist/utils/extract.js +208 -0
  231. package/dist/utils/extract.js.map +1 -0
  232. package/dist/utils/extract.mjs +18 -0
  233. package/dist/utils/extract.mjs.map +1 -0
  234. package/dist/utils/index.d.ts +13 -0
  235. package/dist/utils/index.js +226 -0
  236. package/dist/utils/index.js.map +1 -0
  237. package/dist/utils/index.mjs +21 -0
  238. package/dist/utils/index.mjs.map +1 -0
  239. package/dist/utils/utils.d.ts +2 -0
  240. package/dist/utils/utils.js +19 -0
  241. package/dist/utils/utils.js.map +1 -0
  242. package/dist/utils/utils.mjs +1 -0
  243. package/dist/utils/utils.mjs.map +1 -0
  244. package/dist/utils/utils.test.d.ts +2 -0
  245. package/dist/utils/utils.test.js +9 -0
  246. package/dist/utils/utils.test.js.map +1 -0
  247. package/dist/utils/utils.test.mjs +7 -0
  248. package/dist/utils/utils.test.mjs.map +1 -0
  249. package/package.json +3 -3
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/hooks/use-copilot-runtime-client.ts
38
+ var use_copilot_runtime_client_exports = {};
39
+ __export(use_copilot_runtime_client_exports, {
40
+ useCopilotRuntimeClient: () => useCopilotRuntimeClient
41
+ });
42
+ module.exports = __toCommonJS(use_copilot_runtime_client_exports);
43
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
44
+
45
+ // src/components/toast/toast-provider.tsx
46
+ var import_react2 = require("react");
47
+
48
+ // src/components/error-boundary/error-utils.tsx
49
+ var import_react = require("react");
50
+
51
+ // src/components/toast/exclamation-mark-icon.tsx
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ var ExclamationMarkIcon = ({
54
+ className,
55
+ style
56
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
57
+ "svg",
58
+ {
59
+ xmlns: "http://www.w3.org/2000/svg",
60
+ width: "24",
61
+ height: "24",
62
+ viewBox: "0 0 24 24",
63
+ fill: "none",
64
+ stroke: "currentColor",
65
+ strokeWidth: "2",
66
+ strokeLinecap: "round",
67
+ strokeLinejoin: "round",
68
+ className: `lucide lucide-circle-alert ${className ? className : ""}`,
69
+ style,
70
+ children: [
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
73
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
74
+ ]
75
+ }
76
+ );
77
+
78
+ // src/components/error-boundary/error-utils.tsx
79
+ var import_jsx_runtime2 = require("react/jsx-runtime");
80
+ function ErrorToast({ errors }) {
81
+ const errorsToRender = errors.map((error, idx) => {
82
+ var _a, _b, _c;
83
+ const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
84
+ const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
85
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
86
+ "div",
87
+ {
88
+ style: {
89
+ marginTop: idx === 0 ? 0 : 10,
90
+ marginBottom: 14
91
+ },
92
+ children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
94
+ code && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
95
+ "div",
96
+ {
97
+ style: {
98
+ fontWeight: "600",
99
+ marginBottom: 4
100
+ },
101
+ children: [
102
+ "Copilot Cloud Error:",
103
+ " ",
104
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
105
+ ]
106
+ }
107
+ ),
108
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: message })
109
+ ]
110
+ },
111
+ idx
112
+ );
113
+ });
114
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
115
+ "div",
116
+ {
117
+ style: {
118
+ fontSize: "13px",
119
+ maxWidth: "600px"
120
+ },
121
+ children: [
122
+ errorsToRender,
123
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
124
+ ]
125
+ }
126
+ );
127
+ }
128
+ function useErrorToast() {
129
+ const { addToast } = useToast();
130
+ return (0, import_react.useCallback)(
131
+ (error) => {
132
+ const errorId = error.map((err) => {
133
+ var _a, _b;
134
+ const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
135
+ const stack = err.stack || "";
136
+ return btoa(message + stack).slice(0, 32);
137
+ }).join("|");
138
+ addToast({
139
+ type: "error",
140
+ id: errorId,
141
+ // Toast libraries typically dedupe by id
142
+ message: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorToast, { errors: error })
143
+ });
144
+ },
145
+ [addToast]
146
+ );
147
+ }
148
+
149
+ // src/components/toast/toast-provider.tsx
150
+ var import_jsx_runtime3 = require("react/jsx-runtime");
151
+ var ToastContext = (0, import_react2.createContext)(void 0);
152
+ function useToast() {
153
+ const context = (0, import_react2.useContext)(ToastContext);
154
+ if (!context) {
155
+ throw new Error("useToast must be used within a ToastProvider");
156
+ }
157
+ return context;
158
+ }
159
+
160
+ // src/hooks/use-copilot-runtime-client.ts
161
+ var import_react3 = require("react");
162
+ var useCopilotRuntimeClient = (options) => {
163
+ const { addGraphQLErrorsToast } = useToast();
164
+ const addErrorToast = useErrorToast();
165
+ const runtimeClient = (0, import_react3.useMemo)(() => {
166
+ return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
167
+ handleGQLErrors: (error) => {
168
+ if (error.graphQLErrors.length) {
169
+ addGraphQLErrorsToast(error.graphQLErrors);
170
+ } else {
171
+ addErrorToast([error]);
172
+ }
173
+ }
174
+ }));
175
+ }, [options, addGraphQLErrorsToast]);
176
+ return runtimeClient;
177
+ };
178
+ // Annotate the CommonJS export names for ESM import in node:
179
+ 0 && (module.exports = {
180
+ useCopilotRuntimeClient
181
+ });
182
+ //# sourceMappingURL=use-copilot-runtime-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-copilot-runtime-client.ts","../../src/components/toast/toast-provider.tsx","../../src/components/error-boundary/error-utils.tsx","../../src/components/toast/exclamation-mark-icon.tsx"],"sourcesContent":["import {\n CopilotRuntimeClient,\n CopilotRuntimeClientOptions,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useMemo } from \"react\";\nimport { useErrorToast } from \"../components/error-boundary/error-utils\";\n\nexport const useCopilotRuntimeClient = (options: CopilotRuntimeClientOptions) => {\n const { addGraphQLErrorsToast } = useToast();\n const addErrorToast = useErrorToast();\n\n const runtimeClient = useMemo(() => {\n return new CopilotRuntimeClient({\n ...options,\n handleGQLErrors: (error) => {\n if ((error as any).graphQLErrors.length) {\n addGraphQLErrorsToast((error as any).graphQLErrors as GraphQLError[]);\n } else {\n addErrorToast([error]);\n }\n },\n });\n }, [options, addGraphQLErrorsToast]);\n\n return runtimeClient;\n};\n","import { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { ErrorToast } from \"../error-boundary/error-utils\";\nimport { PartialBy } from \"@copilotkit/shared\";\n\ninterface Toast {\n id: string;\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n duration?: number;\n}\n\ninterface ToastContextValue {\n toasts: Toast[];\n addToast: (toast: PartialBy<Toast, \"id\">) => void;\n addGraphQLErrorsToast: (errors: GraphQLError[]) => void;\n removeToast: (id: string) => void;\n enabled: boolean;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport function useToast() {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"useToast must be used within a ToastProvider\");\n }\n return context;\n}\n\nexport function ToastProvider({\n enabled,\n children,\n}: {\n enabled: boolean;\n children: React.ReactNode;\n}) {\n const [toasts, setToasts] = useState<Toast[]>([]);\n const addToast = useCallback((toast: PartialBy<Toast, \"id\">) => {\n const id = toast.id ?? Math.random().toString(36).substring(2, 9);\n\n setToasts((currentToasts) => {\n if (currentToasts.find((toast) => toast.id === id)) return currentToasts;\n return [...currentToasts, { ...toast, id }];\n });\n\n if (toast.duration) {\n setTimeout(() => {\n removeToast(id);\n }, toast.duration);\n }\n }, []);\n\n const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {\n // We do not display these errors unless we are in dev mode.\n // if (!showDevConsole) {\n // return;\n // }\n\n addToast({\n type: \"error\",\n message: <ErrorToast errors={errors} />,\n });\n }, []);\n\n const removeToast = useCallback((id: string) => {\n setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const value = {\n toasts,\n addToast,\n addGraphQLErrorsToast,\n removeToast,\n enabled,\n };\n\n return (\n <ToastContext.Provider value={value}>\n <div\n style={{\n position: \"fixed\",\n bottom: \"1rem\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 50,\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.5rem\",\n }}\n >\n {toasts.length > 1 && (\n <div style={{ textAlign: \"right\" }}>\n <button\n onClick={() => setToasts([])}\n style={{\n padding: \"4px 8px\",\n fontSize: \"12px\",\n cursor: \"pointer\",\n background: \"white\",\n border: \"1px solid rgba(0,0,0,0.2)\",\n borderRadius: \"4px\",\n }}\n >\n Close All\n </button>\n </div>\n )}\n {toasts.map((toast) => (\n <Toast\n key={toast.id}\n message={toast.message}\n type={toast.type}\n onClose={() => removeToast(toast.id)}\n />\n ))}\n </div>\n {children}\n </ToastContext.Provider>\n );\n}\n\nfunction Toast({\n message,\n type = \"info\",\n onClose,\n}: {\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n onClose: () => void;\n}) {\n const bgColors = {\n info: \"#3b82f6\",\n success: \"#22c55e\",\n warning: \"#eab308\",\n error: \"#ef4444\",\n };\n\n return (\n <div\n style={{\n backgroundColor: bgColors[type],\n color: \"white\",\n padding: \"0.5rem 1.5rem\",\n borderRadius: \"0.25rem\",\n boxShadow: \"0 2px 4px rgba(0,0,0,0.1)\",\n position: \"relative\",\n minWidth: \"200px\",\n }}\n >\n <div>{message}</div>\n <button\n onClick={onClose}\n style={{\n position: \"absolute\",\n top: \"0\",\n right: \"0\",\n background: \"none\",\n border: \"none\",\n color: \"white\",\n cursor: \"pointer\",\n padding: \"0.5rem\",\n fontSize: \"1rem\",\n }}\n >\n ✕\n </button>\n </div>\n );\n}\n","import React, { useCallback, useEffect } from \"react\";\nimport { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../toast/toast-provider\";\nimport { ExclamationMarkIcon } from \"../toast/exclamation-mark-icon\";\n\nexport function ErrorToast({ errors }: { errors: (Error | GraphQLError)[] }) {\n const errorsToRender = errors.map((error, idx) => {\n const message =\n \"extensions\" in error\n ? (error.extensions?.originalError as undefined | { message?: string })?.message\n : error.message;\n const code = \"extensions\" in error ? (error.extensions?.code as string) : null;\n\n return (\n <div\n key={idx}\n style={{\n marginTop: idx === 0 ? 0 : 10,\n marginBottom: 14,\n }}\n >\n <ExclamationMarkIcon style={{ marginBottom: 4 }} />\n\n {code && (\n <div\n style={{\n fontWeight: \"600\",\n marginBottom: 4,\n }}\n >\n Copilot Cloud Error:{\" \"}\n <span style={{ fontFamily: \"monospace\", fontWeight: \"normal\" }}>{code}</span>\n </div>\n )}\n <div>{message}</div>\n </div>\n );\n });\n return (\n <div\n style={{\n fontSize: \"13px\",\n maxWidth: \"600px\",\n }}\n >\n {errorsToRender}\n <div style={{ fontSize: \"11px\", opacity: 0.75 }}>\n NOTE: This error only displays during local development.\n </div>\n </div>\n );\n}\n\nexport function useErrorToast() {\n const { addToast } = useToast();\n\n return useCallback(\n (error: (Error | GraphQLError)[]) => {\n const errorId = error\n .map((err) => {\n const message =\n \"extensions\" in err\n ? (err.extensions?.originalError as any)?.message || err.message\n : err.message;\n const stack = err.stack || \"\";\n return btoa(message + stack).slice(0, 32); // Create hash from message + stack\n })\n .join(\"|\");\n\n addToast({\n type: \"error\",\n id: errorId, // Toast libraries typically dedupe by id\n message: <ErrorToast errors={error} />,\n });\n },\n [addToast],\n );\n}\n\nexport function useAsyncCallback<T extends (...args: any[]) => Promise<any>>(\n callback: T,\n deps: Parameters<typeof useCallback>[1],\n) {\n const addErrorToast = useErrorToast();\n return useCallback(async (...args: Parameters<T>) => {\n try {\n return await callback(...args);\n } catch (error) {\n console.error(\"Error in async callback:\", error);\n // @ts-ignore\n addErrorToast([error]);\n throw error;\n }\n }, deps);\n}\n","import React from \"react\";\n\nexport const ExclamationMarkIcon = ({\n className,\n style,\n}: {\n className?: string;\n style?: React.CSSProperties;\n}) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`lucide lucide-circle-alert ${className ? className : \"\"}`}\n style={style}\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\" />\n <line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\" />\n </svg>\n);\n"],"mappings":"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","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_react"]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ useCopilotRuntimeClient
3
+ } from "../chunk-6BQVZFNO.mjs";
4
+ import "../chunk-LNI2Z45S.mjs";
5
+ import "../chunk-O7ARI5CV.mjs";
6
+ import "../chunk-SKC7AJIV.mjs";
7
+ export {
8
+ useCopilotRuntimeClient
9
+ };
10
+ //# sourceMappingURL=use-copilot-runtime-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,9 @@
1
+ type FlatCategoryStoreId = string;
2
+ interface UseFlatCategoryStoreReturn<T> {
3
+ addElement: (value: T, categories: string[]) => FlatCategoryStoreId;
4
+ removeElement: (id: FlatCategoryStoreId) => void;
5
+ allElements: (categories: string[]) => T[];
6
+ }
7
+ declare const useFlatCategoryStore: <T>() => UseFlatCategoryStoreReturn<T>;
8
+
9
+ export { FlatCategoryStoreId, UseFlatCategoryStoreReturn, useFlatCategoryStore as default };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/hooks/use-flat-category-store.ts
21
+ var use_flat_category_store_exports = {};
22
+ __export(use_flat_category_store_exports, {
23
+ default: () => use_flat_category_store_default
24
+ });
25
+ module.exports = __toCommonJS(use_flat_category_store_exports);
26
+ var import_react = require("react");
27
+ var import_shared = require("@copilotkit/shared");
28
+ var useFlatCategoryStore = () => {
29
+ const [elements, dispatch] = (0, import_react.useReducer)(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
30
+ const addElement = (0, import_react.useCallback)((value, categories) => {
31
+ const newId = (0, import_shared.randomId)();
32
+ dispatch({
33
+ type: "ADD_ELEMENT",
34
+ value,
35
+ id: newId,
36
+ categories
37
+ });
38
+ return newId;
39
+ }, []);
40
+ const removeElement = (0, import_react.useCallback)((id) => {
41
+ dispatch({ type: "REMOVE_ELEMENT", id });
42
+ }, []);
43
+ const allElements = (0, import_react.useCallback)(
44
+ (categories) => {
45
+ const categoriesSet = new Set(categories);
46
+ const result = [];
47
+ elements.forEach((element) => {
48
+ if (setsHaveIntersection(categoriesSet, element.categories)) {
49
+ result.push(element.value);
50
+ }
51
+ });
52
+ return result;
53
+ },
54
+ [elements]
55
+ );
56
+ return { addElement, removeElement, allElements };
57
+ };
58
+ var use_flat_category_store_default = useFlatCategoryStore;
59
+ function flatCategoryStoreReducer(state, action) {
60
+ switch (action.type) {
61
+ case "ADD_ELEMENT": {
62
+ const { value, id, categories } = action;
63
+ const newElement = {
64
+ id,
65
+ value,
66
+ categories: new Set(categories)
67
+ };
68
+ const newState = new Map(state);
69
+ newState.set(id, newElement);
70
+ return newState;
71
+ }
72
+ case "REMOVE_ELEMENT": {
73
+ const newState = new Map(state);
74
+ newState.delete(action.id);
75
+ return newState;
76
+ }
77
+ default:
78
+ return state;
79
+ }
80
+ }
81
+ function setsHaveIntersection(setA, setB) {
82
+ const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
83
+ for (let item of smallerSet) {
84
+ if (largerSet.has(item)) {
85
+ return true;
86
+ }
87
+ }
88
+ return false;
89
+ }
90
+ //# sourceMappingURL=use-flat-category-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-flat-category-store.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { randomId } from \"@copilotkit/shared\";\n\nexport type FlatCategoryStoreId = string;\n\nexport interface UseFlatCategoryStoreReturn<T> {\n addElement: (value: T, categories: string[]) => FlatCategoryStoreId;\n removeElement: (id: FlatCategoryStoreId) => void;\n allElements: (categories: string[]) => T[];\n}\n\ninterface FlatCategoryStoreElement<T> {\n id: FlatCategoryStoreId;\n value: T;\n categories: Set<string>;\n}\n\nconst useFlatCategoryStore = <T>(): UseFlatCategoryStoreReturn<T> => {\n const [elements, dispatch] = useReducer<\n React.Reducer<Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>, Action<T>>\n >(flatCategoryStoreReducer, new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>());\n\n const addElement = useCallback((value: T, categories: string[]): FlatCategoryStoreId => {\n const newId = randomId();\n dispatch({\n type: \"ADD_ELEMENT\",\n value,\n id: newId,\n categories,\n });\n return newId;\n }, []);\n\n const removeElement = useCallback((id: FlatCategoryStoreId): void => {\n dispatch({ type: \"REMOVE_ELEMENT\", id });\n }, []);\n\n const allElements = useCallback(\n (categories: string[]): T[] => {\n const categoriesSet = new Set(categories);\n const result: T[] = [];\n elements.forEach((element) => {\n if (setsHaveIntersection(categoriesSet, element.categories)) {\n result.push(element.value);\n }\n });\n return result;\n },\n [elements],\n );\n\n return { addElement, removeElement, allElements };\n};\n\nexport default useFlatCategoryStore;\n\n// Action types\ntype Action<T> =\n | {\n type: \"ADD_ELEMENT\";\n value: T;\n id: FlatCategoryStoreId;\n categories: string[];\n }\n | { type: \"REMOVE_ELEMENT\"; id: FlatCategoryStoreId };\n\n// Reducer\nfunction flatCategoryStoreReducer<T>(\n state: Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>,\n action: Action<T>,\n): Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>> {\n switch (action.type) {\n case \"ADD_ELEMENT\": {\n const { value, id, categories } = action;\n const newElement: FlatCategoryStoreElement<T> = {\n id,\n value,\n categories: new Set(categories),\n };\n const newState = new Map(state);\n newState.set(id, newElement);\n return newState;\n }\n case \"REMOVE_ELEMENT\": {\n const newState = new Map(state);\n newState.delete(action.id);\n return newState;\n }\n default:\n return state;\n }\n}\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwC;AACxC,oBAAyB;AAgBzB,IAAM,uBAAuB,MAAwC;AACnE,QAAM,CAAC,UAAU,QAAQ,QAAI,yBAE3B,0BAA0B,oBAAI,IAAsD,CAAC;AAEvF,QAAM,iBAAa,0BAAY,CAAC,OAAU,eAA8C;AACtF,UAAM,YAAQ,wBAAS;AACvB,aAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,MACA,IAAI;AAAA,MACJ;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAgB,0BAAY,CAAC,OAAkC;AACnE,aAAS,EAAE,MAAM,kBAAkB,GAAG,CAAC;AAAA,EACzC,GAAG,CAAC,CAAC;AAEL,QAAM,kBAAc;AAAA,IAClB,CAAC,eAA8B;AAC7B,YAAM,gBAAgB,IAAI,IAAI,UAAU;AACxC,YAAM,SAAc,CAAC;AACrB,eAAS,QAAQ,CAAC,YAAY;AAC5B,YAAI,qBAAqB,eAAe,QAAQ,UAAU,GAAG;AAC3D,iBAAO,KAAK,QAAQ,KAAK;AAAA,QAC3B;AAAA,MACF,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,YAAY,eAAe,YAAY;AAClD;AAEA,IAAO,kCAAQ;AAaf,SAAS,yBACP,OACA,QACuD;AACvD,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,eAAe;AAClB,YAAM,EAAE,OAAO,IAAI,WAAW,IAAI;AAClC,YAAM,aAA0C;AAAA,QAC9C;AAAA,QACA;AAAA,QACA,YAAY,IAAI,IAAI,UAAU;AAAA,MAChC;AACA,YAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,eAAS,IAAI,IAAI,UAAU;AAC3B,aAAO;AAAA,IACT;AAAA,IACA,KAAK,kBAAkB;AACrB,YAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,eAAS,OAAO,OAAO,EAAE;AACzB,aAAO;AAAA,IACT;AAAA,IACA;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,qBAAwB,MAAc,MAAuB;AACpE,QAAM,CAAC,YAAY,SAAS,IAAI,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;AAEnF,WAAS,QAAQ,YAAY;AAC3B,QAAI,UAAU,IAAI,IAAI,GAAG;AACvB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ use_flat_category_store_default
3
+ } from "../chunk-5FHSUKQL.mjs";
4
+ import "../chunk-SKC7AJIV.mjs";
5
+ export {
6
+ use_flat_category_store_default as default
7
+ };
8
+ //# sourceMappingURL=use-flat-category-store.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,12 @@
1
+ import { DocumentPointer } from '../types/document-pointer.js';
2
+
3
+ /**
4
+ * Makes a document readable by Copilot.
5
+ * @param document The document to make readable.
6
+ * @param categories The categories to associate with the document.
7
+ * @param dependencies The dependencies to use for the effect.
8
+ * @returns The id of the document.
9
+ */
10
+ declare function useMakeCopilotDocumentReadable(document: DocumentPointer, categories?: string[], dependencies?: any[]): string | undefined;
11
+
12
+ export { useMakeCopilotDocumentReadable };
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
49
+
50
+ // src/hooks/use-make-copilot-document-readable.ts
51
+ var use_make_copilot_document_readable_exports = {};
52
+ __export(use_make_copilot_document_readable_exports, {
53
+ useMakeCopilotDocumentReadable: () => useMakeCopilotDocumentReadable
54
+ });
55
+ module.exports = __toCommonJS(use_make_copilot_document_readable_exports);
56
+ var import_react2 = require("react");
57
+
58
+ // src/context/copilot-context.tsx
59
+ var import_react = __toESM(require("react"));
60
+ var emptyCopilotContext = {
61
+ actions: {},
62
+ setAction: () => {
63
+ },
64
+ removeAction: () => {
65
+ },
66
+ coAgentStateRenders: {},
67
+ setCoAgentStateRender: () => {
68
+ },
69
+ removeCoAgentStateRender: () => {
70
+ },
71
+ chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },
72
+ getContextString: (documents, categories) => returnAndThrowInDebug(""),
73
+ addContext: () => "",
74
+ removeContext: () => {
75
+ },
76
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
77
+ })),
78
+ isLoading: false,
79
+ setIsLoading: () => returnAndThrowInDebug(false),
80
+ chatInstructions: "",
81
+ setChatInstructions: () => returnAndThrowInDebug(""),
82
+ getDocumentsContext: (categories) => returnAndThrowInDebug([]),
83
+ addDocumentContext: () => returnAndThrowInDebug(""),
84
+ removeDocumentContext: () => {
85
+ },
86
+ runtimeClient: {},
87
+ copilotApiConfig: new class {
88
+ get chatApiEndpoint() {
89
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
90
+ }
91
+ get headers() {
92
+ return {};
93
+ }
94
+ get body() {
95
+ return {};
96
+ }
97
+ }(),
98
+ chatSuggestionConfiguration: {},
99
+ addChatSuggestionConfiguration: () => {
100
+ },
101
+ removeChatSuggestionConfiguration: () => {
102
+ },
103
+ showDevConsole: "auto",
104
+ coagentStates: {},
105
+ setCoagentStates: () => {
106
+ },
107
+ coagentStatesRef: { current: {} },
108
+ setCoagentStatesWithRef: () => {
109
+ },
110
+ agentSession: null,
111
+ setAgentSession: () => {
112
+ },
113
+ forwardedParameters: {},
114
+ agentLock: null,
115
+ threadId: null,
116
+ setThreadId: () => {
117
+ },
118
+ runId: null,
119
+ setRunId: () => {
120
+ },
121
+ chatAbortControllerRef: { current: null },
122
+ availableAgents: []
123
+ };
124
+ var CopilotContext = import_react.default.createContext(emptyCopilotContext);
125
+ function useCopilotContext() {
126
+ const context = import_react.default.useContext(CopilotContext);
127
+ if (context === emptyCopilotContext) {
128
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
129
+ }
130
+ return context;
131
+ }
132
+ function returnAndThrowInDebug(_value) {
133
+ throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
134
+ }
135
+
136
+ // src/hooks/use-make-copilot-document-readable.ts
137
+ function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
138
+ const { addDocumentContext, removeDocumentContext } = useCopilotContext();
139
+ const idRef = (0, import_react2.useRef)();
140
+ (0, import_react2.useEffect)(() => {
141
+ const id = addDocumentContext(document, categories);
142
+ idRef.current = id;
143
+ return () => {
144
+ removeDocumentContext(id);
145
+ };
146
+ }, [addDocumentContext, removeDocumentContext, ...dependencies]);
147
+ return idRef.current;
148
+ }
149
+ // Annotate the CommonJS export names for ESM import in node:
150
+ 0 && (module.exports = {
151
+ useMakeCopilotDocumentReadable
152
+ });
153
+ //# sourceMappingURL=use-make-copilot-document-readable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useCopilotContext();\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n","import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { CopilotRuntimeClient, ForwardedParametersInput } from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n}\n\nexport type InChatRenderFunction = (\n props: ActionRenderProps<any> | CatchAllActionRenderProps<any>,\n) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string | null;\n setThreadId: React.Dispatch<React.SetStateAction<string | null>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates?: Record<ActionName, AuthState>;\n setAuthStates?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: null,\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAkC;;;ACMlC,mBAAkB;AA+LlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,WAAW;AAAA,EACX,cAAc,MAAM,sBAAsB,KAAK;AAAA,EAE/C,kBAAkB;AAAA,EAClB,qBAAqB,MAAM,sBAAsB,EAAE;AAAA,EAEnD,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,eAAe,CAAC;AAAA,EAEhB,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IAEA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AAAA,EAEH,6BAA6B,CAAC;AAAA,EAC9B,gCAAgC,MAAM;AAAA,EAAC;AAAA,EACvC,mCAAmC,MAAM;AAAA,EAAC;AAAA,EAC1C,gBAAgB;AAAA,EAChB,eAAe,CAAC;AAAA,EAChB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,kBAAkB,EAAE,SAAS,CAAC,EAAE;AAAA,EAChC,yBAAyB,MAAM;AAAA,EAAC;AAAA,EAChC,cAAc;AAAA,EACd,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,qBAAqB,CAAC;AAAA,EACtB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,OAAO;AAAA,EACP,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,wBAAwB,EAAE,SAAS,KAAK;AAAA,EACxC,iBAAiB,CAAC;AACpB;AAEO,IAAM,iBAAiB,aAAAC,QAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,aAAAA,QAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,QAAc;AAC9C,QAAM,IAAI,MAAM,uEAAuE;AACzF;;;ADnQO,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,kBAAkB;AACxE,QAAM,YAAQ,sBAAe;AAE7B,+BAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf;","names":["import_react","React"]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ useMakeCopilotDocumentReadable
3
+ } from "../chunk-HIUT2NLX.mjs";
4
+ import "../chunk-WXREY7UP.mjs";
5
+ import "../chunk-SKC7AJIV.mjs";
6
+ export {
7
+ useMakeCopilotDocumentReadable
8
+ };
9
+ //# sourceMappingURL=use-make-copilot-document-readable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,18 @@
1
+ type TreeNodeId = string;
2
+ interface TreeNode {
3
+ id: TreeNodeId;
4
+ value: string;
5
+ children: TreeNode[];
6
+ parentId?: TreeNodeId;
7
+ categories: Set<string>;
8
+ }
9
+ type Tree = TreeNode[];
10
+ interface UseTreeReturn {
11
+ tree: Tree;
12
+ addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;
13
+ printTree: (categories: string[]) => string;
14
+ removeElement: (id: TreeNodeId) => void;
15
+ }
16
+ declare const useTree: () => UseTreeReturn;
17
+
18
+ export { Tree, TreeNode, TreeNodeId, UseTreeReturn, useTree as default };