@copilotkit/react-core 1.5.1-next.2 → 1.5.1-next.3
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.
- package/CHANGELOG.md +9 -0
- package/dist/{chunk-LNI2Z45S.mjs → chunk-2KCEHGSI.mjs} +50 -100
- package/dist/chunk-2KCEHGSI.mjs.map +1 -0
- package/dist/{chunk-2KT73RVG.mjs → chunk-6OR25P32.mjs} +19 -75
- package/dist/chunk-6OR25P32.mjs.map +1 -0
- package/dist/{chunk-3GQPEN4M.mjs → chunk-DDVXFNYA.mjs} +32 -66
- package/dist/chunk-DDVXFNYA.mjs.map +1 -0
- package/dist/{chunk-XOQMISG3.mjs → chunk-FXHKK52V.mjs} +13 -14
- package/dist/chunk-FXHKK52V.mjs.map +1 -0
- package/dist/{chunk-HIUT2NLX.mjs → chunk-H4VZMKR6.mjs} +2 -2
- package/dist/{chunk-X36DNILG.mjs → chunk-H7LSKIDK.mjs} +23 -71
- package/dist/chunk-H7LSKIDK.mjs.map +1 -0
- package/dist/chunk-JDQCJCAQ.mjs +295 -0
- package/dist/chunk-JDQCJCAQ.mjs.map +1 -0
- package/dist/chunk-L34MHAXR.mjs +1 -0
- package/dist/{chunk-WXREY7UP.mjs → chunk-LODRWFMB.mjs} +4 -16
- package/dist/chunk-LODRWFMB.mjs.map +1 -0
- package/dist/{chunk-EWKJMQOF.mjs → chunk-MWZO6TUR.mjs} +13 -29
- package/dist/chunk-MWZO6TUR.mjs.map +1 -0
- package/dist/{chunk-6BQVZFNO.mjs → chunk-ODN4H66E.mjs} +2 -6
- package/dist/chunk-ODN4H66E.mjs.map +1 -0
- package/dist/{chunk-FQ53HQYZ.mjs → chunk-QDGDXRRJ.mjs} +2 -2
- package/dist/{chunk-22XKTBPF.mjs → chunk-XINZBP3J.mjs} +3 -15
- package/dist/chunk-XINZBP3J.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +0 -9
- package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -21
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +0 -9
- package/dist/components/copilot-provider/copilotkit.js +95 -224
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +8 -9
- package/dist/components/copilot-provider/index.d.ts +0 -9
- package/dist/components/copilot-provider/index.js +95 -224
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +8 -9
- package/dist/components/index.d.ts +0 -9
- package/dist/components/index.js +95 -224
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -9
- package/dist/components/toast/toast-provider.d.ts +1 -2
- package/dist/components/toast/toast-provider.js +63 -77
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/context/copilot-context.d.ts +4 -37
- package/dist/context/copilot-context.js +3 -15
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +3 -15
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/hooks/index.d.ts +1 -3
- package/dist/hooks/index.js +297 -703
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +23 -35
- package/dist/hooks/use-chat.d.ts +3 -35
- package/dist/hooks/use-chat.js +205 -453
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +3 -4
- package/dist/hooks/use-coagent-state-render.d.ts +2 -2
- package/dist/hooks/use-coagent-state-render.js +8 -43
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -4
- package/dist/hooks/use-coagent.d.ts +1 -14
- package/dist/hooks/use-coagent.js +265 -603
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +12 -20
- package/dist/hooks/use-copilot-action.d.ts +2 -12
- package/dist/hooks/use-copilot-action.js +19 -169
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -4
- package/dist/hooks/use-copilot-chat.d.ts +0 -2
- package/dist/hooks/use-copilot-chat.js +240 -545
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +11 -13
- package/dist/hooks/use-copilot-readable.js +3 -15
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.js +4 -110
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.js +3 -15
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +398 -812
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -43
- package/dist/lib/copilot-task.d.ts +1 -6
- package/dist/lib/copilot-task.js +17 -55
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +9 -11
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +17 -55
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -11
- package/dist/types/frontend-action.d.ts +2 -21
- package/dist/types/frontend-action.js +0 -34
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/types/frontend-action.mjs +0 -7
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/extract.d.ts +2 -3
- package/dist/utils/extract.js +3 -21
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +8 -9
- package/dist/utils/index.js +3 -21
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +9 -10
- package/package.json +5 -5
- package/dist/chunk-22XKTBPF.mjs.map +0 -1
- package/dist/chunk-2KT73RVG.mjs.map +0 -1
- package/dist/chunk-3GQPEN4M.mjs.map +0 -1
- package/dist/chunk-6BQVZFNO.mjs.map +0 -1
- package/dist/chunk-EWKJMQOF.mjs.map +0 -1
- package/dist/chunk-LHKIIAUQ.mjs +0 -59
- package/dist/chunk-LHKIIAUQ.mjs.map +0 -1
- package/dist/chunk-LNI2Z45S.mjs.map +0 -1
- package/dist/chunk-NR2BTA6Z.mjs +0 -1
- package/dist/chunk-VGOFRULA.mjs +0 -401
- package/dist/chunk-VGOFRULA.mjs.map +0 -1
- package/dist/chunk-VNTDIJSG.mjs +0 -37
- package/dist/chunk-VNTDIJSG.mjs.map +0 -1
- package/dist/chunk-WXREY7UP.mjs.map +0 -1
- package/dist/chunk-X36DNILG.mjs.map +0 -1
- package/dist/chunk-XERJQUHA.mjs +0 -31
- package/dist/chunk-XERJQUHA.mjs.map +0 -1
- package/dist/chunk-XOQMISG3.mjs.map +0 -1
- package/dist/components/error-boundary/error-boundary.d.ts +0 -22
- package/dist/components/error-boundary/error-boundary.js +0 -183
- package/dist/components/error-boundary/error-boundary.js.map +0 -1
- package/dist/components/error-boundary/error-boundary.mjs +0 -12
- package/dist/components/error-boundary/error-boundary.mjs.map +0 -1
- package/dist/components/error-boundary/error-utils.d.ts +0 -11
- package/dist/components/error-boundary/error-utils.js +0 -177
- package/dist/components/error-boundary/error-utils.js.map +0 -1
- package/dist/components/error-boundary/error-utils.mjs +0 -13
- package/dist/components/error-boundary/error-utils.mjs.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.d.ts +0 -8
- package/dist/hooks/use-copilot-authenticated-action.js +0 -418
- package/dist/hooks/use-copilot-authenticated-action.js.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +0 -12
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +0 -1
- /package/dist/{chunk-HIUT2NLX.mjs.map → chunk-H4VZMKR6.mjs.map} +0 -0
- /package/dist/{chunk-NR2BTA6Z.mjs.map → chunk-L34MHAXR.mjs.map} +0 -0
- /package/dist/{chunk-FQ53HQYZ.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,14 +2,10 @@ import {
|
|
|
2
2
|
ExclamationMarkIcon
|
|
3
3
|
} from "./chunk-O7ARI5CV.mjs";
|
|
4
4
|
import {
|
|
5
|
-
__async,
|
|
6
5
|
__spreadProps,
|
|
7
6
|
__spreadValues
|
|
8
7
|
} from "./chunk-SKC7AJIV.mjs";
|
|
9
8
|
|
|
10
|
-
// src/components/error-boundary/error-utils.tsx
|
|
11
|
-
import { useCallback as useCallback2 } from "react";
|
|
12
|
-
|
|
13
9
|
// src/components/toast/toast-provider.tsx
|
|
14
10
|
import { createContext, useContext, useState, useCallback } from "react";
|
|
15
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -27,13 +23,8 @@ function ToastProvider({
|
|
|
27
23
|
}) {
|
|
28
24
|
const [toasts, setToasts] = useState([]);
|
|
29
25
|
const addToast = useCallback((toast) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setToasts((currentToasts) => {
|
|
33
|
-
if (currentToasts.find((toast2) => toast2.id === id))
|
|
34
|
-
return currentToasts;
|
|
35
|
-
return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
|
|
36
|
-
});
|
|
26
|
+
const id = Math.random().toString(36).substring(2, 9);
|
|
27
|
+
setToasts((currentToasts) => [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })]);
|
|
37
28
|
if (toast.duration) {
|
|
38
29
|
setTimeout(() => {
|
|
39
30
|
removeToast(id);
|
|
@@ -41,9 +32,54 @@ function ToastProvider({
|
|
|
41
32
|
}
|
|
42
33
|
}, []);
|
|
43
34
|
const addGraphQLErrorsToast = useCallback((errors) => {
|
|
35
|
+
const errorsToRender = errors.map((error, idx) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const message = error.message;
|
|
38
|
+
const code = (_a = error.extensions) == null ? void 0 : _a.code;
|
|
39
|
+
return /* @__PURE__ */ jsxs(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
style: {
|
|
43
|
+
marginTop: idx === 0 ? 0 : 10,
|
|
44
|
+
marginBottom: 14
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
48
|
+
code && /* @__PURE__ */ jsxs(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
style: {
|
|
52
|
+
fontWeight: "600",
|
|
53
|
+
marginBottom: 4
|
|
54
|
+
},
|
|
55
|
+
children: [
|
|
56
|
+
"Copilot Cloud Error:",
|
|
57
|
+
" ",
|
|
58
|
+
/* @__PURE__ */ jsx("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ jsx("div", { children: message })
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
idx
|
|
66
|
+
);
|
|
67
|
+
});
|
|
44
68
|
addToast({
|
|
45
69
|
type: "error",
|
|
46
|
-
message: /* @__PURE__ */
|
|
70
|
+
message: /* @__PURE__ */ jsxs(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
style: {
|
|
74
|
+
fontSize: "13px",
|
|
75
|
+
maxWidth: "600px"
|
|
76
|
+
},
|
|
77
|
+
children: [
|
|
78
|
+
errorsToRender,
|
|
79
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This is a Copilot Cloud error, and it only displays during local development." })
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
)
|
|
47
83
|
});
|
|
48
84
|
}, []);
|
|
49
85
|
const removeToast = useCallback((id) => {
|
|
@@ -118,7 +154,7 @@ function Toast({
|
|
|
118
154
|
style: {
|
|
119
155
|
backgroundColor: bgColors[type],
|
|
120
156
|
color: "white",
|
|
121
|
-
padding: "0.5rem
|
|
157
|
+
padding: "0.5rem 1rem",
|
|
122
158
|
borderRadius: "0.25rem",
|
|
123
159
|
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
124
160
|
position: "relative",
|
|
@@ -149,94 +185,8 @@ function Toast({
|
|
|
149
185
|
);
|
|
150
186
|
}
|
|
151
187
|
|
|
152
|
-
// src/components/error-boundary/error-utils.tsx
|
|
153
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
154
|
-
function ErrorToast({ errors }) {
|
|
155
|
-
const errorsToRender = errors.map((error, idx) => {
|
|
156
|
-
var _a, _b, _c;
|
|
157
|
-
const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
|
|
158
|
-
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
159
|
-
return /* @__PURE__ */ jsxs2(
|
|
160
|
-
"div",
|
|
161
|
-
{
|
|
162
|
-
style: {
|
|
163
|
-
marginTop: idx === 0 ? 0 : 10,
|
|
164
|
-
marginBottom: 14
|
|
165
|
-
},
|
|
166
|
-
children: [
|
|
167
|
-
/* @__PURE__ */ jsx2(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
168
|
-
code && /* @__PURE__ */ jsxs2(
|
|
169
|
-
"div",
|
|
170
|
-
{
|
|
171
|
-
style: {
|
|
172
|
-
fontWeight: "600",
|
|
173
|
-
marginBottom: 4
|
|
174
|
-
},
|
|
175
|
-
children: [
|
|
176
|
-
"Copilot Cloud Error:",
|
|
177
|
-
" ",
|
|
178
|
-
/* @__PURE__ */ jsx2("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
179
|
-
]
|
|
180
|
-
}
|
|
181
|
-
),
|
|
182
|
-
/* @__PURE__ */ jsx2("div", { children: message })
|
|
183
|
-
]
|
|
184
|
-
},
|
|
185
|
-
idx
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
return /* @__PURE__ */ jsxs2(
|
|
189
|
-
"div",
|
|
190
|
-
{
|
|
191
|
-
style: {
|
|
192
|
-
fontSize: "13px",
|
|
193
|
-
maxWidth: "600px"
|
|
194
|
-
},
|
|
195
|
-
children: [
|
|
196
|
-
errorsToRender,
|
|
197
|
-
/* @__PURE__ */ jsx2("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
function useErrorToast() {
|
|
203
|
-
const { addToast } = useToast();
|
|
204
|
-
return useCallback2(
|
|
205
|
-
(error) => {
|
|
206
|
-
const errorId = error.map((err) => {
|
|
207
|
-
var _a, _b;
|
|
208
|
-
const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
|
|
209
|
-
const stack = err.stack || "";
|
|
210
|
-
return btoa(message + stack).slice(0, 32);
|
|
211
|
-
}).join("|");
|
|
212
|
-
addToast({
|
|
213
|
-
type: "error",
|
|
214
|
-
id: errorId,
|
|
215
|
-
// Toast libraries typically dedupe by id
|
|
216
|
-
message: /* @__PURE__ */ jsx2(ErrorToast, { errors: error })
|
|
217
|
-
});
|
|
218
|
-
},
|
|
219
|
-
[addToast]
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
function useAsyncCallback(callback, deps) {
|
|
223
|
-
const addErrorToast = useErrorToast();
|
|
224
|
-
return useCallback2((...args) => __async(this, null, function* () {
|
|
225
|
-
try {
|
|
226
|
-
return yield callback(...args);
|
|
227
|
-
} catch (error) {
|
|
228
|
-
console.error("Error in async callback:", error);
|
|
229
|
-
addErrorToast([error]);
|
|
230
|
-
throw error;
|
|
231
|
-
}
|
|
232
|
-
}), deps);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
188
|
export {
|
|
236
|
-
ErrorToast,
|
|
237
|
-
useErrorToast,
|
|
238
|
-
useAsyncCallback,
|
|
239
189
|
useToast,
|
|
240
190
|
ToastProvider
|
|
241
191
|
};
|
|
242
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-2KCEHGSI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/toast/toast-provider.tsx"],"sourcesContent":["import { useCopilotContext } from \"../../context\";\nimport { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { ExclamationMarkIcon } from \"./exclamation-mark-icon\";\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: Omit<Toast, \"id\">) => void;\n addGraphQLErrorsToast: (errors: GraphQLError[]) => void;\n removeToast: (id: string) => void;\n enabled: boolean;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport function useToast() {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"useToast must be used within a ToastProvider\");\n }\n return context;\n}\n\nexport function ToastProvider({\n enabled,\n children,\n}: {\n enabled: boolean;\n children: React.ReactNode;\n}) {\n const [toasts, setToasts] = useState<Toast[]>([]);\n const addToast = useCallback((toast: Omit<Toast, \"id\">) => {\n const id = Math.random().toString(36).substring(2, 9);\n\n setToasts((currentToasts) => [...currentToasts, { ...toast, id }]);\n\n if (toast.duration) {\n setTimeout(() => {\n removeToast(id);\n }, toast.duration);\n }\n }, []);\n\n const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {\n // We do not display these errors unless we are in dev mode.\n // if (!showDevConsole) {\n // return;\n // }\n\n const errorsToRender = errors.map((error, idx) => {\n const message = error.message;\n const code = error.extensions?.code as string;\n\n return (\n <div\n key={idx}\n style={{\n marginTop: idx === 0 ? 0 : 10,\n marginBottom: 14,\n }}\n >\n <ExclamationMarkIcon style={{ marginBottom: 4 }} />\n\n {code && (\n <div\n style={{\n fontWeight: \"600\",\n marginBottom: 4,\n }}\n >\n Copilot Cloud Error:{\" \"}\n <span style={{ fontFamily: \"monospace\", fontWeight: \"normal\" }}>{code}</span>\n </div>\n )}\n <div>{message}</div>\n </div>\n );\n });\n\n addToast({\n type: \"error\",\n message: (\n <div\n style={{\n fontSize: \"13px\",\n maxWidth: \"600px\",\n }}\n >\n {errorsToRender}\n <div style={{ fontSize: \"11px\", opacity: 0.75 }}>\n NOTE: This is a Copilot Cloud error, and it only displays during local development.\n </div>\n </div>\n ),\n });\n }, []);\n\n const removeToast = useCallback((id: string) => {\n setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const value = {\n toasts,\n addToast,\n addGraphQLErrorsToast,\n removeToast,\n enabled,\n };\n\n return (\n <ToastContext.Provider value={value}>\n <div\n style={{\n position: \"fixed\",\n bottom: \"1rem\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 50,\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.5rem\",\n }}\n >\n {toasts.length > 1 && (\n <div style={{ textAlign: \"right\" }}>\n <button\n onClick={() => setToasts([])}\n style={{\n padding: \"4px 8px\",\n fontSize: \"12px\",\n cursor: \"pointer\",\n background: \"white\",\n border: \"1px solid rgba(0,0,0,0.2)\",\n borderRadius: \"4px\",\n }}\n >\n Close All\n </button>\n </div>\n )}\n {toasts.map((toast) => (\n <Toast\n key={toast.id}\n message={toast.message}\n type={toast.type}\n onClose={() => removeToast(toast.id)}\n />\n ))}\n </div>\n {children}\n </ToastContext.Provider>\n );\n}\n\nfunction Toast({\n message,\n type = \"info\",\n onClose,\n}: {\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n onClose: () => void;\n}) {\n const bgColors = {\n info: \"#3b82f6\",\n success: \"#22c55e\",\n warning: \"#eab308\",\n error: \"#ef4444\",\n };\n\n return (\n <div\n style={{\n backgroundColor: bgColors[type],\n color: \"white\",\n padding: \"0.5rem 1rem\",\n borderRadius: \"0.25rem\",\n boxShadow: \"0 2px 4px rgba(0,0,0,0.1)\",\n position: \"relative\",\n minWidth: \"200px\",\n }}\n >\n <div>{message}</div>\n <button\n onClick={onClose}\n style={{\n position: \"absolute\",\n top: \"0\",\n right: \"0\",\n background: \"none\",\n border: \"none\",\n color: \"white\",\n cursor: \"pointer\",\n padding: \"0.5rem\",\n fontSize: \"1rem\",\n }}\n >\n ✕\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAEA,SAAgB,eAAe,YAAY,UAAU,mBAAmB;AAkE9D,cAGE,YAHF;AAhDV,IAAM,eAAe,cAA6C,MAAS;AAEpE,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,GAGG;AACD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkB,CAAC,CAAC;AAChD,QAAM,WAAW,YAAY,CAAC,UAA6B;AACzD,UAAM,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AAEpD,cAAU,CAAC,kBAAkB,CAAC,GAAG,eAAe,iCAAK,QAAL,EAAY,GAAG,EAAC,CAAC;AAEjE,QAAI,MAAM,UAAU;AAClB,iBAAW,MAAM;AACf,oBAAY,EAAE;AAAA,MAChB,GAAG,MAAM,QAAQ;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,wBAAwB,YAAY,CAAC,WAA2B;AAMpE,UAAM,iBAAiB,OAAO,IAAI,CAAC,OAAO,QAAQ;AAxDtD;AAyDM,YAAM,UAAU,MAAM;AACtB,YAAM,QAAO,WAAM,eAAN,mBAAkB;AAE/B,aACE;AAAA,QAAC;AAAA;AAAA,UAEC,OAAO;AAAA,YACL,WAAW,QAAQ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|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
shouldShowDevConsole
|
|
6
|
-
} from "./chunk-MLAS4QUR.mjs";
|
|
7
|
-
import {
|
|
8
|
-
CopilotMessages
|
|
9
|
-
} from "./chunk-XXR4QFAQ.mjs";
|
|
2
|
+
use_flat_category_store_default
|
|
3
|
+
} from "./chunk-5FHSUKQL.mjs";
|
|
10
4
|
import {
|
|
11
5
|
use_tree_default
|
|
12
6
|
} from "./chunk-6U3UH3KO.mjs";
|
|
13
7
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
8
|
+
CopilotMessages
|
|
9
|
+
} from "./chunk-XXR4QFAQ.mjs";
|
|
16
10
|
import {
|
|
17
11
|
useCopilotRuntimeClient
|
|
18
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ODN4H66E.mjs";
|
|
13
|
+
import {
|
|
14
|
+
ToastProvider
|
|
15
|
+
} from "./chunk-2KCEHGSI.mjs";
|
|
19
16
|
import {
|
|
20
17
|
CopilotContext
|
|
21
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LODRWFMB.mjs";
|
|
22
19
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./chunk-
|
|
20
|
+
shouldShowDevConsole
|
|
21
|
+
} from "./chunk-MLAS4QUR.mjs";
|
|
25
22
|
import {
|
|
26
23
|
__async,
|
|
27
24
|
__objRest,
|
|
@@ -42,7 +39,7 @@ import {
|
|
|
42
39
|
} from "@copilotkit/runtime-client-gql";
|
|
43
40
|
|
|
44
41
|
// src/components/copilot-provider/copilotkit.tsx
|
|
45
|
-
import { useCallback,
|
|
42
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
46
43
|
import { flushSync } from "react-dom";
|
|
47
44
|
import {
|
|
48
45
|
COPILOT_CLOUD_CHAT_URL,
|
|
@@ -53,7 +50,7 @@ function CopilotKit(_a) {
|
|
|
53
50
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
54
51
|
const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
|
|
55
52
|
const enabled = shouldShowDevConsole(showDevConsole);
|
|
56
|
-
return /* @__PURE__ */ jsx(ToastProvider, { enabled, children: /* @__PURE__ */ jsx(
|
|
53
|
+
return /* @__PURE__ */ jsx(ToastProvider, { enabled, children: /* @__PURE__ */ jsx(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) });
|
|
57
54
|
}
|
|
58
55
|
function CopilotKitInternal(_a) {
|
|
59
56
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
@@ -72,7 +69,6 @@ function CopilotKitInternal(_a) {
|
|
|
72
69
|
const { addElement, removeElement, printTree } = use_tree_default();
|
|
73
70
|
const [isLoading, setIsLoading] = useState(false);
|
|
74
71
|
const [chatInstructions, setChatInstructions] = useState("");
|
|
75
|
-
const [authStates, setAuthStates] = useState({});
|
|
76
72
|
const {
|
|
77
73
|
addElement: addDocument,
|
|
78
74
|
removeElement: removeDocument,
|
|
@@ -197,20 +193,7 @@ ${nonDocumentStrings}`;
|
|
|
197
193
|
props.credentials,
|
|
198
194
|
props.cloudRestrictToTopic
|
|
199
195
|
]);
|
|
200
|
-
const headers =
|
|
201
|
-
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
202
|
-
if (state.status === "authenticated" && state.authHeaders) {
|
|
203
|
-
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
204
|
-
(headers2, [key, value]) => __spreadProps(__spreadValues({}, headers2), {
|
|
205
|
-
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
206
|
-
}),
|
|
207
|
-
{}
|
|
208
|
-
));
|
|
209
|
-
}
|
|
210
|
-
return acc;
|
|
211
|
-
}, {});
|
|
212
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
213
|
-
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
196
|
+
const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
|
|
214
197
|
const runtimeClient = useCopilotRuntimeClient({
|
|
215
198
|
url: copilotApiConfig.chatApiEndpoint,
|
|
216
199
|
publicApiKey: copilotApiConfig.publicApiKey,
|
|
@@ -227,29 +210,7 @@ ${nonDocumentStrings}`;
|
|
|
227
210
|
return rest;
|
|
228
211
|
});
|
|
229
212
|
};
|
|
230
|
-
const [availableAgents, setAvailableAgents] = useState([]);
|
|
231
213
|
const [coagentStates, setCoagentStates] = useState({});
|
|
232
|
-
const coagentStatesRef = useRef({});
|
|
233
|
-
const setCoagentStatesWithRef = useCallback(
|
|
234
|
-
(value) => {
|
|
235
|
-
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
236
|
-
coagentStatesRef.current = newValue;
|
|
237
|
-
setCoagentStates((prev) => {
|
|
238
|
-
return newValue;
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
[]
|
|
242
|
-
);
|
|
243
|
-
useEffect(() => {
|
|
244
|
-
const fetchData = () => __async(this, null, function* () {
|
|
245
|
-
var _a2;
|
|
246
|
-
const result = yield runtimeClient.availableAgents();
|
|
247
|
-
if ((_a2 = result.data) == null ? void 0 : _a2.availableAgents) {
|
|
248
|
-
setAvailableAgents(result.data.availableAgents.agents);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
void fetchData();
|
|
252
|
-
}, []);
|
|
253
214
|
let initialAgentSession = null;
|
|
254
215
|
if (props.agent) {
|
|
255
216
|
initialAgentSession = {
|
|
@@ -257,9 +218,6 @@ ${nonDocumentStrings}`;
|
|
|
257
218
|
};
|
|
258
219
|
}
|
|
259
220
|
const [agentSession, setAgentSession] = useState(initialAgentSession);
|
|
260
|
-
const [threadId, setThreadId] = useState(null);
|
|
261
|
-
const [runId, setRunId] = useState(null);
|
|
262
|
-
const chatAbortControllerRef = useRef(null);
|
|
263
221
|
const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
|
|
264
222
|
return /* @__PURE__ */ jsx(
|
|
265
223
|
CopilotContext.Provider,
|
|
@@ -290,22 +248,9 @@ ${nonDocumentStrings}`;
|
|
|
290
248
|
showDevConsole,
|
|
291
249
|
coagentStates,
|
|
292
250
|
setCoagentStates,
|
|
293
|
-
coagentStatesRef,
|
|
294
|
-
setCoagentStatesWithRef,
|
|
295
251
|
agentSession,
|
|
296
252
|
setAgentSession,
|
|
297
|
-
runtimeClient
|
|
298
|
-
forwardedParameters: props.forwardedParameters || {},
|
|
299
|
-
agentLock: props.agent || null,
|
|
300
|
-
threadId,
|
|
301
|
-
setThreadId,
|
|
302
|
-
runId,
|
|
303
|
-
setRunId,
|
|
304
|
-
chatAbortControllerRef,
|
|
305
|
-
availableAgents,
|
|
306
|
-
authConfig: props.authConfig,
|
|
307
|
-
authStates,
|
|
308
|
-
setAuthStates
|
|
253
|
+
runtimeClient
|
|
309
254
|
},
|
|
310
255
|
children: /* @__PURE__ */ jsx(CopilotMessages, { children })
|
|
311
256
|
}
|
|
@@ -352,8 +297,7 @@ function extract(_0) {
|
|
|
352
297
|
data,
|
|
353
298
|
abortSignal,
|
|
354
299
|
stream,
|
|
355
|
-
requestType = CopilotRequestType.Task
|
|
356
|
-
forwardedParameters
|
|
300
|
+
requestType = CopilotRequestType.Task
|
|
357
301
|
}) {
|
|
358
302
|
var _a, _b;
|
|
359
303
|
const { messages } = context;
|
|
@@ -400,10 +344,10 @@ function extract(_0) {
|
|
|
400
344
|
metadata: {
|
|
401
345
|
requestType
|
|
402
346
|
},
|
|
403
|
-
forwardedParameters:
|
|
347
|
+
forwardedParameters: {
|
|
404
348
|
toolChoice: "function",
|
|
405
349
|
toolChoiceFunctionName: action.name
|
|
406
|
-
}
|
|
350
|
+
}
|
|
407
351
|
},
|
|
408
352
|
properties: context.copilotApiConfig.properties,
|
|
409
353
|
signal: abortSignal
|
|
@@ -479,4 +423,4 @@ export {
|
|
|
479
423
|
CopilotKitInternal,
|
|
480
424
|
defaultCopilotContextCategories
|
|
481
425
|
};
|
|
482
|
-
//# sourceMappingURL=chunk-
|
|
426
|
+
//# sourceMappingURL=chunk-6OR25P32.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/extract.ts","../src/components/copilot-provider/copilotkit.tsx"],"sourcesContent":["import {\n Action,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n MappedParameterTypes,\n Parameter,\n actionParametersToJsonSchema,\n} from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessage,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\nimport { CopilotContextParams, CopilotMessagesContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { CopilotRuntimeClient } from \"@copilotkit/runtime-client-gql\";\nimport {\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n} from \"@copilotkit/runtime-client-gql\";\n\ninterface InitialState<T extends Parameter[] | [] = []> {\n status: \"initial\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface InProgressState<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface CompleteState<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n}\n\ntype StreamHandlerArgs<T extends Parameter[] | [] = []> =\n | InitialState<T>\n | InProgressState<T>\n | CompleteState<T>;\n\ninterface ExtractOptions<T extends Parameter[]> {\n context: CopilotContextParams & CopilotMessagesContextParams;\n instructions: string;\n parameters: T;\n include?: IncludeOptions;\n data?: any;\n abortSignal?: AbortSignal;\n stream?: (args: StreamHandlerArgs<T>) => void;\n requestType?: CopilotRequestType;\n}\n\ninterface IncludeOptions {\n readable?: boolean;\n messages?: boolean;\n}\n\nexport async function extract<const T extends Parameter[]>({\n context,\n instructions,\n parameters,\n include,\n data,\n abortSignal,\n stream,\n requestType = CopilotRequestType.Task,\n}: ExtractOptions<T>): Promise<MappedParameterTypes<T>> {\n const { messages } = context;\n\n const action: Action<any> = {\n name: \"extract\",\n description: instructions,\n parameters,\n handler: (args: any) => {},\n };\n\n const includeReadable = include?.readable ?? false;\n const includeMessages = include?.messages ?? false;\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (includeReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage: Message = new TextMessage({\n content: makeSystemMessage(contextString, instructions),\n role: Role.System,\n });\n\n const instructionsMessage: Message = new TextMessage({\n content: makeInstructionsMessage(instructions),\n role: Role.User,\n });\n\n const response = context.runtimeClient.asStream(\n context.runtimeClient.generateCopilotResponse({\n data: {\n frontend: {\n actions: [\n {\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n },\n ],\n url: window.location.href,\n },\n\n messages: convertMessagesToGqlInput(\n includeMessages\n ? [systemMessage, instructionsMessage, ...filterAgentStateMessages(messages)]\n : [systemMessage, instructionsMessage],\n ),\n metadata: {\n requestType: requestType,\n },\n forwardedParameters: {\n toolChoice: \"function\",\n toolChoiceFunctionName: action.name,\n },\n },\n properties: context.copilotApiConfig.properties,\n signal: abortSignal,\n }),\n );\n\n const reader = response.getReader();\n\n let isInitial = true;\n\n let actionExecutionMessage: ActionExecutionMessage | undefined = undefined;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n break;\n }\n\n if (abortSignal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n actionExecutionMessage = convertGqlOutputToMessages(\n value.generateCopilotResponse.messages,\n ).find((msg) => msg.isActionExecutionMessage()) as ActionExecutionMessage | undefined;\n\n if (!actionExecutionMessage) {\n continue;\n }\n\n stream?.({\n status: isInitial ? \"initial\" : \"inProgress\",\n args: actionExecutionMessage.arguments as Partial<MappedParameterTypes<T>>,\n });\n\n isInitial = false;\n }\n\n if (!actionExecutionMessage) {\n throw new Error(\"extract() failed: No function call occurred\");\n }\n\n stream?.({\n status: \"complete\",\n args: actionExecutionMessage.arguments as MappedParameterTypes<T>,\n });\n\n return actionExecutionMessage.arguments as MappedParameterTypes<T>;\n}\n\n// We need to put this in a user message since some LLMs need\n// at least one user message to function\nfunction makeInstructionsMessage(instructions: string): string {\n return `\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n\nAny additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.\n`;\n}\n\nfunction makeSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with a function called extract you MUST call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call the function without saying anything else.\n`;\n}\n","/**\n * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.\n *\n * ## Example\n *\n * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).\n *\n * ```tsx\n * import { CopilotKit } from \"@copilotkit/react-core\";\n *\n * <CopilotKit runtimeUrl=\"<your-runtime-url>\">\n * // ... your app ...\n * </CopilotKit>\n * ```\n */\n\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n ChatComponentsCache,\n AgentSession,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { CopilotChatSuggestionConfiguration, DocumentPointer } from \"../../types\";\nimport { flushSync } from \"react-dom\";\nimport {\n COPILOT_CLOUD_CHAT_URL,\n CopilotCloudConfig,\n FunctionCallHandler,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n} from \"@copilotkit/shared\";\n\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { CoAgentStateRender } from \"../../types/coagent-action\";\nimport { CoagentState } from \"../../types/coagent-state\";\nimport { CopilotMessages } from \"./copilot-messages\";\nimport { ToastProvider } from \"../toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"../../hooks/use-copilot-runtime-client\";\nimport { shouldShowDevConsole } from \"../../utils\";\n\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n const enabled = shouldShowDevConsole(showDevConsole);\n return (\n <ToastProvider enabled={enabled}>\n <CopilotKitInternal {...props}>{children}</CopilotKitInternal>\n </ToastProvider>\n );\n}\n\nexport function CopilotKitInternal({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n if (!props.runtimeUrl && !props.publicApiKey) {\n throw new Error(\n \"Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component.\",\n );\n }\n\n const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;\n\n const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});\n const [coAgentStateRenders, setCoAgentStateRenders] = useState<\n Record<string, CoAgentStateRender<any>>\n >({});\n const chatComponentsCache = useRef<ChatComponentsCache>({\n actions: {},\n coAgentStateRenders: {},\n });\n const { addElement, removeElement, printTree } = useTree();\n const [isLoading, setIsLoading] = useState(false);\n const [chatInstructions, setChatInstructions] = useState(\"\");\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setAction = useCallback((id: string, action: FrontendAction<any>) => {\n setActions((prevPoints) => {\n return {\n ...prevPoints,\n [id]: action,\n };\n });\n }, []);\n\n const removeAction = useCallback((id: string) => {\n setActions((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {\n setCoAgentStateRenders((prevPoints) => {\n return {\n ...prevPoints,\n [id]: stateRender,\n };\n });\n }, []);\n\n const removeCoAgentStateRender = useCallback((id: string) => {\n setCoAgentStateRenders((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));\n },\n [actions],\n );\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n if (!props.publicApiKey) {\n if (props.cloudRestrictToTopic) {\n throw new Error(\n \"To use the cloudRestrictToTopic feature, please sign up at https://copilotkit.ai and provide a publicApiKey.\",\n );\n }\n }\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = useMemo(() => {\n let cloud: CopilotCloudConfig | undefined = undefined;\n if (props.publicApiKey) {\n cloud = {\n guardrails: {\n input: {\n restrictToTopic: {\n enabled: props.cloudRestrictToTopic ? true : false,\n validTopics: props.cloudRestrictToTopic?.validTopics || [],\n invalidTopics: props.cloudRestrictToTopic?.invalidTopics || [],\n },\n },\n },\n };\n }\n\n return {\n publicApiKey: props.publicApiKey,\n ...(cloud ? { cloud } : {}),\n chatApiEndpoint: chatApiEndpoint,\n headers: props.headers || {},\n properties: props.properties || {},\n transcribeAudioUrl: props.transcribeAudioUrl,\n textToSpeechUrl: props.textToSpeechUrl,\n credentials: props.credentials,\n };\n }, [\n props.publicApiKey,\n props.headers,\n props.properties,\n props.transcribeAudioUrl,\n props.textToSpeechUrl,\n props.credentials,\n props.cloudRestrictToTopic,\n ]);\n\n const headers = {\n ...(copilotApiConfig.headers || {}),\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n });\n\n const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{\n [key: string]: CopilotChatSuggestionConfiguration;\n }>({});\n\n const addChatSuggestionConfiguration = (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => {\n setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));\n };\n\n const removeChatSuggestionConfiguration = (id: string) => {\n setChatSuggestionConfiguration((prev) => {\n const { [id]: _, ...rest } = prev;\n return rest;\n });\n };\n\n const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});\n let initialAgentSession: AgentSession | null = null;\n if (props.agent) {\n initialAgentSession = {\n agentName: props.agent,\n };\n }\n\n const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);\n\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n\n return (\n <CopilotContext.Provider\n value={{\n actions,\n chatComponentsCache,\n getFunctionCallHandler,\n setAction,\n removeAction,\n coAgentStateRenders,\n setCoAgentStateRender,\n removeCoAgentStateRender,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n isLoading,\n setIsLoading,\n chatSuggestionConfiguration,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n chatInstructions,\n setChatInstructions,\n showDevConsole,\n coagentStates,\n setCoagentStates,\n agentSession,\n setAgentSession,\n runtimeClient,\n }}\n >\n <CopilotMessages>{children}</CopilotMessages>\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async ({ messages, name, args }) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[name];\n let result: any = undefined;\n if (action) {\n await new Promise<void>((resolve, reject) => {\n flushSync(async () => {\n try {\n result = await action.handler?.(args);\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n });\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n return result;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAKE;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACEP,SAAS,aAAa,SAAS,QAAQ,gBAAgB;AASvD,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EAGA;A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AM,wBAAwB;AAAA,MAChC,EAAE,KAAK,CAAC,QAAQ,IAAI,yBAAyB,CAAC;AAE9C,UAAI,CAAC,wBAAwB;AAC3B;AAAA,MACF;AAEA,uCAAS;AAAA,QACP,QAAQ,YAAY,YAAY;AAAA,QAChC,MAAM,uBAAuB;AAAA,MAC/B;AAEA,kBAAY;AAAA,IACd;AAEA,QAAI,CAAC,wBAAwB;AAC3B,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,qCAAS;AAAA,MACP,QAAQ;AAAA,MACR,MAAM,uBAAuB;AAAA,IAC/B;AAEA,WAAO,uBAAuB;AAAA,EAChC;AAAA;AAIA,SAAS,wBAAwB,cAA8B;AAC7D,SAAO;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA;AAAA;AAAA;AAAA;AAKF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;","names":["_a","_b","action"]}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
useCopilotMessagesContext
|
|
6
|
-
} from "./chunk-DCTJZ742.mjs";
|
|
3
|
+
} from "./chunk-H7LSKIDK.mjs";
|
|
7
4
|
import {
|
|
8
5
|
useCopilotContext
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LODRWFMB.mjs";
|
|
10
7
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-LNI2Z45S.mjs";
|
|
8
|
+
useCopilotMessagesContext
|
|
9
|
+
} from "./chunk-DCTJZ742.mjs";
|
|
14
10
|
import {
|
|
15
11
|
__async,
|
|
16
12
|
__spreadProps,
|
|
@@ -20,27 +16,18 @@ import {
|
|
|
20
16
|
// src/hooks/use-coagent.ts
|
|
21
17
|
import { useEffect } from "react";
|
|
22
18
|
function useCoAgent(options) {
|
|
23
|
-
const generalContext = useCopilotContext();
|
|
24
|
-
const { availableAgents } = generalContext;
|
|
25
|
-
const { addToast } = useToast();
|
|
26
19
|
const isExternalStateManagement = (options2) => {
|
|
27
20
|
return "state" in options2 && "setState" in options2;
|
|
28
21
|
};
|
|
29
22
|
const { name } = options;
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
|
|
32
|
-
const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
|
|
33
|
-
console.warn(message);
|
|
34
|
-
addToast({ type: "warning", message });
|
|
35
|
-
}
|
|
36
|
-
}, [availableAgents]);
|
|
37
23
|
const isInternalStateManagementWithInitial = (options2) => {
|
|
38
24
|
return "initialState" in options2;
|
|
39
25
|
};
|
|
26
|
+
const generalContext = useCopilotContext();
|
|
40
27
|
const messagesContext = useCopilotMessagesContext();
|
|
41
28
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
42
|
-
const { coagentStates,
|
|
43
|
-
const { appendMessage
|
|
29
|
+
const { coagentStates, setCoagentStates } = context;
|
|
30
|
+
const { appendMessage } = useCopilotChat();
|
|
44
31
|
const getCoagentState = (coagentStates2, name2) => {
|
|
45
32
|
if (coagentStates2[name2]) {
|
|
46
33
|
return coagentStates2[name2];
|
|
@@ -57,13 +44,15 @@ function useCoAgent(options) {
|
|
|
57
44
|
}
|
|
58
45
|
};
|
|
59
46
|
const setState = (newState) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
setCoagentStates((prevAgentStates) => {
|
|
48
|
+
let coagentState2 = getCoagentState(prevAgentStates, name);
|
|
49
|
+
const updatedState = typeof newState === "function" ? newState(coagentState2.state) : newState;
|
|
50
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
51
|
+
[name]: __spreadProps(__spreadValues({}, coagentState2), {
|
|
52
|
+
state: updatedState
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
});
|
|
67
56
|
};
|
|
68
57
|
const coagentState = getCoagentState(coagentStates, name);
|
|
69
58
|
const state = isExternalStateManagement(options) ? options.state : coagentState.state;
|
|
@@ -73,27 +62,22 @@ function useCoAgent(options) {
|
|
|
73
62
|
} else if (coagentStates[name] === void 0) {
|
|
74
63
|
setState(options.initialState === void 0 ? {} : options.initialState);
|
|
75
64
|
}
|
|
76
|
-
}, [
|
|
77
|
-
isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
|
|
78
|
-
// reset initialstate on reset
|
|
79
|
-
coagentStates[name] === void 0
|
|
80
|
-
]);
|
|
81
|
-
const runAgentCallback = useAsyncCallback(
|
|
82
|
-
(hint) => __async(this, null, function* () {
|
|
83
|
-
yield runAgent(name, context, appendMessage, runChatCompletion, hint);
|
|
84
|
-
}),
|
|
85
|
-
[name, context, appendMessage, runChatCompletion]
|
|
86
|
-
);
|
|
65
|
+
}, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
|
|
87
66
|
return {
|
|
88
67
|
name,
|
|
89
68
|
nodeName: coagentState.nodeName,
|
|
90
|
-
|
|
69
|
+
state,
|
|
70
|
+
setState,
|
|
91
71
|
running: coagentState.running,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
stop: () =>
|
|
96
|
-
|
|
72
|
+
start: () => {
|
|
73
|
+
startAgent(name, context);
|
|
74
|
+
},
|
|
75
|
+
stop: () => {
|
|
76
|
+
stopAgent(name, context);
|
|
77
|
+
},
|
|
78
|
+
run: (hint) => {
|
|
79
|
+
return runAgent(name, context, appendMessage, hint);
|
|
80
|
+
}
|
|
97
81
|
};
|
|
98
82
|
}
|
|
99
83
|
function startAgent(name, context) {
|
|
@@ -106,22 +90,11 @@ function stopAgent(name, context) {
|
|
|
106
90
|
const { agentSession, setAgentSession } = context;
|
|
107
91
|
if (agentSession && agentSession.agentName === name) {
|
|
108
92
|
setAgentSession(null);
|
|
109
|
-
context.setCoagentStates((prevAgentStates) => {
|
|
110
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
111
|
-
[name]: __spreadProps(__spreadValues({}, prevAgentStates[name]), {
|
|
112
|
-
running: false,
|
|
113
|
-
active: false,
|
|
114
|
-
threadId: void 0,
|
|
115
|
-
nodeName: void 0,
|
|
116
|
-
runId: void 0
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
93
|
} else {
|
|
121
94
|
console.warn(`No agent session found for ${name}`);
|
|
122
95
|
}
|
|
123
96
|
}
|
|
124
|
-
function runAgent(name, context, appendMessage,
|
|
97
|
+
function runAgent(name, context, appendMessage, hint) {
|
|
125
98
|
return __async(this, null, function* () {
|
|
126
99
|
var _a, _b;
|
|
127
100
|
const { agentSession, setAgentSession } = context;
|
|
@@ -137,24 +110,17 @@ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
|
|
|
137
110
|
previousState = message.state;
|
|
138
111
|
}
|
|
139
112
|
}
|
|
140
|
-
let state = ((_b = (_a = context.
|
|
113
|
+
let state = ((_b = (_a = context.coagentStates) == null ? void 0 : _a[name]) == null ? void 0 : _b.state) || {};
|
|
141
114
|
if (hint) {
|
|
142
115
|
const hintMessage = hint({ previousState, currentState: state });
|
|
143
116
|
if (hintMessage) {
|
|
144
117
|
yield appendMessage(hintMessage);
|
|
145
|
-
} else {
|
|
146
|
-
yield runChatCompletion();
|
|
147
118
|
}
|
|
148
|
-
} else {
|
|
149
|
-
yield runChatCompletion();
|
|
150
119
|
}
|
|
151
120
|
});
|
|
152
121
|
}
|
|
153
122
|
|
|
154
123
|
export {
|
|
155
|
-
useCoAgent
|
|
156
|
-
startAgent,
|
|
157
|
-
stopAgent,
|
|
158
|
-
runAgent
|
|
124
|
+
useCoAgent
|
|
159
125
|
};
|
|
160
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-DDVXFNYA.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)</span>.\n * </Callout>\n * <Frame className=\"my-12\">\n * <img\n * src=\"/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 { useEffect } from \"react\";\nimport {\n CopilotContextParams,\n CopilotMessagesContextParams,\n useCopilotContext,\n useCopilotMessagesContext,\n} from \"../context\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { useCopilotChat } from \"./use-copilot-chat\";\nimport { AgentStateMessage, Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\n\ninterface WithInternalStateManagementAndInitial<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * The initial state of the agent.\n */\n initialState: T;\n}\n\ninterface WithInternalStateManagement {\n /**\n * The name of the agent being used.\n */\n name: string;\n /**\n * Optional initialState with default type any\n */\n initialState?: any;\n}\n\ninterface WithExternalStateManagement<T> {\n /**\n * The name of the agent being used.\n */\n name: string;\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.\n */\nexport function useCoAgent<T = any>(options: UseCoagentOptions<T>): UseCoagentReturnType<T> {\n const isExternalStateManagement = (\n options: UseCoagentOptions<T>,\n ): options is WithExternalStateManagement<T> => {\n return \"state\" in options && \"setState\" in options;\n };\n\n const { name } = options;\n\n const isInternalStateManagementWithInitial = (\n options: UseCoagentOptions<T>,\n ): options is WithInternalStateManagementAndInitial<T> => {\n return \"initialState\" in options;\n };\n\n const generalContext = useCopilotContext();\n const messagesContext = useCopilotMessagesContext();\n const context = { ...generalContext, ...messagesContext };\n const { coagentStates, setCoagentStates } = context;\n const { appendMessage } = useCopilotChat();\n\n const getCoagentState = (coagentStates: Record<string, CoagentState>, name: string) => {\n if (coagentStates[name]) {\n return coagentStates[name];\n } else {\n return {\n name,\n state: isInternalStateManagementWithInitial(options) ? options.initialState : {},\n running: false,\n active: false,\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n };\n }\n };\n\n // if we manage state internally, we need to provide a function to set the state\n const setState = (newState: T | ((prevState: T | undefined) => T)) => {\n setCoagentStates((prevAgentStates) => {\n let coagentState: CoagentState = getCoagentState(prevAgentStates, name);\n\n const updatedState =\n typeof newState === \"function\" ? (newState as Function)(coagentState.state) : newState;\n\n return {\n ...prevAgentStates,\n [name]: {\n ...coagentState,\n state: updatedState,\n },\n };\n });\n };\n\n const coagentState = getCoagentState(coagentStates, name);\n\n const state = isExternalStateManagement(options) ? options.state : coagentState.state;\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 }, [isExternalStateManagement(options) ? JSON.stringify(options.state) : undefined]);\n\n // Return the state and setState function\n return {\n name,\n nodeName: coagentState.nodeName,\n state,\n setState,\n running: coagentState.running,\n start: () => {\n startAgent(name, context);\n },\n stop: () => {\n stopAgent(name, context);\n },\n run: (hint?: HintFunction) => {\n return runAgent(name, context, appendMessage, hint);\n },\n };\n}\n\nfunction startAgent(name: string, context: CopilotContextParams) {\n const { setAgentSession } = context;\n setAgentSession({\n agentName: name,\n });\n}\n\nfunction stopAgent(name: string, context: CopilotContextParams) {\n const { agentSession, setAgentSession } = context;\n if (agentSession && agentSession.agentName === name) {\n setAgentSession(null);\n } else {\n console.warn(`No agent session found for ${name}`);\n }\n}\n\nasync function runAgent(\n name: string,\n context: CopilotContextParams & CopilotMessagesContextParams,\n appendMessage: (message: Message) => Promise<void>,\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 = context.messages.length - 1; i >= 0; i--) {\n const message = context.messages[i];\n if (message.isAgentStateMessage() && message.agentName === name) {\n previousState = message.state;\n }\n }\n\n let state = context.coagentStates?.[name]?.state || {};\n\n if (hint) {\n const hintMessage = hint({ previousState, currentState: state });\n if (hintMessage) {\n await appendMessage(hintMessage);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0FA,SAAS,iBAAiB;AAgHnB,SAAS,WAAoB,SAAwD;AAC1F,QAAM,4BAA4B,CAChCA,aAC8C;AAC9C,WAAO,WAAWA,YAAW,cAAcA;AAAA,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