@copilotkit/react-core 1.5.13 → 1.5.14

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 (111) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-X62FIPVR.mjs → chunk-67W2A4DM.mjs} +5 -5
  3. package/dist/{chunk-N37EFAUX.mjs → chunk-7QGQVBD7.mjs} +2 -2
  4. package/dist/chunk-D34OH4VN.mjs +201 -0
  5. package/dist/chunk-D34OH4VN.mjs.map +1 -0
  6. package/dist/{chunk-6BQUI465.mjs → chunk-DZCTHC4G.mjs} +5 -5
  7. package/dist/{chunk-CBWNO2FP.mjs → chunk-GPWNMXSU.mjs} +2 -2
  8. package/dist/chunk-PMAFHQ7P.mjs +65 -0
  9. package/dist/chunk-PMAFHQ7P.mjs.map +1 -0
  10. package/dist/{chunk-MF4F77OY.mjs → chunk-PMHLIIAI.mjs} +10 -10
  11. package/dist/chunk-PMHLIIAI.mjs.map +1 -0
  12. package/dist/{chunk-YVQNSJ4Z.mjs → chunk-RKYHRYN3.mjs} +1 -1
  13. package/dist/{chunk-YVQNSJ4Z.mjs.map → chunk-RKYHRYN3.mjs.map} +1 -1
  14. package/dist/{chunk-J6UBNKIR.mjs → chunk-S5MSFDGS.mjs} +2 -2
  15. package/dist/{chunk-MYCYEMIM.mjs → chunk-TJTOQRGB.mjs} +35 -30
  16. package/dist/chunk-TJTOQRGB.mjs.map +1 -0
  17. package/dist/chunk-UMQQA6HK.mjs +80 -0
  18. package/dist/chunk-UMQQA6HK.mjs.map +1 -0
  19. package/dist/{chunk-IFBUUIU7.mjs → chunk-V74U56PX.mjs} +8 -10
  20. package/dist/chunk-V74U56PX.mjs.map +1 -0
  21. package/dist/{chunk-VEGDEDID.mjs → chunk-VEQGQAGN.mjs} +2 -2
  22. package/dist/{chunk-EXX267DG.mjs → chunk-YJT6IYNV.mjs} +2 -2
  23. package/dist/components/copilot-provider/copilot-messages.d.ts +4 -12
  24. package/dist/components/copilot-provider/copilot-messages.js +3 -18
  25. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  26. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  27. package/dist/components/copilot-provider/copilotkit-props.d.ts +15 -1
  28. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  29. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  30. package/dist/components/copilot-provider/copilotkit.js +324 -34
  31. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  32. package/dist/components/copilot-provider/copilotkit.mjs +6 -4
  33. package/dist/components/copilot-provider/index.js +324 -34
  34. package/dist/components/copilot-provider/index.js.map +1 -1
  35. package/dist/components/copilot-provider/index.mjs +6 -4
  36. package/dist/components/error-boundary/error-boundary.d.ts +12 -3
  37. package/dist/components/error-boundary/error-boundary.js +324 -18
  38. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  39. package/dist/components/error-boundary/error-boundary.mjs +3 -1
  40. package/dist/components/index.js +324 -34
  41. package/dist/components/index.js.map +1 -1
  42. package/dist/components/index.mjs +6 -4
  43. package/dist/components/usage-banner.d.ts +22 -0
  44. package/dist/components/usage-banner.js +226 -0
  45. package/dist/components/usage-banner.js.map +1 -0
  46. package/dist/components/usage-banner.mjs +10 -0
  47. package/dist/components/usage-banner.mjs.map +1 -0
  48. package/dist/context/copilot-context.d.ts +3 -3
  49. package/dist/context/copilot-context.js.map +1 -1
  50. package/dist/context/copilot-context.mjs +1 -1
  51. package/dist/context/index.js.map +1 -1
  52. package/dist/context/index.mjs +4 -4
  53. package/dist/hooks/index.d.ts +1 -1
  54. package/dist/hooks/index.js +8 -8
  55. package/dist/hooks/index.js.map +1 -1
  56. package/dist/hooks/index.mjs +19 -17
  57. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  58. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  59. package/dist/hooks/use-coagent.js.map +1 -1
  60. package/dist/hooks/use-coagent.mjs +8 -6
  61. package/dist/hooks/use-copilot-action.js.map +1 -1
  62. package/dist/hooks/use-copilot-action.mjs +2 -2
  63. package/dist/hooks/use-copilot-authenticated-action.d.ts +12 -2
  64. package/dist/hooks/use-copilot-authenticated-action.js +8 -8
  65. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  66. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  67. package/dist/hooks/use-copilot-chat.js.map +1 -1
  68. package/dist/hooks/use-copilot-chat.mjs +7 -5
  69. package/dist/hooks/use-copilot-readable.js.map +1 -1
  70. package/dist/hooks/use-copilot-readable.mjs +2 -2
  71. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  72. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +341 -51
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +23 -21
  77. package/dist/lib/copilot-task.js.map +1 -1
  78. package/dist/lib/copilot-task.mjs +7 -5
  79. package/dist/lib/index.js.map +1 -1
  80. package/dist/lib/index.mjs +7 -5
  81. package/dist/lib/status-checker.d.ts +17 -0
  82. package/dist/lib/status-checker.js +102 -0
  83. package/dist/lib/status-checker.js.map +1 -0
  84. package/dist/lib/status-checker.mjs +8 -0
  85. package/dist/lib/status-checker.mjs.map +1 -0
  86. package/dist/utils/extract.js.map +1 -1
  87. package/dist/utils/extract.mjs +6 -4
  88. package/dist/utils/index.js.map +1 -1
  89. package/dist/utils/index.mjs +6 -4
  90. package/package.json +3 -3
  91. package/src/components/copilot-provider/copilot-messages.tsx +2 -2
  92. package/src/components/copilot-provider/copilotkit-props.tsx +16 -1
  93. package/src/components/copilot-provider/copilotkit.tsx +43 -27
  94. package/src/components/error-boundary/error-boundary.tsx +51 -4
  95. package/src/components/usage-banner.tsx +205 -0
  96. package/src/context/copilot-context.tsx +3 -3
  97. package/src/hooks/index.ts +1 -1
  98. package/src/hooks/use-copilot-authenticated-action.ts +17 -7
  99. package/src/lib/status-checker.ts +64 -0
  100. package/dist/chunk-IFBUUIU7.mjs.map +0 -1
  101. package/dist/chunk-MF4F77OY.mjs.map +0 -1
  102. package/dist/chunk-MYCYEMIM.mjs.map +0 -1
  103. package/dist/chunk-X47CUJJT.mjs +0 -37
  104. package/dist/chunk-X47CUJJT.mjs.map +0 -1
  105. /package/dist/{chunk-X62FIPVR.mjs.map → chunk-67W2A4DM.mjs.map} +0 -0
  106. /package/dist/{chunk-N37EFAUX.mjs.map → chunk-7QGQVBD7.mjs.map} +0 -0
  107. /package/dist/{chunk-6BQUI465.mjs.map → chunk-DZCTHC4G.mjs.map} +0 -0
  108. /package/dist/{chunk-CBWNO2FP.mjs.map → chunk-GPWNMXSU.mjs.map} +0 -0
  109. /package/dist/{chunk-J6UBNKIR.mjs.map → chunk-S5MSFDGS.mjs.map} +0 -0
  110. /package/dist/{chunk-VEGDEDID.mjs.map → chunk-VEQGQAGN.mjs.map} +0 -0
  111. /package/dist/{chunk-EXX267DG.mjs.map → chunk-YJT6IYNV.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # ui
2
2
 
3
+ ## 1.5.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 0061f65: - feat: allows dev mode for cloud onboarding flow
8
+ - Updated dependencies [0061f65]
9
+ - @copilotkit/shared@1.5.14
10
+ - @copilotkit/runtime-client-gql@1.5.14
11
+
12
+ ## 1.5.14-next.0
13
+
14
+ ### Patch Changes
15
+
16
+ - 0061f65: - feat: allows dev mode for cloud onboarding flow
17
+ - Updated dependencies [0061f65]
18
+ - @copilotkit/shared@1.5.14-next.0
19
+ - @copilotkit/runtime-client-gql@1.5.14-next.0
20
+
3
21
  ## 1.5.13
4
22
 
5
23
  ### Patch Changes
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-MYCYEMIM.mjs";
3
+ } from "./chunk-TJTOQRGB.mjs";
4
+ import {
5
+ useCopilotContext
6
+ } from "./chunk-RKYHRYN3.mjs";
4
7
  import {
5
8
  useCopilotMessagesContext
6
9
  } from "./chunk-DCTJZ742.mjs";
7
10
  import {
8
11
  useChat
9
12
  } from "./chunk-KGCYVAIN.mjs";
10
- import {
11
- useCopilotContext
12
- } from "./chunk-YVQNSJ4Z.mjs";
13
13
  import {
14
14
  useAsyncCallback
15
15
  } from "./chunk-HZCROITJ.mjs";
@@ -218,4 +218,4 @@ export {
218
218
  useCopilotChat,
219
219
  defaultSystemMessage
220
220
  };
221
- //# sourceMappingURL=chunk-X62FIPVR.mjs.map
221
+ //# sourceMappingURL=chunk-67W2A4DM.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-YVQNSJ4Z.mjs";
3
+ } from "./chunk-RKYHRYN3.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-readable.ts
6
6
  import { useEffect, useRef } from "react";
@@ -25,4 +25,4 @@ function useCopilotReadable({ description, value, parentId, categories, convert
25
25
  export {
26
26
  useCopilotReadable
27
27
  };
28
- //# sourceMappingURL=chunk-N37EFAUX.mjs.map
28
+ //# sourceMappingURL=chunk-7QGQVBD7.mjs.map
@@ -0,0 +1,201 @@
1
+ // src/components/usage-banner.tsx
2
+ import { Severity, ERROR_NAMES } from "@copilotkit/shared";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var defaultIcons = {
5
+ [Severity.Error]: /* @__PURE__ */ jsxs(
6
+ "svg",
7
+ {
8
+ viewBox: "0 0 24 24",
9
+ width: "20",
10
+ height: "20",
11
+ stroke: "currentColor",
12
+ strokeWidth: "2",
13
+ fill: "none",
14
+ strokeLinecap: "round",
15
+ strokeLinejoin: "round",
16
+ children: [
17
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
18
+ /* @__PURE__ */ jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
19
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
20
+ ]
21
+ }
22
+ )
23
+ };
24
+ function UsageBanner({
25
+ severity = Severity.Error,
26
+ message = "",
27
+ icon,
28
+ actions
29
+ }) {
30
+ if (!message || !severity) {
31
+ return null;
32
+ }
33
+ const Icon = icon || defaultIcons[severity];
34
+ const bgColor = {
35
+ info: "#dbeafe",
36
+ warning: "#fef3c7",
37
+ error: "#fee2e2"
38
+ }[severity];
39
+ const textColor = {
40
+ info: "#1e40af",
41
+ warning: "#854d0e",
42
+ error: "#991b1b"
43
+ }[severity];
44
+ const iconColor = {
45
+ info: "#3b82f6",
46
+ warning: "#eab308",
47
+ error: "#ef4444"
48
+ }[severity];
49
+ const primaryButtonColor = {
50
+ info: "#3b82f6",
51
+ warning: "#eab308",
52
+ error: "#ef4444"
53
+ }[severity];
54
+ const primaryButtonHoverColor = {
55
+ info: "#2563eb",
56
+ warning: "#ca8a04",
57
+ error: "#dc2626"
58
+ }[severity];
59
+ return /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ style: {
63
+ position: "fixed",
64
+ bottom: "16px",
65
+ left: "50%",
66
+ transform: "translateX(-50%)",
67
+ maxWidth: "90%",
68
+ zIndex: 9999
69
+ },
70
+ children: /* @__PURE__ */ jsxs(
71
+ "div",
72
+ {
73
+ style: {
74
+ display: "flex",
75
+ flexWrap: "wrap",
76
+ alignItems: "center",
77
+ gap: "12px",
78
+ borderRadius: "9999px",
79
+ border: "1px solid #e5e7eb",
80
+ backgroundColor: bgColor,
81
+ padding: "8px 16px",
82
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)"
83
+ },
84
+ children: [
85
+ /* @__PURE__ */ jsx("div", { style: { color: iconColor }, children: Icon }),
86
+ /* @__PURE__ */ jsx(
87
+ "span",
88
+ {
89
+ style: {
90
+ flex: 1,
91
+ fontSize: "14px",
92
+ fontWeight: 500,
93
+ color: textColor,
94
+ whiteSpace: "normal",
95
+ wordBreak: "break-word"
96
+ },
97
+ children: message
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsxs(
101
+ "div",
102
+ {
103
+ style: {
104
+ display: "flex",
105
+ gap: "8px",
106
+ flexWrap: "wrap"
107
+ },
108
+ children: [
109
+ (actions == null ? void 0 : actions.secondary) && /* @__PURE__ */ jsx(
110
+ "button",
111
+ {
112
+ onClick: actions.secondary.onClick,
113
+ style: {
114
+ borderRadius: "9999px",
115
+ padding: "4px 12px",
116
+ fontSize: "14px",
117
+ fontWeight: 500,
118
+ color: textColor,
119
+ backgroundColor: "transparent",
120
+ border: "none",
121
+ cursor: "pointer",
122
+ transition: "background-color 0.2s"
123
+ },
124
+ onMouseOver: (e) => e.currentTarget.style.backgroundColor = "rgba(255,255,255,0.5)",
125
+ onMouseOut: (e) => e.currentTarget.style.backgroundColor = "transparent",
126
+ children: actions.secondary.label
127
+ }
128
+ ),
129
+ (actions == null ? void 0 : actions.primary) && /* @__PURE__ */ jsx(
130
+ "button",
131
+ {
132
+ onClick: actions.primary.onClick,
133
+ style: {
134
+ borderRadius: "9999px",
135
+ padding: "4px 12px",
136
+ fontSize: "14px",
137
+ fontWeight: 500,
138
+ color: "#fff",
139
+ backgroundColor: primaryButtonColor,
140
+ border: "none",
141
+ cursor: "pointer",
142
+ transition: "background-color 0.2s"
143
+ },
144
+ onMouseOver: (e) => e.currentTarget.style.backgroundColor = primaryButtonHoverColor,
145
+ onMouseOut: (e) => e.currentTarget.style.backgroundColor = primaryButtonColor,
146
+ children: actions.primary.label
147
+ }
148
+ )
149
+ ]
150
+ }
151
+ )
152
+ ]
153
+ }
154
+ )
155
+ }
156
+ );
157
+ }
158
+ function renderCopilotKitUsage(error) {
159
+ switch (error.name) {
160
+ case ERROR_NAMES.CONFIGURATION_ERROR:
161
+ return /* @__PURE__ */ jsx(UsageBanner, { severity: error.severity, message: error.message });
162
+ case ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR:
163
+ return /* @__PURE__ */ jsx(
164
+ UsageBanner,
165
+ {
166
+ severity: error.severity,
167
+ message: error.message,
168
+ actions: {
169
+ primary: {
170
+ label: "Sign In",
171
+ onClick: () => {
172
+ window.location.href = "https://cloud.copilotkit.ai";
173
+ }
174
+ }
175
+ }
176
+ }
177
+ );
178
+ case ERROR_NAMES.UPGRADE_REQUIRED_ERROR:
179
+ return /* @__PURE__ */ jsx(
180
+ UsageBanner,
181
+ {
182
+ severity: error.severity,
183
+ message: error.message,
184
+ actions: {
185
+ primary: {
186
+ label: "Upgrade",
187
+ onClick: () => {
188
+ window.location.href = "https://copilotkit.ai/";
189
+ }
190
+ }
191
+ }
192
+ }
193
+ );
194
+ }
195
+ }
196
+
197
+ export {
198
+ UsageBanner,
199
+ renderCopilotKitUsage
200
+ };
201
+ //# sourceMappingURL=chunk-D34OH4VN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/usage-banner.tsx"],"sourcesContent":["import { Severity, CopilotKitError, ERROR_NAMES } from \"@copilotkit/shared\";\n\ninterface UsageBannerProps {\n severity?: Severity;\n message?: string;\n icon?: React.ReactNode;\n actions?: {\n primary?: {\n label: string;\n onClick: () => void;\n };\n secondary?: {\n label: string;\n onClick: () => void;\n };\n };\n}\n\nconst defaultIcons: Record<Severity, JSX.Element> = {\n [Severity.Error]: (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"20\"\n height=\"20\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n <line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n </svg>\n ),\n};\n\nexport function UsageBanner({\n severity = Severity.Error,\n message = \"\",\n icon,\n actions,\n}: UsageBannerProps) {\n if (!message || !severity) {\n return null;\n }\n\n const Icon = icon || defaultIcons[severity];\n\n const bgColor = {\n info: \"#dbeafe\",\n warning: \"#fef3c7\",\n error: \"#fee2e2\",\n }[severity];\n\n const textColor = {\n info: \"#1e40af\",\n warning: \"#854d0e\",\n error: \"#991b1b\",\n }[severity];\n\n const iconColor = {\n info: \"#3b82f6\",\n warning: \"#eab308\",\n error: \"#ef4444\",\n }[severity];\n\n const primaryButtonColor = {\n info: \"#3b82f6\",\n warning: \"#eab308\",\n error: \"#ef4444\",\n }[severity];\n\n const primaryButtonHoverColor = {\n info: \"#2563eb\",\n warning: \"#ca8a04\",\n error: \"#dc2626\",\n }[severity];\n\n return (\n <div\n style={{\n position: \"fixed\",\n bottom: \"16px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n maxWidth: \"90%\",\n zIndex: 9999,\n }}\n >\n <div\n style={{\n display: \"flex\",\n flexWrap: \"wrap\",\n alignItems: \"center\",\n gap: \"12px\",\n borderRadius: \"9999px\",\n border: \"1px solid #e5e7eb\",\n backgroundColor: bgColor,\n padding: \"8px 16px\",\n boxShadow: \"0 4px 6px -1px rgba(0, 0, 0, 0.1)\",\n }}\n >\n <div style={{ color: iconColor }}>{Icon}</div>\n <span\n style={{\n flex: 1,\n fontSize: \"14px\",\n fontWeight: 500,\n color: textColor,\n whiteSpace: \"normal\",\n wordBreak: \"break-word\",\n }}\n >\n {message}\n </span>\n <div\n style={{\n display: \"flex\",\n gap: \"8px\",\n flexWrap: \"wrap\",\n }}\n >\n {actions?.secondary && (\n <button\n onClick={actions.secondary.onClick}\n style={{\n borderRadius: \"9999px\",\n padding: \"4px 12px\",\n fontSize: \"14px\",\n fontWeight: 500,\n color: textColor,\n backgroundColor: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n transition: \"background-color 0.2s\",\n }}\n onMouseOver={(e) => (e.currentTarget.style.backgroundColor = \"rgba(255,255,255,0.5)\")}\n onMouseOut={(e) => (e.currentTarget.style.backgroundColor = \"transparent\")}\n >\n {actions.secondary.label}\n </button>\n )}\n {actions?.primary && (\n <button\n onClick={actions.primary.onClick}\n style={{\n borderRadius: \"9999px\",\n padding: \"4px 12px\",\n fontSize: \"14px\",\n fontWeight: 500,\n color: \"#fff\",\n backgroundColor: primaryButtonColor,\n border: \"none\",\n cursor: \"pointer\",\n transition: \"background-color 0.2s\",\n }}\n onMouseOver={(e) => (e.currentTarget.style.backgroundColor = primaryButtonHoverColor)}\n onMouseOut={(e) => (e.currentTarget.style.backgroundColor = primaryButtonColor)}\n >\n {actions.primary.label}\n </button>\n )}\n </div>\n </div>\n </div>\n );\n}\n\nexport function renderCopilotKitUsage(error: CopilotKitError) {\n switch (error.name) {\n case ERROR_NAMES.CONFIGURATION_ERROR:\n return <UsageBanner severity={error.severity} message={error.message} />;\n case ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR:\n return (\n <UsageBanner\n severity={error.severity}\n message={error.message}\n actions={{\n primary: {\n label: \"Sign In\",\n onClick: () => {\n window.location.href = \"https://cloud.copilotkit.ai\";\n },\n },\n }}\n />\n );\n case ERROR_NAMES.UPGRADE_REQUIRED_ERROR:\n return (\n <UsageBanner\n severity={error.severity}\n message={error.message}\n actions={{\n primary: {\n label: \"Upgrade\",\n onClick: () => {\n window.location.href = \"https://copilotkit.ai/\";\n },\n },\n }}\n />\n );\n }\n}\n"],"mappings":";AAAA,SAAS,UAA2B,mBAAmB;AAoBnD,SAUE,KAVF;AAFJ,IAAM,eAA8C;AAAA,EAClD,CAAC,SAAS,KAAK,GACb;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,QAAO;AAAA,MACP,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,MAAK;AAAA,MACL,eAAc;AAAA,MACd,gBAAe;AAAA,MAEf;AAAA,4BAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,MAAK;AAAA,QAC/B,oBAAC,UAAK,IAAG,MAAK,IAAG,KAAI,IAAG,KAAI,IAAG,MAAK;AAAA,QACpC,oBAAC,UAAK,IAAG,KAAI,IAAG,KAAI,IAAG,MAAK,IAAG,MAAK;AAAA;AAAA;AAAA,EACtC;AAEJ;AAEO,SAAS,YAAY;AAAA,EAC1B,WAAW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M,UAAU,SAAS,MAAM,SAAS;AAAA,IACxE,KAAK,YAAY;AACf,aACE;AAAA,QAAC;AAAA;AAAA,UACC,UAAU,MAAM;AAAA,UAChB,SAAS,MAAM;AAAA,UACf,SAAS;AAAA,YACP,SAAS;AAAA,cACP,OAAO;AAAA,cACP,SAAS,MAAM;AACb,uBAAO,SAAS,OAAO;AAAA,cACzB;AAAA,YACF;AAAA,UACF;AAAA;AAAA,MACF;AAAA,IAEJ,KAAK,YAAY;AACf,aACE;AAAA,QAAC;AAAA;AAAA,UACC,UAAU,MAAM;AAAA,UAChB,SAAS,MAAM;AAAA,UACf,SAAS;AAAA,YACP,SAAS;AAAA,cACP,OAAO;AAAA,cACP,SAAS,MAAM;AACb,uBAAO,SAAS,OAAO;AAAA,cACzB;AAAA,YACF;AAAA,UACF;AAAA;AAAA,MACF;AAAA,EAEN;AACF;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  useCopilotChat
3
- } from "./chunk-X62FIPVR.mjs";
3
+ } from "./chunk-67W2A4DM.mjs";
4
+ import {
5
+ useCopilotContext
6
+ } from "./chunk-RKYHRYN3.mjs";
4
7
  import {
5
8
  useCopilotMessagesContext
6
9
  } from "./chunk-DCTJZ742.mjs";
7
10
  import {
8
11
  useCopilotRuntimeClient
9
12
  } from "./chunk-CQWEXISS.mjs";
10
- import {
11
- useCopilotContext
12
- } from "./chunk-YVQNSJ4Z.mjs";
13
13
  import {
14
14
  useAsyncCallback,
15
15
  useToast
@@ -178,4 +178,4 @@ export {
178
178
  stopAgent,
179
179
  runAgent
180
180
  };
181
- //# sourceMappingURL=chunk-6BQUI465.mjs.map
181
+ //# sourceMappingURL=chunk-DZCTHC4G.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotContext
3
- } from "./chunk-YVQNSJ4Z.mjs";
3
+ } from "./chunk-RKYHRYN3.mjs";
4
4
  import {
5
5
  useToast
6
6
  } from "./chunk-HZCROITJ.mjs";
@@ -58,4 +58,4 @@ function useCoAgentStateRender(action, dependencies) {
58
58
  export {
59
59
  useCoAgentStateRender
60
60
  };
61
- //# sourceMappingURL=chunk-CBWNO2FP.mjs.map
61
+ //# sourceMappingURL=chunk-GPWNMXSU.mjs.map
@@ -0,0 +1,65 @@
1
+ import {
2
+ __async
3
+ } from "./chunk-SKC7AJIV.mjs";
4
+
5
+ // src/lib/status-checker.ts
6
+ import {
7
+ COPILOT_CLOUD_API_URL,
8
+ COPILOT_CLOUD_PUBLIC_API_KEY_HEADER
9
+ } from "@copilotkit/shared";
10
+ var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
11
+ var StatusChecker = class {
12
+ constructor() {
13
+ this.activeKey = null;
14
+ this.intervalId = null;
15
+ this.instanceCount = 0;
16
+ this.lastResponse = null;
17
+ }
18
+ start(publicApiKey, onUpdate) {
19
+ return __async(this, null, function* () {
20
+ this.instanceCount++;
21
+ if (this.activeKey === publicApiKey)
22
+ return;
23
+ if (this.intervalId)
24
+ clearInterval(this.intervalId);
25
+ const checkStatus = () => __async(this, null, function* () {
26
+ try {
27
+ const response = yield fetch(`${COPILOT_CLOUD_API_URL}/ciu`, {
28
+ method: "GET",
29
+ headers: {
30
+ [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
31
+ }
32
+ }).then((response2) => response2.json());
33
+ this.lastResponse = response;
34
+ onUpdate == null ? void 0 : onUpdate(response);
35
+ return response;
36
+ } catch (error) {
37
+ return null;
38
+ }
39
+ });
40
+ const initialResponse = yield checkStatus();
41
+ this.intervalId = setInterval(checkStatus, STATUS_CHECK_INTERVAL);
42
+ this.activeKey = publicApiKey;
43
+ return initialResponse;
44
+ });
45
+ }
46
+ getLastResponse() {
47
+ return this.lastResponse;
48
+ }
49
+ stop() {
50
+ this.instanceCount--;
51
+ if (this.instanceCount === 0) {
52
+ if (this.intervalId) {
53
+ clearInterval(this.intervalId);
54
+ this.intervalId = null;
55
+ this.activeKey = null;
56
+ this.lastResponse = null;
57
+ }
58
+ }
59
+ }
60
+ };
61
+
62
+ export {
63
+ StatusChecker
64
+ };
65
+ //# sourceMappingURL=chunk-PMAFHQ7P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/status-checker.ts"],"sourcesContent":["import {\n COPILOT_CLOUD_API_URL,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n Severity,\n} from \"@copilotkit/shared\";\n\nconst STATUS_CHECK_INTERVAL = 1000 * 60 * 5; // 5 minutes\n\nexport type Status = {\n severity: Severity;\n message: string;\n};\n\nexport class StatusChecker {\n private activeKey: string | null = null;\n private intervalId: ReturnType<typeof setInterval> | null = null;\n private instanceCount = 0;\n private lastResponse: Status | null = null;\n\n async start(publicApiKey: string, onUpdate?: (status: Status | null) => void) {\n this.instanceCount++;\n if (this.activeKey === publicApiKey) return;\n\n if (this.intervalId) clearInterval(this.intervalId);\n\n const checkStatus = async () => {\n try {\n const response = await fetch(`${COPILOT_CLOUD_API_URL}/ciu`, {\n method: \"GET\",\n headers: {\n [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey,\n },\n }).then((response) => response.json() as Promise<Status>);\n this.lastResponse = response;\n onUpdate?.(response);\n return response;\n } catch (error) {\n // Silently fail\n return null;\n }\n };\n\n const initialResponse = await checkStatus();\n this.intervalId = setInterval(checkStatus, STATUS_CHECK_INTERVAL);\n this.activeKey = publicApiKey;\n return initialResponse;\n }\n\n getLastResponse() {\n return this.lastResponse;\n }\n\n stop() {\n this.instanceCount--;\n if (this.instanceCount === 0) {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.activeKey = null;\n this.lastResponse = null;\n }\n }\n }\n}\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,IAAM,wBAAwB,MAAO,KAAK;AAOnC,IAAM,gBAAN,MAAoB;AAAA,EAApB;AACL,SAAQ,YAA2B;AACnC,SAAQ,aAAoD;AAC5D,SAAQ,gBAAgB;AACxB,SAAQ,eAA8B;AAAA;AAAA,EAEhC,MAAM,cAAsB,UAA4C;AAAA;AAC5E,WAAK;AACL,UAAI,KAAK,cAAc;AAAc;AAErC,UAAI,KAAK;AAAY,sBAAc,KAAK,UAAU;AAElD,YAAM,cAAc,MAAY;AAC9B,YAAI;AACF,gBAAM,WAAW,MAAM,MAAM,GAAG,6BAA6B;AAAA,YAC3D,QAAQ;AAAA,YACR,SAAS;AAAA,cACP,CAAC,mCAAmC,GAAG;AAAA,YACzC;AAAA,UACF,CAAC,EAAE,KAAK,CAACA,cAAaA,UAAS,KAAK,CAAoB;AACxD,eAAK,eAAe;AACpB,+CAAW;AACX,iBAAO;AAAA,QACT,SAAS,OAAP;AAEA,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,YAAM,kBAAkB,MAAM,YAAY;AAC1C,WAAK,aAAa,YAAY,aAAa,qBAAqB;AAChE,WAAK,YAAY;AACjB,aAAO;AAAA,IACT;AAAA;AAAA,EAEA,kBAAkB;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,OAAO;AACL,SAAK;AACL,QAAI,KAAK,kBAAkB,GAAG;AAC5B,UAAI,KAAK,YAAY;AACnB,sBAAc,KAAK,UAAU;AAC7B,aAAK,aAAa;AAClB,aAAK,YAAY;AACjB,aAAK,eAAe;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":["response"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  useCopilotAction
3
- } from "./chunk-EXX267DG.mjs";
3
+ } from "./chunk-YJT6IYNV.mjs";
4
4
  import {
5
5
  useCopilotContext
6
- } from "./chunk-YVQNSJ4Z.mjs";
6
+ } from "./chunk-RKYHRYN3.mjs";
7
7
  import {
8
8
  __spreadProps,
9
9
  __spreadValues
@@ -12,8 +12,8 @@ import {
12
12
  // src/hooks/use-copilot-authenticated-action.ts
13
13
  import { Fragment, useCallback, useRef } from "react";
14
14
  import React from "react";
15
- function useCopilotAuthenticatedAction(action, dependencies) {
16
- const { authConfig, authStates, setAuthStates } = useCopilotContext();
15
+ function useCopilotAuthenticatedAction_c(action, dependencies) {
16
+ const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
17
17
  const pendingActionRef = useRef(null);
18
18
  const executeAction = useCallback(
19
19
  (props) => {
@@ -26,14 +26,14 @@ function useCopilotAuthenticatedAction(action, dependencies) {
26
26
  );
27
27
  const wrappedRender = useCallback(
28
28
  (props) => {
29
- const isAuthenticated = Object.values(authStates || {}).some(
29
+ const isAuthenticated = Object.values(authStates_c || {}).some(
30
30
  (state) => state.status === "authenticated"
31
31
  );
32
32
  if (!isAuthenticated) {
33
33
  pendingActionRef.current = props;
34
- return (authConfig == null ? void 0 : authConfig.SignInComponent) ? React.createElement(authConfig.SignInComponent, {
34
+ return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? React.createElement(authConfig_c.SignInComponent, {
35
35
  onSignInComplete: (authState) => {
36
- setAuthStates == null ? void 0 : setAuthStates((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
36
+ setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
37
37
  if (pendingActionRef.current) {
38
38
  executeAction(pendingActionRef.current);
39
39
  pendingActionRef.current = null;
@@ -43,7 +43,7 @@ function useCopilotAuthenticatedAction(action, dependencies) {
43
43
  }
44
44
  return executeAction(props);
45
45
  },
46
- [action, authStates, setAuthStates]
46
+ [action, authStates_c, setAuthStates_c]
47
47
  );
48
48
  useCopilotAction(
49
49
  __spreadProps(__spreadValues({}, action), {
@@ -54,6 +54,6 @@ function useCopilotAuthenticatedAction(action, dependencies) {
54
54
  }
55
55
 
56
56
  export {
57
- useCopilotAuthenticatedAction
57
+ useCopilotAuthenticatedAction_c
58
58
  };
59
- //# sourceMappingURL=chunk-MF4F77OY.mjs.map
59
+ //# sourceMappingURL=chunk-PMHLIIAI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-authenticated-action.ts"],"sourcesContent":["import { Parameter } from \"@copilotkit/shared\";\nimport { Fragment, useCallback, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { FrontendAction, ActionRenderProps } from \"../types/frontend-action\";\nimport { useCopilotAction } from \"./use-copilot-action\";\nimport React from \"react\";\n\n/**\n * Hook to create an authenticated action that requires user sign-in before execution.\n *\n * @remarks\n * This feature is only available when using CopilotKit's hosted cloud service.\n * To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey.\n *\n * @param action - The frontend action to be wrapped with authentication\n * @param dependencies - Optional array of dependencies that will trigger recreation of the action when changed\n */\nexport function useCopilotAuthenticatedAction_c<T extends Parameter[]>(\n action: FrontendAction<T>,\n dependencies?: any[],\n): void {\n const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();\n const pendingActionRef = useRef<ActionRenderProps<Parameter[]> | null>(null);\n\n const executeAction = useCallback(\n (props: ActionRenderProps<Parameter[]>) => {\n if (typeof action.render === \"function\") {\n return action.render(props);\n }\n return action.render || React.createElement(Fragment);\n },\n [action],\n );\n\n const wrappedRender = useCallback(\n (props: ActionRenderProps<Parameter[]>): string | React.ReactElement => {\n const isAuthenticated = Object.values(authStates_c || {}).some(\n (state) => state.status === \"authenticated\",\n );\n\n if (!isAuthenticated) {\n // Store action details for later execution\n pendingActionRef.current = props;\n\n return authConfig_c?.SignInComponent\n ? React.createElement(authConfig_c.SignInComponent, {\n onSignInComplete: (authState) => {\n setAuthStates_c?.((prev) => ({ ...prev, [action.name]: authState }));\n if (pendingActionRef.current) {\n executeAction(pendingActionRef.current);\n pendingActionRef.current = null;\n }\n },\n })\n : React.createElement(Fragment);\n }\n\n return executeAction(props);\n },\n [action, authStates_c, setAuthStates_c],\n );\n\n useCopilotAction(\n {\n ...action,\n render: wrappedRender,\n } as FrontendAction<T>,\n dependencies,\n );\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,UAAU,aAAa,cAAc;AAI9C,OAAO,WAAW;AAYX,SAAS,gCACd,QACA,cACM;AACN,QAAM,EAAE,cAAc,cAAc,gBAAgB,IAAI,kBAAkB;AAC1E,QAAM,mBAAmB,OAA8C,IAAI;AAE3E,QAAM,gBAAgB;AAAA,IACpB,CAAC,UAA0C;AACzC,UAAI,OAAO,OAAO,WAAW,YAAY;AACvC,eAAO,OAAO,OAAO,KAAK;AAAA,MAC5B;AACA,aAAO,OAAO,UAAU,MAAM,cAAc,QAAQ;AAAA,IACtD;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,UAAuE;AACtE,YAAM,kBAAkB,OAAO,OAAO,gBAAgB,CAAC,CAAC,EAAE;AAAA,QACxD,CAAC,UAAU,MAAM,WAAW;AAAA,MAC9B;AAEA,UAAI,CAAC,iBAAiB;AAEpB,yBAAiB,UAAU;AAE3B,gBAAO,6CAAc,mBACjB,MAAM,cAAc,aAAa,iBAAiB;AAAA,UAChD,kBAAkB,CAAC,cAAc;AAC/B,+DAAkB,CAAC,SAAU,iCAAK,OAAL,EAAW,CAAC,OAAO,IAAI,GAAG,UAAU;AACjE,gBAAI,iBAAiB,SAAS;AAC5B,4BAAc,iBAAiB,OAAO;AACtC,+BAAiB,UAAU;AAAA,YAC7B;AAAA,UACF;AAAA,QACF,CAAC,IACD,MAAM,cAAc,QAAQ;AAAA,MAClC;AAEA,aAAO,cAAc,KAAK;AAAA,IAC5B;AAAA,IACA,CAAC,QAAQ,cAAc,eAAe;AAAA,EACxC;AAEA;AAAA,IACE,iCACK,SADL;AAAA,MAEE,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -87,4 +87,4 @@ export {
87
87
  CopilotContext,
88
88
  useCopilotContext
89
89
  };
90
- //# sourceMappingURL=chunk-YVQNSJ4Z.mjs.map
90
+ //# sourceMappingURL=chunk-RKYHRYN3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n}\n\nexport type InChatRenderFunction = (\n props: ActionRenderProps<any> | CatchAllActionRenderProps<any>,\n) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates?: Record<ActionName, AuthState>;\n setAuthStates?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;AAMA,OAAO,WAAW;AAsMlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,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C;AACxD,QAAM,UAAU,MAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,QAAc;AAC9C,QAAM,IAAI,MAAM,uEAAuE;AACzF;","names":[]}
1
+ {"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n}\n\nexport type InChatRenderFunction = (\n props: ActionRenderProps<any> | CatchAllActionRenderProps<any>,\n) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Pick<ForwardedParametersInput, \"temperature\">;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;AAMA,OAAO,WAAW;AAsMlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EA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EAAC;AAAA,EACpB,OAAO;AAAA,EACP,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,wBAAwB,EAAE,SAAS,KAAK;AAAA,EACxC,iBAAiB,CAAC;AAAA,EAClB,YAAY,CAAC;AAAA,EACb,eAAe,MAAM;AAAA,EAAC;AACxB;AAEO,IAAM,iBAAiB,MAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,MAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,QAAc;AAC9C,QAAM,IAAI,MAAM,uEAAuE;AACzF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotContext
3
- } from "./chunk-YVQNSJ4Z.mjs";
3
+ } from "./chunk-RKYHRYN3.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-J6UBNKIR.mjs.map
23
+ //# sourceMappingURL=chunk-S5MSFDGS.mjs.map