Add full-stack Agent execution tracking and analytics:
**Database (conversation-service)**
- New `agent_executions` table: tracks each specialist Agent invocation
with agentType, agentName, durationMs, success, tenantId
- Migration: AddAgentExecutionsTable1738800000000
- ORM entity: AgentExecutionORM with indexes on tenant, conversation,
agentType, createdAt, and (tenant+date) composite
**Data Capture (conversation-service)**
- conversation.service.ts: captures `agent_start` and `agent_complete`
StreamChunk events in the sendMessage() async generator loop
- Persists agent execution records to DB after each message completes
- Non-blocking: agent persistence failures are logged but don't break
the main conversation flow
**Admin API (conversation-service)**
- GET /conversations/admin/statistics/agents?days=30
Aggregated stats per agent type: totalCalls, successCount, failureCount,
successRate, avgDurationMs, min/max duration
- GET /conversations/admin/statistics/agents/trend?days=7&agentType=
Daily trend data: date, agentType, calls, avgDurationMs, successRate
- GET /conversations/admin/:id/agent-executions
Per-conversation agent execution records ordered by createdAt
**Admin Client - Analytics Page**
- New AgentAnalyticsTab component with:
- 4 summary cards (total calls, success rate, avg duration, top agent)
- Agent statistics table (Ant Design Table with sortable columns,
color-coded Tags, Progress bar for success rate)
- Stacked bar trend chart (Recharts BarChart, color per agent type)
- Time range selectors (7/14/30/90 days)
- Added as third tab "Agent 使用分析" in AnalyticsPage dimension tabs
**Admin Client - Conversations Page**
- Added "Agent 使用详情" section to conversation detail drawer
(between Token Usage and Messages sections)
- Shows per-conversation agent execution table with agent name (color Tag),
duration, success/failure status, and timestamp
- Empty state: "暂无 Agent 使用记录"
Agent color mapping: policy_expert=#1890ff, assessment_expert=#52c41a,
strategist=#722ed1, objection_handler=#eb2f96, case_analyst=#faad14,
memory_manager=#13c2c2
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
||
|---|---|---|
| .claude | ||
| database/migrations | ||
| docs | ||
| infrastructure | ||
| kong | ||
| nginx | ||
| packages | ||
| scripts | ||
| .builder.Dockerfile | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| README.md | ||
| deploy.sh | ||
| docker-compose.yml | ||
| iconsulting部署架构.jpg | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| tsconfig.base.json | ||
| turbo.json | ||
| 优才.jpg | ||
| 香港移民类别.jpg | ||
README.md
iConsulting - 香港移民在线咨询系统
基于 Claude Agent SDK 的智能在线客服系统,专注于提供香港移民咨询服务。
功能特性
- 智能咨询: 基于 Claude Agent SDK 的自然语言对话
- 付费评估: 移民资格评估服务,支持支付宝/微信/信用卡
- 知识增强: RAG + Neo4j 知识图谱
- 自我进化: 从对话中学习,根据管理员指令调整
- 长期记忆: 基于时间线的知识图谱记录
- 多端支持: PC Web / H5 响应式设计
支持的移民类别
- 优才计划 (QMAS) - 行业翘楚、精英人士
- 专才计划 (GEP) - 专业人才
- 留学IANG - 非本地毕业生
- 高才通 (TTPS) - 高端人才
- 投资移民 (CIES) - 投资者
- 科技人才 (TechTAS) - 科技领域人才
技术架构
├── 前端 (Clean Architecture)
│ ├── React 18 + TypeScript
│ ├── TailwindCSS + Radix UI
│ └── Zustand + React Query
│
├── 后端 (DDD + Hexagonal + 微服务)
│ ├── NestJS
│ ├── Claude Agent SDK
│ └── TypeORM
│
└── 基础设施
├── PostgreSQL + pgvector (RAG)
├── Neo4j (知识图谱)
├── Redis (缓存)
└── Kafka (消息队列)
项目结构
iconsulting/
├── packages/
│ ├── shared/ # 共享类型、常量、工具
│ ├── web-client/ # 用户端 Web 应用
│ ├── admin-client/ # 管理端 Web 应用
│ └── services/ # 后端微服务
│ ├── api-gateway/ # API 网关
│ ├── user-service/ # 用户服务
│ ├── conversation-service/ # 对话服务 (核心)
│ ├── knowledge-service/ # 知识服务
│ ├── payment-service/ # 支付服务
│ ├── admin-service/ # 管理服务
│ └── evolution-service/ # 进化服务
│
├── infrastructure/
│ └── docker/ # Docker 配置
│
├── DEVELOPMENT_GUIDE.md # 详细开发指导
└── README.md
快速开始
1. 安装依赖
# 安装 pnpm (如果没有)
npm install -g pnpm
# 安装项目依赖
pnpm install
2. 启动基础设施
# 启动 Docker 容器 (PostgreSQL, Neo4j, Redis, Kafka)
pnpm docker:dev
3. 配置环境变量
# 复制环境变量示例文件
cp .env.example .env
# 编辑 .env 文件,填入必要的配置
# 特别是 ANTHROPIC_API_KEY
4. 运行数据库迁移
pnpm db:migrate
5. 启动开发服务器
# 启动所有服务
pnpm dev
访问:
- 用户端: http://localhost:5173
- 管理端: http://localhost:5174
- API: http://localhost:3000
环境变量
关键配置项:
# Claude API
ANTHROPIC_API_KEY=sk-ant-xxx
# 数据库
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=iconsulting
POSTGRES_PASSWORD=your_password
POSTGRES_DB=iconsulting
# Neo4j
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_password
# 支付 (支付宝/微信)
ALIPAY_APP_ID=xxx
WECHAT_APP_ID=xxx
完整配置请参考 .env.example
文档
| 文档 | 说明 |
|---|---|
| 架构文档 | 系统整体架构、服务职责、数据流、部署配置 |
| Agent 评估报告 | Agent 能力评估、成熟度分析、升级路线图 |
| 开发指南 | 详细开发指导、代码示例、API 设计 |
| MinIO 配置 | 对象存储配置说明 |
开发进度
已完成
- 项目架构设计
- 开发指导文档
- Monorepo 配置
- 共享类型定义
- Docker 基础设施配置
- 数据库 Schema
- 对话服务 (Claude Agent SDK 集成)
- 用户端前端基础框架
进行中
- 用户服务
- 知识服务 (RAG + Neo4j)
- 支付服务
- 管理服务 (自我进化)
- 管理后台前端
贡献指南
- Fork 本仓库
- 创建特性分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
许可证
私有项目,保留所有权利。