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