@customize-agent/server 4.0.52 → 4.0.54

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.
Files changed (54) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +20 -20
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/chunks/432.js +1 -1
  5. package/.next/server/chunks/6697.js +31 -31
  6. package/.next/server/middleware-build-manifest.js +1 -1
  7. package/.next/server/pages/404.html +1 -1
  8. package/.next/server/pages/500.html +1 -1
  9. package/.next/server/pages/api/assets/generated/preview.js +1 -1
  10. package/.next/server/pages/api/assets/generated.js +1 -1
  11. package/.next/server/pages/api/documents/export.js +1 -1
  12. package/.next/server/pages/api/documents/generate.js +1 -1
  13. package/.next/server/pages/api/documents/generated/[id].js +1 -1
  14. package/.next/server/pages/api/documents/generated.js +1 -1
  15. package/.next/server/pages/asset-library.html +1 -1
  16. package/.next/server/pages/context/long-term.html +1 -1
  17. package/.next/server/pages/context/short-term.html +1 -1
  18. package/.next/server/pages/document-roles.html +1 -1
  19. package/.next/server/pages/documents.html +1 -1
  20. package/.next/server/pages/guide.html +1 -1
  21. package/.next/server/pages/index.html +1 -1
  22. package/.next/server/pages/knowledge/file-detail.html +1 -1
  23. package/.next/server/pages/knowledge/files.html +1 -1
  24. package/.next/server/pages/knowledge/manage.html +1 -1
  25. package/.next/server/pages/knowledge/search.html +1 -1
  26. package/.next/server/pages/knowledge.html +1 -1
  27. package/.next/server/pages/models.html +1 -1
  28. package/.next/server/pages/overview.html +1 -1
  29. package/.next/server/pages/prompt.html +1 -1
  30. package/.next/server/pages/settings.html +1 -1
  31. package/.next/server/pages/system/logs.html +1 -1
  32. package/.next/server/pages-manifest.json +15 -15
  33. package/.next/static/{z8eSOMtVWA-Ve20p9dRke → Gjm7sUmlMDFP1formv8BS}/_buildManifest.js +1 -1
  34. package/.next/static/chunks/{317-18aac52df5551e76.js → 317-0cc5d3d1f0f660e8.js} +1 -1
  35. package/.next/static/chunks/375-f731e5ec66ab942c.js +1 -0
  36. package/.next/static/chunks/496-ceb2d8197d6335cf.js +1 -0
  37. package/.next/static/chunks/694-b6ab4967c35bbcee.js +1 -0
  38. package/.next/static/chunks/788-db05269178a28c20.js +1 -0
  39. package/.next/static/chunks/795-262a7ef599d655f4.js +1 -0
  40. package/.next/static/chunks/940-364bc292676ba191.js +1 -0
  41. package/.next/static/chunks/pages/document-roles-00219c0a0871daec.js +1 -0
  42. package/.next/static/chunks/pages/documents-930fccb8c2804b16.js +1 -0
  43. package/.next/static/chunks/pages/guide-4f27a34912654b0b.js +1 -0
  44. package/package.json +3 -3
  45. package/.next/static/chunks/375-4a1c73eb22d653d2.js +0 -1
  46. package/.next/static/chunks/496-4fb9a063790e65ff.js +0 -1
  47. package/.next/static/chunks/694-2d545cfbb9779f2c.js +0 -1
  48. package/.next/static/chunks/788-7f7359a830e3f4fd.js +0 -1
  49. package/.next/static/chunks/795-d8fb7a0420512701.js +0 -1
  50. package/.next/static/chunks/940-7cb66111eee2f9fb.js +0 -1
  51. package/.next/static/chunks/pages/document-roles-fd02980db151650c.js +0 -1
  52. package/.next/static/chunks/pages/documents-d34a2487e74532e1.js +0 -1
  53. package/.next/static/chunks/pages/guide-0a3cdfa79c037307.js +0 -1
  54. /package/.next/static/{z8eSOMtVWA-Ve20p9dRke → Gjm7sUmlMDFP1formv8BS}/_ssgManifest.js +0 -0
package/.next/BUILD_ID CHANGED
@@ -1 +1 @@
1
- z8eSOMtVWA-Ve20p9dRke
1
+ Gjm7sUmlMDFP1formv8BS
@@ -5,8 +5,8 @@
5
5
  "devFiles": [],
6
6
  "ampDevFiles": [],
7
7
  "lowPriorityFiles": [
8
- "static/z8eSOMtVWA-Ve20p9dRke/_buildManifest.js",
9
- "static/z8eSOMtVWA-Ve20p9dRke/_ssgManifest.js"
8
+ "static/Gjm7sUmlMDFP1formv8BS/_buildManifest.js",
9
+ "static/Gjm7sUmlMDFP1formv8BS/_ssgManifest.js"
10
10
  ],
11
11
  "rootMainFiles": [],
12
12
  "rootMainFilesTree": {},
@@ -17,8 +17,8 @@
17
17
  "static/chunks/main-91fb767ebd74c9c1.js",
18
18
  "static/chunks/433-233659be69169c19.js",
19
19
  "static/chunks/787-c18af810af3433f6.js",
20
- "static/chunks/694-2d545cfbb9779f2c.js",
21
- "static/chunks/795-d8fb7a0420512701.js",
20
+ "static/chunks/694-b6ab4967c35bbcee.js",
21
+ "static/chunks/795-262a7ef599d655f4.js",
22
22
  "static/chunks/pages/index-a2a24e9602e7ea52.js"
23
23
  ],
24
24
  "/_app": [
@@ -41,7 +41,7 @@
41
41
  "static/chunks/433-233659be69169c19.js",
42
42
  "static/chunks/787-c18af810af3433f6.js",
43
43
  "static/chunks/102-881dcc464f983c89.js",
44
- "static/chunks/317-18aac52df5551e76.js",
44
+ "static/chunks/317-0cc5d3d1f0f660e8.js",
45
45
  "static/chunks/pages/asset-library-8ba41e8bc4644f41.js"
46
46
  ],
47
47
  "/context/long-term": [
@@ -53,7 +53,7 @@
53
53
  "static/chunks/576-6699fed6c88502fe.js",
54
54
  "static/chunks/195-2c0168eacab722d2.js",
55
55
  "static/chunks/985-4b4a3ed36ada16eb.js",
56
- "static/chunks/375-4a1c73eb22d653d2.js",
56
+ "static/chunks/375-f731e5ec66ab942c.js",
57
57
  "static/chunks/102-881dcc464f983c89.js",
58
58
  "static/chunks/289-0031e62ca424247b.js",
59
59
  "static/chunks/455-97ad88d6604f54b7.js",
@@ -69,7 +69,7 @@
69
69
  "static/chunks/576-6699fed6c88502fe.js",
70
70
  "static/chunks/195-2c0168eacab722d2.js",
71
71
  "static/chunks/985-4b4a3ed36ada16eb.js",
72
- "static/chunks/375-4a1c73eb22d653d2.js",
72
+ "static/chunks/375-f731e5ec66ab942c.js",
73
73
  "static/chunks/102-881dcc464f983c89.js",
74
74
  "static/chunks/289-0031e62ca424247b.js",
75
75
  "static/chunks/455-97ad88d6604f54b7.js",
@@ -85,8 +85,8 @@
85
85
  "static/chunks/576-6699fed6c88502fe.js",
86
86
  "static/chunks/195-2c0168eacab722d2.js",
87
87
  "static/chunks/455-97ad88d6604f54b7.js",
88
- "static/chunks/496-4fb9a063790e65ff.js",
89
- "static/chunks/pages/document-roles-fd02980db151650c.js"
88
+ "static/chunks/496-ceb2d8197d6335cf.js",
89
+ "static/chunks/pages/document-roles-00219c0a0871daec.js"
90
90
  ],
91
91
  "/documents": [
92
92
  "static/chunks/webpack-77d10b4726f13aa5.js",
@@ -96,12 +96,12 @@
96
96
  "static/chunks/787-c18af810af3433f6.js",
97
97
  "static/chunks/576-6699fed6c88502fe.js",
98
98
  "static/chunks/195-2c0168eacab722d2.js",
99
- "static/chunks/375-4a1c73eb22d653d2.js",
99
+ "static/chunks/375-f731e5ec66ab942c.js",
100
100
  "static/chunks/455-97ad88d6604f54b7.js",
101
101
  "static/chunks/506-93f730bc149d0dce.js",
102
- "static/chunks/940-7cb66111eee2f9fb.js",
102
+ "static/chunks/940-364bc292676ba191.js",
103
103
  "static/chunks/499-d6bcc76195b28550.js",
104
- "static/chunks/pages/documents-d34a2487e74532e1.js"
104
+ "static/chunks/pages/documents-930fccb8c2804b16.js"
105
105
  ],
106
106
  "/guide": [
107
107
  "static/chunks/webpack-77d10b4726f13aa5.js",
@@ -109,9 +109,9 @@
109
109
  "static/chunks/main-91fb767ebd74c9c1.js",
110
110
  "static/chunks/433-233659be69169c19.js",
111
111
  "static/chunks/787-c18af810af3433f6.js",
112
- "static/chunks/940-7cb66111eee2f9fb.js",
112
+ "static/chunks/940-364bc292676ba191.js",
113
113
  "static/chunks/20-86ac6910225cce4e.js",
114
- "static/chunks/pages/guide-0a3cdfa79c037307.js"
114
+ "static/chunks/pages/guide-4f27a34912654b0b.js"
115
115
  ],
116
116
  "/knowledge": [
117
117
  "static/chunks/webpack-77d10b4726f13aa5.js",
@@ -127,7 +127,7 @@
127
127
  "static/chunks/787-c18af810af3433f6.js",
128
128
  "static/chunks/576-6699fed6c88502fe.js",
129
129
  "static/chunks/985-4b4a3ed36ada16eb.js",
130
- "static/chunks/375-4a1c73eb22d653d2.js",
130
+ "static/chunks/375-f731e5ec66ab942c.js",
131
131
  "static/chunks/102-881dcc464f983c89.js",
132
132
  "static/chunks/289-0031e62ca424247b.js",
133
133
  "static/chunks/506-93f730bc149d0dce.js",
@@ -143,7 +143,7 @@
143
143
  "static/chunks/787-c18af810af3433f6.js",
144
144
  "static/chunks/576-6699fed6c88502fe.js",
145
145
  "static/chunks/985-4b4a3ed36ada16eb.js",
146
- "static/chunks/375-4a1c73eb22d653d2.js",
146
+ "static/chunks/375-f731e5ec66ab942c.js",
147
147
  "static/chunks/102-881dcc464f983c89.js",
148
148
  "static/chunks/289-0031e62ca424247b.js",
149
149
  "static/css/09be1fdeab8595ab.css",
@@ -156,7 +156,7 @@
156
156
  "static/chunks/433-233659be69169c19.js",
157
157
  "static/chunks/787-c18af810af3433f6.js",
158
158
  "static/chunks/506-93f730bc149d0dce.js",
159
- "static/chunks/788-7f7359a830e3f4fd.js",
159
+ "static/chunks/788-db05269178a28c20.js",
160
160
  "static/chunks/pages/knowledge/manage-ed99a6cb254ddbb7.js"
161
161
  ],
162
162
  "/knowledge/search": [
@@ -191,8 +191,8 @@
191
191
  "static/chunks/main-91fb767ebd74c9c1.js",
192
192
  "static/chunks/433-233659be69169c19.js",
193
193
  "static/chunks/787-c18af810af3433f6.js",
194
- "static/chunks/694-2d545cfbb9779f2c.js",
195
- "static/chunks/795-d8fb7a0420512701.js",
194
+ "static/chunks/694-b6ab4967c35bbcee.js",
195
+ "static/chunks/795-262a7ef599d655f4.js",
196
196
  "static/chunks/pages/overview-1260176045ed5f7a.js"
197
197
  ],
198
198
  "/prompt": [
@@ -223,7 +223,7 @@
223
223
  "static/chunks/576-6699fed6c88502fe.js",
224
224
  "static/chunks/195-2c0168eacab722d2.js",
225
225
  "static/chunks/985-4b4a3ed36ada16eb.js",
226
- "static/chunks/375-4a1c73eb22d653d2.js",
226
+ "static/chunks/375-f731e5ec66ab942c.js",
227
227
  "static/chunks/102-881dcc464f983c89.js",
228
228
  "static/chunks/289-0031e62ca424247b.js",
229
229
  "static/chunks/861-91cbdd34b8e23151.js",
@@ -3,9 +3,9 @@
3
3
  "routes": {},
4
4
  "dynamicRoutes": {},
5
5
  "preview": {
6
- "previewModeId": "1f8826505509a73cdea9537ce6bb9d2e",
7
- "previewModeSigningKey": "f7fbae4f2f5400b6769f03fc4c2db287af29f01572abb4bd2ef8284a488d5c4a",
8
- "previewModeEncryptionKey": "18ab5d85f134955107f8d3e2eb57441322eb3673e44aa831e8c4c4691ccbaa71"
6
+ "previewModeId": "6b868cb84803328a9a5502cfcf63e133",
7
+ "previewModeSigningKey": "cc4801f58620bf773350d4a9260aba23513efe4b91c2d12abf0282f577f17e15",
8
+ "previewModeEncryptionKey": "e8cd62e07fc41c1c819b39b71e628010605fe55580b127bbdf693098f8e3d80d"
9
9
  },
10
10
  "notFoundRoutes": []
11
11
  }
@@ -2,4 +2,4 @@
2
2
  `,"utf8")}function k(a,b){let c=Date.now(),d=i(a),e=d.findIndex(a=>a.id===b.id),f=e>=0?d[e]:void 0,g={id:b.id,type:b.type,title:b.title,stage:b.stage??f?.stage??"uploading",status:b.status??f?.status??"processing",message:b.message??f?.message??"",percent:b.percent??f?.percent??0,fileName:b.fileName??f?.fileName,filePath:b.filePath??f?.filePath,chunkCount:b.chunkCount??f?.chunkCount,textLength:b.textLength??f?.textLength,extractionMode:b.extractionMode??f?.extractionMode,error:b.error??f?.error,createdAt:f?.createdAt??c,updatedAt:c};return e>=0?d[e]=g:d.push(g),j(a,d),g}function l(a,b=50){return i(a).sort((a,b)=>b.updatedAt-a.updatedAt).slice(0,b)}function m(a,b){return i(a).find(a=>a.id===b)}function n(a,b){return i(a).filter(a=>!b||a.type===b).sort((a,b)=>b.updatedAt-a.updatedAt)[0]}function o(a){return i(a).filter(a=>"processing"===a.status).sort((a,b)=>b.updatedAt-a.updatedAt)}function p(a){let b=i(a),c=h(a);return d.existsSync(c)&&d.unlinkSync(c),b.length}function q(a,b){let c=i(a),d=c.filter(a=>a.id!==b);return d.length!==c.length&&(j(a,d),!0)}},23328:(a,b,c)=>{c.d(b,{Qh:()=>l,VS:()=>p,Yy:()=>o,aY:()=>n});var d=c(19898),e=c(87550),f=c.n(e),g=c(33873),h=c(21820),i=c(29021);let j=null;function k(){return g.join(h.homedir(),".customize-agent")}function l(){return j||(j=new d.MultiProjectManager(k())),j}function m(a){let b=g.resolve(a),c=g.resolve(g.join(h.homedir(),".customize-agent"));return!(i.existsSync(g.join(b,"pnpm-workspace.yaml"))&&i.existsSync(g.join(b,"apps","server")))&&(b===c||b.includes(`${g.sep}.customize-agent${g.sep}`)||b.endsWith(`${g.sep}apps${g.sep}server`)||b.endsWith(`${g.sep}apps${g.sep}cli`))}function n(){let a=process.env.CUSTOMIZE_PROJECT_ROOT??process.env.INIT_CWD;if(a&&i.existsSync(a)&&!m(a))return g.resolve(a);let b=function(){let a=g.join(k(),"projects","registry.db");if(!i.existsSync(a))return[];let b=new(f())(a,{readonly:!0});try{return b.prepare("SELECT project_root FROM project_registry ORDER BY last_opened_at DESC").all().map(a=>g.resolve(a.project_root)).filter(a=>!m(a))}finally{b.close()}}();return b.length>0?b[0]:process.env.INIT_CWD&&!m(process.env.INIT_CWD)?process.env.INIT_CWD:g.resolve(process.cwd(),"../..")}function o(a,b={}){let c=new Map;for(let b of function(a){let b=g.join(h.homedir(),".customize-agent","projects",(0,d.computeProjectId)(g.resolve(a)),"kb.db");if(!i.existsSync(b))return[];let c=new d.IndexStateStore(b);try{return c.listRecords().map(a=>({...a,matchedBy:"metadata"}))}finally{c.close()}}(a))c.set(b.relativePath,b);for(let b of function(a){let b=g.join(a,"knowledgeBase");if(!i.existsSync(b))return[];let c=[],d=a=>{for(let e of i.readdirSync(a,{withFileTypes:!0})){let f=g.join(a,e.name);if(e.isDirectory()){d(f);continue}if(e.name.endsWith(".source.txt"))continue;let h=i.statSync(f),j=g.relative(b,f).split(g.sep).join("/");c.push({relativePath:j,category:j.includes("表格数据/")?"spreadsheet":j.includes("图片素材/")?"image":j.includes("图纸文件/")?"cad":j.includes("文档资料/")?"document":"other",format:g.extname(j).slice(1).toLowerCase()||"text",contentHash:"",fileSize:h.size,mtime:h.mtimeMs,chunkCount:0,collectionName:"",indexedAt:0,lastVerifiedAt:0,status:"disk",matchedBy:"disk"})}};return d(b),c}(a)){let a=c.get(b.relativePath);c.set(b.relativePath,a?{...a,fileSize:b.fileSize,mtime:b.mtime,matchedBy:"metadata"}:b)}return Array.from(c.values()).filter(a=>!b.category||a.category===b.category).sort((a,b)=>b.mtime-a.mtime||a.relativePath.localeCompare(b.relativePath,"zh-CN"))}async function p(a,b={}){let c=(b.query||"").trim(),d=Math.max(1,Math.min(500,b.limit??50)),e=new Map,f=o(a,{category:b.category});for(let a of f)(!c||`${a.relativePath}
3
3
  ${a.category}
4
4
  ${a.format}
5
- ${a.status}`.toLowerCase().includes(c.toLowerCase()))&&e.set(a.relativePath,{...a,matchedBy:c?"path":a.matchedBy});if(c&&!1!==b.includeContent)try{for(let b of(await l().search(a,c,{limit:Math.max(20,d)})).results){let a=b.filePath,c=e.get(a)||f.find(b=>b.relativePath===a);e.set(a,{...c||{relativePath:a,category:"content",format:"knowledge",fileSize:0,mtime:0,chunkCount:0,indexedAt:0,lastVerifiedAt:0,status:"active"},matchedBy:"content",score:b.score})}}catch{}let g=Array.from(e.values()).sort((a,b)=>{let c=a=>"content"===a.matchedBy?3:"path"===a.matchedBy?2:+("metadata"===a.matchedBy);return c(b)-c(a)||(b.score??0)-(a.score??0)||b.mtime-a.mtime||a.relativePath.localeCompare(b.relativePath,"zh-CN")});return{files:g.slice(0,d),total:g.length}}},70432:(a,b,c)=>{c.d(b,{DA:()=>k,ls:()=>l});var d=c(79646),e=c(33873),f=c.n(e),g=c(23328),h=c(6708);let i=new Map;async function j(a,b,c,d){let e;try{e=await (0,g.Qh)().getProject(a.projectRoot);let f=e=>{var f;return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:(f=e.stage,"parsing"===f||"chunking"===f||"vectorizing"===f||"done"===f||"error"===f?f:"indexing"===f?"chunking":"scanning"===f?"uploading":"vectorizing"),status:"error"===e.stage?"error":"processing",percent:e.percent,message:e.message,filePath:e.filePath||a.relativePath,chunkCount:e.chunkCount,error:e.vectorStatus?.error})},i=a.relativePath?await e.reindexFile(a.relativePath,{vectorMode:a.vectorMode,onProgress:f}):a.forceReindexAll?await e.forceReindexAll({vectorMode:a.vectorMode,onProgress:f}):await e.consumePendingIndexJobs({vectorMode:a.vectorMode,onProgress:f,waitForUploadId:a.uploadOperationId}),j=0;for(;!a.relativePath&&(e.countPendingIndexJobs()>0||a.uploadOperationId&&e.uploadSessionIsOpen(a.uploadOperationId)&&j<120);){if(0===e.countPendingIndexJobs()){j+=1,await new Promise(a=>setTimeout(a,1e3));continue}j=0;let b=await e.consumePendingIndexJobs({vectorMode:a.vectorMode,onProgress:f,waitForUploadId:a.uploadOperationId});i={newFiles:[...i.newFiles,...b.newFiles],modifiedFiles:[...i.modifiedFiles,...b.modifiedFiles],deletedFiles:[...i.deletedFiles,...b.deletedFiles],unchangedCount:i.unchangedCount+b.unchangedCount,mtimeOnlyCount:i.mtimeOnlyCount+b.mtimeOnlyCount,skippedFiles:[...i.skippedFiles,...b.skippedFiles],hasChanges:i.hasChanges||b.hasChanges,diffTimeMs:i.diffTimeMs+b.diffTimeMs}}let k=e.getVectorStatus();if("error"===k.status){let f=k.error||"HNSWLib 向量入库失败";return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"error",status:"error",percent:100,message:f,error:f}),{success:!1,error:f,stats:{...e.getStats(),vectorStatus:k}}}return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"done",status:"success",percent:100,message:a.relativePath?"单文件重新解析完成":"知识库后台索引完成",filePath:a.relativePath,fileName:a.relativePath?.split("/").pop()}),{success:!0,stats:{...e.getStats(),vectorStatus:k}}}catch(g){let f=g instanceof Error?g.stack||g.message:String(g);return e?.failPendingIndexJobs?.(f),(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"error",status:"error",percent:100,message:f,error:f}),{success:!1,error:f}}}function k(a){!function(a){let b=i.get(a.projectRoot);if(b)return b.promise;let c=a.uploadOperationId??a.id,e=a.uploadOperationId?"upload":"reindex",g=a.uploadOperationId?`上传 ${a.uploadTitle??"文件"}`:a.relativePath?`重新解析 ${a.relativePath}`:"知识库后台索引";(0,h.Qf)(a.projectRoot,{id:c,type:e,title:g,stage:"uploading",status:"processing",percent:5,message:"索引任务已进入后台队列",filePath:a.relativePath,fileName:a.relativePath?.split("/").pop()});let k=("1"===process.env.CUSTOMIZE_AGENT_DISABLE_KB_CHILD_PROCESS?j(a,c,e,g):function(a,b,c,e){let g=f().resolve(process.cwd(),"scripts/kb-index-worker.cjs");return new Promise(f=>{let i=(0,d.fork)(g,[JSON.stringify({...a,operationId:b})],{cwd:process.cwd(),stdio:["ignore","pipe","pipe","ipc"],env:process.env});i.stdout?.on("data",d=>{let f=String(d).trim();f&&(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"parsing",status:"processing",percent:5,message:`后台索引输出:${f.slice(-1e3)}`})}),i.stderr?.on("data",d=>{let f=String(d).trim();f&&(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"parsing",status:"processing",percent:5,message:`后台索引错误输出:${f.slice(-1e3)}`})}),i.on("error",d=>{let g=d instanceof Error?d.message:String(d);(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"error",status:"error",percent:100,message:g,error:g}),f({success:!1,error:g})}),i.on("exit",d=>{if(0===d)f({success:!0});else{let g=`知识库后台进程退出,退出码 ${d??"unknown"}`;(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"error",status:"error",percent:100,message:g,error:g}),f({success:!1,error:g})}})})}(a,c,e,g)).finally(()=>i.delete(a.projectRoot));i.set(a.projectRoot,{operationId:c,promise:k,startedAt:Date.now()})}(a)}function l(a){let b=i.get(a);return b?{operationId:b.operationId,startedAt:b.startedAt}:void 0}}};
5
+ ${a.status}`.toLowerCase().includes(c.toLowerCase()))&&e.set(a.relativePath,{...a,matchedBy:c?"path":a.matchedBy});if(c&&!1!==b.includeContent)try{for(let b of(await l().search(a,c,{limit:Math.max(20,d)})).results){let a=b.filePath,c=e.get(a)||f.find(b=>b.relativePath===a);e.set(a,{...c||{relativePath:a,category:"content",format:"knowledge",fileSize:0,mtime:0,chunkCount:0,indexedAt:0,lastVerifiedAt:0,status:"active"},matchedBy:"content",score:b.score})}}catch{}let g=Array.from(e.values()).sort((a,b)=>{let c=a=>"content"===a.matchedBy?3:"path"===a.matchedBy?2:+("metadata"===a.matchedBy);return c(b)-c(a)||(b.score??0)-(a.score??0)||b.mtime-a.mtime||a.relativePath.localeCompare(b.relativePath,"zh-CN")});return{files:g.slice(0,d),total:g.length}}},70432:(a,b,c)=>{c.d(b,{DA:()=>l,ls:()=>m});var d=c(79646),e=c(33873),f=c.n(e),g=c(23328),h=c(6708);let i=new Map;function j(a){return String(a).split(/\r?\n/u).map(a=>a.trim()).filter(a=>a&&!/^Image too small to scale!!/u.test(a)&&"Line cannot be recognized!!"!==a).join("\n")}async function k(a,b,c,d){let e;try{e=await (0,g.Qh)().getProject(a.projectRoot);let f=e=>{var f;return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:(f=e.stage,"parsing"===f||"chunking"===f||"vectorizing"===f||"done"===f||"error"===f?f:"indexing"===f?"chunking":"scanning"===f?"uploading":"vectorizing"),status:"error"===e.stage?"error":"processing",percent:e.percent,message:e.message,filePath:e.filePath||a.relativePath,chunkCount:e.chunkCount,error:e.vectorStatus?.error})},i=a.relativePath?await e.reindexFile(a.relativePath,{vectorMode:a.vectorMode,onProgress:f}):a.forceReindexAll?await e.forceReindexAll({vectorMode:a.vectorMode,onProgress:f}):await e.consumePendingIndexJobs({vectorMode:a.vectorMode,onProgress:f,waitForUploadId:a.uploadOperationId}),j=0;for(;!a.relativePath&&(e.countPendingIndexJobs()>0||a.uploadOperationId&&e.uploadSessionIsOpen(a.uploadOperationId)&&j<120);){if(0===e.countPendingIndexJobs()){j+=1,await new Promise(a=>setTimeout(a,1e3));continue}j=0;let b=await e.consumePendingIndexJobs({vectorMode:a.vectorMode,onProgress:f,waitForUploadId:a.uploadOperationId});i={newFiles:[...i.newFiles,...b.newFiles],modifiedFiles:[...i.modifiedFiles,...b.modifiedFiles],deletedFiles:[...i.deletedFiles,...b.deletedFiles],unchangedCount:i.unchangedCount+b.unchangedCount,mtimeOnlyCount:i.mtimeOnlyCount+b.mtimeOnlyCount,skippedFiles:[...i.skippedFiles,...b.skippedFiles],hasChanges:i.hasChanges||b.hasChanges,diffTimeMs:i.diffTimeMs+b.diffTimeMs}}let k=e.getVectorStatus();if("error"===k.status){let f=k.error||"HNSWLib 向量入库失败";return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"error",status:"error",percent:100,message:f,error:f}),{success:!1,error:f,stats:{...e.getStats(),vectorStatus:k}}}return(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"done",status:"success",percent:100,message:a.relativePath?"单文件重新解析完成":"知识库后台索引完成",filePath:a.relativePath,fileName:a.relativePath?.split("/").pop()}),{success:!0,stats:{...e.getStats(),vectorStatus:k}}}catch(g){let f=g instanceof Error?g.stack||g.message:String(g);return e?.failPendingIndexJobs?.(f),(0,h.Qf)(a.projectRoot,{id:b,type:c,title:d,stage:"error",status:"error",percent:100,message:f,error:f}),{success:!1,error:f}}}function l(a){!function(a){let b=i.get(a.projectRoot);if(b)return b.promise;let c=a.uploadOperationId??a.id,e=a.uploadOperationId?"upload":"reindex",g=a.uploadOperationId?`上传 ${a.uploadTitle??"文件"}`:a.relativePath?`重新解析 ${a.relativePath}`:"知识库后台索引";(0,h.Qf)(a.projectRoot,{id:c,type:e,title:g,stage:"uploading",status:"processing",percent:5,message:"索引任务已进入后台队列",filePath:a.relativePath,fileName:a.relativePath?.split("/").pop()});let l=("1"===process.env.CUSTOMIZE_AGENT_DISABLE_KB_CHILD_PROCESS?k(a,c,e,g):function(a,b,c,e){let g=f().resolve(process.cwd(),"scripts/kb-index-worker.cjs");return new Promise(f=>{let i=(0,d.fork)(g,[JSON.stringify({...a,operationId:b})],{cwd:process.cwd(),stdio:["ignore","pipe","pipe","ipc"],env:process.env});i.stdout?.on("data",d=>{let f=j(d);f&&(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"parsing",status:"processing",percent:5,message:`后台索引输出:${f.slice(-1e3)}`})}),i.stderr?.on("data",d=>{let f=j(d);f&&(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"parsing",status:"processing",percent:5,message:`后台索引错误输出:${f.slice(-1e3)}`})}),i.on("error",d=>{let g=d instanceof Error?d.message:String(d);(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"error",status:"error",percent:100,message:g,error:g}),f({success:!1,error:g})}),i.on("exit",d=>{if(0===d)f({success:!0});else{let g=`知识库后台进程退出,退出码 ${d??"unknown"}`;(0,h.Qf)(a.projectRoot,{id:b,type:c,title:e,stage:"error",status:"error",percent:100,message:g,error:g}),f({success:!1,error:g})}})})}(a,c,e,g)).finally(()=>i.delete(a.projectRoot));i.set(a.projectRoot,{operationId:c,promise:l,startedAt:Date.now()})}(a)}function m(a){let b=i.get(a);return b?{operationId:b.operationId,startedAt:b.startedAt}:void 0}}};