@customize-agent/server 3.0.8 → 3.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +145 -123
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +6 -0
- package/.next/server/chunks/5076.js +2 -2
- package/.next/server/chunks/8204.js +1 -1
- package/.next/server/chunks/9270.js +1 -1
- package/.next/server/chunks/9301.js +2 -2
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/context/long-term.html +1 -1
- package/.next/server/pages/context/short-term.html +1 -1
- package/.next/server/pages/document-roles.html +1 -1
- package/.next/server/pages/documents.html +1 -1
- package/.next/server/pages/guide.html +1 -0
- package/.next/server/pages/guide.js.nft.json +1 -0
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/knowledge/file-detail.html +1 -1
- package/.next/server/pages/knowledge/files.html +1 -1
- package/.next/server/pages/knowledge/manage.html +1 -1
- package/.next/server/pages/knowledge/search.html +1 -1
- package/.next/server/pages/knowledge.html +1 -1
- package/.next/server/pages/models.html +1 -1
- package/.next/server/pages/overview.html +1 -1
- package/.next/server/pages/prompt.html +1 -1
- package/.next/server/pages/settings.html +1 -1
- package/.next/server/pages-manifest.json +17 -16
- package/.next/static/VXIEr9wT7-PwtFzF1Z4a2/_buildManifest.js +1 -0
- package/.next/static/chunks/{15-c0cd098235feea60.js → 15-289cb38b53bafa4a.js} +1 -1
- package/.next/static/chunks/167-9f45623d7ea7ab43.js +1 -0
- package/.next/static/chunks/174-e7df14600b457a5c.js +10 -0
- package/.next/static/chunks/201-b16b4788042ed1aa.js +1 -0
- package/.next/static/chunks/227-442963c7b630eade.js +1 -0
- package/.next/static/chunks/257-ba16dfe16a27f417.js +1 -0
- package/.next/static/chunks/260-7a7a65a3ca8539ba.js +28 -0
- package/.next/static/chunks/{292-a1cc113f5092109b.js → 292-c2888a94068fae74.js} +1 -1
- package/.next/static/chunks/382-dd7535429e16931b.js +25 -0
- package/.next/static/chunks/{400-82e564931b06011b.js → 400-ba996d76e74a7368.js} +1 -1
- package/.next/static/chunks/446-0591221372df7d49.js +4 -0
- package/.next/static/chunks/{455-3fed2dde34ca1eef.js → 455-e31becaaf948f868.js} +1 -1
- package/.next/static/chunks/492-62671486700ed3f9.js +1 -0
- package/.next/static/chunks/{517-c6a8c0e680dafa46.js → 517-f43787133528ba48.js} +1 -1
- package/.next/static/chunks/668-662b7bc81e4ad48f.js +4 -0
- package/.next/static/chunks/740-cd38299e151d3ffc.js +16 -0
- package/.next/static/chunks/841-3d29160e695d62bc.js +1 -0
- package/.next/static/chunks/851-1190cb42a0630eef.js +1 -0
- package/.next/static/chunks/{891-ff3efd43c148bd2c.js → 891-b6a172e1df7ab8c1.js} +1 -1
- package/.next/static/chunks/912-6c4e14cfeb726d91.js +11 -0
- package/.next/static/chunks/951-320008e618be7e4f.js +1 -0
- package/.next/static/chunks/958-0793922b6b146891.js +1 -0
- package/.next/static/chunks/969-8843874536e7fd83.js +1 -0
- package/.next/static/chunks/992-ea93dfa182a02a8e.js +1 -0
- package/.next/static/chunks/pages/_app-15fb8428c7126df0.js +140 -0
- package/.next/static/chunks/pages/context/{long-term-7dd213ed6aaf6901.js → long-term-9685fc1fd8397807.js} +1 -1
- package/.next/static/chunks/pages/context/{short-term-70f45e74d6778422.js → short-term-86f5d204405bb05c.js} +1 -1
- package/.next/static/chunks/pages/document-roles-1449654aa961426e.js +1 -0
- package/.next/static/chunks/pages/documents-214c9e8ba476e90b.js +1 -0
- package/.next/static/chunks/pages/guide-b1a75703238c7f77.js +1 -0
- package/.next/static/chunks/pages/knowledge/{file-detail-9a889d5cb64f568c.js → file-detail-21dbc84d04f969ca.js} +1 -1
- package/.next/static/chunks/pages/knowledge/{files-1d99abf5b4d33896.js → files-369d7ccf6a6e4e43.js} +1 -1
- package/.next/static/chunks/pages/knowledge/{manage-21b21d79b5cf4cd5.js → manage-447ce42652c203f4.js} +1 -1
- package/.next/static/chunks/pages/knowledge/{search-70a7b107d722facd.js → search-5a199ff773f7938b.js} +1 -1
- package/.next/static/chunks/pages/knowledge-81fd1e907a6fcb84.js +1 -0
- package/.next/static/chunks/pages/models-fc67c4147d2aa3cb.js +1 -0
- package/.next/static/chunks/pages/overview-558db8205a06d058.js +1 -0
- package/.next/static/chunks/pages/prompt-654d82321a383233.js +1 -0
- package/.next/static/chunks/pages/{settings-daf6d46ceb1dbd41.js → settings-88f50b9cafc389e0.js} +1 -1
- package/package.json +2 -2
- package/.next/static/TPNkWJVdxfNk1foFSh7Uw/_buildManifest.js +0 -1
- package/.next/static/chunks/129-abc5698c238befa3.js +0 -1
- package/.next/static/chunks/174-4fe307a1ae432ca3.js +0 -10
- package/.next/static/chunks/227-5d0e79ce4e00983e.js +0 -1
- package/.next/static/chunks/257-43a44acbd7b6e330.js +0 -1
- package/.next/static/chunks/260-b4f5be8cad9d5eb8.js +0 -28
- package/.next/static/chunks/425-fe4960449c1faceb.js +0 -25
- package/.next/static/chunks/446-c2604ca982998533.js +0 -4
- package/.next/static/chunks/492-764fcf49f0c198bc.js +0 -1
- package/.next/static/chunks/544-b1e7fb125bd5ba92.js +0 -1
- package/.next/static/chunks/668-ff3d8f8bff59e606.js +0 -4
- package/.next/static/chunks/740-2d2619c22f2573ad.js +0 -16
- package/.next/static/chunks/846-7f8d40514b6985f3.js +0 -1
- package/.next/static/chunks/958-ed6bd7651b040ee8.js +0 -1
- package/.next/static/chunks/969-7ca2307001c18a53.js +0 -1
- package/.next/static/chunks/992-52509d4b96af607f.js +0 -1
- package/.next/static/chunks/pages/_app-b70d02eb20e482ce.js +0 -140
- package/.next/static/chunks/pages/document-roles-8f6b20debf515131.js +0 -1
- package/.next/static/chunks/pages/documents-56ca6f45e69c19e5.js +0 -1
- package/.next/static/chunks/pages/knowledge-b3ef77e79801287c.js +0 -1
- package/.next/static/chunks/pages/models-faf86bc243e1e43a.js +0 -1
- package/.next/static/chunks/pages/overview-f7614487f399659f.js +0 -1
- package/.next/static/chunks/pages/prompt-54f8cf8df33e3c2e.js +0 -1
- /package/.next/static/{TPNkWJVdxfNk1foFSh7Uw → VXIEr9wT7-PwtFzF1Z4a2}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[893],{260:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>N});var o=n(5321),a=n(7109),i=n(6644),r=n(7807),c=n(1702),s=n(5114),l=n(6171),d=n(3442),u=n(4668),p=n(8787),y=n(4849),m=n(9400),h=n(5258),f=n(3455),g=n(9650),x=n(8209),w=n(486),S=n(3374),j=n(8383),T=n(6619),b=n(3998),C=n(6578),v=n(5551);let O={project_fact:"项目知识",user_preference:"用户偏好",feedback:"历史纠偏",pattern:"解决方案"},E={high:"red",medium:"orange",low:"default"};function N(){let e=(0,i.Vr)(),{message:t}=r.A.useApp(),[n,N]=(0,a.useState)(!0),[P,A]=(0,a.useState)([]),[k,R]=(0,a.useState)({count:0,totalBytes:0}),[J,U]=(0,a.useState)(""),[D,I]=(0,a.useState)(!1),[_,L]=(0,a.useState)(null),[z,B]=(0,a.useState)(""),[M,H]=(0,a.useState)(""),[W,F]=(0,a.useState)(!1),V=async n=>{N(!0);try{let[e,t]=await Promise.all([(0,C.hn)("long_term",n),(0,C.p)("long_term")]);A(e),R(t)}catch(n){t.error(e("common.error"))}finally{N(!1)}};(0,a.useEffect)(()=>{V()},[]);let X=async n=>{try{await (0,C.xw)(n),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},q=async()=>{try{await (0,C.PH)("long_term"),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},K=async()=>{try{await (0,C.E)("long_term"),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},Q=async()=>{if(_&&z.trim()){F(!0);try{await (0,C.zo)(_.id,{content:z.trim(),context:M||void 0}),t.success(e("common.success")),I(!1),await V(J)}catch(n){t.error(e("common.error"))}finally{F(!1)}}},Z=[{title:e("models.modelName"),dataIndex:"title",ellipsis:!0,width:180},{title:"类型",dataIndex:"type",width:90,render:e=>(0,o.jsx)(c.A,{children:O[e]||e})},{title:e("context.content"),dataIndex:"content",ellipsis:!0},{title:e("context.importance"),dataIndex:"importance",width:80,render:e=>(0,o.jsx)(c.A,{color:E[e]||"default",children:"high"===e?"高":"medium"===e?"中":"低"})},{title:e("context.source"),dataIndex:"source",width:100,ellipsis:!0},{title:e("context.updatedAt"),dataIndex:"updated_at",width:140,render:e=>e?new Date(e).toLocaleString():"-"},{title:e("common.edit"),width:100,render:(t,n)=>(0,o.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,o.jsx)(s.Ay,{size:"small",type:"text",icon:(0,o.jsx)(g.A,{}),onClick:()=>{L(n),B(n.content),H(""),I(!0)}}),(0,o.jsx)(l.A,{title:e("models.deleteProviderConfirm"),onConfirm:()=>{X(n.id)},children:(0,o.jsx)(s.Ay,{size:"small",type:"text",danger:!0,icon:(0,o.jsx)(x.A,{})})})]})}];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("nav.longTermContext")}),(0,o.jsx)("p",{className:"pageDesc",children:e("context.longTermDesc")})]}),(0,o.jsxs)(d.A,{wrap:!0,children:[(0,o.jsx)(u.A,{prefix:(0,o.jsx)(w.A,{}),placeholder:e("common.search"),value:J,onChange:e=>U(e.target.value),onPressEnter:()=>{V(J)},allowClear:!0,style:{width:240}}),(0,o.jsx)(s.Ay,{icon:(0,o.jsx)(S.A,{}),onClick:()=>{q()},children:"压缩"}),(0,o.jsx)(l.A,{title:"确定清除长期上下文吗?",onConfirm:()=>{K()},children:(0,o.jsx)(s.Ay,{danger:!0,icon:(0,o.jsx)(j.A,{}),children:"清除"})})]})]}),(0,o.jsx)(p.A,{size:"small",children:(0,o.jsx)(y.A,{title:"总上下文大小",value:(0,v.z3)(k.totalBytes),prefix:(0,o.jsx)(T.A,{}),suffix:" / ".concat(k.count," 条")})}),(0,o.jsxs)(p.A,{size:"small",children:[(0,o.jsxs)("div",{style:{marginBottom:12,color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(b.A,{})," ",e("context.longTermSource")]}),(0,o.jsx)(m.A,{rowKey:"id",columns:Z,dataSource:P,loading:n,size:"small",pagination:{pageSize:15}})]}),(0,o.jsx)(h.A,{title:e("models.editModel"),open:D,onCancel:()=>I(!1),onOk:()=>{Q()},confirmLoading:W,children:(0,o.jsxs)(f.A,{layout:"vertical",size:"middle",children:[(0,o.jsx)(f.A.Item,{label:e("context.content"),children:(0,o.jsx)(u.A.TextArea,{rows:6,value:z,onChange:e=>B(e.target.value)})}),(0,o.jsx)(f.A.Item,{label:e("context.source"),children:(0,o.jsx)(u.A,{value:M,onChange:e=>H(e.target.value),placeholder:e("context.sourceHint")})})]})})]})}},5551:(e,t,n)=>{"use strict";function o(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 a(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),o=Math.floor(n/60),a=Math.floor(o/24);return a>30?new Date(e).toLocaleDateString(t):"en-US"===t?a>0?"".concat(a,"d ago"):o>0?"".concat(o,"h ago"):n>0?"".concat(n,"m ago"):"Just now":a>0?"".concat(a," 天前"):o>0?"".concat(o," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>c,fw:()=>a,z3:()=>o});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},r={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function c(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?r:i)[e])?t:e}},6382:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/context/long-term",function(){return n(260)}])},6578:(e,t,n)=>{"use strict";async function o(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 o("/api/kb/stats".concat(t))}async function i(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)),o("/api/kb/files?".concat(a))}async function r(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),o("/api/kb/files/detail?".concat(n))}async function c(e,t){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(e,t,n){return o("/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 o=new FileReader;o.onload=()=>{let e=o.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},o.onerror=n,o.readAsDataURL(e)})}async function d(e,t,n){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:t,uploadId:n})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t))}async function y(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t),{method:"DELETE"})}async function m(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function h(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}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 x(){return o("/api/kb/features")}async function w(e,t){var n,a,i,r,c;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(c=t.limit)?c:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(a=t.weights)?void 0:a.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(i=t.weights)?void 0:i.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(r=t.weights)?void 0:r.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),o("/api/kb/search?".concat(s))}async function S(){return o("/api/prompt")}async function j(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 b(e,t){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(){return o("/api/documents/templates")}async function E(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 P(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(){return o("/api/documents/drafts")}async function J(e,t){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function U(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 D(){return o("/api/config/providers")}async function I(e,t){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function _(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function L(){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 B(){return o("/api/config/embedding")}async function M(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function W(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return o("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return o("/api/context".concat(n))}async function X(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function q(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function K(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,t){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function G(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>J,Bh:()=>G,Dl:()=>O,E:()=>K,FC:()=>F,FV:()=>b,H1:()=>g,H7:()=>y,HC:()=>c,HT:()=>i,II:()=>B,NR:()=>C,OX:()=>A,PH:()=>q,QT:()=>u,Qx:()=>p,R1:()=>k,SJ:()=>h,UE:()=>U,VW:()=>x,W2:()=>w,X8:()=>f,Z3:()=>D,_m:()=>I,aP:()=>z,bV:()=>P,bZ:()=>W,c1:()=>d,dd:()=>M,dg:()=>T,dw:()=>v,dx:()=>S,h0:()=>N,h1:()=>_,hc:()=>a,hn:()=>V,l2:()=>E,lv:()=>j,p:()=>X,q7:()=>R,tn:()=>s,u6:()=>H,xC:()=>r,xq:()=>m,xw:()=>Q,zo:()=>Z,zr:()=>L})}},e=>{e.O(0,[260,544,425,668,227,740,174,492,446,400,455,257,636,593,792],()=>e(e.s=6382)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[893],{260:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>N});var o=n(5321),a=n(7109),i=n(3014),r=n(7807),c=n(1702),s=n(5114),l=n(6171),d=n(3442),u=n(4668),p=n(8787),y=n(4849),m=n(9400),h=n(5258),f=n(3455),g=n(9650),x=n(8209),w=n(486),S=n(3374),j=n(8383),T=n(6619),b=n(3998),C=n(6578),v=n(5551);let O={project_fact:"项目知识",user_preference:"用户偏好",feedback:"历史纠偏",pattern:"解决方案"},E={high:"red",medium:"orange",low:"default"};function N(){let e=(0,i.Vr)(),{message:t}=r.A.useApp(),[n,N]=(0,a.useState)(!0),[P,A]=(0,a.useState)([]),[k,R]=(0,a.useState)({count:0,totalBytes:0}),[J,U]=(0,a.useState)(""),[D,I]=(0,a.useState)(!1),[_,L]=(0,a.useState)(null),[z,B]=(0,a.useState)(""),[M,H]=(0,a.useState)(""),[W,F]=(0,a.useState)(!1),V=async n=>{N(!0);try{let[e,t]=await Promise.all([(0,C.hn)("long_term",n),(0,C.p)("long_term")]);A(e),R(t)}catch(n){t.error(e("common.error"))}finally{N(!1)}};(0,a.useEffect)(()=>{V()},[]);let X=async n=>{try{await (0,C.xw)(n),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},q=async()=>{try{await (0,C.PH)("long_term"),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},K=async()=>{try{await (0,C.E)("long_term"),t.success(e("common.success")),await V(J)}catch(n){t.error(e("common.error"))}},Q=async()=>{if(_&&z.trim()){F(!0);try{await (0,C.zo)(_.id,{content:z.trim(),context:M||void 0}),t.success(e("common.success")),I(!1),await V(J)}catch(n){t.error(e("common.error"))}finally{F(!1)}}},Z=[{title:e("models.modelName"),dataIndex:"title",ellipsis:!0,width:180},{title:"类型",dataIndex:"type",width:90,render:e=>(0,o.jsx)(c.A,{children:O[e]||e})},{title:e("context.content"),dataIndex:"content",ellipsis:!0},{title:e("context.importance"),dataIndex:"importance",width:80,render:e=>(0,o.jsx)(c.A,{color:E[e]||"default",children:"high"===e?"高":"medium"===e?"中":"低"})},{title:e("context.source"),dataIndex:"source",width:100,ellipsis:!0},{title:e("context.updatedAt"),dataIndex:"updated_at",width:140,render:e=>e?new Date(e).toLocaleString():"-"},{title:e("common.edit"),width:100,render:(t,n)=>(0,o.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,o.jsx)(s.Ay,{size:"small",type:"text",icon:(0,o.jsx)(g.A,{}),onClick:()=>{L(n),B(n.content),H(""),I(!0)}}),(0,o.jsx)(l.A,{title:e("models.deleteProviderConfirm"),onConfirm:()=>{X(n.id)},children:(0,o.jsx)(s.Ay,{size:"small",type:"text",danger:!0,icon:(0,o.jsx)(x.A,{})})})]})}];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("nav.longTermContext")}),(0,o.jsx)("p",{className:"pageDesc",children:e("context.longTermDesc")})]}),(0,o.jsxs)(d.A,{wrap:!0,children:[(0,o.jsx)(u.A,{prefix:(0,o.jsx)(w.A,{}),placeholder:e("common.search"),value:J,onChange:e=>U(e.target.value),onPressEnter:()=>{V(J)},allowClear:!0,style:{width:240}}),(0,o.jsx)(s.Ay,{icon:(0,o.jsx)(S.A,{}),onClick:()=>{q()},children:"压缩"}),(0,o.jsx)(l.A,{title:"确定清除长期上下文吗?",onConfirm:()=>{K()},children:(0,o.jsx)(s.Ay,{danger:!0,icon:(0,o.jsx)(j.A,{}),children:"清除"})})]})]}),(0,o.jsx)(p.A,{size:"small",children:(0,o.jsx)(y.A,{title:"总上下文大小",value:(0,v.z3)(k.totalBytes),prefix:(0,o.jsx)(T.A,{}),suffix:" / ".concat(k.count," 条")})}),(0,o.jsxs)(p.A,{size:"small",children:[(0,o.jsxs)("div",{style:{marginBottom:12,color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(b.A,{})," ",e("context.longTermSource")]}),(0,o.jsx)(m.A,{rowKey:"id",columns:Z,dataSource:P,loading:n,size:"small",pagination:{pageSize:15}})]}),(0,o.jsx)(h.A,{title:e("models.editModel"),open:D,onCancel:()=>I(!1),onOk:()=>{Q()},confirmLoading:W,children:(0,o.jsxs)(f.A,{layout:"vertical",size:"middle",children:[(0,o.jsx)(f.A.Item,{label:e("context.content"),children:(0,o.jsx)(u.A.TextArea,{rows:6,value:z,onChange:e=>B(e.target.value)})}),(0,o.jsx)(f.A.Item,{label:e("context.source"),children:(0,o.jsx)(u.A,{value:M,onChange:e=>H(e.target.value),placeholder:e("context.sourceHint")})})]})})]})}},5551:(e,t,n)=>{"use strict";function o(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 a(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),o=Math.floor(n/60),a=Math.floor(o/24);return a>30?new Date(e).toLocaleDateString(t):"en-US"===t?a>0?"".concat(a,"d ago"):o>0?"".concat(o,"h ago"):n>0?"".concat(n,"m ago"):"Just now":a>0?"".concat(a," 天前"):o>0?"".concat(o," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>c,fw:()=>a,z3:()=>o});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},r={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function c(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?r:i)[e])?t:e}},6382:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/context/long-term",function(){return n(260)}])},6578:(e,t,n)=>{"use strict";async function o(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 o("/api/kb/stats".concat(t))}async function i(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)),o("/api/kb/files?".concat(a))}async function r(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),o("/api/kb/files/detail?".concat(n))}async function c(e,t){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(e,t,n){return o("/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 o=new FileReader;o.onload=()=>{let e=o.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},o.onerror=n,o.readAsDataURL(e)})}async function d(e,t,n){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:t,uploadId:n})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t))}async function y(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t),{method:"DELETE"})}async function m(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function h(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}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 x(){return o("/api/kb/features")}async function w(e,t){var n,a,i,r,c;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(c=t.limit)?c:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(a=t.weights)?void 0:a.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(i=t.weights)?void 0:i.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(r=t.weights)?void 0:r.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),o("/api/kb/search?".concat(s))}async function S(){return o("/api/prompt")}async function j(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 b(e,t){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(){return o("/api/documents/templates")}async function E(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 P(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(){return o("/api/documents/drafts")}async function J(e,t){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function U(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 D(){return o("/api/config/providers")}async function I(e,t){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function _(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function L(){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 B(){return o("/api/config/embedding")}async function M(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function W(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return o("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return o("/api/context".concat(n))}async function X(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function q(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function K(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,t){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function G(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>J,Bh:()=>G,Dl:()=>O,E:()=>K,FC:()=>F,FV:()=>b,H1:()=>g,H7:()=>y,HC:()=>c,HT:()=>i,II:()=>B,NR:()=>C,OX:()=>A,PH:()=>q,QT:()=>u,Qx:()=>p,R1:()=>k,SJ:()=>h,UE:()=>U,VW:()=>x,W2:()=>w,X8:()=>f,Z3:()=>D,_m:()=>I,aP:()=>z,bV:()=>P,bZ:()=>W,c1:()=>d,dd:()=>M,dg:()=>T,dw:()=>v,dx:()=>S,h0:()=>N,h1:()=>_,hc:()=>a,hn:()=>V,l2:()=>E,lv:()=>j,p:()=>X,q7:()=>R,tn:()=>s,u6:()=>H,xC:()=>r,xq:()=>m,xw:()=>Q,zo:()=>Z,zr:()=>L})}},e=>{e.O(0,[260,167,382,201,668,227,740,174,492,446,400,455,257,636,593,792],()=>e(e.s=6382)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[409],{1162:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var o=n(5321),a=n(7109),i=n(6644),r=n(7807),c=n(1702),s=n(5114),l=n(6171),d=n(3442),u=n(4668),p=n(8787),h=n(4849),y=n(9400),m=n(5258),f=n(3455),g=n(9650),x=n(8209),S=n(486),w=n(3374),j=n(8383),T=n(6619),b=n(3998),C=n(6578),v=n(5551);let O={high:"red",medium:"orange",low:"default"};function E(){let e=(0,i.Vr)(),{message:t}=r.A.useApp(),[n,E]=(0,a.useState)(!0),[N,P]=(0,a.useState)([]),[A,k]=(0,a.useState)({count:0,totalBytes:0}),[R,J]=(0,a.useState)(""),[U,D]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[_,z]=(0,a.useState)(""),[B,M]=(0,a.useState)(""),[H,W]=(0,a.useState)(!1),F=async n=>{E(!0);try{let[e,t]=await Promise.all([(0,C.hn)("short_term",n),(0,C.p)("short_term")]);P(e),k(t)}catch(n){t.error(e("common.error"))}finally{E(!1)}};(0,a.useEffect)(()=>{F()},[]);let V=async n=>{try{await (0,C.xw)(n),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},X=async()=>{try{await (0,C.PH)("short_term"),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},q=async()=>{try{await (0,C.E)("short_term"),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},K=async()=>{if(I&&_.trim()){W(!0);try{await (0,C.zo)(I.id,{content:_.trim(),context:B||void 0}),t.success(e("common.success")),D(!1),await F(R)}catch(n){t.error(e("common.error"))}finally{W(!1)}}},Q=[{title:e("models.modelName"),dataIndex:"title",ellipsis:!0,width:180},{title:e("context.importance"),dataIndex:"importance",width:80,render:e=>(0,o.jsx)(c.A,{color:O[e]||"default",children:"high"===e?"高":"medium"===e?"中":"低"})},{title:e("context.content"),dataIndex:"content",ellipsis:!0},{title:e("context.source"),dataIndex:"source",width:120,ellipsis:!0},{title:e("context.updatedAt"),dataIndex:"updated_at",width:140,render:e=>e?new Date(e).toLocaleString():"-"},{title:e("common.edit"),width:100,render:(t,n)=>(0,o.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,o.jsx)(s.Ay,{size:"small",type:"text",icon:(0,o.jsx)(g.A,{}),onClick:()=>{L(n),z(n.content),M(""),D(!0)}}),(0,o.jsx)(l.A,{title:e("models.deleteProviderConfirm"),onConfirm:()=>{V(n.id)},children:(0,o.jsx)(s.Ay,{size:"small",type:"text",danger:!0,icon:(0,o.jsx)(x.A,{})})})]})}];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("nav.shortTermContext")}),(0,o.jsx)("p",{className:"pageDesc",children:e("context.shortTermDesc")})]}),(0,o.jsxs)(d.A,{wrap:!0,children:[(0,o.jsx)(u.A,{prefix:(0,o.jsx)(S.A,{}),placeholder:e("common.search"),value:R,onChange:e=>J(e.target.value),onPressEnter:()=>{F(R)},allowClear:!0,style:{width:240}}),(0,o.jsx)(s.Ay,{icon:(0,o.jsx)(w.A,{}),onClick:()=>{X()},children:"压缩"}),(0,o.jsx)(l.A,{title:"确定清除短期上下文吗?",onConfirm:()=>{q()},children:(0,o.jsx)(s.Ay,{danger:!0,icon:(0,o.jsx)(j.A,{}),children:"清除"})})]})]}),(0,o.jsx)(p.A,{size:"small",children:(0,o.jsx)(h.A,{title:"总上下文大小",value:(0,v.z3)(A.totalBytes),prefix:(0,o.jsx)(T.A,{}),suffix:" / ".concat(A.count," 条")})}),(0,o.jsxs)(p.A,{size:"small",children:[(0,o.jsxs)("div",{style:{marginBottom:12,color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(b.A,{})," ",e("context.shortTermSource")]}),(0,o.jsx)(y.A,{rowKey:"id",columns:Q,dataSource:N,loading:n,size:"small",pagination:{pageSize:15}})]}),(0,o.jsx)(m.A,{title:e("models.editModel"),open:U,onCancel:()=>D(!1),onOk:()=>{K()},confirmLoading:H,children:(0,o.jsxs)(f.A,{layout:"vertical",size:"middle",children:[(0,o.jsx)(f.A.Item,{label:e("context.content"),children:(0,o.jsx)(u.A.TextArea,{rows:6,value:_,onChange:e=>z(e.target.value)})}),(0,o.jsx)(f.A.Item,{label:e("context.source"),children:(0,o.jsx)(u.A,{value:B,onChange:e=>M(e.target.value),placeholder:e("context.sourceHint")})})]})})]})}},5551:(e,t,n)=>{"use strict";function o(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 a(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),o=Math.floor(n/60),a=Math.floor(o/24);return a>30?new Date(e).toLocaleDateString(t):"en-US"===t?a>0?"".concat(a,"d ago"):o>0?"".concat(o,"h ago"):n>0?"".concat(n,"m ago"):"Just now":a>0?"".concat(a," 天前"):o>0?"".concat(o," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>c,fw:()=>a,z3:()=>o});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},r={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function c(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?r:i)[e])?t:e}},6578:(e,t,n)=>{"use strict";async function o(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 o("/api/kb/stats".concat(t))}async function i(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)),o("/api/kb/files?".concat(a))}async function r(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),o("/api/kb/files/detail?".concat(n))}async function c(e,t){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(e,t,n){return o("/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 o=new FileReader;o.onload=()=>{let e=o.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},o.onerror=n,o.readAsDataURL(e)})}async function d(e,t,n){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:t,uploadId:n})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t),{method:"DELETE"})}async function y(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function m(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}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 x(){return o("/api/kb/features")}async function S(e,t){var n,a,i,r,c;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(c=t.limit)?c:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(a=t.weights)?void 0:a.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(i=t.weights)?void 0:i.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(r=t.weights)?void 0:r.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),o("/api/kb/search?".concat(s))}async function w(){return o("/api/prompt")}async function j(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 b(e,t){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(){return o("/api/documents/templates")}async function E(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 P(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(){return o("/api/documents/drafts")}async function J(e,t){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function U(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 D(){return o("/api/config/providers")}async function I(e,t){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function L(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){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 B(){return o("/api/config/embedding")}async function M(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function W(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return o("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return o("/api/context".concat(n))}async function X(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function q(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function K(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,t){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function G(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>J,Bh:()=>G,Dl:()=>O,E:()=>K,FC:()=>F,FV:()=>b,H1:()=>g,H7:()=>h,HC:()=>c,HT:()=>i,II:()=>B,NR:()=>C,OX:()=>A,PH:()=>q,QT:()=>u,Qx:()=>p,R1:()=>k,SJ:()=>m,UE:()=>U,VW:()=>x,W2:()=>S,X8:()=>f,Z3:()=>D,_m:()=>I,aP:()=>z,bV:()=>P,bZ:()=>W,c1:()=>d,dd:()=>M,dg:()=>T,dw:()=>v,dx:()=>w,h0:()=>N,h1:()=>L,hc:()=>a,hn:()=>V,l2:()=>E,lv:()=>j,p:()=>X,q7:()=>R,tn:()=>s,u6:()=>H,xC:()=>r,xq:()=>y,xw:()=>Q,zo:()=>Z,zr:()=>_})},9164:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/context/short-term",function(){return n(1162)}])}},e=>{e.O(0,[260,544,425,668,227,740,174,492,446,400,455,257,636,593,792],()=>e(e.s=9164)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[409],{1162:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var o=n(5321),a=n(7109),i=n(3014),r=n(7807),c=n(1702),s=n(5114),l=n(6171),d=n(3442),u=n(4668),p=n(8787),h=n(4849),y=n(9400),m=n(5258),f=n(3455),g=n(9650),x=n(8209),S=n(486),w=n(3374),j=n(8383),T=n(6619),b=n(3998),C=n(6578),v=n(5551);let O={high:"red",medium:"orange",low:"default"};function E(){let e=(0,i.Vr)(),{message:t}=r.A.useApp(),[n,E]=(0,a.useState)(!0),[N,P]=(0,a.useState)([]),[A,k]=(0,a.useState)({count:0,totalBytes:0}),[R,J]=(0,a.useState)(""),[U,D]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[_,z]=(0,a.useState)(""),[B,M]=(0,a.useState)(""),[H,W]=(0,a.useState)(!1),F=async n=>{E(!0);try{let[e,t]=await Promise.all([(0,C.hn)("short_term",n),(0,C.p)("short_term")]);P(e),k(t)}catch(n){t.error(e("common.error"))}finally{E(!1)}};(0,a.useEffect)(()=>{F()},[]);let V=async n=>{try{await (0,C.xw)(n),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},X=async()=>{try{await (0,C.PH)("short_term"),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},q=async()=>{try{await (0,C.E)("short_term"),t.success(e("common.success")),await F(R)}catch(n){t.error(e("common.error"))}},K=async()=>{if(I&&_.trim()){W(!0);try{await (0,C.zo)(I.id,{content:_.trim(),context:B||void 0}),t.success(e("common.success")),D(!1),await F(R)}catch(n){t.error(e("common.error"))}finally{W(!1)}}},Q=[{title:e("models.modelName"),dataIndex:"title",ellipsis:!0,width:180},{title:e("context.importance"),dataIndex:"importance",width:80,render:e=>(0,o.jsx)(c.A,{color:O[e]||"default",children:"high"===e?"高":"medium"===e?"中":"低"})},{title:e("context.content"),dataIndex:"content",ellipsis:!0},{title:e("context.source"),dataIndex:"source",width:120,ellipsis:!0},{title:e("context.updatedAt"),dataIndex:"updated_at",width:140,render:e=>e?new Date(e).toLocaleString():"-"},{title:e("common.edit"),width:100,render:(t,n)=>(0,o.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,o.jsx)(s.Ay,{size:"small",type:"text",icon:(0,o.jsx)(g.A,{}),onClick:()=>{L(n),z(n.content),M(""),D(!0)}}),(0,o.jsx)(l.A,{title:e("models.deleteProviderConfirm"),onConfirm:()=>{V(n.id)},children:(0,o.jsx)(s.Ay,{size:"small",type:"text",danger:!0,icon:(0,o.jsx)(x.A,{})})})]})}];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("nav.shortTermContext")}),(0,o.jsx)("p",{className:"pageDesc",children:e("context.shortTermDesc")})]}),(0,o.jsxs)(d.A,{wrap:!0,children:[(0,o.jsx)(u.A,{prefix:(0,o.jsx)(S.A,{}),placeholder:e("common.search"),value:R,onChange:e=>J(e.target.value),onPressEnter:()=>{F(R)},allowClear:!0,style:{width:240}}),(0,o.jsx)(s.Ay,{icon:(0,o.jsx)(w.A,{}),onClick:()=>{X()},children:"压缩"}),(0,o.jsx)(l.A,{title:"确定清除短期上下文吗?",onConfirm:()=>{q()},children:(0,o.jsx)(s.Ay,{danger:!0,icon:(0,o.jsx)(j.A,{}),children:"清除"})})]})]}),(0,o.jsx)(p.A,{size:"small",children:(0,o.jsx)(h.A,{title:"总上下文大小",value:(0,v.z3)(A.totalBytes),prefix:(0,o.jsx)(T.A,{}),suffix:" / ".concat(A.count," 条")})}),(0,o.jsxs)(p.A,{size:"small",children:[(0,o.jsxs)("div",{style:{marginBottom:12,color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(b.A,{})," ",e("context.shortTermSource")]}),(0,o.jsx)(y.A,{rowKey:"id",columns:Q,dataSource:N,loading:n,size:"small",pagination:{pageSize:15}})]}),(0,o.jsx)(m.A,{title:e("models.editModel"),open:U,onCancel:()=>D(!1),onOk:()=>{K()},confirmLoading:H,children:(0,o.jsxs)(f.A,{layout:"vertical",size:"middle",children:[(0,o.jsx)(f.A.Item,{label:e("context.content"),children:(0,o.jsx)(u.A.TextArea,{rows:6,value:_,onChange:e=>z(e.target.value)})}),(0,o.jsx)(f.A.Item,{label:e("context.source"),children:(0,o.jsx)(u.A,{value:B,onChange:e=>M(e.target.value),placeholder:e("context.sourceHint")})})]})})]})}},5551:(e,t,n)=>{"use strict";function o(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 a(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),o=Math.floor(n/60),a=Math.floor(o/24);return a>30?new Date(e).toLocaleDateString(t):"en-US"===t?a>0?"".concat(a,"d ago"):o>0?"".concat(o,"h ago"):n>0?"".concat(n,"m ago"):"Just now":a>0?"".concat(a," 天前"):o>0?"".concat(o," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>c,fw:()=>a,z3:()=>o});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},r={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function c(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?r:i)[e])?t:e}},6578:(e,t,n)=>{"use strict";async function o(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 o("/api/kb/stats".concat(t))}async function i(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)),o("/api/kb/files?".concat(a))}async function r(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),o("/api/kb/files/detail?".concat(n))}async function c(e,t){return o("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(e,t,n){return o("/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 o=new FileReader;o.onload=()=>{let e=o.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},o.onerror=n,o.readAsDataURL(e)})}async function d(e,t,n){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:t,uploadId:n})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t))}async function h(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t),{method:"DELETE"})}async function y(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function m(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}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 x(){return o("/api/kb/features")}async function S(e,t){var n,a,i,r,c;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(c=t.limit)?c:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(a=t.weights)?void 0:a.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(i=t.weights)?void 0:i.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(r=t.weights)?void 0:r.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),o("/api/kb/search?".concat(s))}async function w(){return o("/api/prompt")}async function j(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 b(e,t){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(){return o("/api/documents/templates")}async function E(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 P(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function A(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(){return o("/api/documents/drafts")}async function J(e,t){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function U(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 D(){return o("/api/config/providers")}async function I(e,t){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function L(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){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 B(){return o("/api/config/embedding")}async function M(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function W(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return o("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return o("/api/context".concat(n))}async function X(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function q(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function K(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,t){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function G(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>J,Bh:()=>G,Dl:()=>O,E:()=>K,FC:()=>F,FV:()=>b,H1:()=>g,H7:()=>h,HC:()=>c,HT:()=>i,II:()=>B,NR:()=>C,OX:()=>A,PH:()=>q,QT:()=>u,Qx:()=>p,R1:()=>k,SJ:()=>m,UE:()=>U,VW:()=>x,W2:()=>S,X8:()=>f,Z3:()=>D,_m:()=>I,aP:()=>z,bV:()=>P,bZ:()=>W,c1:()=>d,dd:()=>M,dg:()=>T,dw:()=>v,dx:()=>w,h0:()=>N,h1:()=>L,hc:()=>a,hn:()=>V,l2:()=>E,lv:()=>j,p:()=>X,q7:()=>R,tn:()=>s,u6:()=>H,xC:()=>r,xq:()=>y,xw:()=>Q,zo:()=>Z,zr:()=>_})},9164:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/context/short-term",function(){return n(1162)}])}},e=>{e.O(0,[260,167,382,201,668,227,740,174,492,446,400,455,257,636,593,792],()=>e(e.s=9164)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[623],{2256:(e,n,t)=>{"use strict";t.d(n,{A:()=>o});let o=t(5341).A},3507:(e,n,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/document-roles",function(){return t(9889)}])},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 r(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 s(e,n){let t=new URLSearchParams({relativePath:e});return n&&t.set("projectRoot",n),o("/api/kb/files/detail?".concat(t))}async function a(e,n){return o("/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 o("/api/kb/files/open",{method:"POST",body:JSON.stringify({relativePath:e,target:n,projectRoot:t})})}async function c(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 c(e),relativePath:e.webkitRelativePath||void 0}))),projectRoot:n,uploadId:t})})}async function p(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function u(e){let n=new URLSearchParams({limit:"50"});return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n))}async function m(e){let n=new URLSearchParams;return e&&n.set("projectRoot",e),o("/api/kb/operations?".concat(n),{method:"DELETE"})}async function y(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 x(e){return o("/api/kb/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectRoot:e})})}async function j(){return o("/api/kb/features")}async function g(e,n){var t,i,r,s,a;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!=(a=n.limit)?a:20)),(null==n||null==(t=n.weights)?void 0:t.keyword)!=null&&l.set("keywordWeight",String(n.weights.keyword)),(null==n||null==(i=n.weights)?void 0:i.vector)!=null&&l.set("vectorWeight",String(n.weights.vector)),(null==n||null==(r=n.weights)?void 0:r.rewrite)!=null&&l.set("rewriteWeight",String(n.weights.rewrite)),(null==n||null==(s=n.weights)?void 0:s.hybridBonus)!=null&&l.set("hybridBonus",String(n.weights.hybridBonus)),o("/api/kb/search?".concat(l))}async function A(){return o("/api/prompt")}async function b(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 v(e,n){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(n)),{method:"DELETE"})}async function w(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function S(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function C(){return o("/api/documents/templates")}async function R(e){return o("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function I(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function N(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(){return o("/api/documents/drafts")}async function P(e,n){return o("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:n})})}async function J(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 U(){return o("/api/config/providers")}async function F(e,n){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...n})})}async function D(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function L(){return o("/api/config/models")}async function _(e){return o("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function q(){return o("/api/config/embedding")}async function V(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function W(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function B(){return o("/api/system/stats")}async function X(e,n){let t=n?"?type=".concat(e,"&search=").concat(encodeURIComponent(n)):"?type=".concat(e);return o("/api/context".concat(t))}async function z(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function G(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function M(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,n){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...n})})}async function K(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}t.d(n,{Af:()=>P,Bh:()=>K,Dl:()=>C,E:()=>M,FC:()=>B,FV:()=>v,H1:()=>x,H7:()=>m,HC:()=>a,HT:()=>r,II:()=>q,NR:()=>w,OX:()=>N,PH:()=>G,QT:()=>p,Qx:()=>u,R1:()=>O,SJ:()=>h,UE:()=>J,VW:()=>j,W2:()=>g,X8:()=>f,Z3:()=>U,_m:()=>F,aP:()=>_,bV:()=>I,bZ:()=>W,c1:()=>d,dd:()=>V,dg:()=>T,dw:()=>S,dx:()=>A,h0:()=>k,h1:()=>D,hc:()=>i,hn:()=>X,l2:()=>R,lv:()=>b,p:()=>z,q7:()=>E,tn:()=>l,u6:()=>H,xC:()=>s,xq:()=>y,xw:()=>Q,zo:()=>Z,zr:()=>L})},8770:(e,n,t)=>{"use strict";t.d(n,{A:()=>o});let o=t(1916).A},9889:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>S});var o=t(5321),i=t(7109),r=t(7807),s=t(3455),a=t(8332),l=t(4253),c=t(5114),d=t(6171),p=t(3442),u=t(1702),m=t(8787),y=t(2256),h=t(8770),f=t(5258),x=t(7271),j=t(4668),g=t(8569),A=t(9650),b=t(8209),T=t(4746),v=t(6578),w=t(3014);function S(){let e=(0,w.Vr)(),{message:n}=r.A.useApp(),[t]=s.A.useForm(),[S]=s.A.useForm(),[C,R]=(0,i.useState)([]),[k,I]=(0,i.useState)([]),[N,O]=(0,i.useState)([]),[E,P]=(0,i.useState)([]),[J,U]=(0,i.useState)(!1),[F,D]=(0,i.useState)(!1),L=async()=>{let[e,n,t]=await Promise.all([(0,v.lv)(),(0,v.HT)(),(0,v.dx)()]);R(e.roles),I(e.configs),O(n.files),P(t)};(0,i.useEffect)(()=>{L().catch(()=>n.error(e("common.error")))},[n,e]);let _=C.filter(e=>"file"===e.type),q=C.filter(e=>"prompt"===e.type),V=async()=>{try{let o=await t.validateFields(),i=await (0,v.dg)(o);R(i.roles),I(i.configs),U(!1),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}},H=async()=>{try{let t=await S.validateFields(),o=e=>(null!=e?e:[]).map((e,n)=>{var t;return{roleId:e.roleId,order:Number(null!=(t=e.order)?t:n)}}),i=await (0,v.NR)({...t,fileRoles:o(t.fileRoles),promptRoles:o(t.promptRoles)});R(i.roles),I(i.configs),D(!1),n.success(e("common.success"))}catch(t){n.error(e("common.error"))}},W=async e=>{let n=await (0,v.FV)(e.type,e.id);R(n.roles),I(n.configs)},B=async e=>{let n=await (0,v.dw)(e);R(n.roles),I(n.configs)},X=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"file";t.setFieldsValue(null!=e?e:{id:"role-".concat(Date.now()),name:"",description:"",type:n,executionType:"prompt"===n?"reference":void 0,processingType:"file"===n?"reference":void 0}),U(!0)},z=e=>{S.setFieldsValue(null!=e?e:{id:"config-".concat(Date.now()),name:"",description:"",fileRoles:[],promptRoles:[]}),D(!0)},G=n=>(0,o.jsx)(a.A,{dataSource:C.filter(e=>e.type===n),locale:{emptyText:(0,o.jsx)(l.A,{description:e("common.noData")})},renderItem:n=>(0,o.jsx)(a.A.Item,{actions:[(0,o.jsx)(c.Ay,{type:"text",icon:(0,o.jsx)(A.A,{}),onClick:()=>X(n)},"edit"),(0,o.jsx)(d.A,{title:e("common.confirm"),onConfirm:()=>{W(n)},children:(0,o.jsx)(c.Ay,{type:"text",danger:!0,icon:(0,o.jsx)(b.A,{})})},"delete")],children:(0,o.jsx)(a.A.Item.Meta,{title:(0,o.jsxs)(p.A,{children:[n.name,(0,o.jsx)(u.A,{children:n.id})]}),description:(0,o.jsxs)(p.A,{direction:"vertical",children:[(0,o.jsx)("span",{children:n.description}),(0,o.jsx)("span",{children:"prompt"===n.type?n.executionType:n.processingType}),(0,o.jsx)("span",{children:n.resourceId||"-"})]})})})});return(0,o.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,o.jsx)(m.A,{className:"cardGlass",styles:{body:{padding:24}},children:(0,o.jsxs)("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle mb-1",children:e("roles.title")}),(0,o.jsx)("p",{className:"pageDesc mb-0",children:e("roles.description")})]}),(0,o.jsxs)(p.A,{children:[(0,o.jsx)(c.Ay,{icon:(0,o.jsx)(T.A,{}),onClick:()=>X(void 0,"file"),children:e("roles.newFileRole")}),(0,o.jsx)(c.Ay,{icon:(0,o.jsx)(T.A,{}),onClick:()=>X(void 0,"prompt"),children:e("roles.newPromptRole")}),(0,o.jsx)(c.Ay,{type:"primary",icon:(0,o.jsx)(T.A,{}),onClick:()=>z(),children:e("roles.newConfig")})]})]})}),(0,o.jsxs)(y.A,{gutter:[16,16],children:[(0,o.jsx)(h.A,{xs:24,lg:12,children:(0,o.jsx)(m.A,{title:e("roles.fileRoles"),children:G("file")})}),(0,o.jsx)(h.A,{xs:24,lg:12,children:(0,o.jsx)(m.A,{title:e("roles.promptRoles"),children:G("prompt")})}),(0,o.jsx)(h.A,{xs:24,children:(0,o.jsx)(m.A,{title:e("roles.configs"),children:(0,o.jsx)(a.A,{dataSource:k,locale:{emptyText:(0,o.jsx)(l.A,{description:e("common.noData")})},renderItem:n=>(0,o.jsx)(a.A.Item,{actions:[(0,o.jsx)(c.Ay,{type:"text",icon:(0,o.jsx)(A.A,{}),onClick:()=>z(n)},"edit"),(0,o.jsx)(d.A,{title:e("common.confirm"),onConfirm:()=>{B(n.id)},children:(0,o.jsx)(c.Ay,{type:"text",danger:!0,icon:(0,o.jsx)(b.A,{})})},"delete")],children:(0,o.jsx)(a.A.Item.Meta,{title:(0,o.jsxs)(p.A,{children:[n.name,(0,o.jsx)(u.A,{children:n.id})]}),description:"".concat(e("roles.fileRoles"),": ").concat(n.fileRoles.length," \xb7 ").concat(e("roles.promptRoles"),": ").concat(n.promptRoles.length)})})})})})]}),(0,o.jsx)(f.A,{title:e("roles.roleEditor"),open:J,onOk:()=>{V()},onCancel:()=>U(!1),centered:!0,okText:e("common.save"),children:(0,o.jsxs)(s.A,{form:t,layout:"vertical",children:[(0,o.jsx)(s.A.Item,{name:"type",label:e("roles.roleType"),rules:[{required:!0}],children:(0,o.jsx)(x.A,{options:[{label:e("roles.fileRole"),value:"file"},{label:e("roles.promptRole"),value:"prompt"}]})}),(0,o.jsx)(s.A.Item,{name:"id",label:"ID",rules:[{required:!0}],children:(0,o.jsx)(j.A,{disabled:!0})}),(0,o.jsx)(s.A.Item,{name:"name",label:e("roles.roleName"),rules:[{required:!0}],children:(0,o.jsx)(j.A,{})}),(0,o.jsx)(s.A.Item,{name:"description",label:e("roles.roleDescription"),children:(0,o.jsx)(j.A,{})}),(0,o.jsx)(s.A.Item,{noStyle:!0,shouldUpdate:(e,n)=>e.type!==n.type,children:n=>{let{getFieldValue:t}=n;return"prompt"===t("type")?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.A.Item,{name:"executionType",label:e("roles.executionType"),rules:[{required:!0}],children:(0,o.jsx)(x.A,{options:[{label:e("roles.factExtraction"),value:"fact_extraction"},{label:e("roles.chapterGeneration"),value:"chapter_generation"},{label:e("roles.validation"),value:"validation"},{label:e("roles.formatting"),value:"formatting"},{label:e("roles.reference"),value:"reference"}]})}),(0,o.jsx)(s.A.Item,{name:"resourceId",label:e("roles.bindPrompt"),children:(0,o.jsx)(x.A,{showSearch:!0,options:E.filter(e=>e.hasFile).map(e=>({label:e.projectName,value:e.id}))})})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.A.Item,{name:"processingType",label:e("roles.processingType"),rules:[{required:!0}],children:(0,o.jsx)(x.A,{options:[{label:e("roles.ruleFile"),value:"rule"},{label:e("roles.projectFactFile"),value:"project_fact"},{label:e("roles.tableFile"),value:"table"},{label:e("roles.drawingFile"),value:"drawing"},{label:e("roles.specificationFile"),value:"specification"},{label:e("roles.reference"),value:"reference"}]})}),(0,o.jsx)(s.A.Item,{name:"resourceId",label:e("roles.bindFile"),children:(0,o.jsx)(x.A,{showSearch:!0,options:N.map(e=>({label:e.relativePath,value:e.relativePath}))})})]})}})]})}),(0,o.jsx)(f.A,{title:e("roles.configEditor"),open:F,onOk:()=>{H()},onCancel:()=>D(!1),width:820,centered:!0,okText:e("common.save"),children:(0,o.jsxs)(s.A,{form:S,layout:"vertical",children:[(0,o.jsxs)(y.A,{gutter:12,children:[(0,o.jsx)(h.A,{span:8,children:(0,o.jsx)(s.A.Item,{name:"id",label:"ID",rules:[{required:!0}],children:(0,o.jsx)(j.A,{disabled:!0})})}),(0,o.jsx)(h.A,{span:8,children:(0,o.jsx)(s.A.Item,{name:"name",label:e("roles.configName"),rules:[{required:!0}],children:(0,o.jsx)(j.A,{})})}),(0,o.jsx)(h.A,{span:8,children:(0,o.jsx)(s.A.Item,{name:"description",label:e("roles.configDescription"),children:(0,o.jsx)(j.A,{})})})]}),(0,o.jsx)(g.A,{items:[{key:"file",label:e("roles.fileRoles"),children:(0,o.jsx)(s.A.List,{name:"fileRoles",children:(n,t)=>{let{add:i,remove:r}=t;return(0,o.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[n.map((e,n)=>(0,o.jsxs)(y.A,{gutter:8,children:[(0,o.jsx)(h.A,{span:16,children:(0,o.jsx)(s.A.Item,{name:[e.name,"roleId"],rules:[{required:!0}],children:(0,o.jsx)(x.A,{options:_.map(e=>({label:e.name,value:e.id}))})})}),(0,o.jsx)(h.A,{span:6,children:(0,o.jsx)(s.A.Item,{name:[e.name,"order"],initialValue:n,children:(0,o.jsx)(j.A,{type:"number"})})}),(0,o.jsx)(h.A,{span:2,children:(0,o.jsx)(c.Ay,{danger:!0,onClick:()=>r(e.name),children:"-"})})]},e.key)),(0,o.jsx)(c.Ay,{onClick:()=>i({order:n.length}),children:e("roles.addRole")})]})}})},{key:"prompt",label:e("roles.promptRoles"),children:(0,o.jsx)(s.A.List,{name:"promptRoles",children:(n,t)=>{let{add:i,remove:r}=t;return(0,o.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[n.map((e,n)=>(0,o.jsxs)(y.A,{gutter:8,children:[(0,o.jsx)(h.A,{span:16,children:(0,o.jsx)(s.A.Item,{name:[e.name,"roleId"],rules:[{required:!0}],children:(0,o.jsx)(x.A,{options:q.map(e=>({label:e.name,value:e.id}))})})}),(0,o.jsx)(h.A,{span:6,children:(0,o.jsx)(s.A.Item,{name:[e.name,"order"],initialValue:n,children:(0,o.jsx)(j.A,{type:"number"})})}),(0,o.jsx)(h.A,{span:2,children:(0,o.jsx)(c.Ay,{danger:!0,onClick:()=>r(e.name),children:"-"})})]},e.key)),(0,o.jsx)(c.Ay,{onClick:()=>i({order:n.length}),children:e("roles.addRole")})]})}})}]})]})})]})}}},e=>{e.O(0,[260,167,382,201,668,227,740,174,492,455,951,636,593,792],()=>e(e.s=3507)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[298],{1307:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"}},1699:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>M});var o=n(5321),s=n(7109),i=n(4668),a=n(5292),r=n(7807),c=n(3455),l=n(8787),d=n(5114),u=n(2256),p=n(8770),m=n(8332),h=n(4253),f=n(6171),y=n(3442),g=n(1702),j=n(7271),x=n(1019),A=n(8569),w=n(5258),b=n(4746),v=n(3051),S=n(9650),k=n(8209),C=n(6631),T=n(9071),I=n(1307),O=n(8483);function R(){return(R=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let E=s.forwardRef((e,t)=>s.createElement(O.A,R({},e,{ref:t,icon:I.A})));var P=n(6398);function N(){return(N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let z=s.forwardRef((e,t)=>s.createElement(O.A,N({},e,{ref:t,icon:P.A})));var D=n(2192),L=n(6578),U=n(3014);let{TextArea:J}=i.A,{Paragraph:H}=a.A;function M(){var e,t;let n=(0,U.Vr)(),{message:a}=r.A.useApp(),[I]=c.A.useForm(),[O,R]=(0,s.useState)([]),[P,N]=(0,s.useState)("construction-organization-design"),[M,V]=(0,s.useState)([]),[F,_]=(0,s.useState)([]),[G,q]=(0,s.useState)(!1),[B,W]=(0,s.useState)(null),[X,Q]=(0,s.useState)(""),[Z,K]=(0,s.useState)([]),[Y,$]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[en,eo]=(0,s.useState)(!1),[es,ei]=(0,s.useState)([]),[ea,er]=(0,s.useState)(null),ec=async()=>{try{K((await (0,L.q7)()).drafts)}catch(e){K([])}};(0,s.useEffect)(()=>{(0,L.Dl)().then(e=>{var t,n;R(e.templates),N(null!=(n=null==(t=e.templates[0])?void 0:t.id)?n:"construction-organization-design")}).catch(()=>a.error(n("common.error"))),(0,L.lv)().then(e=>{V(e.roles),_(e.configs)}).catch(()=>{V([]),_([])}),ec()},[a,n]);let el=(0,s.useMemo)(()=>O.find(e=>e.id===P),[O,P]),ed=F.map(e=>({label:e.name,value:e.id})),eu=Math.max(0,es.findIndex(e=>e.key===ea)),ep=(e,t,n)=>{er(e),ei(o=>o.map(o=>o.key===e?{...o,status:t,description:n||o.description}:o))},em=e=>{ei(t=>{let n=t.findIndex(t=>t.key===e);return t.map((e,t)=>t<n&&"error"!==e.status?{...e,status:"finish"}:e)})},eh=e=>{I.setFieldsValue(null!=e?e:{id:"custom-template-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[]}),eo(!0)},ef=async()=>{try{let e=await I.validateFields(),t=await (0,L.l2)(e);R(t.templates),N(t.template.id),eo(!1),a.success(n("common.success"))}catch(e){e instanceof Error&&a.error(e.message)}},ey=async e=>{try{let t=await (0,L.bV)(e);R(t.templates),N(t.template.id),a.success(n("common.success"))}catch(e){a.error(n("common.error"))}},eg=async e=>{try{var t,o;let s=await (0,L.h0)(e);R(s.templates),N(null!=(o=null==(t=s.templates[0])?void 0:t.id)?o:""),a.success(n("common.success"))}catch(e){a.error(n("common.error"))}},ej=async()=>{if(!P)return;q(!0),ei([{key:"prepare",title:n("documents.flowPrepare"),description:n("documents.flowPrepareDesc"),status:"process"},{key:"fact_extraction",title:n("documents.flowFactExtraction"),description:n("documents.flowFactExtractionDesc"),status:"wait"},{key:"chapter_generation",title:n("documents.flowChapterGeneration"),description:n("documents.flowChapterGenerationDesc"),status:"wait"},{key:"validation",title:n("documents.flowValidation"),description:n("documents.flowValidationDesc"),status:"wait"},{key:"formatting",title:n("documents.flowFormatting"),description:n("documents.flowFormattingDesc"),status:"wait"},{key:"done",title:n("documents.flowDone"),description:n("documents.flowDoneDesc"),status:"wait"}]),er("prepare");let e=[window.setTimeout(()=>{em("fact_extraction"),ep("fact_extraction","process")},600),window.setTimeout(()=>{em("chapter_generation"),ep("chapter_generation","process")},1800),window.setTimeout(()=>{em("validation"),ep("validation","process")},3200),window.setTimeout(()=>{em("formatting"),ep("formatting","process")},4600)];try{let e=await (0,L.OX)({templateId:P});W(e.draft),Q(e.draft.markdown),ei(t=>t.map(t=>{let o=e.draft.executionStages.find(e=>e.type===t.key);return"prepare"===t.key?{...t,status:"finish",description:n("documents.flowPrepareDone")}:"done"===t.key?{...t,status:e.draft.exportGate.passed?"finish":"error",description:e.draft.exportGate.passed?n("documents.flowDoneDesc"):n("documents.flowGateFailed")}:o?{...t,status:"failed"===o.status?"error":"finish",description:o.message||t.description}:"process"===t.status?{...t,status:"finish"}:t})),er("done"),a.success(n("common.success"))}catch(e){ei(t=>t.map(t=>"process"===t.status?{...t,status:"error",description:e instanceof Error?e.message:n("common.error")}:t)),a.error(e instanceof Error?e.message:n("common.error"))}finally{e.forEach(e=>window.clearTimeout(e)),q(!1)}},ex=async e=>{if(B){$(!0);try{var t=await (0,L.UE)({title:B.title,markdown:X,format:e,enforceGate:"pdf"===e,exportGate:B.exportGate}),o="".concat(B.title,".").concat("markdown"===e?"md":e);let n=URL.createObjectURL(t),s=document.createElement("a");s.href=n,s.download=o,s.click(),URL.revokeObjectURL(n)}catch(e){a.error(n("common.error"))}finally{$(!1)}}},eA=async()=>{if(B)try{let e=await (0,L.Af)({...B,markdown:X});W(e.draft),await ec(),a.success(n("common.success"))}catch(e){a.error(n("common.error"))}},ew=async e=>{if(B){et(e.id);try{var t;let o=await (0,L.R1)({templateId:B.templateId,chapterId:e.id}),s=B.chapters.map(t=>t.id===e.id?o.chapter:t);W({...B,chapters:s}),t=o.chapter,Q(n=>n.includes(e.content)?n.replace(e.content,t.content):"".concat(n,"\n\n").concat(t.content)),a.success(n("common.success"))}catch(e){a.error(n("common.error"))}finally{et(null)}}};return(0,o.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,o.jsx)(l.A,{className:"cardGlass",styles:{body:{padding:24}},children:(0,o.jsxs)("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle mb-1",children:n("documents.title")}),(0,o.jsx)("p",{className:"pageDesc mb-0",children:n("documents.description")})]}),(0,o.jsx)(d.Ay,{type:"primary",size:"large",icon:(0,o.jsx)(b.A,{}),onClick:()=>eh(),children:n("documents.newTemplate")})]})}),(0,o.jsxs)(u.A,{gutter:[16,16],align:"top",children:[(0,o.jsxs)(p.A,{xs:24,lg:8,children:[(0,o.jsx)(l.A,{size:"small",title:n("documents.templateLibrary"),children:(0,o.jsx)(m.A,{dataSource:O,locale:{emptyText:(0,o.jsx)(h.A,{description:n("common.noData")})},renderItem:e=>(0,o.jsx)(m.A.Item,{onClick:()=>N(e.id),className:"cursor-pointer",actions:[(0,o.jsx)(d.Ay,{size:"small",type:"text",icon:(0,o.jsx)(v.A,{}),onClick:t=>{t.stopPropagation(),ey(e.id)}},"copy"),(0,o.jsx)(d.Ay,{size:"small",type:"text",icon:(0,o.jsx)(S.A,{}),disabled:e.builtIn,onClick:t=>{t.stopPropagation(),eh(e)}},"edit"),(0,o.jsx)(f.A,{title:n("documents.deleteTemplateConfirm"),disabled:e.builtIn,onConfirm:t=>{null==t||t.stopPropagation(),eg(e.id)},children:(0,o.jsx)(d.Ay,{size:"small",type:"text",danger:!0,icon:(0,o.jsx)(k.A,{}),disabled:e.builtIn,onClick:e=>e.stopPropagation()})},"delete")],children:(0,o.jsx)(m.A.Item.Meta,{avatar:(0,o.jsx)(C.A,{}),title:(0,o.jsxs)(y.A,{children:[(0,o.jsx)("span",{children:e.name}),e.builtIn&&(0,o.jsx)(g.A,{children:n("documents.builtIn")}),P===e.id&&(0,o.jsx)(g.A,{color:"blue",children:n("documents.selected")})]}),description:(0,o.jsxs)(y.A,{direction:"vertical",size:2,children:[(0,o.jsx)("span",{children:e.description}),(0,o.jsx)(g.A,{children:e.category})]})})})})}),(0,o.jsx)(l.A,{className:"mt-4",size:"small",title:n("documents.draftHistory"),children:(0,o.jsx)(m.A,{size:"small",dataSource:Z.slice(0,8),locale:{emptyText:(0,o.jsx)(h.A,{description:n("common.noData")})},renderItem:e=>(0,o.jsx)(m.A.Item,{onClick:()=>{W(e),Q(e.markdown),N(e.templateId)},className:"cursor-pointer",children:(0,o.jsx)(m.A.Item.Meta,{title:e.title,description:new Date(e.updatedAt).toLocaleString()})})})})]}),(0,o.jsx)(p.A,{xs:24,lg:16,children:(0,o.jsx)(l.A,{size:"small",title:n("documents.workflow"),children:(0,o.jsxs)(y.A,{direction:"vertical",className:"w-full",size:"middle",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"block mb-1",children:n("documents.template")}),(0,o.jsx)(j.A,{className:"w-full",value:P,onChange:N,options:O.map(e=>({label:e.name,value:e.id}))})]}),el&&(0,o.jsxs)(l.A,{size:"small",type:"inner",title:el.outputTitle,children:[(0,o.jsx)(H,{children:el.description}),(0,o.jsx)(y.A,{wrap:!0,children:el.projectRoleConfigId?(0,o.jsx)(g.A,{color:"geekblue",children:(null==(e=F.find(e=>e.id===el.projectRoleConfigId))?void 0:e.name)||el.projectRoleConfigId}):(0,o.jsx)(g.A,{color:"warning",children:n("documents.noRoleConfig")})})]}),el&&(0,o.jsx)(y.A,{direction:"vertical",size:4,children:(0,o.jsxs)("span",{children:[n("documents.projectRoleConfig"),": ",(null==(t=F.find(e=>e.id===el.projectRoleConfigId))?void 0:t.name)||n("documents.noRoleConfig")]})}),(0,o.jsx)(d.Ay,{type:"primary",size:"large",block:!0,icon:(0,o.jsx)(T.A,{}),loading:G,disabled:!(null==el?void 0:el.projectRoleConfigId),onClick:()=>{ej()},children:n("documents.generate")}),es.length>0&&(0,o.jsx)(l.A,{size:"small",type:"inner",title:n("documents.executionStatus"),children:(0,o.jsx)(x.A,{direction:"vertical",size:"small",current:eu,items:es.map(e=>({title:e.title,description:e.description,status:e.status}))})})]})})})]}),(0,o.jsx)(l.A,{size:"small",title:n("documents.editor"),extra:(0,o.jsx)(y.A,{wrap:!0,children:B&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d.Ay,{icon:(0,o.jsx)(E,{}),onClick:()=>{eA()},children:n("documents.saveDraft")}),(0,o.jsx)(d.Ay,{icon:(0,o.jsx)(z,{}),loading:Y,onClick:()=>{ex("markdown")},children:n("documents.downloadMarkdown")}),(0,o.jsx)(d.Ay,{loading:Y,onClick:()=>{ex("html")},children:n("documents.exportHtml")}),(0,o.jsx)(d.Ay,{type:"primary",loading:Y,onClick:()=>{ex("pdf")},children:n("documents.exportPdf")})]})}),children:B?(0,o.jsx)(A.A,{items:[{key:"edit",label:n("documents.edit"),children:(0,o.jsx)(J,{rows:26,value:X,onChange:e=>Q(e.target.value)})},{key:"chapters",label:n("documents.chapters"),children:(0,o.jsx)(m.A,{dataSource:B.chapters,renderItem:e=>(0,o.jsx)(m.A.Item,{actions:[(0,o.jsx)(d.Ay,{size:"small",icon:(0,o.jsx)(D.A,{}),loading:ee===e.id,onClick:()=>{ew(e)},children:n("documents.regenerateChapter")},"regen")],children:(0,o.jsx)(m.A.Item.Meta,{title:e.title,description:(0,o.jsxs)(y.A,{direction:"vertical",children:[(0,o.jsxs)("span",{children:[n("documents.evidenceCount"),": ",e.evidence.length]}),(0,o.jsxs)("span",{children:[n("documents.missingCount"),": ",e.missingFacts.length]})]})})})})},{key:"facts",label:n("documents.structuredFacts"),children:(0,o.jsx)(m.A,{dataSource:B.structuredFacts,renderItem:e=>{var t;return(0,o.jsxs)(m.A.Item,{children:[(0,o.jsx)(m.A.Item.Meta,{title:"".concat(e.key,": ").concat(e.value),description:"".concat(e.sourceFile," \xb7 ").concat((null==(t=M.find(t=>t.id===e.roleId))?void 0:t.name)||e.roleId)}),(0,o.jsx)(g.A,{children:e.confidence.toFixed(2)})]})}})},{key:"sources",label:n("documents.sources"),children:(0,o.jsx)(m.A,{dataSource:B.sources,renderItem:e=>(0,o.jsxs)(m.A.Item,{children:[(0,o.jsx)("span",{children:e.filePath}),(0,o.jsx)(g.A,{children:e.count})]})})},{key:"missing",label:n("documents.missingItems"),children:0===B.missingItems.length?(0,o.jsx)(h.A,{description:n("common.noData")}):(0,o.jsx)(m.A,{dataSource:B.missingItems,renderItem:e=>(0,o.jsx)(m.A.Item,{children:e})})},{key:"validation",label:n("documents.validation"),children:(0,o.jsx)(y.A,{direction:"vertical",className:"w-full",children:B.validationIssues.map(e=>(0,o.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:n("documents.exportGate"),children:(0,o.jsx)(m.A,{dataSource:B.exportGate.checklist,renderItem:e=>(0,o.jsxs)(m.A.Item,{children:[(0,o.jsx)("span",{children:e.label}),(0,o.jsx)(g.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})},{key:"stages",label:n("documents.executionStages"),children:(0,o.jsx)(m.A,{dataSource:B.executionStages,renderItem:e=>(0,o.jsxs)(m.A.Item,{children:[(0,o.jsx)(m.A.Item.Meta,{title:"".concat(e.type," \xb7 ").concat(e.roleId),description:e.message}),(0,o.jsx)(g.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"warning",children:e.status})]})})}]}):(0,o.jsx)(h.A,{description:n("documents.noDraft")})}),(0,o.jsx)(w.A,{title:n("documents.templateEditor"),open:en,onOk:()=>{ef()},onCancel:()=>eo(!1),width:760,centered:!0,okText:n("common.save"),children:(0,o.jsxs)(c.A,{form:I,layout:"vertical",requiredMark:"optional",children:[(0,o.jsxs)(u.A,{gutter:12,children:[(0,o.jsx)(p.A,{xs:24,md:8,children:(0,o.jsx)(c.A.Item,{name:"id",label:"ID",rules:[{required:!0}],children:(0,o.jsx)(i.A,{disabled:!0})})}),(0,o.jsx)(p.A,{xs:24,md:8,children:(0,o.jsx)(c.A.Item,{name:"name",label:n("documents.templateName"),rules:[{required:!0}],children:(0,o.jsx)(i.A,{})})}),(0,o.jsx)(p.A,{xs:24,md:8,children:(0,o.jsx)(c.A.Item,{name:"category",label:n("documents.templateCategory"),children:(0,o.jsx)(i.A,{})})}),(0,o.jsx)(p.A,{xs:24,md:12,children:(0,o.jsx)(c.A.Item,{name:"outputTitle",label:n("documents.outputTitle"),children:(0,o.jsx)(i.A,{})})}),(0,o.jsx)(p.A,{xs:24,md:12,children:(0,o.jsx)(c.A.Item,{name:"description",label:n("documents.templateDescription"),children:(0,o.jsx)(i.A,{})})})]}),(0,o.jsx)(c.A.Item,{name:"projectRoleConfigId",label:n("documents.projectRoleConfig"),rules:[{required:!0,message:n("documents.projectRoleConfigRequired")}],children:(0,o.jsx)(j.A,{showSearch:!0,placeholder:n("documents.projectRoleConfigRequired"),options:ed})})]})})]})}},2192:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var o=n(7109),s=n(4995),i=n(8483);function a(){return(a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let r=o.forwardRef((e,t)=>o.createElement(i.A,a({},e,{ref:t,icon:s.A})))},2887:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z"}}]},name:"file-text",theme:"outlined"}},4995:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"}},6398:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 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:"download",theme:"outlined"}},6403:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/documents",function(){return n(1699)}])},6578:(e,t,n)=>{"use strict";async function o(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 s(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return o("/api/kb/stats".concat(t))}async function i(e){var t,n;let s=new URLSearchParams;return(null==e?void 0:e.projectRoot)&&s.set("projectRoot",e.projectRoot),(null==e?void 0:e.category)&&s.set("category",e.category),(null==e?void 0:e.page)&&s.set("page",String(null!=(t=e.page)?t:1)),(null==e?void 0:e.limit)&&s.set("limit",String(null!=(n=e.limit)?n:50)),o("/api/kb/files?".concat(s))}async function a(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),o("/api/kb/files/detail?".concat(n))}async function r(e,t){return o("/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 o("/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 o=new FileReader;o.onload=()=>{let e=o.result,n=e.indexOf(",");t(n>=0?e.slice(n+1):e)},o.onerror=n,o.readAsDataURL(e)})}async function d(e,t,n){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:t,uploadId:n})})}async function u(e){return o("/api/kb/upload/progress?id=".concat(encodeURIComponent(e)))}async function p(e){let t=new URLSearchParams({limit:"50"});return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t))}async function m(e){let t=new URLSearchParams;return e&&t.set("projectRoot",e),o("/api/kb/operations?".concat(t),{method:"DELETE"})}async function h(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function f(e,t){return o("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePaths:e,projectRoot:t})})}async function y(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 j(){return o("/api/kb/features")}async function x(e,t){var n,s,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==(s=t.weights)?void 0:s.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)),o("/api/kb/search?".concat(c))}async function A(){return o("/api/prompt")}async function w(e){return o("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function b(e){return o("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e,t){return o("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function S(e){return o("/api/documents/roles?mode=config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function k(e){return o("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function C(){return o("/api/documents/templates")}async function T(e){return o("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function I(e){return o("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function O(e){return o("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function R(e){return o("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(e){return o("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(){return o("/api/documents/drafts")}async function N(e,t){return o("/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 D(){return o("/api/config/providers")}async function L(e,t){return o("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function U(e){return o("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function J(){return o("/api/config/models")}async function H(e){return o("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function M(){return o("/api/config/embedding")}async function V(e){return o("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function F(){return o("/api/config/embedding/healthCheck",{method:"POST"})}async function _(e){return o("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function G(){return o("/api/system/stats")}async function q(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return o("/api/context".concat(n))}async function B(e){return o("/api/context?type=".concat(e,"&stats=1"))}async function W(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function X(e){return o("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return o("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function Z(e,t){return o("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function K(e){return o("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>N,Bh:()=>K,Dl:()=>C,E:()=>X,FC:()=>G,FV:()=>v,H1:()=>g,H7:()=>m,HC:()=>r,HT:()=>i,II:()=>M,NR:()=>S,OX:()=>R,PH:()=>W,QT:()=>u,Qx:()=>p,R1:()=>E,SJ:()=>f,UE:()=>z,VW:()=>j,W2:()=>x,X8:()=>y,Z3:()=>D,_m:()=>L,aP:()=>H,bV:()=>O,bZ:()=>_,c1:()=>d,dd:()=>V,dg:()=>b,dw:()=>k,dx:()=>A,h0:()=>I,h1:()=>U,hc:()=>s,hn:()=>q,l2:()=>T,lv:()=>w,p:()=>B,q7:()=>P,tn:()=>c,u6:()=>F,xC:()=>a,xq:()=>h,xw:()=>Q,zo:()=>Z,zr:()=>J})},6631:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var o=n(7109),s=n(2887),i=n(8483);function a(){return(a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let r=o.forwardRef((e,t)=>o.createElement(i.A,a({},e,{ref:t,icon:s.A})))},8847:(e,t)=>{"use strict";t.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"}},9071:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var o=n(7109),s=n(8847),i=n(8483);function a(){return(a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let r=o.forwardRef((e,t)=>o.createElement(i.A,a({},e,{ref:t,icon:s.A})))}},e=>{e.O(0,[260,167,382,201,668,227,740,174,492,455,292,841,951,636,593,792],()=>e(e.s=6403)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[920],{2548:(e,l,i)=>{"use strict";i.r(l),i.d(l,{default:()=>g});var s=i(5321),c=i(5292),d=i(8787),n=i(1019),r=i(2256),t=i(8770),h=i(1702),x=i(3241),j=i(3014);let{Paragraph:a,Title:o,Text:p}=c.A;function g(){let e=(0,j.Vr)();return(0,s.jsxs)("div",{className:"space-y-6 animateFadeIn",children:[(0,s.jsxs)(d.A,{className:"cardGlass",styles:{body:{padding:24}},children:[(0,s.jsx)(o,{level:2,className:"mb-2",children:e("guide.title")}),(0,s.jsx)(a,{className:"pageDesc mb-0",children:e("guide.description")})]}),(0,s.jsx)(d.A,{title:e("guide.fullFlow"),children:(0,s.jsx)(n.A,{direction:"vertical",items:[{title:e("guide.stepModel"),description:e("guide.stepModelDesc")},{title:e("guide.stepKnowledge"),description:e("guide.stepKnowledgeDesc")},{title:e("guide.stepPrompt"),description:e("guide.stepPromptDesc")},{title:e("guide.stepRole"),description:e("guide.stepRoleDesc")},{title:e("guide.stepTemplate"),description:e("guide.stepTemplateDesc")},{title:e("guide.stepGenerate"),description:e("guide.stepGenerateDesc")},{title:e("guide.stepReview"),description:e("guide.stepReviewDesc")},{title:e("guide.stepExport"),description:e("guide.stepExportDesc")}]})}),(0,s.jsx)(d.A,{title:"详细操作手册:从 0 到生成 PDF",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第一步:配置模型"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"进入左侧菜单“模型配置”。"}),(0,s.jsx)("li",{children:"先添加供应商,例如 OpenAI、DeepSeek、OpenRouter、Ollama 或其他兼容 OpenAI 协议的服务。"}),(0,s.jsx)("li",{children:"填写 Base URL、API Key,并保存。"}),(0,s.jsx)("li",{children:"添加模型名称,例如用于推理、生成和阅读的模型。"}),(0,s.jsx)("li",{children:"把可用模型设置为当前启用模型。"}),(0,s.jsx)("li",{children:"点击健康检查,确认模型可调用。模型不可用时,文档生成仍会回退到本地抽取,但 LLM JSON 事实抽取效果会下降。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第二步:上传知识库资料"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"进入“知识库 / 文件管理”或“知识库 / 管理”。"}),(0,s.jsx)("li",{children:"上传项目资料,建议至少包含:招标文件、项目概况、合同或技术要求、清单/表格、图纸说明、规范或企业标准。"}),(0,s.jsx)("li",{children:"上传后等待索引完成,确保文件出现在文件列表中。"}),(0,s.jsx)("li",{children:"表格类文件建议保持清晰表头,例如“工种、人数、进场时间”“设备名称、规格、数量”。"}),(0,s.jsx)("li",{children:"如果是图纸,建议同时上传图纸目录或图纸说明,便于模型理解图纸范围。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第三步:创建提示词"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"进入“提示词管理”。"}),(0,s.jsx)("li",{children:"创建事实抽取提示词:要求模型只抽取资料中明确出现的事实,不允许编造,并保留来源。"}),(0,s.jsx)("li",{children:"创建章节生成提示词:说明文档类型、章节风格、专业语气、引用事实和禁止事项。"}),(0,s.jsx)("li",{children:"创建校验提示词:要求检查工程名称、工期、质量目标、数字、表格引用、章节完整性。"}),(0,s.jsx)("li",{children:"创建格式化提示词:要求封面、目录、编号、表格、段落和正式输出格式。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第四步:创建文件角色"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"进入“角色配置”。"}),(0,s.jsx)("li",{children:"点击“新建文件角色”。"}),(0,s.jsx)("li",{children:"填写角色名称,例如“招标文件事实源”“工程量清单表格”“图纸说明文件”“企业规范文件”。"}),(0,s.jsx)("li",{children:"选择处理类型:规则文件、项目事实文件、表格数据、图纸文件、规范文件或参考资料。"}),(0,s.jsx)("li",{children:"绑定对应的知识库文件。"}),(0,s.jsx)("li",{children:"保存。一个文件角色通常绑定一个明确用途的文件,便于后续排序和追踪来源。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第五步:创建提示词角色"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"在“角色配置”中点击“新建提示词角色”。"}),(0,s.jsx)("li",{children:"填写角色名称,例如“施工组织设计事实抽取”“章节生成规则”“导出前校验规则”。"}),(0,s.jsx)("li",{children:"选择执行类型:事实抽取、章节生成、校验、格式化或参考。"}),(0,s.jsx)("li",{children:"绑定第三步创建的提示词。"}),(0,s.jsx)("li",{children:"保存。角色名称可以自定义,但执行类型必须选对,因为系统会根据执行类型决定用途。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第六步:创建项目角色配置并排序"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"在“角色配置”中点击“新建项目配置”。"}),(0,s.jsx)("li",{children:"填写配置名称,例如“某项目施工组织设计配置”。"}),(0,s.jsx)("li",{children:"添加文件角色,并设置顺序。推荐顺序:规则文件 → 项目事实文件 → 表格数据 → 图纸文件 → 规范文件 → 参考资料。"}),(0,s.jsx)("li",{children:"添加提示词角色,并设置顺序。推荐顺序:事实抽取 → 章节生成 → 校验 → 格式化 → 参考。"}),(0,s.jsx)("li",{children:"保存项目角色配置。后续模板只需要绑定这个配置,不需要重复选择文件和提示词。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第七步:创建模板并绑定项目配置"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"进入“生成编辑”。"}),(0,s.jsx)("li",{children:"点击“新建模板”。"}),(0,s.jsx)("li",{children:"填写模板名称、分类、输出标题和说明。"}),(0,s.jsx)("li",{children:"选择刚才创建的项目角色配置。"}),(0,s.jsx)("li",{children:"保存模板。模板负责定义文档入口,项目角色配置负责提供资料、提示词和执行顺序。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第八步:执行生成并查看状态"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"选择模板,点击“生成”。"}),(0,s.jsx)("li",{children:"页面会显示“执行状态”卡片,依次显示准备配置、事实抽取、章节生成、严格校验、正式排版、生成完成。"}),(0,s.jsx)("li",{children:"当前执行节点会高亮,完成后变为成功。如果失败,会显示错误状态。"}),(0,s.jsx)("li",{children:"生成完成后,编辑器下方的“执行阶段”会展示后端真实执行结果。"})]})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)(o,{level:4,children:"第九步:审查和导出"}),(0,s.jsxs)("ol",{className:"list-decimal pl-6 space-y-2",children:[(0,s.jsx)("li",{children:"先看“结构化事实”,确认工程名称、工期、质量目标、施工范围等是否正确。"}),(0,s.jsx)("li",{children:"再看“来源”,确认事实来自已绑定资料。"}),(0,s.jsx)("li",{children:"查看“缺失项”和“严格校验”,有错误时先补资料或调整角色配置。"}),(0,s.jsx)("li",{children:"查看“导出门禁”。PDF 导出会强制检查门禁,未通过会阻止导出。"}),(0,s.jsx)("li",{children:"确认无阻断错误后,再导出 Markdown、HTML 或 PDF。"})]})]})]})}),(0,s.jsxs)(r.A,{gutter:[16,16],children:[(0,s.jsx)(t.A,{xs:24,lg:12,children:(0,s.jsxs)(d.A,{title:e("guide.roleDesign"),children:[(0,s.jsx)(a,{children:e("guide.roleDesignDesc")}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(h.A,{color:"blue",children:"file"}),(0,s.jsx)(p,{strong:!0,children:e("guide.fileRole")}),(0,s.jsx)(a,{children:e("guide.fileRoleDesc")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(h.A,{color:"purple",children:"prompt"}),(0,s.jsx)(p,{strong:!0,children:e("guide.promptRole")}),(0,s.jsx)(a,{children:e("guide.promptRoleDesc")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(h.A,{color:"geekblue",children:"config"}),(0,s.jsx)(p,{strong:!0,children:e("guide.projectConfig")}),(0,s.jsx)(a,{children:e("guide.projectConfigDesc")})]})]})]})}),(0,s.jsx)(t.A,{xs:24,lg:12,children:(0,s.jsxs)(d.A,{title:e("guide.generationEngine"),children:[(0,s.jsx)(a,{children:e("guide.generationEngineDesc")}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(h.A,{children:e("roles.factExtraction")}),(0,s.jsx)(h.A,{children:e("roles.chapterGeneration")}),(0,s.jsx)(h.A,{children:e("roles.validation")}),(0,s.jsx)(h.A,{children:e("roles.formatting")}),(0,s.jsx)(h.A,{children:e("documents.exportGate")})]})]})})]}),(0,s.jsx)(x.A,{items:[{key:"prepare",label:e("guide.prepareTitle"),children:(0,s.jsx)(a,{children:e("guide.prepareContent")})},{key:"roles",label:e("guide.rolesTitle"),children:(0,s.jsx)(a,{children:e("guide.rolesContent")})},{key:"template",label:e("guide.templateTitle"),children:(0,s.jsx)(a,{children:e("guide.templateContent")})},{key:"generate",label:e("guide.generateTitle"),children:(0,s.jsx)(a,{children:e("guide.generateContent")})},{key:"qa",label:e("guide.qaTitle"),children:(0,s.jsx)(a,{children:e("guide.qaContent")})}]})]})}},4899:(e,l,i)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/guide",function(){return i(2548)}])}},e=>{e.O(0,[260,167,382,292,841,912,636,593,792],()=>e(e.s=4899)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[309],{4569: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"}},5551:(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:()=>o,fw:()=>i,z3:()=>a});let r={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},l={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function o(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?l:r)[e])?t:e}},5819:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var a=n(5321),i=n(7109),r=n(1873),l=n.n(r),o=n(3220),s=n.n(o),c=n(6109),d=n(5292),u=n(6506),p=n(3442),h=n(1702),m=n(9137),y=n(9400),f=n(8787),g=n(6985),x=n(3657),j=n(4253),w=n(2700),S=n(5114),b=n(8569),v=n(4668),C=n(6578),k=n(5551),A=n(4569),_=n.n(A);let{Paragraph:P}=d.A;function T(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return{}}}function N(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).slice(0,30):[]}function R(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 O(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 I(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 E(){var e,t,n,r,o,d,A,E,J,z;let L=(0,c.useRouter)(),D="string"==typeof L.query.relativePath?L.query.relativePath:"",[U,M]=(0,i.useState)(),[H,F]=(0,i.useState)(!1),[B,K]=(0,i.useState)(!1),[V,X]=(0,i.useState)(""),[W,q]=(0,i.useState)([]);(0,i.useEffect)(()=>{D&&(F(!0),(0,C.xC)(D).then(M).finally(()=>F(!1)))},[D]);let $=(0,i.useMemo)(()=>(function(e){let t=T(null==e?void 0:e.file.metadataJson);return"object"==typeof t.extraction&&t.extraction?t.extraction:t})(U),[U]),G=N($.layerNames);(0,i.useEffect)(()=>{q(G)},[null==U?void 0:U.file.relativePath,G.join("|")]);let Z=V.trim().toLowerCase(),Q=(0,i.useMemo)(()=>{var e;return U&&Z?U.chunks.filter(e=>{let t=T(e.metadataJson);return[e.content,e.sectionTitle,t.rowRange,t.chunkKind,t.parentId,JSON.stringify(t)].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))}):null!=(e=null==U?void 0:U.chunks)?e:[]},[U,Z]),Y=(0,i.useMemo)(()=>{var e;return U&&Z?U.parents.filter(e=>[e.content,e.sectionTitle,e.parentId,e.metadataJson].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))):null!=(e=null==U?void 0:U.parents)?e:[]},[U,Z]),ee=async()=>{if(D){K(!0);try{let e=await (0,C.HC)(D);e.detail&&M(e.detail),m.Ay.success("文件索引已重建")}finally{K(!1)}}},et=async e=>{e&&(await navigator.clipboard.writeText(e),m.Ay.success("已复制"))},en=async e=>{D&&(await (0,C.tn)(D,e),m.Ay.success("file"===e?"已请求打开文件":"已请求打开目录"))},ea=[{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:[O("Sheet",N($.sheetNames),X),O("表头",N($.columnNames),X),O("行数",$.rowCount),O("列数",$.columnCount),O("公式数",$.formulaCount),O("合并单元格",$.mergeCount)]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:I(N($.columnNames),"column"),columns:[{title:"列名",dataIndex:"name",render:e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>X(String(e)),children:String(e)})}]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:(null!=(A=null==U?void 0:U.chunks)?A:[]).map(e=>T(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:()=>X(String(e)),children:["行 ",String(e)]})}]}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(E=null==U?void 0:U.chunks)?E:[]).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:[O("图层",N($.layerNames),X),O("块/符号",N($.blockNames),X),O("实体类型",N($.entityTypes),X),O("产品/零件",N($.productNames),X),O("材料",N($.materialNames),X),O("实体名称",N($.entityNames),X)]}),G.length>0?(0,a.jsxs)(f.A,{size:"small",title:"图层开关 / 图纸预览",children:[(0,a.jsx)(g.A.Group,{value:W,options:G.map(e=>({label:e,value:e})),onChange:e=>q(e.map(String))}),(0,a.jsx)("div",{className:_().drawingPreview,children:W.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:[...I(G,"layer").map(e=>({...e,type:"图层"})),...I(N($.entityTypes),"entity").map(e=>({...e,type:"实体类型"})),...I(N($.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:()=>X(String(e)),children:String(e)})}]})]})},{key:"data",label:"数据路径",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[N($.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)}(N($.dataPaths)),onSelect:e=>{var t;return X(String(null!=(t=e[0])?t:""))}}):(0,a.jsx)(j.A,{description:"暂无数据路径"}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(J=null==U?void 0:U.chunks)?J:[]).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 l=/^([^:=]+)\s*[:=]\s*(.*)$/u.exec(e);return{key:"data-".concat(t),path:null!=(i=null==l||null==(n=l[1])?void 0:n.trim())?i:e,value:null!=(r=null==l||null==(a=l[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:()=>X(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:[O("OCR 建议",$.ocrRecommended),O("OCR 原因",$.ocrReason),O("OCR 引擎",$.ocrProvider),O("OCR 语言",$.ocrLanguages),O("OCR 文本长度",$.ocrTextLength),O("PDF 页面 OCR 支持",$.pdfPageOcrSupported),O("PDF OCR 页数",$.ocrPageCount),O("PDF OCR 页数上限",$.pdfOcrPageLimit),O("PDF 渲染器",$.pdfRenderer)]}),(null==U?void 0:U.file.format)==="pdf"?(0,a.jsx)("div",{className:_().pdfPreviewStrip,children:Array.from({length:Math.min(Number(null!=(e=$.ocrPageCount)?e:1)||1,6)},(e,t)=>(0,a.jsx)(l(),{width:220,height:320,src:"/api/kb/files/preview-pdf-page?relativePath=".concat(encodeURIComponent(U.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!=(z=null==U?void 0:U.chunks)?z:[]).map(e=>e.content).join("\n\n").split(/PDF OCR 第\s*(\d+)\s*页[::]/u).slice(1).reduce((e,t,n,a)=>{var i,r,l;return n%2==0&&e.push({key:"page-".concat(t),page:t,text:null!=(l=null==(r=a[n+1])||null==(i=r.split(/PDF OCR 第\s*\d+\s*页[::]/u)[0])?void 0:i.trim())?l:""}),e},[]),pagination:{pageSize:10},columns:[{title:"页码",dataIndex:"page",width:90},{title:"OCR 文本",dataIndex:"text",render:e=>(0,a.jsx)(P,{ellipsis:{rows:4,expandable:!0,symbol:"展开"},children:String(e)})}]})]})}],ei=[{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=T(t.metadataJson).chunkKind)?n:t.category)})}},{title:"章节/范围",width:220,render:(e,t)=>{let n=T(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)(P,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:_().searchContent,children:R(t.content,V)})}],er=[{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)(P,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:_().searchContent,children:R(t.content,V)})}];return H?(0,a.jsx)(w.A,{}):U?(0,a.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(s(),{href:"/knowledge/files",children:"返回文件列表"}),(0,a.jsxs)("div",{className:_().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)(S.Ay,{onClick:()=>{et(null==U?void 0:U.absolutePath)},children:"复制原文件路径"}),(0,a.jsx)(S.Ay,{onClick:()=>{et(null==U?void 0:U.directory)},children:"复制所在目录"}),(0,a.jsx)(S.Ay,{onClick:()=>{en("file")},children:"打开文件"}),(0,a.jsx)(S.Ay,{onClick:()=>{en("directory")},children:"打开目录"}),"pdf"===U.file.format?(0,a.jsx)(S.Ay,{loading:B,onClick:()=>{ee()},children:"重新 OCR"}):null,(0,a.jsx)(S.Ay,{type:"primary",loading:B,onClick:()=>{ee()},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:U.file.relativePath}),(0,a.jsx)(u.A.Item,{label:"原文件",children:null!=(t=U.absolutePath)?t:"-"}),(0,a.jsx)(u.A.Item,{label:"所在目录",children:null!=(n=U.directory)?n:"-"}),(0,a.jsxs)(u.A.Item,{label:"分类",children:[(0,a.jsx)(h.A,{children:(0,k.Jm)(U.file.category)})," ",(0,a.jsx)(h.A,{children:U.file.format})]}),(0,a.jsx)(u.A.Item,{label:"大小",children:(0,k.z3)(U.file.fileSize)}),(0,a.jsx)(u.A.Item,{label:"切片数",children:U.file.chunkCount}),(0,a.jsx)(u.A.Item,{label:"状态",children:U.file.status}),(0,a.jsx)(u.A.Item,{label:"解析模式",children:String(null!=(r=$.extractionMode)?r:"-")}),(0,a.jsx)(u.A.Item,{label:"覆盖范围",children:String(null!=(o=$.contentCoverage)?o:"-")}),(0,a.jsx)(u.A.Item,{label:"正文长度",children:String(null!=(d=$.textLength)?d:"-")})]})}),(0,a.jsx)(f.A,{size:"small",title:"结构化信息",children:(0,a.jsx)(b.A,{items:ea})}),(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:V,onChange:e=>X(e.target.value),placeholder:"筛选 rowRange、图层、实体、data path、section、chunk 内容"}),V?(0,a.jsxs)(p.A,{wrap:!0,children:[(0,a.jsxs)(h.A,{color:"blue",children:["Parent 命中 ",Y.length]}),(0,a.jsxs)(h.A,{color:"green",children:["Child 命中 ",Q.length]}),(0,a.jsxs)(h.A,{color:"purple",children:["筛选词 ",V]})]}):null]})}),(0,a.jsx)(f.A,{size:"small",title:"Parent Chunks (".concat(Y.length,"/").concat(U.parents.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:er,dataSource:Y,pagination:{pageSize:10},size:"small"})}),(0,a.jsx)(f.A,{size:"small",title:"Child Chunks (".concat(Q.length,"/").concat(U.chunks.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:ei,dataSource:Q,pagination:{pageSize:20},size:"small"})})]}):(0,a.jsx)(j.A,{description:"请选择文件"})}},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 l(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function o(e,t){return a("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(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,l,o;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(o=t.limit)?o:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(i=t.weights)?void 0:i.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(r=t.weights)?void 0:r.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(l=t.weights)?void 0:l.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(s))}async function w(){return a("/api/prompt")}async function S(e){return a("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function b(e){return a("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e,t){return a("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(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/templates")}async function _(e){return a("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function T(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function N(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(){return a("/api/documents/drafts")}async function I(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function E(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 J(){return a("/api/config/providers")}async function z(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function L(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return a("/api/config/models")}async function U(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function M(){return a("/api/config/embedding")}async function H(e){return a("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function F(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function B(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function K(){return a("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function X(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function W(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function q(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function $(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function G(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function Z(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>I,Bh:()=>Z,Dl:()=>A,E:()=>q,FC:()=>K,FV:()=>v,H1:()=>g,H7:()=>h,HC:()=>o,HT:()=>r,II:()=>M,NR:()=>C,OX:()=>N,PH:()=>W,QT:()=>u,Qx:()=>p,R1:()=>R,SJ:()=>y,UE:()=>E,VW:()=>x,W2:()=>j,X8:()=>f,Z3:()=>J,_m:()=>z,aP:()=>U,bV:()=>T,bZ:()=>B,c1:()=>d,dd:()=>H,dg:()=>b,dw:()=>k,dx:()=>w,h0:()=>P,h1:()=>L,hc:()=>i,hn:()=>V,l2:()=>_,lv:()=>S,p:()=>X,q7:()=>O,tn:()=>s,u6:()=>F,xC:()=>l,xq:()=>m,xw:()=>$,zo:()=>G,zr:()=>D})},7690:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/file-detail",function(){return n(5819)}])}},e=>{e.O(0,[260,544,425,668,227,740,174,446,400,292,969,517,636,593,792],()=>e(e.s=7690)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[309],{4569: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"}},5551:(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:()=>o,fw:()=>i,z3:()=>a});let r={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},l={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function o(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?l:r)[e])?t:e}},5819:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var a=n(5321),i=n(7109),r=n(1873),l=n.n(r),o=n(3220),s=n.n(o),c=n(6109),d=n(5292),u=n(6506),p=n(3442),h=n(1702),m=n(9137),y=n(9400),f=n(8787),g=n(6985),x=n(3657),j=n(4253),w=n(2700),S=n(5114),b=n(8569),v=n(4668),C=n(6578),k=n(5551),A=n(4569),_=n.n(A);let{Paragraph:P}=d.A;function T(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return{}}}function N(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).slice(0,30):[]}function R(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 O(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 I(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 E(){var e,t,n,r,o,d,A,E,J,z;let L=(0,c.useRouter)(),D="string"==typeof L.query.relativePath?L.query.relativePath:"",[U,M]=(0,i.useState)(),[H,F]=(0,i.useState)(!1),[B,K]=(0,i.useState)(!1),[V,X]=(0,i.useState)(""),[W,q]=(0,i.useState)([]);(0,i.useEffect)(()=>{D&&(F(!0),(0,C.xC)(D).then(M).finally(()=>F(!1)))},[D]);let $=(0,i.useMemo)(()=>(function(e){let t=T(null==e?void 0:e.file.metadataJson);return"object"==typeof t.extraction&&t.extraction?t.extraction:t})(U),[U]),G=N($.layerNames);(0,i.useEffect)(()=>{q(G)},[null==U?void 0:U.file.relativePath,G.join("|")]);let Z=V.trim().toLowerCase(),Q=(0,i.useMemo)(()=>{var e;return U&&Z?U.chunks.filter(e=>{let t=T(e.metadataJson);return[e.content,e.sectionTitle,t.rowRange,t.chunkKind,t.parentId,JSON.stringify(t)].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))}):null!=(e=null==U?void 0:U.chunks)?e:[]},[U,Z]),Y=(0,i.useMemo)(()=>{var e;return U&&Z?U.parents.filter(e=>[e.content,e.sectionTitle,e.parentId,e.metadataJson].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))):null!=(e=null==U?void 0:U.parents)?e:[]},[U,Z]),ee=async()=>{if(D){K(!0);try{let e=await (0,C.HC)(D);e.detail&&M(e.detail),m.Ay.success("文件索引已重建")}finally{K(!1)}}},et=async e=>{e&&(await navigator.clipboard.writeText(e),m.Ay.success("已复制"))},en=async e=>{D&&(await (0,C.tn)(D,e),m.Ay.success("file"===e?"已请求打开文件":"已请求打开目录"))},ea=[{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:[O("Sheet",N($.sheetNames),X),O("表头",N($.columnNames),X),O("行数",$.rowCount),O("列数",$.columnCount),O("公式数",$.formulaCount),O("合并单元格",$.mergeCount)]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:I(N($.columnNames),"column"),columns:[{title:"列名",dataIndex:"name",render:e=>(0,a.jsx)(h.A,{className:"cursor-pointer",onClick:()=>X(String(e)),children:String(e)})}]}),(0,a.jsx)(y.A,{size:"small",pagination:!1,rowKey:"key",dataSource:(null!=(A=null==U?void 0:U.chunks)?A:[]).map(e=>T(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:()=>X(String(e)),children:["行 ",String(e)]})}]}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(E=null==U?void 0:U.chunks)?E:[]).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:[O("图层",N($.layerNames),X),O("块/符号",N($.blockNames),X),O("实体类型",N($.entityTypes),X),O("产品/零件",N($.productNames),X),O("材料",N($.materialNames),X),O("实体名称",N($.entityNames),X)]}),G.length>0?(0,a.jsxs)(f.A,{size:"small",title:"图层开关 / 图纸预览",children:[(0,a.jsx)(g.A.Group,{value:W,options:G.map(e=>({label:e,value:e})),onChange:e=>q(e.map(String))}),(0,a.jsx)("div",{className:_().drawingPreview,children:W.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:[...I(G,"layer").map(e=>({...e,type:"图层"})),...I(N($.entityTypes),"entity").map(e=>({...e,type:"实体类型"})),...I(N($.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:()=>X(String(e)),children:String(e)})}]})]})},{key:"data",label:"数据路径",children:(0,a.jsxs)(p.A,{direction:"vertical",className:"w-full",children:[N($.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)}(N($.dataPaths)),onSelect:e=>{var t;return X(String(null!=(t=e[0])?t:""))}}):(0,a.jsx)(j.A,{description:"暂无数据路径"}),(0,a.jsx)(y.A,{size:"small",rowKey:"key",dataSource:(null!=(J=null==U?void 0:U.chunks)?J:[]).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 l=/^([^:=]+)\s*[:=]\s*(.*)$/u.exec(e);return{key:"data-".concat(t),path:null!=(i=null==l||null==(n=l[1])?void 0:n.trim())?i:e,value:null!=(r=null==l||null==(a=l[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:()=>X(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:[O("OCR 建议",$.ocrRecommended),O("OCR 原因",$.ocrReason),O("OCR 引擎",$.ocrProvider),O("OCR 语言",$.ocrLanguages),O("OCR 文本长度",$.ocrTextLength),O("PDF 页面 OCR 支持",$.pdfPageOcrSupported),O("PDF OCR 页数",$.ocrPageCount),O("PDF OCR 页数上限",$.pdfOcrPageLimit),O("PDF 渲染器",$.pdfRenderer)]}),(null==U?void 0:U.file.format)==="pdf"?(0,a.jsx)("div",{className:_().pdfPreviewStrip,children:Array.from({length:Math.min(Number(null!=(e=$.ocrPageCount)?e:1)||1,6)},(e,t)=>(0,a.jsx)(l(),{width:220,height:320,src:"/api/kb/files/preview-pdf-page?relativePath=".concat(encodeURIComponent(U.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!=(z=null==U?void 0:U.chunks)?z:[]).map(e=>e.content).join("\n\n").split(/PDF OCR 第\s*(\d+)\s*页[::]/u).slice(1).reduce((e,t,n,a)=>{var i,r,l;return n%2==0&&e.push({key:"page-".concat(t),page:t,text:null!=(l=null==(r=a[n+1])||null==(i=r.split(/PDF OCR 第\s*\d+\s*页[::]/u)[0])?void 0:i.trim())?l:""}),e},[]),pagination:{pageSize:10},columns:[{title:"页码",dataIndex:"page",width:90},{title:"OCR 文本",dataIndex:"text",render:e=>(0,a.jsx)(P,{ellipsis:{rows:4,expandable:!0,symbol:"展开"},children:String(e)})}]})]})}],ei=[{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=T(t.metadataJson).chunkKind)?n:t.category)})}},{title:"章节/范围",width:220,render:(e,t)=>{let n=T(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)(P,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:_().searchContent,children:R(t.content,V)})}],er=[{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)(P,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:_().searchContent,children:R(t.content,V)})}];return H?(0,a.jsx)(w.A,{}):U?(0,a.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(s(),{href:"/knowledge/files",children:"返回文件列表"}),(0,a.jsxs)("div",{className:_().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)(S.Ay,{onClick:()=>{et(null==U?void 0:U.absolutePath)},children:"复制原文件路径"}),(0,a.jsx)(S.Ay,{onClick:()=>{et(null==U?void 0:U.directory)},children:"复制所在目录"}),(0,a.jsx)(S.Ay,{onClick:()=>{en("file")},children:"打开文件"}),(0,a.jsx)(S.Ay,{onClick:()=>{en("directory")},children:"打开目录"}),"pdf"===U.file.format?(0,a.jsx)(S.Ay,{loading:B,onClick:()=>{ee()},children:"重新 OCR"}):null,(0,a.jsx)(S.Ay,{type:"primary",loading:B,onClick:()=>{ee()},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:U.file.relativePath}),(0,a.jsx)(u.A.Item,{label:"原文件",children:null!=(t=U.absolutePath)?t:"-"}),(0,a.jsx)(u.A.Item,{label:"所在目录",children:null!=(n=U.directory)?n:"-"}),(0,a.jsxs)(u.A.Item,{label:"分类",children:[(0,a.jsx)(h.A,{children:(0,k.Jm)(U.file.category)})," ",(0,a.jsx)(h.A,{children:U.file.format})]}),(0,a.jsx)(u.A.Item,{label:"大小",children:(0,k.z3)(U.file.fileSize)}),(0,a.jsx)(u.A.Item,{label:"切片数",children:U.file.chunkCount}),(0,a.jsx)(u.A.Item,{label:"状态",children:U.file.status}),(0,a.jsx)(u.A.Item,{label:"解析模式",children:String(null!=(r=$.extractionMode)?r:"-")}),(0,a.jsx)(u.A.Item,{label:"覆盖范围",children:String(null!=(o=$.contentCoverage)?o:"-")}),(0,a.jsx)(u.A.Item,{label:"正文长度",children:String(null!=(d=$.textLength)?d:"-")})]})}),(0,a.jsx)(f.A,{size:"small",title:"结构化信息",children:(0,a.jsx)(b.A,{items:ea})}),(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:V,onChange:e=>X(e.target.value),placeholder:"筛选 rowRange、图层、实体、data path、section、chunk 内容"}),V?(0,a.jsxs)(p.A,{wrap:!0,children:[(0,a.jsxs)(h.A,{color:"blue",children:["Parent 命中 ",Y.length]}),(0,a.jsxs)(h.A,{color:"green",children:["Child 命中 ",Q.length]}),(0,a.jsxs)(h.A,{color:"purple",children:["筛选词 ",V]})]}):null]})}),(0,a.jsx)(f.A,{size:"small",title:"Parent Chunks (".concat(Y.length,"/").concat(U.parents.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:er,dataSource:Y,pagination:{pageSize:10},size:"small"})}),(0,a.jsx)(f.A,{size:"small",title:"Child Chunks (".concat(Q.length,"/").concat(U.chunks.length,")"),children:(0,a.jsx)(y.A,{rowKey:"id",columns:ei,dataSource:Q,pagination:{pageSize:20},size:"small"})})]}):(0,a.jsx)(j.A,{description:"请选择文件"})}},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 l(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function o(e,t){return a("/api/kb/files/reindex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function s(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,l,o;let s=new URLSearchParams({q:e});return(null==t?void 0:t.projectRoot)&&s.set("projectRoot",t.projectRoot),(null==t?void 0:t.category)&&s.set("category",t.category),(null==t?void 0:t.limit)&&s.set("limit",String(null!=(o=t.limit)?o:20)),(null==t||null==(n=t.weights)?void 0:n.keyword)!=null&&s.set("keywordWeight",String(t.weights.keyword)),(null==t||null==(i=t.weights)?void 0:i.vector)!=null&&s.set("vectorWeight",String(t.weights.vector)),(null==t||null==(r=t.weights)?void 0:r.rewrite)!=null&&s.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(l=t.weights)?void 0:l.hybridBonus)!=null&&s.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(s))}async function w(){return a("/api/prompt")}async function S(e){return a("/api/documents/roles".concat(e?"?type=".concat(e):""))}async function b(e){return a("/api/documents/roles",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function v(e,t){return a("/api/documents/roles?type=".concat(e,"&id=").concat(encodeURIComponent(t)),{method:"DELETE"})}async function C(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/templates")}async function _(e){return a("/api/documents/templates",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function P(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function T(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function N(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function R(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(){return a("/api/documents/drafts")}async function I(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function E(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 J(){return a("/api/config/providers")}async function z(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function L(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return a("/api/config/models")}async function U(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function M(){return a("/api/config/embedding")}async function H(e){return a("/api/config/embedding",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function F(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function B(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function K(){return a("/api/system/stats")}async function V(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function X(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function W(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function q(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function $(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function G(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function Z(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>I,Bh:()=>Z,Dl:()=>A,E:()=>q,FC:()=>K,FV:()=>v,H1:()=>g,H7:()=>h,HC:()=>o,HT:()=>r,II:()=>M,NR:()=>C,OX:()=>N,PH:()=>W,QT:()=>u,Qx:()=>p,R1:()=>R,SJ:()=>y,UE:()=>E,VW:()=>x,W2:()=>j,X8:()=>f,Z3:()=>J,_m:()=>z,aP:()=>U,bV:()=>T,bZ:()=>B,c1:()=>d,dd:()=>H,dg:()=>b,dw:()=>k,dx:()=>w,h0:()=>P,h1:()=>L,hc:()=>i,hn:()=>V,l2:()=>_,lv:()=>S,p:()=>X,q7:()=>O,tn:()=>s,u6:()=>F,xC:()=>l,xq:()=>m,xw:()=>$,zo:()=>G,zr:()=>D})},7690:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/file-detail",function(){return n(5819)}])}},e=>{e.O(0,[260,167,382,201,668,227,740,174,446,400,292,969,517,636,593,792],()=>e(e.s=7690)),_N_E=e.O()}]);
|
package/.next/static/chunks/pages/knowledge/{files-1d99abf5b4d33896.js → files-369d7ccf6a6e4e43.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28],{426:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/files",function(){return n(6451)}])},2803:(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"}},3793:(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"}},4569: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"}},5258:(e,t,n)=>{"use strict";n.d(t,{A:()=>w});var a=n(1541),r=n(1848),i=n(1249),s=n(7109),o=n(2658),c=n(3638),l=n(2162),d=n(2725),u=n(4567),p=n(632),h=n(9517),y=n(9412),f=n(9527);let g=(0,d.U)(e=>{let{prefixCls:t,className:n,closeIcon:a,closable:r,type:i,title:d,children:g,footer:m,classNames:x,styles:v,...w}=e,{getPrefixCls:b}=s.useContext(u.QO),{className:j,style:C,classNames:S,styles:P}=(0,u.TP)("modal"),_=b(),k=t||b("modal"),T=(0,p.A)(_),[A,N]=(0,f.Ay)(k,T),[O,E]=(0,l.AV)([S,x],[P,v],{props:e}),L=`${k}-confirm`,R={};return R=i?{closable:r??!1,title:"",footer:"",children:s.createElement(h.k,{...e,prefixCls:k,confirmPrefixCls:L,rootPrefixCls:_,content:g})}:{closable:r??!0,title:d,footer:null!==m&&s.createElement(y.w,{...e}),children:g},s.createElement(o.Z,{prefixCls:k,className:(0,c.$)(A,`${k}-pure-panel`,i&&L,i&&`${L}-${i}`,n,j,N,T,O.root),style:{...C,...E.root},...w,closeIcon:(0,y.O)(k,a),closable:r,classNames:O,styles:E,...R})});var m=n(9739);function x(e){return(0,a.Ay)((0,a.fp)(e))}let v=i.A;v.useModal=m.A,v.info=function(e){return(0,a.Ay)((0,a.$D)(e))},v.success=function(e){return(0,a.Ay)((0,a.Ej)(e))},v.error=function(e){return(0,a.Ay)((0,a.jT)(e))},v.warning=x,v.warn=x,v.confirm=function(e){return(0,a.Ay)((0,a.lr)(e))},v.destroyAll=function(){for(;r.A.length;){let e=r.A.pop();e&&e()}},v.config=a.FB,v._InternalPanelDoNotUseOrYouWillBeFired=g;let w=v},5551:(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 r(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),r=Math.floor(a/24);return r>30?new Date(e).toLocaleDateString(t):"en-US"===t?r>0?"".concat(r,"d ago"):a>0?"".concat(a,"h ago"):n>0?"".concat(n,"m ago"):"Just now":r>0?"".concat(r," 天前"):a>0?"".concat(a," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>o,fw:()=>r,z3:()=>a});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},s={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function o(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?s:i)[e])?t:e}},6451:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var a=n(5321),r=n(7109),i=n(6644),s=n(3220),o=n.n(s),c=n(4986),l=n(7807),d=n(5258),u=n(3442),p=n(1702),h=n(5114),y=n(4668),f=n(7271),g=n(2551),m=n(9605),x=n(8787),v=n(9400),w=n(9012),b=n(8209),j=n(486),C=n(2803),S=n(8483);function P(){return(P=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 _=r.forwardRef((e,t)=>r.createElement(S.A,P({},e,{ref:t,icon:C.A})));var k=n(6578),T=n(5551),A=n(4569),N=n.n(A);let O=["document","spreadsheet","image","cad","code","data","web","diagram","archive","other"];function E(){let e=(0,i.Vr)("knowledge"),{locale:t}=(0,i.x_)(),{message:n}=l.A.useApp(),s=(0,c.useSearchParams)().get("category")||"",[C,S]=(0,r.useState)([]),[P,A]=(0,r.useState)(!0),[E,L]=(0,r.useState)(""),[R,I]=(0,r.useState)(s),[J,U]=(0,r.useState)(!1),[D,M]=(0,r.useState)([]),[H,z]=(0,r.useState)([]),[B,V]=(0,r.useState)(1),F=(0,r.useRef)(R);(0,r.useEffect)(()=>{F.current=R},[R]);let X=(0,r.useCallback)(async e=>{let t=null!=e?e:F.current;A(!0);try{let e=await (0,k.HT)({category:t||void 0,limit:200});S(e.files||[])}catch(e){S([])}finally{A(!1)}},[]);(0,r.useEffect)(()=>{X(R)},[R,X]);let W=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}),$=(0,r.useCallback)(async()=>{try{let e=await (0,k.Qx)();M(e.operations.map(W))}catch(e){}},[]);(0,r.useEffect)(()=>{$()},[$]);let q=async()=>{try{await (0,k.H7)(),M([]),n.success("任务状态已清空")}catch(e){n.error("清空任务状态失败")}},Q=async e=>{if(0===e.length)return;let t=1===e.length?e[0].name:"".concat(e.length," 个文件");U(!0),M(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)),r=setInterval(()=>{(0,k.QT)(a).then(e=>{M(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 i,s;let o=await (0,k.c1)(e,void 0,a);clearInterval(r),(null==(i=o.vectorStatus)?void 0:i.status)==="error"?n.info("文件已上传,正在后台入库"):n.success("上传成功"),L(""),I(""),z([]),V(1),F.current="";let c=null==(s=o.files)?void 0:s.find(e=>e.relativePath===o.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 $(),M(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(o.files)?S(o.files):(await (0,k.H1)(),await X(""),await $())}catch(e){n.error("上传失败"),M(e=>[{type:"error",title:"上传失败 ".concat(t),description:"请重试或检查文件格式",status:"error"},...e].slice(0,50))}finally{clearInterval(r),U(!1)}},K=e=>{let t="selected"===e?H.map(String):"filtered"===e?Z.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()=>{M(e=>[{type:"delete",title:a,description:"正在批量删除文件和索引",status:"processing",percent:10},...e].slice(0,50));try{var r;let a=null!=(r=("all"===e?await (0,k.X8)():await (0,k.SJ)(t)).deleted)?r:t.length;n.success("已删除 ".concat(a," 个文件")),z([]),M(e=>[{type:"delete",title:"批量删除完成",description:"已删除 ".concat(a," 个文件、切片和索引"),status:"success"},...e].slice(0,50)),await X(),await $()}catch(e){n.error("批量删除失败"),M(e=>[{type:"error",title:"批量删除失败",description:"请重试",status:"error"},...e].slice(0,50))}}})},Z=E?C.filter(e=>e.relativePath.toLowerCase().includes(E.toLowerCase())):C,G=[{title:e("fileName"),dataIndex:"relativePath",key:"name",render:e=>(0,a.jsxs)(u.A,{children:[(0,a.jsx)(w.A,{}),(0,a.jsx)(o(),{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,T.Jm)(e,t)})},{title:e("fileSize"),dataIndex:"fileSize",key:"size",width:100,render:e=>(0,T.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,r)=>(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()=>{M(e=>[{type:"delete",title:"删除 ".concat(r.relativePath),description:"正在删除文件记录",status:"processing"},...e].slice(0,50));try{await (0,k.xq)(r.relativePath),n.success("已删除"),M(e=>[{type:"delete",title:"删除完成 ".concat(r.relativePath),description:"文件和索引记录已移除",status:"success"},...e].slice(0,50)),z(e=>e.filter(e=>e!==r.relativePath)),await X(),await $()}catch(e){n.error("删除失败"),M(e=>[{type:"error",title:"删除失败 ".concat(r.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)(y.A,{placeholder:e("searchPlaceholder"),prefix:(0,a.jsx)(j.A,{}),value:E,onChange:e=>{L(e.target.value),V(1)},allowClear:!0,className:N().filterInput}),(0,a.jsx)(f.A,{value:R||void 0,onChange:e=>{I(e||""),V(1)},placeholder:e("filterCategory"),allowClear:!0,className:N().filterSelect,options:[{label:e("allCategories"),value:""},...O.map(e=>({label:(0,T.Jm)(e,t),value:e}))]}),(0,a.jsx)(h.Ay,{type:"primary",icon:(0,a.jsx)(_,{}),loading:J,onClick:()=>{var e;return null==(e=document.getElementById("kb-file-upload-input"))?void 0:e.click()},children:J?e("uploading"):e("upload")}),(0,a.jsx)(h.Ay,{icon:(0,a.jsx)(_,{}),loading:J,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===H.length,icon:(0,a.jsx)(b.A,{}),onClick:()=>K("selected"),children:["删除已选 ",H.length||""]}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===Z.length||!E&&!R,onClick:()=>K("filtered"),children:"删除筛选结果"}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===C.length,onClick:()=>K("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="",Q(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="",Q(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)(w.A,{}),"文件任务状态"]}),(0,a.jsx)(h.Ay,{size:"small",type:"text",disabled:0===D.length,onClick:()=>void q(),children:"清空"})]}),0===D.length?(0,a.jsx)("div",{className:N().statusEmpty,children:"暂无文件任务。"}):(0,a.jsx)("div",{className:N().statusList,children:D.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.jsx)(x.A,{children:(0,a.jsx)(v.A,{rowKey:"relativePath",columns:G,dataSource:Z,loading:P,size:"middle",locale:{emptyText:E?e("emptySearch"):e("noFiles")},pagination:{current:B,pageSize:50,showSizeChanger:!1,onChange:V},rowSelection:{selectedRowKeys:H,onChange:z}})})]})}},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 r(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return a("/api/kb/stats".concat(t))}async function i(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)),a("/api/kb/files?".concat(r))}async function s(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function o(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 y(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function f(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 x(){return a("/api/kb/features")}async function v(e,t){var n,r,i,s,o;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!=(o=t.limit)?o: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==(i=t.weights)?void 0:i.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(s=t.weights)?void 0:s.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(c))}async function w(){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 P(e){return a("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){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 T(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function A(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function N(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(){return a("/api/documents/drafts")}async function L(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function R(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 I(){return a("/api/config/providers")}async function J(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function U(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return a("/api/config/models")}async function M(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){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 B(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function V(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return a("/api/system/stats")}async function X(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function W(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function $(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function q(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function K(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function Z(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>L,Bh:()=>Z,Dl:()=>_,E:()=>q,FC:()=>F,FV:()=>C,H1:()=>m,H7:()=>h,HC:()=>o,HT:()=>i,II:()=>H,NR:()=>S,OX:()=>N,PH:()=>$,QT:()=>u,Qx:()=>p,R1:()=>O,SJ:()=>f,UE:()=>R,VW:()=>x,W2:()=>v,X8:()=>g,Z3:()=>I,_m:()=>J,aP:()=>M,bV:()=>A,bZ:()=>V,c1:()=>d,dd:()=>z,dg:()=>j,dw:()=>P,dx:()=>w,h0:()=>T,h1:()=>U,hc:()=>r,hn:()=>X,l2:()=>k,lv:()=>b,p:()=>W,q7:()=>E,tn:()=>c,u6:()=>B,xC:()=>s,xq:()=>y,xw:()=>Q,zo:()=>K,zr:()=>D})},8209:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var a=n(7109),r=n(3793),i=n(8483);function s(){return(s=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=a.forwardRef((e,t)=>a.createElement(i.A,s({},e,{ref:t,icon:r.A})))}},e=>{e.O(0,[260,544,425,668,227,740,174,446,400,15,636,593,792],()=>e(e.s=426)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28],{426:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/files",function(){return n(6451)}])},2803:(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"}},3793:(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"}},4569: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"}},5258:(e,t,n)=>{"use strict";n.d(t,{A:()=>w});var a=n(1541),r=n(1848),i=n(1249),s=n(7109),o=n(2658),c=n(3638),l=n(2162),d=n(2725),u=n(4567),p=n(632),h=n(9517),y=n(9412),f=n(9527);let g=(0,d.U)(e=>{let{prefixCls:t,className:n,closeIcon:a,closable:r,type:i,title:d,children:g,footer:m,classNames:x,styles:v,...w}=e,{getPrefixCls:b}=s.useContext(u.QO),{className:j,style:C,classNames:S,styles:P}=(0,u.TP)("modal"),_=b(),k=t||b("modal"),T=(0,p.A)(_),[A,N]=(0,f.Ay)(k,T),[O,E]=(0,l.AV)([S,x],[P,v],{props:e}),L=`${k}-confirm`,R={};return R=i?{closable:r??!1,title:"",footer:"",children:s.createElement(h.k,{...e,prefixCls:k,confirmPrefixCls:L,rootPrefixCls:_,content:g})}:{closable:r??!0,title:d,footer:null!==m&&s.createElement(y.w,{...e}),children:g},s.createElement(o.Z,{prefixCls:k,className:(0,c.$)(A,`${k}-pure-panel`,i&&L,i&&`${L}-${i}`,n,j,N,T,O.root),style:{...C,...E.root},...w,closeIcon:(0,y.O)(k,a),closable:r,classNames:O,styles:E,...R})});var m=n(9739);function x(e){return(0,a.Ay)((0,a.fp)(e))}let v=i.A;v.useModal=m.A,v.info=function(e){return(0,a.Ay)((0,a.$D)(e))},v.success=function(e){return(0,a.Ay)((0,a.Ej)(e))},v.error=function(e){return(0,a.Ay)((0,a.jT)(e))},v.warning=x,v.warn=x,v.confirm=function(e){return(0,a.Ay)((0,a.lr)(e))},v.destroyAll=function(){for(;r.A.length;){let e=r.A.pop();e&&e()}},v.config=a.FB,v._InternalPanelDoNotUseOrYouWillBeFired=g;let w=v},5551:(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 r(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),r=Math.floor(a/24);return r>30?new Date(e).toLocaleDateString(t):"en-US"===t?r>0?"".concat(r,"d ago"):a>0?"".concat(a,"h ago"):n>0?"".concat(n,"m ago"):"Just now":r>0?"".concat(r," 天前"):a>0?"".concat(a," 小时前"):n>0?"".concat(n," 分钟前"):"刚刚"}n.d(t,{Jm:()=>o,fw:()=>r,z3:()=>a});let i={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},s={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function o(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===n?s:i)[e])?t:e}},6451:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>E});var a=n(5321),r=n(7109),i=n(3014),s=n(3220),o=n.n(s),c=n(4986),l=n(7807),d=n(5258),u=n(3442),p=n(1702),h=n(5114),y=n(4668),f=n(7271),g=n(2551),m=n(9605),x=n(8787),v=n(9400),w=n(6631),b=n(8209),j=n(486),C=n(2803),S=n(8483);function P(){return(P=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 _=r.forwardRef((e,t)=>r.createElement(S.A,P({},e,{ref:t,icon:C.A})));var k=n(6578),T=n(5551),A=n(4569),N=n.n(A);let O=["document","spreadsheet","image","cad","code","data","web","diagram","archive","other"];function E(){let e=(0,i.Vr)("knowledge"),{locale:t}=(0,i.x_)(),{message:n}=l.A.useApp(),s=(0,c.useSearchParams)().get("category")||"",[C,S]=(0,r.useState)([]),[P,A]=(0,r.useState)(!0),[E,L]=(0,r.useState)(""),[R,I]=(0,r.useState)(s),[J,U]=(0,r.useState)(!1),[D,M]=(0,r.useState)([]),[H,z]=(0,r.useState)([]),[B,V]=(0,r.useState)(1),F=(0,r.useRef)(R);(0,r.useEffect)(()=>{F.current=R},[R]);let X=(0,r.useCallback)(async e=>{let t=null!=e?e:F.current;A(!0);try{let e=await (0,k.HT)({category:t||void 0,limit:200});S(e.files||[])}catch(e){S([])}finally{A(!1)}},[]);(0,r.useEffect)(()=>{X(R)},[R,X]);let W=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}),$=(0,r.useCallback)(async()=>{try{let e=await (0,k.Qx)();M(e.operations.map(W))}catch(e){}},[]);(0,r.useEffect)(()=>{$()},[$]);let q=async()=>{try{await (0,k.H7)(),M([]),n.success("任务状态已清空")}catch(e){n.error("清空任务状态失败")}},Q=async e=>{if(0===e.length)return;let t=1===e.length?e[0].name:"".concat(e.length," 个文件");U(!0),M(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)),r=setInterval(()=>{(0,k.QT)(a).then(e=>{M(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 i,s;let o=await (0,k.c1)(e,void 0,a);clearInterval(r),(null==(i=o.vectorStatus)?void 0:i.status)==="error"?n.info("文件已上传,正在后台入库"):n.success("上传成功"),L(""),I(""),z([]),V(1),F.current="";let c=null==(s=o.files)?void 0:s.find(e=>e.relativePath===o.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 $(),M(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(o.files)?S(o.files):(await (0,k.H1)(),await X(""),await $())}catch(e){n.error("上传失败"),M(e=>[{type:"error",title:"上传失败 ".concat(t),description:"请重试或检查文件格式",status:"error"},...e].slice(0,50))}finally{clearInterval(r),U(!1)}},K=e=>{let t="selected"===e?H.map(String):"filtered"===e?Z.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()=>{M(e=>[{type:"delete",title:a,description:"正在批量删除文件和索引",status:"processing",percent:10},...e].slice(0,50));try{var r;let a=null!=(r=("all"===e?await (0,k.X8)():await (0,k.SJ)(t)).deleted)?r:t.length;n.success("已删除 ".concat(a," 个文件")),z([]),M(e=>[{type:"delete",title:"批量删除完成",description:"已删除 ".concat(a," 个文件、切片和索引"),status:"success"},...e].slice(0,50)),await X(),await $()}catch(e){n.error("批量删除失败"),M(e=>[{type:"error",title:"批量删除失败",description:"请重试",status:"error"},...e].slice(0,50))}}})},Z=E?C.filter(e=>e.relativePath.toLowerCase().includes(E.toLowerCase())):C,G=[{title:e("fileName"),dataIndex:"relativePath",key:"name",render:e=>(0,a.jsxs)(u.A,{children:[(0,a.jsx)(w.A,{}),(0,a.jsx)(o(),{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,T.Jm)(e,t)})},{title:e("fileSize"),dataIndex:"fileSize",key:"size",width:100,render:e=>(0,T.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,r)=>(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()=>{M(e=>[{type:"delete",title:"删除 ".concat(r.relativePath),description:"正在删除文件记录",status:"processing"},...e].slice(0,50));try{await (0,k.xq)(r.relativePath),n.success("已删除"),M(e=>[{type:"delete",title:"删除完成 ".concat(r.relativePath),description:"文件和索引记录已移除",status:"success"},...e].slice(0,50)),z(e=>e.filter(e=>e!==r.relativePath)),await X(),await $()}catch(e){n.error("删除失败"),M(e=>[{type:"error",title:"删除失败 ".concat(r.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)(y.A,{placeholder:e("searchPlaceholder"),prefix:(0,a.jsx)(j.A,{}),value:E,onChange:e=>{L(e.target.value),V(1)},allowClear:!0,className:N().filterInput}),(0,a.jsx)(f.A,{value:R||void 0,onChange:e=>{I(e||""),V(1)},placeholder:e("filterCategory"),allowClear:!0,className:N().filterSelect,options:[{label:e("allCategories"),value:""},...O.map(e=>({label:(0,T.Jm)(e,t),value:e}))]}),(0,a.jsx)(h.Ay,{type:"primary",icon:(0,a.jsx)(_,{}),loading:J,onClick:()=>{var e;return null==(e=document.getElementById("kb-file-upload-input"))?void 0:e.click()},children:J?e("uploading"):e("upload")}),(0,a.jsx)(h.Ay,{icon:(0,a.jsx)(_,{}),loading:J,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===H.length,icon:(0,a.jsx)(b.A,{}),onClick:()=>K("selected"),children:["删除已选 ",H.length||""]}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===Z.length||!E&&!R,onClick:()=>K("filtered"),children:"删除筛选结果"}),(0,a.jsx)(h.Ay,{danger:!0,disabled:0===C.length,onClick:()=>K("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="",Q(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="",Q(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)(w.A,{}),"文件任务状态"]}),(0,a.jsx)(h.Ay,{size:"small",type:"text",disabled:0===D.length,onClick:()=>void q(),children:"清空"})]}),0===D.length?(0,a.jsx)("div",{className:N().statusEmpty,children:"暂无文件任务。"}):(0,a.jsx)("div",{className:N().statusList,children:D.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.jsx)(x.A,{children:(0,a.jsx)(v.A,{rowKey:"relativePath",columns:G,dataSource:Z,loading:P,size:"middle",locale:{emptyText:E?e("emptySearch"):e("noFiles")},pagination:{current:B,pageSize:50,showSizeChanger:!1,onChange:V},rowSelection:{selectedRowKeys:H,onChange:z}})})]})}},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 r(e){let t=e?"?projectRoot=".concat(encodeURIComponent(e)):"";return a("/api/kb/stats".concat(t))}async function i(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)),a("/api/kb/files?".concat(r))}async function s(e,t){let n=new URLSearchParams({relativePath:e});return t&&n.set("projectRoot",t),a("/api/kb/files/detail?".concat(n))}async function o(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 y(e,t){return a("/api/kb/files",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({relativePath:e,projectRoot:t})})}async function f(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 x(){return a("/api/kb/features")}async function v(e,t){var n,r,i,s,o;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!=(o=t.limit)?o: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==(i=t.weights)?void 0:i.rewrite)!=null&&c.set("rewriteWeight",String(t.weights.rewrite)),(null==t||null==(s=t.weights)?void 0:s.hybridBonus)!=null&&c.set("hybridBonus",String(t.weights.hybridBonus)),a("/api/kb/search?".concat(c))}async function w(){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 P(e){return a("/api/documents/roles?mode=config&id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function _(){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 T(e){return a("/api/documents/templates?templateId=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function A(e){return a("/api/documents/templates",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:e})})}async function N(e){return a("/api/documents/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function O(e){return a("/api/documents/chapter/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function E(){return a("/api/documents/drafts")}async function L(e,t){return a("/api/documents/drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,id:t})})}async function R(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 I(){return a("/api/config/providers")}async function J(e,t){return a("/api/config/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,...t})})}async function U(e){return a("/api/config/providers/".concat(encodeURIComponent(e)),{method:"DELETE"})}async function D(){return a("/api/config/models")}async function M(e){return a("/api/config/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function H(){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 B(){return a("/api/config/embedding/healthCheck",{method:"POST"})}async function V(e){return a("/api/config/healthCheck",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})})}async function F(){return a("/api/system/stats")}async function X(e,t){let n=t?"?type=".concat(e,"&search=").concat(encodeURIComponent(t)):"?type=".concat(e);return a("/api/context".concat(n))}async function W(e){return a("/api/context?type=".concat(e,"&stats=1"))}async function $(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"compress",type:e})})}async function q(e){return a("/api/context",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear",type:e})})}async function Q(e){return a("/api/context?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}async function K(e,t){return a("/api/context",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})})}async function Z(e){return a("/api/config/providers/".concat(encodeURIComponent(e)))}n.d(t,{Af:()=>L,Bh:()=>Z,Dl:()=>_,E:()=>q,FC:()=>F,FV:()=>C,H1:()=>m,H7:()=>h,HC:()=>o,HT:()=>i,II:()=>H,NR:()=>S,OX:()=>N,PH:()=>$,QT:()=>u,Qx:()=>p,R1:()=>O,SJ:()=>f,UE:()=>R,VW:()=>x,W2:()=>v,X8:()=>g,Z3:()=>I,_m:()=>J,aP:()=>M,bV:()=>A,bZ:()=>V,c1:()=>d,dd:()=>z,dg:()=>j,dw:()=>P,dx:()=>w,h0:()=>T,h1:()=>U,hc:()=>r,hn:()=>X,l2:()=>k,lv:()=>b,p:()=>W,q7:()=>E,tn:()=>c,u6:()=>B,xC:()=>s,xq:()=>y,xw:()=>Q,zo:()=>K,zr:()=>D})},8209:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var a=n(7109),r=n(3793),i=n(8483);function s(){return(s=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=a.forwardRef((e,t)=>a.createElement(i.A,s({},e,{ref:t,icon:r.A})))}},e=>{e.O(0,[260,167,382,201,668,227,740,174,446,400,15,636,593,792],()=>e(e.s=426)),_N_E=e.O()}]);
|