hailin
5034ef4a70
feat(admin): add System Supervisor — global system status chat interface
...
Add a "系统总监" (System Supervisor) feature that provides admins with
a natural language chat interface to query the entire iConsulting system's
operational status, including all 7 specialist agents, directives, token
usage, conversation statistics, and system health.
Backend:
- SystemSupervisorChatService: Haiku 4.5 with 7 read-only tools
- get_agent_configs: list all 7 agent model/parameter configs
- get_agent_execution_stats: execution counts, success rates, latency
- get_directives_summary: assessment + collection directive overview
- get_token_usage_stats: token consumption and cost by model
- get_conversation_stats: conversation counts, conversion rates, stages
- get_evaluation_rules: quality gate rule configuration
- get_system_health: circuit breakers, Redis, service availability
- AdminSupervisorController: POST /conversations/admin/supervisor/chat
- Registered in AgentsModule (provider + export) and ConversationModule
- Added AgentExecutionORM to TypeOrmModule.forFeature in AgentsModule
Frontend (admin-client):
- features/supervisor/ with Clean Architecture layers:
- infrastructure/supervisor.api.ts: HTTP client
- application/useSupervisor.ts: React Query mutation hook
- presentation/pages/SupervisorPage.tsx: full-page chat UI
- Quick action buttons: 系统概况, Agent统计, 成本报告, 健康检查
- Route: /supervisor, menu icon: EyeOutlined (between 收集指令 and 数据分析)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:49:57 -08:00
hailin
8e4bd95dda
feat(agents): add Collection Expert specialist + admin directive system
...
## Part A: Collection Expert Specialist Agent (7th specialist)
- New specialist: CollectionExpertService (Haiku 4.5, maxTurns 2)
- Analyzes user info completeness against 12-item weighted checklist
- Identifies missing fields, recommends next questions
- Category-specific priority adjustments (QMAS/GEP/IANG/TTPS/CIES/TechTAS)
- Tools: search_knowledge, get_user_context
- Admin directive injection: loads active directives from DB before each run
- Prompt: collection-expert-prompt.ts (completeness calc, validation rules, JSON output)
- Coordinator integration: invoke_collection_expert tool + case in executeAgentTool
- System prompt: section 2.6 usage guide, section 4.3 optional invocation reference
## Part B: Admin Directive System (parallel to assessment directives)
- ORM: CollectionDirectiveORM (collection_directives table)
- Types: general, priority, category, validation
- Multi-tenant with tenant_id + enabled indexes
- SQL: CREATE TABLE collection_directives in init-db.sql
- Controller: /conversations/admin/collection-directives (10 REST endpoints)
- CRUD + toggle + reset + preview + AI chat
- Chat Service: CollectionDirectiveChatService (Haiku 4.5 tool loop)
- 5 tools: list/create/update/delete/reset directives
- mutated flag for frontend cache invalidation
## Part C: Frontend Admin-Client
- Feature module: features/collection-config/ (5 files)
- API client, React Query hooks, Config page, Chat drawer
- Directive types: 通用指令/优先级调整/类别配置/验证规则
- Route: /collection-config in App.tsx
- Sidebar: FormOutlined icon, label '收集指令' in MainLayout.tsx
Files: 11 new, 9 modified | Backend + frontend compile clean
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:07:33 -08:00
hailin
9feb03153b
feat(agents): add admin assessment directive system for dynamic prompt injection
...
Admins can now write natural-language directives that get injected into the
assessment expert's system prompt. Directives are stored in DB, loaded per
execution, and support incremental additions, toggling, and full reset.
Backend:
- New assessment_directives table + ORM entity
- Admin CRUD API at /conversations/admin/assessment-directives
- buildAssessmentExpertPrompt() accepts optional adminDirectives param
- AssessmentExpertService loads active directives from DB before each execution
- Fail-safe: missing repo/tenant context → default prompt (no directives)
Frontend (admin-client):
- New "评估指令" page with table, create/edit modals, toggle switches
- Prompt preview panel showing assembled directive text
- Reset-to-default with confirmation
- React Query hooks for all CRUD operations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:21:21 -08:00
hailin
85c78b0775
feat(admin): add system observability dashboard with circuit breaker monitoring
...
Backend: expose circuit breaker status via new AdminObservabilityController
(health, circuit-breakers, redis endpoints). Frontend: new observability
feature in admin-client with auto-refreshing status cards.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 05:28:24 -08:00
hailin
714a674818
feat(mcp): add MCP Server management — backend API + admin UI
...
实现完整的 MCP (Model Context Protocol) 服务器管理功能,包括后端 API 和管理界面。
## 后端 (conversation-service)
### MCP 混合架构核心 (新增)
- mcp.types.ts: MCP 类型定义 (McpServerConfig, McpToolDefinition, McpConnectionState 等)
- mcp-config.service.ts: 配置解析 — 支持环境变量 MCP_SERVERS 和租户级配置
- mcp-client.service.ts: MCP 客户端 — 连接管理、工具发现、工具执行、运行时增删改
- mcp.module.ts: @Global NestJS 模块,注册 MCP 服务 + TypeORM 实体 + Repository
### 数据持久化 (新增)
- 20260206_add_mcp_server_configs.sql: 数据库迁移 — mcp_server_configs 表
- mcp-server-config.orm.ts: TypeORM 实体 (tenant_id 支持多租户)
- mcp-server-config.repository.ts: Repository 层 (CRUD + ORM→McpServerConfig 转换)
### Admin API (新增)
- admin-mcp.controller.ts: 11 个管理端点,路由前缀 conversations/admin/mcp
- GET /overview — 统计信息 (服务器总数、已连接、错误、工具总数)
- GET/POST /servers — 列表 + 创建
- GET/PUT/DELETE /servers/:id — 详情 + 更新 + 删除
- POST /servers/:id/connect — 手动连接
- POST /servers/:id/disconnect — 手动断开
- GET /servers/:id/tools — 查看已发现工具
- POST /servers/:id/test — 测试连接
- POST /test-config — 测试未保存的配置
### 已有文件修改
- coordinator-tools.ts: getToolsForClaudeAPI() 支持 additionalTools 可选参数
- agent-loop.ts: 支持 additionalTools + additionalConcurrencyMap 透传
- coordinator-agent.service.ts: 注入 McpClientService,工具路由加 MCP 分支
- agents.module.ts: 导入 McpModule
- conversation.module.ts: 注册 AdminMcpController
## 前端 (admin-client)
### API + Hooks (新增)
- mcp.api.ts: Axios API 客户端 + 完整 TypeScript 类型定义
- useMcp.ts: 10 个 React Query hooks (queries + mutations)
### UI 页面 (新增)
- McpPage.tsx: 主页面 — 统计卡片 + 服务器表格 + 操作按钮
- ServerFormDrawer.tsx: 创建/编辑表单 — 基本信息、传输配置、高级设置、连接测试
- ServerDetailDrawer.tsx: 详情抽屉 — 配置展示、工具浏览 (Collapse + JSON Schema)
### 路由 + 导航
- App.tsx: 添加 /mcp 路由
- MainLayout.tsx: 侧边栏添加 "MCP 服务器" 菜单项 (ApiOutlined 图标)
## 依赖
- @modelcontextprotocol/sdk: ^1.0.0 (MCP 协议 SDK)
## 架构设计
- 混合架构: 16 个内置工具保持不变 + MCP 工具动态发现/热插拔
- 工具名前缀 mcp__{serverId}__{toolName} 确保零冲突
- 优雅降级: MCP 连接失败不影响内置工具,仅 log 记录
- 启动加载: 先连接环境变量配置,再连接数据库配置
- 运行时管理: 支持不重启服务即可增删改 MCP Server
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 18:29:02 -08:00
hailin
7f03a4d870
fix(admin-client): add x-admin-id header for super admin API requests
...
- Add x-admin-id header to API interceptor from auth store
- Required for super admin tenant management APIs
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 08:53:40 -08:00
hailin
481c13b67d
feat(admin-client): add tenant management page
...
- Add tenants feature module with Clean Architecture structure
- Create tenantsApi for super admin endpoints
- Add React Query hooks for tenant CRUD operations
- Implement TenantsPage with statistics, list, and modals
- Add tenant route and sidebar menu item
- Support create/edit tenant, suspend/activate, admin management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 07:03:14 -08:00
hailin
931055b51f
feat(admin): add conversation management with device tracking display
...
## Backend (conversation-service)
- Add AdminConversationController with JWT auth for admin API
- Endpoints: list conversations, by user, detail, messages, statistics
- Support filtering by status, userId, date range, conversion
- Add JWT_SECRET environment variable to docker-compose.yml
- Add jsonwebtoken dependency for admin token verification
## Frontend (admin-client)
### New Features:
- Add conversations feature module with:
- API layer (conversations.api.ts)
- React Query hooks (useConversations.ts)
- ConversationsPage with full management UI
### User Management Enhancement:
- Add "最近咨询记录" section in user detail drawer
- Display device info for each conversation:
- IP address with region
- User-Agent (parsed to browser/OS)
- Device fingerprint
- Show conversation status, conversion status, message count
### Navigation:
- Add "对话管理" menu item with MessageOutlined icon
- Add /conversations route
## Files Added:
- admin-conversation.controller.ts (backend admin API)
- conversations feature folder (frontend)
- infrastructure/conversations.api.ts
- application/useConversations.ts
- presentation/pages/ConversationsPage.tsx
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:04:17 -08:00
hailin
042d2e1456
feat(analytics): implement statistics, financial reports, and audit logging
...
Backend (evolution-service):
- Add analytics module with scheduled statistics aggregation
- Implement daily_statistics aggregation (OVERALL, CHANNEL, CATEGORY)
- Add monthly financial report generation and management
- Create audit log service for operation tracking
- Schedule cron jobs for automatic data aggregation
Frontend (admin-client):
- Replace dashboard mock data with real API calls
- Add analytics page with trend charts and dimension breakdown
- Add financial reports page with confirm/lock workflow
- Add audit logs page with filtering and detail view
- Update navigation with analytics submenu
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:01:39 -08:00
hailin
9e1dca25f2
refactor(admin-client): implement 3-layer Clean Architecture for frontend
...
Refactored admin-client from 1.5-layer to 3-layer architecture using
Feature-Sliced Design pattern with Zustand + TanStack Query.
## Architecture Pattern
Each feature now follows 3-layer structure:
```
features/{feature}/
├── presentation/ # React UI components, pages
├── application/ # Zustand stores, TanStack Query hooks
└── infrastructure/ # API clients (axios calls)
```
## Changes by Feature
### Auth Feature
- infrastructure/auth.api.ts: Login, verify API calls
- application/useAuthStore.ts: Zustand store for auth state
- Updated LoginPage.tsx to use useAuthStore
- shared/hooks/useAuth.ts: Re-exports for backward compatibility
### Knowledge Feature
- infrastructure/knowledge.api.ts: Article CRUD APIs
- application/useKnowledge.ts: TanStack Query hooks
- useKnowledgeArticles, useCreateArticle, useUpdateArticle
- useDeleteArticle, usePublishArticle, useUnpublishArticle
- Updated KnowledgePage.tsx to use application hooks
### Experience Feature
- infrastructure/experience.api.ts: Experience management APIs
- application/useExperience.ts: TanStack Query hooks
- usePendingExperiences, useExperienceStatistics
- useApproveExperience, useRejectExperience, useRunEvolution
- Updated ExperiencePage.tsx to use application hooks
### Dashboard Feature
- infrastructure/dashboard.api.ts: Statistics APIs
- application/useDashboard.ts: TanStack Query hooks
- useEvolutionStatistics, useSystemHealth
- Updated DashboardPage.tsx to use application hooks
## Benefits
- Clear separation of concerns (UI / business logic / data access)
- Better testability (each layer can be tested independently)
- Reusable hooks across components
- Type-safe API interfaces
- Centralized API error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 22:17:48 -08:00
hailin
e6e69f15ce
fix(admin): correct 401 redirect path to include /admin prefix
...
The API interceptor was redirecting to /login on 401 errors, but since
admin-client is deployed under /admin/, it should redirect to /admin/login.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 07:57:43 -08:00
hailin
a7add8ff90
Initial commit: iConsulting 香港移民咨询智能客服系统
...
项目架构:
- Monorepo (pnpm + Turborepo)
- 后端: NestJS 微服务 + Claude Agent SDK
- 前端: React + Vite + Ant Design
包含服务:
- conversation-service: 对话服务 (Claude AI)
- user-service: 用户认证服务
- payment-service: 支付服务 (支付宝/微信/Stripe)
- knowledge-service: 知识库服务 (RAG + Neo4j)
- evolution-service: 自我进化服务
- web-client: 用户前端
- admin-client: 管理后台
基础设施:
- PostgreSQL + Redis + Neo4j
- Kong API Gateway
- Nginx 反向代理
- Docker Compose 部署配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 00:01:12 -08:00