@copilotkit/react-core 1.5.1-next.2 → 1.5.1-next.4

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 +18 -0
  2. package/package.json +3 -3
  3. package/dist/chunk-22XKTBPF.mjs +0 -61
  4. package/dist/chunk-22XKTBPF.mjs.map +0 -1
  5. package/dist/chunk-2KT73RVG.mjs +0 -482
  6. package/dist/chunk-2KT73RVG.mjs.map +0 -1
  7. package/dist/chunk-3GQPEN4M.mjs +0 -160
  8. package/dist/chunk-3GQPEN4M.mjs.map +0 -1
  9. package/dist/chunk-5FHSUKQL.mjs +0 -70
  10. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  11. package/dist/chunk-6BQVZFNO.mjs +0 -35
  12. package/dist/chunk-6BQVZFNO.mjs.map +0 -1
  13. package/dist/chunk-6U3UH3KO.mjs +0 -140
  14. package/dist/chunk-6U3UH3KO.mjs.map +0 -1
  15. package/dist/chunk-DCTJZ742.mjs +0 -22
  16. package/dist/chunk-DCTJZ742.mjs.map +0 -1
  17. package/dist/chunk-EFZPSZWO.mjs +0 -1
  18. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  19. package/dist/chunk-EWKJMQOF.mjs +0 -107
  20. package/dist/chunk-EWKJMQOF.mjs.map +0 -1
  21. package/dist/chunk-FQ53HQYZ.mjs +0 -28
  22. package/dist/chunk-FQ53HQYZ.mjs.map +0 -1
  23. package/dist/chunk-HIUT2NLX.mjs +0 -23
  24. package/dist/chunk-HIUT2NLX.mjs.map +0 -1
  25. package/dist/chunk-LHKIIAUQ.mjs +0 -59
  26. package/dist/chunk-LHKIIAUQ.mjs.map +0 -1
  27. package/dist/chunk-LNI2Z45S.mjs +0 -242
  28. package/dist/chunk-LNI2Z45S.mjs.map +0 -1
  29. package/dist/chunk-LUGEI4YQ.mjs +0 -1
  30. package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
  31. package/dist/chunk-MLAS4QUR.mjs +0 -18
  32. package/dist/chunk-MLAS4QUR.mjs.map +0 -1
  33. package/dist/chunk-NR2BTA6Z.mjs +0 -1
  34. package/dist/chunk-NR2BTA6Z.mjs.map +0 -1
  35. package/dist/chunk-O7ARI5CV.mjs +0 -31
  36. package/dist/chunk-O7ARI5CV.mjs.map +0 -1
  37. package/dist/chunk-SKC7AJIV.mjs +0 -61
  38. package/dist/chunk-SKC7AJIV.mjs.map +0 -1
  39. package/dist/chunk-VGOFRULA.mjs +0 -401
  40. package/dist/chunk-VGOFRULA.mjs.map +0 -1
  41. package/dist/chunk-VNTDIJSG.mjs +0 -37
  42. package/dist/chunk-VNTDIJSG.mjs.map +0 -1
  43. package/dist/chunk-WXREY7UP.mjs +0 -87
  44. package/dist/chunk-WXREY7UP.mjs.map +0 -1
  45. package/dist/chunk-X36DNILG.mjs +0 -215
  46. package/dist/chunk-X36DNILG.mjs.map +0 -1
  47. package/dist/chunk-XERJQUHA.mjs +0 -31
  48. package/dist/chunk-XERJQUHA.mjs.map +0 -1
  49. package/dist/chunk-XOQMISG3.mjs +0 -120
  50. package/dist/chunk-XOQMISG3.mjs.map +0 -1
  51. package/dist/chunk-XXR4QFAQ.mjs +0 -29
  52. package/dist/chunk-XXR4QFAQ.mjs.map +0 -1
  53. package/dist/chunk-YPSGKPDA.mjs +0 -1
  54. package/dist/chunk-YPSGKPDA.mjs.map +0 -1
  55. package/dist/components/copilot-provider/copilot-messages.d.ts +0 -16
  56. package/dist/components/copilot-provider/copilot-messages.js +0 -80
  57. package/dist/components/copilot-provider/copilot-messages.js.map +0 -1
  58. package/dist/components/copilot-provider/copilot-messages.mjs +0 -9
  59. package/dist/components/copilot-provider/copilot-messages.mjs.map +0 -1
  60. package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -93
  61. package/dist/components/copilot-provider/copilotkit-props.js +0 -19
  62. package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
  63. package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
  64. package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
  65. package/dist/components/copilot-provider/copilotkit.d.ts +0 -18
  66. package/dist/components/copilot-provider/copilotkit.js +0 -990
  67. package/dist/components/copilot-provider/copilotkit.js.map +0 -1
  68. package/dist/components/copilot-provider/copilotkit.mjs +0 -22
  69. package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
  70. package/dist/components/copilot-provider/index.d.ts +0 -13
  71. package/dist/components/copilot-provider/index.js +0 -990
  72. package/dist/components/copilot-provider/index.js.map +0 -1
  73. package/dist/components/copilot-provider/index.mjs +0 -20
  74. package/dist/components/copilot-provider/index.mjs.map +0 -1
  75. package/dist/components/error-boundary/error-boundary.d.ts +0 -22
  76. package/dist/components/error-boundary/error-boundary.js +0 -183
  77. package/dist/components/error-boundary/error-boundary.js.map +0 -1
  78. package/dist/components/error-boundary/error-boundary.mjs +0 -12
  79. package/dist/components/error-boundary/error-boundary.mjs.map +0 -1
  80. package/dist/components/error-boundary/error-utils.d.ts +0 -11
  81. package/dist/components/error-boundary/error-utils.js +0 -177
  82. package/dist/components/error-boundary/error-utils.js.map +0 -1
  83. package/dist/components/error-boundary/error-utils.mjs +0 -13
  84. package/dist/components/error-boundary/error-utils.mjs.map +0 -1
  85. package/dist/components/index.d.ts +0 -13
  86. package/dist/components/index.js +0 -990
  87. package/dist/components/index.js.map +0 -1
  88. package/dist/components/index.mjs +0 -20
  89. package/dist/components/index.mjs.map +0 -1
  90. package/dist/components/toast/exclamation-mark-icon.d.ts +0 -9
  91. package/dist/components/toast/exclamation-mark-icon.js +0 -55
  92. package/dist/components/toast/exclamation-mark-icon.js.map +0 -1
  93. package/dist/components/toast/exclamation-mark-icon.mjs +0 -8
  94. package/dist/components/toast/exclamation-mark-icon.mjs.map +0 -1
  95. package/dist/components/toast/toast-provider.d.ts +0 -30
  96. package/dist/components/toast/toast-provider.js +0 -269
  97. package/dist/components/toast/toast-provider.js.map +0 -1
  98. package/dist/components/toast/toast-provider.mjs +0 -11
  99. package/dist/components/toast/toast-provider.mjs.map +0 -1
  100. package/dist/context/copilot-context.d.ts +0 -142
  101. package/dist/context/copilot-context.js +0 -138
  102. package/dist/context/copilot-context.js.map +0 -1
  103. package/dist/context/copilot-context.mjs +0 -10
  104. package/dist/context/copilot-context.mjs.map +0 -1
  105. package/dist/context/copilot-messages-context.d.ts +0 -15
  106. package/dist/context/copilot-messages-context.js +0 -57
  107. package/dist/context/copilot-messages-context.js.map +0 -1
  108. package/dist/context/copilot-messages-context.mjs +0 -10
  109. package/dist/context/copilot-messages-context.mjs.map +0 -1
  110. package/dist/context/index.d.ts +0 -11
  111. package/dist/context/index.js +0 -161
  112. package/dist/context/index.js.map +0 -1
  113. package/dist/context/index.mjs +0 -17
  114. package/dist/context/index.mjs.map +0 -1
  115. package/dist/hooks/index.d.ts +0 -21
  116. package/dist/hooks/index.js +0 -1303
  117. package/dist/hooks/index.js.map +0 -1
  118. package/dist/hooks/index.mjs +0 -56
  119. package/dist/hooks/index.mjs.map +0 -1
  120. package/dist/hooks/use-chat.d.ts +0 -124
  121. package/dist/hooks/use-chat.js +0 -608
  122. package/dist/hooks/use-chat.js.map +0 -1
  123. package/dist/hooks/use-chat.mjs +0 -12
  124. package/dist/hooks/use-chat.mjs.map +0 -1
  125. package/dist/hooks/use-coagent-state-render.d.ts +0 -60
  126. package/dist/hooks/use-coagent-state-render.js +0 -195
  127. package/dist/hooks/use-coagent-state-render.js.map +0 -1
  128. package/dist/hooks/use-coagent-state-render.mjs +0 -11
  129. package/dist/hooks/use-coagent-state-render.mjs.map +0 -1
  130. package/dist/hooks/use-coagent.d.ts +0 -199
  131. package/dist/hooks/use-coagent.js +0 -1064
  132. package/dist/hooks/use-coagent.js.map +0 -1
  133. package/dist/hooks/use-coagent.mjs +0 -29
  134. package/dist/hooks/use-coagent.mjs.map +0 -1
  135. package/dist/hooks/use-copilot-action.d.ts +0 -140
  136. package/dist/hooks/use-copilot-action.js +0 -369
  137. package/dist/hooks/use-copilot-action.js.map +0 -1
  138. package/dist/hooks/use-copilot-action.mjs +0 -11
  139. package/dist/hooks/use-copilot-action.mjs.map +0 -1
  140. package/dist/hooks/use-copilot-authenticated-action.d.ts +0 -8
  141. package/dist/hooks/use-copilot-authenticated-action.js +0 -418
  142. package/dist/hooks/use-copilot-authenticated-action.js.map +0 -1
  143. package/dist/hooks/use-copilot-authenticated-action.mjs +0 -12
  144. package/dist/hooks/use-copilot-authenticated-action.mjs.map +0 -1
  145. package/dist/hooks/use-copilot-chat.d.ts +0 -38
  146. package/dist/hooks/use-copilot-chat.js +0 -928
  147. package/dist/hooks/use-copilot-chat.js.map +0 -1
  148. package/dist/hooks/use-copilot-chat.mjs +0 -24
  149. package/dist/hooks/use-copilot-chat.mjs.map +0 -1
  150. package/dist/hooks/use-copilot-readable.d.ts +0 -33
  151. package/dist/hooks/use-copilot-readable.js +0 -158
  152. package/dist/hooks/use-copilot-readable.js.map +0 -1
  153. package/dist/hooks/use-copilot-readable.mjs +0 -9
  154. package/dist/hooks/use-copilot-readable.mjs.map +0 -1
  155. package/dist/hooks/use-copilot-runtime-client.d.ts +0 -5
  156. package/dist/hooks/use-copilot-runtime-client.js +0 -182
  157. package/dist/hooks/use-copilot-runtime-client.js.map +0 -1
  158. package/dist/hooks/use-copilot-runtime-client.mjs +0 -10
  159. package/dist/hooks/use-copilot-runtime-client.mjs.map +0 -1
  160. package/dist/hooks/use-flat-category-store.d.ts +0 -9
  161. package/dist/hooks/use-flat-category-store.js +0 -90
  162. package/dist/hooks/use-flat-category-store.js.map +0 -1
  163. package/dist/hooks/use-flat-category-store.mjs +0 -8
  164. package/dist/hooks/use-flat-category-store.mjs.map +0 -1
  165. package/dist/hooks/use-make-copilot-document-readable.d.ts +0 -12
  166. package/dist/hooks/use-make-copilot-document-readable.js +0 -153
  167. package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
  168. package/dist/hooks/use-make-copilot-document-readable.mjs +0 -9
  169. package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
  170. package/dist/hooks/use-tree.d.ts +0 -18
  171. package/dist/hooks/use-tree.js +0 -172
  172. package/dist/hooks/use-tree.js.map +0 -1
  173. package/dist/hooks/use-tree.mjs +0 -8
  174. package/dist/hooks/use-tree.mjs.map +0 -1
  175. package/dist/index.d.ts +0 -27
  176. package/dist/index.js +0 -2224
  177. package/dist/index.js.map +0 -1
  178. package/dist/index.mjs +0 -83
  179. package/dist/index.mjs.map +0 -1
  180. package/dist/lib/copilot-task.d.ts +0 -97
  181. package/dist/lib/copilot-task.js +0 -195
  182. package/dist/lib/copilot-task.js.map +0 -1
  183. package/dist/lib/copilot-task.mjs +0 -20
  184. package/dist/lib/copilot-task.mjs.map +0 -1
  185. package/dist/lib/index.d.ts +0 -11
  186. package/dist/lib/index.js +0 -197
  187. package/dist/lib/index.js.map +0 -1
  188. package/dist/lib/index.mjs +0 -21
  189. package/dist/lib/index.mjs.map +0 -1
  190. package/dist/types/chat-suggestion-configuration.d.ts +0 -22
  191. package/dist/types/chat-suggestion-configuration.js +0 -19
  192. package/dist/types/chat-suggestion-configuration.js.map +0 -1
  193. package/dist/types/chat-suggestion-configuration.mjs +0 -1
  194. package/dist/types/chat-suggestion-configuration.mjs.map +0 -1
  195. package/dist/types/coagent-action.d.ts +0 -29
  196. package/dist/types/coagent-action.js +0 -19
  197. package/dist/types/coagent-action.js.map +0 -1
  198. package/dist/types/coagent-action.mjs +0 -1
  199. package/dist/types/coagent-action.mjs.map +0 -1
  200. package/dist/types/coagent-state.d.ts +0 -11
  201. package/dist/types/coagent-state.js +0 -19
  202. package/dist/types/coagent-state.js.map +0 -1
  203. package/dist/types/coagent-state.mjs +0 -1
  204. package/dist/types/coagent-state.mjs.map +0 -1
  205. package/dist/types/document-pointer.d.ts +0 -9
  206. package/dist/types/document-pointer.js +0 -19
  207. package/dist/types/document-pointer.js.map +0 -1
  208. package/dist/types/document-pointer.mjs +0 -1
  209. package/dist/types/document-pointer.mjs.map +0 -1
  210. package/dist/types/frontend-action.d.ts +0 -126
  211. package/dist/types/frontend-action.js +0 -53
  212. package/dist/types/frontend-action.js.map +0 -1
  213. package/dist/types/frontend-action.mjs +0 -8
  214. package/dist/types/frontend-action.mjs.map +0 -1
  215. package/dist/types/index.d.ts +0 -7
  216. package/dist/types/index.js +0 -19
  217. package/dist/types/index.js.map +0 -1
  218. package/dist/types/index.mjs +0 -2
  219. package/dist/types/index.mjs.map +0 -1
  220. package/dist/types/system-message.d.ts +0 -3
  221. package/dist/types/system-message.js +0 -19
  222. package/dist/types/system-message.js.map +0 -1
  223. package/dist/types/system-message.mjs +0 -1
  224. package/dist/types/system-message.mjs.map +0 -1
  225. package/dist/utils/dev-console.d.ts +0 -3
  226. package/dist/utils/dev-console.js +0 -42
  227. package/dist/utils/dev-console.js.map +0 -1
  228. package/dist/utils/dev-console.mjs +0 -8
  229. package/dist/utils/dev-console.mjs.map +0 -1
  230. package/dist/utils/extract.d.ts +0 -43
  231. package/dist/utils/extract.js +0 -208
  232. package/dist/utils/extract.js.map +0 -1
  233. package/dist/utils/extract.mjs +0 -18
  234. package/dist/utils/extract.mjs.map +0 -1
  235. package/dist/utils/index.d.ts +0 -13
  236. package/dist/utils/index.js +0 -226
  237. package/dist/utils/index.js.map +0 -1
  238. package/dist/utils/index.mjs +0 -21
  239. package/dist/utils/index.mjs.map +0 -1
  240. package/dist/utils/utils.d.ts +0 -2
  241. package/dist/utils/utils.js +0 -19
  242. package/dist/utils/utils.js.map +0 -1
  243. package/dist/utils/utils.mjs +0 -1
  244. package/dist/utils/utils.mjs.map +0 -1
  245. package/dist/utils/utils.test.d.ts +0 -2
  246. package/dist/utils/utils.test.js +0 -9
  247. package/dist/utils/utils.test.js.map +0 -1
  248. package/dist/utils/utils.test.mjs +0 -7
  249. package/dist/utils/utils.test.mjs.map +0 -1
@@ -1,172 +0,0 @@
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-tree.ts
38
- var use_tree_exports = {};
39
- __export(use_tree_exports, {
40
- default: () => use_tree_default
41
- });
42
- module.exports = __toCommonJS(use_tree_exports);
43
- var import_shared = require("@copilotkit/shared");
44
- var import_react = require("react");
45
- var removeNode = (nodes, id) => {
46
- return nodes.reduce((result, node) => {
47
- if (node.id !== id) {
48
- const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
49
- result.push(newNode);
50
- }
51
- return result;
52
- }, []);
53
- };
54
- var addNode = (nodes, newNode, parentId) => {
55
- if (!parentId) {
56
- return [...nodes, newNode];
57
- }
58
- return nodes.map((node) => {
59
- if (node.id === parentId) {
60
- return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
61
- } else if (node.children.length) {
62
- return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
63
- }
64
- return node;
65
- });
66
- };
67
- var treeIndentationRepresentation = (index, indentLevel) => {
68
- if (indentLevel === 0) {
69
- return (index + 1).toString();
70
- } else if (indentLevel === 1) {
71
- return String.fromCharCode(65 + index);
72
- } else if (indentLevel === 2) {
73
- return String.fromCharCode(97 + index);
74
- } else {
75
- return "-";
76
- }
77
- };
78
- var printNode = (node, prefix = "", indentLevel = 0) => {
79
- const indent = " ".repeat(3).repeat(indentLevel);
80
- const prefixPlusIndentLength = prefix.length + indent.length;
81
- const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
82
- const valueLines = node.value.split("\n");
83
- const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
84
- const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
85
- let output = `${outputFirstLine}
86
- `;
87
- if (outputSubsequentLines) {
88
- output += `${outputSubsequentLines}
89
- `;
90
- }
91
- const childPrePrefix = " ".repeat(prefix.length);
92
- node.children.forEach(
93
- (child, index) => output += printNode(
94
- child,
95
- `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,
96
- indentLevel + 1
97
- )
98
- );
99
- return output;
100
- };
101
- function treeReducer(state, action) {
102
- switch (action.type) {
103
- case "ADD_NODE": {
104
- const { value, parentId, id: newNodeId } = action;
105
- const newNode = {
106
- id: newNodeId,
107
- value,
108
- children: [],
109
- categories: new Set(action.categories)
110
- };
111
- try {
112
- return addNode(state, newNode, parentId);
113
- } catch (error) {
114
- console.error(`Error while adding node with id ${newNodeId}: ${error}`);
115
- return state;
116
- }
117
- }
118
- case "REMOVE_NODE":
119
- return removeNode(state, action.id);
120
- default:
121
- return state;
122
- }
123
- }
124
- var useTree = () => {
125
- const [tree, dispatch] = (0, import_react.useReducer)(treeReducer, []);
126
- const addElement = (0, import_react.useCallback)(
127
- (value, categories, parentId) => {
128
- const newNodeId = (0, import_shared.randomId)();
129
- dispatch({
130
- type: "ADD_NODE",
131
- value,
132
- parentId,
133
- id: newNodeId,
134
- categories
135
- });
136
- return newNodeId;
137
- },
138
- []
139
- );
140
- const removeElement = (0, import_react.useCallback)((id) => {
141
- dispatch({ type: "REMOVE_NODE", id });
142
- }, []);
143
- const printTree = (0, import_react.useCallback)(
144
- (categories) => {
145
- const categoriesSet = new Set(categories);
146
- let output = "";
147
- tree.forEach((node, index) => {
148
- if (!setsHaveIntersection(categoriesSet, node.categories)) {
149
- return;
150
- }
151
- if (index !== 0) {
152
- output += "\n";
153
- }
154
- output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
155
- });
156
- return output;
157
- },
158
- [tree]
159
- );
160
- return { tree, addElement, printTree, removeElement };
161
- };
162
- var use_tree_default = useTree;
163
- function setsHaveIntersection(setA, setB) {
164
- const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
165
- for (let item of smallerSet) {
166
- if (largerSet.has(item)) {
167
- return true;
168
- }
169
- }
170
- return false;
171
- }
172
- //# sourceMappingURL=use-tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/use-tree.ts"],"sourcesContent":["import { randomId } from \"@copilotkit/shared\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type TreeNodeId = string;\n\nexport interface TreeNode {\n id: TreeNodeId;\n value: string;\n children: TreeNode[];\n parentId?: TreeNodeId;\n categories: Set<string>;\n}\n\nexport type Tree = TreeNode[];\n\nexport interface UseTreeReturn {\n tree: Tree;\n addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;\n printTree: (categories: string[]) => string;\n removeElement: (id: TreeNodeId) => void;\n}\n\nconst findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {\n for (const node of nodes) {\n if (node.id === id) {\n return node;\n }\n const result = findNode(node.children, id);\n if (result) {\n return result;\n }\n }\n return undefined;\n};\n\nconst removeNode = (nodes: Tree, id: TreeNodeId): Tree => {\n return nodes.reduce((result: Tree, node) => {\n if (node.id !== id) {\n const newNode = { ...node, children: removeNode(node.children, id) };\n result.push(newNode);\n }\n return result;\n }, []);\n};\n\nconst addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree => {\n if (!parentId) {\n return [...nodes, newNode];\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n return { ...node, children: [...node.children, newNode] };\n } else if (node.children.length) {\n return { ...node, children: addNode(node.children, newNode, parentId) };\n }\n return node;\n });\n};\n\nconst treeIndentationRepresentation = (index: number, indentLevel: number): string => {\n if (indentLevel === 0) {\n return (index + 1).toString();\n } else if (indentLevel === 1) {\n return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'\n } else if (indentLevel === 2) {\n return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'\n } else {\n return \"-\";\n }\n};\n\nconst printNode = (node: TreeNode, prefix = \"\", indentLevel = 0): string => {\n const indent = \" \".repeat(3).repeat(indentLevel);\n\n const prefixPlusIndentLength = prefix.length + indent.length;\n const subsequentLinesPrefix = \" \".repeat(prefixPlusIndentLength);\n\n const valueLines = node.value.split(\"\\n\");\n\n const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;\n const outputSubsequentLines = valueLines\n .slice(1)\n .map((line) => `${subsequentLinesPrefix}${line}`)\n .join(\"\\n\");\n\n let output = `${outputFirstLine}\\n`;\n if (outputSubsequentLines) {\n output += `${outputSubsequentLines}\\n`;\n }\n\n const childPrePrefix = \" \".repeat(prefix.length);\n\n node.children.forEach(\n (child, index) =>\n (output += printNode(\n child,\n `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,\n indentLevel + 1,\n )),\n );\n return output;\n};\n\n// Action types\ntype Action =\n | {\n type: \"ADD_NODE\";\n value: string;\n parentId?: string;\n id: string;\n categories: string[];\n }\n | { type: \"REMOVE_NODE\"; id: string };\n\n// Reducer function\nfunction treeReducer(state: Tree, action: Action): Tree {\n switch (action.type) {\n case \"ADD_NODE\": {\n const { value, parentId, id: newNodeId } = action;\n const newNode: TreeNode = {\n id: newNodeId,\n value,\n children: [],\n categories: new Set(action.categories),\n };\n\n try {\n return addNode(state, newNode, parentId);\n } catch (error) {\n console.error(`Error while adding node with id ${newNodeId}: ${error}`);\n return state;\n }\n }\n case \"REMOVE_NODE\":\n return removeNode(state, action.id);\n default:\n return state;\n }\n}\n\n// useTree hook\nconst useTree = (): UseTreeReturn => {\n const [tree, dispatch] = useReducer(treeReducer, []);\n\n const addElement = useCallback(\n (value: string, categories: string[], parentId?: string): TreeNodeId => {\n const newNodeId = randomId(); // Generate new ID outside of dispatch\n dispatch({\n type: \"ADD_NODE\",\n value,\n parentId,\n id: newNodeId,\n categories: categories,\n });\n return newNodeId; // Return the new ID\n },\n [],\n );\n\n const removeElement = useCallback((id: TreeNodeId): void => {\n dispatch({ type: \"REMOVE_NODE\", id });\n }, []);\n\n const printTree = useCallback(\n (categories: string[]): string => {\n const categoriesSet = new Set(categories);\n\n let output = \"\";\n tree.forEach((node, index) => {\n // if the node does not have any of the desired categories, continue to the next node\n if (!setsHaveIntersection(categoriesSet, node.categories)) {\n return;\n }\n\n // add a new line before each node except the first one\n if (index !== 0) {\n output += \"\\n\";\n }\n\n output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);\n });\n return output;\n },\n [tree],\n );\n\n return { tree, addElement, printTree, removeElement };\n};\n\nexport default useTree;\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;A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AA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,oBAAgB,0BAAY,CAAC,OAAyB;AAC1D,aAAS,EAAE,MAAM,eAAe,GAAG,CAAC;AAAA,EACtC,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAY;AAAA,IAChB,CAAC,eAAiC;AAChC,YAAM,gBAAgB,IAAI,IAAI,UAAU;AAExC,UAAI,SAAS;AACb,WAAK,QAAQ,CAAC,MAAM,UAAU;AAE5B,YAAI,CAAC,qBAAqB,eAAe,KAAK,UAAU,GAAG;AACzD;AAAA,QACF;AAGA,YAAI,UAAU,GAAG;AACf,oBAAU;AAAA,QACZ;AAEA,kBAAU,UAAU,MAAM,GAAG,8BAA8B,OAAO,CAAC,KAAK;AAAA,MAC1E,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO,EAAE,MAAM,YAAY,WAAW,cAAc;AACtD;AAEA,IAAO,mBAAQ;AAEf,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":[]}
@@ -1,8 +0,0 @@
1
- import {
2
- use_tree_default
3
- } from "../chunk-6U3UH3KO.mjs";
4
- import "../chunk-SKC7AJIV.mjs";
5
- export {
6
- use_tree_default as default
7
- };
8
- //# sourceMappingURL=use-tree.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- export { CopilotKit, defaultCopilotContextCategories } from './components/copilot-provider/copilotkit.js';
2
- export { CopilotKitProps } from './components/copilot-provider/copilotkit-props.js';
3
- export { CoagentInChatRenderFunction, CopilotApiConfig, CopilotContext, CopilotContextParams, useCopilotContext } from './context/copilot-context.js';
4
- export { CopilotMessagesContext, CopilotMessagesContextParams, useCopilotMessagesContext } from './context/copilot-messages-context.js';
5
- export { UseCopilotChatOptions, UseCopilotChatReturn, useCopilotChat } from './hooks/use-copilot-chat.js';
6
- export { useCopilotAction } from './hooks/use-copilot-action.js';
7
- export { useCoAgentStateRender } from './hooks/use-coagent-state-render.js';
8
- export { useMakeCopilotDocumentReadable } from './hooks/use-make-copilot-document-readable.js';
9
- export { UseChatHelpers } from './hooks/use-chat.js';
10
- export { useCopilotReadable } from './hooks/use-copilot-readable.js';
11
- export { HintFunction, runAgent, startAgent, stopAgent, useCoAgent } from './hooks/use-coagent.js';
12
- export { useCopilotRuntimeClient } from './hooks/use-copilot-runtime-client.js';
13
- export { useCopilotAuthenticatedAction } from './hooks/use-copilot-authenticated-action.js';
14
- export { DocumentPointer } from './types/document-pointer.js';
15
- export { SystemMessageFunction } from './types/system-message.js';
16
- export { ActionRenderProps, CatchAllActionRenderProps, RenderFunctionStatus } from './types/frontend-action.js';
17
- export { CopilotChatSuggestionConfiguration } from './types/chat-suggestion-configuration.js';
18
- export { CopilotTask, CopilotTaskConfig } from './lib/copilot-task.js';
19
- export { extract } from './utils/extract.js';
20
- export { shouldShowDevConsole } from './utils/dev-console.js';
21
- import 'react/jsx-runtime';
22
- import '@copilotkit/runtime-client-gql';
23
- import 'react';
24
- import '@copilotkit/shared';
25
- import './hooks/use-tree.js';
26
- import './types/coagent-action.js';
27
- import './types/coagent-state.js';