flex-mcp 1.0.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/configs.js +263 -32
- package/dist/api/configs.js.map +1 -1
- package/dist/mcp/aggregator.d.ts.map +1 -1
- package/dist/mcp/aggregator.js +43 -13
- package/dist/mcp/aggregator.js.map +1 -1
- package/dist/mcp/post-sse-transport.d.ts +4 -0
- package/dist/mcp/post-sse-transport.d.ts.map +1 -1
- package/dist/mcp/post-sse-transport.js +118 -5
- package/dist/mcp/post-sse-transport.js.map +1 -1
- package/dist/mcp/tool-sync.d.ts.map +1 -1
- package/dist/mcp/tool-sync.js +12 -14
- package/dist/mcp/tool-sync.js.map +1 -1
- package/dist/web/assets/{Blank-BerVeAls.js → Blank-BX2hzrSo.js} +1 -1
- package/dist/web/assets/{Configs-BZ4p1nld.js → Configs-DGpyzfgE.js} +1 -1
- package/dist/web/assets/Dashboard-Dk-7JVrJ.js +30 -0
- package/dist/web/assets/InitScriptEditor-CJfq5ewu.js +679 -0
- package/dist/web/assets/{Layout-SLPXm-dk.js → Layout-CbJQ0_wa.js} +1 -1
- package/dist/web/assets/{Layout-Br6VMRob.js → Layout-D8dTPthK.js} +1 -1
- package/dist/web/assets/{Login-Cm10QZJ1.js → Login-Apd8mOT7.js} +1 -1
- package/dist/web/assets/{Login-Cn9EfrvS.js → Login-CPVVdjS9.js} +1 -1
- package/dist/web/assets/{Users-Dj8FIlX1.js → Users-Dfo1A39a.js} +1 -1
- package/dist/web/assets/{index-Dy8wTpRZ.js → index-Ku_MdnLs.js} +162 -162
- package/dist/web/assets/style-COdYV8kW.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/api/resources.d.ts +0 -6
- package/dist/api/resources.d.ts.map +0 -1
- package/dist/api/resources.js +0 -159
- package/dist/api/resources.js.map +0 -1
- package/dist/web/assets/Dashboard-DVSQDspm.js +0 -27
- package/dist/web/assets/InitScriptEditor-DlF0Jn7f.js +0 -679
- package/dist/web/assets/style-0VyF1s_q.css +0 -1
|
@@ -1,679 +0,0 @@
|
|
|
1
|
-
import{a1 as Gt,r as j,J as ne,d as it,I as xt,U as Wt,A as ue,c as R,o as O,u as Ct,m as te,f as v,b as o,w as u,g as m,B as L,a2 as Zt,e as It,D as st,h as D,F as ot,s as nt,y as Ce,t as Z,Q as at,Z as Qt,a3 as Yt,K as Et,L as Ee,a4 as Tt,a5 as Xt,a6 as St,a7 as Pt,N as Rt,j as oe,k as ie,O as Vt,a8 as gt,M as Pe,x as we,E as Ft,a9 as fe,S as eo,aa as to,l as et,ab as oo,Y as no,p as ye,C as ft,ac as bt,n as se,G as jt,R as yt,_ as Nt,ad as ro,H as so}from"./index-Dy8wTpRZ.js";import{_ as $t}from"./_plugin-vue_export-helper-DlAUqK2U.js";const ps=Gt("config",()=>{const e=j(null),a=j(!1);async function r(){var T,N;a.value=!0;try{const V=await ne.get("/configs/me");return e.value=V.data.data,e.value}catch(V){throw new Error(((N=(T=V.response)==null?void 0:T.data)==null?void 0:N.error)||"Failed to fetch config")}finally{a.value=!1}}async function l(T){var N,V;a.value=!0;try{const z=await ne.get(`/configs/user/${T}`);return e.value=z.data.data,e.value}catch(z){throw new Error(((V=(N=z.response)==null?void 0:N.data)==null?void 0:V.error)||"Failed to fetch user config")}finally{a.value=!1}}async function c(T){var N,V;a.value=!0;try{const z=await ne.put("/configs/me",T);return e.value=z.data.data,e.value}catch(z){throw new Error(((V=(N=z.response)==null?void 0:N.data)==null?void 0:V.error)||"Failed to update config")}finally{a.value=!1}}async function y(T,N){var V,z;a.value=!0;try{const M=await ne.put(`/configs/user/${T}`,N);return e.value=M.data.data,e.value}catch(M){throw new Error(((z=(V=M.response)==null?void 0:V.data)==null?void 0:z.error)||"Failed to update user config")}finally{a.value=!1}}function S(T){const N={...T,variables:T.variables.map(V=>({...V,value:V.isSecret?`{{${V.name}}}`:V.value}))};return JSON.stringify(N,null,2)}function x(T){try{const N=JSON.parse(T);if(!N.name||!Array.isArray(N.components)||!Array.isArray(N.customTools))throw new Error("Invalid config format");return N}catch(N){throw new Error(`Failed to parse config: ${N.message}`)}}return{currentConfig:e,loading:a,fetchConfig:r,fetchUserConfig:l,updateConfig:c,updateUserConfig:y,exportConfig:S,importConfig:x}});function Be(){if(typeof globalThis<"u"&&"crypto"in globalThis){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID()}return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function At(e){return e==null?!1:typeof e=="boolean"?e:typeof e=="string"?e.trim()!=="":typeof e=="number"?e!==0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!!e}function ao(e,a){let r=e;const l=/\{\{#if\s+(\w+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/if\}\}/g;r=r.replace(l,(y,S,x,T)=>{const N=a[S];return At(N)?x||"":T||""});const c=/\{\{#ifnot\s+(\w+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/ifnot\}\}/g;return r=r.replace(c,(y,S,x,T)=>{const N=a[S];return At(N)?T||"":x||""}),r}function lo(e,a){return e.replace(/\{\{(\w+)\}\}/g,(r,l)=>{const c=a[l];return c!=null?String(c):r})}function ms(e,a){let r=ao(e,a);return r=lo(r,a),r}function Mt(e,a){(a==null||a>e.length)&&(a=e.length);for(var r=0,l=Array(a);r<a;r++)l[r]=e[r];return l}function io(e){if(Array.isArray(e))return e}function uo(e,a,r){return(a=yo(a))in e?Object.defineProperty(e,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[a]=r,e}function co(e,a){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var l,c,y,S,x=[],T=!0,N=!1;try{if(y=(r=r.call(e)).next,a!==0)for(;!(T=(l=y.call(r)).done)&&(x.push(l.value),x.length!==a);T=!0);}catch(V){N=!0,c=V}finally{try{if(!T&&r.return!=null&&(S=r.return(),Object(S)!==S))return}finally{if(N)throw c}}return x}}function po(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(e,a){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter(function(c){return Object.getOwnPropertyDescriptor(e,c).enumerable})),r.push.apply(r,l)}return r}function zt(e){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?Ot(Object(r),!0).forEach(function(l){uo(e,l,r[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ot(Object(r)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(r,l))})}return e}function mo(e,a){if(e==null)return{};var r,l,c=vo(e,a);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(e);for(l=0;l<y.length;l++)r=y[l],a.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(c[r]=e[r])}return c}function vo(e,a){if(e==null)return{};var r={};for(var l in e)if({}.hasOwnProperty.call(e,l)){if(a.indexOf(l)!==-1)continue;r[l]=e[l]}return r}function go(e,a){return io(e)||co(e,a)||ho(e,a)||po()}function fo(e,a){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var l=r.call(e,a);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(e)}function yo(e){var a=fo(e,"string");return typeof a=="symbol"?a:a+""}function ho(e,a){if(e){if(typeof e=="string")return Mt(e,a);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(e,a):void 0}}function wo(e,a,r){return a in e?Object.defineProperty(e,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[a]=r,e}function Dt(e,a){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter(function(c){return Object.getOwnPropertyDescriptor(e,c).enumerable})),r.push.apply(r,l)}return r}function _t(e){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?Dt(Object(r),!0).forEach(function(l){wo(e,l,r[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(r,l))})}return e}function bo(){for(var e=arguments.length,a=new Array(e),r=0;r<e;r++)a[r]=arguments[r];return function(l){return a.reduceRight(function(c,y){return y(c)},l)}}function Ie(e){return function a(){for(var r=this,l=arguments.length,c=new Array(l),y=0;y<l;y++)c[y]=arguments[y];return c.length>=e.length?e.apply(this,c):function(){for(var S=arguments.length,x=new Array(S),T=0;T<S;T++)x[T]=arguments[T];return a.apply(r,[].concat(c,x))}}}function lt(e){return{}.toString.call(e).includes("Object")}function ko(e){return!Object.keys(e).length}function Ve(e){return typeof e=="function"}function xo(e,a){return Object.prototype.hasOwnProperty.call(e,a)}function Co(e,a){return lt(a)||$e("changeType"),Object.keys(a).some(function(r){return!xo(e,r)})&&$e("changeField"),a}function $o(e){Ve(e)||$e("selectorType")}function To(e){Ve(e)||lt(e)||$e("handlerType"),lt(e)&&Object.values(e).some(function(a){return!Ve(a)})&&$e("handlersType")}function So(e){e||$e("initialIsRequired"),lt(e)||$e("initialType"),ko(e)&&$e("initialContent")}function Po(e,a){throw new Error(e[a]||e.default)}var jo={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},$e=Ie(Po)(jo),tt={changes:Co,selector:$o,handler:To,initial:So};function No(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};tt.initial(e),tt.handler(a);var r={current:e},l=Ie(Oo)(r,a),c=Ie(Mo)(r),y=Ie(tt.changes)(e),S=Ie(Ao)(r);function x(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(V){return V};return tt.selector(N),N(r.current)}function T(N){bo(l,c,y,S)(N)}return[x,T]}function Ao(e,a){return Ve(a)?a(e.current):a}function Mo(e,a){return e.current=_t(_t({},e.current),a),a}function Oo(e,a,r){return Ve(a)?a(e.current):Object.keys(r).forEach(function(l){var c;return(c=a[l])===null||c===void 0?void 0:c.call(a,e.current[l])}),r}var zo={create:No},Do={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function _o(e){return function a(){for(var r=this,l=arguments.length,c=new Array(l),y=0;y<l;y++)c[y]=arguments[y];return c.length>=e.length?e.apply(this,c):function(){for(var S=arguments.length,x=new Array(S),T=0;T<S;T++)x[T]=arguments[T];return a.apply(r,[].concat(c,x))}}}function Uo(e){return{}.toString.call(e).includes("Object")}function Bo(e){return e||Ut("configIsRequired"),Uo(e)||Ut("configType"),e.urls?(Io(),{paths:{vs:e.urls.monacoBase}}):e}function Io(){console.warn(qt.deprecation)}function Eo(e,a){throw new Error(e[a]||e.default)}var qt={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
|
-
You are using deprecated way of configuration.
|
|
4
|
-
|
|
5
|
-
Instead of using
|
|
6
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
7
|
-
use
|
|
8
|
-
monaco.config({ paths: { vs: '...' } })
|
|
9
|
-
|
|
10
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
11
|
-
`},Ut=_o(Eo)(qt),Ro={config:Bo},Vo=function(){for(var a=arguments.length,r=new Array(a),l=0;l<a;l++)r[l]=arguments[l];return function(c){return r.reduceRight(function(y,S){return S(y)},c)}};function Lt(e,a){return Object.keys(a).forEach(function(r){a[r]instanceof Object&&e[r]&&Object.assign(a[r],Lt(e[r],a[r]))}),zt(zt({},e),a)}var Fo={type:"cancelation",msg:"operation is manually canceled"};function ht(e){var a=!1,r=new Promise(function(l,c){e.then(function(y){return a?c(Fo):l(y)}),e.catch(c)});return r.cancel=function(){return a=!0},r}var qo=["monaco"],Lo=zo.create({config:Do,isInitialized:!1,resolve:null,reject:null,monaco:null}),Jt=go(Lo,2),Fe=Jt[0],ut=Jt[1];function Jo(e){var a=Ro.config(e),r=a.monaco,l=mo(a,qo);ut(function(c){return{config:Lt(c.config,l),monaco:r}})}function Ko(){var e=Fe(function(a){var r=a.monaco,l=a.isInitialized,c=a.resolve;return{monaco:r,isInitialized:l,resolve:c}});if(!e.isInitialized){if(ut({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ht(wt);if(window.monaco&&window.monaco.editor)return Kt(window.monaco),e.resolve(window.monaco),ht(wt);Vo(Ho,Wo)(Zo)}return ht(wt)}function Ho(e){return document.body.appendChild(e)}function Go(e){var a=document.createElement("script");return e&&(a.src=e),a}function Wo(e){var a=Fe(function(l){var c=l.config,y=l.reject;return{config:c,reject:y}}),r=Go("".concat(a.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=a.reject,r}function Zo(){var e=Fe(function(r){var l=r.config,c=r.resolve,y=r.reject;return{config:l,resolve:c,reject:y}}),a=window.require;a.config(e.config),a(["vs/editor/editor.main"],function(r){var l=r.m||r;Kt(l),e.resolve(l)},function(r){e.reject(r)})}function Kt(e){Fe().monaco||ut({monaco:e})}function Qo(){return Fe(function(e){var a=e.monaco;return a})}var wt=new Promise(function(e,a){return ut({resolve:e,reject:a})}),Yo={config:Jo,init:Ko,__getMonacoInstance:Qo};const Re=it({__name:"MonacoEditor",props:{modelValue:{},language:{},theme:{},options:{},extraLibs:{}},emits:["update:modelValue","save","change"],setup(e,{emit:a}){const r=e,l=a,c=j();let y=null,S=null,x=null,T=!1,N=null;const V=j(new Map);function z(M){if(!S)return;V.value.forEach(E=>{E.dispose()}),V.value.clear();const H=(r.language||"typescript")==="typescript"?S.languages.typescript.typescriptDefaults:S.languages.typescript.javascriptDefaults;H.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1}),H.setCompilerOptions({target:S.languages.typescript.ScriptTarget.ES2020,allowNonTsExtensions:!0,strict:!0}),H.setInlayHintsOptions({includeInlayParameterNameHints:"all"}),M.forEach(E=>{const _=E.filePath||`file:///lib-${Date.now()}.d.ts`,J=H.addExtraLib(E.content,_);V.value.set(_,J)})}return xt(async()=>{var K,H,E;S=await Yo.init(),r.extraLibs&&z(r.extraLibs);const M=r.language||"typescript";x&&x.dispose(),x=S.languages.registerCompletionItemProvider(M,{provideCompletionItems:()=>({suggestions:[]}),triggerCharacters:['"',"'"]}),y=S.editor.create(c.value,{value:r.modelValue,language:M,theme:r.theme||"vs-dark",automaticLayout:!0,minimap:{enabled:!0},fontSize:14,tabSize:2,readOnly:!1,...r.options,quickSuggestions:{other:!0,comments:!1,strings:!0,...(K=r.options)==null?void 0:K.quickSuggestions},suggestOnTriggerCharacters:((H=r.options)==null?void 0:H.suggestOnTriggerCharacters)??!0,wordWrap:((E=r.options)==null?void 0:E.wordWrap)??"off"}),y.onDidChangeModelContent(_=>{var I;if(T)return;const J=y.getValue();l("update:modelValue",J),l("change",J);const C=(I=_.changes)==null?void 0:I[_.changes.length-1];C&&(C.text==='"'||C.text==="'")&&setTimeout(()=>{y&&y.trigger("","editor.action.triggerSuggest",{})},100)}),y.addCommand(S.KeyMod.CtrlCmd|S.KeyCode.KeyS,()=>{l("save")}),N=_=>{if(!(!y||!y.hasTextFocus())){if((_.metaKey||_.ctrlKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),_.stopPropagation();const J=y.getModel();return J&&J.canUndo()&&J.undo(),!1}if((_.metaKey||_.ctrlKey)&&_.key==="z"&&_.shiftKey){_.preventDefault(),_.stopPropagation();const J=y.getModel();return J&&J.canRedo()&&J.redo(),!1}if((_.metaKey||_.ctrlKey)&&_.key==="y"){_.preventDefault(),_.stopPropagation();const J=y.getModel();return J&&J.canRedo()&&J.redo(),!1}}},document.addEventListener("keydown",N,!0)}),Wt(()=>{x==null||x.dispose(),y==null||y.dispose(),N&&(document.removeEventListener("keydown",N,!0),N=null)}),ue(()=>r.modelValue,M=>{if(!y)return;if(y.getValue()!==M){T=!0;try{const H=y.getModel();if(H){const E=H.getFullModelRange();y.executeEdits("external-update",[{range:E,text:M}]),y.pushUndoStop();const _=H.getLineCount(),J=H.getLineMaxColumn(_);y.setPosition({lineNumber:_,column:J})}}finally{setTimeout(()=>{T=!1},0)}}}),ue(()=>r.extraLibs,(M,K)=>{if(!M||!S||!(!K||M.length!==K.length||M.some((_,J)=>{const C=K[J];return!C||_.content!==C.content||_.filePath!==C.filePath})))return;z(M);const E=y==null?void 0:y.getModel();E&&(S.editor.setModelMarkers(E,"typescript",[]),setTimeout(()=>{y&&E&&E.getValue()===E.getValue()&&E.forceTokenization(E.getLineCount())},100))},{deep:!0,immediate:!1}),(M,K)=>(O(),R("div",{ref_key:"editorContainer",ref:c,class:"w-full h-full min-h-[400px]"},null,512))}}),Xo={class:"components-manager"},en={key:0,class:"components-toolbar"},tn={class:"toolbar-actions"},on={key:1},nn={class:"component-item"},rn={class:"component-main"},sn={class:"component-icon"},an={class:"icon-circle"},ln={class:"component-info"},un={class:"component-title"},cn={class:"name"},dn={class:"component-actions"},pn={key:0,class:"component-tools"},mn={key:2,class:"empty-state"},vn={class:"empty-state-content"},gn={class:"empty-actions"},fn={class:"modal-header"},yn={class:"modal-title"},hn={class:"modal-subtitle"},wn={class:"modal-content-wrapper"},bn={class:"tab-pane-content"},kn={class:"mode-switcher"},xn={class:"form-content"},Cn={class:"form-section"},$n={class:"form-grid"},Tn={key:0,class:"form-section"},Sn={class:"form-grid"},Pn={key:1,class:"form-section"},jn={key:2,class:"form-section"},Nn={class:"json-content"},An={class:"editor-wrapper"},Mn={class:"tab-pane-content tools-tab-content"},On={class:"tools-action-bar"},zn={class:"tools-action-buttons"},Dn={key:0,class:"batch-actions"},_n={key:0,class:"tools-list-wrapper"},Un={class:"tools-list"},Bn=["onClick"],In={class:"tool-header"},En={class:"tool-checkbox"},Rn={class:"tool-info"},Vn=["title"],Fn={class:"tooltip-description"},qn={class:"tool-actions"},Ln={class:"detail-section"},Jn=["onDblclick"],Kn={key:2,class:"description-actions"},Hn={key:0,class:"detail-section"},Gn={class:"params-list"},Wn={class:"param-header"},Zn={class:"param-name"},Qn={key:0,class:"param-type"},Yn={key:1,class:"param-required"},Xn=["onDblclick"],er={key:2,class:"field-description-actions"},tr={key:1,class:"detail-section"},or={key:1,class:"tools-empty"},nr={key:2,class:"tools-error"},rr={class:"tab-pane-content"},sr={class:"schema-editor"},ar={class:"schema-tool-info"},lr={class:"original-desc"},ir={class:"schema-actions"},ur={class:"modal-footer"},cr={style:{"font-size":"12px",color:"#666"}},dr={key:0},pr={class:"modal-footer"},mr=it({__name:"MCPComponentsManager",props:{config:{}},emits:["update"],setup(e,{emit:a}){const r=e,l=a,c=Ct(),y=j(!1),S=j("config"),x=j("form"),T=j(!1),N=j(!1),V=j(!1),z=j(!1),M=j(""),K=j(null),H=j(),E=j(""),_=j(""),J=j({}),C=j(!1),I=j({current:0,total:0,currentComponent:""});function ee(i){S.value=i}const B=j([]),G=j(new Set),A=j(null),U=j(null),q=j(""),me=j("tool"),le=j(""),ve=j(""),d=j({name:"",type:"npm",package:"",version:"",url:"",command:"",args:[],env:[],headers:[],disabledTools:[],toolPatches:{},namespace:"",extraConfig:{},rootExtra:{},configStr:"{}",disabled:!1}),Me=[{label:"NPM 包",value:"npm"},{label:"Stdio (Command)",value:"stdio"},{label:"SSE (URL)",value:"url"}],ge={name:{required:!0,message:"请输入名称",trigger:"blur"},type:{required:!0,message:"请选择类型",trigger:"change"}};function be(i){const t={};return i.forEach(n=>{n.key&&(t[n.key]=n.value)}),t}function ke(i){return i?Object.entries(i).map(([t,n])=>({key:t,value:n})):[]}function Oe(i,t){const n=[...r.config.components],k=n.findIndex(p=>p.id===i.id);k!==-1&&(n[k]={...i,disabled:!t},l("update",{components:n}))}function ze(i){var Y,pe,_e;const t=(Y=i.config)!=null&&Y.headers?ke(i.config.headers):[],n=((pe=i.config)==null?void 0:pe.disabledTools)||[],k=(_e=i.config)!=null&&_e.toolPatches?JSON.parse(JSON.stringify(i.config.toolPatches)):{};console.log("加载时的 toolPatches:",JSON.stringify(k,null,2));const{headers:p,disabledTools:f,toolPatches:b,tools:$,...w}=i.config||{},F=["id","name","type","namespace","env","package","version","url","command","args","config","disabled"],X={};Object.keys(i).forEach(Se=>{F.includes(Se)||(X[Se]=i[Se])}),d.value={name:i.name||"",type:i.type||"npm",package:i.package||"",version:i.version||"",url:i.url||"",command:i.command||"",args:i.args||[],env:ke(i.env),headers:t,disabledTools:n,toolPatches:k,namespace:i.namespace||"",extraConfig:w,rootExtra:X,configStr:JSON.stringify(i,null,2),disabled:!!i.disabled}}function qe(){const i={...d.value.rootExtra,name:d.value.name,type:d.value.type,namespace:d.value.namespace||void 0,env:d.value.env.length>0?be(d.value.env):void 0,disabled:d.value.disabled?!0:void 0};d.value.type==="npm"?(i.package=d.value.package,i.version=d.value.version||void 0):d.value.type==="url"?i.url=d.value.url:d.value.type==="stdio"&&(i.command=d.value.command,i.args=d.value.args);const t={...d.value.extraConfig};return d.value.disabledTools.length>0&&(t.disabledTools=d.value.disabledTools),d.value.headers.length>0&&(t.headers=be(d.value.headers)),B.value.length>0&&(t.tools=B.value),d.value.toolPatches&&Object.keys(d.value.toolPatches).length>0&&(t.toolPatches=JSON.parse(JSON.stringify(d.value.toolPatches))),Object.keys(t).length>0&&(i.config=t),JSON.parse(JSON.stringify(i))}ue(x,i=>{var t;if(S.value==="config"){if(i==="json")try{const n=qe();(t=K.value)!=null&&t.id&&(n.id=K.value.id),d.value.configStr=JSON.stringify(n,null,2)}catch(n){console.error(n)}else if(i==="form")try{const n=JSON.parse(d.value.configStr);ze(n)}catch{c.error("JSON 格式错误,忽略更改")}}});async function Le(i){K.value=i,S.value="config",x.value="form",ze(i),B.value=[],M.value="",G.value.clear(),A.value=null,U.value=null,q.value="",await Te(i.id),y.value=!0}async function Te(i){var t,n,k;try{const p=await ne.get(`/configs/component-tools/${i}`);if(p.data.success&&p.data.data.tools&&p.data.data.tools.length>0){B.value=p.data.data.tools;return}}catch(p){((t=p.response)==null?void 0:t.status)===404?console.log("数据库中没有工具列表,尝试从 MCP 组件加载"):console.warn("从数据库加载工具列表失败:",p)}try{const p=r.config.components.find(b=>b.id===i);if(!p){B.value=[];return}const f=await ne.post("/configs/component-tools/load",{componentId:i});if(f.data.success&&f.data.data.tools){const b=((n=p.config)==null?void 0:n.toolPatches)||{},$=Array.isArray((k=p.config)==null?void 0:k.disabledTools)?p.config.disabledTools:[];B.value=f.data.data.tools.map(w=>{const F=w.originalToolName||(()=>{const Y=w.name.split("_");return Y.length>1?Y.slice(-1)[0]:w.name})();let X=w.inputSchema||{type:"object",properties:{}};return b[F]&&(X={...X,...b[F]}),{name:w.name,description:w.description||"",inputSchema:X,disabled:$.includes(F),originalToolName:F}})}else B.value=[]}catch(p){console.warn("从 MCP 组件加载工具列表失败:",p),B.value=[]}}function ct(i){const t=r.config.components.filter(n=>n.id!==i);l("update",{components:t})}async function P(i){var t,n,k;J.value[i.id]=!0;try{const p=await ne.post("/configs/sync-tools",{componentId:i.id});if(p.data.success)if(p.data.data.errors&&p.data.data.errors.length>0)c.error(`同步工具失败: ${p.data.data.errors.join("; ")}`);else if(p.data.data.success>0){c.success(`工具同步成功:${p.data.data.success} 个工具已更新`),p.data.data.failed>0&&c.warning(`${p.data.data.failed} 个工具同步失败`);try{const f=await ne.get(`/configs/component-tools/${i.id}`);if(f.data.success&&f.data.data.tools){const b=f.data.data.tools.length,$=[...r.config.components],w=$.findIndex(F=>F.id===i.id);w!==-1&&($[w]={...$[w],config:{...$[w].config,toolCount:b}},l("update",{components:$}))}}catch(f){console.warn("更新组件工具总数失败:",f)}((t=K.value)==null?void 0:t.id)===i.id&&await Te(i.id)}else c.warning("没有工具需要同步");else c.error(`同步工具失败: ${p.data.error||"未知错误"}`)}catch(p){c.error(`同步工具失败: ${((k=(n=p.response)==null?void 0:n.data)==null?void 0:k.error)||p.message}`)}finally{J.value[i.id]=!1}}async function dt(){var i,t;if(!K.value){c.warning("请先选择要编辑的组件");return}z.value=!0,M.value="";try{const n=await ne.post("/configs/sync-tools",{componentId:K.value.id});n.data.success?n.data.data.errors&&n.data.data.errors.length>0?(M.value=n.data.data.errors.join("; "),c.error(`同步工具失败: ${M.value}`)):n.data.data.success>0?(c.success(`工具同步成功:${n.data.data.success} 个工具已更新`),n.data.data.failed>0&&(c.warning(`${n.data.data.failed} 个工具同步失败`),n.data.data.errors&&n.data.data.errors.length>0&&(M.value=n.data.data.errors.join("; "))),await Te(K.value.id)):c.warning("没有工具需要同步"):(M.value=n.data.error||"同步失败",c.error(`同步工具失败: ${M.value}`))}catch(n){M.value=((t=(i=n.response)==null?void 0:i.data)==null?void 0:t.error)||n.message,c.error(`同步工具失败: ${M.value}`)}finally{z.value=!1}}function Je(i){var n,k,p;const t=((n=i.config)==null?void 0:n.toolCount)??((p=(k=i.config)==null?void 0:k.tools)==null?void 0:p.length);return t!=null&&t>0?t:null}function Ke(i){var k,p,f,b,$;const t=((k=i.config)==null?void 0:k.toolCount)??((f=(p=i.config)==null?void 0:p.tools)==null?void 0:f.length),n=(($=(b=i.config)==null?void 0:b.disabledTools)==null?void 0:$.length)||0;if(t!=null&&t>0){const w=Math.max(0,t-n);return w>0?w:null}return null}function He(i){const t=i.originalToolName||i.name;return d.value.disabledTools.includes(t)}function pt(i,t){const n=i.originalToolName||i.name;t?d.value.disabledTools=d.value.disabledTools.filter(k=>k!==n):d.value.disabledTools.includes(n)||d.value.disabledTools.push(n)}function mt(){d.value.disabledTools=[],c.success("已全选所有工具")}function vt(){const i=B.value.map(n=>n.originalToolName||n.name),t=new Set(d.value.disabledTools);d.value.disabledTools=i.filter(n=>!t.has(n)),c.success("已反选工具")}function ce(i){return i.originalToolName||i.name}function xe(i){const t=ce(i),n=d.value.toolPatches[t];return(n==null?void 0:n.description)!==void 0&&n.description!==null&&n.description!==""?n.description:i.description||"暂无描述"}function Ge(i,t,n){var f;const k=ce(i),p=d.value.toolPatches[k];return((f=p==null?void 0:p.fieldDescriptions)==null?void 0:f[t])!==void 0&&p.fieldDescriptions[t]!==null&&p.fieldDescriptions[t]!==""?p.fieldDescriptions[t]:n||"暂无描述"}function We(i){const t=ce(i),n=d.value.toolPatches[t],k=n==null?void 0:n.description,p=i.description||"暂无描述";return k!=null&&k!==""&&k.trim()!==p.trim()}function Ze(i,t){var b,$,w,F;const n=ce(i),k=d.value.toolPatches[n],p=(b=k==null?void 0:k.fieldDescriptions)==null?void 0:b[t],f=((F=(w=($=i.inputSchema)==null?void 0:$.properties)==null?void 0:w[t])==null?void 0:F.description)||"暂无描述";return p!=null&&p!==""&&p.trim()!==f.trim()}function Qe(i,t,n,k){var p,f;if(t==="tool"){A.value=i,U.value=null;const b=B.value.find($=>$.name===i);q.value=xe(b),me.value="tool",le.value=ce(b)}else{U.value=i,A.value=null;const b=B.value.find($=>$.name===n);b&&((f=(p=b.inputSchema)==null?void 0:p.properties)!=null&&f[k])?q.value=Ge(b,k,b.inputSchema.properties[k].description||""):q.value="",me.value="field",le.value=b?ce(b):n||"",ve.value=k||""}}function je(i,t,n,k){var p,f,b,$;if(t==="tool"){const w=B.value.find(pe=>pe.name===i),F=w?ce(w):i,X=(w==null?void 0:w.description)||"暂无描述",Y=q.value.trim();Y===X.trim()||Y===""?d.value.toolPatches[F]&&(delete d.value.toolPatches[F].description,Object.keys(d.value.toolPatches[F]).length===0&&delete d.value.toolPatches[F]):(d.value.toolPatches[F]||(d.value.toolPatches[F]={}),d.value.toolPatches[F].description=Y),A.value=null,c.success("工具描述已保存")}else{const w=B.value.find(_e=>_e.name===n),F=w?ce(w):n||le.value,X=k||ve.value,Y=((b=(f=(p=w==null?void 0:w.inputSchema)==null?void 0:p.properties)==null?void 0:f[X])==null?void 0:b.description)||"暂无描述",pe=q.value.trim();pe===Y.trim()||pe===""?($=d.value.toolPatches[F])!=null&&$.fieldDescriptions&&(delete d.value.toolPatches[F].fieldDescriptions[X],Object.keys(d.value.toolPatches[F].fieldDescriptions).length===0&&delete d.value.toolPatches[F].fieldDescriptions,Object.keys(d.value.toolPatches[F]).length===0&&delete d.value.toolPatches[F]):(d.value.toolPatches[F]||(d.value.toolPatches[F]={}),d.value.toolPatches[F].fieldDescriptions||(d.value.toolPatches[F].fieldDescriptions={}),d.value.toolPatches[F].fieldDescriptions[X]=pe),U.value=null,c.success("字段描述已保存")}q.value="",le.value="",ve.value="",d.value.toolPatches=JSON.parse(JSON.stringify(d.value.toolPatches)),console.log("保存描述后的 toolPatches:",JSON.stringify(d.value.toolPatches,null,2))}function De(){A.value=null,U.value=null,q.value="",le.value="",ve.value=""}function Ye(i,t,n,k){var p;if(t==="tool"){const f=B.value.find($=>$.name===i),b=f?ce(f):i;d.value.toolPatches[b]&&(delete d.value.toolPatches[b].description,Object.keys(d.value.toolPatches[b]).length===0&&delete d.value.toolPatches[b])}else{const f=B.value.find(w=>w.name===n),b=f?ce(f):n||le.value,$=k||ve.value;(p=d.value.toolPatches[b])!=null&&p.fieldDescriptions&&(delete d.value.toolPatches[b].fieldDescriptions[$],Object.keys(d.value.toolPatches[b].fieldDescriptions||{}).length===0&&delete d.value.toolPatches[b].fieldDescriptions,Object.keys(d.value.toolPatches[b]||{}).length===0&&delete d.value.toolPatches[b])}c.success("已还原为原始描述")}function Xe(i){G.value.has(i)?G.value.delete(i):(G.value.clear(),G.value.add(i))}const g=j(null),s=j(""),h=j("{}");function W(){if(g.value)try{const i=JSON.parse(h.value);d.value.toolPatches[g.value.name]||(d.value.toolPatches[g.value.name]={}),d.value.toolPatches[g.value.name].description=s.value||void 0,d.value.toolPatches[g.value.name].inputSchema=i,c.success("Schema 修改已保存"),S.value="tools"}catch{c.error("JSON Schema 格式错误")}}async function Q(){var i,t,n,k;try{if(S.value==="config"&&x.value==="json")try{const $=JSON.parse(d.value.configStr||"{}");ze($)}catch{throw new Error("配置 JSON 格式错误")}if(await((i=H.value)==null?void 0:i.validate()),N.value=!0,B.value.length===0)try{const $={id:((t=K.value)==null?void 0:t.id)||Be(),name:d.value.name,type:d.value.type,namespace:d.value.namespace,env:be(d.value.env),config:{headers:be(d.value.headers)}};d.value.type==="npm"?($.package=d.value.package,$.version=d.value.version):d.value.type==="url"?$.url=d.value.url:d.value.type==="stdio"&&($.command=d.value.command,$.args=d.value.args);const w=await ne.post("/mcp/inspect",$);B.value=w.data.data.tools||[],B.value.length>0&&c.info(`自动获取到 ${B.value.length} 个工具`)}catch($){console.warn("自动获取工具列表失败:",$)}console.log("保存前的 toolPatches:",JSON.stringify(d.value.toolPatches,null,2));const p=qe();p.id=((n=K.value)==null?void 0:n.id)||Be(),console.log("保存的组件配置:",JSON.stringify(p,null,2)),console.log("组件 config.toolPatches:",JSON.stringify((k=p.config)==null?void 0:k.toolPatches,null,2));const f=[...r.config.components],b=f.findIndex($=>$.id===p.id);b!==-1?f[b]=p:f.push(p),l("update",{components:f}),y.value=!1,ae()}catch(p){console.error("保存错误:",p),c.error(p.message)}finally{N.value=!1}}async function de(){var i,t;C.value=!0,I.value={current:0,total:0,currentComponent:""};try{let n=[],k=[];if(E.value.trim()){const f=JSON.parse(E.value).mcpServers||{};k=Object.entries(f),I.value.total=k.length;for(let b=0;b<k.length;b++){const[$,w]=k[b];I.value.current=b+1,I.value.currentComponent=$;const F=!!w.url,X={headers:w.headers,disabledTools:w.disabledTools,toolPatches:w.toolPatches};w.transportType&&(X.transportType=w.transportType),w.type&&(X.type=w.type);const Y={id:Be(),name:$,type:F?"url":"stdio",url:w.url,command:w.command,args:w.args||[],env:w.env,config:X};try{const pe={...Y,config:{headers:w.headers||{}}},Se=(await ne.post("/mcp/inspect",pe)).data.data.tools||[];Se.length>0&&(X.tools=Se,Y.config=X,console.log(`[导入] 组件 ${$} 解析到 ${Se.length} 个工具`))}catch(pe){console.warn(`[导入] 组件 ${$} 获取工具列表失败:`,pe)}n.push(Y)}}else if(_.value.trim()){const p=JSON.parse(_.value),f=Array.isArray(p)?p:p.components;I.value.total=f.length;for(let b=0;b<f.length;b++){const $=f[b];I.value.current=b+1,I.value.currentComponent=$.name||`组件 ${b+1}`;const w={...$,id:Be()};if(!((i=w.config)!=null&&i.tools)&&(w.url||w.command||w.package))try{const F={...w,config:{...w.config,headers:((t=w.config)==null?void 0:t.headers)||{}}},Y=(await ne.post("/mcp/inspect",F)).data.data.tools||[];Y.length>0&&(w.config||(w.config={}),w.config.tools=Y,console.log(`[导入] 组件 ${w.name} 解析到 ${Y.length} 个工具`))}catch(F){console.warn(`[导入] 组件 ${w.name} 获取工具列表失败:`,F)}n.push(w)}}else throw new Error("请输入 JSON 内容");if(l("update",{components:[...r.config.components,...n]}),await new Promise(p=>setTimeout(p,800)),n.length>0){I.value.total=n.length,I.value.current=0;let p=0,f=0;for(let b=0;b<n.length;b++){const $=n[b];I.value.current=b+1,I.value.currentComponent=`正在同步工具: ${$.name}`;try{const w=await ne.post("/configs/sync-tools",{componentId:$.id});w.data.success?w.data.data.errors&&w.data.data.errors.length>0?(f++,console.warn(`[导入] 组件 ${$.name} 同步工具失败:`,w.data.data.errors.join("; "))):w.data.data.success>0&&(p++,console.log(`[导入] 组件 ${$.name} 同步了 ${w.data.data.success} 个工具`)):(f++,console.warn(`[导入] 组件 ${$.name} 同步工具失败:`,w.data.error))}catch(w){f++,console.warn(`[导入] 组件 ${$.name} 同步工具失败:`,w.message||w)}}p>0?c.success(`导入成功:${n.length} 个组件已添加,${p} 个组件的工具已同步`):f>0?c.warning(`导入完成:${n.length} 个组件已添加,但工具同步失败`):c.success(`导入成功:${n.length} 个组件已添加`)}T.value=!1,E.value="",_.value=""}catch(n){c.error(`导入失败: ${n.message}`)}finally{C.value=!1,I.value={current:0,total:0,currentComponent:""}}}function re(){const i={};r.config.components.forEach(f=>{var $,w,F;const b={env:f.env};if(f.type==="url")b.url=f.url,($=f.config)!=null&&$.headers&&(b.headers=f.config.headers);else{let X=f.command,Y=f.args||[];f.type==="npm"&&(X="npx",Y=["-y",f.package],f.version&&f.version!=="latest"&&(Y[1]=`${f.package}@${f.version}`)),b.command=X,b.args=Y}(w=f.config)!=null&&w.disabledTools&&(b.disabledTools=f.config.disabledTools),(F=f.config)!=null&&F.toolPatches&&(b.toolPatches=f.config.toolPatches),i[f.name]=b});const t=JSON.stringify({mcpServers:i},null,2),n=new Blob([t],{type:"application/json"}),k=URL.createObjectURL(n),p=document.createElement("a");p.href=k,p.download="cursor-mcp.json",p.click(),URL.revokeObjectURL(k),c.success("已导出 Cursor 格式配置")}function ae(){K.value=null,d.value={name:"",type:"npm",package:"",version:"",url:"",command:"",args:[],env:[],headers:[],disabledTools:[],toolPatches:{},namespace:"",extraConfig:{},rootExtra:{},configStr:"{}",disabled:!1},S.value="config",x.value="form",B.value=[],M.value="",A.value=null,U.value=null,q.value="",le.value="",ve.value=""}return ue(()=>y.value,i=>{i||ae()}),(i,t)=>(O(),R("div",Xo,[e.config.components&&e.config.components.length>0?(O(),R("div",en,[v(m(L),{type:"primary",size:"large",class:"add-component-btn",onClick:t[0]||(t[0]=n=>y.value=!0)},{icon:u(()=>[...t[31]||(t[31]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[32]||(t[32]=D(" 添加组件 ",-1))]),_:1}),o("div",tn,[v(m(L),{size:"large",class:"secondary-btn",onClick:t[1]||(t[1]=n=>T.value=!0)},{icon:u(()=>[...t[33]||(t[33]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[34]||(t[34]=D(" 导入 JSON ",-1))]),_:1}),v(m(L),{size:"large",class:"secondary-btn",onClick:re},{icon:u(()=>[...t[35]||(t[35]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[36]||(t[36]=D(" 导出配置 ",-1))]),_:1})])])):te("",!0),e.config.components&&e.config.components.length>0?(O(),R("div",on,[v(m(Zt),{class:"component-list","show-divider":!1},{default:u(()=>[(O(!0),R(ot,null,nt(e.config.components,n=>(O(),Ce(m(Yt),{key:n.id},{default:u(()=>[o("div",nn,[o("div",rn,[o("div",sn,[o("div",an,Z(n.name.charAt(0).toUpperCase()),1)]),o("div",ln,[o("div",un,[o("span",cn,Z(n.name),1),Je(n)!==null?(O(),Ce(m(at),{key:0,size:"small",type:"info"},{default:u(()=>[D(Z(Je(n))+" 工具 ",1)]),_:2},1024)):te("",!0),Ke(n)!==null?(O(),Ce(m(at),{key:1,size:"small",type:"success"},{default:u(()=>[D(Z(Ke(n))+" 可调用 ",1)]),_:2},1024)):te("",!0)])]),o("div",dn,[v(m(Qt),{size:"small",value:!n.disabled,"onUpdate:value":k=>Oe(n,k)},{checked:u(()=>[...t[37]||(t[37]=[D("启用",-1)])]),unchecked:u(()=>[...t[38]||(t[38]=[D("禁用",-1)])]),_:1},8,["value","onUpdate:value"]),v(m(L),{size:"small",loading:J.value[n.id],onClick:k=>P(n),title:"同步工具配置"},{icon:u(()=>[...t[39]||(t[39]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M1 4v6h6M23 20v-6h-6M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[40]||(t[40]=D(" 同步工具 ",-1))]),_:1},8,["loading","onClick"]),v(m(L),{size:"small",onClick:k=>Le(n)},{default:u(()=>[...t[41]||(t[41]=[D("配置",-1)])]),_:1},8,["onClick"]),v(m(L),{size:"small",type:"error",ghost:"",onClick:k=>ct(n.id)},{default:u(()=>[...t[42]||(t[42]=[D("移除",-1)])]),_:1},8,["onClick"])])]),n.config?(O(),R("div",pn)):te("",!0)])]),_:2},1024))),128))]),_:1})])):(O(),R("div",mn,[o("div",vn,[t[47]||(t[47]=It('<div class="empty-icon" data-v-ef266d75><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-ef266d75><path d="M12 2L2 7l10 5 10-5-10-5z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-ef266d75></path><path d="M2 17l10 5 10-5M2 12l10 5 10-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-ef266d75></path></svg></div><h3 class="empty-title" data-v-ef266d75>还没有添加 MCP 组件</h3><p class="empty-description" data-v-ef266d75>点击上方"添加组件"按钮开始添加你的第一个 MCP 组件,或者使用"导入 JSON"快速导入配置</p>',3)),o("div",gn,[v(m(L),{type:"primary",size:"large",onClick:t[2]||(t[2]=n=>y.value=!0)},{icon:u(()=>[...t[43]||(t[43]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[44]||(t[44]=D(" 添加组件 ",-1))]),_:1}),v(m(L),{size:"large",onClick:t[3]||(t[3]=n=>T.value=!0)},{icon:u(()=>[...t[45]||(t[45]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[46]||(t[46]=D(" 导入 JSON ",-1))]),_:1})])])])),v(m(st),{show:y.value,"onUpdate:show":t[27]||(t[27]=n=>y.value=n),preset:"card",bordered:!1,class:"component-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:u(()=>[o("div",fn,[t[48]||(t[48]=o("div",{class:"modal-icon"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"})])],-1)),o("div",null,[o("h3",yn,Z(K.value?"配置 MCP 组件":"添加 MCP 组件"),1),o("p",hn,Z(K.value?"修改组件配置和工具设置":"创建新的 MCP 服务组件"),1)])])]),footer:u(()=>[o("div",ur,[v(m(L),{size:"large",onClick:t[26]||(t[26]=n=>y.value=!1)},{default:u(()=>[...t[79]||(t[79]=[D("取消",-1)])]),_:1}),v(m(L),{type:"primary",size:"large",onClick:Q},{default:u(()=>[D(Z(K.value?"保存修改":"添加组件"),1)]),_:1})])]),default:u(()=>[o("div",wn,[v(m(Et),{value:S.value,"onUpdate:value":[t[25]||(t[25]=n=>S.value=n),ee],type:"line",animated:"",size:"large",class:"component-config-tabs"},{default:u(()=>[v(m(Ee),{name:"config",tab:"基础配置"},{default:u(()=>[o("div",bn,[o("div",kn,[v(m(Xt),{value:x.value,"onUpdate:value":t[4]||(t[4]=n=>x.value=n),size:"medium"},{default:u(()=>[v(m(St),{value:"form"},{default:u(()=>[...t[49]||(t[49]=[o("div",{class:"radio-btn-content"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"表单模式")],-1)])]),_:1}),v(m(St),{value:"json"},{default:u(()=>[...t[50]||(t[50]=[o("div",{class:"radio-btn-content"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("polyline",{points:"16 18 22 12 16 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),o("polyline",{points:"8 6 2 12 8 18",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"JSON 模式")],-1)])]),_:1})]),_:1},8,["value"])]),Tt(o("div",xn,[v(m(Rt),{ref_key:"formRef",ref:H,model:d.value,rules:ge,"label-placement":"top",size:"large"},{default:u(()=>[o("div",Cn,[t[54]||(t[54]=o("h4",{class:"section-title"},"基础信息",-1)),o("div",$n,[v(m(oe),{path:"name"},{label:u(()=>[...t[51]||(t[51]=[o("div",{class:"form-label"},[o("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"组件名称")],-1)])]),default:u(()=>[v(m(ie),{value:d.value.name,"onUpdate:value":t[5]||(t[5]=n=>d.value.name=n),placeholder:"例如: filesystem, github"},null,8,["value"])]),_:1}),v(m(oe),{path:"type"},{label:u(()=>[...t[52]||(t[52]=[o("div",{class:"form-label"},[o("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"组件类型")],-1)])]),default:u(()=>[v(m(Vt),{value:d.value.type,"onUpdate:value":t[6]||(t[6]=n=>d.value.type=n),options:Me},null,8,["value"])]),_:1}),v(m(oe),{path:"namespace"},{label:u(()=>[...t[53]||(t[53]=[o("div",{class:"form-label"},[o("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"命名空间(可选)")],-1)])]),default:u(()=>[v(m(ie),{value:d.value.namespace,"onUpdate:value":t[7]||(t[7]=n=>d.value.namespace=n),placeholder:"用于工具名前缀"},null,8,["value"])]),_:1})])]),d.value.type==="npm"?(O(),R("div",Tn,[t[55]||(t[55]=o("h4",{class:"section-title"},"NPM 配置",-1)),o("div",Sn,[v(m(oe),{path:"package",label:"NPM 包名",class:"col-span-2"},{default:u(()=>[v(m(ie),{value:d.value.package,"onUpdate:value":t[8]||(t[8]=n=>d.value.package=n),placeholder:"@modelcontextprotocol/server-filesystem"},null,8,["value"])]),_:1}),v(m(oe),{path:"version",label:"版本"},{default:u(()=>[v(m(ie),{value:d.value.version,"onUpdate:value":t[9]||(t[9]=n=>d.value.version=n),placeholder:"latest"},null,8,["value"])]),_:1})])])):te("",!0),d.value.type==="url"?(O(),R("div",Pn,[t[56]||(t[56]=o("h4",{class:"section-title"},"URL 配置",-1)),v(m(oe),{path:"url",label:"服务地址"},{default:u(()=>[v(m(ie),{value:d.value.url,"onUpdate:value":t[10]||(t[10]=n=>d.value.url=n),placeholder:"http://localhost:3000/mcp"},null,8,["value"])]),_:1}),v(m(oe),{label:"HTTP Headers"},{default:u(()=>[v(m(gt),{value:d.value.headers,"onUpdate:value":t[11]||(t[11]=n=>d.value.headers=n),preset:"pair","key-placeholder":"Header 名称","value-placeholder":"Header 值"},null,8,["value"])]),_:1})])):te("",!0),d.value.type==="stdio"?(O(),R("div",jn,[t[57]||(t[57]=o("h4",{class:"section-title"},"Stdio 配置",-1)),v(m(oe),{path:"command",label:"执行命令"},{default:u(()=>[v(m(ie),{value:d.value.command,"onUpdate:value":t[12]||(t[12]=n=>d.value.command=n),placeholder:"node, python, uvx"},null,8,["value"])]),_:1}),v(m(oe),{label:"命令行参数"},{default:u(()=>[v(m(gt),{value:d.value.args,"onUpdate:value":t[13]||(t[13]=n=>d.value.args=n),placeholder:"输入参数",min:0},null,8,["value"])]),_:1}),v(m(oe),{label:"环境变量"},{default:u(()=>[v(m(gt),{value:d.value.env,"onUpdate:value":t[14]||(t[14]=n=>d.value.env=n),preset:"pair","key-placeholder":"变量名","value-placeholder":"变量值"},null,8,["value"])]),_:1})])):te("",!0)]),_:1},8,["model"])],512),[[Pt,x.value==="form"]]),Tt(o("div",Nn,[v(m(Pe),{type:"info",bordered:!1,class:"json-alert"},{icon:u(()=>[...t[58]||(t[58]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[59]||(t[59]=D(" 直接编辑组件的完整 JSON 配置,切换回表单模式或保存时会自动同步 ",-1))]),_:1}),o("div",An,[v(Re,{modelValue:d.value.configStr,"onUpdate:modelValue":t[15]||(t[15]=n=>d.value.configStr=n),language:"json",options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},automaticLayout:!0},style:{"min-height":"400px","border-radius":"12px",overflow:"hidden"}},null,8,["modelValue"])])],512),[[Pt,x.value==="json"]])])]),_:1}),v(m(Ee),{name:"tools",tab:"工具管理"},{default:u(()=>[o("div",Mn,[o("div",On,[v(m(Pe),{type:"info",bordered:!1,class:"tools-info-alert"},{icon:u(()=>[...t[60]||(t[60]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[61]||(t[61]=D(' 工具列表来自已保存的配置。您可以禁用特定工具或编辑其 Schema。点击"同步工具"可从 MCP 组件更新工具列表。双击工具描述或字段描述可进行编辑。 ',-1))]),_:1}),o("div",zn,[v(m(L),{type:"primary",size:"large",loading:z.value,onClick:dt,class:"sync-btn"},{icon:u(()=>[...t[62]||(t[62]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M1 4v6h6M23 20v-6h-6M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[D(" "+Z(z.value?"同步中...":"同步工具配置"),1)]),_:1},8,["loading"]),B.value.length>0?(O(),R("div",Dn,[v(m(L),{size:"medium",onClick:mt,class:"batch-btn"},{default:u(()=>[...t[63]||(t[63]=[D(" 全选 ",-1)])]),_:1}),v(m(L),{size:"medium",onClick:vt,class:"batch-btn"},{default:u(()=>[...t[64]||(t[64]=[D(" 反选 ",-1)])]),_:1})])):te("",!0)])]),B.value.length>0?(O(),R("div",_n,[o("div",Un,[(O(!0),R(ot,null,nt(B.value,n=>(O(),R("div",{key:n.name,class:we(["tool-card",{"tool-expanded":G.value.has(n.name)}]),onClick:k=>Xe(n.name)},[o("div",In,[o("div",En,[v(m(Ft),{checked:!He(n),onClick:t[16]||(t[16]=fe(()=>{},["stop"])),"onUpdate:checked":k=>pt(n,k),size:"large"},null,8,["checked","onUpdate:checked"])]),o("div",Rn,[v(m(eo),{trigger:"hover","show-arrow":!0,placement:"top"},{trigger:u(()=>[o("h5",{class:"tool-name",title:xe(n)},Z(n.originalToolName||n.name),9,Vn)]),default:u(()=>[o("div",Fn,Z(xe(n)),1)]),_:2},1024)]),o("div",qn,[o("div",{class:we(["expand-icon",{expanded:G.value.has(n.name)}])},[...t[65]||(t[65]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("polyline",{points:"6 9 12 15 18 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],2)])]),v(m(to),{show:G.value.has(n.name)},{default:u(()=>{var k;return[o("div",{class:"tool-details",onClick:t[21]||(t[21]=fe(()=>{},["stop"]))},[o("div",Ln,[o("div",{class:we(["detail-content",{"has-custom-description":We(n)}])},[A.value!==n.name?(O(),R("div",{key:0,onDblclick:fe(p=>Qe(n.name,"tool"),["stop"]),class:"description-text-editable"},Z(xe(n)),41,Jn)):(O(),Ce(m(ie),{key:1,value:q.value,"onUpdate:value":t[17]||(t[17]=p=>q.value=p),type:"textarea",rows:3,onBlur:p=>je(n.name,"tool"),onKeydown:[et(fe(p=>je(n.name,"tool"),["ctrl"]),["enter"]),et(De,["esc"])],class:"description-input",placeholder:"输入工具描述",onClick:t[18]||(t[18]=fe(()=>{},["stop"]))},null,8,["value","onBlur","onKeydown"])),We(n)&&A.value!==n.name?(O(),R("div",Kn,[t[67]||(t[67]=o("span",{class:"custom-badge",title:"已自定义描述"},"已修改",-1)),v(m(L),{text:"",size:"small",onClick:fe(p=>Ye(n.name,"tool"),["stop"]),class:"reset-btn"},{default:u(()=>[...t[66]||(t[66]=[D(" 还原 ",-1)])]),_:1},8,["onClick"])])):te("",!0)],2)]),(k=n.inputSchema)!=null&&k.properties&&Object.keys(n.inputSchema.properties).length>0?(O(),R("div",Hn,[t[70]||(t[70]=o("div",{class:"detail-section-header"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),o("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"})]),o("h6",null,"参数 Schema")],-1)),o("div",Gn,[(O(!0),R(ot,null,nt(n.inputSchema.properties,(p,f)=>{var b;return O(),R("div",{key:String(f),class:"param-item"},[o("div",Wn,[o("span",Zn,Z(f),1),p.type?(O(),R("span",Qn,Z(p.type),1)):te("",!0),(b=n.inputSchema.required)!=null&&b.includes(String(f))?(O(),R("span",Yn,"必填")):te("",!0)]),o("div",{class:we(["param-description-wrapper",{"has-custom-description":Ze(n,String(f))}])},[U.value!==`${n.name}.${String(f)}`?(O(),R("div",{key:0,class:"param-description",onDblclick:fe($=>Qe(`${n.name}.${String(f)}`,"field",n.name,String(f)),["stop"])},Z(Ge(n,String(f),p.description)),41,Xn)):(O(),Ce(m(ie),{key:1,value:q.value,"onUpdate:value":t[19]||(t[19]=$=>q.value=$),type:"textarea",rows:2,onBlur:$=>je(`${n.name}.${String(f)}`,"field",n.name,String(f)),onKeydown:[et(fe($=>je(`${n.name}.${String(f)}`,"field",n.name,String(f)),["ctrl"]),["enter"]),et(De,["esc"])],class:"description-input",placeholder:"输入字段描述",onClick:t[20]||(t[20]=fe(()=>{},["stop"]))},null,8,["value","onBlur","onKeydown"])),Ze(n,String(f))&&U.value!==`${n.name}.${String(f)}`?(O(),R("div",er,[t[69]||(t[69]=o("span",{class:"custom-badge",title:"已自定义描述"},"已修改",-1)),v(m(L),{text:"",size:"small",onClick:fe($=>Ye(`${n.name}.${String(f)}`,"field",n.name,String(f)),["stop"]),class:"reset-btn"},{default:u(()=>[...t[68]||(t[68]=[D(" 还原 ",-1)])]),_:1},8,["onClick"])])):te("",!0)],2)])}),128))])])):(O(),R("div",tr,[...t[71]||(t[71]=[o("div",{class:"empty-params"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),o("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})]),o("p",null,"该工具没有输入参数")],-1)])]))])]}),_:2},1032,["show"])],10,Bn))),128))])])):V.value?te("",!0):(O(),R("div",or,[...t[72]||(t[72]=[o("div",{class:"empty-content"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("h4",null,"暂无工具列表"),o("p",null,'点击上方"同步工具配置"按钮从 MCP 组件获取工具列表')],-1)])])),M.value?(O(),R("div",nr,[v(m(Pe),{type:"error",bordered:!1},{icon:u(()=>[...t[73]||(t[73]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),header:u(()=>[...t[74]||(t[74]=[D("连接失败",-1)])]),default:u(()=>[D(" "+Z(M.value),1)]),_:1})])):te("",!0)])]),_:1}),S.value==="schema"?(O(),Ce(m(Ee),{key:0,name:"schema",tab:"Schema 编辑","display-directive":"show"},{default:u(()=>{var n,k;return[o("div",rr,[v(m(Pe),{type:"info",bordered:!1,class:"schema-info-alert"},{icon:u(()=>[...t[75]||(t[75]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[76]||(t[76]=D(" 重写工具的提示词。留空表示使用原始描述。修改后将覆盖工具的默认提示词 ",-1))]),_:1}),o("div",sr,[o("div",ar,[o("h4",null,Z((n=g.value)==null?void 0:n.name),1),o("p",lr,"原始描述: "+Z((k=g.value)==null?void 0:k.description),1)]),v(m(oe),{label:"工具名称"},{default:u(()=>{var p;return[v(m(ie),{value:(p=g.value)==null?void 0:p.name,disabled:""},null,8,["value"])]}),_:1}),v(m(oe),{label:"自定义描述"},{default:u(()=>[v(m(ie),{value:s.value,"onUpdate:value":t[22]||(t[22]=p=>s.value=p),type:"textarea",rows:4,placeholder:"输入自定义描述(留空使用原始描述)"},null,8,["value"])]),_:1}),v(m(oe),{label:"完整 Schema (JSON)"},{default:u(()=>[v(Re,{modelValue:h.value,"onUpdate:modelValue":t[23]||(t[23]=p=>h.value=p),language:"json",options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,padding:{top:16,bottom:16}},style:{"min-height":"300px","border-radius":"12px",overflow:"hidden"}},null,8,["modelValue"])]),_:1}),o("div",ir,[v(m(L),{onClick:t[24]||(t[24]=p=>S.value="tools"),size:"large"},{default:u(()=>[...t[77]||(t[77]=[D("取消",-1)])]),_:1}),v(m(L),{type:"primary",onClick:W,size:"large"},{default:u(()=>[...t[78]||(t[78]=[D(" 保存 Schema ",-1)])]),_:1})])])])]}),_:1})):te("",!0)]),_:1},8,["value"])])]),_:1},8,["show"]),v(m(st),{show:T.value,"onUpdate:show":t[30]||(t[30]=n=>T.value=n),preset:"card",title:"导入组件 JSON",bordered:!1,class:"import-modal",style:{width:"800px",maxWidth:"90vw"}},{footer:u(()=>[o("div",pr,[v(m(L),{size:"large",onClick:t[29]||(t[29]=n=>T.value=!1),disabled:C.value},{default:u(()=>[...t[83]||(t[83]=[D("取消",-1)])]),_:1},8,["disabled"]),v(m(L),{type:"primary",size:"large",onClick:de,loading:C.value},{default:u(()=>[D(Z(C.value?`导入中... (${I.value.current}/${I.value.total})`:"导入"),1)]),_:1},8,["loading"])])]),default:u(()=>[v(m(Pe),{type:"info",bordered:!1,style:{"margin-bottom":"20px"}},{icon:u(()=>[...t[80]||(t[80]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[t[81]||(t[81]=D(" 粘贴 Cursor MCP 配置的 JSON(mcpServers 对象) ",-1))]),_:1}),C.value?(O(),Ce(m(Pe),{key:0,type:"info",bordered:!1,style:{"margin-bottom":"20px"}},{icon:u(()=>[v(m(no),{size:"small"})]),default:u(()=>[o("div",null,[t[82]||(t[82]=o("div",{style:{"margin-bottom":"8px"}},[o("strong",null,"正在导入组件...")],-1)),o("div",cr,[D(Z(I.value.currentComponent)+" ",1),I.value.total>0?(O(),R("span",dr," ("+Z(I.value.current)+"/"+Z(I.value.total)+") ",1)):te("",!0)]),I.value.total>0?(O(),Ce(m(oo),{key:0,percentage:Math.round(I.value.current/I.value.total*100),"show-indicator":!1,style:{"margin-top":"8px"}},null,8,["percentage"])):te("",!0)])]),_:1})):te("",!0),v(Re,{modelValue:E.value,"onUpdate:modelValue":t[28]||(t[28]=n=>E.value=n),language:"json",options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,padding:{top:16,bottom:16}},style:{height:"400px","border-radius":"12px",overflow:"hidden"}},null,8,["modelValue"])]),_:1},8,["show"])]))}}),vs=$t(mr,[["__scopeId","data-v-ef266d75"]]);function rt(e){return!e||typeof e!="string"?"Unknown":e.split(/[^a-zA-Z0-9_$]+/).filter(r=>r.length>0).map(r=>r.split("_").filter(l=>l.length>0).map(l=>l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()).join("")).join("")||"Unknown"}function Bt(e){return rt(e)}function he(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?`"${e}"`:`"${e.replace(/"/g,'\\"')}"`}function Ht(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?e:`"${e.replace(/"/g,'\\"')}"`}function Ae(e,a="",r=0){if(r>10)return console.warn("JSON Schema conversion reached maximum depth, returning any"),"any";if(!e||typeof e!="object")return"any";try{if(e.type)switch(e.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return e.items?`Array<${Ae(e.items,a,r+1)}>`:"any[]";case"object":if(e.properties){const l=[],c=Array.isArray(e.required)?e.required:[];for(const[y,S]of Object.entries(e.properties))try{const x=S,T=Ht(y),V=c.includes(y)?"":"?",z=Ae(x,a+" ",r+1),M=x&&typeof x=="object"&&x.description?`/** ${String(x.description).replace(/\*\//g,"* /")} */
|
|
12
|
-
${a} `:"";l.push(`${M}${T}${V}: ${z};`)}catch(x){console.warn(`Failed to process property ${y}:`,x)}return l.length===0?"Record<string, any>":`{
|
|
13
|
-
${a} ${l.join(`
|
|
14
|
-
${a} `)}
|
|
15
|
-
${a}}`}return"Record<string, any>";default:return"any"}if(e.anyOf&&Array.isArray(e.anyOf)){const l=e.anyOf.map(c=>Ae(c,a,r+1)).filter(c=>c&&c!=="any");return l.length>0?l.join(" | "):"any"}if(e.oneOf&&Array.isArray(e.oneOf)){const l=e.oneOf.map(c=>Ae(c,a,r+1)).filter(c=>c&&c!=="any");return l.length>0?l.join(" | "):"any"}if(e.allOf&&Array.isArray(e.allOf)){const l={type:"object",properties:{},required:[]};for(const c of e.allOf)c&&typeof c=="object"&&c.properties&&(l.properties={...l.properties,...c.properties}),c&&typeof c=="object"&&Array.isArray(c.required)&&(l.required=[...l.required||[],...c.required]);return Ae(l,a,r+1)}return Array.isArray(e.enum)?e.enum.map(l=>typeof l=="string"?he(l):JSON.stringify(l)).join(" | "):"any"}catch(l){return console.warn("Error converting JSON Schema to TypeScript:",l,e),"any"}}function kt(e){try{const{config:a,mcpTools:r=[],tables:l=[]}=e,c=a.variables.length>0?`type VarName = ${a.variables.map(C=>he(C.name)).join(" | ")};
|
|
16
|
-
|
|
17
|
-
`:"",y=l.map(C=>{const ee=`${rt(C.name)}TableRow`,B=C.columns.map(G=>{const A=Ht(G.name),q={string:"string",number:"number",boolean:"boolean",date:"string",json:"any"}[G.type]||"any",me=G.nullable?`${q} | null`:q,le=G.nullable?"?":"";return` ${A}${le}: ${me};`}).join(`
|
|
18
|
-
`);return`type ${ee} = {
|
|
19
|
-
${B}
|
|
20
|
-
};
|
|
21
|
-
`}).join(`
|
|
22
|
-
`),S=l.length>0?`type TableName = ${l.map(C=>he(C.name)).join(" | ")};
|
|
23
|
-
|
|
24
|
-
`:"",x=r.length>0?`type ToolName = ${r.map(C=>{const I=C.originalToolName||C.name;return he(I)}).join(" | ")};
|
|
25
|
-
|
|
26
|
-
`:"",T=new Map;r.filter(C=>C&&C.name).forEach(C=>{try{const I=C.name||"Unknown",ee=Ae(C.inputSchema||{type:"object",properties:{}}),B=Bt(I);if(!B||B.trim()===""){console.warn(`[Context Types] Invalid type name for tool: ${I}`);return}const G=`${B}Args`;if(!T.has(G))T.set(G,`type ${G} = ${ee};`);else{const A=T.get(G);A&&A!==`type ${G} = ${ee};`&&console.warn(`[Context Types] Type ${G} already exists with different definition for tool: ${I}`)}}catch(I){console.warn(`[Context Types] Failed to generate type for tool ${C==null?void 0:C.name}:`,I)}});const N=Array.from(T.values()).join(`
|
|
27
|
-
`),V=N?`${N}
|
|
28
|
-
|
|
29
|
-
`:"",z=r.filter(C=>C&&C.name).map(C=>{try{const I=C.originalToolName||C.name,ee=he(I),B=C.name||"Unknown",G=Bt(B);if(!G||G.trim()==="")return console.warn(`[Context Types] Invalid type name for tool: ${B}, skipping overload`),null;const A=`${G}Args`;return T.has(A)||console.warn(`[Context Types] Type ${A} not found in type definitions for tool: ${B}`),`${C.description?` /**
|
|
30
|
-
* ${C.description.replace(/\*\//g,"* /")}
|
|
31
|
-
*
|
|
32
|
-
* @param toolName - 工具名称(原始名称,不带命名空间)
|
|
33
|
-
* @param args - 工具参数
|
|
34
|
-
* @returns 工具执行结果
|
|
35
|
-
*/
|
|
36
|
-
`:" "}callTool(toolName: ${ee}, args: ${A}): Promise<any>;`}catch(I){return console.warn(`Failed to generate overload for tool ${C==null?void 0:C.name}:`,I),null}}).filter(C=>C!==null).join(`
|
|
37
|
-
`),M=r.length>0?`${z}
|
|
38
|
-
/**
|
|
39
|
-
* 调用 MCP 工具
|
|
40
|
-
*
|
|
41
|
-
* @param toolName - 工具名称
|
|
42
|
-
* @param args - 工具参数
|
|
43
|
-
* @returns 工具执行结果
|
|
44
|
-
*/
|
|
45
|
-
callTool(toolName: ToolName, args: any): Promise<any>;`:`/**
|
|
46
|
-
* 调用 MCP 工具
|
|
47
|
-
*
|
|
48
|
-
* @param toolName - 工具名称
|
|
49
|
-
* @param args - 工具参数
|
|
50
|
-
* @returns 工具执行结果
|
|
51
|
-
*/
|
|
52
|
-
callTool(toolName: string, args: any): Promise<any>;`,K=a.variables.length>0?"get(name: VarName): string;":"get(name: string): string;",H=l.map(C=>{const ee=`${rt(C.name)}TableRow`;return` /**
|
|
53
|
-
* 获取指定表的所有数据行
|
|
54
|
-
*
|
|
55
|
-
* @param tableName - 表名
|
|
56
|
-
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* // 获取 users 表的所有数据
|
|
60
|
-
* const allUsers = await context.tables.get('users');
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* // 遍历所有用户
|
|
64
|
-
* const users = await context.tables.get('users');
|
|
65
|
-
* for (const user of users) {
|
|
66
|
-
* console.log(user.name, user.email);
|
|
67
|
-
* }
|
|
68
|
-
*/
|
|
69
|
-
get(tableName: ${he(C.name)}): Promise<Array<${ee}>>;`}).join(`
|
|
70
|
-
`),E=l.length>0?`${H}
|
|
71
|
-
/**
|
|
72
|
-
* 获取指定表的所有数据行
|
|
73
|
-
*
|
|
74
|
-
* @param tableName - 表名
|
|
75
|
-
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* // 获取 users 表的所有数据
|
|
79
|
-
* const allUsers = await context.tables.get('users');
|
|
80
|
-
*/
|
|
81
|
-
get(tableName: TableName): Promise<Array<Record<string, any>>>;`:`/**
|
|
82
|
-
* 获取指定表的所有数据行
|
|
83
|
-
*
|
|
84
|
-
* @param tableName - 表名
|
|
85
|
-
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* // 获取 users 表的所有数据
|
|
89
|
-
* const allUsers = await context.tables.get('users');
|
|
90
|
-
*/
|
|
91
|
-
get(tableName: string): Promise<Array<Record<string, any>>>;`,_=l.map(C=>{const ee=`${rt(C.name)}TableRow`;return` /**
|
|
92
|
-
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
93
|
-
*
|
|
94
|
-
* @param tableName - 表名
|
|
95
|
-
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
96
|
-
* @returns 返回符合过滤条件的数据行数组
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* // 查询所有年龄大于 18 的用户
|
|
100
|
-
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* // 查询所有活跃用户
|
|
104
|
-
* const activeUsers = await context.tables.query('users', (row) => row.isActive === true);
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* // 不传过滤函数,等同于 get(),返回所有数据
|
|
108
|
-
* const allUsers = await context.tables.query('users');
|
|
109
|
-
*/
|
|
110
|
-
query(tableName: ${he(C.name)}, filter?: (row: ${ee}) => boolean): Promise<Array<${ee}>>;`}).join(`
|
|
111
|
-
`),J=l.length>0?`${_}
|
|
112
|
-
/**
|
|
113
|
-
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
114
|
-
*
|
|
115
|
-
* @param tableName - 表名
|
|
116
|
-
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
117
|
-
* @returns 返回符合过滤条件的数据行数组
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* // 查询所有年龄大于 18 的用户
|
|
121
|
-
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
122
|
-
*/
|
|
123
|
-
query(tableName: TableName, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;`:`/**
|
|
124
|
-
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
125
|
-
*
|
|
126
|
-
* @param tableName - 表名
|
|
127
|
-
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
128
|
-
* @returns 返回符合过滤条件的数据行数组
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* // 查询所有年龄大于 18 的用户
|
|
132
|
-
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
133
|
-
*/
|
|
134
|
-
query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;`;return`
|
|
135
|
-
${c}${y}${S}${V}${x}declare interface Context {
|
|
136
|
-
user: {
|
|
137
|
-
id: string;
|
|
138
|
-
email: string;
|
|
139
|
-
role: 'admin' | 'user';
|
|
140
|
-
createdAt: Date;
|
|
141
|
-
updatedAt: Date;
|
|
142
|
-
};
|
|
143
|
-
http: {
|
|
144
|
-
get(url: string, options?: any): Promise<any>;
|
|
145
|
-
post(url: string, data?: any, options?: any): Promise<any>;
|
|
146
|
-
put(url: string, data?: any, options?: any): Promise<any>;
|
|
147
|
-
delete(url: string, options?: any): Promise<any>;
|
|
148
|
-
};
|
|
149
|
-
fs: {
|
|
150
|
-
readFile(path: string): Promise<string>;
|
|
151
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
152
|
-
exists(path: string): Promise<boolean>;
|
|
153
|
-
listDir(path: string): Promise<string[]>;
|
|
154
|
-
mkdir(path: string): Promise<void>;
|
|
155
|
-
};
|
|
156
|
-
cmd: {
|
|
157
|
-
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
158
|
-
};
|
|
159
|
-
utils: {
|
|
160
|
-
md5(input: string): string;
|
|
161
|
-
};
|
|
162
|
-
ripgrep: {
|
|
163
|
-
/**
|
|
164
|
-
* 搜索文件内容
|
|
165
|
-
*/
|
|
166
|
-
search(
|
|
167
|
-
pattern: string,
|
|
168
|
-
options?: {
|
|
169
|
-
/** 工作目录(相对于用户隔离目录) */
|
|
170
|
-
cwd?: string;
|
|
171
|
-
/** 是否大小写敏感 */
|
|
172
|
-
caseSensitive?: boolean;
|
|
173
|
-
/** 是否启用多行匹配 */
|
|
174
|
-
multiline?: boolean;
|
|
175
|
-
/** 文件过滤模式(glob 模式数组) */
|
|
176
|
-
files?: string[];
|
|
177
|
-
/** 排除文件模式(glob 模式数组) */
|
|
178
|
-
excludeFiles?: string[];
|
|
179
|
-
/** 每个文件的最大匹配数 */
|
|
180
|
-
maxCount?: number;
|
|
181
|
-
/** 总结果数的最大限制 */
|
|
182
|
-
maxResults?: number;
|
|
183
|
-
/** 最大递归深度 */
|
|
184
|
-
maxDepth?: number;
|
|
185
|
-
/** 匹配行之前显示的行数 */
|
|
186
|
-
contextBefore?: number;
|
|
187
|
-
/** 匹配行之后显示的行数 */
|
|
188
|
-
contextAfter?: number;
|
|
189
|
-
/** 匹配行前后显示的行数(等同于同时设置 contextBefore 和 contextAfter) */
|
|
190
|
-
context?: number;
|
|
191
|
-
/** 将模式视为固定字符串而非正则表达式 */
|
|
192
|
-
fixedStrings?: boolean;
|
|
193
|
-
/** 只匹配完整的单词 */
|
|
194
|
-
wordRegexp?: boolean;
|
|
195
|
-
/** 文件类型过滤(如:['js', 'ts']) */
|
|
196
|
-
fileTypes?: string[];
|
|
197
|
-
/** 排除的文件类型 */
|
|
198
|
-
excludeTypes?: string[];
|
|
199
|
-
/** 只返回包含匹配的文件名 */
|
|
200
|
-
filesWithMatches?: boolean;
|
|
201
|
-
/** 只返回每个文件的匹配数量 */
|
|
202
|
-
count?: boolean;
|
|
203
|
-
/** 忽略 .gitignore 和 .ignore 文件 */
|
|
204
|
-
noIgnore?: boolean;
|
|
205
|
-
/** 智能大小写:如果模式包含大写字母则大小写敏感 */
|
|
206
|
-
smartCase?: boolean;
|
|
207
|
-
}
|
|
208
|
-
): Promise<Array<{ file: string; line: number; text: string; column?: number; contextBefore?: string[]; contextAfter?: string[] }>>;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* 通过文件名模式搜索文件
|
|
212
|
-
*/
|
|
213
|
-
searchByPath(
|
|
214
|
-
pattern: string,
|
|
215
|
-
options?: {
|
|
216
|
-
/** 工作目录(相对于用户隔离目录) */
|
|
217
|
-
cwd?: string;
|
|
218
|
-
/** 是否大小写敏感 */
|
|
219
|
-
caseSensitive?: boolean;
|
|
220
|
-
/** 最大递归深度 */
|
|
221
|
-
maxDepth?: number;
|
|
222
|
-
/** 文件类型过滤(如:['js', 'ts']) */
|
|
223
|
-
fileTypes?: string[];
|
|
224
|
-
/** 排除的文件类型 */
|
|
225
|
-
excludeTypes?: string[];
|
|
226
|
-
/** 排除文件模式(glob 模式数组) */
|
|
227
|
-
excludeFiles?: string[];
|
|
228
|
-
/** 总结果数的最大限制 */
|
|
229
|
-
maxResults?: number;
|
|
230
|
-
/** 忽略 .gitignore 和 .ignore 文件 */
|
|
231
|
-
noIgnore?: boolean;
|
|
232
|
-
}
|
|
233
|
-
): Promise<string[]>;
|
|
234
|
-
};
|
|
235
|
-
mcp: {
|
|
236
|
-
${M}
|
|
237
|
-
listTools(): Promise<string[]>;
|
|
238
|
-
};
|
|
239
|
-
vars: {
|
|
240
|
-
${K}
|
|
241
|
-
has(name: string): boolean;
|
|
242
|
-
getAll(): Record<string, string>;
|
|
243
|
-
set(name: string, value: string, description?: string): void;
|
|
244
|
-
};
|
|
245
|
-
log: {
|
|
246
|
-
info(message: string, ...args: any[]): void;
|
|
247
|
-
error(message: string, ...args: any[]): void;
|
|
248
|
-
warn(message: string, ...args: any[]): void;
|
|
249
|
-
debug(message: string, ...args: any[]): void;
|
|
250
|
-
};
|
|
251
|
-
tables: {
|
|
252
|
-
/**
|
|
253
|
-
* 列出当前用户的所有表定义
|
|
254
|
-
*
|
|
255
|
-
* @returns 返回表定义数组,每个表定义包含:
|
|
256
|
-
* - id: 表的唯一标识符
|
|
257
|
-
* - name: 表名
|
|
258
|
-
* - description: 表的描述(可选)
|
|
259
|
-
* - columns: 列定义数组,每个列包含 name(列名)、type(类型)、nullable(是否可为空)
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* // 获取所有表定义
|
|
263
|
-
* const tables = await context.tables.list();
|
|
264
|
-
* console.log('共有', tables.length, '张表');
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* // 遍历所有表并打印表名和列信息
|
|
268
|
-
* const tables = await context.tables.list();
|
|
269
|
-
* for (const table of tables) {
|
|
270
|
-
* console.log('表名:', table.name);
|
|
271
|
-
* console.log('列数:', table.columns.length);
|
|
272
|
-
* table.columns.forEach(col => {
|
|
273
|
-
* console.log(' -', col.name + ':', col.type + (col.nullable ? ' (可为空)' : ''));
|
|
274
|
-
* });
|
|
275
|
-
* }
|
|
276
|
-
*/
|
|
277
|
-
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
278
|
-
${E}
|
|
279
|
-
${J}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
`}catch(a){return console.error("Error generating context type definition:",a),`
|
|
283
|
-
declare interface Context {
|
|
284
|
-
user: {
|
|
285
|
-
id: string;
|
|
286
|
-
email: string;
|
|
287
|
-
role: 'admin' | 'user';
|
|
288
|
-
createdAt: Date;
|
|
289
|
-
updatedAt: Date;
|
|
290
|
-
};
|
|
291
|
-
http: {
|
|
292
|
-
get(url: string, options?: any): Promise<any>;
|
|
293
|
-
post(url: string, data?: any, options?: any): Promise<any>;
|
|
294
|
-
put(url: string, data?: any, options?: any): Promise<any>;
|
|
295
|
-
delete(url: string, options?: any): Promise<any>;
|
|
296
|
-
};
|
|
297
|
-
fs: {
|
|
298
|
-
readFile(path: string): Promise<string>;
|
|
299
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
300
|
-
exists(path: string): Promise<boolean>;
|
|
301
|
-
listDir(path: string): Promise<string[]>;
|
|
302
|
-
mkdir(path: string): Promise<void>;
|
|
303
|
-
};
|
|
304
|
-
cmd: {
|
|
305
|
-
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
306
|
-
};
|
|
307
|
-
utils: {
|
|
308
|
-
md5(input: string): string;
|
|
309
|
-
};
|
|
310
|
-
mcp: {
|
|
311
|
-
callTool(toolName: string, args: any): Promise<any>;
|
|
312
|
-
listTools(): Promise<string[]>;
|
|
313
|
-
};
|
|
314
|
-
vars: {
|
|
315
|
-
get(name: string): string;
|
|
316
|
-
has(name: string): boolean;
|
|
317
|
-
getAll(): Record<string, string>;
|
|
318
|
-
set(name: string, value: string, description?: string): void;
|
|
319
|
-
};
|
|
320
|
-
log: {
|
|
321
|
-
info(message: string, ...args: any[]): void;
|
|
322
|
-
error(message: string, ...args: any[]): void;
|
|
323
|
-
warn(message: string, ...args: any[]): void;
|
|
324
|
-
debug(message: string, ...args: any[]): void;
|
|
325
|
-
};
|
|
326
|
-
tables: {
|
|
327
|
-
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
328
|
-
get(tableName: string): Promise<Array<Record<string, any>>>;
|
|
329
|
-
query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
`}}function vr(e){try{const{config:a,mcpTools:r=[],tables:l=[]}=e,c=a.variables.length>0?`type VarName = ${a.variables.map(z=>he(z.name)).join(" | ")};
|
|
333
|
-
|
|
334
|
-
`:"",y=l.length>0?`type TableName = ${l.map(z=>he(z.name)).join(" | ")};
|
|
335
|
-
|
|
336
|
-
`:"",S=r.length>0?`type ToolName = ${r.map(z=>{const M=z.originalToolName||z.name;return he(M)}).join(" | ")};
|
|
337
|
-
|
|
338
|
-
`:"",x=a.variables.length>0?"get(name: VarName): string;":"get(name: string): string;",T=l.length>0?"get(tableName: TableName): Promise<Array<Record<string, any>>>;":"get(tableName: string): Promise<Array<Record<string, any>>>;",N=l.length>0?"query(tableName: TableName, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;":"query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;",V=r.length>0?"callTool(toolName: ToolName, args: any): Promise<any>;":"callTool(toolName: string, args: any): Promise<any>;";return`
|
|
339
|
-
${c}${y}${S}declare interface Context {
|
|
340
|
-
user: {
|
|
341
|
-
id: string;
|
|
342
|
-
email: string;
|
|
343
|
-
role: 'admin' | 'user';
|
|
344
|
-
createdAt: Date;
|
|
345
|
-
updatedAt: Date;
|
|
346
|
-
};
|
|
347
|
-
http: {
|
|
348
|
-
get(url: string, options?: any): Promise<any>;
|
|
349
|
-
post(url: string, data?: any, options?: any): Promise<any>;
|
|
350
|
-
put(url: string, data?: any, options?: any): Promise<any>;
|
|
351
|
-
delete(url: string, options?: any): Promise<any>;
|
|
352
|
-
};
|
|
353
|
-
fs: {
|
|
354
|
-
readFile(path: string): Promise<string>;
|
|
355
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
356
|
-
exists(path: string): Promise<boolean>;
|
|
357
|
-
listDir(path: string): Promise<string[]>;
|
|
358
|
-
mkdir(path: string): Promise<void>;
|
|
359
|
-
};
|
|
360
|
-
cmd: {
|
|
361
|
-
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
362
|
-
};
|
|
363
|
-
utils: {
|
|
364
|
-
md5(input: string): string;
|
|
365
|
-
};
|
|
366
|
-
ripgrep: {
|
|
367
|
-
search(pattern: string, options?: any): Promise<Array<{ file: string; line: number; text: string; column?: number; contextBefore?: string[]; contextAfter?: string[] }>>;
|
|
368
|
-
searchByPath(pattern: string, options?: any): Promise<string[]>;
|
|
369
|
-
};
|
|
370
|
-
mcp: {
|
|
371
|
-
${V}
|
|
372
|
-
listTools(): Promise<string[]>;
|
|
373
|
-
};
|
|
374
|
-
vars: {
|
|
375
|
-
${x}
|
|
376
|
-
has(name: string): boolean;
|
|
377
|
-
getAll(): Record<string, string>;
|
|
378
|
-
set(name: string, value: string, description?: string): void;
|
|
379
|
-
};
|
|
380
|
-
log: {
|
|
381
|
-
info(message: string, ...args: any[]): void;
|
|
382
|
-
error(message: string, ...args: any[]): void;
|
|
383
|
-
warn(message: string, ...args: any[]): void;
|
|
384
|
-
debug(message: string, ...args: any[]): void;
|
|
385
|
-
};
|
|
386
|
-
tables: {
|
|
387
|
-
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
388
|
-
${T}
|
|
389
|
-
${N}
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
`}catch(a){return console.error("Error generating simplified context type definition:",a),`
|
|
393
|
-
declare interface Context {
|
|
394
|
-
user: {
|
|
395
|
-
id: string;
|
|
396
|
-
email: string;
|
|
397
|
-
role: 'admin' | 'user';
|
|
398
|
-
createdAt: Date;
|
|
399
|
-
updatedAt: Date;
|
|
400
|
-
};
|
|
401
|
-
http: {
|
|
402
|
-
get(url: string, options?: any): Promise<any>;
|
|
403
|
-
post(url: string, data?: any, options?: any): Promise<any>;
|
|
404
|
-
put(url: string, data?: any, options?: any): Promise<any>;
|
|
405
|
-
delete(url: string, options?: any): Promise<any>;
|
|
406
|
-
};
|
|
407
|
-
fs: {
|
|
408
|
-
readFile(path: string): Promise<string>;
|
|
409
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
410
|
-
exists(path: string): Promise<boolean>;
|
|
411
|
-
listDir(path: string): Promise<string[]>;
|
|
412
|
-
mkdir(path: string): Promise<void>;
|
|
413
|
-
};
|
|
414
|
-
cmd: {
|
|
415
|
-
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
416
|
-
};
|
|
417
|
-
utils: {
|
|
418
|
-
md5(input: string): string;
|
|
419
|
-
};
|
|
420
|
-
mcp: {
|
|
421
|
-
callTool(toolName: string, args: any): Promise<any>;
|
|
422
|
-
listTools(): Promise<string[]>;
|
|
423
|
-
};
|
|
424
|
-
vars: {
|
|
425
|
-
get(name: string): string;
|
|
426
|
-
has(name: string): boolean;
|
|
427
|
-
getAll(): Record<string, string>;
|
|
428
|
-
set(name: string, value: string, description?: string): void;
|
|
429
|
-
};
|
|
430
|
-
log: {
|
|
431
|
-
info(message: string, ...args: any[]): void;
|
|
432
|
-
error(message: string, ...args: any[]): void;
|
|
433
|
-
warn(message: string, ...args: any[]): void;
|
|
434
|
-
debug(message: string, ...args: any[]): void;
|
|
435
|
-
};
|
|
436
|
-
tables: {
|
|
437
|
-
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
438
|
-
get(tableName: string): Promise<Array<Record<string, any>>>;
|
|
439
|
-
query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
`}}const gr={class:"tools-manager"},fr={class:"tools-toolbar"},yr={class:"tools-table-container"},hr={class:"modal-header"},wr={class:"modal-title"},br={class:"modal-subtitle"},kr={class:"modal-content-wrapper"},xr={class:"tab-pane-content"},Cr={class:"form-section"},$r={class:"form-grid-2"},Tr={class:"form-section"},Sr={class:"section-header"},Pr={class:"parameters-list"},jr={class:"parameter-header"},Nr={class:"parameter-index"},Ar={class:"parameter-fields"},Mr={key:0,class:"empty-parameters"},Or={class:"tab-pane-content"},zr={class:"save-status-indicator"},Dr=["title"],_r={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Ur={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Br={class:"monaco-wrapper"},Ir={class:"modal-footer"},Er={class:"test-args-content"},Rr={key:0,class:"test-args-parameters"},Vr={class:"parameters-header"},Fr={class:"parameters-count"},qr={class:"test-args-input-wrapper"},Lr={class:"test-args-input-header"},Jr={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"14px",height:"14px"}},Kr={key:1,class:"test-result-section"},Hr={class:"test-result-header"},Gr={class:"test-result-title"},Wr={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"18px",height:"18px","margin-right":"8px"}},Zr={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},Qr={class:"test-result-content"},Yr={class:"test-result-pre"},Xr={class:"test-result-code-inner"},es={class:"modal-footer"},Ne=`/**
|
|
443
|
-
* 工具脚本
|
|
444
|
-
* @param args 工具参数对象 (类型根据 Schema 声明自动生成)
|
|
445
|
-
* @param context 上下文对象 (提供常用工具方法等)
|
|
446
|
-
*/
|
|
447
|
-
export default async function (args: ToolArgs, context: Context) {
|
|
448
|
-
const { log } = context;
|
|
449
|
-
|
|
450
|
-
log.info('工具执行中');
|
|
451
|
-
|
|
452
|
-
return {
|
|
453
|
-
// 返回结果
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
`,ts=it({__name:"CustomToolsManager",props:{config:{}},emits:["update"],setup(e,{emit:a}){const r=e,l=a,c=Ct(),y=j(!1),S=j(!1),x=j(null),T=j(),N=j(""),V=j("schema"),z=j(!1),M=j(!1),K=j(""),H=j(!1),E=j("{}"),_=j(null),J=j(!1),C=ye(()=>P.value.serverScript!==K.value),I=ye(()=>z.value?"height: calc(100vh - 120px); border-radius: 12px; overflow: hidden;":"height: 474px; border-radius: 12px; overflow: hidden;"),ee=j([]),B=j([]),G=g=>g?`custom_tool_script_${g}`:"custom_tool_script_new",A=g=>{const s=G(g),h=localStorage.getItem(s);return h||null},U=(g,s)=>{const h=G(g);localStorage.setItem(h,s)},q=g=>{const s=G(g);localStorage.removeItem(s)},me=g=>g?`custom_tool_test_args_${g}`:"custom_tool_test_args_new",le=g=>{const s=me(g);return localStorage.getItem(s)},ve=(g,s)=>{const h=me(g);localStorage.setItem(h,s)},d={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},Me=g=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:s=>{s.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:s=>{s.currentTarget.style.backgroundColor=""}}),ge=[{title:"参数名",key:"name",width:150},{title:"类型",key:"type",width:100},{title:"必需",key:"required",width:80,render:g=>g.required?se(jt,{type:"error"},{default:()=>"是"}):"否"},{title:"描述",key:"description",ellipsis:{tooltip:!0}}],be=[{title:"工具名称",key:"name",width:300,render(g){const s=se("div",{style:"display: flex; align-items: center; gap: 10px;"},[se("div",{style:"width: 32px; height: 32px; border-radius: 50%; background: #e3f2fd; color: #1565c0; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; flex-shrink: 0;"},g.name.charAt(0).toUpperCase()),se("div",{style:"display: flex; flex-direction: column;"},[se("span",{style:"font-weight: 500;"},g.name)])]);return!g.parameters||g.parameters.length===0?s:se("div",{style:"display: flex; align-items: center; justify-content: space-between;"},[s,se(Nt,{trigger:"hover",style:"max-width: 600px; max-height: 500px; padding: 0; overflow: hidden;"},{trigger:()=>se(L,{size:"tiny",tertiary:!0,circle:!0,type:"info"},{default:()=>"📄"}),default:()=>se("div",{style:"max-height: 500px; overflow-y: auto;"},[se(ft,{size:"small",bordered:!1,columns:[{title:"参数名",key:"name",width:120},{title:"类型",key:"type",width:80},{title:"必需",key:"required",width:60,render:h=>h.required?se(jt,{type:"error"},{default:()=>"是"}):"否"},{title:"描述",key:"description"}],data:g.parameters,pagination:!1,singleLine:!1})])})])}},{title:"脚本",key:"script",width:150,render(g){return g.serverScript?se(Nt,{trigger:"hover",placement:"right",style:"max-width: 600px; max-height: 500px; overflow: hidden;"},{trigger:()=>se(at,{type:"info",size:"small",bordered:!0,style:"cursor: pointer;"},{default:()=>"Typescript"}),default:()=>se(ro,{code:g.serverScript,language:"typescript",style:"max-height: 500px; overflow-y: auto; font-size: 12px; display: block;"})}):se(at,{type:"default",size:"small",bordered:!0},{default:()=>"None"})}},{title:"描述",key:"description",ellipsis:{tooltip:!0}},{title:"操作",key:"actions",width:150,render(g){return se(so,{size:"small"},{default:()=>[se(L,{size:"small",onClick:()=>pt(g)},{default:()=>"编辑"}),se(L,{size:"small",type:"error",onClick:()=>mt(g.id)},{default:()=>"删除"})]})}}],ke=ye(()=>{const g=r.config.customTools.filter(h=>(h.source||"custom")==="custom");if(!N.value)return g;const s=N.value.toLowerCase();return g.filter(h=>h.name.toLowerCase().includes(s)||h.description.toLowerCase().includes(s))});async function Oe(){try{const g=await ne.get("/configs/all-tools");g.data.success&&g.data.data.tools?ee.value=g.data.data.tools:ee.value=[]}catch(g){console.error("Failed to load MCP tools from database:",g),ee.value=[]}}async function ze(){try{const g=await ne.get("/tables/definitions");g.data.success&&(B.value=g.data.data||[])}catch(g){console.error("Failed to load tables:",g),B.value=[]}}const qe=ye(()=>{let g=ee.value;if(x.value&&P.value.name){const s={name:P.value.name,description:P.value.description||"",inputSchema:{type:"object",properties:P.value.parameters.reduce((h,W)=>(W.name&&W.name.trim()&&(h[W.name.trim()]={type:W.type,description:W.description||""}),h),{}),required:P.value.parameters.filter(h=>h.required).map(h=>h.name.trim())}};g=g.filter(h=>h.name!==P.value.name).concat(s)}return kt({config:r.config,mcpTools:g,tables:B.value})}),Le=ye(()=>!P.value.parameters||P.value.parameters.length===0?`
|
|
457
|
-
/**
|
|
458
|
-
* 工具参数类型
|
|
459
|
-
*/
|
|
460
|
-
declare interface ToolArgs {
|
|
461
|
-
[key: string]: any;
|
|
462
|
-
}
|
|
463
|
-
`:`
|
|
464
|
-
/**
|
|
465
|
-
* 工具参数类型
|
|
466
|
-
* 根据 Schema 声明自动生成
|
|
467
|
-
*/
|
|
468
|
-
declare interface ToolArgs {
|
|
469
|
-
${P.value.parameters.filter(s=>s.name&&s.name.trim()).map(s=>{const h=s.name.trim(),Q=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(h)?h:`"${h.replace(/"/g,'\\"')}"`,de=s.required?"":"?",re=s.description?`/** ${s.description.replace(/\*\//g,"* /")} */
|
|
470
|
-
`:"";let ae="any";switch(s.type){case"string":ae="string";break;case"number":ae="number";break;case"boolean":ae="boolean";break;case"object":ae="Record<string, any>";break;case"array":ae="any[]";break;default:ae="any"}return`${re}${Q}${de}: ${ae};`}).join(`
|
|
471
|
-
`)}
|
|
472
|
-
}
|
|
473
|
-
`),Te=j(0),ct=ye(()=>[{content:qe.value,filePath:"file:///context.d.ts"},{content:Le.value,filePath:"file:///tool-args.d.ts"}]),P=j({name:"",description:"",serverScript:Ne,parameters:[]}),dt=[{label:"string",value:"string"},{label:"number",value:"number"},{label:"boolean",value:"boolean"},{label:"object",value:"object"},{label:"array",value:"array"}],Je={name:{required:!0,message:"请输入工具名称",trigger:"blur"},description:{required:!0,message:"请输入描述",trigger:"blur"}};function Ke(){return{name:"",type:"string",description:"",required:!1}}function He(){const g={};return P.value.parameters.forEach(s=>{if(s.name&&s.name.trim())switch(s.type){case"number":g[s.name]=0;break;case"boolean":g[s.name]=!1;break;case"array":g[s.name]=[];break;case"object":g[s.name]={};break;default:g[s.name]=""}}),JSON.stringify(g,null,2)}function pt(g){x.value=g;const h=A(g.id)||g.serverScript||Ne;P.value={name:g.name,description:g.description,serverScript:h,parameters:g.parameters?JSON.parse(JSON.stringify(g.parameters)):[]},K.value=g.serverScript||"",y.value=!0}function mt(g){const s=r.config.customTools.filter(h=>h.id!==g);l("update",{customTools:s})}async function vt(){var g,s,h;try{if(await((g=T.value)==null?void 0:g.validate()),S.value=!0,!P.value.serverScript)throw new Error("脚本不能为空");const W={id:((s=x.value)==null?void 0:s.id)||Be(),name:P.value.name,description:P.value.description,serverScript:P.value.serverScript,parameters:P.value.parameters,source:((h=x.value)==null?void 0:h.source)||"custom"},Q=[...r.config.customTools],de=Q.findIndex(re=>re.id===W.id);de!==-1?Q[de]=W:Q.push(W),l("update",{customTools:Q}),q(W.id),q(null),y.value=!1,Xe()}catch(W){c.error(W.message)}finally{S.value=!1}}function ce(g){var h;const s=((h=x.value)==null?void 0:h.id)||null;U(s,g)}function xe(){var s;K.value=P.value.serverScript;const g=((s=x.value)==null?void 0:s.id)||null;U(g,P.value.serverScript),c.success("脚本已保存")}async function Ge(){var g,s,h,W,Q,de;if(!P.value.serverScript.trim()){c.warning("请先编写脚本内容"),H.value=!1;return}xe(),M.value=!0,_.value=null,J.value=!1;try{let re={};try{const i=E.value.trim()||"{}";if(re=JSON.parse(i),typeof re!="object"||Array.isArray(re))throw new Error("参数必须是 JSON 对象")}catch(i){c.error(`参数格式错误: ${i.message}`),M.value=!1;return}const ae=await ne.post("/configs/test-custom-tool",{script:P.value.serverScript,args:re,toolName:P.value.name||"test-tool"});if(ae.data.success){const i=((g=x.value)==null?void 0:g.id)||null;ve(i,E.value);const t=(s=ae.data.data)==null?void 0:s.result;_.value=t,J.value=!0,c.success("测试执行成功")}else _.value={error:ae.data.error,success:!1},J.value=!0,c.error(`测试执行失败: ${ae.data.error}`)}catch(re){_.value={error:((W=(h=re.response)==null?void 0:h.data)==null?void 0:W.error)||re.message,success:!1},J.value=!0,c.error(`测试执行失败: ${((de=(Q=re.response)==null?void 0:Q.data)==null?void 0:de.error)||re.message}`)}finally{M.value=!1}}function We(g){try{return JSON.stringify(g,null,2)}catch{return String(g)}}function Ze(){E.value=He(),c.info("已重置为默认参数")}function Qe(){H.value=!1,_.value=null,J.value=!1}function je(){z.value=!z.value}function De(g){const s=g.match(/export\s+default\s+async\s+function\s*(\w+)?\s*\([^)]*\)\s*\{([\s\S]*)\}/);return s&&s[1]?s[1].trim():g}async function Ye(){try{let g=ee.value;if(x.value&&P.value.name){const p={name:P.value.name,description:P.value.description||"",inputSchema:{type:"object",properties:P.value.parameters.reduce((f,b)=>(b.name&&b.name.trim()&&(f[b.name.trim()]={type:b.type,description:b.description||""}),f),{}),required:P.value.parameters.filter(f=>f.required).map(f=>f.name.trim())}};g=g.filter(f=>f.name!==P.value.name).concat(p)}const s=kt({config:r.config,mcpTools:g,tables:B.value}),h=Le.value,W=P.value.parameters.filter(p=>p.name&&p.name.trim()).map(p=>`- ${p.name} (${p.type}${p.required?", required":", optional"}): ${p.description||"无描述"}`).join(`
|
|
474
|
-
`),Q=B.value.length>0?B.value.map(p=>`- ${p.name}${p.description?`: ${p.description}`:""}`).join(`
|
|
475
|
-
`):"暂无可用数据表",de=P.value.serverScript.trim()||Ne,re=De(de),ae=De(Ne),i=de!==Ne&&re!==ae,t=P.value.name||"未命名工具",n=P.value.description||"无描述",k=i?`请帮我调整/优化以下函数的实现。工具名称:${t},描述:${n}。
|
|
476
|
-
|
|
477
|
-
## 需求描述
|
|
478
|
-
|
|
479
|
-
[请在此处补充你的具体需求描述,说明需要如何调整或优化当前实现]
|
|
480
|
-
|
|
481
|
-
## 类型定义
|
|
482
|
-
|
|
483
|
-
### Context 类型定义
|
|
484
|
-
|
|
485
|
-
\`\`\`typescript
|
|
486
|
-
${s}
|
|
487
|
-
\`\`\`
|
|
488
|
-
|
|
489
|
-
### ToolArgs 类型定义
|
|
490
|
-
|
|
491
|
-
\`\`\`typescript
|
|
492
|
-
${h}
|
|
493
|
-
\`\`\`
|
|
494
|
-
|
|
495
|
-
## 工具参数定义
|
|
496
|
-
|
|
497
|
-
${W||"暂无参数定义"}
|
|
498
|
-
|
|
499
|
-
# 可用表列表:
|
|
500
|
-
|
|
501
|
-
${Q}
|
|
502
|
-
|
|
503
|
-
## 当前实现
|
|
504
|
-
|
|
505
|
-
\`\`\`typescript
|
|
506
|
-
export default async function(args: ToolArgs, context: Context) {
|
|
507
|
-
${re}
|
|
508
|
-
}
|
|
509
|
-
\`\`\`
|
|
510
|
-
|
|
511
|
-
## 输出格式
|
|
512
|
-
|
|
513
|
-
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
514
|
-
|
|
515
|
-
\`\`\`typescript
|
|
516
|
-
export default async function(args: ToolArgs, context: Context) {
|
|
517
|
-
// 函数体
|
|
518
|
-
}
|
|
519
|
-
\`\`\`
|
|
520
|
-
|
|
521
|
-
不要输出任何注释、解释文字或其他内容。
|
|
522
|
-
|
|
523
|
-
## 约束
|
|
524
|
-
|
|
525
|
-
- 只能使用 args 和 context 参数中的 API`:`请帮我实现以下函数。工具名称:${t},描述:${n}。
|
|
526
|
-
|
|
527
|
-
## 需求描述
|
|
528
|
-
|
|
529
|
-
[请在此处补充你的具体需求描述]
|
|
530
|
-
|
|
531
|
-
## 类型定义
|
|
532
|
-
|
|
533
|
-
### Context 类型定义
|
|
534
|
-
|
|
535
|
-
\`\`\`typescript
|
|
536
|
-
${s}
|
|
537
|
-
\`\`\`
|
|
538
|
-
|
|
539
|
-
### ToolArgs 类型定义
|
|
540
|
-
|
|
541
|
-
\`\`\`typescript
|
|
542
|
-
${h}
|
|
543
|
-
\`\`\`
|
|
544
|
-
|
|
545
|
-
## 工具参数定义
|
|
546
|
-
|
|
547
|
-
${W||"暂无参数定义"}
|
|
548
|
-
|
|
549
|
-
# 可用表列表:
|
|
550
|
-
|
|
551
|
-
${Q}
|
|
552
|
-
|
|
553
|
-
## 函数签名
|
|
554
|
-
|
|
555
|
-
\`\`\`typescript
|
|
556
|
-
export default async function(args: ToolArgs, context: Context) {
|
|
557
|
-
// 在此处实现
|
|
558
|
-
}
|
|
559
|
-
\`\`\`
|
|
560
|
-
|
|
561
|
-
## 输出格式
|
|
562
|
-
|
|
563
|
-
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
564
|
-
|
|
565
|
-
\`\`\`typescript
|
|
566
|
-
export default async function(args: ToolArgs, context: Context) {
|
|
567
|
-
// 函数体
|
|
568
|
-
}
|
|
569
|
-
\`\`\`
|
|
570
|
-
|
|
571
|
-
不要输出任何注释、解释文字或其他内容。
|
|
572
|
-
|
|
573
|
-
## 约束
|
|
574
|
-
|
|
575
|
-
- 只能使用 args 和 context 参数中的 API`;await navigator.clipboard.writeText(k),c.success("提示词已复制到剪贴板!")}catch(g){console.error("Failed to copy prompt:",g),c.error("复制失败,请手动复制")}}function Xe(){x.value=null,V.value="schema",z.value=!1,H.value=!1,E.value="{}",_.value=null,J.value=!1;const g=A(null);P.value={name:"",description:"",serverScript:g||Ne,parameters:[]},K.value=""}return xt(()=>{Oe(),ze()}),ue(()=>r.config.components,()=>{Oe()},{deep:!0}),ue(()=>V.value,g=>{g==="implementation"&&yt(()=>{Te.value++})}),ue(()=>P.value.parameters,()=>{yt(()=>{Te.value++})},{deep:!0,immediate:!1}),ue(()=>[P.value.name,P.value.description],()=>{yt(()=>{Te.value++})},{immediate:!1}),ue(()=>H.value,g=>{var s;if(g){const h=((s=x.value)==null?void 0:s.id)||null,W=le(h);W?E.value=W:E.value=He()}}),ue(()=>r.config.customTools,()=>{Oe()},{deep:!0}),ue(()=>y.value,g=>{if(g){if(!x.value){const s=A(null);s&&(P.value.serverScript=s)}}else Xe()}),(g,s)=>(O(),R("div",gr,[o("div",fr,[v(m(L),{type:"primary",size:"large",class:"add-tool-btn",onClick:s[0]||(s[0]=h=>y.value=!0)},{icon:u(()=>[...s[13]||(s[13]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[14]||(s[14]=D(" 添加工具 ",-1))]),_:1}),v(m(ie),{value:N.value,"onUpdate:value":s[1]||(s[1]=h=>N.value=h),placeholder:"搜索工具名称或描述...",size:"large",clearable:"",class:"search-input"},{prefix:u(()=>[...s[15]||(s[15]=[o("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1},8,["value"])]),o("div",yr,[v(m(ft),{columns:be,data:ke.value,pagination:d,"row-props":Me,class:"modern-table"},null,8,["data"])]),v(m(st),{show:y.value,"onUpdate:show":s[9]||(s[9]=h=>y.value=h),preset:"card",bordered:!1,class:"tool-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:u(()=>[o("div",hr,[s[16]||(s[16]=o("div",{class:"modal-icon"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),o("div",null,[o("h3",wr,Z(x.value?"编辑自定义工具":"创建自定义工具"),1),o("p",br,Z(x.value?"修改工具的 Schema 和实现代码":"定义工具的 Schema 并编写实现逻辑"),1)])])]),footer:u(()=>[o("div",Ir,[v(m(L),{size:"large",onClick:s[8]||(s[8]=h=>y.value=!1)},{default:u(()=>[...s[36]||(s[36]=[D("取消",-1)])]),_:1}),v(m(L),{type:"primary",size:"large",loading:S.value,onClick:vt},{default:u(()=>[D(Z(x.value?"保存修改":"创建工具"),1)]),_:1},8,["loading"])])]),default:u(()=>[o("div",kr,[v(m(Rt),{ref_key:"formRef",ref:T,model:P.value,rules:Je,class:"tool-form"},{default:u(()=>[v(m(Et),{value:V.value,"onUpdate:value":s[7]||(s[7]=h=>V.value=h),type:"line",animated:"",size:"large",class:"tool-config-tabs"},{default:u(()=>[v(m(Ee),{name:"schema",tab:"Schema 声明"},{default:u(()=>[o("div",xr,[v(m(Pe),{type:"info",bordered:!1,class:"schema-tip"},{icon:u(()=>[...s[17]||(s[17]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[18]||(s[18]=D(' 在 Schema 声明中定义的参数会自动生成类型定义,在"工具实现"标签页的脚本编辑器中可以使用类型提示 ',-1))]),_:1}),o("div",Cr,[s[21]||(s[21]=o("h4",{class:"section-title"},"基础信息",-1)),o("div",$r,[v(m(oe),{path:"name"},{label:u(()=>[...s[19]||(s[19]=[o("div",{class:"form-label"},[o("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"工具名称")],-1)])]),default:u(()=>[v(m(ie),{value:P.value.name,"onUpdate:value":s[2]||(s[2]=h=>P.value.name=h),placeholder:"例如: my-custom-tool",size:"large"},null,8,["value"])]),_:1}),v(m(oe),{path:"description"},{label:u(()=>[...s[20]||(s[20]=[o("div",{class:"form-label"},[o("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),o("span",null,"工具描述")],-1)])]),default:u(()=>[v(m(ie),{value:P.value.description,"onUpdate:value":s[3]||(s[3]=h=>P.value.description=h),placeholder:"简要描述工具的功能",size:"large"},null,8,["value"])]),_:1})])]),o("div",Tr,[o("div",Sr,[s[24]||(s[24]=o("h4",{class:"section-title"},"参数定义",-1)),v(m(L),{dashed:"",onClick:s[4]||(s[4]=h=>P.value.parameters.push(Ke())),size:"medium"},{icon:u(()=>[...s[22]||(s[22]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[23]||(s[23]=D(" 添加参数 ",-1))]),_:1})]),o("div",Pr,[(O(!0),R(ot,null,nt(P.value.parameters,(h,W)=>(O(),R("div",{key:W,class:"parameter-card"},[o("div",jr,[o("span",Nr,"#"+Z(W+1),1),v(m(L),{type:"error",text:"",size:"small",onClick:Q=>P.value.parameters.splice(W,1)},{icon:u(()=>[...s[25]||(s[25]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[26]||(s[26]=D(" 删除 ",-1))]),_:1},8,["onClick"])]),o("div",Ar,[v(m(oe),{label:"必填",class:"required-field"},{default:u(()=>[v(m(Ft),{checked:h.required,"onUpdate:checked":Q=>h.required=Q},null,8,["checked","onUpdate:checked"])]),_:2},1024),v(m(oe),{label:"参数名",path:`parameters[${W}].name`,rule:{required:!0,message:"必填",trigger:"blur"}},{default:u(()=>[v(m(ie),{value:h.name,"onUpdate:value":Q=>h.name=Q,placeholder:"参数名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),v(m(oe),{label:"类型"},{default:u(()=>[v(m(Vt),{value:h.type,"onUpdate:value":Q=>h.type=Q,options:dt},null,8,["value","onUpdate:value"])]),_:2},1024),v(m(oe),{label:"描述"},{default:u(()=>[v(m(ie),{value:h.description,"onUpdate:value":Q=>h.description=Q,placeholder:"参数描述"},null,8,["value","onUpdate:value"])]),_:2},1024)])]))),128)),P.value.parameters.length===0?(O(),R("div",Mr,[...s[27]||(s[27]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),o("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1),o("p",null,"暂无参数,点击上方按钮添加参数",-1)])])):te("",!0)])])])]),_:1}),v(m(Ee),{name:"implementation",tab:"工具实现"},{default:u(()=>[o("div",Or,[o("div",{class:we(["editor-container",{fullscreen:z.value}])},[o("div",zr,[o("div",{class:we(["status-dot",{unsaved:C.value,saved:!C.value}]),title:C.value?"未保存":"已保存"},null,10,Dr)]),v(m(L),{type:"default",size:"small",class:"fullscreen-btn",onClick:je},{icon:u(()=>[z.value?(O(),R("svg",Ur,[...s[29]||(s[29]=[o("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(O(),R("svg",_r,[...s[28]||(s[28]=[o("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:u(()=>[D(" "+Z(z.value?"退出全屏":"全屏"),1)]),_:1}),o("div",Br,[v(Re,{modelValue:P.value.serverScript,"onUpdate:modelValue":s[5]||(s[5]=h=>P.value.serverScript=h),language:"typescript",options:{minimap:{enabled:!0},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0},"extra-libs":ct.value,onSave:xe,onChange:ce,style:bt(I.value)},null,8,["modelValue","extra-libs","style"])])],2),o("div",{class:we(["editor-actions",{"fullscreen-actions":z.value}])},[v(m(L),{type:"default",size:"small",class:"copy-prompt-btn",onClick:Ye},{icon:u(()=>[...s[30]||(s[30]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M8 5.00069C7.01165 5.00069 6.49359 5.00069 6.09202 5.21967C5.71569 5.42393 5.42413 5.71549 5.21987 6.09182C5 6.49339 5 7.01145 5 7.99979V15.9998C5 16.9881 5 17.5062 5.21987 17.9078C5.42413 18.2841 5.71569 18.5757 6.09202 18.7799C6.49359 18.9998 7.01165 18.9998 8 18.9998H16C16.9883 18.9998 17.5064 18.9998 17.908 18.7799C18.2843 18.5757 18.5759 18.2841 18.7801 17.9078C19 17.5062 19 16.9881 19 15.9998V7.99979C19 7.01145 19 6.49339 18.7801 6.09182C18.5759 5.71549 18.2843 5.42393 17.908 5.21967C17.5064 5.00069 16.9883 5.00069 16 5.00069H8Z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{d:"M9 3.00069C9 2.4484 9 2.17226 9.08579 1.94418C9.18885 1.67761 9.37764 1.38893 9.58579 1.18378C9.79094 0.975636 10.0796 0.786849 10.3462 0.683785C10.5743 0.598 10.8504 0.598 11.4027 0.598H14.5973C15.1496 0.598 15.4257 0.598 15.6538 0.683785C15.9204 0.786849 16.2091 0.975636 16.4142 1.18378C16.6224 1.38893 16.8111 1.67761 16.9142 1.94418C17 2.17226 17 2.4484 17 3.00069V4.00069C17 4.55297 16.5523 5.00069 16 5.00069H8C7.44772 5.00069 7 4.55297 7 4.00069V3.00069C7 2.4484 7 2.17226 7.08579 1.94418C7.18885 1.67761 7.37764 1.38893 7.58579 1.18378C7.79094 0.975636 8.07963 0.786849 8.34621 0.683785C8.57428 0.598 8.85043 0.598 9.40272 0.598H12.5973C13.1496 0.598 13.4257 0.598 13.6538 0.683785C13.9204 0.786849 14.2091 0.975636 14.4142 1.18378C14.6224 1.38893 14.8111 1.67761 14.9142 1.94418C15 2.17226 15 2.4484 15 3.00069",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[31]||(s[31]=D(" 复制提示词到大模型生成 ",-1))]),_:1}),v(m(L),{type:"primary",size:"small",class:"save-btn",disabled:!C.value,onClick:xe},{icon:u(()=>[...s[32]||(s[32]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[33]||(s[33]=D(" 保存 (Ctrl+S) ",-1))]),_:1},8,["disabled"]),v(m(L),{type:"info",size:"small",class:"test-btn",loading:M.value,onClick:s[6]||(s[6]=h=>H.value=!0)},{icon:u(()=>[...s[34]||(s[34]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[s[35]||(s[35]=D(" 测试执行 ",-1))]),_:1},8,["loading"])],2)])]),_:1})]),_:1},8,["value"])]),_:1},8,["model"])])]),_:1},8,["show"]),v(m(st),{show:H.value,"onUpdate:show":s[12]||(s[12]=h=>H.value=h),preset:"card",bordered:!1,class:"test-args-modal",style:bt({width:J.value?"800px":"600px"}),title:"测试执行参数"},{header:u(()=>[...s[37]||(s[37]=[o("div",{class:"modal-header"},[o("div",{class:"modal-icon"},[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),o("div",null,[o("h3",{class:"modal-title"},"输入测试参数"),o("p",{class:"modal-subtitle"},'请输入 JSON 格式的参数(例如:{"param1": "value1", "param2": 123})')])],-1)])]),footer:u(()=>[o("div",es,[v(m(L),{size:"large",onClick:Qe},{default:u(()=>[...s[46]||(s[46]=[D("取消",-1)])]),_:1}),v(m(L),{type:"primary",size:"large",loading:M.value,onClick:Ge},{default:u(()=>[...s[47]||(s[47]=[D(" 执行测试 ",-1)])]),_:1},8,["loading"])])]),default:u(()=>[o("div",Er,[P.value.parameters&&P.value.parameters.length>0?(O(),R("div",Rr,[o("div",Vr,[s[38]||(s[38]=o("span",{class:"parameters-title"},"参数定义",-1)),o("span",Fr,Z(P.value.parameters.length)+" 个参数",1)]),v(m(ft),{columns:ge,data:P.value.parameters.filter(h=>h.name&&h.name.trim()),pagination:!1,size:"small",bordered:"",class:"test-args-table"},null,8,["data"])])):te("",!0),o("div",qr,[o("div",Lr,[s[41]||(s[41]=o("span",{class:"test-args-input-title"},"测试参数 (JSON)",-1)),v(m(L),{size:"small",type:"default",onClick:Ze},{icon:u(()=>[(O(),R("svg",Jr,[...s[39]||(s[39]=[o("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),o("path",{d:"M21 3v5h-5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),o("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),o("path",{d:"M3 21v-5h5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:u(()=>[s[40]||(s[40]=D(" 重置 ",-1))]),_:1})]),v(m(ie),{value:E.value,"onUpdate:value":s[10]||(s[10]=h=>E.value=h),type:"textarea",placeholder:'{"param1": "value1", "param2": 123}',rows:8,autosize:{minRows:8,maxRows:12},class:"test-args-input"},null,8,["value"])]),J.value&&_.value?(O(),R("div",Kr,[o("div",Hr,[o("div",Gr,[(O(),R("svg",Wr,[...s[42]||(s[42]=[o("path",{d:"M9 11l3 3L22 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),o("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])),s[43]||(s[43]=o("span",null,"测试结果",-1))]),v(m(L),{size:"small",text:"",onClick:s[11]||(s[11]=h=>J.value=!1)},{icon:u(()=>[(O(),R("svg",Zr,[...s[44]||(s[44]=[o("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),_:1})]),o("div",Qr,[o("pre",Yr,[o("code",Xr,Z(We(_.value)),1),s[45]||(s[45]=D(`
|
|
576
|
-
`,-1))])])])):te("",!0)])]),_:1},8,["show","style"])]))}}),gs=$t(ts,[["__scopeId","data-v-d764a238"]]),os={class:"init-script-editor"},ns={class:"save-status-indicator"},rs=["title"],ss={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},as={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ls={class:"monaco-wrapper"},is={class:"editor-actions"},Ue=`/**
|
|
577
|
-
* MCP 初始化脚本
|
|
578
|
-
* 在 MCP 客户端连接时执行,用于环境检查、数据预加载等操作
|
|
579
|
-
*/
|
|
580
|
-
export default async function(context: Context) {
|
|
581
|
-
const { log } = context;
|
|
582
|
-
|
|
583
|
-
log.info('🚀 MCP 环境初始化完成');
|
|
584
|
-
|
|
585
|
-
// 示例:检查变量配置
|
|
586
|
-
// const apiKey = context.vars.get('API_KEY');
|
|
587
|
-
// if (!apiKey) {
|
|
588
|
-
// log.warn('⚠️ API_KEY 未配置');
|
|
589
|
-
// }
|
|
590
|
-
}`,us=it({__name:"InitScriptEditor",props:{config:{}},emits:["update"],setup(e,{emit:a}){const r=e,l=a,c=Ct(),y=j([]),S=j([]);async function x(){try{const A=await ne.get("/configs/all-tools");A.data.success&&A.data.data.tools?y.value=A.data.data.tools:y.value=[]}catch(A){console.error("Failed to load MCP tools from database:",A),y.value=[]}}async function T(){try{const A=await ne.get("/tables/definitions");A.data.success&&(S.value=A.data.data||[])}catch(A){console.error("Failed to load tables:",A),S.value=[]}}const N=ye(()=>kt({config:r.config,mcpTools:y.value,tables:S.value})),V=ye(()=>[{content:N.value,filePath:"file:///init-script-context.d.ts"}]);xt(()=>{x(),T()}),ue(()=>r.config.components,()=>{x()},{deep:!0}),ue(()=>r.config.customTools,()=>{x()},{deep:!0});const z=j(r.config.initScript||Ue),M=j(r.config.initScript||""),K=ye(()=>z.value!==M.value),H=j(!1),E=j(!1),_=ye(()=>E.value?"height: 100%; border-radius: 12px; overflow: hidden;":"height: calc(100vh - 300px); min-height: 600px; max-height: 800px; border-radius: 12px; overflow: hidden;");ue(()=>r.config.initScript,(A,U)=>{const q=A||"";if(q===(U||"")||!q&&M.value)return;if(q&&q!==M.value){z.value=q,M.value=q;return}const le=q||Ue;z.value=le,M.value=q},{immediate:!0});function J(A){}async function C(){const A=z.value.trim()||void 0;l("update",{initScript:A}),M.value=A||""}async function I(){var A,U;if(!z.value.trim()){c.warning("请先编写脚本内容");return}await C(),H.value=!0;try{const q=await ne.post("/configs/test-init-script",{script:z.value});q.data.success?c.success("测试执行成功,请查看服务端控制台输出"):c.error(`测试执行失败: ${q.data.error}`)}catch(q){c.error(`测试执行失败: ${((U=(A=q.response)==null?void 0:A.data)==null?void 0:U.error)||q.message}`)}finally{H.value=!1}}function ee(){E.value=!E.value}function B(A){const U=A.match(/export\s+default\s+async\s+function\s*\([^)]*\)\s*\{([\s\S]*)\}/);return U&&U[1]?U[1].trim():A}async function G(){try{const A=vr({config:r.config,mcpTools:y.value,tables:S.value}),U=y.value.map(ge=>`- ${ge.name}: ${ge.description||"无描述"}`).join(`
|
|
591
|
-
`),q=S.value.map(ge=>{const be=ge.columns.map(ke=>` - ${ke.name} (${ke.type}${ke.nullable?", nullable":""})`).join(`
|
|
592
|
-
`);return`- ${ge.name}: ${ge.description||"无描述"}
|
|
593
|
-
${be}`}).join(`
|
|
594
|
-
|
|
595
|
-
`),me=z.value.trim()||Ue,le=B(me),ve=B(Ue),Me=me!==Ue&&le!==ve?`请帮我调整/优化以下函数的实现。
|
|
596
|
-
|
|
597
|
-
## 需求描述
|
|
598
|
-
|
|
599
|
-
[请在此处补充你的具体需求描述,说明需要如何调整或优化当前实现]
|
|
600
|
-
|
|
601
|
-
## 类型定义
|
|
602
|
-
|
|
603
|
-
\`\`\`typescript
|
|
604
|
-
${A}
|
|
605
|
-
\`\`\`
|
|
606
|
-
|
|
607
|
-
## 可用工具
|
|
608
|
-
|
|
609
|
-
${U||"暂无可用工具"}
|
|
610
|
-
|
|
611
|
-
## 可用数据表
|
|
612
|
-
|
|
613
|
-
${q||"暂无可用数据表"}
|
|
614
|
-
|
|
615
|
-
## 当前实现
|
|
616
|
-
|
|
617
|
-
\`\`\`typescript
|
|
618
|
-
export default async function(context: Context) {
|
|
619
|
-
${le}
|
|
620
|
-
}
|
|
621
|
-
\`\`\`
|
|
622
|
-
|
|
623
|
-
## 输出格式
|
|
624
|
-
|
|
625
|
-
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
626
|
-
|
|
627
|
-
\`\`\`typescript
|
|
628
|
-
export default async function(context: Context) {
|
|
629
|
-
// 函数体
|
|
630
|
-
}
|
|
631
|
-
\`\`\`
|
|
632
|
-
|
|
633
|
-
不要输出任何注释、解释文字或其他内容。
|
|
634
|
-
|
|
635
|
-
## 约束
|
|
636
|
-
|
|
637
|
-
- 只能使用 context 参数中的 API`:`请帮我实现以下函数。
|
|
638
|
-
|
|
639
|
-
## 需求描述
|
|
640
|
-
|
|
641
|
-
[请在此处补充你的具体需求描述]
|
|
642
|
-
|
|
643
|
-
## 类型定义
|
|
644
|
-
|
|
645
|
-
\`\`\`typescript
|
|
646
|
-
${A}
|
|
647
|
-
\`\`\`
|
|
648
|
-
|
|
649
|
-
## 可用工具
|
|
650
|
-
|
|
651
|
-
${U||"暂无可用工具"}
|
|
652
|
-
|
|
653
|
-
## 可用数据表
|
|
654
|
-
|
|
655
|
-
${q||"暂无可用数据表"}
|
|
656
|
-
|
|
657
|
-
## 函数签名
|
|
658
|
-
|
|
659
|
-
\`\`\`typescript
|
|
660
|
-
export default async function(context: Context) {
|
|
661
|
-
// 在此处实现
|
|
662
|
-
}
|
|
663
|
-
\`\`\`
|
|
664
|
-
|
|
665
|
-
## 输出格式
|
|
666
|
-
|
|
667
|
-
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
668
|
-
|
|
669
|
-
\`\`\`typescript
|
|
670
|
-
export default async function(context: Context) {
|
|
671
|
-
// 函数体
|
|
672
|
-
}
|
|
673
|
-
\`\`\`
|
|
674
|
-
|
|
675
|
-
不要输出任何注释、解释文字或其他内容。
|
|
676
|
-
|
|
677
|
-
## 约束
|
|
678
|
-
|
|
679
|
-
- 只能使用 context 参数中的 API`;await navigator.clipboard.writeText(Me),c.success("提示词已复制到剪贴板!")}catch(A){console.error("Failed to copy prompt:",A),c.error("复制失败,请手动复制")}}return(A,U)=>(O(),R("div",os,[U[9]||(U[9]=It('<div class="editor-toolbar" data-v-7de05eec><div class="toolbar-info" data-v-7de05eec><svg class="info-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-7de05eec><polyline points="16 18 22 12 16 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-7de05eec></polyline><polyline points="8 6 2 12 8 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-7de05eec></polyline></svg><span data-v-7de05eec>初始化脚本在 MCP 连接时执行,用于初始化环境、加载数据等操作</span></div></div>',1)),o("div",{class:we(["editor-container",{fullscreen:E.value}])},[o("div",ns,[o("div",{class:we(["status-dot",{unsaved:K.value,saved:!K.value}]),title:K.value?"未保存":"已保存"},null,10,rs)]),v(m(L),{type:"default",size:"small",class:"fullscreen-btn",onClick:ee},{icon:u(()=>[E.value?(O(),R("svg",as,[...U[2]||(U[2]=[o("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(O(),R("svg",ss,[...U[1]||(U[1]=[o("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:u(()=>[D(" "+Z(E.value?"退出全屏":"全屏"),1)]),_:1}),o("div",ls,[v(Re,{modelValue:z.value,"onUpdate:modelValue":U[0]||(U[0]=q=>z.value=q),language:"typescript",options:{minimap:{enabled:!0},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0},"extra-libs":V.value,onSave:C,onChange:J,style:bt(_.value)},null,8,["modelValue","extra-libs","style"])]),o("div",is,[v(m(L),{type:"default",size:"small",class:"copy-prompt-btn",onClick:G},{icon:u(()=>[...U[3]||(U[3]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M8 5.00069C7.01165 5.00069 6.49359 5.00069 6.09202 5.21967C5.71569 5.42393 5.42413 5.71549 5.21987 6.09182C5 6.49339 5 7.01145 5 7.99979V15.9998C5 16.9881 5 17.5062 5.21987 17.9078C5.42413 18.2841 5.71569 18.5757 6.09202 18.7799C6.49359 18.9998 7.01165 18.9998 8 18.9998H16C16.9883 18.9998 17.5064 18.9998 17.908 18.7799C18.2843 18.5757 18.5759 18.2841 18.7801 17.9078C19 17.5062 19 16.9881 19 15.9998V7.99979C19 7.01145 19 6.49339 18.7801 6.09182C18.5759 5.71549 18.2843 5.42393 17.908 5.21967C17.5064 5.00069 16.9883 5.00069 16 5.00069H8Z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{d:"M9 3.00069C9 2.4484 9 2.17226 9.08579 1.94418C9.18885 1.67761 9.37764 1.38893 9.58579 1.18378C9.79094 0.975636 10.0796 0.786849 10.3462 0.683785C10.5743 0.598 10.8504 0.598 11.4027 0.598H14.5973C15.1496 0.598 15.4257 0.598 15.6538 0.683785C15.9204 0.786849 16.2091 0.975636 16.4142 1.18378C16.6224 1.38893 16.8111 1.67761 16.9142 1.94418C17 2.17226 17 2.4484 17 3.00069V4.00069C17 4.55297 16.5523 5.00069 16 5.00069H8C7.44772 5.00069 7 4.55297 7 4.00069V3.00069C7 2.4484 7 2.17226 7.08579 1.94418C7.18885 1.67761 7.37764 1.38893 7.58579 1.18378C7.79094 0.975636 8.07963 0.786849 8.34621 0.683785C8.57428 0.598 8.85043 0.598 9.40272 0.598H12.5973C13.1496 0.598 13.4257 0.598 13.6538 0.683785C13.9204 0.786849 14.2091 0.975636 14.4142 1.18378C14.6224 1.38893 14.8111 1.67761 14.9142 1.94418C15 2.17226 15 2.4484 15 3.00069",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[U[4]||(U[4]=D(" 复制提示词到大模型生成 ",-1))]),_:1}),v(m(L),{type:"primary",size:"small",class:"save-btn",disabled:!K.value,onClick:C},{icon:u(()=>[...U[5]||(U[5]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[U[6]||(U[6]=D(" 保存 (Ctrl+S) ",-1))]),_:1},8,["disabled"]),v(m(L),{type:"info",size:"small",class:"test-btn",loading:H.value,onClick:I},{icon:u(()=>[...U[7]||(U[7]=[o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[o("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:u(()=>[U[8]||(U[8]=D(" 测试执行 ",-1))]),_:1},8,["loading"])])],2)]))}}),fs=$t(us,[["__scopeId","data-v-7de05eec"]]);export{gs as C,fs as I,vs as M,Re as _,Be as g,ms as p,ps as u};
|