@zero-library/chat-copilot 3.1.20 → 3.1.22

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 CHANGED
@@ -1213,17 +1213,6 @@ function createChatStore() {
1213
1213
  agent.loading = false;
1214
1214
  }
1215
1215
  };
1216
- const setAgent = (agentInfo) => {
1217
- agent.agentInfo = agentInfo;
1218
- if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1219
- setAgentModel({
1220
- modelName: agent.agentInfo.spec?.model?.modelName || "",
1221
- providerName: agent.agentInfo.spec?.model?.providerName || ""
1222
- });
1223
- } else if (config.layout.userInput) {
1224
- getUserInput(agent.agentInfo.id);
1225
- }
1226
- };
1227
1216
  const setUserInput = (userInput) => {
1228
1217
  if (agent.agentInfo.agentType === 1 /* FLOW */) {
1229
1218
  agent.agentInfo.userInput = userInput;
@@ -1231,15 +1220,28 @@ function createChatStore() {
1231
1220
  };
1232
1221
  const getAgentInfo = async (id) => {
1233
1222
  config.loading = true;
1234
- if (agent.agentInfo.id === id) return;
1235
1223
  try {
1236
1224
  const { data } = await config.services.request.fetchAgentInfo(id || "");
1237
- setAgent(data);
1238
- config.hooks?.onAfterSwitchAgent?.(data);
1225
+ agent.agentInfo = data;
1226
+ config.hooks?.onAfterSwitchAgent?.(agent.agentInfo);
1239
1227
  } finally {
1240
1228
  config.loading = false;
1241
1229
  }
1242
1230
  };
1231
+ const setAgent = async (agentInfo) => {
1232
+ if (!agent.agentInfo.id || agent.agentInfo.id !== agentInfo.id) {
1233
+ await getAgentInfo(agentInfo.id);
1234
+ }
1235
+ agent.agentInfo = { ...agent.agentInfo, ...agentInfo };
1236
+ if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1237
+ setAgentModel({
1238
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
1239
+ providerName: agent.agentInfo.spec?.model?.providerName || ""
1240
+ });
1241
+ } else if (config.layout.userInput) {
1242
+ await getUserInput(agent.agentInfo.id);
1243
+ }
1244
+ };
1243
1245
  const conversations = valtio.proxy({
1244
1246
  /** 会话列表数据 */
1245
1247
  list: {
@@ -1371,7 +1373,17 @@ function createChatStore() {
1371
1373
  isFavorite: true
1372
1374
  }
1373
1375
  });
1374
- favorite.list.items = data || [];
1376
+ const resultItems = common.transforms(data || [], {
1377
+ key: "id",
1378
+ id: "id",
1379
+ label: "title",
1380
+ spec: "spec",
1381
+ isFavorite: "isFavorite",
1382
+ group: (c) => {
1383
+ return classifyTime(c.updatedAt);
1384
+ }
1385
+ });
1386
+ favorite.list.items = resultItems;
1375
1387
  } finally {
1376
1388
  favorite.loading = false;
1377
1389
  }
@@ -2292,7 +2304,7 @@ var ConversationShareBtn_default = ({ icon, ...rest }) => {
2292
2304
  const handleShareConversation = async () => {
2293
2305
  const { data } = await configState.services.request.shareConversation(conversationState.active.id);
2294
2306
  if (data) {
2295
- common.copyText(data.url);
2307
+ common.copyText(data.url, "\u94FE\u63A5\u5DF2\u590D\u5236\uFF0C\u53EF\u76F4\u63A5\u7C98\u8D34\u5206\u4EAB");
2296
2308
  }
2297
2309
  };
2298
2310
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2322,12 +2334,8 @@ var styles_module_default2 = {
2322
2334
  chatHeaderBtnGroup: "styles_module_chatHeaderBtnGroup",
2323
2335
  conversationListPanel: "styles_module_conversationListPanel",
2324
2336
  createConversationButton: "styles_module_createConversationButton",
2325
- conversationListContent: "styles_module_conversationListContent",
2326
2337
  conversations: "styles_module_conversations",
2327
- conversationTabs: "styles_module_conversationTabs",
2328
- conversationTabPane: "styles_module_conversationTabPane",
2329
2338
  conversationEmpty: "styles_module_conversationEmpty",
2330
- conversationScrollArea: "styles_module_conversationScrollArea",
2331
2339
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
2332
2340
  chatWelcome: "styles_module_chatWelcome",
2333
2341
  promptItem: "styles_module_promptItem",
@@ -2344,6 +2352,32 @@ var styles_module_default2 = {
2344
2352
  senderReferenceHeaderTitle: "styles_module_senderReferenceHeaderTitle",
2345
2353
  senderReferenceHeaderContent: "styles_module_senderReferenceHeaderContent"
2346
2354
  };
2355
+ var ConversationTabPane = ({ items, activeKey, emptyDescription, scrollableTarget, menu, onActiveChange }) => {
2356
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full", children: items.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full scroll-fade-in", id: scrollableTarget, children: /* @__PURE__ */ jsxRuntime.jsx(
2357
+ InfiniteScroll__default.default,
2358
+ {
2359
+ dataLength: items.length,
2360
+ hasMore: false,
2361
+ next: () => {
2362
+ console2__default.default.log("next");
2363
+ },
2364
+ loader: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { indicator: /* @__PURE__ */ jsxRuntime.jsx(icons.RedoOutlined, { spin: true }), size: "small" }) }),
2365
+ style: { overflow: "hidden" },
2366
+ scrollableTarget,
2367
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2368
+ xV2.Conversations,
2369
+ {
2370
+ className: styles_module_default2.conversations,
2371
+ items,
2372
+ activeKey,
2373
+ onActiveChange: async (id) => onActiveChange(id),
2374
+ groupable: true,
2375
+ menu
2376
+ }
2377
+ )
2378
+ }
2379
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { description: emptyDescription, image: antd.Empty.PRESENTED_IMAGE_SIMPLE }) }) });
2380
+ };
2347
2381
  var ConversationList_default = () => {
2348
2382
  const chatStore = useChatStore();
2349
2383
  const agentState = valtio.useSnapshot(chatStore.agent);
@@ -2359,15 +2393,7 @@ var ConversationList_default = () => {
2359
2393
  return conversationsState.list.items.filter((item) => item.label);
2360
2394
  }, [conversationsState.list.items]);
2361
2395
  const favoriteConversationList = React10.useMemo(() => {
2362
- return favoriteState.list.items.filter((item) => item.title).map((item) => ({
2363
- ...item,
2364
- key: item.id,
2365
- id: item.id,
2366
- label: item.title,
2367
- spec: item.spec,
2368
- isFavorite: true,
2369
- group: classifyTime(item.updatedAt)
2370
- }));
2396
+ return favoriteState.list.items.filter((item) => item.label);
2371
2397
  }, [favoriteState.list.items]);
2372
2398
  const historyMenuConfig = (conversation) => ({
2373
2399
  items: [
@@ -2420,72 +2446,48 @@ var ConversationList_default = () => {
2420
2446
  ),
2421
2447
  items: []
2422
2448
  });
2423
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationTabs, children: /* @__PURE__ */ jsxRuntime.jsx(
2449
+ const handleConversationChange = async (id) => chatStore.switchConversation(id);
2450
+ return /* @__PURE__ */ jsxRuntime.jsx(
2424
2451
  antd.Tabs,
2425
2452
  {
2426
2453
  activeKey: activeTabKey,
2427
2454
  centered: true,
2455
+ className: "full-tabs",
2428
2456
  onChange: setActiveTabKey,
2429
2457
  items: [
2430
2458
  {
2431
2459
  key: "history",
2432
2460
  label: "\u5386\u53F2\u4F1A\u8BDD",
2433
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationTabPane, children: conversationList.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationScrollArea, id: "historyConversationScrollableDiv", children: /* @__PURE__ */ jsxRuntime.jsx(
2434
- InfiniteScroll__default.default,
2461
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2462
+ ConversationTabPane,
2435
2463
  {
2436
- dataLength: conversationList.length,
2437
- hasMore: false,
2438
- next: () => {
2439
- console2__default.default.log("next");
2440
- },
2441
- loader: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { indicator: /* @__PURE__ */ jsxRuntime.jsx(icons.RedoOutlined, { spin: true }), size: "small" }) }),
2442
- style: { overflow: "hidden" },
2464
+ items: conversationList,
2465
+ activeKey: conversationState.active.id,
2466
+ emptyDescription: "\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55",
2443
2467
  scrollableTarget: "historyConversationScrollableDiv",
2444
- children: /* @__PURE__ */ jsxRuntime.jsx(
2445
- xV2.Conversations,
2446
- {
2447
- className: styles_module_default2.conversations,
2448
- items: conversationList,
2449
- activeKey: conversationState.active.id,
2450
- onActiveChange: async (id) => chatStore.switchConversation(id),
2451
- groupable: true,
2452
- menu: historyMenuConfig
2453
- }
2454
- )
2468
+ menu: historyMenuConfig,
2469
+ onActiveChange: handleConversationChange
2455
2470
  }
2456
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { description: "\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55", image: antd.Empty.PRESENTED_IMAGE_SIMPLE }) }) })
2471
+ )
2457
2472
  },
2458
2473
  {
2459
2474
  key: "favorite",
2460
2475
  label: "\u6536\u85CF\u4F1A\u8BDD",
2461
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationTabPane, children: favoriteConversationList.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationScrollArea, id: "favoriteConversationScrollableDiv", children: /* @__PURE__ */ jsxRuntime.jsx(
2462
- InfiniteScroll__default.default,
2476
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2477
+ ConversationTabPane,
2463
2478
  {
2464
- dataLength: favoriteConversationList.length,
2465
- hasMore: false,
2466
- next: () => {
2467
- console2__default.default.log("next");
2468
- },
2469
- loader: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { indicator: /* @__PURE__ */ jsxRuntime.jsx(icons.RedoOutlined, { spin: true }), size: "small" }) }),
2470
- style: { overflow: "hidden" },
2479
+ items: favoriteConversationList,
2480
+ activeKey: conversationState.active.id,
2481
+ emptyDescription: "\u6682\u65E0\u6536\u85CF\u4F1A\u8BDD",
2471
2482
  scrollableTarget: "favoriteConversationScrollableDiv",
2472
- children: /* @__PURE__ */ jsxRuntime.jsx(
2473
- xV2.Conversations,
2474
- {
2475
- className: styles_module_default2.conversations,
2476
- items: favoriteConversationList,
2477
- activeKey: conversationState.active.id,
2478
- onActiveChange: async (id) => chatStore.switchConversation(id),
2479
- groupable: true,
2480
- menu: favoriteMenuConfig
2481
- }
2482
- )
2483
+ menu: favoriteMenuConfig,
2484
+ onActiveChange: handleConversationChange
2483
2485
  }
2484
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { description: "\u6682\u65E0\u6536\u85CF\u4F1A\u8BDD", image: antd.Empty.PRESENTED_IMAGE_SIMPLE }) }) })
2486
+ )
2485
2487
  }
2486
2488
  ]
2487
2489
  }
2488
- ) });
2490
+ );
2489
2491
  };
2490
2492
 
2491
2493
  // src/ui/common/FeatureComponents/style.module.less
@@ -2619,9 +2621,9 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2619
2621
  ] });
2620
2622
  };
2621
2623
  var ConversationListPanel = ({ header }) => {
2622
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
2624
+ return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full", "zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
2623
2625
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
2624
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.conversationListContent, children: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}) })
2626
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}) })
2625
2627
  ] });
2626
2628
  };
2627
2629
  var ConversationListPanel_default = ConversationListPanel;
@@ -6635,25 +6637,10 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
6635
6637
  chatStore.setServices(services);
6636
6638
  }, [services]);
6637
6639
  common.useDeepEffect(() => {
6638
- if (agentState.agentInfo.id && common.isObject(config.agent?.spec)) {
6639
- chatStore.setAgent({ ...agentState.agentInfo, spec: config.agent.spec || {} });
6640
- }
6641
- }, [agentState.agentInfo.id, config.agent?.spec]);
6642
- common.useDeepEffect(() => {
6643
- if (agentState.agentInfo.id && common.isObject(config.agent?.config)) {
6644
- chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
6645
- }
6646
- }, [agentState.agentInfo.id, config.agent?.config]);
6647
- common.useDeepEffect(() => {
6648
- if (agentState.agentInfo.id) {
6649
- chatStore.setUserInput(config.agent.userInput);
6650
- }
6651
- }, [agentState.agentInfo.id, config.agent?.userInput]);
6652
- common.useDeepEffect(() => {
6653
- if (config?.agent?.id) {
6654
- chatStore.getAgentInfo(config.agent.id);
6640
+ if (config.agent) {
6641
+ chatStore.setAgent(config.agent);
6655
6642
  }
6656
- }, [config.agent?.id]);
6643
+ }, [config.agent]);
6657
6644
  common.useDeepEffect(() => {
6658
6645
  if (agentState.agentInfo.id) {
6659
6646
  chatStore.initConversation(config);