@copilotkit/react-core 1.10.0-next.0 → 1.10.0-next.10

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 (207) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/dist/{chunk-YVBDAURK.mjs → chunk-2TSNHEIS.mjs} +6 -6
  3. package/dist/chunk-2TSNHEIS.mjs.map +1 -0
  4. package/dist/{chunk-DF4YG4PF.mjs → chunk-3RHHNUVV.mjs} +2 -2
  5. package/dist/{chunk-LNAQ7JG3.mjs → chunk-6EKLRL7B.mjs} +2 -2
  6. package/dist/{chunk-O5KV32S5.mjs → chunk-ADZDXHVC.mjs} +2 -2
  7. package/dist/{chunk-4CFY3CON.mjs → chunk-CLMDRYEN.mjs} +2 -2
  8. package/dist/{chunk-G35QHAQ6.mjs → chunk-COEUPDRL.mjs} +20 -21
  9. package/dist/chunk-COEUPDRL.mjs.map +1 -0
  10. package/dist/{chunk-RGKZCCPA.mjs → chunk-DLEXVOQE.mjs} +5 -5
  11. package/dist/{chunk-YAF2LATQ.mjs → chunk-EFL5OBKN.mjs} +1 -1
  12. package/dist/chunk-EFL5OBKN.mjs.map +1 -0
  13. package/dist/{chunk-JWAXDYOW.mjs → chunk-FAUNHSQU.mjs} +3 -3
  14. package/dist/chunk-ICIK2BSB.mjs +17 -0
  15. package/dist/chunk-ICIK2BSB.mjs.map +1 -0
  16. package/dist/chunk-IHAZJF3V.mjs +34 -0
  17. package/dist/chunk-IHAZJF3V.mjs.map +1 -0
  18. package/dist/{chunk-Q6FZZJ5A.mjs → chunk-IN7GE4NO.mjs} +2 -2
  19. package/dist/{chunk-YSQ5I2AE.mjs → chunk-JBLMXZ3O.mjs} +7 -7
  20. package/dist/{chunk-PZXTDFMX.mjs → chunk-JJDXTTEN.mjs} +3 -3
  21. package/dist/chunk-KDAZGZ24.mjs +1 -0
  22. package/dist/{chunk-LIGLZ53V.mjs → chunk-L6HQIJ74.mjs} +29 -13
  23. package/dist/chunk-L6HQIJ74.mjs.map +1 -0
  24. package/dist/{chunk-NAM55D5I.mjs → chunk-LVWV62JZ.mjs} +39 -26
  25. package/dist/chunk-LVWV62JZ.mjs.map +1 -0
  26. package/dist/{chunk-3OQM3NEK.mjs → chunk-N4WEHORG.mjs} +2 -2
  27. package/dist/chunk-OKRZF3DD.mjs +225 -0
  28. package/dist/chunk-OKRZF3DD.mjs.map +1 -0
  29. package/dist/{chunk-SJJNFYGQ.mjs → chunk-Q42NJFXR.mjs} +9 -14
  30. package/dist/chunk-Q42NJFXR.mjs.map +1 -0
  31. package/dist/chunk-QGE7U4NV.mjs +85 -0
  32. package/dist/chunk-QGE7U4NV.mjs.map +1 -0
  33. package/dist/{chunk-XGRBCWK6.mjs → chunk-TEMLWRRT.mjs} +3 -3
  34. package/dist/chunk-TEMLWRRT.mjs.map +1 -0
  35. package/dist/{chunk-YBDRISKO.mjs → chunk-TWYUYC4F.mjs} +43 -9
  36. package/dist/chunk-TWYUYC4F.mjs.map +1 -0
  37. package/dist/{chunk-LU5JPZ24.mjs → chunk-X2DNXTME.mjs} +6 -6
  38. package/dist/chunk-X2DNXTME.mjs.map +1 -0
  39. package/dist/{chunk-DCTJZ742.mjs → chunk-ZLQVRPDS.mjs} +5 -2
  40. package/dist/chunk-ZLQVRPDS.mjs.map +1 -0
  41. package/dist/components/copilot-provider/copilot-messages.d.ts +17 -1
  42. package/dist/components/copilot-provider/copilot-messages.js +46 -7
  43. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  44. package/dist/components/copilot-provider/copilot-messages.mjs +11 -7
  45. package/dist/components/copilot-provider/copilotkit-props.d.ts +5 -3
  46. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  47. package/dist/components/copilot-provider/copilotkit.d.ts +1 -2
  48. package/dist/components/copilot-provider/copilotkit.js +337 -555
  49. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  50. package/dist/components/copilot-provider/copilotkit.mjs +11 -11
  51. package/dist/components/copilot-provider/index.d.ts +1 -2
  52. package/dist/components/copilot-provider/index.js +337 -555
  53. package/dist/components/copilot-provider/index.js.map +1 -1
  54. package/dist/components/copilot-provider/index.mjs +11 -11
  55. package/dist/components/error-boundary/error-boundary.js +176 -323
  56. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  57. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  58. package/dist/components/error-boundary/error-utils.js.map +1 -1
  59. package/dist/components/error-boundary/error-utils.mjs +2 -2
  60. package/dist/components/index.d.ts +1 -2
  61. package/dist/components/index.js +337 -555
  62. package/dist/components/index.js.map +1 -1
  63. package/dist/components/index.mjs +11 -11
  64. package/dist/components/toast/toast-provider.js.map +1 -1
  65. package/dist/components/toast/toast-provider.mjs +1 -1
  66. package/dist/components/usage-banner.d.ts +10 -4
  67. package/dist/components/usage-banner.js +176 -302
  68. package/dist/components/usage-banner.js.map +1 -1
  69. package/dist/components/usage-banner.mjs +3 -1
  70. package/dist/context/copilot-context.d.ts +1 -2
  71. package/dist/context/copilot-context.js +2 -2
  72. package/dist/context/copilot-context.js.map +1 -1
  73. package/dist/context/copilot-context.mjs +1 -1
  74. package/dist/context/copilot-messages-context.d.ts +11 -15
  75. package/dist/context/copilot-messages-context.js +4 -1
  76. package/dist/context/copilot-messages-context.js.map +1 -1
  77. package/dist/context/copilot-messages-context.mjs +1 -1
  78. package/dist/context/index.d.ts +2 -2
  79. package/dist/context/index.js +6 -3
  80. package/dist/context/index.js.map +1 -1
  81. package/dist/context/index.mjs +2 -2
  82. package/dist/{copilot-context-bd88d30d.d.ts → copilot-context-256f9020.d.ts} +4 -22
  83. package/dist/hooks/index.d.ts +7 -5
  84. package/dist/hooks/index.js +250 -122
  85. package/dist/hooks/index.js.map +1 -1
  86. package/dist/hooks/index.mjs +32 -24
  87. package/dist/hooks/use-chat.d.ts +1 -2
  88. package/dist/hooks/use-chat.js +11 -3
  89. package/dist/hooks/use-chat.js.map +1 -1
  90. package/dist/hooks/use-chat.mjs +6 -6
  91. package/dist/hooks/use-coagent-state-render.js +2 -2
  92. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  93. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  94. package/dist/hooks/use-coagent.d.ts +4 -5
  95. package/dist/hooks/use-coagent.js +114 -81
  96. package/dist/hooks/use-coagent.js.map +1 -1
  97. package/dist/hooks/use-coagent.mjs +15 -15
  98. package/dist/hooks/use-copilot-action.d.ts +1 -1
  99. package/dist/hooks/use-copilot-action.js +2 -2
  100. package/dist/hooks/use-copilot-action.js.map +1 -1
  101. package/dist/hooks/use-copilot-action.mjs +4 -4
  102. package/dist/hooks/use-copilot-additional-instructions.js +2 -2
  103. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  104. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  105. package/dist/hooks/use-copilot-authenticated-action.js +2 -2
  106. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  107. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  108. package/dist/hooks/use-copilot-chat-headless_c.d.ts +33 -0
  109. package/dist/hooks/use-copilot-chat-headless_c.js +1837 -0
  110. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
  111. package/dist/hooks/use-copilot-chat-headless_c.mjs +31 -0
  112. package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
  113. package/dist/hooks/use-copilot-chat.d.ts +52 -82
  114. package/dist/hooks/use-copilot-chat.js +60 -13
  115. package/dist/hooks/use-copilot-chat.js.map +1 -1
  116. package/dist/hooks/use-copilot-chat.mjs +15 -16
  117. package/dist/hooks/use-copilot-chat_internal.d.ts +177 -0
  118. package/dist/hooks/use-copilot-chat_internal.js +1770 -0
  119. package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
  120. package/dist/hooks/use-copilot-chat_internal.mjs +29 -0
  121. package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
  122. package/dist/hooks/use-copilot-readable.js +2 -2
  123. package/dist/hooks/use-copilot-readable.js.map +1 -1
  124. package/dist/hooks/use-copilot-readable.mjs +2 -2
  125. package/dist/hooks/use-copilot-runtime-client.js +9 -1
  126. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  127. package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
  128. package/dist/hooks/use-langgraph-interrupt-render.js +2 -2
  129. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  130. package/dist/hooks/use-langgraph-interrupt-render.mjs +3 -3
  131. package/dist/hooks/use-langgraph-interrupt.d.ts +3 -4
  132. package/dist/hooks/use-langgraph-interrupt.js +32 -11
  133. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  134. package/dist/hooks/use-langgraph-interrupt.mjs +15 -15
  135. package/dist/hooks/use-make-copilot-document-readable.js +2 -2
  136. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  137. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  138. package/dist/index-08c43df1.d.ts +36 -0
  139. package/dist/index.d.ts +5 -3
  140. package/dist/index.js +460 -471
  141. package/dist/index.js.map +1 -1
  142. package/dist/index.mjs +34 -26
  143. package/dist/lib/copilot-task.d.ts +1 -2
  144. package/dist/lib/copilot-task.js.map +1 -1
  145. package/dist/lib/copilot-task.mjs +12 -12
  146. package/dist/lib/index.d.ts +1 -2
  147. package/dist/lib/index.js.map +1 -1
  148. package/dist/lib/index.mjs +12 -12
  149. package/dist/types/interrupt-action.d.ts +2 -3
  150. package/dist/utils/dev-console.d.ts +1 -1
  151. package/dist/utils/dev-console.js +9 -1
  152. package/dist/utils/dev-console.js.map +1 -1
  153. package/dist/utils/dev-console.mjs +1 -1
  154. package/dist/utils/extract.d.ts +2 -2
  155. package/dist/utils/extract.js.map +1 -1
  156. package/dist/utils/extract.mjs +11 -11
  157. package/dist/utils/index.d.ts +3 -3
  158. package/dist/utils/index.js +9 -1
  159. package/dist/utils/index.js.map +1 -1
  160. package/dist/utils/index.mjs +11 -11
  161. package/dist/utils/suggestions.d.ts +2 -2
  162. package/dist/utils/suggestions.js.map +1 -1
  163. package/dist/utils/suggestions.mjs +11 -11
  164. package/package.json +3 -3
  165. package/src/components/copilot-provider/copilot-messages.tsx +57 -1
  166. package/src/components/copilot-provider/copilotkit-props.tsx +4 -1
  167. package/src/components/copilot-provider/copilotkit.tsx +20 -10
  168. package/src/components/error-boundary/error-boundary.tsx +5 -15
  169. package/src/components/toast/toast-provider.tsx +1 -3
  170. package/src/components/usage-banner.tsx +193 -316
  171. package/src/context/copilot-context.tsx +12 -6
  172. package/src/context/copilot-messages-context.tsx +7 -1
  173. package/src/hooks/__tests__/use-coagent-config.test.ts +8 -1
  174. package/src/hooks/index.ts +7 -2
  175. package/src/hooks/use-coagent.ts +18 -20
  176. package/src/hooks/use-copilot-action.ts +1 -1
  177. package/src/hooks/use-copilot-chat-headless_c.ts +187 -0
  178. package/src/hooks/use-copilot-chat.ts +64 -495
  179. package/src/hooks/use-copilot-chat_internal.ts +543 -0
  180. package/src/hooks/use-langgraph-interrupt.ts +1 -1
  181. package/src/utils/dev-console.ts +18 -2
  182. package/dist/chunk-57K2ZJ5F.mjs +0 -348
  183. package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
  184. package/dist/chunk-CQPYJIBH.mjs +0 -1
  185. package/dist/chunk-DCTJZ742.mjs.map +0 -1
  186. package/dist/chunk-G35QHAQ6.mjs.map +0 -1
  187. package/dist/chunk-GFJW4RIM.mjs +0 -9
  188. package/dist/chunk-GFJW4RIM.mjs.map +0 -1
  189. package/dist/chunk-LIGLZ53V.mjs.map +0 -1
  190. package/dist/chunk-LU5JPZ24.mjs.map +0 -1
  191. package/dist/chunk-NAM55D5I.mjs.map +0 -1
  192. package/dist/chunk-SJJNFYGQ.mjs.map +0 -1
  193. package/dist/chunk-XGRBCWK6.mjs.map +0 -1
  194. package/dist/chunk-YAF2LATQ.mjs.map +0 -1
  195. package/dist/chunk-YBDRISKO.mjs.map +0 -1
  196. package/dist/chunk-YVBDAURK.mjs.map +0 -1
  197. /package/dist/{chunk-DF4YG4PF.mjs.map → chunk-3RHHNUVV.mjs.map} +0 -0
  198. /package/dist/{chunk-LNAQ7JG3.mjs.map → chunk-6EKLRL7B.mjs.map} +0 -0
  199. /package/dist/{chunk-O5KV32S5.mjs.map → chunk-ADZDXHVC.mjs.map} +0 -0
  200. /package/dist/{chunk-4CFY3CON.mjs.map → chunk-CLMDRYEN.mjs.map} +0 -0
  201. /package/dist/{chunk-RGKZCCPA.mjs.map → chunk-DLEXVOQE.mjs.map} +0 -0
  202. /package/dist/{chunk-JWAXDYOW.mjs.map → chunk-FAUNHSQU.mjs.map} +0 -0
  203. /package/dist/{chunk-Q6FZZJ5A.mjs.map → chunk-IN7GE4NO.mjs.map} +0 -0
  204. /package/dist/{chunk-YSQ5I2AE.mjs.map → chunk-JBLMXZ3O.mjs.map} +0 -0
  205. /package/dist/{chunk-PZXTDFMX.mjs.map → chunk-JJDXTTEN.mjs.map} +0 -0
  206. /package/dist/{chunk-CQPYJIBH.mjs.map → chunk-KDAZGZ24.mjs.map} +0 -0
  207. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-N4WEHORG.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,99 @@
1
1
  # ui
2
2
 
3
+ ## 1.10.0-next.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
8
+
9
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
10
+
11
+ - fix: more fixes addressing breaking changes in new Headless UI
12
+
13
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
14
+
15
+ - chore: address linting issues
16
+
17
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
18
+
19
+ - chore: fixing branding and docs
20
+
21
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
22
+
23
+ - chore: more docs fixing
24
+
25
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
26
+
27
+ - Updated dependencies [6d1de58]
28
+ - @copilotkit/shared@1.10.0-next.10
29
+ - @copilotkit/runtime-client-gql@1.10.0-next.10
30
+
31
+ ## 1.10.0-next.9
32
+
33
+ ### Patch Changes
34
+
35
+ - @copilotkit/runtime-client-gql@1.10.0-next.9
36
+ - @copilotkit/shared@1.10.0-next.9
37
+
38
+ ## 1.10.0-next.8
39
+
40
+ ### Patch Changes
41
+
42
+ - 6de24ce: - fix rerender issues by moving suggestions to the messages context
43
+ - @copilotkit/runtime-client-gql@1.10.0-next.8
44
+ - @copilotkit/shared@1.10.0-next.8
45
+
46
+ ## 1.10.0-next.7
47
+
48
+ ### Patch Changes
49
+
50
+ - @copilotkit/runtime-client-gql@1.10.0-next.7
51
+ - @copilotkit/shared@1.10.0-next.7
52
+
53
+ ## 1.10.0-next.6
54
+
55
+ ### Patch Changes
56
+
57
+ - @copilotkit/runtime-client-gql@1.10.0-next.6
58
+ - @copilotkit/shared@1.10.0-next.6
59
+
60
+ ## 1.10.0-next.5
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [a8c0263]
65
+ - @copilotkit/shared@1.10.0-next.5
66
+ - @copilotkit/runtime-client-gql@1.10.0-next.5
67
+
68
+ ## 1.10.0-next.4
69
+
70
+ ### Patch Changes
71
+
72
+ - 967d0ab: - refactor(chat): separate useCopilotChat into internal implementation and public API
73
+ - @copilotkit/runtime-client-gql@1.10.0-next.4
74
+ - @copilotkit/shared@1.10.0-next.4
75
+
76
+ ## 1.10.0-next.3
77
+
78
+ ### Patch Changes
79
+
80
+ - @copilotkit/runtime-client-gql@1.10.0-next.3
81
+ - @copilotkit/shared@1.10.0-next.3
82
+
83
+ ## 1.10.0-next.2
84
+
85
+ ### Patch Changes
86
+
87
+ - @copilotkit/runtime-client-gql@1.10.0-next.2
88
+ - @copilotkit/shared@1.10.0-next.2
89
+
90
+ ## 1.10.0-next.1
91
+
92
+ ### Patch Changes
93
+
94
+ - @copilotkit/runtime-client-gql@1.10.0-next.1
95
+ - @copilotkit/shared@1.10.0-next.1
96
+
3
97
  ## 1.10.0-next.0
4
98
 
5
99
  ### Minor Changes
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "./chunk-LIGLZ53V.mjs";
4
- import {
5
- useToast
6
- } from "./chunk-YAF2LATQ.mjs";
3
+ } from "./chunk-L6HQIJ74.mjs";
7
4
  import {
8
5
  CopilotContext
9
- } from "./chunk-XGRBCWK6.mjs";
6
+ } from "./chunk-TEMLWRRT.mjs";
7
+ import {
8
+ useToast
9
+ } from "./chunk-EFL5OBKN.mjs";
10
10
  import {
11
11
  __spreadProps,
12
12
  __spreadValues
@@ -62,4 +62,4 @@ function useLangGraphInterrupt(action, dependencies) {
62
62
  export {
63
63
  useLangGraphInterrupt
64
64
  };
65
- //# sourceMappingURL=chunk-YVBDAURK.mjs.map
65
+ //# sourceMappingURL=chunk-2TSNHEIS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-langgraph-interrupt.ts"],"sourcesContent":["import { useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { LangGraphInterruptRender } from \"../types/interrupt-action\";\nimport { useCopilotChat } from \"./use-copilot-chat_internal\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { dataToUUID } from \"@copilotkit/shared\";\n\nexport function useLangGraphInterrupt<TEventValue = any>(\n action: Omit<LangGraphInterruptRender<TEventValue>, \"id\">,\n dependencies?: any[],\n) {\n const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } =\n useContext(CopilotContext);\n const { runChatCompletion } = useCopilotChat();\n const { addToast } = useToast();\n\n const actionId = dataToUUID(JSON.stringify(action), \"lgAction\");\n // We only consider action to be defined once the ID is there\n const hasAction = useMemo(\n () => Boolean(langGraphInterruptAction?.id),\n [langGraphInterruptAction],\n );\n\n const isCurrentAction = useMemo(\n () => langGraphInterruptAction?.id && langGraphInterruptAction?.id === actionId,\n [langGraphInterruptAction],\n );\n\n // Run chat completion to submit a response event. Only if it's the current action\n useEffect(() => {\n if (hasAction && isCurrentAction && langGraphInterruptAction?.event?.response) {\n runChatCompletion();\n }\n }, [langGraphInterruptAction?.event?.response, runChatCompletion, hasAction, isCurrentAction]);\n\n useEffect(() => {\n if (!action) return;\n // An action was already set, with no conditions and it's not the action we're using right now.\n // Show a warning, as this action will not be executed\n if (hasAction && !isCurrentAction && !action.enabled) {\n addToast({\n type: \"warning\",\n message: \"An action is already registered for the interrupt event\",\n });\n return;\n }\n\n if (hasAction && isCurrentAction) {\n return;\n }\n\n setLangGraphInterruptAction({ ...action, id: actionId });\n }, [\n action,\n hasAction,\n isCurrentAction,\n setLangGraphInterruptAction,\n removeLangGraphInterruptAction,\n ...(dependencies || []),\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,eAAe;AAK/C,SAAS,kBAAkB;AAEpB,SAAS,sBACd,QACA,cACA;AAVF;AAWE,QAAM,EAAE,6BAA6B,gCAAgC,yBAAyB,IAC5F,WAAW,cAAc;AAC3B,QAAM,EAAE,kBAAkB,IAAI,eAAe;AAC7C,QAAM,EAAE,SAAS,IAAI,SAAS;AAE9B,QAAM,WAAW,WAAW,KAAK,UAAU,MAAM,GAAG,UAAU;AAE9D,QAAM,YAAY;AAAA,IAChB,MAAM,QAAQ,qEAA0B,EAAE;AAAA,IAC1C,CAAC,wBAAwB;AAAA,EAC3B;AAEA,QAAM,kBAAkB;AAAA,IACtB,OAAM,qEAA0B,QAAM,qEAA0B,QAAO;AAAA,IACvE,CAAC,wBAAwB;AAAA,EAC3B;AAGA,YAAU,MAAM;AA7BlB,QAAAA;AA8BI,QAAI,aAAa,qBAAmBA,MAAA,qEAA0B,UAA1B,gBAAAA,IAAiC,WAAU;AAC7E,wBAAkB;AAAA,IACpB;AAAA,EACF,GAAG,EAAC,0EAA0B,UAA1B,mBAAiC,UAAU,mBAAmB,WAAW,eAAe,CAAC;AAE7F,YAAU,MAAM;AACd,QAAI,CAAC;AAAQ;AAGb,QAAI,aAAa,CAAC,mBAAmB,CAAC,OAAO,SAAS;AACpD,eAAS;AAAA,QACP,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AACD;AAAA,IACF;AAEA,QAAI,aAAa,iBAAiB;AAChC;AAAA,IACF;AAEA,gCAA4B,iCAAK,SAAL,EAAa,IAAI,SAAS,EAAC;AAAA,EACzD,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":["_a"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-XGRBCWK6.mjs";
3
+ } from "./chunk-TEMLWRRT.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-additional-instructions.ts
6
6
  import { useEffect } from "react";
@@ -21,4 +21,4 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
21
21
  export {
22
22
  useCopilotAdditionalInstructions
23
23
  };
24
- //# sourceMappingURL=chunk-DF4YG4PF.mjs.map
24
+ //# sourceMappingURL=chunk-3RHHNUVV.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-XGRBCWK6.mjs";
3
+ } from "./chunk-TEMLWRRT.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-readable.ts
6
6
  import { useEffect, useRef } from "react";
@@ -34,4 +34,4 @@ function useCopilotReadable({
34
34
  export {
35
35
  useCopilotReadable
36
36
  };
37
- //# sourceMappingURL=chunk-LNAQ7JG3.mjs.map
37
+ //# sourceMappingURL=chunk-6EKLRL7B.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-NAM55D5I.mjs";
3
+ } from "./chunk-LVWV62JZ.mjs";
4
4
  import {
5
5
  processActionsForRuntimeRequest
6
6
  } from "./chunk-4CEQJ2X6.mjs";
@@ -117,4 +117,4 @@ ${instructions}
117
117
  export {
118
118
  CopilotTask
119
119
  };
120
- //# sourceMappingURL=chunk-O5KV32S5.mjs.map
120
+ //# sourceMappingURL=chunk-ADZDXHVC.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-XGRBCWK6.mjs";
3
+ } from "./chunk-TEMLWRRT.mjs";
4
4
 
5
5
  // src/hooks/use-make-copilot-document-readable.ts
6
6
  import { useEffect, useRef } from "react";
@@ -20,4 +20,4 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
20
20
  export {
21
21
  useMakeCopilotDocumentReadable
22
22
  };
23
- //# sourceMappingURL=chunk-4CFY3CON.mjs.map
23
+ //# sourceMappingURL=chunk-CLMDRYEN.mjs.map
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "./chunk-LIGLZ53V.mjs";
3
+ } from "./chunk-L6HQIJ74.mjs";
4
4
  import {
5
- useCopilotMessagesContext
6
- } from "./chunk-DCTJZ742.mjs";
5
+ useMessagesTap
6
+ } from "./chunk-TWYUYC4F.mjs";
7
7
  import {
8
8
  useAsyncCallback
9
- } from "./chunk-3OQM3NEK.mjs";
9
+ } from "./chunk-N4WEHORG.mjs";
10
10
  import {
11
11
  useCopilotRuntimeClient
12
- } from "./chunk-JWAXDYOW.mjs";
13
- import {
14
- useToast
15
- } from "./chunk-YAF2LATQ.mjs";
12
+ } from "./chunk-FAUNHSQU.mjs";
16
13
  import {
17
14
  useCopilotContext
18
- } from "./chunk-XGRBCWK6.mjs";
15
+ } from "./chunk-TEMLWRRT.mjs";
16
+ import {
17
+ useToast
18
+ } from "./chunk-EFL5OBKN.mjs";
19
19
  import {
20
20
  __async,
21
21
  __spreadProps,
@@ -26,8 +26,8 @@ import {
26
26
  import { useCallback, useEffect, useMemo, useRef } from "react";
27
27
  import { parseJson, CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
28
28
  function useCoAgent(options) {
29
- const generalContext = useCopilotContext();
30
- const { availableAgents } = generalContext;
29
+ const context = useCopilotContext();
30
+ const { availableAgents } = context;
31
31
  const { setBannerError } = useToast();
32
32
  const lastLoadedThreadId = useRef();
33
33
  const lastLoadedState = useRef();
@@ -43,10 +43,9 @@ function useCoAgent(options) {
43
43
  setBannerError(agentError);
44
44
  }
45
45
  }, [availableAgents]);
46
- const messagesContext = useCopilotMessagesContext();
47
- const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
46
+ const { getMessagesFromTap } = useMessagesTap();
48
47
  const { coagentStates, coagentStatesRef, setCoagentStatesWithRef, threadId, copilotApiConfig } = context;
49
- const { appendMessage, runChatCompletion } = useCopilotChat();
48
+ const { sendMessage, runChatCompletion } = useCopilotChat();
50
49
  const headers = __spreadValues({}, copilotApiConfig.headers || {});
51
50
  const runtimeClient = useCopilotRuntimeClient({
52
51
  url: copilotApiConfig.chatApiEndpoint,
@@ -130,9 +129,9 @@ function useCoAgent(options) {
130
129
  }, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);
131
130
  const runAgentCallback = useAsyncCallback(
132
131
  (hint) => __async(this, null, function* () {
133
- yield runAgent(name, context, appendMessage, runChatCompletion, hint);
132
+ yield runAgent(name, context, getMessagesFromTap(), sendMessage, runChatCompletion, hint);
134
133
  }),
135
- [name, context, appendMessage, runChatCompletion]
134
+ [name, context, sendMessage, runChatCompletion]
136
135
  );
137
136
  return useMemo(() => {
138
137
  const coagentState = getCoagentState({ coagentStates, name, options });
@@ -174,7 +173,7 @@ function stopAgent(name, context) {
174
173
  console.warn(`No agent session found for ${name}`);
175
174
  }
176
175
  }
177
- function runAgent(name, context, appendMessage, runChatCompletion, hint) {
176
+ function runAgent(name, context, messages, sendMessage, runChatCompletion, hint) {
178
177
  return __async(this, null, function* () {
179
178
  var _a, _b;
180
179
  const { agentSession, setAgentSession } = context;
@@ -184,8 +183,8 @@ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
184
183
  });
185
184
  }
186
185
  let previousState = null;
187
- for (let i = context.messages.length - 1; i >= 0; i--) {
188
- const message = context.messages[i];
186
+ for (let i = messages.length - 1; i >= 0; i--) {
187
+ const message = messages[i];
189
188
  if (message.isAgentStateMessage() && message.agentName === name) {
190
189
  previousState = message.state;
191
190
  }
@@ -194,7 +193,7 @@ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
194
193
  if (hint) {
195
194
  const hintMessage = hint({ previousState, currentState: state });
196
195
  if (hintMessage) {
197
- yield appendMessage(hintMessage);
196
+ yield sendMessage(hintMessage);
198
197
  } else {
199
198
  yield runChatCompletion();
200
199
  }
@@ -236,4 +235,4 @@ export {
236
235
  stopAgent,
237
236
  runAgent
238
237
  };
239
- //# sourceMappingURL=chunk-G35QHAQ6.mjs.map
238
+ //# sourceMappingURL=chunk-COEUPDRL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-coagent.ts"],"sourcesContent":["/**\n * <Callout type=\"info\">\n * Usage of this hook assumes some additional setup in your application, for more information\n * on that see the CoAgents <span className=\"text-blue-500\">[getting started guide](/coagents/quickstart/langgraph)</span>.\n * </Callout>\n * <Frame className=\"my-12\">\n * <img\n * src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/coagents/SharedStateCoAgents.gif\"\n * alt=\"CoAgents demonstration\"\n * className=\"w-auto\"\n * />\n * </Frame>\n *\n * This hook is used to integrate an agent into your application. With its use, you can\n * render and update the state of an agent, allowing for a dynamic and interactive experience.\n * We call these shared state experiences agentic copilots, or CoAgents for short.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCoAgent } from \"@copilotkit/react-core\";\n *\n * type AgentState = {\n * count: number;\n * }\n *\n * const agent = useCoAgent<AgentState>({\n * name: \"my-agent\",\n * initialState: {\n * count: 0,\n * },\n * });\n *\n * ```\n *\n * `useCoAgent` returns an object with the following properties:\n *\n * ```tsx\n * const {\n * name, // The name of the agent currently being used.\n * nodeName, // The name of the current LangGraph node.\n * state, // The current state of the agent.\n * setState, // A function to update the state of the agent.\n * running, // A boolean indicating if the agent is currently running.\n * start, // A function to start the agent.\n * stop, // A function to stop the agent.\n * run, // A function to re-run the agent. Takes a HintFunction to inform the agent why it is being re-run.\n * } = agent;\n * ```\n *\n * Finally we can leverage these properties to create reactive experiences with the agent!\n *\n * ```tsx\n * const { state, setState } = useCoAgent<AgentState>({\n * name: \"my-agent\",\n * initialState: {\n * count: 0,\n * },\n * });\n *\n * return (\n * <div>\n * <p>Count: {state.count}</p>\n * <button onClick={() => setState({ count: state.count + 1 })}>Increment</button>\n * </div>\n * );\n * ```\n *\n * This reactivity is bidirectional, meaning that changes to the state from the agent will be reflected in the UI and vice versa.\n *\n * ## Parameters\n * <PropertyReference name=\"options\" type=\"UseCoagentOptions<T>\" required>\n * The options to use when creating the coagent.\n * <PropertyReference name=\"name\" type=\"string\" required>\n * The name of the agent to use.\n * </PropertyReference>\n * <PropertyReference name=\"initialState\" type=\"T | any\">\n * The initial state of the agent.\n * </PropertyReference>\n * <PropertyReference name=\"state\" type=\"T | any\">\n * State to manage externally if you are using this hook with external state management.\n * </PropertyReference>\n * <PropertyReference name=\"setState\" type=\"(newState: T | ((prevState: T | undefined) => T)) => void\">\n * A function to update the state of the agent if you are using this hook with external state management.\n * </PropertyReference>\n * </PropertyReference>\n */\n\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { CopilotContextParams, useCopilotContext } from \"../context\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { useCopilotChat } from \"./use-copilot-chat_internal\";\nimport { Message } from \"@copilotkit/shared\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"./use-copilot-runtime-client\";\nimport { parseJson, CopilotKitAgentDiscoveryError } from \"@copilotkit/shared\";\nimport { useMessagesTap } from \"../components/copilot-provider/copilot-messages\";\nimport { Message as GqlMessage } from \"@copilotkit/runtime-client-gql\";\n\ninterface UseCoagentOptionsBase {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * @deprecated - use \"config.configurable\"\n * Config to pass to a LangGraph Agent\n */\n configurable?: Record<string, any>;\n /**\n * Config to pass to a LangGraph Agent\n */\n config?: {\n configurable?: Record<string, any>;\n [key: string]: any;\n };\n}\n\ninterface WithInternalStateManagementAndInitial<T> extends UseCoagentOptionsBase {\n /**\n * The initial state of the agent.\n */\n initialState: T;\n}\n\ninterface WithInternalStateManagement extends UseCoagentOptionsBase {\n /**\n * Optional initialState with default type any\n */\n initialState?: any;\n}\n\ninterface WithExternalStateManagement<T> extends UseCoagentOptionsBase {\n /**\n * The current state of the agent.\n */\n state: T;\n /**\n * A function to update the state of the agent.\n */\n setState: (newState: T | ((prevState: T | undefined) => T)) => void;\n}\n\ntype UseCoagentOptions<T> =\n | WithInternalStateManagementAndInitial<T>\n | WithInternalStateManagement\n | WithExternalStateManagement<T>;\n\nexport interface UseCoagentReturnType<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * The name of the current LangGraph node.\n */\n nodeName?: string;\n /**\n * The ID of the thread the agent is running in.\n */\n threadId?: string;\n /**\n * A boolean indicating if the agent is currently running.\n */\n running: boolean;\n /**\n * The current state of the agent.\n */\n state: T;\n /**\n * A function to update the state of the agent.\n */\n setState: (newState: T | ((prevState: T | undefined) => T)) => void;\n /**\n * A function to start the agent.\n */\n start: () => void;\n /**\n * A function to stop the agent.\n */\n stop: () => void;\n /**\n * A function to re-run the agent. The hint function can be used to provide a hint to the agent\n * about why it is being re-run again.\n */\n run: (hint?: HintFunction) => Promise<void>;\n}\n\nexport interface HintFunctionParams {\n /**\n * The previous state of the agent.\n */\n previousState: any;\n /**\n * The current state of the agent.\n */\n currentState: any;\n}\n\nexport type HintFunction = (params: HintFunctionParams) => Message | undefined;\n\n/**\n * This hook is used to integrate an agent into your application. With its use, you can\n * render and update the state of the agent, allowing for a dynamic and interactive experience.\n * We call these shared state experiences \"agentic copilots\". To get started using agentic copilots, which\n * we refer to as CoAgents, checkout the documentation at https://docs.copilotkit.ai/coagents/quickstart/langgraph.\n */\nexport function useCoAgent<T = any>(options: UseCoagentOptions<T>): UseCoagentReturnType<T> {\n const context = useCopilotContext();\n const { availableAgents } = context;\n const { setBannerError } = useToast();\n const lastLoadedThreadId = useRef<string>();\n const lastLoadedState = useRef<any>();\n\n const { name } = options;\n useEffect(() => {\n if (availableAgents?.length && !availableAgents.some((a) => a.name === name)) {\n const message = `(useCoAgent): Agent \"${name}\" not found. Make sure the agent exists and is properly configured.`;\n console.warn(message);\n\n // Route to banner instead of toast for consistency\n const agentError = new CopilotKitAgentDiscoveryError({\n agentName: name,\n availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id })),\n });\n setBannerError(agentError);\n }\n }, [availableAgents]);\n\n const { getMessagesFromTap } = useMessagesTap();\n\n const { coagentStates, coagentStatesRef, setCoagentStatesWithRef, threadId, copilotApiConfig } =\n context;\n const { sendMessage, runChatCompletion } = useCopilotChat();\n const headers = {\n ...(copilotApiConfig.headers || {}),\n };\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n showDevConsole: context.showDevConsole,\n });\n\n // if we manage state internally, we need to provide a function to set the state\n const setState = useCallback(\n (newState: T | ((prevState: T | undefined) => T)) => {\n // coagentStatesRef.current || {}\n let coagentState: CoagentState = getCoagentState({ coagentStates, name, options });\n const updatedState =\n typeof newState === \"function\" ? (newState as Function)(coagentState.state) : newState;\n\n setCoagentStatesWithRef({\n ...coagentStatesRef.current,\n [name]: {\n ...coagentState,\n state: updatedState,\n },\n });\n },\n [coagentStates, name],\n );\n\n useEffect(() => {\n const fetchAgentState = async () => {\n if (!threadId || threadId === lastLoadedThreadId.current) return;\n\n const result = await runtimeClient.loadAgentState({\n threadId,\n agentName: name,\n });\n\n // Runtime client handles errors automatically via handleGQLErrors\n if (result.error) {\n return; // Don't process data on error\n }\n\n const newState = result.data?.loadAgentState?.state;\n if (newState === lastLoadedState.current) return;\n\n if (result.data?.loadAgentState?.threadExists && newState && newState != \"{}\") {\n lastLoadedState.current = newState;\n lastLoadedThreadId.current = threadId;\n const fetchedState = parseJson(newState, {});\n isExternalStateManagement(options)\n ? options.setState(fetchedState)\n : setState(fetchedState);\n }\n };\n void fetchAgentState();\n }, [threadId]);\n\n // Sync internal state with external state if state management is external\n useEffect(() => {\n if (isExternalStateManagement(options)) {\n setState(options.state);\n } else if (coagentStates[name] === undefined) {\n setState(options.initialState === undefined ? {} : options.initialState);\n }\n }, [\n isExternalStateManagement(options) ? JSON.stringify(options.state) : undefined,\n // reset initialstate on reset\n coagentStates[name] === undefined,\n ]);\n\n // Sync config when runtime configuration changes\n useEffect(() => {\n const newConfig = options.config\n ? options.config\n : options.configurable\n ? { configurable: options.configurable }\n : undefined;\n\n if (newConfig === undefined) return;\n\n setCoagentStatesWithRef((prev) => {\n const existing = prev[name] ?? {\n name,\n state: isInternalStateManagementWithInitial(options) ? options.initialState : {},\n config: {},\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n };\n\n if (JSON.stringify(existing.config) === JSON.stringify(newConfig)) {\n return prev;\n }\n\n return {\n ...prev,\n [name]: {\n ...existing,\n config: newConfig,\n },\n };\n });\n }, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);\n\n const runAgentCallback = useAsyncCallback(\n async (hint?: HintFunction) => {\n await runAgent(name, context, getMessagesFromTap(), sendMessage, runChatCompletion, hint);\n },\n [name, context, sendMessage, runChatCompletion],\n );\n\n // Return the state and setState function\n return useMemo(() => {\n const coagentState = getCoagentState({ coagentStates, name, options });\n return {\n name,\n nodeName: coagentState.nodeName,\n threadId: coagentState.threadId,\n running: coagentState.running,\n state: coagentState.state,\n setState: isExternalStateManagement(options) ? options.setState : setState,\n start: () => startAgent(name, context),\n stop: () => stopAgent(name, context),\n run: runAgentCallback,\n };\n }, [name, coagentStates, options, setState, runAgentCallback]);\n}\n\nexport function startAgent(name: string, context: CopilotContextParams) {\n const { setAgentSession } = context;\n setAgentSession({\n agentName: name,\n });\n}\n\nexport function stopAgent(name: string, context: CopilotContextParams) {\n const { agentSession, setAgentSession } = context;\n if (agentSession && agentSession.agentName === name) {\n setAgentSession(null);\n context.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [name]: {\n ...prevAgentStates[name],\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n },\n };\n });\n } else {\n console.warn(`No agent session found for ${name}`);\n }\n}\n\nexport async function runAgent(\n name: string,\n context: CopilotContextParams,\n messages: GqlMessage[],\n sendMessage: (message: Message) => Promise<void>,\n runChatCompletion: () => Promise<Message[]>,\n hint?: HintFunction,\n) {\n const { agentSession, setAgentSession } = context;\n if (!agentSession || agentSession.agentName !== name) {\n setAgentSession({\n agentName: name,\n });\n }\n\n let previousState: any = null;\n for (let i = messages.length - 1; i >= 0; i--) {\n const message = messages[i];\n if (message.isAgentStateMessage() && message.agentName === name) {\n previousState = message.state;\n }\n }\n\n let state = context.coagentStatesRef.current?.[name]?.state || {};\n\n if (hint) {\n const hintMessage = hint({ previousState, currentState: state });\n if (hintMessage) {\n await sendMessage(hintMessage);\n } else {\n await runChatCompletion();\n }\n } else {\n await runChatCompletion();\n }\n}\n\nconst isExternalStateManagement = <T>(\n options: UseCoagentOptions<T>,\n): options is WithExternalStateManagement<T> => {\n return \"state\" in options && \"setState\" in options;\n};\n\nconst isInternalStateManagementWithInitial = <T>(\n options: UseCoagentOptions<T>,\n): options is WithInternalStateManagementAndInitial<T> => {\n return \"initialState\" in options;\n};\n\nconst getCoagentState = <T>({\n coagentStates,\n name,\n options,\n}: {\n coagentStates: Record<string, CoagentState>;\n name: string;\n options: UseCoagentOptions<T>;\n}) => {\n if (coagentStates[name]) {\n return coagentStates[name];\n } else {\n return {\n name,\n state: isInternalStateManagementWithInitial<T>(options) ? options.initialState : {},\n config: options.config\n ? options.config\n : options.configurable\n ? { configurable: options.config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M,kBAAkB;AAAA,MAC1B;AAAA,IACF,OAAO;AACL,YAAM,kBAAkB;AAAA,IAC1B;AAAA,EACF;AAAA;AAEA,IAAM,4BAA4B,CAChC,YAC8C;AAC9C,SAAO,WAAW,WAAW,cAAc;AAC7C;AAEA,IAAM,uCAAuC,CAC3C,YACwD;AACxD,SAAO,kBAAkB;AAC3B;AAEA,IAAM,kBAAkB,CAAI;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,MAAI,cAAc,IAAI,GAAG;AACvB,WAAO,cAAc,IAAI;AAAA,EAC3B,OAAO;AACL,WAAO;AAAA,MACL;AAAA,MACA,OAAO,qCAAwC,OAAO,IAAI,QAAQ,eAAe,CAAC;AAAA,MAClF,QAAQ,QAAQ,SACZ,QAAQ,SACR,QAAQ,eACN,EAAE,cAAc,QAAQ,aAAa,IACrC,CAAC;AAAA,MACP,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,UAAU;AAAA,MACV,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- useToast
3
- } from "./chunk-YAF2LATQ.mjs";
4
1
  import {
5
2
  CopilotContext
6
- } from "./chunk-XGRBCWK6.mjs";
3
+ } from "./chunk-TEMLWRRT.mjs";
4
+ import {
5
+ useToast
6
+ } from "./chunk-EFL5OBKN.mjs";
7
7
 
8
8
  // src/hooks/use-coagent-state-render.ts
9
9
  import { useRef, useContext, useEffect } from "react";
@@ -85,4 +85,4 @@ function useCoAgentStateRender(action, dependencies) {
85
85
  export {
86
86
  useCoAgentStateRender
87
87
  };
88
- //# sourceMappingURL=chunk-RGKZCCPA.mjs.map
88
+ //# sourceMappingURL=chunk-DLEXVOQE.mjs.map
@@ -307,4 +307,4 @@ export {
307
307
  useToast,
308
308
  ToastProvider
309
309
  };
310
- //# sourceMappingURL=chunk-YAF2LATQ.mjs.map
310
+ //# sourceMappingURL=chunk-EFL5OBKN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/toast/toast-provider.tsx"],"sourcesContent":["import { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { PartialBy, CopilotKitError, Severity } 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 // Banner management\n bannerError: CopilotKitError | null;\n setBannerError: (error: CopilotKitError | null) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\n// Helper functions for error banner styling\ntype ErrorSeverity = \"critical\" | \"warning\" | \"info\";\n\ninterface ErrorColors {\n background: string;\n border: string;\n text: string;\n icon: string;\n}\n\nfunction getErrorSeverity(error: CopilotKitError): ErrorSeverity {\n // Use structured error severity if available\n if (error.severity) {\n switch (error.severity) {\n case Severity.CRITICAL:\n return \"critical\";\n case Severity.WARNING:\n return \"warning\";\n case Severity.INFO:\n return \"info\";\n default:\n return \"info\";\n }\n }\n\n // Fallback: Check for API key errors which should always be critical\n const message = error.message.toLowerCase();\n if (\n message.includes(\"api key\") ||\n message.includes(\"401\") ||\n message.includes(\"unauthorized\") ||\n message.includes(\"authentication\") ||\n message.includes(\"incorrect api key\")\n ) {\n return \"critical\";\n }\n\n // Default to info level\n return \"info\";\n}\n\nfunction getErrorColors(severity: ErrorSeverity): ErrorColors {\n switch (severity) {\n case \"critical\":\n return {\n background: \"#fee2e2\",\n border: \"#dc2626\",\n text: \"#7f1d1d\",\n icon: \"#dc2626\",\n };\n case \"warning\":\n return {\n background: \"#fef3c7\",\n border: \"#d97706\",\n text: \"#78350f\",\n icon: \"#d97706\",\n };\n case \"info\":\n return {\n background: \"#dbeafe\",\n border: \"#2563eb\",\n text: \"#1e3a8a\",\n icon: \"#2563eb\",\n };\n }\n}\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 [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(null);\n\n const removeToast = useCallback((id: string) => {\n setToasts((prev) => prev.filter((toast) => toast.id !== id));\n }, []);\n\n const addToast = useCallback(\n (toast: PartialBy<Toast, \"id\">) => {\n // Respect the enabled flag for ALL toasts\n if (!enabled) {\n return;\n }\n\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 [enabled, removeToast],\n );\n\n const setBannerError = useCallback(\n (error: CopilotKitError | null) => {\n // Respect the enabled flag for ALL errors\n if (!enabled && error !== null) {\n return;\n }\n setBannerErrorState(error);\n },\n [enabled],\n );\n\n const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {\n // DEPRECATED: All errors now route to banners for consistency\n console.warn(\"addGraphQLErrorsToast is deprecated. All errors now show as banners.\");\n // Function kept for backward compatibility - does nothing\n }, []);\n\n const value = {\n toasts,\n addToast,\n addGraphQLErrorsToast,\n removeToast,\n enabled,\n bannerError,\n setBannerError,\n };\n\n return (\n <ToastContext.Provider value={value}>\n {/* Banner Error Display */}\n {bannerError &&\n (() => {\n const severity = getErrorSeverity(bannerError);\n const colors = getErrorColors(severity);\n\n return (\n <div\n style={{\n position: \"fixed\",\n bottom: \"20px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 9999,\n backgroundColor: colors.background,\n border: `1px solid ${colors.border}`,\n borderLeft: `4px solid ${colors.border}`,\n borderRadius: \"8px\",\n padding: \"12px 16px\",\n fontSize: \"13px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.15)\",\n backdropFilter: \"blur(8px)\",\n maxWidth: \"min(90vw, 700px)\",\n width: \"100%\",\n boxSizing: \"border-box\",\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n gap: \"10px\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n width: \"12px\",\n height: \"12px\",\n borderRadius: \"50%\",\n backgroundColor: colors.border,\n flexShrink: 0,\n }}\n />\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: \"10px\",\n flex: 1,\n minWidth: 0,\n }}\n >\n <div\n style={{\n color: colors.text,\n lineHeight: \"1.4\",\n fontWeight: \"400\",\n fontSize: \"13px\",\n flex: 1,\n wordBreak: \"break-all\",\n overflowWrap: \"break-word\",\n maxWidth: \"550px\",\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 10,\n WebkitBoxOrient: \"vertical\",\n }}\n >\n {(() => {\n let message = bannerError.message;\n\n // Try to extract the useful message from JSON first\n const jsonMatch = message.match(/'message':\\s*'([^']+)'/);\n if (jsonMatch) {\n return jsonMatch[1]; // Return the actual error message\n }\n\n // Strip technical garbage but keep the meaningful message\n message = message.split(\" - \")[0]; // Remove everything after \" - {\"\n message = message.split(\": Error code\")[0]; // Remove \": Error code: 401\"\n message = message.replace(/:\\s*\\d{3}$/, \"\"); // Remove trailing \": 401\"\n message = message.replace(/See more:.*$/g, \"\"); // Remove \"See more\" links\n message = message.trim();\n\n // If it's still garbage (contains { or '), use fallback\n // if (message.includes(\"{\") || message.includes(\"'\")) {\n // return \"Configuration error.... Please check your setup.\";\n // }\n\n return message || \"Configuration error occurred.\";\n })()}\n </div>\n\n {(() => {\n const message = bannerError.message;\n const markdownLinkRegex = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n const plainUrlRegex = /(https?:\\/\\/[^\\s)]+)/g;\n\n // Extract the first URL found\n let url = null;\n let buttonText = \"See More\";\n\n // Check for markdown links first\n const markdownMatch = markdownLinkRegex.exec(message);\n if (markdownMatch) {\n url = markdownMatch[2];\n buttonText = \"See More\";\n } else {\n // Check for plain URLs\n const urlMatch = plainUrlRegex.exec(message);\n if (urlMatch) {\n url = urlMatch[0].replace(/[.,;:'\"]*$/, \"\"); // Remove trailing punctuation\n buttonText = \"See More\";\n }\n }\n\n if (!url) return null;\n\n return (\n <button\n onClick={() => window.open(url, \"_blank\", \"noopener,noreferrer\")}\n style={{\n background: colors.border,\n color: \"white\",\n border: \"none\",\n borderRadius: \"5px\",\n padding: \"4px 10px\",\n fontSize: \"11px\",\n fontWeight: \"500\",\n cursor: \"pointer\",\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"0.9\";\n e.currentTarget.style.transform = \"translateY(-1px)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.transform = \"translateY(0)\";\n }}\n >\n {buttonText}\n </button>\n );\n })()}\n </div>\n </div>\n <button\n onClick={() => setBannerError(null)}\n style={{\n background: \"transparent\",\n border: \"none\",\n color: colors.text,\n cursor: \"pointer\",\n padding: \"2px\",\n borderRadius: \"3px\",\n fontSize: \"14px\",\n lineHeight: \"1\",\n opacity: 0.6,\n transition: \"all 0.2s ease\",\n flexShrink: 0,\n }}\n title=\"Dismiss\"\n onMouseEnter={(e) => {\n e.currentTarget.style.opacity = \"1\";\n e.currentTarget.style.background = \"rgba(0, 0, 0, 0.05)\";\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.opacity = \"0.6\";\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n ×\n </button>\n </div>\n </div>\n );\n })()}\n\n {/* Toast Display - Deprecated: All errors now show as banners */}\n {children}\n </ToastContext.Provider>\n );\n}\n\n// Toast component removed - all errors now show as banners for consistency\n"],"mappings":";;;;;;AACA,SAAgB,eAAe,YAAY,UAAU,mBAAmB;AACxE,SAAqC,gBAAgB;AAgNnC,cASA,YATA;AA5LlB,IAAM,eAAe,cAA6C,MAAS;AAY3E,SAAS,iBAAiB,OAAuC;AAE/D,MAAI,MAAM,UAAU;AAClB,YAAQ,MAAM,UAAU;AAAA,MACtB,KAAK,SAAS;AACZ,eAAO;AAAA,MACT,KAAK,SAAS;AACZ,eAAO;AAAA,MACT,KAAK,SAAS;AACZ,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAGA,QAAM,UAAU,MAAM,QAAQ,YAAY;AAC1C,MACE,QAAQ,SAAS,SAAS,KAC1B,QAAQ,SAAS,KAAK,KACtB,QAAQ,SAAS,cAAc,KAC/B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,mBAAmB,GACpC;AACA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAEA,SAAS,eAAe,UAAsC;AAC5D,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO;AAAA,QACL,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,EACJ;AACF;AAEO,SAAS,WAAW;AACzB,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AACF,GA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CACR,YAAY;AAAA,oCACZ,YAAY;AAAA,kCACd;AAAA,kCACA,cAAc,CAAC,MAAM;AACnB,sCAAE,cAAc,MAAM,UAAU;AAChC,sCAAE,cAAc,MAAM,YAAY;AAAA,kCACpC;AAAA,kCACA,cAAc,CAAC,MAAM;AACnB,sCAAE,cAAc,MAAM,UAAU;AAChC,sCAAE,cAAc,MAAM,YAAY;AAAA,kCACpC;AAAA,kCAEC;AAAA;AAAA,8BACH;AAAA,4BAEJ,GAAG;AAAA;AAAA;AAAA,sBACL;AAAA;AAAA;AAAA,gBACF;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS,MAAM,eAAe,IAAI;AAAA,oBAClC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,QAAQ;AAAA,sBACR,OAAO,OAAO;AAAA,sBACd,QAAQ;AAAA,sBACR,SAAS;AAAA,sBACT,cAAc;AAAA,sBACd,UAAU;AAAA,sBACV,YAAY;AAAA,sBACZ,SAAS;AAAA,sBACT,YAAY;AAAA,sBACZ,YAAY;AAAA,oBACd;AAAA,oBACA,OAAM;AAAA,oBACN,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACA,cAAc,CAAC,MAAM;AACnB,wBAAE,cAAc,MAAM,UAAU;AAChC,wBAAE,cAAc,MAAM,aAAa;AAAA,oBACrC;AAAA,oBACD;AAAA;AAAA,gBAED;AAAA;AAAA;AAAA,UACF;AAAA;AAAA,MACF;AAAA,IAEJ,GAAG;AAAA,IAGJ;AAAA,KACH;AAEJ;","names":["toast"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  shouldShowDevConsole
3
- } from "./chunk-GFJW4RIM.mjs";
3
+ } from "./chunk-ICIK2BSB.mjs";
4
4
  import {
5
5
  useToast
6
- } from "./chunk-YAF2LATQ.mjs";
6
+ } from "./chunk-EFL5OBKN.mjs";
7
7
  import {
8
8
  __async,
9
9
  __objRest,
@@ -146,4 +146,4 @@ function createStructuredError(gqlError) {
146
146
  export {
147
147
  useCopilotRuntimeClient
148
148
  };
149
- //# sourceMappingURL=chunk-JWAXDYOW.mjs.map
149
+ //# sourceMappingURL=chunk-FAUNHSQU.mjs.map
@@ -0,0 +1,17 @@
1
+ // src/utils/dev-console.ts
2
+ function isLocalhost() {
3
+ if (typeof window === "undefined")
4
+ return false;
5
+ return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0";
6
+ }
7
+ function shouldShowDevConsole(showDevConsole) {
8
+ if (showDevConsole !== void 0) {
9
+ return showDevConsole;
10
+ }
11
+ return isLocalhost();
12
+ }
13
+
14
+ export {
15
+ shouldShowDevConsole
16
+ };
17
+ //# sourceMappingURL=chunk-ICIK2BSB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/dev-console.ts"],"sourcesContent":["function isLocalhost(): boolean {\n if (typeof window === \"undefined\") return false;\n\n return (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\" ||\n window.location.hostname === \"0.0.0.0\"\n );\n}\n\nexport function shouldShowDevConsole(showDevConsole?: boolean): boolean {\n // If explicitly set, use that value\n if (showDevConsole !== undefined) {\n return showDevConsole;\n }\n\n // If not set, default to true on localhost\n return isLocalhost();\n}\n"],"mappings":";AAAA,SAAS,cAAuB;AAC9B,MAAI,OAAO,WAAW;AAAa,WAAO;AAE1C,SACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa;AAEjC;AAEO,SAAS,qBAAqB,gBAAmC;AAEtE,MAAI,mBAAmB,QAAW;AAChC,WAAO;AAAA,EACT;AAGA,SAAO,YAAY;AACrB;","names":[]}
@@ -0,0 +1,34 @@
1
+ import {
2
+ useCopilotChat
3
+ } from "./chunk-L6HQIJ74.mjs";
4
+
5
+ // src/hooks/use-copilot-chat.ts
6
+ function useCopilotChat2(options = {}) {
7
+ const {
8
+ visibleMessages,
9
+ appendMessage,
10
+ reloadMessages,
11
+ stopGeneration,
12
+ reset,
13
+ isLoading,
14
+ runChatCompletion,
15
+ mcpServers,
16
+ setMcpServers
17
+ } = useCopilotChat(options);
18
+ return {
19
+ visibleMessages,
20
+ appendMessage,
21
+ reloadMessages,
22
+ stopGeneration,
23
+ reset,
24
+ isLoading,
25
+ runChatCompletion,
26
+ mcpServers,
27
+ setMcpServers
28
+ };
29
+ }
30
+
31
+ export {
32
+ useCopilotChat2 as useCopilotChat
33
+ };
34
+ //# sourceMappingURL=chunk-IHAZJF3V.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"sourcesContent":["/**\n * `useCopilotChat` is a lightweight React hook for headless chat interactions.\n * Perfect for controlling the prebuilt chat components programmatically.\n *\n * **Open Source Friendly** - Works without requiring a free subscription key.\n *\n * <Callout title=\"Looking for fully headless UI?\">\n * Get started with [useCopilotChatHeadless_c](https://docs.copilotkit.ai/reference/hooks/useCopilotChatHeadless_c).\n * </Callout>\n *\n * ## Use Cases:\n *\n * - **Programmatic Messaging**: Send messages without displaying chat UI\n * - **Programmatic control**: Control prebuilt component programmatically\n * - **Background Operations**: Trigger AI interactions in the background\n * - **Fire-and-Forget**: Send messages without needing to read responses\n *\n * ## Usage:\n *\n * ```tsx\n * import { TextMessage, MessageRole } from \"@copilotkit/runtime-client-gql\";\n *\n * const { appendMessage } = useCopilotChat();\n *\n * // Example usage without naming conflicts\n * const handleSendMessage = async (content: string) => {\n * await appendMessage(\n * new TextMessage({\n * role: MessageRole.User,\n * content,\n * })\n * );\n * };\n * ```\n */\n\nimport {\n UseCopilotChatOptions,\n useCopilotChat as useCopilotChatInternal,\n UseCopilotChatReturn as UseCopilotChatReturnInternal,\n} from \"./use-copilot-chat_internal\";\n\n// Create a type that excludes message-related properties from the internal type\nexport type UseCopilotChatReturn = Omit<\n UseCopilotChatReturnInternal,\n | \"messages\"\n | \"sendMessage\"\n | \"suggestions\"\n | \"setSuggestions\"\n | \"generateSuggestions\"\n | \"isLoadingSuggestions\"\n | \"resetSuggestions\"\n | \"interrupt\"\n | \"setMessages\"\n | \"deleteMessage\"\n>;\n\n/**\n * A lightweight React hook for headless chat interactions.\n * Perfect for programmatic messaging, background operations, and custom UI implementations.\n *\n * **Open Source Friendly** - Works without requiring a `publicApiKey`.\n */\nexport function useCopilotChat(options: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const {\n visibleMessages,\n appendMessage,\n reloadMessages,\n stopGeneration,\n reset,\n isLoading,\n runChatCompletion,\n mcpServers,\n setMcpServers,\n } = useCopilotChatInternal(options);\n\n return {\n visibleMessages,\n appendMessage,\n reloadMessages,\n stopGeneration,\n reset,\n isLoading,\n runChatCompletion,\n mcpServers,\n setMcpServers,\n };\n}\n"],"mappings":";;;;;AA+DO,SAASA,gBAAe,UAAiC,CAAC,GAAyB;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,eAAuB,OAAO;AAElC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["useCopilotChat"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-XGRBCWK6.mjs";
3
+ } from "./chunk-TEMLWRRT.mjs";
4
4
 
5
5
  // src/hooks/use-langgraph-interrupt-render.ts
6
6
  import React, { useCallback } from "react";
@@ -44,4 +44,4 @@ function useLangGraphInterruptRender() {
44
44
  export {
45
45
  useLangGraphInterruptRender
46
46
  };
47
- //# sourceMappingURL=chunk-Q6FZZJ5A.mjs.map
47
+ //# sourceMappingURL=chunk-IN7GE4NO.mjs.map
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  useAsyncCallback,
6
6
  useErrorToast
7
- } from "./chunk-3OQM3NEK.mjs";
7
+ } from "./chunk-N4WEHORG.mjs";
8
8
  import {
9
9
  useCopilotRuntimeClient
10
- } from "./chunk-JWAXDYOW.mjs";
11
- import {
12
- useToast
13
- } from "./chunk-YAF2LATQ.mjs";
10
+ } from "./chunk-FAUNHSQU.mjs";
14
11
  import {
15
12
  useCopilotContext
16
- } from "./chunk-XGRBCWK6.mjs";
13
+ } from "./chunk-TEMLWRRT.mjs";
14
+ import {
15
+ useToast
16
+ } from "./chunk-EFL5OBKN.mjs";
17
17
  import {
18
18
  __async,
19
19
  __spreadProps,
@@ -706,4 +706,4 @@ function getPairedFeAction(actions, message) {
706
706
  export {
707
707
  useChat
708
708
  };
709
- //# sourceMappingURL=chunk-YSQ5I2AE.mjs.map
709
+ //# sourceMappingURL=chunk-JBLMXZ3O.mjs.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  useCopilotAction
3
- } from "./chunk-LU5JPZ24.mjs";
3
+ } from "./chunk-X2DNXTME.mjs";
4
4
  import {
5
5
  useCopilotContext
6
- } from "./chunk-XGRBCWK6.mjs";
6
+ } from "./chunk-TEMLWRRT.mjs";
7
7
  import {
8
8
  __spreadProps,
9
9
  __spreadValues
@@ -56,4 +56,4 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
56
56
  export {
57
57
  useCopilotAuthenticatedAction_c
58
58
  };
59
- //# sourceMappingURL=chunk-PZXTDFMX.mjs.map
59
+ //# sourceMappingURL=chunk-JJDXTTEN.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-KDAZGZ24.mjs.map