@zero-library/chat-copilot 3.1.11 → 3.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -55,7 +55,7 @@ interface FileUploadConfig {
55
55
  }
56
56
  interface AgentSpec {
57
57
  model?: ModelConfig;
58
- knowledge?: {
58
+ knowledges?: {
59
59
  items: {
60
60
  id: string;
61
61
  name: string;
@@ -370,6 +370,64 @@ interface ConversationNewTitleEvent {
370
370
  type: 'conversationNewTitle';
371
371
  title: string;
372
372
  }
373
+ interface DisplayMeta {
374
+ label: string;
375
+ value: string;
376
+ }
377
+ interface DisplayKvItem {
378
+ label: string;
379
+ value: string;
380
+ }
381
+ interface DisplayLinkItem {
382
+ title: string;
383
+ url: string;
384
+ summary?: string;
385
+ }
386
+ type DisplayStatusLevel = 'info' | 'success' | 'warning' | 'error';
387
+ type DisplayBlock = {
388
+ kind: 'markdown';
389
+ title?: string;
390
+ content: string;
391
+ } | {
392
+ kind: 'code';
393
+ title?: string;
394
+ content: string;
395
+ lang: string;
396
+ } | {
397
+ kind: 'key_value';
398
+ title?: string;
399
+ items: DisplayKvItem[];
400
+ } | {
401
+ kind: 'links';
402
+ title?: string;
403
+ items: DisplayLinkItem[];
404
+ } | {
405
+ kind: 'status';
406
+ level: DisplayStatusLevel;
407
+ text: string;
408
+ };
409
+ /** 完整展示视图 — ToolCall/ToolResult 事件携带,全量替换语义 */
410
+ interface DisplayView {
411
+ /** 简短标题(文件路径、命令首行等) */
412
+ title: string;
413
+ /** 标题下的一句话摘要 */
414
+ summary?: string;
415
+ /** 通用展示块 */
416
+ blocks?: DisplayBlock[];
417
+ /** 简短元信息 */
418
+ meta?: DisplayMeta[];
419
+ }
420
+ /** 流式展示增量 — ToolCallDelta 事件携带,增量追加语义 */
421
+ interface DisplayDelta {
422
+ /** 标题变更(首次设置或变化时发送,前端直接替换) */
423
+ title?: string;
424
+ /** 内容追加片段(节流后发送,前端追加到末尾) */
425
+ contentAppend?: string;
426
+ /** 流式内容类型 */
427
+ kind?: 'markdown' | 'code' | 'text';
428
+ /** code 类型语言 */
429
+ lang?: string;
430
+ }
373
431
  interface ToolCallEvent {
374
432
  type: 'toolCall';
375
433
  toolCallId?: string;
@@ -382,12 +440,14 @@ interface ToolCallEvent {
382
440
  content?: string;
383
441
  /** 工具调用参数 */
384
442
  arguments?: any;
385
- /** 展示内容(由后端增量推送,格式化的展示文本) */
386
- display?: string;
443
+ /** 完整展示视图(全量替换语义,未实现 display 方法的工具为 null) */
444
+ display?: DisplayView | null;
387
445
  /** 执行状态 */
388
446
  status?: 'pending' | 'running' | 'success' | 'error';
389
447
  /** 该工具是否触发了子智能体(前端动态判断:有 toolCallId 的子消息到达时标记) */
390
448
  hasSubAgent?: boolean;
449
+ /** 前端内部标记:是否使用 display 协议渲染 */
450
+ displayProtocol?: boolean;
391
451
  }
392
452
  interface ToolCallDeltaEvent {
393
453
  type: 'toolCallDelta';
@@ -401,8 +461,8 @@ interface ToolCallDeltaEvent {
401
461
  index?: number;
402
462
  /** 增量参数字符串,需追加拼接 */
403
463
  argumentsDelta?: string;
404
- /** 格式化展示内容(每次 delta 携带最新完整快照,直接覆盖) */
405
- display?: string;
464
+ /** 流式展示增量(增量追加语义,无变化时不出现此字段) */
465
+ displayDelta?: DisplayDelta;
406
466
  /** 执行状态 */
407
467
  status?: 'pending' | 'running' | 'success' | 'error';
408
468
  }
@@ -418,12 +478,16 @@ interface ToolResultEvent {
418
478
  content?: string;
419
479
  /** 工具执行结果 */
420
480
  result?: any;
421
- /** 格式化展示内容(结果阶段的全量快照,直接覆盖) */
422
- display?: string;
481
+ /** 完整展示视图(结果阶段全量替换语义) */
482
+ display?: DisplayView | null;
423
483
  /** 执行状态 */
424
484
  status?: 'pending' | 'running' | 'success' | 'error';
485
+ /** 是否出错(与 status='error' 始终一致,推荐使用此字段) */
486
+ isError?: boolean;
425
487
  errorMessage?: string;
426
488
  /** 耗时(ms) */
489
+ durationMs?: number;
490
+ /** 兼容旧字段名 */
427
491
  duration?: number;
428
492
  }
429
493
  interface A2uiCommandEvent {
package/dist/index.esm.js CHANGED
@@ -1279,7 +1279,7 @@ function createChatStore() {
1279
1279
  const { data } = await config.services.request.createConversationId({ agentId: agent.agentInfo.id, convMeta: config.params.convMeta });
1280
1280
  const newSpec = {
1281
1281
  skills: { items: [] },
1282
- knowledge: { items: [] }
1282
+ knowledges: { items: [] }
1283
1283
  };
1284
1284
  updateConversations({
1285
1285
  id: data || "",
@@ -1594,36 +1594,34 @@ function createChatStore() {
1594
1594
  messages.push(finalMsg);
1595
1595
  } else {
1596
1596
  const contents = messages[idx].content;
1597
- const existingItemIndex = contents.findIndex(
1597
+ let existingItemIndex = contents.findIndex(
1598
1598
  (item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId
1599
1599
  );
1600
+ if (existingItemIndex === -1 && contentItem.toolCallId) {
1601
+ existingItemIndex = contents.findIndex(
1602
+ (item) => item.type === "toolCall" && !item.toolCallId && item._streamingIndex !== void 0
1603
+ );
1604
+ }
1600
1605
  if (existingItemIndex !== -1) {
1601
- const existingItem = contents[existingItemIndex];
1606
+ const nextItem = { ...contents[existingItemIndex] };
1602
1607
  const newContent = contentItem.content || contentItem.arguments;
1603
- const nextItem = { ...existingItem };
1604
1608
  if (typeof newContent === "string") {
1605
- nextItem.content = (existingItem.content || "") + newContent;
1609
+ nextItem.content = (nextItem.content || "") + newContent;
1606
1610
  } else if (newContent !== void 0) {
1607
1611
  nextItem.arguments = newContent;
1608
1612
  }
1609
- if (contentItem.toolName) {
1610
- nextItem.toolName = contentItem.toolName;
1611
- }
1612
- if (contentItem.title) {
1613
- nextItem.title = contentItem.title;
1614
- }
1615
- if (contentItem.status) {
1616
- nextItem.status = contentItem.status;
1617
- }
1618
- if (contentItem.toolIcon) {
1619
- nextItem.toolIcon = contentItem.toolIcon;
1620
- }
1613
+ if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
1614
+ if (contentItem.title) nextItem.title = contentItem.title;
1615
+ if (contentItem.status) nextItem.status = contentItem.status;
1616
+ if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
1617
+ if (contentItem.display?.title) nextItem.title = contentItem.display.title;
1621
1618
  if (contentItem.display) {
1622
- nextItem.display = (existingItem.display || "") + contentItem.display;
1619
+ nextItem.argsDisplay = contentItem.display;
1620
+ nextItem.displayProtocol = true;
1623
1621
  }
1624
1622
  messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
1625
1623
  } else {
1626
- messages[idx].content = [...contents, contentItem];
1624
+ messages[idx].content = [...contents, { ...contentItem, displayProtocol: !!contentItem.display }];
1627
1625
  }
1628
1626
  }
1629
1627
  if (isMain) conversation.messages[msg.conversationId].loading = true;
@@ -1642,25 +1640,20 @@ function createChatStore() {
1642
1640
  const contents = messages[idx].content;
1643
1641
  const toolCallIndex = contents.findIndex((item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId);
1644
1642
  if (toolCallIndex !== -1) {
1645
- const toolCallItem = contents[toolCallIndex];
1646
1643
  const nextToolCallItem = {
1647
- ...toolCallItem,
1644
+ ...contents[toolCallIndex],
1648
1645
  result: contentItem.result ?? contentItem.content
1649
1646
  };
1650
- if (contentItem.status) {
1651
- nextToolCallItem.status = contentItem.status;
1652
- }
1653
- if (contentItem.errorMessage) {
1654
- nextToolCallItem.errorMessage = contentItem.errorMessage;
1655
- }
1656
- if (contentItem.duration) {
1657
- nextToolCallItem.duration = contentItem.duration;
1658
- }
1659
- if (contentItem.title) {
1660
- nextToolCallItem.title = contentItem.title;
1661
- }
1662
- if (contentItem.display !== void 0) {
1663
- nextToolCallItem.display = contentItem.display;
1647
+ if (contentItem.status) nextToolCallItem.status = contentItem.status;
1648
+ if (contentItem.isError !== void 0) nextToolCallItem.isError = contentItem.isError;
1649
+ if (contentItem.errorMessage) nextToolCallItem.errorMessage = contentItem.errorMessage;
1650
+ const dur = contentItem.durationMs ?? contentItem.duration;
1651
+ if (dur !== void 0) nextToolCallItem.duration = dur;
1652
+ if (contentItem.title) nextToolCallItem.title = contentItem.title;
1653
+ if (contentItem.display?.title) nextToolCallItem.title = contentItem.display.title;
1654
+ if (contentItem.display) {
1655
+ nextToolCallItem.resultDisplay = contentItem.display;
1656
+ nextToolCallItem.displayProtocol = true;
1664
1657
  }
1665
1658
  messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
1666
1659
  } else {
@@ -1687,59 +1680,74 @@ function createChatStore() {
1687
1680
  let idx = -1;
1688
1681
  if (contentItem.toolCallId) {
1689
1682
  idx = messages.findLastIndex(
1690
- (m) => m.content?.some((c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId)
1683
+ (m) => m.content?.some((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId)
1684
+ );
1685
+ }
1686
+ if (idx === -1 && contentItem.index !== void 0) {
1687
+ idx = messages.findLastIndex(
1688
+ (m) => m.executionId === msg.executionId && m.content?.some((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId)
1691
1689
  );
1692
1690
  }
1693
1691
  if (idx === -1) idx = findExecutionMsgIndex(msg, messages);
1692
+ const buildNewItem = () => {
1693
+ const item = {
1694
+ type: "toolCall",
1695
+ toolCallId: contentItem.toolCallId || void 0,
1696
+ _streamingIndex: contentItem.index,
1697
+ toolName: contentItem.toolName || void 0,
1698
+ toolIcon: contentItem.toolIcon,
1699
+ title: contentItem.title,
1700
+ content: contentItem.displayDelta ? "" : contentItem.argumentsDelta || "",
1701
+ status: contentItem.status || "running",
1702
+ displayProtocol: !!contentItem.displayDelta
1703
+ };
1704
+ if (contentItem.displayDelta?.title) item.title = contentItem.displayDelta.title;
1705
+ if (contentItem.displayDelta?.contentAppend) {
1706
+ item.streamingArgsDisplay = {
1707
+ title: contentItem.displayDelta.title,
1708
+ content: contentItem.displayDelta.contentAppend,
1709
+ kind: contentItem.displayDelta.kind,
1710
+ lang: contentItem.displayDelta.lang
1711
+ };
1712
+ }
1713
+ return item;
1714
+ };
1694
1715
  if (idx === -1) {
1695
- messages.push({
1696
- ...msg,
1697
- content: [
1698
- {
1699
- type: "toolCall",
1700
- toolCallId: contentItem.toolCallId,
1701
- toolName: contentItem.toolName || void 0,
1702
- toolIcon: contentItem.toolIcon,
1703
- title: contentItem.title,
1704
- content: contentItem.argumentsDelta || "",
1705
- display: contentItem.display,
1706
- status: contentItem.status || "running"
1707
- }
1708
- ],
1709
- generating: true
1710
- });
1716
+ messages.push({ ...msg, content: [buildNewItem()], generating: true });
1711
1717
  } else {
1712
1718
  const contents = messages[idx].content;
1713
- const itemIdx = contents.findIndex(
1714
- (c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId
1715
- );
1719
+ let itemIdx = -1;
1720
+ if (contentItem.toolCallId) {
1721
+ itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId);
1722
+ }
1723
+ if (itemIdx === -1 && contentItem.index !== void 0) {
1724
+ itemIdx = contents.findIndex((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId);
1725
+ }
1716
1726
  if (itemIdx !== -1) {
1717
1727
  const existing = contents[itemIdx];
1718
1728
  const nextItem = {
1719
1729
  ...existing,
1720
1730
  type: "toolCall",
1721
- content: (existing.content || "") + (contentItem.argumentsDelta || "")
1731
+ content: contentItem.displayDelta ? existing.content || "" : (existing.content || "") + (contentItem.argumentsDelta || "")
1722
1732
  };
1733
+ if (contentItem.toolCallId && !existing.toolCallId) nextItem.toolCallId = contentItem.toolCallId;
1723
1734
  if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
1724
1735
  if (contentItem.title) nextItem.title = contentItem.title;
1725
1736
  if (contentItem.status) nextItem.status = contentItem.status;
1726
1737
  if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
1727
- if (contentItem.display) nextItem.display = (existing.display || "") + contentItem.display;
1738
+ if (contentItem.displayDelta) nextItem.displayProtocol = true;
1739
+ if (contentItem.displayDelta?.title) nextItem.title = contentItem.displayDelta.title;
1740
+ if (contentItem.displayDelta?.contentAppend) {
1741
+ nextItem.streamingArgsDisplay = {
1742
+ title: contentItem.displayDelta.title || existing.streamingArgsDisplay?.title,
1743
+ content: (existing.streamingArgsDisplay?.content || "") + contentItem.displayDelta.contentAppend,
1744
+ kind: contentItem.displayDelta.kind || existing.streamingArgsDisplay?.kind,
1745
+ lang: contentItem.displayDelta.lang ?? existing.streamingArgsDisplay?.lang
1746
+ };
1747
+ }
1728
1748
  messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
1729
1749
  } else {
1730
- messages[idx].content = [
1731
- ...contents,
1732
- {
1733
- type: "toolCall",
1734
- toolCallId: contentItem.toolCallId,
1735
- toolName: contentItem.toolName || void 0,
1736
- toolIcon: contentItem.toolIcon,
1737
- title: contentItem.title,
1738
- content: contentItem.argumentsDelta || "",
1739
- display: contentItem.display,
1740
- status: contentItem.status || "running"
1741
- }
1742
- ];
1750
+ messages[idx].content = [...contents, buildNewItem()];
1743
1751
  }
1744
1752
  }
1745
1753
  if (isMain) conversation.messages[msg.conversationId].loading = true;
@@ -1969,6 +1977,11 @@ function createChatStore() {
1969
1977
  const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
1970
1978
  await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
1971
1979
  config.hooks?.onAfterSend?.();
1980
+ } catch (err) {
1981
+ conversation.messages[conversationId].loading = false;
1982
+ const errMsg = err?.response?.data?.message || err?.message || "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
1983
+ message.error(errMsg);
1984
+ throw err;
1972
1985
  } finally {
1973
1986
  }
1974
1987
  };
@@ -4767,10 +4780,12 @@ var TextNode2 = React10__default.memo(
4767
4780
 
4768
4781
  // src/components/CustomComponents/ToolRenders/index.module.less
4769
4782
  var index_module_default2 = {
4783
+ toolCollapse: "index_module_toolCollapse",
4770
4784
  iconContainer: "index_module_iconContainer",
4771
4785
  toolName: "index_module_toolName",
4772
4786
  toolNamePending: "index_module_toolNamePending",
4773
4787
  dot: "index_module_dot",
4788
+ dotBlink: "index_module_dotBlink",
4774
4789
  duration: "index_module_duration",
4775
4790
  statusIcon: "index_module_statusIcon",
4776
4791
  expandIcon: "index_module_expandIcon",
@@ -4778,8 +4793,30 @@ var index_module_default2 = {
4778
4793
  sectionLabel: "index_module_sectionLabel",
4779
4794
  plainTextContainer: "index_module_plainTextContainer",
4780
4795
  markdownContainer: "index_module_markdownContainer",
4796
+ summaryText: "index_module_summaryText",
4797
+ metaGrid: "index_module_metaGrid",
4798
+ metaItem: "index_module_metaItem",
4799
+ metaLabel: "index_module_metaLabel",
4800
+ metaValue: "index_module_metaValue",
4801
+ linkList: "index_module_linkList",
4802
+ linkItem: "index_module_linkItem",
4803
+ linkTitle: "index_module_linkTitle",
4804
+ linkIndex: "index_module_linkIndex",
4805
+ linkSummary: "index_module_linkSummary",
4806
+ linkUrl: "index_module_linkUrl",
4807
+ statusBlock: "index_module_statusBlock",
4808
+ status_info: "index_module_status_info",
4809
+ status_success: "index_module_status_success",
4810
+ status_warning: "index_module_status_warning",
4811
+ status_error: "index_module_status_error",
4812
+ errorDisplay: "index_module_errorDisplay",
4781
4813
  sectionBlock: "index_module_sectionBlock",
4814
+ compactSectionBlock: "index_module_compactSectionBlock",
4782
4815
  contentScrollContainer: "index_module_contentScrollContainer",
4816
+ subAgentContainer: "index_module_subAgentContainer",
4817
+ subAgentHeader: "index_module_subAgentHeader",
4818
+ subAgentName: "index_module_subAgentName",
4819
+ subAgentMessages: "index_module_subAgentMessages",
4783
4820
  todoList: "index_module_todoList",
4784
4821
  todoItem: "index_module_todoItem",
4785
4822
  statusIconWrapper: "index_module_statusIconWrapper",
@@ -4788,28 +4825,89 @@ var index_module_default2 = {
4788
4825
  completed: "index_module_completed",
4789
4826
  emptyText: "index_module_emptyText"
4790
4827
  };
4791
- var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
4792
- if (item.display) {
4793
- return /* @__PURE__ */ jsx("pre", { className: index_module_default2.plainTextContainer, children: item.display });
4828
+ var toMarkdown = (content, kind, lang) => {
4829
+ if (kind === "markdown") return content;
4830
+ if (kind === "data") return `\`\`\`json
4831
+ ${content}
4832
+ \`\`\``;
4833
+ return lang ? `\`\`\`${lang}
4834
+ ${content}
4835
+ \`\`\`` : `\`\`\`
4836
+ ${content}
4837
+ \`\`\``;
4838
+ };
4839
+ var renderBlock = (block, index) => {
4840
+ if (block.kind === "status") {
4841
+ return /* @__PURE__ */ jsx("div", { className: `${index_module_default2.statusBlock} ${index_module_default2[`status_${block.level}`] || ""}`, children: block.text }, `status-${index}`);
4794
4842
  }
4795
- return /* @__PURE__ */ jsxs(Fragment, { children: [
4796
- (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4797
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4798
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4843
+ if (block.kind === "key_value") {
4844
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4845
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4846
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.metaGrid, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs("div", { className: index_module_default2.metaItem, children: [
4847
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
4848
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaValue, children: item.value })
4849
+ ] }, `${item.label}-${itemIndex}`)) })
4850
+ ] }, `kv-${index}`);
4851
+ }
4852
+ if (block.kind === "links") {
4853
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4854
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4855
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.linkList, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs("a", { href: item.url, target: "_blank", rel: "noreferrer", className: index_module_default2.linkItem, children: [
4856
+ /* @__PURE__ */ jsxs("span", { className: index_module_default2.linkIndex, children: [
4857
+ itemIndex + 1,
4858
+ "."
4859
+ ] }),
4860
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.linkTitle, children: item.title })
4861
+ ] }, `${item.url}-${itemIndex}`)) })
4862
+ ] }, `links-${index}`);
4863
+ }
4864
+ const markdown = block.kind === "markdown" ? block.content : toMarkdown(block.content, "code", block.lang);
4865
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4866
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4867
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: markdown }) })
4868
+ ] }, `${block.kind}-${index}`);
4869
+ };
4870
+ var renderDisplayView = (view, fallbackLabel) => {
4871
+ if (!view) return null;
4872
+ const hasBody = view.blocks && view.blocks.length > 0 || view.meta && view.meta.length > 0 || view.summary;
4873
+ if (!hasBody) return null;
4874
+ const hasRichBody = !!(view.blocks && view.blocks.length > 0);
4875
+ const isOnlyLinksBlock = !view.summary && (!view.meta || view.meta.length === 0) && view.blocks?.length === 1 && view.blocks[0].kind === "links";
4876
+ const label = isOnlyLinksBlock ? void 0 : (hasRichBody ? view.title : void 0);
4877
+ return /* @__PURE__ */ jsxs("div", { className: `${index_module_default2.sectionBlock} ${!hasRichBody ? index_module_default2.compactSectionBlock : ""}`, children: [
4878
+ label && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: label }),
4879
+ view.summary && /* @__PURE__ */ jsx("div", { className: index_module_default2.summaryText, children: view.summary }),
4880
+ view.meta && view.meta.length > 0 && /* @__PURE__ */ jsx("div", { className: index_module_default2.metaGrid, children: view.meta.map((item, index) => /* @__PURE__ */ jsxs("div", { className: index_module_default2.metaItem, children: [
4881
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
4882
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaValue, children: item.value })
4883
+ ] }, `${item.label}-${index}`)) }),
4884
+ view.blocks?.map((block, index) => renderBlock(block, index))
4885
+ ] });
4886
+ };
4887
+ var DefaultToolRender = ({ argsContent, resultContent, item }) => {
4888
+ const sd = item.streamingArgsDisplay;
4889
+ const isError = item.isError || item.status === "error";
4890
+ const hasStructuredDisplay = !!item.displayProtocol || !!sd?.content || !!item.argsDisplay || !!item.resultDisplay;
4891
+ return /* @__PURE__ */ jsxs("div", { className: isError ? index_module_default2.errorDisplay : "", children: [
4892
+ !item.argsDisplay && sd?.content && /* @__PURE__ */ jsxs("div", { className: `${index_module_default2.sectionBlock} ${index_module_default2.compactSectionBlock}`, children: [
4893
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: sd.title || "\u8F93\u5165\u751F\u6210\u4E2D" }),
4894
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: toMarkdown(sd.content, sd.kind, sd.lang) }) })
4895
+ ] }),
4896
+ renderDisplayView(item.argsDisplay),
4897
+ renderDisplayView(item.resultDisplay),
4898
+ !hasStructuredDisplay && /* @__PURE__ */ jsxs(Fragment, { children: [
4899
+ (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4900
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4901
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4799
4902
  ${argsContent.text}
4800
4903
  \`\`\`` : argsContent.text }) })
4801
- ] }),
4802
- item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4803
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4804
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4904
+ ] }),
4905
+ item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4906
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4907
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4805
4908
  ${resultContent.text}
4806
4909
  \`\`\`` : resultContent.text }) })
4807
- ] }),
4808
- errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4809
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
4810
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: `\`\`\`
4811
- ${errorMessage}
4812
- \`\`\`` }) })
4910
+ ] })
4813
4911
  ] })
4814
4912
  ] });
4815
4913
  };
@@ -4893,6 +4991,9 @@ var formatContent = (content) => {
4893
4991
  return { text, isJson: false, parsed: null };
4894
4992
  }
4895
4993
  };
4994
+ var hasDisplayViewBody = (view) => {
4995
+ return !!(view?.summary || view?.blocks?.length || view?.meta?.length);
4996
+ };
4896
4997
  var ToolCallItem = ({ item }) => {
4897
4998
  const { token } = theme.useToken();
4898
4999
  const renderConfig = getToolRenderConfig(item);
@@ -4919,16 +5020,22 @@ var ToolCallItem = ({ item }) => {
4919
5020
  alwaysShow = renderConfig.alwaysShowContent;
4920
5021
  }
4921
5022
  if (alwaysShow) return true;
4922
- if (item.display) return true;
4923
- if (item.errorMessage) return true;
5023
+ if (item.displayProtocol) {
5024
+ if (item.streamingArgsDisplay?.content) return true;
5025
+ if (hasDisplayViewBody(item.argsDisplay)) return true;
5026
+ if (hasDisplayViewBody(item.resultDisplay)) return true;
5027
+ return false;
5028
+ }
4924
5029
  if (argsContent.text) return true;
4925
5030
  if (resultContent?.text) return true;
4926
5031
  return false;
4927
5032
  }, [
4928
5033
  renderConfig.disableExpandOnError,
4929
5034
  renderConfig.alwaysShowContent,
4930
- item.display,
4931
- item.errorMessage,
5035
+ item.displayProtocol,
5036
+ item.streamingArgsDisplay,
5037
+ item.argsDisplay,
5038
+ item.resultDisplay,
4932
5039
  status,
4933
5040
  argsContent.parsed,
4934
5041
  resultContent?.parsed,
@@ -4956,15 +5063,19 @@ var ToolCallItem = ({ item }) => {
4956
5063
  return /* @__PURE__ */ jsx(
4957
5064
  Collapse,
4958
5065
  {
4959
- style: { width: "70%" },
5066
+ className: index_module_default2.toolCollapse,
5067
+ style: { width: "100%" },
4960
5068
  collapsible: hasContent ? void 0 : "disabled",
4961
5069
  defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
4962
5070
  expandIconPlacement: "end",
4963
5071
  expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsx(RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
4964
5072
  styles: {
4965
5073
  header: {
4966
- padding: "6px 10px",
5074
+ padding: "4px 8px",
4967
5075
  overflow: "hidden"
5076
+ },
5077
+ body: {
5078
+ padding: "0 8px 8px"
4968
5079
  }
4969
5080
  },
4970
5081
  items: [
@@ -5369,7 +5480,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5369
5480
  setCategories([{ id: ALL_CATEGORY_ID, name: "\u5168\u90E8" }, ...tagsRes.data || []]);
5370
5481
  setResources(fetchedResources);
5371
5482
  const spec = conversationState.active.spec;
5372
- const initialItems = isSkill ? spec?.skills?.items : spec?.knowledge?.items;
5483
+ const initialItems = isSkill ? spec?.skills?.items : spec?.knowledges?.items;
5373
5484
  const validIds = new Set(fetchedResources.map((r) => r.id));
5374
5485
  const validSelectedIds = (initialItems || []).map((item) => item.id).filter((id) => validIds.has(id));
5375
5486
  setSelectedIds(validSelectedIds);
@@ -5416,7 +5527,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5416
5527
  items: ids.map((id) => ({ id }))
5417
5528
  };
5418
5529
  } else {
5419
- nextSpec.knowledge = {
5530
+ nextSpec.knowledges = {
5420
5531
  items: ids.map((id) => {
5421
5532
  const resource = resourceList.find((r) => r.id === id);
5422
5533
  return { id, name: resource?.name || "" };
@@ -5563,7 +5674,7 @@ var KnowledgeBtn_default = ({}) => {
5563
5674
  const chatStore = useChatStore();
5564
5675
  const conversationState = useSnapshot(chatStore.conversation);
5565
5676
  const [modalOpen, setModalOpen] = useState(false);
5566
- const knowledgeCount = conversationState.active.spec?.knowledge?.items?.length ?? 0;
5677
+ const knowledgeCount = conversationState.active.spec?.knowledges?.items?.length ?? 0;
5567
5678
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5568
5679
  /* @__PURE__ */ jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
5569
5680
  /* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),