feat(aia): Protocol Agent streaming + editable state panel + protocol generation plan

Day 2 Development (2026-01-24):

Backend Enhancements:
- Implement SSE streaming in ProtocolAgentController using createStreamingService
- Add data condensation via LLM in ProtocolOrchestrator.handleProtocolSync
- Support stage editing without resetting progress
- Add explicit JSON output format for each stage in system prompt
- Create independent seed script for Protocol Agent (seed-protocol-agent.ts)

Frontend Improvements:
- Integrate useAIStream hook for typewriter effect in ChatArea
- Add MarkdownContent component for basic Markdown rendering
- Implement StageEditModal for editing stage data (scientific question, PICO, etc.)
- Add edit button to StageCard (visible on hover)
- Fix routing paths from /aia to /ai-qa
- Enhance CSS with full-screen layout and Markdown styles

New Documentation:
- One-click protocol generation development plan (v1.1)
- Editor selection evaluation (Novel vs BlockNote vs Tiptap)
- Novel fork strategy for AI-native editing

Technical Decisions:
- Choose Novel (Fork) as protocol editor for AI-first design
- Two-stage progressive generation: summary in chat, full protocol in editor
- 10-day development plan for protocol generation feature

Code Stats:
- Backend: 3 files modified, 1 new file
- Frontend: 9 files modified, 2 new files
- Docs: 3 new files

Status: Streaming and editable features working, protocol generation pending
This commit is contained in:
2026-01-24 23:06:33 +08:00
parent 596f2dfc02
commit 4d7d97ca19
18 changed files with 2708 additions and 192 deletions

View File

@@ -24,6 +24,7 @@ import type { Agent, AgentStage } from '../types/index.js';
* 用于从 PromptService 获取对应的提示词
*/
const AGENT_TO_PROMPT_CODE: Record<string, string> = {
'PROTOCOL_AGENT': 'PROTOCOL_SYSTEM', // Protocol Agent使用自己的Prompt系统
'TOPIC_01': 'AIA_SCIENTIFIC_QUESTION',
'TOPIC_02': 'AIA_PICO_ANALYSIS',
'TOPIC_03': 'AIA_TOPIC_EVALUATION',
@@ -39,9 +40,22 @@ const AGENT_TO_PROMPT_CODE: Record<string, string> = {
// ==================== 智能体配置 ====================
/**
* 12个智能体配置(与前端保持一致)
* 13个智能体配置(与前端保持一致)
* 包含12个传统智能体 + 1个Protocol Agent
*/
const AGENTS: Agent[] = [
// Protocol Agent: 全流程研究方案制定
{
id: 'PROTOCOL_AGENT',
name: '全流程研究方案制定',
description: '一站式完成研究方案核心要素科学问题→PICO→研究设计→样本量→观察指标支持一键生成完整方案。',
icon: '🚀',
stage: 'protocol',
color: '#6366F1',
systemPrompt: `你是研究方案制定助手,将引导用户系统地完成临床研究方案的核心要素设计。`,
welcomeMessage: '您好!我是研究方案制定助手。让我们开始制定您的研究方案吧!',
},
// Phase 1: 选题优化智能体
{
id: 'TOPIC_01',