@copilotkit/react-core 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/chunk-22XKTBPF.mjs +61 -0
- package/dist/chunk-22XKTBPF.mjs.map +1 -0
- package/dist/chunk-5FHSUKQL.mjs +70 -0
- package/dist/chunk-5FHSUKQL.mjs.map +1 -0
- package/dist/chunk-6BQVZFNO.mjs +35 -0
- package/dist/chunk-6BQVZFNO.mjs.map +1 -0
- package/dist/chunk-6U3UH3KO.mjs +140 -0
- package/dist/chunk-6U3UH3KO.mjs.map +1 -0
- package/dist/chunk-DCTJZ742.mjs +22 -0
- package/dist/chunk-DCTJZ742.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +1 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-EWKJMQOF.mjs +107 -0
- package/dist/chunk-EWKJMQOF.mjs.map +1 -0
- package/dist/chunk-FQ53HQYZ.mjs +28 -0
- package/dist/chunk-FQ53HQYZ.mjs.map +1 -0
- package/dist/chunk-HIUT2NLX.mjs +23 -0
- package/dist/chunk-HIUT2NLX.mjs.map +1 -0
- package/dist/chunk-KXH7NSOV.mjs +215 -0
- package/dist/chunk-KXH7NSOV.mjs.map +1 -0
- package/dist/chunk-LHKIIAUQ.mjs +59 -0
- package/dist/chunk-LHKIIAUQ.mjs.map +1 -0
- package/dist/chunk-LNI2Z45S.mjs +242 -0
- package/dist/chunk-LNI2Z45S.mjs.map +1 -0
- package/dist/chunk-LUGEI4YQ.mjs +1 -0
- package/dist/chunk-LUGEI4YQ.mjs.map +1 -0
- package/dist/chunk-LZWH4OG5.mjs +482 -0
- package/dist/chunk-LZWH4OG5.mjs.map +1 -0
- package/dist/chunk-M2NT7NOO.mjs +120 -0
- package/dist/chunk-M2NT7NOO.mjs.map +1 -0
- package/dist/chunk-MLAS4QUR.mjs +18 -0
- package/dist/chunk-MLAS4QUR.mjs.map +1 -0
- package/dist/chunk-NR2BTA6Z.mjs +1 -0
- package/dist/chunk-NR2BTA6Z.mjs.map +1 -0
- package/dist/chunk-O7ARI5CV.mjs +31 -0
- package/dist/chunk-O7ARI5CV.mjs.map +1 -0
- package/dist/chunk-SKC7AJIV.mjs +61 -0
- package/dist/chunk-SKC7AJIV.mjs.map +1 -0
- package/dist/chunk-VGOFRULA.mjs +401 -0
- package/dist/chunk-VGOFRULA.mjs.map +1 -0
- package/dist/chunk-VNTDIJSG.mjs +37 -0
- package/dist/chunk-VNTDIJSG.mjs.map +1 -0
- package/dist/chunk-WXREY7UP.mjs +87 -0
- package/dist/chunk-WXREY7UP.mjs.map +1 -0
- package/dist/chunk-XERJQUHA.mjs +31 -0
- package/dist/chunk-XERJQUHA.mjs.map +1 -0
- package/dist/chunk-XXR4QFAQ.mjs +29 -0
- package/dist/chunk-XXR4QFAQ.mjs.map +1 -0
- package/dist/chunk-YMG27BON.mjs +160 -0
- package/dist/chunk-YMG27BON.mjs.map +1 -0
- package/dist/chunk-YPSGKPDA.mjs +1 -0
- package/dist/chunk-YPSGKPDA.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.d.ts +16 -0
- package/dist/components/copilot-provider/copilot-messages.js +80 -0
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.mjs +9 -0
- package/dist/components/copilot-provider/copilot-messages.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.d.ts +93 -0
- package/dist/components/copilot-provider/copilotkit-props.js +19 -0
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs +1 -0
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit.d.ts +18 -0
- package/dist/components/copilot-provider/copilotkit.js +990 -0
- package/dist/components/copilot-provider/copilotkit.js.map +1 -0
- package/dist/components/copilot-provider/copilotkit.mjs +22 -0
- package/dist/components/copilot-provider/copilotkit.mjs.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +13 -0
- package/dist/components/copilot-provider/index.js +990 -0
- package/dist/components/copilot-provider/index.js.map +1 -0
- package/dist/components/copilot-provider/index.mjs +20 -0
- package/dist/components/copilot-provider/index.mjs.map +1 -0
- 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.d.ts +13 -0
- package/dist/components/index.js +990 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +20 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.d.ts +9 -0
- package/dist/components/toast/exclamation-mark-icon.js +55 -0
- package/dist/components/toast/exclamation-mark-icon.js.map +1 -0
- package/dist/components/toast/exclamation-mark-icon.mjs +8 -0
- package/dist/components/toast/exclamation-mark-icon.mjs.map +1 -0
- package/dist/components/toast/toast-provider.d.ts +30 -0
- package/dist/components/toast/toast-provider.js +269 -0
- package/dist/components/toast/toast-provider.js.map +1 -0
- package/dist/components/toast/toast-provider.mjs +11 -0
- package/dist/components/toast/toast-provider.mjs.map +1 -0
- package/dist/context/copilot-context.d.ts +142 -0
- package/dist/context/copilot-context.js +138 -0
- package/dist/context/copilot-context.js.map +1 -0
- package/dist/context/copilot-context.mjs +10 -0
- package/dist/context/copilot-context.mjs.map +1 -0
- package/dist/context/copilot-messages-context.d.ts +15 -0
- package/dist/context/copilot-messages-context.js +57 -0
- package/dist/context/copilot-messages-context.js.map +1 -0
- package/dist/context/copilot-messages-context.mjs +10 -0
- package/dist/context/copilot-messages-context.mjs.map +1 -0
- package/dist/context/index.d.ts +11 -0
- package/dist/context/index.js +161 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +17 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +21 -0
- package/dist/hooks/index.js +1303 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +56 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-chat.d.ts +124 -0
- package/dist/hooks/use-chat.js +608 -0
- package/dist/hooks/use-chat.js.map +1 -0
- package/dist/hooks/use-chat.mjs +12 -0
- package/dist/hooks/use-chat.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render.d.ts +60 -0
- package/dist/hooks/use-coagent-state-render.js +195 -0
- package/dist/hooks/use-coagent-state-render.js.map +1 -0
- package/dist/hooks/use-coagent-state-render.mjs +11 -0
- package/dist/hooks/use-coagent-state-render.mjs.map +1 -0
- package/dist/hooks/use-coagent.d.ts +199 -0
- package/dist/hooks/use-coagent.js +1064 -0
- package/dist/hooks/use-coagent.js.map +1 -0
- package/dist/hooks/use-coagent.mjs +29 -0
- package/dist/hooks/use-coagent.mjs.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +140 -0
- package/dist/hooks/use-copilot-action.js +369 -0
- package/dist/hooks/use-copilot-action.js.map +1 -0
- package/dist/hooks/use-copilot-action.mjs +11 -0
- package/dist/hooks/use-copilot-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.d.ts +8 -0
- package/dist/hooks/use-copilot-authenticated-action.js +418 -0
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs +12 -0
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +38 -0
- package/dist/hooks/use-copilot-chat.js +928 -0
- package/dist/hooks/use-copilot-chat.js.map +1 -0
- package/dist/hooks/use-copilot-chat.mjs +24 -0
- package/dist/hooks/use-copilot-chat.mjs.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +33 -0
- package/dist/hooks/use-copilot-readable.js +158 -0
- package/dist/hooks/use-copilot-readable.js.map +1 -0
- package/dist/hooks/use-copilot-readable.mjs +9 -0
- package/dist/hooks/use-copilot-readable.mjs.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.d.ts +5 -0
- package/dist/hooks/use-copilot-runtime-client.js +182 -0
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -0
- package/dist/hooks/use-copilot-runtime-client.mjs +10 -0
- package/dist/hooks/use-copilot-runtime-client.mjs.map +1 -0
- package/dist/hooks/use-flat-category-store.d.ts +9 -0
- package/dist/hooks/use-flat-category-store.js +90 -0
- package/dist/hooks/use-flat-category-store.js.map +1 -0
- package/dist/hooks/use-flat-category-store.mjs +8 -0
- package/dist/hooks/use-flat-category-store.mjs.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.d.ts +12 -0
- package/dist/hooks/use-make-copilot-document-readable.js +153 -0
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs +9 -0
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -0
- package/dist/hooks/use-tree.d.ts +18 -0
- package/dist/hooks/use-tree.js +172 -0
- package/dist/hooks/use-tree.js.map +1 -0
- package/dist/hooks/use-tree.mjs +8 -0
- package/dist/hooks/use-tree.mjs.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +2224 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +83 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/copilot-task.d.ts +97 -0
- package/dist/lib/copilot-task.js +195 -0
- package/dist/lib/copilot-task.js.map +1 -0
- package/dist/lib/copilot-task.mjs +20 -0
- package/dist/lib/copilot-task.mjs.map +1 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/index.js +197 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +21 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/chat-suggestion-configuration.d.ts +22 -0
- package/dist/types/chat-suggestion-configuration.js +19 -0
- package/dist/types/chat-suggestion-configuration.js.map +1 -0
- package/dist/types/chat-suggestion-configuration.mjs +1 -0
- package/dist/types/chat-suggestion-configuration.mjs.map +1 -0
- package/dist/types/coagent-action.d.ts +29 -0
- package/dist/types/coagent-action.js +19 -0
- package/dist/types/coagent-action.js.map +1 -0
- package/dist/types/coagent-action.mjs +1 -0
- package/dist/types/coagent-action.mjs.map +1 -0
- package/dist/types/coagent-state.d.ts +11 -0
- package/dist/types/coagent-state.js +19 -0
- package/dist/types/coagent-state.js.map +1 -0
- package/dist/types/coagent-state.mjs +1 -0
- package/dist/types/coagent-state.mjs.map +1 -0
- package/dist/types/document-pointer.d.ts +9 -0
- package/dist/types/document-pointer.js +19 -0
- package/dist/types/document-pointer.js.map +1 -0
- package/dist/types/document-pointer.mjs +1 -0
- package/dist/types/document-pointer.mjs.map +1 -0
- package/dist/types/frontend-action.d.ts +126 -0
- package/dist/types/frontend-action.js +53 -0
- package/dist/types/frontend-action.js.map +1 -0
- package/dist/types/frontend-action.mjs +8 -0
- package/dist/types/frontend-action.mjs.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/system-message.d.ts +3 -0
- package/dist/types/system-message.js +19 -0
- package/dist/types/system-message.js.map +1 -0
- package/dist/types/system-message.mjs +1 -0
- package/dist/types/system-message.mjs.map +1 -0
- package/dist/utils/dev-console.d.ts +3 -0
- package/dist/utils/dev-console.js +42 -0
- package/dist/utils/dev-console.js.map +1 -0
- package/dist/utils/dev-console.mjs +8 -0
- package/dist/utils/dev-console.mjs.map +1 -0
- package/dist/utils/extract.d.ts +43 -0
- package/dist/utils/extract.js +208 -0
- package/dist/utils/extract.js.map +1 -0
- package/dist/utils/extract.mjs +18 -0
- package/dist/utils/extract.mjs.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +226 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +21 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/utils.mjs +1 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/utils.test.d.ts +2 -0
- package/dist/utils/utils.test.js +9 -0
- package/dist/utils/utils.test.js.map +1 -0
- package/dist/utils/utils.test.mjs +7 -0
- package/dist/utils/utils.test.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultCopilotContextCategories
|
|
3
|
+
} from "./chunk-LZWH4OG5.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useCopilotMessagesContext
|
|
6
|
+
} from "./chunk-DCTJZ742.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useChat
|
|
9
|
+
} from "./chunk-VGOFRULA.mjs";
|
|
10
|
+
import {
|
|
11
|
+
useCopilotContext
|
|
12
|
+
} from "./chunk-WXREY7UP.mjs";
|
|
13
|
+
import {
|
|
14
|
+
useAsyncCallback
|
|
15
|
+
} from "./chunk-LNI2Z45S.mjs";
|
|
16
|
+
import {
|
|
17
|
+
__async,
|
|
18
|
+
__objRest,
|
|
19
|
+
__spreadProps,
|
|
20
|
+
__spreadValues
|
|
21
|
+
} from "./chunk-SKC7AJIV.mjs";
|
|
22
|
+
|
|
23
|
+
// src/hooks/use-copilot-chat.ts
|
|
24
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
25
|
+
import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
26
|
+
function useCopilotChat(_a = {}) {
|
|
27
|
+
var _b = _a, {
|
|
28
|
+
makeSystemMessage
|
|
29
|
+
} = _b, options = __objRest(_b, [
|
|
30
|
+
"makeSystemMessage"
|
|
31
|
+
]);
|
|
32
|
+
const {
|
|
33
|
+
getContextString,
|
|
34
|
+
getFunctionCallHandler,
|
|
35
|
+
copilotApiConfig,
|
|
36
|
+
isLoading,
|
|
37
|
+
setIsLoading,
|
|
38
|
+
chatInstructions,
|
|
39
|
+
actions,
|
|
40
|
+
coagentStatesRef,
|
|
41
|
+
setCoagentStatesWithRef,
|
|
42
|
+
coAgentStateRenders,
|
|
43
|
+
agentSession,
|
|
44
|
+
setAgentSession,
|
|
45
|
+
forwardedParameters,
|
|
46
|
+
agentLock,
|
|
47
|
+
threadId,
|
|
48
|
+
setThreadId,
|
|
49
|
+
runId,
|
|
50
|
+
setRunId,
|
|
51
|
+
chatAbortControllerRef
|
|
52
|
+
} = useCopilotContext();
|
|
53
|
+
const { messages, setMessages } = useCopilotMessagesContext();
|
|
54
|
+
const latestGetContextString = useUpdatedRef(getContextString);
|
|
55
|
+
const deleteMessage = useCallback(
|
|
56
|
+
(messageId) => {
|
|
57
|
+
setMessages((prev) => prev.filter((message) => message.id !== messageId));
|
|
58
|
+
},
|
|
59
|
+
[setMessages]
|
|
60
|
+
);
|
|
61
|
+
const makeSystemMessageCallback = useCallback(() => {
|
|
62
|
+
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
63
|
+
const contextString = latestGetContextString.current([], defaultCopilotContextCategories);
|
|
64
|
+
return new TextMessage({
|
|
65
|
+
content: systemMessageMaker(contextString, chatInstructions),
|
|
66
|
+
role: Role.System
|
|
67
|
+
});
|
|
68
|
+
}, [getContextString, makeSystemMessage, chatInstructions]);
|
|
69
|
+
const onCoAgentStateRender = useAsyncCallback(
|
|
70
|
+
(args) => __async(this, null, function* () {
|
|
71
|
+
var _a2;
|
|
72
|
+
const { name, nodeName, state } = args;
|
|
73
|
+
let action = Object.values(coAgentStateRenders).find(
|
|
74
|
+
(action2) => action2.name === name && action2.nodeName === nodeName
|
|
75
|
+
);
|
|
76
|
+
if (!action) {
|
|
77
|
+
action = Object.values(coAgentStateRenders).find(
|
|
78
|
+
(action2) => action2.name === name && !action2.nodeName
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (action) {
|
|
82
|
+
yield (_a2 = action.handler) == null ? void 0 : _a2.call(action, { state, nodeName });
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
[coAgentStateRenders]
|
|
86
|
+
);
|
|
87
|
+
const { append, reload, stop, runChatCompletion } = useChat(__spreadProps(__spreadValues({}, options), {
|
|
88
|
+
actions: Object.values(actions),
|
|
89
|
+
copilotConfig: copilotApiConfig,
|
|
90
|
+
initialMessages: options.initialMessages || [],
|
|
91
|
+
onFunctionCall: getFunctionCallHandler(),
|
|
92
|
+
onCoAgentStateRender,
|
|
93
|
+
messages,
|
|
94
|
+
setMessages,
|
|
95
|
+
makeSystemMessageCallback,
|
|
96
|
+
isLoading,
|
|
97
|
+
setIsLoading,
|
|
98
|
+
coagentStatesRef,
|
|
99
|
+
setCoagentStatesWithRef,
|
|
100
|
+
agentSession,
|
|
101
|
+
setAgentSession,
|
|
102
|
+
forwardedParameters,
|
|
103
|
+
threadId,
|
|
104
|
+
setThreadId,
|
|
105
|
+
runId,
|
|
106
|
+
setRunId,
|
|
107
|
+
chatAbortControllerRef,
|
|
108
|
+
agentLock
|
|
109
|
+
}));
|
|
110
|
+
const latestAppend = useUpdatedRef(append);
|
|
111
|
+
const latestAppendFunc = useAsyncCallback(
|
|
112
|
+
(message) => __async(this, null, function* () {
|
|
113
|
+
return yield latestAppend.current(message);
|
|
114
|
+
}),
|
|
115
|
+
[latestAppend]
|
|
116
|
+
);
|
|
117
|
+
const latestReload = useUpdatedRef(reload);
|
|
118
|
+
const latestReloadFunc = useAsyncCallback(() => __async(this, null, function* () {
|
|
119
|
+
return yield latestReload.current();
|
|
120
|
+
}), [latestReload]);
|
|
121
|
+
const latestStop = useUpdatedRef(stop);
|
|
122
|
+
const latestStopFunc = useCallback(() => {
|
|
123
|
+
return latestStop.current();
|
|
124
|
+
}, [latestStop]);
|
|
125
|
+
const latestDelete = useUpdatedRef(deleteMessage);
|
|
126
|
+
const latestDeleteFunc = useCallback(
|
|
127
|
+
(messageId) => {
|
|
128
|
+
return latestDelete.current(messageId);
|
|
129
|
+
},
|
|
130
|
+
[latestDelete]
|
|
131
|
+
);
|
|
132
|
+
const latestSetMessages = useUpdatedRef(setMessages);
|
|
133
|
+
const latestSetMessagesFunc = useCallback(
|
|
134
|
+
(messages2) => {
|
|
135
|
+
return latestSetMessages.current(messages2);
|
|
136
|
+
},
|
|
137
|
+
[latestSetMessages]
|
|
138
|
+
);
|
|
139
|
+
const latestRunChatCompletion = useUpdatedRef(runChatCompletion);
|
|
140
|
+
const latestRunChatCompletionFunc = useAsyncCallback(() => __async(this, null, function* () {
|
|
141
|
+
return yield latestRunChatCompletion.current();
|
|
142
|
+
}), [latestRunChatCompletion]);
|
|
143
|
+
const reset = useCallback(() => {
|
|
144
|
+
latestStopFunc();
|
|
145
|
+
setMessages([]);
|
|
146
|
+
setThreadId(null);
|
|
147
|
+
setRunId(null);
|
|
148
|
+
setCoagentStatesWithRef({});
|
|
149
|
+
let initialAgentSession = null;
|
|
150
|
+
if (agentLock) {
|
|
151
|
+
initialAgentSession = {
|
|
152
|
+
agentName: agentLock
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
setAgentSession(initialAgentSession);
|
|
156
|
+
}, [
|
|
157
|
+
latestStopFunc,
|
|
158
|
+
setMessages,
|
|
159
|
+
setThreadId,
|
|
160
|
+
setCoagentStatesWithRef,
|
|
161
|
+
setAgentSession,
|
|
162
|
+
agentLock
|
|
163
|
+
]);
|
|
164
|
+
const latestReset = useUpdatedRef(reset);
|
|
165
|
+
const latestResetFunc = useCallback(() => {
|
|
166
|
+
return latestReset.current();
|
|
167
|
+
}, [latestReset]);
|
|
168
|
+
return {
|
|
169
|
+
visibleMessages: messages,
|
|
170
|
+
appendMessage: latestAppendFunc,
|
|
171
|
+
setMessages: latestSetMessagesFunc,
|
|
172
|
+
reloadMessages: latestReloadFunc,
|
|
173
|
+
stopGeneration: latestStopFunc,
|
|
174
|
+
reset: latestResetFunc,
|
|
175
|
+
deleteMessage: latestDeleteFunc,
|
|
176
|
+
runChatCompletion: latestRunChatCompletionFunc,
|
|
177
|
+
isLoading
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function useUpdatedRef(value) {
|
|
181
|
+
const ref = useRef(value);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
ref.current = value;
|
|
184
|
+
}, [value]);
|
|
185
|
+
return ref;
|
|
186
|
+
}
|
|
187
|
+
function defaultSystemMessage(contextString, additionalInstructions) {
|
|
188
|
+
return `
|
|
189
|
+
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
190
|
+
|
|
191
|
+
Help 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.
|
|
192
|
+
Always be polite and respectful, and prefer brevity over verbosity.
|
|
193
|
+
|
|
194
|
+
The user has provided you with the following context:
|
|
195
|
+
\`\`\`
|
|
196
|
+
${contextString}
|
|
197
|
+
\`\`\`
|
|
198
|
+
|
|
199
|
+
They have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.
|
|
200
|
+
|
|
201
|
+
Please assist them as best you can.
|
|
202
|
+
|
|
203
|
+
You can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.
|
|
204
|
+
|
|
205
|
+
If you would like to call a function, call it without saying anything else.
|
|
206
|
+
` + (additionalInstructions ? `
|
|
207
|
+
|
|
208
|
+
${additionalInstructions}` : "");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export {
|
|
212
|
+
useCopilotChat,
|
|
213
|
+
defaultSystemMessage
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=chunk-KXH7NSOV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"sourcesContent":["/**\n * `useCopilotChat` is a React hook that lets you directly interact with the\n * Copilot instance. Use to implement a fully custom UI (headless UI) or to\n * programmatically interact with the Copilot instance managed by the default\n * UI.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChat } from \"@copilotkit/react-core\";\n * import { Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\n *\n * export function YourComponent() {\n * const { appendMessage } = useCopilotChat();\n *\n * appendMessage(\n * new TextMessage({\n * content: \"Hello World\",\n * role: Role.User,\n * }),\n * );\n * }\n * ```\n *\n * `useCopilotChat` returns an object with the following properties:\n *\n * ```tsx\n * const {\n * visibleMessages, // An array of messages that are currently visible in the chat.\n * appendMessage, // A function to append a message to the chat.\n * setMessages, // A function to set the messages in the chat.\n * deleteMessage, // A function to delete a message from the chat.\n * reloadMessages, // A function to reload the messages from the API.\n * stopGeneration, // A function to stop the generation of the next message.\n * isLoading, // A boolean indicating if the chat is loading.\n * } = useCopilotChat();\n * ```\n */\nimport { useRef, useEffect, useCallback } from \"react\";\nimport { AgentSession, useCopilotContext } from \"../context/copilot-context\";\nimport { Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { SystemMessageFunction } from \"../types\";\nimport { useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { CoAgentStateRenderHandlerArguments } from \"@copilotkit/shared\";\nimport { useCopilotMessagesContext } from \"../context\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\n\nexport interface UseCopilotChatOptions {\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n /**\n * System messages of the chat. Defaults to an empty array.\n */\n initialMessages?: Message[];\n\n /**\n * A function to generate the system message. Defaults to `defaultSystemMessage`.\n */\n makeSystemMessage?: SystemMessageFunction;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n appendMessage: (message: Message) => Promise<void>;\n setMessages: (messages: Message[]) => void;\n deleteMessage: (messageId: string) => void;\n reloadMessages: () => Promise<void>;\n stopGeneration: () => void;\n reset: () => void;\n isLoading: boolean;\n runChatCompletion: () => Promise<Message[]>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const {\n getContextString,\n getFunctionCallHandler,\n copilotApiConfig,\n isLoading,\n setIsLoading,\n chatInstructions,\n actions,\n coagentStatesRef,\n setCoagentStatesWithRef,\n coAgentStateRenders,\n agentSession,\n setAgentSession,\n forwardedParameters,\n agentLock,\n threadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n } = useCopilotContext();\n const { messages, setMessages } = useCopilotMessagesContext();\n\n // We need to ensure that makeSystemMessageCallback always uses the latest\n // useCopilotReadable data.\n const latestGetContextString = useUpdatedRef(getContextString);\n const deleteMessage = useCallback(\n (messageId: string) => {\n setMessages((prev) => prev.filter((message) => message.id !== messageId));\n },\n [setMessages],\n );\n\n const makeSystemMessageCallback = useCallback(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n // this always gets the latest context string\n const contextString = latestGetContextString.current([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return new TextMessage({\n content: systemMessageMaker(contextString, chatInstructions),\n role: Role.System,\n });\n }, [getContextString, makeSystemMessage, chatInstructions]);\n\n const onCoAgentStateRender = useAsyncCallback(\n async (args: CoAgentStateRenderHandlerArguments) => {\n const { name, nodeName, state } = args;\n let action = Object.values(coAgentStateRenders).find(\n (action) => action.name === name && action.nodeName === nodeName,\n );\n if (!action) {\n action = Object.values(coAgentStateRenders).find(\n (action) => action.name === name && !action.nodeName,\n );\n }\n if (action) {\n await action.handler?.({ state, nodeName });\n }\n },\n [coAgentStateRenders],\n );\n\n const { append, reload, stop, runChatCompletion } = useChat({\n ...options,\n actions: Object.values(actions),\n copilotConfig: copilotApiConfig,\n initialMessages: options.initialMessages || [],\n onFunctionCall: getFunctionCallHandler(),\n onCoAgentStateRender,\n messages,\n setMessages,\n makeSystemMessageCallback,\n isLoading,\n setIsLoading,\n coagentStatesRef,\n setCoagentStatesWithRef,\n agentSession,\n setAgentSession,\n forwardedParameters,\n threadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n agentLock,\n });\n\n // this is a workaround born out of a bug that Athena incessantly ran into.\n // We could not find the origin of the bug, however, it was clear that an outdated version of the append function was being used somehow --\n // it referenced the old state of the messages array, and not the latest one.\n //\n // We want to make copilotkit as abuse-proof as possible, so we are adding this workaround to ensure that the latest version of the append function is always used.\n //\n // How does this work?\n // we store the relevant function in a ref that is always up-to-date, and then we use that ref in the callback.\n const latestAppend = useUpdatedRef(append);\n const latestAppendFunc = useAsyncCallback(\n async (message: Message) => {\n return await latestAppend.current(message);\n },\n [latestAppend],\n );\n\n const latestReload = useUpdatedRef(reload);\n const latestReloadFunc = useAsyncCallback(async () => {\n return await latestReload.current();\n }, [latestReload]);\n\n const latestStop = useUpdatedRef(stop);\n const latestStopFunc = useCallback(() => {\n return latestStop.current();\n }, [latestStop]);\n\n const latestDelete = useUpdatedRef(deleteMessage);\n const latestDeleteFunc = useCallback(\n (messageId: string) => {\n return latestDelete.current(messageId);\n },\n [latestDelete],\n );\n\n const latestSetMessages = useUpdatedRef(setMessages);\n const latestSetMessagesFunc = useCallback(\n (messages: Message[]) => {\n return latestSetMessages.current(messages);\n },\n [latestSetMessages],\n );\n\n const latestRunChatCompletion = useUpdatedRef(runChatCompletion);\n const latestRunChatCompletionFunc = useAsyncCallback(async () => {\n return await latestRunChatCompletion.current!();\n }, [latestRunChatCompletion]);\n\n const reset = useCallback(() => {\n latestStopFunc();\n setMessages([]);\n setThreadId(null);\n setRunId(null);\n setCoagentStatesWithRef({});\n let initialAgentSession: AgentSession | null = null;\n if (agentLock) {\n initialAgentSession = {\n agentName: agentLock,\n };\n }\n setAgentSession(initialAgentSession);\n }, [\n latestStopFunc,\n setMessages,\n setThreadId,\n setCoagentStatesWithRef,\n setAgentSession,\n agentLock,\n ]);\n\n const latestReset = useUpdatedRef(reset);\n const latestResetFunc = useCallback(() => {\n return latestReset.current();\n }, [latestReset]);\n\n return {\n visibleMessages: messages,\n appendMessage: latestAppendFunc,\n setMessages: latestSetMessagesFunc,\n reloadMessages: latestReloadFunc,\n stopGeneration: latestStopFunc,\n reset: latestResetFunc,\n deleteMessage: latestDeleteFunc,\n runChatCompletion: latestRunChatCompletionFunc,\n isLoading,\n };\n}\n\n// store `value` in a ref and update\n// it whenever it changes.\nfunction useUpdatedRef<T>(value: T) {\n const ref = useRef(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\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 functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,QAAQ,WAAW,mBAAmB;AAE/C,SAAkB,MAAM,mBAAmB;AA4CpC,SAAS,eAAe,KAGJ,CAAC,GAAyB;AAHtB,eAC7B;AAAA;AAAA,EAvFF,IAsF+B,IAE1B,oBAF0B,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
} from "./chunk-EWKJMQOF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useCopilotContext
|
|
6
|
+
} from "./chunk-WXREY7UP.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__spreadProps,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "./chunk-SKC7AJIV.mjs";
|
|
11
|
+
|
|
12
|
+
// src/hooks/use-copilot-authenticated-action.ts
|
|
13
|
+
import { Fragment, useCallback, useRef } from "react";
|
|
14
|
+
import React from "react";
|
|
15
|
+
function useCopilotAuthenticatedAction(action, dependencies) {
|
|
16
|
+
const { authConfig, authStates, setAuthStates } = useCopilotContext();
|
|
17
|
+
const pendingActionRef = useRef(null);
|
|
18
|
+
const executeAction = useCallback(
|
|
19
|
+
(props) => {
|
|
20
|
+
if (typeof action.render === "function") {
|
|
21
|
+
return action.render(props);
|
|
22
|
+
}
|
|
23
|
+
return action.render || React.createElement(Fragment);
|
|
24
|
+
},
|
|
25
|
+
[action]
|
|
26
|
+
);
|
|
27
|
+
const wrappedRender = useCallback(
|
|
28
|
+
(props) => {
|
|
29
|
+
const isAuthenticated = Object.values(authStates || {}).some(
|
|
30
|
+
(state) => state.status === "authenticated"
|
|
31
|
+
);
|
|
32
|
+
if (!isAuthenticated) {
|
|
33
|
+
pendingActionRef.current = props;
|
|
34
|
+
return (authConfig == null ? void 0 : authConfig.SignInComponent) ? React.createElement(authConfig.SignInComponent, {
|
|
35
|
+
onSignInComplete: (authState) => {
|
|
36
|
+
setAuthStates == null ? void 0 : setAuthStates((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
37
|
+
if (pendingActionRef.current) {
|
|
38
|
+
executeAction(pendingActionRef.current);
|
|
39
|
+
pendingActionRef.current = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}) : React.createElement(Fragment);
|
|
43
|
+
}
|
|
44
|
+
return executeAction(props);
|
|
45
|
+
},
|
|
46
|
+
[action, authStates, setAuthStates]
|
|
47
|
+
);
|
|
48
|
+
useCopilotAction(
|
|
49
|
+
__spreadProps(__spreadValues({}, action), {
|
|
50
|
+
render: wrappedRender
|
|
51
|
+
}),
|
|
52
|
+
dependencies
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
useCopilotAuthenticatedAction
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-LHKIIAUQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-authenticated-action.ts"],"sourcesContent":["import { Parameter } from \"@copilotkit/shared\";\nimport { Fragment, useCallback, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { FrontendAction, ActionRenderProps } from \"../types/frontend-action\";\nimport { useCopilotAction } from \"./use-copilot-action\";\nimport React from \"react\";\n\nexport function useCopilotAuthenticatedAction<T extends Parameter[]>(\n action: FrontendAction<T>,\n dependencies?: any[],\n): void {\n const { authConfig, authStates, setAuthStates } = useCopilotContext();\n const pendingActionRef = useRef<ActionRenderProps<Parameter[]> | null>(null);\n\n const executeAction = useCallback(\n (props: ActionRenderProps<Parameter[]>) => {\n if (typeof action.render === \"function\") {\n return action.render(props);\n }\n return action.render || React.createElement(Fragment);\n },\n [action],\n );\n\n const wrappedRender = useCallback(\n (props: ActionRenderProps<Parameter[]>): string | React.ReactElement => {\n const isAuthenticated = Object.values(authStates || {}).some(\n (state) => state.status === \"authenticated\",\n );\n\n if (!isAuthenticated) {\n // Store action details for later execution\n pendingActionRef.current = props;\n\n return authConfig?.SignInComponent\n ? React.createElement(authConfig.SignInComponent, {\n onSignInComplete: (authState) => {\n setAuthStates?.((prev) => ({ ...prev, [action.name]: authState }));\n if (pendingActionRef.current) {\n executeAction(pendingActionRef.current);\n pendingActionRef.current = null;\n }\n },\n })\n : React.createElement(Fragment);\n }\n\n return executeAction(props);\n },\n [action, authStates, setAuthStates],\n );\n\n useCopilotAction(\n {\n ...action,\n render: wrappedR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mjs";
|
|
4
|
+
import {
|
|
5
|
+
__async,
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./chunk-SKC7AJIV.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/error-boundary/error-utils.tsx
|
|
11
|
+
import { useCallback as useCallback2 } from "react";
|
|
12
|
+
|
|
13
|
+
// src/components/toast/toast-provider.tsx
|
|
14
|
+
import { createContext, useContext, useState, useCallback } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var ToastContext = createContext(void 0);
|
|
17
|
+
function useToast() {
|
|
18
|
+
const context = useContext(ToastContext);
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
function ToastProvider({
|
|
25
|
+
enabled,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
const [toasts, setToasts] = useState([]);
|
|
29
|
+
const addToast = useCallback((toast) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const id = (_a = toast.id) != null ? _a : Math.random().toString(36).substring(2, 9);
|
|
32
|
+
setToasts((currentToasts) => {
|
|
33
|
+
if (currentToasts.find((toast2) => toast2.id === id))
|
|
34
|
+
return currentToasts;
|
|
35
|
+
return [...currentToasts, __spreadProps(__spreadValues({}, toast), { id })];
|
|
36
|
+
});
|
|
37
|
+
if (toast.duration) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
removeToast(id);
|
|
40
|
+
}, toast.duration);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
const addGraphQLErrorsToast = useCallback((errors) => {
|
|
44
|
+
addToast({
|
|
45
|
+
type: "error",
|
|
46
|
+
message: /* @__PURE__ */ jsx(ErrorToast, { errors })
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
const removeToast = useCallback((id) => {
|
|
50
|
+
setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
|
|
51
|
+
}, []);
|
|
52
|
+
const value = {
|
|
53
|
+
toasts,
|
|
54
|
+
addToast,
|
|
55
|
+
addGraphQLErrorsToast,
|
|
56
|
+
removeToast,
|
|
57
|
+
enabled
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
60
|
+
/* @__PURE__ */ jsxs(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
style: {
|
|
64
|
+
position: "fixed",
|
|
65
|
+
bottom: "1rem",
|
|
66
|
+
left: "50%",
|
|
67
|
+
transform: "translateX(-50%)",
|
|
68
|
+
zIndex: 50,
|
|
69
|
+
display: "flex",
|
|
70
|
+
flexDirection: "column",
|
|
71
|
+
gap: "0.5rem"
|
|
72
|
+
},
|
|
73
|
+
children: [
|
|
74
|
+
toasts.length > 1 && /* @__PURE__ */ jsx("div", { style: { textAlign: "right" }, children: /* @__PURE__ */ jsx(
|
|
75
|
+
"button",
|
|
76
|
+
{
|
|
77
|
+
onClick: () => setToasts([]),
|
|
78
|
+
style: {
|
|
79
|
+
padding: "4px 8px",
|
|
80
|
+
fontSize: "12px",
|
|
81
|
+
cursor: "pointer",
|
|
82
|
+
background: "white",
|
|
83
|
+
border: "1px solid rgba(0,0,0,0.2)",
|
|
84
|
+
borderRadius: "4px"
|
|
85
|
+
},
|
|
86
|
+
children: "Close All"
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
toasts.map((toast) => /* @__PURE__ */ jsx(
|
|
90
|
+
Toast,
|
|
91
|
+
{
|
|
92
|
+
message: toast.message,
|
|
93
|
+
type: toast.type,
|
|
94
|
+
onClose: () => removeToast(toast.id)
|
|
95
|
+
},
|
|
96
|
+
toast.id
|
|
97
|
+
))
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
children
|
|
102
|
+
] });
|
|
103
|
+
}
|
|
104
|
+
function Toast({
|
|
105
|
+
message,
|
|
106
|
+
type = "info",
|
|
107
|
+
onClose
|
|
108
|
+
}) {
|
|
109
|
+
const bgColors = {
|
|
110
|
+
info: "#3b82f6",
|
|
111
|
+
success: "#22c55e",
|
|
112
|
+
warning: "#eab308",
|
|
113
|
+
error: "#ef4444"
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsxs(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
style: {
|
|
119
|
+
backgroundColor: bgColors[type],
|
|
120
|
+
color: "white",
|
|
121
|
+
padding: "0.5rem 1.5rem",
|
|
122
|
+
borderRadius: "0.25rem",
|
|
123
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
124
|
+
position: "relative",
|
|
125
|
+
minWidth: "200px"
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx("div", { children: message }),
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
onClick: onClose,
|
|
133
|
+
style: {
|
|
134
|
+
position: "absolute",
|
|
135
|
+
top: "0",
|
|
136
|
+
right: "0",
|
|
137
|
+
background: "none",
|
|
138
|
+
border: "none",
|
|
139
|
+
color: "white",
|
|
140
|
+
cursor: "pointer",
|
|
141
|
+
padding: "0.5rem",
|
|
142
|
+
fontSize: "1rem"
|
|
143
|
+
},
|
|
144
|
+
children: "\u2715"
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
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
|
+
export {
|
|
236
|
+
ErrorToast,
|
|
237
|
+
useErrorToast,
|
|
238
|
+
useAsyncCallback,
|
|
239
|
+
useToast,
|
|
240
|
+
ToastProvider
|
|
241
|
+
};
|
|
242
|
+
//# sourceMappingURL=chunk-LNI2Z45S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/error-boundary/error-utils.tsx","../src/components/toast/toast-provider.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 1.5rem\",\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":";;;;;;;;;;AAAA,SAAgB,eAAAA,oBAA8B;;;ACC9C,SAAgB,eAAe,YAAY,UAAU,mBAAmB;AA4DzD,cAkBT,YAlBS;AAzCf,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,UAAkC;AAtClE;AAuCI,UAAM,MAAK,WAAM,OAAN,YAAY,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC;AAEhE,cAAU,CAAC,kBAA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QAAQ;AAAA,EACX;AACF;AAEO,SAAS,iBACd,UACA,MACA;AACA,QAAM,gBAAgB,cAAc;AACpC,SAAOE,aAAY,IAAU,SAAwB;AACnD,QAAI;AACF,aAAO,MAAM,SAAS,GAAG,IAAI;AAAA,IAC/B,SAAS,OAAP;AACA,cAAQ,MAAM,4BAA4B,KAAK;AAE/C,oBAAc,CAAC,KAAK,CAAC;AACrB,YAAM;AAAA,IACR;AAAA,EACF,IAAG,IAAI;AACT;","names":["useCallback","toast","jsx","jsxs","useCallback"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-LUGEI4YQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|