@zero-library/chat-copilot 1.0.12 → 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 -463
- 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 -465
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
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) {
|
|
@@ -1272,10 +1203,9 @@ function createChatStore() {
|
|
|
1272
1203
|
responseMode: 2
|
|
1273
1204
|
};
|
|
1274
1205
|
const extraParams = common.deepCopy(config.params?.params || {});
|
|
1275
|
-
|
|
1276
|
-
Object.assign(extraParams, userInputParams, message3 ? {} : { ...references?.params }, params);
|
|
1206
|
+
Object.assign(extraParams, message2 ? {} : { ...references?.params }, params);
|
|
1277
1207
|
sendParams.params = extraParams;
|
|
1278
|
-
if (!
|
|
1208
|
+
if (!message2) {
|
|
1279
1209
|
setContent("");
|
|
1280
1210
|
setContentParams();
|
|
1281
1211
|
setFileList([]);
|
|
@@ -1338,7 +1268,7 @@ function createChatStore() {
|
|
|
1338
1268
|
/** 设置智能体 */
|
|
1339
1269
|
setAgent,
|
|
1340
1270
|
/** 设置智能体用户输入 */
|
|
1341
|
-
setUserInput,
|
|
1271
|
+
// setUserInput,
|
|
1342
1272
|
/** 设置会话配置 */
|
|
1343
1273
|
setConversationSpec,
|
|
1344
1274
|
/** 历史会话状态 */
|
|
@@ -1372,7 +1302,7 @@ function createChatStore() {
|
|
|
1372
1302
|
/** 接收消息 */
|
|
1373
1303
|
acceptMessage,
|
|
1374
1304
|
/** 获取智能体用户输入 */
|
|
1375
|
-
getUserInput,
|
|
1305
|
+
// getUserInput,
|
|
1376
1306
|
/** 消息反馈 */
|
|
1377
1307
|
feedback
|
|
1378
1308
|
};
|
|
@@ -1392,7 +1322,6 @@ var styles_module_default2 = {
|
|
|
1392
1322
|
bubbleList: "styles_module_bubbleList",
|
|
1393
1323
|
resourceBtn: "styles_module_resourceBtn",
|
|
1394
1324
|
resourceBtnActive: "styles_module_resourceBtnActive",
|
|
1395
|
-
userInputCollapse: "styles_module_userInputCollapse",
|
|
1396
1325
|
logoArea: "styles_module_logoArea",
|
|
1397
1326
|
logoContainer: "styles_module_logoContainer",
|
|
1398
1327
|
staticHalo: "styles_module_staticHalo",
|
|
@@ -2098,12 +2027,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
|
|
|
2098
2027
|
}, [paramsStr]);
|
|
2099
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" }) }) });
|
|
2100
2029
|
};
|
|
2101
|
-
var IndexQuote_default = ({ data, loading, message:
|
|
2030
|
+
var IndexQuote_default = ({ data, loading, message: message2 }) => {
|
|
2102
2031
|
const [open, setOpen] = React6.useState(false);
|
|
2103
2032
|
const citation = React6.useMemo(() => {
|
|
2104
|
-
const citations =
|
|
2033
|
+
const citations = message2.content?.find((item) => item.type === "citation")?.citations ?? [];
|
|
2105
2034
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
2106
|
-
}, [data.citationId,
|
|
2035
|
+
}, [data.citationId, message2.content]);
|
|
2107
2036
|
const onClick = () => {
|
|
2108
2037
|
if (!citation?.citationUrl) return;
|
|
2109
2038
|
if (common.isExternal(citation.citationUrl)) {
|
|
@@ -2248,16 +2177,16 @@ function preprocessCustomTagPayloads(content = "", payloadTagPattern) {
|
|
|
2248
2177
|
payloadMap
|
|
2249
2178
|
};
|
|
2250
2179
|
}
|
|
2251
|
-
var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(),
|
|
2180
|
+
var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(), message2) => {
|
|
2252
2181
|
const WrappedComponent = ({ children, streamStatus, ...rest }) => {
|
|
2253
2182
|
const rawData = resolveMappedMarkdownPayload(children, payloadMap);
|
|
2254
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Component, { message:
|
|
2183
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { message: message2, ...rest, data: rawData, loading: streamStatus === "loading" });
|
|
2255
2184
|
};
|
|
2256
2185
|
WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
|
|
2257
2186
|
return WrappedComponent;
|
|
2258
2187
|
};
|
|
2259
|
-
var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(),
|
|
2260
|
-
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 }) => {
|
|
2261
2190
|
const config = React6.useMemo(() => getMarkdownConfig(), []);
|
|
2262
2191
|
const formattedContent = React6.useMemo(() => formatMixedContent(content), [content]);
|
|
2263
2192
|
const newComponents = React6.useMemo(
|
|
@@ -2282,7 +2211,7 @@ var XMarkdown_default = ({ message: message3, components = {}, content = "", ...
|
|
|
2282
2211
|
() => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
|
|
2283
2212
|
[formattedContent, payloadTagPattern]
|
|
2284
2213
|
);
|
|
2285
|
-
const markdownComponents = React6.useMemo(() => adaptMarkdownComponents(newComponents, payloadMap,
|
|
2214
|
+
const markdownComponents = React6.useMemo(() => adaptMarkdownComponents(newComponents, payloadMap, message2), [componentKeys, message2, payloadMap]);
|
|
2286
2215
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2287
2216
|
XMarkdown__default.default,
|
|
2288
2217
|
{
|
|
@@ -3177,9 +3106,9 @@ function diffConversationMessages(messages, prevCursors) {
|
|
|
3177
3106
|
const nextCursors = [];
|
|
3178
3107
|
const pendingItems = [];
|
|
3179
3108
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3180
|
-
const
|
|
3181
|
-
const messageId = String(
|
|
3182
|
-
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 : [];
|
|
3183
3112
|
const prevCursor = prevCursors[messageIndex];
|
|
3184
3113
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
3185
3114
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -3210,9 +3139,9 @@ function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
|
|
|
3210
3139
|
}
|
|
3211
3140
|
function reduceA2uiRuntimeMessages(state, messages) {
|
|
3212
3141
|
const { shouldReplayAll, pendingItems, nextCursors } = diffConversationMessages(messages || [], state.processedMessageCursors);
|
|
3213
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((
|
|
3214
|
-
const messageId = String(
|
|
3215
|
-
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 : [];
|
|
3216
3145
|
return items.map((item) => ({ messageIndex, messageId, item }));
|
|
3217
3146
|
}) : pendingItems;
|
|
3218
3147
|
if (!shouldReplayAll && itemsToProcess.length === 0) {
|
|
@@ -3262,9 +3191,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
3262
3191
|
delete nextState.modelPathBySurface[surfaceId];
|
|
3263
3192
|
}
|
|
3264
3193
|
});
|
|
3265
|
-
nextState.processedMessageCursors = shouldReplayAll ? messages.map((
|
|
3266
|
-
messageId: String(
|
|
3267
|
-
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
|
|
3268
3197
|
})) : nextCursors;
|
|
3269
3198
|
nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
|
|
3270
3199
|
if (deletedSurfaceIds.size) {
|
|
@@ -3601,9 +3530,9 @@ function diffMessages(messages, prevCursors) {
|
|
|
3601
3530
|
const nextCursors = [];
|
|
3602
3531
|
const pendingItems = [];
|
|
3603
3532
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3604
|
-
const
|
|
3605
|
-
const messageId = String(
|
|
3606
|
-
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 : [];
|
|
3607
3536
|
const prevCursor = prevCursors[messageIndex];
|
|
3608
3537
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
3609
3538
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -3634,8 +3563,8 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
3634
3563
|
}, [conversationId]);
|
|
3635
3564
|
React6__default.default.useEffect(() => {
|
|
3636
3565
|
const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
|
|
3637
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((
|
|
3638
|
-
const items = Array.isArray(
|
|
3566
|
+
const itemsToProcess = shouldReplayAll ? messages.flatMap((message2) => {
|
|
3567
|
+
const items = Array.isArray(message2?.content) ? message2.content : [];
|
|
3639
3568
|
return items.map((item) => ({ item }));
|
|
3640
3569
|
}) : pendingItems;
|
|
3641
3570
|
if (!shouldReplayAll && itemsToProcess.length === 0) return;
|
|
@@ -3647,9 +3576,9 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
3647
3576
|
const surfaceId = extractSurfaceId3(item.command);
|
|
3648
3577
|
if (surfaceId) nextLatestCommandIndexBySurface[surfaceId] = nextCommandIndex;
|
|
3649
3578
|
});
|
|
3650
|
-
processedMessageCursorsRef.current = shouldReplayAll ? messages.map((
|
|
3651
|
-
messageId: String(
|
|
3652
|
-
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
|
|
3653
3582
|
})) : nextCursors;
|
|
3654
3583
|
latestCommandIndexBySurfaceRef.current = nextLatestCommandIndexBySurface;
|
|
3655
3584
|
commandIndexRef.current = nextCommandIndex;
|
|
@@ -3934,21 +3863,21 @@ var ToolCallNode = React6__default.default.memo(({ item }) => {
|
|
|
3934
3863
|
return /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item });
|
|
3935
3864
|
});
|
|
3936
3865
|
var TextNode = React6__default.default.memo(
|
|
3937
|
-
({ item, role, customComponents, message:
|
|
3866
|
+
({ item, role, customComponents, message: message2 }) => {
|
|
3938
3867
|
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
3939
3868
|
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
3940
3869
|
return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
|
|
3941
3870
|
}
|
|
3942
3871
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3943
3872
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
3944
|
-
!!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
3873
|
+
!!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content })
|
|
3945
3874
|
] });
|
|
3946
3875
|
}
|
|
3947
3876
|
);
|
|
3948
3877
|
var StepErrorNode = React6__default.default.memo(
|
|
3949
|
-
({ item, customComponents, message:
|
|
3878
|
+
({ item, customComponents, message: message2 }) => {
|
|
3950
3879
|
if (!item.errorMessage) return null;
|
|
3951
|
-
return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
3880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage });
|
|
3952
3881
|
}
|
|
3953
3882
|
);
|
|
3954
3883
|
var FilesNode = React6__default.default.memo(({ item }) => {
|
|
@@ -3978,9 +3907,9 @@ var FilesNode = React6__default.default.memo(({ item }) => {
|
|
|
3978
3907
|
}, [item.files]);
|
|
3979
3908
|
return /* @__PURE__ */ jsxRuntime.jsx(xV2.FileCard.List, { items: fileItems });
|
|
3980
3909
|
});
|
|
3981
|
-
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 }) => {
|
|
3982
3911
|
const content = React6.useMemo(() => {
|
|
3983
|
-
return (
|
|
3912
|
+
return (message2.content || []).filter((item) => {
|
|
3984
3913
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
3985
3914
|
return false;
|
|
3986
3915
|
}
|
|
@@ -3992,12 +3921,12 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
3992
3921
|
}
|
|
3993
3922
|
return true;
|
|
3994
3923
|
});
|
|
3995
|
-
}, [loading,
|
|
3924
|
+
}, [loading, message2.content]);
|
|
3996
3925
|
const quoteMsg = React6.useMemo(() => {
|
|
3997
3926
|
const quoteMsg2 = {};
|
|
3998
|
-
if (
|
|
3927
|
+
if (message2.params) {
|
|
3999
3928
|
try {
|
|
4000
|
-
const citation = JSON.parse(
|
|
3929
|
+
const citation = JSON.parse(message2.params).citation;
|
|
4001
3930
|
if (citation) {
|
|
4002
3931
|
quoteMsg2.messageContent = citation;
|
|
4003
3932
|
}
|
|
@@ -4005,7 +3934,7 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
4005
3934
|
}
|
|
4006
3935
|
}
|
|
4007
3936
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
4008
|
-
}, [
|
|
3937
|
+
}, [message2.params, message2.quoteMsg]);
|
|
4009
3938
|
if (content.length === 0) return null;
|
|
4010
3939
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, vertical: true, gap: 8, children: [
|
|
4011
3940
|
content.map((item, index) => {
|
|
@@ -4019,8 +3948,8 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
|
|
|
4019
3948
|
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4020
3949
|
item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
4021
3950
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(ToolCallNode, { item }, `tool-call-${item.toolCallId || index}`),
|
|
4022
|
-
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role:
|
|
4023
|
-
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}`),
|
|
4024
3953
|
item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
|
|
4025
3954
|
item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
4026
3955
|
] })
|
|
@@ -4148,14 +4077,14 @@ var BubbleListItems_default = ({
|
|
|
4148
4077
|
const messageRefs = React6.useRef({});
|
|
4149
4078
|
const chatRecords = React6.useMemo(() => {
|
|
4150
4079
|
const chatRecords2 = [];
|
|
4151
|
-
conversationMessages.forEach((
|
|
4152
|
-
const role = getRole(
|
|
4080
|
+
conversationMessages.forEach((message2, messageIndex) => {
|
|
4081
|
+
const role = getRole(message2.role);
|
|
4153
4082
|
const isLeftBubble = role.user === "agent";
|
|
4154
|
-
const isMessageLoading = !!
|
|
4083
|
+
const isMessageLoading = !!message2.generating;
|
|
4155
4084
|
const showLogButton = isDebug && isLeftBubble && !isMessageLoading && isWorkFlow;
|
|
4156
|
-
const baseKey = `${
|
|
4085
|
+
const baseKey = `${message2.executionId}-${messageIndex}`;
|
|
4157
4086
|
const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
|
|
4158
|
-
|
|
4087
|
+
message2.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
|
|
4159
4088
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 4, children: [
|
|
4160
4089
|
showLogButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4161
4090
|
antd.Button,
|
|
@@ -4165,7 +4094,7 @@ var BubbleListItems_default = ({
|
|
|
4165
4094
|
size: "small",
|
|
4166
4095
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.FileTextOutlined, {}),
|
|
4167
4096
|
onClick: () => {
|
|
4168
|
-
setLogPanelOpen(true,
|
|
4097
|
+
setLogPanelOpen(true, message2.executionId);
|
|
4169
4098
|
}
|
|
4170
4099
|
}
|
|
4171
4100
|
),
|
|
@@ -4188,21 +4117,21 @@ var BubbleListItems_default = ({
|
|
|
4188
4117
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4189
4118
|
antd.Button,
|
|
4190
4119
|
{
|
|
4191
|
-
color:
|
|
4120
|
+
color: message2.feedback === 1 ? "primary" : "default",
|
|
4192
4121
|
size: "small",
|
|
4193
4122
|
variant: "text",
|
|
4194
4123
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
|
|
4195
|
-
onClick: () => chatStore.feedback(
|
|
4124
|
+
onClick: () => chatStore.feedback(message2.executionId, 1, messageIndex)
|
|
4196
4125
|
}
|
|
4197
4126
|
),
|
|
4198
4127
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4199
4128
|
antd.Button,
|
|
4200
4129
|
{
|
|
4201
|
-
color:
|
|
4130
|
+
color: message2.feedback === 2 ? "primary" : "default",
|
|
4202
4131
|
size: "small",
|
|
4203
4132
|
variant: "text",
|
|
4204
4133
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
|
|
4205
|
-
onClick: () => chatStore.feedback(
|
|
4134
|
+
onClick: () => chatStore.feedback(message2.executionId, 2, messageIndex)
|
|
4206
4135
|
}
|
|
4207
4136
|
),
|
|
4208
4137
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4210,7 +4139,7 @@ var BubbleListItems_default = ({
|
|
|
4210
4139
|
{
|
|
4211
4140
|
control: agentActions,
|
|
4212
4141
|
ctx: {
|
|
4213
|
-
message:
|
|
4142
|
+
message: message2,
|
|
4214
4143
|
get dom() {
|
|
4215
4144
|
return messageRefs.current[baseKey];
|
|
4216
4145
|
}
|
|
@@ -4229,7 +4158,7 @@ var BubbleListItems_default = ({
|
|
|
4229
4158
|
MessageRender_default,
|
|
4230
4159
|
{
|
|
4231
4160
|
role,
|
|
4232
|
-
message:
|
|
4161
|
+
message: message2,
|
|
4233
4162
|
messageIndex,
|
|
4234
4163
|
customComponents,
|
|
4235
4164
|
loading: isMessageLoading,
|
|
@@ -4513,326 +4442,6 @@ var ChatSenderHeader = () => {
|
|
|
4513
4442
|
] });
|
|
4514
4443
|
};
|
|
4515
4444
|
var ChatSenderHeader_default = ChatSenderHeader;
|
|
4516
|
-
var MonacoEditor = ({ value = "", onChange, placeholder, height = 200, readOnly = false, style }) => {
|
|
4517
|
-
const handleKeyDownCapture = React6.useCallback((e) => {
|
|
4518
|
-
if (e.key === " " || e.code === "Space") {
|
|
4519
|
-
e.stopPropagation();
|
|
4520
|
-
}
|
|
4521
|
-
}, []);
|
|
4522
|
-
const handleKeyUpCapture = React6.useCallback((e) => {
|
|
4523
|
-
if (e.key === " " || e.code === "Space") {
|
|
4524
|
-
e.stopPropagation();
|
|
4525
|
-
}
|
|
4526
|
-
}, []);
|
|
4527
|
-
const handleScriptChange = React6.useCallback(
|
|
4528
|
-
(event) => {
|
|
4529
|
-
onChange?.(event.target.value || "");
|
|
4530
|
-
},
|
|
4531
|
-
[onChange]
|
|
4532
|
-
);
|
|
4533
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style, onKeyDownCapture: handleKeyDownCapture, onKeyUpCapture: handleKeyUpCapture, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4534
|
-
antd.Input.TextArea,
|
|
4535
|
-
{
|
|
4536
|
-
value,
|
|
4537
|
-
onChange: handleScriptChange,
|
|
4538
|
-
readOnly,
|
|
4539
|
-
placeholder,
|
|
4540
|
-
autoSize: false,
|
|
4541
|
-
style: {
|
|
4542
|
-
height,
|
|
4543
|
-
resize: "vertical",
|
|
4544
|
-
fontFamily: 'Monaco, Menlo, Consolas, "Courier New", monospace',
|
|
4545
|
-
...style
|
|
4546
|
-
}
|
|
4547
|
-
}
|
|
4548
|
-
) });
|
|
4549
|
-
};
|
|
4550
|
-
var MonacoEditor_default = MonacoEditor;
|
|
4551
|
-
var { Text: Text5 } = antd.Typography;
|
|
4552
|
-
var START_NODE_TYPE = "start";
|
|
4553
|
-
var FormFileUpload = ({ value, onChange, multiple = false }) => {
|
|
4554
|
-
const { token } = antd.theme.useToken();
|
|
4555
|
-
const fileList = Array.isArray(value) ? value : value ? [value] : [];
|
|
4556
|
-
const chatStore = useChatStore();
|
|
4557
|
-
const configState = valtio.useSnapshot(chatStore.config);
|
|
4558
|
-
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
4559
|
-
const customRequest = async (options) => {
|
|
4560
|
-
const { file, onSuccess, onError } = options;
|
|
4561
|
-
try {
|
|
4562
|
-
const formData = new FormData();
|
|
4563
|
-
formData.append("file", file);
|
|
4564
|
-
const res = await configState.services.request.chatUpload(chatStore.agent.agentInfo.id, formData, conversationState.active.id);
|
|
4565
|
-
if (res.code === 200 && res.data?.length) {
|
|
4566
|
-
const uploadedFile = res.data[0];
|
|
4567
|
-
onSuccess(uploadedFile);
|
|
4568
|
-
if (multiple) {
|
|
4569
|
-
onChange?.([...fileList, uploadedFile]);
|
|
4570
|
-
} else {
|
|
4571
|
-
onChange?.([uploadedFile]);
|
|
4572
|
-
}
|
|
4573
|
-
} else {
|
|
4574
|
-
antd.message.error(res.message || "\u4E0A\u4F20\u5931\u8D25");
|
|
4575
|
-
onError(new Error(res.message));
|
|
4576
|
-
}
|
|
4577
|
-
} catch (error) {
|
|
4578
|
-
onError(error);
|
|
4579
|
-
}
|
|
4580
|
-
};
|
|
4581
|
-
const handleRemove = (fileToRemove) => {
|
|
4582
|
-
const newList = fileList.filter((f) => f.id !== fileToRemove.id);
|
|
4583
|
-
onChange?.(newList.length > 0 ? newList : void 0);
|
|
4584
|
-
};
|
|
4585
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 12, style: { width: "100%" }, children: [
|
|
4586
|
-
!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" }) }),
|
|
4587
|
-
fileList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: fileList.map((file) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4588
|
-
antd.Flex,
|
|
4589
|
-
{
|
|
4590
|
-
align: "center",
|
|
4591
|
-
justify: "space-between",
|
|
4592
|
-
style: {
|
|
4593
|
-
padding: "8px 12px",
|
|
4594
|
-
backgroundColor: token.colorFillAlter,
|
|
4595
|
-
borderRadius: token.borderRadiusLG || 8,
|
|
4596
|
-
border: `1px solid ${token.colorBorderSecondary}`
|
|
4597
|
-
},
|
|
4598
|
-
children: [
|
|
4599
|
-
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 12, style: { overflow: "hidden", flex: 1 }, children: [
|
|
4600
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4601
|
-
"div",
|
|
4602
|
-
{
|
|
4603
|
-
style: {
|
|
4604
|
-
width: 40,
|
|
4605
|
-
height: 40,
|
|
4606
|
-
backgroundColor: "#000",
|
|
4607
|
-
borderRadius: token.borderRadiusSM || 4,
|
|
4608
|
-
display: "flex",
|
|
4609
|
-
alignItems: "center",
|
|
4610
|
-
justifyContent: "center",
|
|
4611
|
-
flexShrink: 0
|
|
4612
|
-
},
|
|
4613
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(common.FileIcon, { suffix: file.extension || common.getFileSuffixName(file.name), fontSize: 20 })
|
|
4614
|
-
}
|
|
4615
|
-
),
|
|
4616
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden", display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
4617
|
-
/* @__PURE__ */ jsxRuntime.jsx(Text5, { ellipsis: true, style: { width: "100%", fontSize: 14, fontWeight: 500 }, children: file.name }),
|
|
4618
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Text5, { type: "secondary", style: { fontSize: 12 }, children: [
|
|
4619
|
-
(file.extension || common.getFileSuffixName(file.name)).toUpperCase(),
|
|
4620
|
-
" \u2022 ",
|
|
4621
|
-
common.formatSize(file.size, { from: "B" })
|
|
4622
|
-
] })
|
|
4623
|
-
] })
|
|
4624
|
-
] }),
|
|
4625
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), onClick: () => handleRemove(file), style: { color: token.colorTextSecondary } })
|
|
4626
|
-
]
|
|
4627
|
-
},
|
|
4628
|
-
file.id || file.uid
|
|
4629
|
-
)) })
|
|
4630
|
-
] });
|
|
4631
|
-
};
|
|
4632
|
-
var FormMonacoEditor = ({ value, onChange }) => {
|
|
4633
|
-
const { token } = antd.theme.useToken();
|
|
4634
|
-
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 }) });
|
|
4635
|
-
};
|
|
4636
|
-
var UserInputPanel = () => {
|
|
4637
|
-
const chatStore = useChatStore();
|
|
4638
|
-
const agentSnap = valtio.useSnapshot(chatStore.agent);
|
|
4639
|
-
const flowSpecSnap = valtio.useSnapshot(flowSpecState);
|
|
4640
|
-
const [form] = antd.Form.useForm();
|
|
4641
|
-
const [activeKey, setActiveKey] = React6.useState(["1"]);
|
|
4642
|
-
const { layout } = valtio.useSnapshot(chatStore.config);
|
|
4643
|
-
const startNode = React6.useMemo(() => {
|
|
4644
|
-
return flowSpecSnap.nodes.find((n) => String(n.type || "").toLowerCase() === START_NODE_TYPE);
|
|
4645
|
-
}, [flowSpecSnap.nodes]);
|
|
4646
|
-
const inputs = React6.useMemo(() => {
|
|
4647
|
-
if (agentSnap.agentInfo.userInput?.length > 0) {
|
|
4648
|
-
return agentSnap.agentInfo.userInput.filter((i) => i.enableEdit);
|
|
4649
|
-
}
|
|
4650
|
-
return (startNode?.data.input || []).filter((i) => i.enableEdit);
|
|
4651
|
-
}, [startNode, agentSnap.agentInfo.userInput]);
|
|
4652
|
-
React6.useEffect(() => {
|
|
4653
|
-
if (inputs.length > 0) {
|
|
4654
|
-
const initialValues = inputs.reduce((acc, cur) => {
|
|
4655
|
-
const value = cur.value;
|
|
4656
|
-
acc[cur.name] = value;
|
|
4657
|
-
return acc;
|
|
4658
|
-
}, {});
|
|
4659
|
-
form.setFieldsValue(initialValues);
|
|
4660
|
-
}
|
|
4661
|
-
}, [inputs, form]);
|
|
4662
|
-
const handleValuesChange = (changedValues) => {
|
|
4663
|
-
if (agentSnap.agentInfo.userInput?.length > 0) {
|
|
4664
|
-
const newInput = agentSnap.agentInfo.userInput.map((v) => {
|
|
4665
|
-
if (v.name in changedValues) {
|
|
4666
|
-
const newValue = changedValues[v.name];
|
|
4667
|
-
return { ...v, value: newValue };
|
|
4668
|
-
}
|
|
4669
|
-
return v;
|
|
4670
|
-
});
|
|
4671
|
-
chatStore.setAgent({ ...agentSnap.agentInfo, userInput: newInput });
|
|
4672
|
-
return;
|
|
4673
|
-
}
|
|
4674
|
-
const nodeIndex = flowSpecState.nodes.findIndex((n) => n.id === startNode?.id);
|
|
4675
|
-
if (nodeIndex > -1) {
|
|
4676
|
-
const currentInput = flowSpecState.nodes[nodeIndex].data.input;
|
|
4677
|
-
const newInput = currentInput.map((v) => {
|
|
4678
|
-
if (v.name in changedValues) {
|
|
4679
|
-
const newValue = changedValues[v.name];
|
|
4680
|
-
return { ...v, value: newValue };
|
|
4681
|
-
}
|
|
4682
|
-
return v;
|
|
4683
|
-
});
|
|
4684
|
-
flowSpecState.nodes[nodeIndex].data.input = newInput;
|
|
4685
|
-
}
|
|
4686
|
-
};
|
|
4687
|
-
const handleStartChat = () => {
|
|
4688
|
-
form.validateFields().then(() => {
|
|
4689
|
-
setActiveKey([]);
|
|
4690
|
-
}).catch(() => {
|
|
4691
|
-
antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
|
|
4692
|
-
});
|
|
4693
|
-
};
|
|
4694
|
-
const renderFormItem = (item) => {
|
|
4695
|
-
const itemStyle = { marginBottom: 0 };
|
|
4696
|
-
const commonProps = {
|
|
4697
|
-
label: item.name,
|
|
4698
|
-
name: item.name,
|
|
4699
|
-
style: itemStyle,
|
|
4700
|
-
rules: item.rules?.map((r) => {
|
|
4701
|
-
const valStr = String(r.value || "");
|
|
4702
|
-
if (r.type === "required") return { required: true, message: r.message };
|
|
4703
|
-
if (r.type === "email") return { type: "email", message: r.message };
|
|
4704
|
-
if (r.type === "pattern") return { pattern: new RegExp(valStr), message: r.message };
|
|
4705
|
-
if (r.type === "max" || r.type === "min") {
|
|
4706
|
-
return {
|
|
4707
|
-
validator: (_, val) => {
|
|
4708
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4709
|
-
const numVal = Number(val);
|
|
4710
|
-
if (isNaN(numVal)) return Promise.resolve();
|
|
4711
|
-
if (r.type === "max" && numVal > Number(valStr)) return Promise.reject(new Error(r.message));
|
|
4712
|
-
if (r.type === "min" && numVal < Number(valStr)) return Promise.reject(new Error(r.message));
|
|
4713
|
-
return Promise.resolve();
|
|
4714
|
-
}
|
|
4715
|
-
};
|
|
4716
|
-
}
|
|
4717
|
-
if (r.type === "length") {
|
|
4718
|
-
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
4719
|
-
return {
|
|
4720
|
-
validator: (_, val) => {
|
|
4721
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4722
|
-
const strVal = String(val);
|
|
4723
|
-
if (min !== void 0 && strVal.length < min) return Promise.reject(new Error(r.message));
|
|
4724
|
-
if (max !== void 0 && strVal.length > max) return Promise.reject(new Error(r.message));
|
|
4725
|
-
return Promise.resolve();
|
|
4726
|
-
}
|
|
4727
|
-
};
|
|
4728
|
-
}
|
|
4729
|
-
if (r.type === "size") {
|
|
4730
|
-
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
4731
|
-
return {
|
|
4732
|
-
validator: (_, val) => {
|
|
4733
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4734
|
-
let len = 0;
|
|
4735
|
-
if (Array.isArray(val)) {
|
|
4736
|
-
len = val.length;
|
|
4737
|
-
} else if (typeof val === "string") {
|
|
4738
|
-
try {
|
|
4739
|
-
const parsed = JSON.parse(val);
|
|
4740
|
-
if (Array.isArray(parsed)) len = parsed.length;
|
|
4741
|
-
else return Promise.resolve();
|
|
4742
|
-
} catch (e) {
|
|
4743
|
-
return Promise.resolve();
|
|
4744
|
-
}
|
|
4745
|
-
} else {
|
|
4746
|
-
return Promise.resolve();
|
|
4747
|
-
}
|
|
4748
|
-
if (min !== void 0 && len < min) return Promise.reject(new Error(r.message));
|
|
4749
|
-
if (max !== void 0 && len > max) return Promise.reject(new Error(r.message));
|
|
4750
|
-
return Promise.resolve();
|
|
4751
|
-
}
|
|
4752
|
-
};
|
|
4753
|
-
}
|
|
4754
|
-
if (r.type === "enum") {
|
|
4755
|
-
const options = valStr.split(",").map((s) => s.trim());
|
|
4756
|
-
return {
|
|
4757
|
-
validator: (_, val) => {
|
|
4758
|
-
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
4759
|
-
if (options.includes(String(val))) return Promise.resolve();
|
|
4760
|
-
return Promise.reject(new Error(r.message));
|
|
4761
|
-
}
|
|
4762
|
-
};
|
|
4763
|
-
}
|
|
4764
|
-
return {};
|
|
4765
|
-
})
|
|
4766
|
-
};
|
|
4767
|
-
if (["STRING", "LONG"].includes(item.type)) {
|
|
4768
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
4769
|
-
}
|
|
4770
|
-
if (["NUMBER"].includes(item.type)) {
|
|
4771
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.InputNumber, { style: { width: "100%" }, placeholder: "\u8BF7\u8F93\u5165\u6570\u503C" }) });
|
|
4772
|
-
}
|
|
4773
|
-
if (item.type === "BOOLEAN") {
|
|
4774
|
-
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: [
|
|
4775
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
|
|
4776
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { size: "small" })
|
|
4777
|
-
] }) });
|
|
4778
|
-
}
|
|
4779
|
-
if (item.type === "FILE") {
|
|
4780
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: false }) });
|
|
4781
|
-
}
|
|
4782
|
-
if (item.type === "ARRAY_FILE") {
|
|
4783
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: true }) });
|
|
4784
|
-
}
|
|
4785
|
-
if (["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"].includes(item.type)) {
|
|
4786
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormMonacoEditor, {}) });
|
|
4787
|
-
}
|
|
4788
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
4789
|
-
};
|
|
4790
|
-
const genExtra = () => {
|
|
4791
|
-
if (activeKey.includes("1")) return null;
|
|
4792
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4793
|
-
antd.Button,
|
|
4794
|
-
{
|
|
4795
|
-
type: "text",
|
|
4796
|
-
size: "small",
|
|
4797
|
-
onClick: (e) => {
|
|
4798
|
-
e.stopPropagation();
|
|
4799
|
-
setActiveKey(["1"]);
|
|
4800
|
-
},
|
|
4801
|
-
children: "\u7F16\u8F91"
|
|
4802
|
-
}
|
|
4803
|
-
);
|
|
4804
|
-
};
|
|
4805
|
-
const items = [
|
|
4806
|
-
{
|
|
4807
|
-
key: "1",
|
|
4808
|
-
label: "\u53C2\u6570\u8BBE\u7F6E",
|
|
4809
|
-
extra: genExtra(),
|
|
4810
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4811
|
-
/* @__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" }) }),
|
|
4812
|
-
/* @__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" }) })
|
|
4813
|
-
] })
|
|
4814
|
-
}
|
|
4815
|
-
];
|
|
4816
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.userInputCollapse, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4817
|
-
antd.Collapse,
|
|
4818
|
-
{
|
|
4819
|
-
activeKey,
|
|
4820
|
-
onChange: (keys) => {
|
|
4821
|
-
const newKeys = typeof keys === "string" ? [keys] : keys;
|
|
4822
|
-
setActiveKey(newKeys);
|
|
4823
|
-
},
|
|
4824
|
-
items,
|
|
4825
|
-
className: "m-16",
|
|
4826
|
-
styles: {
|
|
4827
|
-
body: {
|
|
4828
|
-
paddingRight: 0,
|
|
4829
|
-
paddingBottom: 10
|
|
4830
|
-
}
|
|
4831
|
-
}
|
|
4832
|
-
}
|
|
4833
|
-
) });
|
|
4834
|
-
};
|
|
4835
|
-
var UserInputPanel_default = UserInputPanel;
|
|
4836
4445
|
|
|
4837
4446
|
// src/ui/layouts/components/styles.module.less
|
|
4838
4447
|
var styles_module_default5 = {
|
|
@@ -4857,11 +4466,10 @@ var ChatMainPanel = React6.memo(
|
|
|
4857
4466
|
[]
|
|
4858
4467
|
);
|
|
4859
4468
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
4860
|
-
|
|
4469
|
+
valtio.useSnapshot(chatStore.agent);
|
|
4861
4470
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
|
|
4862
4471
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
4863
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: [
|
|
4864
|
-
common.shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { DefaultComponent: UserInputPanel_default }),
|
|
4865
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 }) }),
|
|
4866
4474
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(ChatSenderHeader_default, {}) }),
|
|
4867
4475
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default5.inputContainer, vertical: true, gap: 8, children: [
|
|
@@ -4931,7 +4539,7 @@ var index_module_default2 = {
|
|
|
4931
4539
|
animatedSplitter: "index_module_animatedSplitter",
|
|
4932
4540
|
hideSplitterBar: "index_module_hideSplitterBar"
|
|
4933
4541
|
};
|
|
4934
|
-
var layouts_default = React6.forwardRef(({ theme:
|
|
4542
|
+
var layouts_default = React6.forwardRef(({ theme: theme3, params, hooks, layout, config, services }, _ref) => {
|
|
4935
4543
|
const chatStore = React6.useMemo(() => createChatStore(), []);
|
|
4936
4544
|
const senderRef = React6.useRef(null);
|
|
4937
4545
|
React6.useImperativeHandle(
|
|
@@ -4980,11 +4588,6 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
|
|
|
4980
4588
|
chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
|
|
4981
4589
|
}
|
|
4982
4590
|
}, [agentState.agentInfo.id, config.agent?.config]);
|
|
4983
|
-
common.useDeepEffect(() => {
|
|
4984
|
-
if (agentState.agentInfo.id) {
|
|
4985
|
-
chatStore.setUserInput(config.agent.userInput);
|
|
4986
|
-
}
|
|
4987
|
-
}, [agentState.agentInfo.id, config.agent?.userInput]);
|
|
4988
4591
|
common.useDeepEffect(() => {
|
|
4989
4592
|
if (config?.agent?.id) {
|
|
4990
4593
|
chatStore.getAgentInfo(config.agent.id);
|
|
@@ -5011,20 +4614,20 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
|
|
|
5011
4614
|
}, [hasPreView]);
|
|
5012
4615
|
common.useWebSocket({
|
|
5013
4616
|
url: configState.services.websocketUrls?.[0],
|
|
5014
|
-
onMessage: (
|
|
4617
|
+
onMessage: (message2) => chatStore.acceptMessage(message2.payload),
|
|
5015
4618
|
clientHeartbeat: false,
|
|
5016
4619
|
reconnectInterval: 1e4
|
|
5017
4620
|
});
|
|
5018
4621
|
common.useWebSocket({
|
|
5019
4622
|
url: configState.services.websocketUrls?.[1],
|
|
5020
|
-
onMessage: (
|
|
4623
|
+
onMessage: (message2) => chatStore.acceptMessage(message2.payload),
|
|
5021
4624
|
clientHeartbeat: false,
|
|
5022
4625
|
reconnectInterval: 1e4
|
|
5023
4626
|
});
|
|
5024
4627
|
React6.useEffect(() => {
|
|
5025
4628
|
hooks?.onBeforeInit?.();
|
|
5026
4629
|
}, []);
|
|
5027
|
-
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: [
|
|
5028
4631
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
5029
4632
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, className: "full-scroll", children: [
|
|
5030
4633
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
|