Files
PlantAI-rag-new/ui/src/stores/paper.js
T
admin 91f6a1c242 feat: 新增论文撰写功能 paper-writer(独立 MCP 服务 + BFF 大脑 + 前端三卡)
- paper_writer_service(8097):FastAPI + MCP streamable-http 单端点,9 工具
  (propose_paper_outline/write_paper_section/get_paper_progress/search_refs/
  revise_paper_section/revise_paper/get_paper/complete_paper/cancel_paper),
  SQLite 三表(papers/paper_sections/citations,WAL),GB/T 7714 引用协议
- BFF:services/paper/{mcp_client,agent}.py(裸 JSON-RPC 客户端 + 规则状态机)、
  routers/paper.py、schemas.py 4 个 Paper*Block + ArtifactBlock 加 paper_id/citation_count、
  config.py 开关、main.py 条件注册、docgen.py 抽 insert_artifact 公共 helper
- 前端:intent.js paperIntent 纯函数、Composer docgen 分支 sub-route、sendPaper/轮询、
  PaperBriefCard/PaperOutlineCard/PaperProgressCard、DocPane cite-chip
- deploy/paper_restart.sh + toggle_paper.sh;compile_sdk.sh 白名单追加 paper 文件
- tests/paper 26 条(工具逻辑 + MCP 协议 + BFF 状态机 + 块 schema + 前端 intent 单测)
2026-09-30 22:29:22 +08:00

37 lines
990 B
JavaScript

// stores/paper.js —— 论文撰写探活 + 开关(镜像 health.js 的 30s 周期探活)
// availability: 'online' | 'offline' | 'unknown'。offline 时 Composer 触发词落 docgen 单发降级。
import { defineStore } from 'pinia';
import { paperHealth } from '../api/paper.js';
const HEALTH_INTERVAL = 30000;
export const usePaperStore = defineStore('paper', {
state: () => ({
availability: 'unknown',
polling: false,
}),
actions: {
async probe() {
try {
const data = await paperHealth();
this.availability = data && data.ok ? 'online' : 'offline';
} catch {
this.availability = 'offline';
}
},
start() {
if (this.polling) return;
this.polling = true;
this.probe();
this._timer = setInterval(() => {
if (document.hidden) return;
this.probe();
}, HEALTH_INTERVAL);
},
stop() {
clearInterval(this._timer);
this.polling = false;
},
},
});