From 26bb69a7eef965f6aa0d5bde2bd6df3ea3ab2782 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:42:58 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E5=8F=8D=E9=A6=88=20=E2=80=94=20=E9=98=B2?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E6=89=AB=E6=8F=8F=20+=20=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=86=85=E5=AE=B9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/308aecfa-5d15-4ae4-85ec-c3d84ec636db Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- server/age-os/agents/persona-engine.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/server/age-os/agents/persona-engine.js b/server/age-os/agents/persona-engine.js index c2e9bb6b..14b61a32 100644 --- a/server/age-os/agents/persona-engine.js +++ b/server/age-os/agents/persona-engine.js @@ -28,11 +28,11 @@ const LivingModule = require('./living-module'); // ─── 笔记本5页标准结构 ─── const NOTEBOOK_PAGES = { - 1: { title: '我是谁', requiredKeys: ['identity', 'self_awareness'] }, - 2: { title: '我和谁有关系', requiredKeys: ['relationships'] }, - 3: { title: '我的世界有哪些地方', requiredKeys: ['places'] }, - 4: { title: '我的感受和记忆', requiredKeys: ['emotional_anchors'] }, - 5: { title: '我的时间线', requiredKeys: ['timeline'] } + 1: { title: '我是谁', defaultContent: { identity: {}, self_awareness: {} } }, + 2: { title: '我和谁有关系', defaultContent: { relationships: [] } }, + 3: { title: '我的世界有哪些地方', defaultContent: { places: [] } }, + 4: { title: '我的感受和记忆', defaultContent: { emotional_anchors: [], security_note: '' } }, + 5: { title: '我的时间线', defaultContent: { timeline: [] } } }; class PersonaEngine extends LivingModule { @@ -53,6 +53,7 @@ class PersonaEngine extends LivingModule { // 巡检统计 this._lastScanResult = null; this._scanInterval = null; + this._scanRunning = false; } /** @@ -91,6 +92,13 @@ class PersonaEngine extends LivingModule { * 全面巡检 — 检查所有人格体健康状态 */ async _runFullScan() { + // 防止并发扫描 + if (this._scanRunning) { + console.log('[PersonaEngine] 巡检已在运行中·跳过'); + return this._lastScanResult; + } + this._scanRunning = true; + const startTime = Date.now(); console.log('[PersonaEngine] 开始全面巡检...'); @@ -141,6 +149,7 @@ class PersonaEngine extends LivingModule { const duration = Date.now() - startTime; result.duration_ms = duration; this._lastScanResult = result; + this._scanRunning = false; // 学习巡检结果 await this.learnFromRun('diagnosis', `人格体巡检完成: ${result.personas.total}个人格体, ${result.notebooks.incomplete}个笔记本不完整`, { @@ -176,10 +185,7 @@ class PersonaEngine extends LivingModule { isComplete = false; // 自动补全缺失页面 const pageConfig = NOTEBOOK_PAGES[pageNum]; - const defaultContent = {}; - for (const key of pageConfig.requiredKeys) { - defaultContent[key] = key.endsWith('s') ? [] : {}; - } + const defaultContent = JSON.parse(JSON.stringify(pageConfig.defaultContent)); await db.query( `INSERT INTO notebook_pages (persona_id, page_number, title, content, last_modified_by)