@blueking/chat-x 0.0.51 → 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 +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,379 @@
|
|
|
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)
|