@customize-agent/server 4.12.10 → 4.12.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +20 -20
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/chunks/2886.js +1 -1
- package/.next/server/chunks/6482.js +3 -3
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/asset-library.html +1 -1
- package/.next/server/pages/document-roles.html +1 -1
- package/.next/server/pages/documents.html +1 -1
- package/.next/server/pages/guide.html +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/knowledge/file-detail.html +1 -1
- package/.next/server/pages/knowledge/files.html +1 -1
- package/.next/server/pages/knowledge/manage.html +1 -1
- package/.next/server/pages/knowledge.html +1 -1
- package/.next/server/pages/models.html +1 -1
- package/.next/server/pages/overview.html +1 -1
- package/.next/server/pages/prompt.html +1 -1
- package/.next/server/pages/settings.html +1 -1
- package/.next/server/pages/system/logs.html +1 -1
- package/.next/server/pages/template-references.html +1 -1
- package/.next/server/pages-manifest.json +22 -22
- package/.next/static/{G3ffFF2PYW8v9Z8Nl4rDj → D_2Mkgwh0uGeQ7vj6NZTK}/_buildManifest.js +1 -1
- package/.next/static/chunks/{224-790cf01fcf6820ee.js → 224-0415408fff1d1c8b.js} +1 -1
- package/.next/static/chunks/260-580088826d643423.js +1 -0
- package/.next/static/chunks/{289-42781fb699646699.js → 289-fc1b25371e004552.js} +1 -1
- package/.next/static/chunks/788-dca0d550ad6bd8b2.js +1 -0
- package/.next/static/chunks/pages/documents-66057ee3c8ffff6d.js +1 -0
- package/.next/static/chunks/pages/knowledge/files-45b40149a6f4a9d5.js +1 -0
- package/.next/static/chunks/pages/knowledge/manage-5b1b4d3804752f8b.js +1 -0
- package/.next/static/chunks/pages/prompt-edc2dfea09aaedc1.js +1 -0
- package/.next/static/chunks/pages/system/logs-ee67e2c93147dfc3.js +1 -0
- package/package.json +1 -1
- package/.next/static/chunks/260-244c94eacd903620.js +0 -1
- package/.next/static/chunks/788-e98701da4d6ca319.js +0 -1
- package/.next/static/chunks/pages/documents-185ab225628d4705.js +0 -1
- package/.next/static/chunks/pages/knowledge/files-3ba329d8e6335929.js +0 -1
- package/.next/static/chunks/pages/knowledge/manage-558987c599dc4cd5.js +0 -1
- package/.next/static/chunks/pages/prompt-839287c514595765.js +0 -1
- package/.next/static/chunks/pages/system/logs-2e849bcdf371d791.js +0 -1
- /package/.next/static/{G3ffFF2PYW8v9Z8Nl4rDj → D_2Mkgwh0uGeQ7vj6NZTK}/_ssgManifest.js +0 -0
package/.next/BUILD_ID
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
D_2Mkgwh0uGeQ7vj6NZTK
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"devFiles": [],
|
|
6
6
|
"ampDevFiles": [],
|
|
7
7
|
"lowPriorityFiles": [
|
|
8
|
-
"static/
|
|
9
|
-
"static/
|
|
8
|
+
"static/D_2Mkgwh0uGeQ7vj6NZTK/_buildManifest.js",
|
|
9
|
+
"static/D_2Mkgwh0uGeQ7vj6NZTK/_ssgManifest.js"
|
|
10
10
|
],
|
|
11
11
|
"rootMainFiles": [],
|
|
12
12
|
"rootMainFilesTree": {},
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"static/chunks/883-506cbca959974997.js",
|
|
41
41
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
42
42
|
"static/chunks/700-5d29b0475311f590.js",
|
|
43
|
-
"static/chunks/224-
|
|
43
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
44
44
|
"static/chunks/102-881dcc464f983c89.js",
|
|
45
|
-
"static/chunks/289-
|
|
45
|
+
"static/chunks/289-fc1b25371e004552.js",
|
|
46
46
|
"static/chunks/994-241f87efc61005b8.js",
|
|
47
47
|
"static/chunks/pages/asset-library-f6319fc04559e43d.js"
|
|
48
48
|
],
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
56
56
|
"static/chunks/700-5d29b0475311f590.js",
|
|
57
57
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
58
|
-
"static/chunks/224-
|
|
58
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
59
59
|
"static/chunks/787-c18af810af3433f6.js",
|
|
60
60
|
"static/chunks/102-881dcc464f983c89.js",
|
|
61
61
|
"static/chunks/195-2c0168eacab722d2.js",
|
|
62
|
-
"static/chunks/289-
|
|
62
|
+
"static/chunks/289-fc1b25371e004552.js",
|
|
63
63
|
"static/chunks/455-e1b41ac4946d2b6f.js",
|
|
64
64
|
"static/chunks/pages/document-roles-4ccb2db16dc4b63c.js"
|
|
65
65
|
],
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
73
73
|
"static/chunks/700-5d29b0475311f590.js",
|
|
74
74
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
75
|
-
"static/chunks/224-
|
|
75
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
76
76
|
"static/chunks/787-c18af810af3433f6.js",
|
|
77
77
|
"static/chunks/195-2c0168eacab722d2.js",
|
|
78
78
|
"static/chunks/455-e1b41ac4946d2b6f.js",
|
|
79
79
|
"static/chunks/506-93f730bc149d0dce.js",
|
|
80
80
|
"static/chunks/930-0436dcaa92fb41f6.js",
|
|
81
|
-
"static/chunks/pages/documents-
|
|
81
|
+
"static/chunks/pages/documents-66057ee3c8ffff6d.js"
|
|
82
82
|
],
|
|
83
83
|
"/guide": [
|
|
84
84
|
"static/chunks/webpack-4224e970a97a4a86.js",
|
|
@@ -105,10 +105,10 @@
|
|
|
105
105
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
106
106
|
"static/chunks/700-5d29b0475311f590.js",
|
|
107
107
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
108
|
-
"static/chunks/224-
|
|
108
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
109
109
|
"static/chunks/787-c18af810af3433f6.js",
|
|
110
110
|
"static/chunks/102-881dcc464f983c89.js",
|
|
111
|
-
"static/chunks/289-
|
|
111
|
+
"static/chunks/289-fc1b25371e004552.js",
|
|
112
112
|
"static/chunks/506-93f730bc149d0dce.js",
|
|
113
113
|
"static/chunks/850-0f48354694fc6b3e.js",
|
|
114
114
|
"static/css/ad5a592c79d1448b.css",
|
|
@@ -123,11 +123,11 @@
|
|
|
123
123
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
124
124
|
"static/chunks/700-5d29b0475311f590.js",
|
|
125
125
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
126
|
-
"static/chunks/224-
|
|
126
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
127
127
|
"static/chunks/102-881dcc464f983c89.js",
|
|
128
|
-
"static/chunks/289-
|
|
128
|
+
"static/chunks/289-fc1b25371e004552.js",
|
|
129
129
|
"static/css/ad5a592c79d1448b.css",
|
|
130
|
-
"static/chunks/pages/knowledge/files-
|
|
130
|
+
"static/chunks/pages/knowledge/files-45b40149a6f4a9d5.js"
|
|
131
131
|
],
|
|
132
132
|
"/knowledge/manage": [
|
|
133
133
|
"static/chunks/webpack-4224e970a97a4a86.js",
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
139
139
|
"static/chunks/787-c18af810af3433f6.js",
|
|
140
140
|
"static/chunks/506-93f730bc149d0dce.js",
|
|
141
|
-
"static/chunks/788-
|
|
142
|
-
"static/chunks/pages/knowledge/manage-
|
|
141
|
+
"static/chunks/788-dca0d550ad6bd8b2.js",
|
|
142
|
+
"static/chunks/pages/knowledge/manage-5b1b4d3804752f8b.js"
|
|
143
143
|
],
|
|
144
144
|
"/models": [
|
|
145
145
|
"static/chunks/webpack-4224e970a97a4a86.js",
|
|
@@ -170,8 +170,8 @@
|
|
|
170
170
|
"static/chunks/700-5d29b0475311f590.js",
|
|
171
171
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
172
172
|
"static/chunks/195-2c0168eacab722d2.js",
|
|
173
|
-
"static/chunks/260-
|
|
174
|
-
"static/chunks/pages/prompt-
|
|
173
|
+
"static/chunks/260-580088826d643423.js",
|
|
174
|
+
"static/chunks/pages/prompt-edc2dfea09aaedc1.js"
|
|
175
175
|
],
|
|
176
176
|
"/settings": [
|
|
177
177
|
"static/chunks/webpack-4224e970a97a4a86.js",
|
|
@@ -188,11 +188,11 @@
|
|
|
188
188
|
"static/chunks/69-34d57b77fd2eed20.js",
|
|
189
189
|
"static/chunks/700-5d29b0475311f590.js",
|
|
190
190
|
"static/chunks/44-d3545eedd5c75ef1.js",
|
|
191
|
-
"static/chunks/224-
|
|
191
|
+
"static/chunks/224-0415408fff1d1c8b.js",
|
|
192
192
|
"static/chunks/102-881dcc464f983c89.js",
|
|
193
193
|
"static/chunks/195-2c0168eacab722d2.js",
|
|
194
|
-
"static/chunks/289-
|
|
195
|
-
"static/chunks/pages/system/logs-
|
|
194
|
+
"static/chunks/289-fc1b25371e004552.js",
|
|
195
|
+
"static/chunks/pages/system/logs-ee67e2c93147dfc3.js"
|
|
196
196
|
],
|
|
197
197
|
"/template-references": [
|
|
198
198
|
"static/chunks/webpack-4224e970a97a4a86.js",
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"routes": {},
|
|
4
4
|
"dynamicRoutes": {},
|
|
5
5
|
"preview": {
|
|
6
|
-
"previewModeId": "
|
|
7
|
-
"previewModeSigningKey": "
|
|
8
|
-
"previewModeEncryptionKey": "
|
|
6
|
+
"previewModeId": "d7912522744cc8c07be4877d9b0d90e3",
|
|
7
|
+
"previewModeSigningKey": "49b9d251a4372e9b2ca057b0912a644270d1e9dba5ce7bc32ca62a1d187d382e",
|
|
8
|
+
"previewModeEncryptionKey": "83ebedbf05722e89f620ce38f24f63a555f418cdeb73cd4e39976fed5efeeb75"
|
|
9
9
|
},
|
|
10
10
|
"notFoundRoutes": []
|
|
11
11
|
}
|
|
@@ -124,7 +124,7 @@ ${a.chapters.map((b,c)=>{let d=F(b,a.factsModel);return`${c+1}. ${b.title}:${d
|
|
|
124
124
|
${b.facts.map(a=>`- ${B(a)}`).join("\n")}`:"可信基础事实主表(本章相关):系统当前结构化事实确认不足,应扩大本地知识库检索、补抽事实并修复事实落位;正文只能使用已确认事实,不得编造参数。",b&&b.traceLines.length?`关键事实证据追踪清单(本章相关):
|
|
125
125
|
${b.traceLines.join("\n")}`:"",...a.structure.matrixLines,b?`章节专业任务卡:
|
|
126
126
|
${b.taskCard}`:"",b?`章节实施方案:
|
|
127
|
-
${b.executionPlan}`:"",a.requirementRules||"",...a.structure.droppedFactNote].filter(Boolean).join("\n")}({chapterTitle:(0,t.GQ)(a.title),structure:cD,requirementRules:cC})}).constructionOrgContext,b.scopedBlueprint].filter(Boolean).join("\n\n"):cc};bW||(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-blueprint",status:"success",message:"已生成全局事实主表与文档蓝图,后续章节和小节将共用同一套专业约束",details:cB.split("\n").slice(0,12)},{subtitle:"全局蓝图"}));let cG=(0,w.tF)({requirement:a.requirement,promptTexts:aY,template:p,chapters:b9,spec:aE}),cI=(0,ep.NP)({template:p,context:bZ,title:p.name});bZ.documentPlan=cI.plan,bZ.nodes.push(cI.node),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"agent-document-planner",status:"success",message:cI.node.outputSummary||"Agent 文档规划完成",details:cI.plan.chapters.map(a=>`${a.title}:${a.sections.length} 条细目`)},{subtitle:"Agent Document Planner",order:$.length})),G=b9.map(a=>a.id);let cJ=cG.targetChars||[...cG.chapterTargets.values()].reduce((a,b)=>a+b,0),cK=(0,bj.JP)({template:p,targetWords:cJ,requirement:a.requirement,materialFileCount:ae.length,evidenceCount:bp.length}),cL=(0,bk.C)({template:p,chapters:b9,targetWords:cJ,requirement:a.requirement,materialFileCount:ae.length,evidenceCount:bp.length,hasVeryLargeExplicitChapter:b9.some(a=>(a.sections||[]).filter(Boolean).length>=30),configuredChapterConcurrency:Number(process.env.DOCUMENT_CHAPTER_CONCURRENCY||0),strategy:cK}),cM=(0,bj.Zk)(cK);(0,ac.t5)(cJ),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-strategy",status:"success",message:`已自动选择 ${cK.mode} 生成策略:章节审查 ${cK.enableChapterReview?"启用":"跳过"}、全局审查 ${cK.enableGlobalReview?`${cK.globalReviewSamplingRate&&cK.globalReviewSamplingRate<1?`抽检 ${Math.round((cK.globalReviewSamplingRate??1)*100)}%`:"启用"}`:"跳过"}、最终质量审查 ${cK.enableFinalQualityReview?"启用":"跳过"}、全文扩写 ${cK.enableDocumentBudgetExpansion?"启用":"跳过"}`,details:cL.triggers},{subtitle:"后台自动策略"})),b_.scopeConflicts.length>0&&(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"scope-conflict-resolution",status:"success",message:`源级数据口径冲突已裁决(补疑/澄清修正文件权威最高):${b_.scopeConflicts.map(a=>a.resolution?`${a.scope} → ${a.resolution}`:`${a.scope} → 待人工复核`).join(";")}`,details:b_.scopeConflicts.flatMap(a=>a.values.map(a=>`来源「${a.sourceFile||"未知文件"}」取值 ${a.value}${a.unit}`))},{subtitle:"数据口径裁决"}));let cQ=as?"OUTLINE 章节":"模板章节",cS=(0,bi.X5)({type:"validation",roleId:"section-planning",status:"success",message:`小节规划:${ch} 章由 LLM 基于${cQ}、项目资料理解和证据规划小节,${cg} 章已由模板显式提供小节并跳过规划`,details:ci.length?[...ci]:void 0},{subtitle:"小节规划策略"}),cW=as?`;识别到 OUTLINE 章节 ${ap.length} 个`:";未识别到有效 OUTLINE,将使用模板章节",cX=[..._.prompts.map(a=>`${a.category}|${a.roleId}|${a.id}|${a.name}|${a.bindingSource}|${a.content.length} 字符|hash=${a.contentHash}|${a.contentPreview}`),..._.unresolvedRoles.map(a=>`unresolved|${a}|项目角色配置中的提示词角色不存在`),..._.missingResourceRoles.map(a=>`missingResource|${a}|提示词角色未显式绑定资源`)];(0,bi.fx)($,(0,bi.X5)({type:"role_binding",roleId:V,status:"success",message:`已绑定项目资料 ${ae.length} 份、${_.prompts.length} 个有效提示词;写作 ${_.writerPrompts.length}、章节 ${_.chapterPrompts.length}、抽取 ${_.extractionPrompts.length};已自动抽取运行时规则 ${aW.executionSummary.length} 条${cW}`,details:[...cX,...aW.executionSummary.map(a=>`runtimeRule|${a}`)]},{subtitle:W,roleName:W})),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"runtime-prompt-rules",status:"success",message:`运行时提示词规则已抽取:${aW.executionSummary.length} 条,版本 ${aW.sourceHash}`,details:aW.executionSummary.length?[...aW.executionSummary,`必需表格:${aW.requiredTables.join("、")||"无"}`,`必含关键词:${aW.requiredKeywords?.join("、")||"无"}`,`禁含内容:${aW.forbiddenPatterns?.join("、")||"无"}`]:["未从提示词中识别到额外硬规则,使用系统默认质量规则"]},{subtitle:"提示词规则执行"})),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-readiness",status:aG.ready?"success":"failed",message:"生成准备度:绑定资料已就绪",details:aG.diagnostics},{subtitle:"生成准备度检查"})),(0,bi.fx)($,cS),S();let cZ=Math.round(([...cG.chapterTargets.values()].reduce((a,b)=>a+b,0)||cG.targetChars||0)/Math.max(1,b9.length)),c1=Number(process.env.DOCUMENT_CHAPTER_CONCURRENCY||0),c3=cL.chapterConcurrency,c5=cL.reviewConcurrency;(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"chapter-concurrency",status:"success",message:`章节流水线调度:${b9.length} 章全部同批并行生成,审查修复 ${c5} 路流水线(章节生成完立即进入审查,与后续章节生成重叠)`,details:[`有效章节数:${b9.length}`,`平均章节目标:${cZ} 字`,Number.isFinite(c1)&&c1>0?`章节并发来自 DOCUMENT_CHAPTER_CONCURRENCY=${Math.floor(c1)}`:`全部章节并行生成,在飞调用不设并发上限;修复轮次预算 ${cL.repairRoundBudget} 轮`]},{subtitle:"章节流水线策略"})),S();let c7=new z.jf(c5),c8=[],c9={remaining:cL.repairPoolBudget},da=[...bb].filter(Boolean).sort(),db=Date.now(),dc=da.length>0?(await (0,z.l$)(c4,async a=>bG(a,da,Math.min(bd,12),""),{kind:"search"})).flat():[];cM.evidence.searchQueries+=c4.length,cM.evidence.searchMs+=Date.now()-db;for(let b=0;b<b9.length;b+=c3){let d=b9.slice(b,b+c3);for(let f of(await Promise.all(d.map(async(d,f)=>{let g,h=b+f;(0,z.Te)(a.signal);let i=Date.now(),j=$.length;try{var k;let b,f,m,o;$.push((0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 正在检索证据并准备章节内容`,details:[`章节序号:${h+1}/${b9.length}`,`二级小节:${d.sections?.length||0} 个`,"正在生成检索查询"],progress:{current:h+1,total:b9.length,label:"章节生成"}},{subtitle:(0,t.GQ)(d.title),order:h})),S();let r=a.resumeChapters?.find(a=>a.id===d.id||a.title===d.title),y=r?.content?.trim(),B=r?.evidence?.length?[...r.evidence]:[],C=aj.chapterPlans.find(a=>a.chapterId===d.id||a.chapterTitle===d.title),D=C?Object.values(C.evidenceQueries).flat().filter(Boolean):[],E=d.queries.length>0?d.queries:[p.name,p.outputTitle,d.title],F=b8.get(d.id);if(b$&&F&&F.graphFiles.size>0){let a=[...bb],b=b=>a.includes(b)?b:a.find(a=>a.endsWith(b)||a.includes(b));for(let a of[...F.graphFiles].map(a=>b(a)||a).filter(a=>(0,bj.Tz)(c,a,bb))){let b=bF(a);if(b?.chunks?.length)for(let c of b.chunks)B.push({chapterId:d.id,filePath:b.file?.relativePath||a,score:5+(F.graphWorks.length+F.graphMethods.length)*.5,content:c.content,roleId:a6.get(a),processingType:a7.get(a),sectionTitle:c.sectionTitle,source:"graph-evidence"})}}let G=/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title),H=dI(d,[...E,...D],[]),I=Date.now();$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 正在执行质量优先的章节检索${F?.graphFiles.size?`(图谱匹配 ${F.graphFiles.size} 个文件)`:""}`,details:H.map(a=>`检索:${a.slice(0,42)}`),progress:{current:h+1,total:b9.length,label:"证据检索"}},{subtitle:(0,t.GQ)(d.title),order:h}),S();let J=y?[]:[...bb].filter(Boolean).sort(),K=y?[]:bW?.evidenceByChapterId?.[d.id]||[];K.length>0&&B.push(...K);let L=[],M=(d.requiredFacts||[]).filter(a=>!!a&&!H.some(b=>b.includes(a)||a.includes(b))).map(a=>`${d.title} ${a}`),N=[...H,...M];if(J.length>0&&N.length>0){(0,z.Te)(a.signal);let b=await (0,z.l$)(N,async a=>bG(a,J,Math.min(bd,12),d.title),{kind:"search"});L.push(...b)}for(let a of(cM.evidence.searchQueries+=N.length,cM.evidence.searchMs+=Date.now()-I,L))B.push(...a.filter(a=>(0,bj.Tz)(c,a.filePath,a5)).map(a=>({chapterId:d.id,filePath:a.filePath,score:a.score,content:a.content,roleId:a6.get(a.filePath),processingType:a7.get(a.filePath),sectionTitle:a.sectionTitle,source:a.source})));G&&J.length>0&&dc.length>0&&B.push(...dc.filter(a=>(0,bj.Tz)(c,a.filePath,a5)).map(a=>({chapterId:d.id,filePath:a.filePath,score:a.score,content:a.content,roleId:a6.get(a.filePath),processingType:a7.get(a.filePath),sectionTitle:a.sectionTitle,source:"basic-fact-cache"})));let O=y?[]:await (0,bl.$b)({manager:q,projectRoot:c,chapter:d,plan:C,profile:ai,scopedFilePaths:J,limitPerQuery:Math.min(bd,10),signal:a.signal}).catch(()=>[]);B.push(...O);let P=new Set((d.pinnedEvidenceFilePaths||[]).filter(Boolean)),T=[];/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title)&&B.push(...bO.map(a=>({...a,chapterId:d.id,source:"pinned-evidence"})));let V=bJ.filter(a=>/招标|投标须知|评标办法|专用合同条款|投标人须知/u.test(`${a.filePath||""}${a.sectionTitle||""}`));for(let a of(/概况|工程|项目|总体|部署/u.test(d.title)&&V.length>0&&B.push(...V.map(a=>({...a,chapterId:d.id,source:"pinned-evidence"}))),new Set([...P]))){if(!(0,bj.Tz)(c,a,a5))continue;let b=P.has(a),e=bF(a);e&&B.push(...e.chunks.map(a=>({chapterId:d.id,filePath:e.file.relativePath,score:1,content:a.content,roleId:a6.get(e.file.relativePath),processingType:a7.get(e.file.relativePath),sectionTitle:a.sectionTitle,source:b?"pinned-evidence":"bound-file"})))}let W=B.filter(a=>(0,bj.Tz)(c,a.filePath,bb));if(!y&&aQ.enabled&&aQ.allowProjectFacts){let b=await bK({config:aQ,chapterId:d.id,chapterTitle:d.title,sectionTitles:d.sections||[],runtimeRules:aW,localFacts:[...bY.project,...bY.schedule,...bY.quality,...bY.safety,...bY.resources,...bY.preciseFacts],signal:a.signal});br.queries.push(...b.queries),br.filteredCount+=b.filtered+b.evidence.length}let Y=y?[]:(0,bl.SK)({project:a9,chapter:d,plan:C,profile:ai,scopedFilePaths:J,highRisk:bo.highRisk});Y.length>0&&W.push(...bP(Y,bc)),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a))));let Z=W,aa=await (0,R.Mv)([(0,Q.Yx)(d)],Z.map(dG)),ab=dH(d,W,{preservePinned:!0,semantic:{similarity:aa,queryText:(0,Q.Yx)(d)}},cM);ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:initial`);let ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a))),ag=0,ah=F?[F.graphWorks.length?`图谱识别本章工程内容:${F.graphWorks.join("、")}`:"",F.graphMethods.length?`图谱识别本章施工方法:${F.graphMethods.join("、")}`:"",F.graphBoqItems.length?`图谱识别本章BOQ清单项(${F.graphBoqItems.length}项):${F.graphBoqItems.map(a=>`${a.name} ${a.quantity}${a.unit}`).join("、")}`:"",F.gaps.length?`图谱识别本章资料缺口:${F.gaps.join(";")}`:""].filter(Boolean).join("\n"):"",ak=function(a){let b=[];for(let c of a){if(!c.resolution)continue;let a=c.values.filter(a=>`${a.value}${a.unit}`!==c.resolution);if(0===a.length)continue;let d=a.map(a=>`${a.value}${a.unit}`).join("、");"high"===c.confidence?b.push(`${c.scope}必须统一为 ${c.resolution}(补疑/答疑/澄清类修正文件权威最高;${d} 已被修正,正文禁止出现)`):"medium"===c.confidence?b.push(`${c.scope}应统一为 ${c.resolution}(按资料来源优先级裁决;${d} 为败选值,正文避免使用)`):b.push(`${c.scope}参考口径为 ${c.resolution}(锚定较弱,请人工复核;${d} 不参与自动改写)`)}return b}(b_.scopeConflicts),al=cw.length>0?(()=>{let a=a0(d.title),b=cw.filter(b=>b.chapterTitle===a);return 0===b.length?"":["【本章必须显性响应的招标要求(逐条写入正文,零响应即评标失分)】",...b.map(a=>`- ${a.kind}:${a.item.text}`)].join("\n")})():"",am=[ah,al,ak.length?`【数据口径强制约束】${ak.join(";")}`:"",C?.writingGoal,C?.mustCover?.length?`本章必须覆盖:${C.mustCover.join("、")}`:"",C?.mustUseMaterialKinds?.length?`本章优先使用资料类型:${C.mustUseMaterialKinds.join("、")}`:""].filter(Boolean).join("\n"),an=dz(_,d);if(_.writerPrompts.length>0&&!an.primaryWriter)throw Error(`${(0,t.GQ)(d.title)} 写作主控提示词未进入章节生成阶段`);let ao=[an.promptTexts,aI].filter(Boolean).join("\n\n"),ap=an.promptDetails.length?an.promptDetails:["未绑定章节写作提示词"],aq=function(a){let b=a.profile||l,c=[],d=[a.template.name,a.template.outputTitle,a.chapter.title,a.chapter.purpose,...a.chapter.sections||[],...a.chapter.requiredFacts||[]].filter(Boolean).join(" "),e=a.spec?.chapterRules.find(b=>b.id===a.chapter.id||b.title===a.chapter.title);for(let d of a.chapter.requiredFacts||[])ax(c,b,{label:d,category:n(b,d)?.category||"required",required:!0,source:"template"});for(let d of a.chapter.sections||[])ax(c,b,{label:d,category:"section",required:!1,source:"section",queries:aw(d,[a.chapter.title])});for(let d of a.plan?.requiredContents||[])ax(c,b,{label:d,category:n(b,d)?.category||"plan",required:!0,source:"plan"});for(let d of a.plan?.evidenceNeeds||[])ax(c,b,{label:d,category:n(b,d)?.category||"plan",required:!0,source:"plan"});for(let d of e?.requiredFactIds||[]){let e=a.spec?.factFields.find(a=>a.id===d);e&&ax(c,b,{label:e.name,category:n(b,e.name)?.category||"spec",required:!0,source:"spec",fieldId:e.id,queries:aw(e.name,[e.extractionHint||"",e.validationHint||""])})}for(let e of a.spec?.factFields||[]){if(!e.required)continue;let f=n(b,e.name),g=`${e.name} ${e.extractionHint||""} ${e.validationHint||""}`;(d.includes(e.name)||aw(e.name,f?.aliases||[]).some(a=>d.includes(a))||a.chapter.requiredFacts.some(a=>a.includes(e.name)||e.name.includes(a)))&&ax(c,b,{label:e.name,category:f?.category||"spec",required:!0,source:"spec",fieldId:e.id,queries:aw(e.name,[g])})}for(let a of b.factFields)[a.name,...a.aliases].some(a=>a.length>=2&&d.includes(a))&&ay(c,b,a,"profile","must_use"===a.usagePolicy,[d]);let f=av(a.requirement||"");if(f)for(let a of b.factFields)[a.name,...a.aliases].some(a=>a.length>=2&&f.includes(a))&&ay(c,b,a,"requirement",!0,[f]);let g=av(a.promptTexts||"");if(g)for(let d of b.factFields)[d.name,...d.aliases].some(a=>a.length>=2&&g.includes(a))&&ay(c,b,d,"prompt","must_use"===d.usagePolicy,[a.chapter.title]);return c}({template:p,chapter:d,spec:aE,profile:aF,promptTexts:ao,requirement:a.requirement,plan:C?{requiredContents:C.mustCover,evidenceNeeds:Object.values(C.evidenceQueries).flat()}:void 0}),ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS}),as=ar.filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label),at=function(a){let b=(a.chapter.requiredFacts||[]).filter(b=>!a.evidence.some(a=>eq(`${a.sectionTitle||""}${a.content||""}`).includes(eq(b)))),c=(a.chapter.tablePlans||[]).flatMap(a=>a.fillability?.missingProjectFactFields||[]),d=a.evidence.length<3?["章节证据数量不足"]:[],e=b.length+c.length+d.length,f=e>=5?"high":e>=2?"medium":"low",g="high"===f?"evidence_first":c.length>0?"generate_with_review_notes":b.length>0?"section_first":"normal";return{chapterId:a.chapter.id,chapterTitle:a.chapter.title,canGenerate:!0,riskLevel:f,missingFacts:b,missingEvidence:d,tableFieldGaps:[...new Set(c)],suggestedStrategy:g,reason:0===e?"章节事实、证据和表格可填性满足常规生成条件。":`识别到 ${e} 项生成前缺口,按 ${g} 策略生成。`}}({chapter:d,evidence:ab}),au=new Set(ab.map(a=>a.filePath)).size,aC=!!F&&(F?.graphFiles.size||0)>=8&&au>=6&&0===ad.length&&"low"===at.riskLevel,aD=function(a){let b=a.evidenceFileCount<=2;return a.scopedFileCount>80?b:"evidence_first"===a.suggestedStrategy||a.highRisk||a.missingFactsCount>0||a.requiredMissingNeedsCount>0||b||a.evidenceCount<8&&"low"!==a.riskLevel}({scopedFileCount:J.length,evidenceCount:ab.length,evidenceFileCount:au,suggestedStrategy:at.suggestedStrategy,highRisk:bo.highRisk,missingFactsCount:ad.length,requiredMissingNeedsCount:as.length,riskLevel:at.riskLevel});if(!aC&&aD&&J.length>0){let b=await bh({manager:q,projectRoot:c,chapter:d,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,requiredNeeds:[...new Set([...ad,...as])],highRisk:bo.highRisk||as.length>0,signal:a.signal}).catch(()=>[]);ag=b.length,b.length>0&&(W=dH(d,[...W,...bP(b,bc)],{preservePinned:!0},cM),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a)))),ab=dH(d,W,{preservePinned:!0},cM),ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:deep`),ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a)))),as=(ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS})).filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label)}if(as.length>0&&J.length>0){let b=bP(await bh({manager:q,projectRoot:c,chapter:d,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,requiredNeeds:as,highRisk:!0,signal:a.signal}).catch(()=>[]),bc);b.length>0&&(W=dH(d,[...W,...b],{preservePinned:!0},cM),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a)))),ab=dH(d,W,{preservePinned:!0},cM),ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:supplemental`),ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a))),as=(ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS})).filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label))}for(let a of(bR(ab,bc,`chapter:${d.id}:writer-input`),0===ab.length&&bu.push(`${d.title}:缺少可支撑正文的项目资料证据`),ad))bu.push(`${d.title}:事实需求未满足 ${a}`);let aG=(0,bi.X5)({type:"knowledge_retrieval",roleId:"knowledge-base",status:bp.length>0?"success":"failed",message:`已检索/绑定 ${bp.length} 条证据`});bB<0?bB=(0,bi.fx)($,aG):$[bB]={...aG,order:$[bB]?.order??aG.order},S(),(0,z.Te)(a.signal);let aH=new Map,aJ=b=>{let e=(0,z.c6)({kind:"section",query:`${d.title} ${b}`.trim(),scopedFilePaths:J}),f=aH.get(e);if(f)return Promise.resolve(f);let g=(0,bm.Ym)(b,d,ab),h=g.filter(a=>af.AM.test(a.content)).length;return g.length>=4&&h>=1?(aH.set(e,g),Promise.resolve(g)):dJ({manager:q,projectRoot:c,chapter:d,sectionTitle:b,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,signal:a.signal}).then(a=>(aH.set(e,a),a))},aK=b=>{if(0===b.length||0===J.length)return Promise.resolve([]);let e=b.join(" ");return dJ({manager:q,projectRoot:c,chapter:d,sectionTitle:e,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,signal:a.signal}).catch(()=>[])},aL=function(a){let b=a.chapter.sections?.length||0,c=(a.chapter.sections||[]).filter(b=>a.evidence.some(a=>(0,u.Lk)(a,b)||`${a.sectionTitle||""} ${a.content}`.includes(b))).length,d=a.chapter.requiredFacts.length,e=a.chapter.requiredFacts.filter(b=>a.evidence.some(a=>(0,u.Lk)(a,b))).length;return{chapterId:a.chapter.id,chapterTitle:a.chapter.title,risk:a.risk,evidenceCount:a.evidence.length,evidenceFiles:new Set(a.evidence.map(a=>a.filePath)).size,sectionCovered:c,sectionTotal:b,requiredFactCovered:e,requiredFactTotal:d}}({chapter:d,evidence:ab,risk:bo});bq.push(aL);let aM=new Set(ab.map(a=>a.filePath)),aN=ab.reduce((a,b)=>a+b.content.length,0),aO=[...bo.highRisk?[`召回覆盖风险(${bo.riskReason||"切片未完全预加载"}):已加载 ${bo.loadedChunks}/${bo.totalChunks},已启用深召回`]:[],`项目理解缓存证据:${K.length} 条`,`深召回证据:${ag} 条`,`事实覆盖:${aL.requiredFactCovered}/${aL.requiredFactTotal}`,`小节覆盖:${aL.sectionCovered}/${aL.sectionTotal}`];$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 已选取 ${ab.length} 条高相关证据,正在生成正文`,details:[`使用绑定文件:${aM.size} 份`,`上下文字符:${aN}`,`检索查询:${H.length} 组`,...aO],progress:{current:h+1,total:b9.length,label:"正文生成"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(),cM.evidence.contextChars+=aN;let aP=(k=ar,az(k.flatMap(a=>a.facts))),aR=/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title)?bU:[],aS=(0,bm.hZ)({chapter:d,plan:void 0,spec:aE,roleFacts:T,evidence:ab,missingFacts:ad,indexedFacts:[...aR,...aP],resolvedFactNeeds:ar,factNeedsPrompt:function(a){let b=a.map(a=>{let b=a.facts.slice(0,5).map(b=>`${b.key||b.fieldName||a.need.label}=${aB(b.value)}${b.sourceFile?`(${e.basename(b.sourceFile)})`:""}`),c=a.facts.length?[]:(a.evidence||[]).slice(0,2).map(a=>`证据片段:${aB(a.content).slice(0,160)}${a.filePath?`(${e.basename(a.filePath)})`:""}`);return`- ${a.need.required?"必须":"相关"}|${a.need.label}|${a.status}${b.length||c.length?`:${[...b,...c].join(";")}`:":未在已解析资料中确认"}`});return b.length?`事实需求覆盖卡片:
|
|
127
|
+
${b.executionPlan}`:"",a.requirementRules||"",...a.structure.droppedFactNote].filter(Boolean).join("\n")}({chapterTitle:(0,t.GQ)(a.title),structure:cD,requirementRules:cC})}).constructionOrgContext,b.scopedBlueprint].filter(Boolean).join("\n\n"):cc};bW||(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-blueprint",status:"success",message:"已生成全局事实主表与文档蓝图,后续章节和小节将共用同一套专业约束",details:cB.split("\n").slice(0,12)},{subtitle:"全局蓝图"}));let cG=(0,w.tF)({requirement:a.requirement,promptTexts:aY,template:p,chapters:b9,spec:aE}),cI=await (0,ep.NP)({template:p,context:bZ,title:p.name});bZ.documentPlan=cI.plan,bZ.nodes.push(cI.node),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"agent-document-planner",status:"success",message:cI.node.outputSummary||"Agent 文档规划完成",details:cI.plan.chapters.map(a=>`${a.title}:${a.sections.length} 条细目`)},{subtitle:"Agent Document Planner",order:$.length})),G=b9.map(a=>a.id);let cJ=cG.targetChars||[...cG.chapterTargets.values()].reduce((a,b)=>a+b,0),cK=(0,bj.JP)({template:p,targetWords:cJ,requirement:a.requirement,materialFileCount:ae.length,evidenceCount:bp.length}),cL=(0,bk.C)({template:p,chapters:b9,targetWords:cJ,requirement:a.requirement,materialFileCount:ae.length,evidenceCount:bp.length,hasVeryLargeExplicitChapter:b9.some(a=>(a.sections||[]).filter(Boolean).length>=30),configuredChapterConcurrency:Number(process.env.DOCUMENT_CHAPTER_CONCURRENCY||0),strategy:cK}),cM=(0,bj.Zk)(cK);(0,ac.t5)(cJ),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-strategy",status:"success",message:`已自动选择 ${cK.mode} 生成策略:章节审查 ${cK.enableChapterReview?"启用":"跳过"}、全局审查 ${cK.enableGlobalReview?`${cK.globalReviewSamplingRate&&cK.globalReviewSamplingRate<1?`抽检 ${Math.round((cK.globalReviewSamplingRate??1)*100)}%`:"启用"}`:"跳过"}、最终质量审查 ${cK.enableFinalQualityReview?"启用":"跳过"}、全文扩写 ${cK.enableDocumentBudgetExpansion?"启用":"跳过"}`,details:cL.triggers},{subtitle:"后台自动策略"})),b_.scopeConflicts.length>0&&(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"scope-conflict-resolution",status:"success",message:`源级数据口径冲突已裁决(补疑/澄清修正文件权威最高):${b_.scopeConflicts.map(a=>a.resolution?`${a.scope} → ${a.resolution}`:`${a.scope} → 待人工复核`).join(";")}`,details:b_.scopeConflicts.flatMap(a=>a.values.map(a=>`来源「${a.sourceFile||"未知文件"}」取值 ${a.value}${a.unit}`))},{subtitle:"数据口径裁决"}));let cQ=as?"OUTLINE 章节":"模板章节",cS=(0,bi.X5)({type:"validation",roleId:"section-planning",status:"success",message:`小节规划:${ch} 章由 LLM 基于${cQ}、项目资料理解和证据规划小节,${cg} 章已由模板显式提供小节并跳过规划`,details:ci.length?[...ci]:void 0},{subtitle:"小节规划策略"}),cW=as?`;识别到 OUTLINE 章节 ${ap.length} 个`:";未识别到有效 OUTLINE,将使用模板章节",cX=[..._.prompts.map(a=>`${a.category}|${a.roleId}|${a.id}|${a.name}|${a.bindingSource}|${a.content.length} 字符|hash=${a.contentHash}|${a.contentPreview}`),..._.unresolvedRoles.map(a=>`unresolved|${a}|项目角色配置中的提示词角色不存在`),..._.missingResourceRoles.map(a=>`missingResource|${a}|提示词角色未显式绑定资源`)];(0,bi.fx)($,(0,bi.X5)({type:"role_binding",roleId:V,status:"success",message:`已绑定项目资料 ${ae.length} 份、${_.prompts.length} 个有效提示词;写作 ${_.writerPrompts.length}、章节 ${_.chapterPrompts.length}、抽取 ${_.extractionPrompts.length};已自动抽取运行时规则 ${aW.executionSummary.length} 条${cW}`,details:[...cX,...aW.executionSummary.map(a=>`runtimeRule|${a}`)]},{subtitle:W,roleName:W})),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"runtime-prompt-rules",status:"success",message:`运行时提示词规则已抽取:${aW.executionSummary.length} 条,版本 ${aW.sourceHash}`,details:aW.executionSummary.length?[...aW.executionSummary,`必需表格:${aW.requiredTables.join("、")||"无"}`,`必含关键词:${aW.requiredKeywords?.join("、")||"无"}`,`禁含内容:${aW.forbiddenPatterns?.join("、")||"无"}`]:["未从提示词中识别到额外硬规则,使用系统默认质量规则"]},{subtitle:"提示词规则执行"})),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"document-readiness",status:aG.ready?"success":"failed",message:"生成准备度:绑定资料已就绪",details:aG.diagnostics},{subtitle:"生成准备度检查"})),(0,bi.fx)($,cS),S();let cZ=Math.round(([...cG.chapterTargets.values()].reduce((a,b)=>a+b,0)||cG.targetChars||0)/Math.max(1,b9.length)),c1=Number(process.env.DOCUMENT_CHAPTER_CONCURRENCY||0),c3=cL.chapterConcurrency,c5=cL.reviewConcurrency;(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:"chapter-concurrency",status:"success",message:`章节流水线调度:${b9.length} 章全部同批并行生成,审查修复 ${c5} 路流水线(章节生成完立即进入审查,与后续章节生成重叠)`,details:[`有效章节数:${b9.length}`,`平均章节目标:${cZ} 字`,Number.isFinite(c1)&&c1>0?`章节并发来自 DOCUMENT_CHAPTER_CONCURRENCY=${Math.floor(c1)}`:`全部章节并行生成,在飞调用不设并发上限;修复轮次预算 ${cL.repairRoundBudget} 轮`]},{subtitle:"章节流水线策略"})),S();let c7=new z.jf(c5),c8=[],c9={remaining:cL.repairPoolBudget},da=[...bb].filter(Boolean).sort(),db=Date.now(),dc=da.length>0?(await (0,z.l$)(c4,async a=>bG(a,da,Math.min(bd,12),""),{kind:"search"})).flat():[];cM.evidence.searchQueries+=c4.length,cM.evidence.searchMs+=Date.now()-db;for(let b=0;b<b9.length;b+=c3){let d=b9.slice(b,b+c3);for(let f of(await Promise.all(d.map(async(d,f)=>{let g,h=b+f;(0,z.Te)(a.signal);let i=Date.now(),j=$.length;try{var k;let b,f,m,o;$.push((0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 正在检索证据并准备章节内容`,details:[`章节序号:${h+1}/${b9.length}`,`二级小节:${d.sections?.length||0} 个`,"正在生成检索查询"],progress:{current:h+1,total:b9.length,label:"章节生成"}},{subtitle:(0,t.GQ)(d.title),order:h})),S();let r=a.resumeChapters?.find(a=>a.id===d.id||a.title===d.title),y=r?.content?.trim(),B=r?.evidence?.length?[...r.evidence]:[],C=aj.chapterPlans.find(a=>a.chapterId===d.id||a.chapterTitle===d.title),D=C?Object.values(C.evidenceQueries).flat().filter(Boolean):[],E=d.queries.length>0?d.queries:[p.name,p.outputTitle,d.title],F=b8.get(d.id);if(b$&&F&&F.graphFiles.size>0){let a=[...bb],b=b=>a.includes(b)?b:a.find(a=>a.endsWith(b)||a.includes(b));for(let a of[...F.graphFiles].map(a=>b(a)||a).filter(a=>(0,bj.Tz)(c,a,bb))){let b=bF(a);if(b?.chunks?.length)for(let c of b.chunks)B.push({chapterId:d.id,filePath:b.file?.relativePath||a,score:5+(F.graphWorks.length+F.graphMethods.length)*.5,content:c.content,roleId:a6.get(a),processingType:a7.get(a),sectionTitle:c.sectionTitle,source:"graph-evidence"})}}let G=/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title),H=dI(d,[...E,...D],[]),I=Date.now();$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 正在执行质量优先的章节检索${F?.graphFiles.size?`(图谱匹配 ${F.graphFiles.size} 个文件)`:""}`,details:H.map(a=>`检索:${a.slice(0,42)}`),progress:{current:h+1,total:b9.length,label:"证据检索"}},{subtitle:(0,t.GQ)(d.title),order:h}),S();let J=y?[]:[...bb].filter(Boolean).sort(),K=y?[]:bW?.evidenceByChapterId?.[d.id]||[];K.length>0&&B.push(...K);let L=[],M=(d.requiredFacts||[]).filter(a=>!!a&&!H.some(b=>b.includes(a)||a.includes(b))).map(a=>`${d.title} ${a}`),N=[...H,...M];if(J.length>0&&N.length>0){(0,z.Te)(a.signal);let b=await (0,z.l$)(N,async a=>bG(a,J,Math.min(bd,12),d.title),{kind:"search"});L.push(...b)}for(let a of(cM.evidence.searchQueries+=N.length,cM.evidence.searchMs+=Date.now()-I,L))B.push(...a.filter(a=>(0,bj.Tz)(c,a.filePath,a5)).map(a=>({chapterId:d.id,filePath:a.filePath,score:a.score,content:a.content,roleId:a6.get(a.filePath),processingType:a7.get(a.filePath),sectionTitle:a.sectionTitle,source:a.source})));G&&J.length>0&&dc.length>0&&B.push(...dc.filter(a=>(0,bj.Tz)(c,a.filePath,a5)).map(a=>({chapterId:d.id,filePath:a.filePath,score:a.score,content:a.content,roleId:a6.get(a.filePath),processingType:a7.get(a.filePath),sectionTitle:a.sectionTitle,source:"basic-fact-cache"})));let O=y?[]:await (0,bl.$b)({manager:q,projectRoot:c,chapter:d,plan:C,profile:ai,scopedFilePaths:J,limitPerQuery:Math.min(bd,10),signal:a.signal}).catch(()=>[]);B.push(...O);let P=new Set((d.pinnedEvidenceFilePaths||[]).filter(Boolean)),T=[];/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title)&&B.push(...bO.map(a=>({...a,chapterId:d.id,source:"pinned-evidence"})));let V=bJ.filter(a=>/招标|投标须知|评标办法|专用合同条款|投标人须知/u.test(`${a.filePath||""}${a.sectionTitle||""}`));for(let a of(/概况|工程|项目|总体|部署/u.test(d.title)&&V.length>0&&B.push(...V.map(a=>({...a,chapterId:d.id,source:"pinned-evidence"}))),new Set([...P]))){if(!(0,bj.Tz)(c,a,a5))continue;let b=P.has(a),e=bF(a);e&&B.push(...e.chunks.map(a=>({chapterId:d.id,filePath:e.file.relativePath,score:1,content:a.content,roleId:a6.get(e.file.relativePath),processingType:a7.get(e.file.relativePath),sectionTitle:a.sectionTitle,source:b?"pinned-evidence":"bound-file"})))}let W=B.filter(a=>(0,bj.Tz)(c,a.filePath,bb));if(!y&&aQ.enabled&&aQ.allowProjectFacts){let b=await bK({config:aQ,chapterId:d.id,chapterTitle:d.title,sectionTitles:d.sections||[],runtimeRules:aW,localFacts:[...bY.project,...bY.schedule,...bY.quality,...bY.safety,...bY.resources,...bY.preciseFacts],signal:a.signal});br.queries.push(...b.queries),br.filteredCount+=b.filtered+b.evidence.length}let Y=y?[]:(0,bl.SK)({project:a9,chapter:d,plan:C,profile:ai,scopedFilePaths:J,highRisk:bo.highRisk});Y.length>0&&W.push(...bP(Y,bc)),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a))));let Z=W,aa=await (0,R.Mv)([(0,Q.Yx)(d)],Z.map(dG)),ab=dH(d,W,{preservePinned:!0,semantic:{similarity:aa,queryText:(0,Q.Yx)(d)}},cM);ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:initial`);let ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a))),ag=0,ah=F?[F.graphWorks.length?`图谱识别本章工程内容:${F.graphWorks.join("、")}`:"",F.graphMethods.length?`图谱识别本章施工方法:${F.graphMethods.join("、")}`:"",F.graphBoqItems.length?`图谱识别本章BOQ清单项(${F.graphBoqItems.length}项):${F.graphBoqItems.map(a=>`${a.name} ${a.quantity}${a.unit}`).join("、")}`:"",F.gaps.length?`图谱识别本章资料缺口:${F.gaps.join(";")}`:""].filter(Boolean).join("\n"):"",ak=function(a){let b=[];for(let c of a){if(!c.resolution)continue;let a=c.values.filter(a=>`${a.value}${a.unit}`!==c.resolution);if(0===a.length)continue;let d=a.map(a=>`${a.value}${a.unit}`).join("、");"high"===c.confidence?b.push(`${c.scope}必须统一为 ${c.resolution}(补疑/答疑/澄清类修正文件权威最高;${d} 已被修正,正文禁止出现)`):"medium"===c.confidence?b.push(`${c.scope}应统一为 ${c.resolution}(按资料来源优先级裁决;${d} 为败选值,正文避免使用)`):b.push(`${c.scope}参考口径为 ${c.resolution}(锚定较弱,请人工复核;${d} 不参与自动改写)`)}return b}(b_.scopeConflicts),al=cw.length>0?(()=>{let a=a0(d.title),b=cw.filter(b=>b.chapterTitle===a);return 0===b.length?"":["【本章必须显性响应的招标要求(逐条写入正文,零响应即评标失分)】",...b.map(a=>`- ${a.kind}:${a.item.text}`)].join("\n")})():"",am=[ah,al,ak.length?`【数据口径强制约束】${ak.join(";")}`:"",C?.writingGoal,C?.mustCover?.length?`本章必须覆盖:${C.mustCover.join("、")}`:"",C?.mustUseMaterialKinds?.length?`本章优先使用资料类型:${C.mustUseMaterialKinds.join("、")}`:""].filter(Boolean).join("\n"),an=dz(_,d);if(_.writerPrompts.length>0&&!an.primaryWriter)throw Error(`${(0,t.GQ)(d.title)} 写作主控提示词未进入章节生成阶段`);let ao=[an.promptTexts,aI].filter(Boolean).join("\n\n"),ap=an.promptDetails.length?an.promptDetails:["未绑定章节写作提示词"],aq=function(a){let b=a.profile||l,c=[],d=[a.template.name,a.template.outputTitle,a.chapter.title,a.chapter.purpose,...a.chapter.sections||[],...a.chapter.requiredFacts||[]].filter(Boolean).join(" "),e=a.spec?.chapterRules.find(b=>b.id===a.chapter.id||b.title===a.chapter.title);for(let d of a.chapter.requiredFacts||[])ax(c,b,{label:d,category:n(b,d)?.category||"required",required:!0,source:"template"});for(let d of a.chapter.sections||[])ax(c,b,{label:d,category:"section",required:!1,source:"section",queries:aw(d,[a.chapter.title])});for(let d of a.plan?.requiredContents||[])ax(c,b,{label:d,category:n(b,d)?.category||"plan",required:!0,source:"plan"});for(let d of a.plan?.evidenceNeeds||[])ax(c,b,{label:d,category:n(b,d)?.category||"plan",required:!0,source:"plan"});for(let d of e?.requiredFactIds||[]){let e=a.spec?.factFields.find(a=>a.id===d);e&&ax(c,b,{label:e.name,category:n(b,e.name)?.category||"spec",required:!0,source:"spec",fieldId:e.id,queries:aw(e.name,[e.extractionHint||"",e.validationHint||""])})}for(let e of a.spec?.factFields||[]){if(!e.required)continue;let f=n(b,e.name),g=`${e.name} ${e.extractionHint||""} ${e.validationHint||""}`;(d.includes(e.name)||aw(e.name,f?.aliases||[]).some(a=>d.includes(a))||a.chapter.requiredFacts.some(a=>a.includes(e.name)||e.name.includes(a)))&&ax(c,b,{label:e.name,category:f?.category||"spec",required:!0,source:"spec",fieldId:e.id,queries:aw(e.name,[g])})}for(let a of b.factFields)[a.name,...a.aliases].some(a=>a.length>=2&&d.includes(a))&&ay(c,b,a,"profile","must_use"===a.usagePolicy,[d]);let f=av(a.requirement||"");if(f)for(let a of b.factFields)[a.name,...a.aliases].some(a=>a.length>=2&&f.includes(a))&&ay(c,b,a,"requirement",!0,[f]);let g=av(a.promptTexts||"");if(g)for(let d of b.factFields)[d.name,...d.aliases].some(a=>a.length>=2&&g.includes(a))&&ay(c,b,d,"prompt","must_use"===d.usagePolicy,[a.chapter.title]);return c}({template:p,chapter:d,spec:aE,profile:aF,promptTexts:ao,requirement:a.requirement,plan:C?{requiredContents:C.mustCover,evidenceNeeds:Object.values(C.evidenceQueries).flat()}:void 0}),ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS}),as=ar.filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label),at=function(a){let b=(a.chapter.requiredFacts||[]).filter(b=>!a.evidence.some(a=>eq(`${a.sectionTitle||""}${a.content||""}`).includes(eq(b)))),c=(a.chapter.tablePlans||[]).flatMap(a=>a.fillability?.missingProjectFactFields||[]),d=a.evidence.length<3?["章节证据数量不足"]:[],e=b.length+c.length+d.length,f=e>=5?"high":e>=2?"medium":"low",g="high"===f?"evidence_first":c.length>0?"generate_with_review_notes":b.length>0?"section_first":"normal";return{chapterId:a.chapter.id,chapterTitle:a.chapter.title,canGenerate:!0,riskLevel:f,missingFacts:b,missingEvidence:d,tableFieldGaps:[...new Set(c)],suggestedStrategy:g,reason:0===e?"章节事实、证据和表格可填性满足常规生成条件。":`识别到 ${e} 项生成前缺口,按 ${g} 策略生成。`}}({chapter:d,evidence:ab}),au=new Set(ab.map(a=>a.filePath)).size,aC=!!F&&(F?.graphFiles.size||0)>=8&&au>=6&&0===ad.length&&"low"===at.riskLevel,aD=function(a){let b=a.evidenceFileCount<=2;return a.scopedFileCount>80?b:"evidence_first"===a.suggestedStrategy||a.highRisk||a.missingFactsCount>0||a.requiredMissingNeedsCount>0||b||a.evidenceCount<8&&"low"!==a.riskLevel}({scopedFileCount:J.length,evidenceCount:ab.length,evidenceFileCount:au,suggestedStrategy:at.suggestedStrategy,highRisk:bo.highRisk,missingFactsCount:ad.length,requiredMissingNeedsCount:as.length,riskLevel:at.riskLevel});if(!aC&&aD&&J.length>0){let b=await bh({manager:q,projectRoot:c,chapter:d,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,requiredNeeds:[...new Set([...ad,...as])],highRisk:bo.highRisk||as.length>0,signal:a.signal}).catch(()=>[]);ag=b.length,b.length>0&&(W=dH(d,[...W,...bP(b,bc)],{preservePinned:!0},cM),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a)))),ab=dH(d,W,{preservePinned:!0},cM),ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:deep`),ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a)))),as=(ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS})).filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label)}if(as.length>0&&J.length>0){let b=bP(await bh({manager:q,projectRoot:c,chapter:d,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,requiredNeeds:as,highRisk:!0,signal:a.signal}).catch(()=>[]),bc);b.length>0&&(W=dH(d,[...W,...b],{preservePinned:!0},cM),W=bP(W,bc),bS.size>0&&(W=W.filter(a=>!bS.has(X(a)))),ab=dH(d,W,{preservePinned:!0},cM),ab=c$(ab,b_.scopeConflicts),bR(ab,bc,`chapter:${d.id}:supplemental`),ad=d.requiredFacts.filter(a=>!ab.some(b=>(0,u.Lk)(b,a))),as=(ar=aA({needs:aq,factsModel:bY,evidence:W,profile:aF,excludedEvidenceKeys:bS})).filter(a=>a.need.required&&"satisfied"!==a.status).map(a=>a.need.label))}for(let a of(bR(ab,bc,`chapter:${d.id}:writer-input`),0===ab.length&&bu.push(`${d.title}:缺少可支撑正文的项目资料证据`),ad))bu.push(`${d.title}:事实需求未满足 ${a}`);let aG=(0,bi.X5)({type:"knowledge_retrieval",roleId:"knowledge-base",status:bp.length>0?"success":"failed",message:`已检索/绑定 ${bp.length} 条证据`});bB<0?bB=(0,bi.fx)($,aG):$[bB]={...aG,order:$[bB]?.order??aG.order},S(),(0,z.Te)(a.signal);let aH=new Map,aJ=b=>{let e=(0,z.c6)({kind:"section",query:`${d.title} ${b}`.trim(),scopedFilePaths:J}),f=aH.get(e);if(f)return Promise.resolve(f);let g=(0,bm.Ym)(b,d,ab),h=g.filter(a=>af.AM.test(a.content)).length;return g.length>=4&&h>=1?(aH.set(e,g),Promise.resolve(g)):dJ({manager:q,projectRoot:c,chapter:d,sectionTitle:b,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,signal:a.signal}).then(a=>(aH.set(e,a),a))},aK=b=>{if(0===b.length||0===J.length)return Promise.resolve([]);let e=b.join(" ");return dJ({manager:q,projectRoot:c,chapter:d,sectionTitle:e,scopedFilePaths:J,fileRoleByPath:a6,fileProcessingByPath:a7,signal:a.signal}).catch(()=>[])},aL=function(a){let b=a.chapter.sections?.length||0,c=(a.chapter.sections||[]).filter(b=>a.evidence.some(a=>(0,u.Lk)(a,b)||`${a.sectionTitle||""} ${a.content}`.includes(b))).length,d=a.chapter.requiredFacts.length,e=a.chapter.requiredFacts.filter(b=>a.evidence.some(a=>(0,u.Lk)(a,b))).length;return{chapterId:a.chapter.id,chapterTitle:a.chapter.title,risk:a.risk,evidenceCount:a.evidence.length,evidenceFiles:new Set(a.evidence.map(a=>a.filePath)).size,sectionCovered:c,sectionTotal:b,requiredFactCovered:e,requiredFactTotal:d}}({chapter:d,evidence:ab,risk:bo});bq.push(aL);let aM=new Set(ab.map(a=>a.filePath)),aN=ab.reduce((a,b)=>a+b.content.length,0),aO=[...bo.highRisk?[`召回覆盖风险(${bo.riskReason||"切片未完全预加载"}):已加载 ${bo.loadedChunks}/${bo.totalChunks},已启用深召回`]:[],`项目理解缓存证据:${K.length} 条`,`深召回证据:${ag} 条`,`事实覆盖:${aL.requiredFactCovered}/${aL.requiredFactTotal}`,`小节覆盖:${aL.sectionCovered}/${aL.sectionTotal}`];$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:_.writerPrompts[0]?.id,status:"running",message:`${(0,t.GQ)(d.title)} 已选取 ${ab.length} 条高相关证据,正在生成正文`,details:[`使用绑定文件:${aM.size} 份`,`上下文字符:${aN}`,`检索查询:${H.length} 组`,...aO],progress:{current:h+1,total:b9.length,label:"正文生成"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(),cM.evidence.contextChars+=aN;let aP=(k=ar,az(k.flatMap(a=>a.facts))),aR=/概况|工程|项目|总体|部署|进度|工期|质量/u.test(d.title)?bU:[],aS=(0,bm.hZ)({chapter:d,plan:void 0,spec:aE,roleFacts:T,evidence:ab,missingFacts:ad,indexedFacts:[...aR,...aP],resolvedFactNeeds:ar,factNeedsPrompt:function(a){let b=a.map(a=>{let b=a.facts.slice(0,5).map(b=>`${b.key||b.fieldName||a.need.label}=${aB(b.value)}${b.sourceFile?`(${e.basename(b.sourceFile)})`:""}`),c=a.facts.length?[]:(a.evidence||[]).slice(0,2).map(a=>`证据片段:${aB(a.content).slice(0,160)}${a.filePath?`(${e.basename(a.filePath)})`:""}`);return`- ${a.need.required?"必须":"相关"}|${a.need.label}|${a.status}${b.length||c.length?`:${[...b,...c].join(";")}`:":未在已解析资料中确认"}`});return b.length?`事实需求覆盖卡片:
|
|
128
128
|
${b.join("\n")}`:""}(ar)}),aT=(0,ep.up)({plan:cI.plan,chapter:d,context:bZ,evidence:ab});if(bZ.chapterTasks=[...(bZ.chapterTasks||[]).filter(a=>a.chapterId!==d.id),aT.task],bZ.nodes.push(aT.node),(0,c0.cN)(bZ),(0,bi.fx)($,(0,bi.X5)({type:"validation",roleId:`agent-chapter-task-${d.id}`,status:aT.task.ready||y?"success":"failed",message:aT.task.ready?aT.node.outputSummary||`${(0,t.GQ)(d.title)} 章节任务规划完成`:y?`${(0,t.GQ)(d.title)} 章节任务未完全就绪,已复用已有正文并交由 Reviewer/Repairer 处理`:aT.node.outputSummary||`${(0,t.GQ)(d.title)} 章节任务规划完成`,details:aT.task.issues.map(a=>a.message)},{subtitle:"Agent Chapter Task Planner",order:$.length})),S(A),!aT.task.ready&&!y)throw Error(`${(0,t.GQ)(d.title)} 章节任务未就绪:${aT.task.issues.map(a=>a.message).join(";")}`);let aU=[ao,(0,ep.bT)(aT.task)].filter(Boolean).join("\n\n"),aV={total:ar.length,satisfied:ar.filter(a=>"satisfied"===a.status).length,missing:ar.filter(a=>"missing"===a.status).length,lowConfidence:ar.filter(a=>"low_confidence"===a.status).length};for(let a of as)bu.push(`${d.title}:事实需求未确认 ${a}`);let aX=aE?.chapterRules.find(a=>a.id===d.id||a.title===d.title),aY=cG.chapterTargets.get(d.id)||1200,aZ=d.sections?.filter(Boolean).length||0,a$=/[、,,;;]/u.test(d.title),a_=function(a){let{budgetTarget:b,sectionCount:c,title:d,longformStrict:e}=a,f=/[、,,;;]/u.test(d),g=/工期|进度|质量|安全|危大|资源|人材机|保障|措施|重难点/u.test(d),h=/概况|结语|附录|说明/u.test(d),i=c>0?c*(f?720:g?900:780):g?5200:3600,j=e?h?2600:g?5200:3600:Math.min(1200,b),k=e?Math.min(Math.max(4200,b),c>=30?9800:f?8800:g?9200:7200):b,l=e?Math.max(j,b):Math.max(j,Math.min(b,i,k));return{budgetTarget:b,roundTarget:l,structureTarget:i,maxWords:Math.ceil(l*(a.longformStrict?1.12:1.18)),label:`章节预算约 ${b} 字,本轮生成约 ${l} 字,结构目标约 ${i} 字`}}({budgetTarget:aY,sectionCount:aZ,title:d.title,longformStrict:cG.longformStrict}),a1=Math.ceil(a_.maxWords*(cG.maxChars?1.05:1)),a2=cG.targetChars?Math.min(1800,Math.max(600,Math.floor(.45*a_.roundTarget))):1200,a3=a_.roundTarget,a4=Math.max(Math.min(aX?.minWords||0,a3),Math.min(aE?.dynamicChapterRule.minWordsPerChapter||0,a3),Math.floor(.68*a3),a2),a8=(0,bm.uV)(a4,a3),ba=aZ>0?cG.longformStrict?a3:Math.min(a3,Math.max(1800,a_.structureTarget)):a3,be=Math.max(4,Number(process.env.DOCUMENT_SECTION_FIRST_MAX_SECTIONS||8)),bf=process.env.DOCUMENT_SECTION_FIRST_GENERATION,bg=void 0!==bf&&0===Number(bf),bk=void 0!==bf&&0!==Number(bf),bn=a3>=6e3&&aZ>=4&&aZ<=be&&!a$,bw=!bg&&aZ>=2&&(aZ>be||a$||cG.longformStrict&&aZ>=6),bC=!bg&&!bw&&aZ>=2&&aZ<=be&&(bk||bn||cG.longformStrict),bD=0,bE=a=>{let b=Date.now();if(b-bD<3e3)return;bD=b;let c=a.filter(Boolean).join("\n\n");c.trim()&&S([...A,{id:d.id,title:d.title,content:`## ${d.title}
|
|
129
129
|
|
|
130
130
|
${c}`,evidence:ab,missingFacts:ad,sections:d.sections||[],tablePlans:d.tablePlans||[],inProgress:!0}])},bH=a=>{"complete"===a.phase&&a.partialSections&&bE(a.partialSections)};if(y)o=dx(y,d),o=await dn(o,bN),g=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"success",message:`${(0,t.GQ)(d.title)} 已复用已有章节正文:当前 ${(0,w.V7)(o)} 字,跳过 Writer,直接进入 Reviewer/Repairer/Final Gate`,details:[`有效证据:${ab.length} 条`,`事实需求:${aV.satisfied}/${aV.total} 已满足,缺失 ${aV.missing},低置信 ${aV.lowConfidence}`,"来源:resumeChapters/checkpointChapters"],progress:{current:h+1,total:b9.length,label:"复用章节"}},{subtitle:(0,t.GQ)(d.title),order:h}),$[j]=g,S(A);else{let e;if($[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"running",message:bw?`${(0,t.GQ)(d.title)} 正在规划主题块并准备并发成稿`:bC?`${(0,t.GQ)(d.title)} 正在按小节并发成稿`:`${(0,t.GQ)(d.title)} 正在整章一次成稿`,details:bw||bC?[...ap,`有效证据:${ab.length} 条`,`事实需求:${aV.satisfied}/${aV.total} 已满足,缺失 ${aV.missing},低置信 ${aV.lowConfidence}`,a_.label,`生成上限约 ${a1} 字`,`模板细目:${d.sections?.length||0} 条`,bw?"细目较多,先由章级 Planner 聚类为主题块并语义合并,再按主题块全并发出稿,避免逐小节碎片化":"按章节结构拆分小节自然并发生成,章节聚合后再审查修复"]:[...ap,`有效证据:${ab.length} 条`,`事实需求:${aV.satisfied}/${aV.total} 已满足,缺失 ${aV.missing},低置信 ${aV.lowConfidence}`,a_.label,`生成上限约 ${a1} 字`,`规划小节:${aZ} 个`,"首次生成必须覆盖章节结构、小节和事实,篇幅目标仅作为规划参考"],progress:{current:h+1,total:b9.length,label:bw?"主题块并发":bC?"小节并发":"整章成稿"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(),bw){let c=(0,t.GQ)(d.title),g=cB.split("\n").filter(a=>a.includes(c)),i=g.length>0?g.join("\n"):cB,k=await U(()=>(0,bj.X6)(cM,`chapter-plan:${d.id}`,()=>bx({template:p,chapter:d,evidence:ab,projectContext:cc,requirement:a.requirement,roleContext:am,targetWords:ba,graphContext:aT.task.graphContext,blueprintContext:i,signal:a.signal,diagnostics:cM})));if(k.blocks.length>0){b=k,m=function(a,b){let c={};for(let d of a)for(let a of b.blocks){let b=a.subPoints.filter(a=>a.sources.some(a=>bt(a,d))||bt(a.title,d));if(b.length>0){c[d]=b.map(a=>a.title);break}}return c}(bs(d),k);let c=[ao,(0,ep.$8)(aT.task,k)].filter(Boolean).join("\n\n");f=c;let g=k.blocks.reduce((a,b)=>a+b.subPoints.length,0),i=k.blocks.reduce((a,b)=>a+b.subPoints.reduce((a,b)=>a+Math.max(0,b.sources.length-1),0),0),l=k.llmPlanned?k.llmFailure?`(部分主题块降级:${k.llmFailure.slice(0,80)})`:k.fallbackSections.length>0?`(${k.fallbackSections.length} 条细目由覆盖校验挂回主题块)`:"":`(LLM 规划未命中:${(k.llmFailure||"未返回有效结构").slice(0,80)},已按语义域确定性分组)`;$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"running",message:`${(0,t.GQ)(d.title)} 已规划 ${k.blocks.length} 个主题块,正在按主题块并发成稿${l}`,details:[...ap,`有效证据:${ab.length} 条`,`输入细目 ${aZ} 条 → 主题块 ${k.blocks.length} 个(每块 2~4 个 H4 要点)`,`语义合并 ${i} 条细目,目录级 H4 合计 ${g} 个`,"单块 1200~2200 字,主题块间全并发,单节深度与整体耗时双优"],progress:{current:h+1,total:b9.length,label:"主题块并发"}},{subtitle:(0,t.GQ)(d.title),order:h});let n=$.find(a=>a.roleId===`agent-chapter-task-${d.id}`);n&&(n.message=`${aT.task.sections.filter(a=>a.ready).length}/${aT.task.sections.length} 条细目任务就绪(已规划为 ${k.blocks.length} 个主题块)`),S(A),e=await U(()=>(0,bj.X6)(cM,`chapter-planned-block-draft:${d.id}`,()=>(0,bm.nl)({template:p,chapter:d,evidence:ab,missingFacts:ad,promptTexts:c,projectContext:cF(d),requirement:a.requirement,roleContext:am,targetWords:ba,maxWords:a1,forbidDrawingImages:!1,factCoverageContext:aS,compactProjectContext:!0,scopedProjectContext:cE,sectionEvidenceProvider:aJ,onSectionProgress:bH,diagnostics:cM,signal:a.signal},k)))}}else e=bC?await U(()=>(0,bj.X6)(cM,`chapter-section-draft:${d.id}`,()=>(0,bm.N1)({template:p,chapter:d,evidence:ab,missingFacts:ad,promptTexts:aU,projectContext:cF(d),requirement:a.requirement,roleContext:am,targetWords:ba,maxWords:a1,forbidDrawingImages:!1,factCoverageContext:aS,projectRoot:c,modelName:(0,ac.$y)()?.model.name,materialContextHash:(0,z.c6)({materialFilePaths:ae,promptTexts:ao}),allowPartialResult:!1,compactProjectContext:!0,scopedProjectContext:cE,sectionEvidenceProvider:aJ,onSectionProgress:bH,diagnostics:cM,signal:a.signal}))):await U(()=>(0,bj.X6)(cM,`chapter-draft:${d.id}`,()=>(0,bm.eu)(p,d,ab,ad,aU,cF(d),a.requirement,am,{forbidDrawingImages:!1,minWords:a4,targetWords:a3,maxWords:a1,maxTokens:a8,factCoverageContext:aS,signal:a.signal,diagnostics:cM,supplementEvidenceProvider:aK,evidenceFloorChars:cL.evidenceFloorChars,evidenceCeilingChars:cL.evidenceCeilingChars})));if(!e&&(bw||bC)&&(bw&&(b=void 0,f=void 0,m=void 0),$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"running",message:`${(0,t.GQ)(d.title)} ${bw?"主题块成稿未完成":"小节成稿未完成"},正在切换为整章紧凑备用成稿`,details:[`LLM 最近错误:${cM.llm.lastError||"成稿空响应或超时"}`,`有效证据:${ab.length} 条`],progress:{current:h+1,total:b9.length,label:"整章备用"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(A),e=await U(()=>(0,bj.X6)(cM,`chapter-compact-fallback:${d.id}`,()=>(0,bm.eu)(p,d,ab,ad,aU,cF(d),a.requirement,am,{forbidDrawingImages:!1,minWords:Math.floor(.65*a4),targetWords:Math.floor(.75*ba),maxWords:a1,maxTokens:a8,factCoverageContext:aS,signal:a.signal,diagnostics:cM,supplementEvidenceProvider:aK,evidenceFloorChars:cL.evidenceFloorChars,evidenceCeilingChars:cL.evidenceCeilingChars}).catch(a=>{cM.llm.lastError=a instanceof Error?a.message:String(a)})))),!e&&ab.length>0){$[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"running",message:`${(0,t.GQ)(d.title)} LLM 多路径未返回有效正文,正在反馈失败原因重试紧凑整章生成`,details:[`LLM 最近错误:${cM.llm.lastError||"空响应或超时"}`,`证据条数:${ab.length}`],progress:{current:h+1,total:b9.length,label:"失败原因重试"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(A);let b=[am,`【上一轮 LLM 生成失败,请先分析失败原因,再调整策略重新输出完整章节正文】失败原因:${cM.llm.lastError||"空响应或超时"}`].filter(Boolean).join("\n");e=await U(()=>(0,bj.X6)(cM,`chapter-lastretry:${d.id}`,()=>(0,bm.eu)(p,d,ab,ad,aU,cF(d),a.requirement,b,{forbidDrawingImages:!1,minWords:Math.floor(.55*a4),targetWords:Math.floor(.6*ba),maxWords:a1,maxTokens:a8,factCoverageContext:aS,signal:a.signal,diagnostics:cM,supplementEvidenceProvider:aK,evidenceFloorChars:cL.evidenceFloorChars,evidenceCeilingChars:cL.evidenceCeilingChars}).catch(a=>{cM.llm.lastError=a instanceof Error?a.message:String(a)})))}if(!e&&ab.length>0&&($[j]=(0,bi.X5)({type:"chapter_generation",roleId:"chapter_generation",promptId:an.primaryPromptId,status:"running",message:`${(0,t.GQ)(d.title)} LLM 全故障,正在用当前项目证据生成带阻断标记的可审查骨架草稿`,details:[`LLM 最近错误:${cM.llm.lastError||"空响应或超时"}`,`证据条数:${ab.length}`,"骨架草稿将带 [EVIDENCE_SKELETON] 标记并由 Review 门禁强制拦截,不允许静默通过"],progress:{current:h+1,total:b9.length,label:"证据骨架"}},{subtitle:(0,t.GQ)(d.title),order:h}),S(A),e=`[EVIDENCE_SKELETON]
|