@copilotkit/react-core 0.25.0 → 0.36.0-mme-push-to-talk.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 (216) hide show
  1. package/.turbo/turbo-build.log +108 -189
  2. package/CHANGELOG.md +11 -0
  3. package/dist/{chunk-ZIR7KCEA.mjs → chunk-4GYWZE2P.mjs} +1 -2
  4. package/dist/{chunk-OWBDHSLH.mjs → chunk-5L4TYK4W.mjs} +8 -4
  5. package/dist/{chunk-MZ5UN3BY.mjs → chunk-6WFEP6DR.mjs} +1 -2
  6. package/dist/chunk-BJZMR7WC.mjs +0 -0
  7. package/dist/chunk-CROTHJUA.mjs +0 -0
  8. package/dist/chunk-CWK7RV25.mjs +0 -0
  9. package/dist/chunk-FT5DESSI.mjs +0 -0
  10. package/dist/{chunk-PC6FY3LD.mjs → chunk-FT5S7PNE.mjs} +1 -2
  11. package/dist/{chunk-O35YOIHC.mjs → chunk-GBUK745N.mjs} +1 -2
  12. package/dist/{chunk-MRXNTQOX.mjs → chunk-HIDP27A7.mjs} +0 -1
  13. package/dist/chunk-HNKVKTPX.mjs +0 -0
  14. package/dist/{chunk-YULKJPY3.mjs → chunk-K4KJZOIZ.mjs} +0 -1
  15. package/dist/chunk-KQTWUIAM.mjs +0 -0
  16. package/dist/{chunk-4NNFSZOY.mjs → chunk-LD2JLHT2.mjs} +2 -3
  17. package/dist/chunk-LOLJLZCX.mjs +0 -0
  18. package/dist/chunk-M4IVLZIH.mjs +0 -0
  19. package/dist/{chunk-VUY2K2DI.mjs → chunk-NWOJ4DVV.mjs} +1 -2
  20. package/dist/{chunk-CGT3AVYT.mjs → chunk-QBL56RUZ.mjs} +5 -4
  21. package/dist/{chunk-M6WULIFO.mjs → chunk-SIFJW3HD.mjs} +4 -5
  22. package/dist/{chunk-72BJ3A3S.mjs → chunk-UNX3EO3E.mjs} +1 -2
  23. package/dist/{chunk-6ARSX7BW.mjs → chunk-V5SRTWPE.mjs} +1 -2
  24. package/dist/chunk-VK5H6Y6B.mjs +121 -0
  25. package/dist/{chunk-6VF626RG.mjs → chunk-WNH25WIR.mjs} +4 -5
  26. package/dist/chunk-YGKURLXD.mjs +0 -0
  27. package/dist/chunk-YQ6KMLKO.mjs +0 -0
  28. package/dist/{chunk-KTUNGBJF.mjs → chunk-YQUWTA3R.mjs} +1 -2
  29. package/dist/{chunk-7LVVZQRG.mjs → chunk-ZYDU7WF7.mjs} +7 -6
  30. package/dist/components/copilot-provider/copilotkit-props.d.ts +18 -12
  31. package/dist/components/copilot-provider/copilotkit-props.js +0 -1
  32. package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
  33. package/dist/components/copilot-provider/copilotkit.d.ts +0 -20
  34. package/dist/components/copilot-provider/copilotkit.js +3 -2
  35. package/dist/components/copilot-provider/copilotkit.mjs +5 -6
  36. package/dist/components/copilot-provider/index.js +3 -2
  37. package/dist/components/copilot-provider/index.mjs +6 -7
  38. package/dist/components/index.js +3 -2
  39. package/dist/components/index.mjs +7 -8
  40. package/dist/context/copilot-context.d.ts +8 -0
  41. package/dist/context/copilot-context.js +0 -1
  42. package/dist/context/copilot-context.mjs +2 -3
  43. package/dist/context/index.js +0 -1
  44. package/dist/context/index.mjs +3 -4
  45. package/dist/hooks/index.js +4 -3
  46. package/dist/hooks/index.mjs +16 -17
  47. package/dist/hooks/use-chat.js +4 -3
  48. package/dist/hooks/use-chat.mjs +3 -4
  49. package/dist/hooks/use-copilot-action.js +0 -1
  50. package/dist/hooks/use-copilot-action.mjs +3 -4
  51. package/dist/hooks/use-copilot-chat.js +4 -3
  52. package/dist/hooks/use-copilot-chat.mjs +10 -11
  53. package/dist/hooks/use-copilot-readable.js +0 -1
  54. package/dist/hooks/use-copilot-readable.mjs +3 -4
  55. package/dist/hooks/use-flat-category-store.js +0 -1
  56. package/dist/hooks/use-flat-category-store.mjs +2 -3
  57. package/dist/hooks/use-make-copilot-actionable.js +0 -1
  58. package/dist/hooks/use-make-copilot-actionable.mjs +3 -4
  59. package/dist/hooks/use-make-copilot-document-readable.js +0 -1
  60. package/dist/hooks/use-make-copilot-document-readable.mjs +3 -4
  61. package/dist/hooks/use-make-copilot-readable.js +0 -1
  62. package/dist/hooks/use-make-copilot-readable.mjs +3 -4
  63. package/dist/hooks/use-tree.js +0 -1
  64. package/dist/hooks/use-tree.mjs +2 -3
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +122 -7
  67. package/dist/index.mjs +30 -26
  68. package/dist/lib/copilot-task.d.ts +97 -1
  69. package/dist/lib/copilot-task.js +9 -3
  70. package/dist/lib/copilot-task.mjs +9 -10
  71. package/dist/lib/index.js +9 -3
  72. package/dist/lib/index.mjs +10 -11
  73. package/dist/openai-assistants/hooks/index.js +0 -1
  74. package/dist/openai-assistants/hooks/index.mjs +12 -13
  75. package/dist/openai-assistants/hooks/use-assistants.js +0 -1
  76. package/dist/openai-assistants/hooks/use-assistants.mjs +3 -4
  77. package/dist/openai-assistants/hooks/use-copilot-chat-v2.js +0 -1
  78. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +11 -12
  79. package/dist/openai-assistants/index.js +0 -1
  80. package/dist/openai-assistants/index.mjs +13 -14
  81. package/dist/openai-assistants/utils/index.js +0 -1
  82. package/dist/openai-assistants/utils/index.mjs +3 -4
  83. package/dist/openai-assistants/utils/process-message-stream.js +0 -1
  84. package/dist/openai-assistants/utils/process-message-stream.mjs +2 -3
  85. package/dist/types/document-pointer.js +0 -1
  86. package/dist/types/document-pointer.mjs +0 -1
  87. package/dist/types/frontend-action.js +0 -1
  88. package/dist/types/frontend-action.mjs +0 -1
  89. package/dist/types/index.js +0 -1
  90. package/dist/types/index.mjs +1 -2
  91. package/dist/types/system-message.js +0 -1
  92. package/dist/types/system-message.mjs +0 -1
  93. package/dist/utils/extract.d.ts +36 -0
  94. package/dist/utils/extract.js +244 -0
  95. package/dist/utils/extract.mjs +14 -0
  96. package/dist/utils/fetch-chat-completion.d.ts +7 -1
  97. package/dist/utils/fetch-chat-completion.js +4 -3
  98. package/dist/utils/fetch-chat-completion.mjs +2 -3
  99. package/dist/utils/index.d.ts +8 -0
  100. package/dist/utils/index.js +266 -0
  101. package/dist/utils/index.mjs +22 -0
  102. package/dist/utils/utils.js +0 -1
  103. package/dist/utils/utils.mjs +0 -1
  104. package/dist/utils/utils.test.js +0 -1
  105. package/dist/utils/utils.test.mjs +0 -1
  106. package/package.json +4 -4
  107. package/src/components/copilot-provider/copilotkit-props.tsx +20 -12
  108. package/src/components/copilot-provider/copilotkit.tsx +40 -20
  109. package/src/context/copilot-context.tsx +11 -1
  110. package/src/hooks/use-chat.ts +2 -2
  111. package/src/hooks/use-copilot-readable.ts +94 -0
  112. package/src/index.tsx +1 -6
  113. package/src/lib/copilot-task.ts +97 -1
  114. package/src/utils/extract.ts +164 -0
  115. package/src/utils/fetch-chat-completion.ts +5 -1
  116. package/src/utils/index.ts +8 -0
  117. package/tsup.config.ts +1 -1
  118. package/typedoc.json +4 -0
  119. package/dist/chunk-4NNFSZOY.mjs.map +0 -1
  120. package/dist/chunk-6ARSX7BW.mjs.map +0 -1
  121. package/dist/chunk-6VF626RG.mjs.map +0 -1
  122. package/dist/chunk-72BJ3A3S.mjs.map +0 -1
  123. package/dist/chunk-7GFKOIO7.mjs +0 -1
  124. package/dist/chunk-7GFKOIO7.mjs.map +0 -1
  125. package/dist/chunk-7LVVZQRG.mjs.map +0 -1
  126. package/dist/chunk-BABVSMJR.mjs +0 -1
  127. package/dist/chunk-BABVSMJR.mjs.map +0 -1
  128. package/dist/chunk-CGT3AVYT.mjs.map +0 -1
  129. package/dist/chunk-EFZPSZWO.mjs +0 -1
  130. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  131. package/dist/chunk-EYKDJBDE.mjs +0 -1
  132. package/dist/chunk-EYKDJBDE.mjs.map +0 -1
  133. package/dist/chunk-FRAKUJWH.mjs +0 -1
  134. package/dist/chunk-FRAKUJWH.mjs.map +0 -1
  135. package/dist/chunk-JD7BAH7U.mjs +0 -1
  136. package/dist/chunk-JD7BAH7U.mjs.map +0 -1
  137. package/dist/chunk-KTUNGBJF.mjs.map +0 -1
  138. package/dist/chunk-LUGEI4YQ.mjs +0 -1
  139. package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
  140. package/dist/chunk-M6WULIFO.mjs.map +0 -1
  141. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  142. package/dist/chunk-MZ5UN3BY.mjs.map +0 -1
  143. package/dist/chunk-O35YOIHC.mjs.map +0 -1
  144. package/dist/chunk-OWBDHSLH.mjs.map +0 -1
  145. package/dist/chunk-PC6FY3LD.mjs.map +0 -1
  146. package/dist/chunk-SPCZTZCY.mjs +0 -1
  147. package/dist/chunk-SPCZTZCY.mjs.map +0 -1
  148. package/dist/chunk-VNRDQJXW.mjs +0 -1
  149. package/dist/chunk-VNRDQJXW.mjs.map +0 -1
  150. package/dist/chunk-VUY2K2DI.mjs.map +0 -1
  151. package/dist/chunk-YULKJPY3.mjs.map +0 -1
  152. package/dist/chunk-ZIR7KCEA.mjs.map +0 -1
  153. package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
  154. package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
  155. package/dist/components/copilot-provider/copilotkit.js.map +0 -1
  156. package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
  157. package/dist/components/copilot-provider/index.js.map +0 -1
  158. package/dist/components/copilot-provider/index.mjs.map +0 -1
  159. package/dist/components/index.js.map +0 -1
  160. package/dist/components/index.mjs.map +0 -1
  161. package/dist/context/copilot-context.js.map +0 -1
  162. package/dist/context/copilot-context.mjs.map +0 -1
  163. package/dist/context/index.js.map +0 -1
  164. package/dist/context/index.mjs.map +0 -1
  165. package/dist/hooks/index.js.map +0 -1
  166. package/dist/hooks/index.mjs.map +0 -1
  167. package/dist/hooks/use-chat.js.map +0 -1
  168. package/dist/hooks/use-chat.mjs.map +0 -1
  169. package/dist/hooks/use-copilot-action.js.map +0 -1
  170. package/dist/hooks/use-copilot-action.mjs.map +0 -1
  171. package/dist/hooks/use-copilot-chat.js.map +0 -1
  172. package/dist/hooks/use-copilot-chat.mjs.map +0 -1
  173. package/dist/hooks/use-copilot-readable.js.map +0 -1
  174. package/dist/hooks/use-copilot-readable.mjs.map +0 -1
  175. package/dist/hooks/use-flat-category-store.js.map +0 -1
  176. package/dist/hooks/use-flat-category-store.mjs.map +0 -1
  177. package/dist/hooks/use-make-copilot-actionable.js.map +0 -1
  178. package/dist/hooks/use-make-copilot-actionable.mjs.map +0 -1
  179. package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
  180. package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
  181. package/dist/hooks/use-make-copilot-readable.js.map +0 -1
  182. package/dist/hooks/use-make-copilot-readable.mjs.map +0 -1
  183. package/dist/hooks/use-tree.js.map +0 -1
  184. package/dist/hooks/use-tree.mjs.map +0 -1
  185. package/dist/index.js.map +0 -1
  186. package/dist/index.mjs.map +0 -1
  187. package/dist/lib/copilot-task.js.map +0 -1
  188. package/dist/lib/copilot-task.mjs.map +0 -1
  189. package/dist/lib/index.js.map +0 -1
  190. package/dist/lib/index.mjs.map +0 -1
  191. package/dist/openai-assistants/hooks/index.js.map +0 -1
  192. package/dist/openai-assistants/hooks/index.mjs.map +0 -1
  193. package/dist/openai-assistants/hooks/use-assistants.js.map +0 -1
  194. package/dist/openai-assistants/hooks/use-assistants.mjs.map +0 -1
  195. package/dist/openai-assistants/hooks/use-copilot-chat-v2.js.map +0 -1
  196. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +0 -1
  197. package/dist/openai-assistants/index.js.map +0 -1
  198. package/dist/openai-assistants/index.mjs.map +0 -1
  199. package/dist/openai-assistants/utils/index.js.map +0 -1
  200. package/dist/openai-assistants/utils/index.mjs.map +0 -1
  201. package/dist/openai-assistants/utils/process-message-stream.js.map +0 -1
  202. package/dist/openai-assistants/utils/process-message-stream.mjs.map +0 -1
  203. package/dist/types/document-pointer.js.map +0 -1
  204. package/dist/types/document-pointer.mjs.map +0 -1
  205. package/dist/types/frontend-action.js.map +0 -1
  206. package/dist/types/frontend-action.mjs.map +0 -1
  207. package/dist/types/index.js.map +0 -1
  208. package/dist/types/index.mjs.map +0 -1
  209. package/dist/types/system-message.js.map +0 -1
  210. package/dist/types/system-message.mjs.map +0 -1
  211. package/dist/utils/fetch-chat-completion.js.map +0 -1
  212. package/dist/utils/fetch-chat-completion.mjs.map +0 -1
  213. package/dist/utils/utils.js.map +0 -1
  214. package/dist/utils/utils.mjs.map +0 -1
  215. package/dist/utils/utils.test.js.map +0 -1
  216. package/dist/utils/utils.test.mjs.map +0 -1
@@ -1,15 +1,14 @@
1
1
  import {
2
2
  CopilotTask
3
- } from "../chunk-OWBDHSLH.mjs";
4
- import "../chunk-JD7BAH7U.mjs";
5
- import "../chunk-SPCZTZCY.mjs";
6
- import "../chunk-7LVVZQRG.mjs";
7
- import "../chunk-YULKJPY3.mjs";
8
- import "../chunk-VUY2K2DI.mjs";
9
- import "../chunk-CGT3AVYT.mjs";
10
- import "../chunk-O35YOIHC.mjs";
11
- import "../chunk-MRXNTQOX.mjs";
3
+ } from "../chunk-5L4TYK4W.mjs";
4
+ import "../chunk-BJZMR7WC.mjs";
5
+ import "../chunk-FT5DESSI.mjs";
6
+ import "../chunk-ZYDU7WF7.mjs";
7
+ import "../chunk-K4KJZOIZ.mjs";
8
+ import "../chunk-NWOJ4DVV.mjs";
9
+ import "../chunk-QBL56RUZ.mjs";
10
+ import "../chunk-GBUK745N.mjs";
11
+ import "../chunk-HIDP27A7.mjs";
12
12
  export {
13
13
  CopilotTask
14
14
  };
15
- //# sourceMappingURL=copilot-task.mjs.map
package/dist/lib/index.js CHANGED
@@ -75,7 +75,8 @@ function fetchChatCompletion(_0) {
75
75
  temperature,
76
76
  headers,
77
77
  body,
78
- signal
78
+ signal,
79
+ toolChoice
79
80
  }) {
80
81
  temperature || (temperature = 0.5);
81
82
  tools || (tools = []);
@@ -83,6 +84,7 @@ function fetchChatCompletion(_0) {
83
84
  const { content, role, name, function_call } = message;
84
85
  return { content, role, name, function_call };
85
86
  });
87
+ toolChoice || (toolChoice = "auto");
86
88
  const response = yield fetch(copilotConfig.chatApiEndpoint, {
87
89
  method: "POST",
88
90
  headers: __spreadValues(__spreadValues({
@@ -92,7 +94,7 @@ function fetchChatCompletion(_0) {
92
94
  model,
93
95
  messages: cleanedMessages,
94
96
  stream: true
95
- }, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice: "auto" } : {}), copilotConfig.body), copilotConfig.backendOnlyProps), excludeBackendOnlyProps(copilotConfig)), body ? __spreadValues({}, body) : {}), copilotConfig.cloud ? { cloud: copilotConfig.cloud } : {})),
97
+ }, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice: toolChoice } : {}), copilotConfig.body), copilotConfig.backendOnlyProps), excludeBackendOnlyProps(copilotConfig)), body ? __spreadValues({}, body) : {}), copilotConfig.cloud ? { cloud: copilotConfig.cloud } : {})),
96
98
  signal
97
99
  });
98
100
  return response;
@@ -130,6 +132,11 @@ var CopilotTask = class {
130
132
  this.includeCopilotReadable = config.includeCopilotReadable !== false;
131
133
  this.includeCopilotActions = config.includeCopilotActions !== false && config.includeCopilotActionable !== false;
132
134
  }
135
+ /**
136
+ * Run the task.
137
+ * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.
138
+ * @param data The data to use for the task.
139
+ */
133
140
  run(context, data) {
134
141
  return __async(this, null, function* () {
135
142
  const entryPoints = this.includeCopilotActions ? Object.assign({}, context.entryPoints) : {};
@@ -213,4 +220,3 @@ ${instructions}
213
220
  0 && (module.exports = {
214
221
  CopilotTask
215
222
  });
216
- //# sourceMappingURL=index.js.map
@@ -1,16 +1,15 @@
1
- import "../chunk-LUGEI4YQ.mjs";
1
+ import "../chunk-KQTWUIAM.mjs";
2
2
  import {
3
3
  CopilotTask
4
- } from "../chunk-OWBDHSLH.mjs";
5
- import "../chunk-JD7BAH7U.mjs";
6
- import "../chunk-SPCZTZCY.mjs";
7
- import "../chunk-7LVVZQRG.mjs";
8
- import "../chunk-YULKJPY3.mjs";
9
- import "../chunk-VUY2K2DI.mjs";
10
- import "../chunk-CGT3AVYT.mjs";
11
- import "../chunk-O35YOIHC.mjs";
12
- import "../chunk-MRXNTQOX.mjs";
4
+ } from "../chunk-5L4TYK4W.mjs";
5
+ import "../chunk-BJZMR7WC.mjs";
6
+ import "../chunk-FT5DESSI.mjs";
7
+ import "../chunk-ZYDU7WF7.mjs";
8
+ import "../chunk-K4KJZOIZ.mjs";
9
+ import "../chunk-NWOJ4DVV.mjs";
10
+ import "../chunk-QBL56RUZ.mjs";
11
+ import "../chunk-GBUK745N.mjs";
12
+ import "../chunk-HIDP27A7.mjs";
13
13
  export {
14
14
  CopilotTask
15
15
  };
16
- //# sourceMappingURL=index.mjs.map
@@ -265,4 +265,3 @@ If you would like to call a function, call it without saying anything else.
265
265
  0 && (module.exports = {
266
266
  useCopilotChatV2
267
267
  });
268
- //# sourceMappingURL=index.js.map
@@ -1,18 +1,17 @@
1
- import "../../chunk-BABVSMJR.mjs";
1
+ import "../../chunk-YQ6KMLKO.mjs";
2
2
  import {
3
3
  useCopilotChatV2
4
- } from "../../chunk-M6WULIFO.mjs";
5
- import "../../chunk-FRAKUJWH.mjs";
6
- import "../../chunk-MZ5UN3BY.mjs";
7
- import "../../chunk-VNRDQJXW.mjs";
8
- import "../../chunk-JD7BAH7U.mjs";
9
- import "../../chunk-SPCZTZCY.mjs";
10
- import "../../chunk-7LVVZQRG.mjs";
11
- import "../../chunk-YULKJPY3.mjs";
12
- import "../../chunk-VUY2K2DI.mjs";
13
- import "../../chunk-O35YOIHC.mjs";
14
- import "../../chunk-MRXNTQOX.mjs";
4
+ } from "../../chunk-SIFJW3HD.mjs";
5
+ import "../../chunk-YGKURLXD.mjs";
6
+ import "../../chunk-6WFEP6DR.mjs";
7
+ import "../../chunk-CWK7RV25.mjs";
8
+ import "../../chunk-BJZMR7WC.mjs";
9
+ import "../../chunk-FT5DESSI.mjs";
10
+ import "../../chunk-ZYDU7WF7.mjs";
11
+ import "../../chunk-K4KJZOIZ.mjs";
12
+ import "../../chunk-NWOJ4DVV.mjs";
13
+ import "../../chunk-GBUK745N.mjs";
14
+ import "../../chunk-HIDP27A7.mjs";
15
15
  export {
16
16
  useCopilotChatV2
17
17
  };
18
- //# sourceMappingURL=index.mjs.map
@@ -151,4 +151,3 @@ function experimental_useAssistant({
151
151
  0 && (module.exports = {
152
152
  experimental_useAssistant
153
153
  });
154
- //# sourceMappingURL=use-assistants.js.map
@@ -1,10 +1,10 @@
1
- import "../../chunk-FRAKUJWH.mjs";
1
+ import "../../chunk-YGKURLXD.mjs";
2
2
  import {
3
3
  processMessageStream
4
- } from "../../chunk-MZ5UN3BY.mjs";
4
+ } from "../../chunk-6WFEP6DR.mjs";
5
5
  import {
6
6
  __async
7
- } from "../../chunk-MRXNTQOX.mjs";
7
+ } from "../../chunk-HIDP27A7.mjs";
8
8
 
9
9
  // src/openai-assistants/hooks/use-assistants.ts
10
10
  import { useState } from "react";
@@ -89,4 +89,3 @@ function experimental_useAssistant({
89
89
  export {
90
90
  experimental_useAssistant
91
91
  };
92
- //# sourceMappingURL=use-assistants.mjs.map
@@ -265,4 +265,3 @@ If you would like to call a function, call it without saying anything else.
265
265
  defaultSystemMessage,
266
266
  useCopilotChatV2
267
267
  });
268
- //# sourceMappingURL=use-copilot-chat-v2.js.map
@@ -1,19 +1,18 @@
1
1
  import {
2
2
  defaultSystemMessage,
3
3
  useCopilotChatV2
4
- } from "../../chunk-M6WULIFO.mjs";
5
- import "../../chunk-FRAKUJWH.mjs";
6
- import "../../chunk-MZ5UN3BY.mjs";
7
- import "../../chunk-VNRDQJXW.mjs";
8
- import "../../chunk-JD7BAH7U.mjs";
9
- import "../../chunk-SPCZTZCY.mjs";
10
- import "../../chunk-7LVVZQRG.mjs";
11
- import "../../chunk-YULKJPY3.mjs";
12
- import "../../chunk-VUY2K2DI.mjs";
13
- import "../../chunk-O35YOIHC.mjs";
14
- import "../../chunk-MRXNTQOX.mjs";
4
+ } from "../../chunk-SIFJW3HD.mjs";
5
+ import "../../chunk-YGKURLXD.mjs";
6
+ import "../../chunk-6WFEP6DR.mjs";
7
+ import "../../chunk-CWK7RV25.mjs";
8
+ import "../../chunk-BJZMR7WC.mjs";
9
+ import "../../chunk-FT5DESSI.mjs";
10
+ import "../../chunk-ZYDU7WF7.mjs";
11
+ import "../../chunk-K4KJZOIZ.mjs";
12
+ import "../../chunk-NWOJ4DVV.mjs";
13
+ import "../../chunk-GBUK745N.mjs";
14
+ import "../../chunk-HIDP27A7.mjs";
15
15
  export {
16
16
  defaultSystemMessage,
17
17
  useCopilotChatV2
18
18
  };
19
- //# sourceMappingURL=use-copilot-chat-v2.mjs.map
@@ -267,4 +267,3 @@ If you would like to call a function, call it without saying anything else.
267
267
  processMessageStream,
268
268
  useCopilotChatV2
269
269
  });
270
- //# sourceMappingURL=index.js.map
@@ -1,22 +1,21 @@
1
- import "../chunk-7GFKOIO7.mjs";
2
- import "../chunk-BABVSMJR.mjs";
1
+ import "../chunk-HNKVKTPX.mjs";
2
+ import "../chunk-YQ6KMLKO.mjs";
3
3
  import {
4
4
  useCopilotChatV2
5
- } from "../chunk-M6WULIFO.mjs";
6
- import "../chunk-FRAKUJWH.mjs";
5
+ } from "../chunk-SIFJW3HD.mjs";
6
+ import "../chunk-YGKURLXD.mjs";
7
7
  import {
8
8
  processMessageStream
9
- } from "../chunk-MZ5UN3BY.mjs";
10
- import "../chunk-VNRDQJXW.mjs";
11
- import "../chunk-JD7BAH7U.mjs";
12
- import "../chunk-SPCZTZCY.mjs";
13
- import "../chunk-7LVVZQRG.mjs";
14
- import "../chunk-YULKJPY3.mjs";
15
- import "../chunk-VUY2K2DI.mjs";
16
- import "../chunk-O35YOIHC.mjs";
17
- import "../chunk-MRXNTQOX.mjs";
9
+ } from "../chunk-6WFEP6DR.mjs";
10
+ import "../chunk-CWK7RV25.mjs";
11
+ import "../chunk-BJZMR7WC.mjs";
12
+ import "../chunk-FT5DESSI.mjs";
13
+ import "../chunk-ZYDU7WF7.mjs";
14
+ import "../chunk-K4KJZOIZ.mjs";
15
+ import "../chunk-NWOJ4DVV.mjs";
16
+ import "../chunk-GBUK745N.mjs";
17
+ import "../chunk-HIDP27A7.mjs";
18
18
  export {
19
19
  processMessageStream,
20
20
  useCopilotChatV2
21
21
  };
22
- //# sourceMappingURL=index.mjs.map
@@ -70,4 +70,3 @@ function processMessageStream(reader, processMessage) {
70
70
  0 && (module.exports = {
71
71
  processMessageStream
72
72
  });
73
- //# sourceMappingURL=index.js.map
@@ -1,9 +1,8 @@
1
- import "../../chunk-FRAKUJWH.mjs";
1
+ import "../../chunk-YGKURLXD.mjs";
2
2
  import {
3
3
  processMessageStream
4
- } from "../../chunk-MZ5UN3BY.mjs";
5
- import "../../chunk-MRXNTQOX.mjs";
4
+ } from "../../chunk-6WFEP6DR.mjs";
5
+ import "../../chunk-HIDP27A7.mjs";
6
6
  export {
7
7
  processMessageStream
8
8
  };
9
- //# sourceMappingURL=index.mjs.map
@@ -68,4 +68,3 @@ function processMessageStream(reader, processMessage) {
68
68
  0 && (module.exports = {
69
69
  processMessageStream
70
70
  });
71
- //# sourceMappingURL=process-message-stream.js.map
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  processMessageStream
3
- } from "../../chunk-MZ5UN3BY.mjs";
4
- import "../../chunk-MRXNTQOX.mjs";
3
+ } from "../../chunk-6WFEP6DR.mjs";
4
+ import "../../chunk-HIDP27A7.mjs";
5
5
  export {
6
6
  processMessageStream
7
7
  };
8
- //# sourceMappingURL=process-message-stream.mjs.map
@@ -16,4 +16,3 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/types/document-pointer.ts
17
17
  var document_pointer_exports = {};
18
18
  module.exports = __toCommonJS(document_pointer_exports);
19
- //# sourceMappingURL=document-pointer.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=document-pointer.mjs.map
@@ -16,4 +16,3 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/types/frontend-action.ts
17
17
  var frontend_action_exports = {};
18
18
  module.exports = __toCommonJS(frontend_action_exports);
19
- //# sourceMappingURL=frontend-action.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=frontend-action.mjs.map
@@ -16,4 +16,3 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/types/index.ts
17
17
  var types_exports = {};
18
18
  module.exports = __toCommonJS(types_exports);
19
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
- import "../chunk-EFZPSZWO.mjs";
2
- //# sourceMappingURL=index.mjs.map
1
+ import "../chunk-LOLJLZCX.mjs";
@@ -16,4 +16,3 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/types/system-message.ts
17
17
  var system_message_exports = {};
18
18
  module.exports = __toCommonJS(system_message_exports);
19
- //# sourceMappingURL=system-message.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=system-message.mjs.map
@@ -0,0 +1,36 @@
1
+ import { Parameter, MappedParameterTypes } from '@copilotkit/shared';
2
+ import { CopilotContextParams } from '../context/copilot-context.js';
3
+ import '../types/frontend-action.js';
4
+ import 'react';
5
+ import '../hooks/use-tree.js';
6
+ import '../types/document-pointer.js';
7
+
8
+ interface InitialState<T extends Parameter[] | [] = []> {
9
+ status: "initial";
10
+ args: Partial<MappedParameterTypes<T>>;
11
+ }
12
+ interface InProgressState<T extends Parameter[] | [] = []> {
13
+ status: "inProgress";
14
+ args: Partial<MappedParameterTypes<T>>;
15
+ }
16
+ interface CompleteState<T extends Parameter[] | [] = []> {
17
+ status: "complete";
18
+ args: MappedParameterTypes<T>;
19
+ }
20
+ type StreamHandlerArgs<T extends Parameter[] | [] = []> = InitialState<T> | InProgressState<T> | CompleteState<T>;
21
+ interface ExtractOptions<T extends Parameter[]> {
22
+ context: CopilotContextParams;
23
+ instructions: string;
24
+ parameters: T;
25
+ include?: IncludeOptions;
26
+ data?: any;
27
+ abortSignal?: AbortSignal;
28
+ stream?: (args: StreamHandlerArgs<T>) => void;
29
+ }
30
+ interface IncludeOptions {
31
+ readable?: boolean;
32
+ messages?: boolean;
33
+ }
34
+ declare function extract<const T extends Parameter[]>({ context, instructions, parameters, include, data, abortSignal, stream, }: ExtractOptions<T>): Promise<MappedParameterTypes<T>>;
35
+
36
+ export { extract };
@@ -0,0 +1,244 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
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 __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
+ // If the importer is in node compatibility mode or this is not an ESM
36
+ // file that has been converted to a CommonJS file using a Babel-
37
+ // compatible transform (i.e. "__esModule" has not been set), then set
38
+ // "default" to the CommonJS "module.exports" for node compatibility.
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ var __async = (__this, __arguments, generator) => {
44
+ return new Promise((resolve, reject) => {
45
+ var fulfilled = (value) => {
46
+ try {
47
+ step(generator.next(value));
48
+ } catch (e) {
49
+ reject(e);
50
+ }
51
+ };
52
+ var rejected = (value) => {
53
+ try {
54
+ step(generator.throw(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ };
59
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
60
+ step((generator = generator.apply(__this, __arguments)).next());
61
+ });
62
+ };
63
+
64
+ // src/utils/extract.ts
65
+ var extract_exports = {};
66
+ __export(extract_exports, {
67
+ extract: () => extract
68
+ });
69
+ module.exports = __toCommonJS(extract_exports);
70
+ var import_shared3 = require("@copilotkit/shared");
71
+
72
+ // src/components/copilot-provider/copilotkit.tsx
73
+ var import_react = require("react");
74
+ var import_shared = require("@copilotkit/shared");
75
+ var import_jsx_runtime = require("react/jsx-runtime");
76
+ var defaultCopilotContextCategories = ["global"];
77
+
78
+ // src/utils/fetch-chat-completion.ts
79
+ var import_shared2 = require("@copilotkit/shared");
80
+ function fetchChatCompletion(_0) {
81
+ return __async(this, arguments, function* ({
82
+ copilotConfig,
83
+ model,
84
+ messages,
85
+ tools,
86
+ temperature,
87
+ headers,
88
+ body,
89
+ signal,
90
+ toolChoice
91
+ }) {
92
+ temperature || (temperature = 0.5);
93
+ tools || (tools = []);
94
+ const cleanedMessages = messages.map((message) => {
95
+ const { content, role, name, function_call } = message;
96
+ return { content, role, name, function_call };
97
+ });
98
+ toolChoice || (toolChoice = "auto");
99
+ const response = yield fetch(copilotConfig.chatApiEndpoint, {
100
+ method: "POST",
101
+ headers: __spreadValues(__spreadValues({
102
+ "Content-Type": "application/json"
103
+ }, copilotConfig.headers), headers ? __spreadValues({}, headers) : {}),
104
+ body: JSON.stringify(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
105
+ model,
106
+ messages: cleanedMessages,
107
+ stream: true
108
+ }, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice: toolChoice } : {}), copilotConfig.body), copilotConfig.backendOnlyProps), excludeBackendOnlyProps(copilotConfig)), body ? __spreadValues({}, body) : {}), copilotConfig.cloud ? { cloud: copilotConfig.cloud } : {})),
109
+ signal
110
+ });
111
+ return response;
112
+ });
113
+ }
114
+ function excludeBackendOnlyProps(copilotConfig) {
115
+ var _a;
116
+ const backendOnlyProps = (_a = copilotConfig.backendOnlyProps) != null ? _a : {};
117
+ if (Object.keys(backendOnlyProps).length > 0) {
118
+ return {
119
+ [import_shared2.EXCLUDE_FROM_FORWARD_PROPS_KEYS]: Object.keys(backendOnlyProps)
120
+ };
121
+ } else {
122
+ return {};
123
+ }
124
+ }
125
+ function fetchAndDecodeChatCompletion(params) {
126
+ return __async(this, null, function* () {
127
+ const response = yield fetchChatCompletion(params);
128
+ if (!response.ok || !response.body) {
129
+ response.events = null;
130
+ } else {
131
+ const events = yield (0, import_shared2.decodeChatCompletion)((0, import_shared2.parseChatCompletion)(response.body));
132
+ response.events = events;
133
+ }
134
+ return response;
135
+ });
136
+ }
137
+
138
+ // src/utils/extract.ts
139
+ var import_untruncate_json = __toESM(require("untruncate-json"));
140
+ function extract(_0) {
141
+ return __async(this, arguments, function* ({
142
+ context,
143
+ instructions,
144
+ parameters,
145
+ include,
146
+ data,
147
+ abortSignal,
148
+ stream
149
+ }) {
150
+ var _a, _b;
151
+ const { messages } = context;
152
+ const action = {
153
+ name: "extract",
154
+ parameters,
155
+ handler: (args) => {
156
+ }
157
+ };
158
+ const includeReadable = (_a = include == null ? void 0 : include.readable) != null ? _a : false;
159
+ const includeMessages = (_b = include == null ? void 0 : include.messages) != null ? _b : false;
160
+ let contextString = "";
161
+ if (data) {
162
+ contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
163
+ }
164
+ if (includeReadable) {
165
+ contextString += context.getContextString([], defaultCopilotContextCategories);
166
+ }
167
+ const systemMessage = {
168
+ id: "system",
169
+ content: makeSystemMessage(contextString, instructions),
170
+ role: "system"
171
+ };
172
+ const headers = __spreadValues(__spreadValues({}, context.copilotApiConfig.headers || {}), context.copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: context.copilotApiConfig.publicApiKey } : {});
173
+ const response = yield fetchAndDecodeChatCompletion({
174
+ copilotConfig: context.copilotApiConfig,
175
+ messages: includeMessages ? [systemMessage, ...messages] : [systemMessage],
176
+ tools: context.getChatCompletionFunctionDescriptions({ extract: action }),
177
+ headers,
178
+ body: context.copilotApiConfig.body,
179
+ toolChoice: { type: "function", function: { name: "extract" } },
180
+ signal: abortSignal
181
+ });
182
+ if (!response.events) {
183
+ throw new Error("extract() failed: Could not fetch chat completion");
184
+ }
185
+ const reader = response.events.getReader();
186
+ let isInitial = true;
187
+ while (true) {
188
+ const { done, value } = yield reader.read();
189
+ if (done) {
190
+ break;
191
+ }
192
+ if (value.type === "partial") {
193
+ try {
194
+ let partialArguments = JSON.parse((0, import_untruncate_json.default)(value.arguments));
195
+ stream == null ? void 0 : stream({
196
+ status: isInitial ? "initial" : "inProgress",
197
+ args: partialArguments
198
+ });
199
+ isInitial = false;
200
+ } catch (e) {
201
+ }
202
+ }
203
+ if (value.type === "function") {
204
+ stream == null ? void 0 : stream({
205
+ status: "complete",
206
+ args: value.arguments
207
+ });
208
+ return value.arguments;
209
+ }
210
+ }
211
+ throw new Error("extract() failed: No function call occurred");
212
+ });
213
+ }
214
+ function makeSystemMessage(contextString, instructions) {
215
+ return `
216
+ Please act as an efficient, competent, conscientious, and industrious professional assistant.
217
+
218
+ Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
219
+ Always be polite and respectful, and prefer brevity over verbosity.
220
+
221
+ The user has provided you with the following context:
222
+ \`\`\`
223
+ ${contextString}
224
+ \`\`\`
225
+
226
+ They have also provided you with a function you MUST call to initiate actions on their behalf.
227
+
228
+ Please assist them as best you can.
229
+
230
+ This is not a conversation, so please do not ask questions. Just call the function without saying anything else.
231
+
232
+ The user has given you the following task to complete:
233
+
234
+ \`\`\`
235
+ ${instructions}
236
+ \`\`\`
237
+
238
+ Any additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.
239
+ `;
240
+ }
241
+ // Annotate the CommonJS export names for ESM import in node:
242
+ 0 && (module.exports = {
243
+ extract
244
+ });
@@ -0,0 +1,14 @@
1
+ import {
2
+ extract
3
+ } from "../chunk-VK5H6Y6B.mjs";
4
+ import "../chunk-BJZMR7WC.mjs";
5
+ import "../chunk-FT5DESSI.mjs";
6
+ import "../chunk-ZYDU7WF7.mjs";
7
+ import "../chunk-K4KJZOIZ.mjs";
8
+ import "../chunk-NWOJ4DVV.mjs";
9
+ import "../chunk-QBL56RUZ.mjs";
10
+ import "../chunk-GBUK745N.mjs";
11
+ import "../chunk-HIDP27A7.mjs";
12
+ export {
13
+ extract
14
+ };
@@ -15,8 +15,14 @@ interface FetchChatCompletionParams {
15
15
  headers?: Record<string, string> | Headers;
16
16
  body?: object;
17
17
  signal?: AbortSignal;
18
+ toolChoice?: string | {
19
+ type: "function";
20
+ function: {
21
+ name: string;
22
+ };
23
+ };
18
24
  }
19
- declare function fetchChatCompletion({ copilotConfig, model, messages, tools, temperature, headers, body, signal, }: FetchChatCompletionParams): Promise<Response>;
25
+ declare function fetchChatCompletion({ copilotConfig, model, messages, tools, temperature, headers, body, signal, toolChoice, }: FetchChatCompletionParams): Promise<Response>;
20
26
  interface DecodedChatCompletionResponse extends Response {
21
27
  events: ReadableStream<ChatCompletionEvent> | null;
22
28
  }