@blueking/chat-x 0.0.51 → 0.0.52-dev.2
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/README.md +15 -8
- package/dist/ag-ui/types/contents.d.ts +2 -0
- package/dist/ag-ui/types/messages.d.ts +6 -1
- package/dist/common/constants.d.ts +2 -0
- package/dist/components/ai-buttons/add-menu-btn/add-menu-btn.vue.d.ts +24 -0
- package/dist/components/chat-content/collapsible-content/collapsible-content.vue.d.ts +28 -0
- package/dist/components/chat-content/file-content/upload-file-item.vue.d.ts +5 -2
- package/dist/components/chat-content/file-content/upload-image-item.vue.d.ts +1 -0
- package/dist/components/chat-content/flow-agent-content/use-flow-node-actions.d.ts +1 -1
- package/dist/components/chat-input/ai-slash-input/ai-slash-input.vue.d.ts +21 -10
- package/dist/components/chat-input/ai-slash-input/command.d.ts +6 -3
- package/dist/components/chat-input/ai-slash-input/constants.d.ts +2 -0
- package/dist/components/chat-input/ai-slash-input/use-menu-trigger.d.ts +17 -0
- package/dist/components/chat-input/build-default-placeholder.d.ts +9 -3
- package/dist/components/chat-input/chat-input.vue.d.ts +30 -18
- package/dist/components/chat-input/input-menu/constants.d.ts +60 -0
- package/dist/components/chat-input/input-menu/index.d.ts +4 -0
- package/dist/components/chat-input/input-menu/input-menu-option.vue.d.ts +14 -0
- package/dist/components/chat-input/input-menu/input-menu-panel.vue.d.ts +17 -0
- package/dist/components/chat-input/input-menu/use-input-menu.d.ts +22 -0
- package/dist/components/chat-input/model-selector/types.d.ts +3 -2
- package/dist/components/chat-message/message-container/message-container.vue.d.ts +1 -1
- package/dist/components/chat-message/user-message/user-message.vue.d.ts +1 -1
- package/dist/components/mention/create-mention-tippy.d.ts +27 -0
- package/dist/components/mention/index.d.ts +4 -0
- package/dist/components/{chat-input/ai-slash-input/ai-prompt-list/ai-prompt-list.vue.d.ts → mention/mention-popover.vue.d.ts} +3 -2
- package/dist/components/{chat-input/ai-slash-input/ai-skill-list/ai-skill-list.vue.d.ts → mention/mention-tag.vue.d.ts} +7 -3
- package/dist/components/{chat-input/ai-slash-input/ai-slash-menu/ai-slash-menu.vue.d.ts → mention/mention-text.vue.d.ts} +3 -3
- package/dist/components/resource-icon/index.d.ts +1 -0
- package/dist/components/resource-icon/resource-icon.vue.d.ts +11 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/use-artifact-preview.d.ts +5 -2
- package/dist/composables/use-common.d.ts +0 -9
- package/dist/composables/use-global-config.d.ts +4 -0
- package/dist/composables/use-input-mention.d.ts +13 -0
- package/dist/composables/use-message-group.d.ts +1011 -72
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/input.d.ts +21 -0
- package/dist/icons/menu-item.d.ts +22 -0
- package/dist/index.css +1 -1
- package/dist/index.js +5116 -4595
- package/dist/index.js.map +1 -1
- package/dist/lang/lang.d.ts +13 -3
- package/dist/mcp/generated/docs/activity-message.md +3 -3
- package/dist/mcp/generated/docs/add-menu-btn.md +91 -0
- package/dist/mcp/generated/docs/ai-selection.md +1 -1
- package/dist/mcp/generated/docs/ai-slash-input.md +72 -26
- package/dist/mcp/generated/docs/assistant-message.md +7 -1
- package/dist/mcp/generated/docs/chat-container.md +45 -6
- package/dist/mcp/generated/docs/chat-input.md +327 -483
- package/dist/mcp/generated/docs/collapsible-content.md +78 -0
- package/dist/mcp/generated/docs/constants.md +36 -3
- package/dist/mcp/generated/docs/execution-summary.md +1 -23
- package/dist/mcp/generated/docs/file-artifact-panel.md +24 -5
- package/dist/mcp/generated/docs/file-content.md +4 -0
- package/dist/mcp/generated/docs/file-upload-btn.md +15 -12
- package/dist/mcp/generated/docs/flow-agent-content.md +10 -12
- package/dist/mcp/generated/docs/input-menu-panel.md +166 -0
- package/dist/mcp/generated/docs/mention-tag.md +83 -0
- package/dist/mcp/generated/docs/mention-text.md +86 -0
- package/dist/mcp/generated/docs/message-container.md +1 -1
- package/dist/mcp/generated/docs/message-render.md +1 -1
- package/dist/mcp/generated/docs/message-tools.md +15 -4
- package/dist/mcp/generated/docs/messages.md +3 -0
- package/dist/mcp/generated/docs/model-selector.md +4 -2
- package/dist/mcp/generated/docs/overflow-tips.md +3 -3
- package/dist/mcp/generated/docs/resource-icon.md +102 -0
- package/dist/mcp/generated/docs/text-content.md +7 -3
- package/dist/mcp/generated/docs/theme.md +27 -35
- package/dist/mcp/generated/docs/use-artifact-preview.md +7 -3
- package/dist/mcp/generated/docs/use-command-selection.md +1 -1
- package/dist/mcp/generated/docs/use-container-scroll.md +2 -1
- package/dist/mcp/generated/docs/use-flow-node-actions.md +8 -15
- package/dist/mcp/generated/docs/use-global-config.md +11 -4
- package/dist/mcp/generated/docs/use-input-mention.md +119 -0
- package/dist/mcp/generated/docs/use-menu-keydown.md +15 -16
- package/dist/mcp/generated/docs/use-message-group.md +3 -6
- package/dist/mcp/generated/docs/user-message.md +39 -17
- package/dist/mcp/generated/index.json +233 -81
- package/dist/types/editor.d.ts +0 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/input-menu.d.ts +46 -0
- package/dist/utils/artifact-tags.d.ts +36 -0
- package/dist/utils/collect-message-artifacts.d.ts +14 -0
- package/dist/utils/file.d.ts +3 -3
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/upload-file.d.ts +6 -1
- package/package.json +4 -3
- package/skills/blueking-chat-x/SKILL.md +143 -0
- package/skills/blueking-chat-x/references/_index.md +153 -0
- package/skills/blueking-chat-x/references/components/activity-layout.md +134 -0
- package/skills/blueking-chat-x/references/components/activity-message.md +486 -0
- package/skills/blueking-chat-x/references/components/add-menu-btn.md +88 -0
- package/skills/blueking-chat-x/references/components/ai-image.md +230 -0
- package/skills/blueking-chat-x/references/components/ai-loading.md +131 -0
- package/skills/blueking-chat-x/references/components/ai-selection.md +439 -0
- package/skills/blueking-chat-x/references/components/ai-slash-input.md +102 -0
- package/skills/blueking-chat-x/references/components/animation-text.md +202 -0
- package/skills/blueking-chat-x/references/components/assistant-message.md +504 -0
- package/skills/blueking-chat-x/references/components/chat-container.md +912 -0
- package/skills/blueking-chat-x/references/components/chat-input.md +614 -0
- package/skills/blueking-chat-x/references/components/cite-content.md +142 -0
- package/skills/blueking-chat-x/references/components/code-content.md +211 -0
- package/skills/blueking-chat-x/references/components/collapsible-content.md +76 -0
- package/skills/blueking-chat-x/references/components/common-error-content.md +73 -0
- package/skills/blueking-chat-x/references/components/content-render.md +233 -0
- package/skills/blueking-chat-x/references/components/delete-tool.md +191 -0
- package/skills/blueking-chat-x/references/components/desc-panel.md +162 -0
- package/skills/blueking-chat-x/references/components/detail-section.md +91 -0
- package/skills/blueking-chat-x/references/components/execution-summary.md +150 -0
- package/skills/blueking-chat-x/references/components/file-artifact-panel.md +307 -0
- package/skills/blueking-chat-x/references/components/file-content.md +340 -0
- package/skills/blueking-chat-x/references/components/file-icon.md +109 -0
- package/skills/blueking-chat-x/references/components/file-upload-btn.md +162 -0
- package/skills/blueking-chat-x/references/components/flow-agent-content.md +266 -0
- package/skills/blueking-chat-x/references/components/flow-agent-node-detail.md +236 -0
- package/skills/blueking-chat-x/references/components/highlight-keyword.md +146 -0
- package/skills/blueking-chat-x/references/components/image-content.md +182 -0
- package/skills/blueking-chat-x/references/components/image-preview-group.md +184 -0
- package/skills/blueking-chat-x/references/components/image-preview.md +226 -0
- package/skills/blueking-chat-x/references/components/info-message.md +144 -0
- package/skills/blueking-chat-x/references/components/input-attachment.md +49 -0
- package/skills/blueking-chat-x/references/components/input-info-alert.md +42 -0
- package/skills/blueking-chat-x/references/components/input-menu-panel.md +162 -0
- package/skills/blueking-chat-x/references/components/interrupt-message.md +212 -0
- package/skills/blueking-chat-x/references/components/key-value-content.md +128 -0
- package/skills/blueking-chat-x/references/components/knowledge-rag-content.md +122 -0
- package/skills/blueking-chat-x/references/components/latex-content.md +200 -0
- package/skills/blueking-chat-x/references/components/loading-message.md +192 -0
- package/skills/blueking-chat-x/references/components/markdown-content.md +232 -0
- package/skills/blueking-chat-x/references/components/mention-tag.md +79 -0
- package/skills/blueking-chat-x/references/components/mention-text.md +83 -0
- package/skills/blueking-chat-x/references/components/mermaid-content.md +189 -0
- package/skills/blueking-chat-x/references/components/message-container.md +645 -0
- package/skills/blueking-chat-x/references/components/message-loading.md +118 -0
- package/skills/blueking-chat-x/references/components/message-render.md +327 -0
- package/skills/blueking-chat-x/references/components/message-time.md +177 -0
- package/skills/blueking-chat-x/references/components/message-tools.md +427 -0
- package/skills/blueking-chat-x/references/components/model-selector.md +157 -0
- package/skills/blueking-chat-x/references/components/preview-toolbar.md +42 -0
- package/skills/blueking-chat-x/references/components/questions-container.md +85 -0
- package/skills/blueking-chat-x/references/components/reasoning-message.md +232 -0
- package/skills/blueking-chat-x/references/components/reference-content.md +135 -0
- package/skills/blueking-chat-x/references/components/reference-doc-content.md +109 -0
- package/skills/blueking-chat-x/references/components/resource-icon.md +98 -0
- package/skills/blueking-chat-x/references/components/scroll-btn.md +159 -0
- package/skills/blueking-chat-x/references/components/selection-footer.md +78 -0
- package/skills/blueking-chat-x/references/components/selection-question.md +88 -0
- package/skills/blueking-chat-x/references/components/shortcut-btn.md +204 -0
- package/skills/blueking-chat-x/references/components/shortcut-btns.md +266 -0
- package/skills/blueking-chat-x/references/components/shortcut-render.md +424 -0
- package/skills/blueking-chat-x/references/components/simple-table.md +101 -0
- package/skills/blueking-chat-x/references/components/text-content.md +80 -0
- package/skills/blueking-chat-x/references/components/tool-approval-card.md +183 -0
- package/skills/blueking-chat-x/references/components/tool-btn.md +317 -0
- package/skills/blueking-chat-x/references/components/tool-message.md +235 -0
- package/skills/blueking-chat-x/references/components/toolcall-render.md +348 -0
- package/skills/blueking-chat-x/references/components/user-feedback.md +233 -0
- package/skills/blueking-chat-x/references/components/user-message.md +444 -0
- package/skills/blueking-chat-x/references/components/user-question-answered-card.md +104 -0
- package/skills/blueking-chat-x/references/components/user-question-card.md +231 -0
- package/skills/blueking-chat-x/references/components/user-question-choice.md +105 -0
- package/skills/blueking-chat-x/references/components/user-question-option.md +42 -0
- package/skills/blueking-chat-x/references/components/vnode-renderer.md +122 -0
- package/skills/blueking-chat-x/references/composables/use-animation-text.md +196 -0
- package/skills/blueking-chat-x/references/composables/use-artifact-preview.md +235 -0
- package/skills/blueking-chat-x/references/composables/use-clipboard.md +203 -0
- package/skills/blueking-chat-x/references/composables/use-command-selection.md +150 -0
- package/skills/blueking-chat-x/references/composables/use-container-scroll.md +57 -0
- package/skills/blueking-chat-x/references/composables/use-custom-tab.md +158 -0
- package/skills/blueking-chat-x/references/composables/use-flow-node-actions.md +164 -0
- package/skills/blueking-chat-x/references/composables/use-full-screen.md +112 -0
- package/skills/blueking-chat-x/references/composables/use-global-config.md +155 -0
- package/skills/blueking-chat-x/references/composables/use-input-mention.md +115 -0
- package/skills/blueking-chat-x/references/composables/use-menu-keydown.md +161 -0
- package/skills/blueking-chat-x/references/composables/use-message-group.md +244 -0
- package/skills/blueking-chat-x/references/composables/use-observer-visible-list.md +188 -0
- package/skills/blueking-chat-x/references/composables/use-parent-scrolling.md +46 -0
- package/skills/blueking-chat-x/references/directives/index.md +61 -0
- package/skills/blueking-chat-x/references/directives/overflow-tips.md +205 -0
- package/skills/blueking-chat-x/references/icons/index.md +185 -0
- package/skills/blueking-chat-x/references/plugins/index.md +56 -0
- package/skills/blueking-chat-x/references/plugins/markdown-container.md +55 -0
- package/skills/blueking-chat-x/references/plugins/markdown-latex.md +205 -0
- package/skills/blueking-chat-x/references/plugins/markdown-mermaid.md +247 -0
- package/skills/blueking-chat-x/references/theme/theme.md +423 -0
- package/skills/blueking-chat-x/references/types/constants.md +340 -0
- package/skills/blueking-chat-x/references/types/index.md +120 -0
- package/skills/blueking-chat-x/references/types/interrupt.md +379 -0
- package/skills/blueking-chat-x/references/types/messages.md +556 -0
- package/skills/blueking-chat-x/references/types/schema.md +91 -0
- package/skills/blueking-chat-x/references/utils/index.md +196 -0
- package/skills/blueking-chat-x/scripts/generate-references.mjs +536 -0
- package/dist/components/chat-input/ai-slash-editor/ai-slash-editor.vue.d.ts +0 -28
- package/dist/components/chat-input/ai-slash-editor/theme.d.ts +0 -24
- package/dist/mcp/generated/docs/ai-prompt-list.md +0 -45
- package/dist/mcp/generated/docs/ai-skill-list.md +0 -75
- package/dist/mcp/generated/docs/ai-slash-editor.md +0 -43
- package/dist/mcp/generated/docs/ai-slash-menu.md +0 -42
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
# 消息类型
|
|
2
|
+
|
|
3
|
+
> since 1.0.0
|
|
4
|
+
|
|
5
|
+
文档说明 Message 联合类型、BaseMessage、MessageRole、MessageStatus、User/Assistant/Tool/Activity/Reasoning 等具体形态及 MessageContentType。 业务构造 messages 数组供 ChatContainer/MessageContainer 渲染;Tool 消息经 useMessageGroup 注入 Assistant。可声明合并扩展 AIBluekingMessageMap。
|
|
6
|
+
|
|
7
|
+
**关联**:message-container(列表渲染与工具栏)、message-render(按 role 分发渲染)、chat-container(数据源与交互入口)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# 消息类型
|
|
12
|
+
|
|
13
|
+
> **分类**:type
|
|
14
|
+
|
|
15
|
+
`@blueking/chat-x` 提供了完整的消息类型定义,用于构建 AI 对话消息。
|
|
16
|
+
|
|
17
|
+
## 消息基础类型
|
|
18
|
+
|
|
19
|
+
### Message
|
|
20
|
+
|
|
21
|
+
所有消息类型的联合类型:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
type Message = MessageMap[MessageType];
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### BaseMessage
|
|
28
|
+
|
|
29
|
+
消息基础接口:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
interface BaseMessage<T extends MessageType, C = string> {
|
|
33
|
+
// 消息唯一 ID(客户端生成)
|
|
34
|
+
id: number | string;
|
|
35
|
+
|
|
36
|
+
// 消息 ID(服务端返回)
|
|
37
|
+
messageId: number | string;
|
|
38
|
+
|
|
39
|
+
// 消息角色
|
|
40
|
+
role: T;
|
|
41
|
+
|
|
42
|
+
// 消息内容
|
|
43
|
+
content: C;
|
|
44
|
+
|
|
45
|
+
// 消息状态
|
|
46
|
+
status: MessageStatus;
|
|
47
|
+
|
|
48
|
+
// 可选:单条消息实例唯一标识(`useMessageGroup` 在缺失时会自动生成并写回)
|
|
49
|
+
uid?: string;
|
|
50
|
+
|
|
51
|
+
// 消息名称(可选)
|
|
52
|
+
name?: string;
|
|
53
|
+
|
|
54
|
+
// 可选:消息创建时间,ISO 字符串或毫秒时间戳,由消息层(chat-helper)写入
|
|
55
|
+
// 用于 MessageTime 展示;缺省时不展示时间
|
|
56
|
+
createdAt?: number | string;
|
|
57
|
+
|
|
58
|
+
// 消息属性(可选)
|
|
59
|
+
property?: {
|
|
60
|
+
// 发送时输入框的富文本文档;content 仍是纯文本(不改后端契约),
|
|
61
|
+
// 有这份文档时用户消息会把 @ 选中的资源原样还原成标签,编辑回填也不会丢标签
|
|
62
|
+
docSchema?: TagSchema;
|
|
63
|
+
extra?: {
|
|
64
|
+
// 引用内容
|
|
65
|
+
cite:
|
|
66
|
+
| string
|
|
67
|
+
| {
|
|
68
|
+
title: string;
|
|
69
|
+
data: { key: string; value: string }[];
|
|
70
|
+
type: 'structured';
|
|
71
|
+
};
|
|
72
|
+
// 快捷指令名称
|
|
73
|
+
command: string;
|
|
74
|
+
// 上下文信息
|
|
75
|
+
context: Record<string, any>[];
|
|
76
|
+
// 快捷指令配置
|
|
77
|
+
shortcut?: Shortcut;
|
|
78
|
+
// 暂停标记:为 true 时该消息所在消息组不显示 MessageTools 工具栏
|
|
79
|
+
pause?: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 消息角色
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
enum MessageRole {
|
|
89
|
+
// 用户消息
|
|
90
|
+
User = 'user',
|
|
91
|
+
|
|
92
|
+
// AI 助手消息
|
|
93
|
+
Assistant = 'assistant',
|
|
94
|
+
|
|
95
|
+
// 系统消息
|
|
96
|
+
System = 'system',
|
|
97
|
+
|
|
98
|
+
// 开发者消息
|
|
99
|
+
Developer = 'developer',
|
|
100
|
+
|
|
101
|
+
// 引导消息
|
|
102
|
+
Guide = 'guide',
|
|
103
|
+
|
|
104
|
+
// 隐藏消息(不显示)
|
|
105
|
+
Hidden = 'hidden',
|
|
106
|
+
HiddenAssistant = 'hidden-assistant',
|
|
107
|
+
HiddenGuide = 'hidden-guide',
|
|
108
|
+
HiddenSystem = 'hidden-system',
|
|
109
|
+
HiddenUser = 'hidden-user',
|
|
110
|
+
|
|
111
|
+
// 信息消息
|
|
112
|
+
Info = 'info',
|
|
113
|
+
|
|
114
|
+
// human-in-the-loop 中断消息
|
|
115
|
+
Interrupt = 'interrupt',
|
|
116
|
+
|
|
117
|
+
// 加载中消息
|
|
118
|
+
Loading = 'loading',
|
|
119
|
+
|
|
120
|
+
// 暂停消息
|
|
121
|
+
Pause = 'pause',
|
|
122
|
+
|
|
123
|
+
// 占位消息
|
|
124
|
+
Placeholder = 'placeholder',
|
|
125
|
+
|
|
126
|
+
// 推理过程消息
|
|
127
|
+
Reasoning = 'reasoning',
|
|
128
|
+
|
|
129
|
+
// 模板消息
|
|
130
|
+
TemplateAssistant = 'template-assistant',
|
|
131
|
+
TemplateGuide = 'template-guide',
|
|
132
|
+
TemplateHidden = 'template-hidden',
|
|
133
|
+
TemplateSystem = 'template-system',
|
|
134
|
+
TemplateUser = 'template-user',
|
|
135
|
+
|
|
136
|
+
// 工具调用消息
|
|
137
|
+
Tool = 'tool',
|
|
138
|
+
|
|
139
|
+
// 活动消息(如引用文档)
|
|
140
|
+
Activity = 'activity',
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 消息状态
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
enum MessageStatus {
|
|
148
|
+
// 已完成
|
|
149
|
+
Complete = 'complete',
|
|
150
|
+
|
|
151
|
+
// 已完成(与 Complete 同义,兼容协议/后端返回的 completed)
|
|
152
|
+
Completed = 'completed',
|
|
153
|
+
|
|
154
|
+
// 已禁用
|
|
155
|
+
Disabled = 'disabled',
|
|
156
|
+
|
|
157
|
+
// 错误
|
|
158
|
+
Error = 'error',
|
|
159
|
+
|
|
160
|
+
// 请求中
|
|
161
|
+
Fetching = 'fetching',
|
|
162
|
+
|
|
163
|
+
// 等待中
|
|
164
|
+
Pending = 'pending',
|
|
165
|
+
|
|
166
|
+
// 已停止
|
|
167
|
+
Stop = 'stop',
|
|
168
|
+
|
|
169
|
+
// 停止请求中
|
|
170
|
+
StopLoading = 'stop-loading',
|
|
171
|
+
|
|
172
|
+
// 流式输出中
|
|
173
|
+
Streaming = 'streaming',
|
|
174
|
+
|
|
175
|
+
// 成功
|
|
176
|
+
Success = 'success',
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
完整取值与说明见 [常量枚举 · MessageStatus](./constants#messagestatus)。
|
|
181
|
+
|
|
182
|
+
## 具体消息类型
|
|
183
|
+
|
|
184
|
+
### UserMessage
|
|
185
|
+
|
|
186
|
+
用户消息:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
type UserMessage = BaseMessage<MessageRole.User, InputContent[] | string>;
|
|
190
|
+
|
|
191
|
+
// 示例
|
|
192
|
+
const userMessage: UserMessage = {
|
|
193
|
+
id: '1',
|
|
194
|
+
messageId: 1,
|
|
195
|
+
role: MessageRole.User,
|
|
196
|
+
content: '你好',
|
|
197
|
+
status: MessageStatus.Complete,
|
|
198
|
+
};
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### AssistantMessage
|
|
202
|
+
|
|
203
|
+
AI 助手消息:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface AssistantMessage extends BaseMessage<MessageRole.Assistant> {
|
|
207
|
+
// 工具调用列表
|
|
208
|
+
toolCalls?: ToolCall[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 工具调用
|
|
212
|
+
type ToolCall = {
|
|
213
|
+
id: string;
|
|
214
|
+
type: MessageContentType.Function;
|
|
215
|
+
function: FunctionCall;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// 调用类型:不填等价于 function
|
|
219
|
+
type FunctionCallType = 'function' | 'mcp' | 'skill';
|
|
220
|
+
|
|
221
|
+
type FunctionCall = {
|
|
222
|
+
name: string;
|
|
223
|
+
arguments: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
mcpName?: string;
|
|
226
|
+
// 决定 ToolcallRender 头部前缀(调用工具 / 调用 MCP / 读取 Skill)
|
|
227
|
+
type?: FunctionCallType;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// 示例
|
|
231
|
+
const assistantMessage: AssistantMessage = {
|
|
232
|
+
id: '2',
|
|
233
|
+
messageId: 2,
|
|
234
|
+
role: MessageRole.Assistant,
|
|
235
|
+
content: '你好!有什么可以帮助你的?',
|
|
236
|
+
status: MessageStatus.Complete,
|
|
237
|
+
toolCalls: [
|
|
238
|
+
{
|
|
239
|
+
id: 'call_1',
|
|
240
|
+
type: MessageContentType.Function,
|
|
241
|
+
function: {
|
|
242
|
+
name: 'get_weather',
|
|
243
|
+
arguments: '{"city": "北京"}',
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### ReasoningMessage
|
|
251
|
+
|
|
252
|
+
推理过程消息:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
interface ReasoningMessage extends BaseMessage<MessageRole.Reasoning, string[]> {
|
|
256
|
+
// 推理耗时(毫秒)
|
|
257
|
+
duration?: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 示例
|
|
261
|
+
const reasoningMessage: ReasoningMessage = {
|
|
262
|
+
id: '3',
|
|
263
|
+
messageId: 3,
|
|
264
|
+
role: MessageRole.Reasoning,
|
|
265
|
+
content: ['让我分析一下这个问题...', '首先,需要考虑以下几点:', '1. 技术可行性'],
|
|
266
|
+
status: MessageStatus.Complete,
|
|
267
|
+
duration: 3500,
|
|
268
|
+
};
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### ToolMessage
|
|
272
|
+
|
|
273
|
+
工具调用结果消息:
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface ToolMessage extends BaseMessage<MessageRole.Tool, string> {
|
|
277
|
+
// 工具调用 ID(对应 AssistantMessage 中的 toolCalls[].id)
|
|
278
|
+
toolCallId: string;
|
|
279
|
+
|
|
280
|
+
// 执行耗时(毫秒)
|
|
281
|
+
duration: number;
|
|
282
|
+
|
|
283
|
+
// 错误信息
|
|
284
|
+
error?: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// 示例
|
|
288
|
+
const toolMessage: ToolMessage = {
|
|
289
|
+
id: '4',
|
|
290
|
+
messageId: 4,
|
|
291
|
+
role: MessageRole.Tool,
|
|
292
|
+
content: '{"temperature": 25, "weather": "晴天"}',
|
|
293
|
+
status: MessageStatus.Complete,
|
|
294
|
+
toolCallId: 'call_1',
|
|
295
|
+
duration: 1200,
|
|
296
|
+
};
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### ActivityMessage
|
|
300
|
+
|
|
301
|
+
活动消息(如引用文档、知识检索):
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// 引用文档内容类型
|
|
305
|
+
type ReferenceDocumentContent = {
|
|
306
|
+
name: string;
|
|
307
|
+
originFile: string;
|
|
308
|
+
url: string;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// 知识检索内容类型
|
|
312
|
+
type KnowledgeRagContent = {
|
|
313
|
+
content: string;
|
|
314
|
+
referenceDocument: ReferenceDocumentContent[];
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
interface ActivityMessage extends BaseMessage<MessageRole.Activity, KnowledgeRagContent | ReferenceDocumentContent[]> {
|
|
318
|
+
activityType: MessageContentType.KnowledgeRag | MessageContentType.ReferenceDocument | string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// 示例 1:引用文档
|
|
322
|
+
const referenceMessage: ActivityMessage = {
|
|
323
|
+
id: '5',
|
|
324
|
+
messageId: 5,
|
|
325
|
+
role: MessageRole.Activity,
|
|
326
|
+
content: [
|
|
327
|
+
{ name: '参考文档 1', url: 'https://example.com/1', originFile: 'https://example.com/origin/1' },
|
|
328
|
+
{ name: '参考文档 2', url: 'https://example.com/2', originFile: 'https://example.com/origin/2' },
|
|
329
|
+
],
|
|
330
|
+
status: MessageStatus.Complete,
|
|
331
|
+
activityType: 'reference',
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// 示例 2:知识检索(knowledge_rag)
|
|
335
|
+
const knowledgeRagMessage: ActivityMessage = {
|
|
336
|
+
id: '6',
|
|
337
|
+
messageId: 6,
|
|
338
|
+
role: MessageRole.Activity,
|
|
339
|
+
content: {
|
|
340
|
+
content: '开始召回知识\n重排召回结果中\n完成召回并分类\n',
|
|
341
|
+
referenceDocument: [
|
|
342
|
+
{ name: '知识文档 1', url: 'https://example.com/doc1', originFile: 'https://example.com/origin/doc1' },
|
|
343
|
+
{ name: '知识文档 2', url: 'https://example.com/doc2', originFile: 'https://example.com/origin/doc2' },
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
status: MessageStatus.Complete,
|
|
347
|
+
activityType: 'knowledge_rag',
|
|
348
|
+
};
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**ActivityMessage 类型说明:**
|
|
352
|
+
|
|
353
|
+
| activityType | content 类型 | 说明 |
|
|
354
|
+
| ----------------- | ---------------------------- | ---------------------------------------- |
|
|
355
|
+
| `'reference'` | `ReferenceDocumentContent[]` | 引用文档列表 |
|
|
356
|
+
| `'knowledge_rag'` | `KnowledgeRagContent` | 知识检索结果,包含检索过程内容和引用文档 |
|
|
357
|
+
|
|
358
|
+
**ReferenceDocumentContent 字段说明:**
|
|
359
|
+
|
|
360
|
+
| 字段 | 类型 | 说明 |
|
|
361
|
+
| ------------ | -------- | ---------------- |
|
|
362
|
+
| `name` | `string` | 文档名称 |
|
|
363
|
+
| `url` | `string` | 文档预览链接 |
|
|
364
|
+
| `originFile` | `string` | 文档原始文件链接 |
|
|
365
|
+
|
|
366
|
+
### InterruptMessage
|
|
367
|
+
|
|
368
|
+
human-in-the-loop 中断消息,对应 AG-UI `RUN_FINISHED` 事件的 `outcome` 对象结构。`content.outcome.type === 'interrupt'` 时,[InterruptMessageRender](../components/agent/interrupt-message) 从 `interrupts` 渲染审批卡片或把 `UserQuestion` 交给输入区;`type: 'success'` 表示 resume 后的成功结果,`UserQuestion` 会根据 `result` 回显回答内容。类型详见 [中断类型 Interrupt](./interrupt.md)。
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
type RunFinishedOutcome = { interrupts: Interrupt[]; type: 'interrupt' } | { type: 'success' };
|
|
372
|
+
|
|
373
|
+
type InterruptMessage = BaseMessage<
|
|
374
|
+
MessageRole.Interrupt,
|
|
375
|
+
{
|
|
376
|
+
message?: string;
|
|
377
|
+
outcome?: RunFinishedOutcome;
|
|
378
|
+
result?: BaseResume<InterruptReason>;
|
|
379
|
+
runId?: string;
|
|
380
|
+
threadId?: string;
|
|
381
|
+
}
|
|
382
|
+
>;
|
|
383
|
+
|
|
384
|
+
const interruptMessage: InterruptMessage = {
|
|
385
|
+
id: 'interrupt-message-1',
|
|
386
|
+
messageId: 'interrupt-message-1',
|
|
387
|
+
role: MessageRole.Interrupt,
|
|
388
|
+
status: MessageStatus.Pending,
|
|
389
|
+
content: {
|
|
390
|
+
message: '算法方案评审单需要您关注',
|
|
391
|
+
runId: 'run_ai_dev_tool_approval',
|
|
392
|
+
threadId: 'thread_ai_dev_tool_approval',
|
|
393
|
+
outcome: {
|
|
394
|
+
type: 'interrupt',
|
|
395
|
+
interrupts: [
|
|
396
|
+
{
|
|
397
|
+
id: 'interrupt_ai_dev_tool_approval',
|
|
398
|
+
reason: InterruptReason.AIDevToolApproval,
|
|
399
|
+
toolCallId: 'tool_call_review_ticket',
|
|
400
|
+
message: '算法方案评审单需要您关注',
|
|
401
|
+
metadata: {
|
|
402
|
+
ticket: {
|
|
403
|
+
approvers: ['张三', '李四'],
|
|
404
|
+
sn: 'REV-2026-04-24-001',
|
|
405
|
+
status: APPROVAL_STATUS.PENDING,
|
|
406
|
+
submit_time: '2026-04-24 14:30:15',
|
|
407
|
+
title: '算法方案评审单',
|
|
408
|
+
url: 'https://example.com/review-tickets/REV-2026-04-24-001',
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
};
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### InfoMessage
|
|
419
|
+
|
|
420
|
+
信息消息:
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
type InfoMessage = BaseMessage<MessageRole.Info, string>;
|
|
424
|
+
|
|
425
|
+
// 示例
|
|
426
|
+
const infoMessage: InfoMessage = {
|
|
427
|
+
id: '6',
|
|
428
|
+
messageId: 6,
|
|
429
|
+
role: MessageRole.Info,
|
|
430
|
+
content: '会话已开始',
|
|
431
|
+
status: MessageStatus.Complete,
|
|
432
|
+
};
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### LoadingMessage
|
|
436
|
+
|
|
437
|
+
加载中消息,用于在等待 AI 响应时显示加载状态:
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
type LoadingMessage = BaseMessage<MessageRole.Loading, string>;
|
|
441
|
+
|
|
442
|
+
// 示例
|
|
443
|
+
const loadingMessage: LoadingMessage = {
|
|
444
|
+
id: 'loading',
|
|
445
|
+
messageId: '',
|
|
446
|
+
role: MessageRole.Loading,
|
|
447
|
+
content: '',
|
|
448
|
+
status: MessageStatus.Pending,
|
|
449
|
+
};
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## 消息内容类型
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
enum MessageContentType {
|
|
456
|
+
// 二进制内容
|
|
457
|
+
Binary = 'binary',
|
|
458
|
+
|
|
459
|
+
// FlowAgent 流程执行
|
|
460
|
+
FlowAgent = 'flow_agent',
|
|
461
|
+
|
|
462
|
+
// 函数调用
|
|
463
|
+
Function = 'function',
|
|
464
|
+
|
|
465
|
+
// 键值对
|
|
466
|
+
KeyValue = 'key_value',
|
|
467
|
+
|
|
468
|
+
// 知识检索
|
|
469
|
+
KnowledgeRag = 'knowledge_rag',
|
|
470
|
+
|
|
471
|
+
// 其他
|
|
472
|
+
Other = 'other',
|
|
473
|
+
|
|
474
|
+
// 引用文档
|
|
475
|
+
ReferenceDocument = 'reference_document',
|
|
476
|
+
|
|
477
|
+
// 文本
|
|
478
|
+
Text = 'text',
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## 类型扩展
|
|
483
|
+
|
|
484
|
+
支持通过声明合并扩展消息类型:
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
// 在项目中扩展
|
|
488
|
+
declare global {
|
|
489
|
+
interface AIBluekingMessageMap {
|
|
490
|
+
'custom-role': CustomMessage;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface CustomMessage extends BaseMessage<'custom-role'> {
|
|
495
|
+
customField: string;
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
## 使用示例
|
|
500
|
+
|
|
501
|
+
```vue
|
|
502
|
+
<template>
|
|
503
|
+
<MessageContainer
|
|
504
|
+
:messages="messages"
|
|
505
|
+
:message-status="messageStatus"
|
|
506
|
+
:on-agent-action="handleAgentAction"
|
|
507
|
+
:on-user-action="handleUserAction"
|
|
508
|
+
/>
|
|
509
|
+
</template>
|
|
510
|
+
|
|
511
|
+
<script setup lang="ts">
|
|
512
|
+
import { ref } from 'vue';
|
|
513
|
+
import { MessageContainer, MessageRole, MessageStatus, type Message } from '@blueking/chat-x';
|
|
514
|
+
|
|
515
|
+
const messageStatus = ref<MessageStatus>(MessageStatus.Complete);
|
|
516
|
+
|
|
517
|
+
const messages = ref<Message[]>([
|
|
518
|
+
{
|
|
519
|
+
id: '1',
|
|
520
|
+
messageId: 1,
|
|
521
|
+
role: MessageRole.User,
|
|
522
|
+
content: '你好',
|
|
523
|
+
status: MessageStatus.Complete,
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
id: '2',
|
|
527
|
+
messageId: 2,
|
|
528
|
+
role: MessageRole.Reasoning,
|
|
529
|
+
content: ['思考中...', '分析问题...'],
|
|
530
|
+
status: MessageStatus.Complete,
|
|
531
|
+
duration: 2000,
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
id: '3',
|
|
535
|
+
messageId: 3,
|
|
536
|
+
role: MessageRole.Assistant,
|
|
537
|
+
content: '你好!有什么可以帮助你的?',
|
|
538
|
+
status: MessageStatus.Complete,
|
|
539
|
+
},
|
|
540
|
+
]);
|
|
541
|
+
|
|
542
|
+
const handleAgentAction = async tool => {
|
|
543
|
+
console.log('Agent action:', tool);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
const handleUserAction = async tool => {
|
|
547
|
+
console.log('User action:', tool);
|
|
548
|
+
};
|
|
549
|
+
</script>
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
## 关联组件
|
|
553
|
+
|
|
554
|
+
- [MessageContainer](../components/setup/message-container) — 消息列表
|
|
555
|
+
- [MessageRender](../components/message/message-render) — 单条消息渲染
|
|
556
|
+
- [ChatContainer](../components/setup/chat-container) — 聊天容器
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# 用户问题 Schema
|
|
2
|
+
|
|
3
|
+
> since 2.0.0
|
|
4
|
+
|
|
5
|
+
schema.ts 仍导出 UserSingleChoiceQuestionSchema、UserMultiChoiceQuestionSchema、UserQuestionSchema 及 FromSchema 推导类型; 新的 aidev:user_question 中断不再通过 BaseInterrupt.responseSchema 区分单选/多选,而是在 metadata.questions[].multiSelect 中描述题型。
|
|
6
|
+
|
|
7
|
+
**关联**:interrupt(新 UserQuestionInterrupt 与 UserQuestionResume 协议)、user-question-card(根据 metadata.questions 渲染单选、多选与 Others 输入)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# 用户问题 Schema
|
|
12
|
+
|
|
13
|
+
> **分类**:type
|
|
14
|
+
|
|
15
|
+
`src/ag-ui/types/schema.ts` 保留了历史 JSON Schema 工具导出:
|
|
16
|
+
|
|
17
|
+
- `UserSingleChoiceQuestionSchema`
|
|
18
|
+
- `UserMultiChoiceQuestionSchema`
|
|
19
|
+
- `UserQuestionSchema`
|
|
20
|
+
- `UserSingleChoiceQuestion`
|
|
21
|
+
- `UserMultiChoiceQuestion`
|
|
22
|
+
- `UserQuestion`
|
|
23
|
+
|
|
24
|
+
新的 `InterruptReason.UserQuestion`(`'aidev:user_question'`)协议不再依赖 `BaseInterrupt.responseSchema`,而是在 `UserQuestionInterrupt.metadata.questions[]` 中用 `multiSelect` 描述单选 / 多选题,并通过 `UserQuestionResume.payload.answers` 回传回答。
|
|
25
|
+
|
|
26
|
+
## 新协议入口
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
type UserQuestionItem = {
|
|
30
|
+
header: string;
|
|
31
|
+
multiSelect: boolean;
|
|
32
|
+
options?: UserQuestionOptionItem[];
|
|
33
|
+
question: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type UserQuestionResume = {
|
|
37
|
+
interruptId: string;
|
|
38
|
+
reason: InterruptReason.UserQuestion;
|
|
39
|
+
status: 'cancelled' | 'resolved';
|
|
40
|
+
payload: {
|
|
41
|
+
answers: UserQuestionAnswerItem[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
完整结构见 [中断类型 Interrupt](./interrupt.md#userquestioninterrupt)。
|
|
47
|
+
|
|
48
|
+
## 历史导出
|
|
49
|
+
|
|
50
|
+
### UserSingleChoiceQuestionSchema
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const UserSingleChoiceQuestionSchema = {
|
|
54
|
+
properties: {
|
|
55
|
+
question: {
|
|
56
|
+
enum: [],
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ['question'],
|
|
61
|
+
type: 'object',
|
|
62
|
+
} as const;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### UserMultiChoiceQuestionSchema
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const UserMultiChoiceQuestionSchema = {
|
|
69
|
+
properties: {
|
|
70
|
+
question: {
|
|
71
|
+
items: {
|
|
72
|
+
enum: [],
|
|
73
|
+
type: 'string',
|
|
74
|
+
},
|
|
75
|
+
uniqueItems: true,
|
|
76
|
+
type: 'array',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ['question'],
|
|
80
|
+
type: 'object',
|
|
81
|
+
} as const;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### UserQuestionSchema
|
|
85
|
+
|
|
86
|
+
`UserQuestionSchema` 与 `UserQuestion` 仍为 `UserMultiChoiceQuestionSchema` / `UserMultiChoiceQuestion` 的别名。
|
|
87
|
+
|
|
88
|
+
## 关联文档
|
|
89
|
+
|
|
90
|
+
- [中断类型 Interrupt](./interrupt.md)
|
|
91
|
+
- [UserQuestionCard 用户问题中断](../components/agent/user-question-card)
|