@yuku123/z-agent-frontend-component 0.1.1

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 (41) hide show
  1. package/README.md +66 -0
  2. package/dist/z-agent-frontend-component.css +1 -0
  3. package/dist/z-agent-frontend-component.es.js +9956 -0
  4. package/dist/z-agent-frontend-component.umd.js +219 -0
  5. package/package.json +77 -0
  6. package/src/api/apiRouter.js +78 -0
  7. package/src/api/index.js +23 -0
  8. package/src/api/request.js +59 -0
  9. package/src/api/routes.js +140 -0
  10. package/src/dev.jsx +80 -0
  11. package/src/index.js +86 -0
  12. package/src/pages/agent/app/index.jsx +2 -0
  13. package/src/pages/agent/editor/AgentAppEditor.jsx +456 -0
  14. package/src/pages/agent/editor/WorkflowEditor.jsx +495 -0
  15. package/src/pages/agent/editor/nodes/index.ts +225 -0
  16. package/src/pages/agent/index.jsx +1379 -0
  17. package/src/pages/agent/share.jsx +512 -0
  18. package/src/pages/ak/AkUsageDrawer.jsx +208 -0
  19. package/src/pages/ak/index.jsx +496 -0
  20. package/src/pages/llm/index.jsx +736 -0
  21. package/src/pages/llm/model/index.jsx +220 -0
  22. package/src/pages/llm/provider/index.jsx +173 -0
  23. package/src/pages/mcp/index.jsx +359 -0
  24. package/src/pages/oss/BucketList.jsx +320 -0
  25. package/src/pages/oss/ObjectBrowser.jsx +409 -0
  26. package/src/pages/product/execute.jsx +608 -0
  27. package/src/pages/product/index.jsx +628 -0
  28. package/src/pages/product/scene.jsx +746 -0
  29. package/src/pages/script/ApiBridgeEditor.jsx +255 -0
  30. package/src/pages/script/CurlImportModal.jsx +263 -0
  31. package/src/pages/script/FieldMappingEditor.jsx +131 -0
  32. package/src/pages/script/OpenApiImportModal.jsx +212 -0
  33. package/src/pages/script/index.jsx +532 -0
  34. package/src/pages/skill/index.jsx +1595 -0
  35. package/src/pages/trace/DebugPlayground.jsx +357 -0
  36. package/src/pages/trace/components/MetricsDashboard.jsx +164 -0
  37. package/src/pages/trace/components/RagFragments.jsx +134 -0
  38. package/src/pages/trace/components/Timeline.jsx +142 -0
  39. package/src/pages/trace/components/ToolCallTree.jsx +116 -0
  40. package/src/pages/trace/index.jsx +13 -0
  41. package/src/pages/usage/index.jsx +352 -0
@@ -0,0 +1,219 @@
1
+ (function(Z,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("antd"),require("@ant-design/icons"),require("@yuku123/z-frontend-common"),require("@logicflow/core"),require("@logicflow/extension"),require("react-router-dom"),require("react-markdown"),require("remark-gfm"),require("echarts-for-react")):typeof define=="function"&&define.amd?define(["exports","react","antd","@ant-design/icons","@yuku123/z-frontend-common","@logicflow/core","@logicflow/extension","react-router-dom","react-markdown","remark-gfm","echarts-for-react"],s):(Z=typeof globalThis<"u"?globalThis:Z||self,s(Z.ZAgentFrontendComponent={},Z.React,Z.antd,Z.icons,Z.ZFrontendCommon,Z.LogicFlow,Z.LogicFlowExtension,Z.ReactRouterDOM,Z.ReactMarkdown,Z.RemarkGfm,Z.EChartsReact))})(this,(function(Z,s,t,l,We,re,Be,Ve,At,hs,Pt){"use strict";var Ke={exports:{}},Fe={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Et;function ms(){if(Et)return Fe;Et=1;var o=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function a(n,T,d){var b=null;if(d!==void 0&&(b=""+d),T.key!==void 0&&(b=""+T.key),"key"in T){d={};for(var f in T)f!=="key"&&(d[f]=T[f])}else d=T;return T=d.ref,{$$typeof:o,type:n,key:b,ref:T!==void 0?T:null,props:d}}return Fe.Fragment=i,Fe.jsx=a,Fe.jsxs=a,Fe}var Ne={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var zt;function gs(){return zt||(zt=1,process.env.NODE_ENV!=="production"&&(function(){function o(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===U?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case v:return"Fragment";case x:return"Profiler";case S:return"StrictMode";case C:return"Suspense";case P:return"SuspenseList";case V:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case u:return"Portal";case G:return r.displayName||"Context";case D:return(r._context.displayName||"Context")+".Consumer";case g:var L=r.render;return r=r.displayName,r||(r=L.displayName||L.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case K:return L=r.displayName||null,L!==null?L:o(r.type)||"Memo";case O:L=r._payload,r=r._init;try{return o(r(L))}catch{}}return null}function i(r){return""+r}function a(r){try{i(r);var L=!1}catch{L=!0}if(L){L=console;var $=L.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return $.call(L,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),i(r)}}function n(r){if(r===v)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===O)return"<...>";try{var L=o(r);return L?"<"+L+">":"<...>"}catch{return"<...>"}}function T(){var r=A.A;return r===null?null:r.getOwner()}function d(){return Error("react-stack-top-frame")}function b(r){if(k.call(r,"key")){var L=Object.getOwnPropertyDescriptor(r,"key").get;if(L&&L.isReactWarning)return!1}return r.key!==void 0}function f(r,L){function $(){y||(y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",L))}$.isReactWarning=!0,Object.defineProperty(r,"key",{get:$,configurable:!0})}function j(){var r=o(this.type);return M[r]||(M[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function w(r,L,$,R,se,je){var le=$.ref;return r={$$typeof:N,type:r,key:L,props:$,_owner:R},(le!==void 0?le:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:j}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:je}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function h(r,L,$,R,se,je){var le=L.children;if(le!==void 0)if(R)if(_(le)){for(R=0;R<le.length;R++)m(le[R]);Object.freeze&&Object.freeze(le)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(le);if(k.call(L,"key")){le=o(r);var fe=Object.keys(L).filter(function(ee){return ee!=="key"});R=0<fe.length?"{key: someKey, "+fe.join(": ..., ")+": ...}":"{key: someKey}",c[le+R]||(fe=0<fe.length?"{"+fe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,R,le,fe,le),c[le+R]=!0)}if(le=null,$!==void 0&&(a($),le=""+$),b(L)&&(a(L.key),le=""+L.key),"key"in L){$={};for(var W in L)W!=="key"&&($[W]=L[W])}else $=L;return le&&f($,typeof r=="function"?r.displayName||r.name||"Unknown":r),w(r,le,$,T(),se,je)}function m(r){z(r)?r._store&&(r._store.validated=1):typeof r=="object"&&r!==null&&r.$$typeof===O&&(r._payload.status==="fulfilled"?z(r._payload.value)&&r._payload.value._store&&(r._payload.value._store.validated=1):r._store&&(r._store.validated=1))}function z(r){return typeof r=="object"&&r!==null&&r.$$typeof===N}var F=s,N=Symbol.for("react.transitional.element"),u=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),G=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),U=Symbol.for("react.client.reference"),A=F.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=Object.prototype.hasOwnProperty,_=Array.isArray,p=console.createTask?console.createTask:function(){return null};F={react_stack_bottom_frame:function(r){return r()}};var y,M={},E=F.react_stack_bottom_frame.bind(F,d)(),Q=p(n(d)),c={};Ne.Fragment=v,Ne.jsx=function(r,L,$){var R=1e4>A.recentlyCreatedOwnerStacks++;return h(r,L,$,!1,R?Error("react-stack-top-frame"):E,R?p(n(r)):Q)},Ne.jsxs=function(r,L,$){var R=1e4>A.recentlyCreatedOwnerStacks++;return h(r,L,$,!0,R?Error("react-stack-top-frame"):E,R?p(n(r)):Q)}})()),Ne}var Rt;function fs(){return Rt||(Rt=1,process.env.NODE_ENV==="production"?Ke.exports=ms():Ke.exports=gs()),Ke.exports}var e=fs();const ys=We.createRequest({baseURL:"/api",timeout:15e3}),qe=We.createRequest({baseURL:"/api",timeout:15e3}),$e=We.createRequest({baseURL:"/api",timeout:15e3});function et(o){const i=function(n,T={}){const d={...T};return d.body!==void 0&&(d.data=d.body,delete d.body),typeof d.method=="string"&&(d.method=d.method.toUpperCase()),d.url=n,o.request(d)};return["get","post","put","delete","patch","head","request","create","interceptors"].forEach(n=>{typeof o[n]=="function"?i[n]=o[n].bind(o):i[n]=o[n]}),i}const te=et(ys);et(qe),et($e);const Bt={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE"},Ge={};function B(o,i,a,n,T){Ge[o]||(Ge[o]={}),Ge[o][i]={verb:a,path:n,transform:T}}function js(o,i){let a=0;return o.replace(/\{(\w+)\}/g,()=>String(i[a++]??""))}function bs(o,i){return i.startsWith("/ctc/ac")||i.startsWith("/ctc/authorization")||i.startsWith("/ctc/surl")?$e:i.startsWith("/auth/")?qe:te}function ve(o){return new Proxy({},{get:(i,a)=>{if(!(a==="then"||typeof a=="symbol"))return a==="toJSON"||a==="constructor"||a==="toString"?()=>`[apiRouter:${o}]`:async(...n)=>{var d;const T=(d=Ge[o])==null?void 0:d[a];if(!T)return{code:200,message:"ok",data:[],total:0};try{const b=js(T.path,n),f=bs(T.verb,b),j={};T.verb===Bt.GET||T.verb===Bt.DELETE?n.length>0&&typeof n[0]=="object"&&n[0]!==null&&(j.params=n[0]):n.length===1?j.data=n[0]:n.length>1&&(typeof n[0]=="object"&&n[0]!==null&&(j.data=n[0]),typeof n[1]=="object"&&n[1]!==null&&(j.params=n[1]));const w=await f.request({method:T.verb,url:b,...j});return T.transform?T.transform(w,n):w}catch(b){return console.warn(`[apiRouter] ${o}.${a} failed:`,(b==null?void 0:b.message)||b),{code:200,message:"ok",data:[],total:0}}}}})}B("llmApi","knowledgeList","GET","/llm-gateway/knowledge/list"),B("llmApi","skillTemplateList","GET","/llm-gateway/skill/template-list"),B("llmApi","toolTemplateList","GET","/llm-gateway/tool/template-list"),B("llmApi","appConfig","GET","/llm-gateway/app/config"),B("llmApi","appSkillAdd","POST","/llm-gateway/app/skill-add"),B("llmApi","appToolAdd","POST","/llm-gateway/app/tool-add"),B("mcpApi","list","GET","/mcp/server/list"),B("mcpApi","listTools","POST","/mcp/server/tools/list"),B("mcpApi","callTool","POST","/mcp/server/tools/call"),B("mcpApi","test","POST","/mcp/server/test"),B("mcpApi","create","POST","/mcp/server"),B("mcpApi","update","POST","/mcp/server/update"),B("mcpApi","delete","POST","/mcp/server/delete"),B("ossApi","listBuckets","GET","/v1/bucket"),B("ossApi","getBucketStats","GET","/v1/bucket/{bucketName}/stats"),B("ossApi","createBucket","POST","/v1/bucket"),B("ossApi","deleteBucket","DELETE","/v1/bucket/{bucketName}"),B("ossApi","setBucketAcl","PUT","/v1/bucket/{bucketName}/acl"),B("ossApi","listObjects","GET","/v1/object/{bucketName}"),B("ossApi","presignedUrl","GET","/v1/object/{bucketName}/{objectKey}/url"),B("ossApi","uploadObject","POST","/v1/object/{bucketName}/{objectKey}"),B("ossApi","downloadUrl","GET","/v1/object/{bucketName}/{objectKey}/url"),B("ossApi","deleteObject","DELETE","/v1/object/{bucketName}/{objectKey}"),B("ossApi","copyObject","POST","/v1/object/{bucketName}/{objectKey}/copy"),B("ossApi","batchDelete","POST","/v1/object/{bucketName}/batch-delete"),B("ossApi","createFolder","POST","/v1/folder/{bucketName}/{folderKey}"),B("scriptApi","list","GET","/script/list"),B("scriptApi","create","POST","/script"),B("scriptApi","update","POST","/script/update"),B("scriptApi","delete","POST","/script/delete"),B("scriptApi","publish","POST","/script/publish"),B("scriptApi","unpublish","POST","/script/unpublish"),B("scriptApi","run","POST","/script/run"),B("scriptApi","importCurl","POST","/script/import-curl"),B("scriptApi","importOpenApi","POST","/script/import-openapi"),B("scriptApi","previewMapping","POST","/script/preview-mapping"),B("skillApi","page","GET","/skill/page"),B("skillApi","categoryTree","GET","/skill/category-tree"),B("skillApi","create","POST","/skill"),B("skillApi","createCategory","POST","/skill/category"),B("skillApi","deleteCategory","POST","/skill/category/delete"),B("skillApi","getBySkillCode","GET","/skill/by-code"),B("skillApi","install","POST","/skill/install"),B("skillApi","stats","GET","/skill/stats"),B("skillApi","versions","GET","/skill/versions"),B("skillApi","downloadPackage","GET","/skill/download"),B("skillApi","uploadPackage","POST","/skill/upload"),B("agentApi","appPage","POST","/agent/app/page"),B("agentApi","appGet","GET","/agent/app/get"),B("agentApi","appCreate","POST","/agent/app"),B("agentApi","appUpdate","POST","/agent/app/update"),B("agentApi","appDelete","POST","/agent/app/delete"),B("agentApi","appPublish","POST","/agent/app/publish"),B("agentApi","appUpgrade","POST","/agent/app/upgrade"),B("agentApi","appToggleShare","POST","/agent/app/toggleShare"),B("agentApi","versions","GET","/agent/app/versions"),B("agentApi","groupTree","GET","/agent/group/tree"),B("agentApi","groupCreate","POST","/agent/group"),B("agentApi","groupUpdate","POST","/agent/group/update"),B("agentApi","groupDelete","POST","/agent/group/delete"),B("agentApi","chatHistory","GET","/agent/chat/history"),B("agentApi","chatStream","POST","/agent/chat/send"),B("agentApi","chatClear","POST","/agent/chat/clear"),B("agentApi","shareVerify","GET","/agent/share/verify"),B("flowApi","list","GET","/agent/flow/list"),B("flowApi","get","GET","/agent/flow/{id}"),B("flowApi","byFlowId","GET","/agent/flow/byFlowId"),B("flowApi","versions","GET","/agent/flow/versions"),B("flowApi","create","POST","/agent/flow/create"),B("flowApi","update","POST","/agent/flow/update"),B("flowApi","publish","POST","/agent/flow/publish/{id}"),B("flowApi","archive","POST","/agent/flow/archive/{id}"),B("flowApi","newVersion","POST","/agent/flow/newVersion/{parentId}"),B("flowApi","delete","POST","/agent/flow/delete/{id}"),B("flowApi","execute","POST","/agent/flow/execute/{id}"),B("flowApi","health","GET","/agent/flow/health"),B("productApi","page","GET","/v1/products"),B("productApi","create","POST","/v1/products"),B("productApi","update","PUT","/v1/products/{id}"),B("productApi","delete","DELETE","/v1/products/{id}"),B("productApi","publish","POST","/v1/products/{id}/publish"),B("productApi","offline","POST","/v1/products/{id}/offline"),B("productApi","configGet","GET","/v1/products/{id}/config"),B("productApi","configSave","PUT","/v1/products/{id}/config"),B("sceneApi","page","GET","/v1/scenes"),B("sceneApi","create","POST","/v1/scenes"),B("sceneApi","update","PUT","/v1/scenes/{id}"),B("sceneApi","delete","DELETE","/v1/scenes/{id}"),B("sceneApi","duplicate","POST","/v1/scenes/{id}/duplicate"),B("sceneApi","publish","POST","/v1/scenes/{id}/publish"),B("sceneApi","offline","POST","/v1/scenes/{id}/offline"),B("sceneApi","execute","POST","/v1/scenes/{id}/execute"),B("sceneApi","canvasGet","GET","/v1/scenes/{id}/canvas"),B("sceneApi","configGet","GET","/v1/scenes/{id}/config"),B("sceneApi","nodes","GET","/v1/scenes/{id}/nodes"),B("sceneApi","chatHistory","GET","/v1/scenes/{id}/chat-history");const ae=ve("agentApi"),De=ve("flowApi"),Ae=ve("llmApi"),Ie=ve("mcpApi"),be=ve("scriptApi"),ge=ve("skillApi"),Se=ve("productApi"),ue=ve("sceneApi"),me=ve("ossApi"),bt=class bt extends re.CircleNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#52c41a",i.stroke="#52c41a",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#fff",i.fontSize=14,i}};bt.extendKey="start";let tt=bt;const St=class St extends re.RectNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#e6f4ff",i.stroke="#1677ff",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#1677ff",i.fontSize=13,i}};St.extendKey="llm";let st=St;const Ct=class Ct extends re.RectNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#f0f5ff",i.stroke="#2f54eb",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#2f54eb",i.fontSize=13,i}};Ct.extendKey="agent";let lt=Ct;const vt=class vt extends re.PolygonNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#fff7e6",i.stroke="#fa8c16",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#d46b08",i.fontSize=12,i}getAttributes(){const i=super.getAttributes(),a=120,n=80,T=[[i.x,i.y-n/2],[i.x+a/2,i.y],[i.x,i.y+n/2],[i.x-a/2,i.y]];return{...i,points:T,width:a,height:n}}};vt.extendKey="condition";let ot=vt;const Tt=class Tt extends re.RectNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#fff7e6",i.stroke="#fa8c16",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#d46b08",i.fontSize=13,i}};Tt.extendKey="http";let it=Tt;const wt=class wt extends re.RectNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#f6ffed",i.stroke="#13c2c2",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#08979c",i.fontSize=13,i}};wt.extendKey="template";let nt=wt;const kt=class kt extends re.RectNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#f9f0ff",i.stroke="#722ed1",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#722ed1",i.fontSize=13,i}getShape(){const{x:i,y:a,width:n,height:T}=this.getAttributes(),d=n/2,b=T/2,f=12;return re.h("polygon",{points:[[i-d+f,a-b],[i+d-f,a-b],[i+d,a],[i+d-f,a+b],[i-d+f,a+b],[i-d,a]]})}};kt.extendKey="parallel";let rt=kt;const It=class It extends re.CircleNode{getNodeStyle(){const i=super.getNodeStyle();return i.fill="#ff4d4f",i.stroke="#ff4d4f",i.strokeWidth=2,i}getTextStyle(){const i=super.getTextStyle();return i.color="#fff",i.fontSize=14,i}};It.extendKey="end";let at=It;function Ss(o){o.register({type:"start",view:tt,model:re.CircleNodeModel}),o.register({type:"llm",view:st,model:re.RectNodeModel}),o.register({type:"agent",view:lt,model:re.RectNodeModel}),o.register({type:"condition",view:ot,model:re.PolygonNodeModel}),o.register({type:"http",view:it,model:re.RectNodeModel}),o.register({type:"template",view:nt,model:re.RectNodeModel}),o.register({type:"parallel",view:rt,model:re.RectNodeModel}),o.register({type:"end",view:at,model:re.CircleNodeModel})}const ct=[{type:"start",label:"开始",icon:"https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/start.png"},{type:"llm",label:"LLM 调用",icon:"🤖"},{type:"agent",label:"Agent 节点",icon:"🤖"},{type:"condition",label:"条件分支",icon:"https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/condition.png"},{type:"http",label:"HTTP 请求",icon:"🔗"},{type:"template",label:"模板转换",icon:"📝"},{type:"parallel",label:"并行执行",icon:"⚡"},{type:"end",label:"结束",icon:"https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/end.png"}];re.use(Be.Control),re.use(Be.MiniMap),re.use(Be.Menu),re.use(Be.DndPanel),re.use(Be.SelectionSelect);const Ft={nodes:[{id:"start_1",type:"start",x:150,y:280,text:"开始"},{id:"llm_1",type:"llm",x:380,y:280,text:"LLM 调用"},{id:"end_1",type:"end",x:610,y:280,text:"结束"}],edges:[{id:"e1",type:"polyline",sourceNodeId:"start_1",targetNodeId:"llm_1",text:""},{id:"e2",type:"polyline",sourceNodeId:"llm_1",targetNodeId:"end_1",text:""}]},Cs=({node:o,onChange:i,onClose:a})=>{var T,d,b,f,j;if(!o)return null;const n=((T=ct.find(w=>w.type===o.type))==null?void 0:T.label)||o.type;return e.jsxs("div",{style:{position:"absolute",right:16,top:16,width:260,background:"#fff",borderRadius:8,boxShadow:"0 2px 12px rgba(0,0,0,0.12)",padding:16,zIndex:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsx("div",{children:e.jsx(t.Tag,{color:"blue",children:n})}),e.jsx(t.Button,{type:"text",size:"small",onClick:a,children:"✕"})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"节点 ID"}),e.jsx("div",{style:{fontSize:13,color:"#333"},children:o.id})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"显示文本"}),e.jsx("input",{style:{width:"100%",border:"1px solid #d9d9d9",borderRadius:4,padding:"4px 8px",fontSize:13},defaultValue:o.text,onBlur:w=>i(o.id,{text:w.target.value}),placeholder:"输入显示文本"})]}),o.type==="llm"&&e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"模型"}),e.jsxs("select",{style:{width:"100%",border:"1px solid #d9d9d9",borderRadius:4,padding:"4px 8px",fontSize:13},defaultValue:((d=o.properties)==null?void 0:d.model)||"qwen2.5:7b",onChange:w=>i(o.id,{properties:{...o.properties,model:w.target.value}}),children:[e.jsx("option",{value:"qwen2.5:7b",children:"Qwen 2.5 7B"}),e.jsx("option",{value:"qwen2.5:72b",children:"Qwen 2.5 72B"}),e.jsx("option",{value:"gpt-4o",children:"GPT-4o"})]})]}),o.type==="http"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"HTTP Method"}),e.jsxs("select",{style:{width:"100%",border:"1px solid #d9d9d9",borderRadius:4,padding:"4px 8px",fontSize:13},defaultValue:((b=o.properties)==null?void 0:b.method)||"GET",onChange:w=>i(o.id,{properties:{...o.properties,method:w.target.value}}),children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"}),e.jsx("option",{value:"DELETE",children:"DELETE"})]})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"URL"}),e.jsx("input",{style:{width:"100%",border:"1px solid #d9d9d9",borderRadius:4,padding:"4px 8px",fontSize:13},defaultValue:((f=o.properties)==null?void 0:f.url)||"",onBlur:w=>i(o.id,{properties:{...o.properties,url:w.target.value}}),placeholder:"https://api.example.com/..."})]})]}),o.type==="condition"&&e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:4},children:"条件表达式"}),e.jsx("textarea",{style:{width:"100%",border:"1px solid #d9d9d9",borderRadius:4,padding:"4px 8px",fontSize:12,resize:"vertical"},rows:3,defaultValue:((j=o.properties)==null?void 0:j.expression)||"",onBlur:w=>i(o.id,{properties:{...o.properties,expression:w.target.value}}),placeholder:"e.g. status == 'success'"})]})]})},Nt=({readOnly:o=!1,value:i,onChange:a,appCode:n,flowName:T})=>{const d=s.useRef(null),b=s.useRef(null),[f,j]=s.useState(null),[w,h]=s.useState(i||Ft),[m,z]=s.useState(null),[F,N]=s.useState(!1),[u,v]=s.useState(!1);s.useEffect(()=>{if(!d.current)return;const O=new re({container:d.current,grid:{size:20,visible:!0,type:"dot",config:{color:"#e5e5e5"}},keyboard:{enabled:!0},snapline:!0,outline:!0,textEdit:!o,isSilentMode:o,style:{rect:{rx:6,ry:6},polyline:{stroke:"#bfbfbf",strokeWidth:2}},edgeType:"polyline"});Ss(O),O.extension.dndPanel.setPatternItems(ct.map(U=>({type:U.type,label:U.label,icon:U.icon}))),O.extension.miniMap&&O.extension.miniMap.show({width:160,height:100,showEdge:!0,isShowHeader:!1});const V=i||Ft;return O.render(V),h(V),O.on("node:click",({data:U})=>{o||j(U)}),O.on("blank:click",()=>{j(null)}),O.on("graph:change",()=>{const U=O.getGraphData();h(U),a==null||a(U)}),b.current=O,()=>{O.destroy()}},[]);const S=s.useCallback((O,V)=>{if(!b.current)return;b.current.updateText(O,V.text||""),V.properties&&b.current.updateProperties(O,V.properties);const U=b.current.getGraphData().nodes.find(A=>A.id===O);U&&j(U)},[]);s.useCallback(O=>{var k;if(!b.current||o)return;const V=b.current.getGraphData(),U=V.nodes.reduce((_,p)=>_+p.x,0)/(V.nodes.length||1),A=V.nodes.reduce((_,p)=>_+p.y,0)/(V.nodes.length||1);b.current.addNode({type:O,x:U+80,y:A,text:((k=ct.find(_=>_.type===O))==null?void 0:k.label)||O})},[o]);const x=s.useCallback(()=>{var V,U;if(!b.current||o)return;const O=b.current.getSelectedModels();(V=O.nodes)!=null&&V.length&&O.nodes.forEach(A=>b.current.deleteNode(A.id)),(U=O.edges)!=null&&U.length&&O.edges.forEach(A=>b.current.deleteEdge(A.id)),j(null)},[o]),D=s.useCallback(()=>{!b.current||o||b.current.undo()},[o]),G=s.useCallback(()=>{!b.current||o||b.current.redo()},[o]),g=s.useCallback(()=>{if(!b.current)return;const O=b.current.getGraphData();h(O),a==null||a(O),t.message.success("流程已保存到前端")},[a]),C=s.useCallback(async()=>{if(!b.current||!n){t.message.warning("缺少 appCode, 无法保存到后端");return}N(!0);try{const O=b.current.getGraphData(),V={flowId:n,name:T||n,description:`App ${n} 的工作流`,nodes:JSON.stringify(O.nodes||[]),edges:JSON.stringify(O.edges||[]),variables:JSON.stringify(O.variables||{}),flowType:"AGENT",appCode:n,status:"DRAFT",version:1,creator:localStorage.getItem("userInfo")&&JSON.parse(localStorage.getItem("userInfo")||"{}").userCode||"anonymous"};let U;if(m)U=await De.update({...V,id:m});else{U=await De.create(V);const A=(U==null?void 0:U.data)??U;A&&typeof A=="number"?z(A):A&&A.id&&z(A.id)}t.message.success("流程已保存到后端 z_agent_flow_definition"),a==null||a(O)}catch(O){t.message.error("保存到后端失败: "+((O==null?void 0:O.message)||"未知错误"))}finally{N(!1)}},[n,T,m,a]),P=s.useCallback(async()=>{if(!m){t.message.warning('请先点击"保存到后端"');return}try{await De.publish(m),v(!1),t.message.success("流程已发布, 现在可以被 Agent Runtime 执行")}catch(O){t.message.error("发布失败: "+((O==null?void 0:O.message)||"未知错误"))}},[m]);s.useEffect(()=>{!n||o||(async()=>{try{const O=await De.byFlowId({flowId:n,version:1}),V=(O==null?void 0:O.data)??O;V&&V.id&&V.nodes&&(z(V.id),b.current&&b.current.render({nodes:JSON.parse(V.nodes),edges:JSON.parse(V.edges)}),t.message.info("已加载上次保存的工作流 v"+(V.version||1)))}catch{}})()},[n]);const K=s.useCallback(()=>{j(null)},[]);return e.jsxs("div",{style:{position:"relative",height:520,borderRadius:8,overflow:"hidden",background:"#fafafa",border:"1px solid #e8e8e8"},children:[!o&&e.jsxs("div",{style:{position:"absolute",top:8,left:8,zIndex:5,display:"flex",gap:6,alignItems:"center",background:"#fff",borderRadius:6,padding:"4px 8px",boxShadow:"0 1px 6px rgba(0,0,0,0.08)"},children:[e.jsxs(t.Space,{size:4,children:[e.jsx(t.Tooltip,{title:"撤销",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.UndoOutlined,{}),onClick:D})}),e.jsx(t.Tooltip,{title:"重做",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.RedoOutlined,{}),onClick:G})}),e.jsx("div",{style:{width:1,height:16,background:"#e8e8e8",margin:"0 2px"}}),e.jsx(t.Tooltip,{title:"删除选中",children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:x})}),e.jsx(t.Tooltip,{title:"保存到前端 (AgentApp)",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.SaveOutlined,{}),onClick:g})}),e.jsx("div",{style:{width:1,height:16,background:"#e8e8e8",margin:"0 2px"}}),e.jsx(t.Tooltip,{title:"保存到后端 z_agent_flow_definition (FEATURE013 A5)",children:e.jsx(t.Button,{size:"small",type:"primary",ghost:!0,icon:e.jsx(l.CloudUploadOutlined,{}),loading:F,disabled:!n,onClick:C,children:"保存流程"})}),e.jsx(t.Tooltip,{title:"发布 (DRAFT → PUBLISHED, FlowEngine 可加载执行)",children:e.jsx(t.Button,{size:"small",type:"primary",disabled:!m,onClick:()=>v(!0),children:"发布"})})]}),m&&e.jsxs(t.Tag,{color:"blue",style:{marginLeft:8},children:["flowId=",m]}),e.jsx("div",{style:{fontSize:12,color:"#999",marginLeft:8},children:"从左侧拖入节点到画布,双击节点编辑文本"})]}),e.jsxs(t.Modal,{title:"发布工作流",open:u,onOk:P,onCancel:()=>v(!1),okText:"确认发布",cancelText:"取消",children:[e.jsxs("p",{children:["发布后, ",e.jsx("b",{children:"FlowOrchestrationService"})," 会在下次请求时加载这个 flow, Agent Runtime 可以通过 ",e.jsxs("code",{children:["/api/agent/flow/execute/",m]})," 触发执行。"]}),e.jsx("p",{style:{color:"#999",fontSize:12},children:"提示: 如需修改, 需点击「升级到新版本」创建草稿。"})]}),e.jsx("div",{ref:d,style:{width:"100%",height:"100%"}}),f&&!o&&e.jsx(Cs,{node:f,onChange:S,onClose:K}),o&&e.jsx("div",{style:{position:"absolute",top:8,right:8,zIndex:5,background:"rgba(0,0,0,0.5)",color:"#fff",borderRadius:4,padding:"2px 8px",fontSize:12},children:"只读模式"})]})},{TextArea:Pe}=t.Input,{Text:Te,Title:vs}=t.Typography,Dt={ollama:[{code:"qwen2.5:7b-instruct-q4_K_M",name:"Qwen 2.5 7B"},{code:"qwen3:8b",name:"Qwen3 8B"},{code:"llama3:latest",name:"Llama 3"},{code:"qwen2.5:14b-instruct-q4_K_M",name:"Qwen 2.5 14B"}],openai:[{code:"gpt-4o",name:"GPT-4o"},{code:"gpt-4o-mini",name:"GPT-4o Mini"},{code:"gpt-4-turbo",name:"GPT-4 Turbo"}],dashscope:[{code:"qwen-max",name:"Qwen Max"},{code:"qwen-plus",name:"Qwen Plus"},{code:"qwen-turbo",name:"Qwen Turbo"}]},Lt={chat:{label:"对话",icon:e.jsx(l.MessageOutlined,{}),color:"#1677ff",desc:"纯文本对话,配置 Prompt + 模型即可",tabs:["basic","prompt","modelParams","memory"],tabLabels:{basic:"基本信息",prompt:"系统提示词",modelParams:"模型参数",memory:"记忆配置"}},agent:{label:"智能体",icon:e.jsx(l.RobotOutlined,{}),color:"#722ed1",desc:"工具调用 + 技能 + 知识库,具备自主决策能力",tabs:["basic","prompt","modelParams","memory","tools","skills","variables","knowledge"],tabLabels:{basic:"基本信息",prompt:"系统提示词",modelParams:"模型参数",memory:"记忆配置",tools:"工具配置",skills:"技能配置",variables:"变量配置",knowledge:"知识库"}},workflow:{label:"工作流",icon:e.jsx(l.ApartmentOutlined,{}),color:"#13c2c2",desc:"可视化多步骤流程编排",tabs:["basic","modelParams","workflow"],tabLabels:{basic:"基本信息",modelParams:"模型参数",workflow:"流程编排"}}},Mt=({app:o,onBack:i,onSaved:a})=>{const[n,T]=s.useState(o),d=n.status==="PUBLISHED",b=n.agentMode||"chat",f=Lt[b]||Lt.chat,[j,w]=s.useState(!1),[h,m]=s.useState(!1),[z,F]=s.useState(f.tabs[0]),[N]=t.Form.useForm(),[u,v]=s.useState(null);s.useEffect(()=>{z&&!f.tabs.includes(z)&&F(f.tabs[0])},[b]);const S=g=>{T(C=>({...C,agentMode:g})),N.setFieldsValue({agentMode:g})},x=async()=>{try{const g=await N.validateFields();w(!0),await ae.appUpdate({id:n.id,agentMode:b,...g,workflowData:u}),t.message.success("保存成功"),a==null||a()}catch(g){g.errorFields||t.message.error("保存失败")}finally{w(!1)}},D=async()=>{try{await ae.appPublish(n.appCode),t.message.success("发布成功"),a==null||a()}catch{t.message.error("发布失败")}},G=async()=>{try{m(!0);const g=await ae.appUpgrade(n.appCode),C=(g==null?void 0:g.data)||g;C&&(T(C),t.message.success(`已升级到 ${C.version||"新"} 版本,可编辑后发布`))}catch(g){t.message.error("升级失败:"+((g==null?void 0:g.message)||"未知错误"))}finally{m(!1)}};return e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:"1px solid #f0f0f0",background:"#fff",flexShrink:0},children:[e.jsx(t.Button,{type:"text",icon:e.jsx(l.ArrowLeftOutlined,{}),onClick:i}),e.jsxs(vs,{level:5,style:{margin:0,flex:1,minWidth:0},children:[e.jsx("span",{style:{marginRight:8},children:n.appName}),e.jsxs(t.Tag,{color:f.color,style:{borderRadius:20,marginRight:4},children:[f.icon," ",f.label]}),e.jsx(t.Tag,{color:d?"green":"default",style:{borderRadius:20},children:d?"已发布":"草稿"})]}),e.jsx("div",{style:{flex:1}}),d?e.jsx(t.Button,{icon:e.jsx(l.DiffOutlined,{}),loading:h,onClick:G,children:"升级到新草稿"}):e.jsxs(t.Space,{children:[e.jsx(t.Button,{icon:e.jsx(l.SaveOutlined,{}),type:"primary",ghost:!0,onClick:x,loading:j,children:"保存"}),e.jsx(t.Button,{icon:e.jsx(l.RocketOutlined,{}),type:"primary",onClick:D,children:"发布"})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:16,background:"#f5f5f5"},children:[d&&e.jsx(t.Alert,{type:"warning",showIcon:!0,icon:e.jsx(l.EyeOutlined,{}),message:"查看模式:当前为已发布版本,所有字段仅可浏览不可修改",description:"如需调整配置,请点击右上角「升级到新草稿」按钮,系统会基于当前版本创建一份可编辑的草稿。",style:{marginBottom:16,borderRadius:8}}),e.jsx(t.Card,{size:"small",style:{marginBottom:16,borderLeft:`3px solid ${f.color}`},bodyStyle:{padding:"12px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:120},children:[e.jsx("span",{style:{fontSize:18,color:f.color},children:f.icon}),e.jsxs("div",{children:[e.jsx(Te,{strong:!0,style:{fontSize:13},children:"应用类型"}),e.jsx("div",{children:e.jsxs(Te,{type:"secondary",style:{fontSize:12},children:[f.label,"模式"]})})]})]}),e.jsx(t.Select,{value:b,disabled:d,onChange:S,style:{flex:1,maxWidth:400},options:[{value:"chat",label:e.jsxs("span",{children:[e.jsx(l.MessageOutlined,{style:{color:"#1677ff"}})," 对话 - 纯文本对话"]})},{value:"agent",label:e.jsxs("span",{children:[e.jsx(l.RobotOutlined,{style:{color:"#722ed1"}})," 智能体 - 工具调用 + 知识库"]})},{value:"workflow",label:e.jsxs("span",{children:[e.jsx(l.ApartmentOutlined,{style:{color:"#13c2c2"}})," 工作流 - 多步骤流程编排"]})}]}),e.jsx(Te,{type:"secondary",style:{fontSize:12},children:f.desc})]})}),e.jsx(t.Card,{size:"small",children:e.jsx(t.Tabs,{activeKey:z,onChange:F,style:{minHeight:300},children:f.tabs.map(g=>{var C;return e.jsx(t.Tabs.TabPane,{tab:f.tabLabels[g]||g,children:e.jsxs(t.Form,{form:N,layout:"vertical",initialValues:{appName:n.appName,description:n.description,prompt:n.prompt,modelProvider:n.modelProvider||"ollama",modelName:n.modelName||"qwen2.5:7b-instruct-q4_K_M",iconUrl:n.iconUrl,tools:n.tools,skillCodes:n.skillCodes,variables:n.variables,knowledgeIds:n.knowledgeIds,temperature:n.temperature??.7,topP:n.topP??.9,maxTokens:n.maxTokens??4096,historyWindowSize:n.historyWindowSize??50,enableLongMemory:n.enableLongMemory??!1,memoryPrompt:n.memoryPrompt||""},children:[g==="basic"&&e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:16,children:e.jsx(t.Form.Item,{name:"appName",label:"应用名称",rules:[{required:!0}],children:e.jsx(t.Input,{disabled:d})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"iconUrl",label:"图标 URL",children:e.jsx(t.Input,{disabled:d,placeholder:"图片URL"})})}),e.jsx(t.Col,{span:24,children:e.jsx(t.Form.Item,{name:"description",label:"应用描述",children:e.jsx(Pe,{rows:2,disabled:d})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"modelProvider",label:"供应商",rules:[{required:!0}],children:e.jsxs(t.Select,{disabled:d,onChange:P=>{const K=Dt[P]||[];K[0]&&N.setFieldsValue({modelName:K[0].code})},children:[e.jsx(t.Select.Option,{value:"ollama",children:"Ollama"}),e.jsx(t.Select.Option,{value:"openai",children:"OpenAI"}),e.jsx(t.Select.Option,{value:"dashscope",children:"阿里通义"})]})})}),e.jsx(t.Col,{span:16,children:e.jsx(t.Form.Item,{name:"modelName",label:"模型",rules:[{required:!0}],children:e.jsx(t.Select,{disabled:d,children:(Dt[((C=N.getFieldValue)==null?void 0:C.call(N,"modelProvider"))||n.modelProvider||"ollama"]||[]).map(P=>e.jsx(t.Select.Option,{value:P.code,children:P.name},P.code))})})})]}),g==="prompt"&&e.jsx(t.Form.Item,{name:"prompt",label:"系统提示词",extra:"定义 Agent 的身份、能力、行为规范和约束条件",children:e.jsx(Pe,{rows:12,disabled:d,placeholder:"你是智能助手,负责回答用户问题..."})}),g==="modelParams"&&e.jsxs("div",{children:[e.jsx(t.Alert,{type:"info",showIcon:!0,message:"模型参数控制生成行为。不同模型支持的参数范围略有差异。",style:{marginBottom:16,border:"none",background:"#e6f4ff"}}),e.jsxs(t.Card,{size:"small",style:{background:"#fafafa",marginBottom:16},children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs(Te,{strong:!0,children:[e.jsx(l.ThunderboltOutlined,{})," 采样参数"]}),e.jsx(Te,{type:"secondary",style:{marginLeft:8,fontSize:12},children:"控制生成多样性和确定性"})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"temperature",label:"Temperature 温度",extra:"0=确定性,2=高随机",children:e.jsx(t.InputNumber,{min:0,max:2,step:.1,disabled:d,style:{width:"100%"}})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"topP",label:"Top P 核采样",extra:"0-1,建议 0.9",children:e.jsx(t.InputNumber,{min:0,max:1,step:.05,disabled:d,style:{width:"100%"}})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"maxTokens",label:"Max Tokens 最大输出",extra:"单次响应最大 token 数",children:e.jsx(t.InputNumber,{min:100,max:128e3,step:100,disabled:d,style:{width:"100%"}})})})]})]})]}),g==="memory"&&e.jsxs("div",{children:[e.jsx(t.Alert,{type:"info",showIcon:!0,message:"记忆配置控制对话上下文管理",style:{marginBottom:16,border:"none",background:"#e6f4ff"}}),e.jsxs(t.Card,{size:"small",style:{background:"#fafafa",marginBottom:16},children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs(Te,{strong:!0,children:[e.jsx(l.DatabaseOutlined,{})," 历史窗口"]}),e.jsx(Te,{type:"secondary",style:{marginLeft:8,fontSize:12},children:"保留最近 N 条对话消息作为上下文"})]}),e.jsx(t.Form.Item,{name:"historyWindowSize",label:"历史窗口大小",children:e.jsx(t.InputNumber,{min:0,max:100,disabled:d,style:{width:200}})})]}),e.jsxs(t.Card,{size:"small",style:{background:"#fafafa",marginBottom:16},children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs(Te,{strong:!0,children:[e.jsx(l.BookOutlined,{})," 长期记忆"]}),e.jsx(Te,{type:"secondary",style:{marginLeft:8,fontSize:12},children:"跨会话持久化关键信息"})]}),e.jsx(t.Form.Item,{name:"enableLongMemory",label:"启用长期记忆",valuePropName:"checked",children:e.jsx(t.Switch,{disabled:d})}),e.jsx(t.Form.Item,{name:"memoryPrompt",label:"记忆提示词",extra:"定义如何总结和存储对话内容",children:e.jsx(Pe,{rows:3,disabled:d,placeholder:"例:提取用户的偏好和关键事实,以 JSON 结构存储..."})})]})]}),g==="tools"&&e.jsx(t.Form.Item,{name:"tools",label:"工具配置",extra:"JSON 数组格式",children:e.jsx(Pe,{rows:8,disabled:d,placeholder:'[{"toolCode":"web-search","toolName":"网页搜索"}]'})}),g==="skills"&&e.jsx(t.Form.Item,{name:"skillCodes",label:"技能编码",extra:"JSON 数组格式",children:e.jsx(Pe,{rows:8,disabled:d,placeholder:'["code-review", "data-analyzer"]'})}),g==="variables"&&e.jsx(t.Form.Item,{name:"variables",label:"变量配置",extra:"JSON 数组格式",children:e.jsx(Pe,{rows:8,disabled:d,placeholder:'[{"name":"userName","label":"用户名","type":"string"}]'})}),g==="knowledge"&&e.jsx(t.Form.Item,{name:"knowledgeIds",label:"知识库",extra:"JSON 数组格式",children:e.jsx(Pe,{rows:8,disabled:d,placeholder:"[1, 2, 3]"})}),g==="workflow"&&e.jsxs("div",{children:[e.jsx(t.Alert,{type:"info",showIcon:!0,message:"工作流模式使用轻量引擎,支持中断恢复。节点定义存储在应用配置中。",style:{marginBottom:16,border:"none",background:"#e6f4ff"}}),e.jsx(We.ErrorBoundary,{fallbackTitle:"流程编辑器加载失败",fallbackDescription:"LogicFlow 初始化异常。请重试,或切换到「对话」/「智能体」模式后重新切回工作流。",onReset:()=>v(null),children:e.jsx(Nt,{readOnly:d,value:u,onChange:v,appCode:n.appCode,flowName:n.appName})})]})]})},g)})})})]})]})},{TextArea:Ts}=t.Input,{Option:we}=t.Select,{TabPane:dt}=t.Tabs,{Text:xe,Title:ze}=t.Typography,_t=()=>{const[o,i]=s.useState(""),[a,n]=s.useState(""),[T,d]=s.useState(0),[b,f]=s.useState(null),j=()=>d(w=>w+1);return b?e.jsx("div",{style:{flex:1,overflow:"hidden",borderRadius:8,background:"#fff",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(Mt,{app:b,onBack:()=>{f(null),j()},onSaved:()=>{f(null),j()}})}):e.jsxs("div",{style:{display:"flex",gap:16,height:"calc(100vh - 180px)",padding:16},children:[e.jsx(t.Card,{size:"small",style:{width:300,overflow:"auto",flexShrink:0},title:"分组",extra:e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),onClick:j}),children:e.jsx(ks,{selectedGroupCode:o,onGroupSelect:(w,h)=>{i(w||""),n(w&&h||"")},onGroupRefresh:j},T)}),e.jsx(t.Card,{size:"small",style:{flex:1,overflow:"auto"},title:a||void 0,children:e.jsx(Ps,{selectedGroupCode:o,onEditApp:f})})]})},pt={ollama:[{code:"qwen2.5:7b-instruct-q4_K_M",name:"Qwen 2.5 7B"},{code:"qwen3:8b",name:"Qwen3 8B"},{code:"llama3:latest",name:"Llama 3"},{code:"qwen2.5:14b-instruct-q4_K_M",name:"Qwen 2.5 14B"}],openai:[{code:"gpt-4o",name:"GPT-4o"},{code:"gpt-4o-mini",name:"GPT-4o Mini"},{code:"gpt-4-turbo",name:"GPT-4 Turbo"}],dashscope:[{code:"qwen-max",name:"Qwen Max"},{code:"qwen-plus",name:"Qwen Plus"},{code:"qwen-turbo",name:"Qwen Turbo"}]},ws=o=>{const i={};o.forEach(n=>{i[n.groupCode]={key:n.groupCode,title:n.groupName,children:[]}});const a=[];return o.forEach(n=>{const T=i[n.groupCode];n.parentCode&&i[n.parentCode]?i[n.parentCode].children.push(T):n.parentCode||a.push(T)}),a},ks=({selectedGroupCode:o,onGroupSelect:i,onGroupRefresh:a})=>{const[n,T]=s.useState([]),[d,b]=s.useState(!1),[f,j]=s.useState(!1),[w,h]=s.useState(null),[m,z]=s.useState(null),[F]=t.Form.useForm(),N=s.useRef(null),u=g=>{i(g===o?"":g,"")},v=()=>{b(!0),ae.groupTree().then(g=>{T((g==null?void 0:g.data)||g||[])}).finally(()=>b(!1))};s.useEffect(()=>{v()},[]);const S=()=>{const g={};n.forEach(P=>{g[P.groupCode]={key:P.groupCode,title:P.groupName,groupCode:P.groupCode,parentCode:P.parentCode||"",icon:o===P.groupCode?e.jsx(l.FolderOpenOutlined,{}):e.jsx(l.FolderOutlined,{}),data:P,children:[]}});const C=[];return n.forEach(P=>{const K=g[P.groupCode];P.parentCode&&g[P.parentCode]?g[P.parentCode].children.push(K):P.parentCode||C.push(K)}),C},x=g=>{const C=n.find(P=>P.groupCode===g.groupCode);return e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:"pointer"},onClick:()=>u(g.groupCode),children:[e.jsx("span",{style:{flex:1,fontSize:13},children:g.title}),e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.PlusOutlined,{style:{fontSize:11,color:"#1890ff"}}),onClick:P=>{P.stopPropagation(),z(C),h(null),F.resetFields(),F.setFieldsValue({parentCode:g.groupCode}),j(!0)},title:"新增子分组"}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.EditOutlined,{style:{fontSize:11}}),onClick:P=>{P.stopPropagation(),h(C),F.setFieldsValue({groupName:C.groupName,parentCode:C.parentCode||""}),z(null),j(!0)}}),e.jsx(t.Popconfirm,{title:`删除分组"${C.groupName}"?`,description:"子分组也会被删除",onConfirm:()=>D(g.groupCode),onCancel:P=>P==null?void 0:P.stopPropagation(),children:e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{style:{fontSize:11}}),onClick:P=>P.stopPropagation()})})]})]})},D=async g=>{try{await ae.groupDelete(g),t.message.success("删除成功"),a()}catch{t.message.error("删除失败")}},G=async()=>{try{const g=await F.validateFields();b(!0),w?(await ae.groupUpdate({groupCode:w.groupCode,groupName:g.groupName,parentCode:g.parentCode||""}),t.message.success("更新成功")):(await ae.groupCreate({groupName:g.groupName,parentCode:g.parentCode||"",groupCode:"grp_"+Date.now()}),t.message.success("创建成功")),j(!1),a()}catch{t.message.error("操作失败")}finally{b(!1)}};return e.jsxs("div",{style:{padding:"4px 0"},children:[e.jsx("div",{style:{maxHeight:"calc(100vh - 320px)",overflow:"auto"},children:e.jsx(t.Tree,{treeData:S(),defaultExpandAll:!0,showLine:!0,blockNode:!0,titleRender:x,selectedKeys:o?[o]:[],onSelect:()=>{}})}),e.jsx(t.Modal,{title:w?"编辑分组":m?`新建子分组 - ${m.groupName}`:"新建分组",open:f,onCancel:()=>j(!1),onOk:()=>F.submit(),destroyOnClose:!0,children:e.jsxs(t.Form,{form:F,layout:"vertical",onFinish:G,children:[e.jsx(t.Form.Item,{name:"groupName",label:"分组名称",rules:[{required:!0,message:"请输入分组名称"}],children:e.jsx(t.Input,{ref:N,placeholder:"如:客服机器人"})}),e.jsx(t.Form.Item,{name:"parentCode",label:"父分组",children:e.jsx(t.Select,{allowClear:!0,placeholder:"留空为顶级分组",children:n.filter(g=>w?g.groupCode!==w.groupCode:!0).map(g=>e.jsx(t.Select.Option,{value:g.groupCode,children:g.groupName},g.groupCode))})})]})})]})},Is=({record:o,onEdit:i,onView:a,onPublish:n,onUpgrade:T,onShare:d,onDelete:b,onToolConfig:f,onToggleShare:j,loading:w})=>{var F,N;const h=o.status==="PUBLISHED",m=o.version||1,z=!!o.shareEnabled;return e.jsx(t.Card,{hoverable:!0,style:{borderRadius:12,border:"1px solid #f0f0f0",transition:"all 0.3s"},bodyStyle:{padding:16},actions:[h?e.jsx(t.Tooltip,{title:"查看发布版本(只读)",children:e.jsx(t.Button,{type:"text",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>a==null?void 0:a(o),children:"查看"})},"view"):e.jsx(t.Tooltip,{title:"编辑草稿",children:e.jsx(t.Button,{type:"text",icon:e.jsx(l.EditOutlined,{}),onClick:()=>i(o),children:"编辑"})},"edit"),h?e.jsx(t.Tooltip,{title:"基于当前版本创建新草稿",children:e.jsx(t.Button,{type:"text",icon:e.jsx(l.DiffOutlined,{}),onClick:()=>T==null?void 0:T(o),children:"升级"})},"upgrade"):e.jsx(t.Tooltip,{title:"发布后即可分享",children:e.jsx(t.Button,{type:"text",icon:e.jsx(l.RocketOutlined,{}),onClick:()=>n(o.appCode),children:"发布"})},"publish"),e.jsx(t.Tooltip,{title:z?"查看/复制分享链接":"开启后生成分享链接",children:e.jsx(t.Button,{type:"text",icon:z?e.jsx(l.GlobalOutlined,{style:{color:"#52c41a"}}):e.jsx(l.LockOutlined,{}),onClick:()=>d==null?void 0:d(o),children:"分享"})},"share"),e.jsx(t.Tooltip,{title:"工具配置",children:e.jsx(t.Button,{type:"text",icon:e.jsx(l.SettingOutlined,{}),onClick:()=>f==null?void 0:f(o),children:"工具"})},"tools"),e.jsx(t.Popconfirm,{title:"确定删除此应用?",onConfirm:()=>b(o.id),okText:"删除",okButtonProps:{danger:!0},children:e.jsx(t.Button,{type:"text",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),children:"删除"})},"delete")],children:e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(t.Avatar,{shape:"square",size:64,src:o.iconUrl,icon:e.jsx(l.RobotOutlined,{}),style:{background:h?"linear-gradient(135deg, #52c41a 0%, #389e0d 100%)":"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:8},children:[e.jsxs("div",{children:[e.jsx(ze,{level:5,style:{margin:0,color:"#262626"},children:o.appName}),e.jsx(xe,{type:"secondary",style:{fontSize:12,fontFamily:"monospace"},children:o.appCode})]}),e.jsxs(t.Space,{size:4,children:[e.jsxs(t.Tag,{style:{borderRadius:20,fontSize:11},children:["v",m]}),e.jsx(t.Tag,{color:h?"success":"default",style:{borderRadius:20},children:h?"已发布":"草稿"}),z&&e.jsx(t.Tooltip,{title:"已开启分享,点击「分享」按钮获取链接",children:e.jsx(t.Tag,{color:"green",icon:e.jsx(l.GlobalOutlined,{}),style:{borderRadius:20,fontSize:11,margin:0},children:"已分享"})})]})]}),o.description&&e.jsx("div",{style:{color:"#595959",fontSize:13,marginBottom:12,lineHeight:1.6},children:o.description}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(t.Tag,{color:"blue",style:{margin:0},children:o.modelProvider||"ollama"}),e.jsx(xe,{style:{fontSize:13,color:"#8c8c8c"},children:o.modelName||"qwen2.5:7b"})]}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:12,color:"#8c8c8c",marginTop:8},children:[e.jsxs("span",{children:["创建于 ",((F=o.gmtCreate)==null?void 0:F.split(" ")[0])||"-"]}),o.gmtModified!==o.gmtCreate&&e.jsxs("span",{children:["更新于 ",((N=o.gmtModified)==null?void 0:N.split(" ")[0])||"-"]})]})]})]})})},Os=({app:o,onEnable:i})=>{const[a,n]=s.useState(!1);return e.jsxs("div",{style:{padding:"24px 0",textAlign:"center"},children:[e.jsx("div",{style:{width:96,height:96,borderRadius:"50%",margin:"24px auto",background:"linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.LockOutlined,{style:{fontSize:40,color:"#52c41a"}})}),e.jsx(ze,{level:5,style:{marginTop:8},children:"该应用尚未开启分享"}),e.jsxs(xe,{type:"secondary",style:{display:"block",marginBottom:24,fontSize:13},children:["开启后,任何人都可通过专属链接访问该 Agent",e.jsx("br",{}),"无需登录、可嵌入网页 / 群聊 / 二维码"]}),e.jsx(t.Button,{type:"primary",size:"large",icon:e.jsx(l.GlobalOutlined,{}),loading:a,onClick:async()=>{n(!0);try{await i()}finally{n(!1)}},style:{borderRadius:8,minWidth:160},children:"开启分享"}),e.jsx(t.Divider,{style:{margin:"32px 0 16px"},plain:!0,children:e.jsx(xe,{type:"secondary",style:{fontSize:12},children:"分享后你可以获得"})}),e.jsx(t.Space,{orientation:"vertical",size:"small",style:{width:"100%",textAlign:"left",padding:"0 16px"},children:[{icon:e.jsx(l.LinkOutlined,{}),text:"独立的访问链接与二维码"},{icon:e.jsx(l.CopyOutlined,{}),text:"一键复制到微信 / 飞书 / 邮件"},{icon:e.jsx(l.EyeOutlined,{}),text:"实时统计访问人数与对话轮次"}].map((T,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#595959",fontSize:13},children:[e.jsx("span",{style:{color:"#52c41a"},children:T.icon}),T.text]},d))})]})},As=({app:o,onDisable:i,onRefresh:a})=>{var h,m;const n=o.shareCode?`${window.location.origin}/share/${o.shareCode}`:"",[T,d]=s.useState(!1),[b,f]=s.useState(!1),j=async()=>{if(n)try{await navigator.clipboard.writeText(n),d(!0),t.message.success("链接已复制"),setTimeout(()=>d(!1),2e3)}catch{const z=document.createElement("textarea");z.value=n,document.body.appendChild(z),z.select(),document.execCommand("copy"),document.body.removeChild(z),d(!0),t.message.success("链接已复制"),setTimeout(()=>d(!1),2e3)}},w=async()=>{f(!0);try{await a()}finally{f(!1)}};return e.jsxs("div",{children:[e.jsx(t.Alert,{type:"success",showIcon:!0,message:"已开启分享",description:"链接现在可被任何人访问,关闭分享后旧链接立即失效。",style:{borderRadius:8,marginBottom:20}}),e.jsxs("div",{style:{display:"flex",gap:20,padding:20,background:"#fafafa",borderRadius:12,alignItems:"center",marginBottom:20},children:[e.jsx("div",{style:{background:"#fff",padding:12,borderRadius:8,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",flexShrink:0},children:n?e.jsx(t.QRCode,{value:n,size:140,bordered:!1}):e.jsx("div",{style:{width:140,height:140,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(xe,{type:"secondary",children:"无链接"})})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(xe,{type:"secondary",style:{fontSize:12},children:"分享链接"}),e.jsx(t.Input.TextArea,{value:n,readOnly:!0,autoSize:{minRows:2,maxRows:3},style:{marginTop:4,fontSize:12,fontFamily:"monospace",resize:"none"},onClick:z=>z.target.select()}),e.jsxs(t.Space,{style:{marginTop:8},size:"small",children:[e.jsx(t.Button,{type:"primary",size:"small",icon:T?e.jsx(l.CheckCircleFilled,{}):e.jsx(l.CopyOutlined,{}),onClick:j,disabled:!n,children:T?"已复制":"复制链接"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.LinkOutlined,{}),onClick:()=>n&&window.open(n,"_blank"),disabled:!n,children:"打开"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),loading:b,onClick:w,children:"刷新链接"})]})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx(ze,{level:5,style:{fontSize:13,marginBottom:12},children:"分享设置"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{style:{padding:12,background:"#fafafa",borderRadius:8},children:[e.jsx(xe,{type:"secondary",style:{fontSize:11},children:"访问方式"}),e.jsx("div",{style:{marginTop:4},children:e.jsx(t.Tag,{color:"blue",style:{margin:0},children:"公开链接"})})]}),e.jsxs("div",{style:{padding:12,background:"#fafafa",borderRadius:8},children:[e.jsx(xe,{type:"secondary",style:{fontSize:11},children:"是否需要登录"}),e.jsx("div",{style:{marginTop:4},children:e.jsx(t.Tag,{style:{margin:0},children:"不需要"})})]}),e.jsxs("div",{style:{padding:12,background:"#fafafa",borderRadius:8},children:[e.jsx(xe,{type:"secondary",style:{fontSize:11},children:"创建时间"}),e.jsx("div",{style:{marginTop:4,fontSize:13},children:((h=o.shareGmtCreate)==null?void 0:h.split(" ")[0])||((m=o.gmtModified)==null?void 0:m.split(" ")[0])||"-"})]}),e.jsxs("div",{style:{padding:12,background:"#fafafa",borderRadius:8},children:[e.jsx(xe,{type:"secondary",style:{fontSize:11},children:"累计访问"}),e.jsxs("div",{style:{marginTop:4,fontSize:13},children:[o.shareVisitCount??0," 次"]})]})]})]}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsx(t.Popconfirm,{title:"确定要关闭分享吗?",description:"关闭后,链接将立即失效。",okText:"关闭分享",okButtonProps:{danger:!0},cancelText:"取消",onConfirm:i,children:e.jsx(t.Button,{block:!0,danger:!0,icon:e.jsx(l.LockOutlined,{}),children:"关闭分享"})})]})},Ps=({selectedGroupCode:o,onEditApp:i})=>{const[a,n]=s.useState([]),[T,d]=s.useState(!1),[b,f]=s.useState(""),[j,w]=s.useState(""),[h,m]=s.useState(1),[z]=s.useState(12),[F,N]=s.useState(0),[u,v]=s.useState(!1),[S,x]=s.useState([]),[D,G]=s.useState(!1),[g,C]=s.useState(null),[P,K]=s.useState(!1),[O,V]=s.useState(null),[U,A]=s.useState("card"),[k,_]=s.useState(pt.ollama),[p,y]=s.useState(!1),[M]=t.Form.useForm(),[E,Q]=s.useState([]);s.useEffect(()=>{c(),r()},[h,b,j,o]);const c=()=>{d(!0),ae.appPage({appName:b,status:j,groupCode:o,id:h}).then(H=>{H&&(n(H.records||[]),N(H.total||0))}).catch(H=>t.message.error("加载失败")).finally(()=>d(!1))},r=()=>{ae.groupTree().then(H=>{const X=(H==null?void 0:H.data)||H||[];x(X),Q(X.filter(ie=>ie.groupCode)),c()})},L=()=>{var ie;M.resetFields();const H="ollama",X=pt[H]||[];_(X),M.setFieldsValue({modelProvider:H,modelName:((ie=X[0])==null?void 0:ie.code)||"",groupCode:o}),y(!0)},$=async()=>{try{const H=await M.validateFields();v(!0),await ae.appCreate(H),t.message.success("创建成功"),y(!1),c()}catch(H){H.errorFields||t.message.error("操作失败")}finally{v(!1)}},R=H=>{i(H)},se=H=>{i(H)},je=async H=>{try{await ae.appDelete(H),t.message.success("删除成功"),c()}catch{t.message.error("删除失败")}},le=async H=>{try{await ae.appPublish(H),t.message.success("发布成功"),c()}catch{t.message.error("发布失败")}},fe=async H=>{try{await ae.appUpgrade(H.appCode),t.message.success("已升级到新草稿版本,可编辑后发布"),c();const X=await ae.appGet(H.appCode),ie=(X==null?void 0:X.data)||X;ie&&i(ie)}catch(X){t.message.error("升级失败:"+((X==null?void 0:X.message)||"未知错误"))}},W=H=>{V(H),K(!0)},ee=async(H,X)=>{try{const ie=await ae.appToggleShare(H.appCode,X),he=(ie==null?void 0:ie.data)||ie;t.message.success(X?"已开启分享":"已关闭分享"),n(ne=>ne.map(ye=>ye.id===H.id?{...ye,shareEnabled:X,shareCode:he||ye.shareCode}:ye)),V(ne=>ne&&ne.id===H.id?{...ne,shareEnabled:X,shareCode:he||ne.shareCode}:ne)}catch(ie){t.message.error("操作失败:"+((ie==null?void 0:ie.message)||"未知错误"))}},ce=a.filter(H=>H.status==="PUBLISHED").length;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,padding:"16px 20px",background:"#fafafa",borderRadius:8},children:[e.jsxs(t.Space,{wrap:!0,children:[e.jsx(t.Input.Search,{placeholder:"搜索应用名称/编码",onSearch:H=>{f(H),m(1)},style:{width:280},allowClear:!0,enterButton:!0}),e.jsxs(t.Select,{placeholder:"状态筛选",allowClear:!0,style:{width:140},onChange:H=>{w(H),m(1)},children:[e.jsx(we,{value:"DRAFT",children:"草稿"}),e.jsx(we,{value:"PUBLISHED",children:"已发布"})]})]}),e.jsxs(t.Space,{children:[F>0&&e.jsxs(xe,{type:"secondary",children:["共 ",e.jsx(xe,{strong:!0,children:F})," 个应用,已发布 ",e.jsx(xe,{strong:!0,style:{color:"#52c41a"},children:ce})," 个"]}),e.jsx(t.Button,{size:"small",type:U==="card"?"primary":"default",icon:e.jsx(l.AppstoreFilled,{}),onClick:()=>A("card"),style:{borderRadius:6}}),e.jsx(t.Button,{size:"small",type:U==="list"?"primary":"default",icon:e.jsx(l.UnorderedListOutlined,{}),onClick:()=>A("list"),style:{borderRadius:6}}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:L,style:{borderRadius:8},children:"新建应用"})]})]}),T&&e.jsxs("div",{style:{textAlign:"center",padding:48},children:[e.jsx(l.LoadingOutlined,{style:{fontSize:32,color:"#667eea"}}),e.jsx("div",{style:{marginTop:16,color:"#8c8c8c"},children:"加载中..."})]}),!T&&a.length===0&&e.jsxs("div",{style:{textAlign:"center",padding:"64px 24px",background:"#fafafa",borderRadius:12},children:[e.jsx("div",{style:{width:80,height:80,borderRadius:"50%",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 24px"},children:e.jsx(l.RobotOutlined,{style:{fontSize:36,color:"#fff"}})}),e.jsx(ze,{level:4,style:{marginBottom:8},children:"还没有应用"}),e.jsx(xe,{type:"secondary",style:{display:"block",marginBottom:24},children:"点击「新建应用」开始创建您的第一个 Agent"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:L,style:{borderRadius:8},children:"新建应用"})]}),!T&&a.length>0&&U==="card"&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(400px, 1fr))",gap:16,marginBottom:16},children:a.map(H=>e.jsx(Is,{record:H,onEdit:R,onView:se,onPublish:le,onUpgrade:fe,onShare:W,onDelete:je,onToolConfig:X=>{C(X),G(!0)},onShareManage:X=>{V(X),K(!0)}},H.id))}),!T&&a.length>0&&U==="list"&&e.jsx(t.Table,{dataSource:a,rowKey:"id",size:"small",pagination:!1,columns:[{title:"名称",dataIndex:"appName",width:180,render:(H,X)=>e.jsx("a",{onClick:()=>R(X),style:{fontWeight:500},children:H||X.appCode})},{title:"版本",dataIndex:"version",width:60,render:H=>e.jsxs(t.Tag,{style:{fontSize:11},children:["v",H||1]})},{title:"编码",dataIndex:"appCode",width:180,render:H=>e.jsx("code",{style:{fontSize:12,color:"#8c8c8c"},children:H})},{title:"状态",dataIndex:"status",width:80,render:H=>e.jsx(t.Tag,{color:H==="PUBLISHED"?"green":"default",children:H==="PUBLISHED"?"已发布":"草稿"})},{title:"供应商",dataIndex:"modelProvider",width:100},{title:"模型",dataIndex:"modelName",width:140,ellipsis:!0},{title:"创建时间",dataIndex:"gmtCreate",width:170},{title:"操作",width:220,render:(H,X)=>e.jsxs(t.Space,{size:"small",children:[X.status==="PUBLISHED"?e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>se(X),children:"查看"}),e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.DiffOutlined,{}),onClick:()=>fe(X),children:"升级"})]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.EditOutlined,{}),onClick:()=>R(X),children:"编辑"}),e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.RocketOutlined,{}),onClick:()=>le(X.appCode),children:"发布"})]}),e.jsx(t.Popconfirm,{title:"确定删除?",onConfirm:()=>je(X.id),children:e.jsx(t.Button,{size:"small",type:"link",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),children:"删除"})})]})}]}),!T&&F>z&&e.jsxs("div",{style:{textAlign:"center",marginTop:16},children:[e.jsx(t.Button,{onClick:()=>m(H=>Math.max(1,H-1)),disabled:h===1,children:"上一页"}),e.jsxs("span",{style:{margin:"0 16px"},children:["第 ",e.jsx(xe,{strong:!0,children:h})," / ",Math.ceil(F/z)," 页"]}),e.jsx(t.Button,{onClick:()=>m(H=>H+1),disabled:h>=Math.ceil(F/z),children:"下一页"})]}),e.jsx(t.Modal,{title:"新建应用",open:p,onOk:$,onCancel:()=>y(!1),confirmLoading:u,width:520,okText:"创建",cancelText:"取消",children:e.jsxs(t.Form,{form:M,layout:"vertical",size:"middle",children:[e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(t.Form.Item,{name:"appName",label:"应用名称",rules:[{required:!0,message:"请输入应用名称"}],style:{flex:1},children:e.jsx(t.Input,{placeholder:"如:智能客服助手"})}),e.jsx(t.Form.Item,{name:"groupCode",label:"分组",style:{width:160},children:e.jsx(t.TreeSelect,{allowClear:!0,placeholder:"默认",treeData:ws(E),treeDefaultExpandAll:!0,onChange:H=>M.setFieldsValue({groupCode:H||""}),style:{width:"100%"}})})]}),e.jsx(t.Form.Item,{name:"description",label:"应用描述",children:e.jsx(Ts,{rows:2,placeholder:"简短描述这个应用的能力和使用场景"})}),e.jsx(t.Divider,{style:{margin:"12px 0",fontSize:12,color:"#8c8c8c"},children:"应用类型"}),e.jsx(t.Form.Item,{name:"agentMode",label:"类型",rules:[{required:!0,message:"请选择应用类型"}],initialValue:"chat",children:e.jsxs(t.Select,{children:[e.jsx(we,{value:"chat",children:"对话 - 纯文本对话"}),e.jsx(we,{value:"agent",children:"智能体 - 工具调用 + 知识库"}),e.jsx(we,{value:"workflow",children:"工作流 - 多步骤流程编排"})]})}),e.jsx(t.Divider,{style:{margin:"12px 0",fontSize:12,color:"#8c8c8c"},children:"模型配置"}),e.jsx(t.Form.Item,{name:"modelProvider",label:"提供商",rules:[{required:!0}],initialValue:"ollama",children:e.jsxs(t.Select,{onChange:H=>{var ie;const X=pt[H]||[];_(X),M.setFieldsValue({modelName:((ie=X[0])==null?void 0:ie.code)||""})},children:[e.jsx(we,{value:"ollama",children:"Ollama (本地)"}),e.jsx(we,{value:"openai",children:"OpenAI"}),e.jsx(we,{value:"dashscope",children:"阿里通义"})]})}),e.jsx(t.Form.Item,{name:"modelName",label:"模型",rules:[{required:!0}],children:e.jsx(t.Select,{children:k.map(H=>e.jsx(we,{value:H.code,children:H.name},H.code))})})]})}),e.jsx(t.Drawer,{title:g?`${g.appName} - 工具配置`:"工具配置",width:560,open:D,onClose:()=>G(!1),children:g&&e.jsx(Es,{appCode:g.appCode})}),e.jsx(t.Drawer,{title:O?`${O.appName} · 分享`:"分享",width:520,open:P,onClose:()=>K(!1),destroyOnClose:!0,extra:O&&e.jsxs(t.Space,{children:[e.jsx(xe,{type:"secondary",style:{fontSize:12},children:"分享"}),e.jsx(t.Switch,{size:"small",checked:!!O.shareEnabled,onChange:H=>ee(O,H)})]}),children:O&&(O.shareEnabled?e.jsx(As,{app:O,onDisable:()=>ee(O,!1),onRefresh:()=>ee(O,!0)}):e.jsx(Os,{app:O,onEnable:()=>ee(O,!0)}))})]})},Es=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState([]),[j,w]=s.useState([]),[h,m]=s.useState([]),[z,F]=s.useState([]),[N,u]=s.useState([]),[v,S]=s.useState(!1),[x,D]=s.useState(!1),[G,g]=s.useState("tools"),[C,P]=s.useState(!1);s.useEffect(()=>{P(!0),ae.appPage({id:1,pageSize:100}).then(k=>{i((k==null?void 0:k.records)||[])}).finally(()=>P(!1))},[]),s.useEffect(()=>{a&&(S(!0),Promise.all([Ae.toolTemplateList(),Ae.skillTemplateList(),Ae.knowledgeList()]).then(([k,_,p])=>{d((k==null?void 0:k.data)||k||[]),f((_==null?void 0:_.data)||_||[]),w((p==null?void 0:p.data)||p||[]),K(a.appCode)}).finally(()=>S(!1)))},[a]);const K=k=>{Ae.appConfig(k).then(_=>{const p=(_==null?void 0:_.data)||_||{};m(p.tools||[]),F(p.skills||[]),u(p.knowledgeBases||[])}).catch(()=>{})},O=(k,_)=>k.includes(_),V=(k,_)=>{k==="tool"?m(p=>p.includes(_)?p.filter(y=>y!==_):[...p,_]):k==="skill"?F(p=>p.includes(_)?p.filter(y=>y!==_):[...p,_]):u(p=>p.includes(_)?p.filter(y=>y!==_):[...p,_])},U=async()=>{if(a){D(!0);try{for(const k of h)await Ae.appToolAdd({appCode:a.appCode,toolCode:k}).catch(()=>{});for(const k of z)await Ae.appSkillAdd({appCode:a.appCode,skillId:Number(k)}).catch(()=>{});t.message.success("工具配置已保存")}catch{t.message.error("保存失败")}finally{D(!1)}}},A=(k,_,p,y,M,E)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16},children:[_,e.jsx("span",{style:{fontWeight:500},children:k}),e.jsx(t.Tag,{children:p.length})]}),p.length===0?e.jsx(t.Empty,{description:"暂无可用项",image:t.Empty.PRESENTED_IMAGE_SIMPLE}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:p.map(E)})]});return o.length===0?e.jsx("div",{style:{padding:48,textAlign:"center"},children:e.jsx(t.Empty,{description:"请先创建应用后再配置工具"})}):e.jsx("div",{style:{padding:24},children:e.jsxs(t.Row,{gutter:24,children:[e.jsxs(t.Col,{span:8,children:[e.jsx(ze,{level:5,style:{marginBottom:16},children:"选择应用"}),e.jsx("div",{style:{background:"#fafafa",borderRadius:8,padding:16,maxHeight:500,overflow:"auto"},children:o.map(k=>e.jsx("div",{onClick:()=>n(k),style:{padding:"12px 16px",marginBottom:8,borderRadius:8,cursor:"pointer",background:(a==null?void 0:a.id)===k.id?"#fff":"transparent",border:(a==null?void 0:a.id)===k.id?"2px solid #667eea":"2px solid transparent",transition:"all 0.2s"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(t.Avatar,{size:"small",icon:e.jsx(l.RobotOutlined,{}),style:{background:k.status==="PUBLISHED"?"linear-gradient(135deg, #52c41a, #389e0d)":"linear-gradient(135deg, #667eea, #764ba2)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:14},children:k.appName}),e.jsx("div",{style:{fontSize:11,color:"#8c8c8c"},children:k.appCode})]})]})},k.id))})]}),e.jsx(t.Col,{span:16,children:a?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs(ze,{level:5,style:{margin:0},children:["配置 ",a.appName]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.CheckCircleFilled,{}),onClick:U,loading:x,children:"保存配置"})]}),e.jsxs(t.Tabs,{activeKey:G,onChange:g,children:[e.jsx(dt,{tab:"工具",children:e.jsx("div",{style:{padding:16,background:"#fafafa",borderRadius:8},children:A("可用工具",e.jsx(ToolOutlined,{}),T,h,"tool",k=>e.jsxs("div",{onClick:()=>V("tool",k.toolCode),style:{padding:"10px 14px",background:O(h,k.toolCode)?"#e6f7ff":"#fff",border:`1px solid ${O(h,k.toolCode)?"#91d5ff":"#f0f0f0"}`,borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:20,height:20,borderRadius:4,background:O(h,k.toolCode)?"#1890ff":"#d9d9d9",display:"flex",alignItems:"center",justifyContent:"center"},children:O(h,k.toolCode)&&e.jsx(l.CheckCircleFilled,{style:{color:"#fff",fontSize:12}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:k.toolName||k.toolCode}),e.jsx("div",{style:{fontSize:11,color:"#8c8c8c"},children:k.description||k.toolCode})]})]},k.toolCode))})},"tools"),e.jsx(dt,{tab:"技能",children:e.jsx("div",{style:{padding:16,background:"#fafafa",borderRadius:8},children:A("可用技能",e.jsx(l.StarOutlined,{}),b,z,"skill",k=>e.jsxs("div",{onClick:()=>V("skill",String(k.id)),style:{padding:"10px 14px",background:O(z,String(k.id))?"#fff7e6":"#fff",border:`1px solid ${O(z,String(k.id))?"#ffd591":"#f0f0f0"}`,borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:20,height:20,borderRadius:4,background:O(z,String(k.id))?"#fa8c16":"#d9d9d9",display:"flex",alignItems:"center",justifyContent:"center"},children:O(z,String(k.id))&&e.jsx(l.CheckCircleFilled,{style:{color:"#fff",fontSize:12}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:k.name}),e.jsx("div",{style:{fontSize:11,color:"#8c8c8c"},children:k.description||k.code})]})]},k.id))})},"skills"),e.jsx(dt,{tab:"知识库",children:e.jsx("div",{style:{padding:16,background:"#fafafa",borderRadius:8},children:A("可用知识库",e.jsx(l.BookOutlined,{}),j,N,"kb",k=>e.jsxs("div",{onClick:()=>V("kb",String(k.id)),style:{padding:"10px 14px",background:O(N,String(k.id))?"#f6ffed":"#fff",border:`1px solid ${O(N,String(k.id))?"#b7eb8f":"#f0f0f0"}`,borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:20,height:20,borderRadius:4,background:O(N,String(k.id))?"#52c41a":"#d9d9d9",display:"flex",alignItems:"center",justifyContent:"center"},children:O(N,String(k.id))&&e.jsx(l.CheckCircleFilled,{style:{color:"#fff",fontSize:12}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:k.name}),e.jsx("div",{style:{fontSize:11,color:"#8c8c8c"},children:k.description||`ID: ${k.id}`})]})]},k.id))})},"knowledge")]})]}):e.jsxs("div",{style:{padding:48,textAlign:"center",background:"#fafafa",borderRadius:12},children:[e.jsx(l.RobotOutlined,{style:{fontSize:48,color:"#d9d9d9"}}),e.jsx("div",{style:{marginTop:16,color:"#8c8c8c"},children:"请从左侧选择一个应用"})]})})]})})},{TextArea:zs}=t.Input,Rs=({children:o,className:i})=>{const a=String(o).replace(/\n$/,""),[n,T]=s.useState(!1),d=()=>{navigator.clipboard.writeText(a).then(()=>{T(!0),setTimeout(()=>T(!1),2e3)})};return e.jsxs("div",{style:{position:"relative",margin:"8px 0"},children:[e.jsx(t.Button,{size:"small",icon:n?e.jsx(l.CheckCircleFilled,{}):e.jsx(l.CopyOutlined,{}),onClick:d,style:{position:"absolute",right:8,top:8,opacity:.7},children:n?"已复制":"复制"}),e.jsx("pre",{style:{background:"#1e1e1e",color:"#d4d4d4",borderRadius:6,padding:"12px 16px",overflow:"auto",fontSize:13,lineHeight:1.5,fontFamily:'Consolas, Monaco, "Courier New", monospace'},children:e.jsx("code",{className:i,children:a})})]})},Bs=({msg:o})=>{const i=o.role==="user",a=o.status==="FAILED";return e.jsxs("div",{style:{display:"flex",justifyContent:i?"flex-end":"flex-start",marginBottom:16,animation:"fadeIn 0.3s ease"},children:[!i&&e.jsx(t.Avatar,{icon:e.jsx(l.RobotOutlined,{}),size:36,style:{marginRight:10,background:"#1890ff",flexShrink:0}}),e.jsxs("div",{style:{maxWidth:"72%",display:"flex",flexDirection:"column",alignItems:i?"flex-end":"flex-start"},children:[a&&e.jsx(t.Tag,{color:"red",icon:e.jsx(l.ExclamationCircleFilled,{}),style:{marginBottom:4},children:"出错了"}),i?e.jsx("div",{style:{padding:"10px 14px",borderRadius:"16px 16px 4px 16px",background:"linear-gradient(135deg, #1890ff, #096dd9)",color:"#fff",lineHeight:1.6,fontSize:15,boxShadow:"0 2px 8px rgba(24,144,255,0.3)"},children:o.content}):e.jsx("div",{style:{padding:"12px 16px",borderRadius:"16px 16px 16px 4px",background:"#fff",color:"#333",lineHeight:1.7,fontSize:15,boxShadow:"0 1px 4px rgba(0,0,0,0.1)",border:"1px solid #f0f0f0"},children:e.jsx(At,{remarkPlugins:[hs],components:{code({node:n,inline:T,className:d,children:b,...f}){return T?e.jsx("code",{style:{background:"#f5f5f5",padding:"2px 6px",borderRadius:4,fontFamily:"monospace",fontSize:"0.9em",color:"#c7254e"},...f,children:b}):e.jsx(Rs,{className:d,children:b})},p({children:n}){return e.jsx("p",{style:{margin:"0 0 8px 0"},children:n})},ul({children:n}){return e.jsx("ul",{style:{margin:"4px 0",paddingLeft:20},children:n})},ol({children:n}){return e.jsx("ol",{style:{margin:"4px 0",paddingLeft:20},children:n})},li({children:n}){return e.jsx("li",{style:{marginBottom:2},children:n})},strong({children:n}){return e.jsx("strong",{style:{color:"#1890ff"},children:n})},h1({children:n}){return e.jsx("h1",{style:{fontSize:18,margin:"8px 0"},children:n})},h2({children:n}){return e.jsx("h2",{style:{fontSize:16,margin:"8px 0"},children:n})},h3({children:n}){return e.jsx("h3",{style:{fontSize:14,margin:"6px 0"},children:n})},blockquote({children:n}){return e.jsx("blockquote",{style:{borderLeft:"3px solid #1890ff",margin:"8px 0",paddingLeft:12,color:"#666"},children:n})}},children:o.content})}),o.latencyMs&&!i&&!a&&e.jsxs("span",{style:{fontSize:11,color:"#bbb",marginTop:4},children:[e.jsx(l.ClockCircleOutlined,{style:{marginRight:3}}),o.latencyMs,"ms"]})]}),i&&e.jsx(t.Avatar,{icon:e.jsx(l.UserOutlined,{}),size:36,style:{marginLeft:10,background:"#52c41a",flexShrink:0}})]})},Fs=({appName:o,appDesc:i})=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"60vh",color:"#666"},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16,background:"linear-gradient(135deg, #1890ff, #52c41a)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",fontWeight:"bold"},children:o||"Agent"}),i&&e.jsx("p",{style:{color:"#999",marginBottom:24},children:i}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap",justifyContent:"center",maxWidth:500},children:["有什么可以帮助你的?","告诉我你的问题","试试问我任何事情"].map((a,n)=>e.jsx(t.Tag,{style:{padding:"6px 12px",fontSize:13,cursor:"pointer",borderRadius:16},onClick:()=>{const T=new CustomEvent("insertTip",{detail:a});window.dispatchEvent(T)},children:a},n))})]}),Ns=()=>{const{shareCode:o}=Ve.useParams(),[i,a]=s.useState(!0),[n,T]=s.useState(""),[d,b]=s.useState(""),[f,j]=s.useState(""),[w,h]=s.useState([]),[m,z]=s.useState(""),[F,N]=s.useState(!1),[u,v]=s.useState(!1),[S,x]=s.useState(""),[D,G]=s.useState(!1),g=s.useRef(null),C=s.useRef(null);s.useRef(null),s.useEffect(()=>{P();const U=A=>z(k=>k||A.detail);return window.addEventListener("insertTip",U),()=>window.removeEventListener("insertTip",U)},[o]),s.useEffect(()=>{var U;(U=g.current)==null||U.scrollIntoView({behavior:"smooth"})},[w]);const P=async()=>{a(!0),x("");try{const U=await ae.shareVerify(o);if(U){T(U.instanceCode),b(U.appName||"Agent"),j(U.appDesc||""),v(!0);try{const A=await ae.chatHistory(U.instanceCode,50);if(A.data&&A.data.length>0){const k=[];A.data.forEach(_=>{k.push({id:`u_${_.id}`,role:"user",content:_.userMessage,time:_.gmtCreate,status:"SUCCESS"}),k.push({id:`a_${_.id}`,role:"assistant",content:_.assistantMessage,time:_.gmtCreate,status:_.status,latencyMs:_.latencyMs})}),h(k)}}catch(A){console.warn("加载历史失败",A)}}}catch{x("分享链接无效或已过期"),G(!0)}a(!1)},K=s.useCallback(async()=>{var y;const U=m.trim();if(!U||F)return;const k={id:`u_${Date.now()}`,role:"user",content:U,status:"SUCCESS"};h(M=>[...M,k]),z(""),N(!0);const _=`a_${Date.now()}`;let p="";h(M=>[...M,{id:_,role:"assistant",content:"",status:"LOADING"}]);try{const M=localStorage.getItem("token"),E=ae.chatStream(n,U,"visitor","游客",M);E.onmessage=Q=>{Q.data==="[DONE]"?(E.close(),h(c=>c.map(r=>r.id===_?{...r,content:p||"好的,我明白了。",status:"SUCCESS"}:r)),N(!1)):(p+=Q.data,h(c=>c.map(r=>r.id===_?{...r,content:p,status:"LOADING"}:r)))},E.onerror=Q=>{E.close(),h(c=>c.map(r=>r.id===_?{...r,content:"抱歉,AI 服务暂时不可用,请稍后重试。",status:"FAILED"}:r)),N(!1)}}catch{h(E=>E.map(Q=>Q.id===_?{...Q,content:"抱歉,AI 服务暂时不可用,请稍后重试。",status:"FAILED"}:Q)),N(!1)}(y=C.current)==null||y.focus()},[m,F,n]),O=()=>{t.Modal.confirm({title:"清空对话",content:"确定清空当前对话记录?此操作不可恢复。",okText:"清空",okButtonProps:{danger:!0},onOk:()=>{h([]),ae.chatClear(n).catch(()=>{})}})},V=U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),K())};return i?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",background:"#f0f2f5"},children:e.jsx(t.Spin,{indicator:e.jsx(l.LoadingOutlined,{style:{fontSize:32},spin:!0}),tip:"正在连接..."})}):D||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",background:"#f0f2f5"},children:e.jsxs(t.Card,{style:{textAlign:"center",maxWidth:400},children:[e.jsx(l.ExclamationCircleFilled,{style:{fontSize:48,color:"#ff4d4f",marginBottom:16}}),e.jsx("h3",{children:S||"无法访问此应用"}),e.jsx("p",{style:{color:"#999"},children:"可能的原因:链接已失效、应用已被删除或访问权限不足。"}),e.jsx(t.Button,{type:"primary",href:"/",icon:e.jsx(l.RobotOutlined,{}),children:"返回首页"})]})}):e.jsxs("div",{style:{height:"100vh",display:"flex",flexDirection:"column",background:"linear-gradient(180deg, #f0f2f5 0%, #fff 100%)"},children:[e.jsxs("div",{style:{borderBottom:"1px solid #e8e8e8",background:"#fff",padding:"12px 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(t.Avatar,{shape:"square",size:36,icon:e.jsx(l.RobotOutlined,{}),style:{background:"#1890ff"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:16},children:d}),f&&e.jsx("div",{style:{fontSize:12,color:"#999"},children:f})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontSize:12,color:u?"#52c41a":"#ff4d4f"},children:[e.jsx(l.CheckCircleFilled,{style:{marginRight:4}}),u?"已连接":"未连接"]}),e.jsx(t.Tooltip,{title:"清空对话",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.ClearOutlined,{}),onClick:O,disabled:w.length===0,children:"清空"})})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 24px"},children:[w.length===0?e.jsx(Fs,{appName:d,appDesc:f}):e.jsx(e.Fragment,{children:e.jsx(t.List,{dataSource:w,renderItem:U=>e.jsx(Bs,{msg:U}),locale:{emptyText:""}})}),e.jsx("div",{ref:g})]}),w.length===0&&e.jsx("div",{style:{padding:"0 24px 8px",display:"flex",gap:8,flexWrap:"wrap"},children:["你好","你能做什么?","介绍下自己"].map((U,A)=>e.jsx(t.Button,{size:"small",type:"default",onClick:()=>z(U),children:U},A))}),e.jsxs("div",{style:{borderTop:"1px solid #e8e8e8",background:"#fff",padding:"12px 24px 20px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-end"},children:[e.jsx(zs,{ref:C,value:m,onChange:U=>z(U.target.value),onKeyDown:V,placeholder:"输入消息,Enter 发送,Shift+Enter 换行",autoSize:{minRows:1,maxRows:4},style:{flex:1,borderRadius:20},disabled:F||!u}),e.jsx(t.Button,{type:"primary",icon:F?e.jsx(l.LoadingOutlined,{}):e.jsx(l.SendOutlined,{}),onClick:K,loading:F,disabled:!m.trim()||!u,style:{borderRadius:20,width:56,height:36}})]}),e.jsx("div",{style:{fontSize:11,color:"#ccc",marginTop:6,textAlign:"center"},children:"AI 助手可能会产生不准确的信息,请仔细甄别"})]}),e.jsx("style",{children:`
23
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
24
+ `})]})},{confirm:Ds}=t.Modal,ut=[{providerCode:"ollama",providerName:"Ollama",providerType:"ollama",baseUrl:"http://localhost:11434",enabled:1,priority:100},{providerCode:"openai",providerName:"OpenAI",providerType:"openai",baseUrl:"https://api.openai.com",enabled:1,priority:90},{providerCode:"dashscope",providerName:"阿里通义",providerType:"dashscope",baseUrl:"https://dashscope.aliyuncs.com",enabled:1,priority:80}],He=[{id:1,modelCode:"qwen2.5:7b-instruct-q4_K_M",modelName:"Qwen 2.5 7B",providerCode:"ollama",modelType:"chat",contextWindow:32768,status:"ACTIVE",description:"通义千问 2.5 轻量级文本生成模型",inputPrice:0,outputPrice:0},{id:2,modelCode:"qwen3:8b",modelName:"Qwen3 8B",providerCode:"ollama",modelType:"chat",contextWindow:40960,status:"ACTIVE",description:"通义千问 3 最新一代模型",inputPrice:0,outputPrice:0},{id:3,modelCode:"gpt-4o",modelName:"GPT-4o",providerCode:"openai",modelType:"chat",contextWindow:128e3,status:"ACTIVE",description:"OpenAI 旗舰多模态模型",inputPrice:.0025,outputPrice:.01},{id:4,modelCode:"gpt-4o-mini",modelName:"GPT-4o Mini",providerCode:"openai",modelType:"chat",contextWindow:128e3,status:"ACTIVE",description:"轻量快速,性价比高",inputPrice:15e-5,outputPrice:6e-4},{id:5,modelCode:"qwen-vl-max",modelName:"Qwen VL Max",providerCode:"dashscope",modelType:"vision",contextWindow:8192,status:"ACTIVE",description:"通义千问视觉模型,支持图像理解",inputPrice:.002,outputPrice:.008},{id:6,modelCode:"qwen2-audio",modelName:"Qwen2 Audio",providerCode:"dashscope",modelType:"audio",contextWindow:8192,status:"ACTIVE",description:"通义千问语音模型",inputPrice:.001,outputPrice:.004},{id:7,modelCode:"text-embedding-v3",modelName:"Text Embedding V3",providerCode:"openai",modelType:"embedding",contextWindow:8191,status:"ACTIVE",description:"OpenAI 文本嵌入模型",inputPrice:2e-5,outputPrice:0},{id:8,modelCode:"codestral",modelName:"Codestral",providerCode:"ollama",modelType:"code",contextWindow:32768,status:"ACTIVE",description:"代码生成专用模型,支持多种编程语言",inputPrice:0,outputPrice:0},{id:9,modelCode:"dall-e-3",modelName:"DALL·E 3",providerCode:"openai",modelType:"image",contextWindow:0,status:"ACTIVE",description:"OpenAI 图像生成模型",inputPrice:.04,outputPrice:0}],Ee=[{key:"chat",title:"文本生成",icon:e.jsx(l.BranchesOutlined,{}),color:"#1677ff",bg:"#e6f4ff",border:"#1677ff"},{key:"code",title:"代码生成",icon:e.jsx(l.ThunderboltOutlined,{}),color:"#722ed1",bg:"#f9f0ff",border:"#722ed1"},{key:"image",title:"图像生成",icon:e.jsx(l.PictureOutlined,{}),color:"#13c2c2",bg:"#e6fffb",border:"#13c2c2"},{key:"vision",title:"视觉理解",icon:e.jsx(l.EyeOutlined,{}),color:"#fa8c16",bg:"#fff7e6",border:"#fa8c16"},{key:"audio",title:"语音",icon:e.jsx(l.AudioOutlined,{}),color:"#eb2f96",bg:"#fff0f6",border:"#eb2f96"},{key:"embedding",title:"嵌入/向量",icon:e.jsx(l.NodeIndexOutlined,{}),color:"#52c41a",bg:"#f6ffed",border:"#52c41a"}],Ls=[{value:"ollama",label:"Ollama"},{value:"openai",label:"OpenAI"},{value:"dashscope",label:"阿里通义"},{value:"azure",label:"Azure OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"custom",label:"自定义"}],Ms=()=>{const[o,i]=s.useState([]),[a,n]=s.useState([]),[T,d]=s.useState(!1),[b,f]=s.useState("chat"),[j,w]=s.useState(null),[h,m]=s.useState(!1),[z,F]=s.useState(null),[N]=t.Form.useForm(),[u,v]=s.useState(!1),[S,x]=s.useState(null),[D]=t.Form.useForm(),G=async()=>{d(!0);try{const[p,y]=await Promise.all([te("/llm-center/model/list",{method:"GET"}).catch(()=>null),te("/llm-center/provider/list",{method:"GET"}).catch(()=>null)]),M=Array.isArray(p)?p:(p==null?void 0:p.data)||[],E=Array.isArray(y)?y:(y==null?void 0:y.data)||[];M.length===0&&E.length===0?(n(ut),i(He)):(i(M),n(E))}catch{n(ut),i(He)}finally{d(!1)}};s.useEffect(()=>{G()},[]);const g={};Ee.forEach(p=>{g[p.key]=o.filter(y=>y.modelType===p.key).length});const C=o.filter(p=>{const y=!b||p.modelType===b,M=!j||p.providerCode===j;return y&&M}),P={ollama:"blue",openai:"green",dashscope:"cyan",azure:"purple",anthropic:"orange",custom:"default"},K=()=>{F(null),N.resetFields(),N.setFieldsValue({status:"ACTIVE",contextWindow:4096}),m(!0)},O=p=>{F(p),N.setFieldsValue(p),m(!0)},V=p=>{Ds({title:"确认删除",content:`删除模型 ${p.modelName} ?`,onOk:async()=>{if(o===He){i(o.filter(y=>y.id!==p.id)),t.message.success("删除成功");return}await te("/llm-center/model/delete",{method:"POST",data:{id:p.id}}),t.message.success("删除成功"),G()}})},U=async()=>{try{const p=await N.validateFields();if(o===He){i(z?o.map(y=>y.id===z.id?{...y,...p}:y):[...o,{...p,id:Date.now()}]),t.message.success(z?"更新成功":"创建成功"),m(!1);return}await te(z?"/llm-center/model/update":"/llm-center/model/create",{method:"POST",data:p}),t.message.success(z?"更新成功":"创建成功"),m(!1),G()}catch{}},A=()=>{x(null),D.resetFields(),D.setFieldsValue({status:"ACTIVE"}),v(!0)},k=async()=>{try{const p=await D.validateFields();if(a===ut){n(S?a.map(y=>y.providerCode===S.providerCode?{...y,...p}:y):[...a,{...p}]),t.message.success(S?"更新成功":"创建成功"),v(!1);return}await te(S?"/llm-center/provider/update":"/llm-center/provider/create",{method:"POST",data:p}),t.message.success(S?"更新成功":"创建成功"),v(!1),G()}catch{}},_=p=>{const y=b===p.key,M=g[p.key]||0;return e.jsxs("div",{onClick:()=>f(p.key),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",marginBottom:2,cursor:"pointer",borderRadius:8,borderLeft:y?`3px solid ${p.color}`:"3px solid transparent",background:y?p.bg:"transparent",transition:"all 0.2s"},onMouseEnter:E=>{y||(E.currentTarget.style.background="#f5f5f5")},onMouseLeave:E=>{y||(E.currentTarget.style.background="transparent")},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:y?p.color:"#f0f0f0",color:y?"#fff":"#8c8c8c",fontSize:16,flexShrink:0,transition:"all 0.2s"},children:p.icon}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsx("div",{style:{fontSize:13,fontWeight:y?600:400,color:y?"#262626":"#595959",lineHeight:1.4},children:p.title})}),e.jsx("span",{style:{fontSize:11,color:y?p.color:"#bababa",fontWeight:y?600:400,background:y?"#fff":"transparent",padding:"1px 7px",borderRadius:10},children:M})]},p.key)};return Ee.find(p=>p.key===b)||Ee[0],e.jsxs("div",{style:{display:"flex",gap:16,height:"calc(100vh - 180px)",padding:16},children:[e.jsxs(t.Card,{size:"small",style:{width:210,overflow:"auto",flexShrink:0,border:"none",boxShadow:"0 1px 3px rgba(0,0,0,0.06)"},bodyStyle:{padding:"8px 0"},children:[e.jsx("div",{style:{padding:"8px 14px 4px",fontSize:12,color:"#8c8c8c",fontWeight:500},children:"能力分类"}),Ee.map(_)]}),e.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column",gap:12},children:[e.jsx(t.Card,{size:"small",style:{flexShrink:0},bodyStyle:{padding:"10px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:"#8c8c8c",marginRight:4,whiteSpace:"nowrap"},children:"供应商"}),e.jsx(t.Tag,{style:{cursor:"pointer",padding:"2px 10px",fontSize:12,borderRadius:16,margin:0},color:j?"default":"blue",onClick:()=>w(null),children:"全部"}),a.map(p=>e.jsx(t.Tag,{style:{cursor:"pointer",padding:"2px 10px",fontSize:12,borderRadius:16,margin:0},color:j===p.providerCode?P[p.providerType]||"blue":"default",onClick:()=>w(p.providerCode),children:p.providerName},p.providerCode)),e.jsx("div",{style:{flex:1}}),e.jsx(t.Button,{size:"small",type:"primary",ghost:!0,icon:e.jsx(l.PlusOutlined,{}),onClick:K,children:"新增模型"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.ApiOutlined,{}),onClick:A,children:"新增供应商"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),onClick:G})]})}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:T?e.jsx("div",{style:{textAlign:"center",padding:80},children:e.jsx(t.Spin,{size:"large"})}):C.length===0?e.jsx("div",{style:{textAlign:"center",padding:80},children:e.jsx(t.Empty,{description:"暂无匹配的模型"})}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(340px, 1fr))",gap:12},children:C.map(p=>{var E;const y=a.find(Q=>Q.providerCode===p.providerCode),M=Ee.find(Q=>Q.key===p.modelType);return e.jsx(t.Card,{size:"small",hoverable:!0,style:{borderRadius:8,borderTop:`3px solid ${(M==null?void 0:M.color)||"#d9d9d9"}`},bodyStyle:{padding:14},actions:[e.jsx(t.Tooltip,{title:"编辑模型",children:e.jsx(l.EditOutlined,{onClick:()=>O(p)})},"edit"),e.jsx(t.Tooltip,{title:"删除模型",children:e.jsx(l.DeleteOutlined,{style:{color:"#ff4d4f"},onClick:()=>V(p)})},"delete")],children:e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:M?`linear-gradient(135deg, ${M.color}, ${M.color}dd)`:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:M?e.jsx("span",{style:{color:"#fff",fontSize:20},children:M.icon}):e.jsx(l.GlobalOutlined,{style:{fontSize:20,color:"#fff"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#262626"},children:p.modelName||p.modelCode}),e.jsx("div",{style:{fontSize:12,color:"#8c8c8c",fontFamily:"monospace"},children:p.modelCode})]}),e.jsx(t.Tag,{color:p.status==="ACTIVE"?"green":"red",style:{borderRadius:20,fontSize:11,lineHeight:"20px",margin:0},children:p.status==="ACTIVE"?"正常":"禁用"})]}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsxs(t.Tag,{color:P[y==null?void 0:y.providerType]||"default",style:{fontSize:11,borderRadius:4},children:[e.jsx(l.GlobalOutlined,{style:{marginRight:4}}),(y==null?void 0:y.providerName)||p.providerCode]}),e.jsx(t.Tag,{style:{fontSize:11,borderRadius:4},children:((E=Ee.find(Q=>Q.key===p.modelType))==null?void 0:E.title)||p.modelType}),p.contextWindow>0&&e.jsxs(t.Tag,{style:{fontSize:11,borderRadius:4},children:[(p.contextWindow/1e3).toFixed(0),"K CTX"]})]}),p.description&&e.jsx("div",{style:{marginTop:6,fontSize:12,color:"#8c8c8c",lineHeight:1.5},children:p.description})]})]})},p.id||p.modelCode)})})})]}),e.jsx(t.Modal,{title:z?"编辑模型":"新增模型",open:h,onOk:U,onCancel:()=>m(!1),width:640,children:e.jsxs(t.Form,{form:N,layout:"vertical",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"modelCode",label:"模型编码",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: qwen2.5:72b, gpt-4o",disabled:!!z})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"modelName",label:"模型名称",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: Qwen 2.5 72B"})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"providerCode",label:"所属供应商",rules:[{required:!0}],children:e.jsx(t.Select,{placeholder:"选择供应商",children:a.map(p=>e.jsx(t.Select.Option,{value:p.providerCode,children:p.providerName},p.providerCode))})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"modelType",label:"能力类型",rules:[{required:!0}],children:e.jsx(t.Select,{placeholder:"选择能力分类",children:Ee.map(p=>e.jsx(t.Select.Option,{value:p.key,children:e.jsxs(t.Space,{children:[e.jsx("span",{style:{color:p.color},children:p.icon}),p.title]})},p.key))})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"contextWindow",label:"上下文窗口 (tokens)",children:e.jsx(t.InputNumber,{style:{width:"100%"},placeholder:"如: 4096",min:0})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"status",label:"状态",initialValue:"ACTIVE",children:e.jsxs(t.Select,{children:[e.jsx(t.Select.Option,{value:"ACTIVE",children:"正常"}),e.jsx(t.Select.Option,{value:"INACTIVE",children:"禁用"})]})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"inputPrice",label:"输入价格 (元/千token)",children:e.jsx(t.InputNumber,{style:{width:"100%"},min:0,precision:6})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"outputPrice",label:"输出价格 (元/千token)",children:e.jsx(t.InputNumber,{style:{width:"100%"},min:0,precision:6})})})]}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(t.Input.TextArea,{rows:2,placeholder:"模型描述..."})})]})}),e.jsx(t.Modal,{title:S?"编辑供应商":"新增供应商",open:u,onOk:k,onCancel:()=>v(!1),width:560,children:e.jsxs(t.Form,{form:D,layout:"vertical",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"providerCode",label:"供应商编码",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: ollama, openai",disabled:!!S})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"providerName",label:"供应商名称",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: Ollama, OpenAI"})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"providerType",label:"类型",rules:[{required:!0}],children:e.jsx(t.Select,{placeholder:"选择类型",children:Ls.map(p=>e.jsx(t.Select.Option,{value:p.value,children:p.label},p.value))})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"status",label:"状态",initialValue:"ACTIVE",children:e.jsxs(t.Select,{children:[e.jsx(t.Select.Option,{value:"ACTIVE",children:"正常"}),e.jsx(t.Select.Option,{value:"INACTIVE",children:"禁用"})]})})})]}),e.jsx(t.Divider,{style:{margin:"8px 0",fontSize:12,color:"#8c8c8c"},children:"连接配置"}),e.jsx(t.Form.Item,{name:"baseUrl",label:"Base URL",rules:[{required:!0}],tooltip:"标准供应商自动填充地址;自定义/Ollama 需手动填写",children:e.jsx(t.Input,{placeholder:"如: http://localhost:11434"})}),e.jsx(t.Form.Item,{name:"apiKey",label:"API Key",tooltip:"系统级凭据,可在系统配置中统一管理。此字段仅用于展示,实际运行时从环境变量读取",children:e.jsx(t.Input.Password,{placeholder:"可选,建议通过系统配置管理"})})]})})]})},{confirm:_s}=t.Modal,Us=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(!1),[b,f]=s.useState(null),[j]=t.Form.useForm(),w=async()=>{n(!0);try{const v=await te("/llm-center/provider/list",{method:"GET"}),S=Array.isArray(v)?v:(v==null?void 0:v.data)||[];i(S)}catch{t.message.error("加载失败")}finally{n(!1)}};s.useEffect(()=>{w()},[]);const h=()=>{f(null),j.resetFields(),d(!0)},m=v=>{f(v),j.setFieldsValue(v),d(!0)},z=async v=>{_s({title:"确认删除",content:`删除供应商 ${v.providerName} ?`,onOk:async()=>{await te("/llm-center/provider/delete",{method:"POST",data:{id:v.id}}),t.message.success("删除成功"),w()}})},F=async()=>{try{const v=await j.validateFields();await te(b?"/llm-center/provider/update":"/llm-center/provider/create",{method:"POST",data:v}),t.message.success(b?"更新成功":"创建成功"),d(!1),w()}catch{}},N={ollama:"blue",openai:"green",azure:"purple",anthropic:"orange"},u=[{title:"供应商",render:(v,S)=>e.jsxs(t.Space,{children:[e.jsx(l.GlobalOutlined,{style:{fontSize:20,color:N[S.providerCode]||"blue"}}),e.jsxs("div",{children:[e.jsx("div",{children:e.jsx("strong",{children:S.providerName})}),e.jsx("div",{style:{fontSize:12,color:"#999"},children:S.providerCode})]})]})},{title:"类型",dataIndex:"providerType",render:v=>e.jsx(t.Tag,{color:N[v]||"default",children:v==null?void 0:v.toUpperCase()})},{title:"Base URL",dataIndex:"baseUrl",ellipsis:!0},{title:"模型数量",dataIndex:"modelCount",render:v=>e.jsx(t.Tag,{children:v||0})},{title:"状态",dataIndex:"status",render:v=>e.jsx(t.Tag,{color:v==="ACTIVE"?"green":"red",children:v==="ACTIVE"?"正常":"异常"})},{title:"操作",width:150,render:(v,S)=>e.jsxs(t.Space,{children:[e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>m(S),children:"编辑"}),e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>z(S),children:"删除"})]})}];return e.jsxs("div",{children:[e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"供应商数",value:o.length})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"活跃模型",value:o.reduce((v,S)=>v+(S.modelCount||0),0)})})})]}),e.jsx("div",{style:{marginBottom:16},children:e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:h,children:"添加供应商"})}),e.jsx(t.Table,{columns:u,dataSource:o,loading:a,rowKey:"id"}),e.jsx(t.Modal,{title:b?"编辑供应商":"添加供应商",open:T,onOk:F,onCancel:()=>d(!1),width:500,children:e.jsxs(t.Form,{form:j,layout:"vertical",children:[e.jsx(t.Form.Item,{name:"providerCode",label:"供应商编码",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: ollama, openai, azure",disabled:!!b})}),e.jsx(t.Form.Item,{name:"providerName",label:"供应商名称",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: Ollama, OpenAI"})}),e.jsx(t.Form.Item,{name:"providerType",label:"类型",rules:[{required:!0}],children:e.jsxs(t.Select,{children:[e.jsx(t.Select.Option,{value:"ollama",children:"Ollama"}),e.jsx(t.Select.Option,{value:"openai",children:"OpenAI"}),e.jsx(t.Select.Option,{value:"azure",children:"Azure OpenAI"}),e.jsx(t.Select.Option,{value:"anthropic",children:"Anthropic"})]})}),e.jsx(t.Form.Item,{name:"baseUrl",label:"Base URL",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: http://localhost:11434"})}),e.jsx(t.Form.Item,{name:"apiKey",label:"API Key",children:e.jsx(t.Input.Password,{placeholder:"可选,部分供应商需要"})}),e.jsx(t.Form.Item,{name:"status",label:"状态",initialValue:"ACTIVE",children:e.jsxs(t.Select,{children:[e.jsx(t.Select.Option,{value:"ACTIVE",children:"正常"}),e.jsx(t.Select.Option,{value:"INACTIVE",children:"异常"})]})})]})})]})},{confirm:Ws}=t.Modal,Vs=()=>{const[o,i]=s.useState([]),[a,n]=s.useState([]),[T,d]=s.useState(!1),[b,f]=s.useState(!1),[j,w]=s.useState(null),[h]=t.Form.useForm(),m=async()=>{d(!0);try{const x=await te("/llm-center/model/list",{method:"GET"}),D=Array.isArray(x)?x:(x==null?void 0:x.data)||[];i(D)}catch{t.message.error("加载失败")}finally{d(!1)}},z=async()=>{try{const x=await te("/llm-center/provider/list",{method:"GET"}),D=Array.isArray(x)?x:(x==null?void 0:x.data)||[];n(D)}catch{}};s.useEffect(()=>{m(),z()},[]);const F=()=>{w(null),h.resetFields(),h.setFieldsValue({status:"ACTIVE",contextWindow:4096}),f(!0)},N=x=>{w(x),h.setFieldsValue(x),f(!0)},u=async x=>{Ws({title:"确认删除",content:`删除模型 ${x.modelName} ?`,onOk:async()=>{await te("/llm-center/model/delete",{method:"POST",data:{id:x.id}}),t.message.success("删除成功"),m()}})},v=async()=>{try{const x=await h.validateFields();await te(j?"/llm-center/model/update":"/llm-center/model/create",{method:"POST",data:x}),t.message.success(j?"更新成功":"创建成功"),f(!1),m()}catch{}},S=[{title:"模型编码",dataIndex:"modelCode",width:120},{title:"模型名称",dataIndex:"modelName",width:150},{title:"供应商",dataIndex:"providerCode",render:x=>e.jsx(t.Tag,{children:x})},{title:"上下文窗口",dataIndex:"contextWindow",render:x=>x?`${x.toLocaleString()} tokens`:"-"},{title:"输入价格",dataIndex:"inputPrice",render:x=>x?`¥${x}/千token`:"-"},{title:"输出价格",dataIndex:"outputPrice",render:x=>x?`¥${x}/千token`:"-"},{title:"状态",dataIndex:"status",render:x=>e.jsx(t.Tag,{color:x==="ACTIVE"?"green":"red",children:x==="ACTIVE"?"正常":"禁用"})},{title:"操作",width:150,render:(x,D)=>e.jsxs(t.Space,{children:[e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>N(D),children:"编辑"}),e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>u(D),children:"删除"})]})}];return e.jsxs("div",{children:[e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"模型总数",value:o.length})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"活跃模型",value:o.filter(x=>x.status==="ACTIVE").length})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"总上下文",value:o.reduce((x,D)=>x+(D.contextWindow||0),0).toLocaleString(),suffix:"tokens"})})})]}),e.jsx("div",{style:{marginBottom:16},children:e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:F,children:"添加模型"})}),e.jsx(t.Table,{columns:S,dataSource:o,loading:T,rowKey:"id"}),e.jsx(t.Modal,{title:j?"编辑模型":"添加模型",open:b,onOk:v,onCancel:()=>f(!1),width:600,children:e.jsxs(t.Form,{form:h,layout:"vertical",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"modelCode",label:"模型编码",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: qwen2.5, gpt-4o",disabled:!!j})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"modelName",label:"模型名称",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: Qwen 2.5 72B"})})})]}),e.jsx(t.Form.Item,{name:"providerCode",label:"供应商",rules:[{required:!0}],children:e.jsx(t.Select,{placeholder:"选择供应商",children:a.map(x=>e.jsx(t.Select.Option,{value:x.providerCode,children:x.providerName},x.providerCode))})}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"contextWindow",label:"上下文窗口 (tokens)",children:e.jsx(t.InputNumber,{style:{width:"100%"},placeholder:"如: 4096"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"status",label:"状态",initialValue:"ACTIVE",children:e.jsxs(t.Select,{children:[e.jsx(t.Select.Option,{value:"ACTIVE",children:"正常"}),e.jsx(t.Select.Option,{value:"INACTIVE",children:"禁用"})]})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"inputPrice",label:"输入价格 (元/千token)",children:e.jsx(t.InputNumber,{style:{width:"100%"},min:0,precision:6,placeholder:"如: 0.001"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"outputPrice",label:"输出价格 (元/千token)",children:e.jsx(t.InputNumber,{style:{width:"100%"},min:0,precision:6,placeholder:"如: 0.002"})})})]}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(t.Input.TextArea,{rows:2,placeholder:"模型描述..."})})]})})]})},{Text:Ut}=t.Typography,Wt=o=>o?Number(o).toFixed(4):"0.0000",Vt=({open:o,ak:i,onClose:a})=>{const[n,T]=s.useState(null),[d,b]=s.useState([]),[f,j]=s.useState([]),[w,h]=s.useState(!1);s.useEffect(()=>{!o||!i||m()},[o,i]);const m=async()=>{var u,v;h(!0);try{const[S,x,D]=await Promise.allSettled([te("/llm-gateway/usage/overview",{method:"GET",params:{accessKey:i.accessKey}}),te("/llm-gateway/usage/trend",{method:"GET",params:{accessKey:i.accessKey,days:7}}),te("/llm-gateway/usage/records",{method:"GET",params:{accessKey:i.accessKey,page:1,size:20}})]);T(S.status==="fulfilled"&&(((u=S.value)==null?void 0:u.data)||S.value)||null),b(x.status==="fulfilled"?Array.isArray(x.value)?x.value:((v=x.value)==null?void 0:v.data)||[]:[]);const G=D.status==="fulfilled"?D.value:null;j(G?Array.isArray(G)?G:G.records||G.data||[]:[])}catch{}finally{h(!1)}},z=(u,v)=>{navigator.clipboard.writeText(u),message.success(`${v} 已复制`)},F={tooltip:{trigger:"axis"},legend:{data:["Token消耗","调用次数"]},grid:{top:40,right:40,bottom:30,left:50},xAxis:{type:"category",data:d.map(u=>u.date||u.statDate||"")},yAxis:[{type:"value",name:"Tokens",position:"left"},{type:"value",name:"调用次数",position:"right"}],series:[{name:"Token消耗",type:"bar",data:d.map(u=>u.dailyTokens||u.totalTokens||0)},{name:"调用次数",type:"line",yAxisIndex:1,data:d.map(u=>u.dailyCalls||u.totalCalls||0)}]},N=[{title:"时间",dataIndex:"gmtCreate",width:160},{title:"应用",dataIndex:"appCode",render:u=>u?e.jsx(t.Tag,{color:"blue",children:u}):"-"},{title:"用户",dataIndex:"userName",render:u=>u||"-"},{title:"供应商",dataIndex:"providerCode",render:u=>u?e.jsx(t.Tag,{color:"purple",children:u}):"-"},{title:"模型",dataIndex:"modelCode",render:u=>u?e.jsx(t.Tag,{children:u}):"-"},{title:"输入Token",dataIndex:"inputTokens",render:u=>(u==null?void 0:u.toLocaleString())||"-"},{title:"输出Token",dataIndex:"outputTokens",render:u=>(u==null?void 0:u.toLocaleString())||"-"},{title:"状态",dataIndex:"status",render:u=>e.jsx(t.Tag,{color:u==="SUCCESS"?"green":"red",children:u||"-"})},{title:"费用",dataIndex:"totalCost",render:u=>e.jsxs(Ut,{style:{color:"#faad14"},children:["¥",u||"0.0000"]})}];return e.jsx(t.Drawer,{title:e.jsxs(t.Space,{children:[e.jsx("span",{children:"用量详情 ·"}),e.jsx(Ut,{strong:!0,children:i==null?void 0:i.akName}),(i==null?void 0:i.accessKey)&&e.jsxs(t.Space,{size:4,children:[e.jsx("code",{style:{fontSize:12,color:"#595959",background:"#f5f5f5",padding:"2px 6px",borderRadius:4},children:i.accessKey}),e.jsx(l.CopyOutlined,{style:{cursor:"pointer",color:"#1677ff"},onClick:()=>z(i.accessKey,"AccessKey")})]})]}),open:o,onClose:a,width:820,destroyOnClose:!0,children:e.jsxs(t.Spin,{spinning:w,children:[e.jsxs(t.Row,{gutter:12,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"累计 Token",value:(n==null?void 0:n.totalTokens)||0,prefix:e.jsx(l.ThunderboltOutlined,{style:{color:"#667eea"}}),formatter:u=>Number(u).toLocaleString(),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"累计费用",value:Wt(n==null?void 0:n.totalCost),prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"今日 Token",value:(n==null?void 0:n.todayTokens)||0,prefix:e.jsx(l.ClockCircleOutlined,{style:{color:"#52c41a"}}),formatter:u=>Number(u).toLocaleString(),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"今日费用",value:Wt(n==null?void 0:n.todayCost),prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),valueStyle:{fontSize:18}})})})]}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsxs(t.Tabs,{defaultActiveKey:"trend",size:"small",children:[e.jsx(t.Tabs.TabPane,{tab:"用量趋势",icon:e.jsx(l.BarChartOutlined,{}),children:e.jsx(t.Card,{size:"small",bodyStyle:{padding:12},children:d.length>0?e.jsx(Pt,{option:F,style:{height:300}}):e.jsx(t.Empty,{description:"该 AK 暂无用量数据",style:{padding:"40px 0"}})})},"trend"),e.jsx(t.Tabs.TabPane,{tab:"调用明细",icon:e.jsx(l.ApiOutlined,{}),children:e.jsx(t.Table,{columns:N,dataSource:f,rowKey:"id",size:"small",pagination:{pageSize:20,showSizeChanger:!1},locale:{emptyText:e.jsx(t.Empty,{description:"暂无调用记录"})}})},"records")]})]})})},{confirm:Ks}=t.Modal,Kt="http://localhost:8888",Gt=o=>o?o>=1e6?(o/1e6).toFixed(1)+"M":o>=1e3?(o/1e3).toFixed(1)+"K":Number(o).toLocaleString():"0",Gs=()=>{const[o,i]=s.useState("PERSONAL"),[a,n]=s.useState([]),[T,d]=s.useState(!1),[b,f]=s.useState(!1),[j,w]=s.useState(null),[h]=t.Form.useForm(),[m,z]=s.useState(null),[F,N]=s.useState(null),[u,v]=s.useState([]),S=async()=>{d(!0);try{const A=await te("/ak/list",{method:"GET",params:{akType:o}});n(Array.isArray(A)?A:(A==null?void 0:A.data)||[])}catch{t.message.error("加载失败")}finally{d(!1)}},x=async()=>{try{const A=await te("/agent/app/page",{method:"POST",body:JSON.stringify({current:1,size:100})}),k=Array.isArray(A)?A:(A==null?void 0:A.records)||(A==null?void 0:A.data)||[];v(k.map(_=>({value:_.appCode,label:_.appName||_.appCode})))}catch{}};s.useEffect(()=>{S()},[o]),s.useEffect(()=>{x()},[]);const D=()=>{w(null),h.resetFields(),h.setFieldsValue({akType:o}),f(!0)},G=A=>{w(A),h.setFieldsValue({akName:A.akName,description:A.description,akType:A.akType||"PERSONAL",appCode:A.appCode,appName:A.appName}),f(!0)},g=A=>{Ks({title:"确认删除",content:`删除 AK「${A.akName}」?此操作不可恢复。`,okText:"删除",okType:"danger",onOk:async()=>{await te("/ak/delete",{method:"POST",params:{id:A.id}}),t.message.success("删除成功"),S()}})},C=async A=>{const k=A.status===1?0:1;await te("/ak/toggle",{method:"POST",params:{id:A.id,status:k}}),t.message.success(k===1?"已启用":"已禁用"),S()},P=async()=>{try{const A=await h.validateFields();if(j)await te("/ak/update",{method:"POST",data:{...A,id:j.id}}),t.message.success("更新成功"),f(!1),S();else{const k=await te("/ak/create",{method:"POST",data:A}),_=k!=null&&k.accessKey?k:(k==null?void 0:k.data)||{};f(!1),S(),z({akName:A.akName,accessKey:_.accessKey,secretKey:_.secretKey})}}catch{}},K=(A,k)=>{navigator.clipboard.writeText(A),t.message.success(`${k} 已复制`)},O=[{title:"名称",dataIndex:"akName",key:"akName",width:160,render:(A,k)=>e.jsxs(t.Space,{children:[e.jsx(l.KeyOutlined,{style:{color:"#1677ff"}}),e.jsx("span",{style:{fontWeight:500},children:A}),k.akType==="APP"&&k.appName&&e.jsx(t.Tag,{color:"purple",style:{borderRadius:10,fontSize:11},children:k.appName})]})},{title:"AccessKey",dataIndex:"accessKey",key:"accessKey",width:200,render:A=>e.jsxs(t.Space,{children:[e.jsx("code",{style:{fontFamily:"monospace",fontSize:12,color:"#595959",background:"#f5f5f5",padding:"3px 8px",borderRadius:4},children:A}),e.jsx(t.Tooltip,{title:"复制 AccessKey",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:k=>{k.stopPropagation(),K(A,"AccessKey")}})})]})},{title:"Token 消耗",dataIndex:"totalTokens",key:"totalTokens",width:110,sorter:(A,k)=>(A.totalTokens||0)-(k.totalTokens||0),render:A=>e.jsxs(t.Space,{children:[e.jsx(l.ThunderboltOutlined,{style:{color:"#faad14",fontSize:12}}),e.jsx("span",{style:{fontWeight:500},children:Gt(A)})]})},{title:"最后使用",dataIndex:"lastUsedTime",key:"lastUsedTime",width:160,render:A=>e.jsx(t.Space,{size:4,children:e.jsx("span",{style:{color:A?"#595959":"#bfbfbf",fontSize:13},children:A||"从未使用"})})},{title:"状态",dataIndex:"status",key:"status",width:70,render:A=>e.jsx(t.Tag,{color:A===1?"green":"red",style:{borderRadius:20},children:A===1?"正常":"禁用"})},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"创建时间",dataIndex:"createdTime",key:"createdTime",width:160},{title:"操作",key:"action",width:130,render:(A,k)=>e.jsxs(t.Space,{size:"small",onClick:_=>_.stopPropagation(),children:[e.jsx(t.Tooltip,{title:k.status===1?"禁用":"启用",children:e.jsx(t.Button,{size:"small",type:"text",icon:k.status===1?e.jsx(l.StopOutlined,{style:{color:"#faad14"}}):e.jsx(l.CheckCircleOutlined,{style:{color:"#52c41a"}}),onClick:()=>C(k)})}),e.jsx(t.Tooltip,{title:"编辑",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.KeyOutlined,{}),onClick:()=>G(k)})}),e.jsx(t.Tooltip,{title:"删除",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.DeleteOutlined,{style:{color:"#ff4d4f"}}),onClick:()=>g(k)})})]})}],V=a.reduce((A,k)=>A+(k.totalTokens||0),0),U=a.filter(A=>A.status===1).length;return e.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[e.jsx(t.Alert,{type:"info",showIcon:!0,icon:e.jsx(l.ApiOutlined,{}),message:e.jsxs(t.Space,{children:[e.jsx("span",{style:{fontWeight:500},children:"API 接入地址:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:13,background:"#e6f4ff",padding:"2px 8px",borderRadius:4},children:Kt}),e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>K(Kt,"API 地址")}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:12},children:"使用此地址 + AccessKey 调用平台所有模型"})]}),style:{border:"none",background:"#e6f4ff"}}),e.jsxs(t.Row,{gutter:12,children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"AK 总数",value:a.length,prefix:e.jsx(l.KeyOutlined,{}),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"累计 Token",value:Gt(V),prefix:e.jsx(l.ThunderboltOutlined,{}),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"有效 AK",value:U,prefix:e.jsx(l.CheckCircleOutlined,{style:{color:"#52c41a"}}),valueStyle:{fontSize:18}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{background:"#f5f5f5"},bodyStyle:{padding:"10px 14px"},children:e.jsx(t.Statistic,{title:"所属应用",value:new Set(a.map(A=>A.appCode).filter(Boolean)).size,prefix:e.jsx(l.AppstoreOutlined,{}),valueStyle:{fontSize:18}})})})]}),e.jsx(t.Card,{size:"small",styles:{body:{padding:0}},children:e.jsx(t.Tabs,{activeKey:o,onChange:i,size:"small",tabBarStyle:{margin:0,padding:"0 16px"},tabBarExtraContent:e.jsxs(t.Space,{style:{padding:"8px 0"},children:[e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:D,size:"small",children:o==="PERSONAL"?"申请个人 AK":"申请应用 AK"}),e.jsx(t.Button,{icon:e.jsx(l.ReloadOutlined,{}),onClick:S,size:"small"})]}),items:[{key:"PERSONAL",label:e.jsxs(t.Space,{children:[e.jsx(l.UserOutlined,{}),"个人 AK"]}),children:e.jsx(t.Spin,{spinning:T,children:e.jsx(t.Table,{dataSource:a,columns:O,rowKey:"id",pagination:!1,size:"small",onRow:A=>({onClick:()=>N(A),style:{cursor:"pointer"}}),locale:{emptyText:'暂无个人 AK,点右上角"申请个人 AK"创建'}})})},{key:"APP",label:e.jsxs(t.Space,{children:[e.jsx(l.AppstoreOutlined,{}),"应用 AK"]}),children:e.jsx(t.Spin,{spinning:T,children:e.jsx(t.Table,{dataSource:a,columns:O,rowKey:"id",pagination:!1,size:"small",onRow:A=>({onClick:()=>N(A),style:{cursor:"pointer"}}),locale:{emptyText:'暂无应用 AK,点右上角"申请应用 AK"并绑定一个应用'}})})}]})}),e.jsx(t.Modal,{title:j?"编辑 AK":o==="APP"?"申请应用 AK":"申请个人 AK",open:b,onOk:P,onCancel:()=>f(!1),width:520,okText:j?"保存":"申请",destroyOnClose:!0,children:e.jsxs(t.Form,{form:h,layout:"vertical",preserve:!1,children:[e.jsx(t.Form.Item,{name:"akType",label:"AK 类型",rules:[{required:!0}],children:e.jsxs(t.Radio.Group,{disabled:!!j,children:[e.jsx(t.Radio.Button,{value:"PERSONAL",children:"个人 AK"}),e.jsx(t.Radio.Button,{value:"APP",children:"应用 AK"})]})}),e.jsx(t.Form.Item,{shouldUpdate:(A,k)=>A.akType!==k.akType,noStyle:!0,children:()=>h.getFieldValue("akType")==="APP"&&e.jsx(t.Form.Item,{name:"appCode",label:"所属应用",rules:[{required:!0,message:"应用 AK 必须绑定一个应用"}],children:e.jsx(t.Select,{showSearch:!0,optionFilterProp:"label",placeholder:"选择应用",options:u})})}),e.jsx(t.Form.Item,{name:"akName",label:"名称",rules:[{required:!0,message:"请输入 AK 名称"}],children:e.jsx(t.Input,{placeholder:o==="APP"?"如:生产环境-订单服务":"如:本地调试"})}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(t.Input.TextArea,{rows:2,placeholder:"密钥用途..."})}),!j&&e.jsx(t.Alert,{type:"info",showIcon:!0,message:"AccessKey 和 SecretKey 将由系统自动生成。SecretKey 仅在创建时展示一次,请妥善保管。",style:{background:"#e6f4ff",border:"none"}})]})}),e.jsx(t.Modal,{title:"AK 创建成功",open:!!m,onCancel:()=>z(null),footer:e.jsx(t.Button,{type:"primary",onClick:()=>z(null),children:"我已保存,关闭"}),width:520,children:m&&e.jsxs("div",{children:[e.jsx(t.Alert,{type:"warning",showIcon:!0,message:"SecretKey 仅在此展示一次,关闭后将无法再次查看。请立即复制并妥善保管。",style:{marginBottom:16}}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:"AccessKey"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("code",{style:{flex:1,fontFamily:"monospace",fontSize:14,padding:"8px 12px",background:"#f5f5f5",borderRadius:6,border:"1px solid #d9d9d9"},children:m.accessKey}),e.jsx(t.Button,{icon:e.jsx(l.CopyOutlined,{}),onClick:()=>K(m.accessKey,"AccessKey"),children:"复制"})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:"SecretKey"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("code",{style:{flex:1,fontFamily:"monospace",fontSize:14,padding:"8px 12px",background:"#fff7e6",borderRadius:6,border:"1px solid #ffd591",color:"#d46b08"},children:m.secretKey}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>K(m.secretKey,"SecretKey"),children:"复制"})]})]}),e.jsx("div",{style:{fontSize:12,color:"#ff4d4f",marginTop:8},children:"⚠ 请立即复制 SecretKey,此弹窗关闭后将无法再次获取。如遗失,请删除后重新申请。"})]})}),e.jsx(Vt,{open:!!F,ak:F,onClose:()=>N(null)})]})},{TextArea:Ht}=t.Input,{Text:Oe}=t.Typography;function Hs(){var E,Q;const[o,i]=s.useState("servers"),[a,n]=s.useState([]),[T,d]=s.useState(!1),[b,f]=s.useState(!1),[j,w]=s.useState(null),[h]=t.Form.useForm(),[m,z]=s.useState(null),[F,N]=s.useState([]),[u,v]=s.useState(null),[S,x]=s.useState("{}"),[D,G]=s.useState(""),[g,C]=s.useState(!1),[P,K]=s.useState(null);s.useEffect(()=>{O()},[]);const O=async()=>{d(!0);try{const c=localStorage.getItem("z_tenant")||"default",r=await Ie.list(c);n(Array.isArray(r)?r:(r==null?void 0:r.data)||r||[])}catch(c){console.warn("MCP API 不可用:",c==null?void 0:c.message),n([])}finally{d(!1)}},V=async()=>{try{const r={...await h.validateFields()};j?(r.id=j.id,await Ie.update(r),t.message.success("更新成功")):(await Ie.create(r),t.message.success("创建成功")),f(!1),w(null),h.resetFields(),O()}catch{}},U=c=>{w(c),h.setFieldsValue(c),f(!0)},A=async c=>{await Ie.delete(c),t.message.success("已删除"),O()},k=async c=>{K({loading:!0});try{const r=await Ie.test(c.id);K((r==null?void 0:r.data)||r)}catch(r){K({connected:!1,error:r.message})}},_=async c=>{z(c),v(null),G("");try{const r=await Ie.listTools(c.id),L=(r==null?void 0:r.data)||r;N((L==null?void 0:L.tools)||[])}catch{N([]),t.message.error("获取工具列表失败")}},p=c=>{v(c);const r=c.inputSchema;if(r!=null&&r.properties){const L={};Object.keys(r.properties).forEach($=>{L[$]=""}),x(JSON.stringify(L,null,2))}else x("{}");G("")},y=async()=>{if(!(!m||!u)){C(!0),G("Running...");try{let c={};try{c=JSON.parse(S)}catch{}const r=await Ie.callTool(m.id,u.name,c),L=(r==null?void 0:r.data)||r;L!=null&&L.content&&L.content.length>0?G(L.content[0].text||JSON.stringify(L.content,null,2)):G(JSON.stringify(L,null,2))}catch(c){G("Error: "+c.message)}finally{C(!1)}}},M=[{title:"名称",dataIndex:"serverName",key:"serverName",width:140},{title:"类型",dataIndex:"transportType",key:"transportType",width:80,render:c=>e.jsx(t.Tag,{color:c==="STDIO"?"purple":"blue",children:c||"HTTP"})},{title:"URL",dataIndex:"url",key:"url",ellipsis:!0},{title:"状态",dataIndex:"status",key:"status",width:80,render:c=>e.jsx(t.Tag,{color:c==="active"?"green":"default",children:c||"active"})},{title:"操作",key:"actions",width:260,render:(c,r)=>e.jsxs(t.Space,{size:"small",children:[e.jsx(t.Button,{size:"small",icon:e.jsx(l.ApiOutlined,{}),onClick:()=>_(r),children:"工具"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.LinkOutlined,{}),onClick:()=>k(r),children:"测试"}),e.jsx(t.Button,{size:"small",onClick:()=>U(r),children:"编辑"}),e.jsx(t.Popconfirm,{title:"确认删除?",onConfirm:()=>A(r.id),children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{style:{height:"calc(100vh - 180px)",display:"flex",flexDirection:"column"},children:[e.jsxs(t.Tabs,{activeKey:o,onChange:i,tabBarExtraContent:e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:()=>{w(null),h.resetFields(),f(!0)},children:"添加服务"}),children:[e.jsx(t.Tabs.TabPane,{tab:"服务管理"},"servers"),e.jsx(t.Tabs.TabPane,{tab:"工具测试",disabled:!m},"test")]}),o==="servers"&&e.jsxs("div",{style:{flex:1,display:"flex",gap:16,overflow:"hidden"},children:[e.jsx("div",{style:{flex:m?"0 0 50%":1,overflow:"auto"},children:e.jsx(t.Table,{columns:M,dataSource:a,rowKey:"id",loading:T,size:"small",pagination:!1,onRow:c=>({onClick:()=>_(c),style:{background:(m==null?void 0:m.id)===c.id?"#e6f7ff":void 0,cursor:"pointer"}})})}),m&&e.jsxs("div",{style:{flex:"0 0 50%",borderLeft:"1px solid #f0f0f0",paddingLeft:16,overflow:"auto"},children:[e.jsxs("div",{style:{marginBottom:12,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(Oe,{strong:!0,style:{fontSize:15},children:[m.serverName," — 工具列表"]}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),onClick:()=>_(m),children:"刷新"})]}),F.length===0?e.jsx("div",{style:{textAlign:"center",padding:40,color:"#999"},children:"暂无工具"}):F.map(c=>e.jsx(t.Card,{size:"small",hoverable:!0,style:{marginBottom:8,borderColor:(u==null?void 0:u.name)===c.name?"#1890ff":void 0},onClick:()=>{p(c),i("test")},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx(Oe,{strong:!0,children:c.name}),e.jsx("br",{}),e.jsx(Oe,{type:"secondary",style:{fontSize:12},children:c.description})]}),e.jsx(t.Tag,{color:"blue",style:{cursor:"pointer"},onClick:r=>{r.stopPropagation(),p(c),i("test")},children:"测试 →"})]})},c.name))]})]}),o==="test"&&u&&e.jsxs("div",{style:{flex:1,display:"flex",gap:16,overflow:"hidden"},children:[e.jsxs("div",{style:{flex:"0 0 40%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{marginBottom:8},children:[e.jsx(Oe,{strong:!0,children:u.name}),e.jsx(Oe,{type:"secondary",style:{marginLeft:8},children:u.description})]}),e.jsx(Oe,{type:"secondary",style:{marginBottom:4},children:"参数 (JSON):"}),e.jsx(Ht,{rows:8,value:S,onChange:c=>x(c.target.value),style:{fontFamily:"monospace",fontSize:13}}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:y,loading:g,style:{marginTop:12},children:"执行"})]}),e.jsxs("div",{style:{flex:"0 0 60%",display:"flex",flexDirection:"column"},children:[e.jsx(Oe,{type:"secondary",style:{marginBottom:4},children:"结果:"}),e.jsx("pre",{style:{flex:1,overflow:"auto",background:"#f5f5f5",padding:12,borderRadius:4,fontFamily:"monospace",fontSize:13,margin:0,whiteSpace:"pre-wrap"},children:D||'点击"执行"查看结果'})]})]}),e.jsx(t.Modal,{title:"测试连接 - ",open:!!P,onCancel:()=>K(null),footer:e.jsx(t.Button,{onClick:()=>K(null),children:"关闭"}),children:P!=null&&P.loading?e.jsx(Oe,{children:"测试中..."}):P?e.jsxs(t.Descriptions,{column:1,size:"small",children:[e.jsx(t.Descriptions.Item,{label:"连接状态",children:e.jsx(t.Tag,{color:P.connected?"green":"red",children:P.connected?"成功":"失败"})}),P.serverInfo&&e.jsxs(t.Descriptions.Item,{label:"服务信息",children:[(E=P.serverInfo)==null?void 0:E.name," v",(Q=P.serverInfo)==null?void 0:Q.version]}),P.toolCount!==void 0&&e.jsx(t.Descriptions.Item,{label:"工具数量",children:P.toolCount}),P.error&&e.jsx(t.Descriptions.Item,{label:"错误",children:P.error})]}):null}),e.jsx(t.Modal,{title:j?"编辑 MCP 服务":"添加 MCP 服务",open:b,onOk:V,onCancel:()=>{f(!1),w(null),h.resetFields()},children:e.jsxs(t.Form,{form:h,layout:"vertical",initialValues:{transportType:"HTTP",timeout:60,status:"active"},children:[e.jsx(t.Form.Item,{name:"serverName",label:"服务名称",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"如: z-agent-mcp-impl-db"})}),e.jsx(t.Form.Item,{name:"transportType",label:"传输类型",children:e.jsx(t.Select,{options:[{label:"HTTP",value:"HTTP"},{label:"STDIO",value:"STDIO"}]})}),e.jsx(t.Form.Item,{name:"url",label:"URL",rules:[{required:!0}],children:e.jsx(t.Input,{placeholder:"http://localhost:8095/mcp"})}),e.jsx(t.Form.Item,{name:"authToken",label:"Auth Token",children:e.jsx(t.Input.Password,{placeholder:"Bearer token (可选)"})}),e.jsx(t.Form.Item,{name:"timeout",label:"超时(秒)",children:e.jsx(t.InputNumber,{min:5,max:300,style:{width:"100%"}})}),e.jsx(t.Form.Item,{name:"status",label:"状态",children:e.jsx(t.Select,{options:[{label:"启用",value:"active"},{label:"停用",value:"inactive"}]})}),e.jsx(t.Form.Item,{name:"remark",label:"备注",children:e.jsx(Ht,{rows:2})})]})})]})}const Re={private:{label:"私有",color:"default",icon:e.jsx(l.LockOutlined,{})},"public-read":{label:"公共读",color:"blue",icon:e.jsx(l.EyeOutlined,{})},"public-read-write":{label:"公共读写",color:"orange",icon:e.jsx(l.GlobalOutlined,{})},"authenticated-read":{label:"认证读",color:"purple",icon:e.jsx(l.TeamOutlined,{})}};function Js(){const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(!1),[b]=t.Form.useForm(),[f,j]=s.useState(!1),w=Ve.useNavigate(),h=s.useCallback(async()=>{n(!0);try{const u=await me.listBuckets(),v=Array.isArray(u)?u:(u==null?void 0:u.data)||[];i(v)}catch(u){console.error("loadBuckets error:",u),t.message.error("加载桶列表失败:"+((u==null?void 0:u.message)||"未知错误"))}finally{n(!1)}},[]);s.useEffect(()=>{h()},[h]);const m=async()=>{try{const u=await b.validateFields();j(!0),await me.createBucket(u),t.message.success("桶创建成功"),d(!1),b.resetFields(),h()}catch(u){if(u!=null&&u.errorFields)return;t.message.error("创建失败:"+((u==null?void 0:u.message)||"未知错误"))}finally{j(!1)}},z=async u=>{try{await me.deleteBucket(u),t.message.success("已删除"),h()}catch(v){t.message.error("删除失败:"+((v==null?void 0:v.message)||"未知错误"))}},F=async(u,v)=>{try{await me.setBucketAcl(u,v),t.message.success("ACL 已更新"),h()}catch(S){t.message.error("设置 ACL 失败:"+((S==null?void 0:S.message)||"未知错误"))}},N=u=>({items:Object.keys(Re).map(v=>({key:v,label:Re[v].label,icon:Re[v].icon})),onClick:({key:v})=>F(u,v)});return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,background:"#fff",padding:"14px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.04)",marginBottom:16},children:[e.jsx(l.DatabaseOutlined,{style:{fontSize:18,color:"#1890ff"}}),e.jsx("span",{style:{fontSize:16,fontWeight:600},children:"对象存储"}),e.jsx(t.Tag,{color:"blue",children:"OSS Buckets"}),e.jsx("div",{style:{flex:1}}),e.jsx(t.Button,{icon:e.jsx(l.ReloadOutlined,{}),onClick:h,children:"刷新"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:()=>d(!0),children:"创建桶"})]}),e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"桶总数",value:o.length,prefix:e.jsx(l.ApartmentOutlined,{style:{color:"#1890ff"}})})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"公共读",value:o.filter(u=>u.acl==="public-read").length,valueStyle:{color:"#1890ff"},prefix:e.jsx(l.EyeOutlined,{})})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"私有",value:o.filter(u=>!u.acl||u.acl==="private").length,valueStyle:{color:"#999"},prefix:e.jsx(l.LockOutlined,{})})})})]}),a?e.jsx("div",{style:{textAlign:"center",padding:80},children:e.jsx(t.Spin,{size:"large"})}):o.length===0?e.jsx(t.Empty,{image:e.jsx(l.CloudOutlined,{style:{fontSize:64,color:"#bfbfbf"}}),description:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,marginBottom:8},children:"还没有桶"}),e.jsx("div",{style:{color:"#999",fontSize:13,marginBottom:16},children:"创建一个桶来开始使用对象存储"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:()=>d(!0),children:"创建第一个桶"})]}),style:{padding:80,background:"#fff",borderRadius:10}}):e.jsx(t.Row,{gutter:[16,16],children:o.map(u=>{var S;const v=Re[u.acl]||Re.private;return e.jsx(t.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(t.Card,{hoverable:!0,onClick:()=>w(`/ai/oss/bucket/${encodeURIComponent(u.name)}`),style:{borderRadius:12,border:"none",boxShadow:"0 2px 12px rgba(0,0,0,0.07)"},styles:{body:{padding:18}},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:10,background:"linear-gradient(135deg, #1890ff 0%, #36cfc9 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.FolderOutlined,{style:{fontSize:22,color:"#fff"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:"#262626",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.name}),e.jsxs("div",{style:{fontSize:12,color:"#999",marginTop:4},children:[u.region||"default"," · ",((S=u.createTime)==null?void 0:S.slice(0,10))||"-"]})]}),e.jsx(t.Dropdown,{trigger:["click"],menu:N(u.name),onClick:x=>x.stopPropagation(),children:e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.MoreOutlined,{}),onClick:x=>x.stopPropagation()})})]}),e.jsx("div",{style:{marginTop:14,display:"flex",gap:6,flexWrap:"wrap"},children:e.jsx(t.Tag,{color:v.color,icon:v.icon,children:v.label})}),e.jsxs("div",{style:{marginTop:14,paddingTop:12,borderTop:"1px solid #f5f5f5",display:"flex",gap:8,justifyContent:"space-between"},children:[e.jsx(t.Tooltip,{title:"进入桶",children:e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.AppstoreOutlined,{}),onClick:x=>{x.stopPropagation(),w(`/ai/oss/bucket/${encodeURIComponent(u.name)}`)},children:"浏览对象"})}),e.jsx(t.Popconfirm,{title:`确定删除桶 "${u.name}"?`,description:"桶必须为空才能删除",onConfirm:x=>{x==null||x.stopPropagation(),z(u.name)},onCancel:x=>x==null?void 0:x.stopPropagation(),okText:"确认",cancelText:"取消",okType:"danger",children:e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:x=>x.stopPropagation(),children:"删除"})})]})]})},u.id||u.name)})}),e.jsx(t.Modal,{title:e.jsxs(t.Space,{children:[e.jsx(l.CloudOutlined,{style:{color:"#1890ff"}}),e.jsx("span",{children:"创建存储桶"})]}),open:T,onCancel:()=>{d(!1),b.resetFields()},onOk:m,confirmLoading:f,okText:"创建",cancelText:"取消",destroyOnClose:!0,children:e.jsxs(t.Form,{form:b,layout:"vertical",initialValues:{acl:"private"},style:{marginTop:16},children:[e.jsx(t.Form.Item,{name:"name",label:"桶名称",rules:[{required:!0,message:"请输入桶名称"},{pattern:/^[a-z0-9][a-z0-9-]{2,62}[a-z0-9]$/,message:"只能包含小写字母、数字、连字符,长度 3-63"}],extra:"仅支持小写字母、数字、连字符,长度 3-63 字符",children:e.jsx(t.Input,{placeholder:"my-bucket",prefix:e.jsx(l.FolderOutlined,{})})}),e.jsx(t.Form.Item,{name:"region",label:"区域",initialValue:"default",children:e.jsx(t.Input,{placeholder:"default"})}),e.jsx(t.Form.Item,{name:"acl",label:"访问权限",initialValue:"private",children:e.jsx(t.Select,{options:Object.entries(Re).map(([u,v])=>({value:u,label:e.jsxs(t.Space,{children:[v.icon,v.label]})}))})})]})})]})}const Jt=o=>{if(!o||o===0)return"-";const i=["B","KB","MB","GB","TB"];let a=0,n=o;for(;n>=1024&&a<i.length-1;)n/=1024,a++;return n.toFixed(a===0?0:1)+" "+i[a]},Ys=o=>{var a;if(o.endsWith("/"))return e.jsx(l.FolderOutlined,{style:{color:"#faad14"}});const i=(a=o.split(".").pop())==null?void 0:a.toLowerCase();return["zip","tar","gz","rar","7z"].includes(i)?e.jsx(l.FileZipOutlined,{style:{color:"#722ed1"}}):["png","jpg","jpeg","gif","svg","webp"].includes(i)?e.jsx(l.FileImageOutlined,{style:{color:"#13c2c2"}}):["md","txt","log","json","xml","yaml","yml"].includes(i)?e.jsx(l.FileTextOutlined,{style:{color:"#52c41a"}}):e.jsx(l.FileOutlined,{style:{color:"#8c8c8c"}})};function Qs(){const{bucketName:o}=Ve.useParams(),i=decodeURIComponent(o||""),a=Ve.useNavigate(),[n,T]=s.useState([]),[d,b]=s.useState(!1),[f,j]=s.useState(""),[w,h]=s.useState({objectCount:0,totalSize:0}),[m,z]=s.useState(""),[F,N]=s.useState([]),[u,v]=s.useState(!1),[S,x]=s.useState(!1),[D]=t.Form.useForm();s.useRef(null);const G=s.useCallback(async(y=f)=>{if(i){b(!0);try{const M=await me.listObjects(i,y||void 0),E=Array.isArray(M)?M:(M==null?void 0:M.data)||[];T(E)}catch(M){t.message.error("加载对象失败:"+((M==null?void 0:M.message)||"未知错误")),T([])}finally{b(!1)}}},[i,f]),g=s.useCallback(async()=>{try{const y=await me.getBucketStats(i);h(y||{objectCount:0,totalSize:0})}catch{}},[i]);s.useEffect(()=>{j(""),N([])},[i]),s.useEffect(()=>{G(f),g()},[f,G,g]);const C=y=>{y.endsWith("/")&&(j(y),N([]))},P=y=>{j(y),N([])},K=async y=>{if(!y)return!1;v(!0);const M=(f||"")+y.name;try{await me.uploadObject(i,M,y),t.message.success(`已上传: ${y.name}`),G(f),g()}catch(E){t.message.error("上传失败:"+((E==null?void 0:E.message)||"未知错误"))}finally{v(!1)}return!1},O=async y=>{if(!(!y||y.length===0))try{y.length===1?await me.deleteObject(i,y[0]):await me.batchDelete(i,y),t.message.success(`已删除 ${y.length} 个`),N([]),G(f),g()}catch(M){t.message.error("删除失败:"+((M==null?void 0:M.message)||"未知错误"))}},V=async()=>{try{const y=await D.validateFields(),M=(f||"")+y.name+"/";await me.createFolder(i,M),t.message.success("文件夹已创建"),x(!1),D.resetFields(),G(f)}catch(y){if(y!=null&&y.errorFields)return;t.message.error("创建失败:"+((y==null?void 0:y.message)||"未知错误"))}},U=async y=>{try{const M=await me.presignedUrl(i,y,3600),E=(M==null?void 0:M.url)||me.downloadUrl(i,y);window.open(E,"_blank")}catch{window.open(me.downloadUrl(i,y),"_blank")}},A=async y=>{const M=(f||"")+"_copy_"+y.split("/").pop();try{await me.copyObject(i,y,i,M),t.message.success("已复制"),G(f)}catch(E){t.message.error("复制失败:"+((E==null?void 0:E.message)||"未知错误"))}},k=m?n.filter(y=>{var M;return(M=y.key)==null?void 0:M.toLowerCase().includes(m.toLowerCase())}):n,_=[{title:"名称",dataIndex:"key",render:(y,M)=>{const E=(y==null?void 0:y.endsWith("/"))||M.folder,Q=(y==null?void 0:y.split("/").filter(Boolean).pop())||y;return e.jsx("span",{style:{cursor:E?"pointer":"default",color:E?"#faad14":"#262626"},onClick:()=>E&&C(y),children:e.jsxs(t.Space,{children:[Ys(y),e.jsx("span",{style:{fontWeight:E?500:400},children:Q})]})})}},{title:"大小",dataIndex:"size",width:110,render:y=>Jt(y)},{title:"类型",dataIndex:"contentType",width:200,ellipsis:!0,render:y=>y?e.jsx(t.Tag,{children:y}):"-"},{title:"修改时间",dataIndex:"lastModified",width:180,render:y=>y?new Date(y).toLocaleString():"-"},{title:"操作",width:160,fixed:"right",render:(y,M)=>{var c;const Q=((c=M.key)==null?void 0:c.endsWith("/"))||M.folder?[{key:"enter",icon:e.jsx(l.FolderOutlined,{}),label:"进入"},{key:"delete",icon:e.jsx(l.DeleteOutlined,{}),label:"删除",danger:!0}]:[{key:"download",icon:e.jsx(l.DownloadOutlined,{}),label:"下载"},{key:"copy",icon:e.jsx(l.CopyOutlined,{}),label:"复制"},{key:"delete",icon:e.jsx(l.DeleteOutlined,{}),label:"删除",danger:!0}];return e.jsx(t.Dropdown,{trigger:["click"],menu:{items:Q,onClick:({key:r,domEvent:L})=>{L.stopPropagation(),r==="enter"?C(M.key):r==="download"?U(M.key):r==="copy"?A(M.key):r==="delete"&&O([M.key])}},children:e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.MoreOutlined,{})})})}}],p=[{title:"所有桶",onClick:()=>a("/ai/oss/bucket")},{title:i}];if(f){const y=f.split("/").filter(Boolean);let M="";y.forEach(E=>{M+=E+"/",p.push({title:E,onClick:()=>P(M)})})}return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,background:"#fff",padding:"14px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.04)",marginBottom:16},children:[e.jsx(t.Button,{type:"text",icon:e.jsx(l.ArrowLeftOutlined,{}),onClick:()=>a("/ai/oss/bucket"),children:"返回"}),e.jsx(l.FolderOutlined,{style:{fontSize:18,color:"#faad14"}}),e.jsx("span",{style:{fontSize:16,fontWeight:600},children:i}),e.jsx("div",{style:{flex:1}}),e.jsx(t.Input.Search,{placeholder:"搜索对象名...",value:m,onChange:y=>z(y.target.value),style:{width:220},allowClear:!0}),e.jsx(t.Button,{icon:e.jsx(l.ReloadOutlined,{}),onClick:()=>{G(f),g()}})]}),e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"对象数",value:w.objectCount||0})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"总大小",value:Jt(w.totalSize)})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Card,{children:e.jsx(t.Statistic,{title:"Provider",value:w.activeProvider||"-",valueStyle:{fontSize:18,color:"#1890ff"},prefix:e.jsx(l.CloudOutlined,{})})})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#fff",padding:"10px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.04)",marginBottom:12},children:[e.jsx(t.Breadcrumb,{items:p,style:{flex:1}}),F.length>0&&e.jsx(t.Popconfirm,{title:`确定删除 ${F.length} 个对象?`,onConfirm:()=>O(F),okText:"确认",cancelText:"取消",okType:"danger",children:e.jsxs(t.Button,{danger:!0,size:"small",icon:e.jsx(l.DeleteOutlined,{}),children:["批量删除 (",F.length,")"]})}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.FolderAddOutlined,{}),onClick:()=>x(!0),children:"新建文件夹"}),e.jsx(t.Upload,{beforeUpload:K,showUploadList:!1,disabled:u,children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.UploadOutlined,{}),loading:u,children:"上传文件"})})]}),e.jsx(t.Card,{styles:{body:{padding:0}},children:d?e.jsx("div",{style:{textAlign:"center",padding:60},children:e.jsx(t.Spin,{size:"large"})}):k.length===0?e.jsx(t.Empty,{image:e.jsx(l.CloudOutlined,{style:{fontSize:48,color:"#bfbfbf"}}),description:m?"没有匹配的对象":"桶是空的,上传第一个文件吧",style:{padding:60}}):e.jsx(t.Table,{rowKey:"key",columns:_,dataSource:k,pagination:!1,size:"middle",rowSelection:{selectedRowKeys:F,onChange:N},onRow:y=>({onDoubleClick:()=>{var M;((M=y.key)!=null&&M.endsWith("/")||y.folder)&&C(y.key)}})})}),e.jsx(t.Modal,{title:"新建文件夹",open:S,onCancel:()=>{x(!1),D.resetFields()},onOk:V,okText:"创建",cancelText:"取消",destroyOnClose:!0,children:e.jsxs(t.Form,{form:D,layout:"vertical",style:{marginTop:16},children:[e.jsx(t.Form.Item,{name:"name",label:"文件夹名",rules:[{required:!0,message:"请输入文件夹名"}],children:e.jsx(t.Input,{prefix:e.jsx(l.FolderOutlined,{}),placeholder:"my-folder"})}),e.jsxs("div",{style:{fontSize:12,color:"#999"},children:["将创建在:",e.jsxs("code",{children:[i,"/",f||""]})]})]})})]})}const Zs=[{value:"string",label:"string"},{value:"number",label:"number"},{value:"boolean",label:"boolean"},{value:"object",label:"object"},{value:"array",label:"array"}];function xt({value:o=[],onChange:i,readonly:a=!1}){const n=(j,w,h)=>{const m=[...o];m[j]={...m[j],[w]:h},i(m)},T=j=>{const w=o.filter((h,m)=>m!==j);i(w)},d=(j,w)=>{const h=j+w;if(h<0||h>=o.length)return;const m=[...o],z=m[j];m[j]=m[h],m[h]=z,i(m)},b=()=>{i([...o,{name:"",type:"string",jsonPath:"",required:!1,description:""}])},f=[{title:"输出字段名",dataIndex:"name",width:150,render:(j,w,h)=>a?e.jsx("span",{style:{fontFamily:"monospace"},children:j}):e.jsx(t.Input,{size:"small",value:j,onChange:m=>n(h,"name",m.target.value),placeholder:"e.g. user_name"})},{title:"类型",dataIndex:"type",width:100,render:(j,w,h)=>a?e.jsx("span",{children:j}):e.jsx(t.Select,{size:"small",value:j,onChange:m=>n(h,"type",m),options:Zs,style:{width:"100%"}})},{title:"JSONPath",dataIndex:"jsonPath",width:220,render:(j,w,h)=>a?e.jsx("span",{style:{fontFamily:"monospace",color:"#0958d9"},children:j}):e.jsx(t.Input,{size:"small",value:j,onChange:m=>n(h,"jsonPath",m.target.value),placeholder:"$.data.user.name",style:{fontFamily:"monospace"}})},{title:"必填",dataIndex:"required",width:60,render:(j,w,h)=>a?e.jsx("span",{style:{color:j?"#ff4d4f":"#999"},children:j?"是":"否"}):e.jsx(t.Switch,{size:"small",checked:j,onChange:m=>n(h,"required",m)})},{title:"描述",dataIndex:"description",width:160,render:(j,w,h)=>a?e.jsx("span",{style:{color:"#666"},children:j}):e.jsx(t.Input,{size:"small",value:j,onChange:m=>n(h,"description",m.target.value),placeholder:"字段说明"})},...a?[]:[{title:"操作",key:"action",width:100,render:(j,w,h)=>e.jsxs(t.Space,{size:"small",children:[e.jsx(t.Tooltip,{title:"上移",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.ArrowUpOutlined,{}),disabled:h===0,onClick:()=>d(h,-1)})}),e.jsx(t.Tooltip,{title:"下移",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.ArrowDownOutlined,{}),disabled:h===o.length-1,onClick:()=>d(h,1)})}),e.jsx(t.Tooltip,{title:"删除",children:e.jsx(t.Button,{size:"small",type:"text",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>T(h)})})]})}]];return e.jsxs("div",{children:[e.jsx(t.Table,{dataSource:o,columns:f,rowKey:(j,w)=>w,pagination:!1,size:"small",bordered:!0,style:{marginBottom:8}}),!a&&e.jsx(t.Button,{size:"small",type:"dashed",icon:e.jsx(l.PlusOutlined,{}),onClick:b,block:!0,children:"添加字段映射"}),o.length===0&&!a&&e.jsx("div",{style:{textAlign:"center",color:"#999",padding:12},children:"暂未配置输出字段映射。发布后 MCP 工具将返回原始响应体。"})]})}const{TextArea:Xs}=t.Input,{Step:ht}=t.Steps;function Yt({open:o,onClose:i,onSuccess:a}){var V,U,A,k,_;const[n,T]=s.useState(0),[d,b]=s.useState(!1),[f,j]=s.useState(!1),[w,h]=s.useState(""),[m,z]=s.useState(null),[F,N]=s.useState([]),[u,v]=s.useState(null),[S,x]=s.useState("mapping"),D=()=>{T(0),h(""),z(null),N([]),v(null),x("mapping")},G=()=>{D(),i()},g=async()=>{if(!w.trim()){t.message.warning("请粘贴 curl 命令");return}b(!0);try{const p=await be.importCurl({curl:w});p!=null&&p.success?(z(p),N(p.outputMapping||[]),T(1)):t.message.error((p==null?void 0:p.message)||"解析失败")}catch(p){t.message.error("解析失败: "+((p==null?void 0:p.message)||"网络错误"))}finally{b(!1)}},C=async()=>{j(!0);try{const p=await be.previewMapping({curl:w,outputMapping:F.filter(y=>y.name&&y.jsonPath)});v(p),x("result")}catch(p){t.message.error("预览失败: "+((p==null?void 0:p.message)||"网络错误"))}finally{j(!1)}},P=async()=>{b(!0);try{const p=await be.importCurl({curl:w,outputMapping:F.filter(y=>y.name&&y.jsonPath)});p!=null&&p.success?(t.message.success(`脚本 [${p.scriptCode}] 创建成功`),D(),a==null||a(),i()):t.message.error((p==null?void 0:p.message)||"创建失败")}catch(p){t.message.error("创建失败: "+((p==null?void 0:p.message)||"网络错误"))}finally{b(!1)}},K=(V=m==null?void 0:m.request)==null?void 0:V.httpRequestLine,O=(A=(U=m==null?void 0:m.request)==null?void 0:U.httpRequestHeader)==null?void 0:A.headers;return e.jsxs(t.Modal,{title:e.jsxs(t.Space,{children:[e.jsx(l.ApiOutlined,{}),"从 Curl 导入 API Bridge 脚本"]}),open:o,onCancel:G,width:900,footer:null,destroyOnClose:!0,children:[e.jsxs(t.Steps,{current:n,size:"small",style:{marginBottom:24},children:[e.jsx(ht,{title:"粘贴 curl",description:"输入 curl 命令"}),e.jsx(ht,{title:"配置映射",description:"设置字段映射"}),e.jsx(ht,{title:"确认创建",description:"保存脚本"})]}),n===0&&e.jsxs("div",{children:[e.jsx("p",{style:{color:"#666",marginBottom:8},children:"粘贴任意 HTTP curl 命令,系统将自动解析并生成 API_BRIDGE 脚本"}),e.jsx(Xs,{rows:8,value:w,onChange:p=>h(p.target.value),placeholder:`curl -X POST https://api.example.com/users \\
25
+ -H "Authorization: Bearer \${token}" \\
26
+ -H "Content-Type: application/json" \\
27
+ -d '{"name": "\${name}", "email": "\${email}"}'`,style:{fontFamily:"monospace",fontSize:13,marginBottom:12}}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.CodeOutlined,{}),onClick:g,loading:d,block:!0,children:"解析 curl"})]}),n===1&&m&&e.jsxs("div",{children:[e.jsxs(t.Card,{size:"small",title:"请求信息",style:{marginBottom:16},children:[e.jsxs(t.Descriptions,{column:3,size:"small",children:[e.jsx(t.Descriptions.Item,{label:"方法",children:e.jsx(t.Tag,{color:"blue",children:(K==null?void 0:K.method)||"GET"})}),e.jsx(t.Descriptions.Item,{label:"URL",span:2,children:e.jsx(Text,{copyable:!0,style:{fontFamily:"monospace",fontSize:12},children:K==null?void 0:K.url})})]}),O&&Object.keys(O).length>0&&e.jsxs("div",{style:{marginTop:8},children:[e.jsx("span",{style:{fontSize:12,color:"#666",fontWeight:500},children:"请求头: "}),Object.entries(O).map(([p,y])=>e.jsxs(t.Tag,{style:{fontFamily:"monospace",fontSize:11},children:[p,": ",String(y).substring(0,40)]},p))]}),((k=m.inputParams)==null?void 0:k.length)>0&&e.jsxs("div",{style:{marginTop:8},children:[e.jsx("span",{style:{fontSize:12,color:"#666",fontWeight:500},children:"输入参数: "}),m.inputParams.map(p=>e.jsxs(t.Tag,{color:p.required?"orange":"default",style:{fontFamily:"monospace"},children:[p.name," ",e.jsxs("span",{style:{fontSize:10},children:["(",p.in,")"]})]},p.name))]})]}),e.jsx(t.Tabs,{activeKey:S,onChange:x,items:[{key:"mapping",label:"输出字段映射",children:e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:12,color:"#666",marginBottom:8},children:"配置 JSONPath 从响应中抽取字段。MCP 工具只返回映射后的字段。"}),e.jsx(xt,{value:F,onChange:N})]})},{key:"result",label:"试运行结果",children:e.jsxs("div",{children:[e.jsx(t.Button,{icon:e.jsx(l.ExperimentOutlined,{}),onClick:C,loading:f,style:{marginBottom:12},children:"试运行并查看映射结果"}),u&&e.jsxs("div",{children:[u.error?e.jsx(t.Alert,{type:"error",message:u.error,style:{marginBottom:12}}):e.jsxs(t.Descriptions,{column:3,size:"small",bordered:!0,style:{marginBottom:12},children:[e.jsx(t.Descriptions.Item,{label:"状态码",children:u.status}),e.jsxs(t.Descriptions.Item,{label:"耗时",children:[u.durationMs,"ms"]}),e.jsxs(t.Descriptions.Item,{label:"响应体大小",children:[(((_=u.bodyRaw)==null?void 0:_.length)||0).toLocaleString()," chars"]})]}),u.mapped&&Object.keys(u.mapped).length>0&&e.jsx(t.Card,{size:"small",title:"映射结果",style:{marginBottom:12},children:e.jsx("pre",{style:{fontFamily:"monospace",fontSize:12,margin:0,whiteSpace:"pre-wrap"},children:JSON.stringify(u.mapped,null,2)})}),u.bodyObject&&e.jsx(t.Card,{size:"small",title:"原始响应 (JSON)",style:{marginBottom:12},children:e.jsx("pre",{style:{fontFamily:"monospace",fontSize:12,margin:0,maxHeight:300,overflow:"auto",whiteSpace:"pre-wrap"},children:JSON.stringify(u.bodyObject,null,2)})})]})]})}]})]}),n===1&&m&&e.jsx("div",{style:{marginTop:16,textAlign:"right"},children:e.jsxs(t.Space,{children:[e.jsx(t.Button,{onClick:()=>{T(0),z(null)},children:"返回"}),e.jsx(t.Button,{onClick:C,loading:f,children:"试运行"}),e.jsx(t.Button,{type:"primary",onClick:P,loading:d,children:"创建脚本"})]})})]})}const{TextArea:qs}=t.Input;function Qt({open:o,onClose:i,onSuccess:a}){const[n,T]=s.useState(""),[d,b]=s.useState(null),[f,j]=s.useState(null),[w,h]=s.useState(!1),m=()=>{T(""),b(null),j(null)},z=()=>{m(),i()},F=()=>{if(!n.trim()){t.message.warning("请粘贴 OpenAPI JSON");return}try{const x=JSON.parse(n).paths;if(!x){t.message.warning("OpenAPI 中没有 paths 段");return}const D=[];for(const G of Object.keys(x)){const g=x[G];for(const C of["get","post","put","delete","patch"]){const P=g[C];P&&D.push({key:`${C}_${G}`,method:C.toUpperCase(),path:G,summary:P.summary||P.operationId||"",operationId:P.operationId||"-"})}}b(D),D.length===0?t.message.info("未找到可解析的接口"):t.message.success(`解析到 ${D.length} 个接口`)}catch(S){t.message.error("JSON 解析失败: "+S.message)}},N=async()=>{if(n.trim()){h(!0);try{const S=await be.importOpenApi({openApiJson:n});S!=null&&S.success?(j(S),t.message.success(`成功导入 ${S.count} 个脚本`)):t.message.error((S==null?void 0:S.message)||"导入失败")}catch(S){t.message.error("导入失败: "+((S==null?void 0:S.message)||"网络错误"))}finally{h(!1)}}},u=[{title:"方法",dataIndex:"method",key:"method",width:80,render:S=>{const x={GET:"green",POST:"blue",PUT:"orange",DELETE:"red",PATCH:"purple"};return e.jsx(t.Tag,{color:x[S]||"default",children:S})}},{title:"路径",dataIndex:"path",key:"path",width:280,render:S=>e.jsx("code",{style:{fontSize:12},children:S})},{title:"描述",dataIndex:"summary",key:"summary",ellipsis:!0},{title:"OperationId",dataIndex:"operationId",key:"operationId",width:160,render:S=>e.jsx(t.Tag,{style:{fontFamily:"monospace"},children:S})}],v=[{title:"方法",dataIndex:"method",key:"method",width:80,render:S=>{const x={GET:"green",POST:"blue",PUT:"orange",DELETE:"red",PATCH:"purple"};return e.jsx(t.Tag,{color:x[S]||"default",children:S})}},{title:"路径",dataIndex:"path",key:"path",width:280,render:S=>e.jsx("code",{style:{fontSize:12},children:S})},{title:"脚本编码",dataIndex:"scriptCode",key:"scriptCode",width:200,render:S=>e.jsx(t.Tag,{color:"blue",style:{fontFamily:"monospace"},children:S})},{title:"脚本名称",dataIndex:"scriptName",key:"scriptName",ellipsis:!0},{title:"结果",dataIndex:"created",key:"created",width:80,render:S=>S?e.jsx(t.Tag,{color:"green",children:"成功"}):e.jsx(t.Tag,{color:"red",children:"跳过"})}];return e.jsxs(t.Modal,{title:e.jsxs(t.Space,{children:[e.jsx(l.ApiOutlined,{}),"从 OpenAPI 批量导入脚本"]}),open:o,onCancel:z,width:960,footer:null,destroyOnClose:!0,children:[!d&&!f&&e.jsxs("div",{children:[e.jsx("p",{style:{color:"#666",marginBottom:8},children:"粘贴 OpenAPI 3.0 / Swagger 2.0 规范的 JSON 内容,系统将自动为每个端点生成 API_BRIDGE 脚本。"}),e.jsx(qs,{rows:12,value:n,onChange:S=>T(S.target.value),placeholder:`{
28
+ "openapi": "3.0.0",
29
+ "info": {...},
30
+ "paths": {
31
+ "/users": {
32
+ "get": {
33
+ "operationId": "listUsers",
34
+ "summary": "获取用户列表",
35
+ ...
36
+ }
37
+ }
38
+ }
39
+ }`,style:{fontFamily:"monospace",fontSize:13,marginBottom:12}}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.FileTextOutlined,{}),onClick:F,block:!0,children:"解析预览"})]}),d&&!f&&e.jsxs("div",{children:[e.jsx(t.Alert,{type:"info",message:`共解析到 ${d.length} 个接口,确认后将批量导入为 API_BRIDGE 脚本`,style:{marginBottom:12},showIcon:!0}),e.jsx(t.Table,{dataSource:d,columns:u,pagination:{pageSize:10},size:"small",bordered:!0,rowKey:"key"}),e.jsx("div",{style:{marginTop:16,textAlign:"right"},children:e.jsxs(t.Space,{children:[e.jsx(t.Button,{onClick:()=>{b(null),T("")},children:"返回修改"}),e.jsxs(t.Button,{type:"primary",icon:e.jsx(l.UploadOutlined,{}),onClick:N,loading:w,children:["导入 ",d.length," 个脚本"]})]})})]}),f&&e.jsxs("div",{children:[e.jsxs(t.Card,{style:{marginBottom:12,textAlign:"center"},children:[e.jsx(t.Progress,{type:"circle",percent:100,format:()=>`${f.count}`,width:80}),e.jsxs("div",{style:{marginTop:8,fontWeight:500},children:["成功导入 ",f.count," 个脚本"]})]}),e.jsx(t.Table,{dataSource:f.items||[],columns:v,pagination:{pageSize:10},size:"small",bordered:!0,rowKey:"scriptCode"}),e.jsx("div",{style:{marginTop:16,textAlign:"right"},children:e.jsx(t.Space,{children:e.jsx(t.Button,{onClick:()=>{m(),a==null||a(),i()},children:"完成"})})})]})]})}const{Text:Je,Paragraph:Ll}=t.Typography,$s=[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"DELETE",label:"DELETE"},{value:"PATCH",label:"PATCH"},{value:"HEAD",label:"HEAD"},{value:"OPTIONS",label:"OPTIONS"}],el=[{value:"path",label:"path"},{value:"query",label:"query"},{value:"header",label:"header"},{value:"body",label:"body"}];function Zt({value:o,onChange:i,readonly:a=!1}){var S,x,D,G,g;const[n,T]=s.useState(null),[d,b]=s.useState(null);s.useEffect(()=>{if(!o){T({request:{httpRequestLine:{url:"",requestMethod:"GET"},httpRequestHeader:{headers:{}},httpRequestBody:{body:null}},inputParams:[],outputMapping:[]}),b(null);return}try{const C=typeof o=="string"?JSON.parse(o):o;C.request||(C.request={}),C.request.httpRequestLine||(C.request.httpRequestLine={}),C.request.httpRequestHeader||(C.request.httpRequestHeader={}),C.request.httpRequestBody||(C.request.httpRequestBody={}),C.inputParams||(C.inputParams=[]),C.outputMapping||(C.outputMapping=[]),T(C),b(null)}catch(C){b("JSON 解析失败: "+C.message)}},[o]);const f=s.useCallback(C=>{T(C),i==null||i(JSON.stringify(C,null,2))},[i]);if(d)return e.jsxs(t.Card,{size:"small",style:{borderColor:"#ff4d4f"},children:[e.jsx(Je,{type:"danger",children:d}),e.jsx("pre",{style:{fontFamily:"monospace",fontSize:12,marginTop:8,maxHeight:200,overflow:"auto"},children:typeof o=="string"?o.substring(0,500):String(o)})]});if(!n)return null;const j=((S=n.request)==null?void 0:S.httpRequestLine)||{},w=((D=(x=n.request)==null?void 0:x.httpRequestHeader)==null?void 0:D.headers)||{},h=C=>{const P=JSON.parse(JSON.stringify(n));P.request.httpRequestLine.requestMethod=C,f(P)},m=C=>{const P=JSON.parse(JSON.stringify(n));P.request.httpRequestLine.url=C,f(P)},z=(C,P,K)=>{const O=JSON.parse(JSON.stringify(n));O.inputParams[C][P]=K,f(O)},F=C=>{const P=JSON.parse(JSON.stringify(n));P.inputParams=P.inputParams.filter((K,O)=>O!==C),f(P)},N=()=>{const C=JSON.parse(JSON.stringify(n));C.inputParams.push({name:"",in:"query",required:!1,description:"",defaultValue:""}),f(C)},u=C=>{const P=JSON.parse(JSON.stringify(n));P.outputMapping=C,f(P)},v=[{title:"参数名",dataIndex:"name",width:140,render:(C,P,K)=>a?e.jsx(Je,{code:!0,children:C}):e.jsx(t.Input,{size:"small",value:C,onChange:O=>z(K,"name",O.target.value),placeholder:"param name"})},{title:"位置",dataIndex:"in",width:100,render:(C,P,K)=>a?e.jsx(t.Tag,{children:C}):e.jsx(t.Select,{size:"small",value:C,onChange:O=>z(K,"in",O),options:el,style:{width:"100%"}})},{title:"必填",dataIndex:"required",width:70,render:(C,P,K)=>a?e.jsx("span",{style:{color:C?"#ff4d4f":"#999"},children:C?"是":"否"}):e.jsx(t.Switch,{size:"small",checked:C,onChange:O=>z(K,"required",O)})},{title:"默认值",dataIndex:"defaultValue",width:120,render:(C,P,K)=>a?e.jsx("span",{children:C||"-"}):e.jsx(t.Input,{size:"small",value:C||"",onChange:O=>z(K,"defaultValue",O.target.value),placeholder:"default"})},{title:"描述",dataIndex:"description",render:(C,P,K)=>a?e.jsx("span",{style:{color:"#666"},children:C}):e.jsx(t.Input,{size:"small",value:C,onChange:O=>z(K,"description",O.target.value),placeholder:"描述"})},...a?[]:[{title:"",key:"action",width:50,render:(C,P,K)=>e.jsx(t.Tooltip,{title:"删除",children:e.jsx(t.Button,{size:"small",type:"text",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>F(K)})})}]];return e.jsxs("div",{children:[e.jsx(t.Card,{size:"small",title:"请求配置",style:{marginBottom:16},children:e.jsxs(t.Space,{style:{width:"100%"},direction:"vertical",size:"small",children:[e.jsxs(t.Space,{align:"center",style:{width:"100%"},children:[a?e.jsx(t.Tag,{color:"blue",style:{fontSize:14,padding:"2px 12px"},children:j.requestMethod||"GET"}):e.jsx(t.Select,{value:j.requestMethod||"GET",onChange:h,options:$s,style:{width:120}}),a?e.jsx(Je,{code:!0,style:{fontSize:13,wordBreak:"break-all"},children:j.url}):e.jsx(t.Input,{value:j.url||"",onChange:C=>m(C.target.value),placeholder:"https://api.example.com/resource/{id}?key=${key}",style:{fontFamily:"monospace",flex:1}})]}),Object.keys(w).length>0&&e.jsxs("div",{children:[e.jsx(Je,{type:"secondary",style:{fontSize:12},children:"请求头: "}),Object.entries(w).map(([C,P])=>e.jsxs(t.Tag,{style:{fontFamily:"monospace",fontSize:11},children:[C,": ",String(P).substring(0,50)]},C))]})]})}),e.jsx(t.Card,{size:"small",title:`输入参数 (${((G=n.inputParams)==null?void 0:G.length)||0})`,style:{marginBottom:16},extra:!a&&e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.PlusOutlined,{}),onClick:N,children:"添加"}),children:e.jsx(t.Table,{dataSource:n.inputParams||[],columns:v,rowKey:(C,P)=>P,pagination:!1,size:"small",locale:{emptyText:"暂无输入参数"}})}),e.jsx(t.Card,{size:"small",title:`输出字段映射 (${((g=n.outputMapping)==null?void 0:g.length)||0})`,children:e.jsx(xt,{value:n.outputMapping||[],onChange:u,readonly:a})})]})}const{TextArea:mt}=t.Input,{Text:gt,Paragraph:Xt}=t.Typography,tl=[{value:"EL",label:"EL (SpEL)"},{value:"GROOVY",label:"Groovy"},{value:"LUA",label:"Lua"},{value:"SQL",label:"SQL"},{value:"MOCK",label:"Mock Template"},{value:"API_BRIDGE",label:"API Bridge"}],sl=[{value:"NONE",label:"None"},{value:"HTTP",label:"HTTP"},{value:"MCP",label:"MCP"},{value:"BOTH",label:"HTTP + MCP"}],qt={0:{text:"Draft",color:"default"},1:{text:"Active",color:"green"},2:{text:"Disabled",color:"red"}},ll={NONE:"default",HTTP:"blue",MCP:"purple",BOTH:"cyan"},ol=[{id:1,scriptCode:"hello-el",scriptName:"Hello EL表达式",dslType:"EL",exposeAs:"HTTP",status:1,version:"1.0.0",httpPath:"/run/hello-el",sourceCode:"'Hello from ' + #name + '!'"},{id:2,scriptCode:"hello-groovy",scriptName:"Hello Groovy",dslType:"GROOVY",exposeAs:"NONE",status:1,version:"1.0.0",sourceCode:`def result = "Hello from Groovy!"
40
+ return result`},{id:3,scriptCode:"mock-users",scriptName:"Mock Users API",dslType:"MOCK",exposeAs:"HTTP",status:1,version:"1.0.0",httpPath:"/run/mock-users",sourceCode:'{"users": [{"name": "@name", "email": "@email"}]}'},{id:4,scriptCode:"parse-sql",scriptName:"SQL解析器",dslType:"SQL",exposeAs:"NONE",status:1,version:"1.0.0",sourceCode:"SELECT id, name FROM users WHERE status = 1"},{id:5,scriptCode:"lua-greet",scriptName:"Lua问候",dslType:"LUA",exposeAs:"NONE",status:0,version:"0.1.0",sourceCode:'return "Hello from Lua!"'},{id:6,scriptCode:"fetch-weather",scriptName:"Fetch Weather",dslType:"API_BRIDGE",exposeAs:"MCP",status:1,version:"1.0.0",mcpToolName:"fetch_weather",sourceCode:`source: https://api.weather.com
41
+ method: GET`}];function il(){const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(!1),[b,f]=s.useState(!1),[j,w]=s.useState(null),[h]=t.Form.useForm(),[m,z]=s.useState(!1),[F,N]=s.useState(null),[u,v]=s.useState("{}"),[S,x]=s.useState(""),[D,G]=s.useState(!1),[g,C]=s.useState(!1),[P,K]=s.useState(!1),[O,V]=s.useState(null),A=t.Form.useWatch("dslType",h)==="API_BRIDGE";s.useEffect(()=>{k()},[]);const k=async()=>{n(!0);try{const R=await be.list();i(Array.isArray(R)?R:(R==null?void 0:R.data)||R||[]),d(!1)}catch(R){console.warn("Script API unavailable:",R==null?void 0:R.message),i(ol),d(!0),t.message.warning("后端未连接,显示模拟数据")}finally{n(!1)}},_=()=>{w(null),h.resetFields(),h.setFieldsValue({dslType:"EL",exposeAs:"NONE",status:0}),V(null),f(!0)},p=R=>{V(R==="API_BRIDGE"?JSON.stringify({request:{httpRequestLine:{url:"",requestMethod:"GET"},httpRequestHeader:{headers:{}},httpRequestBody:{body:null}},inputParams:[],outputMapping:[]}):null)},y=R=>{w(R),h.setFieldsValue(R),R.dslType==="API_BRIDGE"?V(R.sourceCode):V(null),f(!0)},M=async()=>{try{const R=await h.validateFields();R.dslType==="API_BRIDGE"&&O!=null&&(R.sourceCode=O),j?(await be.update(j.scriptCode,R),t.message.success("更新成功")):(await be.create(R),t.message.success("创建成功")),f(!1),V(null),k()}catch(R){if(R!=null&&R.errorFields)return;t.message.error("保存失败: "+((R==null?void 0:R.message)||"未知错误"))}},E=async R=>{try{await be.delete(R),t.message.success("删除成功"),k()}catch{t.message.error("删除失败")}},Q=R=>{N(R),v("{}"),x(""),z(!0)},c=async()=>{if(F){G(!0);try{const R=JSON.parse(u),se=await be.run(F.scriptCode,R);x(JSON.stringify(se,null,2))}catch(R){x("Error: "+((R==null?void 0:R.message)||"执行失败"))}finally{G(!1)}}},r=async(R,se)=>{try{await be.publish(R.scriptCode,se||"HTTP"),t.message.success("发布成功"),k()}catch{t.message.error("发布失败")}},L=async R=>{try{await be.unpublish(R.scriptCode),t.message.success("已取消发布"),k()}catch{t.message.error("操作失败")}},$=[{title:"名称",dataIndex:"scriptName",key:"scriptName",width:180,render:(R,se)=>e.jsxs(t.Space,{children:[e.jsx(l.CodeOutlined,{}),e.jsx(gt,{strong:!0,children:R})]})},{title:"编码",dataIndex:"scriptCode",key:"scriptCode",width:150,render:R=>e.jsx(gt,{code:!0,copyable:{text:R},children:R})},{title:"DSL类型",dataIndex:"dslType",key:"dslType",width:120,render:R=>e.jsx(t.Tag,{children:R})},{title:"暴露方式",dataIndex:"exposeAs",key:"exposeAs",width:120,render:R=>e.jsx(t.Tag,{color:ll[R]||"default",children:R})},{title:"状态",dataIndex:"status",key:"status",width:100,render:R=>{const se=qt[R]||qt[0];return e.jsx(t.Tag,{color:se.color,children:se.text})}},{title:"版本",dataIndex:"version",key:"version",width:80},{title:"HTTP路径",dataIndex:"httpPath",key:"httpPath",width:180,render:R=>R?e.jsx(gt,{type:"secondary",copyable:{text:R},children:R}):"-"},{title:"MCP工具名",dataIndex:"mcpToolName",key:"mcpToolName",width:160,render:R=>R?e.jsx(t.Tag,{color:"purple",children:R}):"-"},{title:"操作",key:"action",width:260,fixed:"right",render:(R,se)=>e.jsxs(t.Space,{size:"small",children:[e.jsx(t.Tooltip,{title:"运行测试",children:e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:()=>Q(se),children:"运行"})}),e.jsx(t.Tooltip,{title:"编辑",children:e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.EditOutlined,{}),onClick:()=>y(se)})}),se.exposeAs==="NONE"?e.jsx(t.Tooltip,{title:"发布为HTTP",children:e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.CloudUploadOutlined,{}),onClick:()=>r(se,"HTTP"),children:"发布"})}):e.jsx(t.Tooltip,{title:"取消发布",children:e.jsx(t.Button,{size:"small",type:"link",icon:e.jsx(l.CloudDownloadOutlined,{}),onClick:()=>L(se),children:"取消"})}),e.jsx(t.Popconfirm,{title:"确认删除?",onConfirm:()=>E(se.scriptCode),children:e.jsx(t.Button,{size:"small",type:"link",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{children:[T&&e.jsxs("div",{style:{padding:"8px 16px",marginBottom:16,background:"#fffbe6",border:"1px solid #ffe58f",borderRadius:4},children:[e.jsx(t.Tag,{color:"orange",children:"Mock"})," 后端未连接,当前显示模拟数据"]}),e.jsxs(t.Card,{title:"脚本中心",extra:e.jsxs(t.Space,{children:[e.jsx(t.Button,{icon:e.jsx(l.ImportOutlined,{}),onClick:()=>C(!0),children:"导入 Curl"}),e.jsx(t.Button,{icon:e.jsx(l.CloudServerOutlined,{}),onClick:()=>K(!0),children:"导入 OpenAPI"}),e.jsx(t.Button,{icon:e.jsx(l.PlayCircleOutlined,{}),onClick:k,children:"刷新"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:_,children:"新建脚本"})]}),children:[e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Statistic,{title:"总脚本数",value:o.length})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Statistic,{title:"已发布",value:o.filter(R=>R.exposeAs!=="NONE").length})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Statistic,{title:"HTTP",value:o.filter(R=>R.exposeAs==="HTTP"||R.exposeAs==="BOTH").length})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Statistic,{title:"MCP",value:o.filter(R=>R.exposeAs==="MCP"||R.exposeAs==="BOTH").length})})]}),e.jsx(t.Table,{dataSource:o,columns:$,rowKey:"id",loading:a,pagination:{pageSize:10},scroll:{x:1300},size:"small"})]}),e.jsx(t.Modal,{title:j?"编辑脚本":"新建脚本",open:b,onCancel:()=>f(!1),onOk:M,width:800,okText:"保存",cancelText:"取消",children:e.jsxs(t.Form,{form:h,layout:"vertical",style:{marginTop:16},children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"scriptName",label:"脚本名称",rules:[{required:!0,message:"请输入名称"}],children:e.jsx(t.Input,{placeholder:"e.g. Hello World"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"scriptCode",label:"脚本编码",rules:[{required:!0,message:"请输入编码"}],children:e.jsx(t.Input,{placeholder:"e.g. hello-world",disabled:!!j})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"dslType",label:"DSL类型",children:e.jsx(t.Select,{options:tl,onChange:p})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"exposeAs",label:"暴露方式",children:e.jsx(t.Select,{options:sl})})}),e.jsx(t.Col,{span:8,children:e.jsx(t.Form.Item,{name:"version",label:"版本",children:e.jsx(t.Input,{placeholder:"1.0.0"})})})]}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(t.Input,{placeholder:"脚本描述"})}),A?e.jsx(t.Form.Item,{label:"API Bridge 配置",children:e.jsx(Zt,{value:O,onChange:V})}):e.jsxs(e.Fragment,{children:[e.jsx(t.Form.Item,{name:"inputSchema",label:"输入 Schema (JSON)",children:e.jsx(mt,{rows:3,placeholder:'{"type": "object", "properties": {"name": {"type": "string"}}}'})}),e.jsx(t.Form.Item,{name:"sourceCode",label:"源代码",rules:[{required:!0,message:"请输入源代码"}],children:e.jsx(mt,{rows:12,placeholder:"输入DSL脚本代码...",style:{fontFamily:"monospace",fontSize:13}})})]})]})}),e.jsx(t.Drawer,{title:e.jsxs(t.Space,{children:[e.jsx(l.PlayCircleOutlined,{}),"运行测试: ",F==null?void 0:F.scriptName]}),open:m,onClose:()=>z(!1),width:600,children:F&&e.jsxs("div",{children:[e.jsxs(t.Descriptions,{column:1,size:"small",bordered:!0,style:{marginBottom:16},children:[e.jsx(t.Descriptions.Item,{label:"编码",children:F.scriptCode}),e.jsx(t.Descriptions.Item,{label:"DSL类型",children:F.dslType}),e.jsx(t.Descriptions.Item,{label:"暴露方式",children:F.exposeAs})]}),e.jsx(Xt,{strong:!0,children:"输入参数 (JSON):"}),e.jsx(mt,{rows:5,value:u,onChange:R=>v(R.target.value),style:{fontFamily:"monospace",fontSize:13,marginBottom:12}}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),loading:D,onClick:c,block:!0,children:"执行"}),S&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx(Xt,{strong:!0,children:"执行结果:"}),e.jsx("pre",{style:{background:"#f5f5f5",padding:12,borderRadius:4,maxHeight:400,overflow:"auto",fontSize:13,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:S})]})]})}),e.jsx(Yt,{open:g,onClose:()=>C(!1),onSuccess:k}),e.jsx(Qt,{open:P,onClose:()=>K(!1),onSuccess:k})]})}const $t=[{id:1,skillCode:"code-review",skillName:"代码审查",categoryCode:"backend",version:"1.2.0",author:"zifang",status:"PUBLISHED",description:"自动审查代码质量,检测潜在 Bug 和安全漏洞,支持 Java/Python/Go 等多种语言。",tags:"java,python,code-quality,lint",downloadCount:128,content:`# 代码审查技能
42
+
43
+ 自动分析代码变更并给出审查意见。`,files:[{path:"SKILL.md",content:`# Code Review Skill
44
+
45
+ Automated code review with AI-powered analysis.
46
+
47
+ ## Features
48
+ - Static analysis
49
+ - Security vulnerability detection
50
+ - Style enforcement
51
+ `},{path:"scripts/analyze.py",content:`import ast
52
+
53
+ def analyze_file(filepath):
54
+ with open(filepath) as f:
55
+ tree = ast.parse(f.read())
56
+ results = []
57
+ for node in ast.walk(tree):
58
+ if isinstance(node, ast.FunctionDef):
59
+ results.append({"type": "function", "name": node.name})
60
+ return results
61
+ `},{path:"rules/java-rules.yaml",content:`rules:
62
+ - id: avoid-system-out
63
+ pattern: System.out.println
64
+ severity: WARNING
65
+ - id: catch-exception
66
+ pattern: catch (Exception e)
67
+ severity: ERROR
68
+ `}]},{id:2,skillCode:"data-analyzer",skillName:"数据分析师",categoryCode:"backend",version:"1.0.0",author:"zifang",status:"PUBLISHED",description:"SQL 查询生成与数据分析助手,支持 MySQL/PostgreSQL/ClickHouse。",tags:"sql,data,analysis,dashboard",downloadCount:86,content:`# 数据分析师技能
69
+
70
+ 通过自然语言生成SQL查询。`,files:[{path:"SKILL.md",content:`# Data Analyzer Skill
71
+
72
+ Natural language to SQL query generation.
73
+ ## Supported Databases: MySQL, PostgreSQL, ClickHouse
74
+ `},{path:"queries/templates.sql",content:`-- User retention
75
+ SELECT DATE(created_at) as day, COUNT(DISTINCT user_id) as active_users
76
+ FROM user_events
77
+ WHERE created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY)
78
+ GROUP BY DATE(created_at) ORDER BY day;
79
+ -- Revenue summary
80
+ SELECT product_category, SUM(amount) as total_revenue
81
+ FROM transactions GROUP BY product_category;
82
+ `}]},{id:3,skillCode:"ui-gen",skillName:"UI 生成器",categoryCode:"frontend",version:"2.1.0",author:"zifang",status:"PUBLISHED",description:"从设计稿或描述生成 React 组件代码,支持 Ant Design 组件库。",tags:"react,antd,ui,component",downloadCount:215,content:`# UI 生成器技能
83
+
84
+ 从文字描述生成UI代码。`,files:[{path:"SKILL.md",content:`# UI Generator Skill
85
+
86
+ Generate React components from natural language.
87
+ ## Tech Stack: React 18, Ant Design 5, TypeScript
88
+ `},{path:"templates/component.ejs",content:`import React from "react";
89
+ import { Card, Button, Space } from "antd";
90
+
91
+ interface <%= compName %>Props { title?: string; onAction?: () => void }
92
+
93
+ const <%= compName %>: React.FC<<%= compName %>Props> = ({ title, onAction }) => (
94
+ <Card title={title}><Space><Button onClick={onAction}>Action</Button></Space></Card>
95
+ );
96
+ export default <%= compName %>;
97
+ `},{path:"styles/default.css",content:`.ui-gen-container { padding: 24px; background: #fff; border-radius: 8px; }
98
+ .ui-gen-header { display: flex; align-items: center; margin-bottom: 16px; }
99
+ `}]},{id:4,skillCode:"doc-writer",skillName:"文档编写",categoryCode:"doc",version:"1.0.0",author:"zifang",status:"PUBLISHED",description:"自动生成项目文档、API 文档、README。支持 Javadoc/Swagger/Markdown 格式。",tags:"documentation,api,markdown,javadoc",downloadCount:67,content:`# 文档编写技能
100
+
101
+ 自动生成各类文档。`,files:[{path:"SKILL.md",content:`# Doc Writer Skill
102
+
103
+ Automated documentation generation.
104
+ ## Formats: Markdown, Javadoc, OpenAPI/Swagger
105
+ `},{path:"templates/api-doc.md",content:`# {{apiName}}
106
+
107
+ {{description}}
108
+
109
+ {{#each endpoints}}
110
+ ### {{method}} {{path}}
111
+ **Parameters:**
112
+ | Name | Type | Required | Description |
113
+ |------|------|----------|-------------|
114
+ {{/each}}
115
+ `}]},{id:5,skillCode:"ci-helper",skillName:"CI/CD 助手",categoryCode:"devops",version:"2.0.0",author:"zifang",status:"PUBLISHED",description:"Pipeline 配置生成、Dockerfile 优化、K8s 部署清单自动生成。",tags:"ci/cd,docker,kubernetes,devops",downloadCount:94,content:`# CI/CD 助手技能
116
+
117
+ 自动化运维配置生成。`,files:[{path:"SKILL.md",content:`# CI/CD Helper Skill
118
+
119
+ Automated CI/CD configuration generation.
120
+ ## Platforms: GitHub Actions, GitLab CI, Jenkins
121
+ `},{path:"pipelines/build.yaml",content:`name: build-and-test
122
+ on: [push, pull_request]
123
+ jobs:
124
+ build:
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+ - name: Setup JDK 17
129
+ uses: actions/setup-java@v3
130
+ with:
131
+ java-version: "17"
132
+ distribution: "temurin"
133
+ - run: mvn clean verify
134
+ `},{path:"docker/Dockerfile",content:`FROM eclipse-temurin:17-jre-alpine
135
+ WORKDIR /app
136
+ COPY target/*.jar app.jar
137
+ EXPOSE 8080
138
+ ENTRYPOINT ["java", "-jar", "app.jar"]
139
+ `}]},{id:6,skillCode:"test-gen",skillName:"测试生成器",categoryCode:"testing",version:"1.3.0",author:"zifang",status:"PUBLISHED",description:"基于代码自动生成单元测试和集成测试用例,支持 JUnit/TestNG/Pytest。",tags:"testing,junit,pytest,tdd",downloadCount:156,content:`# 测试生成器技能
140
+
141
+ 自动生成测试代码。`,files:[{path:"SKILL.md",content:`# Test Generator Skill
142
+
143
+ Automated test generation.
144
+ ## Frameworks: JUnit 5, TestNG, Pytest
145
+ `},{path:"configs/junit-config.yaml",content:`generator:
146
+ framework: junit5
147
+ mockLibrary: mockito
148
+ coverage: 0.8
149
+ rules:
150
+ - skipGettersSetters: true
151
+ - generateEdgeCases: true
152
+ - maxAssertionsPerTest: 5
153
+ `}]},{id:7,skillCode:"agent-flow",skillName:"Agent 工作流",categoryCode:"ai-agent",version:"1.1.0",author:"zifang",status:"PUBLISHED",description:"多步骤 Agent 工作流编排引擎,支持条件判断、循环、并行执行。",tags:"agent,workflow,automation,llm",downloadCount:201,content:`# Agent 工作流技能
154
+
155
+ 编排多步骤 Agent 工作流。`,files:[{path:"SKILL.md",content:`# Agent Flow Skill
156
+
157
+ Multi-step agent workflow orchestration.
158
+ ## Features: Conditional branching, Loops, Parallel execution, Retry
159
+ `},{path:"workflows/order-flow.yaml",content:`workflow:
160
+ id: order-processing
161
+ steps:
162
+ - id: validate-order
163
+ type: function
164
+ handler: validateOrder
165
+ - id: check-inventory
166
+ type: function
167
+ handler: checkInventory
168
+ retry: 3
169
+ - id: process-payment
170
+ type: function
171
+ handler: processPayment
172
+ - id: send-notification
173
+ type: function
174
+ parallel: true
175
+ `},{path:"nodes/check-condition.js",content:`module.exports = async (context, params) => {
176
+ const { field, operator, value } = params;
177
+ const actual = context.get(field);
178
+ const ops = { eq: (a, b) => a === b, gt: (a, b) => a > b, lt: (a, b) => a < b, in: (a, b) => b.includes(a) };
179
+ if (!ops[operator]) throw new Error("Unknown operator: " + operator);
180
+ return ops[operator](actual, value);
181
+ };
182
+ `}]},{id:8,skillCode:"api-mocker",skillName:"API Mock",categoryCode:"frontend",version:"1.0.0",author:"zifang",status:"DRAFT",description:"快速生成 API Mock 服务,基于 OpenAPI 规范自动生成模拟数据。",tags:"api,mock,prototype",downloadCount:45,content:`# API Mock 技能
183
+
184
+ 快速生成API Mock。`,files:[{path:"SKILL.md",content:`# API Mock Skill
185
+
186
+ Rapid API mock server from OpenAPI specs.
187
+ ## Features: OpenAPI 3.0, Realistic data, Custom delay
188
+ `},{path:"configs/openapi-spec.yaml",content:`openapi: "3.0.0"
189
+ info:
190
+ title: Sample API
191
+ version: "1.0.0"
192
+ paths:
193
+ /users:
194
+ get:
195
+ summary: List users
196
+ responses:
197
+ "200":
198
+ description: User list
199
+ content:
200
+ application/json:
201
+ schema:
202
+ type: array
203
+ items:
204
+ $ref: "#/components/schemas/User"
205
+ components:
206
+ schemas:
207
+ User:
208
+ type: object
209
+ properties:
210
+ id: { type: integer }
211
+ name: { type: string }
212
+ email: { type: string }
213
+ `}]}],ft=[{categoryCode:"backend",categoryName:"后端开发",parentCode:"",skillCount:2},{categoryCode:"frontend",categoryName:"前端开发",parentCode:"",skillCount:2},{categoryCode:"devops",categoryName:"DevOps",parentCode:"",skillCount:1},{categoryCode:"testing",categoryName:"测试",parentCode:"",skillCount:1},{categoryCode:"ai-agent",categoryName:"AI Agent",parentCode:"",skillCount:1},{categoryCode:"doc",categoryName:"文档",parentCode:"",skillCount:1}],es={total:8,published:7},{TextArea:nl}=t.Input,{Title:Ml,Paragraph:rl,Text:al}=t.Typography,ts={backend:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",frontend:"linear-gradient(135deg, #f093fb 0%, #f5576c 100%)",devops:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",testing:"linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)","ai-agent":"linear-gradient(135deg, #fa709a 0%, #fee140 100%)",doc:"linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)",default:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)"},Le=o=>ts[o]||ts.default,ss={PUBLISHED:"已发布",DRAFT:"草稿",ARCHIVED:"已归档"},Ye=["blue","green","cyan","purple","orange","red"],cl=o=>{const i={};o.forEach(n=>{i[n.categoryCode]={key:n.categoryCode,title:n.categoryName,categoryCode:n.categoryCode,categoryName:n.categoryName,parentCode:n.parentCode||"",skillCount:n.skillCount||0,data:n,children:[]}});const a=[];return o.forEach(n=>{const T=i[n.categoryCode];n.parentCode&&i[n.parentCode]?i[n.parentCode].children.push(T):n.parentCode||a.push(T)}),a},ls=o=>{const i=[],a=(n,T)=>{n.forEach(d=>{var f;const b=d.categoryCode||d.key;i.push({categoryCode:b,categoryName:d.categoryName||d.title,parentCode:T||d.parentCode||"",skillCount:d.skillCount||0}),(f=d.children)!=null&&f.length&&a(d.children,b)})};return o!=null&&o.length&&a(o,""),i};function dl(o){const i={key:"__root__",children:[]},a={"":i};return o.forEach(n=>{const T=n.path.split("/");T.pop();let d="";T.forEach((b,f)=>{const j=T.slice(0,f+1).join("/");a[j]||(a[j]={key:j,title:b,isLeaf:!1,children:[]}),a[d].children.some(w=>w.key===j)||a[d].children.push(a[j]),d=j})}),o.forEach(n=>{const T=n.path.includes("/")?n.path.split("/").slice(0,-1).join("/"):"",d=n.path.includes("/")?n.path.split("/").pop():n.path;a[T].children.push({key:n.path,title:d,isLeaf:!0,file:n})}),i.children}function pl(){const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(0),[b,f]=s.useState(1),j=s.useRef(12),[w,h]=s.useState(""),[m,z]=s.useState(void 0),[F,N]=s.useState("download_count"),[u,v]=s.useState([]),[S,x]=s.useState([]),[D,G]=s.useState(!1),[g,C]=s.useState(null),[P,K]=s.useState(""),[O,V]=s.useState([]),[U,A]=s.useState(!1),[k,_]=s.useState("overview"),[p,y]=s.useState(null),[M,E]=s.useState([]),[Q,c]=s.useState(!1),[r]=t.Form.useForm(),[L,$]=s.useState(!1),[R,se]=s.useState(!1),[je,le]=s.useState({total:0,published:0}),[fe,W]=s.useState(!1),[ee,ce]=s.useState(null),[H,X]=s.useState(null),[ie,he]=s.useState(!1),[ne]=t.Form.useForm(),[ye,_e]=s.useState(220),Tl=s.useRef(null),Ze=s.useRef(!1),as=s.useRef(0),cs=s.useRef(0),Ot=async()=>{try{const I=await ge.stats();I&&(I.total!==void 0||I.published!==void 0)?le(I):I!=null&&I.data?le(I.data):le(es)}catch{le(es)}},Ue=s.useCallback(async(I=1)=>{var J;n(!0);try{const Y={current:I,size:j.current,sortBy:F};w&&(Y.keyword=w),m&&(Y.categoryCode=m),(w||m)&&(Y.status="PUBLISHED");const q=await ge.page(Y);if(q&&q.records)i(q.records),d(Number(q.total)||q.records.length);else if(Array.isArray(q))i(q),d(q.length);else if((J=q==null?void 0:q.data)!=null&&J.records)i(q.data.records),d(Number(q.data.total)||q.data.records.length);else{const oe=$t.filter(pe=>!(w&&!pe.skillName.includes(w)&&!pe.description.includes(w)||m&&pe.categoryCode!==m));i(oe),d(oe.length)}}catch(Y){console.error("loadSkills error:",Y);const q=$t.filter(oe=>!(w&&!oe.skillName.includes(w)&&!oe.description.includes(w)||m&&oe.categoryCode!==m));i(q),d(q.length)}finally{n(!1)}},[w,m,F]),Xe=async()=>{var I,J;try{const Y=await ge.categoryTree(),q=oe=>(oe||[]).map(pe=>({categoryCode:pe.catCode||pe.categoryCode,categoryName:pe.catName||pe.categoryName,parentCode:pe.parentCode||"",skillCount:pe.skillCount||0,children:pe.children?q(pe.children):void 0}));if(Array.isArray(Y)&&Y.length>0){const oe=q(Y);(I=oe[0])!=null&&I.children?v(ls(oe)):v(oe)}else if(Y!=null&&Y.data&&Y.data.length>0){const oe=q(Y.data);(J=oe[0])!=null&&J.children?v(ls(oe)):v(oe)}else v(ft)}catch{const q=localStorage.getItem("z_skill_categories");if(q)try{v(JSON.parse(q))}catch{v(ft)}else v(ft)}};s.useEffect(()=>{Ot(),Xe()},[]),s.useEffect(()=>{Ue(b)},[Ue,b]);const wl=()=>{f(1),Ue(1)},kl=I=>{z(J=>J===I?void 0:I),f(1)},Il=I=>{N(I),f(1)},Ol=async I=>{var J,Y,q;C(I),G(!0),K(I.content||""),V([]),y(null),E([]),_("overview"),A(!0);try{const[oe,pe]=await Promise.allSettled([ge.getBySkillCode(I.skillCode),ge.versions(I.skillCode)]);if(oe.status==="fulfilled"&&oe.value){const Ce=((J=oe.value)==null?void 0:J.data)||oe.value;if(Ce&&typeof Ce=="object"){const Dl={...I,...Ce};C(Dl),K(Ce.content||Ce.readme||I.content||""),(Y=Ce.files)!=null&&Y.length&&y(Ce.files[0])}}if(pe.status==="fulfilled"&&pe.value){const Ce=((q=pe.value)==null?void 0:q.data)||pe.value;Array.isArray(Ce)&&V(Ce)}}catch(oe){console.warn("openDetail error:",oe)}finally{A(!1)}},ds=async I=>{try{await navigator.clipboard.writeText(I),t.message.success("已复制到剪贴板")}catch{t.message.error("复制失败")}},ps=I=>{if(I)if(I.packageType==="ZIP"&&(I.packagePath||I.version)){const J=ge.downloadPackage(I.skillCode,I.version);window.open(J,"_blank")}else I.content&&ds(I.content)},us=async I=>{try{const J=await ge.install({skillCode:I});J!=null?(t.message.success("安装成功"),Ot()):t.message.error("安装失败")}catch{t.message.error("安装异常")}},Al=async I=>{if(!g)return!1;if(!I.name.toLowerCase().endsWith(".zip"))return t.message.error("仅支持 .zip 格式"),t.Upload.LIST_IGNORE;se(!0);try{await ge.uploadPackage(g.skillCode,g.version||"1.0.0",I),t.message.success("上传成功"),C(J=>J&&{...J,packageType:"ZIP"});try{const J=await ge.getBySkillCode(g.skillCode),Y=J&&typeof J=="object"&&"data"in J?J.data:J;Y&&C(q=>q&&{...q,...Y})}catch{}Ue(b)}catch(J){console.error("uploadPackage error:",J),t.message.error("上传失败:"+((J==null?void 0:J.message)||"未知错误"))}finally{se(!1)}return!1},Pl=async()=>{try{const I=await r.validateFields();$(!0);const J=await ge.create({...I,status:"PUBLISHED"});J!=null?(t.message.success("发布成功"),c(!1),r.resetFields(),Ue(1),Ot()):t.message.error("发布失败")}catch(I){if(I!=null&&I.errorFields)return;t.message.error("发布异常")}finally{$(!1)}},xs=I=>{ce(null),X(I),ne.resetFields(),I&&ne.setFieldsValue({parentCode:I.categoryCode}),W(!0)},El=I=>{ce(I),X(null),ne.setFieldsValue({categoryCode:I.categoryCode,categoryName:I.categoryName,parentCode:I.parentCode||""}),W(!0)},zl=async()=>{try{const I=await ne.validateFields();he(!0),ee?(await ge.createCategory({catCode:I.categoryCode,catName:I.categoryName,parentCode:I.parentCode||""}),t.message.success("更新成功")):(await ge.createCategory({catCode:I.categoryCode,catName:I.categoryName,parentCode:I.parentCode||""}),t.message.success("创建成功")),W(!1),Xe()}catch(I){if(I!=null&&I.errorFields)return;const J=ne.getFieldsValue();let Y=[...u];if(ee){const q=Y.findIndex(oe=>oe.categoryCode===ee.categoryCode);q>=0&&(Y[q]={...Y[q],...J})}else Y.push({categoryCode:J.categoryCode,categoryName:J.categoryName,parentCode:J.parentCode||"",skillCount:0});v(Y),localStorage.setItem("z_skill_categories",JSON.stringify(Y)),W(!1),t.message.success(ee?"更新成功":"创建成功")}finally{he(!1)}},Rl=async I=>{try{const J=u.find(q=>q.categoryCode===I),Y=J==null?void 0:J.id;if(Y)await ge.deleteCategory(Y);else throw new Error("no api id");t.message.success("删除成功"),Xe()}catch{const Y=u.filter(q=>q.categoryCode!==I);v(Y),localStorage.setItem("z_skill_categories",JSON.stringify(Y)),t.message.success("删除成功")}},Bl=I=>{const J=u.find(Y=>Y.categoryCode===I.categoryCode);return J?e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:"pointer"},onClick:()=>kl(I.categoryCode),children:[m===I.categoryCode?e.jsx(l.FolderOpenOutlined,{style:{fontSize:13,color:"#667eea"}}):e.jsx(l.FolderOutlined,{style:{fontSize:13,color:"#8c8c8c"}}),e.jsx("span",{style:{flex:1,fontSize:13,color:m===I.categoryCode?"#667eea":void 0,fontWeight:m===I.categoryCode?600:400},children:J.categoryName}),e.jsx(t.Tag,{style:{fontSize:10,padding:"0 4px",lineHeight:"16px",marginRight:0},children:J.skillCount||0}),e.jsx(t.Dropdown,{trigger:["click"],menu:{items:[{key:"add",icon:e.jsx(l.PlusOutlined,{}),label:"新增子分类"},{key:"edit",icon:e.jsx(l.EditOutlined,{}),label:"编辑分类"},{type:"divider"},{key:"delete",icon:e.jsx(l.DeleteOutlined,{}),label:"删除分类",danger:!0}],onClick:({key:Y,domEvent:q})=>{q.stopPropagation(),Y==="add"?xs(J):Y==="edit"?El(J):Y==="delete"&&t.Modal.confirm({title:`删除分类"${J.categoryName}"?`,content:"子分类也会被删除",okText:"确认删除",okType:"danger",cancelText:"取消",onOk:()=>Rl(I.categoryCode)})}},children:e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(l.MoreOutlined,{style:{fontSize:13}}),onClick:Y=>Y.stopPropagation()})})]}):e.jsx("span",{children:I.title})},Fl=[{value:"download_count",label:"最热门"},{value:"gmt_create",label:"最新发布"},{value:"skill_name",label:"名称排序"}],Nl=s.useCallback(I=>{I.preventDefault(),Ze.current=!0,as.current=I.clientX,cs.current=ye,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[ye]);return s.useEffect(()=>{const I=Y=>{if(!Ze.current)return;const q=Math.max(180,Math.min(cs.current+Y.clientX-as.current,340));_e(q)},J=()=>{Ze.current&&(Ze.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",I),window.addEventListener("mouseup",J),()=>{window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",J)}},[]),e.jsxs("div",{style:{display:"flex",gap:16,minHeight:600},children:[e.jsx("div",{ref:Tl,style:{width:ye,flexShrink:0},children:e.jsx(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.AppstoreOutlined,{style:{color:"#667eea",marginRight:6}}),"分类"]}),extra:e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),onClick:Xe}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.PlusOutlined,{}),onClick:()=>xs(null)})]}),styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"10px 14px"},body:{padding:"6px 8px"}},children:e.jsx(t.Tree,{showIcon:!1,treeData:cl(u),defaultExpandAll:!0,showLine:!0,titleRender:Bl,selectedKeys:m?[m]:[],onSelect:()=>{},style:{fontSize:13}})})}),e.jsx("div",{onMouseDown:Nl,style:{width:6,cursor:"col-resize",flexShrink:0,background:"#f0f0f0",borderRadius:3,alignSelf:"stretch"}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",flexWrap:"wrap",background:"#fff",padding:"14px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[e.jsx(t.Input,{prefix:e.jsx(l.SearchOutlined,{style:{color:"#bfbfbf"}}),placeholder:"搜索技能名称、描述、标签...",value:w,onChange:I=>h(I.target.value),onPressEnter:wl,allowClear:!0,style:{width:260,borderRadius:8}}),e.jsx(t.Select,{value:F,onChange:Il,options:Fl,style:{width:130,borderRadius:8}}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{display:"flex",gap:20,alignItems:"center"},children:[e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#667eea",lineHeight:1.2},children:je.total||0}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:"全部技能"})]}),e.jsx("div",{style:{width:1,height:32,background:"#f0f0f0"}}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#52c41a",lineHeight:1.2},children:je.published||0}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:"已发布"})]})]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.CloudUploadOutlined,{}),onClick:()=>c(!0),style:{borderRadius:8,height:36,paddingInline:18,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",fontWeight:600,boxShadow:"0 4px 12px rgba(102,126,234,0.3)"},children:"发布技能"})]}),a?e.jsx("div",{style:{textAlign:"center",padding:60},children:e.jsx(t.Spin,{size:"large"})}):o.length===0?e.jsx(t.Empty,{description:"暂无技能",style:{padding:60}}):e.jsx(t.Row,{gutter:[16,16],children:o.map(I=>{const J=(I.tags||"").split(",").filter(Boolean);return e.jsx(t.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(t.Card,{hoverable:!0,size:"small",onClick:()=>Ol(I),style:{borderRadius:12,border:"none",boxShadow:"0 2px 12px rgba(0,0,0,0.07)",overflow:"hidden",cursor:"pointer"},styles:{body:{padding:0}},onMouseEnter:Y=>{Y.currentTarget.style.boxShadow="0 8px 24px rgba(102,126,234,0.18)",Y.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:Y=>{Y.currentTarget.style.boxShadow="0 2px 12px rgba(0,0,0,0.07)",Y.currentTarget.style.transform="translateY(0)"},children:[e.jsx("div",{style:{background:Le(I.categoryCode),padding:"14px 16px",borderRadius:"12px 12px 0 0"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(8px)"},children:e.jsx(l.CodeOutlined,{style:{fontSize:20,color:"#fff"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#fff",lineHeight:1.3},children:I.skillName}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.8)",marginTop:2},children:["v",I.version," · ",I.author]})]}),I.status!=="PUBLISHED"&&e.jsx(t.Tag,{style:{background:"rgba(255,255,255,0.25)",color:"#fff",border:"none",borderRadius:10,fontSize:11},children:ss[I.status]})]})}),e.jsxs("div",{style:{padding:"12px 14px 14px"},children:[e.jsx(rl,{ellipsis:{rows:2},style:{fontSize:12,color:"#666",marginBottom:10,minHeight:36},children:I.description||"暂无描述"}),e.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap",marginBottom:10},children:[J.slice(0,3).map((Y,q)=>e.jsx(t.Tag,{color:Ye[q%Ye.length],style:{fontSize:11,borderRadius:4,marginBottom:2},children:Y},Y)),J.length>3&&e.jsxs(t.Tag,{style:{fontSize:11},children:["+",J.length-3]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:10,borderTop:"1px solid #f5f5f5"},children:[e.jsx(t.Tooltip,{title:"安装次数",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[e.jsx(l.FireOutlined,{style:{color:"#ff4d4f",fontSize:12}}),e.jsx(al,{type:"secondary",style:{fontSize:12},children:I.downloadCount||0})]})}),e.jsx(t.Button,{type:"primary",size:"small",icon:e.jsx(l.DownloadOutlined,{}),onClick:Y=>{Y.stopPropagation(),us(I.skillCode)},style:{borderRadius:6,background:Le(I.categoryCode),border:"none",fontWeight:500},children:"安装"})]})]})]})},I.id)})}),T>j.current&&e.jsx("div",{style:{textAlign:"right",padding:"8px 0"},children:e.jsx(t.Pagination,{current:b,pageSize:j.current,total:T,onChange:I=>{f(I),window.scrollTo({top:0,behavior:"smooth"})},showSizeChanger:!1})})]}),e.jsx(t.Drawer,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:8,background:Le(g==null?void 0:g.categoryCode),display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.CodeOutlined,{style:{fontSize:18,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:15,fontWeight:600},children:g==null?void 0:g.skillName}),e.jsxs("div",{style:{fontSize:11,color:"#999",fontWeight:400},children:["v",g==null?void 0:g.version," · ",g==null?void 0:g.author," · ",ss[g==null?void 0:g.status]||(g==null?void 0:g.status)]})]})]}),open:D,onClose:()=>G(!1),width:"75%",styles:{header:{padding:"14px 24px",borderBottom:"1px solid #f0f0f0"},body:{padding:0}},children:g&&e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid #f0f0f0",display:"flex",alignItems:"center",gap:16,flexWrap:"wrap",background:"#fafafa"},children:[g.packageType==="ZIP"&&g.packagePath?e.jsx(t.Button,{type:"primary",size:"large",icon:e.jsx(l.DownloadOutlined,{}),onClick:()=>ps(g),style:{borderRadius:8,background:Le(g.categoryCode),border:"none",fontWeight:600,height:40,paddingInline:24},children:"下载技能包 (ZIP)"}):g.content?e.jsx(t.Button,{type:"primary",size:"large",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>ds(g.content),style:{borderRadius:8,background:Le(g.categoryCode),border:"none",fontWeight:600,height:40,paddingInline:24},children:"复制技能内容"}):e.jsx(t.Button,{size:"large",disabled:!0,icon:e.jsx(l.DownloadOutlined,{}),style:{height:40},children:"暂无下载包"}),e.jsx(t.Button,{icon:e.jsx(l.DownloadOutlined,{}),onClick:()=>us(g.skillCode),style:{borderRadius:8,height:40},children:"安装此技能"}),e.jsxs("div",{style:{flex:1,display:"flex",gap:8,flexWrap:"wrap",justifyContent:"flex-end"},children:[e.jsxs(t.Tag,{icon:e.jsx(l.CheckCircleOutlined,{}),color:"blue",children:["v",g.version]}),e.jsxs(t.Tag,{icon:e.jsx(l.FireOutlined,{}),color:"red",children:[g.downloadCount||0," 次安装"]}),e.jsx(t.Tag,{icon:e.jsx(l.StarOutlined,{}),color:"orange",children:g.author}),g.gmtModified&&e.jsx(t.Tag,{icon:e.jsx(l.ClockCircleOutlined,{}),color:"default",children:new Date(g.gmtModified).toLocaleDateString()})]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(t.Tabs,{activeKey:k,onChange:_,style:{height:"100%"},tabBarStyle:{padding:"0 24px",marginBottom:0},items:[{key:"overview",label:e.jsxs("span",{children:[e.jsx(l.InfoCircleOutlined,{})," 概述"]}),children:e.jsx("div",{style:{padding:"20px 24px"},children:U?e.jsx("div",{style:{textAlign:"center",padding:40},children:e.jsx(t.Spin,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#333",marginBottom:8},children:"简介"}),e.jsx("div",{style:{fontSize:14,color:"#555",lineHeight:1.8},children:g.description||"暂无描述"})]}),g.tags&&e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#333",marginBottom:8},children:"标签"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:(g.tags||"").split(",").filter(Boolean).map((I,J)=>e.jsx(t.Tag,{color:Ye[J%Ye.length],style:{fontSize:12,borderRadius:4,padding:"2px 8px"},children:I},I))})]}),P&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#333",marginBottom:8},children:"技能说明"}),e.jsx("div",{style:{background:"#fafafa",border:"1px solid #f0f0f0",padding:16,borderRadius:8,lineHeight:1.8,fontSize:14,color:"#333"},children:e.jsx(At,{components:{code:({node:I,inline:J,className:Y,children:q,...oe})=>J?e.jsx("code",{style:{background:"#f0f0f0",padding:"2px 6px",borderRadius:4,fontSize:13},...oe,children:q}):e.jsx("pre",{style:{background:"#1e1e1e",color:"#d4d4d4",padding:14,borderRadius:8,overflow:"auto",fontSize:13},children:e.jsx("code",{...oe,children:q})}),h1:({children:I})=>e.jsx("h1",{style:{fontSize:20,fontWeight:700,borderBottom:"1px solid #eee",paddingBottom:8,marginBottom:12},children:I}),h2:({children:I})=>e.jsx("h2",{style:{fontSize:17,fontWeight:600,marginTop:20,marginBottom:8},children:I}),h3:({children:I})=>e.jsx("h3",{style:{fontSize:15,fontWeight:600,marginTop:16,marginBottom:6},children:I}),ul:({children:I})=>e.jsx("ul",{style:{paddingLeft:20,marginBottom:12},children:I}),li:({children:I})=>e.jsx("li",{style:{marginBottom:4},children:I}),p:({children:I})=>e.jsx("p",{style:{marginBottom:10},children:I})},children:P})})]})]})})},{key:"files",label:e.jsxs("span",{children:[e.jsx(l.FileTextOutlined,{})," 文件"]}),children:e.jsxs("div",{style:{padding:"20px 24px"},children:[g.files&&g.files.length>0?e.jsxs("div",{style:{display:"flex",gap:16,height:400},children:[e.jsx("div",{style:{width:220,flexShrink:0,border:"1px solid #f0f0f0",borderRadius:8,overflow:"auto",padding:"4px 0"},children:e.jsx(t.Tree,{treeData:dl(g.files),defaultExpandAll:!0,showIcon:!0,selectedKeys:p?[p.path]:[],onSelect:(I,J)=>{J.node.isLeaf&&J.node.file&&y(J.node.file)},titleRender:I=>e.jsx("span",{style:{fontSize:13},children:I.title}),icon:I=>I.isLeaf?e.jsx(l.FileTextOutlined,{style:{fontSize:13,color:"#8c8c8c"}}):e.jsx(l.FolderOutlined,{style:{fontSize:13,color:"#faad14"}})})}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:p?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:6},children:p.path}),e.jsx("pre",{style:{flex:1,background:"#1e1e1e",color:"#d4d4d4",padding:14,borderRadius:8,fontSize:12,lineHeight:1.6,overflow:"auto",whiteSpace:"pre-wrap",fontFamily:'"SF Mono","Fira Code","Consolas",monospace',margin:0},children:p.content||"(empty)"})]}):e.jsx("div",{style:{color:"#999",textAlign:"center",paddingTop:80},children:"选择一个文件查看内容"})})]}):g.packageType==="ZIP"&&g.packagePath?e.jsxs("div",{style:{background:"#f6ffed",border:"1px solid #b7eb8f",borderRadius:8,padding:20,textAlign:"center"},children:[e.jsx(l.FileZipOutlined,{style:{fontSize:36,color:"#52c41a",marginBottom:12}}),e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#389e0d",marginBottom:8},children:"ZIP 包已上传"}),e.jsx("div",{style:{fontSize:12,color:"#999",wordBreak:"break-all"},children:g.packagePath}),e.jsx(t.Button,{type:"link",icon:e.jsx(l.DownloadOutlined,{}),onClick:()=>ps(g),style:{marginTop:12},children:"下载并解压查看文件"})]}):e.jsxs("div",{style:{textAlign:"center",padding:40,color:"#999"},children:[e.jsx(l.FileTextOutlined,{style:{fontSize:36,color:"#d9d9d9",marginBottom:12}}),e.jsx("div",{children:"暂无文件,上传 ZIP 包后可查看文件目录"})]}),e.jsxs("div",{style:{marginTop:20,borderTop:"1px solid #f0f0f0",paddingTop:16},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#333",marginBottom:8},children:"上传技能包"}),e.jsx(t.Upload,{accept:".zip",showUploadList:!1,beforeUpload:Al,disabled:R,children:e.jsxs("div",{style:{border:"2px dashed #d9d9d9",borderRadius:8,padding:16,textAlign:"center",cursor:R?"not-allowed":"pointer",opacity:R?.6:1},children:[R?e.jsx(t.Spin,{size:"small"}):e.jsx(l.CloudUploadOutlined,{style:{fontSize:20,color:"#bfbfbf"}}),e.jsx("div",{style:{fontSize:12,color:"#999",marginTop:6},children:R?"上传中...":g.packageType==="ZIP"?"重新上传 ZIP":"上传 ZIP 包"})]})})]})]})},{key:"versions",label:e.jsxs("span",{children:[e.jsx(l.HistoryOutlined,{})," 版本历史 ",O.length>0&&`(${O.length})`]}),children:e.jsx("div",{style:{padding:"20px 24px"},children:O.length>0?e.jsx(t.Timeline,{items:O.map((I,J)=>({color:J===0?"green":"gray",children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(t.Tag,{color:J===0?"green":"default",style:{fontWeight:600},children:I.version||I.versionNumber||`v${J+1}`}),J===0&&e.jsx(t.Tag,{color:"blue",children:"当前版本"})]}),I.changeLog&&e.jsx("div",{style:{fontSize:13,color:"#666",marginTop:4},children:I.changeLog}),e.jsx("div",{style:{fontSize:11,color:"#bbb",marginTop:2},children:I.gmtCreate?new Date(I.gmtCreate).toLocaleString():""})]})}))}):e.jsxs("div",{style:{textAlign:"center",padding:40,color:"#999"},children:[e.jsx(l.HistoryOutlined,{style:{fontSize:36,color:"#d9d9d9",marginBottom:12}}),e.jsx("div",{children:"暂无版本记录"}),e.jsxs("div",{style:{fontSize:12,color:"#bbb",marginTop:4},children:["当前版本: v",g.version]})]})})}]})})]})}),e.jsx(t.Modal,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.CloudUploadOutlined,{style:{fontSize:16,color:"#fff"}})}),e.jsx("span",{style:{fontSize:16},children:"发布新技能"})]}),open:Q,onCancel:()=>{c(!1),r.resetFields()},onOk:Pl,confirmLoading:L,okText:"确认发布",cancelText:"取消",width:580,style:{top:80},children:e.jsxs(t.Form,{form:r,layout:"vertical",style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(t.Form.Item,{name:"skillCode",label:"技能编码",rules:[{required:!0,message:"请输入技能编码"}],style:{flex:1},children:e.jsx(t.Input,{placeholder:"如 java-entity-gen",style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"skillName",label:"技能名称",rules:[{required:!0,message:"请输入技能名称"}],style:{flex:1},children:e.jsx(t.Input,{placeholder:"如 Java Entity 生成器",style:{borderRadius:8}})})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(t.Form.Item,{name:"categoryCode",label:"分类",style:{flex:1},children:e.jsx(t.Input,{placeholder:"如 backend",style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"version",label:"版本号",initialValue:"1.0.0",rules:[{required:!0}],style:{flex:1},children:e.jsx(t.Input,{placeholder:"1.0.0",style:{borderRadius:8}})})]}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(nl,{rows:3,placeholder:"简要描述技能功能...",style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"tags",label:"标签",children:e.jsx(t.Input,{placeholder:"用逗号分隔,如 java,entity,generator",style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"author",label:"作者",children:e.jsx(t.Input,{placeholder:"技能作者",style:{borderRadius:8}})})]})}),e.jsx(t.Modal,{title:ee?"编辑分类":H?`新建子分类 - ${H.categoryName}`:"新建分类",open:fe,onCancel:()=>W(!1),onOk:()=>ne.submit(),confirmLoading:ie,destroyOnClose:!0,okText:"确认",cancelText:"取消",children:e.jsxs(t.Form,{form:ne,layout:"vertical",onFinish:zl,style:{marginTop:8},children:[e.jsx(t.Form.Item,{name:"categoryCode",label:"分类编码",rules:[{required:!0,message:"请输入分类编码"}],children:e.jsx(t.Input,{placeholder:"如 backend",disabled:!!ee,style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"categoryName",label:"分类名称",rules:[{required:!0,message:"请输入分类名称"}],children:e.jsx(t.Input,{placeholder:"如 后端开发",style:{borderRadius:8}})}),e.jsx(t.Form.Item,{name:"parentCode",label:"父分类",children:e.jsx(t.Select,{allowClear:!0,placeholder:"留空为顶级分类",popupMatchSelectWidth:!1,children:u.filter(I=>ee?I.categoryCode!==ee.categoryCode:!0).map(I=>e.jsx(t.Select.Option,{value:I.categoryCode,children:I.categoryName},I.categoryCode))})})]})})]})}const{TextArea:os}=t.Input,{Option:ke}=t.Select,{TabPane:is}=t.Tabs,ul=()=>{const[o,i]=s.useState("list");return e.jsx(t.Card,{style:{minHeight:"calc(100vh - 140px)"},children:e.jsxs(t.Tabs,{activeKey:o,onChange:i,children:[e.jsx(is,{tab:e.jsxs("span",{children:[e.jsx(l.ShopOutlined,{})," 产品管理"]}),children:e.jsx(xl,{})},"list"),e.jsx(is,{tab:e.jsxs("span",{children:[e.jsx(l.FileTextOutlined,{})," 产品配置"]}),children:e.jsx(hl,{})},"config")]})})},xl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(""),[b,f]=s.useState(""),[j,w]=s.useState(1),[h]=s.useState(12),[m,z]=s.useState(0),[F,N]=s.useState(!1),[u]=t.Form.useForm(),[v,S]=s.useState(null),[x,D]=s.useState(!1),[G,g]=s.useState(!1),[C,P]=s.useState(null);s.useEffect(()=>{K()},[j,T,b]);const K=async()=>{n(!0);try{const E=await Se.page({productName:T,status:b,id:j});E.data&&(i(E.data.records||[]),z(E.data.total||0))}catch(E){t.message.error("加载失败: "+(E.message||""))}n(!1)},O=()=>{S(null),u.resetFields(),u.setFieldsValue({status:"DRAFT"}),N(!0)},V=E=>{S(E),u.setFieldsValue({productCode:E.productCode,productName:E.productName,description:E.description,category:E.category,version:E.version||"1.0.0",iconUrl:E.iconUrl,status:E.status,tags:E.tags}),N(!0)},U=async()=>{try{const E=await u.validateFields();D(!0),v?(await Se.update({id:v.id,...E}),t.message.success("更新成功")):(await Se.create(E),t.message.success("创建成功")),N(!1),K()}catch(E){E.errorFields||t.message.error("操作失败")}finally{D(!1)}},A=async E=>{try{await Se.delete(E),t.message.success("删除成功"),K()}catch{t.message.error("删除失败")}},k=async E=>{try{await Se.publish(E),t.message.success("发布成功"),K()}catch{t.message.error("发布失败")}},_=async E=>{try{await Se.offline(E),t.message.success("下架成功"),K()}catch{t.message.error("下架失败")}},p=async E=>{P(E),g(!0)},y=E=>{navigator.clipboard.writeText(E).then(()=>t.message.success("产品编码已复制")).catch(()=>{})},M=[{title:"产品",key:"product",width:280,render:(E,Q)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:8,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.ShopOutlined,{style:{fontSize:18,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:Q.productName}),e.jsxs("div",{style:{fontSize:12,color:"#999"},children:[e.jsx("span",{style:{fontFamily:"monospace"},children:Q.productCode}),e.jsx(t.Tooltip,{title:"复制编码",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>y(Q.productCode),style:{marginLeft:4,padding:0}})})]})]})]})},{title:"分类",dataIndex:"category",width:120,render:E=>E?e.jsx(t.Tag,{icon:e.jsx(l.TagOutlined,{}),children:E}):e.jsx("span",{style:{color:"#ccc"},children:"未分类"})},{title:"状态",dataIndex:"status",width:100,render:E=>{const Q={PUBLISHED:"success",DRAFT:"warning",OFFLINE:"error",ARCHIVED:"default"},c={PUBLISHED:"已发布",DRAFT:"草稿",OFFLINE:"已下架",ARCHIVED:"已归档"};return e.jsx(t.Badge,{status:Q[E]||"default",text:c[E]||E})}},{title:"版本",dataIndex:"version",width:90,render:E=>e.jsxs("span",{style:{fontFamily:"monospace"},children:["v",E||"1.0.0"]})},{title:"描述",dataIndex:"description",ellipsis:!0},{title:"操作",width:320,render:(E,Q)=>e.jsxs(t.Space,{size:"small",wrap:!0,children:[e.jsx(t.Tooltip,{title:"查看详情",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>p(Q),children:"详情"})}),e.jsx(t.Tooltip,{title:"编辑配置",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>V(Q),children:"编辑"})}),Q.status==="DRAFT"&&e.jsx(t.Tooltip,{title:"发布产品",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.CheckCircleOutlined,{}),onClick:()=>k(Q.productCode),children:"发布"})}),Q.status==="PUBLISHED"&&e.jsx(t.Tooltip,{title:"下架产品",children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.StopOutlined,{}),onClick:()=>_(Q.productCode),children:"下架"})}),e.jsx(t.Tooltip,{title:"执行场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:()=>window.open(`/ai/product/execute?productCode=${Q.productCode}`,"_blank"),children:"执行"})}),e.jsx(t.Popconfirm,{title:"确定删除此产品?",onConfirm:()=>A(Q.id),okText:"删除",okButtonProps:{danger:!0},children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:16,gap:12,flexWrap:"wrap"},children:[e.jsxs(t.Space,{children:[e.jsx(t.Input.Search,{placeholder:"搜索产品名称/编码",onSearch:E=>{d(E),w(1)},style:{width:220},allowClear:!0}),e.jsxs(t.Select,{placeholder:"状态筛选",allowClear:!0,style:{width:120},onChange:E=>{f(E),w(1)},children:[e.jsx(ke,{value:"DRAFT",children:"草稿"}),e.jsx(ke,{value:"PUBLISHED",children:"已发布"}),e.jsx(ke,{value:"OFFLINE",children:"已下架"}),e.jsx(ke,{value:"ARCHIVED",children:"已归档"})]})]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:O,children:"新建产品"})]}),e.jsx(t.Table,{dataSource:o,columns:M,loading:a,rowKey:"id",pagination:{current:j,pageSize:h,total:m,showSizeChanger:!1,showTotal:E=>`共 ${E} 个产品`,onChange:E=>w(E)},locale:{emptyText:e.jsx(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE,description:"还没有产品,点击新建开始创建"})}}),e.jsx(t.Modal,{title:v?`编辑产品: ${v.productName}`:"新建产品",open:F,onOk:U,onCancel:()=>N(!1),width:640,confirmLoading:x,okText:v?"保存":"创建",children:e.jsxs(t.Form,{form:u,layout:"vertical",size:"middle",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"productName",label:"产品名称",rules:[{required:!0,message:"请输入产品名称"}],children:e.jsx(t.Input,{placeholder:"如:智能客服助手"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"productCode",label:"产品编码",rules:[{required:!0,message:"请输入产品编码"}],children:e.jsx(t.Input,{placeholder:"如 product-ai-assistant",disabled:!!v})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"category",label:"产品分类",children:e.jsx(t.Input,{placeholder:"如 AI助手, 图像生成"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"version",label:"版本号",initialValue:"1.0.0",children:e.jsx(t.Input,{placeholder:"1.0.0"})})})]}),e.jsx(t.Form.Item,{name:"description",label:"产品描述",children:e.jsx(os,{rows:2,placeholder:"简短描述这个产品的能力和使用场景"})}),e.jsx(t.Form.Item,{name:"tags",label:"产品标签",children:e.jsx(t.Input,{placeholder:"用逗号分隔,如 AI,客服,对话"})}),e.jsx(t.Form.Item,{name:"iconUrl",label:"图标URL",children:e.jsx(t.Input,{placeholder:"可选,图标图片URL"})}),!v&&e.jsx(t.Form.Item,{name:"status",label:"创建后状态",initialValue:"DRAFT",children:e.jsxs(t.Select,{children:[e.jsx(ke,{value:"DRAFT",children:"草稿(仅自己可见)"}),e.jsx(ke,{value:"PUBLISHED",children:"直接发布"})]})})]})}),e.jsx(t.Drawer,{title:"产品详情",open:G,onClose:()=>g(!1),width:560,children:C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:10,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.ShopOutlined,{style:{fontSize:22,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:C.productName}),e.jsx("div",{style:{fontSize:12,color:"#999"},children:C.productCode})]})]}),e.jsx(t.Divider,{style:{margin:"8px 0"}}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Statistic,{title:"分类",value:C.category||"未分类",valueStyle:{fontSize:14}})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Statistic,{title:"版本",value:C.version||"1.0.0",valueStyle:{fontSize:14}})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"状态"}),e.jsx(t.Badge,{status:C.status==="PUBLISHED"?"success":C.status==="DRAFT"?"warning":"error",text:C.status==="PUBLISHED"?"已发布":C.status==="DRAFT"?"草稿":C.status==="OFFLINE"?"已下架":"已归档"})]}),C.tags&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:6},children:"标签"}),e.jsx(t.Space,{wrap:!0,children:(C.tags||"").split(",").filter(Boolean).map((E,Q)=>e.jsx(t.Tag,{color:"blue",children:E},Q))})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"描述"}),e.jsx("div",{style:{color:"#333",lineHeight:1.6},children:C.description||"暂无描述"})]})]})})]})},hl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState({scenes:[],params:[]}),[b,f]=s.useState(!1),[j,w]=s.useState(!1),[h,m]=s.useState(!1),[z]=t.Form.useForm();s.useEffect(()=>{Se.page({id:1,pageSize:100}).then(x=>{var D;i(((D=x.data)==null?void 0:D.records)||[])})},[]),s.useEffect(()=>{a&&F(a.productCode)},[a]);const F=async x=>{f(!0);try{const D=await Se.configGet(x);d(D.data||{scenes:[],params:[]})}catch{d({scenes:[],params:[]})}f(!1)},N=async()=>{if(a){w(!0);try{await Se.configSave({productCode:a.productCode,...T}),t.message.success("配置已保存")}catch{t.message.error("保存失败")}finally{w(!1)}}},u=()=>{z.resetFields(),m(!0)},v=async()=>{try{const x=await z.validateFields();d(D=>({...D,scenes:[...D.scenes||[],{...x,id:Date.now()}]})),m(!1),t.message.success("场景已添加")}catch{}},S=x=>{d(D=>({...D,scenes:(D.scenes||[]).filter(G=>G.id!==x)}))};return e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.ShopOutlined,{style:{color:"#667eea",marginRight:6}}),"选择产品"]}),style:{width:260,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:[(o||[]).map(x=>e.jsxs("div",{onClick:()=>n(x),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===x.id?"linear-gradient(135deg, #667eea22, #764ba222)":"transparent",border:(a==null?void 0:a.id)===x.id?"1px solid #667eea44":"1px solid transparent",transition:"all 0.2s"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:x.productName}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:x.productCode})]},x.id)),o.length===0&&e.jsx(t.Empty,{description:"暂无产品",style:{padding:20}})]}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["产品配置 ",a?`- ${a.productName}`:""]}),extra:e.jsx(t.Button,{type:"primary",icon:e.jsx(l.CloudUploadOutlined,{}),onClick:N,disabled:!a,loading:j,children:"保存配置"}),style:{flex:1,borderRadius:10},children:a?b?e.jsx("div",{style:{textAlign:"center",padding:40},children:"加载中..."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:20},children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsx("span",{style:{fontWeight:500},children:"关联场景"}),e.jsx(t.Button,{size:"small",icon:e.jsx(l.PlusOutlined,{}),onClick:u,children:"添加场景"})]}),(T.scenes||[]).length===0?e.jsxs("div",{style:{textAlign:"center",padding:"20px 0",color:"#999",background:"#fafafa",borderRadius:8},children:[e.jsx(l.ExclamationCircleOutlined,{style:{marginRight:6}}),"暂无关联场景"]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(T.scenes||[]).map((x,D)=>e.jsx(t.Card,{size:"small",style:{background:"#fafafa",border:"none"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx(t.Tag,{color:"purple",children:x.sceneName}),e.jsx("span",{style:{fontSize:12,color:"#666",marginLeft:8},children:x.sceneCode})]}),e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>S(x.id)})]})},x.id||D))})]})}):e.jsx(t.Empty,{description:"请先选择产品",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})}),e.jsx(t.Modal,{title:"添加场景",open:h,onOk:v,onCancel:()=>m(!1),okText:"添加",children:e.jsxs(t.Form,{form:z,layout:"vertical",children:[e.jsx(t.Form.Item,{name:"sceneName",label:"场景名称",rules:[{required:!0,message:"请输入场景名称"}],children:e.jsx(t.Input,{placeholder:"如 智能问答"})}),e.jsx(t.Form.Item,{name:"sceneCode",label:"场景编码",rules:[{required:!0,message:"请输入场景编码"}],children:e.jsx(t.Input,{placeholder:"如 chat_scene"})}),e.jsx(t.Form.Item,{name:"sceneType",label:"场景类型",initialValue:"CONVERSATION",children:e.jsxs(t.Select,{children:[e.jsx(ke,{value:"CONVERSATION",children:"对话"}),e.jsx(ke,{value:"TASK",children:"任务"}),e.jsx(ke,{value:"WORKFLOW",children:"工作流"})]})}),e.jsx(t.Form.Item,{name:"description",label:"描述",children:e.jsx(os,{rows:2,placeholder:"场景描述"})})]})})]})},{TextArea:ml}=t.Input,{Text:Me,Title:gl}=t.Typography,{Option:ns}=t.Select,fl=()=>{var je,le,fe;const o=new URLSearchParams(window.location.search),i=o.get("productCode")||"",a=o.get("sceneCode")||"",[n,T]=s.useState(i),[d,b]=s.useState(a),[f,j]=s.useState([]),[w,h]=s.useState([]),[m,z]=s.useState([]),[F,N]=s.useState(""),[u,v]=s.useState(!1),[S,x]=s.useState(!1),[D,G]=s.useState(""),[g,C]=s.useState(!1),[P,K]=s.useState([]),[O,V]=s.useState(!1),[U]=t.Form.useForm(),[A,k]=s.useState({temperature:.7,maxTokens:2048,topP:1}),[_,p]=s.useState(null),y=s.useRef(null),M=s.useRef(null),E=s.useRef(null);s.useEffect(()=>{Se.page({id:1,pageSize:100,status:"PUBLISHED"}).then(W=>{var ee;j(((ee=W.data)==null?void 0:ee.records)||[])})},[]),s.useEffect(()=>{if(!n){h([]);return}ue.page({id:1,pageSize:100,status:"PUBLISHED",productCode:n}).then(W=>{var ee;h(((ee=W.data)==null?void 0:ee.records)||[])})},[n]),s.useEffect(()=>{if(!d){p(null);return}ue.configGet(d).then(W=>{p(W.data)}).catch(()=>p(null))},[d]),s.useEffect(()=>{d&&ue.chatHistory(d).then(W=>{K(Array.isArray(W.data)?W.data:[])}).catch(()=>K([]))},[d]),s.useEffect(()=>{var W;(W=y.current)==null||W.scrollIntoView({behavior:"smooth"})},[m,D]),s.useEffect(()=>{var W;(W=E.current)==null||W.focus()},[d]);const Q=s.useCallback(async()=>{if(!F.trim()||!d||u||S)return;const W=F.trim();N("");const ee={id:Date.now(),role:"user",content:W,timestamp:new Date().toLocaleTimeString()};z(ce=>[...ce,ee]),v(!0),G("");try{x(!0);const ce=localStorage.getItem("userId")||"anonymous",H=localStorage.getItem("userName")||"匿名用户",X=new EventSource(`/api/scene/execute/stream?sceneCode=${d}&message=${encodeURIComponent(W)}&userId=${ce}&userName=${encodeURIComponent(H)}`);M.current=X,X.onmessage=ie=>{try{const he=JSON.parse(ie.data);if(he.type==="chunk")G(ne=>ne+he.content);else if(he.type==="done"){const ne={id:Date.now()+1,role:"assistant",content:D+he.content,timestamp:new Date().toLocaleTimeString()};z(ye=>[...ye,ne]),G(""),x(!1),X.close()}else he.type==="error"&&(t.message.error(he.content||"执行出错"),G(""),x(!1),X.close())}catch{G(ne=>ne+ie.data)}},X.onerror=async()=>{var ie,he;X.close(),x(!1),v(!1);try{const ne=await ue.execute({sceneCode:d,message:W,userId:ce,userName:H,config:A}),ye={id:Date.now()+1,role:"assistant",content:((ie=ne.data)==null?void 0:ie.content)||((he=ne.data)==null?void 0:he.reply)||JSON.stringify(ne.data)||"无响应",timestamp:new Date().toLocaleTimeString()};z(_e=>[..._e,ye])}catch{const ye={id:Date.now()+1,role:"assistant",content:"抱歉,执行过程中出现错误,请稍后重试。",timestamp:new Date().toLocaleTimeString()};z(_e=>[..._e,ye])}}}catch{t.message.error("执行失败"),v(!1),x(!1)}},[F,d,u,S,A,D]),c=W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),Q())},r=()=>{z([]),t.message.success("对话已清空")},L=()=>{var W;if((W=M.current)==null||W.close(),D){const ee={id:Date.now()+1,role:"assistant",content:D,timestamp:new Date().toLocaleTimeString()};z(ce=>[...ce,ee])}G(""),x(!1),v(!1),t.message.info("已停止生成")},$=W=>{navigator.clipboard.writeText(W).then(()=>t.message.success("已复制")).catch(()=>{})},R=W=>{W.messages&&z(Array.isArray(W.messages)?W.messages:[]),C(!1),t.message.success("已加载历史记录")},se=W=>W.split(`
214
+ `).map((ee,ce)=>ee.startsWith("```")&&ee.endsWith("```")?e.jsx("pre",{style:{background:"#f5f5f5",padding:8,borderRadius:6,fontSize:12,overflow:"auto"},children:ee.slice(3,-3)},ce):e.jsx("div",{style:{lineHeight:1.7},children:ee},ce));return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"calc(100vh - 140px)",padding:0},children:[e.jsxs("div",{style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",padding:"14px 20px",display:"flex",alignItems:"center",gap:16,flexWrap:"wrap"},children:[e.jsx(t.Select,{value:n||void 0,onChange:W=>{T(W),b("")},placeholder:"选择产品",allowClear:!0,style:{width:180,borderRadius:8},size:"large",children:f.map(W=>e.jsx(ns,{value:W.productCode,children:W.productName},W.productCode))}),e.jsx(t.Select,{value:d||void 0,onChange:W=>b(W),placeholder:"选择场景",allowClear:!0,style:{width:200,borderRadius:8},size:"large",disabled:!n,children:w.map(W=>e.jsx(ns,{value:W.sceneCode,children:W.sceneName},W.sceneCode))}),d&&e.jsxs(t.Tag,{icon:e.jsx(l.CheckCircleOutlined,{}),color:"green",style:{borderRadius:20},children:[((je=w.find(W=>W.sceneCode===d))==null?void 0:je.sceneName)||d," 已就绪"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(t.Space,{children:[e.jsx(t.Tooltip,{title:"执行配置",children:e.jsx(t.Button,{icon:e.jsx(l.ThunderboltOutlined,{}),onClick:()=>V(!0),style:{borderRadius:8},children:"参数"})}),e.jsx(t.Tooltip,{title:"历史记录",children:e.jsx(t.Button,{icon:e.jsx(l.HistoryOutlined,{}),onClick:()=>C(!0),style:{borderRadius:8},children:"历史"})}),e.jsx(t.Tooltip,{title:"清空对话",children:e.jsx(t.Button,{icon:e.jsx(l.ClearOutlined,{}),onClick:r,style:{borderRadius:8},children:"清空"})})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",background:"#f5f5f5",display:"flex",flexDirection:"column"},children:d?e.jsxs(e.Fragment,{children:[m.length===0&&e.jsxs("div",{style:{textAlign:"center",padding:"30px 0 20px"},children:[e.jsx(t.Avatar,{size:56,icon:e.jsx(l.RobotOutlined,{}),style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",margin:"0 auto"}}),e.jsx(gl,{level:5,style:{marginTop:12,marginBottom:4},children:((le=w.find(W=>W.sceneCode===d))==null?void 0:le.sceneName)||"场景助手"}),e.jsx(Me,{type:"secondary",children:(_==null?void 0:_.description)||((fe=w.find(W=>W.sceneCode===d))==null?void 0:fe.description)||"开始对话吧!"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[m.map(W=>e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:[e.jsx(t.Avatar,{size:36,icon:W.role==="user"?e.jsx(l.UserOutlined,{}):e.jsx(l.RobotOutlined,{}),style:{background:W.role==="user"?"#1890ff":"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",flexShrink:0}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx(Me,{strong:!0,style:{fontSize:13},children:W.role==="user"?"我":"助手"}),e.jsx(Me,{type:"secondary",style:{fontSize:11},children:W.timestamp}),W.role==="assistant"&&e.jsx(t.Tooltip,{title:"复制回复",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>$(W.content),style:{padding:0}})})]}),e.jsx(t.Card,{size:"small",style:{background:W.role==="user"?"#1890ff":"#fff",color:W.role==="user"?"#fff":"#333",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},styles:{body:{padding:"10px 14px"}},children:se(W.content)})]})]},W.id)),S&&D&&e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:[e.jsx(t.Avatar,{size:36,icon:e.jsx(l.RobotOutlined,{}),style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",flexShrink:0}}),e.jsx("div",{style:{flex:1},children:e.jsxs(t.Card,{size:"small",style:{background:"#fff",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},styles:{body:{padding:"10px 14px"}},children:[se(D),e.jsx("span",{style:{display:"inline-block",width:8,height:16,background:"#667eea",marginLeft:2,animation:"blink 1s infinite",borderRadius:2}})]})})]}),u&&!S&&e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:[e.jsx(t.Avatar,{size:36,icon:e.jsx(l.RobotOutlined,{}),style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",flexShrink:0}}),e.jsxs(t.Card,{size:"small",style:{background:"#fff",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},styles:{body:{padding:"10px 14px"}},children:[e.jsx(t.Spin,{indicator:e.jsx(l.LoadingOutlined,{style:{fontSize:16,color:"#667eea"},spin:!0})}),e.jsx(Me,{type:"secondary",style:{marginLeft:8},children:"正在思考..."})]})]})]}),e.jsx("div",{ref:y})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(t.Empty,{image:e.jsx("div",{style:{fontSize:48,opacity:.3},children:e.jsx(l.RobotOutlined,{})}),description:e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:15,marginBottom:6},children:"请先选择产品与场景"}),e.jsx("div",{style:{color:"#999",fontSize:13},children:"在顶部选择要执行的场景,即可开始体验"})]}),style:{padding:40}})})}),e.jsxs("div",{style:{background:"#fff",padding:"12px 20px",borderTop:"1px solid #f0f0f0",display:"flex",gap:12,alignItems:"flex-end"},children:[e.jsx(ml,{ref:E,value:F,onChange:W=>N(W.target.value),onKeyDown:c,placeholder:d?"输入消息,Enter 发送,Shift+Enter 换行...":"请先选择场景...",disabled:!d||S,autoSize:{minRows:1,maxRows:4},style:{flex:1,borderRadius:20,resize:"none"}}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:S?e.jsx(t.Tooltip,{title:"停止生成",children:e.jsx(t.Button,{danger:!0,icon:e.jsx(l.CloseCircleOutlined,{}),onClick:L,style:{borderRadius:20}})}):e.jsx(t.Tooltip,{title:"发送",children:e.jsx(t.Button,{type:"primary",icon:e.jsx(l.SendOutlined,{}),onClick:Q,disabled:!d||!F.trim()||u,style:{borderRadius:20,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none"}})})})]}),e.jsx(t.Modal,{title:e.jsxs("span",{children:[e.jsx(l.HistoryOutlined,{style:{marginRight:8}}),"对话历史"]}),open:g,onCancel:()=>C(!1),footer:null,width:600,children:P.length===0?e.jsx(t.Empty,{description:"暂无历史记录"}):e.jsx(t.List,{dataSource:P,renderItem:(W,ee)=>{var ce;return e.jsx(t.List.Item,{actions:[e.jsx(t.Button,{size:"small",icon:e.jsx(l.ReloadOutlined,{}),onClick:()=>R(W),children:"加载"},"load")],children:e.jsx(t.List.Item.Meta,{avatar:e.jsx(t.Avatar,{icon:e.jsx(yl,{}),style:{background:"#667eea"}}),title:`会话 ${ee+1} — ${W.startTime||""}`,description:e.jsxs(Me,{type:"secondary",style:{fontSize:12},children:[((ce=W.messages)==null?void 0:ce.length)||0," 条消息"]})})})}})}),e.jsx(t.Modal,{title:e.jsxs("span",{children:[e.jsx(l.ThunderboltOutlined,{style:{marginRight:8}}),"执行参数配置"]}),open:O,onCancel:()=>V(!1),onOk:()=>{V(!1),t.message.success("参数已保存")},okText:"保存",children:e.jsxs(t.Form,{form:U,layout:"vertical",initialValues:A,children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"temperature",label:"Temperature (随机性)",children:e.jsx(InputNumber,{min:0,max:2,step:.1,style:{width:"100%"}})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"maxTokens",label:"Max Tokens (最大字数)",children:e.jsx(InputNumber,{min:100,max:8192,step:100,style:{width:"100%"}})})})]}),e.jsx(t.Form.Item,{name:"topP",label:"Top P",children:e.jsx(InputNumber,{min:0,max:1,step:.05,style:{width:"100%"}})})]})}),e.jsx("style",{children:`
215
+ @keyframes blink {
216
+ 0%, 100% { opacity: 1; }
217
+ 50% { opacity: 0; }
218
+ }
219
+ `})]})},yl=()=>e.jsx(l.RobotOutlined,{}),{TextArea:rs}=t.Input,{Option:de}=t.Select,{TabPane:yt}=t.Tabs,jl=()=>{const[o,i]=s.useState("list");return e.jsx(t.Card,{style:{minHeight:"calc(100vh - 140px)"},children:e.jsxs(t.Tabs,{activeKey:o,onChange:i,children:[e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.NodeIndexOutlined,{})," 场景管理"]}),children:e.jsx(bl,{})},"list"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.SettingOutlined,{})," 节点配置"]}),children:e.jsx(Sl,{})},"nodes"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.ApiOutlined,{})," 场景编排"]}),children:e.jsx(Cl,{})},"canvas")]})})},bl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(""),[b,f]=s.useState(""),[j,w]=s.useState(1),[h]=s.useState(12),[m,z]=s.useState(0),[F,N]=s.useState(!1),[u]=t.Form.useForm(),[v,S]=s.useState(null),[x,D]=s.useState(!1),[G,g]=s.useState(!1),[C,P]=s.useState(null),[K,O]=s.useState([]);s.useEffect(()=>{Se.page({id:1,pageSize:100}).then(r=>{var L;O(((L=r.data)==null?void 0:L.records)||[])})},[]),s.useEffect(()=>{V()},[j,T,b]);const V=async()=>{n(!0);try{const r=await ue.page({sceneName:T,status:b,id:j});r.data&&(i(r.data.records||[]),z(r.data.total||0))}catch(r){t.message.error("加载失败: "+(r.message||""))}n(!1)},U=()=>{S(null),u.resetFields(),u.setFieldsValue({status:"DRAFT",sceneType:"CONVERSATION"}),N(!0)},A=r=>{S(r),u.setFieldsValue({sceneCode:r.sceneCode,sceneName:r.sceneName,description:r.description,productCode:r.productCode,sceneType:r.sceneType||"CONVERSATION",version:r.version||"1.0.0",status:r.status,iconUrl:r.iconUrl}),N(!0)},k=async()=>{try{const r=await u.validateFields();D(!0),v?(await ue.update({id:v.id,...r}),t.message.success("更新成功")):(await ue.create(r),t.message.success("创建成功")),N(!1),V()}catch(r){r.errorFields||t.message.error("操作失败")}finally{D(!1)}},_=async r=>{try{await ue.delete(r),t.message.success("删除成功"),V()}catch{t.message.error("删除失败")}},p=async r=>{try{await ue.publish(r),t.message.success("发布成功"),V()}catch{t.message.error("发布失败")}},y=async r=>{try{await ue.offline(r),t.message.success("下架成功"),V()}catch{t.message.error("下架失败")}},M=r=>{P(r),g(!0)},E=async r=>{try{await ue.duplicate(r.id),t.message.success("复制成功"),V()}catch{t.message.error("复制失败")}},Q=r=>{navigator.clipboard.writeText(r).then(()=>t.message.success("场景编码已复制")).catch(()=>{})},c=[{title:"场景",key:"scene",width:280,render:(r,L)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:8,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:18,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:L.sceneName}),e.jsxs("div",{style:{fontSize:12,color:"#999"},children:[e.jsx("span",{style:{fontFamily:"monospace"},children:L.sceneCode}),e.jsx(t.Tooltip,{title:"复制编码",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>Q(L.sceneCode),style:{marginLeft:4,padding:0}})})]})]})]})},{title:"所属产品",dataIndex:"productCode",width:160,render:r=>r?e.jsx(t.Tag,{color:"blue",children:r}):e.jsx("span",{style:{color:"#ccc"},children:"未关联"})},{title:"类型",dataIndex:"sceneType",width:100,render:r=>{const L={CONVERSATION:"对话",TASK:"任务",WORKFLOW:"工作流"};return e.jsx(t.Tag,{icon:e.jsx(l.NodeOutlined,{}),children:L[r]||r})}},{title:"状态",dataIndex:"status",width:100,render:r=>{const L={PUBLISHED:"success",DRAFT:"warning",OFFLINE:"error",ARCHIVED:"default"},$={PUBLISHED:"已发布",DRAFT:"草稿",OFFLINE:"已下架",ARCHIVED:"已归档"};return e.jsx(t.Badge,{status:L[r]||"default",text:$[r]||r})}},{title:"版本",dataIndex:"version",width:90,render:r=>e.jsxs("span",{style:{fontFamily:"monospace"},children:["v",r||"1.0.0"]})},{title:"描述",dataIndex:"description",ellipsis:!0},{title:"操作",width:340,render:(r,L)=>e.jsxs(t.Space,{size:"small",wrap:!0,children:[e.jsx(t.Tooltip,{title:"查看详情",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>M(L),children:"详情"})}),e.jsx(t.Tooltip,{title:"编辑配置",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>A(L),children:"编辑"})}),e.jsx(t.Tooltip,{title:"复制场景",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>E(L),children:"复制"})}),L.status==="DRAFT"&&e.jsx(t.Tooltip,{title:"发布场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.CheckCircleOutlined,{}),onClick:()=>p(L.sceneCode),children:"发布"})}),L.status==="PUBLISHED"&&e.jsx(t.Tooltip,{title:"下架场景",children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.StopOutlined,{}),onClick:()=>y(L.sceneCode),children:"下架"})}),e.jsx(t.Tooltip,{title:"执行场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:()=>window.open(`/ai/product/execute?sceneCode=${L.sceneCode}`,"_blank"),children:"执行"})}),e.jsx(t.Popconfirm,{title:"确定删除此场景?",onConfirm:()=>_(L.id),okText:"删除",okButtonProps:{danger:!0},children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:16,gap:12,flexWrap:"wrap"},children:[e.jsxs(t.Space,{children:[e.jsx(t.Input.Search,{placeholder:"搜索场景名称/编码",onSearch:r=>{d(r),w(1)},style:{width:220},allowClear:!0}),e.jsxs(t.Select,{placeholder:"状态筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"已发布"}),e.jsx(de,{value:"OFFLINE",children:"已下架"})]}),e.jsxs(t.Select,{placeholder:"类型筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"CONVERSATION",children:"对话"}),e.jsx(de,{value:"TASK",children:"任务"}),e.jsx(de,{value:"WORKFLOW",children:"工作流"})]})]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:U,children:"新建场景"})]}),e.jsx(t.Table,{dataSource:o,columns:c,loading:a,rowKey:"id",pagination:{current:j,pageSize:h,total:m,showSizeChanger:!1,showTotal:r=>`共 ${r} 个场景`,onChange:r=>w(r)},locale:{emptyText:e.jsx(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE,description:"还没有场景,点击新建开始创建"})}}),e.jsx(t.Modal,{title:v?`编辑场景: ${v.sceneName}`:"新建场景",open:F,onOk:k,onCancel:()=>N(!1),width:640,confirmLoading:x,okText:v?"保存":"创建",children:e.jsxs(t.Form,{form:u,layout:"vertical",size:"middle",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneName",label:"场景名称",rules:[{required:!0,message:"请输入场景名称"}],children:e.jsx(t.Input,{placeholder:"如 智能问答助手"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneCode",label:"场景编码",rules:[{required:!0,message:"请输入场景编码"}],children:e.jsx(t.Input,{placeholder:"如 chat_scene",disabled:!!v})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneType",label:"场景类型",initialValue:"CONVERSATION",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"CONVERSATION",children:"对话场景"}),e.jsx(de,{value:"TASK",children:"任务场景"}),e.jsx(de,{value:"WORKFLOW",children:"工作流场景"})]})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"productCode",label:"所属产品",children:e.jsx(t.Select,{allowClear:!0,placeholder:"选择产品",children:K.map(r=>e.jsx(de,{value:r.productCode,children:r.productName},r.productCode))})})})]}),e.jsx(t.Form.Item,{name:"description",label:"场景描述",children:e.jsx(rs,{rows:2,placeholder:"简短描述这个场景的能力和使用方式"})}),e.jsx(t.Form.Item,{name:"version",label:"版本号",initialValue:"1.0.0",children:e.jsx(t.Input,{placeholder:"1.0.0"})}),!v&&e.jsx(t.Form.Item,{name:"status",label:"创建后状态",initialValue:"DRAFT",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"直接发布"})]})})]})}),e.jsx(t.Drawer,{title:"场景详情",open:G,onClose:()=>g(!1),width:560,children:C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:10,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:22,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:C.sceneName}),e.jsx("div",{style:{fontSize:12,color:"#999"},children:C.sceneCode})]})]}),e.jsx(t.Divider,{style:{margin:"8px 0"}}),e.jsxs(t.Row,{gutter:16,children:[e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"类型"}),e.jsx(t.Tag,{children:C.sceneType==="CONVERSATION"?"对话":C.sceneType==="TASK"?"任务":"工作流"})]}),e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"版本"}),e.jsx("span",{style:{fontFamily:"monospace"},children:C.version||"1.0.0"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"状态"}),e.jsx(t.Badge,{status:C.status==="PUBLISHED"?"success":C.status==="DRAFT"?"warning":"error",text:C.status==="PUBLISHED"?"已发布":C.status==="DRAFT"?"草稿":C.status==="OFFLINE"?"已下架":"已归档"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"描述"}),e.jsx("div",{style:{color:"#333",lineHeight:1.6},children:C.description||"暂无描述"})]})]})})]})},Sl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState(!1),[j,w]=s.useState(!1),[h]=t.Form.useForm();s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(S=>{var x;i(((x=S.data)==null?void 0:x.records)||[])})},[]),s.useEffect(()=>{a&&m(a.sceneCode)},[a]);const m=async S=>{f(!0);try{const x=await ue.nodes(S);d(x.data||[])}catch{d([])}f(!1)},z=()=>{h.resetFields(),h.setFieldsValue({nodeType:"LLM",isEnabled:!0}),w(!0)},F=async()=>{try{const S=await h.validateFields();d(x=>[...x||[],{...S,id:Date.now()}]),w(!1),t.message.success("节点已添加")}catch{}},N=S=>{d(x=>(x||[]).filter(D=>D.id!==S))},u=S=>{d(x=>x.map(D=>D.id===S?{...D,isEnabled:!D.isEnabled}:D))},v=[{title:"节点名称",dataIndex:"nodeName",key:"nodeName"},{title:"节点类型",dataIndex:"nodeType",key:"nodeType",render:S=>e.jsx(t.Tag,{color:"blue",children:S})},{title:"配置",dataIndex:"config",key:"config",ellipsis:!0},{title:"启用",dataIndex:"isEnabled",key:"isEnabled",render:(S,x)=>e.jsx(t.Switch,{checked:S,onChange:()=>u(x.id)})},{title:"操作",width:100,render:(S,x)=>e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>N(x.id)})}];return e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"选择场景"]}),style:{width:260,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:[(o||[]).map(S=>e.jsxs("div",{onClick:()=>n(S),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===S.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===S.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:S.sceneName}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:S.sceneCode})]},S.id)),o.length===0&&e.jsx(t.Empty,{description:"暂无场景",style:{padding:20}})]}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["节点配置 ",a?`- ${a.sceneName}`:""]}),extra:e.jsx(t.Button,{size:"small",icon:e.jsx(l.PlusOutlined,{}),onClick:z,disabled:!a,children:"添加节点"}),style:{flex:1,borderRadius:10},children:a?e.jsx(t.Table,{dataSource:T,columns:v,rowKey:"id",pagination:!1,locale:{emptyText:e.jsx(t.Empty,{description:"暂无节点,点击添加开始配置",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}}):e.jsx(t.Empty,{description:"请先选择场景",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})}),e.jsx(t.Modal,{title:"添加节点",open:j,onOk:F,onCancel:()=>w(!1),okText:"添加",children:e.jsxs(t.Form,{form:h,layout:"vertical",children:[e.jsx(t.Form.Item,{name:"nodeName",label:"节点名称",rules:[{required:!0,message:"请输入节点名称"}],children:e.jsx(t.Input,{placeholder:"如 LLM调用节点"})}),e.jsx(t.Form.Item,{name:"nodeType",label:"节点类型",initialValue:"LLM",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"LLM",children:"LLM调用"}),e.jsx(de,{value:"TOOL",children:"工具调用"}),e.jsx(de,{value:"CONDITION",children:"条件分支"}),e.jsx(de,{value:"TRANSFORM",children:"数据转换"}),e.jsx(de,{value:"HTTP",children:"HTTP请求"})]})}),e.jsx(t.Form.Item,{name:"config",label:"节点配置",children:e.jsx(rs,{rows:3,placeholder:'JSON格式配置,如 {"model":"gpt-4"}'})})]})})]})},Cl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState([]);s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(h=>{var m;i(((m=h.data)==null?void 0:m.records)||[])})},[]);const j=async h=>{n(h);try{const m=await ue.canvasGet(h.sceneCode);m.data&&(d(m.data.nodes||[]),f(m.data.edges||[]))}catch{d([]),f([])}},w=[{title:"节点",dataIndex:"label",key:"label",width:200},{title:"类型",dataIndex:"type",key:"type",render:h=>e.jsx(t.Tag,{color:"purple",children:h})},{title:"位置",dataIndex:"position",key:"position",render:h=>e.jsxs("span",{style:{fontSize:11,color:"#999"},children:["x:",(h==null?void 0:h.x)||0," y:",(h==null?void 0:h.y)||0]})}];return e.jsxs("div",{style:{display:"flex",gap:16,minHeight:500},children:[e.jsx(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"场景列表"]}),style:{width:240,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:(o||[]).map(h=>e.jsxs("div",{onClick:()=>j(h),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===h.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===h.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:h.sceneName}),e.jsx(t.Tag,{style:{fontSize:10,marginTop:2},children:h.sceneType})]},h.id))}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["场景编排画布 ",a?`- ${a.sceneName}`:""]}),style:{flex:1,borderRadius:10},styles:{body:{padding:16,display:"flex",flexDirection:"column",gap:12}},children:a?T.length===0?e.jsx(t.Empty,{description:"暂无节点配置,请先在节点配置中添加节点",style:{padding:40},image:t.Empty.PRESENTED_IMAGE_SIMPLE}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0",borderBottom:"1px solid #f0f0f0"},children:[e.jsx(l.ThunderboltOutlined,{style:{color:"#4facfe"}}),e.jsxs("span",{style:{fontSize:13,color:"#666"},children:["编排节点 ",T.length," 个,连接 ",b.length," 条"]})]}),e.jsx(t.Table,{dataSource:T,columns:w,rowKey:"id",pagination:!1,size:"small"}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginTop:8},children:"连线"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:b.map((h,m)=>e.jsx(t.Card,{size:"small",style:{background:"#fafafa",border:"none"},children:e.jsxs("span",{style:{fontFamily:"monospace",fontSize:12},children:[h.source," → ",h.target]})},m))})]})]}):e.jsx(t.Empty,{description:"请选择场景进行编排",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})})]})},{Text:jt}=t.Typography,{TabPane:Qe}=t.Tabs,vl=()=>{const[o,i]=s.useState(null),[a,n]=s.useState([]),[T,d]=s.useState([]),[b,f]=s.useState([]),[j,w]=s.useState([]),[h,m]=s.useState(!1),[z,F]=s.useState(null),[N,u]=s.useState(null),[v,S]=s.useState(null),[x,D]=s.useState([]),[G,g]=s.useState([]),[C,P]=s.useState([]);s.useEffect(()=>{te("/llm-center/provider/list").then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.data)||[];D(r)}).catch(()=>{}),K(null),te("/agent/app/page",{method:"POST",body:JSON.stringify({current:1,size:100})}).then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];P(r)}).catch(()=>{})},[]);const K=c=>{te("/llm-center/model/list",{params:{providerCode:c}}).then(r=>{const L=Array.isArray(r)?r:(r==null?void 0:r.data)||[];g(L)}).catch(()=>{})},O=c=>{u(c),S(null),K(c)},V=()=>({appCode:z,providerCode:N,modelCode:v}),U=async()=>{try{const c=await te("/llm-gateway/usage/overview",{method:"GET",params:V()});i((c==null?void 0:c.data)||c||null)}catch(c){console.warn("Usage overview API unavailable:",c==null?void 0:c.message),i(null)}},A=async()=>{try{const c=await te("/llm-gateway/usage/by-app",{method:"GET"});n(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-app API unavailable:",c==null?void 0:c.message),n([])}},k=async()=>{try{const c=await te("/llm-gateway/usage/by-user",{method:"GET",params:V()});d(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-user API unavailable:",c==null?void 0:c.message),d([])}},_=async()=>{try{const c=await te("/llm-gateway/usage/trend",{method:"GET",params:{...V(),days:7}});f(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage trend API unavailable:",c==null?void 0:c.message),f([])}},p=async()=>{m(!0);try{const c=await te("/llm-gateway/usage/records",{method:"GET",params:{...V(),page:1,size:20}}),r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];w(r)}catch(c){console.warn("Usage records API unavailable:",c==null?void 0:c.message),w([])}finally{m(!1)}};s.useEffect(()=>{U(),A(),k(),_(),p()},[z,N,v]);const y={tooltip:{trigger:"axis"},legend:{data:["Token消耗","调用次数"]},xAxis:{type:"category",data:b.map(c=>c.date)},yAxis:[{type:"value",name:"Tokens",position:"left"},{type:"value",name:"调用次数",position:"right"}],series:[{name:"Token消耗",type:"bar",data:b.map(c=>c.dailyTokens)},{name:"调用次数",type:"line",yAxisIndex:1,data:b.map(c=>c.dailyCalls)}]},M=[{title:"应用编码",dataIndex:"appCode"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],E=[{title:"用户ID",dataIndex:"userId"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],Q=[{title:"时间",dataIndex:"gmtCreate",width:160},{title:"应用",dataIndex:"appCode",render:c=>e.jsx(t.Tag,{color:"blue",children:c||"-"})},{title:"用户",dataIndex:"userName"},{title:"供应商",dataIndex:"providerCode",render:c=>e.jsx(t.Tag,{color:"purple",children:c||"-"})},{title:"模型",dataIndex:"modelCode",render:c=>e.jsx(t.Tag,{children:c||"-"})},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"延迟",dataIndex:"latencyMs",render:c=>c?`${c}ms`:"-"},{title:"状态",dataIndex:"status",render:c=>e.jsx(t.Tag,{color:c==="SUCCESS"?"green":"red",children:c||"-"})},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",c||0]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",flexWrap:"wrap",background:"#fff",padding:"12px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)",marginBottom:16},children:[e.jsx("span",{style:{fontWeight:600,color:"#333",marginRight:4},children:"维度筛选:"}),e.jsx(t.Select,{placeholder:"筛选应用",allowClear:!0,style:{width:180},value:z,onChange:F,options:C.map(c=>({value:c.appCode,label:c.appName||c.appCode}))}),e.jsx(t.Select,{placeholder:"筛选供应商",allowClear:!0,style:{width:180},value:N,onChange:O,options:x.map(c=>({value:c.providerCode,label:c.providerName}))}),e.jsx(t.Select,{placeholder:"筛选模型",allowClear:!0,style:{width:180},value:v,onChange:S,options:G.map(c=>({value:c.modelCode,label:c.modelName}))}),(z||N||v)&&e.jsx("a",{onClick:()=>{F(null),u(null),S(null)},style:{fontSize:12},children:"清空筛选"})]}),e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计 Token"}),value:(o==null?void 0:o.totalTokens)||0,prefix:e.jsx(l.RocketOutlined,{style:{color:"#667eea"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计费用"}),value:(o==null?void 0:o.totalCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日 Token"}),value:(o==null?void 0:o.todayTokens)||0,prefix:e.jsx(l.BarChartOutlined,{style:{color:"#52c41a"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日费用"}),value:(o==null?void 0:o.todayCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),precision:4,suffix:"元",valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})})]}),e.jsxs(t.Tabs,{defaultActiveKey:"trend",children:[e.jsx(Qe,{tab:"用量趋势",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(Pt,{option:y,style:{height:300}})})},"trend"),e.jsx(Qe,{tab:"按应用统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:M,dataSource:a,rowKey:"appCode",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byApp"),e.jsx(Qe,{tab:"按用户统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:E,dataSource:T,rowKey:"userId",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byUser"),e.jsx(Qe,{tab:"调用明细",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:Q,dataSource:j,loading:h,rowKey:"id",pagination:{pageSize:20,showSizeChanger:!1},locale:{emptyText:"暂无数据"}})})},"records")]})]})};Z.AgentAppEditor=Mt,Z.AgentAppList=_t,Z.AgentAppPage=_t,Z.AgentSharePage=Ns,Z.AkManage=Gs,Z.AkUsageDrawer=Vt,Z.ApiBridgeEditor=Zt,Z.BucketList=Js,Z.CurlImportModal=Yt,Z.FieldMappingEditor=xt,Z.LlmModel=Vs,Z.LlmProvider=Us,Z.McpPage=Hs,Z.ModelManage=Ms,Z.ObjectBrowser=Qs,Z.OpenApiImportModal=Qt,Z.ProductExecute=fl,Z.ProductList=ul,Z.ProductScene=jl,Z.ScriptCenterPage=il,Z.SkillMarket=pl,Z.UsageDashboard=vl,Z.WorkflowEditor=Nt,Z.agentApi=ae,Z.authRequest=qe,Z.ctcRequest=$e,Z.flowApi=De,Z.llmApi=Ae,Z.mcpApi=Ie,Z.ossApi=me,Z.productApi=Se,Z.request=te,Z.sceneApi=ue,Z.scriptApi=be,Z.skillApi=ge,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})}));