@copilotkit/react-core 1.4.8-no-pino-redact.1 → 1.4.8

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 (95) hide show
  1. package/CHANGELOG.md +8 -3
  2. package/dist/{chunk-XBVKTDXP.mjs → chunk-6EMLM6WX.mjs} +17 -14
  3. package/dist/chunk-6EMLM6WX.mjs.map +1 -0
  4. package/dist/{chunk-ODN4H66E.mjs → chunk-7LRDVJH5.mjs} +6 -2
  5. package/dist/chunk-7LRDVJH5.mjs.map +1 -0
  6. package/dist/{chunk-O22KGHOQ.mjs → chunk-FSC4A3JN.mjs} +17 -13
  7. package/dist/chunk-FSC4A3JN.mjs.map +1 -0
  8. package/dist/{chunk-OT67R4NB.mjs → chunk-IFTHM7LF.mjs} +2 -2
  9. package/dist/{chunk-DHGXL5PC.mjs → chunk-IVYL7JRC.mjs} +7 -4
  10. package/dist/chunk-IVYL7JRC.mjs.map +1 -0
  11. package/dist/chunk-NTLCOVE5.mjs +321 -0
  12. package/dist/chunk-NTLCOVE5.mjs.map +1 -0
  13. package/dist/chunk-QCUP6HLK.mjs +37 -0
  14. package/dist/chunk-QCUP6HLK.mjs.map +1 -0
  15. package/dist/{chunk-2KCEHGSI.mjs → chunk-SFPANIOY.mjs} +99 -49
  16. package/dist/chunk-SFPANIOY.mjs.map +1 -0
  17. package/dist/{chunk-JHEAUB3Z.mjs → chunk-X6ZF5WAX.mjs} +1 -1
  18. package/dist/{chunk-JHEAUB3Z.mjs.map → chunk-X6ZF5WAX.mjs.map} +1 -1
  19. package/dist/{chunk-Y7MI4PBB.mjs → chunk-YUY5ZAST.mjs} +6 -3
  20. package/dist/chunk-YUY5ZAST.mjs.map +1 -0
  21. package/dist/components/copilot-provider/copilotkit.js +156 -91
  22. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  23. package/dist/components/copilot-provider/copilotkit.mjs +4 -3
  24. package/dist/components/copilot-provider/index.js +156 -91
  25. package/dist/components/copilot-provider/index.js.map +1 -1
  26. package/dist/components/copilot-provider/index.mjs +4 -3
  27. package/dist/components/error-boundary/error-boundary.d.ts +22 -0
  28. package/dist/components/error-boundary/error-boundary.js +183 -0
  29. package/dist/components/error-boundary/error-boundary.js.map +1 -0
  30. package/dist/components/error-boundary/error-boundary.mjs +12 -0
  31. package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
  32. package/dist/components/error-boundary/error-utils.d.ts +11 -0
  33. package/dist/components/error-boundary/error-utils.js +177 -0
  34. package/dist/components/error-boundary/error-utils.js.map +1 -0
  35. package/dist/components/error-boundary/error-utils.mjs +13 -0
  36. package/dist/components/error-boundary/error-utils.mjs.map +1 -0
  37. package/dist/components/index.js +156 -91
  38. package/dist/components/index.js.map +1 -1
  39. package/dist/components/index.mjs +4 -3
  40. package/dist/components/toast/toast-provider.d.ts +2 -1
  41. package/dist/components/toast/toast-provider.js +76 -62
  42. package/dist/components/toast/toast-provider.js.map +1 -1
  43. package/dist/components/toast/toast-provider.mjs +1 -1
  44. package/dist/hooks/index.js +398 -253
  45. package/dist/hooks/index.js.map +1 -1
  46. package/dist/hooks/index.mjs +9 -8
  47. package/dist/hooks/use-chat.js +343 -199
  48. package/dist/hooks/use-chat.js.map +1 -1
  49. package/dist/hooks/use-chat.mjs +3 -3
  50. package/dist/hooks/use-coagent-state-render.d.ts +2 -2
  51. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  52. package/dist/hooks/use-coagent-state-render.mjs +1 -1
  53. package/dist/hooks/use-coagent.js +378 -233
  54. package/dist/hooks/use-coagent.js.map +1 -1
  55. package/dist/hooks/use-coagent.mjs +7 -6
  56. package/dist/hooks/use-copilot-action.js +132 -7
  57. package/dist/hooks/use-copilot-action.js.map +1 -1
  58. package/dist/hooks/use-copilot-action.mjs +3 -1
  59. package/dist/hooks/use-copilot-chat.js +367 -223
  60. package/dist/hooks/use-copilot-chat.js.map +1 -1
  61. package/dist/hooks/use-copilot-chat.mjs +6 -5
  62. package/dist/hooks/use-copilot-runtime-client.js +110 -4
  63. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  64. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  65. package/dist/index.js +439 -335
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +10 -9
  68. package/dist/lib/copilot-task.js.map +1 -1
  69. package/dist/lib/copilot-task.mjs +5 -4
  70. package/dist/lib/index.js.map +1 -1
  71. package/dist/lib/index.mjs +5 -4
  72. package/dist/utils/extract.js.map +1 -1
  73. package/dist/utils/extract.mjs +4 -3
  74. package/dist/utils/index.js.map +1 -1
  75. package/dist/utils/index.mjs +4 -3
  76. package/package.json +3 -3
  77. package/src/components/copilot-provider/copilotkit.tsx +4 -1
  78. package/src/components/error-boundary/error-boundary.tsx +42 -0
  79. package/src/components/error-boundary/error-utils.tsx +95 -0
  80. package/src/components/toast/toast-provider.tsx +10 -49
  81. package/src/hooks/use-chat.ts +286 -259
  82. package/src/hooks/use-coagent-state-render.ts +2 -2
  83. package/src/hooks/use-coagent.ts +14 -11
  84. package/src/hooks/use-copilot-action.ts +3 -2
  85. package/src/hooks/use-copilot-chat.ts +9 -8
  86. package/src/hooks/use-copilot-runtime-client.ts +4 -0
  87. package/dist/chunk-2KCEHGSI.mjs.map +0 -1
  88. package/dist/chunk-DHGXL5PC.mjs.map +0 -1
  89. package/dist/chunk-EUIBVFV6.mjs +0 -294
  90. package/dist/chunk-EUIBVFV6.mjs.map +0 -1
  91. package/dist/chunk-O22KGHOQ.mjs.map +0 -1
  92. package/dist/chunk-ODN4H66E.mjs.map +0 -1
  93. package/dist/chunk-XBVKTDXP.mjs.map +0 -1
  94. package/dist/chunk-Y7MI4PBB.mjs.map +0 -1
  95. /package/dist/{chunk-OT67R4NB.mjs.map → chunk-IFTHM7LF.mjs.map} +0 -0
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __async = (__this, __arguments, generator) => {
20
+ return new Promise((resolve, reject) => {
21
+ var fulfilled = (value) => {
22
+ try {
23
+ step(generator.next(value));
24
+ } catch (e) {
25
+ reject(e);
26
+ }
27
+ };
28
+ var rejected = (value) => {
29
+ try {
30
+ step(generator.throw(value));
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ };
35
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
+ step((generator = generator.apply(__this, __arguments)).next());
37
+ });
38
+ };
39
+
40
+ // src/components/error-boundary/error-utils.tsx
41
+ var error_utils_exports = {};
42
+ __export(error_utils_exports, {
43
+ ErrorToast: () => ErrorToast,
44
+ useAsyncCallback: () => useAsyncCallback,
45
+ useErrorToast: () => useErrorToast
46
+ });
47
+ module.exports = __toCommonJS(error_utils_exports);
48
+ var import_react2 = require("react");
49
+
50
+ // src/components/toast/toast-provider.tsx
51
+ var import_react = require("react");
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ var ToastContext = (0, import_react.createContext)(void 0);
54
+ function useToast() {
55
+ const context = (0, import_react.useContext)(ToastContext);
56
+ if (!context) {
57
+ throw new Error("useToast must be used within a ToastProvider");
58
+ }
59
+ return context;
60
+ }
61
+
62
+ // src/components/toast/exclamation-mark-icon.tsx
63
+ var import_jsx_runtime2 = require("react/jsx-runtime");
64
+ var ExclamationMarkIcon = ({
65
+ className,
66
+ style
67
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
68
+ "svg",
69
+ {
70
+ xmlns: "http://www.w3.org/2000/svg",
71
+ width: "24",
72
+ height: "24",
73
+ viewBox: "0 0 24 24",
74
+ fill: "none",
75
+ stroke: "currentColor",
76
+ strokeWidth: "2",
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ className: `lucide lucide-circle-alert ${className ? className : ""}`,
80
+ style,
81
+ children: [
82
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
84
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
85
+ ]
86
+ }
87
+ );
88
+
89
+ // src/components/error-boundary/error-utils.tsx
90
+ var import_jsx_runtime3 = require("react/jsx-runtime");
91
+ function ErrorToast({ errors }) {
92
+ const errorsToRender = errors.map((error, idx) => {
93
+ var _a, _b, _c;
94
+ const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
95
+ const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
96
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
97
+ "div",
98
+ {
99
+ style: {
100
+ marginTop: idx === 0 ? 0 : 10,
101
+ marginBottom: 14
102
+ },
103
+ children: [
104
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
105
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
106
+ "div",
107
+ {
108
+ style: {
109
+ fontWeight: "600",
110
+ marginBottom: 4
111
+ },
112
+ children: [
113
+ "Copilot Cloud Error:",
114
+ " ",
115
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
116
+ ]
117
+ }
118
+ ),
119
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
120
+ ]
121
+ },
122
+ idx
123
+ );
124
+ });
125
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
126
+ "div",
127
+ {
128
+ style: {
129
+ fontSize: "13px",
130
+ maxWidth: "600px"
131
+ },
132
+ children: [
133
+ errorsToRender,
134
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
135
+ ]
136
+ }
137
+ );
138
+ }
139
+ function useErrorToast() {
140
+ const { addToast } = useToast();
141
+ return (0, import_react2.useCallback)(
142
+ (error) => {
143
+ const errorId = error.map((err) => {
144
+ var _a, _b;
145
+ const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
146
+ const stack = err.stack || "";
147
+ return btoa(message + stack).slice(0, 32);
148
+ }).join("|");
149
+ addToast({
150
+ type: "error",
151
+ id: errorId,
152
+ // Toast libraries typically dedupe by id
153
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
154
+ });
155
+ },
156
+ [addToast]
157
+ );
158
+ }
159
+ function useAsyncCallback(callback, deps) {
160
+ const addErrorToast = useErrorToast();
161
+ return (0, import_react2.useCallback)((...args) => __async(this, null, function* () {
162
+ try {
163
+ return yield callback(...args);
164
+ } catch (error) {
165
+ console.error("Error in async callback:", error);
166
+ addErrorToast([error]);
167
+ throw error;
168
+ }
169
+ }), deps);
170
+ }
171
+ // Annotate the CommonJS export names for ESM import in node:
172
+ 0 && (module.exports = {
173
+ ErrorToast,
174
+ useAsyncCallback,
175
+ useErrorToast
176
+ });
177
+ //# sourceMappingURL=error-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/error-boundary/error-utils.tsx","../../../src/components/toast/toast-provider.tsx","../../../src/components/toast/exclamation-mark-icon.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../toast/toast-provider\";\nimport { ExclamationMarkIcon } from \"../toast/exclamation-mark-icon\";\n\nexport function ErrorToast({ errors }: { errors: (Error | GraphQLError)[] }) {\n const errorsToRender = errors.map((error, idx) => {\n const message =\n \"extensions\" in error\n ? (error.extensions?.originalError as undefined | { message?: string })?.message\n : error.message;\n const code = \"extensions\" in error ? (error.extensions?.code as string) : null;\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 return (\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 error only displays during local development.\n </div>\n </div>\n );\n}\n\nexport function useErrorToast() {\n const { addToast } = useToast();\n\n return useCallback(\n (error: (Error | GraphQLError)[]) => {\n const errorId = error\n .map((err) => {\n const message =\n \"extensions\" in err\n ? (err.extensions?.originalError as any)?.message || err.message\n : err.message;\n const stack = err.stack || \"\";\n return btoa(message + stack).slice(0, 32); // Create hash from message + stack\n })\n .join(\"|\");\n\n addToast({\n type: \"error\",\n id: errorId, // Toast libraries typically dedupe by id\n message: <ErrorToast errors={error} />,\n });\n },\n [addToast],\n );\n}\n\nexport function useAsyncCallback<T extends (...args: any[]) => Promise<any>>(\n callback: T,\n deps: Parameters<typeof useCallback>[1],\n) {\n const addErrorToast = useErrorToast();\n return useCallback(async (...args: Parameters<T>) => {\n try {\n return await callback(...args);\n } catch (error) {\n console.error(\"Error in async callback:\", error);\n // @ts-ignore\n addErrorToast([error]);\n throw error;\n }\n }, deps);\n}\n","import { GraphQLError } from \"@copilotkit/runtime-client-gql\";\nimport React, { createContext, useContext, useState, useCallback } from \"react\";\nimport { ErrorToast } from \"../error-boundary/error-utils\";\nimport { PartialBy } from \"@copilotkit/shared\";\n\ninterface Toast {\n id: string;\n message: string | React.ReactNode;\n type: \"info\" | \"success\" | \"warning\" | \"error\";\n duration?: number;\n}\n\ninterface ToastContextValue {\n toasts: Toast[];\n addToast: (toast: PartialBy<Toast, \"id\">) => void;\n addGraphQLErrorsToast: (errors: GraphQLError[]) => void;\n removeToast: (id: string) => void;\n enabled: boolean;\n}\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: PartialBy<Toast, \"id\">) => {\n const id = toast.id ?? Math.random().toString(36).substring(2, 9);\n\n setToasts((currentToasts) => {\n if (currentToasts.find((toast) => toast.id === id)) return currentToasts;\n return [...currentToasts, { ...toast, id }];\n });\n\n if (toast.duration) {\n setTimeout(() => {\n removeToast(id);\n }, toast.duration);\n }\n }, []);\n\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 addToast({\n type: \"error\",\n message: <ErrorToast errors={errors} />,\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","import React from \"react\";\n\nexport const ExclamationMarkIcon = ({\n className,\n style,\n}: {\n className?: string;\n style?: React.CSSProperties;\n}) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`lucide lucide-circle-alert ${className ? className : \"\"}`}\n style={style}\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\" />\n <line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\" />\n </svg>\n);\n"],"mappings":"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","names":["import_react","import_jsx_runtime","import_jsx_runtime"]}
@@ -0,0 +1,13 @@
1
+ import {
2
+ ErrorToast,
3
+ useAsyncCallback,
4
+ useErrorToast
5
+ } from "../../chunk-SFPANIOY.mjs";
6
+ import "../../chunk-O7ARI5CV.mjs";
7
+ import "../../chunk-SKC7AJIV.mjs";
8
+ export {
9
+ ErrorToast,
10
+ useAsyncCallback,
11
+ useErrorToast
12
+ };
13
+ //# sourceMappingURL=error-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -86,7 +86,7 @@ __export(components_exports, {
86
86
  module.exports = __toCommonJS(components_exports);
87
87
 
88
88
  // src/components/copilot-provider/copilotkit.tsx
89
- var import_react8 = require("react");
89
+ var import_react10 = require("react");
90
90
 
91
91
  // src/context/copilot-context.tsx
92
92
  var import_react = __toESM(require("react"));
@@ -380,6 +380,9 @@ function CopilotMessages(_a) {
380
380
  }
381
381
 
382
382
  // src/components/toast/toast-provider.tsx
383
+ var import_react7 = require("react");
384
+
385
+ // src/components/error-boundary/error-utils.tsx
383
386
  var import_react6 = require("react");
384
387
 
385
388
  // src/components/toast/exclamation-mark-icon.tsx
@@ -409,11 +412,82 @@ var ExclamationMarkIcon = ({
409
412
  }
410
413
  );
411
414
 
412
- // src/components/toast/toast-provider.tsx
415
+ // src/components/error-boundary/error-utils.tsx
413
416
  var import_jsx_runtime3 = require("react/jsx-runtime");
414
- var ToastContext = (0, import_react6.createContext)(void 0);
417
+ function ErrorToast({ errors }) {
418
+ const errorsToRender = errors.map((error, idx) => {
419
+ var _a, _b, _c;
420
+ const message = "extensions" in error ? (_b = (_a = error.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message : error.message;
421
+ const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
422
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
423
+ "div",
424
+ {
425
+ style: {
426
+ marginTop: idx === 0 ? 0 : 10,
427
+ marginBottom: 14
428
+ },
429
+ children: [
430
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
431
+ code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
432
+ "div",
433
+ {
434
+ style: {
435
+ fontWeight: "600",
436
+ marginBottom: 4
437
+ },
438
+ children: [
439
+ "Copilot Cloud Error:",
440
+ " ",
441
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
442
+ ]
443
+ }
444
+ ),
445
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
446
+ ]
447
+ },
448
+ idx
449
+ );
450
+ });
451
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
452
+ "div",
453
+ {
454
+ style: {
455
+ fontSize: "13px",
456
+ maxWidth: "600px"
457
+ },
458
+ children: [
459
+ errorsToRender,
460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
461
+ ]
462
+ }
463
+ );
464
+ }
465
+ function useErrorToast() {
466
+ const { addToast } = useToast();
467
+ return (0, import_react6.useCallback)(
468
+ (error) => {
469
+ const errorId = error.map((err) => {
470
+ var _a, _b;
471
+ const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
472
+ const stack = err.stack || "";
473
+ return btoa(message + stack).slice(0, 32);
474
+ }).join("|");
475
+ addToast({
476
+ type: "error",
477
+ id: errorId,
478
+ // Toast libraries typically dedupe by id
479
+ message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
480
+ });
481
+ },
482
+ [addToast]
483
+ );
484
+ }
485
+
486
+ // src/components/toast/toast-provider.tsx
487
+ var import_jsx_runtime4 = require("react/jsx-runtime");
488
+ var ToastContext = (0, import_react7.createContext)(void 0);
415
489
  function useToast() {
416
- const context = (0, import_react6.useContext)(ToastContext);
490
+ const context = (0, import_react7.useContext)(ToastContext);
417
491
  if (!context) {
418
492
  throw new Error("useToast must be used within a ToastProvider");
419
493
  }
@@ -423,68 +497,28 @@ function ToastProvider({
423
497
  enabled,
424
498
  children
425
499
  }) {
426
- const [toasts, setToasts] = (0, import_react6.useState)([]);
427
- const addToast = (0, import_react6.useCallback)((toast) => {
428
- const id = Math.random().toString(36).substring(2, 9);
429
- setToasts((currentToasts) => [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })]);
500
+ const [toasts, setToasts] = (0, import_react7.useState)([]);
501
+ const addToast = (0, import_react7.useCallback)((toast) => {
502
+ var _a;
503
+ const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
504
+ setToasts((currentToasts) => {
505
+ if (currentToasts.find((toast2) => toast2.id === id))
506
+ return currentToasts;
507
+ return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
508
+ });
430
509
  if (toast.duration) {
431
510
  setTimeout(() => {
432
511
  removeToast(id);
433
512
  }, toast.duration);
434
513
  }
435
514
  }, []);
436
- const addGraphQLErrorsToast = (0, import_react6.useCallback)((errors) => {
437
- const errorsToRender = errors.map((error, idx) => {
438
- var _a;
439
- const message = error.message;
440
- const code = (_a = error.extensions) == null ? void 0 : _a.code;
441
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
442
- "div",
443
- {
444
- style: {
445
- marginTop: idx === 0 ? 0 : 10,
446
- marginBottom: 14
447
- },
448
- children: [
449
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
450
- code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
451
- "div",
452
- {
453
- style: {
454
- fontWeight: "600",
455
- marginBottom: 4
456
- },
457
- children: [
458
- "Copilot Cloud Error:",
459
- " ",
460
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
461
- ]
462
- }
463
- ),
464
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message })
465
- ]
466
- },
467
- idx
468
- );
469
- });
515
+ const addGraphQLErrorsToast = (0, import_react7.useCallback)((errors) => {
470
516
  addToast({
471
517
  type: "error",
472
- message: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
473
- "div",
474
- {
475
- style: {
476
- fontSize: "13px",
477
- maxWidth: "600px"
478
- },
479
- children: [
480
- errorsToRender,
481
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This is a Copilot Cloud error, and it only displays during local development." })
482
- ]
483
- }
484
- )
518
+ message: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorToast, { errors })
485
519
  });
486
520
  }, []);
487
- const removeToast = (0, import_react6.useCallback)((id) => {
521
+ const removeToast = (0, import_react7.useCallback)((id) => {
488
522
  setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
489
523
  }, []);
490
524
  const value = {
@@ -494,8 +528,8 @@ function ToastProvider({
494
528
  removeToast,
495
529
  enabled
496
530
  };
497
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ToastContext.Provider, { value, children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
531
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ToastContext.Provider, { value, children: [
532
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
499
533
  "div",
500
534
  {
501
535
  style: {
@@ -509,7 +543,7 @@ function ToastProvider({
509
543
  gap: "0.5rem"
510
544
  },
511
545
  children: [
512
- toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
546
+ toasts.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
513
547
  "button",
514
548
  {
515
549
  onClick: () => setToasts([]),
@@ -524,7 +558,7 @@ function ToastProvider({
524
558
  children: "Close All"
525
559
  }
526
560
  ) }),
527
- toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
561
+ toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
528
562
  Toast,
529
563
  {
530
564
  message: toast.message,
@@ -550,7 +584,7 @@ function Toast({
550
584
  warning: "#eab308",
551
585
  error: "#ef4444"
552
586
  };
553
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
587
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
554
588
  "div",
555
589
  {
556
590
  style: {
@@ -563,8 +597,8 @@ function Toast({
563
597
  minWidth: "200px"
564
598
  },
565
599
  children: [
566
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: message }),
567
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
600
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: message }),
601
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
568
602
  "button",
569
603
  {
570
604
  onClick: onClose,
@@ -589,14 +623,17 @@ function Toast({
589
623
 
590
624
  // src/hooks/use-copilot-runtime-client.ts
591
625
  var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
592
- var import_react7 = require("react");
626
+ var import_react8 = require("react");
593
627
  var useCopilotRuntimeClient = (options) => {
594
628
  const { addGraphQLErrorsToast } = useToast();
595
- const runtimeClient = (0, import_react7.useMemo)(() => {
629
+ const addErrorToast = useErrorToast();
630
+ const runtimeClient = (0, import_react8.useMemo)(() => {
596
631
  return new import_runtime_client_gql.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
597
632
  handleGQLErrors: (error) => {
598
633
  if (error.graphQLErrors.length) {
599
634
  addGraphQLErrorsToast(error.graphQLErrors);
635
+ } else {
636
+ addErrorToast([error]);
600
637
  }
601
638
  }
602
639
  }));
@@ -618,13 +655,41 @@ function getHostname() {
618
655
  return "";
619
656
  }
620
657
 
658
+ // src/components/error-boundary/error-boundary.tsx
659
+ var import_react9 = __toESM(require("react"));
660
+ var import_jsx_runtime5 = require("react/jsx-runtime");
661
+ var CopilotErrorBoundary = class extends import_react9.default.Component {
662
+ constructor(props) {
663
+ super(props);
664
+ this.state = { hasError: false };
665
+ }
666
+ static getDerivedStateFromError(error) {
667
+ return { hasError: true, error };
668
+ }
669
+ componentDidCatch(error, errorInfo) {
670
+ console.error("CopilotKit Error:", error, errorInfo);
671
+ }
672
+ render() {
673
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorToast2, { error: this.state.error, children: this.props.children });
674
+ }
675
+ };
676
+ function ErrorToast2({ error, children }) {
677
+ const addErrorToast = useErrorToast();
678
+ (0, import_react9.useEffect)(() => {
679
+ if (error) {
680
+ addErrorToast([error]);
681
+ }
682
+ }, [error, addErrorToast]);
683
+ return children;
684
+ }
685
+
621
686
  // src/components/copilot-provider/copilotkit.tsx
622
- var import_jsx_runtime4 = require("react/jsx-runtime");
687
+ var import_jsx_runtime6 = require("react/jsx-runtime");
623
688
  function CopilotKit(_a) {
624
689
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
625
690
  const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
626
691
  const enabled = shouldShowDevConsole(showDevConsole);
627
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) });
692
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
628
693
  }
629
694
  function CopilotKitInternal(_a) {
630
695
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
@@ -634,49 +699,49 @@ function CopilotKitInternal(_a) {
634
699
  );
635
700
  }
636
701
  const chatApiEndpoint = props.runtimeUrl || import_shared3.COPILOT_CLOUD_CHAT_URL;
637
- const [actions, setActions] = (0, import_react8.useState)({});
638
- const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react8.useState)({});
639
- const chatComponentsCache = (0, import_react8.useRef)({
702
+ const [actions, setActions] = (0, import_react10.useState)({});
703
+ const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
704
+ const chatComponentsCache = (0, import_react10.useRef)({
640
705
  actions: {},
641
706
  coAgentStateRenders: {}
642
707
  });
643
708
  const { addElement, removeElement, printTree } = use_tree_default();
644
- const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
645
- const [chatInstructions, setChatInstructions] = (0, import_react8.useState)("");
709
+ const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
710
+ const [chatInstructions, setChatInstructions] = (0, import_react10.useState)("");
646
711
  const {
647
712
  addElement: addDocument,
648
713
  removeElement: removeDocument,
649
714
  allElements: allDocuments
650
715
  } = use_flat_category_store_default();
651
- const setAction = (0, import_react8.useCallback)((id, action) => {
716
+ const setAction = (0, import_react10.useCallback)((id, action) => {
652
717
  setActions((prevPoints) => {
653
718
  return __spreadProps(__spreadValues({}, prevPoints), {
654
719
  [id]: action
655
720
  });
656
721
  });
657
722
  }, []);
658
- const removeAction = (0, import_react8.useCallback)((id) => {
723
+ const removeAction = (0, import_react10.useCallback)((id) => {
659
724
  setActions((prevPoints) => {
660
725
  const newPoints = __spreadValues({}, prevPoints);
661
726
  delete newPoints[id];
662
727
  return newPoints;
663
728
  });
664
729
  }, []);
665
- const setCoAgentStateRender = (0, import_react8.useCallback)((id, stateRender) => {
730
+ const setCoAgentStateRender = (0, import_react10.useCallback)((id, stateRender) => {
666
731
  setCoAgentStateRenders((prevPoints) => {
667
732
  return __spreadProps(__spreadValues({}, prevPoints), {
668
733
  [id]: stateRender
669
734
  });
670
735
  });
671
736
  }, []);
672
- const removeCoAgentStateRender = (0, import_react8.useCallback)((id) => {
737
+ const removeCoAgentStateRender = (0, import_react10.useCallback)((id) => {
673
738
  setCoAgentStateRenders((prevPoints) => {
674
739
  const newPoints = __spreadValues({}, prevPoints);
675
740
  delete newPoints[id];
676
741
  return newPoints;
677
742
  });
678
743
  }, []);
679
- const getContextString = (0, import_react8.useCallback)(
744
+ const getContextString = (0, import_react10.useCallback)(
680
745
  (documents, categories) => {
681
746
  const documentsString = documents.map((document) => {
682
747
  return `${document.name} (${document.sourceApplication}):
@@ -689,37 +754,37 @@ ${nonDocumentStrings}`;
689
754
  },
690
755
  [printTree]
691
756
  );
692
- const addContext = (0, import_react8.useCallback)(
757
+ const addContext = (0, import_react10.useCallback)(
693
758
  (context, parentId, categories = defaultCopilotContextCategories) => {
694
759
  return addElement(context, categories, parentId);
695
760
  },
696
761
  [addElement]
697
762
  );
698
- const removeContext = (0, import_react8.useCallback)(
763
+ const removeContext = (0, import_react10.useCallback)(
699
764
  (id) => {
700
765
  removeElement(id);
701
766
  },
702
767
  [removeElement]
703
768
  );
704
- const getFunctionCallHandler = (0, import_react8.useCallback)(
769
+ const getFunctionCallHandler = (0, import_react10.useCallback)(
705
770
  (customEntryPoints) => {
706
771
  return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
707
772
  },
708
773
  [actions]
709
774
  );
710
- const getDocumentsContext = (0, import_react8.useCallback)(
775
+ const getDocumentsContext = (0, import_react10.useCallback)(
711
776
  (categories) => {
712
777
  return allDocuments(categories);
713
778
  },
714
779
  [allDocuments]
715
780
  );
716
- const addDocumentContext = (0, import_react8.useCallback)(
781
+ const addDocumentContext = (0, import_react10.useCallback)(
717
782
  (documentPointer, categories = defaultCopilotContextCategories) => {
718
783
  return addDocument(documentPointer, categories);
719
784
  },
720
785
  [addDocument]
721
786
  );
722
- const removeDocumentContext = (0, import_react8.useCallback)(
787
+ const removeDocumentContext = (0, import_react10.useCallback)(
723
788
  (documentId) => {
724
789
  removeDocument(documentId);
725
790
  },
@@ -732,7 +797,7 @@ ${nonDocumentStrings}`;
732
797
  );
733
798
  }
734
799
  }
735
- const copilotApiConfig = (0, import_react8.useMemo)(() => {
800
+ const copilotApiConfig = (0, import_react10.useMemo)(() => {
736
801
  var _a2, _b2;
737
802
  let cloud = void 0;
738
803
  if (props.publicApiKey) {
@@ -774,7 +839,7 @@ ${nonDocumentStrings}`;
774
839
  headers,
775
840
  credentials: copilotApiConfig.credentials
776
841
  });
777
- const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react8.useState)({});
842
+ const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
778
843
  const addChatSuggestionConfiguration = (id, suggestion) => {
779
844
  setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
780
845
  };
@@ -784,9 +849,9 @@ ${nonDocumentStrings}`;
784
849
  return rest;
785
850
  });
786
851
  };
787
- const [coagentStates, setCoagentStates] = (0, import_react8.useState)({});
788
- const coagentStatesRef = (0, import_react8.useRef)({});
789
- const setCoagentStatesWithRef = (0, import_react8.useCallback)(
852
+ const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
853
+ const coagentStatesRef = (0, import_react10.useRef)({});
854
+ const setCoagentStatesWithRef = (0, import_react10.useCallback)(
790
855
  (value) => {
791
856
  const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
792
857
  coagentStatesRef.current = newValue;
@@ -802,9 +867,9 @@ ${nonDocumentStrings}`;
802
867
  agentName: props.agent
803
868
  };
804
869
  }
805
- const [agentSession, setAgentSession] = (0, import_react8.useState)(initialAgentSession);
870
+ const [agentSession, setAgentSession] = (0, import_react10.useState)(initialAgentSession);
806
871
  const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
807
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
872
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
808
873
  CopilotContext.Provider,
809
874
  {
810
875
  value: {
@@ -839,7 +904,7 @@ ${nonDocumentStrings}`;
839
904
  setAgentSession,
840
905
  runtimeClient
841
906
  },
842
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotMessages, { children })
907
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopilotMessages, { children })
843
908
  }
844
909
  );
845
910
  }