flex-mcp 1.1.11 → 1.1.13
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/web/assets/Blank-BHJQs5sx.js +1 -0
- package/dist/web/assets/Configs-ClEYNzO5.js +1 -0
- package/dist/web/assets/{Dashboard-DG4KlU_v.js → Dashboard-CnyNQRgh.js} +4 -4
- package/dist/web/assets/InitScriptEditor-BFTWTD26.js +499 -0
- package/dist/web/assets/Layout-B9iGlIQE.js +1 -0
- package/dist/web/assets/Layout-Da7GFkga.js +1 -0
- package/dist/web/assets/Login-BWlz3FI1.js +1 -0
- package/dist/web/assets/Login-DXNFmh7b.js +1 -0
- package/dist/web/assets/Users-DGRVEG-v.js +1 -0
- package/dist/web/assets/index-CmiEbWrJ.js +2 -0
- package/dist/web/assets/monaco-editor-BXWd1EVR.js +11 -0
- package/dist/web/assets/naive-ui-BwyHI4J3.js +7313 -0
- package/dist/web/assets/style-CrcCgeaU.css +1 -0
- package/dist/web/assets/vendor-DpXl860f.js +58 -0
- package/dist/web/index.html +5 -2
- package/package.json +1 -1
- package/dist/web/assets/Blank-DnwEW0VT.js +0 -1
- package/dist/web/assets/Configs-Bq1LRu7c.js +0 -1
- package/dist/web/assets/InitScriptEditor-BpsNM3mj.js +0 -509
- package/dist/web/assets/Layout-CZunjis7.js +0 -1
- package/dist/web/assets/Layout-DuBl1mVJ.js +0 -1
- package/dist/web/assets/Login-CV4pyxSI.js +0 -1
- package/dist/web/assets/Login-Drzps0QW.js +0 -1
- package/dist/web/assets/Users-zsruR1wp.js +0 -1
- package/dist/web/assets/index-mIcNgFiY.js +0 -7371
- package/dist/web/assets/style-BdM4weEm.css +0 -1
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import{b_ as It,r as S,q as dt,o as Tt,ah as Lt,w as Ce,c0 as V,c5 as ce,c1 as t,bm as je,bU as O,s as Se,bW as c,bV as r,bs as l,c2 as zt,l as U,F as rt,bN as lt,bS as De,c7 as ae,a3 as Pt,v as Nt,c9 as Me,c4 as at,Z as Fe,aI as xt,G as me}from"./vendor-DpXl860f.js";import{a as pe,i as qt,g as Ht,p as Kt}from"./index-CmiEbWrJ.js";import{u as $t,B as G,C as Gt,g as it,q as Ye,x as Zt,D as Wt,k as _t,l as ut,E as Qt,F as Mt,c as Ft,d as fe,e as ke,o as Jt,G as bt,m as Le,h as Ut,r as Yt,H as Xt,I as eo,w as to,f as kt,i as jt,y as Ot,J as oo,j as so}from"./naive-ui-BwyHI4J3.js";import{_ as pt}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Cn=It("config",()=>{const p=S(null),z=S(!1);async function h(){var A,j;z.value=!0;try{const L=await pe.get("/configs/me");return p.value=L.data.data,p.value}catch(L){throw new Error(((j=(A=L.response)==null?void 0:A.data)==null?void 0:j.error)||"Failed to fetch config")}finally{z.value=!1}}async function C(A){var j,L;z.value=!0;try{const B=await pe.get(`/configs/user/${A}`);return p.value=B.data.data,p.value}catch(B){throw new Error(((L=(j=B.response)==null?void 0:j.data)==null?void 0:L.error)||"Failed to fetch user config")}finally{z.value=!1}}async function m(A){var j,L;z.value=!0;try{const B=await pe.put("/configs/me",A);return p.value=B.data.data,p.value}catch(B){throw new Error(((L=(j=B.response)==null?void 0:j.data)==null?void 0:L.error)||"Failed to update config")}finally{z.value=!1}}async function R(A,j){var L,B;z.value=!0;try{const q=await pe.put(`/configs/user/${A}`,j);return p.value=q.data.data,p.value}catch(q){throw new Error(((B=(L=q.response)==null?void 0:L.data)==null?void 0:B.error)||"Failed to update user config")}finally{z.value=!1}}function T(A){const j={...A,variables:A.variables.map(L=>({...L,value:L.isSecret?`{{${L.name}}}`:L.value}))};return JSON.stringify(j,null,2)}function x(A){try{const j=JSON.parse(A);if(!j.name||!Array.isArray(j.components)||!Array.isArray(j.customTools))throw new Error("Invalid config format");return j}catch(j){throw new Error(`Failed to parse config: ${j.message}`)}}return{currentConfig:p,loading:z,fetchConfig:h,fetchUserConfig:C,updateConfig:m,updateUserConfig:R,exportConfig:T,importConfig:x}});function Qe(){if(typeof globalThis<"u"&&"crypto"in globalThis){const p=globalThis.crypto;if(p&&typeof p.randomUUID=="function")return p.randomUUID()}return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function At(p){return p==null?!1:typeof p=="boolean"?p:typeof p=="string"?p.trim()!=="":typeof p=="number"?p!==0:Array.isArray(p)?p.length>0:typeof p=="object"?Object.keys(p).length>0:!!p}function no(p,z){let h=p;const C=/\{\{#if\s+(\w+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/if\}\}/g;h=h.replace(C,(R,T,x,A)=>{const j=z[T];return At(j)?x||"":A||""});const m=/\{\{#ifnot\s+(\w+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/ifnot\}\}/g;return h=h.replace(m,(R,T,x,A)=>{const j=z[T];return At(j)?A||"":x||""}),h}function ao(p,z){return p.replace(/\{\{(\w+)\}\}/g,(h,C)=>{const m=z[C];return m!=null?String(m):h})}function xn(p,z){let h=no(p,z);return h=ao(h,z),h}const ro={class:"monaco-editor-wrapper"},lo={key:0,class:"monaco-loading"},io=dt({__name:"MonacoEditor",props:{modelValue:{},language:{},theme:{},options:{},extraLibs:{}},emits:["update:modelValue","save","change"],setup(p,{emit:z}){const h=p,C=z,m=S(),R=S(!0);let T=null,x=null,A=null,j=!1,L=null;const B=S(new Map);function q(E){if(!x)return;B.value.forEach(I=>{I.dispose()}),B.value.clear();const W=(h.language||"typescript")==="typescript"?x.languages.typescript.typescriptDefaults:x.languages.typescript.javascriptDefaults;W.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1}),W.setCompilerOptions({target:x.languages.typescript.ScriptTarget.ES2020,allowNonTsExtensions:!0,strict:!0}),W.setInlayHintsOptions({includeInlayParameterNameHints:"all"}),E.forEach(I=>{const _=I.filePath||`file:///lib-${Date.now()}.d.ts`,g=W.addExtraLib(I.content,_);B.value.set(_,g)})}return Tt(async()=>{var E,ee,W;try{qt()?x=Ht():x=await Kt(),h.extraLibs&&q(h.extraLibs);const I=h.language||"typescript";A&&A.dispose(),A=x.languages.registerCompletionItemProvider(I,{provideCompletionItems:()=>({suggestions:[]}),triggerCharacters:['"',"'"]}),T=x.editor.create(m.value,{value:h.modelValue,language:I,theme:h.theme||"vs-dark",automaticLayout:!0,minimap:{enabled:!0},fontSize:14,tabSize:2,readOnly:!1,...h.options,quickSuggestions:{other:!0,comments:!1,strings:!0,...(E=h.options)==null?void 0:E.quickSuggestions},suggestOnTriggerCharacters:((ee=h.options)==null?void 0:ee.suggestOnTriggerCharacters)??!0,wordWrap:((W=h.options)==null?void 0:W.wordWrap)??"off"}),T.onDidChangeModelContent(_=>{var te;if(j)return;const g=T.getValue();C("update:modelValue",g),C("change",g);const N=(te=_.changes)==null?void 0:te[_.changes.length-1];N&&(N.text==='"'||N.text==="'")&&setTimeout(()=>{T&&T.trigger("","editor.action.triggerSuggest",{})},100)}),T.addCommand(x.KeyMod.CtrlCmd|x.KeyCode.KeyS,()=>{C("save")}),L=_=>{if(!(!T||!T.hasTextFocus())){if((_.metaKey||_.ctrlKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),_.stopPropagation();const g=T.getModel();return g&&g.canUndo()&&g.undo(),!1}if((_.metaKey||_.ctrlKey)&&_.key==="z"&&_.shiftKey){_.preventDefault(),_.stopPropagation();const g=T.getModel();return g&&g.canRedo()&&g.redo(),!1}if((_.metaKey||_.ctrlKey)&&_.key==="y"){_.preventDefault(),_.stopPropagation();const g=T.getModel();return g&&g.canRedo()&&g.redo(),!1}}},document.addEventListener("keydown",L,!0),R.value=!1}catch(I){console.error("Failed to load Monaco Editor:",I),R.value=!1}}),Lt(()=>{A==null||A.dispose(),T==null||T.dispose(),L&&(document.removeEventListener("keydown",L,!0),L=null)}),Ce(()=>h.modelValue,E=>{if(!T)return;if(T.getValue()!==E){j=!0;try{const W=T.getModel();if(W){const I=W.getFullModelRange();T.executeEdits("external-update",[{range:I,text:E}]),T.pushUndoStop();const _=W.getLineCount(),g=W.getLineMaxColumn(_);T.setPosition({lineNumber:_,column:g})}}finally{setTimeout(()=>{j=!1},0)}}}),Ce(()=>h.extraLibs,(E,ee)=>{if(!E||!x||!(!ee||E.length!==ee.length||E.some((_,g)=>{const N=ee[g];return!N||_.content!==N.content||_.filePath!==N.filePath})))return;q(E);const I=T==null?void 0:T.getModel();I&&(x.editor.setModelMarkers(I,"typescript",[]),setTimeout(()=>{T&&I&&I.getValue()===I.getValue()&&I.forceTokenization(I.getLineCount())},100))},{deep:!0,immediate:!1}),(E,ee)=>(O(),V("div",ro,[R.value?(O(),V("div",lo,[...ee[0]||(ee[0]=[t("div",{class:"loading-spinner"},null,-1),t("div",{class:"loading-text"},"正在加载编辑器...",-1)])])):ce("",!0),t("div",{ref_key:"editorContainer",ref:m,class:je(["w-full h-full min-h-[400px]",{"editor-hidden":R.value}])},null,2)]))}}),ct=pt(io,[["__scopeId","data-v-7643f27f"]]),uo={class:"components-manager"},co={key:0,class:"components-toolbar"},po={class:"toolbar-actions"},vo={key:1},go={class:"component-item"},mo={class:"component-main"},fo={class:"component-icon"},yo={class:"icon-circle"},ho={class:"component-info"},wo={class:"component-title"},bo={class:"name"},ko={class:"component-actions"},Co={key:0,class:"component-tools"},xo={key:2,class:"empty-state"},To={class:"empty-state-content"},$o={class:"empty-actions"},So={class:"modal-header"},Po={class:"modal-title"},No={class:"modal-subtitle"},Mo={class:"modal-content-wrapper"},jo={class:"tab-pane-content"},Oo={class:"mode-switcher"},Ao={class:"form-content"},Do={class:"form-section"},zo={class:"form-grid"},_o={key:0,class:"form-section"},Fo={class:"form-grid"},Jo={key:1,class:"form-section"},Uo={key:2,class:"form-section"},Bo={class:"json-content"},Eo={class:"editor-wrapper"},Ro={class:"tab-pane-content tools-tab-content"},Vo={class:"tools-action-bar"},Io={class:"tools-action-buttons"},Lo={key:0,class:"batch-actions"},qo={key:0,class:"tools-list-wrapper"},Ho={class:"tools-list"},Ko=["onClick"],Go={class:"tool-header"},Zo={class:"tool-checkbox"},Wo={class:"tool-info"},Qo=["title"],Yo={class:"tooltip-description"},Xo={class:"tool-actions"},es={class:"detail-section"},ts=["onDblclick"],os={key:2,class:"description-actions"},ss={key:0,class:"detail-section"},ns={class:"params-list"},as={class:"param-header"},rs={class:"param-name"},ls={key:0,class:"param-type"},is={key:1,class:"param-required"},us=["onDblclick"],cs={key:2,class:"field-description-actions"},ds={key:1,class:"detail-section"},ps={key:1,class:"tools-empty"},vs={key:2,class:"tools-error"},gs={class:"modal-footer"},ms={style:{"font-size":"12px",color:"#666"}},fs={key:0},ys={class:"modal-footer"},hs=dt({__name:"MCPComponentsManager",props:{config:{}},emits:["update"],setup(p,{emit:z}){const h=p,C=z,m=$t(),R=S(!1),T=S("config"),x=S("form"),A=S(!1),j=S(!1),L=S(!1),B=S(!1),q=S(""),E=S(null),ee=S(),W=S(""),I=S(""),_=S({}),g=S(!1),N=S({current:0,total:0,currentComponent:""});function te(n){T.value=n}const J=S([]),Q=S(new Set),F=S({}),de=S(0),Ne=Se(()=>{const n=a.value.toolPatches,e=F.value,o=J.value;de.value;const f={};return o.forEach(u=>{var y;const d=we(u),k=n[d];k&&k.description!==void 0&&k.description!==null&&k.description!==""?f[u.name]=k.description:f[u.name]=((y=e[d])==null?void 0:y.description)||"暂无描述"}),f}),ye=S(null),he=S(null),ve=S(""),Ue=S("tool"),xe=S(""),Te=S(""),a=S({name:"",type:"npm",package:"",version:"",url:"",command:"",args:[],env:[],headers:[],disabledTools:[],toolPatches:{},namespace:"",extraConfig:{},rootExtra:{},configStr:"{}",disabled:!1}),K=[{label:"NPM 包",value:"npm"},{label:"Stdio (Command)",value:"stdio"},{label:"SSE (URL)",value:"url"}],H={name:{required:!0,message:"请输入名称",trigger:"blur"},type:{required:!0,message:"请选择类型",trigger:"change"}};function oe(n){const e={};return n.forEach(o=>{o.key&&(e[o.key]=o.value)}),e}function ze(n){return n?Object.entries(n).map(([e,o])=>({key:e,value:o})):[]}function Oe(n,e){const o=[...h.config.components],f=o.findIndex(u=>u.id===n.id);f!==-1&&(o[f]={...n,disabled:!e},C("update",{components:o}))}function Pe(n){var M,re,ne;const e=(M=n.config)!=null&&M.headers?ze(n.config.headers):[],o=((re=n.config)==null?void 0:re.disabledTools)||[],f=(ne=n.config)!=null&&ne.toolPatches?JSON.parse(JSON.stringify(n.config.toolPatches)):{};console.log("加载时的 toolPatches:",JSON.stringify(f,null,2));const{headers:u,disabledTools:d,toolPatches:k,tools:w,...y}=n.config||{},se=["id","name","type","namespace","env","package","version","url","command","args","config","disabled"],$={};Object.keys(n).forEach(D=>{se.includes(D)||($[D]=n[D])}),a.value={name:n.name||"",type:n.type||"npm",package:n.package||"",version:n.version||"",url:n.url||"",command:n.command||"",args:n.args||[],env:ze(n.env),headers:e,disabledTools:o,toolPatches:f,namespace:n.namespace||"",extraConfig:y,rootExtra:$,configStr:JSON.stringify(n,null,2),disabled:!!n.disabled}}function Be(){const n={...a.value.rootExtra,name:a.value.name,type:a.value.type,namespace:a.value.namespace||void 0,env:a.value.env.length>0?oe(a.value.env):void 0,disabled:a.value.disabled?!0:void 0};a.value.type==="npm"?(n.package=a.value.package,n.version=a.value.version||void 0):a.value.type==="url"?n.url=a.value.url:a.value.type==="stdio"&&(n.command=a.value.command,n.args=a.value.args);const e={...a.value.extraConfig};return e.disabledTools=a.value.disabledTools,a.value.headers.length>0&&(e.headers=oe(a.value.headers)),J.value.length>0&&(e.tools=J.value),a.value.toolPatches&&Object.keys(a.value.toolPatches).length>0&&(e.toolPatches=JSON.parse(JSON.stringify(a.value.toolPatches))),Object.keys(e).length>0&&(n.config=e),JSON.parse(JSON.stringify(n))}Ce(x,n=>{var e;if(T.value==="config"){if(n==="json")try{const o=Be();(e=E.value)!=null&&e.id&&(o.id=E.value.id),a.value.configStr=JSON.stringify(o,null,2)}catch(o){console.error(o)}else if(n==="form")try{const o=JSON.parse(a.value.configStr);Pe(o)}catch{m.error("JSON 格式错误,忽略更改")}}});async function P(n){var e;E.value=n,T.value="config",x.value="form",Pe(n),J.value=[],q.value="",Q.value.clear(),ye.value=null,he.value=null,ve.value="",F.value={},console.log("[editComponent] form.value.toolPatches after fillFormFromData:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[editComponent] component.config?.toolPatches:",JSON.stringify((e=n.config)==null?void 0:e.toolPatches,null,2)),await He(n.id,!0),console.log("[editComponent] form.value.toolPatches after loadComponentTools:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[editComponent] originalTools after loadComponentTools:",JSON.stringify(F.value,null,2)),R.value=!0}async function He(n,e=!1){var o,f,u,d,k,w,y,se;try{const $=await pe.get(`/configs/component-tools/${n}`);if($.data.success&&$.data.data.tools&&$.data.data.tools.length>0){const M=h.config.components.find(b=>b.id===n),re=e?((o=M==null?void 0:M.config)==null?void 0:o.toolPatches)||{}:{},ne=Array.isArray((f=M==null?void 0:M.config)==null?void 0:f.disabledTools)?M.config.disabledTools:[],D={};J.value=$.data.data.tools.map(b=>{const X=b.originalToolName||b.name;if(b.originalDescription!==void 0&&b.originalInputSchema!==void 0)D[X]={description:b.originalDescription||"",inputSchema:JSON.parse(JSON.stringify(b.originalInputSchema||{type:"object",properties:{}}))};else{const be=re[X];be&&be.description!==void 0&&be.description!==null&&be.description!==""?(console.warn(`[loadComponentTools] 无法获取工具 ${X} 的原始数据,因为后端 API 没有返回 originalDescription`),F.value[X]?D[X]=F.value[X]:D[X]={description:"",inputSchema:{type:"object",properties:{}}}):D[X]={description:b.description||"",inputSchema:JSON.parse(JSON.stringify(b.inputSchema||{type:"object",properties:{}}))}}let ge=b.inputSchema||{type:"object",properties:{}};if(e&&re[X]){const be=re[X];be.inputSchema&&(ge={...ge,...be.inputSchema})}return{name:b.name,description:b.description||"",inputSchema:ge,disabled:ne.includes(X),originalToolName:X}}),e&&Object.keys(F.value).forEach(b=>{D[b]||(D[b]=F.value[b])}),Object.keys(D).forEach(b=>{var X;D[b].description===""&&((X=F.value[b])!=null&&X.description)&&(D[b]=F.value[b])}),F.value=D;const le=a.value.toolPatches&&Object.keys(a.value.toolPatches).length>0?a.value.toolPatches:((u=M==null?void 0:M.config)==null?void 0:u.toolPatches)||{};console.log("[loadComponentTools] existingToolPatches:",JSON.stringify(le,null,2)),console.log("[loadComponentTools] form.value.toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[loadComponentTools] component.config?.toolPatches:",JSON.stringify((d=M==null?void 0:M.config)==null?void 0:d.toolPatches,null,2));const Z={},ie=new Set(J.value.map(b=>b.originalToolName||b.name).filter(b=>b!=null&&b!==""));console.log("[loadComponentTools] currentToolNames:",Array.from(ie)),console.log("[loadComponentTools] existingToolPatches keys:",Object.keys(le)),Object.keys(le).forEach(b=>{ie.has(b)?(Z[b]=le[b],console.log(`[loadComponentTools] 保留 toolPatch: ${b}`)):console.log(`[loadComponentTools] 过滤掉 toolPatch: ${b} (不在当前工具列表中)`)}),M&&(e||Object.keys(Z).length>0)&&(M.config?M.config.toolPatches=Z:M.config={toolPatches:Z}),a.value.toolPatches=JSON.parse(JSON.stringify(Z)),console.log("[loadComponentTools] final form.value.toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[loadComponentTools] originalTools:",JSON.stringify(F.value,null,2));return}}catch($){((k=$.response)==null?void 0:k.status)===404?console.log("数据库中没有工具列表,尝试从 MCP 组件加载"):console.warn("从数据库加载工具列表失败:",$)}try{const $=h.config.components.find(re=>re.id===n);if(!$){J.value=[];return}const M=await pe.post("/configs/component-tools/load",{componentId:n});if(M.data.success&&M.data.data.tools){const re=e?((w=$.config)==null?void 0:w.toolPatches)||{}:{},ne=Array.isArray((y=$.config)==null?void 0:y.disabledTools)?$.config.disabledTools:[],D={};J.value=M.data.data.tools.map(b=>{const X=b.originalToolName||(()=>{const be=b.name.split("_");return be.length>1?be.slice(-1)[0]:b.name})();D[X]={description:b.description||"",inputSchema:JSON.parse(JSON.stringify(b.inputSchema||{type:"object",properties:{}}))};let ge=b.inputSchema||{type:"object",properties:{}};if(e&&re[X]){const be=re[X];be.inputSchema&&(ge={...ge,...be.inputSchema})}return{name:b.name,description:b.description||"",inputSchema:ge,disabled:ne.includes(X),originalToolName:X}}),e&&Object.keys(F.value).forEach(b=>{D[b]||(D[b]=F.value[b])}),F.value=D;const le=a.value.toolPatches&&Object.keys(a.value.toolPatches).length>0?a.value.toolPatches:((se=$.config)==null?void 0:se.toolPatches)||{};console.log("[loadComponentTools-from-MCP] existingToolPatches:",JSON.stringify(le,null,2));const Z={},ie=new Set(J.value.map(b=>b.originalToolName));Object.keys(le).forEach(b=>{ie.has(b)&&(Z[b]=le[b])}),e&&$&&($.config?$.config.toolPatches=Z:$.config={toolPatches:Z}),a.value.toolPatches=JSON.parse(JSON.stringify(Z)),console.log("[loadComponentTools-from-MCP] final form.value.toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[loadComponentTools-from-MCP] originalTools:",JSON.stringify(F.value,null,2))}else J.value=[]}catch($){console.warn("从 MCP 组件加载工具列表失败:",$),J.value=[]}}function vt(n){const e=h.config.components.filter(o=>o.id!==n);C("update",{components:e})}async function gt(n){var e,o,f;_.value[n.id]=!0;try{const u=await pe.post("/configs/sync-tools",{componentId:n.id});if(u.data.success)if(u.data.data.errors&&u.data.data.errors.length>0)m.error(`同步工具失败: ${u.data.data.errors.join("; ")}`);else if(u.data.data.success>0){m.success(`工具同步成功:${u.data.data.success} 个工具已更新`),u.data.data.failed>0&&m.warning(`${u.data.data.failed} 个工具同步失败`);try{const d=await pe.get(`/configs/component-tools/${n.id}`);if(d.data.success&&d.data.data.tools){const k=d.data.data.tools.length,w=[...h.config.components],y=w.findIndex(se=>se.id===n.id);y!==-1&&(w[y]={...w[y],config:{...w[y].config,toolCount:k}},C("update",{components:w}))}}catch(d){console.warn("更新组件工具总数失败:",d)}((e=E.value)==null?void 0:e.id)===n.id&&await He(n.id,!0)}else m.warning("没有工具需要同步");else m.error(`同步工具失败: ${u.data.error||"未知错误"}`)}catch(u){m.error(`同步工具失败: ${((f=(o=u.response)==null?void 0:o.data)==null?void 0:f.error)||u.message}`)}finally{_.value[n.id]=!1}}async function Xe(){var n,e;if(!E.value){m.warning("请先选择要编辑的组件");return}B.value=!0,q.value="";try{const o=await pe.post("/configs/sync-tools",{componentId:E.value.id});o.data.success?o.data.data.errors&&o.data.data.errors.length>0?(q.value=o.data.data.errors.join("; "),m.error(`同步工具失败: ${q.value}`)):o.data.data.success>0?(m.success(`工具同步成功:${o.data.data.success} 个工具已更新`),o.data.data.failed>0&&(m.warning(`${o.data.data.failed} 个工具同步失败`),o.data.data.errors&&o.data.data.errors.length>0&&(q.value=o.data.data.errors.join("; "))),await He(E.value.id,!0)):m.warning("没有工具需要同步"):(q.value=o.data.error||"同步失败",m.error(`同步工具失败: ${q.value}`))}catch(o){q.value=((e=(n=o.response)==null?void 0:n.data)==null?void 0:e.error)||o.message,m.error(`同步工具失败: ${q.value}`)}finally{B.value=!1}}function et(n){var o,f,u;const e=((o=n.config)==null?void 0:o.toolCount)??((u=(f=n.config)==null?void 0:f.tools)==null?void 0:u.length);return e!=null&&e>0?e:null}function tt(n){var f,u,d,k,w;const e=((f=n.config)==null?void 0:f.toolCount)??((d=(u=n.config)==null?void 0:u.tools)==null?void 0:d.length),o=((w=(k=n.config)==null?void 0:k.disabledTools)==null?void 0:w.length)||0;if(e!=null&&e>0){const y=Math.max(0,e-o);return y>0?y:null}return null}function mt(n){const e=n.originalToolName||n.name;return a.value.disabledTools.includes(e)}function ft(n,e){const o=n.originalToolName||n.name;e?a.value.disabledTools=a.value.disabledTools.filter(f=>f!==o):a.value.disabledTools.includes(o)||a.value.disabledTools.push(o)}function Ke(){a.value.disabledTools=[],m.success("已全选所有工具")}function yt(){const n=J.value.map(o=>o.originalToolName||o.name),e=new Set(a.value.disabledTools);a.value.disabledTools=n.filter(o=>!e.has(o)),m.success("已反选工具")}function we(n){return n.originalToolName||n.name}function Ee(n){return Ne.value[n.name]||"暂无描述"}function ot(n,e,o){var $,M,re,ne;de.value;const f=we(n),u=a.value.toolPatches,d=F.value,k=u[f],w=d[f],y=($=k==null?void 0:k.fieldDescriptions)==null?void 0:$[e];return y!=null&&y!==""?y:((ne=(re=(M=w==null?void 0:w.inputSchema)==null?void 0:M.properties)==null?void 0:re[e])==null?void 0:ne.description)||"暂无描述"}function st(n){var d;const e=we(n),o=a.value.toolPatches[e],f=o==null?void 0:o.description;if(f==null||f==="")return!1;const u=((d=F.value[e])==null?void 0:d.description)||n.description||"暂无描述";return console.log(`[hasCustomDescription] Tool ${e}:`,{hasCustomDescription:!!f,customDescription:f==null?void 0:f.trim(),originalDescription:u==null?void 0:u.trim(),areDifferent:(f==null?void 0:f.trim())!==(u==null?void 0:u.trim()),toolPatches:a.value.toolPatches[e],originalTools:F.value[e],formToolPatches:a.value.toolPatches,allOriginalTools:F.value,toolKey:e,toolName:n.name,toolOriginalToolName:n.originalToolName}),!F.value[e]&&f?(console.log(`[hasCustomDescription] Tool ${e}: originalTools not loaded yet, but has custom description, returning true`),!0):(console.log(`[hasCustomDescription] Tool ${e}: toolPatches 中有描述,返回 true 以显示还原按钮`),!0)}function nt(n,e){var k,w,y,se,$,M,re,ne,D,le,Z,ie,b;const o=we(n),f=a.value.toolPatches[o],u=(k=f==null?void 0:f.fieldDescriptions)==null?void 0:k[e];if(u==null||u==="")return!1;const d=(($=(se=(y=(w=F.value[o])==null?void 0:w.inputSchema)==null?void 0:y.properties)==null?void 0:se[e])==null?void 0:$.description)||((ne=(re=(M=n.inputSchema)==null?void 0:M.properties)==null?void 0:re[e])==null?void 0:ne.description)||"暂无描述";return console.log(`[hasCustomFieldDescription] Tool ${o}, Field ${e}:`,{hasCustomDescription:!!u,customDescription:u==null?void 0:u.trim(),originalDescription:d==null?void 0:d.trim(),areDifferent:(u==null?void 0:u.trim())!==(d==null?void 0:d.trim()),fieldPatches:(D=f==null?void 0:f.fieldDescriptions)==null?void 0:D[e],originalFieldDesc:(b=(ie=(Z=(le=F.value[o])==null?void 0:le.inputSchema)==null?void 0:Z.properties)==null?void 0:ie[e])==null?void 0:b.description,hasOriginalTool:!!F.value[o],toolKey:o,toolName:n.name,toolOriginalToolName:n.originalToolName}),!F.value[o]&&u?(console.log(`[hasCustomFieldDescription] Tool ${o}, Field ${e}: originalTools not loaded yet, but has custom description, returning true`),!0):(console.log(`[hasCustomFieldDescription] Tool ${o}, Field ${e}: toolPatches 中有字段描述,返回 true 以显示还原按钮`),!0)}function Ge(n,e,o,f){var u,d,k,w,y,se;if(e==="tool"){ye.value=n,he.value=null;const $=J.value.find(M=>M.name===n);ve.value=Ee($),Ue.value="tool",xe.value=we($)}else{he.value=n,ye.value=null;const $=J.value.find(M=>M.name===o);if($&&((d=(u=$.inputSchema)==null?void 0:u.properties)!=null&&d[f])){const M=$?we($):"";(se=(y=(w=(k=F.value[M])==null?void 0:k.inputSchema)==null?void 0:w.properties)==null?void 0:y[f])!=null&&se.description||$.inputSchema.properties[f].description,ve.value=ot($,f)}else ve.value="";Ue.value="field",xe.value=$?we($):o||"",Te.value=f||""}}function Re(n,e,o,f){var u,d,k,w,y,se,$,M,re;if(e==="tool"){const ne=J.value.find(ie=>ie.name===n),D=ne?we(ne):n,le=((u=F.value[D])==null?void 0:u.description)||(ne==null?void 0:ne.description)||"暂无描述",Z=ve.value.trim();Z===le.trim()||Z===""?a.value.toolPatches[D]&&(delete a.value.toolPatches[D].description,Object.keys(a.value.toolPatches[D]).length===0&&delete a.value.toolPatches[D]):(a.value.toolPatches[D]||(a.value.toolPatches[D]={}),a.value.toolPatches[D].description=Z),ye.value=null,m.success("工具描述已保存")}else{const ne=J.value.find(b=>b.name===o),D=ne?we(ne):o||xe.value,le=f||Te.value,Z=((y=(w=(k=(d=F.value[D])==null?void 0:d.inputSchema)==null?void 0:k.properties)==null?void 0:w[le])==null?void 0:y.description)||((M=($=(se=ne==null?void 0:ne.inputSchema)==null?void 0:se.properties)==null?void 0:$[le])==null?void 0:M.description)||"暂无描述",ie=ve.value.trim();ie===Z.trim()||ie===""?(re=a.value.toolPatches[D])!=null&&re.fieldDescriptions&&(delete a.value.toolPatches[D].fieldDescriptions[le],Object.keys(a.value.toolPatches[D].fieldDescriptions).length===0&&delete a.value.toolPatches[D].fieldDescriptions,Object.keys(a.value.toolPatches[D]).length===0&&delete a.value.toolPatches[D]):(a.value.toolPatches[D]||(a.value.toolPatches[D]={}),a.value.toolPatches[D].fieldDescriptions||(a.value.toolPatches[D].fieldDescriptions={}),a.value.toolPatches[D].fieldDescriptions[le]=ie),he.value=null,m.success("字段描述已保存")}ve.value="",xe.value="",Te.value="",a.value.toolPatches=JSON.parse(JSON.stringify(a.value.toolPatches)),de.value++,console.log("保存描述后的 toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),Fe(()=>{console.log("保存描述后 DOM 更新完成")})}function Ze(){ye.value=null,he.value=null,ve.value="",xe.value="",Te.value=""}async function i(n,e,o,f){var u,d,k,w,y,se,$,M,re,ne,D;if(e==="tool"){const le=J.value.find(ie=>ie.name===n),Z=le?we(le):n;if(a.value.toolPatches[Z]){const ie=a.value.toolPatches,b={};Object.keys(ie).forEach(X=>{if(X!==Z)b[X]={...ie[X]};else{const ge={...ie[X]};delete ge.description,Object.keys(ge).length>0&&(b[X]=ge)}}),a.value.toolPatches=b,de.value++,console.log("[resetDescription-tool] 还原后的 toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[resetDescription-tool] toolKey:",Z),console.log("[resetDescription-tool] 还原后的 patch:",a.value.toolPatches[Z]),console.log("[resetDescription-tool] originalTools:",JSON.stringify(F.value[Z],null,2)),console.log("[resetDescription-tool] toolDescriptionsMap 值:",Ne.value[le.name]),m.success("工具描述已还原")}}else{const le=J.value.find(b=>b.name===o),Z=le?we(le):o||xe.value,ie=f||Te.value;if((u=a.value.toolPatches[Z])!=null&&u.fieldDescriptions){const b=a.value.toolPatches,X={};Object.keys(b).forEach(We=>{if(We!==Z)X[We]={...b[We]};else{const _e={...b[We]};if(_e.fieldDescriptions){const ht={};Object.keys(_e.fieldDescriptions).forEach(wt=>{wt!==ie&&(ht[wt]=_e.fieldDescriptions[wt])}),Object.keys(ht).length>0?_e.fieldDescriptions=ht:delete _e.fieldDescriptions}Object.keys(_e).length>0&&(X[We]=_e)}}),a.value.toolPatches=JSON.parse(JSON.stringify(X)),de.value++,console.log("[resetDescription-field] 还原后的 toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("[resetDescription-field] actualToolKey:",Z),console.log("[resetDescription-field] actualFieldName:",ie),console.log("[resetDescription-field] 还原后的 patch:",a.value.toolPatches[Z]),console.log("[resetDescription-field] 还原后的 patch.fieldDescriptions:",(d=a.value.toolPatches[Z])==null?void 0:d.fieldDescriptions),console.log("[resetDescription-field] originalTools:",JSON.stringify(F.value[Z],null,2)),console.log("[resetDescription-field] originalTools 字段描述:",(se=(y=(w=(k=F.value[Z])==null?void 0:k.inputSchema)==null?void 0:w.properties)==null?void 0:y[ie])==null?void 0:se.description),await Fe();const ge=a.value.toolPatches[Z],be=($=ge==null?void 0:ge.fieldDescriptions)==null?void 0:$[ie],Vt=((D=(ne=(re=(M=F.value[Z])==null?void 0:M.inputSchema)==null?void 0:re.properties)==null?void 0:ne[ie])==null?void 0:D.description)||"暂无描述";console.log("[resetDescription-field] 还原后的 patch.fieldDescriptions:",ge==null?void 0:ge.fieldDescriptions),console.log("[resetDescription-field] 字段描述是否已删除:",be===void 0),console.log("[resetDescription-field] 期望的原始值:",Vt),de.value++,await Fe(),m.success("字段描述已还原")}}ve.value="",xe.value="",Te.value="",console.log("还原描述后的 toolPatches:",JSON.stringify(a.value.toolPatches,null,2)),console.log("还原描述后的 originalTools:",JSON.stringify(F.value,null,2)),Fe(()=>{console.log("DOM 更新完成,descriptionUpdateKey:",de.value)})}function s(n){Q.value.has(n)?Q.value.delete(n):(Q.value.clear(),Q.value.add(n))}async function v(){var n,e,o,f;try{if(T.value==="config"&&x.value==="json")try{const w=JSON.parse(a.value.configStr||"{}");Pe(w)}catch{throw new Error("配置 JSON 格式错误")}if(await((n=ee.value)==null?void 0:n.validate()),j.value=!0,J.value.length===0)try{const w={id:((e=E.value)==null?void 0:e.id)||Qe(),name:a.value.name,type:a.value.type,namespace:a.value.namespace,env:oe(a.value.env),config:{headers:oe(a.value.headers)}};a.value.type==="npm"?(w.package=a.value.package,w.version=a.value.version):a.value.type==="url"?w.url=a.value.url:a.value.type==="stdio"&&(w.command=a.value.command,w.args=a.value.args);const y=await pe.post("/mcp/inspect",w);J.value=y.data.data.tools||[],J.value.length>0&&m.info(`自动获取到 ${J.value.length} 个工具`)}catch(w){console.warn("自动获取工具列表失败:",w)}console.log("保存前的 toolPatches:",JSON.stringify(a.value.toolPatches,null,2));const u=Be();u.id=((o=E.value)==null?void 0:o.id)||Qe(),console.log("保存的组件配置:",JSON.stringify(u,null,2)),console.log("组件 config.toolPatches:",JSON.stringify((f=u.config)==null?void 0:f.toolPatches,null,2));const d=[...h.config.components],k=d.findIndex(w=>w.id===u.id);k!==-1?d[k]=u:d.push(u),C("update",{components:d}),R.value=!1,$e()}catch(u){console.error("保存错误:",u),m.error(u.message)}finally{j.value=!1}}async function Y(){var n,e;g.value=!0,N.value={current:0,total:0,currentComponent:""};try{let o=[],f=[];if(W.value.trim()){const d=JSON.parse(W.value).mcpServers||{};f=Object.entries(d),N.value.total=f.length;for(let k=0;k<f.length;k++){const[w,y]=f[k];N.value.current=k+1,N.value.currentComponent=w;const se=!!y.url,$={headers:y.headers,disabledTools:y.disabledTools,toolPatches:y.toolPatches};y.transportType&&($.transportType=y.transportType),y.type&&($.type=y.type);const M={id:Qe(),name:w,type:se?"url":"stdio",url:y.url,command:y.command,args:y.args||[],env:y.env,config:$};try{const re={...M,config:{headers:y.headers||{}}},D=(await pe.post("/mcp/inspect",re)).data.data.tools||[];D.length>0&&($.tools=D,M.config=$,console.log(`[导入] 组件 ${w} 解析到 ${D.length} 个工具`))}catch(re){console.warn(`[导入] 组件 ${w} 获取工具列表失败:`,re)}o.push(M)}}else if(I.value.trim()){const u=JSON.parse(I.value),d=Array.isArray(u)?u:u.components;N.value.total=d.length;for(let k=0;k<d.length;k++){const w=d[k];N.value.current=k+1,N.value.currentComponent=w.name||`组件 ${k+1}`;const y={...w,id:Qe()};if(!((n=y.config)!=null&&n.tools)&&(y.url||y.command||y.package))try{const se={...y,config:{...y.config,headers:((e=y.config)==null?void 0:e.headers)||{}}},M=(await pe.post("/mcp/inspect",se)).data.data.tools||[];M.length>0&&(y.config||(y.config={}),y.config.tools=M,console.log(`[导入] 组件 ${y.name} 解析到 ${M.length} 个工具`))}catch(se){console.warn(`[导入] 组件 ${y.name} 获取工具列表失败:`,se)}o.push(y)}}else throw new Error("请输入 JSON 内容");if(C("update",{components:[...h.config.components,...o]}),await new Promise(u=>setTimeout(u,800)),o.length>0){N.value.total=o.length,N.value.current=0;let u=0,d=0;for(let k=0;k<o.length;k++){const w=o[k];N.value.current=k+1,N.value.currentComponent=`正在同步工具: ${w.name}`;try{const y=await pe.post("/configs/sync-tools",{componentId:w.id});y.data.success?y.data.data.errors&&y.data.data.errors.length>0?(d++,console.warn(`[导入] 组件 ${w.name} 同步工具失败:`,y.data.data.errors.join("; "))):y.data.data.success>0&&(u++,console.log(`[导入] 组件 ${w.name} 同步了 ${y.data.data.success} 个工具`)):(d++,console.warn(`[导入] 组件 ${w.name} 同步工具失败:`,y.data.error))}catch(y){d++,console.warn(`[导入] 组件 ${w.name} 同步工具失败:`,y.message||y)}}u>0?m.success(`导入成功:${o.length} 个组件已添加,${u} 个组件的工具已同步`):d>0?m.warning(`导入完成:${o.length} 个组件已添加,但工具同步失败`):m.success(`导入成功:${o.length} 个组件已添加`)}A.value=!1,W.value="",I.value=""}catch(o){m.error(`导入失败: ${o.message}`)}finally{g.value=!1,N.value={current:0,total:0,currentComponent:""}}}function ue(){const n={};h.config.components.forEach(d=>{var w,y,se;const k={env:d.env};if(d.type==="url")k.url=d.url,(w=d.config)!=null&&w.headers&&(k.headers=d.config.headers);else{let $=d.command,M=d.args||[];d.type==="npm"&&($="npx",M=["-y",d.package],d.version&&d.version!=="latest"&&(M[1]=`${d.package}@${d.version}`)),k.command=$,k.args=M}(y=d.config)!=null&&y.disabledTools&&(k.disabledTools=d.config.disabledTools),(se=d.config)!=null&&se.toolPatches&&(k.toolPatches=d.config.toolPatches),n[d.name]=k});const e=JSON.stringify({mcpServers:n},null,2),o=new Blob([e],{type:"application/json"}),f=URL.createObjectURL(o),u=document.createElement("a");u.href=f,u.download="cursor-mcp.json",u.click(),URL.revokeObjectURL(f),m.success("已导出 Cursor 格式配置")}function $e(){E.value=null,a.value={name:"",type:"npm",package:"",version:"",url:"",command:"",args:[],env:[],headers:[],disabledTools:[],toolPatches:{},namespace:"",extraConfig:{},rootExtra:{},configStr:"{}",disabled:!1},T.value="config",x.value="form",J.value=[],q.value="",ye.value=null,he.value=null,ve.value="",xe.value="",Te.value=""}return Ce(()=>R.value,n=>{n||$e()}),(n,e)=>(O(),V("div",uo,[p.config.components&&p.config.components.length>0?(O(),V("div",co,[c(l(G),{type:"primary",size:"large",class:"add-component-btn",onClick:e[0]||(e[0]=o=>R.value=!0)},{icon:r(()=>[...e[28]||(e[28]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[e[29]||(e[29]=U(" 添加组件 ",-1))]),_:1}),t("div",po,[c(l(G),{size:"large",class:"secondary-btn",onClick:e[1]||(e[1]=o=>A.value=!0)},{icon:r(()=>[...e[30]||(e[30]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[31]||(e[31]=U(" 导入 JSON ",-1))]),_:1}),c(l(G),{size:"large",class:"secondary-btn",onClick:ue},{icon:r(()=>[...e[32]||(e[32]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[33]||(e[33]=U(" 导出配置 ",-1))]),_:1})])])):ce("",!0),p.config.components&&p.config.components.length>0?(O(),V("div",vo,[c(l(Gt),{class:"component-list","show-divider":!1},{default:r(()=>[(O(!0),V(rt,null,lt(p.config.components,o=>(O(),De(l(Wt),{key:o.id},{default:r(()=>[t("div",go,[t("div",mo,[t("div",fo,[t("div",yo,ae(o.name.charAt(0).toUpperCase()),1)]),t("div",ho,[t("div",wo,[t("span",bo,ae(o.name),1),o.namespace&&o.namespace.trim()!==""?(O(),De(l(Ye),{key:0,size:"small",type:"warning",style:{"margin-left":"8px"}},{default:r(()=>[U(" 命名空间:"+ae(o.namespace.trim()),1)]),_:2},1024)):ce("",!0),et(o)!==null?(O(),De(l(Ye),{key:1,size:"small",type:"info"},{default:r(()=>[U(ae(et(o))+" 工具 ",1)]),_:2},1024)):ce("",!0),tt(o)!==null?(O(),De(l(Ye),{key:2,size:"small",type:"success"},{default:r(()=>[U(ae(tt(o))+" 可调用 ",1)]),_:2},1024)):ce("",!0)])]),t("div",ko,[c(l(Zt),{size:"small",value:!o.disabled,"onUpdate:value":f=>Oe(o,f)},{checked:r(()=>[...e[34]||(e[34]=[U("启用",-1)])]),unchecked:r(()=>[...e[35]||(e[35]=[U("禁用",-1)])]),_:1},8,["value","onUpdate:value"]),c(l(G),{size:"small",loading:_.value[o.id],onClick:f=>gt(o),title:"同步工具配置"},{icon:r(()=>[...e[36]||(e[36]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[37]||(e[37]=U(" 同步工具 ",-1))]),_:1},8,["loading","onClick"]),c(l(G),{size:"small",onClick:f=>P(o)},{default:r(()=>[...e[38]||(e[38]=[U("配置",-1)])]),_:1},8,["onClick"]),c(l(G),{size:"small",type:"error",ghost:"",onClick:f=>vt(o.id)},{default:r(()=>[...e[39]||(e[39]=[U("移除",-1)])]),_:1},8,["onClick"])])]),o.config?(O(),V("div",Co)):ce("",!0)])]),_:2},1024))),128))]),_:1})])):(O(),V("div",xo,[t("div",To,[e[44]||(e[44]=zt('<div class="empty-icon" data-v-46d5bbd7><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-46d5bbd7><path d="M12 2L2 7l10 5 10-5-10-5z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-46d5bbd7></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-46d5bbd7></path></svg></div><h3 class="empty-title" data-v-46d5bbd7>还没有添加 MCP 组件</h3><p class="empty-description" data-v-46d5bbd7>点击上方"添加组件"按钮开始添加你的第一个 MCP 组件,或者使用"导入 JSON"快速导入配置</p>',3)),t("div",$o,[c(l(G),{type:"primary",size:"large",onClick:e[2]||(e[2]=o=>R.value=!0)},{icon:r(()=>[...e[40]||(e[40]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[e[41]||(e[41]=U(" 添加组件 ",-1))]),_:1}),c(l(G),{size:"large",onClick:e[3]||(e[3]=o=>A.value=!0)},{icon:r(()=>[...e[42]||(e[42]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[43]||(e[43]=U(" 导入 JSON ",-1))]),_:1})])])])),c(l(it),{show:R.value,"onUpdate:show":e[24]||(e[24]=o=>R.value=o),preset:"card",bordered:!1,class:"component-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:r(()=>[t("div",So,[e[45]||(e[45]=t("div",{class:"modal-icon"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"})])],-1)),t("div",null,[t("h3",Po,ae(E.value?"配置 MCP 组件":"添加 MCP 组件"),1),t("p",No,ae(E.value?"修改组件配置和工具设置":"创建新的 MCP 服务组件"),1)])])]),footer:r(()=>[t("div",gs,[c(l(G),{size:"large",onClick:e[23]||(e[23]=o=>R.value=!1)},{default:r(()=>[...e[72]||(e[72]=[U("取消",-1)])]),_:1}),c(l(G),{type:"primary",size:"large",onClick:v},{default:r(()=>[U(ae(E.value?"保存修改":"添加组件"),1)]),_:1})])]),default:r(()=>[t("div",Mo,[c(l(_t),{value:T.value,"onUpdate:value":[e[22]||(e[22]=o=>T.value=o),te],type:"line",animated:"",size:"large",class:"component-config-tabs"},{default:r(()=>[c(l(ut),{name:"config",tab:"基础配置"},{default:r(()=>[t("div",jo,[t("div",Oo,[c(l(Qt),{value:x.value,"onUpdate:value":e[4]||(e[4]=o=>x.value=o),size:"medium"},{default:r(()=>[c(l(Mt),{value:"form"},{default:r(()=>[...e[46]||(e[46]=[t("div",{class:"radio-btn-content"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"表单模式")],-1)])]),_:1}),c(l(Mt),{value:"json"},{default:r(()=>[...e[47]||(e[47]=[t("div",{class:"radio-btn-content"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("polyline",{points:"16 18 22 12 16 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("polyline",{points:"8 6 2 12 8 18",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),t("span",null,"JSON 模式")],-1)])]),_:1})]),_:1},8,["value"])]),Pt(t("div",Ao,[c(l(Ft),{ref_key:"formRef",ref:ee,model:a.value,rules:H,"label-placement":"top",size:"large"},{default:r(()=>[t("div",Do,[e[51]||(e[51]=t("h4",{class:"section-title"},"基础信息",-1)),t("div",zo,[c(l(fe),{path:"name"},{label:r(()=>[...e[48]||(e[48]=[t("div",{class:"form-label"},[t("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"组件名称")],-1)])]),default:r(()=>[c(l(ke),{value:a.value.name,"onUpdate:value":e[5]||(e[5]=o=>a.value.name=o),placeholder:"例如: filesystem, github"},null,8,["value"])]),_:1}),c(l(fe),{path:"type"},{label:r(()=>[...e[49]||(e[49]=[t("div",{class:"form-label"},[t("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"组件类型")],-1)])]),default:r(()=>[c(l(Jt),{value:a.value.type,"onUpdate:value":e[6]||(e[6]=o=>a.value.type=o),options:K},null,8,["value"])]),_:1}),c(l(fe),{path:"namespace"},{label:r(()=>[...e[50]||(e[50]=[t("div",{class:"form-label"},[t("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"命名空间(可选)")],-1)])]),default:r(()=>[c(l(ke),{value:a.value.namespace,"onUpdate:value":e[7]||(e[7]=o=>a.value.namespace=o),placeholder:"用于工具名前缀"},null,8,["value"])]),_:1})])]),a.value.type==="npm"?(O(),V("div",_o,[e[52]||(e[52]=t("h4",{class:"section-title"},"NPM 配置",-1)),t("div",Fo,[c(l(fe),{path:"package",label:"NPM 包名",class:"col-span-2"},{default:r(()=>[c(l(ke),{value:a.value.package,"onUpdate:value":e[8]||(e[8]=o=>a.value.package=o),placeholder:"@modelcontextprotocol/server-filesystem"},null,8,["value"])]),_:1}),c(l(fe),{path:"version",label:"版本"},{default:r(()=>[c(l(ke),{value:a.value.version,"onUpdate:value":e[9]||(e[9]=o=>a.value.version=o),placeholder:"latest"},null,8,["value"])]),_:1})])])):ce("",!0),a.value.type==="url"?(O(),V("div",Jo,[e[53]||(e[53]=t("h4",{class:"section-title"},"URL 配置",-1)),c(l(fe),{path:"url",label:"服务地址"},{default:r(()=>[c(l(ke),{value:a.value.url,"onUpdate:value":e[10]||(e[10]=o=>a.value.url=o),placeholder:"http://localhost:3000/mcp"},null,8,["value"])]),_:1}),c(l(fe),{label:"HTTP Headers"},{default:r(()=>[c(l(bt),{value:a.value.headers,"onUpdate:value":e[11]||(e[11]=o=>a.value.headers=o),preset:"pair","key-placeholder":"Header 名称","value-placeholder":"Header 值"},null,8,["value"])]),_:1})])):ce("",!0),a.value.type==="stdio"?(O(),V("div",Uo,[e[54]||(e[54]=t("h4",{class:"section-title"},"Stdio 配置",-1)),c(l(fe),{path:"command",label:"执行命令"},{default:r(()=>[c(l(ke),{value:a.value.command,"onUpdate:value":e[12]||(e[12]=o=>a.value.command=o),placeholder:"node, python, uvx"},null,8,["value"])]),_:1}),c(l(fe),{label:"命令行参数"},{default:r(()=>[c(l(bt),{value:a.value.args,"onUpdate:value":e[13]||(e[13]=o=>a.value.args=o),placeholder:"输入参数",min:0},null,8,["value"])]),_:1}),c(l(fe),{label:"环境变量"},{default:r(()=>[c(l(bt),{value:a.value.env,"onUpdate:value":e[14]||(e[14]=o=>a.value.env=o),preset:"pair","key-placeholder":"变量名","value-placeholder":"变量值"},null,8,["value"])]),_:1})])):ce("",!0)]),_:1},8,["model"])],512),[[Nt,x.value==="form"]]),Pt(t("div",Bo,[c(l(Le),{type:"info",bordered:!1,class:"json-alert"},{icon:r(()=>[...e[55]||(e[55]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[56]||(e[56]=U(" 直接编辑组件的完整 JSON 配置,切换回表单模式或保存时会自动同步 ",-1))]),_:1}),t("div",Eo,[c(ct,{modelValue:a.value.configStr,"onUpdate:modelValue":e[15]||(e[15]=o=>a.value.configStr=o),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),[[Nt,x.value==="json"]])])]),_:1}),c(l(ut),{name:"tools",tab:"工具管理"},{default:r(()=>[t("div",Ro,[t("div",Vo,[c(l(Le),{type:"info",bordered:!1,class:"tools-info-alert"},{icon:r(()=>[...e[57]||(e[57]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[58]||(e[58]=U(' 工具列表来自已保存的配置。您可以禁用特定工具或编辑其 Schema。点击"同步工具"可从 MCP 组件更新工具列表。双击工具描述或字段描述可进行编辑。 ',-1))]),_:1}),t("div",Io,[c(l(G),{type:"primary",size:"large",loading:B.value,onClick:Xe,class:"sync-btn"},{icon:r(()=>[...e[59]||(e[59]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[U(" "+ae(B.value?"同步中...":"同步工具配置"),1)]),_:1},8,["loading"]),J.value.length>0?(O(),V("div",Lo,[c(l(G),{size:"medium",onClick:Ke,class:"batch-btn"},{default:r(()=>[...e[60]||(e[60]=[U(" 全选 ",-1)])]),_:1}),c(l(G),{size:"medium",onClick:yt,class:"batch-btn"},{default:r(()=>[...e[61]||(e[61]=[U(" 反选 ",-1)])]),_:1})])):ce("",!0)])]),J.value.length>0?(O(),V("div",qo,[t("div",Ho,[(O(!0),V(rt,null,lt(J.value,o=>(O(),V("div",{key:o.name,class:je(["tool-card",{"tool-expanded":Q.value.has(o.name)}]),onClick:f=>s(o.name)},[t("div",Go,[t("div",Zo,[c(l(Ut),{checked:!mt(o),onClick:e[16]||(e[16]=Me(()=>{},["stop"])),"onUpdate:checked":f=>ft(o,f),size:"large"},null,8,["checked","onUpdate:checked"])]),t("div",Wo,[c(l(Yt),{trigger:"hover","show-arrow":!0,placement:"top"},{trigger:r(()=>[t("h5",{class:"tool-name",title:Ee(o)},ae(o.originalToolName||o.name),9,Qo)]),default:r(()=>[t("div",Yo,ae(Ee(o)),1)]),_:2},1024)]),t("div",Xo,[t("div",{class:je(["expand-icon",{expanded:Q.value.has(o.name)}])},[...e[62]||(e[62]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("polyline",{points:"6 9 12 15 18 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],2)])]),c(l(Xt),{show:Q.value.has(o.name)},{default:r(()=>{var f;return[t("div",{class:"tool-details",onClick:e[21]||(e[21]=Me(()=>{},["stop"]))},[t("div",es,[t("div",{class:je(["detail-content",{"has-custom-description":st(o)}])},[ye.value!==o.name?(O(),V("div",{onDblclick:Me(u=>Ge(o.name,"tool"),["stop"]),class:"description-text-editable",key:`tool-desc-${o.name}-${de.value}`},ae(Ee(o)),41,ts)):(O(),De(l(ke),{key:1,value:ve.value,"onUpdate:value":e[17]||(e[17]=u=>ve.value=u),type:"textarea",rows:3,onBlur:u=>Re(o.name,"tool"),onKeydown:[at(Me(u=>Re(o.name,"tool"),["ctrl"]),["enter"]),at(Ze,["esc"])],class:"description-input",placeholder:"输入工具描述",onClick:e[18]||(e[18]=Me(()=>{},["stop"]))},null,8,["value","onBlur","onKeydown"])),st(o)&&ye.value!==o.name?(O(),V("div",os,[e[64]||(e[64]=t("span",{class:"custom-badge",title:"已自定义描述"},"已修改",-1)),c(l(G),{text:"",size:"small",onClick:Me(u=>i(o.name,"tool"),["stop"]),class:"reset-btn"},{default:r(()=>[...e[63]||(e[63]=[U(" 还原 ",-1)])]),_:1},8,["onClick"])])):ce("",!0)],2)]),(f=o.inputSchema)!=null&&f.properties&&Object.keys(o.inputSchema.properties).length>0?(O(),V("div",ss,[e[67]||(e[67]=t("div",{class:"detail-section-header"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",stroke:"currentColor","stroke-width":"2"})]),t("h6",null,"参数 Schema")],-1)),t("div",ns,[(O(!0),V(rt,null,lt(o.inputSchema.properties,(u,d)=>{var k;return O(),V("div",{key:String(d),class:"param-item"},[t("div",as,[t("span",rs,ae(d),1),u.type?(O(),V("span",ls,ae(u.type),1)):ce("",!0),(k=o.inputSchema.required)!=null&&k.includes(String(d))?(O(),V("span",is,"必填")):ce("",!0)]),t("div",{class:je(["param-description-wrapper",{"has-custom-description":nt(o,String(d))}])},[he.value!==`${o.name}.${String(d)}`?(O(),V("div",{class:"param-description",onDblclick:Me(w=>Ge(`${o.name}.${String(d)}`,"field",o.name,String(d)),["stop"]),key:`field-desc-${o.name}-${String(d)}-${de.value}`},ae(ot(o,String(d),u.description)),41,us)):(O(),De(l(ke),{key:1,value:ve.value,"onUpdate:value":e[19]||(e[19]=w=>ve.value=w),type:"textarea",rows:2,onBlur:w=>Re(`${o.name}.${String(d)}`,"field",o.name,String(d)),onKeydown:[at(Me(w=>Re(`${o.name}.${String(d)}`,"field",o.name,String(d)),["ctrl"]),["enter"]),at(Ze,["esc"])],class:"description-input",placeholder:"输入字段描述",onClick:e[20]||(e[20]=Me(()=>{},["stop"]))},null,8,["value","onBlur","onKeydown"])),nt(o,String(d))&&he.value!==`${o.name}.${String(d)}`?(O(),V("div",cs,[e[66]||(e[66]=t("span",{class:"custom-badge",title:"已自定义描述"},"已修改",-1)),c(l(G),{text:"",size:"small",onClick:Me(w=>i(`${o.name}.${String(d)}`,"field",o.name,String(d)),["stop"]),class:"reset-btn"},{default:r(()=>[...e[65]||(e[65]=[U(" 还原 ",-1)])]),_:1},8,["onClick"])])):ce("",!0)],2)])}),128))])])):(O(),V("div",ds,[...e[68]||(e[68]=[t("div",{class:"empty-params"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),t("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})]),t("p",null,"该工具没有输入参数")],-1)])]))])]}),_:2},1032,["show"])],10,Ko))),128))])])):L.value?ce("",!0):(O(),V("div",ps,[...e[69]||(e[69]=[t("div",{class:"empty-content"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("h4",null,"暂无工具列表"),t("p",null,'点击上方"同步工具配置"按钮从 MCP 组件获取工具列表')],-1)])])),q.value?(O(),V("div",vs,[c(l(Le),{type:"error",bordered:!1},{icon:r(()=>[...e[70]||(e[70]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[...e[71]||(e[71]=[U("连接失败",-1)])]),default:r(()=>[U(" "+ae(q.value),1)]),_:1})])):ce("",!0)])]),_:1})]),_:1},8,["value"])])]),_:1},8,["show"]),c(l(it),{show:A.value,"onUpdate:show":e[27]||(e[27]=o=>A.value=o),preset:"card",title:"导入组件 JSON",bordered:!1,class:"import-modal",style:{width:"800px",maxWidth:"90vw"}},{footer:r(()=>[t("div",ys,[c(l(G),{size:"large",onClick:e[26]||(e[26]=o=>A.value=!1),disabled:g.value},{default:r(()=>[...e[76]||(e[76]=[U("取消",-1)])]),_:1},8,["disabled"]),c(l(G),{type:"primary",size:"large",onClick:Y,loading:g.value},{default:r(()=>[U(ae(g.value?`导入中... (${N.value.current}/${N.value.total})`:"导入"),1)]),_:1},8,["loading"])])]),default:r(()=>[c(l(Le),{type:"info",bordered:!1,style:{"margin-bottom":"20px"}},{icon:r(()=>[...e[73]||(e[73]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[e[74]||(e[74]=U(" 粘贴 Cursor MCP 配置的 JSON(mcpServers 对象) ",-1))]),_:1}),g.value?(O(),De(l(Le),{key:0,type:"info",bordered:!1,style:{"margin-bottom":"20px"}},{icon:r(()=>[c(l(to),{size:"small"})]),default:r(()=>[t("div",null,[e[75]||(e[75]=t("div",{style:{"margin-bottom":"8px"}},[t("strong",null,"正在导入组件...")],-1)),t("div",ms,[U(ae(N.value.currentComponent)+" ",1),N.value.total>0?(O(),V("span",fs," ("+ae(N.value.current)+"/"+ae(N.value.total)+") ",1)):ce("",!0)]),N.value.total>0?(O(),De(l(eo),{key:0,percentage:Math.round(N.value.current/N.value.total*100),"show-indicator":!1,style:{"margin-top":"8px"}},null,8,["percentage"])):ce("",!0)])]),_:1})):ce("",!0),c(ct,{modelValue:W.value,"onUpdate:modelValue":e[25]||(e[25]=o=>W.value=o),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"])]))}}),Tn=pt(hs,[["__scopeId","data-v-46d5bbd7"]]);function Je(p){return!p||typeof p!="string"?"Unknown":p.split(/[^a-zA-Z0-9_$]+/).filter(h=>h.length>0).map(h=>h.split("_").filter(C=>C.length>0).map(C=>C.charAt(0).toUpperCase()+C.slice(1).toLowerCase()).join("")).join("")||"Unknown"}function Dt(p){return Je(p)}function Ae(p){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p)?`"${p}"`:`"${p.replace(/"/g,'\\"')}"`}function St(p){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p)?p:`"${p.replace(/"/g,'\\"')}"`}function qe(p,z="",h=0){if(h>10)return console.warn("JSON Schema conversion reached maximum depth, returning any"),"any";if(!p||typeof p!="object")return"any";try{if(p.type)switch(p.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return p.items?`Array<${qe(p.items,z,h+1)}>`:"any[]";case"object":if(p.properties){const C=[],m=Array.isArray(p.required)?p.required:[];for(const[R,T]of Object.entries(p.properties))try{const x=T,A=St(R),L=m.includes(R)?"":"?",B=qe(x,z+" ",h+1),q=x&&typeof x=="object"&&x.description?`/** ${String(x.description).replace(/\*\//g,"* /")} */
|
|
2
|
+
${z} `:"";C.push(`${q}${A}${L}: ${B};`)}catch(x){console.warn(`Failed to process property ${R}:`,x)}return C.length===0?"Record<string, any>":`{
|
|
3
|
+
${z} ${C.join(`
|
|
4
|
+
${z} `)}
|
|
5
|
+
${z}}`}return"Record<string, any>";default:return"any"}if(p.anyOf&&Array.isArray(p.anyOf)){const C=p.anyOf.map(m=>qe(m,z,h+1)).filter(m=>m&&m!=="any");return C.length>0?C.join(" | "):"any"}if(p.oneOf&&Array.isArray(p.oneOf)){const C=p.oneOf.map(m=>qe(m,z,h+1)).filter(m=>m&&m!=="any");return C.length>0?C.join(" | "):"any"}if(p.allOf&&Array.isArray(p.allOf)){const C={type:"object",properties:{},required:[]};for(const m of p.allOf)m&&typeof m=="object"&&m.properties&&(C.properties={...C.properties,...m.properties}),m&&typeof m=="object"&&Array.isArray(m.required)&&(C.required=[...C.required||[],...m.required]);return qe(C,z,h+1)}return Array.isArray(p.enum)?p.enum.map(C=>typeof C=="string"?Ae(C):JSON.stringify(C)).join(" | "):"any"}catch(C){return console.warn("Error converting JSON Schema to TypeScript:",C,p),"any"}}function Bt(p){try{const{config:z,mcpTools:h=[],tables:C=[]}=p,m=z.variables.length>0?`type VarName = ${z.variables.map(g=>Ae(g.name)).join(" | ")};
|
|
6
|
+
|
|
7
|
+
`:"",R=C.map(g=>{const te=`${Je(g.name)}TableRow`,J=g.columns.map(Q=>{const F=St(Q.name),Ne={string:"string",number:"number",boolean:"boolean",date:"string",json:"any"}[Q.type]||"any",ye=Q.nullable?`${Ne} | null`:Ne,he=Q.nullable?"?":"";return` ${F}${he}: ${ye};`}).join(`
|
|
8
|
+
`);return`type ${te} = {
|
|
9
|
+
${J}
|
|
10
|
+
};
|
|
11
|
+
`}).join(`
|
|
12
|
+
`),T=C.length>0?`type TableName = ${C.map(g=>Ae(g.name)).join(" | ")};
|
|
13
|
+
|
|
14
|
+
`:"",x=h.length>0?`type ToolName = ${h.map(g=>{const N=g.originalToolName||g.name;return Ae(N)}).join(" | ")};
|
|
15
|
+
|
|
16
|
+
`:"",A=new Map;h.filter(g=>g&&g.name).forEach(g=>{try{const N=g.name||"Unknown",te=qe(g.inputSchema||{type:"object",properties:{}}),J=Dt(N);if(!J||J.trim()===""){console.warn(`[Context Types] Invalid type name for tool: ${N}`);return}const Q=`${J}Args`;if(!A.has(Q))A.set(Q,`type ${Q} = ${te};`);else{const F=A.get(Q);F&&F!==`type ${Q} = ${te};`&&console.warn(`[Context Types] Type ${Q} already exists with different definition for tool: ${N}`)}}catch(N){console.warn(`[Context Types] Failed to generate type for tool ${g==null?void 0:g.name}:`,N)}});const j=Array.from(A.values()).join(`
|
|
17
|
+
`),L=j?`${j}
|
|
18
|
+
|
|
19
|
+
`:"",B=h.filter(g=>g&&g.name).map(g=>{try{const N=g.originalToolName||g.name,te=Ae(N),J=g.name||"Unknown",Q=Dt(J);if(!Q||Q.trim()==="")return console.warn(`[Context Types] Invalid type name for tool: ${J}, skipping overload`),null;const F=`${Q}Args`;return A.has(F)||console.warn(`[Context Types] Type ${F} not found in type definitions for tool: ${J}`),`${g.description?` /**
|
|
20
|
+
* ${g.description.replace(/\*\//g,"* /")}
|
|
21
|
+
*
|
|
22
|
+
* @param toolName - 工具名称
|
|
23
|
+
* @param args - 工具参数
|
|
24
|
+
*/
|
|
25
|
+
`:" "}callTool(toolName: ${te}, args: ${F}): Promise<any>;`}catch(N){return console.warn(`Failed to generate overload for tool ${g==null?void 0:g.name}:`,N),null}}).filter(g=>g!==null).join(`
|
|
26
|
+
`),q=h.length>0?`${B}
|
|
27
|
+
/**
|
|
28
|
+
* 调用 MCP 工具
|
|
29
|
+
*
|
|
30
|
+
* @param toolName - 工具名称
|
|
31
|
+
* @param args - 工具参数
|
|
32
|
+
*/
|
|
33
|
+
callTool(toolName: ToolName, args: any): Promise<any>;`:`/**
|
|
34
|
+
* 调用 MCP 工具
|
|
35
|
+
*
|
|
36
|
+
* @param toolName - 工具名称
|
|
37
|
+
* @param args - 工具参数
|
|
38
|
+
*/
|
|
39
|
+
callTool(toolName: string, args: any): Promise<any>;`,E=z.variables.length>0?"get(name: VarName): string;":"get(name: string): string;",ee=C.map(g=>{const te=`${Je(g.name)}TableRow`;return` /**
|
|
40
|
+
* 获取指定表的所有数据行
|
|
41
|
+
*
|
|
42
|
+
* @param tableName - 表名
|
|
43
|
+
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // 获取 users 表的所有数据
|
|
47
|
+
* const allUsers = await context.tables.get('users');
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // 遍历所有用户
|
|
51
|
+
* const users = await context.tables.get('users');
|
|
52
|
+
* for (const user of users) {
|
|
53
|
+
* console.log(user.name, user.email);
|
|
54
|
+
* }
|
|
55
|
+
*/
|
|
56
|
+
get(tableName: ${Ae(g.name)}): Promise<Array<${te}>>;`}).join(`
|
|
57
|
+
`),W=C.length>0?`${ee}
|
|
58
|
+
/**
|
|
59
|
+
* 获取指定表的所有数据行
|
|
60
|
+
*
|
|
61
|
+
* @param tableName - 表名
|
|
62
|
+
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // 获取 users 表的所有数据
|
|
66
|
+
* const allUsers = await context.tables.get('users');
|
|
67
|
+
*/
|
|
68
|
+
get(tableName: TableName): Promise<Array<Record<string, any>>>;`:`/**
|
|
69
|
+
* 获取指定表的所有数据行
|
|
70
|
+
*
|
|
71
|
+
* @param tableName - 表名
|
|
72
|
+
* @returns 返回该表的所有数据行数组,每行是一个包含列数据的对象
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // 获取 users 表的所有数据
|
|
76
|
+
* const allUsers = await context.tables.get('users');
|
|
77
|
+
*/
|
|
78
|
+
get(tableName: string): Promise<Array<Record<string, any>>>;`,I=C.map(g=>{const te=`${Je(g.name)}TableRow`;return` /**
|
|
79
|
+
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
80
|
+
*
|
|
81
|
+
* @param tableName - 表名
|
|
82
|
+
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
83
|
+
* @returns 返回符合过滤条件的数据行数组
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // 查询所有年龄大于 18 的用户
|
|
87
|
+
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // 查询所有活跃用户
|
|
91
|
+
* const activeUsers = await context.tables.query('users', (row) => row.isActive === true);
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // 不传过滤函数,等同于 get(),返回所有数据
|
|
95
|
+
* const allUsers = await context.tables.query('users');
|
|
96
|
+
*/
|
|
97
|
+
query(tableName: ${Ae(g.name)}, filter?: (row: ${te}) => boolean): Promise<Array<${te}>>;`}).join(`
|
|
98
|
+
`),_=C.length>0?`${I}
|
|
99
|
+
/**
|
|
100
|
+
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
101
|
+
*
|
|
102
|
+
* @param tableName - 表名
|
|
103
|
+
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
104
|
+
* @returns 返回符合过滤条件的数据行数组
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* // 查询所有年龄大于 18 的用户
|
|
108
|
+
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
109
|
+
*/
|
|
110
|
+
query(tableName: TableName, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;`:`/**
|
|
111
|
+
* 查询指定表的数据,支持使用过滤函数筛选行
|
|
112
|
+
*
|
|
113
|
+
* @param tableName - 表名
|
|
114
|
+
* @param filter - 可选的过滤函数,接收一行数据作为参数,返回 true 表示保留该行
|
|
115
|
+
* @returns 返回符合过滤条件的数据行数组
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // 查询所有年龄大于 18 的用户
|
|
119
|
+
* const adults = await context.tables.query('users', (row) => row.age > 18);
|
|
120
|
+
*/
|
|
121
|
+
query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;`;return`
|
|
122
|
+
${m}${R}${T}${L}${x}declare interface Context {
|
|
123
|
+
user: {
|
|
124
|
+
id: string;
|
|
125
|
+
email: string;
|
|
126
|
+
role: 'admin' | 'user';
|
|
127
|
+
createdAt: Date;
|
|
128
|
+
updatedAt: Date;
|
|
129
|
+
};
|
|
130
|
+
http: {
|
|
131
|
+
get(url: string, options?: any): Promise<any>;
|
|
132
|
+
post(url: string, data?: any, options?: any): Promise<any>;
|
|
133
|
+
put(url: string, data?: any, options?: any): Promise<any>;
|
|
134
|
+
delete(url: string, options?: any): Promise<any>;
|
|
135
|
+
};
|
|
136
|
+
fs: {
|
|
137
|
+
readFile(path: string): Promise<string>;
|
|
138
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
139
|
+
exists(path: string): Promise<boolean>;
|
|
140
|
+
listDir(path: string): Promise<string[]>;
|
|
141
|
+
mkdir(path: string): Promise<void>;
|
|
142
|
+
isFile(path: string): Promise<boolean>;
|
|
143
|
+
};
|
|
144
|
+
cmd: {
|
|
145
|
+
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
146
|
+
};
|
|
147
|
+
utils: {
|
|
148
|
+
md5(input: string): string;
|
|
149
|
+
};
|
|
150
|
+
ripgrep: {
|
|
151
|
+
/**
|
|
152
|
+
* 搜索文件内容
|
|
153
|
+
*/
|
|
154
|
+
search(
|
|
155
|
+
pattern: string,
|
|
156
|
+
options?: {
|
|
157
|
+
/** 工作目录(相对于用户隔离目录) */
|
|
158
|
+
cwd?: string;
|
|
159
|
+
/** 是否大小写敏感 */
|
|
160
|
+
caseSensitive?: boolean;
|
|
161
|
+
/** 是否启用多行匹配 */
|
|
162
|
+
multiline?: boolean;
|
|
163
|
+
/** 文件过滤模式(glob 模式数组) */
|
|
164
|
+
files?: string[];
|
|
165
|
+
/** 排除文件模式(glob 模式数组) */
|
|
166
|
+
excludeFiles?: string[];
|
|
167
|
+
/** 每个文件的最大匹配数 */
|
|
168
|
+
maxCount?: number;
|
|
169
|
+
/** 总结果数的最大限制 */
|
|
170
|
+
maxResults?: number;
|
|
171
|
+
/** 最大递归深度 */
|
|
172
|
+
maxDepth?: number;
|
|
173
|
+
/** 匹配行之前显示的行数 */
|
|
174
|
+
contextBefore?: number;
|
|
175
|
+
/** 匹配行之后显示的行数 */
|
|
176
|
+
contextAfter?: number;
|
|
177
|
+
/** 匹配行前后显示的行数(等同于同时设置 contextBefore 和 contextAfter) */
|
|
178
|
+
context?: number;
|
|
179
|
+
/** 将模式视为固定字符串而非正则表达式 */
|
|
180
|
+
fixedStrings?: boolean;
|
|
181
|
+
/** 只匹配完整的单词 */
|
|
182
|
+
wordRegexp?: boolean;
|
|
183
|
+
/** 文件类型过滤(如:['js', 'ts']) */
|
|
184
|
+
fileTypes?: string[];
|
|
185
|
+
/** 排除的文件类型 */
|
|
186
|
+
excludeTypes?: string[];
|
|
187
|
+
/** 只返回包含匹配的文件名 */
|
|
188
|
+
filesWithMatches?: boolean;
|
|
189
|
+
/** 只返回每个文件的匹配数量 */
|
|
190
|
+
count?: boolean;
|
|
191
|
+
/** 忽略 .gitignore 和 .ignore 文件 */
|
|
192
|
+
noIgnore?: boolean;
|
|
193
|
+
/** 智能大小写:如果模式包含大写字母则大小写敏感 */
|
|
194
|
+
smartCase?: boolean;
|
|
195
|
+
}
|
|
196
|
+
): Promise<Array<{ file: string; line: number; text: string; column?: number; contextBefore?: string[]; contextAfter?: string[] }>>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 通过文件名模式搜索文件
|
|
200
|
+
*/
|
|
201
|
+
searchByPath(
|
|
202
|
+
pattern: string,
|
|
203
|
+
options?: {
|
|
204
|
+
/** 工作目录(相对于用户隔离目录) */
|
|
205
|
+
cwd?: string;
|
|
206
|
+
/** 是否大小写敏感 */
|
|
207
|
+
caseSensitive?: boolean;
|
|
208
|
+
/** 最大递归深度 */
|
|
209
|
+
maxDepth?: number;
|
|
210
|
+
/** 文件类型过滤(如:['js', 'ts']) */
|
|
211
|
+
fileTypes?: string[];
|
|
212
|
+
/** 排除的文件类型 */
|
|
213
|
+
excludeTypes?: string[];
|
|
214
|
+
/** 排除文件模式(glob 模式数组) */
|
|
215
|
+
excludeFiles?: string[];
|
|
216
|
+
/** 总结果数的最大限制 */
|
|
217
|
+
maxResults?: number;
|
|
218
|
+
/** 忽略 .gitignore 和 .ignore 文件 */
|
|
219
|
+
noIgnore?: boolean;
|
|
220
|
+
}
|
|
221
|
+
): Promise<string[]>;
|
|
222
|
+
};
|
|
223
|
+
mcp: {
|
|
224
|
+
${q}
|
|
225
|
+
listTools(): Promise<string[]>;
|
|
226
|
+
};
|
|
227
|
+
vars: {
|
|
228
|
+
${E}
|
|
229
|
+
has(name: string): boolean;
|
|
230
|
+
getAll(): Record<string, string>;
|
|
231
|
+
set(name: string, value: string, description?: string): void;
|
|
232
|
+
};
|
|
233
|
+
log: {
|
|
234
|
+
info(message: string, ...args: any[]): void;
|
|
235
|
+
error(message: string, ...args: any[]): void;
|
|
236
|
+
warn(message: string, ...args: any[]): void;
|
|
237
|
+
debug(message: string, ...args: any[]): void;
|
|
238
|
+
};
|
|
239
|
+
tables: {
|
|
240
|
+
/**
|
|
241
|
+
* 列出当前用户的所有表定义
|
|
242
|
+
*
|
|
243
|
+
* @returns 返回表定义数组,每个表定义包含:
|
|
244
|
+
* - id: 表的唯一标识符
|
|
245
|
+
* - name: 表名
|
|
246
|
+
* - description: 表的描述(可选)
|
|
247
|
+
* - columns: 列定义数组,每个列包含 name(列名)、type(类型)、nullable(是否可为空)
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* // 获取所有表定义
|
|
251
|
+
* const tables = await context.tables.list();
|
|
252
|
+
* console.log('共有', tables.length, '张表');
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* // 遍历所有表并打印表名和列信息
|
|
256
|
+
* const tables = await context.tables.list();
|
|
257
|
+
* for (const table of tables) {
|
|
258
|
+
* console.log('表名:', table.name);
|
|
259
|
+
* console.log('列数:', table.columns.length);
|
|
260
|
+
* table.columns.forEach(col => {
|
|
261
|
+
* console.log(' -', col.name + ':', col.type + (col.nullable ? ' (可为空)' : ''));
|
|
262
|
+
* });
|
|
263
|
+
* }
|
|
264
|
+
*/
|
|
265
|
+
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
266
|
+
${W}
|
|
267
|
+
${_}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
`}catch(z){return console.error("Error generating context type definition:",z),`
|
|
271
|
+
declare interface Context {
|
|
272
|
+
user: {
|
|
273
|
+
id: string;
|
|
274
|
+
email: string;
|
|
275
|
+
role: 'admin' | 'user';
|
|
276
|
+
createdAt: Date;
|
|
277
|
+
updatedAt: Date;
|
|
278
|
+
};
|
|
279
|
+
http: {
|
|
280
|
+
get(url: string, options?: any): Promise<any>;
|
|
281
|
+
post(url: string, data?: any, options?: any): Promise<any>;
|
|
282
|
+
put(url: string, data?: any, options?: any): Promise<any>;
|
|
283
|
+
delete(url: string, options?: any): Promise<any>;
|
|
284
|
+
};
|
|
285
|
+
fs: {
|
|
286
|
+
readFile(path: string): Promise<string>;
|
|
287
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
288
|
+
exists(path: string): Promise<boolean>;
|
|
289
|
+
listDir(path: string): Promise<string[]>;
|
|
290
|
+
mkdir(path: string): Promise<void>;
|
|
291
|
+
isFile(path: string): Promise<boolean>;
|
|
292
|
+
};
|
|
293
|
+
cmd: {
|
|
294
|
+
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
295
|
+
};
|
|
296
|
+
utils: {
|
|
297
|
+
md5(input: string): string;
|
|
298
|
+
};
|
|
299
|
+
mcp: {
|
|
300
|
+
callTool(toolName: string, args: any): Promise<any>;
|
|
301
|
+
listTools(): Promise<string[]>;
|
|
302
|
+
};
|
|
303
|
+
vars: {
|
|
304
|
+
get(name: string): string;
|
|
305
|
+
has(name: string): boolean;
|
|
306
|
+
getAll(): Record<string, string>;
|
|
307
|
+
set(name: string, value: string, description?: string): void;
|
|
308
|
+
};
|
|
309
|
+
log: {
|
|
310
|
+
info(message: string, ...args: any[]): void;
|
|
311
|
+
error(message: string, ...args: any[]): void;
|
|
312
|
+
warn(message: string, ...args: any[]): void;
|
|
313
|
+
debug(message: string, ...args: any[]): void;
|
|
314
|
+
};
|
|
315
|
+
tables: {
|
|
316
|
+
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
317
|
+
get(tableName: string): Promise<Array<Record<string, any>>>;
|
|
318
|
+
query(tableName: string, filter?: (row: Record<string, any>) => boolean): Promise<Array<Record<string, any>>>;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
`}}function Et(p){const{tables:z=[]}=p,h="callTool(toolName: any, args: any): Promise<any>;",C=z.map(j=>{const B=`${Je(j.name)}TableRow`,q=j.columns.map(E=>{const ee=St(E.name),I={string:"string",number:"number",boolean:"boolean",date:"string",json:"any"}[E.type]||"any",_=E.nullable?`${I} | null`:I,g=E.nullable?"?":"";return` ${ee}${g}: ${_};`}).join(`
|
|
322
|
+
`);return`type ${B} = {
|
|
323
|
+
${q}
|
|
324
|
+
};`}).join(`
|
|
325
|
+
|
|
326
|
+
`),m=C?`${C}
|
|
327
|
+
|
|
328
|
+
`:"",R=z.map(j=>{const B=`${Je(j.name)}TableRow`;return` get(tableName: ${Ae(j.name)}): Promise<Array<${B}>>;`}).join(`
|
|
329
|
+
`),T=z.length>0?`${R}
|
|
330
|
+
get(tableName: string): Promise<Array<Record<string, any>>>;`:"get(tableName: string): Promise<Array<Record<string, any>>>;",x=z.map(j=>{const B=`${Je(j.name)}TableRow`;return` query(tableName: ${Ae(j.name)}, filter?: (row: ${B}) => boolean): Promise<Array<${B}>>;`}).join(`
|
|
331
|
+
`),A=z.length>0?`${x}
|
|
332
|
+
query(tableName: string, 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>>>;";return`${m}declare interface Context {
|
|
333
|
+
user: {
|
|
334
|
+
id: string;
|
|
335
|
+
email: string;
|
|
336
|
+
role: 'admin' | 'user';
|
|
337
|
+
createdAt: Date;
|
|
338
|
+
updatedAt: Date;
|
|
339
|
+
};
|
|
340
|
+
http: {
|
|
341
|
+
get(url: string, options?: any): Promise<any>;
|
|
342
|
+
post(url: string, data?: any, options?: any): Promise<any>;
|
|
343
|
+
put(url: string, data?: any, options?: any): Promise<any>;
|
|
344
|
+
delete(url: string, options?: any): Promise<any>;
|
|
345
|
+
};
|
|
346
|
+
fs: {
|
|
347
|
+
readFile(path: string): Promise<string>;
|
|
348
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
349
|
+
exists(path: string): Promise<boolean>;
|
|
350
|
+
listDir(path: string): Promise<string[]>;
|
|
351
|
+
mkdir(path: string): Promise<void>;
|
|
352
|
+
isFile(path: string): Promise<boolean>;
|
|
353
|
+
};
|
|
354
|
+
cmd: {
|
|
355
|
+
exec(command: string, options?: { cwd?: string; timeout?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
356
|
+
};
|
|
357
|
+
utils: {
|
|
358
|
+
md5(input: string): string;
|
|
359
|
+
};
|
|
360
|
+
ripgrep: {
|
|
361
|
+
search(pattern: string, options?: any): Promise<Array<{ file: string; line: number; text: string; column?: number; contextBefore?: string[]; contextAfter?: string[] }>>;
|
|
362
|
+
searchByPath(pattern: string, options?: any): Promise<string[]>;
|
|
363
|
+
};
|
|
364
|
+
mcp: {
|
|
365
|
+
${h}
|
|
366
|
+
listTools(): Promise<string[]>;
|
|
367
|
+
};
|
|
368
|
+
vars: {
|
|
369
|
+
get(name: string): string;
|
|
370
|
+
has(name: string): boolean;
|
|
371
|
+
getAll(): Record<string, string>;
|
|
372
|
+
set(name: string, value: string, description?: string): void;
|
|
373
|
+
};
|
|
374
|
+
log: {
|
|
375
|
+
info(message: string, ...args: any[]): void;
|
|
376
|
+
error(message: string, ...args: any[]): void;
|
|
377
|
+
warn(message: string, ...args: any[]): void;
|
|
378
|
+
debug(message: string, ...args: any[]): void;
|
|
379
|
+
};
|
|
380
|
+
tables: {
|
|
381
|
+
list(): Promise<Array<{ id: string; name: string; description?: string; columns: Array<{ name: string; type: string; nullable: boolean }> }>>;
|
|
382
|
+
${T}
|
|
383
|
+
${A}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
`}function Rt(p){const{contextTypeDef:z,toolArgsType:h,functionBody:C,hasCustomImplementation:m,toolName:R,toolDescription:T,functionParams:x="both"}=p,A=(q=!1)=>{const E=q?C:" // 在此处实现";return x==="both"?`export default async function(args: ToolArgs, context: Context) {
|
|
387
|
+
${E}
|
|
388
|
+
}`:x==="args"?`export default async function(args: ToolArgs) {
|
|
389
|
+
${E}
|
|
390
|
+
}`:`export default async function(context: Context) {
|
|
391
|
+
${E}
|
|
392
|
+
}`},j=()=>x==="both"?"- 只能使用 args 和 context 参数中的 API":x==="args"?"- 只能使用 args 参数中的 API":"- 只允许使用 context 参数中的 API",L=()=>m?R&&T?`请帮我调整/优化以下函数的实现。工具名称:${R},描述:${T}。`:"请帮我调整/优化以下函数的实现。":R&&T?`请帮我实现以下函数。工具名称:${R},描述:${T}。`:"请帮我实现以下函数。",B=()=>{const q=[];return h&&q.push(`### ToolArgs 类型定义
|
|
393
|
+
|
|
394
|
+
\`\`\`typescript
|
|
395
|
+
${h}
|
|
396
|
+
\`\`\``),q.push(`### Context 类型定义
|
|
397
|
+
|
|
398
|
+
\`\`\`typescript
|
|
399
|
+
${z}
|
|
400
|
+
\`\`\``),q.join(`
|
|
401
|
+
|
|
402
|
+
`)};return m?`${L()}
|
|
403
|
+
|
|
404
|
+
## 类型定义
|
|
405
|
+
|
|
406
|
+
${B()}
|
|
407
|
+
|
|
408
|
+
## 当前实现
|
|
409
|
+
|
|
410
|
+
\`\`\`typescript
|
|
411
|
+
${A(!0)}
|
|
412
|
+
\`\`\`
|
|
413
|
+
|
|
414
|
+
## 输出格式
|
|
415
|
+
|
|
416
|
+
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
417
|
+
|
|
418
|
+
\`\`\`typescript
|
|
419
|
+
${A(!1)}
|
|
420
|
+
\`\`\`
|
|
421
|
+
|
|
422
|
+
不要输出任何注释、解释文字或其他内容。
|
|
423
|
+
|
|
424
|
+
## 约束
|
|
425
|
+
|
|
426
|
+
${j()}`:`${L()}
|
|
427
|
+
|
|
428
|
+
## 类型定义
|
|
429
|
+
|
|
430
|
+
${B()}
|
|
431
|
+
|
|
432
|
+
## 函数签名
|
|
433
|
+
|
|
434
|
+
\`\`\`typescript
|
|
435
|
+
${A(!1)}
|
|
436
|
+
\`\`\`
|
|
437
|
+
|
|
438
|
+
## 输出格式
|
|
439
|
+
|
|
440
|
+
只输出以下函数定义代码(类型部分不必输出),格式如下:
|
|
441
|
+
|
|
442
|
+
\`\`\`typescript
|
|
443
|
+
${A(!1)}
|
|
444
|
+
\`\`\`
|
|
445
|
+
|
|
446
|
+
不要输出任何注释、解释文字或其他内容。
|
|
447
|
+
|
|
448
|
+
## 约束
|
|
449
|
+
|
|
450
|
+
${j()}`}const ws={class:"tools-manager"},bs={class:"tools-toolbar"},ks={class:"tools-table-container"},Cs={class:"modal-header"},xs={class:"modal-title"},Ts={class:"modal-subtitle"},$s={class:"modal-content-wrapper"},Ss={class:"tab-pane-content"},Ps={class:"form-section"},Ns={class:"form-grid-2"},Ms={class:"form-section"},js={class:"section-header"},Os={class:"parameters-list"},As={class:"parameter-header"},Ds={class:"parameter-index"},zs={class:"parameter-fields"},_s={key:0,class:"empty-parameters"},Fs={class:"tab-pane-content"},Js={class:"save-status-indicator"},Us=["title"],Bs={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Es={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Rs={class:"monaco-wrapper"},Vs={class:"modal-footer"},Is={class:"test-args-content"},Ls={key:0,class:"test-args-parameters"},qs={class:"parameters-header"},Hs={class:"parameters-count"},Ks={class:"test-args-input-wrapper"},Gs={class:"test-args-input-header"},Zs={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"14px",height:"14px"}},Ws={key:1,class:"test-result-section"},Qs={class:"test-result-header"},Ys={class:"test-result-title"},Xs={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"18px",height:"18px","margin-right":"8px"}},en={class:"test-result-actions"},tn={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},on={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},sn={class:"test-result-content"},nn={class:"test-result-pre"},an={class:"test-result-code-inner"},rn={class:"modal-footer"},Ve=`/**
|
|
451
|
+
* 工具脚本
|
|
452
|
+
* @param args 工具参数对象 (类型根据 Schema 声明自动生成)
|
|
453
|
+
* @param context 上下文对象 (提供常用工具方法等)
|
|
454
|
+
*/
|
|
455
|
+
export default async function (args: ToolArgs, context: Context) {
|
|
456
|
+
const { log } = context;
|
|
457
|
+
|
|
458
|
+
log.info('工具执行中');
|
|
459
|
+
|
|
460
|
+
return {
|
|
461
|
+
// 返回结果
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
`,ln=dt({__name:"CustomToolsManager",props:{config:{}},emits:["update"],setup(p,{emit:z}){const h=p,C=z,m=$t(),R=S(!1),T=S(!1),x=S(null),A=S(),j=S(""),L=S("schema"),B=S(!1),q=S(!1),E=S(""),ee=S(!1),W=S("{}"),I=S(null),_=S(!1),g=Se(()=>P.value.serverScript!==E.value),N=Se(()=>B.value?"height: calc(100vh - 120px); border-radius: 12px; overflow: hidden;":"height: 474px; border-radius: 12px; overflow: hidden;"),te=S([]),J=S([]),Q=i=>i?`custom_tool_script_${i}`:"custom_tool_script_new",F=i=>{const s=Q(i),v=localStorage.getItem(s);return v||null},de=(i,s)=>{const v=Q(i);localStorage.setItem(v,s)},Ne=i=>{const s=Q(i);localStorage.removeItem(s)},ye=i=>i?`custom_tool_test_args_${i}`:"custom_tool_test_args_new",he=i=>{const s=ye(i);return localStorage.getItem(s)},ve=(i,s)=>{const v=ye(i);localStorage.setItem(v,s)},Ue={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},xe=i=>({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=""}}),Te=[{title:"参数名",key:"name",width:150},{title:"类型",key:"type",width:100},{title:"必需",key:"required",width:80,render:i=>i.required?me(jt,{type:"error"},{default:()=>"是"}):"否"},{title:"描述",key:"description",ellipsis:{tooltip:!0}}],a=[{title:"工具名称",key:"name",width:300,render(i){const s=me("div",{style:"display: flex; align-items: center; gap: 10px;"},[me("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;"},i.name.charAt(0).toUpperCase()),me("div",{style:"display: flex; flex-direction: column;"},[me("span",{style:"font-weight: 500;"},i.name)])]);return!i.parameters||i.parameters.length===0?s:me("div",{style:"display: flex; align-items: center; justify-content: space-between;"},[s,me(Ot,{trigger:"hover",style:"max-width: 600px; max-height: 500px; padding: 0; overflow: hidden;"},{trigger:()=>me(G,{size:"tiny",tertiary:!0,circle:!0,type:"info"},{default:()=>"📄"}),default:()=>me("div",{style:"max-height: 500px; overflow-y: auto;"},[me(kt,{size:"small",bordered:!1,columns:[{title:"参数名",key:"name",width:120},{title:"类型",key:"type",width:80},{title:"必需",key:"required",width:60,render:v=>v.required?me(jt,{type:"error"},{default:()=>"是"}):"否"},{title:"描述",key:"description"}],data:i.parameters,pagination:!1,singleLine:!1})])})])}},{title:"脚本",key:"script",width:150,render(i){return i.serverScript?me(Ot,{trigger:"hover",placement:"right",style:"max-width: 600px; max-height: 500px; overflow: hidden;"},{trigger:()=>me(Ye,{type:"info",size:"small",bordered:!0,style:"cursor: pointer;"},{default:()=>"Typescript"}),default:()=>me(oo,{code:i.serverScript,language:"typescript",style:"max-height: 500px; overflow-y: auto; font-size: 12px; display: block;"})}):me(Ye,{type:"default",size:"small",bordered:!0},{default:()=>"None"})}},{title:"描述",key:"description",ellipsis:{tooltip:!0}},{title:"操作",key:"actions",width:150,render(i){return me(so,{size:"small"},{default:()=>[me(G,{size:"small",onClick:()=>et(i)},{default:()=>"编辑"}),me(G,{size:"small",type:"error",onClick:()=>tt(i.id)},{default:()=>"删除"})]})}}],K=Se(()=>{const i=h.config.customTools.filter(v=>(v.source||"custom")==="custom");if(!j.value)return i;const s=j.value.toLowerCase();return i.filter(v=>v.name.toLowerCase().includes(s)||v.description.toLowerCase().includes(s))});async function H(){try{const i=await pe.get("/configs/all-tools");i.data.success&&i.data.data.tools?te.value=i.data.data.tools:te.value=[]}catch(i){console.error("Failed to load MCP tools from database:",i),te.value=[]}}async function oe(){try{const i=await pe.get("/tables/definitions");i.data.success&&(J.value=i.data.data||[])}catch(i){console.error("Failed to load tables:",i),J.value=[]}}const ze=Se(()=>{let i=te.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((v,Y)=>(Y.name&&Y.name.trim()&&(v[Y.name.trim()]={type:Y.type,description:Y.description||""}),v),{}),required:P.value.parameters.filter(v=>v.required).map(v=>v.name.trim())}};i=i.filter(v=>v.name!==P.value.name).concat(s)}return Bt({config:h.config,mcpTools:i,tables:J.value})}),Oe=Se(()=>!P.value.parameters||P.value.parameters.length===0?`
|
|
465
|
+
/**
|
|
466
|
+
* 工具参数类型
|
|
467
|
+
*/
|
|
468
|
+
declare interface ToolArgs {
|
|
469
|
+
[key: string]: any;
|
|
470
|
+
}
|
|
471
|
+
`:`
|
|
472
|
+
/**
|
|
473
|
+
* 工具参数类型
|
|
474
|
+
* 根据 Schema 声明自动生成
|
|
475
|
+
*/
|
|
476
|
+
declare interface ToolArgs {
|
|
477
|
+
${P.value.parameters.filter(s=>s.name&&s.name.trim()).map(s=>{const v=s.name.trim(),ue=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(v)?v:`"${v.replace(/"/g,'\\"')}"`,$e=s.required?"":"?",n=s.description?`/** ${s.description.replace(/\*\//g,"* /")} */
|
|
478
|
+
`:"";let e="any";switch(s.type){case"string":e="string";break;case"number":e="number";break;case"boolean":e="boolean";break;case"object":e="Record<string, any>";break;case"array":e="any[]";break;default:e="any"}return`${n}${ue}${$e}: ${e};`}).join(`
|
|
479
|
+
`)}
|
|
480
|
+
}
|
|
481
|
+
`),Pe=S(0),Be=Se(()=>[{content:ze.value,filePath:"file:///context.d.ts"},{content:Oe.value,filePath:"file:///tool-args.d.ts"}]),P=S({name:"",description:"",serverScript:Ve,parameters:[]}),He=[{label:"string",value:"string"},{label:"number",value:"number"},{label:"boolean",value:"boolean"},{label:"object",value:"object"},{label:"array",value:"array"}],vt={name:{required:!0,message:"请输入工具名称",trigger:"blur"},description:{required:!0,message:"请输入描述",trigger:"blur"}};function gt(){return{name:"",type:"string",description:"",required:!1}}function Xe(){const i={};return P.value.parameters.forEach(s=>{if(s.name&&s.name.trim())switch(s.type){case"number":i[s.name]=0;break;case"boolean":i[s.name]=!1;break;case"array":i[s.name]=[];break;case"object":i[s.name]={};break;default:i[s.name]=""}}),JSON.stringify(i,null,2)}function et(i){x.value=i;const v=F(i.id)||i.serverScript||Ve;P.value={name:i.name,description:i.description,serverScript:v,parameters:i.parameters?JSON.parse(JSON.stringify(i.parameters)):[]},E.value=i.serverScript||"",R.value=!0}function tt(i){const s=h.config.customTools.filter(v=>v.id!==i);C("update",{customTools:s})}async function mt(){var i,s,v;try{if(await((i=A.value)==null?void 0:i.validate()),T.value=!0,!P.value.serverScript)throw new Error("脚本不能为空");const Y={id:((s=x.value)==null?void 0:s.id)||Qe(),name:P.value.name,description:P.value.description,serverScript:P.value.serverScript,parameters:P.value.parameters,source:((v=x.value)==null?void 0:v.source)||"custom"},ue=[...h.config.customTools],$e=ue.findIndex(n=>n.id===Y.id);$e!==-1?ue[$e]=Y:ue.push(Y),C("update",{customTools:ue}),Ne(Y.id),Ne(null),R.value=!1,Ze()}catch(Y){m.error(Y.message)}finally{T.value=!1}}function ft(i){var v;const s=((v=x.value)==null?void 0:v.id)||null;de(s,i)}function Ke(){var s;E.value=P.value.serverScript;const i=((s=x.value)==null?void 0:s.id)||null;de(i,P.value.serverScript),m.success("脚本已保存")}async function yt(){var i,s,v,Y,ue,$e;if(!P.value.serverScript.trim()){m.warning("请先编写脚本内容"),ee.value=!1;return}Ke(),q.value=!0,I.value=null,_.value=!1;try{let n={};try{const o=W.value.trim()||"{}";if(n=JSON.parse(o),typeof n!="object"||Array.isArray(n))throw new Error("参数必须是 JSON 对象")}catch(o){m.error(`参数格式错误: ${o.message}`),q.value=!1;return}const e=await pe.post("/configs/test-custom-tool",{script:P.value.serverScript,args:n,toolName:P.value.name||"test-tool"});if(e.data.success){const o=((i=x.value)==null?void 0:i.id)||null;ve(o,W.value);const f=(s=e.data.data)==null?void 0:s.result;I.value=f,_.value=!0,m.success("测试执行成功")}else I.value={error:e.data.error,success:!1},_.value=!0,m.error(`测试执行失败: ${e.data.error}`)}catch(n){I.value={error:((Y=(v=n.response)==null?void 0:v.data)==null?void 0:Y.error)||n.message,success:!1},_.value=!0,m.error(`测试执行失败: ${(($e=(ue=n.response)==null?void 0:ue.data)==null?void 0:$e.error)||n.message}`)}finally{q.value=!1}}function we(i){try{return JSON.stringify(i,null,2)}catch{return String(i)}}async function Ee(){if(I.value)try{const i=we(I.value);await navigator.clipboard.writeText(i),m.success("测试结果已复制到剪贴板")}catch{try{const s=we(I.value),v=document.createElement("textarea");v.value=s,v.style.position="fixed",v.style.left="-999999px",v.style.top="-999999px",document.body.appendChild(v),v.focus(),v.select();const Y=document.execCommand("copy");document.body.removeChild(v),Y?m.success("测试结果已复制到剪贴板"):m.error("复制失败,请手动复制")}catch{m.error("复制失败,请手动复制")}}}function ot(){W.value=Xe(),m.info("已重置为默认参数")}function st(){ee.value=!1,I.value=null,_.value=!1}function nt(){B.value=!B.value}function Ge(i){const s=i.match(/export\s+default\s+async\s+function\s*(\w+)?\s*\([^)]*\)\s*\{([\s\S]*)\}/);return s&&s[1]?s[1].trim():i}async function Re(){try{let i=te.value;if(x.value&&P.value.name){const u={name:P.value.name,description:P.value.description||"",inputSchema:{type:"object",properties:P.value.parameters.reduce((d,k)=>(k.name&&k.name.trim()&&(d[k.name.trim()]={type:k.type,description:k.description||""}),d),{}),required:P.value.parameters.filter(d=>d.required).map(d=>d.name.trim())}};i=i.filter(d=>d.name!==P.value.name).concat(u)}const s=Et({config:h.config,mcpTools:i,tables:J.value}),v=P.value.parameters.length>0?`type ToolArgs = {
|
|
482
|
+
${P.value.parameters.filter(u=>u.name&&u.name.trim()).map(u=>{const d=u.required?"":"?",w={string:"string",number:"number",boolean:"boolean",array:"any[]",object:"Record<string, any>"}[u.type]||"any",y=u.description?` /** ${u.description} */`:"";return` ${u.name.trim()}${d}: ${w};${y}`}).join(`
|
|
483
|
+
`)}
|
|
484
|
+
};`:"type ToolArgs = Record<string, any>;",Y=P.value.serverScript.trim()||Ve,ue=Ge(Y),$e=Ge(Ve),n=Y!==Ve&&ue!==$e,e=P.value.name||"未命名工具",o=P.value.description||"无描述",f=Rt({contextTypeDef:s,toolArgsType:v,functionBody:ue,hasCustomImplementation:n,toolName:e,toolDescription:o,functionParams:"both"});await navigator.clipboard.writeText(f),m.success("提示词已复制到剪贴板!")}catch(i){console.error("Failed to copy prompt:",i),m.error("复制失败,请手动复制")}}function Ze(){x.value=null,L.value="schema",B.value=!1,ee.value=!1,W.value="{}",I.value=null,_.value=!1;const i=F(null);P.value={name:"",description:"",serverScript:i||Ve,parameters:[]},E.value=""}return Tt(()=>{H(),oe()}),Ce(()=>h.config.components,()=>{H()},{deep:!0}),Ce(()=>L.value,i=>{i==="implementation"&&Fe(()=>{Pe.value++})}),Ce(()=>P.value.parameters,()=>{Fe(()=>{Pe.value++})},{deep:!0,immediate:!1}),Ce(()=>[P.value.name,P.value.description],()=>{Fe(()=>{Pe.value++})},{immediate:!1}),Ce(()=>ee.value,i=>{var s;if(i){const v=((s=x.value)==null?void 0:s.id)||null,Y=he(v);Y?W.value=Y:W.value=Xe()}}),Ce(()=>h.config.customTools,()=>{H()},{deep:!0}),Ce(()=>R.value,i=>{if(i){if(!x.value){const s=F(null);s&&(P.value.serverScript=s)}}else Ze()}),(i,s)=>(O(),V("div",ws,[t("div",bs,[c(l(G),{type:"primary",size:"large",class:"add-tool-btn",onClick:s[0]||(s[0]=v=>R.value=!0)},{icon:r(()=>[...s[13]||(s[13]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[s[14]||(s[14]=U(" 添加工具 ",-1))]),_:1}),c(l(ke),{value:j.value,"onUpdate:value":s[1]||(s[1]=v=>j.value=v),placeholder:"搜索工具名称或描述...",size:"large",clearable:"",class:"search-input"},{prefix:r(()=>[...s[15]||(s[15]=[t("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"])]),t("div",ks,[c(l(kt),{columns:a,data:K.value,pagination:Ue,"row-props":xe,class:"modern-table"},null,8,["data"])]),c(l(it),{show:R.value,"onUpdate:show":s[9]||(s[9]=v=>R.value=v),preset:"card",bordered:!1,class:"tool-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:r(()=>[t("div",Cs,[s[16]||(s[16]=t("div",{class:"modal-icon"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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)),t("div",null,[t("h3",xs,ae(x.value?"编辑自定义工具":"创建自定义工具"),1),t("p",Ts,ae(x.value?"修改工具的 Schema 和实现代码":"定义工具的 Schema 并编写实现逻辑"),1)])])]),footer:r(()=>[t("div",Vs,[c(l(G),{size:"large",onClick:s[8]||(s[8]=v=>R.value=!1)},{default:r(()=>[...s[36]||(s[36]=[U("取消",-1)])]),_:1}),c(l(G),{type:"primary",size:"large",loading:T.value,onClick:mt},{default:r(()=>[U(ae(x.value?"保存修改":"创建工具"),1)]),_:1},8,["loading"])])]),default:r(()=>[t("div",$s,[c(l(Ft),{ref_key:"formRef",ref:A,model:P.value,rules:vt,class:"tool-form"},{default:r(()=>[c(l(_t),{value:L.value,"onUpdate:value":s[7]||(s[7]=v=>L.value=v),type:"line",animated:"",size:"large",class:"tool-config-tabs"},{default:r(()=>[c(l(ut),{name:"schema",tab:"Schema 声明"},{default:r(()=>[t("div",Ss,[c(l(Le),{type:"info",bordered:!1,class:"schema-tip"},{icon:r(()=>[...s[17]||(s[17]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[s[18]||(s[18]=U(' 在 Schema 声明中定义的参数会自动生成类型定义,在"工具实现"标签页的脚本编辑器中可以使用类型提示 ',-1))]),_:1}),t("div",Ps,[s[21]||(s[21]=t("h4",{class:"section-title"},"基础信息",-1)),t("div",Ns,[c(l(fe),{path:"name"},{label:r(()=>[...s[19]||(s[19]=[t("div",{class:"form-label"},[t("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"工具名称")],-1)])]),default:r(()=>[c(l(ke),{value:P.value.name,"onUpdate:value":s[2]||(s[2]=v=>P.value.name=v),placeholder:"例如: my-custom-tool",size:"large"},null,8,["value"])]),_:1}),c(l(fe),{path:"description"},{label:r(()=>[...s[20]||(s[20]=[t("div",{class:"form-label"},[t("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"})]),t("span",null,"工具描述")],-1)])]),default:r(()=>[c(l(ke),{value:P.value.description,"onUpdate:value":s[3]||(s[3]=v=>P.value.description=v),placeholder:"简要描述工具的功能",size:"large"},null,8,["value"])]),_:1})])]),t("div",Ms,[t("div",js,[s[24]||(s[24]=t("h4",{class:"section-title"},"参数定义",-1)),c(l(G),{dashed:"",onClick:s[4]||(s[4]=v=>P.value.parameters.push(gt())),size:"medium"},{icon:r(()=>[...s[22]||(s[22]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[s[23]||(s[23]=U(" 添加参数 ",-1))]),_:1})]),t("div",Os,[(O(!0),V(rt,null,lt(P.value.parameters,(v,Y)=>(O(),V("div",{key:Y,class:"parameter-card"},[t("div",As,[t("span",Ds,"#"+ae(Y+1),1),c(l(G),{type:"error",text:"",size:"small",onClick:ue=>P.value.parameters.splice(Y,1)},{icon:r(()=>[...s[25]||(s[25]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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:r(()=>[s[26]||(s[26]=U(" 删除 ",-1))]),_:1},8,["onClick"])]),t("div",zs,[c(l(fe),{label:"必填",class:"required-field"},{default:r(()=>[c(l(Ut),{checked:v.required,"onUpdate:checked":ue=>v.required=ue},null,8,["checked","onUpdate:checked"])]),_:2},1024),c(l(fe),{label:"参数名",path:`parameters[${Y}].name`,rule:{required:!0,message:"必填",trigger:"blur"}},{default:r(()=>[c(l(ke),{value:v.name,"onUpdate:value":ue=>v.name=ue,placeholder:"参数名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),c(l(fe),{label:"类型"},{default:r(()=>[c(l(Jt),{value:v.type,"onUpdate:value":ue=>v.type=ue,options:He},null,8,["value","onUpdate:value"])]),_:2},1024),c(l(fe),{label:"描述"},{default:r(()=>[c(l(ke),{value:v.description,"onUpdate:value":ue=>v.description=ue,placeholder:"参数描述"},null,8,["value","onUpdate:value"])]),_:2},1024)])]))),128)),P.value.parameters.length===0?(O(),V("div",_s,[...s[27]||(s[27]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),t("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1),t("p",null,"暂无参数,点击上方按钮添加参数",-1)])])):ce("",!0)])])])]),_:1}),c(l(ut),{name:"implementation",tab:"工具实现"},{default:r(()=>[t("div",Fs,[t("div",{class:je(["editor-container",{fullscreen:B.value}])},[t("div",Js,[t("div",{class:je(["status-dot",{unsaved:g.value,saved:!g.value}]),title:g.value?"未保存":"已保存"},null,10,Us)]),c(l(G),{type:"default",size:"small",class:"fullscreen-btn",onClick:nt},{icon:r(()=>[B.value?(O(),V("svg",Es,[...s[29]||(s[29]=[t("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(),V("svg",Bs,[...s[28]||(s[28]=[t("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:r(()=>[U(" "+ae(B.value?"退出全屏":"全屏"),1)]),_:1}),t("div",Rs,[c(ct,{modelValue:P.value.serverScript,"onUpdate:modelValue":s[5]||(s[5]=v=>P.value.serverScript=v),language:"typescript",options:{minimap:{enabled:!0},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0},"extra-libs":Be.value,onSave:Ke,onChange:ft,style:xt(N.value)},null,8,["modelValue","extra-libs","style"])])],2),t("div",{class:je(["editor-actions",{"fullscreen-actions":B.value}])},[c(l(G),{type:"default",size:"small",class:"copy-prompt-btn",onClick:Re},{icon:r(()=>[...s[30]||(s[30]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"}),t("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:r(()=>[s[31]||(s[31]=U(" 复制提示词到大模型生成 ",-1))]),_:1}),c(l(G),{type:"primary",size:"small",class:"save-btn",disabled:!g.value,onClick:Ke},{icon:r(()=>[...s[32]||(s[32]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[s[33]||(s[33]=U(" 保存 (Ctrl+S) ",-1))]),_:1},8,["disabled"]),c(l(G),{type:"info",size:"small",class:"test-btn",loading:q.value,onClick:s[6]||(s[6]=v=>ee.value=!0)},{icon:r(()=>[...s[34]||(s[34]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[s[35]||(s[35]=U(" 测试执行 ",-1))]),_:1},8,["loading"])],2)])]),_:1})]),_:1},8,["value"])]),_:1},8,["model"])])]),_:1},8,["show"]),c(l(it),{show:ee.value,"onUpdate:show":s[12]||(s[12]=v=>ee.value=v),preset:"card",bordered:!1,class:"test-args-modal",style:xt({width:_.value?"800px":"600px"}),title:"测试执行参数"},{header:r(()=>[...s[37]||(s[37]=[t("div",{class:"modal-header"},[t("div",{class:"modal-icon"},[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),t("div",null,[t("h3",{class:"modal-title"},"输入测试参数"),t("p",{class:"modal-subtitle"},'请输入 JSON 格式的参数(例如:{"param1": "value1", "param2": 123})')])],-1)])]),footer:r(()=>[t("div",rn,[c(l(G),{size:"large",onClick:st},{default:r(()=>[...s[48]||(s[48]=[U("取消",-1)])]),_:1}),c(l(G),{type:"primary",size:"large",loading:q.value,onClick:yt},{default:r(()=>[...s[49]||(s[49]=[U(" 执行测试 ",-1)])]),_:1},8,["loading"])])]),default:r(()=>[t("div",Is,[P.value.parameters&&P.value.parameters.length>0?(O(),V("div",Ls,[t("div",qs,[s[38]||(s[38]=t("span",{class:"parameters-title"},"参数定义",-1)),t("span",Hs,ae(P.value.parameters.length)+" 个参数",1)]),c(l(kt),{columns:Te,data:P.value.parameters.filter(v=>v.name&&v.name.trim()),pagination:!1,size:"small",bordered:"",class:"test-args-table"},null,8,["data"])])):ce("",!0),t("div",Ks,[t("div",Gs,[s[41]||(s[41]=t("span",{class:"test-args-input-title"},"测试参数 (JSON)",-1)),c(l(G),{size:"small",type:"default",onClick:ot},{icon:r(()=>[(O(),V("svg",Zs,[...s[39]||(s[39]=[t("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),t("path",{d:"M21 3v5h-5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),t("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),t("path",{d:"M3 21v-5h5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:r(()=>[s[40]||(s[40]=U(" 重置 ",-1))]),_:1})]),c(l(ke),{value:W.value,"onUpdate:value":s[10]||(s[10]=v=>W.value=v),type:"textarea",placeholder:'{"param1": "value1", "param2": 123}',rows:8,autosize:{minRows:8,maxRows:12},class:"test-args-input"},null,8,["value"])]),_.value&&I.value?(O(),V("div",Ws,[t("div",Qs,[t("div",Ys,[(O(),V("svg",Xs,[...s[42]||(s[42]=[t("path",{d:"M9 11l3 3L22 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),t("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]=t("span",null,"测试结果",-1))]),t("div",en,[c(l(G),{size:"small",text:"",onClick:Ee},{icon:r(()=>[(O(),V("svg",tn,[...s[44]||(s[44]=[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),t("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:r(()=>[s[45]||(s[45]=U(" 复制 ",-1))]),_:1}),c(l(G),{size:"small",text:"",onClick:s[11]||(s[11]=v=>_.value=!1)},{icon:r(()=>[(O(),V("svg",on,[...s[46]||(s[46]=[t("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),_:1})])]),t("div",sn,[t("pre",nn,[t("code",an,ae(we(I.value)),1),s[47]||(s[47]=U(`
|
|
485
|
+
`,-1))])])])):ce("",!0)])]),_:1},8,["show","style"])]))}}),$n=pt(ln,[["__scopeId","data-v-99a8719e"]]),un={class:"init-script-editor"},cn={key:0,class:"data-loading-overlay"},dn={class:"save-status-indicator"},pn=["title"],vn={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},gn={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},mn={class:"monaco-wrapper"},fn={class:"editor-actions"},Ie=`/**
|
|
486
|
+
* MCP 初始化脚本
|
|
487
|
+
* 在 MCP 客户端连接时执行,用于环境检查、数据预加载等操作
|
|
488
|
+
*/
|
|
489
|
+
export default async function(context: Context) {
|
|
490
|
+
const { log } = context;
|
|
491
|
+
|
|
492
|
+
log.info('🚀 MCP 环境初始化完成');
|
|
493
|
+
|
|
494
|
+
// 示例:检查变量配置
|
|
495
|
+
// const apiKey = context.vars.get('API_KEY');
|
|
496
|
+
// if (!apiKey) {
|
|
497
|
+
// log.warn('⚠️ API_KEY 未配置');
|
|
498
|
+
// }
|
|
499
|
+
}`,Ct="init-script-local-draft",yn=dt({__name:"InitScriptEditor",props:{config:{}},emits:["update"],setup(p,{emit:z}){const h=$t(),C=p,m=z,R=S([]),T=S([]);async function x(){try{const K=await pe.get("/configs/all-tools");K.data.success&&K.data.data.tools?R.value=K.data.data.tools:R.value=[]}catch(K){console.error("Failed to load MCP tools from database:",K),R.value=[]}}async function A(){try{const K=await pe.get("/tables/definitions");K.data.success&&(T.value=K.data.data||[])}catch(K){console.error("Failed to load tables:",K),T.value=[]}}const j=Se(()=>Bt({config:C.config,mcpTools:R.value,tables:T.value})),L=Se(()=>[{content:j.value,filePath:"file:///init-script-context.d.ts"}]),B=S(!0);Tt(async()=>{B.value=!0;try{await Promise.all([x(),A()])}finally{B.value=!1}}),Ce(()=>C.config.components,()=>{x()},{deep:!0}),Ce(()=>C.config.customTools,()=>{x()},{deep:!0});function q(){try{return localStorage.getItem(Ct)||null}catch(K){return console.error("Failed to load local script:",K),null}}function E(K){try{localStorage.setItem(Ct,K)}catch(H){console.error("Failed to save to local storage:",H)}}function ee(){try{localStorage.removeItem(Ct)}catch(K){console.error("Failed to clear local script:",K)}}const W=q(),I=C.config.initScript||"",g=S(W||I||Ie),N=S(I),te=S(W||""),J=Se(()=>g.value!==te.value),Q=Se(()=>te.value!==N.value),F=S(!1),de=S(!1),Ne=Se(()=>de.value?"height: 100%; border-radius: 12px; overflow: hidden;":"height: calc(100vh - 300px); min-height: 600px; max-height: 800px; border-radius: 12px; overflow: hidden;");Ce(()=>C.config.initScript,(K,H)=>{const oe=K||"";if(oe===(H||""))return;const Oe=q();if(Oe&&oe===Oe){ee(),te.value="",N.value=oe,g.value=oe;return}if(Oe&&oe!==Oe){ee(),te.value="",N.value=oe;const Be=oe||Ie;g.value=Be;return}if(N.value=oe,!oe&&N.value)return;const Pe=oe||Ie;g.value=Pe,N.value=oe},{immediate:!0});function ye(K){}function he(){const K=g.value.trim()||"";E(K),te.value=K,h.success("已保存到本地 (Ctrl+S)")}async function ve(){const K=te.value.trim()||void 0;m("update",{initScript:K}),N.value=K||"",ee(),te.value=""}async function Ue(){var K,H;if(!g.value.trim()){h.warning("请先编写脚本内容");return}he(),F.value=!0;try{const oe=await pe.post("/configs/test-init-script",{script:g.value});oe.data.success?h.success("测试执行成功,请查看服务端控制台输出"):h.error(`测试执行失败: ${oe.data.error}`)}catch(oe){h.error(`测试执行失败: ${((H=(K=oe.response)==null?void 0:K.data)==null?void 0:H.error)||oe.message}`)}finally{F.value=!1}}function xe(){de.value=!de.value}function Te(K){const H=K.match(/export\s+default\s+async\s+function\s*\([^)]*\)\s*\{([\s\S]*)\}/);return H&&H[1]?H[1].trim():K}async function a(){try{const K=Et({config:C.config,mcpTools:R.value,tables:T.value}),H=g.value.trim()||Ie,oe=Te(H),ze=Te(Ie),Pe=Rt({contextTypeDef:K,functionBody:oe,hasCustomImplementation:H!==Ie&&oe!==ze,functionParams:"context"});await navigator.clipboard.writeText(Pe),h.success("提示词已复制到剪贴板!")}catch(K){console.error("Failed to copy prompt:",K),h.error("复制失败,请手动复制")}}return(K,H)=>(O(),V("div",un,[H[10]||(H[10]=zt('<div class="editor-toolbar" data-v-7566710a><div class="toolbar-info" data-v-7566710a><svg class="info-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-7566710a><polyline points="16 18 22 12 16 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-7566710a></polyline><polyline points="8 6 2 12 8 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-7566710a></polyline></svg><span data-v-7566710a>初始化脚本在 MCP 连接时执行,用于初始化环境、加载数据等操作</span></div></div>',1)),t("div",{class:je(["editor-container",{fullscreen:de.value}])},[B.value?(O(),V("div",cn,[...H[1]||(H[1]=[t("div",{class:"loading-spinner"},null,-1),t("div",{class:"loading-text"},"正在加载类型定义...",-1)])])):ce("",!0),t("div",dn,[t("div",{class:je(["status-dot",{unsaved:J.value,saved:!J.value,"local-only":Q.value&&!J.value}]),title:J.value?"未保存到本地":Q.value?"已保存到本地,未上传":"已保存"},null,10,pn)]),c(l(G),{type:"default",size:"small",class:"fullscreen-btn",onClick:xe},{icon:r(()=>[de.value?(O(),V("svg",gn,[...H[3]||(H[3]=[t("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(),V("svg",vn,[...H[2]||(H[2]=[t("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:r(()=>[U(" "+ae(de.value?"退出全屏":"全屏"),1)]),_:1}),t("div",mn,[c(ct,{modelValue:g.value,"onUpdate:modelValue":H[0]||(H[0]=oe=>g.value=oe),language:"typescript",options:{minimap:{enabled:!0},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0},"extra-libs":L.value,onSave:he,onChange:ye,style:xt(Ne.value)},null,8,["modelValue","extra-libs","style"])]),t("div",fn,[c(l(G),{type:"default",size:"small",class:"copy-prompt-btn",onClick:a},{icon:r(()=>[...H[4]||(H[4]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("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"}),t("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:r(()=>[H[5]||(H[5]=U(" 复制提示词到大模型生成 ",-1))]),_:1}),c(l(G),{type:"primary",size:"small",class:"upload-btn",disabled:!Q.value,onClick:ve},{icon:r(()=>[...H[6]||(H[6]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("polyline",{points:"17 8 12 3 7 8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("line",{x1:"12",y1:"3",x2:"12",y2:"15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[H[7]||(H[7]=U(" 上传脚本 ",-1))]),_:1},8,["disabled"]),c(l(G),{type:"info",size:"small",class:"test-btn",loading:F.value,onClick:Ue},{icon:r(()=>[...H[8]||(H[8]=[t("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("polygon",{points:"5 3 19 12 5 21 5 3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[H[9]||(H[9]=U(" 测试执行 ",-1))]),_:1},8,["loading"])])],2)]))}}),Sn=pt(yn,[["__scopeId","data-v-7566710a"]]);export{$n as C,Sn as I,ct as M,Tn as a,Qe as g,xn as p,Cn as u};
|