docs(iit): Add IIT Manager Agent V2.9 development plan with multi-agent architecture

Features:
- Add V2.9 enhancements: Cron Skill, User Profiling, Feedback Loop, Multi-Intent Handling
- Create modular development plan documents (database, engines, services, memory, tasks)
- Add V2.5/V2.6/V2.8/V2.9 design documents for architecture evolution
- Add system design white papers and implementation guides

Architecture:
- Dual-Brain Architecture (SOP + ReAct engines)
- Three-layer memory system (Flow Log, Hot Memory, History Book)
- ProfilerService for personalized responses
- SchedulerService with Cron Skill support

Also includes:
- Frontend nginx config updates
- Backend test scripts for WeChat signature
- Database backup files

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-05 22:33:26 +08:00
parent 4b9b90ffb8
commit 0c590854b5
27 changed files with 7279 additions and 7 deletions

View File

@@ -0,0 +1,176 @@
/**
* 更新 REDCap 生产环境配置
*
* 将本地开发环境的 REDCap 配置更新为生产环境
*
* 使用方法:
* 1. 开启 RDS PostgreSQL 外网访问
* 2. 设置环境变量DATABASE_URL=postgresql://airesearch:Xibahe%40fengzhibo117@pgm-2zex1m2y3r23hdn5xo.pg.rds.aliyuncs.com:5432/ai_clinical_research_test
* 3. 运行npx tsx src/modules/iit-manager/update-redcap-prod-config.ts
* 4. 关闭 RDS PostgreSQL 外网访问
*/
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
// 生产环境配置
const PROD_CONFIG = {
name: 'Test0202',
redcapUrl: 'https://redcap.xunzhengyixue.com',
redcapApiToken: '93785593BED5A25DB3818D7C221FC045',
redcapProjectId: '16', // REDCap 项目 ID
};
async function main() {
console.log('🔍 查看当前项目配置...\n');
try {
// 1. 查看当前配置
const existingProjects = await prisma.$queryRaw<Array<{
id: string;
name: string;
redcap_url: string;
redcap_api_token: string;
redcap_project_id: string;
status: string;
dify_dataset_id: string | null;
}>>`
SELECT id, name, redcap_url, redcap_api_token, redcap_project_id, status, dify_dataset_id
FROM iit_schema.projects
ORDER BY created_at DESC
`;
if (existingProjects.length > 0) {
console.log('📋 当前项目配置:');
existingProjects.forEach((p, i) => {
console.log(`\n项目 ${i + 1}:`);
console.log(` ID: ${p.id}`);
console.log(` 名称: ${p.name}`);
console.log(` REDCap URL: ${p.redcap_url}`);
console.log(` REDCap 项目ID: ${p.redcap_project_id}`);
console.log(` 状态: ${p.status}`);
console.log(` Dify Dataset: ${p.dify_dataset_id || '未配置'}`);
});
// 2. 检查是否已有生产环境配置
const hasProdConfig = existingProjects.some(
p => p.redcap_url === PROD_CONFIG.redcapUrl
);
if (hasProdConfig) {
console.log('\n✅ 已存在生产环境配置,更新 API Token...');
await prisma.$executeRaw`
UPDATE iit_schema.projects
SET redcap_api_token = ${PROD_CONFIG.redcapApiToken},
name = ${PROD_CONFIG.name},
updated_at = NOW()
WHERE redcap_url = ${PROD_CONFIG.redcapUrl}
`;
console.log('✅ 生产环境配置已更新');
} else {
// 3. 如果只有本地配置,更新为生产环境
const activeProject = existingProjects.find(p => p.status === 'active');
if (activeProject) {
console.log('\n🔄 将活跃项目更新为生产环境配置...');
await prisma.$executeRaw`
UPDATE iit_schema.projects
SET name = ${PROD_CONFIG.name},
redcap_url = ${PROD_CONFIG.redcapUrl},
redcap_api_token = ${PROD_CONFIG.redcapApiToken},
updated_at = NOW()
WHERE id = ${activeProject.id}
`;
console.log('✅ 项目配置已更新为生产环境');
} else {
// 4. 创建新的生产环境配置
console.log('\n 创建新的生产环境项目配置...');
await prisma.$executeRaw`
INSERT INTO iit_schema.projects (
id, name, redcap_url, redcap_api_token, redcap_project_id,
field_mappings, status, created_at, updated_at
) VALUES (
gen_random_uuid(),
${PROD_CONFIG.name},
${PROD_CONFIG.redcapUrl},
${PROD_CONFIG.redcapApiToken},
${PROD_CONFIG.redcapProjectId},
'{}'::jsonb,
'active',
NOW(),
NOW()
)
`;
console.log('✅ 生产环境项目配置已创建');
}
}
} else {
// 5. 数据库中没有项目,创建新的
console.log('📋 数据库中没有项目配置,创建新的生产环境配置...');
await prisma.$executeRaw`
INSERT INTO iit_schema.projects (
id, name, redcap_url, redcap_api_token, redcap_project_id,
field_mappings, status, created_at, updated_at
) VALUES (
gen_random_uuid(),
${PROD_CONFIG.name},
${PROD_CONFIG.redcapUrl},
${PROD_CONFIG.redcapApiToken},
${PROD_CONFIG.redcapProjectId},
'{}'::jsonb,
'active',
NOW(),
NOW()
)
`;
console.log('✅ 生产环境项目配置已创建');
}
// 6. 验证最终配置
console.log('\n📋 验证最终配置...\n');
const finalConfig = await prisma.$queryRaw<Array<{
id: string;
name: string;
redcap_url: string;
redcap_project_id: string;
status: string;
}>>`
SELECT id, name, redcap_url, redcap_project_id, status
FROM iit_schema.projects
WHERE status = 'active'
`;
if (finalConfig.length > 0) {
console.log('✅ 活跃项目配置:');
finalConfig.forEach(p => {
console.log(` 名称: ${p.name}`);
console.log(` REDCap URL: ${p.redcap_url}`);
console.log(` REDCap 项目ID: ${p.redcap_project_id}`);
console.log(` ID: ${p.id}`);
});
}
console.log('\n🎉 配置完成!');
console.log('\n📝 下一步:');
console.log(' 1. 在 REDCap 控制中心启用 Data Entry Trigger (DET)');
console.log(' 2. 配置 DET URL: https://iit.xunzhengyixue.com/api/v1/iit/webhooks/redcap');
console.log(' 3. 测试数据同步');
} catch (error: any) {
console.error('❌ 操作失败:', error.message);
} finally {
await prisma.$disconnect();
}
}
main();