# tencentblueking/bk-aidev-agent architecture

> Architecture diagram of the GitHub repository tencentblueking/bk-aidev-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencentblueking/bk-aidev-agent
- Repository: https://github.com/tencentblueking/bk-aidev-agent

## Overview

该仓库提供蓝鲸 AIDev 智能体开发框架及其生态集成：用户通过 AI 小鲸进行流式对话，智能体运行时组织模型、工具与知识能力，蓝鲸插件和企业微信插件提供平台及消息渠道接入。图保留文档明确列出的能力；由于未提供多数核心模块的源码摘录，内部调用关系仅在有证据时连线。

Main entry points: [`src/agent/aidev_agent/core/graphs/react/graph.py`](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/graphs/react/graph.py) (智能体流程), [`src/frontend/ai-blueking/packages/ai-blueking/src/components/chat-bot.vue`](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/components/chat-bot.vue) (对话组件), [`src/plugins/aidev_bkplugin/aidev_bkplugin/apps.py`](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/apps.py) (蓝鲸智能体插件), [`src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py`](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py) (持久事件总线)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["AI 小鲸前端"]
  node_chat_ui["对话组件<br/>[chat-bot.vue]"]
  node_session_ui["会话管理"]
  node_model_ui["模型选择"]
  node_chat_helper["对话客户端<br/>[use-agent.ts]"]
end

subgraph group_runtime["智能体运行时"]
  node_agent_flow["智能体流程<br/>[graph.py]"]
  node_model_chain["模型与中间件<br/>[model_chain.py]"]
  node_tool_runtime["工具调用<br/>[node.py]"]
  node_knowledge["知识检索<br/>[knowledge.py]"]
  node_runtime_tools["沙箱运行工具<br/>[provider.py]"]
  node_interrupts["审批与提问<br/>[processor.py]"]
  node_message_handlers["消息处理<br/>[factory.py]"]
end

subgraph group_platform["蓝鲸平台插件"]
  node_bk_plugin["蓝鲸智能体插件<br/>[apps.py]"]
  node_event_bus["持久事件总线"]
  node_event_store[("插件事件模型<br/>[models.py]")]
end

subgraph group_channels["消息渠道"]
  node_wxbot["企业微信机器人"]
end

subgraph group_telemetry["运行观测"]
  node_otel_handler["追踪回调"]
  node_agent_metrics["智能体指标<br/>[metrics.py]"]
  node_metric_export["插件指标导出<br/>[otel_metrics.py]"]
end

node_user(("用户"))

node_user -->|"发起对话"| node_chat_ui
node_chat_ui -.->|"提交消息"| node_chat_helper
node_chat_helper -.->|"连接智能体"| node_bk_plugin
node_bk_plugin -->|"接入框架"| node_agent_flow
node_agent_flow -.->|"调用模型"| node_model_chain
node_agent_flow -->|"调用工具"| node_tool_runtime
node_agent_flow -.->|"检索知识"| node_knowledge
node_tool_runtime -.->|"运行沙箱"| node_runtime_tools
node_agent_flow -.->|"请求审批"| node_interrupts
node_agent_flow -->|"流式输出"| node_message_handlers
node_session_ui -->|"管理会话"| node_chat_ui
node_model_ui -.->|"选择模型"| node_chat_ui
node_bk_plugin -->|"发布事件"| node_event_bus
node_event_bus -->|"持久化投递"| node_event_store
node_wxbot -->|"消费事件"| node_event_bus
node_agent_flow -.->|"记录运行"| node_otel_handler
node_otel_handler -->|"记录指标"| node_agent_metrics
node_metric_export -->|"导出指标"| node_agent_metrics

click node_chat_ui "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/components/chat-bot.vue"
click node_session_ui "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/session-business-manager.ts"
click node_model_ui "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/model-selection-manager.ts"
click node_chat_helper "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/chat-helper/src/agent/use-agent.ts"
click node_agent_flow "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/graphs/react/graph.py"
click node_model_chain "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/model/model_chain.py"
click node_tool_runtime "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/tool/node.py"
click node_knowledge "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/knowledge.py"
click node_runtime_tools "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/tools/runtime_tools/provider.py"
click node_interrupts "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/interrupt_manager/processor.py"
click node_message_handlers "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/services/messages_handler/factory.py"
click node_bk_plugin "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/apps.py"
click node_event_bus "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py"
click node_event_store "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/models.py"
click node_wxbot "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_wxbot/aidev_wxbot/wxaibot/database_delivery.py"
click node_otel_handler "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/opentelemetry/callback_handler.py"
click node_agent_metrics "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/opentelemetry/metrics.py"
click node_metric_export "https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/services/otel_metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat_ui,node_session_ui,node_model_ui,node_chat_helper toneBlue
class node_agent_flow,node_model_chain,node_tool_runtime,node_knowledge,node_runtime_tools,node_interrupts,node_message_handlers toneAmber
class node_bk_plugin,node_event_bus,node_event_store toneMint
class node_wxbot toneRose
class node_otel_handler,node_agent_metrics,node_metric_export,node_user toneIndigo
```

## Components

### AI 小鲸前端

- [对话组件](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/components/chat-bot.vue): `src/frontend/ai-blueking/packages/ai-blueking/src/components/chat-bot.vue`
- [会话管理](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/session-business-manager.ts): `src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/session-business-manager.ts`
- [模型选择](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/model-selection-manager.ts): `src/frontend/ai-blueking/packages/ai-blueking/src/manager/business/model-selection-manager.ts`
- [对话客户端](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/frontend/ai-blueking/packages/chat-helper/src/agent/use-agent.ts): `src/frontend/ai-blueking/packages/chat-helper/src/agent/use-agent.ts`

### 智能体运行时

- [智能体流程](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/graphs/react/graph.py): `src/agent/aidev_agent/core/graphs/react/graph.py`
- [模型与中间件](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/model/model_chain.py): `src/agent/aidev_agent/core/nodes/model/model_chain.py`
- [工具调用](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/tool/node.py): `src/agent/aidev_agent/core/nodes/tool/node.py`
- [知识检索](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/nodes/knowledge.py): `src/agent/aidev_agent/core/nodes/knowledge.py`
- [沙箱运行工具](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/core/tools/runtime_tools/provider.py): `src/agent/aidev_agent/core/tools/runtime_tools/provider.py`
- [审批与提问](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/interrupt_manager/processor.py): `src/agent/aidev_agent/packages/interrupt_manager/processor.py`
- [消息处理](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/services/messages_handler/factory.py): `src/agent/aidev_agent/services/messages_handler/factory.py`

### 蓝鲸平台插件

- [蓝鲸智能体插件](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/apps.py): `src/plugins/aidev_bkplugin/aidev_bkplugin/apps.py`
- [持久事件总线](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py): `src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py`
- [插件事件模型](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/models.py): `src/plugins/aidev_bkplugin/aidev_bkplugin/models.py`

### 消息渠道

- [企业微信机器人](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_wxbot/aidev_wxbot/wxaibot/database_delivery.py): `src/plugins/aidev_wxbot/aidev_wxbot/wxaibot/database_delivery.py`

### 运行观测

- [追踪回调](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/opentelemetry/callback_handler.py): `src/agent/aidev_agent/packages/opentelemetry/callback_handler.py`
- [智能体指标](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/agent/aidev_agent/packages/opentelemetry/metrics.py): `src/agent/aidev_agent/packages/opentelemetry/metrics.py`
- [插件指标导出](https://github.com/tencentblueking/bk-aidev-agent/blob/develop/src/plugins/aidev_bkplugin/aidev_bkplugin/services/otel_metrics.py): `src/plugins/aidev_bkplugin/aidev_bkplugin/services/otel_metrics.py`

### Other components

- **用户**

## Connections

- 用户 → 对话组件: 发起对话
- 对话组件 → 对话客户端: 提交消息
- 对话客户端 → 蓝鲸智能体插件: 连接智能体
- 蓝鲸智能体插件 → 智能体流程: 接入框架
- 智能体流程 → 模型与中间件: 调用模型
- 智能体流程 → 工具调用: 调用工具
- 智能体流程 → 知识检索: 检索知识
- 工具调用 → 沙箱运行工具: 运行沙箱
- 智能体流程 → 审批与提问: 请求审批
- 智能体流程 → 消息处理: 流式输出
- 会话管理 → 对话组件: 管理会话 (evidence: `src/frontend/ai-blueking/packages/ai-blueking/src/composables/use-session-handlers.ts`)
- 模型选择 → 对话组件: 选择模型
- 蓝鲸智能体插件 → 持久事件总线: 发布事件
- 持久事件总线 → 插件事件模型: 持久化投递 (evidence: `src/plugins/aidev_bkplugin/aidev_bkplugin/services/database_event_bus.py`)
- 企业微信机器人 → 持久事件总线: 消费事件 (evidence: `src/plugins/aidev_wxbot/aidev_wxbot/wxaibot/database_delivery.py`)
- 智能体流程 → 追踪回调: 记录运行
- 追踪回调 → 智能体指标: 记录指标 (evidence: `src/agent/aidev_agent/packages/opentelemetry/callback_handler.py`)
- 插件指标导出 → 智能体指标: 导出指标 (evidence: `src/plugins/aidev_bkplugin/aidev_bkplugin/services/otel_metrics.py`)
