@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,266 @@
|
|
|
1
|
+
# FlowAgentContent FlowAgent 执行内容
|
|
2
|
+
|
|
3
|
+
> 能力域:Agent 能力 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
渲染 FlowAgent 任务/节点执行状态、耗时、详情入口和自定义 Tab 联动。 源码位置:src/components/chat-content/flow-agent-content/flow-agent-content.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:flow-agent-node-detail(详情入口点击后挂载到自定义 Tab 渲染)、activity-layout(提供可折叠的活动容器外壳)、chat-container(通过自定义 Tab 在侧栏展示节点详情)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# FlowAgentContent FlowAgent 执行内容
|
|
12
|
+
|
|
13
|
+
> **能力域**:Agent 能力
|
|
14
|
+
|
|
15
|
+
渲染 FlowAgent(标准运维 / 流程编排)执行过程的活动组件,以「任务 → 节点」两级结构展示执行状态、耗时统计与详情入口。组件内部消费 `useCustomTabConsumer`,点击节点「详情」会向侧栏的自定义 Tab 注入 `FlowAgentNodeDetail` 渲染节点输入输出。
|
|
16
|
+
|
|
17
|
+
通常不需要直接使用,`MessageRender` 会根据消息 `content.type === flow_agent` 自动渲染。
|
|
18
|
+
|
|
19
|
+
## 源码事实
|
|
20
|
+
|
|
21
|
+
- **源码位置**:`src/components/chat-content/flow-agent-content/flow-agent-content.vue`
|
|
22
|
+
- **能力说明**:渲染 FlowAgent 任务/节点执行状态、耗时、详情入口和自定义 Tab 联动。
|
|
23
|
+
|
|
24
|
+
## 核心能力
|
|
25
|
+
|
|
26
|
+
- **状态聚合统计**:汇总所有任务的 `statistics.state_counts`,在标题栏按「执行中 / 成功 / 失败 / 挂起 / 待执行」分类展示带颜色的计数(超过 99 显示 `99+`)
|
|
27
|
+
- **两级折叠**:任务整体由 `ActivityLayout` 折叠;每个任务节点列表可单独展开/收起
|
|
28
|
+
- **耗时格式化**:节点耗时与任务总耗时按 `d/h/m/s` 紧凑展示,小于 1 秒显示 `<1s`
|
|
29
|
+
- **节点行尾操作**:hover 失败节点行显示「重试 / 跳过 / 详情」按钮组(间距 12px);成功 / 运行中等非失败节点仅显示「详情」。重试 / 跳过依赖节点 `retryable` / `skippable` 能力位,通过 `onInterruptResume` 回传 Agent
|
|
30
|
+
- **重试 / 跳过进行中态**:点击后节点行进入 `is-pending`,按钮组常驻显示(无需 hover);进行中按钮切换为 loading +「重试中 / 跳过中」,重试与跳过互斥禁用;被阻塞按钮 hover 显示提示(如「任务正在重试中,不可跳过」);详情不受影响。pending 以 `task_id:node_id:retry` 为键,后端 `retry` 计数变化后自动失效
|
|
31
|
+
- **详情入口联动**:「详情」按钮点击后通过自定义 Tab 挂载 `FlowAgentNodeDetail`
|
|
32
|
+
- **分享态只读查看**:`RenderMode.Share` 下保留耗时、「详情」「有效证据」等只读查看入口,仅隐藏「重试 / 跳过」等交互式 resume 操作
|
|
33
|
+
- **侧栏执行情况面板只读**:侧栏「执行情况」Tab 内经 `ExecutionSummary` 渲染的同一组件同样只保留「详情」,不展示「重试 / 跳过」;面板身份由 `ExecutionSummary` 通过 `EXECUTION_PANEL_TOKEN` 提供,组件以 `useExecutionPanelInject` 读取。因此重试 / 跳过只出现在对话流内的执行情况
|
|
34
|
+
|
|
35
|
+
## 状态映射
|
|
36
|
+
|
|
37
|
+
组件将后端原始 `state` / `task_state` 归一为 5 类收敛状态(`getConvergedState`),用于图标、颜色与统计分类:
|
|
38
|
+
|
|
39
|
+
| 收敛状态 | 颜色 | 原始状态 |
|
|
40
|
+
| ----------- | ----------- | --------------------------------------------------------------------------------- |
|
|
41
|
+
| `success` | `#18B456` | `FINISHED` |
|
|
42
|
+
| `failed` | `#EA3636` | `FAILED`、`REVOKED`、`ROLL_BACK_FAILED` |
|
|
43
|
+
| `suspended` | `#F59500` | `SUSPENDED` |
|
|
44
|
+
| `pending` | `#4D4F56` | `PENDING` |
|
|
45
|
+
| `running` | `#3A84FF` | `CREATED`、`LOOP_READY`、`READY`、`RUNNING`、`BLOCKED`、`ROLLING_BACK`、`ROLL_BACK_SUCCESS` 及未知状态(兜底) |
|
|
46
|
+
|
|
47
|
+
## 基础用法
|
|
48
|
+
|
|
49
|
+
`content` 为任务数组 `BkFlowTask[]`;传入单个对象时组件会自动包装为单元素数组。
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<template>
|
|
53
|
+
<FlowAgentContent
|
|
54
|
+
:content="flowContent"
|
|
55
|
+
:message-uid="messageUid"
|
|
56
|
+
:on-interrupt-resume="handleInterruptResume"
|
|
57
|
+
:status="status"
|
|
58
|
+
/>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
import { FlowAgentContent } from '@blueking/chat-x';
|
|
63
|
+
import type { BkFlowMessageContent, OnInterruptResume } from '@blueking/chat-x';
|
|
64
|
+
|
|
65
|
+
const messageUid = 'flow-msg-1';
|
|
66
|
+
const status = 'success';
|
|
67
|
+
const handleInterruptResume: OnInterruptResume = async payload => {
|
|
68
|
+
console.log('flow node resume:', payload);
|
|
69
|
+
};
|
|
70
|
+
const flowContent: BkFlowMessageContent = [
|
|
71
|
+
{
|
|
72
|
+
task_id: 100,
|
|
73
|
+
task_name: '主机巡检流程',
|
|
74
|
+
task_state: 'FINISHED',
|
|
75
|
+
task_outputs: { result: 'ok' },
|
|
76
|
+
statistics: { state_counts: { FINISHED: 2, FAILED: 1 }, total: 3 },
|
|
77
|
+
nodes: {
|
|
78
|
+
n1: { id: 'n1', name: '采集主机指标', state: 'FINISHED', elapsed_time: 12, type: 'task', loop: 0, retry: 0, skip: false, start_time: '', finish_time: '' },
|
|
79
|
+
n2: { id: 'n2', name: '分析异常项', state: 'FINISHED', elapsed_time: 65, type: 'task', loop: 0, retry: 0, skip: false, start_time: '', finish_time: '' },
|
|
80
|
+
n3: { id: 'n3', name: '推送告警', state: 'FAILED', elapsed_time: 3, type: 'task', loop: 0, retry: 1, skip: false, retryable: true, skippable: true, start_time: '', finish_time: '' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
</script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**渲染效果**(hover 失败节点行可看到「重试 / 跳过 / 详情」按钮组;点击「详情」会向侧栏自定义 Tab 注入节点详情)
|
|
88
|
+
|
|
89
|
+
## 执行中状态
|
|
90
|
+
|
|
91
|
+
`status` 为 `pending` / `streaming` 时,标题栏图标显示为加载动画;运行中的节点显示旋转 Loading,待执行 / 挂起节点显示对应颜色的状态点。
|
|
92
|
+
|
|
93
|
+
## 失败节点重试 / 跳过
|
|
94
|
+
|
|
95
|
+
失败节点(`convergedState === 'failed'`)且具备对应能力位时,在**对话流内**的执行情况 hover 行尾展示「重试」或「跳过」按钮(侧栏「执行情况」面板与 Share 分享态不展示,见下方显隐条件)。点击后:
|
|
96
|
+
|
|
97
|
+
1. 节点行添加 `is-pending` class,按钮组常驻显示(设计稿:鼠标移出后仍可见进行中反馈)
|
|
98
|
+
2. 被点击按钮进入 loading +「重试中 / 跳过中」,重试与跳过均禁用(`is-disabled`,置灰色 `#c4c6cc`)
|
|
99
|
+
3. 另一按钮 hover 显示阻塞提示(`v-tippy`)
|
|
100
|
+
4. 调用 `onInterruptResume`,**不传** `interrupt` 参数;进行中重复点击被 `handleActionClick` 拦截
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// 组件层点击分发(禁用态不执行 run)
|
|
104
|
+
const handleActionClick = (action: FlowNodeActionVM) => {
|
|
105
|
+
if (action.disabled) return;
|
|
106
|
+
action.run();
|
|
107
|
+
};
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// 重试
|
|
112
|
+
onInterruptResume?.({
|
|
113
|
+
operation: InterruptResumeOperation.FlowNodeRetry,
|
|
114
|
+
payload: { node_id: node.id, task_id: task.task_id },
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// 跳过
|
|
118
|
+
onInterruptResume?.({
|
|
119
|
+
operation: InterruptResumeOperation.FlowNodeSkip,
|
|
120
|
+
payload: { node_id: node.id, task_id: task.task_id },
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
| 按钮 | 显隐条件 | 进行中表现 | `operation` |
|
|
125
|
+
| ---- | ------------------------------------- | ---------------------------------- | ---------------------- |
|
|
126
|
+
| 重试 | 失败态且 `node.retryable === true`;且不在 Share 分享态、不在侧栏「执行情况」面板内 | loading +「重试中」,二者均禁用 | `flow_node_retry` |
|
|
127
|
+
| 跳过 | 失败态且 `node.skippable === true`;且不在 Share 分享态、不在侧栏「执行情况」面板内 | loading +「跳过中」,二者均禁用 | `flow_node_skip` |
|
|
128
|
+
| 详情 | 始终展示(含 Share 分享态与侧栏面板) | 不受 pending 影响 | —(打开侧栏 Tab,不走 resume) |
|
|
129
|
+
|
|
130
|
+
行尾操作由内部 composable [`useFlowNodeActions`](/composables/use-flow-node-actions) 聚合为声明式列表,组件层仅遍历渲染;两类只读场景合并为它的 `hideResumeActions` 入参。
|
|
131
|
+
|
|
132
|
+
## 节点详情联动
|
|
133
|
+
|
|
134
|
+
点击节点「详情」按钮时,组件调用 `addCustomTab` 注入一个以 `${task_id}|${node.id}|${node.name}` 为唯一 `name` 的 Tab,渲染组件为 `FlowAgentNodeDetail`:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
addCustomTab?.({
|
|
138
|
+
label: node.name,
|
|
139
|
+
name: `${task.task_id}|${node.id}|${node.name}`,
|
|
140
|
+
data: {
|
|
141
|
+
component: BkFlowNodeDetail,
|
|
142
|
+
messageUid: props.messageUid,
|
|
143
|
+
props: {
|
|
144
|
+
loading: true,
|
|
145
|
+
node_id: node.id,
|
|
146
|
+
node_name: node.name,
|
|
147
|
+
task_id: task.task_id,
|
|
148
|
+
task_name: task.task_name,
|
|
149
|
+
data: {},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> 实际节点详情数据由应用层在 `ChatContainer` 的 `onCustomTabChange` 中异步拉取后回填,组件本身只负责挂载占位与传参。组件卸载时(在消息容器滚动上下文中)会自动调用 `removeCustomTab` 清理对应 Tab。
|
|
156
|
+
|
|
157
|
+
## 组件结构
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
ActivityLayout(activity-type=flow_agent,v-model:collapsed)
|
|
161
|
+
├── #title(执行情况统计栏)
|
|
162
|
+
│ ├── AiLoading / ArrowRightIcon(加载态 / 折叠箭头)
|
|
163
|
+
│ └── flow-agent-stat-item × N(按收敛状态分类的计数)
|
|
164
|
+
└── flow-agent-task-group × N(任务)
|
|
165
|
+
├── flow-agent-task-header(点击折叠当前任务)
|
|
166
|
+
│ ├── task-arrow(任务展开箭头)
|
|
167
|
+
│ ├── task-state-icon(Loading / 状态图标)
|
|
168
|
+
│ ├── task-name(HighlightKeyword + 溢出提示)
|
|
169
|
+
│ └── task-time(任务总耗时 = 各节点耗时累加)
|
|
170
|
+
└── flow-agent-task-nodes(v-show 折叠)
|
|
171
|
+
└── flow-agent-node-item × N(节点;`is-pending` 时按钮组常驻)
|
|
172
|
+
├── node-status(Loading / 状态圆点)
|
|
173
|
+
├── node-name(HighlightKeyword + 溢出提示)
|
|
174
|
+
└── node-trailing(含 Share 分享态)
|
|
175
|
+
├── node-time(节点耗时,hover / pending 时隐藏)
|
|
176
|
+
└── node-actions(hover 或 `is-pending` 时显示,间距 12px)
|
|
177
|
+
├── node-action-btn「重试」(失败 + retryable;Share 态与侧栏面板隐藏;进行中 loading + 禁用)
|
|
178
|
+
├── node-action-btn「跳过」(失败 + skippable;Share 态与侧栏面板隐藏;进行中 loading + 禁用)
|
|
179
|
+
└── node-action-btn「详情」(始终可用,含 Share 态与侧栏面板,点击挂载详情 Tab)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API
|
|
183
|
+
|
|
184
|
+
### Props
|
|
185
|
+
|
|
186
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
187
|
+
| ---------- | ------------------------ | ---- | ----------- | -------------------------------------------------------------------------- |
|
|
188
|
+
| content | `BkFlowMessageContent` | 否 | `[{}]` | 任务数组;传入单个 `BkFlowTask` 时自动包装为单元素数组 |
|
|
189
|
+
| messageUid | `string` | 否 | — | 所属消息唯一标识,注入到节点详情 Tab 的 `data.messageUid`,用于异步回填数据 |
|
|
190
|
+
| onInterruptResume | `OnInterruptResume` | 否 | — | 节点「重试 / 跳过」与第三方审批取消复用同一回调,按 `payload.operation` 分流;流程节点操作时不传 `interrupt` |
|
|
191
|
+
| status | `MessageStatus` | 否 | — | 消息状态;`pending` / `streaming` 时标题栏显示加载动画 |
|
|
192
|
+
|
|
193
|
+
### Emits
|
|
194
|
+
|
|
195
|
+
- 无。
|
|
196
|
+
|
|
197
|
+
### Slots
|
|
198
|
+
|
|
199
|
+
- 无。
|
|
200
|
+
|
|
201
|
+
### Expose
|
|
202
|
+
|
|
203
|
+
- 无。
|
|
204
|
+
|
|
205
|
+
## 类型定义
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// 来自 @blueking/chat-x 导出
|
|
209
|
+
type BkFlowMessageContent = BkFlowTask[];
|
|
210
|
+
|
|
211
|
+
interface BkFlowTask {
|
|
212
|
+
task_id: number;
|
|
213
|
+
task_name: string;
|
|
214
|
+
task_state: string; // 原始任务状态,经 getConvergedState 归一
|
|
215
|
+
task_outputs: unknown; // 任务输出(当前展示区块已注释,不渲染)
|
|
216
|
+
statistics: {
|
|
217
|
+
state_counts: Record<string, number>; // 原始状态 → 数量,用于标题统计聚合
|
|
218
|
+
total: number;
|
|
219
|
+
};
|
|
220
|
+
nodes: Record<string, BkFlowNode>; // key 为节点 id
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface BkFlowNode {
|
|
224
|
+
id: string;
|
|
225
|
+
name: string;
|
|
226
|
+
state: string; // 原始节点状态
|
|
227
|
+
elapsed_time: number; // 耗时(秒)
|
|
228
|
+
type: string;
|
|
229
|
+
loop: number;
|
|
230
|
+
retry: number;
|
|
231
|
+
retryable?: boolean; // 是否可重试(失败节点「重试」按钮显隐)
|
|
232
|
+
skip: boolean;
|
|
233
|
+
skippable?: boolean; // 是否可跳过(失败节点「跳过」按钮显隐)
|
|
234
|
+
start_time: string;
|
|
235
|
+
finish_time: string;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## 组件依赖
|
|
240
|
+
|
|
241
|
+
- `AiLoading` — 标题栏流式加载动画
|
|
242
|
+
- `ActivityLayout` — 可折叠活动容器外壳
|
|
243
|
+
- `BkFlowNodeDetail` — 节点详情面板(经自定义 Tab 挂载)
|
|
244
|
+
- `Loading`(bkui-vue) — 运行中状态的旋转指示
|
|
245
|
+
- `HighlightKeyword` — 任务 / 节点名称的搜索关键词高亮
|
|
246
|
+
|
|
247
|
+
## 注意事项
|
|
248
|
+
|
|
249
|
+
1. **依赖自定义 Tab 上下文**:组件内部使用 `useCustomTabConsumer()!`,必须存在 `useCustomTabProvider` 提供者(`ChatContainer` 已内置)。脱离上下文直接使用需自行提供,否则详情入口会报错。
|
|
250
|
+
2. **统计来自 `statistics.state_counts` 而非节点遍历**:标题栏计数直接读取后端下发的统计,不会实时统计 `nodes`;两者不一致时以 `state_counts` 为准。
|
|
251
|
+
3. **任务总耗时为节点累加**:`task-time` 由各节点 `elapsed_time` 求和得到,并非任务级独立字段。
|
|
252
|
+
4. **`task_outputs` 暂不渲染**:模板中任务输出展示区块已注释,传入也不会显示。
|
|
253
|
+
5. **未知状态兜底为 `running`**:`getConvergedState` 对未识别的原始状态统一归为运行中。
|
|
254
|
+
6. **Share 模式只读查看**:`RenderMode.Share` 下保留节点/任务耗时与「详情」「有效证据」查看入口,仅过滤「重试 / 跳过」等交互式 resume 操作(由 `useFlowNodeActions` 的 `hideResumeActions` 收敛)。
|
|
255
|
+
7. **侧栏「执行情况」面板同为只读**:面板内经 `ExecutionSummary` → `MessageRender` 渲染的本组件不展示「重试 / 跳过」,只保留「详情」;判定来自 `useExecutionPanelInject()`(内部上下文,未从包入口导出;缺省 `false`),与 Share 态一起并入 `hideResumeActions`。因此脱离 `ExecutionSummary` 独立使用组件时,行为与对话流内一致。
|
|
256
|
+
8. **`onInterruptResume` 透传链路**:`MessageRender` → `ActivityMessage` → `FlowAgentContent`;未传入时重试 / 跳过按钮仍展示但点击无回调。
|
|
257
|
+
9. **pending 自动收敛**:`useFlowNodeActions` 以 `task_id:node_id:retry` 为 pending 键;节点重试再次失败(`retry` +1)后键变化,进行中态自动解除,无需手动清理。
|
|
258
|
+
|
|
259
|
+
## 关联组件
|
|
260
|
+
|
|
261
|
+
- [FlowAgentNodeDetail](/components/agent/flow-agent-node-detail) — 节点详情面板
|
|
262
|
+
- [ActivityLayout](/components/helper/activity-layout) — 可折叠活动容器
|
|
263
|
+
- [ChatContainer](/components/setup/chat-container) — 侧栏自定义 Tab 挂载场景
|
|
264
|
+
- [useFlowNodeActions](/composables/use-flow-node-actions) — 节点行尾操作聚合 composable
|
|
265
|
+
- [中断类型 Interrupt](/types/interrupt) — `InterruptResumeOperation`、`FlowNodeResume`、`OnInterruptResume`
|
|
266
|
+
- [使用建议] 优先通过上层组合组件(`MessageRender`)使用;直接使用前请确认 `content` 数据结构来自对应类型定义。
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# FlowAgentNodeDetail FlowAgent 节点详情
|
|
2
|
+
|
|
3
|
+
> 能力域:Agent 能力 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
展示 FlowAgent 节点输入、输出、异常、耗时等详情。 源码位置:src/components/chat-content/flow-agent-content/flow-agent-node-detail.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:flow-agent-content(节点详情入口由 FlowAgentContent 挂载到自定义 Tab)、detail-section(详情页内部分段容器)、simple-table(展示输入参数、插件输出定义与结构化输出)、chat-container(应用层通过 onCustomTabChange 拉取节点详情并回填)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# FlowAgentNodeDetail FlowAgent 节点详情
|
|
12
|
+
|
|
13
|
+
> **能力域**:Agent 能力
|
|
14
|
+
|
|
15
|
+
`FlowAgentNodeDetail` 用于展示 FlowAgent 单个节点的配置与输出详情。它通常被 `FlowAgentContent` 通过自定义 Tab 挂载到侧栏,应用层再根据 `messageUid`、`task_id`、`node_id` 拉取真实节点详情并回填到 `data`。
|
|
16
|
+
|
|
17
|
+
组件自身只负责详情展示,不负责接口请求、Tab 生命周期或消息定位逻辑。
|
|
18
|
+
|
|
19
|
+
## 源码事实
|
|
20
|
+
|
|
21
|
+
- **源码位置**:`src/components/chat-content/flow-agent-content/flow-agent-node-detail.vue`
|
|
22
|
+
- **能力说明**:展示 FlowAgent 节点输入、输出、异常、耗时等详情。
|
|
23
|
+
|
|
24
|
+
## 核心能力
|
|
25
|
+
|
|
26
|
+
- **双 Tab 展示**:内置“节点配置”和“节点输出”两个页签,默认展示“节点配置”
|
|
27
|
+
- **配置详情**:展示流程模板、节点名称、步骤名称、是否可选、失败处理和超时控制
|
|
28
|
+
- **参数表格**:使用 `SimpleTable` 展示输入参数、插件输出定义和结构化输出
|
|
29
|
+
- **加载骨架屏**:`loading` 为 `true` 时展示标题和内容骨架,不渲染真实数据
|
|
30
|
+
- **定位插槽**:提供 `locateButton` 插槽,允许侧栏注入“在对话中定位”等操作按钮
|
|
31
|
+
- **值格式化**:`null` / `undefined` 显示为 `--`,对象值通过 `JSON.stringify` 转为字符串
|
|
32
|
+
|
|
33
|
+
## 基础用法
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<template>
|
|
37
|
+
<FlowAgentNodeDetail
|
|
38
|
+
:data="nodeDetailData"
|
|
39
|
+
:loading="false"
|
|
40
|
+
node_id="n1"
|
|
41
|
+
node_name="采集主机指标"
|
|
42
|
+
:task_id="100"
|
|
43
|
+
task_name="主机巡检流程"
|
|
44
|
+
>
|
|
45
|
+
<template #locateButton>
|
|
46
|
+
<button type="button">定位</button>
|
|
47
|
+
</template>
|
|
48
|
+
</FlowAgentNodeDetail>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import FlowAgentNodeDetail from '@blueking/chat-x/src/components/chat-content/flow-agent-content/flow-agent-node-detail.vue';
|
|
53
|
+
import type { NodeDetailData } from '@blueking/chat-x';
|
|
54
|
+
|
|
55
|
+
const nodeDetailData: Partial<NodeDetailData> = {
|
|
56
|
+
basic_info: {
|
|
57
|
+
node_name: '采集主机指标',
|
|
58
|
+
template_name: '主机巡检流程',
|
|
59
|
+
stage_name: '巡检准备',
|
|
60
|
+
optional: false,
|
|
61
|
+
skippable: true,
|
|
62
|
+
retryable: true,
|
|
63
|
+
error_ignorable: false,
|
|
64
|
+
auto_retry: { enable: true, interval: 30, times: 2 },
|
|
65
|
+
timeout_config: { enable: true, seconds: 300, action: 'forced_fail' },
|
|
66
|
+
},
|
|
67
|
+
inputs: {
|
|
68
|
+
bk_host_id: 10001,
|
|
69
|
+
collect_items: ['cpu', 'memory', 'disk'],
|
|
70
|
+
},
|
|
71
|
+
plugin_output: [
|
|
72
|
+
{
|
|
73
|
+
key: '${cpu_usage}',
|
|
74
|
+
name: 'CPU 使用率',
|
|
75
|
+
type: 'number',
|
|
76
|
+
schema: { description: '当前主机 CPU 使用率', enum: [], type: 'number' },
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
outputs: [{ key: 'cpu_usage', preset: false, value: 23.5 }],
|
|
80
|
+
};
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**渲染效果**
|
|
85
|
+
|
|
86
|
+
## 加载态
|
|
87
|
+
|
|
88
|
+
`loading` 为 `true` 时,组件展示骨架屏,标题中的节点名和内容区均不会读取 `data` 展示。
|
|
89
|
+
|
|
90
|
+
## 空数据
|
|
91
|
+
|
|
92
|
+
当输入参数、插件输出定义或结构化输出为空时,对应 `SimpleTable` 渲染 `--` 占位行。
|
|
93
|
+
|
|
94
|
+
## Tab 内容
|
|
95
|
+
|
|
96
|
+
| Tab | 内容 |
|
|
97
|
+
| ---------- | ------------------------------------------------------------ |
|
|
98
|
+
| 节点配置 | 基础信息、失败处理、超时控制、输入参数、插件输出定义 |
|
|
99
|
+
| 节点输出 | 结构化输出,来自 `data.outputs` |
|
|
100
|
+
|
|
101
|
+
`activeTab` 是组件内部状态,不通过 prop 或 expose 暴露。
|
|
102
|
+
|
|
103
|
+
## 字段展示规则
|
|
104
|
+
|
|
105
|
+
| 区域 | 数据来源 | 展示规则 |
|
|
106
|
+
| ------------ | -------------------------------- | --------------------------------------------- |
|
|
107
|
+
| 流程模板 | `data.basic_info.template_name` | 空值显示 `--` |
|
|
108
|
+
| 节点名称 | `data.basic_info.node_name` | 空值显示 `--` |
|
|
109
|
+
| 步骤名称 | `data.basic_info.stage_name` | 空值显示 `--` |
|
|
110
|
+
| 是否可选 | `data.basic_info.optional` | `true` 显示“是”,否则显示“否” |
|
|
111
|
+
| 失败处理 | `skippable` / `auto_retry.enable` | 支持“手动跳过”和“自动重试”;均无时显示 `--` |
|
|
112
|
+
| 超时控制 | `timeout_config` | 未启用时显示 `--`;`forced_fail` 显示“强制失败” |
|
|
113
|
+
| 输入参数 | `data.inputs` | 对象条目转为 `{ key, value }` 表格 |
|
|
114
|
+
| 插件输出定义 | `data.plugin_output` | 展示名称、变量说明和 KEY |
|
|
115
|
+
| 结构化输出 | `data.outputs` | 展示输出 key 与格式化后的 value |
|
|
116
|
+
|
|
117
|
+
## 自定义 Tab 联动
|
|
118
|
+
|
|
119
|
+
`FlowAgentContent` 点击节点“详情”时,会将本组件挂载到自定义 Tab,并先传入 `loading: true` 和节点定位参数:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
addCustomTab?.({
|
|
123
|
+
label: node.name,
|
|
124
|
+
name: `${task.task_id}|${node.id}|${node.name}`,
|
|
125
|
+
data: {
|
|
126
|
+
component: BkFlowNodeDetail,
|
|
127
|
+
messageUid: props.messageUid,
|
|
128
|
+
props: {
|
|
129
|
+
loading: true,
|
|
130
|
+
node_id: node.id,
|
|
131
|
+
node_name: node.name,
|
|
132
|
+
task_id: task.task_id,
|
|
133
|
+
task_name: task.task_name,
|
|
134
|
+
data: {},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
应用层通常在 `ChatContainer` 的 `onCustomTabChange` 中读取这些参数,请求节点详情后返回新的 `props.data` 和 `props.loading`。
|
|
141
|
+
|
|
142
|
+
## API
|
|
143
|
+
|
|
144
|
+
### Props
|
|
145
|
+
|
|
146
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
147
|
+
| --------- | -------------------------- | ---- | ------ | ---------------------------- |
|
|
148
|
+
| data | `Partial<NodeDetailData>` | 是 | — | 节点详情数据 |
|
|
149
|
+
| loading | `boolean` | 否 | — | 是否显示骨架屏 |
|
|
150
|
+
| node_id | `string` | 否 | — | 节点 ID,来自自定义 Tab 参数 |
|
|
151
|
+
| node_name | `string` | 否 | — | 节点名称 |
|
|
152
|
+
| task_id | `number` | 否 | — | 任务 ID |
|
|
153
|
+
| task_name | `string` | 否 | — | 任务名称 |
|
|
154
|
+
|
|
155
|
+
> Props 类型来自 `CustomBkFlowTabData['props'] & { data: Partial<NodeDetailData> }`。
|
|
156
|
+
|
|
157
|
+
### Emits
|
|
158
|
+
|
|
159
|
+
- 无。
|
|
160
|
+
|
|
161
|
+
### Slots
|
|
162
|
+
|
|
163
|
+
| 插槽名 | 说明 |
|
|
164
|
+
| ------------ | ---------------------------- |
|
|
165
|
+
| locateButton | 标题栏右侧操作区,如定位按钮 |
|
|
166
|
+
|
|
167
|
+
### Expose
|
|
168
|
+
|
|
169
|
+
- 无。
|
|
170
|
+
|
|
171
|
+
## 类型定义
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
export type CustomBkFlowTabData = CustomTabData<{
|
|
175
|
+
data?: Partial<NodeDetailData>;
|
|
176
|
+
loading?: boolean;
|
|
177
|
+
node_id?: string;
|
|
178
|
+
node_name?: string;
|
|
179
|
+
task_id?: number;
|
|
180
|
+
task_name?: string;
|
|
181
|
+
}>;
|
|
182
|
+
|
|
183
|
+
export interface NodeDetailData {
|
|
184
|
+
inputs: Record<string, unknown>;
|
|
185
|
+
node_id: string;
|
|
186
|
+
task_id: number;
|
|
187
|
+
basic_info: {
|
|
188
|
+
auto_retry: {
|
|
189
|
+
enable: boolean;
|
|
190
|
+
interval: number;
|
|
191
|
+
times: number;
|
|
192
|
+
};
|
|
193
|
+
error_ignorable: boolean;
|
|
194
|
+
node_name: string;
|
|
195
|
+
optional: boolean;
|
|
196
|
+
retryable: boolean;
|
|
197
|
+
skippable: boolean;
|
|
198
|
+
stage_name: string;
|
|
199
|
+
template_name: string;
|
|
200
|
+
timeout_config: {
|
|
201
|
+
action: string;
|
|
202
|
+
enable: boolean;
|
|
203
|
+
seconds: number;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
outputs: Array<{
|
|
207
|
+
key: string;
|
|
208
|
+
preset: boolean;
|
|
209
|
+
value: unknown;
|
|
210
|
+
}>;
|
|
211
|
+
plugin_output: Array<{
|
|
212
|
+
key: string;
|
|
213
|
+
name: string;
|
|
214
|
+
schema: {
|
|
215
|
+
description: string;
|
|
216
|
+
enum: unknown[];
|
|
217
|
+
properties?: Record<string, unknown>;
|
|
218
|
+
type: string;
|
|
219
|
+
};
|
|
220
|
+
type: string;
|
|
221
|
+
}>;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 使用建议
|
|
226
|
+
|
|
227
|
+
- 优先由 [FlowAgentContent](./flow-agent-content.md) 通过自定义 Tab 挂载,不建议业务组件手动拼装 Tab 生命周期。
|
|
228
|
+
- 接口请求与数据回填应放在应用层 `ChatContainer` 的 `onCustomTabChange` 链路中处理。
|
|
229
|
+
- `data` 可传 `Partial<NodeDetailData>`,但真实展示依赖 `basic_info`、`inputs`、`plugin_output`、`outputs` 等字段;缺字段时对应区域会降级为空表格或 `--`。
|
|
230
|
+
|
|
231
|
+
## 关联组件
|
|
232
|
+
|
|
233
|
+
- [FlowAgentContent](./flow-agent-content.md) — 节点详情入口。
|
|
234
|
+
- [DetailSection](./detail-section.md) — 详情分段容器。
|
|
235
|
+
- [SimpleTable](./simple-table.md) — 详情表格。
|
|
236
|
+
- [ChatContainer](../setup/chat-container.md) — 自定义 Tab 数据回填入口。
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# HighlightKeyword 关键词高亮
|
|
2
|
+
|
|
3
|
+
> 能力域:辅助能力 | 导入:`import { HighlightKeyword } from '@blueking/chat-x'` | since 1.0.0
|
|
4
|
+
|
|
5
|
+
根据注入关键词高亮文本片段。 源码位置:src/components/highlight-keyword/highlight-keyword.ts。
|
|
6
|
+
|
|
7
|
+
**关联**:toolcall-render(工具调用标题与状态文案高亮)、desc-panel(工具详情键值与描述文本高亮)、execution-summary(执行摘要搜索过滤与列表高亮)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# HighlightKeyword 关键词高亮
|
|
12
|
+
## 源码事实
|
|
13
|
+
|
|
14
|
+
- **源码位置**:`src/components/highlight-keyword/highlight-keyword.ts`
|
|
15
|
+
- **能力域**:辅助能力
|
|
16
|
+
- **能力说明**:根据注入关键词高亮文本片段。
|
|
17
|
+
|
|
18
|
+
> **能力域**:辅助能力
|
|
19
|
+
|
|
20
|
+
函数式组件,用于在文本中高亮匹配的搜索关键词。通过 `useKeywordInject` 从上层注入关键词,自动将匹配部分包裹在带高亮样式的 `<span>` 中。
|
|
21
|
+
|
|
22
|
+
主要配合 `ExecutionSummary` 的搜索功能使用,实现搜索结果的视觉高亮。
|
|
23
|
+
|
|
24
|
+
## 工作原理
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
props.text + inject(keyword)
|
|
28
|
+
│
|
|
29
|
+
├── keyword 为空 → 直接渲染原文本
|
|
30
|
+
│
|
|
31
|
+
└── keyword 非空
|
|
32
|
+
├── 正则 split 文本为 parts[]
|
|
33
|
+
├── parts.length === 1 → 无匹配,渲染原文本
|
|
34
|
+
└── parts.length > 1 → 匹配部分用 <span class="highlight"> 包裹
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
组件使用 `defineComponent` + `h()` 渲染函数实现,不依赖模板。
|
|
38
|
+
|
|
39
|
+
## 基础用法
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<HighlightKeyword :text="text" />
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { HighlightKeyword } from '@blueking/chat-x';
|
|
48
|
+
|
|
49
|
+
const text = '这是一段包含 Vue 3 Composition API 的示例文本';
|
|
50
|
+
</script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> **注意**:关键词通过 `useKeywordProvider` / `useKeywordInject`(`provide/inject`)注入,不通过 props 传入。上层需先调用 `useKeywordProvider()` 设置关键词。
|
|
54
|
+
|
|
55
|
+
**渲染效果**(在输入框中输入关键词,观察文本高亮变化)
|
|
56
|
+
|
|
57
|
+
## 关键词高亮示例
|
|
58
|
+
|
|
59
|
+
预设关键词为 `API`,文本中所有匹配部分会以高亮背景显示:
|
|
60
|
+
|
|
61
|
+
## 与 ExecutionSummary 配合
|
|
62
|
+
|
|
63
|
+
`ExecutionSummary` 内部通过 `useKeywordProvider` 提供搜索关键词,后代组件中的 `HighlightKeyword` 自动响应:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
ExecutionSummary
|
|
67
|
+
├── useKeywordProvider(keyword) ← Input 绑定
|
|
68
|
+
└── MessageRender
|
|
69
|
+
└── AssistantMessage
|
|
70
|
+
└── ToolcallRender
|
|
71
|
+
└── HighlightKeyword(:text) ← inject(keyword)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 配套 Composables
|
|
75
|
+
|
|
76
|
+
### useKeywordProvider
|
|
77
|
+
|
|
78
|
+
在上层组件中创建关键词并 `provide`,后代组件通过 `useKeywordInject` 消费:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { useKeywordProvider } from '@blueking/chat-x';
|
|
82
|
+
|
|
83
|
+
const { keyword } = useKeywordProvider();
|
|
84
|
+
keyword.value = '搜索词';
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### useKeywordInject
|
|
88
|
+
|
|
89
|
+
在后代组件中注入关键词,返回 `ComputedRef<string> | undefined`:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { useKeywordInject } from '@blueking/chat-x';
|
|
93
|
+
|
|
94
|
+
const keyword = useKeywordInject();
|
|
95
|
+
console.log(keyword?.value); // 当前搜索关键词
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### useKeywordMatch
|
|
99
|
+
|
|
100
|
+
用于判断组件的可搜索文本是否与当前关键词匹配。内部调用 `useKeywordInject` 获取关键词,根据传入的文本提取函数判断是否命中:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { useKeywordMatch } from '@blueking/chat-x';
|
|
104
|
+
|
|
105
|
+
const { keywordMatched } = useKeywordMatch(() => [props.title, props.description, props.content]);
|
|
106
|
+
|
|
107
|
+
// keywordMatched.value === true 表示命中搜索
|
|
108
|
+
// keywordMatched.value === false 表示未命中(可据此隐藏组件)
|
|
109
|
+
// keyword 为空时始终返回 true
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`useKeywordMatch` 的典型用途是在 `ExecutionSummary` 的搜索过滤中,让组件自行判断是否匹配搜索词,与 `HighlightKeyword` 配合实现搜索 + 高亮。
|
|
113
|
+
|
|
114
|
+
## API
|
|
115
|
+
|
|
116
|
+
### Props
|
|
117
|
+
|
|
118
|
+
| 属性名 | 类型 | 必填 | 说明 |
|
|
119
|
+
| ------ | -------- | ---- | ---------- |
|
|
120
|
+
| text | `string` | ✓ | 待高亮文本 |
|
|
121
|
+
|
|
122
|
+
### 依赖注入
|
|
123
|
+
|
|
124
|
+
| 注入项 | 提供方 | 说明 |
|
|
125
|
+
| ------- | -------------------- | ---------------------- |
|
|
126
|
+
| keyword | `useKeywordProvider` | 搜索关键词,响应式更新 |
|
|
127
|
+
|
|
128
|
+
### 配套 Composables
|
|
129
|
+
|
|
130
|
+
| 函数名 | 参数 | 返回值 | 说明 |
|
|
131
|
+
| -------------------- | ----------------------------------------------- | ------------------------------------------ | --------------------------------------------- |
|
|
132
|
+
| `useKeywordProvider` | — | `{ keyword: ShallowRef<string> }` | 创建并 `provide` 关键词,用于上层组件 |
|
|
133
|
+
| `useKeywordInject` | — | `ComputedRef<string> \| undefined` | 注入关键词,用于后代组件 |
|
|
134
|
+
| `useKeywordMatch` | `getSearchTexts: () => (string \| undefined)[]` | `{ keywordMatched: ComputedRef<boolean> }` | 判断组件文本是否匹配关键词,空关键词返回 true |
|
|
135
|
+
|
|
136
|
+
### CSS 类名
|
|
137
|
+
|
|
138
|
+
| 类名 | 说明 |
|
|
139
|
+
| ----------------------- | ----------------------------------- |
|
|
140
|
+
| `.ai-highlight-keyword` | 匹配文本的高亮样式(背景色 + 圆角) |
|
|
141
|
+
|
|
142
|
+
## 关联组件
|
|
143
|
+
|
|
144
|
+
- [ToolcallRender](/components/agent/toolcall-render) — 工具调用头部高亮
|
|
145
|
+
- [DescPanel](/components/rendering/desc-panel) — 详情面板键值高亮
|
|
146
|
+
- [ExecutionSummary](/components/agent/execution-summary) — 执行摘要搜索
|