@blueking/chat-x 0.0.51-beta.5 → 0.0.52-dev.1
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 +4953 -4429
- 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-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 +3 -2
- 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,340 @@
|
|
|
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: 'rebuild', name: '重新生成', description: '重新生成将清空下文内容' },
|
|
228
|
+
{ id: 'share', name: '分享', description: '分享' },
|
|
229
|
+
];
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### CONST_USER_MESSAGE_TOOLS
|
|
233
|
+
|
|
234
|
+
用户消息工具按钮列表:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
const CONST_USER_MESSAGE_TOOLS: IToolBtn[] = [
|
|
238
|
+
{ id: 'copy', name: '复制', description: '复制' },
|
|
239
|
+
{ id: 'edit', name: '编辑', description: '编辑' },
|
|
240
|
+
{ id: 'delete', name: '删除', description: '删除' },
|
|
241
|
+
];
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
> `cite`(引用)已从两份列表移除,后续不再支持。
|
|
245
|
+
|
|
246
|
+
### CONST_USER_MESSAGE_MAX_HEIGHT
|
|
247
|
+
|
|
248
|
+
用户消息正文的折叠阈值(px),超出后由 [CollapsibleContent](/components/rendering/collapsible-content) 折叠并展示「显示更多」:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const CONST_USER_MESSAGE_MAX_HEIGHT = 200;
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### CONST_UPDATE_TOOLS
|
|
255
|
+
|
|
256
|
+
更新工具按钮列表(点赞/不满意):
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
const CONST_UPDATE_TOOLS: IToolBtn[] = [
|
|
260
|
+
{ id: 'like', name: '点赞', description: '点赞' },
|
|
261
|
+
{ id: 'unlike', name: '不满意', description: '不满意' },
|
|
262
|
+
{ id: 'delete', name: '删除', description: '删除' },
|
|
263
|
+
];
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## 默认快捷指令
|
|
267
|
+
|
|
268
|
+
### DEFAULT_SHORTCUTS
|
|
269
|
+
|
|
270
|
+
默认快捷指令列表:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
const DEFAULT_SHORTCUTS: Shortcut[] = [{ id: 'ask-whale', name: '问问小鲸' }];
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## 上传常量
|
|
277
|
+
|
|
278
|
+
与 [ChatInput 文件上传](/components/input/chat-input#file-upload) 共用。完整扩展名列表见源码 `src/utils/upload-accept.ts`。
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const ALLOWED_UPLOAD_EXTENSIONS = {
|
|
282
|
+
image: ['.gif', '.jpeg', '.jpg', '.png', '.webp'],
|
|
283
|
+
document: ['.doc', '.docx', '.ppt', '.pptx', '.xls', '.xlsx', '.pdf' /* ... */],
|
|
284
|
+
text: ['.txt', '.md', '.json' /* ... */],
|
|
285
|
+
code: ['.py', '.js', '.ts', '.vue' /* ... */],
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/** 「文件」项 / 拖拽 / 粘贴的默认 accept,以及入队校验默认值 */
|
|
289
|
+
const DEFAULT_UPLOAD_ACCEPT = Object.values(ALLOWED_UPLOAD_EXTENSIONS).flat().join(',');
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
| 常量 | 说明 |
|
|
293
|
+
| ---- | ---- |
|
|
294
|
+
| `ALLOWED_UPLOAD_EXTENSIONS` | 默认允许的扩展名分类(含点);分类用于 tooltip 展示 |
|
|
295
|
+
| `DEFAULT_UPLOAD_ACCEPT` | `ChatInput.accept` 缺省值 |
|
|
296
|
+
|
|
297
|
+
## 使用示例
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import {
|
|
301
|
+
MessageRole,
|
|
302
|
+
MessageStatus,
|
|
303
|
+
MessageContentType,
|
|
304
|
+
MessageToolsStatus,
|
|
305
|
+
RenderMode,
|
|
306
|
+
CHAT_Z_INDEX,
|
|
307
|
+
CONST_MESSAGE_TOOLS,
|
|
308
|
+
DEFAULT_SHORTCUTS,
|
|
309
|
+
DEFAULT_UPLOAD_ACCEPT,
|
|
310
|
+
} from '@blueking/chat-x';
|
|
311
|
+
|
|
312
|
+
// 创建消息
|
|
313
|
+
const message = {
|
|
314
|
+
id: '1',
|
|
315
|
+
messageId: 1,
|
|
316
|
+
role: MessageRole.User,
|
|
317
|
+
content: '你好',
|
|
318
|
+
status: MessageStatus.Complete,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// 检查消息状态
|
|
322
|
+
if (message.status === MessageStatus.Streaming) {
|
|
323
|
+
console.log('消息正在流式输出中...');
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 使用默认工具按钮
|
|
327
|
+
console.log(
|
|
328
|
+
'可用工具:',
|
|
329
|
+
CONST_MESSAGE_TOOLS.map(t => t.name),
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// 上传:「文件」项 / 拖拽 / 粘贴用 DEFAULT_UPLOAD_ACCEPT(已含图片扩展名)
|
|
333
|
+
const filePickerAccept = DEFAULT_UPLOAD_ACCEPT;
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## 关联组件
|
|
337
|
+
|
|
338
|
+
- [MessageTools](../components/feedback/message-tools) — 消息工具栏
|
|
339
|
+
- [ChatInput](../components/input/chat-input) — 输入与状态
|
|
340
|
+
- [MessageContainer](../components/setup/message-container) — 工具与消息展示
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# 类型定义
|
|
2
|
+
|
|
3
|
+
`@blueking/chat-x` 提供完整的 TypeScript 类型定义。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 类型定义
|
|
8
|
+
|
|
9
|
+
`@blueking/chat-x` 提供完整的 TypeScript 类型定义。
|
|
10
|
+
|
|
11
|
+
## 类型文档
|
|
12
|
+
|
|
13
|
+
| 类型 | 说明 | 文档 |
|
|
14
|
+
| --------- | -------- | ---------------------- |
|
|
15
|
+
| Message | 消息类型 | [查看](./messages.md) |
|
|
16
|
+
| Constants | 常量枚举 | [查看](./constants.md) |
|
|
17
|
+
| Interrupt | 中断类型 | [查看](./interrupt.md) |
|
|
18
|
+
| Schema | 用户问题 Schema | [查看](./schema.md) |
|
|
19
|
+
|
|
20
|
+
## 引入类型
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import type {
|
|
24
|
+
// 消息类型
|
|
25
|
+
Message,
|
|
26
|
+
UserMessage,
|
|
27
|
+
AssistantMessage,
|
|
28
|
+
ReasoningMessage,
|
|
29
|
+
ToolMessage,
|
|
30
|
+
ActivityMessage,
|
|
31
|
+
InfoMessage,
|
|
32
|
+
BaseMessage,
|
|
33
|
+
MessageMap,
|
|
34
|
+
MessageType,
|
|
35
|
+
|
|
36
|
+
// 工具调用
|
|
37
|
+
ToolCall,
|
|
38
|
+
FunctionCall,
|
|
39
|
+
FunctionCallType,
|
|
40
|
+
Tool,
|
|
41
|
+
|
|
42
|
+
// 快捷指令
|
|
43
|
+
Shortcut,
|
|
44
|
+
ShortcutComponent,
|
|
45
|
+
InputShortcutComponent,
|
|
46
|
+
TextareaShortcutComponent,
|
|
47
|
+
SelectShortcutComponent,
|
|
48
|
+
CheckboxGroupShortcutComponent,
|
|
49
|
+
RadioGroupShortcutComponent,
|
|
50
|
+
SwitcherShortcutComponent,
|
|
51
|
+
|
|
52
|
+
// 工具按钮
|
|
53
|
+
IToolBtn,
|
|
54
|
+
|
|
55
|
+
// 输入相关
|
|
56
|
+
TagSchema,
|
|
57
|
+
MentionState,
|
|
58
|
+
UploadFile,
|
|
59
|
+
UploadFileVariant,
|
|
60
|
+
|
|
61
|
+
// 输入框菜单
|
|
62
|
+
IInputMenuItem,
|
|
63
|
+
IInputMenuGroup,
|
|
64
|
+
MenuItemType,
|
|
65
|
+
MenuTrigger,
|
|
66
|
+
|
|
67
|
+
// 内容类型
|
|
68
|
+
ContentType,
|
|
69
|
+
ContentMap,
|
|
70
|
+
InputContent,
|
|
71
|
+
|
|
72
|
+
// 中断类型
|
|
73
|
+
Interrupt,
|
|
74
|
+
InterruptMessage,
|
|
75
|
+
OnInterruptResume,
|
|
76
|
+
UserQuestionAnswerItem,
|
|
77
|
+
UserQuestionInterrupt,
|
|
78
|
+
UserQuestionResume,
|
|
79
|
+
|
|
80
|
+
// 历史用户问题 Schema
|
|
81
|
+
UserQuestion,
|
|
82
|
+
UserMultiChoiceQuestion,
|
|
83
|
+
UserSingleChoiceQuestion,
|
|
84
|
+
} from '@blueking/chat-x';
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 引入枚举
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { MessageRole, MessageStatus, MessageContentType, MessageState, UploadStatus } from '@blueking/chat-x';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
::: warning 已移除的输入相关类型
|
|
94
|
+
`IAiSlashMenuItem`、`IAiSlashGroupItem`、`ISkillListItem`、`resourceTypeMap`、`ResourceType` 随旧版 `@` / `/` 菜单一并移除,统一改用 `IInputMenuItem` 与 `MenuItemType`,迁移方式见 [ChatInput](/components/input/chat-input)。
|
|
95
|
+
:::
|
|
96
|
+
|
|
97
|
+
## 引入常量
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import {
|
|
101
|
+
CHAT_Z_INDEX,
|
|
102
|
+
EDITOR_Z_INDEX,
|
|
103
|
+
EDITOR_MENU_Z_INDEX,
|
|
104
|
+
SHORTCUT_MENU_Z_INDEX,
|
|
105
|
+
SELECTION_Z_INDEX,
|
|
106
|
+
CONST_MESSAGE_TOOLS,
|
|
107
|
+
CONST_USER_MESSAGE_TOOLS,
|
|
108
|
+
CONST_USER_MESSAGE_MAX_HEIGHT,
|
|
109
|
+
CONST_UPDATE_TOOLS,
|
|
110
|
+
MAX_UPLOAD_FILES,
|
|
111
|
+
MAX_UPLOAD_FILE_SIZE,
|
|
112
|
+
ALLOWED_UPLOAD_EXTENSIONS,
|
|
113
|
+
DEFAULT_UPLOAD_ACCEPT,
|
|
114
|
+
MENU_ITEM_TYPES,
|
|
115
|
+
DEFAULT_SHORTCUTS,
|
|
116
|
+
UserQuestionSchema,
|
|
117
|
+
UserMultiChoiceQuestionSchema,
|
|
118
|
+
UserSingleChoiceQuestionSchema,
|
|
119
|
+
} from '@blueking/chat-x';
|
|
120
|
+
```
|