@customize-agent/server 3.0.16 → 3.0.17

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 (47) hide show
  1. package/.next/build-manifest.json +12 -12
  2. package/.next/prerender-manifest.json +3 -3
  3. package/.next/server/chunks/3445.js +1 -1
  4. package/.next/server/middleware-build-manifest.js +1 -1
  5. package/.next/server/pages/api/assets/generated/preview.js +1 -1
  6. package/.next/server/pages/api/assets/generated.js +1 -1
  7. package/.next/server/pages/api/documents/export.js +1 -1
  8. package/.next/server/pages/api/documents/generate.js +1 -1
  9. package/.next/server/pages/api/documents/generated/[id].js +1 -1
  10. package/.next/server/pages/api/documents/generated.js +1 -1
  11. package/.next/server/pages/asset-library.html +1 -1
  12. package/.next/server/pages/context/long-term.html +1 -1
  13. package/.next/server/pages/context/short-term.html +1 -1
  14. package/.next/server/pages/document-roles.html +1 -1
  15. package/.next/server/pages/document-specs.html +1 -1
  16. package/.next/server/pages/documents.html +1 -1
  17. package/.next/server/pages/knowledge/file-detail.html +1 -1
  18. package/.next/server/pages/knowledge/files.html +1 -1
  19. package/.next/server/pages/knowledge/manage.html +1 -1
  20. package/.next/server/pages/knowledge/search.html +1 -1
  21. package/.next/server/pages/models.html +1 -1
  22. package/.next/server/pages/overview.html +1 -1
  23. package/.next/server/pages-manifest.json +25 -25
  24. package/.next/static/chunks/pages/asset-library-82606363f9142bad.js +1 -0
  25. package/.next/static/chunks/pages/context/{long-term-09e23b06634b08d9.js → long-term-f2a550bc848ec1a3.js} +1 -1
  26. package/.next/static/chunks/pages/context/short-term-1de28da82d2b6276.js +1 -0
  27. package/.next/static/chunks/pages/document-roles-54a1cc04116e8c18.js +1 -0
  28. package/.next/static/chunks/pages/document-specs-723dee6883949a17.js +1 -0
  29. package/.next/static/chunks/pages/documents-c1a01ae631b42488.js +1 -0
  30. package/.next/static/chunks/pages/knowledge/file-detail-7a1a3d4352ecfa0a.js +1 -0
  31. package/.next/static/chunks/pages/knowledge/files-f0e05583bf7c57d9.js +1 -0
  32. package/.next/static/chunks/pages/knowledge/manage-8acff53019eb6cc1.js +1 -0
  33. package/.next/static/chunks/pages/knowledge/{search-3fd704d2afa1af3e.js → search-1f3bd8fcb7af3e4d.js} +1 -1
  34. package/.next/static/chunks/pages/models-11533caad3723009.js +1 -0
  35. package/.next/static/chunks/pages/overview-f80672c242d9aa32.js +1 -0
  36. package/.next/static/customize-agent-dashboard/_buildManifest.js +1 -1
  37. package/package.json +1 -1
  38. package/.next/static/chunks/pages/asset-library-0f607b74fa016470.js +0 -1
  39. package/.next/static/chunks/pages/context/short-term-2f5fd8531e87b5bd.js +0 -1
  40. package/.next/static/chunks/pages/document-roles-077fc7159c88e89e.js +0 -1
  41. package/.next/static/chunks/pages/document-specs-fb5b8a89cff6d1e3.js +0 -1
  42. package/.next/static/chunks/pages/documents-38320ae2fd50be35.js +0 -1
  43. package/.next/static/chunks/pages/knowledge/file-detail-ad1dc61c1413db0c.js +0 -1
  44. package/.next/static/chunks/pages/knowledge/files-896c058f2da5e907.js +0 -1
  45. package/.next/static/chunks/pages/knowledge/manage-6da10158f75718cf.js +0 -1
  46. package/.next/static/chunks/pages/models-7bdf24068811ae91.js +0 -1
  47. package/.next/static/chunks/pages/overview-572bba4876e617f5.js +0 -1
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[298],{6578:(e,t,n)=>{"use strict";async function s(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.text(),t=e||"HTTP ".concat(n.status);try{let n=JSON.parse(e);t=n.error||n.message||t}catch(e){}throw Error(t)}return n.json()}async function o(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return s("/api/kb/stats".concat(t))}async function i(e){var t,n;let o=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&o.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&o.set("category",e.category),(null==e?void 0:e.page)&&o.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&o.set("limit",String(null!=(n=e.limit)?n:50)),s("/api/kb/files?".concat(o))}async function a(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),s("/api/kb/files/detail?".concat(n))}async function r(e,t){return s("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function c(e,t,n){return s("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:t,projectRoot:n})})}async function l(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>{let e=s.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},s.onerror=n,s.readAsDataURL(e)})}async function d(e,t,n){return s("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:t,uploadId:n})})}async function u(e){return s("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t))}async function m(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t),{method:"DELETE"})}async function h(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function y(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function f(e){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return s("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function x(){return s("/api/kb/features")}async function j(e,t){var n,o,i,a,r;let c=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&c.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&c.set("category",t.category),(null==t?void 0:t.limit)&&c.set("limit",String(null!=(r=t.limit)?r:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&c.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(o=t.weights)?void 0:o.vector)!=null&&c.set("vectorWeight",String(t.weights.vector)),(null==t||null==(i=t.weights)?void 0:i.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(a=t.weights)?void 0:a.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),s("/api/kb/search?".concat(c))}async function w(){return s("/api/prompt")}async function A(e){return s("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function v(e){return s("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function b(e,t){return s("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function S(e){return s("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return s("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function I(){return s("/api/documents/specs")}async function C(e){return s("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function T(e){return s("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function E(){return s("/api/documents/templates")}async function R(e){return s("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return s("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function N(e){return s("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function O(e){return s("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function _(){return s("/api/documents/generated")}async function L(e){return s("/api/documents/generated/".concat(encodeURIComponent(e)))}async function D(e,t){return s("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function U(e){return s("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function J(){return s("/api/assets/generated")}async function M(e){return s("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function F(e){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function z(e,t){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:t})})}async function G(e){return s("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function q(e,t){return s("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function H(e){let t=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());return t.blob()}async function K(){return s("/api/config/providers")}async function Q(e,t){return s("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function V(e){return s("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function W(){return s("/api/config/models")}async function X(e){return s("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function B(){return s("/api/config/embedding")}async function Z(e){return s("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function $(){return s("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return s("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return s("/api/system/stats")}async function et(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return s("/api/context".concat(n))}async function en(e){return s("/api/context?type=".concat(e,"&stats=1"))}async function es(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function eo(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function ei(e){return s("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function ea(e,t){return s("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function er(e){return s("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>q,Bh:()=>er,Dl:()=>E,E:()=>eo,EK:()=>C,ER:()=>T,FC:()=>ee,FV:()=>b,H1:()=>g,H7:()=>m,HC:()=>r,HT:()=>i,II:()=>B,JU:()=>M,NR:()=>S,OX:()=>O,PH:()=>es,QG:()=>U,QT:()=>u,Qx:()=>p,R1:()=>G,SJ:()=>y,UE:()=>H,VW:()=>x,W2:()=>j,X8:()=>f,Z3:()=>K,_m:()=>Q,a6:()=>D,aP:()=>X,bV:()=>N,bZ:()=>Y,c1:()=>d,cQ:()=>_,dd:()=>Z,dg:()=>v,dw:()=>k,dx:()=>w,f$:()=>J,h0:()=>P,h1:()=>V,hc:()=>o,hn:()=>et,l2:()=>R,lv:()=>A,mx:()=>I,oS:()=>z,p:()=>en,tn:()=>c,u6:()=>$,uc:()=>F,v7:()=>L,xC:()=>a,xq:()=>h,xw:()=>ei,zo:()=>ea,zr:()=>W})},16403:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/documents",function(){return n(19562)}])},19562:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>V});var s=n(65321),o=n(97109),i=n(7576),a=n(35292),r=n(17807),c=n(63455),l=n(68787),d=n(85114),u=n(2256),p=n(38770),m=n(38332),h=n(84253),y=n(26171),f=n(33442),g=n(11702),x=n(57271),j=n(9730),w=n(58569),A=n(25258),v=n(26631),b=n(23216),S=n(26619),k=n(8263),I=n(16285),C=n(8579),T=n(75548),E=n(7851),R=n(84742),P=n(29071),N=n(63552),O=n(76830),_=n(83914),L=n(58209),D=n(54746),U=n(93051),J=n(99650),M=n(67547),F=n(99811),z=n(6578),G=n(13014);let{TextArea:q}=i.A,{Paragraph:H}=a.A,K=null;function Q(){null==K||K.listeners.forEach(e=>e())}function V(){var e,t,n;let a=(0,G.Vr)(),{message:V}=r.A.useApp(),[W]=c.A.useForm(),[X,B]=(0,o.useState)([]),[Z,$]=(0,o.useState)("construction-organization-design"),[Y,ee]=(0,o.useState)([]),[et,en]=(0,o.useState)([]),[es,eo]=(0,o.useState)([]),[ei,ea]=(0,o.useState)(!1),[er,ec]=(0,o.useState)(null),[el,ed]=(0,o.useState)(""),[eu,ep]=(0,o.useState)([]),[em,eh]=(0,o.useState)(null),[ey,ef]=(0,o.useState)(!1),[eg,ex]=(0,o.useState)(null),[ej,ew]=(0,o.useState)(!1),[eA,ev]=(0,o.useState)([]),[eb,eS]=(0,o.useState)(null),ek=async()=>{try{ep((await (0,z.cQ)()).documents)}catch(e){ep([])}};(0,o.useEffect)(()=>{let e=()=>{K&&(ev(K.flowSteps),eS(K.activeFlowKey),ea(K.loading),K.draft&&ec(K.draft),void 0!==K.content&&ed(K.content))};return null==K||K.listeners.add(e),e(),()=>{null==K||K.listeners.delete(e)}},[]),(0,o.useEffect)(()=>{(0,z.Dl)().then(e=>{var t,n;B(e.templates),$(null!=(n=null==(t=e.templates[0])?void 0:t.id)?n:"construction-organization-design")}).catch(()=>V.error(a("common.error"))),(0,z.lv)().then(e=>{ee(e.roles),en(e.configs)}).catch(()=>{ee([]),en([])}),(0,z.mx)().then(e=>eo(e.specs)).catch(()=>eo([])),ek()},[V,a]);let eI=(0,o.useMemo)(()=>X.find(e=>e.id===Z),[X,Z]),eC=et.map(e=>({label:e.name,value:e.id})),eT=es.map(e=>({label:e.name,value:e.id})),eE=Math.max(0,eA.findIndex(e=>e.key===eb)),eR=e=>e.map((e,t)=>({key:"sub-".concat(t),title:e,status:"wait"})),eP=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eI,t=es.find(t=>t.id===(null==e?void 0:e.documentSpecId)),n=et.find(t=>t.id===(null==e?void 0:e.projectRoleConfigId)),o=((null==n?void 0:n.fileRoles)||[]).map(e=>{var t;return(null==(t=Y.find(t=>t.id===e.roleId))?void 0:t.name)||e.roleId}),i=((null==n?void 0:n.promptRoles)||[]).map(e=>{var t;return(null==(t=Y.find(t=>t.id===e.roleId))?void 0:t.name)||e.roleId}),r=(null==t?void 0:t.factFields.map(e=>e.name))||(null==e?void 0:e.chapters.flatMap(e=>e.requiredFacts))||[],c=(null==e?void 0:e.chapters.map(e=>e.title))||[],l=i.some(e=>/封面|图片|资源|cover|image/iu.test(e));return[{key:"prepare",title:a("documents.flowPrepare"),description:"读取“".concat((null==e?void 0:e.name)||"当前模板","”并创建后台生成任务"),status:"process",icon:(0,s.jsx)(v.A,{}),subSteps:eR(["读取模板参数",(null==e?void 0:e.documentSpecId)?"加载规范包:".concat((null==t?void 0:t.name)||e.documentSpecId):"未绑定规范包,使用模板章节要求","创建后台生成任务"])},{key:"role_binding",title:"动态角色配置绑定",description:"绑定 ".concat(o.length," 个文件角色、").concat(i.length," 个提示词角色"),status:"wait",icon:(0,s.jsx)(b.A,{}),subSteps:eR([...o.length?o.map(e=>"文件角色:".concat(e)):["没有文件角色,使用模板绑定文件"],...i.length?i.map(e=>"提示词角色:".concat(e)):["没有提示词角色,使用默认生成策略"]].slice(0,10))},{key:"knowledge_retrieval",title:"知识库证据检索",description:"按 ".concat(c.length," 个章节检索文本、文档、表格、图片、图纸和附件"),status:"wait",icon:(0,s.jsx)(S.A,{}),subSteps:eR(c.length?c.slice(0,10).map(e=>"检索章节:".concat(e)):["按模板标题检索证据"])},{key:"file_understanding",title:"多类型文件理解",description:"按文件角色处理文本、PDF/Word、表格、图片、图纸和附件",status:"wait",icon:(0,s.jsx)(k.A,{}),subSteps:eR(["识别文件类型和角色","构建结构化资源证据包","必要时调用多模态文件理解"])},{key:"fact_extraction",title:"动态 schema 事实抽取",description:"按 ".concat(r.length," 个规范/章节事实字段抽取并检测冲突"),status:"wait",icon:(0,s.jsx)(I.A,{}),subSteps:eR(r.length?r.slice(0,10).map(e=>"抽取事实:".concat(e)):["抽取模板要求的事实","合并来源和角色","检测事实冲突"])},{key:"chapter_generation",title:"章节生成",description:"按 ".concat(c.length," 个模板章节逐章生成"),status:"wait",icon:(0,s.jsx)(C.A,{}),subSteps:eR(c.length?c.slice(0,10).map(e=>"生成:".concat(e)):["构造章节提示词","等待 LLM 生成","整理章节证据"])},...l?[{key:"asset_generation",title:"生成资源处理",description:"根据资源/图片提示词生成或登记本地资源",status:"wait",icon:(0,s.jsx)(T.A,{}),subSteps:eR(["生成资源提示词","保存到 generatedDocuments/assets","登记资源元数据"])}]:[],{key:"validation",title:"规范包与门禁校验",description:t?"执行 ".concat(t.gateRules.length," 条门禁规则"):"执行模板基础校验",status:"wait",icon:(0,s.jsx)(E.A,{}),subSteps:eR([...(null==t?void 0:t.factFields.filter(e=>e.required).map(e=>"必填事实:".concat(e.name)))||[],...(null==t?void 0:t.gateRules.map(e=>"门禁:".concat(e.name)))||["检查章节证据","检查缺失项","检查导出门禁"]].slice(0,10))},{key:"formatting",title:a("documents.flowFormatting"),description:"整理标题、表格、图片、附件引用和正式 Markdown",status:"wait",icon:(0,s.jsx)(R.A,{}),subSteps:eR(["整理标题层级","整理多类型资源引用","生成正式 Markdown"])},{key:"llm_review",title:"LLM 审查优化",description:"再次使用动态 schema、角色和结构化证据审查优化初稿",status:"wait",icon:(0,s.jsx)(P.A,{}),subSteps:eR(["构造审查提示词","检查事实来源和冲突","回填优化后的 Markdown"])},{key:"export_ready",title:"导出就绪",description:"确认 Markdown/HTML/DOCX/PDF 可导出",status:"wait",icon:(0,s.jsx)(N.A,{}),subSteps:eR(["生成导出检查清单","确认阻断项","准备导出格式"])},{key:"done",title:a("documents.flowDone"),description:a("documents.flowDoneDesc"),status:"wait",icon:(0,s.jsx)(O.A,{}),subSteps:eR(["展示生成结果","允许编辑正文","允许导出文件"])}]},eN=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ei;(null==K?void 0:K.loading)&&(K.flowSteps=e,K.activeFlowKey=t,K.loading=n,Q())},eO=(e,t)=>{if("wait"===t)return e.subSteps.map(e=>({...e,status:"wait"}));if("finish"===t)return e.subSteps.map(e=>({...e,status:"finish"}));if("error"===t)return e.subSteps.map((e,t)=>({...e,status:0===t?"error":e.status}));let n=e.subSteps.findIndex(e=>"wait"===e.status);return e.subSteps.map((e,t)=>t<n||-1===n?{...e,status:"finish"}:t===n?{...e,status:"process"}:e)},e_=(e,t,n)=>{eS(e),ev(s=>{let o=s.map(s=>s.key===e?{...s,status:t,description:n||s.description,subSteps:eO(s,t)}:s);return eN(o,e),o})};(0,o.useEffect)(()=>{if(!ei||!eb)return;let e=window.setInterval(()=>{ev(e=>{let t=e.map(e=>{if(e.key!==eb||"process"!==e.status)return e;let t=e.subSteps.findIndex(e=>"process"===e.status),n=t<0?0:Math.min(t+1,e.subSteps.length-1);return{...e,subSteps:e.subSteps.map((e,t)=>t<n?{...e,status:"finish"}:t===n?{...e,status:"process"}:{...e,status:"wait"})}});return eN(t,eb),t})},1400);return()=>window.clearInterval(e)},[eb,ei]);let eL=e=>{ev(t=>{let n=t.findIndex(t=>t.key===e),s=t.map((e,t)=>t<n&&"error"!==e.status?{...e,status:"finish",subSteps:eO(e,"finish")}:e);return eN(s,e),s})},eD=e=>{W.setFieldsValue(null!=e?e:{id:"custom-template-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,documentSpecId:void 0,chapters:[]}),ew(!0)},eU=async()=>{try{let e=await W.validateFields(),t=await (0,z.l2)(e);B(t.templates),$(t.template.id),ew(!1),await ek(),V.success(a("common.success"))}catch(e){e instanceof Error&&V.error(e.message)}},eJ=async e=>{try{let t=await (0,z.bV)(e);B(t.templates),$(t.template.id),V.success(a("common.success"))}catch(e){V.error(a("common.error"))}},eM=async e=>{try{var t,n;let s=await (0,z.h0)(e);B(s.templates),$(null!=(n=null==(t=s.templates[0])?void 0:t.id)?n:""),V.success(a("common.success"))}catch(e){V.error(a("common.error"))}},eF=async e=>{try{await (0,z.QG)(e),em===e&&(eh(null),ec(null),ed("")),await ek(),V.success(a("common.success"))}catch(e){V.error(a("common.error"))}},ez=async e=>{let t=[{key:"chapter_generation",message:"后台任务已创建,正在轮询等待 LLM 章节生成完成…"},{key:"asset_generation",message:"正在轮询等待封面和生成资源写入本地记录…"},{key:"validation",message:"正在轮询等待校验、导出门禁和格式化完成…"},{key:"llm_review",message:"正在轮询等待 LLM 审查优化完成…"}],n=0;for(;;){let{document:s}=await (0,z.v7)(e);if("completed"===s.status&&s.draft)return s;if("failed"===s.status)throw Error(s.error||"生成失败");let o=t[Math.min(n,t.length-1)];eL(o.key),e_(o.key,"process",o.message),n+=1,await new Promise(e=>window.setTimeout(e,1500))}},eG=async()=>{if(!Z)return;if(null==K?void 0:K.loading){ev(K.flowSteps),eS(K.activeFlowKey),ea(!0);return}ea(!0);let e=eP(X.find(e=>e.id===Z)||eI),t=(0,z.OX)({templateId:Z});K={id:Date.now(),templateId:Z,loading:!0,flowSteps:e,activeFlowKey:"prepare",promise:t,listeners:new Set},ev(e),eS("prepare");let n=[{key:"role_binding",message:"正在读取模板、文件角色、提示词角色和文档规范包…"},{key:"knowledge_retrieval",message:"正在从知识库检索章节证据、表格、图片和附件…"},{key:"file_understanding",message:"正在准备多模态文件理解;如果模型支持图片/文件理解,会等待模型返回…"},{key:"fact_extraction",message:"正在等待 LLM 事实抽取和后续章节生成结果,请不要关闭页面…"}].map((e,t)=>window.setTimeout(()=>{eL(e.key),e_(e.key,"process",e.message)},600+900*t));try{let e=await t,s=e.documentId?await ez(e.documentId):void 0,o=e.draft||(null==s?void 0:s.draft);if(!o)throw Error("生成结果为空");(e.documentId||(null==s?void 0:s.id))&&eh(e.documentId||s.id),n.forEach(e=>window.clearTimeout(e)),eL("done"),ec(o),ed((null==s?void 0:s.editedMarkdown)||(null==s?void 0:s.markdown)||o.markdown),(null==K?void 0:K.promise)===t&&(K.draft=o,K.content=(null==s?void 0:s.editedMarkdown)||(null==s?void 0:s.markdown)||o.markdown),ev(e=>{let t=e.map(e=>{let t=o.executionStages.find(t=>t.type===e.key);if("prepare"===e.key)return{...e,status:"finish",description:a("documents.flowPrepareDone"),subSteps:eO(e,"finish")};if("done"===e.key){let t=o.exportGate.passed?"finish":"error";return{...e,status:t,description:o.exportGate.passed?a("documents.flowDoneDesc"):a("documents.flowGateFailed"),subSteps:eO(e,t)}}if(!t)return"process"===e.status?{...e,status:"finish",subSteps:eO(e,"finish")}:e;let n="failed"===t.status?"error":"finish";return{...e,status:n,description:"".concat(t.status.toUpperCase(),":").concat(t.message||e.description),subSteps:eO(e,n)}});return eN(t,"done",!1),t}),eS("done"),(null==K?void 0:K.promise)===t&&(K.activeFlowKey="done",K.loading=!1,Q()),await ek(),V.success(a("common.success"))}catch(n){let e=n instanceof Error?n.message:a("common.error");ev(t=>{let n=t.map(t=>"process"===t.status?{...t,status:"error",description:e,subSteps:eO(t,"error")}:t);return eN(n,eb,!1),n}),(null==K?void 0:K.promise)===t&&(K.loading=!1,K.error=e,Q()),V.error(e)}finally{n.forEach(e=>window.clearTimeout(e)),ea(!1),(null==K?void 0:K.promise)===t&&(K.loading=!1,Q())}},eq=async e=>{if(er){ef(!0);try{let o=null==(t=es.find(e=>e.id===(null==eI?void 0:eI.documentSpecId)))?void 0:t.wordTemplatePath;var t,n=await (0,z.UE)({documentId:em||void 0,title:er.title,markdown:el,format:e,enforceGate:"pdf"===e||"docx"===e,exportGate:er.exportGate,wordTemplatePath:o}),s="".concat(er.title,".").concat("markdown"===e?"md":e);let i=URL.createObjectURL(n),a=document.createElement("a");a.href=i,a.download=s,a.click(),URL.revokeObjectURL(i)}catch(e){V.error(a("common.error"))}finally{ef(!1)}}},eH=async()=>{if(er)try{if(em)await (0,z.a6)(em,{editedMarkdown:el,markdown:el});else{let e=await (0,z.Af)({...er,markdown:el});ec(e.draft)}await ek(),V.success(a("common.success"))}catch(e){V.error(a("common.error"))}},eK=async e=>{if(er){ex(e.id);try{var t;let n=await (0,z.R1)({templateId:er.templateId,chapterId:e.id}),s=er.chapters.map(t=>t.id===e.id?n.chapter:t);ec({...er,chapters:s}),t=n.chapter,ed(n=>n.includes(e.content)?n.replace(e.content,t.content):"".concat(n,"\n\n").concat(t.content)),V.success(a("common.success"))}catch(e){V.error(a("common.error"))}finally{ex(null)}}};return(0,s.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,s.jsx)(l.A,{className:"cardGlass",styles:{body:{padding:24}},children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"pageTitle mb-1",children:a("documents.title")}),(0,s.jsx)("p",{className:"pageDesc mb-0",children:a("documents.description")})]}),(0,s.jsx)(d.Ay,{type:"primary",size:"large",icon:(0,s.jsx)(D.A,{}),onClick:()=>eD(),children:a("documents.newTemplate")})]})}),(0,s.jsxs)(u.A,{gutter:[16,16],align:"top",children:[(0,s.jsxs)(p.A,{xs:24,lg:8,children:[(0,s.jsx)(l.A,{size:"small",title:a("documents.templateLibrary"),children:(0,s.jsx)(m.A,{dataSource:X,locale:{emptyText:(0,s.jsx)(h.A,{description:a("common.noData")})},renderItem:e=>(0,s.jsx)(m.A.Item,{onClick:()=>$(e.id),className:"cursor-pointer",actions:[(0,s.jsx)(d.Ay,{size:"small",type:"text",icon:(0,s.jsx)(U.A,{}),onClick:t=>{t.stopPropagation(),eJ(e.id)}},"copy"),(0,s.jsx)(d.Ay,{size:"small",type:"text",icon:(0,s.jsx)(J.A,{}),disabled:e.builtIn,onClick:t=>{t.stopPropagation(),eD(e)}},"edit"),(0,s.jsx)(y.A,{title:a("documents.deleteTemplateConfirm"),disabled:e.builtIn,onConfirm:t=>{null==t||t.stopPropagation(),eM(e.id)},children:(0,s.jsx)(d.Ay,{size:"small",type:"text",danger:!0,icon:(0,s.jsx)(L.A,{}),disabled:e.builtIn,onClick:e=>e.stopPropagation()})},"delete")],children:(0,s.jsx)(m.A.Item.Meta,{avatar:(0,s.jsx)(v.A,{}),title:(0,s.jsxs)(f.A,{children:[(0,s.jsx)("span",{children:e.name}),e.builtIn&&(0,s.jsx)(g.A,{children:a("documents.builtIn")}),Z===e.id&&(0,s.jsx)(g.A,{color:"blue",children:a("documents.selected")})]}),description:(0,s.jsxs)(f.A,{direction:"vertical",size:2,children:[(0,s.jsx)("span",{children:e.description}),(0,s.jsx)(g.A,{children:e.category})]})})})})}),(0,s.jsx)(l.A,{className:"mt-4",size:"small",title:a("documents.draftHistory"),children:(0,s.jsx)(m.A,{size:"small",dataSource:eu.slice(0,8),locale:{emptyText:(0,s.jsx)(h.A,{description:a("common.noData")})},renderItem:e=>(0,s.jsx)(m.A.Item,{onClick:()=>{(async()=>{eh(e.id),$(e.templateId);let{document:t}=await (0,z.v7)(e.id);ec(t.draft||null),ed(t.editedMarkdown||t.markdown)})()},className:"cursor-pointer",actions:[(0,s.jsx)(y.A,{title:"确认删除这条生成记录?",onConfirm:t=>{null==t||t.stopPropagation(),eF(e.id)},children:(0,s.jsx)(d.Ay,{size:"small",type:"text",danger:!0,icon:(0,s.jsx)(L.A,{}),onClick:e=>e.stopPropagation()})},"delete")],children:(0,s.jsx)(m.A.Item.Meta,{title:(0,s.jsxs)(f.A,{children:[(0,s.jsx)("span",{children:e.title}),(0,s.jsx)(g.A,{color:"completed"===e.status?"success":"failed"===e.status?"error":"processing",children:e.status})]}),description:new Date(e.updatedAt).toLocaleString()})})})})]}),(0,s.jsx)(p.A,{xs:24,lg:16,children:(0,s.jsx)(l.A,{size:"small",title:a("documents.workflow"),children:(0,s.jsxs)(f.A,{direction:"vertical",className:"w-full",size:"middle",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"block mb-1",children:a("documents.template")}),(0,s.jsx)(x.A,{className:"w-full",value:Z,onChange:$,options:X.map(e=>({label:e.name,value:e.id}))})]}),eI&&(0,s.jsxs)(l.A,{size:"small",type:"inner",title:eI.outputTitle,children:[(0,s.jsx)(H,{children:eI.description}),(0,s.jsxs)(f.A,{wrap:!0,children:[eI.projectRoleConfigId?(0,s.jsx)(g.A,{color:"geekblue",children:(null==(e=et.find(e=>e.id===eI.projectRoleConfigId))?void 0:e.name)||eI.projectRoleConfigId}):(0,s.jsx)(g.A,{color:"warning",children:a("documents.noRoleConfig")}),eI.documentSpecId?(0,s.jsx)(g.A,{color:"cyan",children:(null==(t=es.find(e=>e.id===eI.documentSpecId))?void 0:t.name)||eI.documentSpecId}):null]})]}),eI&&(0,s.jsx)(f.A,{direction:"vertical",size:4,children:(0,s.jsxs)("span",{children:[a("documents.projectRoleConfig"),": ",(null==(n=et.find(e=>e.id===eI.projectRoleConfigId))?void 0:n.name)||a("documents.noRoleConfig")]})}),(0,s.jsx)(d.Ay,{type:"primary",size:"large",block:!0,icon:(0,s.jsx)(P.A,{}),loading:ei,disabled:!(null==eI?void 0:eI.projectRoleConfigId),onClick:()=>{eG()},children:a("documents.generate")}),eA.length>0&&(0,s.jsx)(l.A,{size:"small",type:"inner",title:a("documents.executionStatus"),children:(0,s.jsx)(j.A,{direction:"vertical",size:"small",current:eE,items:eA.map(e=>({title:e.title,description:(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{children:e.description}),(0,s.jsx)("div",{className:"space-y-0.5",children:e.subSteps.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-[var(--colorTextSecondary)]",children:["process"===(t=e.status)?(0,s.jsx)(_.A,{}):"finish"===t?(0,s.jsx)(R.A,{}):"error"===t?(0,s.jsx)(L.A,{}):(0,s.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--colorTextTertiary)]"}),(0,s.jsx)("span",{children:e.title})]},e.key)})})]}),status:e.status,icon:"process"===e.status?(0,s.jsx)(_.A,{}):e.icon}))})})]})})})]}),(0,s.jsx)(l.A,{size:"small",title:a("documents.editor"),extra:(0,s.jsx)(f.A,{wrap:!0,children:er&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Ay,{icon:(0,s.jsx)(M.A,{}),onClick:()=>{eH()},children:a("documents.saveDraft")}),(0,s.jsx)(d.Ay,{icon:(0,s.jsx)(O.A,{}),loading:ey,onClick:()=>{eq("markdown")},children:a("documents.downloadMarkdown")}),(0,s.jsx)(d.Ay,{loading:ey,onClick:()=>{eq("html")},children:a("documents.exportHtml")}),(0,s.jsx)(d.Ay,{loading:ey,onClick:()=>{eq("docx")},children:a("documents.exportDocx")}),(0,s.jsx)(d.Ay,{type:"primary",loading:ey,onClick:()=>{eq("pdf")},children:a("documents.exportPdf")})]})}),children:er?(0,s.jsx)(w.A,{items:[{key:"edit",label:a("documents.edit"),children:(0,s.jsx)(q,{rows:26,value:el,onChange:e=>ed(e.target.value)})},{key:"chapters",label:a("documents.chapters"),children:(0,s.jsx)(m.A,{dataSource:er.chapters,renderItem:e=>(0,s.jsx)(m.A.Item,{actions:[(0,s.jsx)(d.Ay,{size:"small",icon:(0,s.jsx)(F.A,{}),loading:eg===e.id,onClick:()=>{eK(e)},children:a("documents.regenerateChapter")},"regen")],children:(0,s.jsx)(m.A.Item.Meta,{title:e.title,description:(0,s.jsxs)(f.A,{direction:"vertical",children:[(0,s.jsxs)("span",{children:[a("documents.evidenceCount"),": ",e.evidence.length]}),(0,s.jsxs)("span",{children:[a("documents.missingCount"),": ",e.missingFacts.length]})]})})})})},{key:"facts",label:a("documents.structuredFacts"),children:(0,s.jsx)(m.A,{dataSource:er.structuredFacts,renderItem:e=>{var t;return(0,s.jsxs)(m.A.Item,{children:[(0,s.jsx)(m.A.Item.Meta,{title:"".concat(e.key,": ").concat(e.value),description:"".concat(e.sourceFile," \xb7 ").concat((null==(t=Y.find(t=>t.id===e.roleId))?void 0:t.name)||e.roleId)}),(0,s.jsx)(g.A,{children:e.confidence.toFixed(2)})]})}})},{key:"sources",label:a("documents.sources"),children:(0,s.jsx)(m.A,{dataSource:er.sources,renderItem:e=>(0,s.jsxs)(m.A.Item,{children:[(0,s.jsx)("span",{children:e.filePath}),(0,s.jsx)(g.A,{children:e.count})]})})},{key:"missing",label:a("documents.missingItems"),children:0===er.missingItems.length?(0,s.jsx)(h.A,{description:a("common.noData")}):(0,s.jsx)(m.A,{dataSource:er.missingItems,renderItem:e=>(0,s.jsx)(m.A.Item,{children:e})})},{key:"validation",label:a("documents.validation"),children:(0,s.jsx)(f.A,{direction:"vertical",className:"w-full",children:er.validationIssues.map(e=>(0,s.jsxs)(g.A,{color:"error"===e.level?"error":"warning"===e.level?"warning":"blue",children:[e.message,e.suggestion?":".concat(e.suggestion):""]},e.message))})},{key:"gate",label:a("documents.exportGate"),children:(0,s.jsx)(m.A,{dataSource:er.exportGate.checklist,renderItem:e=>(0,s.jsxs)(m.A.Item,{children:[(0,s.jsx)("span",{children:e.label}),(0,s.jsx)(g.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})},{key:"stages",label:a("documents.executionStages"),children:(0,s.jsx)(m.A,{dataSource:er.executionStages,renderItem:e=>{var t,n;return(0,s.jsxs)(m.A.Item,{children:[(0,s.jsx)(m.A.Item.Meta,{avatar:(t=e.type,({role_binding:(0,s.jsx)(b.A,{}),knowledge_retrieval:(0,s.jsx)(S.A,{}),file_understanding:(0,s.jsx)(k.A,{}),fact_extraction:(0,s.jsx)(I.A,{}),chapter_generation:(0,s.jsx)(C.A,{}),asset_generation:(0,s.jsx)(T.A,{}),validation:(0,s.jsx)(E.A,{}),formatting:(0,s.jsx)(R.A,{}),llm_review:(0,s.jsx)(P.A,{}),export_ready:(0,s.jsx)(N.A,{}),reference:(0,s.jsx)(T.A,{})})[t]||(0,s.jsx)(v.A,{})),title:"".concat({role_binding:"角色配置绑定",knowledge_retrieval:"知识库检索",file_understanding:"多模态文件理解",fact_extraction:"LLM 事实抽取",chapter_generation:"LLM 章节生成",asset_generation:"多模态资源生成",validation:"规则校验",formatting:"格式化排版",llm_review:"LLM 审查优化",export_ready:"导出就绪",reference:"参考资源处理"}[n=e.type]||n," \xb7 ").concat(e.roleId),description:e.message}),(0,s.jsx)(g.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"skipped"===e.status?"default":"warning",children:e.status})]})}})}]}):(0,s.jsx)(h.A,{description:a("documents.noDraft")})}),(0,s.jsx)(A.A,{maskClosable:!1,title:a("documents.templateEditor"),open:ej,onOk:()=>{eU()},onCancel:()=>ew(!1),width:760,centered:!0,okText:a("common.save"),children:(0,s.jsxs)(c.A,{form:W,layout:"vertical",requiredMark:"optional",children:[(0,s.jsxs)(u.A,{gutter:12,children:[(0,s.jsx)(p.A,{xs:24,md:8,children:(0,s.jsx)(c.A.Item,{name:"id",label:"ID",rules:[{required:!0}],children:(0,s.jsx)(i.A,{disabled:!0})})}),(0,s.jsx)(p.A,{xs:24,md:8,children:(0,s.jsx)(c.A.Item,{name:"name",label:a("documents.templateName"),rules:[{required:!0}],children:(0,s.jsx)(i.A,{})})}),(0,s.jsx)(p.A,{xs:24,md:8,children:(0,s.jsx)(c.A.Item,{name:"category",label:a("documents.templateCategory"),children:(0,s.jsx)(i.A,{})})}),(0,s.jsx)(p.A,{xs:24,md:12,children:(0,s.jsx)(c.A.Item,{name:"outputTitle",label:a("documents.outputTitle"),children:(0,s.jsx)(i.A,{})})}),(0,s.jsx)(p.A,{xs:24,md:12,children:(0,s.jsx)(c.A.Item,{name:"description",label:a("documents.templateDescription"),children:(0,s.jsx)(i.A,{})})})]}),(0,s.jsx)(c.A.Item,{name:"projectRoleConfigId",label:a("documents.projectRoleConfig"),rules:[{required:!0,message:a("documents.projectRoleConfigRequired")}],children:(0,s.jsx)(x.A,{showSearch:!0,placeholder:a("documents.projectRoleConfigRequired"),options:eC})}),(0,s.jsx)(c.A.Item,{name:"documentSpecId",label:a("documents.documentSpec"),children:(0,s.jsx)(x.A,{allowClear:!0,showSearch:!0,placeholder:a("documents.documentSpecPlaceholder"),options:eT})})]})})]})}}},e=>{e.O(0,[260,167,382,628,271,576,700,174,183,232,292,951,858,617,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[309],{6578:(e,t,n)=>{"use strict";async function a(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.text(),t=e||"HTTP ".concat(n.status);try{let n=JSON.parse(e);t=n.error||n.message||t}catch(e){}throw Error(t)}return n.json()}async function i(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return a("/api/kb/stats".concat(t))}async function r(e){var t,n;let i=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&i.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&i.set("category",e.category),(null==e?void 0:e.page)&&i.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&i.set("limit",String(null!=(n=e.limit)?n:50)),a("/api/kb/files?".concat(i))}async function o(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function s(e,t){return a("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function l(e,t,n){return a("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:t,projectRoot:n})})}async function c(e){return new Promise((t,n)=>{let a=new FileReader;a.onload=()=>{let e=a.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},a.onerror=n,a.readAsDataURL(e)})}async function d(e,t,n){return a("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await c(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:t,uploadId:n})})}async function u(e){return a("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),a("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),a("/api/kb/operations?".concat(t),{method:"DELETE"})}async function m(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function y(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function f(e){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return a("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function x(){return a("/api/kb/features")}async function j(e,t){var n,i,r,o,s;let l=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&l.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&l.set("category",t.category),(null==t?void 0:t.limit)&&l.set("limit",String(null!=(s=t.limit)?s:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&l.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(i=t.weights)?void 0:i.vector)!=null&&l.set("vectorWeight",String(t.weights.vector)),(null==t||null==(r=t.weights)?void 0:r.rewrite)!=null&&l.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(o=t.weights)?void 0:o.hybridBonus)!=null&&l.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(l))}async function S(){return a("/api/prompt")}async function w(e){return a("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function C(e){return a("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function b(e,t){return a("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function v(e){return a("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return a("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function A(){return a("/api/documents/specs")}async function T(e){return a("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return a("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){return a("/api/documents/templates")}async function N(e){return a("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function I(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(){return a("/api/documents/generated")}async function J(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)))}async function U(e,t){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function L(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return a("/api/assets/generated")}async function z(e){return a("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function M(e){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function H(e,t){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:t})})}async function F(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function B(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function K(e){let t=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());return t.blob()}async function V(){return a("/api/config/providers")}async function X(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function W(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function q(){return a("/api/config/models")}async function $(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function G(){return a("/api/config/embedding")}async function Q(e){return a("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Z(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return a("/api/system/stats")}async function et(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function en(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function ea(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function ei(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function er(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function eo(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function es(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>B,Bh:()=>es,Dl:()=>_,E:()=>ei,EK:()=>T,ER:()=>P,FC:()=>ee,FV:()=>b,H1:()=>g,H7:()=>h,HC:()=>s,HT:()=>r,II:()=>G,JU:()=>z,NR:()=>v,OX:()=>I,PH:()=>ea,QG:()=>L,QT:()=>u,Qx:()=>p,R1:()=>F,SJ:()=>y,UE:()=>K,VW:()=>x,W2:()=>j,X8:()=>f,Z3:()=>V,_m:()=>X,a6:()=>U,aP:()=>$,bV:()=>O,bZ:()=>Y,c1:()=>d,cQ:()=>E,dd:()=>Q,dg:()=>C,dw:()=>k,dx:()=>S,f$:()=>D,h0:()=>R,h1:()=>W,hc:()=>i,hn:()=>et,l2:()=>N,lv:()=>w,mx:()=>A,oS:()=>H,p:()=>en,tn:()=>l,u6:()=>Z,uc:()=>M,v7:()=>J,xC:()=>o,xq:()=>m,xw:()=>er,zo:()=>eo,zr:()=>q})},14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusPanel:"style_statusPanel__9arTu",statusPanelHeader:"style_statusPanelHeader__nKv1I",statusEmpty:"style_statusEmpty__8LWzH",statusList:"style_statusList__FpNgC",statusItem:"style_statusItem__uzO80",statusHeader:"style_statusHeader__o9q_b",statusDesc:"style_statusDesc__XiWFa",statusPath:"style_statusPath__Udxvv",statusMeta:"style_statusMeta__XukHt",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},37690:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/file-detail",function(){return n(48200)}])},45551:(e,t,n)=>{"use strict";function a(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),n=e/Math.pow(1024,t);return"".concat(n.toFixed(+(0!==t))," ").concat(["B","KB","MB","GB","TB"][t])}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";if(!e||e<=0)return"en-US"===t?"Never":"从未";let n=Math.floor(Math.floor((Date.now()-e)/1e3)/60),a=Math.floor(n/60),i=Math.floor(a/24);return i>30?new Date(e).toLocaleDateString(t):"en-US"===t?i>0?"".concat(i,"d ago"):a>0?"".concat(a,"h ago"):n>0?"".concat(n,"m ago"):"Just now":i>0?"".concat(i," 天前"):a>0?"".concat(a," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>s,fw:()=>i,z3:()=>a});let r={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},o={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function s(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?o:r)[e])?t:e}},48200:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>J});var a=n(65321),i=n(97109),r=n(1873),o=n.n(r),s=n(43220),l=n.n(s),c=n(86109),d=n(35292),u=n(76506),p=n(33442),h=n(11702),m=n(9137),y=n(59400),f=n(68787),g=n(56985),x=n(49604),j=n(84253),S=n(42700),w=n(85493),C=n(85114),b=n(58569),v=n(7576),k=n(6578),A=n(45551),T=n(14569),P=n.n(T);let{Paragraph:_}=d.A;function N(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return{}}}function R(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).slice(0,30):[]}function O(e,t){let n=t.trim()?[t.trim(),...t.split(/[\s,,。;;::、]+/u)].filter(Boolean).sort((e,t)=>t.length-e.length):[];if(0===n.length)return e;let i=RegExp("(".concat(n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),")"),"giu");return e.split(i).map((e,t)=>n.some(t=>t.toLowerCase()===e.toLowerCase())?(0,a.jsx)("mark",{children:e},t):e)}function I(e,t,n){return null==t||""===t||Array.isArray(t)&&0===t.length?null:(0,a.jsx)(u.A.Item,{label:e,children:Array.isArray(t)?(0,a.jsx)(p.A,{wrap:!0,children:t.map(e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>null==n?void 0:n(String(e)),children:String(e)},String(e)))}):String(t)})}function E(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"value";return e.map((e,n)=>({key:"".concat(t,"-").concat(n),name:e}))}function J(){var e,t,n,r,s,d,T,J,U,L;let D=(0,c.useRouter)(),z="string"==typeof D.query.relativePath?D.query.relativePath:"",[M,H]=(0,i.useState)(),[F,B]=(0,i.useState)(!1),[K,V]=(0,i.useState)(""),[X,W]=(0,i.useState)(!1),[q,$]=(0,i.useState)(""),[G,Q]=(0,i.useState)([]);(0,i.useEffect)(()=>{z&&(B(!0),V(""),(0,k.xC)(z).then(H).catch(e=>{H(void 0),V(e instanceof Error?e.message:"文件详情加载失败")}).finally(()=>B(!1)))},[z]);let Z=(0,i.useMemo)(()=>(function(e){let t=N(null==e?void 0:e.file.metadataJson);return"object"==typeof t.extraction&&t.extraction?t.extraction:t})(M),[M]),Y=R(Z.layerNames);(0,i.useEffect)(()=>{Q(Y)},[null==M?void 0:M.file.relativePath,Y.join("|")]);let ee=q.trim().toLowerCase(),et=(0,i.useMemo)(()=>{var e;return M&&ee?M.chunks.filter(e=>{let t=N(e.metadataJson);return[e.content,e.sectionTitle,t.rowRange,t.chunkKind,t.parentId,JSON.stringify(t)].some(e=>String(null!=e?e:"").toLowerCase().includes(ee))}):null!=(e=null==M?void 0:M.chunks)?e:[]},[M,ee]),en=(0,i.useMemo)(()=>{var e;return M&&ee?M.parents.filter(e=>[e.content,e.sectionTitle,e.parentId,e.metadataJson].some(e=>String(null!=e?e:"").toLowerCase().includes(ee))):null!=(e=null==M?void 0:M.parents)?e:[]},[M,ee]),ea=async()=>{if(z){W(!0);try{let e=await (0,k.HC)(z);e.detail&&H(e.detail),m.Ay.success("文件索引已重建")}finally{W(!1)}}},ei=async e=>{e&&(await navigator.clipboard.writeText(e),m.Ay.success("已复制"))},er=async e=>{z&&(await (0,k.tn)(z,e),m.Ay.success("file"===e?"已请求打开文件":"已请求打开目录"))},eo=[{key:"table",label:"表格",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[(0,a.jsxs)(u.A,{size:"small",column:2,bordered:!0,children:[I("Sheet",R(Z.sheetNames),$),I("表头",R(Z.columnNames),$),I("行数",Z.rowCount),I("列数",Z.columnCount),I("公式数",Z.formulaCount),I("合并单元格",Z.mergeCount)]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:E(R(Z.columnNames),"column"),columns:[{title:"列名",dataIndex:"name",render:e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>$(String(e)),children:String(e)})}]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:(null!=(T=null==M?void 0:M.chunks)?T:[]).map(e=>N(e.metadataJson).rowRange).filter(e=>"string"==typeof e).map((e,t)=>({key:"row-".concat(t),name:e})),columns:[{title:"行范围",dataIndex:"name",render:e=>(0,a.jsxs)(h.A,{color:"gold",className:"cursor-pointer",onClick:()=>$(String(e)),children:["行 ",String(e)]})}]}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(J=null==M?void 0:M.chunks)?J:[]).flatMap(e=>e.content.split(/\r?\n/u)).map(e=>e.trim()).filter(e=>e.includes("|")).slice(0,80).map((e,t)=>({key:"grid-".concat(t),cells:e.split("|").map(e=>e.trim()).filter(Boolean)})),pagination:{pageSize:10},columns:[{title:"表格网格预览",dataIndex:"cells",render:e=>(0,a.jsx)(p.A,{wrap:!0,children:e.map((e,t)=>(0,a.jsx)(h.A,{children:e},"".concat(e,"-").concat(t)))})}]})]})},{key:"drawing",label:"图纸",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[(0,a.jsxs)(u.A,{size:"small",column:2,bordered:!0,children:[I("图层",R(Z.layerNames),$),I("块/符号",R(Z.blockNames),$),I("实体类型",R(Z.entityTypes),$),I("产品/零件",R(Z.productNames),$),I("材料",R(Z.materialNames),$),I("实体名称",R(Z.entityNames),$)]}),Y.length>0?(0,a.jsxs)(f.A,{size:"small",title:"图层开关 / 图纸预览",children:[(0,a.jsx)(g.A.Group,{value:G,options:Y.map(e=>({label:e,value:e})),onChange:e=>Q(e.map(String))}),(0,a.jsx)("div",{className:P().drawingPreview,children:G.map(e=>(0,a.jsx)(h.A,{color:"blue",children:e},e))})]}):null,(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:[...E(Y,"layer").map(e=>({...e,type:"图层"})),...E(R(Z.entityTypes),"entity").map(e=>({...e,type:"实体类型"})),...E(R(Z.blockNames),"block").map(e=>({...e,type:"块/符号"}))],columns:[{title:"类型",dataIndex:"type",width:120},{title:"名称",dataIndex:"name",render:e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>$(String(e)),children:String(e)})}]})]})},{key:"data",label:"数据路径",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[R(Z.dataPaths).length>0?(0,a.jsx)(x.A,{defaultExpandAll:!0,treeData:function(e){let t=new Map;for(let n of e){let e=t;for(let t of n.replace(/\[(\d+)\]/gu,".$1").split(".").filter(Boolean))e.has(t)||e.set(t,new Map),e=e.get(t)}let n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return[...e.entries()].map(e=>{let[a,i]=e;return{title:a,key:t?"".concat(t,".").concat(a):a,children:n(i,t?"".concat(t,".").concat(a):a)}})};return n(t)}(R(Z.dataPaths)),onSelect:e=>{var t;return $(String(null!=(t=e[0])?t:""))}}):(0,a.jsx)(j.A,{description:"暂无数据路径"}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(U=null==M?void 0:M.chunks)?U:[]).flatMap(e=>e.content.split(/\r?\n/u)).map(e=>e.trim()).filter(e=>/^[\w.[\]-]+\s*[:=]/u.test(e)).slice(0,200).map((e,t)=>{var n,a,i,r;let o=/^([^:=]+)\s*[:=]\s*(.*)$/u.exec(e);return{key:"data-".concat(t),path:null!=(i=null==o||null==(n=o[1])?void 0:n.trim())?i:e,value:null!=(r=null==o||null==(a=o[2])?void 0:a.trim())?r:""}}),pagination:{pageSize:20},columns:[{title:"Path",dataIndex:"path",width:260,render:e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>$(String(e)),children:String(e)})},{title:"Value",dataIndex:"value",render:e=>(0,a.jsx)("span",{className:"break-all",children:String(e)})}]})]})},{key:"ocr",label:"OCR/PDF",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[(0,a.jsxs)(u.A,{size:"small",column:2,bordered:!0,children:[I("OCR 建议",Z.ocrRecommended),I("OCR 原因",Z.ocrReason),I("OCR 引擎",Z.ocrProvider),I("OCR 语言",Z.ocrLanguages),I("OCR 文本长度",Z.ocrTextLength),I("PDF 页面 OCR 支持",Z.pdfPageOcrSupported),I("PDF OCR 页数",Z.ocrPageCount),I("PDF OCR 页数上限",Z.pdfOcrPageLimit),I("PDF 渲染器",Z.pdfRenderer)]}),(null==M?void 0:M.file.format)==="pdf"?(0,a.jsx)("div",{className:P().pdfPreviewStrip,children:Array.from({length:Math.min(Number(null!=(e=Z.ocrPageCount)?e:1)||1,6)},(e,t)=>(0,a.jsx)(o(),{width:220,height:320,src:"/api/kb/files/preview-pdf-page?relativePath=".concat(encodeURIComponent(M.file.relativePath),"&page=").concat(t+1),alt:"PDF 第 ".concat(t+1," 页"),unoptimized:!0},t))}):null,(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(L=null==M?void 0:M.chunks)?L:[]).map(e=>e.content).join("\n\n").split(/PDF OCR 第\s*(\d+)\s*页[::]/u).slice(1).reduce((e,t,n,a)=>{var i,r,o;return n%2==0&&e.push({key:"page-".concat(t),page:t,text:null!=(o=null==(r=a[n+1])||null==(i=r.split(/PDF OCR 第\s*\d+\s*页[::]/u)[0])?void 0:i.trim())?o:""}),e},[]),pagination:{pageSize:10},columns:[{title:"页码",dataIndex:"page",width:90},{title:"OCR 文本",dataIndex:"text",render:e=>(0,a.jsx)(_,{ellipsis:{rows:4,expandable:!0,symbol:"展开"},children:String(e)})}]})]})}],es=[{title:"#",dataIndex:"chunkIndex",width:70,render:e=>String(e)},{title:"类型",width:110,render:(e,t)=>{var n;return(0,a.jsx)(h.A,{children:String(null!=(n=N(t.metadataJson).chunkKind)?n:t.category)})}},{title:"章节/范围",width:220,render:(e,t)=>{let n=N(t.metadataJson),i="string"==typeof n.rowRange?n.rowRange:void 0;return(0,a.jsxs)(p.A,{wrap:!0,children:[t.sectionTitle?(0,a.jsx)(h.A,{color:"cyan",children:t.sectionTitle}):null,i?(0,a.jsxs)(h.A,{color:"gold",children:["行 ",i]}):null]})}},{title:"Token",dataIndex:"tokenCount",width:90},{title:"内容",render:(e,t)=>(0,a.jsx)(_,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:P().searchContent,children:O(t.content,q)})}],el=[{title:"Parent",dataIndex:"parentId",width:260,render:e=>(0,a.jsx)("span",{className:"break-all",children:e})},{title:"切片数",dataIndex:"chunkCount",width:90},{title:"章节",dataIndex:"sectionTitle",width:220},{title:"内容",render:(e,t)=>(0,a.jsx)(_,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:P().searchContent,children:O(t.content,q)})}];return F?(0,a.jsx)(S.A,{}):K?(0,a.jsx)(w.A,{type:"error",showIcon:!0,message:"文件详情加载失败",description:K}):M?(0,a.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l(),{href:"/knowledge/files",children:"返回文件列表"}),(0,a.jsxs)("div",{className:P().searchResultHeader,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"pageTitle",children:"文件详情"}),(0,a.jsx)("p",{className:"pageDesc",children:"查看解析结果、图纸/表格/数据结构化字段、parent chunk 和 child chunk。"})]}),(0,a.jsxs)(p.A,{children:[(0,a.jsx)(C.Ay,{onClick:()=>{ei(null==M?void 0:M.absolutePath)},children:"复制原文件路径"}),(0,a.jsx)(C.Ay,{onClick:()=>{ei(null==M?void 0:M.directory)},children:"复制所在目录"}),(0,a.jsx)(C.Ay,{onClick:()=>{er("file")},children:"打开文件"}),(0,a.jsx)(C.Ay,{onClick:()=>{er("directory")},children:"打开目录"}),"pdf"===M.file.format?(0,a.jsx)(C.Ay,{loading:X,onClick:()=>{ea()},children:"重新 OCR"}):null,(0,a.jsx)(C.Ay,{type:"primary",loading:X,onClick:()=>{ea()},children:"重建该文件索引"})]})]})]}),(0,a.jsx)(f.A,{size:"small",title:"基础信息",children:(0,a.jsxs)(u.A,{size:"small",column:2,bordered:!0,children:[(0,a.jsx)(u.A.Item,{label:"路径",children:M.file.relativePath}),(0,a.jsx)(u.A.Item,{label:"原文件",children:null!=(t=M.absolutePath)?t:"-"}),(0,a.jsx)(u.A.Item,{label:"所在目录",children:null!=(n=M.directory)?n:"-"}),(0,a.jsxs)(u.A.Item,{label:"分类",children:[(0,a.jsx)(h.A,{children:(0,A.Jm)(M.file.category)})," ",(0,a.jsx)(h.A,{children:M.file.format})]}),(0,a.jsx)(u.A.Item,{label:"大小",children:(0,A.z3)(M.file.fileSize)}),(0,a.jsx)(u.A.Item,{label:"切片数",children:M.file.chunkCount}),(0,a.jsx)(u.A.Item,{label:"状态",children:M.file.status}),(0,a.jsx)(u.A.Item,{label:"解析模式",children:String(null!=(r=Z.extractionMode)?r:"-")}),(0,a.jsx)(u.A.Item,{label:"覆盖范围",children:String(null!=(s=Z.contentCoverage)?s:"-")}),(0,a.jsx)(u.A.Item,{label:"正文长度",children:String(null!=(d=Z.textLength)?d:"-")})]})}),(0,a.jsx)(f.A,{size:"small",title:"结构化信息",children:(0,a.jsx)(b.A,{items:eo})}),(0,a.jsx)(f.A,{size:"small",title:"详情筛选",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[(0,a.jsx)(v.A,{allowClear:!0,value:q,onChange:e=>$(e.target.value),placeholder:"筛选 rowRange、图层、实体、data path、section、chunk 内容"}),q?(0,a.jsxs)(p.A,{wrap:!0,children:[(0,a.jsxs)(h.A,{color:"blue",children:["Parent 命中 ",en.length]}),(0,a.jsxs)(h.A,{color:"green",children:["Child 命中 ",et.length]}),(0,a.jsxs)(h.A,{color:"purple",children:["筛选词 ",q]})]}):null]})}),(0,a.jsx)(f.A,{size:"small",title:"Parent Chunks (".concat(en.length,"/").concat(M.parents.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:el,dataSource:en,pagination:{pageSize:10},size:"small"})}),(0,a.jsx)(f.A,{size:"small",title:"Child Chunks (".concat(et.length,"/").concat(M.chunks.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:es,dataSource:et,pagination:{pageSize:20},size:"small"})})]}):(0,a.jsx)(j.A,{description:"请选择文件"})}}},e=>{e.O(0,[260,167,382,628,271,576,700,174,985,400,292,350,80,636,593,792],()=>e(e.s=37690)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28],{6578:(e,t,n)=>{"use strict";async function a(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.text(),t=e||"HTTP ".concat(n.status);try{let n=JSON.parse(e);t=n.error||n.message||t}catch(e){}throw Error(t)}return n.json()}async function o(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return a("/api/kb/stats".concat(t))}async function r(e){var t,n;let o=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&o.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&o.set("category",e.category),(null==e?void 0:e.page)&&o.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&o.set("limit",String(null!=(n=e.limit)?n:50)),a("/api/kb/files?".concat(o))}async function i(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function s(e,t){return a("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function c(e,t,n){return a("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:t,projectRoot:n})})}async function l(e){return new Promise((t,n)=>{let a=new FileReader;a.onload=()=>{let e=a.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},a.onerror=n,a.readAsDataURL(e)})}async function d(e,t,n){return a("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:t,uploadId:n})})}async function u(e){return a("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),a("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),a("/api/kb/operations?".concat(t),{method:"DELETE"})}async function f(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function y(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function g(e){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function m(e){return a("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function v(){return a("/api/kb/features")}async function w(e,t){var n,o,r,i,s;let c=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&c.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&c.set("category",t.category),(null==t?void 0:t.limit)&&c.set("limit",String(null!=(s=t.limit)?s:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&c.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(o=t.weights)?void 0:o.vector)!=null&&c.set("vectorWeight",String(t.weights.vector)),(null==t||null==(r=t.weights)?void 0:r.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(i=t.weights)?void 0:i.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(c))}async function x(){return a("/api/prompt")}async function b(e){return a("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function j(e){return a("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function C(e,t){return a("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function S(e){return a("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function T(e){return a("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){return a("/api/documents/specs")}async function k(e){return a("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return a("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function E(){return a("/api/documents/templates")}async function N(e){return a("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function A(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function R(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function I(){return a("/api/documents/generated")}async function L(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)))}async function M(e,t){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function H(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function J(){return a("/api/assets/generated")}async function U(e){return a("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(e){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function B(e,t){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:t})})}async function F(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function W(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function z(e){let t=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());return t.blob()}async function $(){return a("/api/config/providers")}async function V(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function X(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function q(){return a("/api/config/models")}async function Q(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function K(){return a("/api/config/embedding")}async function Z(e){return a("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function G(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return a("/api/system/stats")}async function et(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function en(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function ea(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function eo(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function er(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function ei(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function es(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>W,Bh:()=>es,Dl:()=>E,E:()=>eo,EK:()=>k,ER:()=>P,FC:()=>ee,FV:()=>C,H1:()=>m,H7:()=>h,HC:()=>s,HT:()=>r,II:()=>K,JU:()=>U,NR:()=>S,OX:()=>R,PH:()=>ea,QG:()=>H,QT:()=>u,Qx:()=>p,R1:()=>F,SJ:()=>y,UE:()=>z,VW:()=>v,W2:()=>w,X8:()=>g,Z3:()=>$,_m:()=>V,a6:()=>M,aP:()=>Q,bV:()=>O,bZ:()=>Y,c1:()=>d,cQ:()=>I,dd:()=>Z,dg:()=>j,dw:()=>T,dx:()=>x,f$:()=>J,h0:()=>A,h1:()=>X,hc:()=>o,hn:()=>et,l2:()=>N,lv:()=>b,mx:()=>_,oS:()=>B,p:()=>en,tn:()=>c,u6:()=>G,uc:()=>D,v7:()=>L,xC:()=>i,xq:()=>f,xw:()=>er,zo:()=>ei,zr:()=>q})},10218:(e,t,n)=>{"use strict";n.d(t,{A:()=>g,H:()=>f});var a=n(97109),o=n(4932),r=n(42644);let i=e=>"object"==typeof e&&null!=e&&1===e.nodeType,s=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,c=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let n=getComputedStyle(e,null);return s(n.overflowY,t)||s(n.overflowX,t)||(e=>{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},l=(e,t,n,a,o,r,i,s)=>r<e&&i>t||r>e&&i<t?0:r<=e&&s<=n||i>=t&&s>=n?r-e-a:i>t&&s<n||r<e&&s>n?i-t+o:0,d=e=>{let t=e.parentElement;return null==t?e.getRootNode().host||null:t},u=(e,t)=>{var n,a,o,r;if("undefined"==typeof document)return[];let{scrollMode:s,block:u,inline:p,boundary:h,skipOverflowHiddenElements:f}=t,y="function"==typeof h?h:e=>e!==h;if(!i(e))throw TypeError("Invalid target");let g=document.scrollingElement||document.documentElement,m=[],v=e;for(;i(v)&&y(v);){if((v=d(v))===g){m.push(v);break}null!=v&&v===document.body&&c(v)&&!c(document.documentElement)||null!=v&&c(v,f)&&m.push(v)}let w=null!=(a=null==(n=window.visualViewport)?void 0:n.width)?a:innerWidth,x=null!=(r=null==(o=window.visualViewport)?void 0:o.height)?r:innerHeight,{scrollX:b,scrollY:j}=window,{height:C,width:S,top:T,right:_,bottom:k,left:P}=e.getBoundingClientRect(),{top:E,right:N,bottom:A,left:O}=(e=>{let t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e),R="start"===u||"nearest"===u?T-E:"end"===u?k+A:T+C/2-E+A,I="center"===p?P+S/2-O+N:"end"===p?_+N:P-O,L=[];for(let e=0;e<m.length;e++){let t=m[e],{height:n,width:a,top:o,right:r,bottom:i,left:d}=t.getBoundingClientRect();if("if-needed"===s&&T>=0&&P>=0&&k<=x&&_<=w&&(t===g&&!c(t)||T>=o&&k<=i&&P>=d&&_<=r))break;let h=getComputedStyle(t),f=parseInt(h.borderLeftWidth,10),y=parseInt(h.borderTopWidth,10),v=parseInt(h.borderRightWidth,10),E=parseInt(h.borderBottomWidth,10),N=0,A=0,O="offsetWidth"in t?t.offsetWidth-t.clientWidth-f-v:0,M="offsetHeight"in t?t.offsetHeight-t.clientHeight-y-E:0,H="offsetWidth"in t?0===t.offsetWidth?0:a/t.offsetWidth:0,J="offsetHeight"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(g===t)N="start"===u?R:"end"===u?R-x:"nearest"===u?l(j,j+x,x,y,E,j+R,j+R+C,C):R-x/2,A="start"===p?I:"center"===p?I-w/2:"end"===p?I-w:l(b,b+w,w,f,v,b+I,b+I+S,S),N=Math.max(0,N+j),A=Math.max(0,A+b);else{N="start"===u?R-o-y:"end"===u?R-i+E+M:"nearest"===u?l(o,i,n,y,E+M,R,R+C,C):R-(o+n/2)+M/2,A="start"===p?I-d-f:"center"===p?I-(d+a/2)+O/2:"end"===p?I-r+v+O:l(d,r,a,f,v+O,I,I+S,S);let{scrollLeft:e,scrollTop:s}=t;N=0===J?0:Math.max(0,Math.min(s+N/J,t.scrollHeight-n/J+M)),A=0===H?0:Math.max(0,Math.min(e+A/H,t.scrollWidth-a/H+O)),R+=s-N,I+=e-A}L.push({el:t,top:N,left:A})}return L};var p=n(26047),h=n(44624);function f(e){return(0,h.$r)(e).join("_")}function y(e,t){let n=t.getFieldInstance(e),a=(0,r.rb)(n);if(a)return a;let o=(0,h.kV)((0,h.$r)(e),t.__INTERNAL__.name);if(o)return document.getElementById(o)}function g(e){let[t]=(0,o.mN)(),n=a.useRef({}),r=a.useMemo(()=>e??{...t,__INTERNAL__:{itemRef:e=>t=>{let a=f(e);t?n.current[a]=t:delete n.current[a]}},scrollToField:(e,t={})=>{let{focus:n,...a}=t,o=y(e,r);o&&(!function(e,t){if(!e.isConnected||!(e=>{let t=e;for(;t&&t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}return!1})(e))return;let n=(e=>{let t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);if("object"==typeof t&&"function"==typeof t.behavior)return t.behavior(u(e,t));let a="boolean"==typeof t||null==t?void 0:t.behavior;for(let{el:o,top:r,left:i}of u(e,!1===t?{block:"end",inline:"nearest"}:t===Object(t)&&0!==Object.keys(t).length?t:{block:"start",inline:"nearest"})){let e=r-n.top+n.bottom,t=i-n.left+n.right;o.scroll({top:e,left:t,behavior:a})}}(o,{scrollMode:"if-needed",block:"nearest",...a}),n&&r.focusField(e))},focusField:e=>{let t=r.getFieldInstance(e);(0,p.Tn)(t?.focus)?t.focus():y(e,r)?.focus?.()},getFieldInstance:e=>{let t=f(e);return n.current[t]}},[e,t]);return[r]}},14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusPanel:"style_statusPanel__9arTu",statusPanelHeader:"style_statusPanelHeader__nKv1I",statusEmpty:"style_statusEmpty__8LWzH",statusList:"style_statusList__FpNgC",statusItem:"style_statusItem__uzO80",statusHeader:"style_statusHeader__o9q_b",statusDesc:"style_statusDesc__XiWFa",statusPath:"style_statusPath__Udxvv",statusMeta:"style_statusMeta__XukHt",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},15437:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});let a=e=>{let{componentCls:t,antCls:n,motionDurationMid:a,motionEaseInOut:o}=e;return{[t]:{[`${n}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`${["height","opacity"].map(e=>`${e} ${a} ${o}`).join(", ")} !important`}},[`${n}-motion-collapse`]:{overflow:"hidden",transition:`${["height","opacity"].map(e=>`${e} ${a} ${o}`).join(", ")} !important`}}}}},23793:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"}},25258:(e,t,n)=>{"use strict";n.d(t,{A:()=>x});var a=n(51541),o=n(61848),r=n(1249),i=n(97109),s=n(72658),c=n(3638),l=n(92162),d=n(82725),u=n(74567),p=n(632),h=n(49517),f=n(79412),y=n(19527);let g=(0,d.U)(e=>{let{prefixCls:t,className:n,closeIcon:a,closable:o,type:r,title:d,children:g,footer:m,classNames:v,styles:w,...x}=e,{getPrefixCls:b}=i.useContext(u.QO),{className:j,style:C,classNames:S,styles:T}=(0,u.TP)("modal"),_=b(),k=t||b("modal"),P=(0,p.A)(_),[E,N]=(0,y.Ay)(k,P),[A,O]=(0,l.AV)([S,v],[T,w],{props:e}),R=`${k}-confirm`,I={};return I=r?{closable:o??!1,title:"",footer:"",children:i.createElement(h.k,{...e,prefixCls:k,confirmPrefixCls:R,rootPrefixCls:_,content:g})}:{closable:o??!0,title:d,footer:null!==m&&i.createElement(f.w,{...e}),children:g},i.createElement(s.Z,{prefixCls:k,className:(0,c.$)(E,`${k}-pure-panel`,r&&R,r&&`${R}-${r}`,n,j,N,P,A.root),style:{...C,...O.root},...x,closeIcon:(0,f.O)(k,a),closable:o,classNames:A,styles:O,...I})});var m=n(99739);function v(e){return(0,a.Ay)((0,a.fp)(e))}let w=r.A;w.useModal=m.A,w.info=function(e){return(0,a.Ay)((0,a.$D)(e))},w.success=function(e){return(0,a.Ay)((0,a.Ej)(e))},w.error=function(e){return(0,a.Ay)((0,a.jT)(e))},w.warning=v,w.warn=v,w.confirm=function(e){return(0,a.Ay)((0,a.lr)(e))},w.destroyAll=function(){for(;o.A.length;){let e=o.A.pop();e&&e()}},w.config=a.FB,w._InternalPanelDoNotUseOrYouWillBeFired=g;let x=w},36451:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>O});var a=n(65321),o=n(97109),r=n(13014),i=n(43220),s=n.n(i),c=n(86109),l=n(17807),d=n(25258),u=n(33442),p=n(11702),h=n(85114),f=n(7576),y=n(57271),g=n(14932),m=n(99605),v=n(68787),w=n(59400),x=n(26631),b=n(58209),j=n(30486),C=n(92803),S=n(88483);function T(){return(T=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}let _=o.forwardRef((e,t)=>o.createElement(S.A,T({},e,{ref:t,icon:C.A})));var k=n(6578),P=n(45551),E=n(14569),N=n.n(E);let A=["document","spreadsheet","image","cad","code","data","web","diagram","archive","other"];function O(){let e=(0,r.Vr)("knowledge"),{locale:t}=(0,r.x_)(),{message:n}=l.A.useApp(),i=(0,c.useRouter)(),C="string"==typeof i.query.category?i.query.category:"",[S,T]=(0,o.useState)([]),[E,O]=(0,o.useState)(!1),[R,I]=(0,o.useState)(""),[L,M]=(0,o.useState)(""),[H,J]=(0,o.useState)(C),[U,D]=(0,o.useState)(!1),[B,F]=(0,o.useState)([]),[W,z]=(0,o.useState)([]),[$,V]=(0,o.useState)(1),X=(0,o.useRef)(H);(0,o.useEffect)(()=>{X.current=H},[H]),(0,o.useEffect)(()=>{J("string"==typeof i.query.category?i.query.category:"")},[i.query.category]);let q=(0,o.useCallback)(async e=>{let t=null!=e?e:X.current;O(!0),I("");try{let e=await (0,k.HT)({category:t||void 0,limit:200});T(e.files||[]),e.initializing&&window.setTimeout(()=>{q(t)},1500)}catch(e){T([]),I(e instanceof Error?e.message:"文件列表加载失败")}finally{O(!1)}},[]);(0,o.useEffect)(()=>{q(H)},[H,q]);let Q=e=>({type:e.type,title:e.title,description:e.message,status:e.status,percent:e.percent,filePath:e.filePath,chunkCount:e.chunkCount,textLength:e.textLength,extractionMode:e.extractionMode}),K=(0,o.useCallback)(async()=>{try{let e=await (0,k.Qx)();F(e.operations.map(Q))}catch(e){}},[]);(0,o.useEffect)(()=>{K()},[K]);let Z=async()=>{try{await (0,k.H7)(),F([]),n.success("任务状态已清空")}catch(e){n.error("清空任务状态失败")}},G=async e=>{if(0===e.length)return;let t=1===e.length?e[0].name:"".concat(e.length," 个文件");D(!0),F(e=>[{type:"upload",title:"上传 ".concat(t),description:"等待上传、解析、切片和入库",status:"processing",percent:10},...e].slice(0,50));let a="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),o=setInterval(()=>{(0,k.QT)(a).then(e=>{F(n=>[{type:"upload",title:"上传 ".concat(t),description:"".concat(e.message).concat(e.chunkCount?",".concat(e.chunkCount," 个切片"):""),status:"error"===e.stage?"warning":"processing",percent:e.percent},...n.filter(e=>e.title!=="上传 ".concat(t))].slice(0,50))}).catch(()=>void 0)},500);try{var r,i;let s=await (0,k.c1)(e,void 0,a);clearInterval(o),(null==(r=s.vectorStatus)?void 0:r.status)==="error"?n.info("文件已上传,正在后台入库"):n.success("上传成功"),M(""),J(""),z([]),V(1),X.current="";let c=null==(i=s.files)?void 0:i.find(e=>e.relativePath===s.relativePath),l=(e=>{if(!e)return{};let t={};try{t=e.metadataJson?JSON.parse(e.metadataJson):{}}catch(e){}let n="object"==typeof t.extraction&&t.extraction?t.extraction:t;return{textLength:"number"==typeof n.textLength?n.textLength:void 0,extractionMode:"string"==typeof n.extractionMode?n.extractionMode:void 0}})(c);await K(),F(e=>[{type:"upload",title:"上传完成 ".concat(t),description:"解析、分块和入库流程已完成",status:"success",filePath:null==c?void 0:c.relativePath,chunkCount:null==c?void 0:c.chunkCount,textLength:l.textLength,extractionMode:l.extractionMode},...e.filter(e=>e.title!=="上传 ".concat(t))].slice(0,50)),Array.isArray(s.files)?T(s.files):(await (0,k.H1)(),await q(""),await K())}catch(e){n.error("上传失败"),F(e=>[{type:"error",title:"上传失败 ".concat(t),description:"请重试或检查文件格式",status:"error"},...e].slice(0,50))}finally{clearInterval(o),D(!1)}},Y=e=>{let t="selected"===e?W.map(String):"filtered"===e?ee.map(e=>e.relativePath):[];if("all"!==e&&0===t.length)return;let a="all"===e?"删除全部文件?":"filtered"===e?"删除当前筛选结果 ".concat(t.length," 个文件?"):"删除已选 ".concat(t.length," 个文件?");d.A.confirm({title:a,content:"将同时删除文件、切片、索引和向量记录。此操作不可撤销。",okText:"确认删除",cancelText:"取消",okButtonProps:{danger:!0},onOk:async()=>{F(e=>[{type:"delete",title:a,description:"正在批量删除文件和索引",status:"processing",percent:10},...e].slice(0,50));try{var o;let a=null!=(o=("all"===e?await (0,k.X8)():await (0,k.SJ)(t)).deleted)?o:t.length;n.success("已删除 ".concat(a," 个文件")),z([]),F(e=>[{type:"delete",title:"批量删除完成",description:"已删除 ".concat(a," 个文件、切片和索引"),status:"success"},...e].slice(0,50)),await q(),await K()}catch(e){n.error("批量删除失败"),F(e=>[{type:"error",title:"批量删除失败",description:"请重试",status:"error"},...e].slice(0,50))}}})},ee=L?S.filter(e=>e.relativePath.toLowerCase().includes(L.toLowerCase())):S,et=[{title:e("fileName"),dataIndex:"relativePath",key:"name",render:(e,t)=>(0,a.jsxs)(u.A,{children:[(0,a.jsx)(x.A,{}),t.builtIn&&(0,a.jsx)(p.A,{color:"gold",children:"内置"}),(0,a.jsx)(s(),{className:"truncate max-w-[400px] inline-block",href:"/knowledge/file-detail?relativePath=".concat(encodeURIComponent(e)),children:e})]})},{title:e("fileCategory"),dataIndex:"category",key:"cat",width:120,render:e=>(0,a.jsx)(p.A,{children:(0,P.Jm)(e,t)})},{title:e("fileSize"),dataIndex:"fileSize",key:"size",width:100,render:e=>(0,P.z3)(e)},{title:"切片",dataIndex:"chunkCount",key:"chunks",width:90,render:e=>(0,a.jsx)(p.A,{color:e>1?"green":"orange",children:e})},{title:"解析状态",dataIndex:"status",key:"status",width:110,render:(e,t)=>(0,a.jsx)(p.A,{color:"active"===e?"green":"red",children:t.errorMessage||e})},{title:e("fileDate"),dataIndex:"mtime",key:"date",width:140,render:e=>e?new Date(e).toLocaleDateString(t):"—"},{title:"",key:"act",width:60,render:(t,o)=>(0,a.jsx)(h.Ay,{type:"text",danger:!0,size:"small",icon:(0,a.jsx)(b.A,{}),onClick:()=>{d.A.confirm({title:e("delete"),content:e("deleteConfirm"),okText:"确认",cancelText:"取消",okButtonProps:{danger:!0},onOk:async()=>{F(e=>[{type:"delete",title:"删除 ".concat(o.relativePath),description:"正在删除文件记录",status:"processing"},...e].slice(0,50));try{await (0,k.xq)(o.relativePath),n.success("已删除"),F(e=>[{type:"delete",title:"删除完成 ".concat(o.relativePath),description:"文件和索引记录已移除",status:"success"},...e].slice(0,50)),z(e=>e.filter(e=>e!==o.relativePath)),await q(),await K()}catch(e){n.error("删除失败"),F(e=>[{type:"error",title:"删除失败 ".concat(o.relativePath),description:"请重试",status:"error"},...e].slice(0,50))}}})}})}];return(0,a.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,a.jsx)("h2",{className:"pageTitle",children:e("fileList")}),(0,a.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,a.jsx)(f.A,{placeholder:e("searchPlaceholder"),prefix:(0,a.jsx)(j.A,{}),value:L,onChange:e=>{M(e.target.value),V(1)},allowClear:!0,className:N().filterInput}),(0,a.jsx)(y.A,{value:H||void 0,onChange:e=>{J(e||""),V(1)},placeholder:e("filterCategory"),allowClear:!0,className:N().filterSelect,options:[{label:e("allCategories"),value:""},...A.map(e=>({label:(0,P.Jm)(e,t),value:e}))]}),(0,a.jsx)(h.Ay,{type:"primary",icon:(0,a.jsx)(_,{}),loading:U,onClick:()=>{var e;return null==(e=document.getElementById("kb-file-upload-input"))?void 0:e.click()},children:U?e("uploading"):e("upload")}),(0,a.jsx)(h.Ay,{icon:(0,a.jsx)(_,{}),loading:U,onClick:()=>{var e;return null==(e=document.getElementById("kb-folder-upload-input"))?void 0:e.click()},children:"上传文件夹"}),(0,a.jsxs)(h.Ay,{danger:!0,disabled:0===W.length,icon:(0,a.jsx)(b.A,{}),onClick:()=>Y("selected"),children:["删除已选 ",W.length||""]}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===ee.length||!L&&!H,onClick:()=>Y("filtered"),children:"删除筛选结果"}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===S.length,onClick:()=>Y("all"),children:"删除全部"}),(0,a.jsx)("input",{id:"kb-file-upload-input",type:"file",multiple:!0,hidden:!0,onChange:e=>{var t;let n=Array.from(null!=(t=e.target.files)?t:[]);e.target.value="",G(n)}}),(0,a.jsx)("input",{id:"kb-folder-upload-input",type:"file",multiple:!0,hidden:!0,webkitdirectory:"",onChange:e=>{var t;let n=Array.from(null!=(t=e.target.files)?t:[]);e.target.value="",G(n)}})]}),(0,a.jsxs)("div",{className:N().statusPanel,children:[(0,a.jsxs)("div",{className:N().statusPanelHeader,children:[(0,a.jsxs)(u.A,{children:[(0,a.jsx)(x.A,{}),"文件任务状态"]}),(0,a.jsx)(h.Ay,{size:"small",type:"text",disabled:0===B.length,onClick:()=>void Z(),children:"清空"})]}),0===B.length?(0,a.jsx)("div",{className:N().statusEmpty,children:"暂无文件任务。"}):(0,a.jsx)("div",{className:N().statusList,children:B.map((e,n)=>(0,a.jsxs)("div",{className:N().statusItem,children:[(0,a.jsxs)("div",{className:N().statusHeader,children:[(0,a.jsxs)(u.A,{size:8,wrap:!0,children:[(0,a.jsx)(p.A,{color:"success"===e.status?"green":"error"===e.status?"red":"warning"===e.status?"orange":"blue",children:"upload"===e.type?"上传":"delete"===e.type?"删除":"reindex"===e.type?"重建":"失败"}),(0,a.jsx)(g.A,{title:e.title,children:(0,a.jsx)("strong",{children:e.title})})]}),(0,a.jsx)(p.A,{color:"success"===e.status?"success":"processing"===e.status?"processing":"warning"===e.status?"warning":"error",children:"success"===e.status?"完成":"processing"===e.status?"处理中":"warning"===e.status?"需关注":"失败"})]}),(0,a.jsx)(g.A,{title:e.description,children:(0,a.jsx)("div",{className:N().statusDesc,children:e.description})}),e.filePath&&(0,a.jsx)(g.A,{title:e.filePath,children:(0,a.jsx)("div",{className:N().statusPath,children:e.filePath})}),(0,a.jsxs)("div",{className:N().statusMeta,children:["number"==typeof e.chunkCount&&(0,a.jsxs)("span",{children:["切片 ",(0,a.jsx)("b",{children:e.chunkCount})]}),"number"==typeof e.textLength&&(0,a.jsxs)("span",{children:["正文 ",(0,a.jsx)("b",{children:e.textLength.toLocaleString(t)})," 字符"]}),e.extractionMode&&(0,a.jsxs)("span",{children:["解析 ",(0,a.jsx)("b",{children:e.extractionMode})]})]}),"number"==typeof e.percent&&"processing"===e.status&&(0,a.jsx)(m.A,{percent:e.percent,size:"small"})]},"".concat(e.title,"-").concat(n)))})]}),(0,a.jsxs)(v.A,{children:[R&&(0,a.jsxs)("div",{className:N().statusEmpty,children:["文件列表加载失败:",R]}),(0,a.jsx)(w.A,{rowKey:"relativePath",columns:et,dataSource:ee,loading:E,size:"middle",locale:{emptyText:E?"正在加载文件列表...":L?e("emptySearch"):e("noFiles")},pagination:{current:$,pageSize:50,showSizeChanger:!1,onChange:V},rowSelection:{selectedRowKeys:W,onChange:z}})]})]})}},44624:(e,t,n)=>{"use strict";n.d(t,{$r:()=>o,BS:()=>i,kV:()=>r});let a=["parentNode"];function o(e){return void 0===e||!1===e?[]:Array.isArray(e)?e:[e]}function r(e,t){if(!e.length)return;let n=e.join("_");return t?`${t}_${n}`:a.includes(n)?`form_item_${n}`:n}function i(e,t,n,a,o,r){let i=a;return void 0!==r?i=r:n.validating?i="validating":e.length?i="error":t.length?i="warning":(n.touched||o&&n.validated)&&(i="success"),i}},45551:(e,t,n)=>{"use strict";function a(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),n=e/Math.pow(1024,t);return"".concat(n.toFixed(+(0!==t))," ").concat(["B","KB","MB","GB","TB"][t])}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";if(!e||e<=0)return"en-US"===t?"Never":"从未";let n=Math.floor(Math.floor((Date.now()-e)/1e3)/60),a=Math.floor(n/60),o=Math.floor(a/24);return o>30?new Date(e).toLocaleDateString(t):"en-US"===t?o>0?"".concat(o,"d ago"):a>0?"".concat(a,"h ago"):n>0?"".concat(n,"m ago"):"Just now":o>0?"".concat(o," 天前"):a>0?"".concat(a," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>s,fw:()=>o,z3:()=>a});let r={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},i={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function s(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?i:r)[e])?t:e}},58209:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var a=n(97109),o=n(23793),r=n(88483);function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}let s=a.forwardRef((e,t)=>a.createElement(r.A,i({},e,{ref:t,icon:o.A})))},90426:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/files",function(){return n(36451)}])},92803:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"}}},e=>{e.O(0,[260,167,382,628,271,576,700,174,985,400,15,636,593,792],()=>e(e.s=90426)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[414],{6578:(e,n,t)=>{"use strict";async function o(e,n){let t=await fetch(e,n);if(!t.ok){let e=await t.text(),n=e||"HTTP ".concat(t.status);try{let t=JSON.parse(e);n=t.error||t.message||n}catch(e){}throw Error(n)}return t.json()}async function a(e){let n=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return o("/api/kb/stats".concat(n))}async function i(e){var n,t;let a=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&a.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&a.set("category",e.category),(null==e?void 0:e.page)&&a.set("page",String(null!=(n=e.page)?n:1)),(null==e?void 0:e.limit)&&a.set("limit",String(null!=(t=e.limit)?t:50)),o("/api/kb/files?".concat(a))}async function c(e,n){let t=new URLSearchParams({relativePath:e});return n&&t.set("projectRoot",n),o("/api/kb/files/detail?".concat(t))}async function r(e,n){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function s(e,n,t){return o("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:n,projectRoot:t})})}async function l(e){return new Promise((n,t)=>{let o=new FileReader;o.onload=()=>{let e=o.result,t=e.indexOf(",");n(t>=0?e.slice(t+1):e)},o.onerror=t,o.readAsDataURL(e)})}async function d(e,n,t){return o("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:n,uploadId:t})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let n=new URLSearchParams({limit:"50"});return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n))}async function y(e){let n=new URLSearchParams;return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n),{method:"DELETE"})}async function f(e,n){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function h(e,n){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:n})})}async function m(e){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return o("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function b(){return o("/api/kb/features")}async function S(e,n){var t,a,i,c,r;let s=new URLSearchParams({q:e});return(null==n?void 0:n.projectRoot)&&s.set("projectRoot",n.projectRoot),(null==n?void 0:n.category)&&s.set("category",n.category),(null==n?void 0:n.limit)&&s.set("limit",String(null!=(r=n.limit)?r:20)),(null==n||null==(t=n.weights)?void 0:t.keyword)!=null&&s.set("keywordWeight",String(n.weights.keyword)),(null==n||null==(a=n.weights)?void 0:a.vector)!=null&&s.set("vectorWeight",String(n.weights.vector)),(null==n||null==(i=n.weights)?void 0:i.rewrite)!=null&&s.set("rewriteWeight",String(n.weights.rewrite)),(null==n||null==(c=n.weights)?void 0:c.hybridBonus)!=null&&s.set("hybridBonus",String(n.weights.hybridBonus)),o("/api/kb/search?".concat(s))}async function w(){return o("/api/prompt")}async function k(e){return o("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function T(e){return o("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function j(e,n){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(n)),{method:"DELETE"})}async function x(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function C(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function v(){return o("/api/documents/specs")}async function E(e){return o("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(e){return o("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function N(){return o("/api/documents/templates")}async function P(e){return o("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function A(e){return o("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function R(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function U(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function J(){return o("/api/documents/generated")}async function D(e){return o("/api/documents/generated/".concat(encodeURIComponent(e)))}async function I(e,n){return o("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function L(e){return o("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function z(){return o("/api/assets/generated")}async function _(e){return o("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function B(e){return o("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function H(e,n){return o("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:n})})}async function M(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function V(e,n){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:n})})}async function W(e){let n=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw Error(await n.text());return n.blob()}async function F(){return o("/api/config/providers")}async function Q(e,n){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...n})})}async function X(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function q(){return o("/api/config/models")}async function G(e){return o("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function K(){return o("/api/config/embedding")}async function Z(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function $(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return o("/api/system/stats")}async function en(e,n){let t=n?"?type=".concat(e,"&search=").concat(encodeURIComponent(n)):"?type=".concat(e);return o("/api/context".concat(t))}async function et(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function eo(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function ea(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function ei(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function ec(e,n){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...n})})}async function er(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}t.d(n,{Af:()=>V,Bh:()=>er,Dl:()=>N,E:()=>ea,EK:()=>E,ER:()=>O,FC:()=>ee,FV:()=>j,H1:()=>g,H7:()=>y,HC:()=>r,HT:()=>i,II:()=>K,JU:()=>_,NR:()=>x,OX:()=>U,PH:()=>eo,QG:()=>L,QT:()=>u,Qx:()=>p,R1:()=>M,SJ:()=>h,UE:()=>W,VW:()=>b,W2:()=>S,X8:()=>m,Z3:()=>F,_m:()=>Q,a6:()=>I,aP:()=>G,bV:()=>R,bZ:()=>Y,c1:()=>d,cQ:()=>J,dd:()=>Z,dg:()=>T,dw:()=>C,dx:()=>w,f$:()=>z,h0:()=>A,h1:()=>X,hc:()=>a,hn:()=>en,l2:()=>P,lv:()=>k,mx:()=>v,oS:()=>H,p:()=>et,tn:()=>s,u6:()=>$,uc:()=>B,v7:()=>D,xC:()=>c,xq:()=>f,xw:()=>ei,zo:()=>ec,zr:()=>q})},45551:(e,n,t)=>{"use strict";function o(e){if(0===e)return"0 B";let n=Math.floor(Math.log(e)/Math.log(1024)),t=e/Math.pow(1024,n);return"".concat(t.toFixed(+(0!==n))," ").concat(["B","KB","MB","GB","TB"][n])}function a(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";if(!e||e<=0)return"en-US"===n?"Never":"从未";let t=Math.floor(Math.floor((Date.now()-e)/1e3)/60),o=Math.floor(t/60),a=Math.floor(o/24);return a>30?new Date(e).toLocaleDateString(n):"en-US"===n?a>0?"".concat(a,"d ago"):o>0?"".concat(o,"h ago"):t>0?"".concat(t,"m ago"):"Just now":a>0?"".concat(a," 天前"):o>0?"".concat(o," 小时前"):t>0?"".concat(t," 分钟前"):"刚刚"}t.d(n,{Jm:()=>r,fw:()=>a,z3:()=>o});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},c={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function r(e){var n;let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(n=("en-US"===t?c:i)[e])?n:e}},50423:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>E});var o=t(65321),a=t(97109),i=t(34986),c=t(13014),r=t(17807),s=t(33442),l=t(85114),d=t(2256),u=t(38770),p=t(68787),y=t(54849),f=t(49292),h=t(59400),m=t(11702),g=t(29606),b=t(30486),S=t(99811),w=t(56768),k=t(26619),T=t(93314),j=t(58740),x=t(6578),C=t(45551);let v=["document","spreadsheet","image","cad","code","data","web","diagram","archive","other"];function E(){var e,n,t;let E=(0,c.Vr)(),{locale:O}=(0,c.x_)(),N=(0,i.useRouter)(),{stats:P,loading:A,reload:R}=function(){let[e,n]=(0,a.useState)(null),[t,o]=(0,a.useState)(!1),i=(0,a.useCallback)(async()=>{o(!0);try{n(await (0,x.hc)())}catch(e){}finally{o(!1)}},[]);return(0,a.useEffect)(()=>{i()},[i]),{stats:e,loading:t,reload:i}}(),U=function(){let[e,n]=(0,a.useState)(null);return(0,a.useEffect)(()=>{(0,x.VW)().then(n).catch(()=>{})},[]),e}(),{reindexing:J,reindex:D}=function(){let[e,n]=(0,a.useState)(!1);return{reindexing:e,reindex:(0,a.useCallback)(async()=>{n(!0);try{return await (0,x.H1)(),!0}catch(e){return!1}finally{n(!1)}},[])}}(),[I,L]=(0,a.useState)("document"),[z,_]=(0,a.useState)({count:0,totalSize:0}),{message:B}=r.A.useApp(),H=(0,a.useCallback)(async e=>{try{let n=await (0,x.HT)({category:e,limit:1e4}),t=0;if(Array.isArray(n.files))for(let e of n.files)t+=e.fileSize||0;_({count:n.total||0,totalSize:t})}catch(e){_({count:0,totalSize:0})}},[]);(0,a.useEffect)(()=>{H(I)},[I,H]);let M=async()=>{await D()?await Promise.all([R(),H(I)]):B.error(E("common.error"))};return(0,o.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle",children:E("knowledge.manageTitle")}),(0,o.jsx)("p",{className:"pageDesc",children:E("knowledge.manageDesc")})]}),(0,o.jsxs)(s.A,{children:[(0,o.jsx)(l.Ay,{icon:(0,o.jsx)(g.A,{}),onClick:()=>N.push("/knowledge/files"),children:E("knowledge.files")}),(0,o.jsx)(l.Ay,{icon:(0,o.jsx)(b.A,{}),onClick:()=>N.push("/knowledge/search"),children:E("knowledge.search")}),(0,o.jsx)(l.Ay,{icon:(0,o.jsx)(S.A,{}),loading:J,onClick:()=>{M()},children:E("knowledge.reindex")})]})]}),(0,o.jsx)(d.A,{gutter:[16,16],children:[{icon:(0,o.jsx)(w.A,{}),label:E("knowledge.totalFiles"),value:null!=(e=null==P?void 0:P.fileCount)?e:0},{icon:(0,o.jsx)(k.A,{}),label:E("knowledge.totalChunks"),value:null!=(n=null==P?void 0:P.chunkCount)?n:0},{icon:(0,o.jsx)(T.A,{}),label:E("knowledge.totalSize"),value:(0,C.z3)(null!=(t=null==P?void 0:P.totalSizeBytes)?t:0)},{icon:(0,o.jsx)(j.A,{}),label:E("knowledge.lastIndexed"),value:(null==P?void 0:P.lastIndexedAt)?(0,C.fw)(P.lastIndexedAt,O):E("common.never")}].map((e,n)=>(0,o.jsx)(u.A,{xs:12,sm:6,children:(0,o.jsx)(p.A,{size:"small",loading:A&&!P,children:(0,o.jsx)(y.A,{title:e.label,value:e.value,prefix:e.icon})})},n))}),(0,o.jsxs)(p.A,{title:E("knowledge.categories"),size:"small",children:[(0,o.jsx)(f.A,{value:I,onChange:e=>L(String(e)),options:v.map(e=>({label:(0,C.Jm)(e,O),value:e})),className:"mb-4"}),(0,o.jsxs)(d.A,{gutter:[16,16],children:[(0,o.jsx)(u.A,{xs:12,sm:8,children:(0,o.jsx)(y.A,{title:E("knowledge.fileCount"),value:z.count,prefix:(0,o.jsx)(w.A,{})})}),(0,o.jsx)(u.A,{xs:12,sm:8,children:(0,o.jsx)(y.A,{title:E("knowledge.totalSize"),value:(0,C.z3)(z.totalSize),prefix:(0,o.jsx)(T.A,{})})})]})]}),U&&(0,o.jsx)(p.A,{title:E("knowledge.features"),size:"small",children:(0,o.jsx)(h.A,{dataSource:[{key:"vectorStore",label:"Vector Store",desc:E("knowledge.featureVectorStoreDesc"),value:U.vectorStore},{key:"embedding",label:"Embedding",desc:E("knowledge.featureEmbeddingDesc"),value:U.embeddingProvider},{key:"dedup",label:E("knowledge.featureDedup"),desc:E("knowledge.featureDedupDesc"),value:U.dedupEngine},{key:"chunker",label:E("knowledge.featureChunker"),desc:E("knowledge.featureChunkerDesc"),value:U.chunker}],columns:[{title:E("knowledge.featureName"),dataIndex:"label",key:"label",width:120},{title:E("knowledge.featureDesc"),dataIndex:"desc",key:"desc"},{title:E("knowledge.featureValue"),dataIndex:"value",key:"value",render:e=>(0,o.jsx)(m.A,{color:"blue",children:e})}],pagination:!1,size:"small"})})]})}},54178:(e,n,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/manage",function(){return t(50423)}])}},e=>{e.O(0,[260,167,382,628,271,700,174,985,400,577,935,636,593,792],()=>e(e.s=54178)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[207],{838:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]},name:"down",theme:"outlined"}},4184:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>S});var s=n(65321),r=n(43220),a=n.n(r),o=n(97109),i=n(35292),c=n(68787),l=n(33442),d=n(7576),u=n(85114),p=n(94992),h=n(76506),y=n(11702),m=n(85493),f=n(42700),g=n(84253),j=n(30486),b=n(6578),x=n(14569),w=n.n(x);let{Paragraph:v}=i.A;function _(e){return"number"==typeof e?e.toFixed(2):"-"}function S(){var e,t,n;let[r,i]=(0,o.useState)(""),[x,S]=(0,o.useState)(!1),[T,C]=(0,o.useState)([]),[O,P]=(0,o.useState)(),[E,k]=(0,o.useState)(),[N,R]=(0,o.useState)(""),[A,I]=(0,o.useState)({keyword:1,vector:.9,rewrite:.72,hybridBonus:.35}),U=async()=>{let e=r.trim();if(e){S(!0),R("");try{let t=await (0,b.W2)(e,{limit:10,weights:A});C(t.results),P(t.queryTimeMs),k(t.debug)}catch(e){C([]),R(e instanceof Error?e.message:"搜索失败")}finally{S(!1)}}};return(0,s.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"pageTitle",children:"知识库搜索"}),(0,s.jsx)("p",{className:"pageDesc",children:"查看 hybrid 检索、parent 回填、分块来源和评分明细。"})]}),(0,s.jsx)(c.A,{size:"small",children:(0,s.jsxs)(l.A.Compact,{className:"w-full",children:[(0,s.jsx)(d.A,{value:r,onChange:e=>i(e.target.value),onPressEnter:()=>{U()},placeholder:"输入要搜索的知识库内容"}),(0,s.jsx)(u.Ay,{type:"primary",icon:(0,s.jsx)(j.A,{}),loading:x,onClick:()=>{U()},children:"搜索"})]})}),(0,s.jsx)(c.A,{size:"small",title:"召回权重调节",children:(0,s.jsxs)(l.A,{wrap:!0,children:[(0,s.jsxs)("span",{children:["Keyword ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.keyword,onChange:e=>I(t=>({...t,keyword:Number(null!=e?e:1)}))})]}),(0,s.jsxs)("span",{children:["Vector ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.vector,onChange:e=>I(t=>({...t,vector:Number(null!=e?e:.9)}))})]}),(0,s.jsxs)("span",{children:["Rewrite ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.rewrite,onChange:e=>I(t=>({...t,rewrite:Number(null!=e?e:.72)}))})]}),(0,s.jsxs)("span",{children:["Hybrid Bonus ",(0,s.jsx)(p.A,{min:0,max:2,step:.05,value:A.hybridBonus,onChange:e=>I(t=>({...t,hybridBonus:Number(null!=e?e:.35)}))})]})]})}),E&&(0,s.jsx)(c.A,{size:"small",title:"检索调试面板",children:(0,s.jsxs)(h.A,{size:"small",column:2,bordered:!0,children:[(0,s.jsx)(h.A.Item,{label:"原始查询",children:E.originalQuery}),(0,s.jsx)(h.A.Item,{label:"Reranker",children:E.reranker}),(0,s.jsx)(h.A.Item,{label:"查询改写",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:null==(e=E.rewrittenQueries)?void 0:e.map(e=>(0,s.jsx)(y.A,{children:e},e))})}),(0,s.jsx)(h.A.Item,{label:"召回数量",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:Object.entries(null!=(t=E.recallCounts)?t:{}).map(e=>{let[t,n]=e;return(0,s.jsxs)(y.A,{children:[t,": ",n]},t)})})}),(0,s.jsx)(h.A.Item,{label:"召回权重",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:Object.entries(null!=(n=E.weights)?n:{}).map(e=>{let[t,n]=e;return(0,s.jsxs)(y.A,{children:[t,": ",n]},t)})})})]})}),(0,s.jsxs)(c.A,{size:"small",title:"搜索结果",extra:"number"==typeof O?"".concat(O," ms"):void 0,children:[N?(0,s.jsx)(m.A,{type:"error",showIcon:!0,message:"搜索失败",description:N,className:"mb-4"}):null,x?(0,s.jsx)(f.A,{}):0===T.length?(0,s.jsx)(g.A,{description:"暂无结果"}):(0,s.jsx)("div",{className:w().searchResultList,children:T.map(e=>{var t,n,o,i,c,d;return(0,s.jsxs)("div",{className:w().searchResultItem,children:[(0,s.jsxs)("div",{className:w().searchResultHeader,children:[(0,s.jsxs)(l.A,{size:8,wrap:!0,children:[(0,s.jsx)(y.A,{color:"hybrid"===e.source?"purple":"vector"===e.source?"blue":"green",children:null!=(d=e.source)?d:"keyword"}),(0,s.jsx)(y.A,{children:e.scope}),e.chunkKind&&(0,s.jsx)(y.A,{color:"geekblue",children:e.chunkKind}),e.rowRange&&(0,s.jsxs)(y.A,{color:"gold",children:["行 ",e.rowRange]}),e.sectionTitle&&(0,s.jsx)(y.A,{color:"cyan",children:e.sectionTitle})]}),(0,s.jsx)("strong",{children:_(e.score)})]}),(0,s.jsxs)("div",{className:w().statusPath,children:[(0,s.jsx)(a(),{href:"/knowledge/file-detail?relativePath=".concat(encodeURIComponent(e.filePath)),children:e.filePath}),"number"==typeof e.chunkIndex?" #".concat(e.chunkIndex):""]}),(0,s.jsx)(v,{ellipsis:{rows:6,expandable:!0,symbol:"展开"},className:w().searchContent,children:function(e,t){let n=[t.trim(),...t.split(/[\s,,。;;::、]+/u)].filter(Boolean).sort((e,t)=>t.length-e.length);if(0===n.length)return e;let r=RegExp("(".concat(n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),")"),"giu");return e.split(r).map((e,t)=>n.some(t=>t.toLowerCase()===e.toLowerCase())?(0,s.jsx)("mark",{children:e},t):e)}(e.content,r)}),e.facets&&Object.keys(e.facets).length>0&&(0,s.jsx)("div",{className:w().statusMeta,children:Object.entries(e.facets).slice(0,8).map(e=>{let[t,n]=e;return(0,s.jsxs)("span",{children:[t," ",(0,s.jsx)("b",{children:Array.isArray(n)?n.join(", "):String(n)})]},t)})}),(0,s.jsxs)("div",{className:w().statusMeta,children:[(0,s.jsxs)("span",{children:["keyword ",(0,s.jsx)("b",{children:_(null==(t=e.scoreDetails)?void 0:t.keywordScore)})]}),(0,s.jsxs)("span",{children:["bm25 ",(0,s.jsx)("b",{children:_(null==(n=e.scoreDetails)?void 0:n.bm25Score)})]}),(0,s.jsxs)("span",{children:["vector ",(0,s.jsx)("b",{children:_(null==(o=e.scoreDetails)?void 0:o.vectorScore)})]}),(0,s.jsxs)("span",{children:["rerank ",(0,s.jsx)("b",{children:_(null==(i=e.scoreDetails)?void 0:i.rerankBoost)})]}),(0,s.jsxs)("span",{children:["hybrid ",(0,s.jsx)("b",{children:_(null==(c=e.scoreDetails)?void 0:c.hybridScore)})]})]})]},e.id)})})]})]})}},6578:(e,t,n)=>{"use strict";async function s(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.text(),t=e||"HTTP ".concat(n.status);try{let n=JSON.parse(e);t=n.error||n.message||t}catch(e){}throw Error(t)}return n.json()}async function r(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return s("/api/kb/stats".concat(t))}async function a(e){var t,n;let r=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&r.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&r.set("category",e.category),(null==e?void 0:e.page)&&r.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&r.set("limit",String(null!=(n=e.limit)?n:50)),s("/api/kb/files?".concat(r))}async function o(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),s("/api/kb/files/detail?".concat(n))}async function i(e,t){return s("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function c(e,t,n){return s("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:t,projectRoot:n})})}async function l(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>{let e=s.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},s.onerror=n,s.readAsDataURL(e)})}async function d(e,t,n){return s("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:t,uploadId:n})})}async function u(e){return s("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t),{method:"DELETE"})}async function y(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function m(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function f(e){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return s("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function j(){return s("/api/kb/features")}async function b(e,t){var n,r,a,o,i;let c=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&c.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&c.set("category",t.category),(null==t?void 0:t.limit)&&c.set("limit",String(null!=(i=t.limit)?i:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&c.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(r=t.weights)?void 0:r.vector)!=null&&c.set("vectorWeight",String(t.weights.vector)),(null==t||null==(a=t.weights)?void 0:a.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(o=t.weights)?void 0:o.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),s("/api/kb/search?".concat(c))}async function x(){return s("/api/prompt")}async function w(e){return s("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function v(e){return s("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function _(e,t){return s("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function S(e){return s("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function T(e){return s("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function C(){return s("/api/documents/specs")}async function O(e){return s("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return s("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function E(){return s("/api/documents/templates")}async function k(e){return s("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function N(e){return s("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function R(e){return s("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return s("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function I(){return s("/api/documents/generated")}async function U(e){return s("/api/documents/generated/".concat(encodeURIComponent(e)))}async function J(e,t){return s("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function L(){return s("/api/assets/generated")}async function D(e){return s("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function H(e){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function B(e,t){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:t})})}async function z(e){return s("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function V(e,t){return s("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function X(e){let t=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());return t.blob()}async function F(){return s("/api/config/providers")}async function M(e,t){return s("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function W(e){return s("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function K(){return s("/api/config/models")}async function Q(e){return s("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function q(){return s("/api/config/embedding")}async function Z(e){return s("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function $(){return s("/api/config/embedding/healthCheck",{method:"POST"})}async function G(e){return s("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function Y(){return s("/api/system/stats")}async function ee(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return s("/api/context".concat(n))}async function et(e){return s("/api/context?type=".concat(e,"&stats=1"))}async function en(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function es(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function er(e){return s("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function ea(e,t){return s("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function eo(e){return s("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>V,Bh:()=>eo,Dl:()=>E,E:()=>es,EK:()=>O,ER:()=>P,FC:()=>Y,FV:()=>_,H1:()=>g,H7:()=>h,HC:()=>i,HT:()=>a,II:()=>q,JU:()=>D,NR:()=>S,OX:()=>A,PH:()=>en,QT:()=>u,Qx:()=>p,R1:()=>z,SJ:()=>m,UE:()=>X,VW:()=>j,W2:()=>b,X8:()=>f,Z3:()=>F,_m:()=>M,a6:()=>J,aP:()=>Q,bV:()=>R,bZ:()=>G,c1:()=>d,cQ:()=>I,dd:()=>Z,dg:()=>v,dw:()=>T,dx:()=>x,f$:()=>L,h0:()=>N,h1:()=>W,hc:()=>r,hn:()=>ee,l2:()=>k,lv:()=>w,mx:()=>C,oS:()=>B,p:()=>et,tn:()=>c,u6:()=>$,uc:()=>H,v7:()=>U,xC:()=>o,xq:()=>y,xw:()=>er,zo:()=>ea,zr:()=>K})},9208:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/search",function(){return n(4184)}])},14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusPanel:"style_statusPanel__9arTu",statusPanelHeader:"style_statusPanelHeader__nKv1I",statusEmpty:"style_statusEmpty__8LWzH",statusList:"style_statusList__FpNgC",statusItem:"style_statusItem__uzO80",statusHeader:"style_statusHeader__o9q_b",statusDesc:"style_statusDesc__XiWFa",statusPath:"style_statusPath__Udxvv",statusMeta:"style_statusMeta__XukHt",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},60470:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var s=n(97109),r=n(838),a=n(88483);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}let i=s.forwardRef((e,t)=>s.createElement(a.A,o({},e,{ref:t,icon:r.A})))},63214:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"}}]},name:"check",theme:"outlined"}},84190:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var s=n(97109),r=n(63214),a=n(88483);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}let i=s.forwardRef((e,t)=>s.createElement(a.A,o({},e,{ref:t,icon:r.A})))}},e=>{e.O(0,[260,167,382,628,576,700,292,20,350,636,593,792],()=>e(e.s=9208)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[207],{838:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]},name:"down",theme:"outlined"}},4184:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>S});var s=n(65321),a=n(43220),r=n.n(a),o=n(97109),i=n(35292),c=n(68787),l=n(33442),d=n(7576),u=n(85114),p=n(94992),h=n(76506),y=n(11702),m=n(85493),f=n(42700),g=n(84253),j=n(30486),b=n(6578),x=n(14569),w=n.n(x);let{Paragraph:v}=i.A;function _(e){return"number"==typeof e?e.toFixed(2):"-"}function S(){var e,t,n;let[a,i]=(0,o.useState)(""),[x,S]=(0,o.useState)(!1),[T,C]=(0,o.useState)([]),[O,E]=(0,o.useState)(),[P,k]=(0,o.useState)(),[R,N]=(0,o.useState)(""),[A,I]=(0,o.useState)({keyword:1,vector:.9,rewrite:.72,hybridBonus:.35}),U=async()=>{let e=a.trim();if(e){S(!0),N("");try{let t=await (0,b.W2)(e,{limit:10,weights:A});C(t.results),E(t.queryTimeMs),k(t.debug)}catch(e){C([]),N(e instanceof Error?e.message:"搜索失败")}finally{S(!1)}}};return(0,s.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"pageTitle",children:"知识库搜索"}),(0,s.jsx)("p",{className:"pageDesc",children:"查看 hybrid 检索、parent 回填、分块来源和评分明细。"})]}),(0,s.jsx)(c.A,{size:"small",children:(0,s.jsxs)(l.A.Compact,{className:"w-full",children:[(0,s.jsx)(d.A,{value:a,onChange:e=>i(e.target.value),onPressEnter:()=>{U()},placeholder:"输入要搜索的知识库内容"}),(0,s.jsx)(u.Ay,{type:"primary",icon:(0,s.jsx)(j.A,{}),loading:x,onClick:()=>{U()},children:"搜索"})]})}),(0,s.jsx)(c.A,{size:"small",title:"召回权重调节",children:(0,s.jsxs)(l.A,{wrap:!0,children:[(0,s.jsxs)("span",{children:["Keyword ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.keyword,onChange:e=>I(t=>({...t,keyword:Number(null!=e?e:1)}))})]}),(0,s.jsxs)("span",{children:["Vector ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.vector,onChange:e=>I(t=>({...t,vector:Number(null!=e?e:.9)}))})]}),(0,s.jsxs)("span",{children:["Rewrite ",(0,s.jsx)(p.A,{min:0,max:5,step:.1,value:A.rewrite,onChange:e=>I(t=>({...t,rewrite:Number(null!=e?e:.72)}))})]}),(0,s.jsxs)("span",{children:["Hybrid Bonus ",(0,s.jsx)(p.A,{min:0,max:2,step:.05,value:A.hybridBonus,onChange:e=>I(t=>({...t,hybridBonus:Number(null!=e?e:.35)}))})]})]})}),P&&(0,s.jsx)(c.A,{size:"small",title:"检索调试面板",children:(0,s.jsxs)(h.A,{size:"small",column:2,bordered:!0,children:[(0,s.jsx)(h.A.Item,{label:"原始查询",children:P.originalQuery}),(0,s.jsx)(h.A.Item,{label:"Reranker",children:P.reranker}),(0,s.jsx)(h.A.Item,{label:"查询改写",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:null==(e=P.rewrittenQueries)?void 0:e.map(e=>(0,s.jsx)(y.A,{children:e},e))})}),(0,s.jsx)(h.A.Item,{label:"召回数量",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:Object.entries(null!=(t=P.recallCounts)?t:{}).map(e=>{let[t,n]=e;return(0,s.jsxs)(y.A,{children:[t,": ",n]},t)})})}),(0,s.jsx)(h.A.Item,{label:"召回权重",span:2,children:(0,s.jsx)(l.A,{wrap:!0,children:Object.entries(null!=(n=P.weights)?n:{}).map(e=>{let[t,n]=e;return(0,s.jsxs)(y.A,{children:[t,": ",n]},t)})})})]})}),(0,s.jsxs)(c.A,{size:"small",title:"搜索结果",extra:"number"==typeof O?"".concat(O," ms"):void 0,children:[R?(0,s.jsx)(m.A,{type:"error",showIcon:!0,message:"搜索失败",description:R,className:"mb-4"}):null,x?(0,s.jsx)(f.A,{}):0===T.length?(0,s.jsx)(g.A,{description:"暂无结果"}):(0,s.jsx)("div",{className:w().searchResultList,children:T.map(e=>{var t,n,o,i,c,d;return(0,s.jsxs)("div",{className:w().searchResultItem,children:[(0,s.jsxs)("div",{className:w().searchResultHeader,children:[(0,s.jsxs)(l.A,{size:8,wrap:!0,children:[(0,s.jsx)(y.A,{color:"hybrid"===e.source?"purple":"vector"===e.source?"blue":"green",children:null!=(d=e.source)?d:"keyword"}),(0,s.jsx)(y.A,{children:e.scope}),e.chunkKind&&(0,s.jsx)(y.A,{color:"geekblue",children:e.chunkKind}),e.rowRange&&(0,s.jsxs)(y.A,{color:"gold",children:["行 ",e.rowRange]}),e.sectionTitle&&(0,s.jsx)(y.A,{color:"cyan",children:e.sectionTitle})]}),(0,s.jsx)("strong",{children:_(e.score)})]}),(0,s.jsxs)("div",{className:w().statusPath,children:[(0,s.jsx)(r(),{href:"/knowledge/file-detail?relativePath=".concat(encodeURIComponent(e.filePath)),children:e.filePath}),"number"==typeof e.chunkIndex?" #".concat(e.chunkIndex):""]}),(0,s.jsx)(v,{ellipsis:{rows:6,expandable:!0,symbol:"展开"},className:w().searchContent,children:function(e,t){let n=[t.trim(),...t.split(/[\s,,。;;::、]+/u)].filter(Boolean).sort((e,t)=>t.length-e.length);if(0===n.length)return e;let a=RegExp("(".concat(n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),")"),"giu");return e.split(a).map((e,t)=>n.some(t=>t.toLowerCase()===e.toLowerCase())?(0,s.jsx)("mark",{children:e},t):e)}(e.content,a)}),e.facets&&Object.keys(e.facets).length>0&&(0,s.jsx)("div",{className:w().statusMeta,children:Object.entries(e.facets).slice(0,8).map(e=>{let[t,n]=e;return(0,s.jsxs)("span",{children:[t," ",(0,s.jsx)("b",{children:Array.isArray(n)?n.join(", "):String(n)})]},t)})}),(0,s.jsxs)("div",{className:w().statusMeta,children:[(0,s.jsxs)("span",{children:["keyword ",(0,s.jsx)("b",{children:_(null==(t=e.scoreDetails)?void 0:t.keywordScore)})]}),(0,s.jsxs)("span",{children:["bm25 ",(0,s.jsx)("b",{children:_(null==(n=e.scoreDetails)?void 0:n.bm25Score)})]}),(0,s.jsxs)("span",{children:["vector ",(0,s.jsx)("b",{children:_(null==(o=e.scoreDetails)?void 0:o.vectorScore)})]}),(0,s.jsxs)("span",{children:["rerank ",(0,s.jsx)("b",{children:_(null==(i=e.scoreDetails)?void 0:i.rerankBoost)})]}),(0,s.jsxs)("span",{children:["hybrid ",(0,s.jsx)("b",{children:_(null==(c=e.scoreDetails)?void 0:c.hybridScore)})]})]})]},e.id)})})]})]})}},6578:(e,t,n)=>{"use strict";async function s(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.text(),t=e||"HTTP ".concat(n.status);try{let n=JSON.parse(e);t=n.error||n.message||t}catch(e){}throw Error(t)}return n.json()}async function a(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return s("/api/kb/stats".concat(t))}async function r(e){var t,n;let a=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&a.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&a.set("category",e.category),(null==e?void 0:e.page)&&a.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&a.set("limit",String(null!=(n=e.limit)?n:50)),s("/api/kb/files?".concat(a))}async function o(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),s("/api/kb/files/detail?".concat(n))}async function i(e,t){return s("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function c(e,t,n){return s("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:t,projectRoot:n})})}async function l(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>{let e=s.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},s.onerror=n,s.readAsDataURL(e)})}async function d(e,t,n){return s("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:t,uploadId:n})})}async function u(e){return s("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),s("/api/kb/operations?".concat(t),{method:"DELETE"})}async function y(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function m(e,t){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function f(e){return s("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return s("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function j(){return s("/api/kb/features")}async function b(e,t){var n,a,r,o,i;let c=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&c.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&c.set("category",t.category),(null==t?void 0:t.limit)&&c.set("limit",String(null!=(i=t.limit)?i:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&c.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(a=t.weights)?void 0:a.vector)!=null&&c.set("vectorWeight",String(t.weights.vector)),(null==t||null==(r=t.weights)?void 0:r.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(o=t.weights)?void 0:o.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),s("/api/kb/search?".concat(c))}async function x(){return s("/api/prompt")}async function w(e){return s("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function v(e){return s("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function _(e,t){return s("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function S(e){return s("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function T(e){return s("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function C(){return s("/api/documents/specs")}async function O(e){return s("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(e){return s("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function P(){return s("/api/documents/templates")}async function k(e){return s("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(e){return s("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function N(e){return s("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return s("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function I(){return s("/api/documents/generated")}async function U(e){return s("/api/documents/generated/".concat(encodeURIComponent(e)))}async function J(e,t){return s("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function L(e){return s("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return s("/api/assets/generated")}async function H(e){return s("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function B(e){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function z(e,t){return s("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:t})})}async function V(e){return s("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function X(e,t){return s("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function F(e){let t=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());return t.blob()}async function M(){return s("/api/config/providers")}async function W(e,t){return s("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function K(e){return s("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Q(){return s("/api/config/models")}async function q(e){return s("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Z(){return s("/api/config/embedding")}async function $(e){return s("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function G(){return s("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return s("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return s("/api/system/stats")}async function et(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return s("/api/context".concat(n))}async function en(e){return s("/api/context?type=".concat(e,"&stats=1"))}async function es(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function ea(e){return s("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function er(e){return s("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function eo(e,t){return s("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function ei(e){return s("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>X,Bh:()=>ei,Dl:()=>P,E:()=>ea,EK:()=>O,ER:()=>E,FC:()=>ee,FV:()=>_,H1:()=>g,H7:()=>h,HC:()=>i,HT:()=>r,II:()=>Z,JU:()=>H,NR:()=>S,OX:()=>A,PH:()=>es,QG:()=>L,QT:()=>u,Qx:()=>p,R1:()=>V,SJ:()=>m,UE:()=>F,VW:()=>j,W2:()=>b,X8:()=>f,Z3:()=>M,_m:()=>W,a6:()=>J,aP:()=>q,bV:()=>N,bZ:()=>Y,c1:()=>d,cQ:()=>I,dd:()=>$,dg:()=>v,dw:()=>T,dx:()=>x,f$:()=>D,h0:()=>R,h1:()=>K,hc:()=>a,hn:()=>et,l2:()=>k,lv:()=>w,mx:()=>C,oS:()=>z,p:()=>en,tn:()=>c,u6:()=>G,uc:()=>B,v7:()=>U,xC:()=>o,xq:()=>y,xw:()=>er,zo:()=>eo,zr:()=>Q})},9208:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/search",function(){return n(4184)}])},14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusPanel:"style_statusPanel__9arTu",statusPanelHeader:"style_statusPanelHeader__nKv1I",statusEmpty:"style_statusEmpty__8LWzH",statusList:"style_statusList__FpNgC",statusItem:"style_statusItem__uzO80",statusHeader:"style_statusHeader__o9q_b",statusDesc:"style_statusDesc__XiWFa",statusPath:"style_statusPath__Udxvv",statusMeta:"style_statusMeta__XukHt",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},60470:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var s=n(97109),a=n(838),r=n(88483);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}let i=s.forwardRef((e,t)=>s.createElement(r.A,o({},e,{ref:t,icon:a.A})))},63214:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"}}]},name:"check",theme:"outlined"}},84190:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var s=n(97109),a=n(63214),r=n(88483);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}let i=s.forwardRef((e,t)=>s.createElement(r.A,o({},e,{ref:t,icon:a.A})))}},e=>{e.O(0,[260,167,382,628,576,700,292,20,350,636,593,792],()=>e(e.s=9208)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46],{69:(e,n)=>{"use strict";n.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5L255.8 713.6l-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.19 8.19 0 00-11.4 0l-39.8 39.8a8.19 8.19 0 000 11.4l110.3 111.2c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.1 304.1 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112m161.2 465.2C726.2 620.3 668.9 644 608 644s-118.2-23.7-161.2-66.8C403.7 534.2 380 476.9 380 416s23.7-118.2 66.8-161.2c43-43.1 100.3-66.8 161.2-66.8s118.2 23.7 161.2 66.8c43.1 43 66.8 100.3 66.8 161.2s-23.7 118.2-66.8 161.2"}}]},name:"key",theme:"outlined"}},2256:(e,n,t)=>{"use strict";t.d(n,{A:()=>a});let a=t(25341).A},5450:(e,n)=>{"use strict";n.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 00-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 000 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3 2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4-186.8-186.8 59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7 35.3 0 68.4 13.7 93.4 38.7 24.9 24.9 38.7 58.1 38.7 93.4 0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 00-11.3 0L501 613.3 410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 00-11.3 0L363 475.3l-43-43a7.85 7.85 0 00-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 000 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3 51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43 66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 01-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 01-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4 186.8 186.8-59.4 59.4z"}}]},name:"api",theme:"outlined"}},6578:(e,n,t)=>{"use strict";async function a(e,n){let t=await fetch(e,n);if(!t.ok){let e=await t.text(),n=e||"HTTP ".concat(t.status);try{let t=JSON.parse(e);n=t.error||t.message||n}catch(e){}throw Error(n)}return t.json()}async function o(e){let n=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return a("/api/kb/stats".concat(n))}async function s(e){var n,t;let o=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&o.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&o.set("category",e.category),(null==e?void 0:e.page)&&o.set("page",String(null!=(n=e.page)?n:1)),(null==e?void 0:e.limit)&&o.set("limit",String(null!=(t=e.limit)?t:50)),a("/api/kb/files?".concat(o))}async function c(e,n){let t=new URLSearchParams({relativePath:e});return n&&t.set("projectRoot",n),a("/api/kb/files/detail?".concat(t))}async function i(e,n){return a("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function l(e,n,t){return a("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:n,projectRoot:t})})}async function r(e){return new Promise((n,t)=>{let a=new FileReader;a.onload=()=>{let e=a.result,t=e.indexOf(",");n(t>=0?e.slice(t+1):e)},a.onerror=t,a.readAsDataURL(e)})}async function d(e,n,t){return a("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await r(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:n,uploadId:t})})}async function m(e){return a("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let n=new URLSearchParams({limit:"50"});return e&&n.set("projectRoot",e),a("/api/kb/operations?".concat(n))}async function u(e){let n=new URLSearchParams;return e&&n.set("projectRoot",e),a("/api/kb/operations?".concat(n),{method:"DELETE"})}async function h(e,n){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function y(e,n){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:n})})}async function f(e){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return a("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function v(){return a("/api/kb/features")}async function b(e,n){var t,o,s,c,i;let l=new URLSearchParams({q:e});return(null==n?void 0:n.projectRoot)&&l.set("projectRoot",n.projectRoot),(null==n?void 0:n.category)&&l.set("category",n.category),(null==n?void 0:n.limit)&&l.set("limit",String(null!=(i=n.limit)?i:20)),(null==n||null==(t=n.weights)?void 0:t.keyword)!=null&&l.set("keywordWeight",String(n.weights.keyword)),(null==n||null==(o=n.weights)?void 0:o.vector)!=null&&l.set("vectorWeight",String(n.weights.vector)),(null==n||null==(s=n.weights)?void 0:s.rewrite)!=null&&l.set("rewriteWeight",String(n.weights.rewrite)),(null==n||null==(c=n.weights)?void 0:c.hybridBonus)!=null&&l.set("hybridBonus",String(n.weights.hybridBonus)),a("/api/kb/search?".concat(l))}async function j(){return a("/api/prompt")}async function x(e){return a("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function A(e){return a("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function C(e,n){return a("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(n)),{method:"DELETE"})}async function S(e){return a("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function w(e){return a("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(){return a("/api/documents/specs")}async function T(e){return a("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function N(e){return a("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function P(){return a("/api/documents/templates")}async function k(e){return a("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function R(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function U(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function _(){return a("/api/documents/generated")}async function I(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)))}async function z(e,n){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function L(e){return a("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function J(){return a("/api/assets/generated")}async function M(e){return a("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(e){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function K(e,n){return a("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:n})})}async function H(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function G(e,n){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:n})})}async function V(e){let n=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw Error(await n.text());return n.blob()}async function B(){return a("/api/config/providers")}async function F(e,n){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...n})})}async function W(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function X(){return a("/api/config/models")}async function Q(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Z(){return a("/api/config/embedding")}async function q(e){return a("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Y(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function $(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return a("/api/system/stats")}async function en(e,n){let t=n?"?type=".concat(e,"&search=").concat(encodeURIComponent(n)):"?type=".concat(e);return a("/api/context".concat(t))}async function et(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function ea(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function eo(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function es(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function ec(e,n){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...n})})}async function ei(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}t.d(n,{Af:()=>G,Bh:()=>ei,Dl:()=>P,E:()=>eo,EK:()=>T,ER:()=>N,FC:()=>ee,FV:()=>C,H1:()=>g,H7:()=>u,HC:()=>i,HT:()=>s,II:()=>Z,JU:()=>M,NR:()=>S,OX:()=>U,PH:()=>ea,QG:()=>L,QT:()=>m,Qx:()=>p,R1:()=>H,SJ:()=>y,UE:()=>V,VW:()=>v,W2:()=>b,X8:()=>f,Z3:()=>B,_m:()=>F,a6:()=>z,aP:()=>Q,bV:()=>R,bZ:()=>$,c1:()=>d,cQ:()=>_,dd:()=>q,dg:()=>A,dw:()=>w,dx:()=>j,f$:()=>J,h0:()=>E,h1:()=>W,hc:()=>o,hn:()=>en,l2:()=>k,lv:()=>x,mx:()=>O,oS:()=>K,p:()=>et,tn:()=>l,u6:()=>Y,uc:()=>D,v7:()=>I,xC:()=>c,xq:()=>h,xw:()=>es,zo:()=>ec,zr:()=>X})},13114:(e,n,t)=>{"use strict";t.d(n,{A:()=>i});var a=t(97109),o=t(5450),s=t(88483);function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,n)=>a.createElement(s.A,c({},e,{ref:n,icon:o.A})))},15527:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>K});var a=t(65321),o=t(97109),s=t(13014),c=t(17807),i=t(85114),l=t(68787),r=t(2256),d=t(38770),m=t(33442),p=t(26171),u=t(11702),h=t(85493),y=t(63455),f=t(57271),g=t(7576),v=t(94992),b=t(25258),j=t(56985),x=t(54746),A=t(29071),C=t(59188),S=t(4216),w=t(13114),O=t(99650),T=t(58209),N=t(69),P=t(88483);function k(){return(k=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let E=o.forwardRef((e,n)=>o.createElement(P.A,k({},e,{ref:n,icon:N.A})));var R=t(30289);function U(){return(U=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let _=o.forwardRef((e,n)=>o.createElement(P.A,U({},e,{ref:n,icon:R.A})));var I=t(6578),z=t(42323),L=t.n(z);let J=[{label:"OpenAI 兼容",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"Google",value:"google"},{label:"Ollama",value:"ollama"},{label:"OpenRouter",value:"openrouter"}],M=[{key:"reader",labelKey:"models.tierReader",descKey:"models.tierReaderDesc"},{key:"reasoning",labelKey:"models.tierReasoning",descKey:"models.tierReasoningDesc"},{key:"action",labelKey:"models.tierAction",descKey:"models.tierActionDesc"}],D=[{key:"imageGeneration",label:"图片生成"},{key:"imageUnderstanding",label:"图片理解"},{key:"fileUnderstanding",label:"文件理解"},{key:"audio",label:"音频能力"},{key:"video",label:"视频能力"}];function K(){let e=(0,s.Vr)(),{message:n}=c.A.useApp(),t=[{label:e("models.embeddingProviderHash"),value:"hash"},{label:e("models.embeddingProviderOpenAI"),value:"openai-compatible"}],[N,P]=(0,o.useState)(!0),[k,R]=(0,o.useState)([]),[U,z]=(0,o.useState)(null),[K,H]=(0,o.useState)({provider:"hash",dimensions:384}),[G,V]=(0,o.useState)(!1),[B,F]=(0,o.useState)(!1),[W,X]=(0,o.useState)(null),[Q,Z]=(0,o.useState)(!1),[q,Y]=(0,o.useState)(""),[$,ee]=(0,o.useState)(""),[en,et]=(0,o.useState)(""),[ea,eo]=(0,o.useState)("openai"),[es,ec]=(0,o.useState)({}),[ei,el]=(0,o.useState)(!1),[er,ed]=(0,o.useState)(!1),[em,ep]=(0,o.useState)(""),[eu,eh]=(0,o.useState)(""),[ey,ef]=(0,o.useState)(""),[eg,ev]=(0,o.useState)(""),[eb,ej]=(0,o.useState)("openai"),[ex,eA]=(0,o.useState)({}),[eC,eS]=(0,o.useState)(!1),[ew,eO]=(0,o.useState)(null),[eT,eN]=(0,o.useState)({}),eP=async()=>{P(!0);try{let[e,n,t]=await Promise.all([(0,I.Z3)().catch(()=>[]),(0,I.zr)().catch(()=>null),(0,I.II)().catch(()=>({provider:"hash",dimensions:384}))]);R(e),z(n),H(t)}catch(t){n.error(e("common.error"))}finally{P(!1)}};(0,o.useEffect)(()=>{eP()},[]);let ek=async()=>{if(q.trim()){el(!0);try{await (0,I._m)(q.trim(),{apiKey:$||void 0,baseUrl:en||void 0,protocol:ea,capabilities:es}),Z(!1),Y(""),ee(""),et(""),eo("openai"),ec({}),await eP(),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}finally{el(!1)}}},eE=async t=>{try{await (0,I.h1)(t),await eP(),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}},eR=async e=>{ep(e.name),eh(e.name),ef("");try{let n=await (0,I.Bh)(e.name);ef(n.apiKey?"••••••••":""),ev(n.baseUrl||""),ej(n.protocol||n.detectedProtocol||"openai"),eA(n.capabilities||{})}catch(n){ev(e.baseUrl||""),ej(e.protocol||e.detectedProtocol||"openai"),eA(e.capabilities||{})}ed(!0)},eU=async()=>{if(eu.trim()){eS(!0);try{let t=ey.includes("•")?void 0:ey||void 0;await (0,I._m)(eu.trim(),{oldName:em,apiKey:t,baseUrl:eg||void 0,protocol:eb,capabilities:ex}),ed(!1),ep(""),eh(""),ef(""),ev(""),ej("openai"),eA({}),await eP(),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}finally{eS(!1)}}},e_=async t=>{eO(t);try{let a=await (0,I.bZ)(t);eN(e=>({...e,[t]:a.success})),n[a.success?"success":"error"](a.success?e("models.connected"):e("models.connectionFailed"))}catch(e){eN(e=>({...e,[t]:!1}))}finally{eO(null)}},eI=async()=>{V(!0);try{let t=await (0,I.dd)(K);H(t),X(null),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}finally{V(!1)}},ez=async()=>{F(!0);try{let t=await (0,I.u6)();X(t.success),n[t.success?"success":"error"](t.message||(t.success?e("models.connected"):e("models.connectionFailed")))}catch(t){X(!1),n.error(e("common.error"))}finally{F(!1)}},eL=async(t,a)=>{if(!U)return;let o={...U},s=o[t];if(!a){s.active="",z(o);try{await (0,I.aP)(o)}catch(t){n.error(e("common.error"))}return}let c=a.indexOf(":"),i=c>=0?a.slice(0,c):a,l=c>=0?a.slice(c+1):a;s.active=l,s.list.some(e=>e.name===l&&e.provider===i)||s.list.push({name:l,provider:i}),z(o);try{await (0,I.aP)(o)}catch(t){n.error(e("common.error"))}};return(0,a.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"pageTitle",children:e("models.title")}),(0,a.jsx)("p",{className:"pageDesc",children:e("models.description")})]}),(0,a.jsx)(i.Ay,{type:"primary",icon:(0,a.jsx)(x.A,{}),onClick:()=>Z(!0),children:e("models.addModel")})]}),(0,a.jsx)(l.A,{title:e("models.modelList"),size:"small",loading:N,children:0===k.length?(0,a.jsx)("span",{className:L().cardMeta,children:e("models.noProviders")}):(0,a.jsx)(r.A,{gutter:[12,12],align:"stretch",children:k.map(n=>(0,a.jsx)(d.A,{xs:24,sm:12,lg:8,xl:6,className:L().providerGrid,children:(0,a.jsxs)(l.A,{size:"small",className:L().providerCard,children:[(0,a.jsxs)("div",{className:L().cardAction,children:[(0,a.jsxs)("div",{className:L().cardMain,children:[(0,a.jsx)("div",{className:L().cardName,title:n.name,children:n.name}),(0,a.jsxs)("div",{className:L().cardMeta,children:[(0,a.jsx)(A.A,{})," ",n.protocol||n.detectedProtocol||"openai"]})]}),(0,a.jsxs)(m.A,{size:2,wrap:!1,children:[(0,a.jsx)(i.Ay,{size:"small",type:"text",loading:ew===n.name,onClick:()=>{e_(n.name)},icon:!0===eT[n.name]?(0,a.jsx)(C.A,{className:"text-[var(--colorOk)]"}):!1===eT[n.name]?(0,a.jsx)(S.A,{className:"text-[var(--colorDanger)]"}):(0,a.jsx)(w.A,{})}),(0,a.jsx)(i.Ay,{size:"small",type:"text",icon:(0,a.jsx)(O.A,{}),onClick:()=>{eR(n)}}),(0,a.jsx)(p.A,{title:e("models.deleteProviderConfirm"),onConfirm:()=>{eE(n.name)},children:(0,a.jsx)(i.Ay,{size:"small",type:"text",danger:!0,icon:(0,a.jsx)(T.A,{})})})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("span",{className:"".concat(L().cardMeta," text-xs"),children:[(0,a.jsx)(E,{})," ",n.hasApiKey?"••••••••":"—"]}),n.baseUrl&&(0,a.jsxs)("span",{className:"".concat(L().cardMeta," ").concat(L().urlLine," text-xs"),title:n.baseUrl,children:[(0,a.jsx)(_,{})," ",n.baseUrl]}),(0,a.jsx)(m.A,{size:[4,4],wrap:!0,children:D.filter(e=>{var t;return null==(t=n.capabilities)?void 0:t[e.key]}).map(e=>(0,a.jsx)(u.A,{color:"purple",children:e.label},e.key))})]})]})},n.name))})}),(0,a.jsxs)(l.A,{title:e("models.embeddingConfig"),size:"small",loading:N,children:[(0,a.jsx)(h.A,{className:"mb-4",type:"info",showIcon:!0,message:e("models.embeddingHint")}),(0,a.jsxs)(y.A,{layout:"vertical",size:"middle",children:[(0,a.jsxs)(r.A,{gutter:[12,12],children:[(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:e("models.embeddingProvider"),children:(0,a.jsx)(f.A,{value:K.provider,options:t,onChange:e=>H(n=>({...n,provider:e,dimensions:"hash"===e?384:n.dimensions||1024}))})})}),"openai-compatible"===K.provider&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:"Base URL",children:(0,a.jsx)(g.A,{value:K.baseUrl,onChange:e=>H(n=>({...n,baseUrl:e.target.value})),placeholder:"http://localhost:11434/v1"})})}),(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:e("models.model"),children:(0,a.jsx)(g.A,{value:K.model,onChange:e=>H(n=>({...n,model:e.target.value})),placeholder:"bge-m3"})})}),(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:e("models.apiKey"),help:K.hasApiKey?e("models.embeddingApiKeyHint"):void 0,children:(0,a.jsx)(g.A.Password,{value:K.apiKey,onFocus:()=>{var e;(null==(e=K.apiKey)?void 0:e.includes("•"))&&H(e=>({...e,apiKey:""}))},onChange:e=>H(n=>({...n,apiKey:e.target.value})),placeholder:e("models.optional")})})})]}),(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:e("models.dimensions"),children:(0,a.jsx)(v.A,{className:"w-full",min:1,value:K.dimensions,onChange:e=>H(n=>({...n,dimensions:Number(e||("hash"===n.provider?384:1024))}))})})}),(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsx)(y.A.Item,{label:e("models.status"),children:(0,a.jsxs)(m.A,{children:[(0,a.jsx)(u.A,{color:"hash"===K.provider?"default":"blue",children:"hash"===K.provider?e("models.localHash"):e("models.openAICompatible")}),!0===W&&(0,a.jsx)(u.A,{color:"success",children:e("models.connected")}),!1===W&&(0,a.jsx)(u.A,{color:"error",children:e("models.connectionFailed")})]})})})]}),(0,a.jsxs)(m.A,{children:[(0,a.jsx)(i.Ay,{type:"primary",loading:G,onClick:()=>{eI()},children:e("models.saveEmbedding")}),(0,a.jsx)(i.Ay,{icon:(0,a.jsx)(w.A,{}),loading:B,onClick:()=>{ez()},children:e("models.testEmbedding")})]})]})]}),U&&(0,a.jsx)(l.A,{title:e("models.modelTiers"),size:"small",children:(0,a.jsx)(r.A,{gutter:[12,12],children:M.map(t=>{var o;let{key:s,labelKey:c,descKey:i}=t,r=U[s],m=r.list.map(e=>({label:"".concat(e.provider," / ").concat(e.name),value:"".concat(e.provider,":").concat(e.name)})),p=k.filter(e=>!r.list.some(n=>n.provider===e.name)).map(e=>({label:"".concat(e.name," / ").concat(e.name),value:"".concat(e.name,":").concat(e.name)}));return(0,a.jsx)(d.A,{xs:24,lg:8,children:(0,a.jsxs)(l.A,{size:"small",title:e(c),children:[(0,a.jsx)("span",{className:L().tierDesc,children:e(i)}),(0,a.jsx)(f.A,{value:r.active?"".concat((null==(o=r.list.find(e=>e.name===r.active))?void 0:o.provider)||"",":").concat(r.active):void 0,onChange:e=>{eL(s,e)},allowClear:!0,placeholder:e("models.selectModelPlaceholder"),className:"w-full",options:[...m,...p]}),r.list.length>0&&(0,a.jsx)("div",{className:L().modelTags,children:r.list.map(t=>(0,a.jsxs)(u.A,{color:t.name===r.active?"blue":void 0,closable:!0,onClose:()=>{var a,o;let c={...U},i=c[s];i.list=i.list.filter(e=>e.name!==t.name||e.provider!==t.provider),i.active===t.name&&(i.active=null!=(o=null==(a=i.list[0])?void 0:a.name)?o:""),z(c),(0,I.aP)(c).catch(()=>n.error(e("common.error")))},children:[t.provider,"/",t.name]},"".concat(t.provider,":").concat(t.name)))})]})},s)})})}),(0,a.jsx)(b.A,{maskClosable:!1,title:e("models.addModel"),open:Q,onCancel:()=>{Z(!1),Y(""),ee(""),et(""),eo("openai")},onOk:()=>{ek()},confirmLoading:ei,children:(0,a.jsxs)(y.A,{layout:"vertical",size:"middle",children:[(0,a.jsx)(y.A.Item,{label:e("models.modelName"),children:(0,a.jsx)(g.A,{value:q,onChange:e=>Y(e.target.value),placeholder:e("models.modelNamePlaceholder")})}),(0,a.jsx)(y.A.Item,{label:e("models.apiKey"),children:(0,a.jsx)(g.A.Password,{value:$,onChange:e=>ee(e.target.value),placeholder:"sk-..."})}),(0,a.jsx)(y.A.Item,{label:e("models.baseUrl"),children:(0,a.jsx)(g.A,{value:en,onChange:e=>et(e.target.value),placeholder:"https://api.openai.com/v1"})}),(0,a.jsx)(y.A.Item,{label:e("models.protocol"),children:(0,a.jsx)(f.A,{value:ea,onChange:eo,options:J})}),(0,a.jsx)(y.A.Item,{label:"多模态能力",children:(0,a.jsx)(j.A.Group,{value:D.filter(e=>es[e.key]).map(e=>e.key),options:D.map(e=>({label:e.label,value:e.key})),onChange:e=>ec(Object.fromEntries(D.map(n=>[n.key,e.includes(n.key)])))})})]})}),(0,a.jsx)(b.A,{maskClosable:!1,title:e("models.editModel"),open:er,onCancel:()=>{ed(!1),ep(""),eh(""),ef(""),ev(""),ej("openai")},onOk:()=>{eU()},confirmLoading:eC,children:(0,a.jsxs)(y.A,{layout:"vertical",size:"middle",children:[(0,a.jsx)(y.A.Item,{label:e("models.modelName"),children:(0,a.jsx)(g.A,{value:eu,onChange:e=>eh(e.target.value),placeholder:e("models.modelNamePlaceholder")})}),(0,a.jsx)(y.A.Item,{label:e("models.apiKey"),help:e("models.apiKeyEditHint"),children:(0,a.jsx)(g.A.Password,{value:ey,onFocus:()=>{ey.includes("•")&&ef("")},onCopy:e=>e.preventDefault(),onChange:e=>ef(e.target.value),placeholder:e("models.apiKeyEditPlaceholder")})}),(0,a.jsx)(y.A.Item,{label:e("models.baseUrl"),children:(0,a.jsx)(g.A,{value:eg,onChange:e=>ev(e.target.value),placeholder:"https://api.openai.com/v1"})}),(0,a.jsx)(y.A.Item,{label:e("models.protocol"),children:(0,a.jsx)(f.A,{value:eb,onChange:ej,options:J})}),(0,a.jsx)(y.A.Item,{label:"多模态能力",children:(0,a.jsx)(j.A.Group,{value:D.filter(e=>ex[e.key]).map(e=>e.key),options:D.map(e=>({label:e.label,value:e.key})),onChange:e=>eA(Object.fromEntries(D.map(n=>[n.key,e.includes(n.key)])))})})]})})]})}},29071:(e,n,t)=>{"use strict";t.d(n,{A:()=>i});var a=t(97109),o=t(78847),s=t(88483);function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,n)=>a.createElement(s.A,c({},e,{ref:n,icon:o.A})))},30289:(e,n)=>{"use strict";n.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.4 800.9c.2-.3.5-.6.7-.9C920.6 722.1 960 621.7 960 512s-39.4-210.1-104.8-288c-.2-.3-.5-.5-.7-.8-1.1-1.3-2.1-2.5-3.2-3.7-.4-.5-.8-.9-1.2-1.4l-4.1-4.7-.1-.1c-1.5-1.7-3.1-3.4-4.6-5.1l-.1-.1c-3.2-3.4-6.4-6.8-9.7-10.1l-.1-.1-4.8-4.8-.3-.3c-1.5-1.5-3-2.9-4.5-4.3-.5-.5-1-1-1.6-1.5-1-1-2-1.9-3-2.8-.3-.3-.7-.6-1-1C736.4 109.2 629.5 64 512 64s-224.4 45.2-304.3 119.2c-.3.3-.7.6-1 1-1 .9-2 1.9-3 2.9-.5.5-1 1-1.6 1.5-1.5 1.4-3 2.9-4.5 4.3l-.3.3-4.8 4.8-.1.1c-3.3 3.3-6.5 6.7-9.7 10.1l-.1.1c-1.6 1.7-3.1 3.4-4.6 5.1l-.1.1c-1.4 1.5-2.8 3.1-4.1 4.7-.4.5-.8.9-1.2 1.4-1.1 1.2-2.1 2.5-3.2 3.7-.2.3-.5.5-.7.8C103.4 301.9 64 402.3 64 512s39.4 210.1 104.8 288c.2.3.5.6.7.9l3.1 3.7c.4.5.8.9 1.2 1.4l4.1 4.7c0 .1.1.1.1.2 1.5 1.7 3 3.4 4.6 5l.1.1c3.2 3.4 6.4 6.8 9.6 10.1l.1.1c1.6 1.6 3.1 3.2 4.7 4.7l.3.3c3.3 3.3 6.7 6.5 10.1 9.6 80.1 74 187 119.2 304.5 119.2s224.4-45.2 304.3-119.2a300 300 0 0010-9.6l.3-.3c1.6-1.6 3.2-3.1 4.7-4.7l.1-.1c3.3-3.3 6.5-6.7 9.6-10.1l.1-.1c1.5-1.7 3.1-3.3 4.6-5 0-.1.1-.1.1-.2 1.4-1.5 2.8-3.1 4.1-4.7.4-.5.8-.9 1.2-1.4a99 99 0 003.3-3.7zm4.1-142.6c-13.8 32.6-32 62.8-54.2 90.2a444.07 444.07 0 00-81.5-55.9c11.6-46.9 18.8-98.4 20.7-152.6H887c-3 40.9-12.6 80.6-28.5 118.3zM887 484H743.5c-1.9-54.2-9.1-105.7-20.7-152.6 29.3-15.6 56.6-34.4 81.5-55.9A373.86 373.86 0 01887 484zM658.3 165.5c39.7 16.8 75.8 40 107.6 69.2a394.72 394.72 0 01-59.4 41.8c-15.7-45-35.8-84.1-59.2-115.4 3.7 1.4 7.4 2.9 11 4.4zm-90.6 700.6c-9.2 7.2-18.4 12.7-27.7 16.4V697a389.1 389.1 0 01115.7 26.2c-8.3 24.6-17.9 47.3-29 67.8-17.4 32.4-37.8 58.3-59 75.1zm59-633.1c11 20.6 20.7 43.3 29 67.8A389.1 389.1 0 01540 327V141.6c9.2 3.7 18.5 9.1 27.7 16.4 21.2 16.7 41.6 42.6 59 75zM540 640.9V540h147.5c-1.6 44.2-7.1 87.1-16.3 127.8l-.3 1.2A445.02 445.02 0 00540 640.9zm0-156.9V383.1c45.8-2.8 89.8-12.5 130.9-28.1l.3 1.2c9.2 40.7 14.7 83.5 16.3 127.8H540zm-56 56v100.9c-45.8 2.8-89.8 12.5-130.9 28.1l-.3-1.2c-9.2-40.7-14.7-83.5-16.3-127.8H484zm-147.5-56c1.6-44.2 7.1-87.1 16.3-127.8l.3-1.2c41.1 15.6 85 25.3 130.9 28.1V484H336.5zM484 697v185.4c-9.2-3.7-18.5-9.1-27.7-16.4-21.2-16.7-41.7-42.7-59.1-75.1-11-20.6-20.7-43.3-29-67.8 37.2-14.6 75.9-23.3 115.8-26.1zm0-370a389.1 389.1 0 01-115.7-26.2c8.3-24.6 17.9-47.3 29-67.8 17.4-32.4 37.8-58.4 59.1-75.1 9.2-7.2 18.4-12.7 27.7-16.4V327zM365.7 165.5c3.7-1.5 7.3-3 11-4.4-23.4 31.3-43.5 70.4-59.2 115.4-21-12-40.9-26-59.4-41.8 31.8-29.2 67.9-52.4 107.6-69.2zM165.5 365.7c13.8-32.6 32-62.8 54.2-90.2 24.9 21.5 52.2 40.3 81.5 55.9-11.6 46.9-18.8 98.4-20.7 152.6H137c3-40.9 12.6-80.6 28.5-118.3zM137 540h143.5c1.9 54.2 9.1 105.7 20.7 152.6a444.07 444.07 0 00-81.5 55.9A373.86 373.86 0 01137 540zm228.7 318.5c-39.7-16.8-75.8-40-107.6-69.2 18.5-15.8 38.4-29.7 59.4-41.8 15.7 45 35.8 84.1 59.2 115.4-3.7-1.4-7.4-2.9-11-4.4zm292.6 0c-3.7 1.5-7.3 3-11 4.4 23.4-31.3 43.5-70.4 59.2-115.4 21 12 40.9 26 59.4 41.8a373.81 373.81 0 01-107.6 69.2z"}}]},name:"global",theme:"outlined"}},38770:(e,n,t)=>{"use strict";t.d(n,{A:()=>a});let a=t(51916).A},42323:e=>{e.exports={cardMeta:"style_cardMeta__6KOa3",cardName:"style_cardName__WcLAf",cardAction:"style_cardAction__XUfPD",cardMain:"style_cardMain__qI1jU",providerCard:"style_providerCard__tLKGs",providerGrid:"style_providerGrid__Gx5GR",urlLine:"style_urlLine__DuMYs",tierDesc:"style_tierDesc__wOd6p",modelTags:"style_modelTags__nmMVj"}},77305:(e,n,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/models",function(){return t(15527)}])},78847:(e,n)=>{"use strict";n.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M848 359.3H627.7L825.8 109c4.1-5.3.4-13-6.3-13H436c-2.8 0-5.5 1.5-6.9 4L170 547.5c-3.1 5.3.7 12 6.9 12h174.4l-89.4 357.6c-1.9 7.8 7.5 13.3 13.3 7.7L853.5 373c5.2-4.9 1.7-13.7-5.5-13.7zM378.2 732.5l60.3-241H281.1l189.6-327.4h224.6L487 427.4h211L378.2 732.5z"}}]},name:"thunderbolt",theme:"outlined"}}},e=>{e.O(0,[260,167,382,628,271,576,183,985,232,20,636,593,792],()=>e(e.s=77305)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[449],{6578:(e,n,t)=>{"use strict";async function o(e,n){let t=await fetch(e,n);if(!t.ok){let e=await t.text(),n=e||"HTTP ".concat(t.status);try{let t=JSON.parse(e);n=t.error||t.message||n}catch(e){}throw Error(n)}return t.json()}async function i(e){let n=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return o("/api/kb/stats".concat(n))}async function s(e){var n,t;let i=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&i.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&i.set("category",e.category),(null==e?void 0:e.page)&&i.set("page",String(null!=(n=e.page)?n:1)),(null==e?void 0:e.limit)&&i.set("limit",String(null!=(t=e.limit)?t:50)),o("/api/kb/files?".concat(i))}async function r(e,n){let t=new URLSearchParams({relativePath:e});return n&&t.set("projectRoot",n),o("/api/kb/files/detail?".concat(t))}async function c(e,n){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function a(e,n,t){return o("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:n,projectRoot:t})})}async function l(e){return new Promise((n,t)=>{let o=new FileReader;o.onload=()=>{let e=o.result,t=e.indexOf(",");n(t>=0?e.slice(t+1):e)},o.onerror=t,o.readAsDataURL(e)})}async function d(e,n,t){return o("/api/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:await Promise.all(e.map(async e=>({fileName:e.name,fileData:await l(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:n,uploadId:t})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let n=new URLSearchParams({limit:"50"});return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n))}async function y(e){let n=new URLSearchParams;return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n),{method:"DELETE"})}async function m(e,n){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:n})})}async function h(e,n){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:n})})}async function f(e){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({all:!0,projectRoot:e})})}async function g(e){return o("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function v(){return o("/api/kb/features")}async function x(e,n){var t,i,s,r,c;let a=new URLSearchParams({q:e});return(null==n?void 0:n.projectRoot)&&a.set("projectRoot",n.projectRoot),(null==n?void 0:n.category)&&a.set("category",n.category),(null==n?void 0:n.limit)&&a.set("limit",String(null!=(c=n.limit)?c:20)),(null==n||null==(t=n.weights)?void 0:t.keyword)!=null&&a.set("keywordWeight",String(n.weights.keyword)),(null==n||null==(i=n.weights)?void 0:i.vector)!=null&&a.set("vectorWeight",String(n.weights.vector)),(null==n||null==(s=n.weights)?void 0:s.rewrite)!=null&&a.set("rewriteWeight",String(n.weights.rewrite)),(null==n||null==(r=n.weights)?void 0:r.hybridBonus)!=null&&a.set("hybridBonus",String(n.weights.hybridBonus)),o("/api/kb/search?".concat(a))}async function j(){return o("/api/prompt")}async function T(e){return o("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function S(e){return o("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function w(e,n){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(n)),{method:"DELETE"})}async function b(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function C(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function k(){return o("/api/documents/specs")}async function A(e){return o("/api/documents/specs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(e){return o("/api/documents/specs?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function E(){return o("/api/documents/templates")}async function P(e){return o("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function N(e){return o("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function R(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function U(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function J(){return o("/api/documents/generated")}async function D(e){return o("/api/documents/generated/".concat(encodeURIComponent(e)))}async function I(e,n){return o("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function L(e){return o("/api/documents/generated/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function z(){return o("/api/assets/generated")}async function _(e){return o("/api/assets/generated?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function B(e){return o("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"index"})})}async function F(e,n){return o("/api/assets/generated",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,action:"open",target:n})})}async function M(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(e,n){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:n})})}async function W(e){let n=await fetch("/api/documents/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw Error(await n.text());return n.blob()}async function Q(){return o("/api/config/providers")}async function V(e,n){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...n})})}async function X(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function q(){return o("/api/config/models")}async function Z(e){return o("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function K(){return o("/api/config/embedding")}async function G(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function $(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function Y(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function ee(){return o("/api/system/stats")}async function en(e,n){let t=n?"?type=".concat(e,"&search=").concat(encodeURIComponent(n)):"?type=".concat(e);return o("/api/context".concat(t))}async function et(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function eo(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function ei(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function es(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function er(e,n){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...n})})}async function ec(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}t.d(n,{Af:()=>H,Bh:()=>ec,Dl:()=>E,E:()=>ei,EK:()=>A,ER:()=>O,FC:()=>ee,FV:()=>w,H1:()=>g,H7:()=>y,HC:()=>c,HT:()=>s,II:()=>K,JU:()=>_,NR:()=>b,OX:()=>U,PH:()=>eo,QG:()=>L,QT:()=>u,Qx:()=>p,R1:()=>M,SJ:()=>h,UE:()=>W,VW:()=>v,W2:()=>x,X8:()=>f,Z3:()=>Q,_m:()=>V,a6:()=>I,aP:()=>Z,bV:()=>R,bZ:()=>Y,c1:()=>d,cQ:()=>J,dd:()=>G,dg:()=>S,dw:()=>C,dx:()=>j,f$:()=>z,h0:()=>N,h1:()=>X,hc:()=>i,hn:()=>en,l2:()=>P,lv:()=>T,mx:()=>k,oS:()=>F,p:()=>et,tn:()=>a,u6:()=>$,uc:()=>B,v7:()=>D,xC:()=>r,xq:()=>m,xw:()=>es,zo:()=>er,zr:()=>q})},27795:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>b});var o=t(65321),i=t(97109),s=t(13014),r=t(85114),c=t(2256),a=t(38770),l=t(68787),d=t(99605),u=t(54849),p=t(33442),y=t(11702),m=t(86109),h=t(99811),f=t(520),g=t(93314),v=t(13114),x=t(29071),j=t(26631),T=t(84742),S=t(38762),w=t(6578);function b(){var e,n,t,b,C,k,A,O,E,P,N,R;let U=(0,s.Vr)(),J=(0,m.useRouter)(),[D,I]=(0,i.useState)(null),[L,z]=(0,i.useState)(!0),[_,B]=(0,i.useState)(0),F=(0,i.useCallback)(async()=>{z(!0);try{let[e,n]=await Promise.all([(0,w.FC)(),(0,w.Z3)().catch(()=>[])]);I(e),B(Array.isArray(n)?n.length:0)}catch(e){}finally{z(!1)}},[]);(0,i.useEffect)(()=>{F();let e=setInterval(()=>{F()},1e4);return()=>clearInterval(e)},[F]);let M=(null!=(n=null==D?void 0:D.cpu.usagePercent)?n:0)>80?"var(--colorDanger)":(null!=(t=null==D?void 0:D.cpu.usagePercent)?t:0)>50?"var(--colorWarning)":"var(--colorOk)",H=(null!=(b=null==D?void 0:D.memory.usagePercent)?b:0)>80?"var(--colorDanger)":(null!=(C=null==D?void 0:D.memory.usagePercent)?C:0)>50?"var(--colorWarning)":"var(--colorOk)",W=(null==D?void 0:D.tasks.total)?Math.round(D.tasks.success/D.tasks.total*100):0,Q=null==D||null==(e=D.models)?void 0:e[0];return(0,o.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle",children:U("overview.title")}),(0,o.jsx)("p",{className:"pageDesc",children:U("overview.description")})]}),(0,o.jsx)(r.Ay,{icon:(0,o.jsx)(h.A,{spin:L}),loading:L,onClick:()=>{F()},children:U("common.retry")})]}),(0,o.jsxs)(c.A,{gutter:[16,16],children:[(0,o.jsx)(a.A,{xs:24,sm:12,children:(0,o.jsx)(l.A,{size:"small",title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f.A,{})," CPU"]}),children:(0,o.jsxs)("div",{style:{textAlign:"center"},children:[(0,o.jsx)(d.A,{type:"circle",percent:null!=(k=null==D?void 0:D.cpu.usagePercent)?k:0,size:120,strokeColor:M,format:e=>"".concat(null==e?void 0:e.toFixed(1),"%")}),(0,o.jsxs)("div",{className:"text-xs mt-2",style:{color:"var(--colorTextSecondary)"},children:[null!=(A=null==D?void 0:D.cpu.cores)?A:0," ",U("overview.cores")]})]})})}),(0,o.jsx)(a.A,{xs:24,sm:12,children:(0,o.jsx)(l.A,{size:"small",title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(g.A,{})," ",U("overview.memory")]}),children:(0,o.jsxs)("div",{style:{textAlign:"center"},children:[(0,o.jsx)(d.A,{type:"circle",percent:null!=(O=null==D?void 0:D.memory.usagePercent)?O:0,size:120,strokeColor:H,format:e=>"".concat(e,"%")}),(0,o.jsxs)("div",{className:"text-xs mt-2",style:{color:"var(--colorTextSecondary)"},children:[null!=(E=null==D?void 0:D.memory.processMB)?E:0," MB / ",null!=(P=null==D?void 0:D.memory.totalMB)?P:0," MB"]})]})})})]}),(0,o.jsxs)(c.A,{gutter:[16,16],children:[(0,o.jsx)(a.A,{xs:12,sm:6,children:(0,o.jsx)(l.A,{size:"small",children:(0,o.jsx)(u.A,{title:U("overview.providersCount"),value:_,prefix:(0,o.jsx)(v.A,{})})})}),(0,o.jsx)(a.A,{xs:12,sm:6,children:(0,o.jsx)(l.A,{size:"small",children:(0,o.jsx)(u.A,{title:U("overview.tokensUsed"),value:null!=(N=null==D?void 0:D.tokens.total)?N:0,prefix:(0,o.jsx)(x.A,{})})})}),(0,o.jsx)(a.A,{xs:12,sm:6,children:(0,o.jsx)(l.A,{size:"small",children:(0,o.jsx)(u.A,{title:U("overview.tasksTotal"),value:null!=(R=null==D?void 0:D.tasks.total)?R:0,prefix:(0,o.jsx)(j.A,{})})})}),(0,o.jsx)(a.A,{xs:12,sm:6,children:(0,o.jsx)(l.A,{size:"small",children:(0,o.jsx)(u.A,{title:U("overview.successRate"),value:W,suffix:"%",prefix:W>80?(0,o.jsx)(T.A,{style:{color:"var(--colorOk)"}}):(0,o.jsx)(S.A,{style:{color:"var(--colorDanger)"}})})})})]}),(0,o.jsxs)(c.A,{gutter:[16,16],children:[(0,o.jsx)(a.A,{xs:24,sm:12,children:(0,o.jsx)(l.A,{size:"small",title:U("overview.topModel"),children:Q?(0,o.jsxs)("div",{className:"flex items-center gap-4",children:[(0,o.jsx)(v.A,{style:{fontSize:24,color:"var(--colorAccent)"}}),(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"font-semibold",children:Q.model}),(0,o.jsxs)("div",{style:{color:"var(--colorTextSecondary)",fontSize:12},children:["@",Q.provider," — ",Q.count," ",U("overview.calls")]})]})]}):(0,o.jsx)("span",{style:{color:"var(--colorTextSecondary)"},children:U("common.noData")})})}),(0,o.jsx)(a.A,{xs:24,sm:12,children:(0,o.jsx)(l.A,{size:"small",title:U("overview.taskTypes"),children:(null==D?void 0:D.tasks.types)&&Object.keys(D.tasks.types).length>0?(0,o.jsx)(p.A,{wrap:!0,children:Object.entries(D.tasks.types).map(e=>{let[n,t]=e;return(0,o.jsxs)(y.A,{children:[n.slice(0,30),": ",t]},n)})}):(0,o.jsx)("span",{style:{color:"var(--colorTextSecondary)"},children:U("common.noData")})})})]}),(0,o.jsx)(l.A,{title:U("overview.quickActions"),size:"small",children:(0,o.jsxs)(p.A,{wrap:!0,children:[(0,o.jsx)(r.Ay,{onClick:()=>{J.push("/knowledge/manage")},children:U("overview.goToKnowledge")}),(0,o.jsx)(r.Ay,{onClick:()=>{J.push("/models")},children:U("overview.goToModels")}),(0,o.jsx)(r.Ay,{onClick:()=>{J.push("/settings")},children:U("overview.goToSettings")}),(0,o.jsx)(r.Ay,{onClick:()=>{J.push("/prompt")},children:U("nav.promptManagement")}),(0,o.jsx)(r.Ay,{onClick:()=>{J.push("/context/long-term")},children:U("nav.contextEngineering")})]})})]})}},53139:(e,n,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/overview",function(){return t(27795)}])}},e=>{e.O(0,[260,167,15,577,224,636,593,792],()=>e(e.s=53139)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST=function(s,e,t,c,a,n,i,d,u,o,f,b,r,k,h,g,l,j,m,p,_,w,x,I,v){return{__rewrites:{afterFiles:[],beforeFiles:[{has:j,source:"/_next/static/:buildId/_buildManifest.js",destination:"/_next/static/customize-agent-dashboard/_buildManifest.js"},{has:j,source:"/_next/static/:buildId/_ssgManifest.js",destination:"/_next/static/customize-agent-dashboard/_ssgManifest.js"}],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:p,bitArray:[]},__routerFilterDynamic:{numItems:k,errorRate:1e-4,numBits:k,numHashes:p,bitArray:[]},"/":["static/chunks/pages/index-c5e0758e6b31deee.js"],"/_error":["static/chunks/pages/_error-282257fbdcc167b4.js"],"/asset-library":[s,e,t,c,a,n,d,u,b,h,"static/chunks/881-a1eb917222b66f09.js","static/chunks/pages/asset-library-0f607b74fa016470.js"],"/context/long-term":[s,e,t,c,a,i,n,d,u,o,f,r,_,"static/chunks/pages/context/long-term-09e23b06634b08d9.js"],"/context/short-term":[s,e,t,c,a,i,n,d,u,o,f,r,_,"static/chunks/pages/context/short-term-2f5fd8531e87b5bd.js"],"/document-roles":[s,e,t,c,a,i,n,d,u,f,h,"static/chunks/pages/document-roles-077fc7159c88e89e.js"],"/document-specs":[s,e,t,c,a,i,n,d,u,f,h,g,"static/chunks/pages/document-specs-fb5b8a89cff6d1e3.js"],"/documents":[s,e,t,c,a,i,n,d,u,f,b,h,w,"static/chunks/617-68a9e848c380f9c3.js","static/chunks/pages/documents-38320ae2fd50be35.js"],"/guide":[s,e,t,b,w,"static/chunks/969-5d5ff5a3ed74f52b.js","static/chunks/pages/guide-acf32d66a6df6e5a.js"],"/knowledge":["static/chunks/pages/knowledge-905248d8dcb15453.js"],"/knowledge/file-detail":[s,e,t,c,a,i,n,d,o,r,b,x,"static/chunks/80-96429163e5c103a8.js",l,"static/chunks/pages/knowledge/file-detail-ad1dc61c1413db0c.js"],"/knowledge/files":[s,e,t,c,a,i,n,d,o,r,I,l,"static/chunks/pages/knowledge/files-896c058f2da5e907.js"],"/knowledge/manage":[s,e,t,c,a,n,d,o,r,v,"static/chunks/935-daa0026982d7fa8d.js","static/chunks/pages/knowledge/manage-6da10158f75718cf.js"],"/knowledge/search":[s,e,t,c,i,n,b,g,x,l,"static/chunks/pages/knowledge/search-3fd704d2afa1af3e.js"],"/models":[s,e,t,c,a,i,u,o,f,g,"static/css/0e153583d22cc52e.css","static/chunks/pages/models-7bdf24068811ae91.js"],"/overview":[s,e,I,v,"static/chunks/224-9a7074031493793b.js","static/chunks/pages/overview-572bba4876e617f5.js"],"/prompt":[s,e,t,c,i,u,o,"static/chunks/pages/prompt-c9bc7884a44d3767.js"],"/settings":[s,"static/css/82b6ddff0ef364fe.css","static/chunks/pages/settings-68f0d05bf95d12da.js"],sortedPages:["/","/_app","/_error","/asset-library","/context/long-term","/context/short-term","/document-roles","/document-specs","/documents","/guide","/knowledge","/knowledge/file-detail","/knowledge/files","/knowledge/manage","/knowledge/search","/models","/overview","/prompt","/settings"]}}("static/chunks/260-cec84dc6c353e104.js","static/chunks/167-d4f384b289ecb70c.js","static/chunks/382-6ab5f41cd91edad0.js","static/chunks/628-27424ba8ca9ca8ce.js","static/chunks/271-39045be4cdbd6af1.js","static/chunks/700-5d29b0475311f590.js","static/chunks/576-fd55b302cb0c9a48.js","static/chunks/174-51b6d64f21e9b976.js","static/chunks/183-8da0232dd30cdc81.js","static/chunks/985-4b4a3ed36ada16eb.js","static/chunks/232-813af4932a145fdc.js","static/chunks/292-f0a2c92861c304e6.js","static/chunks/400-1fa1899b7c3f0bb4.js",0,"static/chunks/951-8ecf8af33ab36369.js","static/chunks/20-8968ee2d4013a5b8.js","static/css/d284a7454d6f6b06.css",void 0,1e-4,NaN,"static/chunks/257-e4ebae17a8ee8412.js","static/chunks/858-5e6982e2b239d4b7.js","static/chunks/350-8c5e13c0577a38c3.js","static/chunks/15-4683808cb8db7005.js","static/chunks/577-5b2691f0c8f17187.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST=function(s,e,t,c,a,d,n,i,u,o,b,r,f,k,h,g,l,j,m,p,_,w,x,I,v){return{__rewrites:{afterFiles:[],beforeFiles:[{has:j,source:"/_next/static/:buildId/_buildManifest.js",destination:"/_next/static/customize-agent-dashboard/_buildManifest.js"},{has:j,source:"/_next/static/:buildId/_ssgManifest.js",destination:"/_next/static/customize-agent-dashboard/_ssgManifest.js"}],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:p,bitArray:[]},__routerFilterDynamic:{numItems:k,errorRate:1e-4,numBits:k,numHashes:p,bitArray:[]},"/":["static/chunks/pages/index-c5e0758e6b31deee.js"],"/_error":["static/chunks/pages/_error-282257fbdcc167b4.js"],"/asset-library":[s,e,t,c,a,d,i,u,r,h,"static/chunks/881-a1eb917222b66f09.js","static/chunks/pages/asset-library-82606363f9142bad.js"],"/context/long-term":[s,e,t,c,a,n,d,i,u,o,b,f,_,"static/chunks/pages/context/long-term-f2a550bc848ec1a3.js"],"/context/short-term":[s,e,t,c,a,n,d,i,u,o,b,f,_,"static/chunks/pages/context/short-term-1de28da82d2b6276.js"],"/document-roles":[s,e,t,c,a,n,d,i,u,b,h,"static/chunks/pages/document-roles-54a1cc04116e8c18.js"],"/document-specs":[s,e,t,c,a,n,d,i,u,b,h,g,"static/chunks/pages/document-specs-723dee6883949a17.js"],"/documents":[s,e,t,c,a,n,d,i,u,b,r,h,w,"static/chunks/617-68a9e848c380f9c3.js","static/chunks/pages/documents-c1a01ae631b42488.js"],"/guide":[s,e,t,r,w,"static/chunks/969-5d5ff5a3ed74f52b.js","static/chunks/pages/guide-acf32d66a6df6e5a.js"],"/knowledge":["static/chunks/pages/knowledge-905248d8dcb15453.js"],"/knowledge/file-detail":[s,e,t,c,a,n,d,i,o,f,r,x,"static/chunks/80-96429163e5c103a8.js",l,"static/chunks/pages/knowledge/file-detail-7a1a3d4352ecfa0a.js"],"/knowledge/files":[s,e,t,c,a,n,d,i,o,f,I,l,"static/chunks/pages/knowledge/files-f0e05583bf7c57d9.js"],"/knowledge/manage":[s,e,t,c,a,d,i,o,f,v,"static/chunks/935-daa0026982d7fa8d.js","static/chunks/pages/knowledge/manage-8acff53019eb6cc1.js"],"/knowledge/search":[s,e,t,c,n,d,r,g,x,l,"static/chunks/pages/knowledge/search-1f3bd8fcb7af3e4d.js"],"/models":[s,e,t,c,a,n,u,o,b,g,"static/css/0e153583d22cc52e.css","static/chunks/pages/models-11533caad3723009.js"],"/overview":[s,e,I,v,"static/chunks/224-9a7074031493793b.js","static/chunks/pages/overview-f80672c242d9aa32.js"],"/prompt":[s,e,t,c,n,u,o,"static/chunks/pages/prompt-c9bc7884a44d3767.js"],"/settings":[s,"static/css/82b6ddff0ef364fe.css","static/chunks/pages/settings-68f0d05bf95d12da.js"],sortedPages:["/","/_app","/_error","/asset-library","/context/long-term","/context/short-term","/document-roles","/document-specs","/documents","/guide","/knowledge","/knowledge/file-detail","/knowledge/files","/knowledge/manage","/knowledge/search","/models","/overview","/prompt","/settings"]}}("static/chunks/260-cec84dc6c353e104.js","static/chunks/167-d4f384b289ecb70c.js","static/chunks/382-6ab5f41cd91edad0.js","static/chunks/628-27424ba8ca9ca8ce.js","static/chunks/271-39045be4cdbd6af1.js","static/chunks/700-5d29b0475311f590.js","static/chunks/576-fd55b302cb0c9a48.js","static/chunks/174-51b6d64f21e9b976.js","static/chunks/183-8da0232dd30cdc81.js","static/chunks/985-4b4a3ed36ada16eb.js","static/chunks/232-813af4932a145fdc.js","static/chunks/292-f0a2c92861c304e6.js","static/chunks/400-1fa1899b7c3f0bb4.js",0,"static/chunks/951-8ecf8af33ab36369.js","static/chunks/20-8968ee2d4013a5b8.js","static/css/d284a7454d6f6b06.css",void 0,1e-4,NaN,"static/chunks/257-e4ebae17a8ee8412.js","static/chunks/858-5e6982e2b239d4b7.js","static/chunks/350-8c5e13c0577a38c3.js","static/chunks/15-4683808cb8db7005.js","static/chunks/577-5b2691f0c8f17187.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customize-agent/server",
3
- "version": "3.0.16",
3
+ "version": "3.0.17",
4
4
  "description": "Customize Agent Web 管理控制台",
5
5
  "exports": {
6
6
  "./package.json": "./package.json"