hailin
e898e6551d
feat(gateway): add per-key model override and alias for transparent model routing
...
Admin can configure modelOverride (actual upstream model) and modelAlias
(name shown to users) per API key. When set, users don't need to specify
the real model — the gateway substitutes it transparently in both requests
and responses (including SSE streams).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 00:31:26 -08:00
hailin
0114e9896d
fix(admin-client): remove unused imports in llm-gateway components
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 23:13:40 -08:00
hailin
6476bd868f
feat(llm-gateway): 新增对外 LLM API 代理服务 — 完整的监管注入、内容审查和管理后台
...
## 新增微服务: llm-gateway (端口 3008)
对外提供与 Anthropic/OpenAI 完全兼容的 API 接口,中间拦截实现:
- API Key 认证:由我们分配 Key 给外部用户,SHA-256 哈希存储
- System Prompt 注入:在请求转发前注入监管合规内容(支持 prepend/append)
- 内容审查过滤:对用户消息进行关键词/正则匹配,支持 block/warn/log 三种动作
- 用量记录:异步批量写入,跟踪 token 消耗和费用估算
- 审计日志:记录每次请求的来源 IP、过滤状态、注入状态等
- 速率限制:基于内存滑动窗口的 RPM 限制
### 技术选型
- Fastify (非 NestJS):纯代理场景无需 DI 容器,路由开销 ~2ms
- SSE 流式管道:零缓冲直通,支持 Anthropic streaming 和 OpenAI streaming
- 规则缓存:30 秒 TTL,避免每次请求查库
### API 端点
- POST /v1/messages — Anthropic Messages API 代理(流式+非流式)
- POST /v1/embeddings — OpenAI Embeddings API 代理
- POST /v1/chat/completions — OpenAI Chat Completions API 代理
- GET /health — 健康检查
## 数据库 (5 张新表)
- gateway_api_keys: 外部用户 API Key(权限、限速、预算、过期时间)
- gateway_injection_rules: 监管内容注入规则(位置、匹配模型、匹配 Key)
- gateway_content_rules: 内容审查规则(关键词/正则、block/warn/log)
- gateway_usage_logs: Token 用量记录(按 Key、模型、提供商统计)
- gateway_audit_logs: 请求审计日志(IP、过滤状态、注入状态)
## Admin 后端 (conversation-service)
4 个 NestJS 控制器,挂载在 /conversations/admin/gateway/ 下:
- AdminGatewayKeysController: Key 的 CRUD + toggle
- AdminGatewayInjectionRulesController: 注入规则 CRUD + toggle
- AdminGatewayContentRulesController: 内容审查规则 CRUD + toggle
- AdminGatewayDashboardController: 仪表盘汇总、用量查询、审计日志查询
5 个 ORM 实体文件对应 5 张数据库表。
## Admin 前端 (admin-client)
新增 features/llm-gateway 模块,Tabs 布局包含 5 个管理面板:
- API Key Tab: 创建/删除/启停 Key,创建时一次性显示完整 Key
- 注入规则 Tab: 配置监管内容(前置/追加到 system prompt)
- 内容审查 Tab: 配置关键词/正则过滤规则
- 用量统计 Tab: 查看 token 消耗、费用、响应时间
- 审计日志 Tab: 查看请求记录、过滤命中、注入状态
菜单项: GatewayOutlined + "LLM 网关",位于"系统总监"和"数据分析"之间。
## 基础设施
- docker-compose.yml: 新增 llm-gateway 服务定义
- kong.yml: 新增 /v1/messages、/v1/embeddings、/v1/chat/completions 路由
- 超时设置 300 秒(LLM 长响应)
- CORS 新增 X-Api-Key、anthropic-version、anthropic-beta 头
- init-db.sql: 新增 5 张 gateway 表的建表语句
## 架构说明
内部服务(conversation-service、knowledge-service、evolution-service)继续直连 API,
llm-gateway 仅服务外部用户。两者通过共享 PostgreSQL 数据库关联配置。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:32:25 -08:00
hailin
1f6d473649
feat(admin): add multimodal image paste support to all admin chat interfaces
...
支持管理员在3个管理聊天界面(系统总监、评估指令、收集指令)中通过
粘贴板粘贴图片,实现与管理Agent的多模态对话。
**新增文件:**
- `shared/hooks/useImagePaste.ts`: 共享 hook,处理剪贴板图片粘贴、
base64 转换、待发送图片管理、多模态内容块构建
**后端改动 (conversation-service):**
- 3个管理聊天服务 (system-supervisor-chat, directive-chat,
collection-directive-chat): chat() 方法参数类型从 `content: string`
改为 `content: Anthropic.MessageParam['content']`,支持接收图片块
- 3个管理控制器 (admin-supervisor, admin-assessment-directive,
admin-collection-directive): DTO content 类型改为 `any` 以透传
前端发送的多模态内容
**前端改动 (admin-client):**
- 3个 API 类型文件: ChatMessage.content 类型扩展为
`string | ContentBlock[]`
- SupervisorPage: 集成 useImagePaste hook,添加 onPaste 处理、
待发送图片预览(64x64 缩略图+删除按钮)、消息中图片渲染
- DirectiveChatDrawer: 同上,48x48 缩略图适配 Drawer 宽度
- CollectionChatDrawer: 同上
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 21:18:57 -08:00
hailin
3b6e1586b7
fix(admin): add Markdown rendering to assessment & collection chat drawers
...
Both directive chat drawers were rendering AI responses as plain text.
Apply the same ReactMarkdown + remark-gfm treatment used in supervisor.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 21:03:22 -08:00
hailin
12e622040a
fix(admin): add Markdown rendering to System Supervisor chat
...
Supervisor responses contain rich Markdown (tables, headers, bold,
lists, code). Previously rendered as plain text with pre-wrap.
- Install react-markdown + remark-gfm for GFM table support
- Wrap assistant messages in ReactMarkdown component
- Add .supervisor-markdown CSS styles (tables, headings, lists, hr, code)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 21:01:20 -08:00
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
22bca31690
feat(agents): add AI chat interface for directive management
...
Add a conversational chat drawer to the assessment config admin page,
allowing admins to manage assessment directives via natural language.
Backend:
- DirectiveChatService: Haiku 4.5 LLM with 5 tools (list, create,
update, delete, reset) and iterative tool loop (max 5 turns)
- System prompt dynamically includes current directive state from DB
- POST /chat endpoint on admin-assessment-directive controller
- Registered in AgentsModule (global), injected via @Optional()
Frontend:
- DirectiveChatDrawer: Ant Design Drawer (480px) with message list,
input box (Enter to send, Shift+Enter for newline), loading state
- useDirectiveChat hook: React Query mutation, auto-invalidates
directive queries when response.mutated === true
- "AI 助手" button added to AssessmentConfigPage header
Files:
- NEW: agents/admin/directive-chat.service.ts (LLM tool-loop service)
- NEW: components/DirectiveChatDrawer.tsx (chat drawer UI)
- MOD: agents.module.ts (register + export DirectiveChatService)
- MOD: admin-assessment-directive.controller.ts (POST /chat endpoint)
- MOD: assessment-config.api.ts (chat API method + types)
- MOD: useAssessmentConfig.ts (useDirectiveChat hook)
- MOD: AssessmentConfigPage.tsx (AI button + drawer integration)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 19:17:07 -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
93ed3343de
refactor(knowledge): separate file upload into independent entry point
...
将知识库的"新建文章"和"上传文件"拆分为两个独立入口:
UI 改动:
- 移除 Segmented 切换器,"新建文章"弹窗恢复为纯手动输入
- 新增独立的"上传文件"按钮 + 上传弹窗(Upload.Dragger)
- 上传提取完成后自动打开"确认提取内容"弹窗,预填标题+内容
- 管理员编辑确认后保存,文章来源标记为 EXTRACT
后端改动:
- CreateArticleDto 新增可选 source 字段
- Controller 使用 dto.source || MANUAL(不再硬编码 MANUAL)
流程:
- 新建文章 → 手动输入 → source = MANUAL
- 上传文件 → 提取文本 → 编辑确认 → source = EXTRACT
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 23:29:37 -08:00
hailin
e16ec7930d
feat(knowledge): add file upload with text extraction for knowledge base
...
支持在管理后台知识库页面上传文件(PDF、Word、TXT、Markdown),
自动提取文本内容,管理员预览编辑后保存为知识库文章。
## 后端 (knowledge-service)
- 新增 TextExtractionService:文件文本提取服务
- PDF 提取:使用 pdf-parse v2 (PDFParse class API)
- Word (.docx) 提取:使用 mammoth.extractRawText()
- TXT/Markdown:直接 UTF-8 解码
- 支持中英文混合字数统计
- 文件大小限制 200MB,类型校验(MIME 白名单)
- 空文本 PDF(扫描件/图片)返回友好错误提示
- 新增上传接口:POST /knowledge/articles/upload
- 使用 NestJS FileInterceptor 处理 multipart/form-data
- 仅提取文本并返回,不直接创建文章(两步流程)
- 返回:extractedText, suggestedTitle, wordCount, pageCount
- 新增 ExtractedTextResponse DTO
- KnowledgeModule 注册 TextExtractionService
## 前端 (admin-client)
- knowledge.api.ts:新增 uploadFile() 方法(FormData + 120s 超时)
- useKnowledge.ts:新增 useUploadKnowledgeFile hook
- KnowledgePage.tsx:
- 新增 Segmented 切换器(手动输入 / 文件上传),仅新建时显示
- 文件上传模式显示 Upload.Dragger 拖拽上传区域
- 上传后自动提取文本,填入标题+内容字段
- 提取完成自动切回手动模式,管理员可预览编辑后保存
- 显示提取结果(字数、页数)
## 用户流程
新建文章 → 切换"文件上传" → 拖入/选择文件 → 系统提取文本
→ 自动填入标题+内容 → 管理员编辑确认 → 点击保存
## 依赖
- pdf-parse@^2.4.5(PDF 文本提取)
- mammoth@^1.8.0(Word 文档文本提取)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:58:19 -08:00
hailin
cc4b7d50e3
feat(admin-client): add manual experience creation in ExperiencePage
...
管理员现在可以在"系统经验管理"页面手动创建经验,而不仅限于审核系统自动生成的经验。
实现细节:
- experience.api.ts: 新增 CreateExperienceDto 类型和 createExperience() API 方法
- 调用 POST /memory/experience 创建经验
- 创建后自动调用 POST /memory/experience/:id/approve 激活
- 管理员手动创建的经验无需额外审核流程
- sourceConversationId 标记为 'admin-manual' 以区分来源
- 默认置信度 80%(高于系统自动生成的 45%)
- useExperience.ts: 新增 useCreateExperience mutation hook
- 创建成功后自动刷新经验列表和统计数据
- ExperiencePage.tsx: 新增"新建经验"按钮和创建表单弹窗
- 表单字段:经验类型、适用场景、经验内容、相关移民类别(可选)、置信度
- 移民类别下拉:QMAS/GEP/IANG/TTPS/CIES/TechTAS
- 表单验证:类型、场景、内容为必填
这与方案A(评估门控失败自动沉淀经验)互补:
- 自动路径:Gate failure → PENDING experience → 管理员审核 → 激活
- 手动路径:管理员直接创建 → 自动激活(无需审核)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:09:47 -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
691a3523e8
feat(analytics): add Agent usage analytics to admin panel
...
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>
2026-02-06 08:00:55 -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
2d4e6285a4
feat(admin): add global token usage statistics
...
- Add token aggregation to statistics/overview endpoint
- Include total tokens, cost, and API calls for all time
- Include today's token usage and cost breakdown
- Display token stats in ConversationsPage with 2 rows of cards
- Add formatNumber helper for K/M number formatting
- Export GlobalTokenStats and TodayTokenStats types
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 17:29:59 -08:00
hailin
7acdf78e0c
fix(conversation): improve token tracking accuracy
...
- Add 'error' chunk type to StreamChunk for partial token capture
- Record partial tokens to token_usage table even on API errors
- Capture error chunk tokens in conversation.service.ts
- Save partial response and tokens before re-throwing errors
- Add token aggregation from token_usage table for accurate stats
- Display detailed token info in admin (cache tokens, cost, API calls)
- Export TokenDetails type for frontend consumption
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 17:23:25 -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
6a3a2130bf
feat(conversation): add device tracking and optimize admin-client build
...
## Device Tracking (conversation-service)
- Add DeviceInfoDto class for validating device information
- Extract client IP from X-Forwarded-For and X-Real-IP headers
- Capture User-Agent header automatically on conversation creation
- Support optional fingerprint and region from client
- Pass deviceInfo through service layer to entity for persistence
Files changed:
- conversation.controller.ts: Add extractClientIp() method and header capture
- conversation.dto.ts: Add DeviceInfoDto with validation decorators
- conversation.service.ts: Update CreateConversationParams interface
## Build Optimization (admin-client)
- Implement code splitting via Rollup manualChunks
- Separate vendor libraries into cacheable chunks:
- vendor-react: react, react-dom, react-router-dom (160KB)
- vendor-antd: antd, @ant-design/icons (1013KB)
- vendor-charts: recharts (409KB)
- vendor-data: @tanstack/react-query, axios, zustand (82KB)
- Main bundle reduced from 1732KB to 61KB (96% reduction)
- Set chunkSizeWarningLimit to 1100KB for antd
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:45:47 -08:00
hailin
e0c2462017
feat(admin): add user management and system settings pages
...
Backend (user-service):
- Add admin user management APIs (list, search, statistics, detail)
- Add pagination and filtering support for user queries
- Add JWT token authentication for admin endpoints
Frontend (admin-client):
- Add UsersPage with user list, search, filters and statistics
- Add SettingsPage with admin profile, password change, system info
- Update App.tsx routes to use new pages
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:58:35 -08:00
hailin
f95bc71254
fix(dashboard): remove failing evolution/health API calls
...
The useEvolutionStatistics and useSystemHealth hooks call endpoints that
depend on a non-existent knowledge-service internal API. Removed these
calls and the related UI sections to prevent 500 errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:33:08 -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
731323ad7c
fix(admin): add basename to BrowserRouter for /admin/ deployment
...
The router needs basename="/admin" to work correctly when deployed
under the /admin/ subpath.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 07:50:22 -08:00
hailin
cb0b8c6ea9
fix(admin): configure base path for /admin/ deployment
...
- Add base: '/admin/' to vite.config.ts for proper asset paths
- Replace vite.svg favicon with inline SVG emoji icon
- Fixes 404 errors when accessing admin panel at /admin/ path
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 07:35:52 -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