@copilotkitnext/react 0.0.13-alpha.1 → 0.0.14
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/dist/index.d.mts +85 -34
- package/dist/index.d.ts +85 -34
- package/dist/index.js +481 -418
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +444 -372
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -9
- package/vitest.config.mjs +5 -0
package/dist/index.js
CHANGED
|
@@ -46,12 +46,14 @@ __export(index_exports, {
|
|
|
46
46
|
CopilotChatToolCallsView: () => CopilotChatToolCallsView_default,
|
|
47
47
|
CopilotChatUserMessage: () => CopilotChatUserMessage_default,
|
|
48
48
|
CopilotChatView: () => CopilotChatView_default,
|
|
49
|
+
CopilotKitCoreReact: () => CopilotKitCoreReact,
|
|
50
|
+
CopilotKitInspector: () => CopilotKitInspector,
|
|
49
51
|
CopilotKitProvider: () => CopilotKitProvider,
|
|
50
52
|
CopilotModalHeader: () => CopilotModalHeader,
|
|
51
53
|
CopilotSidebar: () => CopilotSidebar,
|
|
52
54
|
CopilotSidebarView: () => CopilotSidebarView,
|
|
53
55
|
WildcardToolCallRender: () => WildcardToolCallRender,
|
|
54
|
-
|
|
56
|
+
defineToolCallRenderer: () => defineToolCallRenderer,
|
|
55
57
|
useAgent: () => useAgent,
|
|
56
58
|
useAgentContext: () => useAgentContext,
|
|
57
59
|
useConfigureSuggestions: () => useConfigureSuggestions,
|
|
@@ -59,6 +61,7 @@ __export(index_exports, {
|
|
|
59
61
|
useCopilotKit: () => useCopilotKit,
|
|
60
62
|
useFrontendTool: () => useFrontendTool,
|
|
61
63
|
useHumanInTheLoop: () => useHumanInTheLoop,
|
|
64
|
+
useRenderCustomMessages: () => useRenderCustomMessages,
|
|
62
65
|
useRenderToolCall: () => useRenderToolCall,
|
|
63
66
|
useSuggestions: () => useSuggestions
|
|
64
67
|
});
|
|
@@ -946,38 +949,101 @@ CopilotChatInput.Toolbar.displayName = "CopilotChatInput.Toolbar";
|
|
|
946
949
|
var CopilotChatInput_default = CopilotChatInput;
|
|
947
950
|
|
|
948
951
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
949
|
-
var
|
|
950
|
-
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
951
|
-
var import_remark_math = __toESM(require("remark-math"));
|
|
952
|
-
var import_rehype_pretty_code = __toESM(require("rehype-pretty-code"));
|
|
953
|
-
var import_rehype_katex = __toESM(require("rehype-katex"));
|
|
954
|
-
var import_react15 = require("react");
|
|
952
|
+
var import_react16 = require("react");
|
|
955
953
|
var import_lucide_react3 = require("lucide-react");
|
|
956
954
|
var import_tailwind_merge4 = require("tailwind-merge");
|
|
957
955
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
958
|
-
var
|
|
956
|
+
var import_streamdown = require("streamdown");
|
|
959
957
|
|
|
960
958
|
// src/hooks/use-render-tool-call.tsx
|
|
961
|
-
var
|
|
959
|
+
var import_react7 = require("react");
|
|
962
960
|
var import_core2 = require("@copilotkitnext/core");
|
|
963
961
|
|
|
964
962
|
// src/providers/CopilotKitProvider.tsx
|
|
965
|
-
var
|
|
963
|
+
var import_react6 = require("react");
|
|
966
964
|
var import_zod = require("zod");
|
|
965
|
+
|
|
966
|
+
// src/lib/react-core.ts
|
|
967
967
|
var import_core = require("@copilotkitnext/core");
|
|
968
|
+
var CopilotKitCoreReact = class extends import_core.CopilotKitCore {
|
|
969
|
+
_renderToolCalls = [];
|
|
970
|
+
_renderCustomMessages = [];
|
|
971
|
+
constructor(config) {
|
|
972
|
+
super(config);
|
|
973
|
+
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
974
|
+
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
975
|
+
}
|
|
976
|
+
get renderCustomMessages() {
|
|
977
|
+
return this._renderCustomMessages;
|
|
978
|
+
}
|
|
979
|
+
get renderToolCalls() {
|
|
980
|
+
return this._renderToolCalls;
|
|
981
|
+
}
|
|
982
|
+
setRenderToolCalls(renderToolCalls) {
|
|
983
|
+
this._renderToolCalls = renderToolCalls;
|
|
984
|
+
void this.notifySubscribers(
|
|
985
|
+
(subscriber) => {
|
|
986
|
+
const reactSubscriber = subscriber;
|
|
987
|
+
if (reactSubscriber.onRenderToolCallsChanged) {
|
|
988
|
+
reactSubscriber.onRenderToolCallsChanged({
|
|
989
|
+
copilotkit: this,
|
|
990
|
+
renderToolCalls: this.renderToolCalls
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
"Subscriber onRenderToolCallsChanged error:"
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
// Override to accept React-specific subscriber type
|
|
998
|
+
subscribe(subscriber) {
|
|
999
|
+
return super.subscribe(subscriber);
|
|
1000
|
+
}
|
|
1001
|
+
unsubscribe(subscriber) {
|
|
1002
|
+
super.unsubscribe(subscriber);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
// src/components/CopilotKitInspector.tsx
|
|
1007
|
+
var React4 = __toESM(require("react"));
|
|
1008
|
+
var import_react5 = require("@lit-labs/react");
|
|
1009
|
+
var import_web_inspector = require("@copilotkitnext/web-inspector");
|
|
968
1010
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1011
|
+
(0, import_web_inspector.defineWebInspector)();
|
|
1012
|
+
var CopilotKitInspectorBase = (0, import_react5.createComponent)({
|
|
1013
|
+
tagName: import_web_inspector.WEB_INSPECTOR_TAG,
|
|
1014
|
+
elementClass: import_web_inspector.WebInspectorElement,
|
|
1015
|
+
react: React4
|
|
1016
|
+
});
|
|
1017
|
+
var CopilotKitInspector = React4.forwardRef(
|
|
1018
|
+
({ core, ...rest }, ref) => {
|
|
1019
|
+
const innerRef = React4.useRef(null);
|
|
1020
|
+
React4.useImperativeHandle(ref, () => innerRef.current, []);
|
|
1021
|
+
React4.useEffect(() => {
|
|
1022
|
+
if (innerRef.current) {
|
|
1023
|
+
innerRef.current.core = core ?? null;
|
|
1024
|
+
}
|
|
1025
|
+
}, [core]);
|
|
1026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1027
|
+
CopilotKitInspectorBase,
|
|
1028
|
+
{
|
|
1029
|
+
...rest,
|
|
1030
|
+
ref: innerRef
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
974
1033
|
}
|
|
1034
|
+
);
|
|
1035
|
+
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
1036
|
+
|
|
1037
|
+
// src/providers/CopilotKitProvider.tsx
|
|
1038
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1039
|
+
var CopilotKitContext = (0, import_react6.createContext)({
|
|
1040
|
+
copilotkit: null
|
|
975
1041
|
});
|
|
976
1042
|
function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
977
|
-
const empty = (0,
|
|
1043
|
+
const empty = (0, import_react6.useMemo)(() => [], []);
|
|
978
1044
|
const value = prop ?? empty;
|
|
979
|
-
const initial = (0,
|
|
980
|
-
(0,
|
|
1045
|
+
const initial = (0, import_react6.useRef)(value);
|
|
1046
|
+
(0, import_react6.useEffect)(() => {
|
|
981
1047
|
if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
|
|
982
1048
|
console.error(warningMessage);
|
|
983
1049
|
}
|
|
@@ -991,9 +1057,29 @@ var CopilotKitProvider = ({
|
|
|
991
1057
|
properties = {},
|
|
992
1058
|
agents__unsafe_dev_only: agents = {},
|
|
993
1059
|
renderToolCalls,
|
|
1060
|
+
renderCustomMessages,
|
|
994
1061
|
frontendTools,
|
|
995
|
-
humanInTheLoop
|
|
1062
|
+
humanInTheLoop,
|
|
1063
|
+
showDevConsole = false
|
|
996
1064
|
}) => {
|
|
1065
|
+
const [shouldRenderInspector, setShouldRenderInspector] = (0, import_react6.useState)(false);
|
|
1066
|
+
(0, import_react6.useEffect)(() => {
|
|
1067
|
+
if (typeof window === "undefined") {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (showDevConsole === true) {
|
|
1071
|
+
setShouldRenderInspector(true);
|
|
1072
|
+
} else if (showDevConsole === "auto") {
|
|
1073
|
+
const localhostHosts = /* @__PURE__ */ new Set(["localhost", "127.0.0.1"]);
|
|
1074
|
+
if (localhostHosts.has(window.location.hostname)) {
|
|
1075
|
+
setShouldRenderInspector(true);
|
|
1076
|
+
} else {
|
|
1077
|
+
setShouldRenderInspector(false);
|
|
1078
|
+
}
|
|
1079
|
+
} else {
|
|
1080
|
+
setShouldRenderInspector(false);
|
|
1081
|
+
}
|
|
1082
|
+
}, [showDevConsole]);
|
|
997
1083
|
const renderToolCallsList = useStableArrayProp(
|
|
998
1084
|
renderToolCalls,
|
|
999
1085
|
"renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.",
|
|
@@ -1007,6 +1093,10 @@ var CopilotKitProvider = ({
|
|
|
1007
1093
|
return false;
|
|
1008
1094
|
}
|
|
1009
1095
|
);
|
|
1096
|
+
const renderCustomMessagesList = useStableArrayProp(
|
|
1097
|
+
renderCustomMessages,
|
|
1098
|
+
"renderCustomMessages must be a stable array."
|
|
1099
|
+
);
|
|
1010
1100
|
const frontendToolsList = useStableArrayProp(
|
|
1011
1101
|
frontendTools,
|
|
1012
1102
|
"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead."
|
|
@@ -1015,9 +1105,7 @@ var CopilotKitProvider = ({
|
|
|
1015
1105
|
humanInTheLoop,
|
|
1016
1106
|
"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead."
|
|
1017
1107
|
);
|
|
1018
|
-
const
|
|
1019
|
-
const [currentRenderToolCalls, setCurrentRenderToolCalls] = (0, import_react5.useState)([]);
|
|
1020
|
-
const processedHumanInTheLoopTools = (0, import_react5.useMemo)(() => {
|
|
1108
|
+
const processedHumanInTheLoopTools = (0, import_react6.useMemo)(() => {
|
|
1021
1109
|
const processedTools = [];
|
|
1022
1110
|
const processedRenderToolCalls = [];
|
|
1023
1111
|
humanInTheLoopList.forEach((tool) => {
|
|
@@ -1046,13 +1134,13 @@ var CopilotKitProvider = ({
|
|
|
1046
1134
|
});
|
|
1047
1135
|
return { tools: processedTools, renderToolCalls: processedRenderToolCalls };
|
|
1048
1136
|
}, [humanInTheLoopList]);
|
|
1049
|
-
const allTools = (0,
|
|
1137
|
+
const allTools = (0, import_react6.useMemo)(() => {
|
|
1050
1138
|
const tools = [];
|
|
1051
1139
|
tools.push(...frontendToolsList);
|
|
1052
1140
|
tools.push(...processedHumanInTheLoopTools.tools);
|
|
1053
1141
|
return tools;
|
|
1054
1142
|
}, [frontendToolsList, processedHumanInTheLoopTools]);
|
|
1055
|
-
const allRenderToolCalls = (0,
|
|
1143
|
+
const allRenderToolCalls = (0, import_react6.useMemo)(() => {
|
|
1056
1144
|
const combined = [...renderToolCallsList];
|
|
1057
1145
|
frontendToolsList.forEach((tool) => {
|
|
1058
1146
|
if (tool.render) {
|
|
@@ -1069,69 +1157,55 @@ var CopilotKitProvider = ({
|
|
|
1069
1157
|
combined.push(...processedHumanInTheLoopTools.renderToolCalls);
|
|
1070
1158
|
return combined;
|
|
1071
1159
|
}, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);
|
|
1072
|
-
const copilotkit = (0,
|
|
1073
|
-
const
|
|
1160
|
+
const copilotkit = (0, import_react6.useMemo)(() => {
|
|
1161
|
+
const copilotkit2 = new CopilotKitCoreReact({
|
|
1074
1162
|
runtimeUrl,
|
|
1075
1163
|
headers,
|
|
1076
1164
|
properties,
|
|
1077
1165
|
agents__unsafe_dev_only: agents,
|
|
1078
|
-
tools: allTools
|
|
1079
|
-
|
|
1080
|
-
|
|
1166
|
+
tools: allTools,
|
|
1167
|
+
renderToolCalls: allRenderToolCalls,
|
|
1168
|
+
renderCustomMessages: renderCustomMessagesList
|
|
1169
|
+
});
|
|
1081
1170
|
return copilotkit2;
|
|
1082
|
-
}, [allTools]);
|
|
1083
|
-
(0,
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
computedMap.set(keyOf(rc), rc);
|
|
1089
|
-
}
|
|
1090
|
-
const merged = [...computedMap.values()];
|
|
1091
|
-
for (const rc of prev) {
|
|
1092
|
-
const k = keyOf(rc);
|
|
1093
|
-
if (!computedMap.has(k)) merged.push(rc);
|
|
1094
|
-
}
|
|
1095
|
-
const sameLength = merged.length === prev.length;
|
|
1096
|
-
if (sameLength) {
|
|
1097
|
-
let same = true;
|
|
1098
|
-
for (let i = 0; i < merged.length; i++) {
|
|
1099
|
-
if (merged[i] !== prev[i]) {
|
|
1100
|
-
same = false;
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
if (same) return prev;
|
|
1171
|
+
}, [allTools, allRenderToolCalls, renderCustomMessagesList]);
|
|
1172
|
+
const [, forceUpdate] = (0, import_react6.useReducer)((x) => x + 1, 0);
|
|
1173
|
+
(0, import_react6.useEffect)(() => {
|
|
1174
|
+
const unsubscribe = copilotkit.subscribe({
|
|
1175
|
+
onRenderToolCallsChanged: () => {
|
|
1176
|
+
forceUpdate();
|
|
1105
1177
|
}
|
|
1106
|
-
return merged;
|
|
1107
1178
|
});
|
|
1108
|
-
|
|
1109
|
-
|
|
1179
|
+
return () => {
|
|
1180
|
+
unsubscribe();
|
|
1181
|
+
};
|
|
1182
|
+
}, [copilotkit]);
|
|
1183
|
+
(0, import_react6.useEffect)(() => {
|
|
1110
1184
|
copilotkit.setRuntimeUrl(runtimeUrl);
|
|
1111
1185
|
copilotkit.setHeaders(headers);
|
|
1112
1186
|
copilotkit.setProperties(properties);
|
|
1113
1187
|
copilotkit.setAgents__unsafe_dev_only(agents);
|
|
1114
1188
|
}, [runtimeUrl, headers, properties, agents]);
|
|
1115
|
-
return /* @__PURE__ */ (0,
|
|
1189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1116
1190
|
CopilotKitContext.Provider,
|
|
1117
1191
|
{
|
|
1118
1192
|
value: {
|
|
1119
|
-
copilotkit
|
|
1120
|
-
renderToolCalls: allRenderToolCalls,
|
|
1121
|
-
currentRenderToolCalls,
|
|
1122
|
-
setCurrentRenderToolCalls
|
|
1193
|
+
copilotkit
|
|
1123
1194
|
},
|
|
1124
|
-
children
|
|
1195
|
+
children: [
|
|
1196
|
+
children,
|
|
1197
|
+
shouldRenderInspector ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopilotKitInspector, { core: copilotkit }) : null
|
|
1198
|
+
]
|
|
1125
1199
|
}
|
|
1126
1200
|
);
|
|
1127
1201
|
};
|
|
1128
1202
|
var useCopilotKit = () => {
|
|
1129
|
-
const context = (0,
|
|
1130
|
-
const [, forceUpdate] = (0,
|
|
1203
|
+
const context = (0, import_react6.useContext)(CopilotKitContext);
|
|
1204
|
+
const [, forceUpdate] = (0, import_react6.useReducer)((x) => x + 1, 0);
|
|
1131
1205
|
if (!context) {
|
|
1132
1206
|
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
1133
1207
|
}
|
|
1134
|
-
(0,
|
|
1208
|
+
(0, import_react6.useEffect)(() => {
|
|
1135
1209
|
const unsubscribe = context.copilotkit.subscribe({
|
|
1136
1210
|
onRuntimeConnectionStatusChanged: () => {
|
|
1137
1211
|
forceUpdate();
|
|
@@ -1147,13 +1221,22 @@ var useCopilotKit = () => {
|
|
|
1147
1221
|
// src/hooks/use-render-tool-call.tsx
|
|
1148
1222
|
var import_shared2 = require("@copilotkitnext/shared");
|
|
1149
1223
|
var import_shared3 = require("@copilotkitnext/shared");
|
|
1150
|
-
var
|
|
1224
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1151
1225
|
function useRenderToolCall() {
|
|
1152
|
-
const {
|
|
1226
|
+
const { copilotkit } = useCopilotKit();
|
|
1153
1227
|
const config = useCopilotChatConfiguration();
|
|
1154
1228
|
const agentId = config?.agentId ?? import_shared2.DEFAULT_AGENT_ID;
|
|
1155
|
-
const [executingToolCallIds, setExecutingToolCallIds] = (0,
|
|
1156
|
-
(0,
|
|
1229
|
+
const [executingToolCallIds, setExecutingToolCallIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
|
|
1230
|
+
const renderToolCalls = (0, import_react7.useSyncExternalStore)(
|
|
1231
|
+
(callback) => {
|
|
1232
|
+
return copilotkit.subscribe({
|
|
1233
|
+
onRenderToolCallsChanged: callback
|
|
1234
|
+
});
|
|
1235
|
+
},
|
|
1236
|
+
() => copilotkit.renderToolCalls,
|
|
1237
|
+
() => copilotkit.renderToolCalls
|
|
1238
|
+
);
|
|
1239
|
+
(0, import_react7.useEffect)(() => {
|
|
1157
1240
|
const unsubscribe = copilotkit.subscribe({
|
|
1158
1241
|
onToolExecutionStart: ({ toolCallId }) => {
|
|
1159
1242
|
setExecutingToolCallIds((prev) => {
|
|
@@ -1174,15 +1257,15 @@ function useRenderToolCall() {
|
|
|
1174
1257
|
});
|
|
1175
1258
|
return () => unsubscribe();
|
|
1176
1259
|
}, [copilotkit]);
|
|
1177
|
-
const renderToolCall = (0,
|
|
1260
|
+
const renderToolCall = (0, import_react7.useCallback)(
|
|
1178
1261
|
({
|
|
1179
1262
|
toolCall,
|
|
1180
1263
|
toolMessage
|
|
1181
1264
|
}) => {
|
|
1182
|
-
const exactMatches =
|
|
1265
|
+
const exactMatches = renderToolCalls.filter(
|
|
1183
1266
|
(rc) => rc.name === toolCall.function.name
|
|
1184
1267
|
);
|
|
1185
|
-
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] ||
|
|
1268
|
+
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1186
1269
|
if (!renderConfig) {
|
|
1187
1270
|
return null;
|
|
1188
1271
|
}
|
|
@@ -1190,7 +1273,7 @@ function useRenderToolCall() {
|
|
|
1190
1273
|
const args = (0, import_shared3.partialJSONParse)(toolCall.function.arguments);
|
|
1191
1274
|
const toolName = toolCall.function.name;
|
|
1192
1275
|
if (toolMessage) {
|
|
1193
|
-
return /* @__PURE__ */ (0,
|
|
1276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1194
1277
|
RenderComponent,
|
|
1195
1278
|
{
|
|
1196
1279
|
name: toolName,
|
|
@@ -1201,7 +1284,7 @@ function useRenderToolCall() {
|
|
|
1201
1284
|
toolCall.id
|
|
1202
1285
|
);
|
|
1203
1286
|
} else if (executingToolCallIds.has(toolCall.id)) {
|
|
1204
|
-
return /* @__PURE__ */ (0,
|
|
1287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1205
1288
|
RenderComponent,
|
|
1206
1289
|
{
|
|
1207
1290
|
name: toolName,
|
|
@@ -1212,7 +1295,7 @@ function useRenderToolCall() {
|
|
|
1212
1295
|
toolCall.id
|
|
1213
1296
|
);
|
|
1214
1297
|
} else {
|
|
1215
|
-
return /* @__PURE__ */ (0,
|
|
1298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1216
1299
|
RenderComponent,
|
|
1217
1300
|
{
|
|
1218
1301
|
name: toolName,
|
|
@@ -1224,16 +1307,74 @@ function useRenderToolCall() {
|
|
|
1224
1307
|
);
|
|
1225
1308
|
}
|
|
1226
1309
|
},
|
|
1227
|
-
[
|
|
1310
|
+
[renderToolCalls, executingToolCallIds, agentId]
|
|
1228
1311
|
);
|
|
1229
1312
|
return renderToolCall;
|
|
1230
1313
|
}
|
|
1231
1314
|
|
|
1315
|
+
// src/hooks/use-render-custom-messages.tsx
|
|
1316
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1317
|
+
function useRenderCustomMessages() {
|
|
1318
|
+
const { copilotkit } = useCopilotKit();
|
|
1319
|
+
const config = useCopilotChatConfiguration();
|
|
1320
|
+
if (!config) {
|
|
1321
|
+
return null;
|
|
1322
|
+
}
|
|
1323
|
+
const { agentId, threadId } = config;
|
|
1324
|
+
const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
|
|
1325
|
+
const aHasAgent = a.agentId !== void 0;
|
|
1326
|
+
const bHasAgent = b.agentId !== void 0;
|
|
1327
|
+
if (aHasAgent === bHasAgent) return 0;
|
|
1328
|
+
return aHasAgent ? -1 : 1;
|
|
1329
|
+
});
|
|
1330
|
+
return function(params) {
|
|
1331
|
+
if (!customMessageRenderers.length) {
|
|
1332
|
+
return null;
|
|
1333
|
+
}
|
|
1334
|
+
const { message, position } = params;
|
|
1335
|
+
const runId = copilotkit.getRunIdForMessage(agentId, threadId, message.id);
|
|
1336
|
+
const agent = copilotkit.getAgent(agentId);
|
|
1337
|
+
if (!agent) {
|
|
1338
|
+
throw new Error("Agent not found");
|
|
1339
|
+
}
|
|
1340
|
+
const messagesIdsInRun = agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === runId).map((msg) => msg.id);
|
|
1341
|
+
const messageIndex = agent.messages.findIndex((msg) => msg.id === message.id) ?? 0;
|
|
1342
|
+
const messageIndexInRun = Math.min(messagesIdsInRun.indexOf(message.id), 0);
|
|
1343
|
+
const numberOfMessagesInRun = messagesIdsInRun.length;
|
|
1344
|
+
const stateSnapshot = copilotkit.getStateByRun(agentId, threadId, runId);
|
|
1345
|
+
let result = null;
|
|
1346
|
+
for (const renderer of customMessageRenderers) {
|
|
1347
|
+
if (!renderer.render) {
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
const Component = renderer.render;
|
|
1351
|
+
result = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1352
|
+
Component,
|
|
1353
|
+
{
|
|
1354
|
+
message,
|
|
1355
|
+
position,
|
|
1356
|
+
runId,
|
|
1357
|
+
messageIndex,
|
|
1358
|
+
messageIndexInRun,
|
|
1359
|
+
numberOfMessagesInRun,
|
|
1360
|
+
agentId,
|
|
1361
|
+
stateSnapshot
|
|
1362
|
+
},
|
|
1363
|
+
`${runId}-${message.id}-${position}`
|
|
1364
|
+
);
|
|
1365
|
+
if (result) {
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
return result;
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1232
1373
|
// src/hooks/use-frontend-tool.tsx
|
|
1233
|
-
var
|
|
1374
|
+
var import_react8 = require("react");
|
|
1234
1375
|
function useFrontendTool(tool) {
|
|
1235
|
-
const { copilotkit
|
|
1236
|
-
(0,
|
|
1376
|
+
const { copilotkit } = useCopilotKit();
|
|
1377
|
+
(0, import_react8.useEffect)(() => {
|
|
1237
1378
|
const name = tool.name;
|
|
1238
1379
|
if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
|
|
1239
1380
|
console.warn(
|
|
@@ -1243,52 +1384,52 @@ function useFrontendTool(tool) {
|
|
|
1243
1384
|
}
|
|
1244
1385
|
copilotkit.addTool(tool);
|
|
1245
1386
|
if (tool.render) {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1387
|
+
const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
|
|
1388
|
+
const currentRenderToolCalls = copilotkit.renderToolCalls;
|
|
1389
|
+
const mergedMap = /* @__PURE__ */ new Map();
|
|
1390
|
+
for (const rc of currentRenderToolCalls) {
|
|
1391
|
+
mergedMap.set(keyOf(rc), rc);
|
|
1392
|
+
}
|
|
1393
|
+
const newEntry = {
|
|
1394
|
+
name,
|
|
1395
|
+
args: tool.parameters,
|
|
1396
|
+
agentId: tool.agentId,
|
|
1397
|
+
render: tool.render
|
|
1398
|
+
};
|
|
1399
|
+
mergedMap.set(keyOf(newEntry), newEntry);
|
|
1400
|
+
copilotkit.setRenderToolCalls(Array.from(mergedMap.values()));
|
|
1260
1401
|
}
|
|
1261
1402
|
return () => {
|
|
1262
1403
|
copilotkit.removeTool(name, tool.agentId);
|
|
1263
1404
|
};
|
|
1264
|
-
}, [tool.name, copilotkit
|
|
1405
|
+
}, [tool.name, copilotkit]);
|
|
1265
1406
|
}
|
|
1266
1407
|
|
|
1267
1408
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1268
|
-
var
|
|
1269
|
-
var
|
|
1409
|
+
var import_react9 = require("react");
|
|
1410
|
+
var import_react10 = __toESM(require("react"));
|
|
1270
1411
|
function useHumanInTheLoop(tool) {
|
|
1271
|
-
const
|
|
1412
|
+
const { copilotkit } = useCopilotKit();
|
|
1413
|
+
const [status, setStatus] = (0, import_react9.useState)(
|
|
1272
1414
|
"inProgress"
|
|
1273
1415
|
);
|
|
1274
|
-
const statusRef = (0,
|
|
1275
|
-
const resolvePromiseRef = (0,
|
|
1276
|
-
const { setCurrentRenderToolCalls } = useCopilotKit();
|
|
1416
|
+
const statusRef = (0, import_react9.useRef)(status);
|
|
1417
|
+
const resolvePromiseRef = (0, import_react9.useRef)(null);
|
|
1277
1418
|
statusRef.current = status;
|
|
1278
|
-
const respond = (0,
|
|
1419
|
+
const respond = (0, import_react9.useCallback)(async (result) => {
|
|
1279
1420
|
if (resolvePromiseRef.current) {
|
|
1280
1421
|
resolvePromiseRef.current(result);
|
|
1281
1422
|
setStatus("complete");
|
|
1282
1423
|
resolvePromiseRef.current = null;
|
|
1283
1424
|
}
|
|
1284
1425
|
}, []);
|
|
1285
|
-
const handler = (0,
|
|
1426
|
+
const handler = (0, import_react9.useCallback)(async () => {
|
|
1286
1427
|
return new Promise((resolve) => {
|
|
1287
1428
|
setStatus("executing");
|
|
1288
1429
|
resolvePromiseRef.current = resolve;
|
|
1289
1430
|
});
|
|
1290
1431
|
}, []);
|
|
1291
|
-
const RenderComponent = (0,
|
|
1432
|
+
const RenderComponent = (0, import_react9.useCallback)(
|
|
1292
1433
|
(props) => {
|
|
1293
1434
|
const ToolComponent = tool.render;
|
|
1294
1435
|
const currentStatus = statusRef.current;
|
|
@@ -1299,7 +1440,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1299
1440
|
description: tool.description || "",
|
|
1300
1441
|
respond: void 0
|
|
1301
1442
|
};
|
|
1302
|
-
return
|
|
1443
|
+
return import_react10.default.createElement(ToolComponent, enhancedProps);
|
|
1303
1444
|
} else if (currentStatus === "executing" && props.status === "executing") {
|
|
1304
1445
|
const enhancedProps = {
|
|
1305
1446
|
...props,
|
|
@@ -1307,7 +1448,7 @@ function useHumanInTheLoop(tool) {
|
|
|
1307
1448
|
description: tool.description || "",
|
|
1308
1449
|
respond
|
|
1309
1450
|
};
|
|
1310
|
-
return
|
|
1451
|
+
return import_react10.default.createElement(ToolComponent, enhancedProps);
|
|
1311
1452
|
} else if (currentStatus === "complete" && props.status === "complete") {
|
|
1312
1453
|
const enhancedProps = {
|
|
1313
1454
|
...props,
|
|
@@ -1315,9 +1456,9 @@ function useHumanInTheLoop(tool) {
|
|
|
1315
1456
|
description: tool.description || "",
|
|
1316
1457
|
respond: void 0
|
|
1317
1458
|
};
|
|
1318
|
-
return
|
|
1459
|
+
return import_react10.default.createElement(ToolComponent, enhancedProps);
|
|
1319
1460
|
}
|
|
1320
|
-
return
|
|
1461
|
+
return import_react10.default.createElement(ToolComponent, props);
|
|
1321
1462
|
},
|
|
1322
1463
|
[tool.render, tool.name, tool.description, respond]
|
|
1323
1464
|
);
|
|
@@ -1327,19 +1468,20 @@ function useHumanInTheLoop(tool) {
|
|
|
1327
1468
|
render: RenderComponent
|
|
1328
1469
|
};
|
|
1329
1470
|
useFrontendTool(frontendTool);
|
|
1330
|
-
(0,
|
|
1471
|
+
(0, import_react9.useEffect)(() => {
|
|
1331
1472
|
return () => {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
)
|
|
1473
|
+
const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
|
|
1474
|
+
const currentRenderToolCalls = copilotkit.renderToolCalls;
|
|
1475
|
+
const filtered = currentRenderToolCalls.filter(
|
|
1476
|
+
(rc) => keyOf(rc) !== keyOf({ name: tool.name, agentId: tool.agentId })
|
|
1336
1477
|
);
|
|
1478
|
+
copilotkit.setRenderToolCalls(filtered);
|
|
1337
1479
|
};
|
|
1338
|
-
}, [
|
|
1480
|
+
}, [copilotkit, tool.name, tool.agentId]);
|
|
1339
1481
|
}
|
|
1340
1482
|
|
|
1341
1483
|
// src/hooks/use-agent.tsx
|
|
1342
|
-
var
|
|
1484
|
+
var import_react11 = require("react");
|
|
1343
1485
|
var import_shared4 = require("@copilotkitnext/shared");
|
|
1344
1486
|
var ALL_UPDATES = [
|
|
1345
1487
|
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
@@ -1349,12 +1491,12 @@ var ALL_UPDATES = [
|
|
|
1349
1491
|
function useAgent({ agentId, updates } = {}) {
|
|
1350
1492
|
agentId ??= import_shared4.DEFAULT_AGENT_ID;
|
|
1351
1493
|
const { copilotkit } = useCopilotKit();
|
|
1352
|
-
const [, forceUpdate] = (0,
|
|
1353
|
-
const updateFlags = (0,
|
|
1494
|
+
const [, forceUpdate] = (0, import_react11.useReducer)((x) => x + 1, 0);
|
|
1495
|
+
const updateFlags = (0, import_react11.useMemo)(
|
|
1354
1496
|
() => updates ?? ALL_UPDATES,
|
|
1355
1497
|
[JSON.stringify(updates)]
|
|
1356
1498
|
);
|
|
1357
|
-
const agent = (0,
|
|
1499
|
+
const agent = (0, import_react11.useMemo)(() => {
|
|
1358
1500
|
return copilotkit.getAgent(agentId);
|
|
1359
1501
|
}, [
|
|
1360
1502
|
agentId,
|
|
@@ -1362,7 +1504,7 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
1362
1504
|
copilotkit.runtimeConnectionStatus,
|
|
1363
1505
|
copilotkit
|
|
1364
1506
|
]);
|
|
1365
|
-
(0,
|
|
1507
|
+
(0, import_react11.useEffect)(() => {
|
|
1366
1508
|
if (!agent) {
|
|
1367
1509
|
return;
|
|
1368
1510
|
}
|
|
@@ -1400,11 +1542,11 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
1400
1542
|
}
|
|
1401
1543
|
|
|
1402
1544
|
// src/hooks/use-agent-context.tsx
|
|
1403
|
-
var
|
|
1545
|
+
var import_react12 = require("react");
|
|
1404
1546
|
function useAgentContext(context) {
|
|
1405
1547
|
const { description, value } = context;
|
|
1406
1548
|
const { copilotkit } = useCopilotKit();
|
|
1407
|
-
(0,
|
|
1549
|
+
(0, import_react12.useEffect)(() => {
|
|
1408
1550
|
if (!copilotkit) return;
|
|
1409
1551
|
const id = copilotkit.addContext(context);
|
|
1410
1552
|
return () => {
|
|
@@ -1414,26 +1556,26 @@ function useAgentContext(context) {
|
|
|
1414
1556
|
}
|
|
1415
1557
|
|
|
1416
1558
|
// src/hooks/use-suggestions.tsx
|
|
1417
|
-
var
|
|
1559
|
+
var import_react13 = require("react");
|
|
1418
1560
|
var import_shared5 = require("@copilotkitnext/shared");
|
|
1419
1561
|
function useSuggestions({ agentId } = {}) {
|
|
1420
1562
|
const { copilotkit } = useCopilotKit();
|
|
1421
1563
|
const config = useCopilotChatConfiguration();
|
|
1422
|
-
const resolvedAgentId = (0,
|
|
1423
|
-
const [suggestions, setSuggestions] = (0,
|
|
1564
|
+
const resolvedAgentId = (0, import_react13.useMemo)(() => agentId ?? config?.agentId ?? import_shared5.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
|
|
1565
|
+
const [suggestions, setSuggestions] = (0, import_react13.useState)(() => {
|
|
1424
1566
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1425
1567
|
return result.suggestions;
|
|
1426
1568
|
});
|
|
1427
|
-
const [isLoading, setIsLoading] = (0,
|
|
1569
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(() => {
|
|
1428
1570
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1429
1571
|
return result.isLoading;
|
|
1430
1572
|
});
|
|
1431
|
-
(0,
|
|
1573
|
+
(0, import_react13.useEffect)(() => {
|
|
1432
1574
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
1433
1575
|
setSuggestions(result.suggestions);
|
|
1434
1576
|
setIsLoading(result.isLoading);
|
|
1435
1577
|
}, [copilotkit, resolvedAgentId]);
|
|
1436
|
-
(0,
|
|
1578
|
+
(0, import_react13.useEffect)(() => {
|
|
1437
1579
|
const unsubscribe = copilotkit.subscribe({
|
|
1438
1580
|
onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
|
|
1439
1581
|
if (changedAgentId !== resolvedAgentId) {
|
|
@@ -1463,10 +1605,10 @@ function useSuggestions({ agentId } = {}) {
|
|
|
1463
1605
|
unsubscribe();
|
|
1464
1606
|
};
|
|
1465
1607
|
}, [copilotkit, resolvedAgentId]);
|
|
1466
|
-
const reloadSuggestions = (0,
|
|
1608
|
+
const reloadSuggestions = (0, import_react13.useCallback)(() => {
|
|
1467
1609
|
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
1468
1610
|
}, [copilotkit, resolvedAgentId]);
|
|
1469
|
-
const clearSuggestions = (0,
|
|
1611
|
+
const clearSuggestions = (0, import_react13.useCallback)(() => {
|
|
1470
1612
|
copilotkit.clearSuggestions(resolvedAgentId);
|
|
1471
1613
|
}, [copilotkit, resolvedAgentId]);
|
|
1472
1614
|
return {
|
|
@@ -1478,20 +1620,20 @@ function useSuggestions({ agentId } = {}) {
|
|
|
1478
1620
|
}
|
|
1479
1621
|
|
|
1480
1622
|
// src/hooks/use-configure-suggestions.tsx
|
|
1481
|
-
var
|
|
1623
|
+
var import_react14 = require("react");
|
|
1482
1624
|
var import_shared6 = require("@copilotkitnext/shared");
|
|
1483
1625
|
var EMPTY_DEPS = [];
|
|
1484
1626
|
function useConfigureSuggestions(config, options) {
|
|
1485
1627
|
const { copilotkit } = useCopilotKit();
|
|
1486
1628
|
const chatConfig = useCopilotChatConfiguration();
|
|
1487
1629
|
const extraDeps = options?.deps ?? EMPTY_DEPS;
|
|
1488
|
-
const resolvedConsumerAgentId = (0,
|
|
1489
|
-
const rawConsumerAgentId = (0,
|
|
1490
|
-
const normalizationCacheRef = (0,
|
|
1630
|
+
const resolvedConsumerAgentId = (0, import_react14.useMemo)(() => chatConfig?.agentId ?? import_shared6.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
1631
|
+
const rawConsumerAgentId = (0, import_react14.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
|
|
1632
|
+
const normalizationCacheRef = (0, import_react14.useRef)({
|
|
1491
1633
|
serialized: null,
|
|
1492
1634
|
config: null
|
|
1493
1635
|
});
|
|
1494
|
-
const { normalizedConfig, serializedConfig } = (0,
|
|
1636
|
+
const { normalizedConfig, serializedConfig } = (0, import_react14.useMemo)(() => {
|
|
1495
1637
|
if (!config) {
|
|
1496
1638
|
normalizationCacheRef.current = { serialized: null, config: null };
|
|
1497
1639
|
return { normalizedConfig: null, serializedConfig: null };
|
|
@@ -1521,10 +1663,10 @@ function useConfigureSuggestions(config, options) {
|
|
|
1521
1663
|
normalizationCacheRef.current = { serialized, config: built };
|
|
1522
1664
|
return { normalizedConfig: built, serializedConfig: serialized };
|
|
1523
1665
|
}, [config, resolvedConsumerAgentId, ...extraDeps]);
|
|
1524
|
-
const latestConfigRef = (0,
|
|
1666
|
+
const latestConfigRef = (0, import_react14.useRef)(null);
|
|
1525
1667
|
latestConfigRef.current = normalizedConfig;
|
|
1526
|
-
const previousSerializedConfigRef = (0,
|
|
1527
|
-
const targetAgentId = (0,
|
|
1668
|
+
const previousSerializedConfigRef = (0, import_react14.useRef)(null);
|
|
1669
|
+
const targetAgentId = (0, import_react14.useMemo)(() => {
|
|
1528
1670
|
if (!normalizedConfig) {
|
|
1529
1671
|
return resolvedConsumerAgentId;
|
|
1530
1672
|
}
|
|
@@ -1535,7 +1677,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
1535
1677
|
return consumer;
|
|
1536
1678
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
1537
1679
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
1538
|
-
const requestReload = (0,
|
|
1680
|
+
const requestReload = (0, import_react14.useCallback)(() => {
|
|
1539
1681
|
if (!normalizedConfig) {
|
|
1540
1682
|
return;
|
|
1541
1683
|
}
|
|
@@ -1557,7 +1699,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
1557
1699
|
}
|
|
1558
1700
|
copilotkit.reloadSuggestions(targetAgentId);
|
|
1559
1701
|
}, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
|
|
1560
|
-
(0,
|
|
1702
|
+
(0, import_react14.useEffect)(() => {
|
|
1561
1703
|
if (!serializedConfig || !latestConfigRef.current) {
|
|
1562
1704
|
return;
|
|
1563
1705
|
}
|
|
@@ -1567,7 +1709,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
1567
1709
|
copilotkit.removeSuggestionsConfig(id);
|
|
1568
1710
|
};
|
|
1569
1711
|
}, [copilotkit, serializedConfig, requestReload]);
|
|
1570
|
-
(0,
|
|
1712
|
+
(0, import_react14.useEffect)(() => {
|
|
1571
1713
|
if (!normalizedConfig) {
|
|
1572
1714
|
previousSerializedConfigRef.current = null;
|
|
1573
1715
|
return;
|
|
@@ -1580,7 +1722,7 @@ function useConfigureSuggestions(config, options) {
|
|
|
1580
1722
|
}
|
|
1581
1723
|
requestReload();
|
|
1582
1724
|
}, [normalizedConfig, requestReload, serializedConfig]);
|
|
1583
|
-
(0,
|
|
1725
|
+
(0, import_react14.useEffect)(() => {
|
|
1584
1726
|
if (!normalizedConfig || extraDeps.length === 0) {
|
|
1585
1727
|
return;
|
|
1586
1728
|
}
|
|
@@ -1598,8 +1740,8 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
1598
1740
|
}
|
|
1599
1741
|
|
|
1600
1742
|
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1743
|
+
var import_react15 = __toESM(require("react"));
|
|
1744
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1603
1745
|
function CopilotChatToolCallsView({
|
|
1604
1746
|
message,
|
|
1605
1747
|
messages = []
|
|
@@ -1608,11 +1750,11 @@ function CopilotChatToolCallsView({
|
|
|
1608
1750
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
1609
1751
|
return null;
|
|
1610
1752
|
}
|
|
1611
|
-
return /* @__PURE__ */ (0,
|
|
1753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: message.toolCalls.map((toolCall) => {
|
|
1612
1754
|
const toolMessage = messages.find(
|
|
1613
1755
|
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
1614
1756
|
);
|
|
1615
|
-
return /* @__PURE__ */ (0,
|
|
1757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react15.default.Fragment, { children: renderToolCall({
|
|
1616
1758
|
toolCall,
|
|
1617
1759
|
toolMessage
|
|
1618
1760
|
}) }, toolCall.id);
|
|
@@ -1621,7 +1763,7 @@ function CopilotChatToolCallsView({
|
|
|
1621
1763
|
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
1622
1764
|
|
|
1623
1765
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
1624
|
-
var
|
|
1766
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1625
1767
|
function CopilotChatAssistantMessage({
|
|
1626
1768
|
message,
|
|
1627
1769
|
messages,
|
|
@@ -1698,7 +1840,7 @@ function CopilotChatAssistantMessage({
|
|
|
1698
1840
|
toolbar,
|
|
1699
1841
|
CopilotChatAssistantMessage.Toolbar,
|
|
1700
1842
|
{
|
|
1701
|
-
children: /* @__PURE__ */ (0,
|
|
1843
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1702
1844
|
boundCopyButton,
|
|
1703
1845
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
1704
1846
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
@@ -1719,7 +1861,7 @@ function CopilotChatAssistantMessage({
|
|
|
1719
1861
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
1720
1862
|
const shouldShowToolbar = toolbarVisible && hasContent;
|
|
1721
1863
|
if (children) {
|
|
1722
|
-
return /* @__PURE__ */ (0,
|
|
1864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: children({
|
|
1723
1865
|
markdownRenderer: boundMarkdownRenderer,
|
|
1724
1866
|
toolbar: boundToolbar,
|
|
1725
1867
|
toolCallsView: boundToolCallsView,
|
|
@@ -1739,7 +1881,7 @@ function CopilotChatAssistantMessage({
|
|
|
1739
1881
|
toolbarVisible: shouldShowToolbar
|
|
1740
1882
|
}) });
|
|
1741
1883
|
}
|
|
1742
|
-
return /* @__PURE__ */ (0,
|
|
1884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1743
1885
|
"div",
|
|
1744
1886
|
{
|
|
1745
1887
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -1757,109 +1899,11 @@ function CopilotChatAssistantMessage({
|
|
|
1757
1899
|
);
|
|
1758
1900
|
}
|
|
1759
1901
|
((CopilotChatAssistantMessage2) => {
|
|
1760
|
-
|
|
1761
|
-
children,
|
|
1762
|
-
...props
|
|
1763
|
-
}) => {
|
|
1764
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1765
|
-
"code",
|
|
1766
|
-
{
|
|
1767
|
-
className: "px-[4.8px] py-[2.5px] bg-[rgb(236,236,236)] dark:bg-gray-800 rounded text-sm font-mono font-medium! text-foreground!",
|
|
1768
|
-
...props,
|
|
1769
|
-
children
|
|
1770
|
-
}
|
|
1771
|
-
);
|
|
1772
|
-
};
|
|
1773
|
-
const CodeBlock = ({ children, className, onClick, ...props }) => {
|
|
1774
|
-
const config = useCopilotChatConfiguration();
|
|
1775
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1776
|
-
const [copied, setCopied] = (0, import_react15.useState)(false);
|
|
1777
|
-
const getCodeContent = (node) => {
|
|
1778
|
-
if (typeof node === "string") return node;
|
|
1779
|
-
if (Array.isArray(node)) return node.map(getCodeContent).join("");
|
|
1780
|
-
if (node?.props?.children) return getCodeContent(node.props.children);
|
|
1781
|
-
return "";
|
|
1782
|
-
};
|
|
1783
|
-
const codeContent = getCodeContent(children);
|
|
1784
|
-
const language = props["data-language"];
|
|
1785
|
-
const copyToClipboard = async () => {
|
|
1786
|
-
if (!codeContent.trim()) return;
|
|
1787
|
-
try {
|
|
1788
|
-
setCopied(true);
|
|
1789
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1790
|
-
if (onClick) {
|
|
1791
|
-
onClick();
|
|
1792
|
-
}
|
|
1793
|
-
} catch (err) {
|
|
1794
|
-
console.error("Failed to copy code:", err);
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative", children: [
|
|
1798
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between px-4 pr-3 py-3 text-xs", children: [
|
|
1799
|
-
language && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "font-regular text-muted-foreground dark:text-white", children: language }),
|
|
1800
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1801
|
-
"button",
|
|
1802
|
-
{
|
|
1803
|
-
className: cn(
|
|
1804
|
-
"px-2 gap-0.5 text-xs flex items-center cursor-pointer text-muted-foreground dark:text-white"
|
|
1805
|
-
),
|
|
1806
|
-
onClick: copyToClipboard,
|
|
1807
|
-
title: copied ? labels.assistantMessageToolbarCopyCodeCopiedLabel : `${labels.assistantMessageToolbarCopyCodeLabel} code`,
|
|
1808
|
-
children: [
|
|
1809
|
-
copied ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react3.Check, { className: "h-[10px]! w-[10px]!" }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react3.Copy, { className: "h-[10px]! w-[10px]!" }),
|
|
1810
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[11px]", children: copied ? labels.assistantMessageToolbarCopyCodeCopiedLabel : labels.assistantMessageToolbarCopyCodeLabel })
|
|
1811
|
-
]
|
|
1812
|
-
}
|
|
1813
|
-
)
|
|
1814
|
-
] }),
|
|
1815
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1816
|
-
"pre",
|
|
1817
|
-
{
|
|
1818
|
-
className: cn(
|
|
1819
|
-
className,
|
|
1820
|
-
"rounded-2xl bg-transparent border-t-0 my-1!"
|
|
1821
|
-
),
|
|
1822
|
-
...props,
|
|
1823
|
-
children
|
|
1824
|
-
}
|
|
1825
|
-
)
|
|
1826
|
-
] });
|
|
1827
|
-
};
|
|
1828
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1829
|
-
import_react_markdown.MarkdownHooks,
|
|
1830
|
-
{
|
|
1831
|
-
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
1832
|
-
rehypePlugins: [
|
|
1833
|
-
[
|
|
1834
|
-
import_rehype_pretty_code.default,
|
|
1835
|
-
{
|
|
1836
|
-
keepBackground: false,
|
|
1837
|
-
theme: {
|
|
1838
|
-
dark: "one-dark-pro",
|
|
1839
|
-
light: "one-light"
|
|
1840
|
-
},
|
|
1841
|
-
bypassInlineCode: true
|
|
1842
|
-
}
|
|
1843
|
-
],
|
|
1844
|
-
import_rehype_katex.default
|
|
1845
|
-
],
|
|
1846
|
-
components: {
|
|
1847
|
-
pre: CodeBlock,
|
|
1848
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1849
|
-
code: ({ className: className2, children, ...props }) => {
|
|
1850
|
-
if (typeof children === "string") {
|
|
1851
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InlineCode, { ...props, children });
|
|
1852
|
-
}
|
|
1853
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { className: className2, ...props, children });
|
|
1854
|
-
}
|
|
1855
|
-
},
|
|
1856
|
-
children: (0, import_core3.completePartialMarkdown)(content || "")
|
|
1857
|
-
}
|
|
1858
|
-
) });
|
|
1902
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_streamdown.Streamdown, { className, ...props, children: content ?? "" });
|
|
1859
1903
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
1860
1904
|
className,
|
|
1861
1905
|
...props
|
|
1862
|
-
}) => /* @__PURE__ */ (0,
|
|
1906
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1863
1907
|
"div",
|
|
1864
1908
|
{
|
|
1865
1909
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -1870,8 +1914,8 @@ function CopilotChatAssistantMessage({
|
|
|
1870
1914
|
}
|
|
1871
1915
|
);
|
|
1872
1916
|
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
1873
|
-
return /* @__PURE__ */ (0,
|
|
1874
|
-
/* @__PURE__ */ (0,
|
|
1917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Tooltip, { children: [
|
|
1918
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1875
1919
|
Button,
|
|
1876
1920
|
{
|
|
1877
1921
|
type: "button",
|
|
@@ -1881,13 +1925,13 @@ function CopilotChatAssistantMessage({
|
|
|
1881
1925
|
children
|
|
1882
1926
|
}
|
|
1883
1927
|
) }),
|
|
1884
|
-
/* @__PURE__ */ (0,
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: title }) })
|
|
1885
1929
|
] });
|
|
1886
1930
|
};
|
|
1887
1931
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
1888
1932
|
const config = useCopilotChatConfiguration();
|
|
1889
1933
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1890
|
-
const [copied, setCopied] = (0,
|
|
1934
|
+
const [copied, setCopied] = (0, import_react16.useState)(false);
|
|
1891
1935
|
const handleClick = (event) => {
|
|
1892
1936
|
setCopied(true);
|
|
1893
1937
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -1895,62 +1939,62 @@ function CopilotChatAssistantMessage({
|
|
|
1895
1939
|
onClick(event);
|
|
1896
1940
|
}
|
|
1897
1941
|
};
|
|
1898
|
-
return /* @__PURE__ */ (0,
|
|
1942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1899
1943
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
1900
1944
|
{
|
|
1901
1945
|
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
1902
1946
|
onClick: handleClick,
|
|
1903
1947
|
className,
|
|
1904
1948
|
...props,
|
|
1905
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
1949
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Copy, { className: "size-[18px]" })
|
|
1906
1950
|
}
|
|
1907
1951
|
);
|
|
1908
1952
|
};
|
|
1909
1953
|
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
1910
1954
|
const config = useCopilotChatConfiguration();
|
|
1911
1955
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1912
|
-
return /* @__PURE__ */ (0,
|
|
1956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1913
1957
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
1914
1958
|
{
|
|
1915
1959
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
1916
1960
|
...props,
|
|
1917
|
-
children: /* @__PURE__ */ (0,
|
|
1961
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ThumbsUp, { className: "size-[18px]" })
|
|
1918
1962
|
}
|
|
1919
1963
|
);
|
|
1920
1964
|
};
|
|
1921
1965
|
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
1922
1966
|
const config = useCopilotChatConfiguration();
|
|
1923
1967
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1924
|
-
return /* @__PURE__ */ (0,
|
|
1968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1925
1969
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
1926
1970
|
{
|
|
1927
1971
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
1928
1972
|
...props,
|
|
1929
|
-
children: /* @__PURE__ */ (0,
|
|
1973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ThumbsDown, { className: "size-[18px]" })
|
|
1930
1974
|
}
|
|
1931
1975
|
);
|
|
1932
1976
|
};
|
|
1933
1977
|
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
1934
1978
|
const config = useCopilotChatConfiguration();
|
|
1935
1979
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1936
|
-
return /* @__PURE__ */ (0,
|
|
1980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1937
1981
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
1938
1982
|
{
|
|
1939
1983
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
1940
1984
|
...props,
|
|
1941
|
-
children: /* @__PURE__ */ (0,
|
|
1985
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Volume2, { className: "size-[20px]" })
|
|
1942
1986
|
}
|
|
1943
1987
|
);
|
|
1944
1988
|
};
|
|
1945
1989
|
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
1946
1990
|
const config = useCopilotChatConfiguration();
|
|
1947
1991
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1948
|
-
return /* @__PURE__ */ (0,
|
|
1992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1949
1993
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
1950
1994
|
{
|
|
1951
1995
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
1952
1996
|
...props,
|
|
1953
|
-
children: /* @__PURE__ */ (0,
|
|
1997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.RefreshCw, { className: "size-[18px]" })
|
|
1954
1998
|
}
|
|
1955
1999
|
);
|
|
1956
2000
|
};
|
|
@@ -1965,10 +2009,10 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
1965
2009
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
1966
2010
|
|
|
1967
2011
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
1968
|
-
var
|
|
2012
|
+
var import_react17 = require("react");
|
|
1969
2013
|
var import_lucide_react4 = require("lucide-react");
|
|
1970
2014
|
var import_tailwind_merge5 = require("tailwind-merge");
|
|
1971
|
-
var
|
|
2015
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1972
2016
|
function CopilotChatUserMessage({
|
|
1973
2017
|
message,
|
|
1974
2018
|
onEditMessage,
|
|
@@ -2026,7 +2070,7 @@ function CopilotChatUserMessage({
|
|
|
2026
2070
|
);
|
|
2027
2071
|
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
2028
2072
|
const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
|
|
2029
|
-
children: /* @__PURE__ */ (0,
|
|
2073
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1 justify-end", children: [
|
|
2030
2074
|
additionalToolbarItems,
|
|
2031
2075
|
BoundCopyButton,
|
|
2032
2076
|
onEditMessage && BoundEditButton,
|
|
@@ -2034,7 +2078,7 @@ function CopilotChatUserMessage({
|
|
|
2034
2078
|
] })
|
|
2035
2079
|
});
|
|
2036
2080
|
if (children) {
|
|
2037
|
-
return /* @__PURE__ */ (0,
|
|
2081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: children({
|
|
2038
2082
|
messageRenderer: BoundMessageRenderer,
|
|
2039
2083
|
toolbar: BoundToolbar,
|
|
2040
2084
|
copyButton: BoundCopyButton,
|
|
@@ -2046,7 +2090,7 @@ function CopilotChatUserMessage({
|
|
|
2046
2090
|
additionalToolbarItems
|
|
2047
2091
|
}) });
|
|
2048
2092
|
}
|
|
2049
|
-
return /* @__PURE__ */ (0,
|
|
2093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2050
2094
|
"div",
|
|
2051
2095
|
{
|
|
2052
2096
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group pt-10", className),
|
|
@@ -2060,7 +2104,7 @@ function CopilotChatUserMessage({
|
|
|
2060
2104
|
);
|
|
2061
2105
|
}
|
|
2062
2106
|
((CopilotChatUserMessage2) => {
|
|
2063
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
2107
|
+
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2064
2108
|
"div",
|
|
2065
2109
|
{
|
|
2066
2110
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group", className),
|
|
@@ -2068,7 +2112,7 @@ function CopilotChatUserMessage({
|
|
|
2068
2112
|
children
|
|
2069
2113
|
}
|
|
2070
2114
|
);
|
|
2071
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0,
|
|
2115
|
+
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2072
2116
|
"div",
|
|
2073
2117
|
{
|
|
2074
2118
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2081,7 +2125,7 @@ function CopilotChatUserMessage({
|
|
|
2081
2125
|
CopilotChatUserMessage2.Toolbar = ({
|
|
2082
2126
|
className,
|
|
2083
2127
|
...props
|
|
2084
|
-
}) => /* @__PURE__ */ (0,
|
|
2128
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2085
2129
|
"div",
|
|
2086
2130
|
{
|
|
2087
2131
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2092,8 +2136,8 @@ function CopilotChatUserMessage({
|
|
|
2092
2136
|
}
|
|
2093
2137
|
);
|
|
2094
2138
|
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
2095
|
-
return /* @__PURE__ */ (0,
|
|
2096
|
-
/* @__PURE__ */ (0,
|
|
2139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Tooltip, { children: [
|
|
2140
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2097
2141
|
Button,
|
|
2098
2142
|
{
|
|
2099
2143
|
type: "button",
|
|
@@ -2104,13 +2148,13 @@ function CopilotChatUserMessage({
|
|
|
2104
2148
|
children
|
|
2105
2149
|
}
|
|
2106
2150
|
) }),
|
|
2107
|
-
/* @__PURE__ */ (0,
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: title }) })
|
|
2108
2152
|
] });
|
|
2109
2153
|
};
|
|
2110
2154
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2111
2155
|
const config = useCopilotChatConfiguration();
|
|
2112
2156
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2113
|
-
const [copied, setCopied] = (0,
|
|
2157
|
+
const [copied, setCopied] = (0, import_react17.useState)(false);
|
|
2114
2158
|
const handleClick = (event) => {
|
|
2115
2159
|
setCopied(true);
|
|
2116
2160
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2118,27 +2162,27 @@ function CopilotChatUserMessage({
|
|
|
2118
2162
|
onClick(event);
|
|
2119
2163
|
}
|
|
2120
2164
|
};
|
|
2121
|
-
return /* @__PURE__ */ (0,
|
|
2165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2122
2166
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2123
2167
|
{
|
|
2124
2168
|
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
2125
2169
|
onClick: handleClick,
|
|
2126
2170
|
className,
|
|
2127
2171
|
...props,
|
|
2128
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
2172
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.Copy, { className: "size-[18px]" })
|
|
2129
2173
|
}
|
|
2130
2174
|
);
|
|
2131
2175
|
};
|
|
2132
2176
|
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
2133
2177
|
const config = useCopilotChatConfiguration();
|
|
2134
2178
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2135
|
-
return /* @__PURE__ */ (0,
|
|
2179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2136
2180
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2137
2181
|
{
|
|
2138
2182
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
2139
2183
|
className,
|
|
2140
2184
|
...props,
|
|
2141
|
-
children: /* @__PURE__ */ (0,
|
|
2185
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.Edit, { className: "size-[18px]" })
|
|
2142
2186
|
}
|
|
2143
2187
|
);
|
|
2144
2188
|
};
|
|
@@ -2155,8 +2199,8 @@ function CopilotChatUserMessage({
|
|
|
2155
2199
|
}
|
|
2156
2200
|
const canGoPrev = currentBranch > 0;
|
|
2157
2201
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
2158
|
-
return /* @__PURE__ */ (0,
|
|
2159
|
-
/* @__PURE__ */ (0,
|
|
2202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex items-center gap-1", className), ...props, children: [
|
|
2203
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2160
2204
|
Button,
|
|
2161
2205
|
{
|
|
2162
2206
|
type: "button",
|
|
@@ -2168,15 +2212,15 @@ function CopilotChatUserMessage({
|
|
|
2168
2212
|
}),
|
|
2169
2213
|
disabled: !canGoPrev,
|
|
2170
2214
|
className: "h-6 w-6 p-0",
|
|
2171
|
-
children: /* @__PURE__ */ (0,
|
|
2215
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronLeft, { className: "size-[20px]" })
|
|
2172
2216
|
}
|
|
2173
2217
|
),
|
|
2174
|
-
/* @__PURE__ */ (0,
|
|
2218
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
2175
2219
|
currentBranch + 1,
|
|
2176
2220
|
"/",
|
|
2177
2221
|
numberOfBranches
|
|
2178
2222
|
] }),
|
|
2179
|
-
/* @__PURE__ */ (0,
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2180
2224
|
Button,
|
|
2181
2225
|
{
|
|
2182
2226
|
type: "button",
|
|
@@ -2188,7 +2232,7 @@ function CopilotChatUserMessage({
|
|
|
2188
2232
|
}),
|
|
2189
2233
|
disabled: !canGoNext,
|
|
2190
2234
|
className: "h-6 w-6 p-0",
|
|
2191
|
-
children: /* @__PURE__ */ (0,
|
|
2235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ChevronRight, { className: "size-[20px]" })
|
|
2192
2236
|
}
|
|
2193
2237
|
)
|
|
2194
2238
|
] });
|
|
@@ -2204,14 +2248,14 @@ CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.Br
|
|
|
2204
2248
|
var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
2205
2249
|
|
|
2206
2250
|
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2207
|
-
var
|
|
2251
|
+
var import_react18 = __toESM(require("react"));
|
|
2208
2252
|
var import_lucide_react5 = require("lucide-react");
|
|
2209
|
-
var
|
|
2253
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2210
2254
|
var baseClasses = "group inline-flex h-8 items-center gap-1.5 rounded-full border border-border/60 bg-background px-3 text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
2211
2255
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2212
|
-
var CopilotChatSuggestionPill =
|
|
2256
|
+
var CopilotChatSuggestionPill = import_react18.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
2213
2257
|
const showIcon = !isLoading && icon;
|
|
2214
|
-
return /* @__PURE__ */ (0,
|
|
2258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2215
2259
|
"button",
|
|
2216
2260
|
{
|
|
2217
2261
|
ref,
|
|
@@ -2222,8 +2266,8 @@ var CopilotChatSuggestionPill = import_react17.default.forwardRef(function Copil
|
|
|
2222
2266
|
disabled: isLoading || props.disabled,
|
|
2223
2267
|
...props,
|
|
2224
2268
|
children: [
|
|
2225
|
-
isLoading ? /* @__PURE__ */ (0,
|
|
2226
|
-
/* @__PURE__ */ (0,
|
|
2269
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-4 w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Loader2, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-4 w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2270
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: labelClasses, children })
|
|
2227
2271
|
]
|
|
2228
2272
|
}
|
|
2229
2273
|
);
|
|
@@ -2232,10 +2276,10 @@ CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
|
|
|
2232
2276
|
var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
2233
2277
|
|
|
2234
2278
|
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2235
|
-
var
|
|
2236
|
-
var
|
|
2237
|
-
var DefaultContainer =
|
|
2238
|
-
return /* @__PURE__ */ (0,
|
|
2279
|
+
var import_react19 = __toESM(require("react"));
|
|
2280
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2281
|
+
var DefaultContainer = import_react19.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
2282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2239
2283
|
"div",
|
|
2240
2284
|
{
|
|
2241
2285
|
ref,
|
|
@@ -2247,7 +2291,7 @@ var DefaultContainer = import_react18.default.forwardRef(function DefaultContain
|
|
|
2247
2291
|
}
|
|
2248
2292
|
);
|
|
2249
2293
|
});
|
|
2250
|
-
var CopilotChatSuggestionView =
|
|
2294
|
+
var CopilotChatSuggestionView = import_react19.default.forwardRef(function CopilotChatSuggestionView2({
|
|
2251
2295
|
suggestions,
|
|
2252
2296
|
onSelectSuggestion,
|
|
2253
2297
|
loadingIndexes,
|
|
@@ -2257,7 +2301,7 @@ var CopilotChatSuggestionView = import_react18.default.forwardRef(function Copil
|
|
|
2257
2301
|
children,
|
|
2258
2302
|
...restProps
|
|
2259
2303
|
}, ref) {
|
|
2260
|
-
const loadingSet =
|
|
2304
|
+
const loadingSet = import_react19.default.useMemo(() => {
|
|
2261
2305
|
if (!loadingIndexes || loadingIndexes.length === 0) {
|
|
2262
2306
|
return /* @__PURE__ */ new Set();
|
|
2263
2307
|
}
|
|
@@ -2276,11 +2320,11 @@ var CopilotChatSuggestionView = import_react18.default.forwardRef(function Copil
|
|
|
2276
2320
|
type: "button",
|
|
2277
2321
|
onClick: () => onSelectSuggestion?.(suggestion, index)
|
|
2278
2322
|
});
|
|
2279
|
-
return
|
|
2323
|
+
return import_react19.default.cloneElement(pill, {
|
|
2280
2324
|
key: `${suggestion.title}-${index}`
|
|
2281
2325
|
});
|
|
2282
2326
|
});
|
|
2283
|
-
const boundContainer =
|
|
2327
|
+
const boundContainer = import_react19.default.cloneElement(
|
|
2284
2328
|
ContainerElement,
|
|
2285
2329
|
void 0,
|
|
2286
2330
|
suggestionElements
|
|
@@ -2291,7 +2335,7 @@ var CopilotChatSuggestionView = import_react18.default.forwardRef(function Copil
|
|
|
2291
2335
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2292
2336
|
type: "button"
|
|
2293
2337
|
});
|
|
2294
|
-
return /* @__PURE__ */ (0,
|
|
2338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: children({
|
|
2295
2339
|
container: boundContainer,
|
|
2296
2340
|
suggestion: sampleSuggestion,
|
|
2297
2341
|
suggestions,
|
|
@@ -2302,7 +2346,7 @@ var CopilotChatSuggestionView = import_react18.default.forwardRef(function Copil
|
|
|
2302
2346
|
}) });
|
|
2303
2347
|
}
|
|
2304
2348
|
if (children) {
|
|
2305
|
-
return /* @__PURE__ */ (0,
|
|
2349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2306
2350
|
boundContainer,
|
|
2307
2351
|
children
|
|
2308
2352
|
] });
|
|
@@ -2314,7 +2358,7 @@ var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
|
2314
2358
|
|
|
2315
2359
|
// src/components/chat/CopilotChatMessageView.tsx
|
|
2316
2360
|
var import_tailwind_merge6 = require("tailwind-merge");
|
|
2317
|
-
var
|
|
2361
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2318
2362
|
function CopilotChatMessageView({
|
|
2319
2363
|
messages = [],
|
|
2320
2364
|
assistantMessage,
|
|
@@ -2325,41 +2369,57 @@ function CopilotChatMessageView({
|
|
|
2325
2369
|
className,
|
|
2326
2370
|
...props
|
|
2327
2371
|
}) {
|
|
2328
|
-
const
|
|
2372
|
+
const renderCustomMessage = useRenderCustomMessages();
|
|
2373
|
+
const messageElements = messages.flatMap((message) => {
|
|
2374
|
+
const elements = [];
|
|
2375
|
+
if (renderCustomMessage) {
|
|
2376
|
+
elements.push(
|
|
2377
|
+
renderCustomMessage({
|
|
2378
|
+
message,
|
|
2379
|
+
position: "before"
|
|
2380
|
+
})
|
|
2381
|
+
);
|
|
2382
|
+
}
|
|
2329
2383
|
if (message.role === "assistant") {
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2384
|
+
elements.push(
|
|
2385
|
+
renderSlot(assistantMessage, CopilotChatAssistantMessage_default, {
|
|
2386
|
+
key: message.id,
|
|
2387
|
+
message,
|
|
2388
|
+
messages,
|
|
2389
|
+
isRunning
|
|
2390
|
+
})
|
|
2391
|
+
);
|
|
2336
2392
|
} else if (message.role === "user") {
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2393
|
+
elements.push(
|
|
2394
|
+
renderSlot(userMessage, CopilotChatUserMessage_default, {
|
|
2395
|
+
key: message.id,
|
|
2396
|
+
message
|
|
2397
|
+
})
|
|
2398
|
+
);
|
|
2341
2399
|
}
|
|
2342
|
-
|
|
2400
|
+
if (renderCustomMessage) {
|
|
2401
|
+
elements.push(
|
|
2402
|
+
renderCustomMessage({
|
|
2403
|
+
message,
|
|
2404
|
+
position: "after"
|
|
2405
|
+
})
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
return elements;
|
|
2343
2409
|
}).filter(Boolean);
|
|
2344
2410
|
if (children) {
|
|
2345
2411
|
return children({ messageElements, messages, isRunning });
|
|
2346
2412
|
}
|
|
2347
|
-
return /* @__PURE__ */ (0,
|
|
2413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: (0, import_tailwind_merge6.twMerge)("flex flex-col", className), ...props, children: [
|
|
2348
2414
|
messageElements,
|
|
2349
2415
|
isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
|
|
2350
2416
|
] });
|
|
2351
2417
|
}
|
|
2352
|
-
CopilotChatMessageView.Cursor = function Cursor({
|
|
2353
|
-
|
|
2354
|
-
...props
|
|
2355
|
-
}) {
|
|
2356
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2418
|
+
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2357
2420
|
"div",
|
|
2358
2421
|
{
|
|
2359
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
2360
|
-
"w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1",
|
|
2361
|
-
className
|
|
2362
|
-
),
|
|
2422
|
+
className: (0, import_tailwind_merge6.twMerge)("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
2363
2423
|
...props
|
|
2364
2424
|
}
|
|
2365
2425
|
);
|
|
@@ -2367,11 +2427,11 @@ CopilotChatMessageView.Cursor = function Cursor({
|
|
|
2367
2427
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
2368
2428
|
|
|
2369
2429
|
// src/components/chat/CopilotChatView.tsx
|
|
2370
|
-
var
|
|
2430
|
+
var import_react20 = __toESM(require("react"));
|
|
2371
2431
|
var import_tailwind_merge7 = require("tailwind-merge");
|
|
2372
2432
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
2373
2433
|
var import_lucide_react6 = require("lucide-react");
|
|
2374
|
-
var
|
|
2434
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2375
2435
|
function CopilotChatView({
|
|
2376
2436
|
messageView,
|
|
2377
2437
|
input,
|
|
@@ -2392,11 +2452,11 @@ function CopilotChatView({
|
|
|
2392
2452
|
className,
|
|
2393
2453
|
...props
|
|
2394
2454
|
}) {
|
|
2395
|
-
const inputContainerRef = (0,
|
|
2396
|
-
const [inputContainerHeight, setInputContainerHeight] = (0,
|
|
2397
|
-
const [isResizing, setIsResizing] = (0,
|
|
2398
|
-
const resizeTimeoutRef = (0,
|
|
2399
|
-
(0,
|
|
2455
|
+
const inputContainerRef = (0, import_react20.useRef)(null);
|
|
2456
|
+
const [inputContainerHeight, setInputContainerHeight] = (0, import_react20.useState)(0);
|
|
2457
|
+
const [isResizing, setIsResizing] = (0, import_react20.useState)(false);
|
|
2458
|
+
const resizeTimeoutRef = (0, import_react20.useRef)(null);
|
|
2459
|
+
(0, import_react20.useEffect)(() => {
|
|
2400
2460
|
const element = inputContainerRef.current;
|
|
2401
2461
|
if (!element) return;
|
|
2402
2462
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
@@ -2448,17 +2508,17 @@ function CopilotChatView({
|
|
|
2448
2508
|
scrollToBottomButton,
|
|
2449
2509
|
inputContainerHeight,
|
|
2450
2510
|
isResizing,
|
|
2451
|
-
children: /* @__PURE__ */ (0,
|
|
2511
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
|
|
2452
2512
|
BoundMessageView,
|
|
2453
|
-
hasSuggestions ? /* @__PURE__ */ (0,
|
|
2513
|
+
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2454
2514
|
] }) })
|
|
2455
2515
|
});
|
|
2456
2516
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
2457
2517
|
const BoundDisclaimer = renderSlot(disclaimer, CopilotChatView.Disclaimer, {});
|
|
2458
2518
|
const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
|
|
2459
2519
|
ref: inputContainerRef,
|
|
2460
|
-
children: /* @__PURE__ */ (0,
|
|
2461
|
-
/* @__PURE__ */ (0,
|
|
2520
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2521
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 pointer-events-auto", children: BoundInput }),
|
|
2462
2522
|
BoundDisclaimer
|
|
2463
2523
|
] })
|
|
2464
2524
|
});
|
|
@@ -2471,10 +2531,10 @@ function CopilotChatView({
|
|
|
2471
2531
|
feather: BoundFeather,
|
|
2472
2532
|
inputContainer: BoundInputContainer,
|
|
2473
2533
|
disclaimer: BoundDisclaimer,
|
|
2474
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0,
|
|
2534
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, {})
|
|
2475
2535
|
});
|
|
2476
2536
|
}
|
|
2477
|
-
return /* @__PURE__ */ (0,
|
|
2537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: (0, import_tailwind_merge7.twMerge)("relative h-full", className), ...props, children: [
|
|
2478
2538
|
BoundScrollView,
|
|
2479
2539
|
BoundFeather,
|
|
2480
2540
|
BoundInputContainer
|
|
@@ -2483,9 +2543,9 @@ function CopilotChatView({
|
|
|
2483
2543
|
((CopilotChatView2) => {
|
|
2484
2544
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
2485
2545
|
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
2486
|
-
return /* @__PURE__ */ (0,
|
|
2487
|
-
/* @__PURE__ */ (0,
|
|
2488
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ (0,
|
|
2546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }) }),
|
|
2548
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2489
2549
|
"div",
|
|
2490
2550
|
{
|
|
2491
2551
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -2508,13 +2568,13 @@ function CopilotChatView({
|
|
|
2508
2568
|
className,
|
|
2509
2569
|
...props
|
|
2510
2570
|
}) => {
|
|
2511
|
-
const [hasMounted, setHasMounted] = (0,
|
|
2571
|
+
const [hasMounted, setHasMounted] = (0, import_react20.useState)(false);
|
|
2512
2572
|
const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
2513
|
-
const [showScrollButton, setShowScrollButton] = (0,
|
|
2514
|
-
(0,
|
|
2573
|
+
const [showScrollButton, setShowScrollButton] = (0, import_react20.useState)(false);
|
|
2574
|
+
(0, import_react20.useEffect)(() => {
|
|
2515
2575
|
setHasMounted(true);
|
|
2516
2576
|
}, []);
|
|
2517
|
-
(0,
|
|
2577
|
+
(0, import_react20.useEffect)(() => {
|
|
2518
2578
|
if (autoScroll) return;
|
|
2519
2579
|
const scrollElement = scrollRef.current;
|
|
2520
2580
|
if (!scrollElement) return;
|
|
@@ -2532,10 +2592,10 @@ function CopilotChatView({
|
|
|
2532
2592
|
};
|
|
2533
2593
|
}, [scrollRef, autoScroll]);
|
|
2534
2594
|
if (!hasMounted) {
|
|
2535
|
-
return /* @__PURE__ */ (0,
|
|
2595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }) });
|
|
2536
2596
|
}
|
|
2537
2597
|
if (!autoScroll) {
|
|
2538
|
-
return /* @__PURE__ */ (0,
|
|
2598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2539
2599
|
"div",
|
|
2540
2600
|
{
|
|
2541
2601
|
ref: scrollRef,
|
|
@@ -2545,8 +2605,8 @@ function CopilotChatView({
|
|
|
2545
2605
|
),
|
|
2546
2606
|
...props,
|
|
2547
2607
|
children: [
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
showScrollButton && !isResizing && /* @__PURE__ */ (0,
|
|
2608
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }),
|
|
2609
|
+
showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2550
2610
|
"div",
|
|
2551
2611
|
{
|
|
2552
2612
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -2562,14 +2622,14 @@ function CopilotChatView({
|
|
|
2562
2622
|
}
|
|
2563
2623
|
);
|
|
2564
2624
|
}
|
|
2565
|
-
return /* @__PURE__ */ (0,
|
|
2625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2566
2626
|
import_use_stick_to_bottom.StickToBottom,
|
|
2567
2627
|
{
|
|
2568
2628
|
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
2569
2629
|
resize: "smooth",
|
|
2570
2630
|
initial: "smooth",
|
|
2571
2631
|
...props,
|
|
2572
|
-
children: /* @__PURE__ */ (0,
|
|
2632
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2573
2633
|
ScrollContent,
|
|
2574
2634
|
{
|
|
2575
2635
|
scrollToBottomButton,
|
|
@@ -2584,7 +2644,7 @@ function CopilotChatView({
|
|
|
2584
2644
|
CopilotChatView2.ScrollToBottomButton = ({
|
|
2585
2645
|
className,
|
|
2586
2646
|
...props
|
|
2587
|
-
}) => /* @__PURE__ */ (0,
|
|
2647
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2588
2648
|
Button,
|
|
2589
2649
|
{
|
|
2590
2650
|
variant: "outline",
|
|
@@ -2598,10 +2658,10 @@ function CopilotChatView({
|
|
|
2598
2658
|
className
|
|
2599
2659
|
),
|
|
2600
2660
|
...props,
|
|
2601
|
-
children: /* @__PURE__ */ (0,
|
|
2661
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react6.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
2602
2662
|
}
|
|
2603
2663
|
);
|
|
2604
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0,
|
|
2664
|
+
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2605
2665
|
"div",
|
|
2606
2666
|
{
|
|
2607
2667
|
className: cn(
|
|
@@ -2614,12 +2674,12 @@ function CopilotChatView({
|
|
|
2614
2674
|
...props
|
|
2615
2675
|
}
|
|
2616
2676
|
);
|
|
2617
|
-
CopilotChatView2.InputContainer =
|
|
2677
|
+
CopilotChatView2.InputContainer = import_react20.default.forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ref, className: cn("absolute bottom-0 left-0 right-0 z-20 pointer-events-none", className), ...props, children }));
|
|
2618
2678
|
CopilotChatView2.InputContainer.displayName = "CopilotChatView.InputContainer";
|
|
2619
2679
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
2620
2680
|
const config = useCopilotChatConfiguration();
|
|
2621
2681
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
2682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2623
2683
|
"div",
|
|
2624
2684
|
{
|
|
2625
2685
|
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
@@ -2633,14 +2693,14 @@ var CopilotChatView_default = CopilotChatView;
|
|
|
2633
2693
|
|
|
2634
2694
|
// src/components/chat/CopilotChat.tsx
|
|
2635
2695
|
var import_shared7 = require("@copilotkitnext/shared");
|
|
2636
|
-
var
|
|
2696
|
+
var import_react21 = require("react");
|
|
2637
2697
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
2638
2698
|
var import_client = require("@ag-ui/client");
|
|
2639
|
-
var
|
|
2699
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2640
2700
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
2641
2701
|
const existingConfig = useCopilotChatConfiguration();
|
|
2642
2702
|
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? import_shared7.DEFAULT_AGENT_ID;
|
|
2643
|
-
const resolvedThreadId = (0,
|
|
2703
|
+
const resolvedThreadId = (0, import_react21.useMemo)(
|
|
2644
2704
|
() => threadId ?? existingConfig?.threadId ?? (0, import_shared7.randomUUID)(),
|
|
2645
2705
|
[threadId, existingConfig?.threadId]
|
|
2646
2706
|
);
|
|
@@ -2653,7 +2713,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2653
2713
|
suggestionView: providedSuggestionView,
|
|
2654
2714
|
...restProps
|
|
2655
2715
|
} = props;
|
|
2656
|
-
(0,
|
|
2716
|
+
(0, import_react21.useEffect)(() => {
|
|
2657
2717
|
const connect = async (agent2) => {
|
|
2658
2718
|
try {
|
|
2659
2719
|
await copilotkit.connectAgent({ agent: agent2 });
|
|
@@ -2671,7 +2731,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2671
2731
|
return () => {
|
|
2672
2732
|
};
|
|
2673
2733
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
2674
|
-
const onSubmitInput = (0,
|
|
2734
|
+
const onSubmitInput = (0, import_react21.useCallback)(
|
|
2675
2735
|
async (value) => {
|
|
2676
2736
|
agent?.addMessage({
|
|
2677
2737
|
id: (0, import_shared7.randomUUID)(),
|
|
@@ -2688,7 +2748,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2688
2748
|
},
|
|
2689
2749
|
[agent, copilotkit]
|
|
2690
2750
|
);
|
|
2691
|
-
const handleSelectSuggestion = (0,
|
|
2751
|
+
const handleSelectSuggestion = (0, import_react21.useCallback)(
|
|
2692
2752
|
async (suggestion) => {
|
|
2693
2753
|
if (!agent) {
|
|
2694
2754
|
return;
|
|
@@ -2726,7 +2786,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2726
2786
|
}
|
|
2727
2787
|
});
|
|
2728
2788
|
const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
|
|
2729
|
-
return /* @__PURE__ */ (0,
|
|
2789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2730
2790
|
CopilotChatConfigurationProvider,
|
|
2731
2791
|
{
|
|
2732
2792
|
agentId: resolvedAgentId,
|
|
@@ -2742,17 +2802,17 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2742
2802
|
})(CopilotChat || (CopilotChat = {}));
|
|
2743
2803
|
|
|
2744
2804
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
2745
|
-
var
|
|
2805
|
+
var import_react22 = __toESM(require("react"));
|
|
2746
2806
|
var import_lucide_react7 = require("lucide-react");
|
|
2747
|
-
var
|
|
2807
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2748
2808
|
var DefaultOpenIcon = ({
|
|
2749
2809
|
className,
|
|
2750
2810
|
...props
|
|
2751
|
-
}) => /* @__PURE__ */ (0,
|
|
2811
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
|
|
2752
2812
|
var DefaultCloseIcon = ({
|
|
2753
2813
|
className,
|
|
2754
2814
|
...props
|
|
2755
|
-
}) => /* @__PURE__ */ (0,
|
|
2815
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
|
|
2756
2816
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
2757
2817
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
2758
2818
|
var ICON_TRANSITION_STYLE = Object.freeze({
|
|
@@ -2769,11 +2829,11 @@ var BUTTON_BASE_CLASSES = cn(
|
|
|
2769
2829
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
2770
2830
|
"disabled:pointer-events-none disabled:opacity-60"
|
|
2771
2831
|
);
|
|
2772
|
-
var CopilotChatToggleButton =
|
|
2832
|
+
var CopilotChatToggleButton = import_react22.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
2773
2833
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
2774
2834
|
const configuration = useCopilotChatConfiguration();
|
|
2775
2835
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
2776
|
-
const [fallbackOpen, setFallbackOpen] = (0,
|
|
2836
|
+
const [fallbackOpen, setFallbackOpen] = (0, import_react22.useState)(false);
|
|
2777
2837
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
2778
2838
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
2779
2839
|
const handleClick = (event) => {
|
|
@@ -2807,7 +2867,7 @@ var CopilotChatToggleButton = import_react21.default.forwardRef(function Copilot
|
|
|
2807
2867
|
focusable: false
|
|
2808
2868
|
}
|
|
2809
2869
|
);
|
|
2810
|
-
const openIconElement = /* @__PURE__ */ (0,
|
|
2870
|
+
const openIconElement = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2811
2871
|
"span",
|
|
2812
2872
|
{
|
|
2813
2873
|
"aria-hidden": "true",
|
|
@@ -2821,7 +2881,7 @@ var CopilotChatToggleButton = import_react21.default.forwardRef(function Copilot
|
|
|
2821
2881
|
children: renderedOpenIcon
|
|
2822
2882
|
}
|
|
2823
2883
|
);
|
|
2824
|
-
const closeIconElement = /* @__PURE__ */ (0,
|
|
2884
|
+
const closeIconElement = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2825
2885
|
"span",
|
|
2826
2886
|
{
|
|
2827
2887
|
"aria-hidden": "true",
|
|
@@ -2835,7 +2895,7 @@ var CopilotChatToggleButton = import_react21.default.forwardRef(function Copilot
|
|
|
2835
2895
|
children: renderedCloseIcon
|
|
2836
2896
|
}
|
|
2837
2897
|
);
|
|
2838
|
-
return /* @__PURE__ */ (0,
|
|
2898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2839
2899
|
"button",
|
|
2840
2900
|
{
|
|
2841
2901
|
ref,
|
|
@@ -2859,12 +2919,12 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
2859
2919
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
2860
2920
|
|
|
2861
2921
|
// src/components/chat/CopilotSidebarView.tsx
|
|
2862
|
-
var
|
|
2922
|
+
var import_react24 = require("react");
|
|
2863
2923
|
|
|
2864
2924
|
// src/components/chat/CopilotModalHeader.tsx
|
|
2865
|
-
var
|
|
2925
|
+
var import_react23 = require("react");
|
|
2866
2926
|
var import_lucide_react8 = require("lucide-react");
|
|
2867
|
-
var
|
|
2927
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2868
2928
|
function CopilotModalHeader({
|
|
2869
2929
|
title,
|
|
2870
2930
|
titleContent,
|
|
@@ -2876,7 +2936,7 @@ function CopilotModalHeader({
|
|
|
2876
2936
|
const configuration = useCopilotChatConfiguration();
|
|
2877
2937
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
2878
2938
|
const resolvedTitle = title ?? fallbackTitle;
|
|
2879
|
-
const handleClose = (0,
|
|
2939
|
+
const handleClose = (0, import_react23.useCallback)(() => {
|
|
2880
2940
|
configuration?.setModalOpen(false);
|
|
2881
2941
|
}, [configuration]);
|
|
2882
2942
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -2893,7 +2953,7 @@ function CopilotModalHeader({
|
|
|
2893
2953
|
...rest
|
|
2894
2954
|
});
|
|
2895
2955
|
}
|
|
2896
|
-
return /* @__PURE__ */ (0,
|
|
2956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2897
2957
|
"header",
|
|
2898
2958
|
{
|
|
2899
2959
|
"data-slot": "copilot-modal-header",
|
|
@@ -2903,17 +2963,17 @@ function CopilotModalHeader({
|
|
|
2903
2963
|
className
|
|
2904
2964
|
),
|
|
2905
2965
|
...rest,
|
|
2906
|
-
children: /* @__PURE__ */ (0,
|
|
2907
|
-
/* @__PURE__ */ (0,
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
2909
|
-
/* @__PURE__ */ (0,
|
|
2966
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex-1", "aria-hidden": "true" }),
|
|
2968
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
|
|
2969
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
|
|
2910
2970
|
] })
|
|
2911
2971
|
}
|
|
2912
2972
|
);
|
|
2913
2973
|
}
|
|
2914
2974
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
2915
2975
|
((CopilotModalHeader2) => {
|
|
2916
|
-
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
2976
|
+
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2917
2977
|
"div",
|
|
2918
2978
|
{
|
|
2919
2979
|
className: cn(
|
|
@@ -2927,7 +2987,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
2927
2987
|
CopilotModalHeader2.CloseButton = ({
|
|
2928
2988
|
className,
|
|
2929
2989
|
...props
|
|
2930
|
-
}) => /* @__PURE__ */ (0,
|
|
2990
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2931
2991
|
"button",
|
|
2932
2992
|
{
|
|
2933
2993
|
type: "button",
|
|
@@ -2938,7 +2998,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
2938
2998
|
),
|
|
2939
2999
|
"aria-label": "Close",
|
|
2940
3000
|
...props,
|
|
2941
|
-
children: /* @__PURE__ */ (0,
|
|
3001
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react8.X, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
2942
3002
|
}
|
|
2943
3003
|
);
|
|
2944
3004
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
@@ -2946,14 +3006,14 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
|
2946
3006
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
2947
3007
|
|
|
2948
3008
|
// src/components/chat/CopilotSidebarView.tsx
|
|
2949
|
-
var
|
|
3009
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2950
3010
|
var DEFAULT_SIDEBAR_WIDTH = 480;
|
|
2951
3011
|
var SIDEBAR_TRANSITION_MS = 260;
|
|
2952
3012
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
2953
3013
|
const configuration = useCopilotChatConfiguration();
|
|
2954
3014
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
2955
|
-
const sidebarRef = (0,
|
|
2956
|
-
const [sidebarWidth, setSidebarWidth] = (0,
|
|
3015
|
+
const sidebarRef = (0, import_react24.useRef)(null);
|
|
3016
|
+
const [sidebarWidth, setSidebarWidth] = (0, import_react24.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
2957
3017
|
const widthToCss = (w) => {
|
|
2958
3018
|
return typeof w === "number" ? `${w}px` : w;
|
|
2959
3019
|
};
|
|
@@ -2963,7 +3023,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
2963
3023
|
}
|
|
2964
3024
|
return w;
|
|
2965
3025
|
};
|
|
2966
|
-
(0,
|
|
3026
|
+
(0, import_react24.useEffect)(() => {
|
|
2967
3027
|
if (width !== void 0) {
|
|
2968
3028
|
return;
|
|
2969
3029
|
}
|
|
@@ -2990,8 +3050,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
2990
3050
|
return () => window.removeEventListener("resize", updateWidth);
|
|
2991
3051
|
}, [width]);
|
|
2992
3052
|
const headerElement = renderSlot(header, CopilotModalHeader, {});
|
|
2993
|
-
return /* @__PURE__ */ (0,
|
|
2994
|
-
isSidebarOpen && /* @__PURE__ */ (0,
|
|
3053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
3054
|
+
isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2995
3055
|
"style",
|
|
2996
3056
|
{
|
|
2997
3057
|
dangerouslySetInnerHTML: {
|
|
@@ -3002,8 +3062,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3002
3062
|
}
|
|
3003
3063
|
}
|
|
3004
3064
|
),
|
|
3005
|
-
/* @__PURE__ */ (0,
|
|
3006
|
-
/* @__PURE__ */ (0,
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopilotChatToggleButton_default, {}),
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3007
3067
|
"aside",
|
|
3008
3068
|
{
|
|
3009
3069
|
ref: sidebarRef,
|
|
@@ -3018,9 +3078,9 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3018
3078
|
"aria-hidden": !isSidebarOpen,
|
|
3019
3079
|
"aria-label": "Copilot chat sidebar",
|
|
3020
3080
|
role: "complementary",
|
|
3021
|
-
children: /* @__PURE__ */ (0,
|
|
3081
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
3022
3082
|
headerElement,
|
|
3023
|
-
/* @__PURE__ */ (0,
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopilotChatView_default, { ...props }) })
|
|
3024
3084
|
] })
|
|
3025
3085
|
}
|
|
3026
3086
|
)
|
|
@@ -3029,13 +3089,13 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3029
3089
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3030
3090
|
|
|
3031
3091
|
// src/components/chat/CopilotSidebar.tsx
|
|
3032
|
-
var
|
|
3033
|
-
var
|
|
3092
|
+
var import_react25 = require("react");
|
|
3093
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3034
3094
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
3035
|
-
const SidebarViewOverride = (0,
|
|
3095
|
+
const SidebarViewOverride = (0, import_react25.useMemo)(() => {
|
|
3036
3096
|
const Component = (viewProps) => {
|
|
3037
3097
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
3038
|
-
return /* @__PURE__ */ (0,
|
|
3098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3039
3099
|
CopilotSidebarView,
|
|
3040
3100
|
{
|
|
3041
3101
|
...restProps,
|
|
@@ -3046,7 +3106,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3046
3106
|
};
|
|
3047
3107
|
return Object.assign(Component, CopilotChatView_default);
|
|
3048
3108
|
}, [header, width]);
|
|
3049
|
-
return /* @__PURE__ */ (0,
|
|
3109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3050
3110
|
CopilotChat,
|
|
3051
3111
|
{
|
|
3052
3112
|
...chatProps,
|
|
@@ -3057,9 +3117,9 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3057
3117
|
}
|
|
3058
3118
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
3059
3119
|
|
|
3060
|
-
// src/types/
|
|
3120
|
+
// src/types/defineToolCallRenderer.ts
|
|
3061
3121
|
var import_zod2 = require("zod");
|
|
3062
|
-
function
|
|
3122
|
+
function defineToolCallRenderer(def) {
|
|
3063
3123
|
const argsSchema = def.name === "*" && !def.args ? import_zod2.z.any() : def.args;
|
|
3064
3124
|
return {
|
|
3065
3125
|
name: def.name,
|
|
@@ -3070,25 +3130,25 @@ function defineToolCallRender(def) {
|
|
|
3070
3130
|
}
|
|
3071
3131
|
|
|
3072
3132
|
// src/components/WildcardToolCallRender.tsx
|
|
3073
|
-
var
|
|
3074
|
-
var
|
|
3075
|
-
var WildcardToolCallRender =
|
|
3133
|
+
var import_react26 = require("react");
|
|
3134
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3135
|
+
var WildcardToolCallRender = defineToolCallRenderer({
|
|
3076
3136
|
name: "*",
|
|
3077
3137
|
render: ({ args, result, name, status }) => {
|
|
3078
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
3138
|
+
const [isExpanded, setIsExpanded] = (0, import_react26.useState)(false);
|
|
3079
3139
|
const statusString = String(status);
|
|
3080
3140
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
3081
3141
|
const isComplete = statusString === "complete";
|
|
3082
3142
|
const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
|
|
3083
|
-
return /* @__PURE__ */ (0,
|
|
3084
|
-
/* @__PURE__ */ (0,
|
|
3143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
|
|
3144
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3085
3145
|
"div",
|
|
3086
3146
|
{
|
|
3087
3147
|
className: "flex items-center justify-between gap-3 cursor-pointer",
|
|
3088
3148
|
onClick: () => setIsExpanded(!isExpanded),
|
|
3089
3149
|
children: [
|
|
3090
|
-
/* @__PURE__ */ (0,
|
|
3091
|
-
/* @__PURE__ */ (0,
|
|
3150
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3092
3152
|
"svg",
|
|
3093
3153
|
{
|
|
3094
3154
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -3096,7 +3156,7 @@ var WildcardToolCallRender = defineToolCallRender({
|
|
|
3096
3156
|
viewBox: "0 0 24 24",
|
|
3097
3157
|
strokeWidth: 2,
|
|
3098
3158
|
stroke: "currentColor",
|
|
3099
|
-
children: /* @__PURE__ */ (0,
|
|
3159
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3100
3160
|
"path",
|
|
3101
3161
|
{
|
|
3102
3162
|
strokeLinecap: "round",
|
|
@@ -3106,10 +3166,10 @@ var WildcardToolCallRender = defineToolCallRender({
|
|
|
3106
3166
|
)
|
|
3107
3167
|
}
|
|
3108
3168
|
),
|
|
3109
|
-
/* @__PURE__ */ (0,
|
|
3110
|
-
/* @__PURE__ */ (0,
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
3111
3171
|
] }),
|
|
3112
|
-
/* @__PURE__ */ (0,
|
|
3172
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3113
3173
|
"span",
|
|
3114
3174
|
{
|
|
3115
3175
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -3119,14 +3179,14 @@ var WildcardToolCallRender = defineToolCallRender({
|
|
|
3119
3179
|
]
|
|
3120
3180
|
}
|
|
3121
3181
|
),
|
|
3122
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
3123
|
-
/* @__PURE__ */ (0,
|
|
3124
|
-
/* @__PURE__ */ (0,
|
|
3125
|
-
/* @__PURE__ */ (0,
|
|
3182
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "mt-3 grid gap-4", children: [
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
|
|
3184
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
|
|
3126
3186
|
] }),
|
|
3127
|
-
result !== void 0 && /* @__PURE__ */ (0,
|
|
3128
|
-
/* @__PURE__ */ (0,
|
|
3129
|
-
/* @__PURE__ */ (0,
|
|
3187
|
+
result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
|
|
3188
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
3189
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
|
|
3130
3190
|
] })
|
|
3131
3191
|
] })
|
|
3132
3192
|
] }) });
|
|
@@ -3149,12 +3209,14 @@ var WildcardToolCallRender = defineToolCallRender({
|
|
|
3149
3209
|
CopilotChatToolCallsView,
|
|
3150
3210
|
CopilotChatUserMessage,
|
|
3151
3211
|
CopilotChatView,
|
|
3212
|
+
CopilotKitCoreReact,
|
|
3213
|
+
CopilotKitInspector,
|
|
3152
3214
|
CopilotKitProvider,
|
|
3153
3215
|
CopilotModalHeader,
|
|
3154
3216
|
CopilotSidebar,
|
|
3155
3217
|
CopilotSidebarView,
|
|
3156
3218
|
WildcardToolCallRender,
|
|
3157
|
-
|
|
3219
|
+
defineToolCallRenderer,
|
|
3158
3220
|
useAgent,
|
|
3159
3221
|
useAgentContext,
|
|
3160
3222
|
useConfigureSuggestions,
|
|
@@ -3162,6 +3224,7 @@ var WildcardToolCallRender = defineToolCallRender({
|
|
|
3162
3224
|
useCopilotKit,
|
|
3163
3225
|
useFrontendTool,
|
|
3164
3226
|
useHumanInTheLoop,
|
|
3227
|
+
useRenderCustomMessages,
|
|
3165
3228
|
useRenderToolCall,
|
|
3166
3229
|
useSuggestions
|
|
3167
3230
|
});
|