@copilotkit/react-ui 1.5.1-next.1 → 1.5.1-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/{chunk-F2W5FD7L.mjs → chunk-2B57NCBA.mjs} +3 -3
- package/dist/{chunk-PNQVKBPN.mjs → chunk-4FIGRRFS.mjs} +2 -2
- package/dist/{chunk-PNQVKBPN.mjs.map → chunk-4FIGRRFS.mjs.map} +1 -1
- package/dist/{chunk-EMQEEXUB.mjs → chunk-4LUMV4YO.mjs} +3 -8
- package/dist/chunk-4LUMV4YO.mjs.map +1 -0
- package/dist/{chunk-BH6PCAAL.mjs → chunk-4T3TMQNJ.mjs} +2 -38
- package/dist/chunk-4T3TMQNJ.mjs.map +1 -0
- package/dist/{chunk-UWVGLGFQ.mjs → chunk-63ZKP62F.mjs} +4 -8
- package/dist/chunk-63ZKP62F.mjs.map +1 -0
- package/dist/{chunk-DCNCY2PL.mjs → chunk-DHGDU64D.mjs} +11 -114
- package/dist/chunk-DHGDU64D.mjs.map +1 -0
- package/dist/{chunk-3E7HY2UN.mjs → chunk-OMTPWC7T.mjs} +4 -5
- package/dist/chunk-OMTPWC7T.mjs.map +1 -0
- package/dist/{chunk-7II4YL7R.mjs → chunk-RKPANT3F.mjs} +6 -2
- package/dist/chunk-RKPANT3F.mjs.map +1 -0
- package/dist/{chunk-WSMMTZCM.mjs → chunk-TKFQ7VQR.mjs} +2 -2
- package/dist/{chunk-375NVWZM.mjs → chunk-VYKDFXGS.mjs} +2 -2
- package/dist/chunk-WOUWNTAV.mjs +72 -0
- package/dist/chunk-WOUWNTAV.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +5 -50
- package/dist/components/chat/Chat.js +41 -249
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +8 -8
- package/dist/components/chat/Input.js +2 -7
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +1 -1
- package/dist/components/chat/Messages.d.ts +3 -3
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +41 -253
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +9 -9
- package/dist/components/chat/Popup.js +41 -253
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +10 -10
- package/dist/components/chat/Sidebar.js +41 -253
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +10 -10
- package/dist/components/chat/index.js +41 -253
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +11 -11
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +3 -4
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/dev-console/console.js +28 -128
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +4 -4
- package/dist/components/dev-console/index.js +28 -128
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +4 -4
- package/dist/components/dev-console/utils.js +1 -1
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/help-modal/icons.d.ts +1 -4
- package/dist/components/help-modal/icons.js +2 -39
- package/dist/components/help-modal/icons.js.map +1 -1
- package/dist/components/help-modal/icons.mjs +3 -5
- package/dist/components/help-modal/index.js +27 -147
- package/dist/components/help-modal/index.js.map +1 -1
- package/dist/components/help-modal/index.mjs +2 -2
- package/dist/components/help-modal/modal.js +27 -147
- package/dist/components/help-modal/modal.js.map +1 -1
- package/dist/components/help-modal/modal.mjs +2 -2
- package/dist/components/index.js +41 -253
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +11 -11
- package/dist/index.js +43 -255
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/package.json +4 -4
- package/dist/chunk-3E7HY2UN.mjs.map +0 -1
- package/dist/chunk-7II4YL7R.mjs.map +0 -1
- package/dist/chunk-BH6PCAAL.mjs.map +0 -1
- package/dist/chunk-DCNCY2PL.mjs.map +0 -1
- package/dist/chunk-EMQEEXUB.mjs.map +0 -1
- package/dist/chunk-TI7SY2RI.mjs +0 -164
- package/dist/chunk-TI7SY2RI.mjs.map +0 -1
- package/dist/chunk-UWVGLGFQ.mjs.map +0 -1
- /package/dist/{chunk-F2W5FD7L.mjs.map → chunk-2B57NCBA.mjs.map} +0 -0
- /package/dist/{chunk-WSMMTZCM.mjs.map → chunk-TKFQ7VQR.mjs.map} +0 -0
- /package/dist/{chunk-375NVWZM.mjs.map → chunk-VYKDFXGS.mjs.map} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloseIcon,
|
|
3
|
+
LifeBuoyIcon
|
|
4
|
+
} from "./chunk-4T3TMQNJ.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/help-modal/modal.tsx
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function CopilotKitHelpModal() {
|
|
10
|
+
const [showHelpModal, setShowHelpModal] = useState(false);
|
|
11
|
+
const [issueDescription, setIssueDescription] = useState("");
|
|
12
|
+
const handleSubmit = () => {
|
|
13
|
+
setShowHelpModal(false);
|
|
14
|
+
};
|
|
15
|
+
const HelpButton = () => /* @__PURE__ */ jsx(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
onClick: () => setShowHelpModal(true),
|
|
19
|
+
className: "p-2 bg-transparent rounded-full shadow-lg hover:shadow-xl transition-shadow duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
20
|
+
"aria-label": "Open Help",
|
|
21
|
+
children: /* @__PURE__ */ jsx(LifeBuoyIcon, {})
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx(HelpButton, {}),
|
|
26
|
+
showHelpModal && /* @__PURE__ */ jsx(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
className: "fixed inset-0 flex items-center justify-center p-4",
|
|
30
|
+
style: { backgroundColor: "rgba(11, 15, 26, 0.5)", zIndex: 99 },
|
|
31
|
+
children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-xl max-w-md w-full p-4 flex-col relative", children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
className: "absolute text-gray-400 hover:text-gray-600 focus:outline-none",
|
|
36
|
+
style: { top: "10px", right: "10px" },
|
|
37
|
+
onClick: () => setShowHelpModal(false),
|
|
38
|
+
"aria-label": "Close",
|
|
39
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsx("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
|
|
43
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-4 mb-4", children: [
|
|
44
|
+
/* @__PURE__ */ jsx("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ jsx(
|
|
45
|
+
"a",
|
|
46
|
+
{
|
|
47
|
+
href: "https://go.copilotkit.ai/dev-console-support-discord",
|
|
48
|
+
target: "_blank",
|
|
49
|
+
rel: "noopener noreferrer",
|
|
50
|
+
children: "Go to Discord Support Channel (Community Support)"
|
|
51
|
+
}
|
|
52
|
+
) }),
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ jsx(
|
|
54
|
+
"a",
|
|
55
|
+
{
|
|
56
|
+
href: "https://go.copilotkit.ai/dev-console-support-slack",
|
|
57
|
+
target: "_blank",
|
|
58
|
+
rel: "noopener noreferrer",
|
|
59
|
+
children: "Apply for Priority Direct Slack Support"
|
|
60
|
+
}
|
|
61
|
+
) })
|
|
62
|
+
] })
|
|
63
|
+
] })
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
CopilotKitHelpModal
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-WOUWNTAV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/help-modal/modal.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { CloseIcon, LifeBuoyIcon } from \"./icons\";\n\nexport function CopilotKitHelpModal() {\n const [showHelpModal, setShowHelpModal] = useState(false);\n const [issueDescription, setIssueDescription] = useState(\"\");\n\n const handleSubmit = () => {\n // submit issueDescription\n setShowHelpModal(false);\n };\n\n const HelpButton = () => (\n <button\n onClick={() => setShowHelpModal(true)}\n className=\"p-2 bg-transparent rounded-full shadow-lg hover:shadow-xl transition-shadow duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n aria-label=\"Open Help\"\n >\n <LifeBuoyIcon />\n </button>\n );\n\n return (\n <>\n <HelpButton />\n {showHelpModal && (\n <div\n className=\"fixed inset-0 flex items-center justify-center p-4\"\n style={{ backgroundColor: \"rgba(11, 15, 26, 0.5)\", zIndex: 99 }}\n >\n <div className=\"bg-white rounded-lg shadow-xl max-w-md w-full p-4 flex-col relative\">\n <button\n className=\"absolute text-gray-400 hover:text-gray-600 focus:outline-none\"\n style={{ top: \"10px\", right: \"10px\" }}\n onClick={() => setShowHelpModal(false)}\n aria-label=\"Close\"\n >\n <CloseIcon />\n </button>\n <div className=\"w-full flex mb-6 justify-center\">\n <h2 className=\"text-2xl font-bold\">Help Options</h2>\n </div>\n <div className=\"space-y-4 mb-4\">\n <div className=\"block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm\">\n <a\n href=\"https://go.copilotkit.ai/dev-console-support-discord\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Go to Discord Support Channel (Community Support)\n </a>\n </div>\n <div className=\"block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm\">\n <a\n href=\"https://go.copilotkit.ai/dev-console-support-slack\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Apply for Priority Direct Slack Support\n </a>\n </div>\n </div>\n {/*<form onSubmit={handleSubmit} className=\"flex flex-col space-y-4\">*/}\n {/* <div>*/}\n {/* <label htmlFor=\"feedback\" className=\"block text-sm font-medium text-gray-700 mb-1\">*/}\n {/* Let us know what your issue is:*/}\n {/* </label>*/}\n {/* <textarea*/}\n {/* id=\"feedback\"*/}\n {/* rows={4}*/}\n {/* className=\"w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:border-blue-500\"*/}\n {/* placeholder=\"A Loom link / screen recording is always great!\"*/}\n {/* onChange={e => setIssueDescription(e.target.value)}*/}\n {/* value={issueDescription}*/}\n {/* ></textarea>*/}\n {/* </div>*/}\n {/* <div className=\"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse rounded-b-lg\">*/}\n {/* <button*/}\n {/* type=\"submit\"*/}\n {/* className=\"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-500 text-base font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm\"*/}\n {/* >*/}\n {/* Submit*/}\n {/* </button>*/}\n {/* </div>*/}\n {/*</form>*/}\n </div>\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAgB,gBAAgB;AAkB1B,SAKF,UALE,KAwBM,YAxBN;AAfC,SAAS,sBAAsB;AACpC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AACxD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,EAAE;AAE3D,QAAM,eAAe,MAAM;AAEzB,qBAAiB,KAAK;AAAA,EACxB;AAEA,QAAM,aAAa,MACjB;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,MAAM,iBAAiB,IAAI;AAAA,MACpC,WAAU;AAAA,MACV,cAAW;AAAA,MAEX,8BAAC,gBAAa;AAAA;AAAA,EAChB;AAGF,SACE,iCACE;AAAA,wBAAC,cAAW;AAAA,IACX,iBACC;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,iBAAiB,yBAAyB,QAAQ,GAAG;AAAA,QAE9D,+BAAC,SAAI,WAAU,uEACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,OAAO,EAAE,KAAK,QAAQ,OAAO,OAAO;AAAA,cACpC,SAAS,MAAM,iBAAiB,KAAK;AAAA,cACrC,cAAW;AAAA,cAEX,8BAAC,aAAU;AAAA;AAAA,UACb;AAAA,UACA,oBAAC,SAAI,WAAU,mCACb,8BAAC,QAAG,WAAU,sBAAqB,0BAAY,GACjD;AAAA,UACA,qBAAC,SAAI,WAAU,kBACb;AAAA,gCAAC,SAAI,WAAU,uHACb;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,QAAO;AAAA,gBACP,KAAI;AAAA,gBACL;AAAA;AAAA,YAED,GACF;AAAA,YACA,oBAAC,SAAI,WAAU,uHACb;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,QAAO;AAAA,gBACP,KAAI;AAAA,gBACL;AAAA;AAAA,YAED,GACF;AAAA,aACF;AAAA,WAwBF;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CopilotChatIcons, CopilotChatLabels } from './ChatContext.js';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import { SystemMessageFunction
|
|
4
|
+
import { SystemMessageFunction } from '@copilotkit/react-core';
|
|
5
5
|
import { CopilotChatSuggestion } from '../../types/suggestions.js';
|
|
6
6
|
import { Message } from '@copilotkit/runtime-client-gql';
|
|
7
7
|
import { MessagesProps, RenderMessageProps, InputProps, ResponseButtonProps } from './props.js';
|
|
@@ -27,14 +27,6 @@ interface CopilotChatProps {
|
|
|
27
27
|
* A callback that gets called when a new message it submitted.
|
|
28
28
|
*/
|
|
29
29
|
onSubmitMessage?: (message: string) => void | Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* A custom stop generation function.
|
|
32
|
-
*/
|
|
33
|
-
onStopGeneration?: OnStopGeneration;
|
|
34
|
-
/**
|
|
35
|
-
* A custom reload messages function.
|
|
36
|
-
*/
|
|
37
|
-
onReloadMessages?: OnReloadMessages;
|
|
38
30
|
/**
|
|
39
31
|
* Icons can be used to set custom icons for the chat window.
|
|
40
32
|
*/
|
|
@@ -92,57 +84,20 @@ interface CopilotChatProps {
|
|
|
92
84
|
*/
|
|
93
85
|
children?: React__default.ReactNode;
|
|
94
86
|
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The name of the currently executing agent.
|
|
98
|
-
*/
|
|
99
|
-
currentAgentName: string | undefined;
|
|
100
|
-
/**
|
|
101
|
-
* The messages in the chat.
|
|
102
|
-
*/
|
|
103
|
-
messages: Message[];
|
|
104
|
-
/**
|
|
105
|
-
* Set the messages in the chat.
|
|
106
|
-
*/
|
|
107
|
-
setMessages: (messages: Message[]) => void;
|
|
108
|
-
/**
|
|
109
|
-
* Stop chat generation.
|
|
110
|
-
*/
|
|
111
|
-
stopGeneration: () => void;
|
|
112
|
-
/**
|
|
113
|
-
* Restart the currently executing agent.
|
|
114
|
-
*/
|
|
115
|
-
restartCurrentAgent: () => void;
|
|
116
|
-
/**
|
|
117
|
-
* Stop the currently executing agent.
|
|
118
|
-
*/
|
|
119
|
-
stopCurrentAgent: () => void;
|
|
120
|
-
/**
|
|
121
|
-
* Run the currently executing agent.
|
|
122
|
-
*/
|
|
123
|
-
runCurrentAgent: (hint?: HintFunction) => Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Set the state of the currently executing agent.
|
|
126
|
-
*/
|
|
127
|
-
setCurrentAgentState: (state: any) => void;
|
|
128
|
-
}
|
|
129
|
-
type OnReloadMessagesArguments = OnStopGenerationArguments;
|
|
130
|
-
type OnStopGeneration = (args: OnStopGenerationArguments) => void;
|
|
131
|
-
type OnReloadMessages = (args: OnReloadMessagesArguments) => void;
|
|
132
|
-
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, showResponseButton, onInProgress, onStopGeneration, onReloadMessages, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, Input, ResponseButton, className, icons, labels, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
87
|
+
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, showResponseButton, onInProgress, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, Input, ResponseButton, className, icons, labels, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
133
88
|
declare function WrappedCopilotChat({ children, icons, labels, className, }: {
|
|
134
89
|
children: React__default.ReactNode;
|
|
135
90
|
icons?: CopilotChatIcons;
|
|
136
91
|
labels?: CopilotChatLabels;
|
|
137
92
|
className?: string;
|
|
138
93
|
}): react_jsx_runtime.JSX.Element;
|
|
139
|
-
declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: (isLoading: boolean) => void, onSubmitMessage?: (messageContent: string) => Promise<void> | void
|
|
94
|
+
declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: (isLoading: boolean) => void, onSubmitMessage?: (messageContent: string) => Promise<void> | void) => {
|
|
140
95
|
visibleMessages: Message[];
|
|
141
96
|
isLoading: boolean;
|
|
142
97
|
currentSuggestions: CopilotChatSuggestion[];
|
|
143
98
|
sendMessage: (messageContent: string) => Promise<Message>;
|
|
144
99
|
stopGeneration: () => void;
|
|
145
|
-
reloadMessages: () => void
|
|
100
|
+
reloadMessages: () => Promise<void>;
|
|
146
101
|
};
|
|
147
102
|
|
|
148
|
-
export { CopilotChat, CopilotChatProps,
|
|
103
|
+
export { CopilotChat, CopilotChatProps, WrappedCopilotChat, useCopilotChatLogic };
|
|
@@ -739,10 +739,7 @@ var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
|
739
739
|
});
|
|
740
740
|
const sendIcon = inProgress || pushToTalkState === "transcribing" ? context.icons.activityIcon : context.icons.sendIcon;
|
|
741
741
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
742
|
-
const
|
|
743
|
-
return !inProgress && text.trim().length > 0 && pushToTalkState === "idle";
|
|
744
|
-
};
|
|
745
|
-
const sendDisabled = !canSend();
|
|
742
|
+
const sendDisabled = inProgress || text.length === 0 || pushToTalkState !== "idle";
|
|
746
743
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
747
744
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
748
745
|
Textarea_default,
|
|
@@ -756,9 +753,7 @@ var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
|
756
753
|
onKeyDown: (event) => {
|
|
757
754
|
if (event.key === "Enter" && !event.shiftKey) {
|
|
758
755
|
event.preventDefault();
|
|
759
|
-
|
|
760
|
-
send();
|
|
761
|
-
}
|
|
756
|
+
send();
|
|
762
757
|
}
|
|
763
758
|
}
|
|
764
759
|
}
|
|
@@ -805,9 +800,9 @@ var import_react6 = require("react");
|
|
|
805
800
|
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
806
801
|
|
|
807
802
|
// src/hooks/use-copy-to-clipboard.tsx
|
|
808
|
-
var
|
|
803
|
+
var React5 = __toESM(require("react"));
|
|
809
804
|
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
810
|
-
const [isCopied, setIsCopied] =
|
|
805
|
+
const [isCopied, setIsCopied] = React5.useState(false);
|
|
811
806
|
const copyToClipboard = (value) => {
|
|
812
807
|
var _a;
|
|
813
808
|
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
@@ -1303,8 +1298,8 @@ function RenderActionExecutionMessage(props) {
|
|
|
1303
1298
|
const { chatComponentsCache } = (0, import_react_core3.useCopilotContext)();
|
|
1304
1299
|
const { icons } = useChatContext();
|
|
1305
1300
|
if (message.isActionExecutionMessage()) {
|
|
1306
|
-
if (chatComponentsCache.current !== null &&
|
|
1307
|
-
const render = chatComponentsCache.current.actions[message.name]
|
|
1301
|
+
if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {
|
|
1302
|
+
const render = chatComponentsCache.current.actions[message.name];
|
|
1308
1303
|
if (typeof render === "string") {
|
|
1309
1304
|
if (isCurrentMessage && inProgress) {
|
|
1310
1305
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
|
|
@@ -1327,8 +1322,7 @@ function RenderActionExecutionMessage(props) {
|
|
|
1327
1322
|
const toRender = render({
|
|
1328
1323
|
status,
|
|
1329
1324
|
args,
|
|
1330
|
-
result: actionResult
|
|
1331
|
-
name: message.name
|
|
1325
|
+
result: actionResult
|
|
1332
1326
|
});
|
|
1333
1327
|
if (!toRender && status === "complete") {
|
|
1334
1328
|
return null;
|
|
@@ -1642,7 +1636,7 @@ function logMessages(context) {
|
|
|
1642
1636
|
type: "ActionExecutionMessage",
|
|
1643
1637
|
role: void 0,
|
|
1644
1638
|
name: message.name,
|
|
1645
|
-
scope: message.
|
|
1639
|
+
scope: message.scope,
|
|
1646
1640
|
content: message.arguments
|
|
1647
1641
|
};
|
|
1648
1642
|
} else if (message.isResultMessage()) {
|
|
@@ -1765,52 +1759,41 @@ var import_react8 = require("react");
|
|
|
1765
1759
|
|
|
1766
1760
|
// src/components/help-modal/icons.tsx
|
|
1767
1761
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1768
|
-
var
|
|
1762
|
+
var LifeBuoyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1769
1763
|
"svg",
|
|
1770
1764
|
{
|
|
1771
1765
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1772
|
-
|
|
1766
|
+
width: "24",
|
|
1767
|
+
height: "24",
|
|
1773
1768
|
viewBox: "0 0 24 24",
|
|
1774
|
-
|
|
1769
|
+
fill: "none",
|
|
1775
1770
|
stroke: "currentColor",
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1771
|
+
strokeWidth: "2",
|
|
1772
|
+
strokeLinecap: "round",
|
|
1773
|
+
strokeLinejoin: "round",
|
|
1774
|
+
className: "icon icon-tabler icons-tabler-outline icon-tabler-lifebuoy",
|
|
1775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { transform: "translate(0, -1)", children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" }),
|
|
1778
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M15 15l3.35 3.35" }),
|
|
1780
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M9 15l-3.35 3.35" }),
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M5.65 5.65l3.35 3.35" }),
|
|
1782
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M18.35 5.65l-3.35 3.35" })
|
|
1783
|
+
] })
|
|
1779
1784
|
}
|
|
1780
1785
|
);
|
|
1781
|
-
var
|
|
1786
|
+
var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1782
1787
|
"svg",
|
|
1783
1788
|
{
|
|
1784
|
-
style: {
|
|
1785
|
-
animation: "copilotKitSpinAnimation 1s linear infinite",
|
|
1786
|
-
color
|
|
1787
|
-
},
|
|
1788
|
-
width: "24",
|
|
1789
|
-
height: "24",
|
|
1790
1789
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1791
1790
|
fill: "none",
|
|
1792
1791
|
viewBox: "0 0 24 24",
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
cx: "12",
|
|
1799
|
-
cy: "12",
|
|
1800
|
-
r: "10",
|
|
1801
|
-
stroke: "currentColor",
|
|
1802
|
-
strokeWidth: "4"
|
|
1803
|
-
}
|
|
1804
|
-
),
|
|
1805
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1806
|
-
"path",
|
|
1807
|
-
{
|
|
1808
|
-
style: { opacity: 0.75 },
|
|
1809
|
-
fill: "currentColor",
|
|
1810
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
1811
|
-
}
|
|
1812
|
-
)
|
|
1813
|
-
]
|
|
1792
|
+
strokeWidth: "1.5",
|
|
1793
|
+
stroke: "currentColor",
|
|
1794
|
+
width: "20",
|
|
1795
|
+
height: "20",
|
|
1796
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
1814
1797
|
}
|
|
1815
1798
|
);
|
|
1816
1799
|
|
|
@@ -1819,52 +1802,18 @@ var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
|
1819
1802
|
function CopilotKitHelpModal() {
|
|
1820
1803
|
const [showHelpModal, setShowHelpModal] = (0, import_react8.useState)(false);
|
|
1821
1804
|
const [issueDescription, setIssueDescription] = (0, import_react8.useState)("");
|
|
1822
|
-
const
|
|
1823
|
-
const [emailError, setEmailError] = (0, import_react8.useState)("");
|
|
1824
|
-
const [submitting, setSubmitting] = (0, import_react8.useState)(false);
|
|
1825
|
-
const validateEmail = (email2) => {
|
|
1826
|
-
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
1827
|
-
return re.test(email2);
|
|
1828
|
-
};
|
|
1829
|
-
const handleSubmit = (e) => __async(this, null, function* () {
|
|
1830
|
-
e.preventDefault();
|
|
1831
|
-
if ((email == null ? void 0 : email.length) > 0 && !validateEmail(email)) {
|
|
1832
|
-
setEmailError("Please enter a valid email address");
|
|
1833
|
-
return;
|
|
1834
|
-
}
|
|
1835
|
-
setSubmitting(true);
|
|
1836
|
-
yield fetch("https://api.segment.io/v1/track", {
|
|
1837
|
-
method: "POST",
|
|
1838
|
-
headers: {
|
|
1839
|
-
"Content-Type": "application/json"
|
|
1840
|
-
},
|
|
1841
|
-
body: JSON.stringify({
|
|
1842
|
-
event: "oss.dev-console.help",
|
|
1843
|
-
anonymousId: window.crypto.randomUUID(),
|
|
1844
|
-
properties: { email, text: issueDescription },
|
|
1845
|
-
writeKey: "q0gQqvGYyw9pNyhIocNzefSYKGO1aiwW"
|
|
1846
|
-
})
|
|
1847
|
-
});
|
|
1848
|
-
setEmailError("");
|
|
1849
|
-
setEmail("");
|
|
1850
|
-
setIssueDescription("");
|
|
1851
|
-
setSubmitting(false);
|
|
1805
|
+
const handleSubmit = () => {
|
|
1852
1806
|
setShowHelpModal(false);
|
|
1853
|
-
}
|
|
1807
|
+
};
|
|
1854
1808
|
const HelpButton = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1855
1809
|
"button",
|
|
1856
1810
|
{
|
|
1857
1811
|
onClick: () => setShowHelpModal(true),
|
|
1858
|
-
|
|
1859
|
-
className: "text-sm p-0 bg-transparent rounded border border-blue-500",
|
|
1812
|
+
className: "p-2 bg-transparent rounded-full shadow-lg hover:shadow-xl transition-shadow duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
1860
1813
|
"aria-label": "Open Help",
|
|
1861
|
-
children:
|
|
1814
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LifeBuoyIcon, {})
|
|
1862
1815
|
}
|
|
1863
1816
|
);
|
|
1864
|
-
const submitButtonDisabled = (0, import_react8.useMemo)(
|
|
1865
|
-
() => submitting || !!emailError || issueDescription == null || (issueDescription == null ? void 0 : issueDescription.length) == 0,
|
|
1866
|
-
[submitting, emailError, issueDescription]
|
|
1867
|
-
);
|
|
1868
1817
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1869
1818
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HelpButton, {}),
|
|
1870
1819
|
showHelpModal && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
@@ -1885,15 +1834,6 @@ function CopilotKitHelpModal() {
|
|
|
1885
1834
|
),
|
|
1886
1835
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
|
|
1887
1836
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-4 mb-4", children: [
|
|
1888
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1889
|
-
"a",
|
|
1890
|
-
{
|
|
1891
|
-
href: "https://docs.copilotkit.ai/coagents/troubleshooting/common-issues",
|
|
1892
|
-
target: "_blank",
|
|
1893
|
-
rel: "noopener noreferrer",
|
|
1894
|
-
children: "Visit the Troubleshooting and FAQ section in the docs"
|
|
1895
|
-
}
|
|
1896
|
-
) }),
|
|
1897
1837
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1898
1838
|
"a",
|
|
1899
1839
|
{
|
|
@@ -1912,52 +1852,6 @@ function CopilotKitHelpModal() {
|
|
|
1912
1852
|
children: "Apply for Priority Direct Slack Support"
|
|
1913
1853
|
}
|
|
1914
1854
|
) })
|
|
1915
|
-
] }),
|
|
1916
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("form", { onSubmit: handleSubmit, className: "flex flex-col space-y-2", children: [
|
|
1917
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
|
|
1918
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "feedback", className: "block text-sm font-medium text-gray-700 mb-1", children: "Let us know what your issue is:" }),
|
|
1919
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1920
|
-
"textarea",
|
|
1921
|
-
{
|
|
1922
|
-
id: "feedback",
|
|
1923
|
-
rows: 4,
|
|
1924
|
-
className: "w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:border-blue-500",
|
|
1925
|
-
placeholder: "A Loom link / screen recording is always great!",
|
|
1926
|
-
onChange: (e) => setIssueDescription(e.target.value),
|
|
1927
|
-
value: issueDescription,
|
|
1928
|
-
required: true
|
|
1929
|
-
}
|
|
1930
|
-
)
|
|
1931
|
-
] }),
|
|
1932
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
|
|
1933
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "email", className: "block text-sm font-medium text-gray-700 mb-1", children: "Email (optional):" }),
|
|
1934
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1935
|
-
"input",
|
|
1936
|
-
{
|
|
1937
|
-
type: "email",
|
|
1938
|
-
id: "email",
|
|
1939
|
-
className: `w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:border-blue-500 ${emailError ? "border-red-500" : ""}`,
|
|
1940
|
-
placeholder: "Enter your email for follow-up",
|
|
1941
|
-
onChange: (e) => {
|
|
1942
|
-
setEmail(e.target.value);
|
|
1943
|
-
setEmailError("");
|
|
1944
|
-
},
|
|
1945
|
-
value: email
|
|
1946
|
-
}
|
|
1947
|
-
),
|
|
1948
|
-
emailError && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-red-500 text-sm mt-1", children: emailError })
|
|
1949
|
-
] }),
|
|
1950
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "bg-gray-50 px-4 py-4 sm:px-6 sm:flex sm:flex-row-reverse rounded-b-lg", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1951
|
-
"button",
|
|
1952
|
-
{
|
|
1953
|
-
type: "submit",
|
|
1954
|
-
onClick: handleSubmit,
|
|
1955
|
-
disabled: submitButtonDisabled,
|
|
1956
|
-
style: submitButtonDisabled ? { backgroundColor: "rgb(216, 216, 216)", color: "rgb(129, 129, 129)" } : void 0,
|
|
1957
|
-
className: "w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-500 text-base font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm disabled:shadow-none",
|
|
1958
|
-
children: submitting ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LoadingSpinnerIcon, { color: "white" }) : "Submit"
|
|
1959
|
-
}
|
|
1960
|
-
) })
|
|
1961
1855
|
] })
|
|
1962
1856
|
] })
|
|
1963
1857
|
}
|
|
@@ -2168,7 +2062,6 @@ function DebugMenuButton({
|
|
|
2168
2062
|
}
|
|
2169
2063
|
|
|
2170
2064
|
// src/components/chat/Chat.tsx
|
|
2171
|
-
var import_react_core9 = require("@copilotkit/react-core");
|
|
2172
2065
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2173
2066
|
function CopilotChat({
|
|
2174
2067
|
instructions,
|
|
@@ -2176,8 +2069,6 @@ function CopilotChat({
|
|
|
2176
2069
|
makeSystemMessage,
|
|
2177
2070
|
showResponseButton = true,
|
|
2178
2071
|
onInProgress,
|
|
2179
|
-
onStopGeneration,
|
|
2180
|
-
onReloadMessages,
|
|
2181
2072
|
Messages: Messages2 = Messages,
|
|
2182
2073
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2183
2074
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2200,13 +2091,7 @@ function CopilotChat({
|
|
|
2200
2091
|
sendMessage,
|
|
2201
2092
|
stopGeneration,
|
|
2202
2093
|
reloadMessages
|
|
2203
|
-
} = useCopilotChatLogic(
|
|
2204
|
-
makeSystemMessage,
|
|
2205
|
-
onInProgress,
|
|
2206
|
-
onSubmitMessage,
|
|
2207
|
-
onStopGeneration,
|
|
2208
|
-
onReloadMessages
|
|
2209
|
-
);
|
|
2094
|
+
} = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
|
|
2210
2095
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2211
2096
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2212
2097
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2262,16 +2147,8 @@ function WrappedCopilotChat({
|
|
|
2262
2147
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
2263
2148
|
}
|
|
2264
2149
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2265
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage
|
|
2266
|
-
|
|
2267
|
-
const {
|
|
2268
|
-
visibleMessages,
|
|
2269
|
-
appendMessage,
|
|
2270
|
-
reloadMessages: defaultReloadMessages,
|
|
2271
|
-
stopGeneration: defaultStopGeneration,
|
|
2272
|
-
runChatCompletion,
|
|
2273
|
-
isLoading
|
|
2274
|
-
} = (0, import_react_core8.useCopilotChat)({
|
|
2150
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2151
|
+
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
|
|
2275
2152
|
id: (0, import_shared3.randomId)(),
|
|
2276
2153
|
makeSystemMessage
|
|
2277
2154
|
});
|
|
@@ -2279,8 +2156,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2279
2156
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2280
2157
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2281
2158
|
const abortSuggestions = () => {
|
|
2282
|
-
var
|
|
2283
|
-
(
|
|
2159
|
+
var _a;
|
|
2160
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
2284
2161
|
suggestionsAbortControllerRef.current = null;
|
|
2285
2162
|
};
|
|
2286
2163
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2306,13 +2183,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2306
2183
|
return () => {
|
|
2307
2184
|
clearTimeout(debounceTimerRef.current);
|
|
2308
2185
|
};
|
|
2309
|
-
}, [
|
|
2310
|
-
isLoading,
|
|
2311
|
-
context.chatSuggestionConfiguration,
|
|
2312
|
-
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2313
|
-
// global context
|
|
2314
|
-
visibleMessages.length == 0
|
|
2315
|
-
]);
|
|
2186
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
2316
2187
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2317
2188
|
abortSuggestions();
|
|
2318
2189
|
setCurrentSuggestions([]);
|
|
@@ -2330,85 +2201,6 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2330
2201
|
appendMessage(message);
|
|
2331
2202
|
return message;
|
|
2332
2203
|
});
|
|
2333
|
-
const messages = visibleMessages;
|
|
2334
|
-
const { setMessages } = messagesContext;
|
|
2335
|
-
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2336
|
-
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2337
|
-
if (generalContext.agentSession) {
|
|
2338
|
-
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2339
|
-
nodeName: void 0,
|
|
2340
|
-
threadId: void 0
|
|
2341
|
-
}));
|
|
2342
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2343
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2344
|
-
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2345
|
-
threadId: void 0,
|
|
2346
|
-
nodeName: void 0,
|
|
2347
|
-
runId: void 0
|
|
2348
|
-
})
|
|
2349
|
-
});
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
});
|
|
2353
|
-
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2354
|
-
if (generalContext.agentSession) {
|
|
2355
|
-
yield (0, import_react_core9.runAgent)(
|
|
2356
|
-
generalContext.agentSession.agentName,
|
|
2357
|
-
context,
|
|
2358
|
-
appendMessage,
|
|
2359
|
-
runChatCompletion,
|
|
2360
|
-
hint
|
|
2361
|
-
);
|
|
2362
|
-
}
|
|
2363
|
-
});
|
|
2364
|
-
const stopCurrentAgent = () => {
|
|
2365
|
-
if (generalContext.agentSession) {
|
|
2366
|
-
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2367
|
-
}
|
|
2368
|
-
};
|
|
2369
|
-
const setCurrentAgentState = (state) => {
|
|
2370
|
-
if (generalContext.agentSession) {
|
|
2371
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2372
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2373
|
-
[generalContext.agentSession.agentName]: {
|
|
2374
|
-
state
|
|
2375
|
-
}
|
|
2376
|
-
});
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2379
|
-
};
|
|
2380
|
-
function stopGeneration() {
|
|
2381
|
-
if (onStopGeneration) {
|
|
2382
|
-
onStopGeneration({
|
|
2383
|
-
messages,
|
|
2384
|
-
setMessages,
|
|
2385
|
-
stopGeneration: defaultStopGeneration,
|
|
2386
|
-
currentAgentName,
|
|
2387
|
-
restartCurrentAgent,
|
|
2388
|
-
stopCurrentAgent,
|
|
2389
|
-
runCurrentAgent,
|
|
2390
|
-
setCurrentAgentState
|
|
2391
|
-
});
|
|
2392
|
-
} else {
|
|
2393
|
-
defaultStopGeneration();
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
function reloadMessages() {
|
|
2397
|
-
if (onReloadMessages) {
|
|
2398
|
-
onReloadMessages({
|
|
2399
|
-
messages,
|
|
2400
|
-
setMessages,
|
|
2401
|
-
stopGeneration: defaultStopGeneration,
|
|
2402
|
-
currentAgentName,
|
|
2403
|
-
restartCurrentAgent,
|
|
2404
|
-
stopCurrentAgent,
|
|
2405
|
-
runCurrentAgent,
|
|
2406
|
-
setCurrentAgentState
|
|
2407
|
-
});
|
|
2408
|
-
} else {
|
|
2409
|
-
defaultReloadMessages();
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
2204
|
return {
|
|
2413
2205
|
visibleMessages,
|
|
2414
2206
|
isLoading,
|