flex-mcp 1.1.14 → 1.1.16

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.
@@ -1 +1 @@
1
- import{a as N}from"./index-CmiEbWrJ.js";import{u as S,a as j,C as H,I as P}from"./InitScriptEditor-BFTWTD26.js";import{u as T,B as V,o as E,p as I,s as h,g as D,k as L,l as k}from"./naive-ui-BwyHI4J3.js";import{q as W,r as d,s as q,o as G,c0 as v,c1 as e,bW as s,bS as x,c5 as b,bV as o,bs as a,c2 as O,c7 as _,bU as r,l as A}from"./vendor-DpXl860f.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-BXWd1EVR.js";const J={class:"configs-page"},K={style:{position:"absolute",width:"0",height:"0"}},Q={class:"configs-container"},R={class:"config-content"},X={class:"user-selector-section"},Y={class:"selector-header"},Z={key:0,class:"loading-state"},$={key:1,class:"config-stats"},ee={class:"stat-card"},te={class:"stat-content"},se={class:"stat-value"},oe={class:"stat-card"},ae={class:"stat-content"},ne={class:"stat-value"},le={key:0,class:"modal-content"},ie={class:"tab-content"},re={class:"tab-content"},de={class:"tab-content"},ce=W({__name:"Configs",setup(ve){const u=T(),p=S(),i=d(null),f=d(!1),y=d([]),g=d(!1),w=d("components"),l=q(()=>p.currentConfig),C=d([]);async function M(){try{const n=await N.get("/users");y.value=n.data.data.filter(t=>t.role!=="admin"),C.value=y.value.map(t=>({label:t.email,value:t.id}))}catch{u.error("加载用户列表失败")}}async function B(){if(i.value){f.value=!0;try{await p.fetchUserConfig(i.value)}catch(n){u.error(n.message)}finally{f.value=!1}}}function U(){l.value&&(w.value="components",g.value=!0)}async function m(n){if(i.value)try{await p.updateUserConfig(i.value,n),u.success("更新成功")}catch(t){u.error(t.message)}}function z(n){i.value=n,n&&B()}return G(()=>{M()}),(n,t)=>(r(),v("div",J,[(r(),v("svg",K,[...t[3]||(t[3]=[e("defs",null,[e("linearGradient",{id:"loading-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[e("stop",{offset:"0%","stop-color":"#dc2626"}),e("stop",{offset:"50%","stop-color":"#ea580c"}),e("stop",{offset:"100%","stop-color":"#f59e0b"})])],-1)])])),t[15]||(t[15]=e("div",{class:"page-header"},[e("div",null,[e("h1",{class:"page-title"},"配置管理"),e("p",{class:"page-description"},"查看和编辑用户的 MCP 配置")])],-1)),e("div",Q,[e("main",R,[e("div",X,[e("div",Y,[t[6]||(t[6]=e("div",{class:"selector-label"},[e("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("span",null,"选择用户")],-1)),l.value?(r(),x(a(V),{key:0,type:"primary",size:"large",class:"edit-btn",onClick:U},{icon:o(()=>[...t[4]||(t[4]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[5]||(t[5]=A(" 编辑配置 ",-1))]),_:1})):b("",!0)]),s(a(E),{value:i.value,"onUpdate:value":[t[0]||(t[0]=c=>i.value=c),z],options:C.value,placeholder:"请选择要配置的用户",size:"large",filterable:"",clearable:"",class:"user-select"},{empty:o(()=>[s(a(h),{description:"暂无用户"})]),_:1},8,["value","options"])]),s(a(I),{class:"content-divider"}),f.value?(r(),v("div",Z,[...t[7]||(t[7]=[e("div",{class:"loading-spinner"},[e("svg",{class:"spinner",viewBox:"0 0 50 50"},[e("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"4"})])],-1),e("p",{class:"loading-text"},"加载配置中...",-1)])])):l.value?(r(),v("div",$,[e("div",ee,[t[9]||(t[9]=O('<div class="stat-icon stat-icon--primary" data-v-e297e9f7><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-e297e9f7><rect x="3" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="3" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect></svg></div>',1)),e("div",te,[e("div",se,_(l.value.components.length),1),t[8]||(t[8]=e("div",{class:"stat-label"},"MCP 组件",-1))])]),e("div",oe,[t[11]||(t[11]=e("div",{class:"stat-icon stat-icon--success"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),e("div",ae,[e("div",ne,_(l.value.customTools.length),1),t[10]||(t[10]=e("div",{class:"stat-label"},"自定义工具",-1))])])])):i.value?(r(),x(a(h),{key:3,description:"该用户暂无配置或加载失败",class:"empty-placeholder"},{icon:o(()=>[...t[13]||(t[13]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("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)])]),_:1})):(r(),x(a(h),{key:2,description:"请选择一个用户查看配置",class:"empty-placeholder"},{icon:o(()=>[...t[12]||(t[12]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1}))])]),s(a(D),{show:g.value,"onUpdate:show":t[2]||(t[2]=c=>g.value=c),preset:"card",bordered:!1,class:"config-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh"}},{header:o(()=>[...t[14]||(t[14]=[e("div",{class:"modal-header"},[e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),e("div",null,[e("h3",{class:"modal-title"},"编辑用户配置"),e("p",{class:"modal-subtitle"},"管理 MCP 组件、工具和脚本")])],-1)])]),default:o(()=>[l.value?(r(),v("div",le,[s(a(L),{value:w.value,"onUpdate:value":t[1]||(t[1]=c=>w.value=c),type:"line",animated:"",size:"large",class:"config-tabs"},{default:o(()=>[s(a(k),{name:"components",tab:"MCP 组件"},{default:o(()=>[e("div",ie,[s(j,{config:l.value,onUpdate:m},null,8,["config"])])]),_:1}),s(a(k),{name:"tools",tab:"自定义工具"},{default:o(()=>[e("div",re,[s(H,{config:l.value,onUpdate:m},null,8,["config"])])]),_:1}),s(a(k),{name:"init",tab:"初始化脚本"},{default:o(()=>[e("div",de,[s(P,{config:l.value,onUpdate:m},null,8,["config"])])]),_:1})]),_:1},8,["value"])])):b("",!0)]),_:1},8,["show"])]))}}),he=F(ce,[["__scopeId","data-v-e297e9f7"]]);export{he as default};
1
+ import{a as N}from"./index-DE9Vu0rM.js";import{u as S,M as j,C as H,I as P}from"./InitScriptEditor-DfeJ9u_F.js";import{u as T,B as V,p as E,q as I,t as h,h as q,l as D,m as k}from"./naive-ui-BBnth-GV.js";import{q as L,r as d,s as W,o as G,c0 as v,c1 as e,bW as s,bS as x,c5 as b,bV as o,bs as a,c2 as O,c7 as _,bU as r,l as A}from"./vendor-DpXl860f.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-BXWd1EVR.js";const J={class:"configs-page"},K={style:{position:"absolute",width:"0",height:"0"}},Q={class:"configs-container"},R={class:"config-content"},X={class:"user-selector-section"},Y={class:"selector-header"},Z={key:0,class:"loading-state"},$={key:1,class:"config-stats"},ee={class:"stat-card"},te={class:"stat-content"},se={class:"stat-value"},oe={class:"stat-card"},ae={class:"stat-content"},ne={class:"stat-value"},le={key:0,class:"modal-content"},ie={class:"tab-content"},re={class:"tab-content"},de={class:"tab-content"},ce=L({__name:"Configs",setup(ve){const u=T(),p=S(),i=d(null),f=d(!1),y=d([]),g=d(!1),m=d("components"),l=W(()=>p.currentConfig),C=d([]);async function M(){try{const n=await N.get("/users");y.value=n.data.data.filter(t=>t.role!=="admin"),C.value=y.value.map(t=>({label:t.email,value:t.id}))}catch{u.error("加载用户列表失败")}}async function B(){if(i.value){f.value=!0;try{await p.fetchUserConfig(i.value)}catch(n){u.error(n.message)}finally{f.value=!1}}}function U(){l.value&&(m.value="components",g.value=!0)}async function w(n){if(i.value)try{await p.updateUserConfig(i.value,n),u.success("更新成功")}catch(t){u.error(t.message)}}function z(n){i.value=n,n&&B()}return G(()=>{M()}),(n,t)=>(r(),v("div",J,[(r(),v("svg",K,[...t[3]||(t[3]=[e("defs",null,[e("linearGradient",{id:"loading-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[e("stop",{offset:"0%","stop-color":"#dc2626"}),e("stop",{offset:"50%","stop-color":"#ea580c"}),e("stop",{offset:"100%","stop-color":"#f59e0b"})])],-1)])])),t[15]||(t[15]=e("div",{class:"page-header"},[e("div",null,[e("h1",{class:"page-title"},"配置管理"),e("p",{class:"page-description"},"查看和编辑用户的 MCP 配置")])],-1)),e("div",Q,[e("main",R,[e("div",X,[e("div",Y,[t[6]||(t[6]=e("div",{class:"selector-label"},[e("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("span",null,"选择用户")],-1)),l.value?(r(),x(a(V),{key:0,type:"primary",size:"large",class:"edit-btn",onClick:U},{icon:o(()=>[...t[4]||(t[4]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[5]||(t[5]=A(" 编辑配置 ",-1))]),_:1})):b("",!0)]),s(a(E),{value:i.value,"onUpdate:value":[t[0]||(t[0]=c=>i.value=c),z],options:C.value,placeholder:"请选择要配置的用户",size:"large",filterable:"",clearable:"",class:"user-select"},{empty:o(()=>[s(a(h),{description:"暂无用户"})]),_:1},8,["value","options"])]),s(a(I),{class:"content-divider"}),f.value?(r(),v("div",Z,[...t[7]||(t[7]=[e("div",{class:"loading-spinner"},[e("svg",{class:"spinner",viewBox:"0 0 50 50"},[e("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"4"})])],-1),e("p",{class:"loading-text"},"加载配置中...",-1)])])):l.value?(r(),v("div",$,[e("div",ee,[t[9]||(t[9]=O('<div class="stat-icon stat-icon--primary" data-v-e297e9f7><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-e297e9f7><rect x="3" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="3" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect></svg></div>',1)),e("div",te,[e("div",se,_(l.value.components.length),1),t[8]||(t[8]=e("div",{class:"stat-label"},"MCP 组件",-1))])]),e("div",oe,[t[11]||(t[11]=e("div",{class:"stat-icon stat-icon--success"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),e("div",ae,[e("div",ne,_(l.value.customTools.length),1),t[10]||(t[10]=e("div",{class:"stat-label"},"自定义工具",-1))])])])):i.value?(r(),x(a(h),{key:3,description:"该用户暂无配置或加载失败",class:"empty-placeholder"},{icon:o(()=>[...t[13]||(t[13]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("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)])]),_:1})):(r(),x(a(h),{key:2,description:"请选择一个用户查看配置",class:"empty-placeholder"},{icon:o(()=>[...t[12]||(t[12]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1}))])]),s(a(q),{show:g.value,"onUpdate:show":t[2]||(t[2]=c=>g.value=c),preset:"card",bordered:!1,class:"config-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh"}},{header:o(()=>[...t[14]||(t[14]=[e("div",{class:"modal-header"},[e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),e("div",null,[e("h3",{class:"modal-title"},"编辑用户配置"),e("p",{class:"modal-subtitle"},"管理 MCP 组件、工具和脚本")])],-1)])]),default:o(()=>[l.value?(r(),v("div",le,[s(a(D),{value:m.value,"onUpdate:value":t[1]||(t[1]=c=>m.value=c),type:"line",animated:"",size:"large",class:"config-tabs"},{default:o(()=>[s(a(k),{name:"components",tab:"MCP 组件"},{default:o(()=>[e("div",ie,[s(j,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1}),s(a(k),{name:"tools",tab:"自定义工具"},{default:o(()=>[e("div",re,[s(H,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1}),s(a(k),{name:"init",tab:"初始化脚本"},{default:o(()=>[e("div",de,[s(P,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1})]),_:1},8,["value"])])):b("",!0)]),_:1},8,["show"])]))}}),he=F(ce,[["__scopeId","data-v-e297e9f7"]]);export{he as default};
@@ -1,4 +1,4 @@
1
- import{q as $e,r as m,s as le,w as Se,c0 as y,c1 as a,bW as o,bV as n,bs as l,bU as w,l as h,G as I,o as ze,c5 as te,F as fe,bN as me,c7 as G,bm as Ue,bS as ye,Z as He,ah as Oe,bT as Le,c6 as Pe,c8 as qe,c3 as Je}from"./vendor-DpXl860f.js";import{g as Fe,p as We,M as Ge,u as Ae,I as Ke,C as Ye,a as Qe}from"./InitScriptEditor-BFTWTD26.js";import{a as X,u as Xe,p as Ze}from"./index-CmiEbWrJ.js";import{u as De,B as $,e as J,f as Ie,g as ce,c as Ce,d as W,h as Te,i as xe,j as Ve,k as Ee,l as _e,m as et,o as Ne,p as tt,q as je,r as Re,s as ge,t as at,v as st,w as lt,x as Be,y as nt}from"./naive-ui-BwyHI4J3.js";import{_ as Me}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-BXWd1EVR.js";const ot={class:"variables-manager"},rt={class:"variables-toolbar"},it={class:"variables-table-container"},ut={class:"modal-form-wrapper"},dt=$e({__name:"VariablesManager",props:{config:{}},emits:["update"],setup(ne,{emit:_}){const f=ne,p=_,V=De(),c=m(!1),E=m(!1),z=m(null),O=m(),R=m(""),U={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},Y=C=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:u=>{u.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:u=>{u.currentTarget.style.backgroundColor=""}}),H=[{title:"变量名",key:"name",width:100,render(C){return I("strong",C.name)}},{title:"值",key:"value",width:500,render(C){if(C.isSecret)return I(xe,{type:"info",depth:3,italic:!0},{default:()=>"****** (敏感信息)"});const u=String(C.value).split(`
1
+ import{q as $e,r as m,s as le,w as Se,c0 as y,c1 as a,bW as o,bV as n,bs as l,bU as w,l as h,G as I,o as ze,c5 as te,F as fe,bN as me,c7 as G,bm as Ue,bS as ye,Z as He,ah as Oe,bT as Le,c6 as Pe,c8 as qe,c3 as Je}from"./vendor-DpXl860f.js";import{g as Fe,p as We,_ as Ge,u as Ae,I as Ke,C as Ye,M as Qe}from"./InitScriptEditor-DfeJ9u_F.js";import{a as X,u as Xe,p as Ze}from"./index-DE9Vu0rM.js";import{u as De,B as $,e as J,g as Ie,h as ce,c as Ce,d as W,i as Te,j as xe,k as Ve,l as Ee,m as _e,o as et,p as Ne,q as tt,r as je,s as Re,t as ge,v as at,w as st,x as lt,y as Be,z as nt}from"./naive-ui-BBnth-GV.js";import{_ as Me}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-BXWd1EVR.js";const ot={class:"variables-manager"},rt={class:"variables-toolbar"},it={class:"variables-table-container"},ut={class:"modal-form-wrapper"},dt=$e({__name:"VariablesManager",props:{config:{}},emits:["update"],setup(ne,{emit:_}){const f=ne,p=_,V=De(),c=m(!1),E=m(!1),z=m(null),O=m(),R=m(""),U={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},Y=C=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:u=>{u.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:u=>{u.currentTarget.style.backgroundColor=""}}),H=[{title:"变量名",key:"name",width:100,render(C){return I("strong",C.name)}},{title:"值",key:"value",width:500,render(C){if(C.isSecret)return I(xe,{type:"info",depth:3,italic:!0},{default:()=>"****** (敏感信息)"});const u=String(C.value).split(`
2
2
  `).map((b,Q,oe)=>{const ae=[I("span",{class:"value-line"},b)];return Q<oe.length-1&&ae.push(I("br")),ae}).flat();return I("div",{class:"variable-value-cell"},u)}},{title:"描述",key:"description",width:300,render(C){return I(xe,{depth:3},{default:()=>C.description||"-"})}},{title:"操作",key:"actions",width:150,render(C){return I(Ve,{size:"small"},{default:()=>[I($,{size:"small",onClick:()=>A(C)},{default:()=>"编辑"}),I($,{size:"small",type:"error",onClick:()=>P(C.id)},{default:()=>"删除"})]})}}],B=le(()=>{if(!R.value)return f.config.variables;const C=R.value.toLowerCase();return f.config.variables.filter(u=>{var b;return u.name.toLowerCase().includes(C)||((b=u.description)==null?void 0:b.toLowerCase().includes(C))})}),x=m({name:"",value:"",description:"",isSecret:!1}),L={name:{required:!0,message:"请输入变量名",trigger:"blur"},value:{required:!0,message:"请输入变量值",trigger:"blur"}};function A(C){z.value=C,x.value={name:C.name,value:C.value,description:C.description||"",isSecret:C.isSecret||!1},c.value=!0}function P(C){const u=f.config.variables.filter(b=>b.id!==C);p("update",{variables:u})}async function ve(){var C,u;try{await((C=O.value)==null?void 0:C.validate()),E.value=!0;const b={id:((u=z.value)==null?void 0:u.id)||Fe(),name:x.value.name,value:x.value.value,description:x.value.description||void 0,isSecret:x.value.isSecret},Q=[...f.config.variables],oe=Q.findIndex(ae=>ae.id===b.id);oe!==-1?Q[oe]=b:Q.push(b),p("update",{variables:Q}),c.value=!1,q()}catch(b){V.error(b.message)}finally{E.value=!1}}function q(){z.value=null,x.value={name:"",value:"",description:"",isSecret:!1}}return Se(()=>c.value,C=>{C||q()}),(C,u)=>(w(),y("div",ot,[a("div",rt,[o(l($),{type:"primary",size:"large",class:"add-variable-btn",onClick:u[0]||(u[0]=b=>c.value=!0)},{icon:n(()=>[...u[8]||(u[8]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[u[9]||(u[9]=h(" 添加变量 ",-1))]),_:1}),o(l(J),{value:R.value,"onUpdate:value":u[1]||(u[1]=b=>R.value=b),placeholder:"搜索变量名或描述...",size:"large",clearable:"",class:"search-input"},{prefix:n(()=>[...u[10]||(u[10]=[a("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"])]),a("div",it,[o(l(Ie),{columns:H,data:B.value,pagination:U,"row-props":Y,class:"modern-table"},null,8,["data"])]),o(l(ce),{show:c.value,"onUpdate:show":u[7]||(u[7]=b=>c.value=b),preset:"dialog",title:z.value?"编辑变量":"添加变量",class:"variable-edit-modal",style:{maxHeight:"90vh"}},{action:n(()=>[o(l($),{onClick:u[6]||(u[6]=b=>c.value=!1)},{default:n(()=>[...u[12]||(u[12]=[h("取消",-1)])]),_:1}),o(l($),{type:"primary",loading:E.value,onClick:ve},{default:n(()=>[...u[13]||(u[13]=[h("保存",-1)])]),_:1},8,["loading"])]),default:n(()=>[a("div",ut,[o(l(Ce),{ref_key:"formRef",ref:O,model:x.value,rules:L},{default:n(()=>[o(l(W),{path:"name",label:"变量名"},{default:n(()=>[o(l(J),{value:x.value.name,"onUpdate:value":u[2]||(u[2]=b=>x.value.name=b),placeholder:"例如: API_KEY"},null,8,["value"])]),_:1}),o(l(W),{path:"value",label:"值"},{default:n(()=>[o(l(J),{value:x.value.value,"onUpdate:value":u[3]||(u[3]=b=>x.value.value=b),type:x.value.isSecret?"password":"textarea",rows:x.value.isSecret?void 0:3,placeholder:"变量值"},null,8,["value","type","rows"])]),_:1}),o(l(W),{path:"description",label:"描述"},{default:n(()=>[o(l(J),{value:x.value.description,"onUpdate:value":u[4]||(u[4]=b=>x.value.description=b),type:"textarea",rows:2,placeholder:"可选"},null,8,["value"])]),_:1}),o(l(W),{path:"isSecret",label:"敏感信息"},{default:n(()=>[o(l(Te),{checked:x.value.isSecret,"onUpdate:checked":u[5]||(u[5]=b=>x.value.isSecret=b)},{default:n(()=>[...u[11]||(u[11]=[h("标记为敏感信息(导出时使用占位符)",-1)])]),_:1},8,["checked"])]),_:1})]),_:1},8,["model"])])]),_:1},8,["show","title"])]))}}),ct=Me(dt,[["__scopeId","data-v-f50b6ccd"]]),vt={class:"prompts-manager"},pt={class:"prompts-toolbar"},ft={class:"prompts-table-container"},mt={class:"modal-header"},gt={class:"modal-title"},wt={class:"modal-subtitle"},ht={class:"modal-content-wrapper"},bt={class:"tab-pane-content"},kt={class:"form-section"},yt={class:"form-grid-2"},xt={class:"form-section"},Ct={class:"section-header"},$t={class:"parameters-list"},St={class:"parameter-header"},Dt={class:"parameter-index"},Mt={class:"parameter-fields"},_t={key:0,class:"empty-parameters"},zt={class:"tab-pane-content"},Tt={style:{display:"flex","align-items":"center",gap:"8px"}},Ut={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"18px",height:"18px"}},Nt={class:"messages-section"},jt={class:"message-header"},It={class:"save-status-indicator"},Bt=["title"],At={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vt={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Et={key:0,class:"monaco-wrapper"},Rt={key:0,class:"empty-messages"},Ht={class:"modal-footer"},Ot={class:"test-content"},Lt={class:"test-messages"},Pt={class:"test-message-header"},qt={class:"test-message-content"},Jt={key:0,class:"test-message-empty"},Ft=$e({__name:"PromptsManager",setup(ne){const _=De(),f=m(!1),p=m(!1),V=m(!1),c=m(!1),E=m(!1),z=m(null),O=m(),R=m(""),U=m([]),Y=m("content"),H=m(!1),B=m(-1),x=m(new Map),L=m(!1),A=[{label:"用户",value:"user"},{label:"助手",value:"assistant"}],P={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},ve=d=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:t=>{t.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:t=>{t.currentTarget.style.backgroundColor=""}}),q=[{title:"名称",key:"name",width:200,render(d){return I("strong",d.name)}},{title:"描述",key:"description",render(d){return I(xe,{depth:3},{default:()=>d.description||"-"})}},{title:"参数数量",key:"arguments",width:120,render(d){return I(xe,{depth:3},{default:()=>{var t;return`${((t=d.arguments)==null?void 0:t.length)||0} 个`}})}},{title:"消息数量",key:"messages",width:120,render(d){return I(xe,{depth:3},{default:()=>{var t;return`${((t=d.messages)==null?void 0:t.length)||0} 条`}})}},{title:"操作",key:"actions",width:200,render(d){return I(Ve,{size:"small"},{default:()=>[I($,{size:"small",onClick:()=>ue(d)},{default:()=>"编辑"}),I($,{size:"small",type:"info",onClick:()=>r(d)},{default:()=>"测试"}),I($,{size:"small",type:"error",onClick:()=>we(d.id)},{default:()=>"删除"})]})}}],C=le(()=>{if(!R.value)return U.value;const d=R.value.toLowerCase();return U.value.filter(t=>{var e;return t.name.toLowerCase().includes(d)||((e=t.description)==null?void 0:e.toLowerCase().includes(d))})}),u=m({name:"",description:"",arguments:[],messages:[]}),b=m({arguments:{}}),Q=le(()=>!p.value||!u.value.messages||u.value.messages.length===0?[]:u.value.messages.filter(t=>t.content.text).map(t=>({...t,content:{...t.content,text:We(t.content.text,b.value.arguments)}}))),oe={name:{required:!0,message:"请输入提示词名称",trigger:"blur"},messages:{required:!0,validator:(d,t)=>!t||t.length===0?new Error("至少需要一条消息"):!0,trigger:"blur"}};function ae(d){return x.value.get(d)||!1}function se(d){x.value.set(d,!0)}function ie(d){H.value&&B.value===d?(H.value=!1,B.value=-1):(H.value=!0,B.value=d)}async function Z(){var d,t;try{E.value=!0;const e=await X.get("/prompts");e.data.success&&(U.value=e.data.data)}catch(e){_.error(((t=(d=e.response)==null?void 0:d.data)==null?void 0:t.error)||"加载提示词失败")}finally{E.value=!1}}function pe(){z.value=null,T(),f.value=!0,Y.value="content"}function ue(d){z.value=d,u.value={name:d.name,description:d.description||"",arguments:d.arguments?[...d.arguments]:[],messages:d.messages&&d.messages.length>0?[...d.messages]:[{role:"user",content:{type:"text",text:""}}]},x.value.clear(),f.value=!0,Y.value="content"}async function we(d){var t,e;try{await X.delete(`/prompts/${d}`),_.success("删除成功"),await Z()}catch(s){_.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"删除失败")}}function he(){u.value.arguments.push({name:"",description:"",required:!1})}function re(d){u.value.arguments.splice(d,1)}function be(){u.value.messages.push({role:"user",content:{type:"text",text:""}}),se(u.value.messages.length-1)}function de(d){u.value.messages.splice(d,1),x.value.delete(d),B.value===d?(H.value=!1,B.value=-1):B.value>d&&B.value--}async function ke(){var d,t,e;try{await((d=O.value)==null?void 0:d.validate()),V.value=!0;const s={name:u.value.name,description:u.value.description||void 0,arguments:u.value.arguments.filter(i=>i.name),messages:u.value.messages.filter(i=>i.content.text)};z.value?(await X.put(`/prompts/${z.value.id}`,s),_.success("更新成功")):(await X.post("/prompts",s),_.success("创建成功")),x.value.clear(),f.value=!1,await Z(),T()}catch(s){_.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"保存失败")}finally{V.value=!1}}async function g(){var d,t,e;try{await((d=O.value)==null?void 0:d.validate()),c.value=!0;const s=u.value.arguments.filter(i=>i.name);b.value.arguments=s.reduce((i,j)=>(i[j.name]=b.value.arguments[j.name]||"",i),{}),p.value=!0}catch(s){_.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"测试失败")}finally{c.value=!1}}async function r(d){z.value=d,u.value={name:d.name,description:d.description||"",arguments:d.arguments?[...d.arguments]:[],messages:d.messages?[...d.messages]:[]};const t=u.value.arguments.filter(e=>e.name);b.value.arguments=t.reduce((e,s)=>(e[s.name]="",e),{}),await g()}function T(){z.value=null,u.value={name:"",description:"",arguments:[],messages:[{role:"user",content:{type:"text",text:`# 提示词模板
3
3
 
4
4
  ## 变量替换