@zero-library/chat-copilot 1.0.11 → 1.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.cjs.js +66 -464
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +13 -14
- package/dist/index.d.ts +13 -14
- package/dist/index.esm.js +68 -466
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -47,7 +47,7 @@ var styles_module_default = {
|
|
|
47
47
|
quoteTooltipContainer: "styles_module_quoteTooltipContainer"
|
|
48
48
|
};
|
|
49
49
|
var Attachments_default = React6.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
|
|
50
|
-
const { message:
|
|
50
|
+
const { message: message2 } = antd.App.useApp();
|
|
51
51
|
const chatStore = useChatStore();
|
|
52
52
|
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
53
53
|
const fileListRef = React6.useRef([]);
|
|
@@ -75,7 +75,7 @@ var Attachments_default = React6.forwardRef(({ fileUpload, fileUploadConfig, fil
|
|
|
75
75
|
onChange(files);
|
|
76
76
|
}, [attachedFiles]);
|
|
77
77
|
const onErrorTip = common.useDebounce((errorMsg) => {
|
|
78
|
-
|
|
78
|
+
message2.error(errorMsg);
|
|
79
79
|
}, 300);
|
|
80
80
|
const findConfig = (file) => {
|
|
81
81
|
return fileUploadConfig?.allowedTypes?.find((type) => type === common.getFileSuffixName(file.name)) || "";
|
|
@@ -340,41 +340,6 @@ var classifyTime = (timestamp) => {
|
|
|
340
340
|
return "\u66F4\u65E9";
|
|
341
341
|
}
|
|
342
342
|
};
|
|
343
|
-
var variablesToObject = (variables) => {
|
|
344
|
-
if (!common.isArray(variables)) return {};
|
|
345
|
-
const jsonTypes = ["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"];
|
|
346
|
-
return variables.reduce(
|
|
347
|
-
(acc, cur) => {
|
|
348
|
-
if (cur.type === "BOOLEAN") {
|
|
349
|
-
if (common.isDef(cur.value) && !common.isNull(cur.value)) {
|
|
350
|
-
acc[cur.name] = cur.value;
|
|
351
|
-
}
|
|
352
|
-
} else if (jsonTypes.includes(cur.type)) {
|
|
353
|
-
if (common.isDef(cur.value) && !common.isNull(cur.value)) {
|
|
354
|
-
if (typeof cur.value === "string") {
|
|
355
|
-
if (cur.value === "") {
|
|
356
|
-
acc[cur.name] = cur.type === "OBJECT" ? {} : [];
|
|
357
|
-
} else {
|
|
358
|
-
try {
|
|
359
|
-
acc[cur.name] = JSON.parse(cur.value);
|
|
360
|
-
} catch (e) {
|
|
361
|
-
acc[cur.name] = cur.type === "OBJECT" ? {} : [];
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
} else {
|
|
365
|
-
acc[cur.name] = cur.value;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
if (common.isDef(cur.value) && !common.isNull(cur.value) && cur.value !== "") {
|
|
370
|
-
acc[cur.name] = cur.value;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return acc;
|
|
374
|
-
},
|
|
375
|
-
{}
|
|
376
|
-
);
|
|
377
|
-
};
|
|
378
343
|
var getChatSocketUrl = (baseURL, params) => {
|
|
379
344
|
return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
|
|
380
345
|
};
|
|
@@ -384,7 +349,7 @@ var CONV_MODE = {
|
|
|
384
349
|
PROD: 1,
|
|
385
350
|
DEBUG: 2
|
|
386
351
|
};
|
|
387
|
-
|
|
352
|
+
valtio.proxy({
|
|
388
353
|
nodes: []
|
|
389
354
|
});
|
|
390
355
|
function setLogPanelOpen(_open, _executionId) {
|
|
@@ -589,17 +554,6 @@ function createChatStore() {
|
|
|
589
554
|
const setAgentModel = (model) => {
|
|
590
555
|
agent.model = { ...agent.model, ...model };
|
|
591
556
|
};
|
|
592
|
-
const getUserInput = async (agentId) => {
|
|
593
|
-
agent.loading = true;
|
|
594
|
-
try {
|
|
595
|
-
const res = await config.services.request.getAgentUserInput(agentId);
|
|
596
|
-
if (res.data?.inputs && agent.agentInfo.userInput?.length === 0) {
|
|
597
|
-
agent.agentInfo.userInput = res.data.inputs.filter((item) => item.enableEdit);
|
|
598
|
-
}
|
|
599
|
-
} finally {
|
|
600
|
-
agent.loading = false;
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
557
|
const setAgent = (agentInfo) => {
|
|
604
558
|
agent.agentInfo = agentInfo;
|
|
605
559
|
if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
|
|
@@ -609,13 +563,6 @@ function createChatStore() {
|
|
|
609
563
|
});
|
|
610
564
|
}
|
|
611
565
|
};
|
|
612
|
-
const setUserInput = (userInput) => {
|
|
613
|
-
if (config.params?.convMeta?.mode === CONV_MODE.PROD && agent.agentInfo.agentType === 1 /* FLOW */) {
|
|
614
|
-
getUserInput(agent.agentInfo.id);
|
|
615
|
-
} else if (agent.agentInfo.userInput) {
|
|
616
|
-
agent.agentInfo.userInput = userInput;
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
566
|
const getAgentInfo = async (id) => {
|
|
620
567
|
config.loading = true;
|
|
621
568
|
if (agent.agentInfo.id === id) return;
|
|
@@ -1171,9 +1118,9 @@ function createChatStore() {
|
|
|
1171
1118
|
}
|
|
1172
1119
|
}
|
|
1173
1120
|
}
|
|
1174
|
-
function processMessageContent(
|
|
1121
|
+
function processMessageContent(message2) {
|
|
1175
1122
|
const newMessage = {
|
|
1176
|
-
...
|
|
1123
|
+
...message2,
|
|
1177
1124
|
agentId: agent.agentInfo.id
|
|
1178
1125
|
};
|
|
1179
1126
|
const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
|
|
@@ -1220,13 +1167,13 @@ function createChatStore() {
|
|
|
1220
1167
|
}
|
|
1221
1168
|
processMessageContent(newMessage);
|
|
1222
1169
|
};
|
|
1223
|
-
const sendMessage = async (
|
|
1170
|
+
const sendMessage = async (message2, msgFiles = [], params) => {
|
|
1224
1171
|
const conversationId = conversation.active.id;
|
|
1225
1172
|
if (conversation.messages[conversationId].loading) return;
|
|
1226
1173
|
let msgContent = "", files;
|
|
1227
1174
|
const references = conversation.messages[conversationId].references;
|
|
1228
|
-
if (
|
|
1229
|
-
msgContent =
|
|
1175
|
+
if (message2) {
|
|
1176
|
+
msgContent = message2;
|
|
1230
1177
|
files = msgFiles;
|
|
1231
1178
|
} else {
|
|
1232
1179
|
if (references?.type === 1 && references?.content?.msgContent) {
|
|
@@ -1238,22 +1185,6 @@ function createChatStore() {
|
|
|
1238
1185
|
if (!msgContent) return;
|
|
1239
1186
|
const canProceed = await config.hooks?.onBeforeSend?.(msgContent, files || []);
|
|
1240
1187
|
if (canProceed === false) return;
|
|
1241
|
-
if (agent.agentInfo.userInput?.length) {
|
|
1242
|
-
const invalid = agent.agentInfo.userInput.some((item) => {
|
|
1243
|
-
const isRequired = item.rules?.some((r) => r.type === "required");
|
|
1244
|
-
if (isRequired) {
|
|
1245
|
-
if (item.type === "BOOLEAN") {
|
|
1246
|
-
return common.isNullOrUnDef(item.value);
|
|
1247
|
-
}
|
|
1248
|
-
return common.isNullOrUnDef(item.value) || item.value === "";
|
|
1249
|
-
}
|
|
1250
|
-
return false;
|
|
1251
|
-
});
|
|
1252
|
-
if (invalid) {
|
|
1253
|
-
antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
1188
|
conversation.messages[conversationId].loading = true;
|
|
1258
1189
|
const idx = conversations.list.items.findIndex((item) => item.id === conversationId);
|
|
1259
1190
|
if (idx !== -1 && !conversations.list.items[idx].label) {
|
|
@@ -1264,7 +1195,6 @@ function createChatStore() {
|
|
|
1264
1195
|
message: msgContent,
|
|
1265
1196
|
convMeta: config.params.convMeta,
|
|
1266
1197
|
files,
|
|
1267
|
-
params,
|
|
1268
1198
|
spec: {
|
|
1269
1199
|
...conversation.active.spec,
|
|
1270
1200
|
model: agent.model
|
|
@@ -1273,10 +1203,9 @@ function createChatStore() {
|
|
|
1273
1203
|
responseMode: 2
|
|
1274
1204
|
};
|
|
1275
1205
|
const extraParams = common.deepCopy(config.params?.params || {});
|
|
1276
|
-
|
|
1277
|
-
Object.assign(extraParams, userInputParams, message3 ? {} : { ...references?.params, params });
|
|
1206
|
+
Object.assign(extraParams, message2 ? {} : { ...references?.params }, params);
|
|
1278
1207
|
sendParams.params = extraParams;
|
|
1279
|
-
if (!
|
|
1208
|
+
if (!message2) {
|
|
1280
1209
|
setContent("");
|
|
1281
1210
|
setContentParams();
|
|
1282
1211
|
setFileList([]);
|
|
@@ -1339,7 +1268,7 @@ function createChatStore() {
|
|
|
1339
1268
|
/** 设置智能体 */
|
|
1340
1269
|
setAgent,
|
|
1341
1270
|
/** 设置智能体用户输入 */
|
|
1342
|
-
setUserInput,
|
|
1271
|
+
// setUserInput,
|
|
1343
1272
|
/** 设置会话配置 */
|
|
1344
1273
|
setConversationSpec,
|
|
1345
1274
|
/** 历史会话状态 */
|
|
@@ -1373,7 +1302,7 @@ function createChatStore() {
|
|
|
1373
1302
|
/** 接收消息 */
|
|
1374
1303
|
acceptMessage,
|
|
1375
1304
|
/** 获取智能体用户输入 */
|
|
1376
|
-
getUserInput,
|
|
1305
|
+
// getUserInput,
|
|
1377
1306
|
/** 消息反馈 */
|
|
1378
1307
|
feedback
|
|
1379
1308
|
};
|
|
@@ -1393,7 +1322,6 @@ var styles_module_default2 = {
|
|
|
1393
1322
|
bubbleList: "styles_module_bubbleList",
|
|
1394
1323
|
resourceBtn: "styles_module_resourceBtn",
|
|
1395
1324
|
resourceBtnActive: "styles_module_resourceBtnActive",
|
|
1396
|
-
userInputCollapse: "styles_module_userInputCollapse",
|
|
1397
1325
|
logoArea: "styles_module_logoArea",
|
|
1398
1326
|
logoContainer: "styles_module_logoContainer",
|
|
1399
1327
|
staticHalo: "styles_module_staticHalo",
|
|
@@ -2099,12 +2027,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
|
|
|
2099
2027
|
}, [paramsStr]);
|
|
2100
2028
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown__default.default, { content }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { className: "m-t-32" }) }) });
|
|
2101
2029
|
};
|
|
2102
|
-
var IndexQuote_default = ({ data, loading, message:
|
|
2030
|
+
var IndexQuote_default = ({ data, loading, message: message2 }) => {
|
|
2103
2031
|
const [open, setOpen] = React6.useState(false);
|
|
2104
2032
|
const citation = React6.useMemo(() => {
|
|
2105
|
-
const citations =
|
|
2033
|
+
const citations = message2.content?.find((item) => item.type === "citation")?.citations ?? [];
|
|
2106
2034
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
2107
|
-
}, [data.citationId,
|
|
2035
|
+
}, [data.citationId, message2.content]);
|
|
2108
2036
|
const onClick = () => {
|
|
2109
2037
|
if (!citation?.citationUrl) return;
|
|
2110
2038
|
if (common.isExternal(citation.citationUrl)) {
|
|
@@ -2249,16 +2177,16 @@ function preprocessCustomTagPayloads(content = "", payloadTagPattern) {
|
|
|
2249
2177
|
payloadMap
|
|
2250
2178
|
};
|
|
2251
2179
|
}
|
|
2252
|
-
var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(),
|
|
2180
|
+
var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(), message2) => {
|
|
2253
2181
|
const WrappedComponent = ({ children, streamStatus, ...rest }) => {
|
|
2254
2182
|
const rawData = resolveMappedMarkdownPayload(children, payloadMap);
|
|
2255
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Component, { message:
|
|
2183
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { message: message2, ...rest, data: rawData, loading: streamStatus === "loading" });
|
|
2256
2184
|
};
|
|
2257
2185
|
WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
|
|
2258
2186
|
return WrappedComponent;
|
|
2259
2187
|
};
|
|
2260
|
-
var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(),
|
|
2261
|
-
var XMarkdown_default = ({ message:
|
|
2188
|
+
var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(), message2) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMap, message2)]));
|
|
2189
|
+
var XMarkdown_default = ({ message: message2, components = {}, content = "", ...rest }) => {
|
|
2262
2190
|
const config = React6.useMemo(() => getMarkdownConfig(), []);
|
|
2263
2191
|
const formattedContent = React6.useMemo(() => formatMixedContent(content), [content]);
|
|
2264
2192
|
const newComponents = React6.useMemo(
|
|
@@ -2283,7 +2211,7 @@ var XMarkdown_default = ({ message: message3, components = {}, content = "", ...
|
|
|
2283
2211
|
() => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
|
|
2284
2212
|
[formattedContent, payloadTagPattern]
|
|
2285
2213
|
);
|
|
2286
|
-
const markdownComponents = React6.useMemo(() => adaptMarkdownComponents(newComponents, payloadMap,
|
|
2214
|
+
const markdownComponents = React6.useMemo(() => adaptMarkdownComponents(newComponents, payloadMap, message2), [componentKeys, message2, payloadMap]);
|
|
2287
2215
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2288
2216
|
XMarkdown__default.default,
|
|
2289
2217
|
{
|
|
@@ -3178,9 +3106,9 @@ function diffConversationMessages(messages, prevCursors) {
|
|
|
3178
3106
|
const nextCursors = [];
|
|
3179
3107
|
const pendingItems = [];
|
|
3180
3108
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3181
|
-
const
|
|
3182
|
-
const messageId = String(
|
|
3183
|
-
const items = Array.isArray(
|
|
3109
|
+
const message2 = messages[messageIndex];
|
|
3110
|
+
const messageId = String(message2?.messageId ?? messageIndex);
|
|
3111
|
+
const items = Array.isArray(message2?.content) ? message2.content : [];
|
|
3184
3112
|
const prevCursor = prevCursors[messageIndex];
|
|
3185
3113
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
3186
3114
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -3211,9 +3139,9 @@ function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
|
|
|
3211
3139
|
}
|
|
3212
3140
|
function reduceA2uiRuntimeMessages(state, messages) {
|
|
3213
3141
|
const { shouldReplayAll, pendingItems, nextCursors } = diffConversationMessages(messages || [], state.processedMessageCursors);
|
|
3214
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((
|
|
3215
|
-
const messageId = String(
|
|
3216
|
-
const items = Array.isArray(
|
|
3142
|
+
const itemsToProcess = shouldReplayAll ? messages.flatMap((message2, messageIndex) => {
|
|
3143
|
+
const messageId = String(message2?.messageId ?? messageIndex);
|
|
3144
|
+
const items = Array.isArray(message2?.content) ? message2.content : [];
|
|
3217
3145
|
return items.map((item) => ({ messageIndex, messageId, item }));
|
|
3218
3146
|
}) : pendingItems;
|
|
3219
3147
|
if (!shouldReplayAll && itemsToProcess.length === 0) {
|
|
@@ -3263,9 +3191,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
3263
3191
|
delete nextState.modelPathBySurface[surfaceId];
|
|
3264
3192
|
}
|
|
3265
3193
|
});
|
|
3266
|
-
nextState.processedMessageCursors = shouldReplayAll ? messages.map((
|
|
3267
|
-
messageId: String(
|
|
3268
|
-
contentLength: Array.isArray(
|
|
3194
|
+
nextState.processedMessageCursors = shouldReplayAll ? messages.map((message2, messageIndex) => ({
|
|
3195
|
+
messageId: String(message2?.messageId ?? messageIndex),
|
|
3196
|
+
contentLength: Array.isArray(message2?.content) ? message2.content.length : 0
|
|
3269
3197
|
})) : nextCursors;
|
|
3270
3198
|
nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
|
|
3271
3199
|
if (deletedSurfaceIds.size) {
|
|
@@ -3602,9 +3530,9 @@ function diffMessages(messages, prevCursors) {
|
|
|
3602
3530
|
const nextCursors = [];
|
|
3603
3531
|
const pendingItems = [];
|
|
3604
3532
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3605
|
-
const
|
|
3606
|
-
const messageId = String(
|
|
3607
|
-
const items = Array.isArray(
|
|
3533
|
+
const message2 = messages[messageIndex];
|
|
3534
|
+
const messageId = String(message2?.messageId ?? messageIndex);
|
|
3535
|
+
const items = Array.isArray(message2?.content) ? message2.content : [];
|
|
3608
3536
|
const prevCursor = prevCursors[messageIndex];
|
|
3609
3537
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
3610
3538
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -3635,8 +3563,8 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
3635
3563
|
}, [conversationId]);
|
|
3636
3564
|
React6__default.default.useEffect(() => {
|
|
3637
3565
|
const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
|
|
3638
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((
|
|
3639
|
-
const items = Array.isArray(
|
|
3566
|
+
const itemsToProcess = shouldReplayAll ? messages.flatMap((message2) => {
|
|
3567
|
+
const items = Array.isArray(message2?.content) ? message2.content : [];
|
|
3640
3568
|
return items.map((item) => ({ item }));
|
|
3641
3569
|
}) : pendingItems;
|
|
3642
3570
|
if (!shouldReplayAll && itemsToProcess.length === 0) return;
|
|
@@ -3648,9 +3576,9 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
3648
3576
|
const surfaceId = extractSurfaceId3(item.command);
|
|
3649
3577
|
if (surfaceId) nextLatestCommandIndexBySurface[surfaceId] = nextCommandIndex;
|
|
3650
3578
|
});
|
|
3651
|
-
processedMessageCursorsRef.current = shouldReplayAll ? messages.map((
|
|
3652
|
-
messageId: String(
|
|
3653
|
-
contentLength: Array.isArray(
|
|
3579
|
+
processedMessageCursorsRef.current = shouldReplayAll ? messages.map((message2, messageIndex) => ({
|
|
3580
|
+
messageId: String(message2?.messageId ?? messageIndex),
|
|
3581
|
+
contentLength: Array.isArray(message2?.content) ? message2.content.length : 0
|
|
3654
3582
|
})) : nextCursors;
|
|
3655
3583
|
latestCommandIndexBySurfaceRef.current = nextLatestCommandIndexBySurface;
|
|
3656
3584
|
commandIndexRef.current = nextCommandIndex;
|
|
@@ -3935,21 +3863,21 @@ var ToolCallNode = React6__default.default.memo(({ item }) => {
|
|
|
3935
3863
|
return /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item });
|
|
3936
3864
|
});
|
|
3937
3865
|
var TextNode = React6__default.default.memo(
|
|
3938
|
-
({ item, role, customComponents, message:
|
|
3866
|
+
({ item, role, customComponents, message: message2 }) => {
|
|
3939
3867
|
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
3940
3868
|
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
3941
3869
|
return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
|
|
3942
3870
|
}
|
|
3943
3871
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3944
3872
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
3945
|
-
!!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
3873
|
+
!!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content })
|
|
3946
3874
|
] });
|
|
3947
3875
|
}
|
|
3948
3876
|
);
|
|
3949
3877
|
var StepErrorNode = React6__default.default.memo(
|
|
3950
|
-
({ item, customComponents, message:
|
|
3878
|
+
({ item, customComponents, message: message2 }) => {
|
|
3951
3879
|
if (!item.errorMessage) return null;
|
|
3952
|
-
return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
3880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage });
|
|
3953
3881
|
}
|
|
3954
3882
|
);
|
|
3955
3883
|
var FilesNode = React6__default.default.memo(({ item }) => {
|
|
@@ -3979,9 +3907,9 @@ var FilesNode = React6__default.default.memo(({ item }) => {
|
|
|
3979
3907
|
}, [item.files]);
|
|
3980
3908
|
return /* @__PURE__ */ jsxRuntime.jsx(xV2.FileCard.List, { items: fileItems });
|
|
3981
3909
|
});
|
|
3982
|
-
var MessageRender_default = React6__default.default.memo(({ role, message:
|
|
3910
|
+
var MessageRender_default = React6__default.default.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
3983
3911
|
const content = React6.useMemo(() => {
|
|
3984
|
-
return (
|
|
3912
|
+
return (message2.content || []).filter((item) => {
|
|
3985
3913
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
3986
3914
|
return false;
|
|
3987
3915
|
}
|
|
@@ -3993,12 +3921,12 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
3993
3921
|
}
|
|
3994
3922
|
return true;
|
|
3995
3923
|
});
|
|
3996
|
-
}, [loading,
|
|
3924
|
+
}, [loading, message2.content]);
|
|
3997
3925
|
const quoteMsg = React6.useMemo(() => {
|
|
3998
3926
|
const quoteMsg2 = {};
|
|
3999
|
-
if (
|
|
3927
|
+
if (message2.params) {
|
|
4000
3928
|
try {
|
|
4001
|
-
const citation = JSON.parse(
|
|
3929
|
+
const citation = JSON.parse(message2.params).citation;
|
|
4002
3930
|
if (citation) {
|
|
4003
3931
|
quoteMsg2.messageContent = citation;
|
|
4004
3932
|
}
|
|
@@ -4006,7 +3934,7 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
4006
3934
|
}
|
|
4007
3935
|
}
|
|
4008
3936
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
4009
|
-
}, [
|
|
3937
|
+
}, [message2.params, message2.quoteMsg]);
|
|
4010
3938
|
if (content.length === 0) return null;
|
|
4011
3939
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, vertical: true, gap: 8, children: [
|
|
4012
3940
|
content.map((item, index) => {
|
|
@@ -4020,8 +3948,8 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
4020
3948
|
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4021
3949
|
item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
4022
3950
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(ToolCallNode, { item }, `tool-call-${item.toolCallId || index}`),
|
|
4023
|
-
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role:
|
|
4024
|
-
item.type === "stepError" && /* @__PURE__ */ jsxRuntime.jsx(StepErrorNode, { item, customComponents, message:
|
|
3951
|
+
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role: message2.role, customComponents, message: message2 }, `message-${index}`) }),
|
|
3952
|
+
item.type === "stepError" && /* @__PURE__ */ jsxRuntime.jsx(StepErrorNode, { item, customComponents, message: message2 }, `step-error-${index}`),
|
|
4025
3953
|
item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
|
|
4026
3954
|
item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
4027
3955
|
] })
|
|
@@ -4149,14 +4077,14 @@ var BubbleListItems_default = ({
|
|
|
4149
4077
|
const messageRefs = React6.useRef({});
|
|
4150
4078
|
const chatRecords = React6.useMemo(() => {
|
|
4151
4079
|
const chatRecords2 = [];
|
|
4152
|
-
conversationMessages.forEach((
|
|
4153
|
-
const role = getRole(
|
|
4080
|
+
conversationMessages.forEach((message2, messageIndex) => {
|
|
4081
|
+
const role = getRole(message2.role);
|
|
4154
4082
|
const isLeftBubble = role.user === "agent";
|
|
4155
|
-
const isMessageLoading = !!
|
|
4083
|
+
const isMessageLoading = !!message2.generating;
|
|
4156
4084
|
const showLogButton = isDebug && isLeftBubble && !isMessageLoading && isWorkFlow;
|
|
4157
|
-
const baseKey = `${
|
|
4085
|
+
const baseKey = `${message2.executionId}-${messageIndex}`;
|
|
4158
4086
|
const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
|
|
4159
|
-
|
|
4087
|
+
message2.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
|
|
4160
4088
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 4, children: [
|
|
4161
4089
|
showLogButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4162
4090
|
antd.Button,
|
|
@@ -4166,7 +4094,7 @@ var BubbleListItems_default = ({
|
|
|
4166
4094
|
size: "small",
|
|
4167
4095
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.FileTextOutlined, {}),
|
|
4168
4096
|
onClick: () => {
|
|
4169
|
-
setLogPanelOpen(true,
|
|
4097
|
+
setLogPanelOpen(true, message2.executionId);
|
|
4170
4098
|
}
|
|
4171
4099
|
}
|
|
4172
4100
|
),
|
|
@@ -4189,21 +4117,21 @@ var BubbleListItems_default = ({
|
|
|
4189
4117
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4190
4118
|
antd.Button,
|
|
4191
4119
|
{
|
|
4192
|
-
color:
|
|
4120
|
+
color: message2.feedback === 1 ? "primary" : "default",
|
|
4193
4121
|
size: "small",
|
|
4194
4122
|
variant: "text",
|
|
4195
4123
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
|
|
4196
|
-
onClick: () => chatStore.feedback(
|
|
4124
|
+
onClick: () => chatStore.feedback(message2.executionId, 1, messageIndex)
|
|
4197
4125
|
}
|
|
4198
4126
|
),
|
|
4199
4127
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4200
4128
|
antd.Button,
|
|
4201
4129
|
{
|
|
4202
|
-
color:
|
|
4130
|
+
color: message2.feedback === 2 ? "primary" : "default",
|
|
4203
4131
|
size: "small",
|
|
4204
4132
|
variant: "text",
|
|
4205
4133
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
|
|
4206
|
-
onClick: () => chatStore.feedback(
|
|
4134
|
+
onClick: () => chatStore.feedback(message2.executionId, 2, messageIndex)
|
|
4207
4135
|
}
|
|
4208
4136
|
),
|
|
4209
4137
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4211,7 +4139,7 @@ var BubbleListItems_default = ({
|
|
|
4211
4139
|
{
|
|
4212
4140
|
control: agentActions,
|
|
4213
4141
|
ctx: {
|
|
4214
|
-
message:
|
|
4142
|
+
message: message2,
|
|
4215
4143
|
get dom() {
|
|
4216
4144
|
return messageRefs.current[baseKey];
|
|
4217
4145
|
}
|
|
@@ -4230,7 +4158,7 @@ var BubbleListItems_default = ({
|
|
|
4230
4158
|
MessageRender_default,
|
|
4231
4159
|
{
|
|
4232
4160
|
role,
|
|
4233
|
-
message:
|
|
4161
|
+
message: message2,
|
|
4234
4162
|
messageIndex,
|
|
4235
4163
|
customComponents,
|
|
4236
4164
|
loading: isMessageLoading,
|
|
@@ -4514,326 +4442,6 @@ var ChatSenderHeader = () => {
|
|
|
4514
4442
|
] });
|
|
4515
4443
|
};
|
|
4516
4444
|
var ChatSenderHeader_default = ChatSenderHeader;
|
|
4517
|
-
var MonacoEditor = ({ value = "", onChange, placeholder, height = 200, readOnly = false, style }) => {
|
|
4518
|
-
const handleKeyDownCapture = React6.useCallback((e) => {
|
|
4519
|
-
if (e.key === " " || e.code === "Space") {
|
|
4520
|
-
e.stopPropagation();
|
|
4521
|
-
}
|
|
4522
|
-
}, []);
|
|
4523
|
-
const handleKeyUpCapture = React6.useCallback((e) => {
|
|
4524
|
-
if (e.key === " " || e.code === "Space") {
|
|
4525
|
-
e.stopPropagation();
|
|
4526
|
-
}
|
|
4527
|
-
}, []);
|
|
4528
|
-
const handleScriptChange = React6.useCallback(
|
|
4529
|
-
(event) => {
|
|
4530
|
-
onChange?.(event.target.value || "");
|
|
4531
|
-
},
|
|
4532
|
-
[onChange]
|
|
4533
|
-
);
|
|
4534
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style, onKeyDownCapture: handleKeyDownCapture, onKeyUpCapture: handleKeyUpCapture, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4535
|
-
antd.Input.TextArea,
|
|
4536
|
-
{
|
|
4537
|
-
value,
|
|
4538
|
-
onChange: handleScriptChange,
|
|
4539
|
-
readOnly,
|
|
4540
|
-
placeholder,
|
|
4541
|
-
autoSize: false,
|
|
4542
|
-
style: {
|
|
4543
|
-
height,
|
|
4544
|
-
resize: "vertical",
|
|
4545
|
-
fontFamily: 'Monaco, Menlo, Consolas, "Courier New", monospace',
|
|
4546
|
-
...style
|
|
4547
|
-
}
|
|
4548
|
-
}
|
|
4549
|
-
) });
|
|
4550
|
-
};
|
|
4551
|
-
var MonacoEditor_default = MonacoEditor;
|
|
4552
|
-
var { Text: Text5 } = antd.Typography;
|
|
4553
|
-
var START_NODE_TYPE = "start";
|
|
4554
|
-
var FormFileUpload = ({ value, onChange, multiple = false }) => {
|
|
4555
|
-
const { token } = antd.theme.useToken();
|
|
4556
|
-
const fileList = Array.isArray(value) ? value : value ? [value] : [];
|
|
4557
|
-
const chatStore = useChatStore();
|
|
4558
|
-
const configState = valtio.useSnapshot(chatStore.config);
|
|
4559
|
-
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
4560
|
-
const customRequest = async (options) => {
|
|
4561
|
-
const { file, onSuccess, onError } = options;
|
|
4562
|
-
try {
|
|
4563
|
-
const formData = new FormData();
|
|
4564
|
-
formData.append("file", file);
|
|
4565
|
-
const res = await configState.services.request.chatUpload(chatStore.agent.agentInfo.id, formData, conversationState.active.id);
|
|
4566
|
-
if (res.code === 200 && res.data?.length) {
|
|
4567
|
-
const uploadedFile = res.data[0];
|
|
4568
|
-
onSuccess(uploadedFile);
|
|
4569
|
-
if (multiple) {
|
|
4570
|
-
onChange?.([...fileList, uploadedFile]);
|
|
4571
|
-
} else {
|
|
4572
|
-
onChange?.([uploadedFile]);
|
|
4573
|
-
}
|
|
4574
|
-
} else {
|
|
4575
|
-
antd.message.error(res.message || "\u4E0A\u4F20\u5931\u8D25");
|
|
4576
|
-
onError(new Error(res.message));
|
|
4577
|
-
}
|
|
4578
|
-
} catch (error) {
|
|
4579
|
-
onError(error);
|
|
4580
|
-
}
|
|
4581
|
-
};
|
|
4582
|
-
const handleRemove = (fileToRemove) => {
|
|
4583
|
-
const newList = fileList.filter((f) => f.id !== fileToRemove.id);
|
|
4584
|
-
onChange?.(newList.length > 0 ? newList : void 0);
|
|
4585
|
-
};
|
|
4586
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 12, style: { width: "100%" }, children: [
|
|
4587
|
-
!multiple && fileList.length >= 1 ? null : /* @__PURE__ */ jsxRuntime.jsx(antd.Upload, { multiple, customRequest, showUploadList: false, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloudUploadOutlined, {}), children: "\u4ECE\u672C\u5730\u4E0A\u4F20" }) }),
|
|
4588
|
-
fileList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: fileList.map((file) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4589
|
-
antd.Flex,
|
|
4590
|
-
{
|
|
4591
|
-
align: "center",
|
|
4592
|
-
justify: "space-between",
|
|
4593
|
-
style: {
|
|
4594
|
-
padding: "8px 12px",
|
|
4595
|
-
backgroundColor: token.colorFillAlter,
|
|
4596
|
-
borderRadius: token.borderRadiusLG || 8,
|
|
4597
|
-
border: `1px solid ${token.colorBorderSecondary}`
|
|
4598
|
-
},
|
|
4599
|
-
children: [
|
|
4600
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 12, style: { overflow: "hidden", flex: 1 }, children: [
|
|
4601
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4602
|
-
"div",
|
|
4603
|
-
{
|
|
4604
|
-
style: {
|
|
4605
|
-
width: 40,
|
|
4606
|
-
height: 40,
|
|
4607
|
-
backgroundColor: "#000",
|
|
4608
|
-
borderRadius: token.borderRadiusSM || 4,
|
|
4609
|
-
display: "flex",
|
|
4610
|
-
alignItems: "center",
|
|
4611
|
-
justifyContent: "center",
|
|
4612
|
-
flexShrink: 0
|
|
4613
|
-
},
|
|
4614
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(common.FileIcon, { suffix: file.extension || common.getFileSuffixName(file.name), fontSize: 20 })
|
|
4615
|
-
}
|
|
4616
|
-
),
|
|
4617
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden", display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
4618
|
-
/* @__PURE__ */ jsxRuntime.jsx(Text5, { ellipsis: true, style: { width: "100%", fontSize: 14, fontWeight: 500 }, children: file.name }),
|
|
4619
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Text5, { type: "secondary", style: { fontSize: 12 }, children: [
|
|
4620
|
-
(file.extension || common.getFileSuffixName(file.name)).toUpperCase(),
|
|
4621
|
-
" \u2022 ",
|
|
4622
|
-
common.formatSize(file.size, { from: "B" })
|
|
4623
|
-
] })
|
|
4624
|
-
] })
|
|
4625
|
-
] }),
|
|
4626
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), onClick: () => handleRemove(file), style: { color: token.colorTextSecondary } })
|
|
4627
|
-
]
|
|
4628
|
-
},
|
|
4629
|
-
file.id || file.uid
|
|
4630
|
-
)) })
|
|
4631
|
-
] });
|
|
4632
|
-
};
|
|
4633
|
-
var FormMonacoEditor = ({ value, onChange }) => {
|
|
4634
|
-
const { token } = antd.theme.useToken();
|
|
4635
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { backgroundColor: token.colorFillAlter, padding: 8, borderRadius: token.borderRadius }, children: /* @__PURE__ */ jsxRuntime.jsx(MonacoEditor_default, { language: "json", placeholder: "\u8BF7\u8F93\u5165\u503C...", height: 80, value, onChange }) });
|
|
4636
|
-
};
|
|
4637
|
-
var UserInputPanel = () => {
|
|
4638
|
-
const chatStore = useChatStore();
|
|
4639
|
-
const agentSnap = valtio.useSnapshot(chatStore.agent);
|
|
4640
|
-
const flowSpecSnap = valtio.useSnapshot(flowSpecState);
|
|
4641
|
-
const [form] = antd.Form.useForm();
|
|
4642
|
-
const [activeKey, setActiveKey] = React6.useState(["1"]);
|
|
4643
|
-
const { layout } = valtio.useSnapshot(chatStore.config);
|
|
4644
|
-
const startNode = React6.useMemo(() => {
|
|
4645
|
-
return flowSpecSnap.nodes.find((n) => String(n.type || "").toLowerCase() === START_NODE_TYPE);
|
|
4646
|
-
}, [flowSpecSnap.nodes]);
|
|
4647
|
-
const inputs = React6.useMemo(() => {
|
|
4648
|
-
if (agentSnap.agentInfo.userInput?.length > 0) {
|
|
4649
|
-
return agentSnap.agentInfo.userInput.filter((i) => i.enableEdit);
|
|
4650
|
-
}
|
|
4651
|
-
return (startNode?.data.input || []).filter((i) => i.enableEdit);
|
|
4652
|
-
}, [startNode, agentSnap.agentInfo.userInput]);
|
|
4653
|
-
React6.useEffect(() => {
|
|
4654
|
-
if (inputs.length > 0) {
|
|
4655
|
-
const initialValues = inputs.reduce((acc, cur) => {
|
|
4656
|
-
const value = cur.value;
|
|
4657
|
-
acc[cur.name] = value;
|
|
4658
|
-
return acc;
|
|
4659
|
-
}, {});
|
|
4660
|
-
form.setFieldsValue(initialValues);
|
|
4661
|
-
}
|
|
4662
|
-
}, [inputs, form]);
|
|
4663
|
-
const handleValuesChange = (changedValues) => {
|
|
4664
|
-
if (agentSnap.agentInfo.userInput?.length > 0) {
|
|
4665
|
-
const newInput = agentSnap.agentInfo.userInput.map((v) => {
|
|
4666
|
-
if (v.name in changedValues) {
|
|
4667
|
-
const newValue = changedValues[v.name];
|
|
4668
|
-
return { ...v, value: newValue };
|
|
4669
|
-
}
|
|
4670
|
-
return v;
|
|
4671
|
-
});
|
|
4672
|
-
chatStore.setAgent({ ...agentSnap.agentInfo, userInput: newInput });
|
|
4673
|
-
return;
|
|
4674
|
-
}
|
|
4675
|
-
const nodeIndex = flowSpecState.nodes.findIndex((n) => n.id === startNode?.id);
|
|
4676
|
-
if (nodeIndex > -1) {
|
|
4677
|
-
const currentInput = flowSpecState.nodes[nodeIndex].data.input;
|
|
4678
|
-
const newInput = currentInput.map((v) => {
|
|
4679
|
-
if (v.name in changedValues) {
|
|
4680
|
-
const newValue = changedValues[v.name];
|
|
4681
|
-
return { ...v, value: newValue };
|
|
4682
|
-
}
|
|
4683
|
-
return v;
|
|
4684
|
-
});
|
|
4685
|
-
flowSpecState.nodes[nodeIndex].data.input = newInput;
|
|
4686
|
-
}
|
|
4687
|
-
};
|
|
4688
|
-
const handleStartChat = () => {
|
|
4689
|
-
form.validateFields().then(() => {
|
|
4690
|
-
setActiveKey([]);
|
|
4691
|
-
}).catch(() => {
|
|
4692
|
-
antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
|
|
4693
|
-
});
|
|
4694
|
-
};
|
|
4695
|
-
const renderFormItem = (item) => {
|
|
4696
|
-
const itemStyle = { marginBottom: 0 };
|
|
4697
|
-
const commonProps = {
|
|
4698
|
-
label: item.name,
|
|
4699
|
-
name: item.name,
|
|
4700
|
-
style: itemStyle,
|
|
4701
|
-
rules: item.rules?.map((r) => {
|
|
4702
|
-
const valStr = String(r.value || "");
|
|
4703
|
-
if (r.type === "required") return { required: true, message: r.message };
|
|
4704
|
-
if (r.type === "email") return { type: "email", message: r.message };
|
|
4705
|
-
if (r.type === "pattern") return { pattern: new RegExp(valStr), message: r.message };
|
|
4706
|
-
if (r.type === "max" || r.type === "min") {
|
|
4707
|
-
return {
|
|
4708
|
-
validator: (_, val) => {
|
|
4709
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4710
|
-
const numVal = Number(val);
|
|
4711
|
-
if (isNaN(numVal)) return Promise.resolve();
|
|
4712
|
-
if (r.type === "max" && numVal > Number(valStr)) return Promise.reject(new Error(r.message));
|
|
4713
|
-
if (r.type === "min" && numVal < Number(valStr)) return Promise.reject(new Error(r.message));
|
|
4714
|
-
return Promise.resolve();
|
|
4715
|
-
}
|
|
4716
|
-
};
|
|
4717
|
-
}
|
|
4718
|
-
if (r.type === "length") {
|
|
4719
|
-
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
4720
|
-
return {
|
|
4721
|
-
validator: (_, val) => {
|
|
4722
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4723
|
-
const strVal = String(val);
|
|
4724
|
-
if (min !== void 0 && strVal.length < min) return Promise.reject(new Error(r.message));
|
|
4725
|
-
if (max !== void 0 && strVal.length > max) return Promise.reject(new Error(r.message));
|
|
4726
|
-
return Promise.resolve();
|
|
4727
|
-
}
|
|
4728
|
-
};
|
|
4729
|
-
}
|
|
4730
|
-
if (r.type === "size") {
|
|
4731
|
-
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
4732
|
-
return {
|
|
4733
|
-
validator: (_, val) => {
|
|
4734
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4735
|
-
let len = 0;
|
|
4736
|
-
if (Array.isArray(val)) {
|
|
4737
|
-
len = val.length;
|
|
4738
|
-
} else if (typeof val === "string") {
|
|
4739
|
-
try {
|
|
4740
|
-
const parsed = JSON.parse(val);
|
|
4741
|
-
if (Array.isArray(parsed)) len = parsed.length;
|
|
4742
|
-
else return Promise.resolve();
|
|
4743
|
-
} catch (e) {
|
|
4744
|
-
return Promise.resolve();
|
|
4745
|
-
}
|
|
4746
|
-
} else {
|
|
4747
|
-
return Promise.resolve();
|
|
4748
|
-
}
|
|
4749
|
-
if (min !== void 0 && len < min) return Promise.reject(new Error(r.message));
|
|
4750
|
-
if (max !== void 0 && len > max) return Promise.reject(new Error(r.message));
|
|
4751
|
-
return Promise.resolve();
|
|
4752
|
-
}
|
|
4753
|
-
};
|
|
4754
|
-
}
|
|
4755
|
-
if (r.type === "enum") {
|
|
4756
|
-
const options = valStr.split(",").map((s) => s.trim());
|
|
4757
|
-
return {
|
|
4758
|
-
validator: (_, val) => {
|
|
4759
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4760
|
-
if (options.includes(String(val))) return Promise.resolve();
|
|
4761
|
-
return Promise.reject(new Error(r.message));
|
|
4762
|
-
}
|
|
4763
|
-
};
|
|
4764
|
-
}
|
|
4765
|
-
return {};
|
|
4766
|
-
})
|
|
4767
|
-
};
|
|
4768
|
-
if (["STRING", "LONG"].includes(item.type)) {
|
|
4769
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
4770
|
-
}
|
|
4771
|
-
if (["NUMBER"].includes(item.type)) {
|
|
4772
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.InputNumber, { style: { width: "100%" }, placeholder: "\u8BF7\u8F93\u5165\u6570\u503C" }) });
|
|
4773
|
-
}
|
|
4774
|
-
if (item.type === "BOOLEAN") {
|
|
4775
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { style: itemStyle, name: item.name, valuePropName: "checked", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", children: [
|
|
4776
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
|
|
4777
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { size: "small" })
|
|
4778
|
-
] }) });
|
|
4779
|
-
}
|
|
4780
|
-
if (item.type === "FILE") {
|
|
4781
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: false }) });
|
|
4782
|
-
}
|
|
4783
|
-
if (item.type === "ARRAY_FILE") {
|
|
4784
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: true }) });
|
|
4785
|
-
}
|
|
4786
|
-
if (["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"].includes(item.type)) {
|
|
4787
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormMonacoEditor, {}) });
|
|
4788
|
-
}
|
|
4789
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
4790
|
-
};
|
|
4791
|
-
const genExtra = () => {
|
|
4792
|
-
if (activeKey.includes("1")) return null;
|
|
4793
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4794
|
-
antd.Button,
|
|
4795
|
-
{
|
|
4796
|
-
type: "text",
|
|
4797
|
-
size: "small",
|
|
4798
|
-
onClick: (e) => {
|
|
4799
|
-
e.stopPropagation();
|
|
4800
|
-
setActiveKey(["1"]);
|
|
4801
|
-
},
|
|
4802
|
-
children: "\u7F16\u8F91"
|
|
4803
|
-
}
|
|
4804
|
-
);
|
|
4805
|
-
};
|
|
4806
|
-
const items = [
|
|
4807
|
-
{
|
|
4808
|
-
key: "1",
|
|
4809
|
-
label: "\u53C2\u6570\u8BBE\u7F6E",
|
|
4810
|
-
extra: genExtra(),
|
|
4811
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4812
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Form, { form, layout: "vertical", onValuesChange: handleValuesChange, style: { maxHeight: 500, overflow: "auto", paddingRight: 16 }, children: inputs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 12, children: inputs.map((item) => /* @__PURE__ */ jsxRuntime.jsx(React6__default.default.Fragment, { children: renderFormItem(item) }, item.name)) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "10px", color: "#999", textAlign: "center" }, children: "\u6682\u65E0\u7528\u6237\u8F93\u5165\u5B57\u6BB5" }) }),
|
|
4813
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", justify: "center", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", onClick: handleStartChat, children: "\u5F00\u59CB\u4F1A\u8BDD" }) })
|
|
4814
|
-
] })
|
|
4815
|
-
}
|
|
4816
|
-
];
|
|
4817
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.userInputCollapse, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4818
|
-
antd.Collapse,
|
|
4819
|
-
{
|
|
4820
|
-
activeKey,
|
|
4821
|
-
onChange: (keys) => {
|
|
4822
|
-
const newKeys = typeof keys === "string" ? [keys] : keys;
|
|
4823
|
-
setActiveKey(newKeys);
|
|
4824
|
-
},
|
|
4825
|
-
items,
|
|
4826
|
-
className: "m-16",
|
|
4827
|
-
styles: {
|
|
4828
|
-
body: {
|
|
4829
|
-
paddingRight: 0,
|
|
4830
|
-
paddingBottom: 10
|
|
4831
|
-
}
|
|
4832
|
-
}
|
|
4833
|
-
}
|
|
4834
|
-
) });
|
|
4835
|
-
};
|
|
4836
|
-
var UserInputPanel_default = UserInputPanel;
|
|
4837
4445
|
|
|
4838
4446
|
// src/ui/layouts/components/styles.module.less
|
|
4839
4447
|
var styles_module_default5 = {
|
|
@@ -4858,11 +4466,10 @@ var ChatMainPanel = React6.memo(
|
|
|
4858
4466
|
[]
|
|
4859
4467
|
);
|
|
4860
4468
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
4861
|
-
|
|
4469
|
+
valtio.useSnapshot(chatStore.agent);
|
|
4862
4470
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
|
|
4863
4471
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
4864
4472
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "center", align: "center", vertical: true, gap: 24, className: classNames2__default.default("height-full", styles_module_default5.bodyWidth), children: [
|
|
4865
|
-
common.shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { DefaultComponent: UserInputPanel_default }),
|
|
4866
4473
|
common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
|
|
4867
4474
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(ChatSenderHeader_default, {}) }),
|
|
4868
4475
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default5.inputContainer, vertical: true, gap: 8, children: [
|
|
@@ -4932,7 +4539,7 @@ var index_module_default2 = {
|
|
|
4932
4539
|
animatedSplitter: "index_module_animatedSplitter",
|
|
4933
4540
|
hideSplitterBar: "index_module_hideSplitterBar"
|
|
4934
4541
|
};
|
|
4935
|
-
var layouts_default = React6.forwardRef(({ theme:
|
|
4542
|
+
var layouts_default = React6.forwardRef(({ theme: theme3, params, hooks, layout, config, services }, _ref) => {
|
|
4936
4543
|
const chatStore = React6.useMemo(() => createChatStore(), []);
|
|
4937
4544
|
const senderRef = React6.useRef(null);
|
|
4938
4545
|
React6.useImperativeHandle(
|
|
@@ -4981,11 +4588,6 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
|
|
|
4981
4588
|
chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
|
|
4982
4589
|
}
|
|
4983
4590
|
}, [agentState.agentInfo.id, config.agent?.config]);
|
|
4984
|
-
common.useDeepEffect(() => {
|
|
4985
|
-
if (agentState.agentInfo.id) {
|
|
4986
|
-
chatStore.setUserInput(config.agent.userInput);
|
|
4987
|
-
}
|
|
4988
|
-
}, [agentState.agentInfo.id, config.agent?.userInput]);
|
|
4989
4591
|
common.useDeepEffect(() => {
|
|
4990
4592
|
if (config?.agent?.id) {
|
|
4991
4593
|
chatStore.getAgentInfo(config.agent.id);
|
|
@@ -5012,20 +4614,20 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
|
|
|
5012
4614
|
}, [hasPreView]);
|
|
5013
4615
|
common.useWebSocket({
|
|
5014
4616
|
url: configState.services.websocketUrls?.[0],
|
|
5015
|
-
onMessage: (
|
|
4617
|
+
onMessage: (message2) => chatStore.acceptMessage(message2.payload),
|
|
5016
4618
|
clientHeartbeat: false,
|
|
5017
4619
|
reconnectInterval: 1e4
|
|
5018
4620
|
});
|
|
5019
4621
|
common.useWebSocket({
|
|
5020
4622
|
url: configState.services.websocketUrls?.[1],
|
|
5021
|
-
onMessage: (
|
|
4623
|
+
onMessage: (message2) => chatStore.acceptMessage(message2.payload),
|
|
5022
4624
|
clientHeartbeat: false,
|
|
5023
4625
|
reconnectInterval: 1e4
|
|
5024
4626
|
});
|
|
5025
4627
|
React6.useEffect(() => {
|
|
5026
4628
|
hooks?.onBeforeInit?.();
|
|
5027
4629
|
}, []);
|
|
5028
|
-
return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...
|
|
4630
|
+
return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...theme3 }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: configState.loading, classNames: { root: index_module_default2.spinWrapper }, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default(index_module_default2.chatLayout, "zero-chat-layout", "height-full"), children: [
|
|
5029
4631
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
5030
4632
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, className: "full-scroll", children: [
|
|
5031
4633
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
|