@copilotkit/react-core 1.5.0-tyler-reset-chat.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +158 -4
- package/README.md +2 -0
- package/dist/{chunk-3AYELZJS.mjs → chunk-35EN6BG4.mjs} +2 -2
- package/dist/{chunk-3AYELZJS.mjs.map → chunk-35EN6BG4.mjs.map} +1 -1
- package/dist/{chunk-SEPYQHH7.mjs → chunk-42N5VKIX.mjs} +34 -28
- package/dist/chunk-42N5VKIX.mjs.map +1 -0
- package/dist/{chunk-USL3EHJB.mjs → chunk-5FYKUKG3.mjs} +2 -2
- package/dist/{chunk-ODN4H66E.mjs → chunk-7LRDVJH5.mjs} +6 -2
- package/dist/chunk-7LRDVJH5.mjs.map +1 -0
- package/dist/{chunk-CZMEZR6F.mjs → chunk-BT6WK2JZ.mjs} +34 -19
- package/dist/chunk-BT6WK2JZ.mjs.map +1 -0
- package/dist/{chunk-3R4J2TPH.mjs → chunk-EUU6NNYU.mjs} +29 -13
- package/dist/chunk-EUU6NNYU.mjs.map +1 -0
- package/dist/chunk-QCUP6HLK.mjs +37 -0
- package/dist/chunk-QCUP6HLK.mjs.map +1 -0
- package/dist/chunk-QTDCEDOC.mjs +392 -0
- package/dist/chunk-QTDCEDOC.mjs.map +1 -0
- package/dist/{chunk-JR55I3FL.mjs → chunk-QX6V774L.mjs} +6 -8
- package/dist/chunk-QX6V774L.mjs.map +1 -0
- package/dist/{chunk-2KCEHGSI.mjs → chunk-SFPANIOY.mjs} +99 -49
- package/dist/chunk-SFPANIOY.mjs.map +1 -0
- package/dist/{chunk-2JP64U3A.mjs → chunk-TQN3EZWQ.mjs} +4 -1
- package/dist/chunk-TQN3EZWQ.mjs.map +1 -0
- package/dist/{chunk-XUPO37VH.mjs → chunk-V3PFWGIY.mjs} +2 -2
- package/dist/{chunk-6QKA3SNN.mjs → chunk-VMP6JWBB.mjs} +21 -5
- package/dist/chunk-VMP6JWBB.mjs.map +1 -0
- package/dist/chunk-XERJQUHA.mjs +31 -0
- package/dist/chunk-XERJQUHA.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.js +173 -92
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +5 -4
- package/dist/components/copilot-provider/index.js +173 -92
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +5 -4
- package/dist/components/error-boundary/error-boundary.d.ts +22 -0
- package/dist/components/error-boundary/error-boundary.js +183 -0
- package/dist/components/error-boundary/error-boundary.js.map +1 -0
- package/dist/components/error-boundary/error-boundary.mjs +12 -0
- package/dist/components/error-boundary/error-boundary.mjs.map +1 -0
- package/dist/components/error-boundary/error-utils.d.ts +11 -0
- package/dist/components/error-boundary/error-utils.js +177 -0
- package/dist/components/error-boundary/error-utils.js.map +1 -0
- package/dist/components/error-boundary/error-utils.mjs +13 -0
- package/dist/components/error-boundary/error-utils.mjs.map +1 -0
- package/dist/components/index.js +173 -92
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +5 -4
- package/dist/components/toast/toast-provider.d.ts +2 -1
- package/dist/components/toast/toast-provider.js +76 -62
- 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 -2
- package/dist/context/copilot-context.js +3 -0
- 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 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.js +554 -308
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +13 -11
- package/dist/hooks/use-chat.d.ts +6 -2
- package/dist/hooks/use-chat.js +434 -219
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +4 -3
- package/dist/hooks/use-coagent-state-render.d.ts +2 -2
- package/dist/hooks/use-coagent-state-render.js +3 -0
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +510 -277
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +9 -7
- package/dist/hooks/use-copilot-action.d.ts +12 -2
- package/dist/hooks/use-copilot-action.js +157 -16
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -2
- package/dist/hooks/use-copilot-chat.d.ts +1 -0
- package/dist/hooks/use-copilot-chat.js +483 -253
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +8 -6
- package/dist/hooks/use-copilot-readable.js +3 -0
- 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 +110 -4
- 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 -0
- 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 +1 -1
- package/dist/index.js +616 -401
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -12
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js +33 -13
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +7 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +33 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -5
- package/dist/types/frontend-action.d.ts +21 -2
- package/dist/types/frontend-action.js +34 -0
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/types/frontend-action.mjs +7 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +5 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +5 -4
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +22 -1
- package/src/components/error-boundary/error-boundary.tsx +42 -0
- package/src/components/error-boundary/error-utils.tsx +95 -0
- package/src/components/toast/toast-provider.tsx +10 -49
- package/src/context/copilot-context.tsx +17 -2
- package/src/hooks/use-chat.ts +375 -279
- package/src/hooks/use-coagent-state-render.ts +2 -2
- package/src/hooks/use-coagent.ts +34 -28
- package/src/hooks/use-copilot-action.ts +50 -15
- package/src/hooks/use-copilot-chat.ts +28 -14
- package/src/hooks/use-copilot-runtime-client.ts +4 -0
- package/src/lib/copilot-task.ts +2 -8
- package/src/types/frontend-action.ts +55 -2
- package/src/types/index.ts +5 -1
- package/dist/chunk-2JP64U3A.mjs.map +0 -1
- package/dist/chunk-2KCEHGSI.mjs.map +0 -1
- package/dist/chunk-3R4J2TPH.mjs.map +0 -1
- package/dist/chunk-6EN7J4V2.mjs +0 -317
- package/dist/chunk-6EN7J4V2.mjs.map +0 -1
- package/dist/chunk-6QKA3SNN.mjs.map +0 -1
- package/dist/chunk-CZMEZR6F.mjs.map +0 -1
- package/dist/chunk-JR55I3FL.mjs.map +0 -1
- package/dist/chunk-ODN4H66E.mjs.map +0 -1
- package/dist/chunk-SEPYQHH7.mjs.map +0 -1
- /package/dist/{chunk-USL3EHJB.mjs.map → chunk-5FYKUKG3.mjs.map} +0 -0
- /package/dist/{chunk-XUPO37VH.mjs.map → chunk-V3PFWGIY.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCopilotContext } from "../../context";
|
|
2
1
|
import { GraphQLError } from "@copilotkit/runtime-client-gql";
|
|
3
2
|
import React, { createContext, useContext, useState, useCallback } from "react";
|
|
4
|
-
import {
|
|
3
|
+
import { ErrorToast } from "../error-boundary/error-utils";
|
|
4
|
+
import { PartialBy } from "@copilotkit/shared";
|
|
5
5
|
|
|
6
6
|
interface Toast {
|
|
7
7
|
id: string;
|
|
@@ -12,7 +12,7 @@ interface Toast {
|
|
|
12
12
|
|
|
13
13
|
interface ToastContextValue {
|
|
14
14
|
toasts: Toast[];
|
|
15
|
-
addToast: (toast:
|
|
15
|
+
addToast: (toast: PartialBy<Toast, "id">) => void;
|
|
16
16
|
addGraphQLErrorsToast: (errors: GraphQLError[]) => void;
|
|
17
17
|
removeToast: (id: string) => void;
|
|
18
18
|
enabled: boolean;
|
|
@@ -36,10 +36,13 @@ export function ToastProvider({
|
|
|
36
36
|
children: React.ReactNode;
|
|
37
37
|
}) {
|
|
38
38
|
const [toasts, setToasts] = useState<Toast[]>([]);
|
|
39
|
-
const addToast = useCallback((toast:
|
|
40
|
-
const id = Math.random().toString(36).substring(2, 9);
|
|
39
|
+
const addToast = useCallback((toast: PartialBy<Toast, "id">) => {
|
|
40
|
+
const id = toast.id ?? Math.random().toString(36).substring(2, 9);
|
|
41
41
|
|
|
42
|
-
setToasts((currentToasts) =>
|
|
42
|
+
setToasts((currentToasts) => {
|
|
43
|
+
if (currentToasts.find((toast) => toast.id === id)) return currentToasts;
|
|
44
|
+
return [...currentToasts, { ...toast, id }];
|
|
45
|
+
});
|
|
43
46
|
|
|
44
47
|
if (toast.duration) {
|
|
45
48
|
setTimeout(() => {
|
|
@@ -54,51 +57,9 @@ export function ToastProvider({
|
|
|
54
57
|
// return;
|
|
55
58
|
// }
|
|
56
59
|
|
|
57
|
-
const errorsToRender = errors.map((error, idx) => {
|
|
58
|
-
const message = error.message;
|
|
59
|
-
const code = error.extensions?.code as string;
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
key={idx}
|
|
64
|
-
style={{
|
|
65
|
-
marginTop: idx === 0 ? 0 : 10,
|
|
66
|
-
marginBottom: 14,
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
69
|
-
<ExclamationMarkIcon style={{ marginBottom: 4 }} />
|
|
70
|
-
|
|
71
|
-
{code && (
|
|
72
|
-
<div
|
|
73
|
-
style={{
|
|
74
|
-
fontWeight: "600",
|
|
75
|
-
marginBottom: 4,
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
Copilot Cloud Error:{" "}
|
|
79
|
-
<span style={{ fontFamily: "monospace", fontWeight: "normal" }}>{code}</span>
|
|
80
|
-
</div>
|
|
81
|
-
)}
|
|
82
|
-
<div>{message}</div>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
60
|
addToast({
|
|
88
61
|
type: "error",
|
|
89
|
-
message:
|
|
90
|
-
<div
|
|
91
|
-
style={{
|
|
92
|
-
fontSize: "13px",
|
|
93
|
-
maxWidth: "600px",
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
{errorsToRender}
|
|
97
|
-
<div style={{ fontSize: "11px", opacity: 0.75 }}>
|
|
98
|
-
NOTE: This is a Copilot Cloud error, and it only displays during local development.
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
),
|
|
62
|
+
message: <ErrorToast errors={errors} />,
|
|
102
63
|
});
|
|
103
64
|
}, []);
|
|
104
65
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { CopilotCloudConfig, FunctionCallHandler } from "@copilotkit/shared";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActionRenderProps,
|
|
4
|
+
CatchAllActionRenderProps,
|
|
5
|
+
FrontendAction,
|
|
6
|
+
} from "../types/frontend-action";
|
|
3
7
|
import React from "react";
|
|
4
8
|
import { TreeNodeId } from "../hooks/use-tree";
|
|
5
9
|
import { DocumentPointer } from "../types";
|
|
@@ -68,7 +72,9 @@ export interface CopilotApiConfig {
|
|
|
68
72
|
credentials?: RequestCredentials;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
export type InChatRenderFunction = (
|
|
75
|
+
export type InChatRenderFunction = (
|
|
76
|
+
props: ActionRenderProps<any> | CatchAllActionRenderProps<any>,
|
|
77
|
+
) => string | JSX.Element;
|
|
72
78
|
export type CoagentInChatRenderFunction = (
|
|
73
79
|
props: CoAgentStateRenderProps<any>,
|
|
74
80
|
) => string | JSX.Element | undefined | null;
|
|
@@ -132,6 +138,13 @@ export interface CopilotContextParams {
|
|
|
132
138
|
// agents
|
|
133
139
|
coagentStates: Record<string, CoagentState>;
|
|
134
140
|
setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;
|
|
141
|
+
coagentStatesRef: React.RefObject<Record<string, CoagentState>>;
|
|
142
|
+
setCoagentStatesWithRef: (
|
|
143
|
+
value:
|
|
144
|
+
| Record<string, CoagentState>
|
|
145
|
+
| ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),
|
|
146
|
+
) => void;
|
|
147
|
+
|
|
135
148
|
agentSession: AgentSession | null;
|
|
136
149
|
setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;
|
|
137
150
|
|
|
@@ -198,6 +211,8 @@ const emptyCopilotContext: CopilotContextParams = {
|
|
|
198
211
|
showDevConsole: "auto",
|
|
199
212
|
coagentStates: {},
|
|
200
213
|
setCoagentStates: () => {},
|
|
214
|
+
coagentStatesRef: { current: {} },
|
|
215
|
+
setCoagentStatesWithRef: () => {},
|
|
201
216
|
|
|
202
217
|
agentSession: null,
|
|
203
218
|
setAgentSession: () => {},
|