import{F as ne,G as F,H as A,I as ue,J as de,d as re,K as M,L as ce,M as ge,O as le,a as O,z as s,P as fe,Q as me,R as ve,U as he,V as I,W as J,X as W,Y as L,y as pe,Z as ye,A as ze,D,a0 as X,o as V,b as j,f as d,w as c,e as p,h as i,a1 as Y,a2 as G,c as K,g as P,S as Se,t as xe,N as be,m as Ce}from"./index-BhlVWTSX.js";import{B as Q,O as Z}from"./index-BOKOWplY.js";import{M as y,B as ee,I as te}from"./index-BQhUrQ6p.js";import{D as we}from"./index-dCXdEX8Y.js";function _e(t){const{primaryColorHover:g,borderColor:f}=t;return{resizableTriggerColorHover:g,resizableTriggerColor:f}}const $e={common:ne,self:_e},Pe=F("split",`
 display: flex;
 width: 100%;
 height: 100%;
`,[A("horizontal",`
 flex-direction: row;
 `),A("vertical",`
 flex-direction: column;
 `),F("split-pane-1",`
 overflow: hidden;
 `),F("split-pane-2",`
 overflow: hidden;
 flex: 1;
 `),ue("resize-trigger",`
 background-color: var(--n-resize-trigger-color);
 transition: background-color .3s var(--n-bezier);
 `,[A("hover",`
 background-color: var(--n-resize-trigger-color-hover);
 `),de("&:hover",`
 background-color: var(--n-resize-trigger-color-hover);
 `)])]),Te=Object.assign(Object.assign({},le.props),{direction:{type:String,default:"horizontal"},resizeTriggerSize:{type:Number,default:3},disabled:Boolean,defaultSize:{type:[String,Number],default:.5},"onUpdate:size":[Function,Array],onUpdateSize:[Function,Array],size:[String,Number],min:{type:[String,Number],default:0},max:{type:[String,Number],default:1},pane1Class:String,pane1Style:[Object,String],pane2Class:String,pane2Style:[Object,String],onDragStart:Function,onDragMove:Function,onDragEnd:Function,watchProps:Array}),ae=re({name:"Split",props:Te,slots:Object,setup(t){var g;const{mergedClsPrefixRef:f,inlineThemeDisabled:z}=ge(t),o=le("Split","-split",Pe,$e,t,f),h=O(()=>{const{common:{cubicBezierEaseInOut:r},self:{resizableTriggerColor:a,resizableTriggerColorHover:e}}=o.value;return{"--n-bezier":r,"--n-resize-trigger-color":a,"--n-resize-trigger-color-hover":e}}),S=s(null),w=s(!1),B=fe(t,"size"),n=s(t.defaultSize);!((g=t.watchProps)===null||g===void 0)&&g.includes("defaultSize")&&me(()=>n.value=t.defaultSize);const m=r=>{const a=t["onUpdate:size"];t.onUpdateSize&&W(t.onUpdateSize,r),a&&W(a,r),n.value=r},_=ve(B,n),R=O(()=>{const r=_.value;if(typeof r=="string")return{flex:`0 0 ${r}`};if(typeof r=="number"){const a=r*100;return{flex:`0 0 calc(${a}% - ${t.resizeTriggerSize*a/100}px)`}}}),x=O(()=>t.direction==="horizontal"?{width:`${t.resizeTriggerSize}px`,height:"100%"}:{width:"100%",height:`${t.resizeTriggerSize}px`}),b=O(()=>{const r=t.direction==="horizontal";return{width:r?`${t.resizeTriggerSize}px`:"",height:r?"":`${t.resizeTriggerSize}px`,cursor:t.direction==="horizontal"?"col-resize":"row-resize"}});let u=0;const k=r=>{r.preventDefault(),w.value=!0,t.onDragStart&&t.onDragStart(r);const a="mousemove",e="mouseup",l=C=>{U(C),t.onDragMove&&t.onDragMove(C)},T=()=>{L(a,document,l),L(e,document,T),w.value=!1,t.onDragEnd&&t.onDragEnd(r),document.body.style.cursor=""};document.body.style.cursor=b.value.cursor,I(a,document,l),I(e,document,T);const E=S.value;if(E){const C=E.getBoundingClientRect();t.direction==="horizontal"?u=r.clientX-C.left:u=C.top-r.clientY}U(r)};function U(r){var a,e;const l=(e=(a=S.value)===null||a===void 0?void 0:a.parentElement)===null||e===void 0?void 0:e.getBoundingClientRect();if(!l)return;const{direction:T}=t,E=l.width-t.resizeTriggerSize,C=l.height-t.resizeTriggerSize,N=T==="horizontal"?E:C,ie=T==="horizontal"?r.clientX-l.left-u:r.clientY-l.top+u,{min:q,max:H}=t,se=typeof q=="string"?J(q):q*N,oe=typeof H=="string"?J(H):H*N;let $=ie;$=Math.max($,se),$=Math.min($,oe,N),typeof _.value=="string"?m(`${$}px`):m($/N)}const v=z?he("split",void 0,h,t):void 0;return{themeClass:v?.themeClass,onRender:v?.onRender,cssVars:z?void 0:h,resizeTriggerElRef:S,isDragging:w,mergedClsPrefix:f,resizeTriggerWrapperStyle:b,resizeTriggerStyle:x,handleMouseDown:k,firstPaneStyle:R}},render(){var t,g,f,z,o;return(t=this.onRender)===null||t===void 0||t.call(this),M("div",{class:[`${this.mergedClsPrefix}-split`,`${this.mergedClsPrefix}-split--${this.direction}`,this.themeClass],style:this.cssVars},M("div",{class:[`${this.mergedClsPrefix}-split-pane-1`,this.pane1Class],style:[this.firstPaneStyle,this.pane1Style]},(f=(g=this.$slots)[1])===null||f===void 0?void 0:f.call(g)),!this.disabled&&M("div",{ref:"resizeTriggerElRef",class:`${this.mergedClsPrefix}-split__resize-trigger-wrapper`,style:this.resizeTriggerWrapperStyle,onMousedown:this.handleMouseDown},ce(this.$slots["resize-trigger"],()=>[M("div",{style:this.resizeTriggerStyle,class:[`${this.mergedClsPrefix}-split__resize-trigger`,this.isDragging&&`${this.mergedClsPrefix}-split__resize-trigger--hover`]})])),M("div",{class:[`${this.mergedClsPrefix}-split-pane-2`,this.pane2Class],style:this.pane2Style},(o=(z=this.$slots)[2])===null||o===void 0?void 0:o.call(z)))}}),Me={style:{display:"flex"}},De={style:{width:"250px"}},Ve={style:{"margin-right":"10px"}},Re={style:{"margin-right":"10px"}},Ue={style:{"margin-left":"10px","margin-top":"5px"}},Ee={style:{"margin-left":"10px","max-height":"300px"}},Ne=re({name:"agentedit",__name:"index",setup(t){const{protocol:g,hostname:f,port:z}=pe(),o=`${g}://${f}:${z}`,h=ye();ze(()=>{console.log(h.query.code),h.query.code&&(B(),k(),U())});const S=s(!1),w=s("");async function B(){S.value=!0;try{const a=await D({url:`${o}/api/agentmanager/queryPage`,method:"get",params:{code:h.query.code}});w.value=a.data[0].name,u.value=a.data[0].model,n.value=a.data[0].userPrompt,m.value=a.data[0].systemPrompt,a.data[0].tools&&a.data[0].tools.length>0?x.value=JSON.parse(a.data[0].tools):x.value=[]}catch{S.value=!1,y.error("查询失败")}S.value=!1}const n=s(""),m=s(""),_=s("{}"),R=s([]),x=s([]),b=s([]),u=s("");async function k(){b.value=[];const a=await D({url:`${o}/api/llmconfig/queryPage`,method:"get",params:{limit:1e4,offset:0}});X(a.data)&&a.data.forEach(e=>{b.value.push({label:e.name,value:e.name,disabled:!1})})}async function U(){b.value=[];const a=await D({url:`${o}/api/mcpmanager/queryPage`,method:"get",params:{limit:1e4,offset:0}});X(a.data)&&a.data.forEach(e=>{R.value.push({label:e.name,value:e.id,disabled:!1})})}async function v(){if(!n.value||n.value.length==0){y.warning("请填写用户提示词");return}if(!m.value||m.value.length==0){y.warning("请填写角色提示词");return}if(!u.value||u.value.length==0){y.warning("请选择大模型");return}const a={prompt:n.value};try{await D({url:`${o}/api/agentmanager/save`,method:"post",data:{code:h.query.code,model:u.value,userPrompt:n.value,systemPrompt:m.value,tools:JSON.stringify(x.value),parames:JSON.stringify(a)}}),y.success("保存成功")}catch{y.error("保存失败")}}async function r(){await v(),y.info("开始运行");try{_.value="生成中...";const a=await D({url:`${o}/api/openai/run/${h.query.code}`,method:"post",data:{}});_.value=a.data.res}catch{y.error("运行失败")}}return(a,e)=>(V(),j("div",null,[d(i(be),{title:w.value},{"header-extra":c(()=>e[4]||(e[4]=[P(" 单Agent模式 ")])),default:c(()=>[p("div",Me,[p("div",De,[d(i(Q),{clearable:"",modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=l=>u.value=l),placeholder:"请选择大模型"},{default:c(()=>[(V(!0),j(Y,null,G(b.value,l=>(V(),K(i(Z),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),d(i(ee),{style:{"margin-left":"10px"},onClick:v},{default:c(()=>e[5]||(e[5]=[P(" 保存 ")])),_:1,__:[5]}),d(i(ee),{type:"info",style:{"margin-left":"10px"},onClick:r},{default:c(()=>e[6]||(e[6]=[P(" 运行 ")])),_:1,__:[6]})]),d(i(we)),d(i(ae),{direction:"horizontal",style:{"max-height":"450px"},size:.4},{1:c(()=>[e[7]||(e[7]=P(" 用户提示词 ")),p("div",Ve,[d(i(te),{type:"textarea",modelValue:n.value,"onUpdate:modelValue":e[1]||(e[1]=l=>n.value=l),cols:100,rows:8,resize:"none"},null,8,["modelValue"])]),e[8]||(e[8]=P(" 角色提示词 ")),p("div",Re,[d(i(te),{type:"textarea",modelValue:m.value,"onUpdate:modelValue":e[2]||(e[2]=l=>m.value=l),cols:100,rows:8,resize:"none"},null,8,["modelValue"])])]),2:c(()=>[d(i(ae),{direction:"vertical",style:{height:"450px"},size:.4},{1:c(()=>[e[9]||(e[9]=p("div",{style:{"margin-left":"10px"}},"选择工具",-1)),p("div",Ue,[d(i(Q),{clearable:"",modelValue:x.value,"onUpdate:modelValue":e[3]||(e[3]=l=>x.value=l),searchable:!0,"reserve-keyword":"",multiple:"",placeholder:"添加MCP工具"},{default:c(()=>[(V(!0),j(Y,null,G(R.value,l=>(V(),K(i(Z),{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])]),2:c(()=>[e[10]||(e[10]=p("div",{style:{"margin-left":"10px"}},"结果预览",-1)),p("div",Ee,[d(i(Se),null,{default:c(()=>[P(xe(_.value),1)]),_:1})])]),_:1})]),_:1})]),_:1},8,["title"])]))}}),He=Ce(Ne,[["__scopeId","data-v-6a5febb7"]]);export{He as default};
