@blueking/chat-x 0.0.51-beta.2 → 0.0.51-beta.3

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.
Files changed (106) hide show
  1. package/dist/components/chat-content/file-content/upload-image-item.vue.d.ts +2 -0
  2. package/dist/components/chat-content/file-content/upload-spinner.vue.d.ts +3 -0
  3. package/dist/components/chat-input/chat-input.vue.d.ts +3 -0
  4. package/dist/index.css +1 -1
  5. package/dist/index.js +745 -712
  6. package/dist/index.js.map +1 -1
  7. package/dist/lang/lang.d.ts +4 -1
  8. package/dist/mcp/generated/docs/chat-container.md +1 -1
  9. package/dist/mcp/generated/docs/chat-input.md +3 -2
  10. package/dist/mcp/generated/docs/file-content.md +27 -10
  11. package/dist/mcp/generated/index.json +3 -3
  12. package/dist/mcp/index.js +0 -0
  13. package/package.json +21 -23
  14. package/skills/blueking-chat-x/SKILL.md +0 -139
  15. package/skills/blueking-chat-x/references/_index.md +0 -131
  16. package/skills/blueking-chat-x/references/components/activity-layout.md +0 -134
  17. package/skills/blueking-chat-x/references/components/activity-message.md +0 -486
  18. package/skills/blueking-chat-x/references/components/ai-image.md +0 -230
  19. package/skills/blueking-chat-x/references/components/ai-loading.md +0 -131
  20. package/skills/blueking-chat-x/references/components/ai-prompt-list.md +0 -44
  21. package/skills/blueking-chat-x/references/components/ai-selection.md +0 -439
  22. package/skills/blueking-chat-x/references/components/ai-skill-list.md +0 -73
  23. package/skills/blueking-chat-x/references/components/ai-slash-editor.md +0 -43
  24. package/skills/blueking-chat-x/references/components/ai-slash-input.md +0 -56
  25. package/skills/blueking-chat-x/references/components/ai-slash-menu.md +0 -42
  26. package/skills/blueking-chat-x/references/components/animation-text.md +0 -202
  27. package/skills/blueking-chat-x/references/components/assistant-message.md +0 -498
  28. package/skills/blueking-chat-x/references/components/chat-container.md +0 -869
  29. package/skills/blueking-chat-x/references/components/chat-input.md +0 -769
  30. package/skills/blueking-chat-x/references/components/cite-content.md +0 -142
  31. package/skills/blueking-chat-x/references/components/code-content.md +0 -211
  32. package/skills/blueking-chat-x/references/components/common-error-content.md +0 -73
  33. package/skills/blueking-chat-x/references/components/content-render.md +0 -233
  34. package/skills/blueking-chat-x/references/components/delete-tool.md +0 -191
  35. package/skills/blueking-chat-x/references/components/desc-panel.md +0 -162
  36. package/skills/blueking-chat-x/references/components/detail-section.md +0 -91
  37. package/skills/blueking-chat-x/references/components/execution-summary.md +0 -128
  38. package/skills/blueking-chat-x/references/components/file-artifact-panel.md +0 -289
  39. package/skills/blueking-chat-x/references/components/file-content.md +0 -319
  40. package/skills/blueking-chat-x/references/components/file-icon.md +0 -109
  41. package/skills/blueking-chat-x/references/components/file-upload-btn.md +0 -159
  42. package/skills/blueking-chat-x/references/components/flow-agent-content.md +0 -264
  43. package/skills/blueking-chat-x/references/components/flow-agent-node-detail.md +0 -236
  44. package/skills/blueking-chat-x/references/components/highlight-keyword.md +0 -146
  45. package/skills/blueking-chat-x/references/components/image-content.md +0 -182
  46. package/skills/blueking-chat-x/references/components/image-preview-group.md +0 -184
  47. package/skills/blueking-chat-x/references/components/image-preview.md +0 -226
  48. package/skills/blueking-chat-x/references/components/info-message.md +0 -144
  49. package/skills/blueking-chat-x/references/components/input-attachment.md +0 -49
  50. package/skills/blueking-chat-x/references/components/input-info-alert.md +0 -42
  51. package/skills/blueking-chat-x/references/components/interrupt-message.md +0 -212
  52. package/skills/blueking-chat-x/references/components/key-value-content.md +0 -128
  53. package/skills/blueking-chat-x/references/components/knowledge-rag-content.md +0 -122
  54. package/skills/blueking-chat-x/references/components/latex-content.md +0 -200
  55. package/skills/blueking-chat-x/references/components/loading-message.md +0 -192
  56. package/skills/blueking-chat-x/references/components/markdown-content.md +0 -232
  57. package/skills/blueking-chat-x/references/components/mermaid-content.md +0 -189
  58. package/skills/blueking-chat-x/references/components/message-container.md +0 -645
  59. package/skills/blueking-chat-x/references/components/message-loading.md +0 -118
  60. package/skills/blueking-chat-x/references/components/message-render.md +0 -327
  61. package/skills/blueking-chat-x/references/components/message-time.md +0 -177
  62. package/skills/blueking-chat-x/references/components/message-tools.md +0 -416
  63. package/skills/blueking-chat-x/references/components/model-selector.md +0 -155
  64. package/skills/blueking-chat-x/references/components/preview-toolbar.md +0 -42
  65. package/skills/blueking-chat-x/references/components/questions-container.md +0 -85
  66. package/skills/blueking-chat-x/references/components/reasoning-message.md +0 -232
  67. package/skills/blueking-chat-x/references/components/reference-content.md +0 -135
  68. package/skills/blueking-chat-x/references/components/reference-doc-content.md +0 -109
  69. package/skills/blueking-chat-x/references/components/scroll-btn.md +0 -159
  70. package/skills/blueking-chat-x/references/components/selection-footer.md +0 -78
  71. package/skills/blueking-chat-x/references/components/selection-question.md +0 -88
  72. package/skills/blueking-chat-x/references/components/shortcut-btn.md +0 -204
  73. package/skills/blueking-chat-x/references/components/shortcut-btns.md +0 -266
  74. package/skills/blueking-chat-x/references/components/shortcut-render.md +0 -424
  75. package/skills/blueking-chat-x/references/components/simple-table.md +0 -101
  76. package/skills/blueking-chat-x/references/components/text-content.md +0 -77
  77. package/skills/blueking-chat-x/references/components/tool-approval-card.md +0 -183
  78. package/skills/blueking-chat-x/references/components/tool-btn.md +0 -317
  79. package/skills/blueking-chat-x/references/components/tool-message.md +0 -235
  80. package/skills/blueking-chat-x/references/components/toolcall-render.md +0 -348
  81. package/skills/blueking-chat-x/references/components/user-feedback.md +0 -233
  82. package/skills/blueking-chat-x/references/components/user-message.md +0 -424
  83. package/skills/blueking-chat-x/references/components/user-question-answered-card.md +0 -104
  84. package/skills/blueking-chat-x/references/components/user-question-card.md +0 -231
  85. package/skills/blueking-chat-x/references/components/user-question-choice.md +0 -105
  86. package/skills/blueking-chat-x/references/components/user-question-option.md +0 -42
  87. package/skills/blueking-chat-x/references/components/vnode-renderer.md +0 -122
  88. package/skills/blueking-chat-x/references/composables/use-animation-text.md +0 -196
  89. package/skills/blueking-chat-x/references/composables/use-artifact-preview.md +0 -231
  90. package/skills/blueking-chat-x/references/composables/use-clipboard.md +0 -203
  91. package/skills/blueking-chat-x/references/composables/use-command-selection.md +0 -150
  92. package/skills/blueking-chat-x/references/composables/use-container-scroll.md +0 -57
  93. package/skills/blueking-chat-x/references/composables/use-custom-tab.md +0 -158
  94. package/skills/blueking-chat-x/references/composables/use-flow-node-actions.md +0 -157
  95. package/skills/blueking-chat-x/references/composables/use-full-screen.md +0 -112
  96. package/skills/blueking-chat-x/references/composables/use-global-config.md +0 -148
  97. package/skills/blueking-chat-x/references/composables/use-menu-keydown.md +0 -163
  98. package/skills/blueking-chat-x/references/composables/use-message-group.md +0 -247
  99. package/skills/blueking-chat-x/references/composables/use-observer-visible-list.md +0 -188
  100. package/skills/blueking-chat-x/references/composables/use-parent-scrolling.md +0 -46
  101. package/skills/blueking-chat-x/references/theme/theme.md +0 -431
  102. package/skills/blueking-chat-x/references/types/constants.md +0 -307
  103. package/skills/blueking-chat-x/references/types/interrupt.md +0 -379
  104. package/skills/blueking-chat-x/references/types/messages.md +0 -553
  105. package/skills/blueking-chat-x/references/types/schema.md +0 -91
  106. package/skills/blueking-chat-x/scripts/generate-references.mjs +0 -314
@@ -1,134 +0,0 @@
1
- # ActivityLayout 活动布局
2
-
3
- > 能力域:辅助能力 | 导入:`import { ActivityLayout } from '@blueking/chat-x'` | since 1.0.0
4
-
5
- 活动消息的折叠布局容器,提供 title/default 插槽。 源码位置:src/components/chat-content/activity-layout/activity-layout.vue。
6
-
7
- **关联**:activity-message(活动消息通过本组件承载标题栏与内容区)、knowledge-rag-content(知识召回活动复用本组件展示加载标题与正文)、reference-doc-content(引用文档活动复用本组件展示文档数量与引用列表)、flow-agent-content(FlowAgent 活动复用本组件,但隐藏默认折叠箭头)
8
-
9
- ---
10
-
11
- # ActivityLayout 活动布局
12
-
13
- > **能力域**:辅助能力
14
-
15
- `ActivityLayout` 是活动消息的通用折叠布局容器,负责渲染标题栏、折叠箭头和内容区域。它不关心活动内容类型本身,标题和正文均通过插槽传入,因此常被 `KnowledgeRagContent`、`ReferenceDocContent`、`FlowAgentContent` 等活动组件复用。
16
-
17
- 通常不需要业务侧直接使用;如果要新增一种活动消息内容,可以用它作为标题/内容外壳。
18
-
19
- ## 源码事实
20
-
21
- - **源码位置**:`src/components/chat-content/activity-layout/activity-layout.vue`
22
- - **能力说明**:活动消息的折叠布局容器,提供 `title` / `default` 插槽。
23
-
24
- ## 核心能力
25
-
26
- - **标题栏点击折叠**:点击标题栏切换 `collapsed`,内容区通过 `v-show="!collapsed"` 显示或隐藏
27
- - **双向绑定**:通过 `v-model:collapsed` 让父组件控制展开/收起状态,默认展开
28
- - **标题插槽透传状态**:`title` 插槽会收到 `{ collapsed }`,可根据折叠状态调整标题内容
29
- - **默认折叠箭头**:非 FlowAgent 活动自动在标题右侧显示折叠箭头
30
- - **FlowAgent 特例**:`activityType === MessageContentType.FlowAgent` 时隐藏默认折叠箭头,由 FlowAgent 自己渲染标题交互
31
-
32
- ## 基础用法
33
-
34
- ```vue
35
- <template>
36
- <ActivityLayout v-model:collapsed="collapsed">
37
- <template #title="{ collapsed }">
38
- <span class="ai-activity-message-title-icon">
39
- <DocumentIcon style="font-size: 12px" />
40
- </span>
41
- <span class="ai-activity-message-title-text">
42
- {{ collapsed ? '已折叠' : '引用 2 篇资料作为参考' }}
43
- </span>
44
- </template>
45
-
46
- <div style="padding: 0 14px;">
47
- 活动内容
48
- </div>
49
- </ActivityLayout>
50
- </template>
51
-
52
- <script setup lang="ts">
53
- import { ref } from 'vue';
54
- import ActivityLayout from '@blueking/chat-x/src/components/chat-content/activity-layout/activity-layout.vue';
55
- import { DocumentIcon } from '@blueking/chat-x/src/icons/content';
56
-
57
- const collapsed = ref(false);
58
- </script>
59
- ```
60
-
61
- **渲染效果**
62
-
63
- ## 折叠状态
64
-
65
- `collapsed` 默认为 `false`。设置为 `true` 时只展示标题栏,正文内容保留在 DOM 中但通过 `v-show` 隐藏。
66
-
67
- ## FlowAgent 活动
68
-
69
- 传入 `activityType="flow_agent"` 时,`ActivityLayout` 不渲染右侧默认折叠箭头。该场景下标题栏通常由 `FlowAgentContent` 自己展示状态统计、加载图标和展开箭头。
70
-
71
- ```vue
72
- <ActivityLayout
73
- v-model:collapsed="collapsed"
74
- :activity-type="MessageContentType.FlowAgent"
75
- >
76
- <template #title>
77
- <span>执行情况: 成功 2 / 失败 1</span>
78
- </template>
79
- <div>FlowAgent 节点列表</div>
80
- </ActivityLayout>
81
- ```
82
-
83
- ## 组件结构
84
-
85
- ```
86
- .ai-activity-message
87
- ├── .ai-activity-message-title(点击切换 collapsed)
88
- │ ├── title slot(slot props: { collapsed })
89
- │ └── CollapsedIcon(activityType !== flow_agent 时显示)
90
- └── .ai-activity-message-content(v-show="!collapsed")
91
- └── default slot
92
- ```
93
-
94
- ## API
95
-
96
- ### Props
97
-
98
- | 属性名 | 类型 | 必填 | 默认值 | 说明 |
99
- | ------------ | -------------------- | ---- | ------ | --------------------------------------------- |
100
- | activityType | `MessageContentType` | 否 | — | 活动类型;为 `flow_agent` 时隐藏默认折叠箭头 |
101
-
102
- ### Models
103
-
104
- | 名称 | 类型 | 默认值 | 说明 |
105
- | --------- | --------- | ------- | ---------------- |
106
- | collapsed | `boolean` | `false` | 活动内容是否折叠 |
107
-
108
- ### Emits
109
-
110
- - 无显式 emits;`v-model:collapsed` 会产生 `update:collapsed`。
111
-
112
- ### Slots
113
-
114
- | 插槽名 | 参数 | 说明 |
115
- | ------- | ----------------------- | ---------- |
116
- | title | `{ collapsed: boolean }` | 标题栏内容 |
117
- | default | — | 活动正文 |
118
-
119
- ### Expose
120
-
121
- - 无。
122
-
123
- ## 使用建议
124
-
125
- - 适合作为活动消息内部布局外壳,不建议替代通用卡片、面板或页面 Section。
126
- - 标题栏点击区域会整体触发折叠,标题插槽内如有按钮或链接,需要自行处理事件冒泡。
127
- - `default` 内容使用 `v-show` 控制可见性,折叠时不会卸载内部组件。
128
-
129
- ## 关联组件
130
-
131
- - [ActivityMessage](../message/activity-message.md) — 活动消息分发入口。
132
- - [KnowledgeRagContent](../agent/knowledge-rag-content.md) — 知识召回活动。
133
- - [ReferenceDocContent](../agent/reference-doc-content.md) — 引用文档活动。
134
- - [FlowAgentContent](../agent/flow-agent-content.md) — FlowAgent 执行活动。
@@ -1,486 +0,0 @@
1
- # ActivityMessage 活动消息
2
-
3
- > 能力域:消息系统 | 导入:`import { ActivityMessage } from '@blueking/chat-x'` | since 0.0.20
4
-
5
- 按 activityType 分发 FlowAgent、知识召回、引用文档等活动内容。 源码位置:src/components/chat-message/activity-message/activity-message.vue。
6
-
7
- **关联**:message-render(由 MessageRender 在 role 为 activity 时创建)、flow-agent-content(activityType 为 flow_agent 时渲染)、knowledge-rag-content(activityType 为 knowledge_rag 时渲染)、reference-doc-content(activityType 为 reference_document 时渲染)、chat-container(uid / onInterruptResume / 侧栏 Tab 与 ChatContainer 联动)
8
-
9
- ---
10
-
11
- # ActivityMessage 活动消息
12
-
13
- ## 源码事实
14
-
15
- - **源码位置**:`src/components/chat-message/activity-message/activity-message.vue`
16
- - **能力域**:消息系统
17
- - **能力说明**:按 `activityType` 分发 FlowAgent、知识召回、引用文档等活动内容;未知类型不渲染。
18
-
19
- > **导出说明**:`ActivityMessage` **未**从 `@blueking/chat-x` 包入口导出(入口同名导出是 TS interface)。消费方请通过 `MessageRender` / `MessageContainer` 渲染 `role: 'activity'`。下文带 `*Comp` 的 demo 为文档站内部相对路径示例。
20
-
21
- 活动消息组件,用于展示知识检索(Knowledge RAG)、参考文档引用与 FlowAgent 执行情况。通过 `activityType` 映射到对应子组件;点击标题栏可折叠/展开。
22
-
23
- 组件会将父级传入消息上的 **`uid`** 以 **`message-uid`** 形式透传给各活动子组件(`FlowAgentContent` / `KnowledgeRagContent` / `ReferenceDocContent`),用于侧栏自定义 Tab、`addCustomTab` 的 `data.messageUid` 与主对话区「在对话中定位」联动(详见 [ChatContainer](/components/setup/chat-container))。
24
-
25
- `onInterruptResume` 仅由 `FlowAgentContent` 消费(失败节点「重试 / 跳过」),由 `MessageRender` 从 `ChatContainer` 透传;知识检索、引用文档等活动子组件忽略该 prop。
26
-
27
- ## 三种工作模式
28
-
29
- 组件根据 `activityType` 的值决定渲染模式:
30
-
31
- | `activityType` | 模式 | 标题文案 | 图标 | 内容区 |
32
- | ----------------------- | -------------- | ------------------------------------ | ---------------- | ----------------------------------- |
33
- | `'knowledge_rag'` | 知识检索模式 | 检索中 / 检索完成(随 status 切换) | Loading / 文档 | Markdown 检索摘要 + 引用列表 |
34
- | `'flow_agent'` | FlowAgent 模式 | 执行情况: 成功 N / 失败 N / 执行中 N | Loading / 箭头 | 任务节点树 + 节点详情(自定义 Tab) |
35
- | `'reference_document'` | 引用文档模式 | 引用 N 篇资料作为参考 | 文档图标(固定) | 引用文档列表 |
36
- | 其他未映射值 | — | — | — | **不渲染**(`activityComponent` 为 falsy) |
37
-
38
- > **注意:** 源码仅映射上述三种 `MessageContentType`;`activityType` 缺失或未知时组件输出为空。
39
-
40
- ## 引用文档模式
41
-
42
- `activityType` 必须为 `MessageContentType.ReferenceDocument`(`'reference_document'`),`content` 传入文档对象数组。
43
-
44
- 标题自动显示文档数量,始终展示文档图标,`status` 不影响标题和图标。
45
-
46
- ```vue
47
- <!-- 消费方:经 MessageRender 渲染 -->
48
- <template>
49
- <MessageRender :message="message" />
50
- </template>
51
-
52
- <script setup lang="ts">
53
- import { MessageRender, MessageContentType, MessageRole, MessageStatus } from '@blueking/chat-x';
54
-
55
- const message = {
56
- id: '2',
57
- messageId: '2',
58
- role: MessageRole.Activity,
59
- activityType: MessageContentType.ReferenceDocument,
60
- status: MessageStatus.Complete,
61
- uid: 'activity-ref-1',
62
- content: [
63
- {
64
- name: 'Vue 3 组合式 API 指南',
65
- url: 'https://cn.vuejs.org/guide/extras/composition-api-faq.html',
66
- originFile: 'composition-api.md',
67
- },
68
- { name: 'TypeScript 高级类型手册', url: 'https://www.typescriptlang.org/docs/', originFile: 'ts-advanced.pdf' },
69
- ],
70
- };
71
- </script>
72
- ```
73
-
74
- **渲染效果**
75
-
76
- ## 知识检索模式
77
-
78
- `activityType` 设为 `MessageContentType.KnowledgeRag`(`'knowledge_rag'`),`content` 传入包含 `content`(检索摘要)和 `referenceDocument`(引用文档列表)的对象。
79
-
80
- 标题和图标随 `status` 动态变化:
81
-
82
- | `status` | 图标 | 标题 |
83
- | ----------------------- | -------- | -------- |
84
- | `pending` / `streaming` | Loading | 检索中 |
85
- | 其他(`complete` 等) | 文档图标 | 检索完成 |
86
-
87
- ```vue
88
- <template>
89
- <MessageRender :message="message" />
90
- </template>
91
-
92
- <script setup lang="ts">
93
- import { MessageRender, MessageContentType, MessageRole, MessageStatus } from '@blueking/chat-x';
94
-
95
- const message = {
96
- id: '1',
97
- messageId: '1',
98
- role: MessageRole.Activity,
99
- activityType: MessageContentType.KnowledgeRag,
100
- status: MessageStatus.Complete,
101
- uid: 'activity-rag-1',
102
- content: {
103
- content: '根据知识库检索,Vue 3 引入了 Composition API...',
104
- referenceDocument: [
105
- { name: '知识库文档:Composition API 详解', url: 'https://example.com/kb1', originFile: 'kb1.md' },
106
- ],
107
- },
108
- };
109
- </script>
110
- ```
111
-
112
- **渲染效果(检索完成 + 单引用)**
113
-
114
- **渲染效果(检索完成 + 多引用 + Markdown 摘要)**
115
-
116
- ## 状态变化(知识检索模式)
117
-
118
- `knowledge_rag` 模式下,`status` 决定图标和标题文案:
119
-
120
- **检索中(`pending`)**
121
-
122
- **检索中(`streaming`)**
123
-
124
- **检索完成(`complete`)**
125
-
126
- > **引用文档模式**不受 `status` 影响,始终显示文档图标和文档数量,不会出现 Loading 动画。
127
-
128
- ## 折叠/展开
129
-
130
- 通过 `v-model:collapsed` 控制内容区的折叠状态,点击整个标题栏均可切换。默认为 `false`(展开)。
131
-
132
- 文档站内部示例(相对路径引入组件本体)可通过 `v-model:collapsed` 控制;消费方一般不直接绑定,折叠状态由活动子组件内部管理。
133
-
134
- ```vue
135
- <!-- 文档站内部示例 -->
136
- <ActivityMessageComp
137
- v-model:collapsed="collapsed"
138
- :content="docs"
139
- status="complete"
140
- activity-type="reference_document"
141
- />
142
- ```
143
-
144
- ```ts
145
- const collapsed = ref(false); // false = 展开,true = 折叠
146
- ```
147
-
148
- **渲染效果(展开状态)**
149
-
150
- **渲染效果(折叠状态)**
151
-
152
- ## FlowAgent 执行情况模式
153
-
154
- `activityType` 设为 `MessageContentType.FlowAgent`(`'flow_agent'`),`content` 传入 `BkFlowMessageContent` 任务数组。用于展示一个或多个蓝鲸标准运维(BkFlow)任务的执行状态、节点列表和统计信息。
155
-
156
- ### 核心交互
157
-
158
- - **标题栏**:显示「执行情况」+ 所有任务聚合后的各状态计数(执行中 / 成功 / 失败 / 挂起),颜色区分
159
- - **任务组**:逐个展示任务行,带状态图标、总耗时;点击箭头图标可折叠/展开节点列表
160
- - **有效证据**:`task.has_confidence === true` 时,任务行右侧展示「有效证据」按钮,点击后在侧栏打开置信度/证据详情 Tab(`props.has_confidence: true`)
161
- - **默认激活**:当 `MessageContainer` 已注入滚动上下文(`useContainerScrollProvider`,供 `FlowAgentContent` 内 `useContainerScrollConsumer` 读取)时,组件挂载后若存在 `task.is_active === true` 且 `task.has_confidence === true` 的任务,会自动在侧栏打开该任务的「有效证据」Tab;无滚动 Provider(例如独立演示)时不做自动打开。用户手动切换 Tab 后不再沿用 `is_active` 默认高亮
162
- - **选中态**:当前侧栏 Tab 与任务行 / 节点行联动高亮(`is-selected`);任务 Tab 与「有效证据」Tab 均视为该任务的选中态
163
- - **节点列表**:每个节点显示状态圆点、名称和耗时;hover 时出现行尾操作按钮组
164
- - **失败节点操作**:失败且 `retryable` / `skippable` 为 `true` 的节点,hover 时额外展示「重试」「跳过」按钮,点击后通过 `onInterruptResume` 回传 Agent(不传 `interrupt`)
165
- - **节点详情**:点击「详情」会通过 `useCustomTabConsumer` 在 `ChatContainer` 侧边栏新增自定义 Tab,展示节点配置(基础信息、输入参数、输出参数)
166
-
167
- > `FlowAgentContent` 会读取 `ChatContainer` 注入的 `renderMode`。当 `renderMode === RenderMode.Share` 时,任务行不展示总耗时与「有效证据」,节点列表不展示耗时与「详情」按钮,避免分享预览中出现可交互入口。独立使用 `ActivityMessage` 且没有上层 Provider 时,默认按 `Chat` 模式渲染。
168
-
169
- ### 内部渲染结构
170
-
171
- ```
172
- FlowAgentContent(activityType = 'flow_agent')
173
- ├── ActivityLayout(公共折叠布局容器)
174
- │ └── #title
175
- │ ├── Loading / ArrowIcon(随 status 切换)
176
- │ └── 执行情况:执行中 N / 成功 N / 失败 N / 挂起 N
177
- └── #default
178
- └── TaskGroup × N
179
- ├── TaskHeader(is-selected / has-confidence;箭头点击折叠)
180
- │ ├── 状态图标(running=Loading / success / failed / suspended)
181
- │ ├── task_name(HighlightKeyword 支持搜索高亮)
182
- │ └── trailing:总耗时 + 「有效证据」(has_confidence 时)
183
- └── NodeList
184
- └── NodeItem × N(is-selected 与侧栏 Tab 联动)
185
- ├── 状态圆点(颜色对应状态)
186
- ├── node.name(HighlightKeyword 支持搜索高亮)
187
- ├── node.elapsed_time
188
- └── 行尾操作按钮组(hover 显示)
189
- ├── 重试(失败 + retryable)→ onInterruptResume
190
- ├── 跳过(失败 + skippable)→ onInterruptResume
191
- └── 详情 → 打开节点详情 Tab
192
- ```
193
-
194
- ### 用法示例
195
-
196
- ```vue
197
- <template>
198
- <MessageRender
199
- :message="message"
200
- :on-interrupt-resume="handleInterruptResume"
201
- />
202
- </template>
203
-
204
- <script setup lang="ts">
205
- import { MessageRender, MessageContentType, MessageRole, MessageStatus } from '@blueking/chat-x';
206
- import type { BkFlowMessageContent, OnInterruptResume } from '@blueking/chat-x';
207
-
208
- const flowContent: BkFlowMessageContent = [
209
- {
210
- task_id: 100,
211
- task_name: '数据清洗流程',
212
- task_state: 'FINISHED',
213
- task_outputs: [],
214
- statistics: {
215
- total: 3,
216
- state_counts: { FINISHED: 2, FAILED: 1 },
217
- },
218
- nodes: {
219
- node1: {
220
- id: 'node1',
221
- name: '数据拉取',
222
- state: 'FINISHED',
223
- elapsed_time: 12,
224
- start_time: '2025-01-01 10:00:00',
225
- finish_time: '2025-01-01 10:00:12',
226
- loop: 1,
227
- retry: 0,
228
- skip: false,
229
- type: 'ServiceActivity',
230
- },
231
- node3: {
232
- id: 'node3',
233
- name: '结果写入',
234
- state: 'FAILED',
235
- elapsed_time: 3,
236
- start_time: '2025-01-01 10:00:57',
237
- finish_time: '2025-01-01 10:01:00',
238
- loop: 1,
239
- retry: 0,
240
- skip: false,
241
- retryable: true,
242
- skippable: true,
243
- type: 'ServiceActivity',
244
- },
245
- },
246
- },
247
- ];
248
-
249
- const message = {
250
- id: '3',
251
- messageId: '3',
252
- role: MessageRole.Activity,
253
- activityType: MessageContentType.FlowAgent,
254
- status: MessageStatus.Complete,
255
- uid: 'activity-flow-1',
256
- content: flowContent,
257
- };
258
-
259
- const handleInterruptResume: OnInterruptResume = async payload => {
260
- console.log('节点重试/跳过', payload);
261
- };
262
- </script>
263
- ```
264
-
265
- ## 未知 activityType(不渲染)
266
-
267
- 未映射的 `activityType` 不会回退到引用文档模式,组件直接不渲染:
268
-
269
- ```vue
270
- <template>
271
- <MessageRender :message="message" />
272
- <!-- 页面上无任何活动内容输出 -->
273
- </template>
274
-
275
- <script setup lang="ts">
276
- import { MessageRender, MessageRole, MessageStatus } from '@blueking/chat-x';
277
-
278
- const message = {
279
- id: 'x',
280
- messageId: 'x',
281
- role: MessageRole.Activity,
282
- activityType: 'unknown_activity',
283
- status: MessageStatus.Complete,
284
- content: [{ name: '不会展示', url: '#', originFile: 'a.md' }],
285
- };
286
- </script>
287
- ```
288
-
289
- ### 在 MessageContainer 中自动渲染
290
-
291
- ```typescript
292
- const messages = [
293
- {
294
- id: '3',
295
- role: 'activity',
296
- activityType: MessageContentType.FlowAgent, // 'flow_agent'
297
- status: MessageStatus.Streaming,
298
- content: [
299
- {
300
- task_id: 100,
301
- task_name: '数据清洗流程',
302
- task_state: 'RUNNING',
303
- task_outputs: [],
304
- statistics: { total: 3, state_counts: { RUNNING: 1, FINISHED: 2 } },
305
- nodes: {
306
- /* ... */
307
- },
308
- },
309
- ],
310
- },
311
- ];
312
- ```
313
-
314
- ### 节点状态映射
315
-
316
- 组件内部将 BkFlow 原始状态归并为四种显示状态:
317
-
318
- | 归并状态 | 原始状态 | 颜色 |
319
- | ----------- | ----------------------------------------------------------------------------------- | ------- |
320
- | `running` | CREATED / LOOP_READY / READY / RUNNING / BLOCKED / ROLLING_BACK / ROLL_BACK_SUCCESS | #3A84FF |
321
- | `success` | FINISHED | #18B456 |
322
- | `failed` | FAILED / REVOKED / ROLL_BACK_FAILED | #EA3636 |
323
- | `suspended` | SUSPENDED | #F59500 |
324
- | `pending` | PENDING | #DCDEE5 |
325
-
326
- ### 侧栏 Tab 命名规则
327
-
328
- | 场景 | `tab.name` 格式 |
329
- | ---------- | ---------------------------------------- |
330
- | 任务详情 | `{task_id}` |
331
- | 有效证据 | `{task_id}`(与任务 Tab 同名,label 为「有效证据」,`order: 10` 固定排在「执行情况」之后、节点详情之前) |
332
- | 节点详情 | `{task_id}\|{node.id}\|{node.name}` |
333
-
334
- `CustomBkFlowTabData` 支持 `has_confidence?: boolean`,用于侧栏详情组件区分证据视图与节点视图。应用层可通过 `ChatContainer` 的 `getSideRenderComponent` 覆盖渲染组件。
335
-
336
- ### 节点详情 Tab
337
-
338
- 点击节点的「详情」按钮,内部调用 `useCustomTabConsumer().addCustomTab()` 在 `ChatContainer` 侧边栏新开一个 Tab,渲染 `BkFlowNodeDetail`(或 `getSideRenderComponent` 返回的自定义组件),该组件提供:
339
-
340
- - **节点配置** Tab:基础信息表单(流程模板、节点名称、步骤名称、失败处理、超时控制)+ 输入参数表 + 输出参数表
341
- - **节点输出** Tab:结构化输出参数表
342
- - **骨架屏**:`loading` 为 `true` 时展示骨架屏占位
343
-
344
- ### 相关类型定义
345
-
346
- ```typescript
347
- import { MessageContentType, type BkFlowMessageContent, type BkFlowNode, type BkFlowTask } from '@blueking/chat-x';
348
-
349
- type BkFlowMessageContent = BkFlowTask[];
350
-
351
- type BkFlowTask = {
352
- has_confidence?: boolean; // 是否展示「有效证据」入口;与 is_active 同时为 true 且在消息容器滚动上下文中时,挂载后自动打开「有效证据」侧栏 Tab
353
- is_active?: boolean; // 是否默认激活;需配合 has_confidence 且存在滚动 Provider 才会自动打开侧栏「有效证据」Tab
354
- nodes: Record<string, BkFlowNode>;
355
- statistics: { state_counts: Record<string, number>; total: number };
356
- task_id: number;
357
- task_name: string;
358
- task_outputs: unknown;
359
- task_state: string;
360
- };
361
-
362
- type BkFlowNode = {
363
- elapsed_time: number;
364
- finish_time: string;
365
- id: string;
366
- loop: number;
367
- name: string;
368
- retry: number;
369
- retryable?: boolean;
370
- skip: boolean;
371
- skippable?: boolean;
372
- start_time: string;
373
- state: string;
374
- type: string;
375
- };
376
-
377
- enum MessageContentType {
378
- FlowAgent = 'flow_agent',
379
- KnowledgeRag = 'knowledge_rag',
380
- ReferenceDocument = 'reference_document',
381
- // ...
382
- }
383
- ```
384
-
385
- ## 在 MessageContainer 中使用
386
-
387
- `ActivityMessage` 通常不需要单独使用,`MessageContainer` 会对 `role: 'activity'` 的消息自动渲染:
388
-
389
- ```vue
390
- <template>
391
- <MessageContainer :messages="messages" />
392
- </template>
393
-
394
- <script setup lang="ts">
395
- import { MessageContainer, MessageContentType, MessageStatus } from '@blueking/chat-x';
396
-
397
- const messages = [
398
- // 知识检索消息
399
- {
400
- id: '1',
401
- role: 'activity',
402
- activityType: MessageContentType.KnowledgeRag, // 'knowledge_rag'
403
- status: MessageStatus.Complete,
404
- content: {
405
- content: '根据知识库检索到以下相关信息...',
406
- referenceDocument: [{ name: '文档A', url: 'https://example.com/a', originFile: 'a.md' }],
407
- },
408
- },
409
- // 引用文档消息
410
- {
411
- id: '2',
412
- role: 'activity',
413
- activityType: MessageContentType.ReferenceDocument, // 'reference_document'
414
- status: MessageStatus.Complete,
415
- content: [
416
- { name: '参考文档1', url: 'https://example.com/doc1', originFile: 'doc1.pdf' },
417
- { name: '参考文档2', url: 'https://example.com/doc2', originFile: 'doc2.pdf' },
418
- ],
419
- },
420
- ];
421
- </script>
422
- ```
423
-
424
- ## API
425
-
426
- ### Props
427
-
428
- | 属性名 | 类型 | 默认值 | 说明 |
429
- | ----------------- | --------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------- |
430
- | content | `ReferenceDocumentContent[] \| KnowledgeRagContent \| BkFlowMessageContent` | - | 内容数据,格式随 `activityType` 不同 |
431
- | activityType | `'knowledge_rag' \| 'flow_agent' \| 'reference_document' \| string` | - | 活动类型;仅三种已知值会渲染,其余不渲染 |
432
- | status | `MessageStatus` | - | `knowledge_rag` 影响标题/图标;`flow_agent` 影响标题 Loading |
433
- | id | `string \| number` | - | 消息 ID |
434
- | messageId | `string \| number` | - | 消息唯一标识 |
435
- | uid | `string` | - | 透传为子组件 `message-uid`,用于侧栏 Tab / 「在对话中定位」 |
436
- | onInterruptResume | `OnInterruptResume` | - | 仅 `flow_agent` 子组件消费;失败节点「重试 / 跳过」,由 `MessageRender` 透传 |
437
-
438
- ### v-model
439
-
440
- | 属性名 | 类型 | 默认值 | 说明 |
441
- | --------- | --------- | ------- | --------------------------- |
442
- | collapsed | `boolean` | `false` | 内容折叠状态,`true` 为折叠 |
443
-
444
- ### Events / Slots / Expose
445
-
446
- 无。
447
-
448
- ## 类型定义
449
-
450
- ```typescript
451
- import { MessageContentType } from '@blueking/chat-x';
452
-
453
- // 引用文档条目
454
- type ReferenceDocumentContent = {
455
- name: string; // 文档名称(显示文本)
456
- url: string; // 文档访问链接
457
- originFile: string; // 原始文件名
458
- };
459
-
460
- // 知识检索内容(knowledge_rag 模式)
461
- interface KnowledgeRagContent {
462
- content: string; // 检索摘要,支持 Markdown
463
- referenceDocument: ReferenceDocumentContent[]; // 引用文档列表
464
- }
465
-
466
- // activityType 枚举值
467
- enum MessageContentType {
468
- FlowAgent = 'flow_agent',
469
- KnowledgeRag = 'knowledge_rag',
470
- ReferenceDocument = 'reference_document',
471
- // ...
472
- }
473
- ```
474
-
475
- ## 使用场景
476
-
477
- - **知识检索过程**:以 `knowledge_rag` 模式展示 RAG 检索全过程,从"检索中"到"检索完成"的状态流转
478
- - **参考资料引用**:以 `reference_document` 模式展示 AI 回复所引用的参考文档列表
479
- - **FlowAgent 执行监控**:以 `flow_agent` 模式展示 BkFlow 流程执行状态、节点列表和详情
480
- - **流式场景**:`pending` → `streaming` → `complete` 状态变化配合流式响应实时更新
481
- - **自动渲染**:通过 `MessageContainer` 或 `MessageRender` 自动处理 `role: 'activity'` 消息,无需手动引入
482
-
483
- ## 关联组件
484
-
485
- - [MessageRender](/components/message/message-render) — activity 角色由其实例化
486
- - [AssistantMessage](/components/message/assistant-message) — 常与助手主回复配合出现