@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.
- package/dist/components/chat-content/file-content/upload-image-item.vue.d.ts +2 -0
- package/dist/components/chat-content/file-content/upload-spinner.vue.d.ts +3 -0
- package/dist/components/chat-input/chat-input.vue.d.ts +3 -0
- package/dist/index.css +1 -1
- package/dist/index.js +745 -712
- package/dist/index.js.map +1 -1
- package/dist/lang/lang.d.ts +4 -1
- package/dist/mcp/generated/docs/chat-container.md +1 -1
- package/dist/mcp/generated/docs/chat-input.md +3 -2
- package/dist/mcp/generated/docs/file-content.md +27 -10
- package/dist/mcp/generated/index.json +3 -3
- package/dist/mcp/index.js +0 -0
- package/package.json +21 -23
- package/skills/blueking-chat-x/SKILL.md +0 -139
- package/skills/blueking-chat-x/references/_index.md +0 -131
- package/skills/blueking-chat-x/references/components/activity-layout.md +0 -134
- package/skills/blueking-chat-x/references/components/activity-message.md +0 -486
- package/skills/blueking-chat-x/references/components/ai-image.md +0 -230
- package/skills/blueking-chat-x/references/components/ai-loading.md +0 -131
- package/skills/blueking-chat-x/references/components/ai-prompt-list.md +0 -44
- package/skills/blueking-chat-x/references/components/ai-selection.md +0 -439
- package/skills/blueking-chat-x/references/components/ai-skill-list.md +0 -73
- package/skills/blueking-chat-x/references/components/ai-slash-editor.md +0 -43
- package/skills/blueking-chat-x/references/components/ai-slash-input.md +0 -56
- package/skills/blueking-chat-x/references/components/ai-slash-menu.md +0 -42
- package/skills/blueking-chat-x/references/components/animation-text.md +0 -202
- package/skills/blueking-chat-x/references/components/assistant-message.md +0 -498
- package/skills/blueking-chat-x/references/components/chat-container.md +0 -869
- package/skills/blueking-chat-x/references/components/chat-input.md +0 -769
- package/skills/blueking-chat-x/references/components/cite-content.md +0 -142
- package/skills/blueking-chat-x/references/components/code-content.md +0 -211
- package/skills/blueking-chat-x/references/components/common-error-content.md +0 -73
- package/skills/blueking-chat-x/references/components/content-render.md +0 -233
- package/skills/blueking-chat-x/references/components/delete-tool.md +0 -191
- package/skills/blueking-chat-x/references/components/desc-panel.md +0 -162
- package/skills/blueking-chat-x/references/components/detail-section.md +0 -91
- package/skills/blueking-chat-x/references/components/execution-summary.md +0 -128
- package/skills/blueking-chat-x/references/components/file-artifact-panel.md +0 -289
- package/skills/blueking-chat-x/references/components/file-content.md +0 -319
- package/skills/blueking-chat-x/references/components/file-icon.md +0 -109
- package/skills/blueking-chat-x/references/components/file-upload-btn.md +0 -159
- package/skills/blueking-chat-x/references/components/flow-agent-content.md +0 -264
- package/skills/blueking-chat-x/references/components/flow-agent-node-detail.md +0 -236
- package/skills/blueking-chat-x/references/components/highlight-keyword.md +0 -146
- package/skills/blueking-chat-x/references/components/image-content.md +0 -182
- package/skills/blueking-chat-x/references/components/image-preview-group.md +0 -184
- package/skills/blueking-chat-x/references/components/image-preview.md +0 -226
- package/skills/blueking-chat-x/references/components/info-message.md +0 -144
- package/skills/blueking-chat-x/references/components/input-attachment.md +0 -49
- package/skills/blueking-chat-x/references/components/input-info-alert.md +0 -42
- package/skills/blueking-chat-x/references/components/interrupt-message.md +0 -212
- package/skills/blueking-chat-x/references/components/key-value-content.md +0 -128
- package/skills/blueking-chat-x/references/components/knowledge-rag-content.md +0 -122
- package/skills/blueking-chat-x/references/components/latex-content.md +0 -200
- package/skills/blueking-chat-x/references/components/loading-message.md +0 -192
- package/skills/blueking-chat-x/references/components/markdown-content.md +0 -232
- package/skills/blueking-chat-x/references/components/mermaid-content.md +0 -189
- package/skills/blueking-chat-x/references/components/message-container.md +0 -645
- package/skills/blueking-chat-x/references/components/message-loading.md +0 -118
- package/skills/blueking-chat-x/references/components/message-render.md +0 -327
- package/skills/blueking-chat-x/references/components/message-time.md +0 -177
- package/skills/blueking-chat-x/references/components/message-tools.md +0 -416
- package/skills/blueking-chat-x/references/components/model-selector.md +0 -155
- package/skills/blueking-chat-x/references/components/preview-toolbar.md +0 -42
- package/skills/blueking-chat-x/references/components/questions-container.md +0 -85
- package/skills/blueking-chat-x/references/components/reasoning-message.md +0 -232
- package/skills/blueking-chat-x/references/components/reference-content.md +0 -135
- package/skills/blueking-chat-x/references/components/reference-doc-content.md +0 -109
- package/skills/blueking-chat-x/references/components/scroll-btn.md +0 -159
- package/skills/blueking-chat-x/references/components/selection-footer.md +0 -78
- package/skills/blueking-chat-x/references/components/selection-question.md +0 -88
- package/skills/blueking-chat-x/references/components/shortcut-btn.md +0 -204
- package/skills/blueking-chat-x/references/components/shortcut-btns.md +0 -266
- package/skills/blueking-chat-x/references/components/shortcut-render.md +0 -424
- package/skills/blueking-chat-x/references/components/simple-table.md +0 -101
- package/skills/blueking-chat-x/references/components/text-content.md +0 -77
- package/skills/blueking-chat-x/references/components/tool-approval-card.md +0 -183
- package/skills/blueking-chat-x/references/components/tool-btn.md +0 -317
- package/skills/blueking-chat-x/references/components/tool-message.md +0 -235
- package/skills/blueking-chat-x/references/components/toolcall-render.md +0 -348
- package/skills/blueking-chat-x/references/components/user-feedback.md +0 -233
- package/skills/blueking-chat-x/references/components/user-message.md +0 -424
- package/skills/blueking-chat-x/references/components/user-question-answered-card.md +0 -104
- package/skills/blueking-chat-x/references/components/user-question-card.md +0 -231
- package/skills/blueking-chat-x/references/components/user-question-choice.md +0 -105
- package/skills/blueking-chat-x/references/components/user-question-option.md +0 -42
- package/skills/blueking-chat-x/references/components/vnode-renderer.md +0 -122
- package/skills/blueking-chat-x/references/composables/use-animation-text.md +0 -196
- package/skills/blueking-chat-x/references/composables/use-artifact-preview.md +0 -231
- package/skills/blueking-chat-x/references/composables/use-clipboard.md +0 -203
- package/skills/blueking-chat-x/references/composables/use-command-selection.md +0 -150
- package/skills/blueking-chat-x/references/composables/use-container-scroll.md +0 -57
- package/skills/blueking-chat-x/references/composables/use-custom-tab.md +0 -158
- package/skills/blueking-chat-x/references/composables/use-flow-node-actions.md +0 -157
- package/skills/blueking-chat-x/references/composables/use-full-screen.md +0 -112
- package/skills/blueking-chat-x/references/composables/use-global-config.md +0 -148
- package/skills/blueking-chat-x/references/composables/use-menu-keydown.md +0 -163
- package/skills/blueking-chat-x/references/composables/use-message-group.md +0 -247
- package/skills/blueking-chat-x/references/composables/use-observer-visible-list.md +0 -188
- package/skills/blueking-chat-x/references/composables/use-parent-scrolling.md +0 -46
- package/skills/blueking-chat-x/references/theme/theme.md +0 -431
- package/skills/blueking-chat-x/references/types/constants.md +0 -307
- package/skills/blueking-chat-x/references/types/interrupt.md +0 -379
- package/skills/blueking-chat-x/references/types/messages.md +0 -553
- package/skills/blueking-chat-x/references/types/schema.md +0 -91
- package/skills/blueking-chat-x/scripts/generate-references.mjs +0 -314
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
# 常量枚举
|
|
2
|
-
|
|
3
|
-
> since 1.0.0
|
|
4
|
-
|
|
5
|
-
汇总 MessageRole、MessageStatus(含 Fetching 请求中、Complete/Completed 完成态兼容)、MessageContentType、MessageToolsStatus、MessageState、Z-Index 与 CONST_MESSAGE_TOOLS 等导出常量。 用于构造消息、配置 MessageContainer 工具栏与输入态,以及层级与默认快捷指令。与类型 messages 配套使用。
|
|
6
|
-
|
|
7
|
-
**关联**:message-tools(默认工具 ID 与展示)、chat-input(MessageState 与快捷指令)、message-container(工具栏与消息态)
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# 常量枚举
|
|
12
|
-
|
|
13
|
-
> **分类**:type
|
|
14
|
-
|
|
15
|
-
`@blueking/chat-x` 导出的常量和枚举类型。
|
|
16
|
-
|
|
17
|
-
## 消息相关
|
|
18
|
-
|
|
19
|
-
### MessageRole
|
|
20
|
-
|
|
21
|
-
消息角色枚举:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
enum MessageRole {
|
|
25
|
-
User = 'user',
|
|
26
|
-
Assistant = 'assistant',
|
|
27
|
-
System = 'system',
|
|
28
|
-
Developer = 'developer',
|
|
29
|
-
Guide = 'guide',
|
|
30
|
-
Hidden = 'hidden',
|
|
31
|
-
HiddenAssistant = 'hidden-assistant',
|
|
32
|
-
HiddenGuide = 'hidden-guide',
|
|
33
|
-
HiddenSystem = 'hidden-system',
|
|
34
|
-
HiddenUser = 'hidden-user',
|
|
35
|
-
Info = 'info',
|
|
36
|
-
Interrupt = 'interrupt',
|
|
37
|
-
Loading = 'loading',
|
|
38
|
-
Pause = 'pause',
|
|
39
|
-
Placeholder = 'placeholder',
|
|
40
|
-
Reasoning = 'reasoning',
|
|
41
|
-
TemplateAssistant = 'template-assistant',
|
|
42
|
-
TemplateGuide = 'template-guide',
|
|
43
|
-
TemplateHidden = 'template-hidden',
|
|
44
|
-
TemplateSystem = 'template-system',
|
|
45
|
-
TemplateUser = 'template-user',
|
|
46
|
-
Tool = 'tool',
|
|
47
|
-
Activity = 'activity',
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### MessageStatus
|
|
52
|
-
|
|
53
|
-
消息状态枚举:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
enum MessageStatus {
|
|
57
|
-
Complete = 'complete',
|
|
58
|
-
Completed = 'completed', // 与 Complete 同为完成态,兼容后端/协议返回的 completed
|
|
59
|
-
Disabled = 'disabled',
|
|
60
|
-
Error = 'error',
|
|
61
|
-
Fetching = 'fetching', // 请求中(例如已发用户消息、尚未开始流式,与末尾 Loading 占位一致)
|
|
62
|
-
Pending = 'pending',
|
|
63
|
-
Stop = 'stop',
|
|
64
|
-
StopLoading = 'stop-loading',
|
|
65
|
-
Streaming = 'streaming',
|
|
66
|
-
Success = 'success',
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
| 枚举值 | 说明 |
|
|
71
|
-
| --------------- | ---- |
|
|
72
|
-
| `Complete` / `Completed` | 已完成。`complete` 为库内常用值;`completed` 与之语义相同,用于兼容外部协议或后端返回。`ToolcallRender` 等将二者与 `success` 一并视为成功态。 |
|
|
73
|
-
| `Fetching` | 请求中:与 `useMessageGroup` 在末尾用户消息后注入的 Loading 占位(`LOADING_MESSAGE_ID`)配合时,`ChatContainer` 会将传入输入区与列表底部的状态推导为该值,便于展示「停止」与禁止重复发送。 |
|
|
74
|
-
|
|
75
|
-
### InterruptReason
|
|
76
|
-
|
|
77
|
-
human-in-the-loop 中断原因枚举,用于 `Interrupt.reason` 区分中断类型并选择对应的 UI 渲染器。
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
enum InterruptReason {
|
|
81
|
-
AIDevToolApproval = 'aidev:tool_approval',
|
|
82
|
-
UserQuestion = 'aidev:user_question',
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### APPROVAL_STATUS
|
|
87
|
-
|
|
88
|
-
AI Dev 工具审批单状态枚举,`AIDevToolApprovalInterrupt.metadata.ticket.status` 使用该类型。
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
enum APPROVAL_STATUS {
|
|
92
|
-
ABANDONED = 'abandoned',
|
|
93
|
-
APPROVED = 'approved',
|
|
94
|
-
CANCELLED = 'cancelled',
|
|
95
|
-
DRAFT = 'draft',
|
|
96
|
-
EXPIRED = 'expired',
|
|
97
|
-
PENDING = 'pending',
|
|
98
|
-
REJECTED = 'rejected',
|
|
99
|
-
REVOKED = 'revoked',
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### APPROVAL_STATUS_MAP
|
|
104
|
-
|
|
105
|
-
审批单状态到展示文案的映射,供 `ToolApprovalCard` 等组件使用:
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
const APPROVAL_STATUS_MAP: Record<APPROVAL_STATUS, string> = {
|
|
109
|
-
[APPROVAL_STATUS.ABANDONED]: '已废弃',
|
|
110
|
-
[APPROVAL_STATUS.APPROVED]: '已通过',
|
|
111
|
-
[APPROVAL_STATUS.CANCELLED]: '已取消',
|
|
112
|
-
[APPROVAL_STATUS.DRAFT]: '待审批',
|
|
113
|
-
[APPROVAL_STATUS.EXPIRED]: '已过期',
|
|
114
|
-
[APPROVAL_STATUS.PENDING]: '待审批',
|
|
115
|
-
[APPROVAL_STATUS.REJECTED]: '已拒绝',
|
|
116
|
-
[APPROVAL_STATUS.REVOKED]: '已撤销',
|
|
117
|
-
};
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
| 状态值 | 展示文案 |
|
|
121
|
-
| ----------- | -------- |
|
|
122
|
-
| `pending` | 待审批 |
|
|
123
|
-
| `draft` | 待审批 |
|
|
124
|
-
| `approved` | 已通过 |
|
|
125
|
-
| `rejected` | 已拒绝 |
|
|
126
|
-
| `cancelled` | 已取消 |
|
|
127
|
-
| `expired` | 已过期 |
|
|
128
|
-
| `abandoned` | 已废弃 |
|
|
129
|
-
| `revoked` | 已撤销 |
|
|
130
|
-
|
|
131
|
-
### RunFinishedOutcome
|
|
132
|
-
|
|
133
|
-
AG-UI `RUN_FINISHED` 事件的结束结果类型。中断结果不再是字符串枚举,而是对象联合类型;`type: 'interrupt'` 时,中断列表放在 `interrupts` 字段中。
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
type RunFinishedOutcome = { interrupts: Interrupt[]; type: 'interrupt' } | { type: 'success' };
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### MessageContentType
|
|
140
|
-
|
|
141
|
-
消息内容类型枚举:
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
enum MessageContentType {
|
|
145
|
-
Binary = 'binary',
|
|
146
|
-
FlowAgent = 'flow_agent',
|
|
147
|
-
Function = 'function',
|
|
148
|
-
KeyValue = 'key_value',
|
|
149
|
-
KnowledgeRag = 'knowledge_rag',
|
|
150
|
-
Other = 'other',
|
|
151
|
-
ReferenceDocument = 'reference_document',
|
|
152
|
-
Text = 'text',
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### MessageToolsStatus
|
|
157
|
-
|
|
158
|
-
消息工具栏状态枚举:
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
enum MessageToolsStatus {
|
|
162
|
-
Disabled = 'disabled', // 禁用状态,按钮显示但不可点击
|
|
163
|
-
Hidden = 'hidden', // 隐藏状态,工具栏完全隐藏
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### RenderMode
|
|
168
|
-
|
|
169
|
-
渲染模式枚举,控制 `ChatContainer` / `MessageContainer` 的 UI 行为:
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
enum RenderMode {
|
|
173
|
-
Chat = 'chat', // 默认对话模式
|
|
174
|
-
Share = 'share', // 分享预览模式:隐藏侧边栏和工具栏,启用多选样式
|
|
175
|
-
Test = 'test', // 测试/嵌入模式:过滤掉「分享」按钮
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
| 枚举值 | 侧边栏 | MessageTools | 说明 |
|
|
180
|
-
| ------- | ------ | -------------- | ------------------------------ |
|
|
181
|
-
| `Chat` | 正常 | 全部按钮 | 默认行为 |
|
|
182
|
-
| `Share` | 隐藏 | 隐藏 | 分享预览,仅展示消息内容 |
|
|
183
|
-
| `Test` | 正常 | 过滤掉「分享」 | 测试或嵌入场景,隐藏分享入口 |
|
|
184
|
-
|
|
185
|
-
## 输入状态
|
|
186
|
-
|
|
187
|
-
### MessageState
|
|
188
|
-
|
|
189
|
-
输入框消息状态:
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
const MessageState = {
|
|
193
|
-
ACTIVE: 'active',
|
|
194
|
-
DISABLED: 'disabled',
|
|
195
|
-
LOADING: 'loading',
|
|
196
|
-
} as const;
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Z-Index 常量
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
// 全局 chat-x 组件 Z-Index
|
|
203
|
-
const CHAT_Z_INDEX = 9999;
|
|
204
|
-
|
|
205
|
-
// 编辑器组件 Z-Index
|
|
206
|
-
const EDITOR_Z_INDEX = 10000;
|
|
207
|
-
|
|
208
|
-
// 编辑器菜单 Z-Index
|
|
209
|
-
const EDITOR_MENU_Z_INDEX = 10001;
|
|
210
|
-
|
|
211
|
-
// 快捷指令菜单 Z-Index
|
|
212
|
-
const SHORTCUT_MENU_Z_INDEX = 10002;
|
|
213
|
-
|
|
214
|
-
// 划选弹窗 Z-Index
|
|
215
|
-
const SELECTION_Z_INDEX = 10003;
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## 默认工具按钮
|
|
219
|
-
|
|
220
|
-
### CONST_MESSAGE_TOOLS
|
|
221
|
-
|
|
222
|
-
消息工具按钮列表:
|
|
223
|
-
|
|
224
|
-
```typescript
|
|
225
|
-
const CONST_MESSAGE_TOOLS: IToolBtn[] = [
|
|
226
|
-
{ id: 'copy', name: '复制', description: '复制' },
|
|
227
|
-
{ id: 'cite', name: '引用', description: '引用' },
|
|
228
|
-
{ id: 'rebuild', name: '重新生成', description: '重新生成' },
|
|
229
|
-
{ id: 'share', name: '分享', description: '分享' },
|
|
230
|
-
];
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### CONST_USER_MESSAGE_TOOLS
|
|
234
|
-
|
|
235
|
-
用户消息工具按钮列表:
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
const CONST_USER_MESSAGE_TOOLS: IToolBtn[] = [
|
|
239
|
-
{ id: 'copy', name: '复制', description: '复制' },
|
|
240
|
-
{ id: 'cite', name: '引用', description: '引用' },
|
|
241
|
-
{ id: 'edit', name: '编辑', description: '编辑' },
|
|
242
|
-
{ id: 'delete', name: '删除', description: '删除' },
|
|
243
|
-
];
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### CONST_UPDATE_TOOLS
|
|
247
|
-
|
|
248
|
-
更新工具按钮列表(点赞/不满意):
|
|
249
|
-
|
|
250
|
-
```typescript
|
|
251
|
-
const CONST_UPDATE_TOOLS: IToolBtn[] = [
|
|
252
|
-
{ id: 'like', name: '点赞', description: '点赞' },
|
|
253
|
-
{ id: 'unlike', name: '不满意', description: '不满意' },
|
|
254
|
-
{ id: 'delete', name: '删除', description: '删除' },
|
|
255
|
-
];
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## 默认快捷指令
|
|
259
|
-
|
|
260
|
-
### DEFAULT_SHORTCUTS
|
|
261
|
-
|
|
262
|
-
默认快捷指令列表:
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
const DEFAULT_SHORTCUTS: Shortcut[] = [{ id: 'ask-whale', name: '问问小鲸' }];
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## 使用示例
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
import {
|
|
272
|
-
MessageRole,
|
|
273
|
-
MessageStatus,
|
|
274
|
-
MessageContentType,
|
|
275
|
-
MessageToolsStatus,
|
|
276
|
-
RenderMode,
|
|
277
|
-
CHAT_Z_INDEX,
|
|
278
|
-
CONST_MESSAGE_TOOLS,
|
|
279
|
-
DEFAULT_SHORTCUTS,
|
|
280
|
-
} from '@blueking/chat-x';
|
|
281
|
-
|
|
282
|
-
// 创建消息
|
|
283
|
-
const message = {
|
|
284
|
-
id: '1',
|
|
285
|
-
messageId: 1,
|
|
286
|
-
role: MessageRole.User,
|
|
287
|
-
content: '你好',
|
|
288
|
-
status: MessageStatus.Complete,
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
// 检查消息状态
|
|
292
|
-
if (message.status === MessageStatus.Streaming) {
|
|
293
|
-
console.log('消息正在流式输出中...');
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// 使用默认工具按钮
|
|
297
|
-
console.log(
|
|
298
|
-
'可用工具:',
|
|
299
|
-
CONST_MESSAGE_TOOLS.map(t => t.name),
|
|
300
|
-
);
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
## 关联组件
|
|
304
|
-
|
|
305
|
-
- [MessageTools](../components/feedback/message-tools) — 消息工具栏
|
|
306
|
-
- [ChatInput](../components/input/chat-input) — 输入与状态
|
|
307
|
-
- [MessageContainer](../components/setup/message-container) — 工具与消息展示
|
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
# 中断类型 Interrupt
|
|
2
|
-
|
|
3
|
-
> since 2.0.0
|
|
4
|
-
|
|
5
|
-
定义 RunFinishedOutcome、BaseInterrupt、AIDevToolApprovalInterrupt、AIDevToolApprovalResume、UserQuestionInterrupt、InterruptResult、BaseResume、InterruptMessage 与 OnInterruptResume。 与 MessageRole.Interrupt、InterruptMessageRender、UserQuestionCard、ToolApprovalCard 配合,对应 RUN_FINISHED outcome。
|
|
6
|
-
|
|
7
|
-
**关联**:interrupt-message(根据 outcome.interrupts 与 reason 渲染中断 UI,success 时按 result.reason 回显审批单或用户回答)、user-question-card(UserQuestion 交互面板,挂载在 ChatInput 上方)、tool-approval-card(AIDevToolApproval 专用卡片)、message-render(role 为 interrupt 时派发 InterruptMessageRender)
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# 中断类型 Interrupt
|
|
12
|
-
|
|
13
|
-
> **分类**:type
|
|
14
|
-
|
|
15
|
-
AG-UI [Interrupts](https://docs.ag-ui.com/drafts/interrupts) 协议相关类型,定义在 `src/ag-ui/types/interrupt.ts`,由 `@blueking/chat-x` 导出。
|
|
16
|
-
|
|
17
|
-
中断链路分为两段:
|
|
18
|
-
|
|
19
|
-
1. Agent 返回 `RUN_FINISHED { outcome: { type: 'interrupt', interrupts } }`,前端渲染等待用户处理的 UI。
|
|
20
|
-
2. 用户操作后调用 `onInterruptResume(payload, interrupt?)`,业务侧按 `payload.operation` 分支处理,并将 `payload` 作为 `RunAgentInput.resume` 回传给 Agent。
|
|
21
|
-
|
|
22
|
-
## InterruptResumeOperation
|
|
23
|
-
|
|
24
|
-
统一标识用户在「中断消息 / 活动消息」上触发的、需回传 Agent 处理的动作:
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
enum InterruptResumeOperation {
|
|
28
|
-
/** 主动取消第三方工具审批 */
|
|
29
|
-
ApprovalCancel = 'approval_cancel',
|
|
30
|
-
/** 刷新第三方工具审批:刷新审批单状态 */
|
|
31
|
-
ApprovalRefresh = 'approval_refresh',
|
|
32
|
-
/** 重试失败的流程节点(bkflow) */
|
|
33
|
-
FlowNodeRetry = 'flow_node_retry',
|
|
34
|
-
/** 跳过失败的流程节点(bkflow) */
|
|
35
|
-
FlowNodeSkip = 'flow_node_skip',
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
业务侧通过 `onInterruptResume` 回调的 `payload.operation` 字段进行分支处理;新增操作类型只需扩展此枚举,回调契约与透传链路保持不变。
|
|
40
|
-
|
|
41
|
-
## RunFinishedOutcome
|
|
42
|
-
|
|
43
|
-
`RUN_FINISHED` 事件的 `outcome` 联合类型:
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
type RunFinishedOutcome =
|
|
47
|
-
| { interrupts: Interrupt[]; type: 'interrupt' }
|
|
48
|
-
| { type: 'success' };
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
| `type` | 说明 |
|
|
52
|
-
| ------------- | -------------------------------------------------------------------- |
|
|
53
|
-
| `'interrupt'` | 等待用户响应;`interrupts` 驱动 UI 渲染审批卡片、用户问题面板等 |
|
|
54
|
-
| `'success'` | 用户已通过 `resume` 处理;按 `result.reason` 在会话内回显审批单(`AIDevToolApproval`)或用户回答(`UserQuestion`) |
|
|
55
|
-
|
|
56
|
-
## BaseInterrupt
|
|
57
|
-
|
|
58
|
-
所有中断项的公共结构:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
type BaseInterrupt<T extends InterruptReason, M extends Record<string, any>> = {
|
|
62
|
-
expiresAt?: string;
|
|
63
|
-
id: string;
|
|
64
|
-
message?: string;
|
|
65
|
-
metadata?: M;
|
|
66
|
-
properties?: Record<string, any>;
|
|
67
|
-
reason: T;
|
|
68
|
-
toolCallId: string;
|
|
69
|
-
};
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## AIDevToolApprovalInterrupt
|
|
73
|
-
|
|
74
|
-
AI Dev 第三方工具审批中断,`reason` 为 `InterruptReason.AIDevToolApproval`(`'aidev:tool_approval'`):
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
type AIDevToolApprovalInterruptPayloadMetaData = {
|
|
78
|
-
ticket: {
|
|
79
|
-
approvers: string[];
|
|
80
|
-
sn: string;
|
|
81
|
-
status: APPROVAL_STATUS;
|
|
82
|
-
submit_time: string;
|
|
83
|
-
title: string;
|
|
84
|
-
url: string;
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
type AIDevToolApprovalInterrupt = BaseInterrupt<
|
|
89
|
-
InterruptReason.AIDevToolApproval,
|
|
90
|
-
AIDevToolApprovalInterruptPayloadMetaData
|
|
91
|
-
>;
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## AIDevToolApprovalResume
|
|
95
|
-
|
|
96
|
-
AI Dev 第三方工具审批中断响应(resume 后用于 `outcome.success` 时会话内回显审批单)。`payload.metadata` 透传中断时的 `metadata`(含 `ticket`),以便复用 `ToolApprovalCard` 只读渲染:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
type AIDevToolApprovalResume = BaseResume<
|
|
100
|
-
InterruptReason.AIDevToolApproval,
|
|
101
|
-
{ metadata: AIDevToolApprovalInterruptPayloadMetaData }
|
|
102
|
-
>;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## UserQuestionInterrupt
|
|
106
|
-
|
|
107
|
-
用户回答问题中断,`reason` 为 `InterruptReason.UserQuestion`(`'aidev:user_question'`)。交互面板由 `ChatContainer` 挂载到 `ChatInput` 上方。
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
type UserQuestionInterrupt = BaseInterrupt<
|
|
111
|
-
InterruptReason.UserQuestion,
|
|
112
|
-
{
|
|
113
|
-
questions: UserQuestionItem[];
|
|
114
|
-
}
|
|
115
|
-
>;
|
|
116
|
-
|
|
117
|
-
type UserQuestionItem = {
|
|
118
|
-
header: string;
|
|
119
|
-
/** 是否多选;仅选择题语义,自定义表单类问题可不传 */
|
|
120
|
-
multiSelect?: boolean;
|
|
121
|
-
options?: UserQuestionOptionItem[];
|
|
122
|
-
question: string;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
type UserQuestionOptionItem = {
|
|
126
|
-
description: string;
|
|
127
|
-
label: string;
|
|
128
|
-
};
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
约定:
|
|
132
|
-
|
|
133
|
-
- `multiSelect: false` 表示单选题,`true` 表示多选题;**不传**时 UI 不展示单选/多选标签,默认选择题组件仍按单选行为处理。
|
|
134
|
-
- 前端会为每道**选择题**追加 `label: 'others'` 的自由输入项;后端无需重复下发该选项。
|
|
135
|
-
- 当用户选择 Others 时,`answer[].description` 为用户输入文本。
|
|
136
|
-
- 业务可通过 `UserQuestionCard` 的 `#question` slot 渲染自定义表单;作答有效时调用 `setAnswer` 回传 `UserQuestionAnswerItem`,无效时传 `undefined`。
|
|
137
|
-
- UI 一次只展示一题:标题栏 `< 当前题 / 总题数 >` 切换;单选预设选项作答后自动跳下一题,多选 / Others 需手动切换(协议字段不变)。
|
|
138
|
-
|
|
139
|
-
## Interrupt
|
|
140
|
-
|
|
141
|
-
当前支持的中断联合类型:
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
type Interrupt =
|
|
145
|
-
| AIDevToolApprovalInterrupt
|
|
146
|
-
| UserQuestionInterrupt
|
|
147
|
-
| BaseInterrupt<InterruptReason, Record<string, any>>;
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## InterruptResult
|
|
151
|
-
|
|
152
|
-
中断处理结果(resume 后回传/持久化,用于 `outcome.success` 时会话内回显)。按 `reason` 区分不同结果形态,统一具备 `BaseResume` 的 `{ interruptId, reason, status }`;新增中断类型的回显结果只需在此联合扩展:
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
type InterruptResult = AIDevToolApprovalResume | UserQuestionResume;
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## InterruptResume 联合类型
|
|
159
|
-
|
|
160
|
-
用户操作后通过 `onInterruptResume` 回传的负载(与 `InterruptResult` 用途不同:`InterruptResume` 侧重**动作回传**,`InterruptResult` 侧重**success 态会话内回显**):
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
type InterruptResume = FlowNodeResume | ToolApprovalResume | UserQuestionResume;
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
| 类型 | `operation` / `reason` | 说明 |
|
|
167
|
-
| -------------------- | ----------------------------------- | ------------------------------------------------------------ |
|
|
168
|
-
| `ToolApprovalResume` | `InterruptResumeOperation.ApprovalCancel` / `ApprovalRefresh` | 第三方工具审批取消 / 刷新审批单状态 |
|
|
169
|
-
| `FlowNodeResume` | `flow_node_retry` / `flow_node_skip` | FlowAgent 失败节点重试 / 跳过;**无**对应 `Interrupt` 项 |
|
|
170
|
-
| `UserQuestionResume` | `InterruptReason.UserQuestion`(`reason` 字段) | 用户回答问题 |
|
|
171
|
-
|
|
172
|
-
### ToolApprovalResume
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
type ToolApprovalResume = {
|
|
176
|
-
operation: InterruptResumeOperation.ApprovalCancel | InterruptResumeOperation.ApprovalRefresh;
|
|
177
|
-
payload: { interrupt_id: number | string };
|
|
178
|
-
};
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### FlowNodeResume
|
|
182
|
-
|
|
183
|
-
流程节点不属于 interrupt,节点定位信息(`task_id` / `node_id`)随 `payload` 回传;此时 `onInterruptResume` 的第二个 `interrupt` 参数**不传**。
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
type FlowNodeResume = {
|
|
187
|
-
operation: InterruptResumeOperation.FlowNodeRetry | InterruptResumeOperation.FlowNodeSkip;
|
|
188
|
-
payload: {
|
|
189
|
-
node_id: string;
|
|
190
|
-
task_id: number;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## BaseResume / UserQuestionResume
|
|
196
|
-
|
|
197
|
-
`UserQuestion` 的 resume payload 为单个对象,与 `chat-helper` 的 `IResume` 保持一致:
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
type BaseResume<T extends InterruptReason, P extends Record<string, any>> = {
|
|
201
|
-
interruptId: string;
|
|
202
|
-
payload: P;
|
|
203
|
-
reason: T;
|
|
204
|
-
status: 'cancelled' | 'resolved';
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
type UserQuestionAnswerItem = {
|
|
208
|
-
answer: UserQuestionOptionItem[];
|
|
209
|
-
multiSelect?: boolean;
|
|
210
|
-
question: string;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
type UserQuestionResume = BaseResume<
|
|
214
|
-
InterruptReason.UserQuestion,
|
|
215
|
-
{
|
|
216
|
-
answers: UserQuestionAnswerItem[];
|
|
217
|
-
}
|
|
218
|
-
>;
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
示例:
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
const resume: UserQuestionResume = {
|
|
225
|
-
interruptId: 'interrupt_user_question',
|
|
226
|
-
reason: InterruptReason.UserQuestion,
|
|
227
|
-
status: 'resolved',
|
|
228
|
-
payload: {
|
|
229
|
-
answers: [
|
|
230
|
-
{
|
|
231
|
-
question: '请选择语言',
|
|
232
|
-
multiSelect: true,
|
|
233
|
-
answer: [
|
|
234
|
-
{ label: 'Java', description: 'Java' },
|
|
235
|
-
{ label: 'others', description: 'Rust' },
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
## InterruptMessage
|
|
244
|
-
|
|
245
|
-
`MessageRole.Interrupt` 对应的消息类型,`content` 承载 outcome、可选说明文案与 resume 结果:
|
|
246
|
-
|
|
247
|
-
```typescript
|
|
248
|
-
type InterruptMessage = BaseMessage<
|
|
249
|
-
MessageRole.Interrupt,
|
|
250
|
-
{
|
|
251
|
-
message?: string;
|
|
252
|
-
outcome?: RunFinishedOutcome;
|
|
253
|
-
result?: InterruptResult;
|
|
254
|
-
runId?: string;
|
|
255
|
-
threadId?: string;
|
|
256
|
-
}
|
|
257
|
-
>;
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
| 字段 | 说明 |
|
|
261
|
-
| ---------- | ------------------------------------------------------------ |
|
|
262
|
-
| `message` | 消息组顶部可选说明文案,由 `InterruptMessageRender` 展示 |
|
|
263
|
-
| `outcome` | `type: 'interrupt'` 时从 `interrupts` 渲染交互;`success` 时进入已处理态 |
|
|
264
|
-
| `result` | 用户 resume 后回传/持久化的 `InterruptResult`;按 `reason` 在会话内回显审批单或用户回答 |
|
|
265
|
-
| `runId` | 关联 AG-UI run 标识 |
|
|
266
|
-
| `threadId` | 关联会话线程标识 |
|
|
267
|
-
|
|
268
|
-
## OnInterruptResume
|
|
269
|
-
|
|
270
|
-
用户完成中断操作或 FlowAgent 节点操作后的回调(由 `ChatContainer` / `MessageContainer` / `MessageRender` 透传):
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
type OnInterruptResume = (
|
|
274
|
-
payload: InterruptResume,
|
|
275
|
-
interrupt?: Interrupt,
|
|
276
|
-
) => Promise<void> | void;
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
| 参数 | 说明 |
|
|
280
|
-
| ----------- | ---------------------------------------------------------------------------------------------------------- |
|
|
281
|
-
| `payload` | 用户操作产生的 resume 负载;通过 `payload.operation`(或 `UserQuestionResume.reason`)区分动作类型 |
|
|
282
|
-
| `interrupt` | 原始中断项;审批取消、用户问题等中断来源**必传**;FlowAgent 节点重试 / 跳过等非中断来源**不传** |
|
|
283
|
-
|
|
284
|
-
| `payload.operation` | 触发场景 | `interrupt` |
|
|
285
|
-
| -------------------------------- | -------------------------------- | ----------- |
|
|
286
|
-
| `approval_cancel` | `ToolApprovalCard` 取消审批 | 必传 |
|
|
287
|
-
| `flow_node_retry` / `flow_node_skip` | `FlowAgentContent` 失败节点操作 | 不传 |
|
|
288
|
-
| —(`UserQuestionResume`) | `UserQuestionCard` 提交回答 | 必传 |
|
|
289
|
-
|
|
290
|
-
## 使用示例
|
|
291
|
-
|
|
292
|
-
```typescript
|
|
293
|
-
import {
|
|
294
|
-
APPROVAL_STATUS,
|
|
295
|
-
InterruptReason,
|
|
296
|
-
InterruptResumeOperation,
|
|
297
|
-
MessageRole,
|
|
298
|
-
MessageStatus,
|
|
299
|
-
type InterruptMessage,
|
|
300
|
-
type OnInterruptResume,
|
|
301
|
-
} from '@blueking/chat-x';
|
|
302
|
-
|
|
303
|
-
const message: InterruptMessage = {
|
|
304
|
-
id: 'msg_interrupt_1',
|
|
305
|
-
messageId: 'msg_interrupt_1',
|
|
306
|
-
role: MessageRole.Interrupt,
|
|
307
|
-
status: MessageStatus.Pending,
|
|
308
|
-
content: {
|
|
309
|
-
message: '需要您处理以下中断',
|
|
310
|
-
outcome: {
|
|
311
|
-
type: 'interrupt',
|
|
312
|
-
interrupts: [
|
|
313
|
-
{
|
|
314
|
-
id: 'interrupt_approval_1',
|
|
315
|
-
reason: InterruptReason.AIDevToolApproval,
|
|
316
|
-
toolCallId: 'tool_call_approval_1',
|
|
317
|
-
metadata: {
|
|
318
|
-
ticket: {
|
|
319
|
-
approvers: ['张三'],
|
|
320
|
-
sn: 'REV-2026-04-24-001',
|
|
321
|
-
status: APPROVAL_STATUS.PENDING,
|
|
322
|
-
submit_time: '2026-04-24 14:30:15',
|
|
323
|
-
title: '算法方案评审单',
|
|
324
|
-
url: 'https://example.com/tickets/REV-2026-04-24-001',
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
id: 'interrupt_question_1',
|
|
330
|
-
reason: InterruptReason.UserQuestion,
|
|
331
|
-
toolCallId: 'tool_call_question_1',
|
|
332
|
-
message: '请选择实现方案',
|
|
333
|
-
metadata: {
|
|
334
|
-
questions: [
|
|
335
|
-
{
|
|
336
|
-
header: '请选择实现方案',
|
|
337
|
-
multiSelect: false,
|
|
338
|
-
question: '你希望采用哪种排序实现?',
|
|
339
|
-
options: [
|
|
340
|
-
{ label: 'basic', description: '基础冒泡排序' },
|
|
341
|
-
{ label: 'optimized', description: '提前终止优化版' },
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
],
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const handleInterruptResume: OnInterruptResume = async (payload, interrupt) => {
|
|
353
|
-
if ('operation' in payload) {
|
|
354
|
-
switch (payload.operation) {
|
|
355
|
-
case InterruptResumeOperation.ApprovalCancel:
|
|
356
|
-
console.log('取消审批', payload.payload.interrupt_id, interrupt?.id);
|
|
357
|
-
break;
|
|
358
|
-
case InterruptResumeOperation.ApprovalRefresh:
|
|
359
|
-
console.log('刷新审批单', payload.payload.interrupt_id, interrupt?.id);
|
|
360
|
-
break;
|
|
361
|
-
case InterruptResumeOperation.FlowNodeRetry:
|
|
362
|
-
case InterruptResumeOperation.FlowNodeSkip:
|
|
363
|
-
console.log('流程节点操作', payload.operation, payload.payload);
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
// UserQuestionResume
|
|
369
|
-
console.log('用户问题 resume', interrupt?.id, payload);
|
|
370
|
-
};
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
## 关联文档
|
|
374
|
-
|
|
375
|
-
- [常量枚举 Constants](./constants.md) — `InterruptReason`、`APPROVAL_STATUS`
|
|
376
|
-
- [消息类型 Messages](./messages.md) — `InterruptMessage` 在消息联合类型中的位置
|
|
377
|
-
- [InterruptMessage 中断消息](../components/agent/interrupt-message)
|
|
378
|
-
- [UserQuestionCard 用户问题中断](../components/agent/user-question-card)
|
|
379
|
-
- [ToolApprovalCard 审批卡片](../components/agent/tool-approval-card)
|