@customize-agent/server 4.0.17 → 4.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/required-server-files.json +2 -2
  5. package/.next/server/middleware-build-manifest.js +1 -1
  6. package/.next/server/pages/404.html +1 -1
  7. package/.next/server/pages/500.html +1 -1
  8. package/.next/server/pages/api/prompt/chat.js +6 -3
  9. package/.next/server/pages/asset-library.html +1 -1
  10. package/.next/server/pages/context/long-term.html +1 -1
  11. package/.next/server/pages/context/short-term.html +1 -1
  12. package/.next/server/pages/document-roles.html +1 -1
  13. package/.next/server/pages/document-specs.html +1 -1
  14. package/.next/server/pages/documents.html +1 -1
  15. package/.next/server/pages/guide.html +1 -1
  16. package/.next/server/pages/index.html +1 -1
  17. package/.next/server/pages/knowledge/file-detail.html +1 -1
  18. package/.next/server/pages/knowledge/files.html +1 -1
  19. package/.next/server/pages/knowledge/manage.html +1 -1
  20. package/.next/server/pages/knowledge/search.html +1 -1
  21. package/.next/server/pages/knowledge.html +1 -1
  22. package/.next/server/pages/models.html +1 -1
  23. package/.next/server/pages/overview.html +1 -1
  24. package/.next/server/pages/prompt.html +1 -1
  25. package/.next/server/pages/settings.html +1 -1
  26. package/.next/server/pages/system/logs.html +1 -1
  27. package/.next/server/pages-manifest.json +27 -27
  28. package/.next/static/{lsztDhTkEy3WwGjvuXb2a → GCkNWTRMO7SCR-dJ4k1aa}/_buildManifest.js +1 -1
  29. package/.next/static/chunks/pages/prompt-953d531bb606bd1d.js +1 -0
  30. package/{next.config.js → next.config.ts} +4 -3
  31. package/package.json +6 -6
  32. package/.next/static/chunks/pages/prompt-31107707a8e8d33c.js +0 -1
  33. /package/.next/static/{lsztDhTkEy3WwGjvuXb2a → GCkNWTRMO7SCR-dJ4k1aa}/_ssgManifest.js +0 -0
@@ -1,65 +1,65 @@
1
1
  {
2
2
  "/_app": "pages/_app.js",
3
3
  "/_error": "pages/_error.js",
4
+ "/api/assets/generated": "pages/api/assets/generated.js",
5
+ "/api/assets/generated/preview": "pages/api/assets/generated/preview.js",
4
6
  "/api/config/embedding/healthCheck": "pages/api/config/embedding/healthCheck.js",
7
+ "/api/config/models": "pages/api/config/models.js",
5
8
  "/api/documents/chapter/regenerate": "pages/api/documents/chapter/regenerate.js",
6
- "/api/assets/generated/preview": "pages/api/assets/generated/preview.js",
7
9
  "/api/documents/drafts": "pages/api/documents/drafts.js",
8
- "/api/assets/generated": "pages/api/assets/generated.js",
9
- "/api/config/models": "pages/api/config/models.js",
10
10
  "/api/context": "pages/api/context.js",
11
- "/api/documents/roles": "pages/api/documents/roles.js",
12
- "/api/documents/generated": "pages/api/documents/generated.js",
11
+ "/api/documents/generated/[id]": "pages/api/documents/generated/[id].js",
13
12
  "/api/documents/generate": "pages/api/documents/generate.js",
13
+ "/api/documents/generated": "pages/api/documents/generated.js",
14
14
  "/api/documents/specs": "pages/api/documents/specs.js",
15
+ "/api/documents/roles": "pages/api/documents/roles.js",
15
16
  "/api/documents/templates": "pages/api/documents/templates.js",
16
17
  "/api/kb/categories": "pages/api/kb/categories.js",
18
+ "/api/health": "pages/api/health.js",
19
+ "/api/jobs": "pages/api/jobs.js",
17
20
  "/api/kb/duplicates": "pages/api/kb/duplicates.js",
18
- "/api/jobs/[id]": "pages/api/jobs/[id].js",
19
- "/api/kb/features": "pages/api/kb/features.js",
20
21
  "/api/kb/files/detail": "pages/api/kb/files/detail.js",
21
- "/api/kb/files/reindex": "pages/api/kb/files/reindex.js",
22
+ "/api/kb/features": "pages/api/kb/features.js",
23
+ "/api/kb/files": "pages/api/kb/files.js",
22
24
  "/api/kb/files/open": "pages/api/kb/files/open.js",
25
+ "/api/jobs/[id]": "pages/api/jobs/[id].js",
23
26
  "/api/kb/operations": "pages/api/kb/operations.js",
24
27
  "/api/kb/ignore": "pages/api/kb/ignore.js",
25
- "/api/kb/files": "pages/api/kb/files.js",
28
+ "/api/kb/files/reindex": "pages/api/kb/files/reindex.js",
26
29
  "/api/kb/search": "pages/api/kb/search.js",
27
- "/api/documents/generated/[id]": "pages/api/documents/generated/[id].js",
28
- "/api/kb/stats": "pages/api/kb/stats.js",
30
+ "/api/kb/tags": "pages/api/kb/tags.js",
29
31
  "/api/kb/reindex": "pages/api/kb/reindex.js",
30
- "/api/jobs": "pages/api/jobs.js",
32
+ "/api/kb/stats": "pages/api/kb/stats.js",
31
33
  "/api/kb/upload/progress": "pages/api/kb/upload/progress.js",
32
- "/api/kb/tags": "pages/api/kb/tags.js",
33
- "/api/prompt": "pages/api/prompt.js",
34
34
  "/api/system/logs": "pages/api/system/logs.js",
35
- "/asset-library": "pages/asset-library.html",
35
+ "/api/prompt": "pages/api/prompt.js",
36
+ "/api/system/stats": "pages/api/system/stats.js",
36
37
  "/context/long-term": "pages/context/long-term.html",
37
38
  "/context/short-term": "pages/context/short-term.html",
39
+ "/asset-library": "pages/asset-library.html",
40
+ "/document-roles": "pages/document-roles.html",
41
+ "/document-specs": "pages/document-specs.html",
38
42
  "/guide": "pages/guide.html",
39
- "/api/health": "pages/api/health.js",
43
+ "/documents": "pages/documents.html",
40
44
  "/": "pages/index.html",
41
- "/document-specs": "pages/document-specs.html",
45
+ "/knowledge": "pages/knowledge.html",
42
46
  "/knowledge/file-detail": "pages/knowledge/file-detail.html",
43
47
  "/knowledge/files": "pages/knowledge/files.html",
44
- "/documents": "pages/documents.html",
45
- "/knowledge": "pages/knowledge.html",
46
- "/document-roles": "pages/document-roles.html",
47
48
  "/knowledge/search": "pages/knowledge/search.html",
48
49
  "/knowledge/manage": "pages/knowledge/manage.html",
49
50
  "/overview": "pages/overview.html",
50
51
  "/models": "pages/models.html",
51
- "/api/system/stats": "pages/api/system/stats.js",
52
- "/prompt": "pages/prompt.html",
53
- "/system/logs": "pages/system/logs.html",
54
- "/settings": "pages/settings.html",
55
- "/api/config/providers/[provider]": "pages/api/config/providers/[provider].js",
56
52
  "/api/config/healthCheck": "pages/api/config/healthCheck.js",
57
- "/api/config/embedding": "pages/api/config/embedding.js",
53
+ "/api/config/providers/[provider]": "pages/api/config/providers/[provider].js",
58
54
  "/api/config/providers": "pages/api/config/providers.js",
55
+ "/api/config/embedding": "pages/api/config/embedding.js",
56
+ "/system/logs": "pages/system/logs.html",
59
57
  "/api/kb/files/preview-pdf-page": "pages/api/kb/files/preview-pdf-page.js",
60
58
  "/api/documents/export": "pages/api/documents/export.js",
61
- "/api/prompt/chat": "pages/api/prompt/chat.js",
59
+ "/prompt": "pages/prompt.html",
62
60
  "/api/kb/upload": "pages/api/kb/upload.js",
61
+ "/api/prompt/chat": "pages/api/prompt/chat.js",
62
+ "/settings": "pages/settings.html",
63
63
  "/_document": "pages/_document.js",
64
64
  "/404": "pages/404.html"
65
65
  }
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST=function(s,e,t,c,a,n,d,i,u,o,r,f,k,g,h,l,b){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:g,bitArray:[]},__routerFilterDynamic:{numItems:u,errorRate:1e-4,numBits:u,numHashes:g,bitArray:[]},"/":["static/chunks/pages/index-c5e0758e6b31deee.js"],"/_error":["static/chunks/pages/_error-282257fbdcc167b4.js"],"/asset-library":[s,e,n,"static/chunks/749-dcb0cd85d1455f34.js","static/chunks/pages/asset-library-e9ddfe1cbaac42d9.js"],"/context/long-term":[s,e,t,c,a,n,d,i,h,"static/chunks/pages/context/long-term-2e6a30a8f879df47.js"],"/context/short-term":[s,e,t,c,a,n,d,i,h,"static/chunks/pages/context/short-term-730211234fa3add6.js"],"/document-roles":[s,e,t,c,d,"static/chunks/698-625f34d5d0052e87.js","static/chunks/pages/document-roles-7197641736843503.js"],"/document-specs":[s,e,t,c,d,r,"static/chunks/265-c3a46cef96364aac.js","static/chunks/pages/document-specs-033d848b03b54df3.js"],"/documents":[s,e,t,c,d,o,l,"static/chunks/447-772df02993a8609b.js","static/chunks/pages/documents-3b2f23e2d6b27f1b.js"],"/guide":[s,e,l,"static/chunks/20-23d24b40b69faf0f.js","static/chunks/pages/guide-cdf68a096918c979.js"],"/knowledge":["static/chunks/pages/knowledge-905248d8dcb15453.js"],"/knowledge/file-detail":[s,e,t,a,n,i,o,b,f,"static/chunks/pages/knowledge/file-detail-0a5e267f77f4e8b3.js"],"/knowledge/files":[s,e,t,a,n,i,f,"static/chunks/pages/knowledge/files-a1727a21113f99cd.js"],"/knowledge/manage":[s,e,o,"static/chunks/788-f74cda5d27cf4390.js","static/chunks/pages/knowledge/manage-25eb1a993b155450.js"],"/knowledge/search":[s,e,t,o,r,f,"static/chunks/pages/knowledge/search-2cee4e8b8792170c.js"],"/models":[s,e,t,c,a,d,r,"static/chunks/pages/models-b5f68c4c70257495.js"],"/overview":[s,e,"static/chunks/131-96749f5b6e1460d1.js","static/chunks/pages/overview-28c7ceeca56e6a78.js"],"/prompt":[s,e,t,c,a,"static/chunks/36-205281971ae6919f.js","static/chunks/pages/prompt-31107707a8e8d33c.js"],"/settings":[s,e,"static/chunks/pages/settings-fa9d6a56898ba678.js"],"/system/logs":[s,t,c,a,n,i,b,"static/chunks/pages/system/logs-f4e222140dc7b30c.js"],sortedPages:["/","/_app","/_error","/asset-library","/context/long-term","/context/short-term","/document-roles","/document-specs","/documents","/guide","/knowledge","/knowledge/file-detail","/knowledge/files","/knowledge/manage","/knowledge/search","/models","/overview","/prompt","/settings","/system/logs"]}}("static/chunks/433-ef3d7675b81826a9.js","static/chunks/787-196a2bed7b11745a.js","static/chunks/576-679ab6348b33b960.js","static/chunks/195-9f2e4c67a9deff05.js","static/chunks/985-da0b1f68e59d1e76.js","static/chunks/150-a7b953a600cbd7e0.js","static/chunks/455-9e1e1c7e96845347.js","static/chunks/289-36c210992d5009d5.js",0,"static/chunks/506-b97aadd3e451b379.js","static/chunks/938-0063785681203bb5.js","static/css/09be1fdeab8595ab.css",1e-4,NaN,"static/chunks/932-823e1ae10dd43b8b.js","static/chunks/412-b9c854c6a76db67d.js","static/chunks/512-e2813c7e9454d53c.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST=function(s,e,t,c,a,n,d,i,u,o,r,k,f,g,h,l,b){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:0,errorRate:1e-4,numBits:0,numHashes:g,bitArray:[]},__routerFilterDynamic:{numItems:u,errorRate:1e-4,numBits:u,numHashes:g,bitArray:[]},"/":["static/chunks/pages/index-c5e0758e6b31deee.js"],"/_error":["static/chunks/pages/_error-282257fbdcc167b4.js"],"/asset-library":[s,e,n,"static/chunks/749-dcb0cd85d1455f34.js","static/chunks/pages/asset-library-e9ddfe1cbaac42d9.js"],"/context/long-term":[s,e,t,c,a,n,d,i,h,"static/chunks/pages/context/long-term-2e6a30a8f879df47.js"],"/context/short-term":[s,e,t,c,a,n,d,i,h,"static/chunks/pages/context/short-term-730211234fa3add6.js"],"/document-roles":[s,e,t,c,d,"static/chunks/698-625f34d5d0052e87.js","static/chunks/pages/document-roles-7197641736843503.js"],"/document-specs":[s,e,t,c,d,r,"static/chunks/265-c3a46cef96364aac.js","static/chunks/pages/document-specs-033d848b03b54df3.js"],"/documents":[s,e,t,c,d,o,l,"static/chunks/447-772df02993a8609b.js","static/chunks/pages/documents-3b2f23e2d6b27f1b.js"],"/guide":[s,e,l,"static/chunks/20-23d24b40b69faf0f.js","static/chunks/pages/guide-cdf68a096918c979.js"],"/knowledge":["static/chunks/pages/knowledge-905248d8dcb15453.js"],"/knowledge/file-detail":[s,e,t,a,n,i,o,b,k,"static/chunks/pages/knowledge/file-detail-0a5e267f77f4e8b3.js"],"/knowledge/files":[s,e,t,a,n,i,k,"static/chunks/pages/knowledge/files-a1727a21113f99cd.js"],"/knowledge/manage":[s,e,o,"static/chunks/788-f74cda5d27cf4390.js","static/chunks/pages/knowledge/manage-25eb1a993b155450.js"],"/knowledge/search":[s,e,t,o,r,k,"static/chunks/pages/knowledge/search-2cee4e8b8792170c.js"],"/models":[s,e,t,c,a,d,r,"static/chunks/pages/models-b5f68c4c70257495.js"],"/overview":[s,e,"static/chunks/131-96749f5b6e1460d1.js","static/chunks/pages/overview-28c7ceeca56e6a78.js"],"/prompt":[s,e,t,c,a,"static/chunks/36-205281971ae6919f.js","static/chunks/pages/prompt-953d531bb606bd1d.js"],"/settings":[s,e,"static/chunks/pages/settings-fa9d6a56898ba678.js"],"/system/logs":[s,t,c,a,n,i,b,"static/chunks/pages/system/logs-f4e222140dc7b30c.js"],sortedPages:["/","/_app","/_error","/asset-library","/context/long-term","/context/short-term","/document-roles","/document-specs","/documents","/guide","/knowledge","/knowledge/file-detail","/knowledge/files","/knowledge/manage","/knowledge/search","/models","/overview","/prompt","/settings","/system/logs"]}}("static/chunks/433-ef3d7675b81826a9.js","static/chunks/787-196a2bed7b11745a.js","static/chunks/576-679ab6348b33b960.js","static/chunks/195-9f2e4c67a9deff05.js","static/chunks/985-da0b1f68e59d1e76.js","static/chunks/150-a7b953a600cbd7e0.js","static/chunks/455-9e1e1c7e96845347.js","static/chunks/289-36c210992d5009d5.js",0,"static/chunks/506-b97aadd3e451b379.js","static/chunks/938-0063785681203bb5.js","static/css/09be1fdeab8595ab.css",1e-4,NaN,"static/chunks/932-823e1ae10dd43b8b.js","static/chunks/412-b9c854c6a76db67d.js","static/chunks/512-e2813c7e9454d53c.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[26],{27549:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/prompt",function(){return r(34508)}])},34508:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>J});var o=r(65321),i=r(97109),n=r(79059),l=r(17807),a=r(88762),s=r(68787),c=r(33442),d=r(11702),p=r(57271),h=r(85114),x=r(84253),m=r(56985),y=r(26171),u=r(34052),f=r(7576),g=r(42700),j=r(55122),v=r(29606),S=r(96091),w=r(81668),A=r(54746),b=r(26631),C=r(99650),z=r(58209),k=r(24810),T=r(7492);async function E(){let e=await fetch("/api/prompt");if(!e.ok)throw Error("Failed");return e.json()}async function N(e,t,r){let o=await fetch("/api/prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e,content:t,name:r})});if(!o.ok)throw Error("Failed");return o.json()}async function O(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create",projectRoot:e,content:"# CUSTOMIZE\n"})});if(!t.ok)throw Error("Failed");return t.json()}async function R(e,t){let r=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"createCustom",name:e,content:t})});if(!r.ok)throw Error("Failed");return r.json()}async function B(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"select",selectedIds:e})});if(!t.ok)throw Error("Failed");return t.json()}async function P(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"import",...e&&"object"==typeof e?e:{prompts:[]}})});if(!t.ok)throw Error(await t.text());return t.json()}async function F(){let e=await fetch("/api/kb/files?limit=200");if(!e.ok)throw Error("Failed");return(await e.json()).files||[]}async function I(e){let t=await fetch("/api/kb/files/detail?relativePath=".concat(encodeURIComponent(e)));if(!t.ok)throw Error("Failed");return((await t.json()).chunks||[]).map(e=>e.content||"").filter(Boolean).join("\n\n").slice(0,12e3)}async function H(e){let t=await fetch("/api/prompt/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.text();try{let t=JSON.parse(e);throw Error(t.error||t.message||e||"AI 对话失败")}catch(t){throw Error(e||"AI 对话失败")}}return t.json()}function _(e){return e.id.startsWith("builtin:")}function W(e){return e.id.startsWith("custom:")}function J(){let e=(0,n.Vr)(),{message:t}=l.A.useApp(),[r,J]=(0,i.useState)(!0),[D,M]=(0,i.useState)([]),[U,L]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(null),[G,K]=(0,i.useState)(""),[V,Z]=(0,i.useState)(""),[$,q]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(!1),[et,er]=(0,i.useState)("custom"),[eo,ei]=(0,i.useState)(!1),[en,el]=(0,i.useState)([]),[ea,es]=(0,i.useState)(""),[ec,ed]=(0,i.useState)(""),[ep,eh]=(0,i.useState)(!1),[ex,em]=(0,i.useState)([]),[ey,eu]=(0,i.useState)([]),[ef,eg]=(0,i.useState)(!1),[ej,ev]=(0,i.useState)(!1),eS=(0,i.useRef)(null),ew=(0,i.useRef)(null),eA=async()=>{J(!0);try{M(await E())}catch(r){t.error(e("common.error"))}finally{J(!1)}};(0,i.useEffect)(()=>{eA()},[]),(0,i.useEffect)(()=>{let e=ew.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ea&&window.localStorage.setItem(ea,JSON.stringify(en.slice(-30)))},[en,ep,ea]),(0,i.useEffect)(()=>{!U||ex.length>0||ef||(eg(!0),F().then(em).catch(()=>void 0).finally(()=>eg(!1)))},[U,ex.length,ef]);let eb=(e,t)=>{let r="customize-agent:prompt-chat:".concat((null==e?void 0:e.id)||(null==e?void 0:e.customizePath)||t||"new");es(r),el(function(e){try{let t=JSON.parse(window.localStorage.getItem(e)||"[]");return Array.isArray(t)?t.filter(e=>("user"===e.role||"assistant"===e.role)&&"string"==typeof e.content).slice(-30):[]}catch(e){return[]}}(r)),ed(""),eh(!1),eu([]),ev(!1)},eC=r=>{if(null==r?void 0:r.projectRoot)return void O(r.projectRoot).then(()=>{t.success(e("common.success")),eA()}).catch(()=>t.error(e("common.error")));Y(null),ee(!0),Z(""),K(""),eb(null,"new"),L(!0)},ez=async()=>{if(!V.trim())return void t.error("请输入名称");q(!0);try{X?await N(X.customizePath,G,W(X)?V.trim():void 0):await R(V.trim(),G||"# ".concat(V.trim(),"\n")),t.success(e("common.success")),L(!1),await eA()}catch(r){t.error(e("common.error"))}finally{q(!1)}},ek=async()=>{let e=Array.from(new Set([...ey,...ex.filter(e=>ec.includes("@".concat(e.relativePath))).map(e=>e.relativePath)])).slice(0,3),t=[];for(let r of e){let e=await I(r);e&&t.push({relativePath:r,content:e})}return t},eT=async()=>{let e=ec.trim();if(!e||ep)return;let r=[...en,{role:"user",content:e}];el(r),ed(""),ev(!1),eh(!0);try{let t=await ek(),o=await H({name:V||(null==X?void 0:X.projectName)||"未命名提示词",content:G,message:e,history:en,references:t});el([...r,{role:"assistant",content:o.content||"AI 未返回内容"}])}catch(e){t.error(e instanceof Error?e.message:"AI 对话失败,请检查模型配置"),el(r)}finally{eh(!1)}},eE=async(r,o)=>{let i=o?Array.from(new Set([...D.filter(e=>e.selected).map(e=>e.id),r.id])):D.filter(e=>e.selected&&e.id!==r.id).map(e=>e.id);try{await B(i),M(e=>e.map(e=>({...e,selected:i.includes(e.id)})))}catch(r){t.error(e("common.error"))}},eN=async r=>{try{if(!(await fetch("/api/prompt",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r.projectId,filePath:r.customizePath})})).ok)throw Error("Failed");t.success(e("common.success")),await eA()}catch(r){t.error(e("common.error"))}},eO=async e=>{if(e){ei(!0);try{let r=await e.text(),o=JSON.parse(r),i=await P(o);t.success("已导入 ".concat(i.imported," 条提示词")),await eA()}catch(e){t.error("导入失败,请确认 JSON 文件格式正确")}finally{ei(!1),eS.current&&(eS.current.value="")}}},eR=D.find(e=>e.isCurrent),eB=D.filter(_),eP=D.filter(W),eF=D.filter(e=>!_(e)&&!W(e)),eI="all"===et?D:"builtin"===et?eB:"custom"===et?eP:eF;return r?(0,o.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,o.jsx)(a.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:12},children:Array.from({length:4}).map((e,t)=>(0,o.jsx)(s.A,{size:"small",children:(0,o.jsx)(a.A,{active:!0,paragraph:{rows:4}})},t))})]}):(0,o.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle",children:e("nav.promptManagement")}),(0,o.jsx)("p",{className:"pageDesc",children:e("prompt.description")})]}),(0,o.jsxs)(c.A,{children:[eR&&(0,o.jsxs)(d.A,{color:"green",style:{lineHeight:"22px"},children:[(0,o.jsx)(v.A,{})," ",eR.projectRoot]}),(0,o.jsx)(p.A,{value:et,onChange:er,style:{width:160},options:[{label:"全部 (".concat(D.length,")"),value:"all"},{label:"我的提示词 (".concat(eP.length,")"),value:"custom"},{label:"项目提示词 (".concat(eF.length,")"),value:"project"},{label:"内置示例 (".concat(eB.length,")"),value:"builtin"}]}),(0,o.jsx)("input",{ref:eS,type:"file",accept:"application/json,.json",style:{display:"none"},onChange:e=>{var t;eO(null==(t=e.target.files)?void 0:t[0])}}),(0,o.jsx)(h.Ay,{icon:(0,o.jsx)(S.A,{}),loading:eo,onClick:()=>{var e;return null==(e=eS.current)?void 0:e.click()},children:"导入"}),(0,o.jsx)(h.Ay,{icon:(0,o.jsx)(w.A,{}),disabled:0===eP.length,onClick:()=>{let e=eP.map(e=>["# ".concat(e.projectName),"",e.content||"",""].join("\n")).join("\n---\n\n");!function(e,t){let r=new Blob([t],{type:"text/plain;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=e,i.click(),URL.revokeObjectURL(o)}("customize-prompts-".concat(new Date().toISOString().slice(0,10),".txt"),e),t.success("已导出 ".concat(eP.length," 条我的提示词"))},children:"导出"}),(0,o.jsx)(h.Ay,{type:"primary",icon:(0,o.jsx)(A.A,{}),onClick:()=>eC(),children:"创建提示词"})]})]}),0===eI.length?(0,o.jsx)(x.A,{description:e("prompt.noProjects")}):(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:12},children:eI.map(e=>{let r=e.hasFile&&e.content?e.content.replace(/^#.*$/gm,"").replace(/\n{3,}/g,"\n\n").trim():"";return(0,o.jsxs)(s.A,{size:"small",hoverable:!0,styles:{body:{display:"flex",flexDirection:"column",height:"100%"}},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[(0,o.jsx)(b.A,{style:{color:e.isCurrent?"var(--colorOk)":"var(--colorAccent)",fontSize:14,flexShrink:0}}),(0,o.jsx)("span",{style:{fontWeight:600,fontSize:13,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.projectName}),!e.hasFile&&e.projectRoot&&(0,o.jsx)(h.Ay,{size:"small",icon:(0,o.jsx)(A.A,{}),onClick:()=>eC(e)})]}),e.projectRoot&&(0,o.jsxs)("div",{style:{fontSize:11,color:"var(--colorTextSecondary)",marginBottom:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,o.jsx)(v.A,{style:{marginRight:4}}),e.projectRoot]}),(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:[e.isCurrent&&(0,o.jsx)(d.A,{color:"green",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"当前项目"}),_(e)&&(0,o.jsx)(d.A,{color:"gold",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"内置示例"}),W(e)&&(0,o.jsx)(d.A,{color:"cyan",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"我的提示词"}),!_(e)&&!W(e)&&(0,o.jsx)(d.A,{color:"blue",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"项目提示词"}),e.selected&&(0,o.jsx)(d.A,{color:"purple",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"已选中"}),e.hasFile?(0,o.jsx)(d.A,{color:"blue",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"有文件"}):(0,o.jsx)(d.A,{color:"default",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"无文件"})]}),r&&(0,o.jsxs)("div",{style:{padding:8,background:"var(--colorFillAlter)",borderRadius:6,fontSize:11,maxHeight:80,overflow:"hidden",color:"var(--colorTextSecondary)",whiteSpace:"pre-wrap",fontFamily:"monospace",marginBottom:8,lineHeight:1.5},children:[r.slice(0,180),r.length>180?"...":""]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,paddingTop:8,borderTop:"1px solid var(--colorBorderSecondary)",marginTop:"auto"},children:[e.hasFile?(0,o.jsx)(m.A,{checked:e.selected,onChange:t=>{eE(e,t.target.checked)},style:{fontSize:12},children:"选中"}):(0,o.jsx)("span",{}),(0,o.jsx)("div",{style:{flex:1}}),e.hasFile&&(0,o.jsx)(h.Ay,{size:"small",icon:(0,o.jsx)(C.A,{}),onClick:()=>(e=>{if(_(e)){let r=e.projectName.replace(/^内置|/,"")+" Copy";Y(null),ee(!0),Z(r),K(e.content||""),eb(null,r),L(!0),t.info("内置提示词不可直接编辑,已为你创建副本");return}Y(e),ee(!1),Z(e.projectName),K(e.content||""),eb(e,e.projectName),L(!0)})(e),children:_(e)?"复制":"编辑"}),(0,o.jsx)(y.A,{title:_(e)?"删除内置提示词?":W(e)?"删除自定义提示词?":"删除项目记录及文件?",disabled:_(e),onConfirm:()=>{eN(e)},children:(0,o.jsx)(h.Ay,{size:"small",danger:!0,icon:(0,o.jsx)(z.A,{}),disabled:_(e)})})]})]},e.id)})}),(0,o.jsxs)(u.A,{title:Q?"创建提示词":X&&W(X)?"编辑我的提示词 — ".concat(V||X.projectName):"编辑项目提示词 — ".concat((null==X?void 0:X.projectName)||""),open:U,onClose:()=>L(!1),width:800,maskClosable:!1,style:{borderRadius:"12px 0 0 12px"},styles:{body:{padding:"16px 24px",display:"flex",flexDirection:"column",gap:12,height:"100%"},header:{borderRadius:"12px 0 0 0",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,o.jsxs)(c.A,{children:[(0,o.jsx)(h.Ay,{onClick:()=>L(!1),children:e("common.cancel")}),(0,o.jsx)(h.Ay,{type:"primary",loading:$,onClick:()=>{ez()},children:e("common.save")})]}),children:[(0,o.jsxs)("div",{style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[(0,o.jsx)("div",{style:{marginBottom:12},children:Q||X&&W(X)?(0,o.jsxs)(c.A,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,o.jsx)(f.A,{placeholder:"提示词名称",value:V,onChange:e=>Z(e.target.value),style:{maxWidth:400}}),!Q&&(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==X?void 0:X.customizePath})]}):(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==X?void 0:X.customizePath})}),(0,o.jsx)(f.A.TextArea,{value:G,onChange:e=>K(e.target.value),style:{flex:1,minHeight:280,fontFamily:"SF Mono, Monaco, Consolas, monospace",fontSize:13,resize:"none"}})]}),(0,o.jsxs)("div",{style:{flex:"0 0 300px",border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:"var(--colorBgContainer)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 8px 24px rgba(15, 23, 42, 0.06)"},children:[(0,o.jsxs)("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--colorBorderSecondary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,o.jsxs)(c.A,{size:6,children:[(0,o.jsx)(k.A,{style:{color:"var(--colorAccent)"}}),(0,o.jsx)("span",{style:{fontWeight:600},children:"AI 提示词助手"})]}),(0,o.jsxs)(c.A,{size:6,children:[en.length>0&&(0,o.jsx)(h.Ay,{size:"small",onClick:()=>el([]),children:"清空历史"}),ep?(0,o.jsx)(d.A,{color:"processing",style:{margin:0},children:"生成中"}):(0,o.jsx)(d.A,{color:"blue",style:{margin:0},children:"可对话优化"})]})]}),(0,o.jsx)("div",{ref:ew,style:{flex:1,minHeight:0,overflowY:"auto",padding:12,background:"var(--colorFillAlter)"},children:0!==en.length||ep?(0,o.jsxs)(c.A,{direction:"vertical",size:10,style:{width:"100%"},children:[en.map((e,r)=>{let i="user"===e.role;return(0,o.jsx)("div",{style:{display:"flex",justifyContent:i?"flex-end":"flex-start"},children:(0,o.jsxs)("div",{style:{maxWidth:"88%",padding:"8px 10px",borderRadius:10,background:i?"var(--colorFillSecondary)":"var(--colorBgContainer)",color:"var(--colorText)",border:"1px solid var(--colorBorderSecondary)",whiteSpace:"pre-wrap",lineHeight:1.6,fontSize:13,transition:"all .2s ease"},children:[e.content,!i&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:(0,o.jsx)(h.Ay,{size:"small",type:"primary",onClick:()=>{K(e.content),t.success("已应用到编辑内容,请确认后保存")},children:"应用"})})]})},"".concat(e.role,"-").concat(r))}),ep&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-start"},children:(0,o.jsxs)("div",{style:{padding:"8px 10px",borderRadius:10,background:"var(--colorBgContainer)",border:"1px solid var(--colorBorderSecondary)",color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(g.A,{size:"small",style:{marginRight:8}}),"AI 正在分析并生成内容..."]})})]}):(0,o.jsx)(x.A,{image:x.A.PRESENTED_IMAGE_SIMPLE,description:"输入你的修改目标,例如:帮我变得更适合事实抽取"})}),(0,o.jsx)(j.A,{style:{margin:0}}),(0,o.jsxs)("div",{style:{padding:10},children:[ey.length>0&&(0,o.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:ey.map(e=>(0,o.jsxs)(d.A,{closable:!0,onClose:()=>eu(t=>t.filter(t=>t!==e)),style:{margin:0,maxWidth:210,overflow:"hidden",textOverflow:"ellipsis"},children:["@",e]},e))}),ej&&(0,o.jsx)("div",{style:{maxHeight:120,overflowY:"auto",marginBottom:8,border:"1px solid var(--colorBorderSecondary)",borderRadius:8,background:"var(--colorBgContainer)"},children:ef?(0,o.jsxs)("div",{style:{padding:10,color:"var(--colorTextSecondary)",fontSize:12},children:[(0,o.jsx)(g.A,{size:"small",style:{marginRight:8}}),"正在加载知识库文件..."]}):0===ex.length?(0,o.jsx)("div",{style:{padding:10,color:"var(--colorTextSecondary)",fontSize:12},children:"暂无可召回的知识库文件"}):ex.slice(0,20).map(e=>(0,o.jsxs)("div",{onMouseDown:t=>{var r;t.preventDefault(),r=e.relativePath,eu(e=>e.includes(r)?e:[...e,r]),ed(e=>e.endsWith("@")?"".concat(e).concat(r," "):"".concat(e," @").concat(r," ")),ev(!1)},style:{padding:"7px 10px",cursor:"pointer",borderBottom:"1px solid var(--colorBorderSecondary)",fontSize:12},children:[(0,o.jsx)(b.A,{style:{marginRight:6,color:"var(--colorAccent)"}}),e.relativePath]},e.relativePath))}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[(0,o.jsx)(f.A.TextArea,{value:ec,onChange:e=>{ed(e.target.value),ev(e.target.value.endsWith("@"))},onFocus:()=>ev(ec.endsWith("@")),onPressEnter:e=>{e.shiftKey||(e.preventDefault(),eT())},disabled:ep,placeholder:"输入 @ 召回知识库文件,再描述优化目标...",autoSize:{minRows:1,maxRows:3}}),(0,o.jsx)(h.Ay,{type:"primary",icon:(0,o.jsx)(T.A,{}),loading:ep,disabled:!ec.trim(),onClick:()=>{eT()},children:"发送"})]})]})]})]})]})}}},e=>{e.O(0,[433,787,576,195,985,36,636,593,792],()=>e(e.s=27549)),_N_E=e.O()}]);
@@ -1,3 +1,5 @@
1
+ import type { NextConfig } from 'next';
2
+
1
3
  /** 需要在服务端而非客户端打包的外部依赖(原生模块/大型库) */
2
4
  const serverExternalPackages = [
3
5
  '@customize-agent/knowledge',
@@ -14,8 +16,7 @@ const serverExternalPackages = [
14
16
  'xlsx',
15
17
  ];
16
18
 
17
- /** @type {import('next').NextConfig} */
18
- const nextConfig = {
19
+ const nextConfig: NextConfig = {
19
20
  eslint: {
20
21
  ignoreDuringBuilds: true,
21
22
  },
@@ -51,4 +52,4 @@ const nextConfig = {
51
52
  },
52
53
  };
53
54
 
54
- module.exports = nextConfig;
55
+ export default nextConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customize-agent/server",
3
- "version": "4.0.17",
3
+ "version": "4.0.18",
4
4
  "description": "Customize Agent Web 管理控制台",
5
5
  "exports": {
6
6
  "./package.json": "./package.json"
@@ -18,7 +18,7 @@
18
18
  ".next/images-manifest.json",
19
19
  ".next/react-loadable-manifest.json",
20
20
  "public",
21
- "next.config.js",
21
+ "next.config.ts",
22
22
  "postcss.config.mjs",
23
23
  "scripts",
24
24
  "package.json"
@@ -47,10 +47,11 @@
47
47
  "react": "19.2.7",
48
48
  "react-dom": "19.2.7",
49
49
  "tesseract.js": "^7.0.0",
50
+ "typescript": "^6.0.3",
50
51
  "xlsx": "^0.18.5",
52
+ "@customize-agent/llm": "^3.0.4",
51
53
  "@customize-agent/knowledge": "^4.0.7",
52
- "@customize-agent/runtime": "^3.0.6",
53
- "@customize-agent/llm": "^3.0.4"
54
+ "@customize-agent/runtime": "^3.0.6"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@tailwindcss/postcss": "^4.3.2",
@@ -61,8 +62,7 @@
61
62
  "@types/react-dom": "^19.0.0",
62
63
  "postcss": "^8.4.49",
63
64
  "sass": "^1.101.0",
64
- "tailwindcss": "^4.3.2",
65
- "typescript": "^6.0.3"
65
+ "tailwindcss": "^4.3.2"
66
66
  },
67
67
  "scripts": {
68
68
  "dev": "next dev -p 17321",
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[26],{27549:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/prompt",function(){return r(34508)}])},34508:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>_});var o=r(65321),i=r(97109),n=r(79059),l=r(17807),a=r(88762),s=r(68787),c=r(33442),d=r(11702),p=r(57271),h=r(85114),x=r(84253),m=r(56985),y=r(26171),u=r(34052),f=r(7576),g=r(42700),j=r(55122),v=r(29606),S=r(96091),A=r(81668),w=r(54746),b=r(26631),C=r(99650),k=r(58209),z=r(24810),T=r(7492);async function E(){let e=await fetch("/api/prompt");if(!e.ok)throw Error("Failed");return e.json()}async function N(e,t,r){let o=await fetch("/api/prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e,content:t,name:r})});if(!o.ok)throw Error("Failed");return o.json()}async function O(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create",projectRoot:e,content:"# CUSTOMIZE\n"})});if(!t.ok)throw Error("Failed");return t.json()}async function R(e,t){let r=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"createCustom",name:e,content:t})});if(!r.ok)throw Error("Failed");return r.json()}async function I(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"select",selectedIds:e})});if(!t.ok)throw Error("Failed");return t.json()}async function F(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"import",...e&&"object"==typeof e?e:{prompts:[]}})});if(!t.ok)throw Error(await t.text());return t.json()}async function B(e){let t=await fetch("/api/prompt/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.text();try{let t=JSON.parse(e);throw Error(t.error||t.message||e||"AI 对话失败")}catch(t){throw Error(e||"AI 对话失败")}}return t.json()}function P(e){return e.id.startsWith("builtin:")}function H(e){return e.id.startsWith("custom:")}function _(){let e=(0,n.Vr)(),{message:t}=l.A.useApp(),[r,_]=(0,i.useState)(!0),[J,D]=(0,i.useState)([]),[W,L]=(0,i.useState)(!1),[M,U]=(0,i.useState)(null),[X,G]=(0,i.useState)(""),[K,V]=(0,i.useState)(""),[Y,Z]=(0,i.useState)(!1),[$,q]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)("custom"),[et,er]=(0,i.useState)(!1),[eo,ei]=(0,i.useState)([]),[en,el]=(0,i.useState)(""),[ea,es]=(0,i.useState)(!1),ec=(0,i.useRef)(null),ed=(0,i.useRef)(null),ep=async()=>{_(!0);try{D(await E())}catch(r){t.error(e("common.error"))}finally{_(!1)}};(0,i.useEffect)(()=>{ep()},[]),(0,i.useEffect)(()=>{let e=ed.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[eo,ea]);let eh=()=>{ei([]),el(""),es(!1)},ex=r=>{if(eh(),null==r?void 0:r.projectRoot)return void O(r.projectRoot).then(()=>{t.success(e("common.success")),ep()}).catch(()=>t.error(e("common.error")));U(null),q(!0),V(""),G(""),L(!0)},em=async()=>{if(!K.trim())return void t.error("请输入名称");Z(!0);try{M?await N(M.customizePath,X,H(M)?K.trim():void 0):await R(K.trim(),X||"# ".concat(K.trim(),"\n")),t.success(e("common.success")),L(!1),await ep()}catch(r){t.error(e("common.error"))}finally{Z(!1)}},ey=async()=>{let e=en.trim();if(!e||ea)return;let r=[...eo,{role:"user",content:e}];ei(r),el(""),es(!0);try{let t=await B({name:K||(null==M?void 0:M.projectName)||"未命名提示词",content:X,message:e,history:eo});ei([...r,{role:"assistant",content:t.content||"AI 未返回内容"}])}catch(e){t.error(e instanceof Error?e.message:"AI 对话失败,请检查模型配置"),ei(r)}finally{es(!1)}},eu=async(r,o)=>{let i=o?Array.from(new Set([...J.filter(e=>e.selected).map(e=>e.id),r.id])):J.filter(e=>e.selected&&e.id!==r.id).map(e=>e.id);try{await I(i),D(e=>e.map(e=>({...e,selected:i.includes(e.id)})))}catch(r){t.error(e("common.error"))}},ef=async r=>{try{if(!(await fetch("/api/prompt",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r.projectId,filePath:r.customizePath})})).ok)throw Error("Failed");t.success(e("common.success")),await ep()}catch(r){t.error(e("common.error"))}},eg=async e=>{if(e){er(!0);try{let r=await e.text(),o=JSON.parse(r),i=await F(o);t.success("已导入 ".concat(i.imported," 条提示词")),await ep()}catch(e){t.error("导入失败,请确认 JSON 文件格式正确")}finally{er(!1),ec.current&&(ec.current.value="")}}},ej=J.find(e=>e.isCurrent),ev=J.filter(P),eS=J.filter(H),eA=J.filter(e=>!P(e)&&!H(e)),ew="all"===Q?J:"builtin"===Q?ev:"custom"===Q?eS:eA;return r?(0,o.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,o.jsx)(a.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:12},children:Array.from({length:4}).map((e,t)=>(0,o.jsx)(s.A,{size:"small",children:(0,o.jsx)(a.A,{active:!0,paragraph:{rows:4}})},t))})]}):(0,o.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"pageTitle",children:e("nav.promptManagement")}),(0,o.jsx)("p",{className:"pageDesc",children:e("prompt.description")})]}),(0,o.jsxs)(c.A,{children:[ej&&(0,o.jsxs)(d.A,{color:"green",style:{lineHeight:"22px"},children:[(0,o.jsx)(v.A,{})," ",ej.projectRoot]}),(0,o.jsx)(p.A,{value:Q,onChange:ee,style:{width:160},options:[{label:"全部 (".concat(J.length,")"),value:"all"},{label:"我的提示词 (".concat(eS.length,")"),value:"custom"},{label:"项目提示词 (".concat(eA.length,")"),value:"project"},{label:"内置示例 (".concat(ev.length,")"),value:"builtin"}]}),(0,o.jsx)("input",{ref:ec,type:"file",accept:"application/json,.json",style:{display:"none"},onChange:e=>{var t;eg(null==(t=e.target.files)?void 0:t[0])}}),(0,o.jsx)(h.Ay,{icon:(0,o.jsx)(S.A,{}),loading:et,onClick:()=>{var e;return null==(e=ec.current)?void 0:e.click()},children:"导入"}),(0,o.jsx)(h.Ay,{icon:(0,o.jsx)(A.A,{}),disabled:0===eS.length,onClick:()=>{let e=eS.map(e=>({name:e.projectName,content:e.content,selected:e.selected}));!function(e,t){let r=new Blob([JSON.stringify(t,null,2)],{type:"application/json;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=e,i.click(),URL.revokeObjectURL(o)}("customize-prompts-".concat(new Date().toISOString().slice(0,10),".json"),{version:1,exportedAt:new Date().toISOString(),prompts:e}),t.success("已导出 ".concat(e.length," 条我的提示词"))},children:"导出"}),(0,o.jsx)(h.Ay,{type:"primary",icon:(0,o.jsx)(w.A,{}),onClick:()=>ex(),children:"创建提示词"})]})]}),0===ew.length?(0,o.jsx)(x.A,{description:e("prompt.noProjects")}):(0,o.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:12},children:ew.map(e=>{let r=e.hasFile&&e.content?e.content.replace(/^#.*$/gm,"").replace(/\n{3,}/g,"\n\n").trim():"";return(0,o.jsxs)(s.A,{size:"small",hoverable:!0,styles:{body:{display:"flex",flexDirection:"column",height:"100%"}},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[(0,o.jsx)(b.A,{style:{color:e.isCurrent?"var(--colorOk)":"var(--colorAccent)",fontSize:14,flexShrink:0}}),(0,o.jsx)("span",{style:{fontWeight:600,fontSize:13,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.projectName}),!e.hasFile&&e.projectRoot&&(0,o.jsx)(h.Ay,{size:"small",icon:(0,o.jsx)(w.A,{}),onClick:()=>ex(e)})]}),e.projectRoot&&(0,o.jsxs)("div",{style:{fontSize:11,color:"var(--colorTextSecondary)",marginBottom:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,o.jsx)(v.A,{style:{marginRight:4}}),e.projectRoot]}),(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:[e.isCurrent&&(0,o.jsx)(d.A,{color:"green",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"当前项目"}),P(e)&&(0,o.jsx)(d.A,{color:"gold",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"内置示例"}),H(e)&&(0,o.jsx)(d.A,{color:"cyan",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"我的提示词"}),!P(e)&&!H(e)&&(0,o.jsx)(d.A,{color:"blue",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"项目提示词"}),e.selected&&(0,o.jsx)(d.A,{color:"purple",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"已选中"}),e.hasFile?(0,o.jsx)(d.A,{color:"blue",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"有文件"}):(0,o.jsx)(d.A,{color:"default",style:{margin:0,fontSize:10,lineHeight:"16px"},children:"无文件"})]}),r&&(0,o.jsxs)("div",{style:{padding:8,background:"var(--colorFillAlter)",borderRadius:6,fontSize:11,maxHeight:80,overflow:"hidden",color:"var(--colorTextSecondary)",whiteSpace:"pre-wrap",fontFamily:"monospace",marginBottom:8,lineHeight:1.5},children:[r.slice(0,180),r.length>180?"...":""]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,paddingTop:8,borderTop:"1px solid var(--colorBorderSecondary)",marginTop:"auto"},children:[e.hasFile?(0,o.jsx)(m.A,{checked:e.selected,onChange:t=>{eu(e,t.target.checked)},style:{fontSize:12},children:"选中"}):(0,o.jsx)("span",{}),(0,o.jsx)("div",{style:{flex:1}}),e.hasFile&&(0,o.jsx)(h.Ay,{size:"small",icon:(0,o.jsx)(C.A,{}),onClick:()=>(e=>{if(eh(),P(e)){U(null),q(!0),V(e.projectName.replace(/^内置|/,"")+" Copy"),G(e.content||""),L(!0),t.info("内置提示词不可直接编辑,已为你创建副本");return}U(e),q(!1),V(e.projectName),G(e.content||""),L(!0)})(e),children:P(e)?"复制":"编辑"}),(0,o.jsx)(y.A,{title:P(e)?"删除内置提示词?":H(e)?"删除自定义提示词?":"删除项目记录及文件?",disabled:P(e),onConfirm:()=>{ef(e)},children:(0,o.jsx)(h.Ay,{size:"small",danger:!0,icon:(0,o.jsx)(k.A,{}),disabled:P(e)})})]})]},e.id)})}),(0,o.jsxs)(u.A,{title:$?"创建提示词":M&&H(M)?"编辑我的提示词 — ".concat(K||M.projectName):"编辑项目提示词 — ".concat((null==M?void 0:M.projectName)||""),open:W,onClose:()=>L(!1),width:800,maskClosable:!1,style:{borderRadius:"12px 0 0 12px"},styles:{body:{padding:"16px 24px",display:"flex",flexDirection:"column",gap:12,height:"100%"},header:{borderRadius:"12px 0 0 0",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,o.jsxs)(c.A,{children:[(0,o.jsx)(h.Ay,{onClick:()=>L(!1),children:e("common.cancel")}),(0,o.jsx)(h.Ay,{type:"primary",loading:Y,onClick:()=>{em()},children:e("common.save")})]}),children:[(0,o.jsxs)("div",{style:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},children:[(0,o.jsx)("div",{style:{marginBottom:12},children:$||M&&H(M)?(0,o.jsxs)(c.A,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,o.jsx)(f.A,{placeholder:"提示词名称",value:K,onChange:e=>V(e.target.value),style:{maxWidth:400}}),!$&&(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==M?void 0:M.customizePath})]}):(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==M?void 0:M.customizePath})}),(0,o.jsx)(f.A.TextArea,{value:X,onChange:e=>G(e.target.value),style:{flex:1,minHeight:280,fontFamily:"SF Mono, Monaco, Consolas, monospace",fontSize:13,resize:"none"}})]}),(0,o.jsxs)("div",{style:{flex:"0 0 300px",border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:"var(--colorBgContainer)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 8px 24px rgba(15, 23, 42, 0.06)"},children:[(0,o.jsxs)("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--colorBorderSecondary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,o.jsxs)(c.A,{size:6,children:[(0,o.jsx)(z.A,{style:{color:"var(--colorAccent)"}}),(0,o.jsx)("span",{style:{fontWeight:600},children:"AI 提示词助手"})]}),ea?(0,o.jsx)(d.A,{color:"processing",style:{margin:0},children:"生成中"}):(0,o.jsx)(d.A,{color:"blue",style:{margin:0},children:"可对话优化"})]}),(0,o.jsx)("div",{ref:ed,style:{flex:1,minHeight:0,overflowY:"auto",padding:12,background:"var(--colorFillAlter)"},children:0!==eo.length||ea?(0,o.jsxs)(c.A,{direction:"vertical",size:10,style:{width:"100%"},children:[eo.map((e,r)=>{let i="user"===e.role;return(0,o.jsx)("div",{style:{display:"flex",justifyContent:i?"flex-end":"flex-start"},children:(0,o.jsxs)("div",{style:{maxWidth:"88%",padding:"8px 10px",borderRadius:10,background:i?"var(--colorAccent)":"var(--colorBgContainer)",color:i?"#fff":"var(--colorText)",border:i?"none":"1px solid var(--colorBorderSecondary)",whiteSpace:"pre-wrap",lineHeight:1.6,fontSize:13,transition:"all .2s ease"},children:[e.content,!i&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:(0,o.jsx)(h.Ay,{size:"small",type:"primary",onClick:()=>{G(e.content),t.success("已应用到编辑内容,请确认后保存")},children:"应用"})})]})},"".concat(e.role,"-").concat(r))}),ea&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-start"},children:(0,o.jsxs)("div",{style:{padding:"8px 10px",borderRadius:10,background:"var(--colorBgContainer)",border:"1px solid var(--colorBorderSecondary)",color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(g.A,{size:"small",style:{marginRight:8}}),"AI 正在分析并生成内容..."]})})]}):(0,o.jsx)(x.A,{image:x.A.PRESENTED_IMAGE_SIMPLE,description:"输入你的修改目标,例如:帮我变得更适合事实抽取"})}),(0,o.jsx)(j.A,{style:{margin:0}}),(0,o.jsxs)("div",{style:{padding:10,display:"flex",gap:8,alignItems:"flex-end"},children:[(0,o.jsx)(f.A.TextArea,{value:en,onChange:e=>el(e.target.value),onPressEnter:e=>{e.shiftKey||(e.preventDefault(),ey())},disabled:ea,placeholder:"向 AI 描述你想怎么优化这个提示词...",autoSize:{minRows:1,maxRows:3}}),(0,o.jsx)(h.Ay,{type:"primary",icon:(0,o.jsx)(T.A,{}),loading:ea,disabled:!en.trim(),onClick:()=>{ey()},children:"发送"})]})]})]})]})}}},e=>{e.O(0,[433,787,576,195,985,36,636,593,792],()=>e(e.s=27549)),_N_E=e.O()}]);