import{a9 as ne,n as j,p as F,D as ue,q as de,d as re,r as M,aa as ce,s as ge,v as le,a as N,y as s,H as fe,ab as ve,ac as me,M as he,ad as I,ae as W,af as J,ag as L,W as pe,ah as ye,K as ze,a5 as D,ai as X,o as V,b as A,f as d,w as c,e as p,h as i,aj as Y,ak as K,c as G,g as P,a6 as xe,t as Se,a3 as be,a8 as Ce}from"./index-U-PhABqT.js";import{M as y,a as Q,O as Z,B as ee,I as te}from"./index-C1Is5pBl.js";import{D as we}from"./index-BfL8W95B.js";import"./vue.runtime.esm-bundler-CQYuvFJ3.js";function _e(t){const{primaryColorHover:g,borderColor:f}=t;return{resizableTriggerColorHover:g,resizableTriggerColor:f}}const $e={common:ne,self:_e},Pe=j("split",`
 display: flex;
 width: 100%;
 height: 100%;
`,[F("horizontal",`
 flex-direction: row;
 `),F("vertical",`
 flex-direction: column;
 `),j("split-pane-1",`
 overflow: hidden;
 `),j("split-pane-2",`
 overflow: hidden;
 flex: 1;
 `),ue("resize-trigger",`
 background-color: var(--n-resize-trigger-color);
 transition: background-color .3s var(--n-bezier);
 `,[F("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=N(()=>{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}}),x=s(null),w=s(!1),O=fe(t,"size"),n=s(t.defaultSize);!((g=t.watchProps)===null||g===void 0)&&g.includes("defaultSize")&&ve(()=>n.value=t.defaultSize);const v=r=>{const a=t["onUpdate:size"];t.onUpdateSize&&J(t.onUpdateSize,r),a&&J(a,r),n.value=r},_=me(O,n),R=N(()=>{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)`}}}),S=N(()=>t.direction==="horizontal"?{width:`${t.resizeTriggerSize}px`,height:"100%"}:{width:"100%",height:`${t.resizeTriggerSize}px`}),b=N(()=>{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 q=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=x.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=x.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,k=T==="horizontal"?E:C,ie=T==="horizontal"?r.clientX-l.left-u:r.clientY-l.top+u,{min:B,max:H}=t,se=typeof B=="string"?W(B):B*k,oe=typeof H=="string"?W(H):H*k;let $=ie;$=Math.max($,se),$=Math.min($,oe,k),typeof _.value=="string"?v(`${$}px`):v($/k)}const m=z?he("split",void 0,h,t):void 0;return{themeClass:m?.themeClass,onRender:m?.onRender,cssVars:z?void 0:h,resizeTriggerElRef:x,isDragging:w,mergedClsPrefix:f,resizeTriggerWrapperStyle:b,resizeTriggerStyle:S,handleMouseDown:q,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"}},ke=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&&(O(),q(),U())});const x=s(!1),w=s("");async function O(){x.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,v.value=a.data[0].systemPrompt,a.data[0].tools&&a.data[0].tools.length>0?S.value=JSON.parse(a.data[0].tools):S.value=[]}catch{x.value=!1,y.error("查询失败")}x.value=!1}const n=s(""),v=s(""),_=s("{}"),R=s([]),S=s([]),b=s([]),u=s("");async function q(){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 m(){if(!n.value||n.value.length==0){y.warning("请填写用户提示词");return}if(!v.value||v.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:v.value,tools:JSON.stringify(S.value),parames:JSON.stringify(a)}}),y.success("保存成功")}catch{y.error("保存失败")}}async function r(){await m(),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(),A("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),A(Y,null,K(b.value,l=>(V(),G(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:m},{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:v.value,"onUpdate:modelValue":e[2]||(e[2]=l=>v.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:S.value,"onUpdate:modelValue":e[3]||(e[3]=l=>S.value=l),searchable:!0,"reserve-keyword":"",multiple:"",placeholder:"添加MCP工具"},{default:c(()=>[(V(!0),A(Y,null,K(R.value,l=>(V(),G(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(xe),null,{default:c(()=>[P(Se(_.value),1)]),_:1})])]),_:1})]),_:1})]),_:1},8,["title"])]))}}),He=Ce(ke,[["__scopeId","data-v-6a5febb7"]]);export{He as default};
