feat(aia): Complete AIA V2.0 with universal streaming capabilities

Major Changes:
- Add StreamingService with OpenAI Compatible format
- Upgrade Chat component V2 with Ant Design X integration
- Implement AIA module with 12 intelligent agents
- Update API routes to unified /api/v1 prefix
- Update system documentation

Backend (~1300 lines):
- common/streaming: OpenAI Compatible adapter
- modules/aia: 12 agents, conversation service, streaming integration
- Update route versions (RVW, PKB to v1)

Frontend (~3500 lines):
- modules/aia: AgentHub + ChatWorkspace (100% prototype restoration)
- shared/Chat: AIStreamChat, ThinkingBlock, useAIStream Hook
- Update API endpoints to v1

Documentation:
- AIA module status guide
- Universal capabilities catalog
- System overview updates
- All module documentation sync

Tested: Stream response verified, authentication working
Status: AIA V2.0 core completed (85%)
This commit is contained in:
2026-01-14 19:15:01 +08:00
parent 3d35e9c58b
commit 1b53ab9d52
386 changed files with 52096 additions and 65238 deletions

View File

@@ -82,7 +82,7 @@ interface SendChatMessageBody {
/**
* 发送消息(流式输出)
*
* POST /api/v2/pkb/chat/stream
* POST /api/v1/pkb/chat/stream
*/
export async function sendMessageStream(
request: FastifyRequest<{ Body: SendChatMessageBody }>,

View File

@@ -54,3 +54,4 @@ export default async function healthRoutes(fastify: FastifyInstance) {

View File

@@ -6,44 +6,44 @@
### ========================================
### 1. 创建任务(上传稿件)
### POST /api/v2/rvw/tasks
### POST /api/v1/rvw/tasks
### ========================================
# 注意需要使用工具如Postman上传文件
# curl -X POST http://localhost:3001/api/v2/rvw/tasks \
# 注æ„<EFBFBD>:需è¦<EFBFBD>使用工具(å¦Postman)上传æ‡ä»?
# curl -X POST http://localhost:3001/api/v1/rvw/tasks \
# -F "file=@test.docx" \
# -F "modelType=deepseek-v3"
### ========================================
### 2. 获å<C2B7>任务列表
### GET /api/v2/rvw/tasks
### GET /api/v1/rvw/tasks
### ========================================
### 获å<C2B7>全部任务
GET {{baseUrl}}/api/v2/rvw/tasks
GET {{baseUrl}}/api/v1/rvw/tasks
Content-Type: application/json
### 获取待处理任务
GET {{baseUrl}}/api/v2/rvw/tasks?status=pending
### 获å<EFBFBD>待处ç<EFBFBD>†ä»»åŠ?
GET {{baseUrl}}/api/v1/rvw/tasks?status=pending
Content-Type: application/json
### 获取已完成任务
GET {{baseUrl}}/api/v2/rvw/tasks?status=completed
### 获å<EFBFBD>已完æˆ<EFBFBD>ä»»åŠ?
GET {{baseUrl}}/api/v1/rvw/tasks?status=completed
Content-Type: application/json
### 分页获å<C2B7>
GET {{baseUrl}}/api/v2/rvw/tasks?page=1&limit=10
GET {{baseUrl}}/api/v1/rvw/tasks?page=1&limit=10
Content-Type: application/json
### ========================================
### 3. è¿<C3A8>è¡Œå®¡æŸ¥ï¼ˆé€‰æ©æ™ºèƒ½ä½“)
### POST /api/v2/rvw/tasks/:taskId/run
### POST /api/v1/rvw/tasks/:taskId/run
### ========================================
### å<>ªé€‰æ©è§„范性智能体
POST {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}/run
POST {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}/run
Content-Type: application/json
{
@@ -51,15 +51,15 @@ Content-Type: application/json
}
### å<>ªé€‰æ©æ¹æ³•学智能体
POST {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}/run
POST {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}/run
Content-Type: application/json
{
"agents": ["methodology"]
}
### 同时选择两个智能体(默认)
POST {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}/run
### å<EFBFBD>Œæ—¶é€‰æ©ä¸¤ä¸ªæ™ºèƒ½ä½“(默认ï¼?
POST {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}/run
Content-Type: application/json
{
@@ -69,10 +69,10 @@ Content-Type: application/json
### ========================================
### 4. 批é‡<C3A9>è¿<C3A8>行审查
### POST /api/v2/rvw/tasks/batch/run
### POST /api/v1/rvw/tasks/batch/run
### ========================================
POST {{baseUrl}}/api/v2/rvw/tasks/batch/run
POST {{baseUrl}}/api/v1/rvw/tasks/batch/run
Content-Type: application/json
{
@@ -83,28 +83,28 @@ Content-Type: application/json
### ========================================
### 5. 获å<C2B7>任务详情
### GET /api/v2/rvw/tasks/:taskId
### GET /api/v1/rvw/tasks/:taskId
### ========================================
GET {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}
GET {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}
Content-Type: application/json
### ========================================
### 6. 获å<C2B7>审查报åŠ
### GET /api/v2/rvw/tasks/:taskId/report
### GET /api/v1/rvw/tasks/:taskId/report
### ========================================
GET {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}/report
GET {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}/report
Content-Type: application/json
### ========================================
### 7. 删除任务
### DELETE /api/v2/rvw/tasks/:taskId
### DELETE /api/v1/rvw/tasks/:taskId
### ========================================
DELETE {{baseUrl}}/api/v2/rvw/tasks/{{taskId}}
DELETE {{baseUrl}}/api/v1/rvw/tasks/{{taskId}}
Content-Type: application/json
@@ -112,15 +112,15 @@ Content-Type: application/json
### 旧版API(兼容性æµè¯•)
### ========================================
### 旧版:获取任务列表
### 旧版:获å<EFBFBD>任务列è¡?
GET {{baseUrl}}/api/v1/review/tasks
Content-Type: application/json
### 旧版:获取任务状态
### 旧版:获å<EFBFBD>任务状æ€?
GET {{baseUrl}}/api/v1/review/tasks/{{taskId}}
Content-Type: application/json
### 旧版:获取报告
### 旧版:获å<EFBFBD>报å?
GET {{baseUrl}}/api/v1/review/tasks/{{taskId}}/report
Content-Type: application/json
@@ -132,3 +132,4 @@ Content-Type: application/json

View File

@@ -9,95 +9,95 @@ Write-Host "RVW模块 Phase 1 API测试" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
# 璉<><E79289><EFBFBD><E4BAA4><E288AA>臬炏餈鞱<E9A488>
Write-Host "1. 检查服务器状态..." -ForegroundColor Yellow
Write-Host "1. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?.." -ForegroundColor Yellow
try {
$health = Invoke-RestMethod -Uri "$BaseUrl/health" -Method Get
Write-Host " ✅ 服务器运行中" -ForegroundColor Green
Write-Host " <EFBFBD>?<3F>滚𦛚<E6BB9A><EFBFBD>銵䔶葉" -ForegroundColor Green
} catch {
Write-Host " ❌ 服务器未运行,请先启动后端: cd backend && npm run dev" -ForegroundColor Red
Write-Host " <EFBFBD>?<3F>滚𦛚<E6BB9A>冽𧊋餈鞱<E9A488>嚗諹窈<E8ABB9><E7AA88><EFBFBD><EFBFBD>蝡? cd backend && npm run dev" -ForegroundColor Red
exit 1
}
# 瘚贝<E7989A>1: <20><EFBFBD>隞餃𦛚<E9A483>𡑒”嚗<E2809D><E59A97><EFBFBD><EFBFBD><EFBFBD><E996AC>隡𩤃<E99AA1>
Write-Host "`n2. 测试获取任务列表 (GET /api/v2/rvw/tasks)..." -ForegroundColor Yellow
Write-Host "`n2. 瘚贝<EFBFBD><EFBFBD><EFBFBD>隞餃𦛚<EFBFBD>𡑒” (GET /api/v1/rvw/tasks)..." -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri "$BaseUrl/api/v2/rvw/tasks" -Method Get
Write-Host " ✅ 成功! 当前任务数: $($response.pagination.total)" -ForegroundColor Green
$response = Invoke-RestMethod -Uri "$BaseUrl/api/v1/rvw/tasks" -Method Get
Write-Host " <EFBFBD>?<3F>𣂼<EFBFBD>! 敶枏<E695B6>隞餃𦛚<E9A483>? $($response.pagination.total)" -ForegroundColor Green
if ($response.data.Count -gt 0) {
Write-Host " 最近任务: $($response.data[0].fileName) - $($response.data[0].status)" -ForegroundColor Gray
Write-Host " <EFBFBD><EFBFBD>餈睲遙<EFBFBD>? $($response.data[0].fileName) - $($response.data[0].status)" -ForegroundColor Gray
}
} catch {
Write-Host " ❌ 失败: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " <EFBFBD>?憭梯揖: $($_.Exception.Message)" -ForegroundColor Red
}
# 测试2: 按状态筛选
Write-Host "`n3. 测试筛选待处理任务 (GET /api/v2/rvw/tasks?status=pending)..." -ForegroundColor Yellow
# 瘚贝<EFBFBD>2: <20>厩𠶖<E58EA9><F0A0B696><EFBFBD><EFBFBD>?
Write-Host "`n3. 瘚贝<EFBFBD>蝑偦<EFBFBD><EFBFBD><EFBFBD><EFBFBD>隞餃𦛚 (GET /api/v1/rvw/tasks?status=pending)..." -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri "$BaseUrl/api/v2/rvw/tasks?status=pending" -Method Get
Write-Host " ✅ 成功! 待处理任务数: $($response.pagination.total)" -ForegroundColor Green
$response = Invoke-RestMethod -Uri "$BaseUrl/api/v1/rvw/tasks?status=pending" -Method Get
Write-Host " <EFBFBD>?<3F>𣂼<EFBFBD>! 敺<><E695BA><EFBFBD><EFBFBD><EFBFBD>⊥㺭: $($response.pagination.total)" -ForegroundColor Green
} catch {
Write-Host " ❌ 失败: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " <EFBFBD>?憭梯揖: $($_.Exception.Message)" -ForegroundColor Red
}
# 瘚贝<E7989A>3: 銝𠹺<E98A9D><F0A0B9BA><EFBFBD><EFBFBD>𥕦遣隞餃𦛚
Write-Host "`n4. 测试上传文件 (POST /api/v2/rvw/tasks)..." -ForegroundColor Yellow
Write-Host "`n4. 瘚贝<EFBFBD>銝𠹺<EFBFBD><EFBFBD><EFBFBD> (POST /api/v1/rvw/tasks)..." -ForegroundColor Yellow
if (Test-Path $TestFile) {
try {
# 使用curl上传PowerShell的Invoke-RestMethod对multipart支持不好)
$curlResult = & curl.exe -s -X POST "$BaseUrl/api/v2/rvw/tasks" `
# 雿輻鍂curl銝𠹺<EFBFBD>嚗㇊owerShell<EFBFBD><EFBFBD>nvoke-RestMethod撖雋ultipart<EFBFBD><EFBFBD>銝滚末嚗?
$curlResult = & curl.exe -s -X POST "$BaseUrl/api/v1/rvw/tasks" `
-F "file=@$TestFile" `
-F "modelType=deepseek-v3"
$uploadResponse = $curlResult | ConvertFrom-Json
if ($uploadResponse.success) {
$taskId = $uploadResponse.data.taskId
Write-Host " ✅ 上传成功! TaskId: $taskId" -ForegroundColor Green
Write-Host " 文件名: $($uploadResponse.data.fileName)" -ForegroundColor Gray
Write-Host " <EFBFBD>?銝𠹺<E98A9D><F0A0B9BA>𣂼<EFBFBD>! TaskId: $taskId" -ForegroundColor Green
Write-Host " <EFBFBD><EFBFBD><EFBFBD>? $($uploadResponse.data.fileName)" -ForegroundColor Gray
# 蝑匧<E89D91><E58CA7><EFBFBD><EFBFBD>𣂼<EFBFBD>
Write-Host "`n5. 等待文档提取3秒..." -ForegroundColor Yellow
Write-Host "`n5. 蝑匧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>𣂼<EFBFBD>嚗?蝘𡜐<E89D98>..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
# 瘚贝<E7989A>4: <20><EFBFBD>隞餃𦛚霂行<E99C82>
Write-Host "`n6. 测试获取任务详情 (GET /api/v2/rvw/tasks/$taskId)..." -ForegroundColor Yellow
Write-Host "`n6. 瘚贝<EFBFBD><EFBFBD><EFBFBD>隞餃𦛚霂行<EFBFBD> (GET /api/v1/rvw/tasks/$taskId)..." -ForegroundColor Yellow
try {
$detail = Invoke-RestMethod -Uri "$BaseUrl/api/v2/rvw/tasks/$taskId" -Method Get
Write-Host " ✅ 成功! 状态: $($detail.data.status)" -ForegroundColor Green
$detail = Invoke-RestMethod -Uri "$BaseUrl/api/v1/rvw/tasks/$taskId" -Method Get
Write-Host " <EFBFBD>?<3F>𣂼<EFBFBD>! <20><EFBFBD>? $($detail.data.status)" -ForegroundColor Green
} catch {
Write-Host " ❌ 失败: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " <EFBFBD>?憭梯揖: $($_.Exception.Message)" -ForegroundColor Red
}
# 瘚贝<E7989A>5: 餈鞱<E9A488>摰⊥䰻嚗<E4B0BB><EFBFBD><EFBFBD><E39591><EFBFBD><EFBFBD><EFBFBD>
Write-Host "`n7. 测试运行审查-只选规范性 (POST /api/v2/rvw/tasks/$taskId/run)..." -ForegroundColor Yellow
Write-Host "`n7. 瘚贝<EFBFBD>餈鞱<EFBFBD>摰⊥䰻-<2D><EFBFBD><EFBFBD><E39591><EFBFBD><EFBFBD>?(POST /api/v1/rvw/tasks/$taskId/run)..." -ForegroundColor Yellow
try {
$body = @{ agents = @("editorial") } | ConvertTo-Json
$runResult = Invoke-RestMethod -Uri "$BaseUrl/api/v2/rvw/tasks/$taskId/run" `
$runResult = Invoke-RestMethod -Uri "$BaseUrl/api/v1/rvw/tasks/$taskId/run" `
-Method Post -Body $body -ContentType "application/json"
Write-Host " ✅ 审查任务已启动!" -ForegroundColor Green
Write-Host " ⏳ 注意AI评估需要1-2分钟可稍后查看报告" -ForegroundColor Yellow
Write-Host " <EFBFBD>?摰⊥䰻隞餃𦛚撌脣鍳<E884A3>?" -ForegroundColor Green
Write-Host " <EFBFBD>?瘜冽<E7989C>嚗鋫I霂<49><EFBFBD><E691AF>閬?-2<><32><EFBFBD><EFBFBD>虾蝔滚<E89D94><E6BB9A><EFBFBD><E4BAA6><EFBFBD>" -ForegroundColor Yellow
} catch {
$errorBody = $_.ErrorDetails.Message | ConvertFrom-Json
Write-Host " <20>𩤃<EFBFBD> $($errorBody.message)" -ForegroundColor Yellow
}
} else {
Write-Host " ❌ 上传失败: $($uploadResponse.message)" -ForegroundColor Red
Write-Host " <EFBFBD>?銝𠹺<E98A9D>憭梯揖: $($uploadResponse.message)" -ForegroundColor Red
}
} catch {
Write-Host " ❌ 失败: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " <EFBFBD>?憭梯揖: $($_.Exception.Message)" -ForegroundColor Red
}
} else {
Write-Host " ⚠️ 测试文件不存在: $TestFile" -ForegroundColor Yellow
Write-Host " <EFBFBD>𩤃<EFBFBD> 瘚贝<E7989A><E8B49D><EFBFBD>辣銝滚<E98A9D><E6BB9A>? $TestFile" -ForegroundColor Yellow
Write-Host " 頝唾<E9A09D>銝𠹺<E98A9D>瘚贝<E7989A>嚗諹窈<E8ABB9>见𢆡瘚贝<E7989A>" -ForegroundColor Gray
}
# 测试6: 旧版API兼容性
Write-Host "`n8. 测试旧版API兼容性 (GET /api/v1/review/tasks)..." -ForegroundColor Yellow
# 瘚贝<EFBFBD>6: <20><EFBFBD>API<50>澆捆<E6BE86>?
Write-Host "`n8. 瘚贝<EFBFBD><EFBFBD><EFBFBD>API<EFBFBD>澆捆<EFBFBD>?(GET /api/v1/review/tasks)..." -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri "$BaseUrl/api/v1/review/tasks" -Method Get
Write-Host " ✅ 旧版API正常! 任务数: $($response.pagination.total)" -ForegroundColor Green
Write-Host " <EFBFBD>?<3F><EFBFBD>API甇<49>虜! 隞餃𦛚<E9A483>? $($response.pagination.total)" -ForegroundColor Green
} catch {
Write-Host " ❌ 旧版API异常: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " <EFBFBD>?<3F><EFBFBD>API撘<49>: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n========================================" -ForegroundColor Cyan
@@ -105,9 +105,10 @@ Write-Host "测试完成!" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
Write-Host "<EFBFBD>𡒊賒<EFBFBD><EFBFBD>:" -ForegroundColor Yellow
Write-Host " - 查看报告: GET $BaseUrl/api/v2/rvw/tasks/{taskId}/report" -ForegroundColor Gray
Write-Host " - 批量运行: POST $BaseUrl/api/v2/rvw/tasks/batch/run" -ForegroundColor Gray
Write-Host " - 删除任务: DELETE $BaseUrl/api/v2/rvw/tasks/{taskId}" -ForegroundColor Gray
Write-Host " - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>: GET $BaseUrl/api/v1/rvw/tasks/{taskId}/report" -ForegroundColor Gray
Write-Host " - <EFBFBD><EFBFBD>餈鞱<EFBFBD>: POST $BaseUrl/api/v1/rvw/tasks/batch/run" -ForegroundColor Gray
Write-Host " - <EFBFBD>𣳇膄隞餃𦛚: DELETE $BaseUrl/api/v1/rvw/tasks/{taskId}" -ForegroundColor Gray

View File

@@ -31,7 +31,7 @@ function getUserId(request: FastifyRequest): string {
/**
* 上传稿件创建任务
* POST /api/v2/rvw/tasks
* POST /api/v1/rvw/tasks
*/
export async function createTask(
request: FastifyRequest<{
@@ -143,7 +143,7 @@ export async function createTask(
/**
* 运行审查(选择智能体)
* POST /api/v2/rvw/tasks/:taskId/run
* POST /api/v1/rvw/tasks/:taskId/run
*
* ✅ Platform-Only架构返回 jobId 供前端轮询
*/
@@ -185,7 +185,7 @@ export async function runReview(
/**
* 批量运行审查
* POST /api/v2/rvw/tasks/batch/run
* POST /api/v1/rvw/tasks/batch/run
*/
export async function batchRunReview(
request: FastifyRequest<{
@@ -224,7 +224,7 @@ export async function batchRunReview(
/**
* 获取任务列表
* GET /api/v2/rvw/tasks
* GET /api/v1/rvw/tasks
*/
export async function getTaskList(
request: FastifyRequest<{
@@ -264,7 +264,7 @@ export async function getTaskList(
/**
* 获取任务详情
* GET /api/v2/rvw/tasks/:taskId
* GET /api/v1/rvw/tasks/:taskId
*/
export async function getTaskDetail(
request: FastifyRequest<{
@@ -314,7 +314,7 @@ export async function getTaskDetail(
/**
* 获取审查报告
* GET /api/v2/rvw/tasks/:taskId/report
* GET /api/v1/rvw/tasks/:taskId/report
*/
export async function getTaskReport(
request: FastifyRequest<{
@@ -356,7 +356,7 @@ export async function getTaskReport(
/**
* 删除任务
* DELETE /api/v2/rvw/tasks/:taskId
* DELETE /api/v1/rvw/tasks/:taskId
*/
export async function deleteTask(
request: FastifyRequest<{

View File

@@ -31,3 +31,4 @@ export * from './services/utils.js';

View File

@@ -2,7 +2,7 @@
* RVW稿件审查模块 - 路由定义
* @module rvw/routes
*
* API前缀: /api/v2/rvw
* API前缀: /api/v1/rvw
*/
import type { FastifyInstance } from 'fastify';
@@ -13,34 +13,34 @@ export default async function rvwRoutes(fastify: FastifyInstance) {
// ==================== 任务管理 ====================
// 创建任务(上传稿件)
// POST /api/v2/rvw/tasks
// POST /api/v1/rvw/tasks
fastify.post('/tasks', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.createTask);
// 获取任务列表
// GET /api/v2/rvw/tasks?status=all|pending|completed&page=1&limit=20
// GET /api/v1/rvw/tasks?status=all|pending|completed&page=1&limit=20
fastify.get('/tasks', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.getTaskList);
// 获取任务详情
// GET /api/v2/rvw/tasks/:taskId
// GET /api/v1/rvw/tasks/:taskId
fastify.get('/tasks/:taskId', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.getTaskDetail);
// 获取审查报告
// GET /api/v2/rvw/tasks/:taskId/report
// GET /api/v1/rvw/tasks/:taskId/report
fastify.get('/tasks/:taskId/report', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.getTaskReport);
// 删除任务
// DELETE /api/v2/rvw/tasks/:taskId
// DELETE /api/v1/rvw/tasks/:taskId
fastify.delete('/tasks/:taskId', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.deleteTask);
// ==================== 运行审查 ====================
// 运行审查(选择智能体)
// POST /api/v2/rvw/tasks/:taskId/run
// POST /api/v1/rvw/tasks/:taskId/run
// Body: { agents: ['editorial', 'methodology'] }
fastify.post('/tasks/:taskId/run', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.runReview);
// 批量运行审查
// POST /api/v2/rvw/tasks/batch/run
// POST /api/v1/rvw/tasks/batch/run
// Body: { taskIds: [...], agents: ['editorial', 'methodology'] }
fastify.post('/tasks/batch/run', { preHandler: [authenticate, requireModule('RVW')] }, reviewController.batchRunReview);
}

View File

@@ -122,3 +122,4 @@ export function validateAgentSelection(agents: string[]): void {