@standardagents/builder 0.8.3 → 0.9.0

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,20 +1,20 @@
1
- import{m as ge,c as l,o as s,a as ot,b as o,d as $,u as Pe,e as Le,f as z,r as m,g as ce,h as Te,i,j as X,F as W,k as ne,n as ee,t as b,w as he,l as S,p as He,R as Yt,q as ie,s as Be,v as oe,x as pe,y as ae,T as We,z as st,A as fe,B as _e,C as $t,D as ve,E as Ze,L as _t,G as wt,H as eo,I as to,J as oo,M as Ct,K as ro,P as ao,N as St,O as Ne,Q as so,S as Tt,U as lo,V as rt,W as Se,X as Ee,Y as no,Z as io,_ as lt,$ as Mt,a0 as It,a1 as co,a2 as uo,a3 as po,a4 as mo}from"./vue.js";import{W as go,a as fo,e as gt}from"./monaco.js";import"./vendor.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))e(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const r of d.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&e(r)}).observe(document,{childList:!0,subtree:!0});function a(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function e(c){if(c.ep)return;c.ep=!0;const d=a(c);fetch(c.href,d)}})();const ho={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function vo(u,t){return s(),l("svg",ho,[...t[0]||(t[0]=[ot('<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></g>',1)])])}const bo=ge({name:"lucide-layout-dashboard",render:vo}),yo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xo(u,t){return s(),l("svg",yo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 8V4H8"}),o("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const ko=ge({name:"lucide-bot",render:xo}),_o={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wo(u,t){return s(),l("svg",_o,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const ft=ge({name:"lucide-message-square",render:wo}),Co={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function So(u,t){return s(),l("svg",Co,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),o("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),o("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const To=ge({name:"lucide-cpu",render:So}),Mo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Io(u,t){return s(),l("svg",Mo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Vo=ge({name:"lucide-server",render:Io}),Ao={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Po(u,t){return s(),l("svg",Ao,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Eo=ge({name:"lucide-wrench",render:Po}),Oo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jo(u,t){return s(),l("svg",Oo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),o("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Lo=ge({name:"lucide-settings",render:jo}),Do={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Uo(u,t){return s(),l("svg",Do,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5h16M4 12h16M4 19h16"},null,-1)])])}const qo=ge({name:"lucide-menu",render:Uo}),No={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bo(u,t){return s(),l("svg",No,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Ro=ge({name:"lucide-chevron-left",render:Bo}),Fo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function zo(u,t){return s(),l("svg",Fo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const Ho=ge({name:"lucide-sun",render:zo}),Wo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Jo(u,t){return s(),l("svg",Wo,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const Ko=ge({name:"lucide-moon",render:Jo}),Zo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Go(u,t){return s(),l("svg",Zo,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const Xo=ge({name:"lucide-activity",render:Go}),Qo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yo(u,t){return s(),l("svg",Qo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),o("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const $o=ge({name:"lucide-function-square",render:Yo}),er={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function tr(u,t){return s(),l("svg",er,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 22v-5M9 8V2m6 6V2m3 6v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"},null,-1)])])}const or=ge({name:"lucide-plug",render:tr}),rr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ar(u,t){return s(),l("svg",rr,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const sr=ge({name:"lucide-log-out",render:ar}),lr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nr(u,t){return s(),l("svg",lr,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),o("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const ir=ge({name:"lucide-users",render:nr}),dr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cr(u,t){return s(),l("svg",dr,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),o("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const ur=ge({name:"lucide-key",render:cr}),pr=$({__name:"Sidebar",props:{isCollapsed:{type:Boolean,required:!0},isDark:{type:Boolean,required:!0}},emits:["toggle-sidebar","toggle-theme"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Pe(),r=Le(),n=z(()=>d.name),p=[{id:"dashboard",label:"Dashboard",icon:bo,path:"/"},{id:"threads",label:"Threads",icon:Xo,path:"/threads"},{id:"agents",label:"Agents",icon:ko,path:"/agents"},{id:"prompts",label:"Prompts",icon:ft,path:"/prompts"},{id:"tools",label:"Tools",icon:Eo,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:$o,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:ft,path:"/tools#prompts"},{id:"tools-mcp",label:"MCP",icon:or,path:"/tools#mcp"}]},{id:"models",label:"Models",icon:To,path:"/models"},{id:"providers",label:"Providers",icon:Vo,path:"/providers"}],v=y=>{r.push(y)},g=z(()=>typeof n.value=="string"&&(n.value==="tools"||n.value.startsWith("tools-"))),f=m(!1),h=z(()=>n.value==="users"||n.value==="api-keys"),w=()=>{f.value=!f.value},x=()=>{localStorage.removeItem("auth_token"),r.push("/login")},k=y=>{const _=y.target;f.value&&!_.closest(".settings-menu-container")&&(f.value=!1)};ce(()=>{document.addEventListener("click",k)}),Te(()=>{document.removeEventListener("click",k)});const C={props:e,emit:c,route:d,router:r,activeRoute:n,navItems:p,navigateTo:v,isToolsActive:g,showSettingsMenu:f,isSettingsActive:h,toggleSettingsMenu:w,handleLogout:x,handleClickOutside:k,get IconSettings(){return Lo},get IconMenu(){return qo},get IconChevronLeft(){return Ro},get IconSun(){return Ho},get IconMoon(){return Ko},get IconLogOut(){return sr},get IconUsers(){return ir},get IconKey(){return ur}};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),Q=(u,t)=>{const a=u.__vccOpts||u;for(const[e,c]of t)a[e]=c;return a},mr={class:"p-4 border-b border-gray-300 dark:border-gray-700 flex items-center justify-between"},gr={key:0,class:"text-xl font-bold"},fr={class:"flex-1 flex flex-col justify-between py-4"},hr={class:"flex flex-col gap-1 px-2"},vr={key:0},br=["onClick","title"],yr={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},xr={key:0,class:"ml-4 space-y-0.5"},kr=["onClick"],_r={class:"whitespace-nowrap overflow-hidden text-ellipsis"},wr=["onClick","title"],Cr={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Sr={class:"flex flex-col gap-1 px-2"},Tr=["title"],Mr={key:2,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Ir={class:"relative settings-menu-container"},Vr=["title"],Ar={key:0,class:"flex-1 text-left whitespace-nowrap overflow-hidden text-ellipsis"},Pr={key:0,class:"absolute left-full ml-2 bottom-0 bg-white dark:bg-black border border-black dark:border-white rounded shadow-lg py-2 min-w-[160px] z-50"},Er=["title"],Or={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"};function jr(u,t,a,e,c,d){return s(),l("aside",{class:ee(["flex flex-col border-r border-black dark:border-white transition-all duration-300",a.isCollapsed?"w-16":"w-60"])},[o("div",mr,[a.isCollapsed?i("v-if",!0):(s(),l("h2",gr,"AgentBuilder")),o("button",{onClick:t[0]||(t[0]=r=>u.$emit("toggle-sidebar")),class:"p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors","aria-label":"Toggle sidebar"},[a.isCollapsed?(s(),X(e.IconMenu,{key:1,class:"w-5 h-5"})):(s(),X(e.IconChevronLeft,{key:0,class:"w-5 h-5"}))])]),o("nav",fr,[o("div",hr,[(s(),l(W,null,ne(e.navItems,r=>(s(),l(W,{key:r.id},[r.hasSubnav?(s(),l("div",vr,[i(" Main Tools button "),o("button",{onClick:n=>e.navigateTo(r.path),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",e.isToolsActive?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?r.label:void 0},[(s(),X(He(r.icon),{class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",yr,b(r.label),1))],10,br),i(" Tools subnav "),!a.isCollapsed&&r.subnav?(s(),l("div",xr,[(s(!0),l(W,null,ne(r.subnav,n=>(s(),l("button",{key:n.id,onClick:p=>e.navigateTo(n.path),class:ee(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",e.activeRoute===n.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(s(),X(He(n.icon),{class:"w-4 h-4 flex-shrink-0"})),o("span",_r,b(n.label),1)],10,kr))),128))])):i("v-if",!0)])):(s(),l("button",{key:1,onClick:n=>e.navigateTo(r.path),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",e.activeRoute===r.id?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?r.label:void 0},[(s(),X(He(r.icon),{class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",Cr,b(r.label),1))],10,wr))],64))),64))]),o("div",Sr,[o("button",{onClick:t[1]||(t[1]=r=>u.$emit("toggle-theme")),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all","hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Toggle theme":void 0},[a.isDark?(s(),X(e.IconMoon,{key:1,class:"w-5 h-5 flex-shrink-0"})):(s(),X(e.IconSun,{key:0,class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",Mr,b(a.isDark?"Dark Mode":"Light Mode"),1))],10,Tr),i(" Settings Menu "),o("div",Ir,[o("button",{onClick:he(e.toggleSettingsMenu,["stop"]),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",e.isSettingsActive?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Settings":void 0},[S(e.IconSettings,{class:"w-5 h-5 flex-shrink-0"}),a.isCollapsed?i("v-if",!0):(s(),l("span",Ar," Settings "))],10,Vr),i(" Settings Popover Menu "),e.showSettingsMenu?(s(),l("div",Pr,[o("button",{onClick:t[2]||(t[2]=r=>{e.navigateTo("/settings/users"),e.showSettingsMenu=!1}),class:ee(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",e.activeRoute==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[S(e.IconUsers,{class:"w-4 h-4 flex-shrink-0"}),t[4]||(t[4]=o("span",{class:"whitespace-nowrap"},"Users",-1))],2),o("button",{onClick:t[3]||(t[3]=r=>{e.navigateTo("/settings/api-keys"),e.showSettingsMenu=!1}),class:ee(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",e.activeRoute==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[S(e.IconKey,{class:"w-4 h-4 flex-shrink-0"}),t[5]||(t[5]=o("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])):i("v-if",!0)]),o("button",{onClick:e.handleLogout,class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all","hover:bg-red-500/10 dark:hover:bg-red-500/10 text-red-600 dark:text-red-400",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Logout":void 0},[S(e.IconLogOut,{class:"w-5 h-5 flex-shrink-0"}),a.isCollapsed?i("v-if",!0):(s(),l("span",Or," Logout "))],10,Er)])])],2)}const Lr=Q(pr,[["render",jr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Sidebar.vue"]]);function Dr(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function Ge(){return Dr().mountPoint}function J(u){const t=Ge(),a=u.startsWith("/")?u:`/${u}`;return t==="/"?a:`${t}${a}`}const Ur=$({__name:"WarningBanner",setup(u,{expose:t}){t();const a=m([]),e=m(new Set),c=async()=>{if(localStorage.getItem("auth_token"))try{const g=await fetch(J("/api/diagnostics"));if(g.ok){const f=await g.json();a.value=f.warnings||[]}}catch{}},d=v=>{const g=`${v.type}:${v.details?.name||v.message}`;e.value.add(g)},r=v=>{const g=`${v.type}:${v.details?.name||v.message}`;return!e.value.has(g)},n=v=>{if(v.type==="duplicate_tool_name"){const g=v.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${v.details?.name}" (defined as both ${g}). This may cause unexpected behavior.`}return v.message};ce(()=>{c()});const p={warnings:a,dismissed:e,fetchWarnings:c,dismiss:d,isVisible:r,formatWarning:n};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),qr={class:"warning-banner-container"},Nr={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},Br={class:"flex items-center gap-2"},Rr=["onClick"];function Fr(u,t,a,e,c,d){return s(),l("div",qr,[(s(!0),l(W,null,ne(e.warnings,r=>(s(),l(W,{key:`${r.type}:${r.details?.name}`},[e.isVisible(r)?(s(),l("div",Nr,[o("div",Br,[t[0]||(t[0]=o("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),o("span",null,b(e.formatWarning(r)),1)]),o("button",{onClick:n=>e.dismiss(r),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...t[1]||(t[1]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,Rr)])):i("v-if",!0)],64))),128))])}const zr=Q(Ur,[["render",Fr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/WarningBanner.vue"]]),Hr=$({__name:"App",setup(u,{expose:t}){t();const a=Pe(),e=m(!1),c=m(!1),d=z(()=>a.name!=="login"),r=()=>{e.value=!e.value},n=()=>{c.value=!c.value,c.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};ce(()=>{const v=localStorage.getItem("theme");(v==="dark"||!v&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(c.value=!0,document.documentElement.classList.add("dark"))});const p={route:a,isCollapsed:e,isDark:c,showSidebar:d,toggleSidebar:r,toggleTheme:n,get RouterView(){return Yt},Sidebar:Lr,WarningBanner:zr};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),Wr={class:"flex h-screen font-sans bg-white text-black dark:bg-black dark:text-white"},Jr={class:"flex-1 overflow-auto bg-white dark:bg-black flex flex-col"},Kr={class:"flex-1 overflow-auto"};function Zr(u,t,a,e,c,d){return s(),l("div",Wr,[e.showSidebar?(s(),X(e.Sidebar,{key:0,"is-collapsed":e.isCollapsed,"is-dark":e.isDark,onToggleSidebar:e.toggleSidebar,onToggleTheme:e.toggleTheme},null,8,["is-collapsed","is-dark"])):i("v-if",!0),o("main",Jr,[e.showSidebar?(s(),X(e.WarningBanner,{key:0})):i("v-if",!0),o("div",Kr,[S(e.RouterView)])])])}const Gr=Q(Hr,[["render",Zr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/App.vue"]]),Xr={},Qr={class:"p-8"};function Yr(u,t){return s(),l("div",Qr,[...t[0]||(t[0]=[o("h1",{class:"text-3xl font-bold mb-4"},"Dashboard",-1),o("p",{class:"text-gray-600 dark:text-gray-400"},"Welcome to Agent Kit. Monitor and manage your AI agents from here.",-1)])])}const $r=Q(Xr,[["render",Yr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/DashboardView.vue"]]),ea={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ta(u,t){return s(),l("svg",ea,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const oa=ge({name:"lucide-trash-2",render:ta}),ra={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function aa(u,t){return s(),l("svg",ra,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const sa=ge({name:"lucide-edit",render:aa}),la={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function na(u,t){return s(),l("svg",la,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),o("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Vt=ge({name:"lucide-eye",render:na}),ia=$({__name:"DataTable",props:{columns:{type:Array,required:!0},data:{type:Array,required:!0},actions:{type:Array,required:!1},emptyMessage:{type:String,required:!1,default:"No data available"},loading:{type:Boolean,required:!1,default:!1}},setup(u,{expose:t}){t();const n={props:u,getIcon:p=>{switch(p){case"edit":return sa;case"delete":return oa;case"view":return Vt;default:return null}},getCellValue:(p,v)=>{const g=p[v.key];return v.formatter?v.formatter(g):g??"-"},getCellAlignment:p=>{switch(p){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},handleAction:(p,v)=>{if(p.confirm){const g=p.confirmMessage||`Are you sure you want to ${p.label.toLowerCase()}?`;confirm(g)&&p.handler(v)}else p.handler(v)}};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),da={class:"w-full"},ca={class:"border border-black dark:border-white rounded overflow-hidden"},ua={class:"overflow-x-auto"},pa={class:"w-full"},ma={class:"border-b border-black dark:border-white"},ga={key:0,class:"px-4 py-3 text-right font-medium text-sm"},fa={key:0},ha=["colspan"],va=["colspan"],ba=["innerHTML"],ya={key:0,class:"px-4 py-3 text-right"},xa={class:"inline-flex gap-1"},ka=["onClick","title"];function _a(u,t,a,e,c,d){return s(),l("div",da,[o("div",ca,[o("div",ua,[o("table",pa,[o("thead",ma,[o("tr",null,[(s(!0),l(W,null,ne(a.columns,r=>(s(),l("th",{key:r.key,class:ee(["px-4 py-3 font-medium text-sm",e.getCellAlignment(r.align),r.width||""])},b(r.label),3))),128)),a.actions&&a.actions.length>0?(s(),l("th",ga," Actions ")):i("v-if",!0)])]),o("tbody",null,[i(" Loading state "),a.loading?(s(),l("tr",fa,[o("td",{colspan:a.columns.length+(a.actions?1:0),class:"px-4 py-8 text-center text-gray-500"},[...t[0]||(t[0]=[o("div",{class:"inline-flex items-center gap-2"},[o("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),ie(" Loading... ")],-1)])],8,ha)])):a.data.length===0?(s(),l(W,{key:1},[i(" Empty state "),o("tr",null,[o("td",{colspan:a.columns.length+(a.actions?1:0),class:"px-4 py-8 text-center text-gray-500"},b(a.emptyMessage),9,va)])],2112)):(s(),l(W,{key:2},[i(" Data rows "),(s(!0),l(W,null,ne(a.data,(r,n)=>(s(),l("tr",{key:n,class:"border-t border-gray-200 dark:border-gray-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(s(!0),l(W,null,ne(a.columns,p=>(s(),l("td",{key:p.key,class:ee(["px-4 py-3 text-sm",e.getCellAlignment(p.align)])},[Be(u.$slots,`cell-${p.key}`,{value:r[p.key],row:r,column:p},()=>[p.html?(s(),l("span",{key:0,innerHTML:e.getCellValue(r,p)},null,8,ba)):(s(),l(W,{key:1},[ie(b(e.getCellValue(r,p)),1)],64))])],2))),128)),a.actions&&a.actions.length>0?(s(),l("td",ya,[o("div",xa,[(s(!0),l(W,null,ne(a.actions,(p,v)=>(s(),l("button",{key:v,onClick:g=>e.handleAction(p,r),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:p.label},[(s(),X(He(e.getIcon(p.icon)),{class:"w-4 h-4"}))],8,ka))),128))])])):i("v-if",!0)]))),128))],2112))])])])])])}const Oe=Q(ia,[["render",_a],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/DataTable.vue"]]),wa=$({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(u,{expose:t,emit:a}){const e=a,c=m([]),d=m(!1),r=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:f=>f==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:f=>f||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:f=>f||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:f=>f?new Date(f*1e3).toLocaleDateString():"-"}],n=[{icon:"edit",label:"Edit",handler:f=>e("edit",f)},{icon:"delete",label:"Delete",handler:async f=>{await v(f)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],p=async()=>{d.value=!0;try{const f=await fetch(J("/api/agents"));if(f.ok){const h=await f.json();c.value=h.agents||[]}}catch(f){console.error("Error fetching agents:",f)}finally{d.value=!1}},v=async f=>{try{const h=await fetch(J(`/api/agents/${f.id}`),{method:"DELETE"});if(h.ok)await p();else{const w=await h.json();alert(w.error||"Failed to delete agent")}}catch(h){console.error("Error deleting agent:",h),alert("Failed to delete agent")}};ce(()=>{p()}),t({refresh:p});const g={emit:e,agents:c,loading:d,columns:r,actions:n,fetchAgents:p,deleteAgent:v,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}});function Ca(u,t,a,e,c,d){return s(),l("div",null,[S(e.DataTable,{columns:e.columns,data:e.agents,actions:e.actions,loading:e.loading,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])])}const Sa=Q(wa,[["render",Ca],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AgentsDataTable.vue"]]),Ta=$({__name:"DropShadow",props:{offsetX:{type:Number,required:!1,default:8},offsetY:{type:Number,required:!1,default:8},intensity:{type:Number,required:!1,default:.5},pattern:{type:String,required:!1,default:"crosshatch"}},setup(u,{expose:t}){t();const a=u,e=m(),c=m(),d=m(),r=async()=>{if(await pe(),!e.value||!c.value||!d.value)return;const g=e.value.getContext("2d");if(!g)return;const f=d.value.getBoundingClientRect(),h=f.width+a.offsetX+4,w=f.height+a.offsetY+4;e.value.width=h,e.value.height=w,e.value.style.width=`${h}px`,e.value.style.height=`${w}px`,g.clearRect(0,0,e.value.width,e.value.height);const x=document.documentElement.classList.contains("dark");if(g.fillStyle=x?"#6b7280":"black",g.globalAlpha=a.intensity,a.pattern==="crosshatch"){const k=x?4:3;g.lineWidth=1,g.strokeStyle=x?"#6b7280":"black";for(let C=-f.height;C<f.width;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY),g.lineTo(a.offsetX+C+f.height,a.offsetY+f.height),g.stroke();for(let C=0;C<f.width+f.height;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY+f.height),g.lineTo(a.offsetX+C-f.height,a.offsetY),g.stroke()}else if(a.pattern==="dots"){const C=x?3:2,y=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let _=0;_<f.width;_+=C)for(let I=0;I<f.height;I+=C){const U=Math.floor(_/C)%4,L=Math.floor(I/C)%4;y[L][U]/16<a.intensity&&g.fillRect(a.offsetX+_,a.offsetY+I,1,1)}}else if(a.pattern==="diagonal"){const k=x?5:4;g.lineWidth=1,g.strokeStyle=x?"#6b7280":"black";for(let C=-f.height;C<f.width;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY),g.lineTo(a.offsetX+C+f.height,a.offsetY+f.height),g.stroke()}};let n=null,p=null;ce(()=>{n=new ResizeObserver(()=>{r()}),d.value&&n.observe(d.value),r(),p=new MutationObserver(()=>{r()}),p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Te(()=>{d.value&&n&&n.unobserve(d.value),p&&p.disconnect()}),oe(()=>[a.offsetX,a.offsetY,a.intensity,a.pattern],()=>{r()});const v={props:a,canvas:e,container:c,contentEl:d,drawDitheredShadow:r,get resizeObserver(){return n},set resizeObserver(g){n=g},get mutationObserver(){return p},set mutationObserver(g){p=g}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),Ma={ref:"container",class:"relative"},Ia={ref:"canvas",class:"absolute top-0 left-0 pointer-events-none"},Va={ref:"contentEl",class:"relative"};function Aa(u,t,a,e,c,d){return s(),l("div",Ma,[o("canvas",Ia,null,512),o("div",Va,[Be(u.$slots,"default")],512)],512)}const Re=Q(Ta,[["render",Aa],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/DropShadow.vue"]]),Pa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ea(u,t){return s(),l("svg",Pa,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const At=ge({name:"lucide-x",render:Ea}),Oa=$({__name:"ConfirmDialog",props:{modelValue:{type:Boolean,required:!0},title:{type:String,required:!1,default:"Confirm Action"},message:{type:String,required:!1,default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{type:String,required:!1,default:"Continue"},cancelText:{type:String,required:!1,default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=()=>{c("update:modelValue",!1)},r=()=>{c("confirm"),d()},n=()=>{c("cancel"),d()},p=g=>{g.key==="Escape"&&e.modelValue&&n()};oe(()=>e.modelValue,g=>{g?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")});const v={props:e,emit:c,close:d,handleConfirm:r,handleCancel:n,handleKeydown:p,DropShadow:Re,get IconX(){return At}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),ja={key:0,class:"w-full max-w-md"},La={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},Da={class:"text-xl font-bold text-red-600"},Ua={class:"p-6"},qa={class:"text-gray-700 dark:text-gray-300 mb-6"},Na={class:"flex justify-end gap-3"};function Ba(u,t,a,e,c,d){return s(),X(st,{to:"body"},[S(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:e.handleCancel},[S(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ae(()=>[a.modelValue?(s(),l("div",ja,[S(e.DropShadow,{"offset-x":12,"offset-y":12,intensity:.4},{default:ae(()=>[o("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:t[0]||(t[0]=he(()=>{},["stop"]))},[i(" Header "),o("div",La,[o("h2",Da,b(a.title),1),o("button",{onClick:e.handleCancel,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[S(e.IconX,{class:"w-5 h-5 text-red-600"})])]),i(" Content "),o("div",Ua,[o("p",qa,b(a.message),1),o("div",Na,[o("button",{onClick:e.handleCancel,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors"},b(a.cancelText),1),o("button",{onClick:e.handleConfirm,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},b(a.confirmText),1)])])])]),_:1})])):i("v-if",!0)]),_:1})])):i("v-if",!0)]),_:1})])}const Pt=Q(Oa,[["render",Ba],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ConfirmDialog.vue"]]),Ra=$({__name:"Modal",props:{modelValue:{type:Boolean,required:!0},title:{type:String,required:!1},width:{type:String,required:!1,default:"max-w-lg"},minHeight:{type:String,required:!1,default:"min-h-[24rem]"},hasChanges:{type:Boolean,required:!1,default:void 0}},emits:["update:modelValue","close"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(),r=m(!1),n=m(new Map),p=()=>d.value&&(d.value.querySelector("input")||d.value.querySelector("textarea")||d.value.querySelector("select")||d.value.querySelector("[contenteditable]")||d.value.querySelector(".monaco-editor")),v=()=>{if(!d.value)return;d.value.querySelectorAll(".monaco-editor-container").forEach(j=>{const F=j.__monacoEditor;if(F&&typeof F.getValue=="function"){const K=F.getValue();n.value.set(j,K)}})},g=()=>{if(!d.value)return!1;const L=d.value.querySelectorAll(".monaco-editor-container");for(const j of L){const F=j.__monacoEditor;if(F&&typeof F.getValue=="function"){const K=F.getValue(),D=n.value.get(j);if(D===void 0||(F.getRawOptions?.()||{}).readOnly===!0)continue;if(K!==D)return!0}}return!1},f=()=>{if(e.hasChanges!==void 0)return e.hasChanges;if(!d.value)return!1;if(g())return!0;const L=d.value.querySelectorAll("form");for(const F of L){const D=F.querySelectorAll("input, textarea, select");for(const E of D){const H=E;if(H.type==="checkbox"||H.type==="radio"){const R=H;if(R.checked!==R.defaultChecked)return!0}else if(H.tagName==="SELECT"){const R=H;if(R.value!==R.defaultValue)return!0}else if(H.value!==H.defaultValue)return!0}}const j=d.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const F of j){const K=F;if(K.type==="checkbox"||K.type==="radio"){const D=K;if(D.checked!==D.defaultChecked)return!0}else if(K.tagName==="SELECT"){const D=K;if(D.value!==D.defaultValue)return!0}else if(K.value!==K.defaultValue)return!0}return!1},h=()=>{p()&&f()?r.value=!0:w()},w=()=>{c("update:modelValue",!1),c("close")},x=()=>{r.value=!1,w()},k=()=>{r.value=!1},C=L=>{L.key==="Escape"&&e.modelValue&&(p()||w())};oe(()=>e.modelValue,async L=>{L?(document.addEventListener("keydown",C),document.body.style.overflow="hidden",await pe(),setTimeout(()=>{v()},100)):(document.removeEventListener("keydown",C),document.body.style.overflow="",n.value.clear())});const y=m(!1),U={props:e,emit:c,modalRef:d,showConfirmDialog:r,monacoInitialValues:n,hasFormFields:p,captureMonacoInitialValues:v,hasMonacoChanges:g,hasUnsavedChanges:f,attemptClose:h,close:w,handleConfirmClose:x,handleCancelClose:k,handleKeydown:C,mouseDownOnBackdrop:y,handleBackdropMouseDown:L=>{y.value=L.target===L.currentTarget},handleBackdropClick:L=>{L.target===L.currentTarget&&y.value&&(p()||w()),y.value=!1},DropShadow:Re,ConfirmDialog:Pt,get IconX(){return At}};return Object.defineProperty(U,"__isScriptSetup",{enumerable:!1,value:!0}),U}}),Fa={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-white flex-shrink-0"},za={class:"text-xl font-bold"},Ha={class:"overflow-y-auto flex-1"},Wa={class:"p-6"},Ja={key:0,class:"p-6 border-t-2 border-black dark:border-white flex-shrink-0"};function Ka(u,t,a,e,c,d){return s(),X(st,{to:"body"},[S(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:e.handleBackdropMouseDown,onClick:e.handleBackdropClick},[S(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:ee(["w-full",a.width,"max-h-[85vh] flex flex-col"])},[S(e.DropShadow,{"offset-x":12,"offset-y":12,intensity:.4},{default:ae(()=>[o("div",{ref:"modalRef",class:ee(["bg-white dark:bg-black border-2 border-black dark:border-white flex flex-col max-h-[85vh]",a.minHeight])},[i(" Header (fixed) "),o("div",Fa,[o("h2",za,b(a.title),1),o("button",{onClick:e.attemptClose,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[S(e.IconX,{class:"w-5 h-5"})])]),i(" Content (scrollable) "),o("div",Ha,[o("div",Wa,[Be(u.$slots,"default")])]),i(" Footer (fixed, optional) "),u.$slots.footer?(s(),l("div",Ja,[Be(u.$slots,"footer")])):i("v-if",!0)],2)]),_:3})],2)):i("v-if",!0)]),_:3})],32)):i("v-if",!0)]),_:3}),i(" Confirmation dialog for unsaved changes "),S(e.ConfirmDialog,{modelValue:e.showConfirmDialog,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showConfirmDialog=r),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:e.handleConfirmClose,onCancel:e.handleCancelClose},null,8,["modelValue"])])}const Ve=Q(Ra,[["render",Ka],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Modal.vue"]]),Za=$({__name:"TextInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},type:{type:String,required:!1,default:"text"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue","focus","click"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(null),r=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n=f=>{const h=f.target;c("update:modelValue",h.value)},p=f=>{c("focus",f)},v=f=>{c("click",f)};t({inputRef:d});const g={props:e,emit:c,inputRef:d,inputClasses:r,handleInput:n,handleFocus:p,handleClick:v};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),Ga={class:"space-y-1"},Xa={key:0,class:"block text-sm font-medium"},Qa={key:0,class:"text-red-500"},Ya=["type","value","placeholder","disabled"],$a={key:1,class:"text-xs text-red-500 dark:text-red-400"};function es(u,t,a,e,c,d){return s(),l("div",Ga,[a.label?(s(),l("label",Xa,[ie(b(a.label)+" ",1),a.required?(s(),l("span",Qa,"*")):i("v-if",!0)])):i("v-if",!0),o("input",{ref:"inputRef",type:a.type,value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,class:ee(e.inputClasses),onInput:e.handleInput,onFocus:e.handleFocus,onClick:e.handleClick},null,42,Ya),a.error?(s(),l("p",$a,b(a.error),1)):i("v-if",!0)])}const je=Q(Za,[["render",es],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/TextInput.vue"]]),ts=$({__name:"TextareaInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},rows:{type:Number,required:!1,default:4}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n={props:e,emit:c,textareaClasses:d,handleInput:p=>{const v=p.target;c("update:modelValue",v.value)}};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),os={class:"space-y-1"},rs={key:0,class:"block text-sm font-medium"},as={key:0,class:"text-red-500"},ss=["value","placeholder","disabled","rows"],ls={key:1,class:"text-xs text-red-500 dark:text-red-400"};function ns(u,t,a,e,c,d){return s(),l("div",os,[a.label?(s(),l("label",rs,[ie(b(a.label)+" ",1),a.required?(s(),l("span",as,"*")):i("v-if",!0)])):i("v-if",!0),o("textarea",{value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,class:ee(e.textareaClasses),onInput:e.handleInput},null,42,ss),a.error?(s(),l("p",ls,b(a.error),1)):i("v-if",!0)])}const Et=Q(ts,[["render",ns],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/TextareaInput.vue"]]),is=$({__name:"SelectInput",props:{modelValue:{type:String,required:!1},options:{type:Array,required:!0},placeholder:{type:String,required:!1,default:"Select an option"},searchPlaceholder:{type:String,required:!1,default:"Search..."},label:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(!1),r=m(""),n=m(),p=m(),v=m(),g=m(),f=m(-1),h=z(()=>e.options.find(E=>E.value===e.modelValue)),w=z(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",e.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-white focus:ring-black dark:focus:ring-white"]),x=z(()=>{if(!r.value)return e.options;const E=r.value.toLowerCase();return e.options.filter(H=>H.label.toLowerCase().includes(E)||H.value.toLowerCase().includes(E)||H.description&&H.description.toLowerCase().includes(E))});oe(x,()=>{f.value=-1});const k=()=>{e.disabled||(d.value?_():(d.value=!0,r.value="",f.value=-1,pe(()=>{if(g.value&&(g.value.setAttribute("popover","auto"),g.value.addEventListener("toggle",K),"showPopover"in g.value))try{g.value.showPopover()}catch{}I(),setTimeout(()=>n.value?.focus(),0)})))},C=E=>{c("update:modelValue",E.value),_(),r.value="",f.value=-1},y=E=>{E.stopPropagation(),c("update:modelValue","")},_=()=>{if(g.value){if("hidePopover"in g.value)try{g.value.hidePopover()}catch{}g.value.removeEventListener("toggle",K)}d.value=!1,f.value=-1},I=()=>{if(!v.value||!g.value)return;const E=v.value.getBoundingClientRect();g.value.offsetWidth||E.width,g.value.style.position="fixed",g.value.style.top=`${E.bottom+8}px`,g.value.style.left=`${E.left}px`,g.value.style.width=`${E.width}px`,g.value.style.margin="0"},U=E=>{p.value&&!p.value.contains(E.target)&&g.value&&!g.value.contains(E.target)&&_()},L=E=>{E.key==="Escape"&&d.value&&(_(),v.value?.focus())},j=E=>{if(!d.value)return;const H=x.value;if(H.length!==0)switch(E.key){case"ArrowDown":E.preventDefault(),f.value=f.value<H.length-1?f.value+1:0,F();break;case"ArrowUp":E.preventDefault(),f.value=f.value>0?f.value-1:H.length-1,F();break;case"Enter":E.preventDefault(),f.value>=0&&f.value<H.length&&C(H[f.value]);break}},F=()=>{pe(()=>{const E=g.value?.querySelector(".highlighted-option");E&&E.scrollIntoView({block:"nearest",behavior:"smooth"})})},K=E=>{E.target===g.value&&(d.value=E.newState==="open",d.value&&I())};ce(()=>{document.addEventListener("click",U),document.addEventListener("keydown",L);const E=()=>{d.value&&I()};window.addEventListener("resize",E),window.addEventListener("scroll",E,!0)}),Te(()=>{document.removeEventListener("click",U),document.removeEventListener("keydown",L),window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)});const D={props:e,emit:c,isOpen:d,searchQuery:r,searchInput:n,dropdownRef:p,buttonRef:v,popoverRef:g,highlightedIndex:f,selectedOption:h,buttonClasses:w,filteredOptions:x,toggleDropdown:k,selectOption:C,clearValue:y,closePopover:_,positionPopover:I,handleClickOutside:U,handleEscape:L,handleKeyDown:j,scrollToHighlighted:F,handlePopoverToggle:K,DropShadow:Re};return Object.defineProperty(D,"__isScriptSetup",{enumerable:!1,value:!0}),D}}),ds={ref:"dropdownRef",class:"relative"},cs={key:0,class:"block text-sm font-medium mb-2"},us={key:0,class:"text-red-500"},ps=["disabled","aria-expanded"],ms={class:"flex items-center justify-between gap-1"},gs={key:0,class:"flex items-center gap-2 text-gray-400 flex-1 min-w-0"},fs={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},hs=["src","alt"],vs={class:"block truncate"},bs={key:2,class:"block truncate text-gray-400 flex-1 min-w-0"},ys={key:1,ref:"popoverRef",class:"dropdown-popover"},xs={class:"bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg overflow-hidden"},ks={class:"p-2 border-b border-gray-200 dark:border-gray-700"},_s=["placeholder"],ws={class:"max-h-60 overflow-y-auto"},Cs={key:0,class:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400"},Ss=["onClick","onMouseenter"],Ts={class:"flex-shrink-0 w-5 h-5 mt-0.5"},Ms=["src","alt"],Is={key:1,class:"w-full h-full bg-gray-200 dark:bg-gray-700 rounded"},Vs={class:"flex-1 min-w-0"},As={class:"text-sm font-medium text-black dark:text-white"},Ps={key:0,class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Es={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"};function Os(u,t,a,e,c,d){return s(),l("div",ds,[a.label?(s(),l("label",cs,[ie(b(a.label)+" ",1),a.required?(s(),l("span",us,"*")):i("v-if",!0)])):i("v-if",!0),o("button",{ref:"buttonRef",type:"button",onClick:e.toggleDropdown,disabled:a.disabled,"aria-expanded":e.isOpen,"aria-haspopup":!0,class:ee(e.buttonClasses)},[o("div",ms,[a.loading?(s(),l("span",gs,[...t[1]||(t[1]=[o("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),ie(" Loading... ",-1)])])):e.selectedOption?(s(),l("span",fs,[e.selectedOption.icon?(s(),l("img",{key:0,src:e.selectedOption.icon,alt:e.selectedOption.label,class:"w-5 h-5 flex-shrink-0"},null,8,hs)):i("v-if",!0),o("span",vs,b(e.selectedOption.label),1)])):(s(),l("span",bs,b(a.placeholder),1)),i(" Clear button (only shown when value is selected) "),e.selectedOption&&!a.disabled?(s(),l("button",{key:3,type:"button",onClick:e.clearValue,class:"flex-shrink-0 p-0.5 hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors","aria-label":"Clear selection"},[...t[2]||(t[2]=[o("svg",{class:"h-4 w-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):i("v-if",!0),i(" Dropdown chevron "),t[3]||(t[3]=o("svg",{class:"h-5 w-5 text-gray-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,ps),i(" Popover dropdown "),e.isOpen?(s(),l("div",ys,[S(e.DropShadow,{"offset-x":4,"offset-y":4,intensity:.3},{default:ae(()=>[o("div",xs,[o("div",ks,[fe(o("input",{ref:"searchInput","onUpdate:modelValue":t[0]||(t[0]=r=>e.searchQuery=r),type:"text",placeholder:a.searchPlaceholder,onKeydown:e.handleKeyDown,class:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500"},null,40,_s),[[_e,e.searchQuery]])]),o("div",ws,[e.filteredOptions.length===0?(s(),l("div",Cs," No options found ")):i("v-if",!0),(s(!0),l(W,null,ne(e.filteredOptions,(r,n)=>(s(),l("button",{key:r.value,type:"button",onClick:p=>e.selectOption(r),onMouseenter:p=>e.highlightedIndex=n,class:ee(["w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-900 focus:bg-gray-100 dark:focus:bg-gray-900 focus:outline-none flex items-start gap-3",{"bg-gray-50 dark:bg-gray-900":r.value===a.modelValue,"bg-gray-100 dark:bg-gray-800 highlighted-option":n===e.highlightedIndex}])},[o("div",Ts,[r.icon?(s(),l("img",{key:0,src:r.icon,alt:r.label,class:"w-full h-full"},null,8,Ms)):(s(),l("div",Is))]),o("div",Vs,[o("div",As,b(r.label),1),r.description?(s(),l("div",Ps,b(r.description),1)):i("v-if",!0)])],42,Ss))),128))])])]),_:1})],512)):i("v-if",!0),a.error?(s(),l("p",Es,b(a.error),1)):i("v-if",!0)],512)}const xe=Q(is,[["render",Os],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/SelectInput.vue"]]),js=$({__name:"CheckboxInput",props:{modelValue:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1},helpText:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},error:{type:String,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=$t(),r=z(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50":"hover:scale-110",e.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",e.modelValue?"before:block":"before:hidden"]),p={props:e,emit:c,checkboxId:d,decoratorClasses:r,handleChange:v=>{if(!e.disabled){const g=v.target;c("update:modelValue",g.checked)}}};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),Ls={class:"flex items-start"},Ds=["for"],Us=["id","checked","disabled"],qs={class:"flex items-center h-5"},Ns={class:"flex-1"},Bs={key:0,class:"text-red-500"},Rs={key:1,class:"text-xs text-gray-600 dark:text-gray-400 mt-1"},Fs={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function zs(u,t,a,e,c,d){return s(),l("div",Ls,[o("label",{for:e.checkboxId,class:ee(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":a.disabled}])},[o("input",{id:e.checkboxId,type:"checkbox",checked:a.modelValue,disabled:a.disabled,onChange:e.handleChange,class:"absolute left-[-9999px]"},null,40,Us),o("div",qs,[o("span",{class:ee(e.decoratorClasses)},null,2)]),o("div",Ns,[a.label?(s(),l("span",{key:0,class:ee(["block text-sm font-medium",{"opacity-50":a.disabled}])},[ie(b(a.label)+" ",1),a.required?(s(),l("span",Bs,"*")):i("v-if",!0)],2)):i("v-if",!0),a.helpText?(s(),l("p",Rs,b(a.helpText),1)):i("v-if",!0),a.error?(s(),l("p",Fs,b(a.error),1)):i("v-if",!0)])],10,Ds)])}const Xe=Q(js,[["render",zs],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/CheckboxInput.vue"]]),Hs=$({__name:"AgentModal",props:{modelValue:{type:Boolean,required:!0},editAgent:{type:null,required:!1},mode:{type:String,required:!1}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>e.mode==="edit"),r=m(!1),n=m(""),p=m(""),v=m(""),g=m(null),f=m(""),h=m("dual_ai"),w=m(!1),x=m(""),k=m(""),C=m(null),y=m(""),_=m(""),I=m(""),U=m(""),L=m(!0),j=m(!1),F=m(""),K=m(""),D=m(""),E=m(""),H=m(!1),R=m(null),N=m(""),Z=m(""),G=m(""),P=m(""),V=m(""),T=m(""),q=m(!0),M=m(!1),O=m(""),A=m(""),B=m(""),te=m(""),le=m(null),re=m(""),ue=m(""),me=m(""),{data:we,execute:ke}=ve(J("/api/prompts"),{immediate:!1}).json(),{data:be,execute:Fe}=ve(J("/api/tools?schema=true"),{immediate:!1}).json(),Me=m(null),Qe=m(!1),Ae=m(null),Ye=m(!1),Ue=m(!1),qt=z(()=>{if(!we.value)return[{value:"",label:"Select a prompt..."}];const Y=we.value?.prompts||[];return[{value:"",label:"None"},...Y.map(se=>({value:se.id,label:se.name}))]}),$e=Y=>be.value?be.value[Y]:null,Nt=z(()=>!Me.value||!Me.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Me.value.tools.map(Y=>{const se=typeof Y=="string"?Y:Y.name;return{value:se,label:se}})]),Bt=z(()=>!Ae.value||!Ae.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ae.value.tools.map(Y=>{const se=typeof Y=="string"?Y:Y.name;return{value:se,label:se}})]),Rt=z(()=>{if(!F.value)return[];const Y=$e(F.value);return!Y||!Y.schema||!Y.schema.properties?[]:Object.keys(Y.schema.properties).map(se=>({value:se,label:se}))}),Ft=z(()=>{if(!O.value)return[];const Y=$e(O.value);return!Y||!Y.schema||!Y.schema.properties?[]:Object.keys(Y.schema.properties).map(se=>({value:se,label:se}))}),zt=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Ht=z({get(){return p.value},set(Y){const se=g.value?.inputRef,de=se?.selectionStart??Y.length;let Ce=Y.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Ce.endsWith("_agent")||(Ce=Ce+"_agent"),p.value=Ce,se){se.value=Ce;const ye=Math.min(de,Ce.length-6);se.setSelectionRange(ye,ye)}}}),Wt=async()=>{await pe();const Y=g.value?.inputRef;if(Y&&p.value.endsWith("_agent")){const se=p.value.length-6;Y.setSelectionRange(se,se)}},ut=Y=>!Y||Y==="_agent"?(v.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(Y)?(v.value="",!0):(v.value="Name must start with a letter",!1),qe=()=>{p.value="",n.value="",v.value="",f.value="",h.value="dual_ai",w.value=!1,x.value="",k.value="",C.value=null,y.value="",I.value="",U.value="",L.value=!0,j.value=!1,F.value="",K.value="",D.value="",E.value="",H.value=!1,R.value=null,N.value="",Z.value="",G.value="",Me.value=null,V.value="",T.value="",q.value=!0,M.value=!1,O.value="",A.value="",B.value="",te.value="",le.value=null,re.value="",ue.value="",me.value="",Ae.value=null},pt=async()=>{if(e.editAgent?.id){r.value=!0,Ue.value=!0;try{const Y=await fetch(J(`/api/agents/${e.editAgent.id}`));if(Y.ok){const se=await Y.json(),de=se.agent||se;p.value=de.name||"",n.value=de.name||"",f.value=de.title||"",h.value=de.type||"dual_ai",w.value=de.expose_as_tool||!1,x.value=de.tool_description||"",C.value=de.max_session_turns;const Ce=de.side_a_stop_tool||"",ye=de.side_a_stop_tool_response_property||"",Zt=de.side_b_stop_tool||"",Gt=de.side_b_stop_tool_response_property||"",Xt=de.side_a_end_conversation_tool||"",Qt=de.side_b_end_conversation_tool||"";_.value=de.side_a_label||"",P.value=de.side_b_label||"",I.value=de.side_a_agent_prompt||"",V.value=de.side_b_agent_prompt||"",L.value=!!de.side_a_stop_on_response,j.value=!!de.side_a_stop_tool,H.value=!!de.side_a_manual_stop_condition,R.value=de.side_a_max_turns,q.value=!!de.side_b_stop_on_response,M.value=!!de.side_b_stop_tool,le.value=de.side_b_max_turns,await pe(),F.value=Ce,D.value=ye,O.value=Zt,B.value=Gt,Z.value=Xt,ue.value=Qt}}catch(Y){console.error("Error loading agent data:",Y)}finally{r.value=!1,Ue.value=!1}}},Jt=async()=>{v.value="",y.value="",U.value="",K.value="",E.value="",N.value="",G.value="",T.value="",A.value="",te.value="",re.value="",me.value="";let Y=!1;ut(p.value)||(Y=!0);const se=p.value;h.value==="dual_ai"&&C.value!==null&&C.value!==void 0&&C.value<=0&&(y.value="Max session turns must be a positive number",Y=!0),I.value||(U.value="Please select an agent prompt",Y=!0);const de=L.value||F.value,Ce=h.value==="ai_human"&&H.value;if(!de&&!Ce&&(U.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Y=!0),F.value&&!D.value&&(E.value="Response property required when using stop tool",Y=!0),R.value!==null&&R.value<=0&&(N.value="Max turns must be a positive number",Y=!0),h.value==="dual_ai"&&!Z.value&&!ue.value&&(G.value="At least one side must have an end conversation tool",me.value="At least one side must have an end conversation tool",Y=!0),h.value==="dual_ai"&&(V.value||(T.value="Please select an agent prompt",Y=!0),O.value&&!B.value&&(te.value="Response property required when using stop tool",Y=!0),le.value!==null&&le.value<=0&&(re.value="Max turns must be a positive number",Y=!0)),Y)return;const ye={name:se,title:f.value||null,type:h.value,expose_as_tool:w.value,tool_description:w.value?x.value:null,max_session_turns:h.value==="dual_ai"?C.value:null,side_a_label:_.value||null,side_a_agent_prompt:I.value,side_a_stop_on_response:L.value,side_a_stop_tool:F.value||null,side_a_stop_tool_response_property:D.value||null,side_a_manual_stop_condition:H.value,side_a_max_turns:R.value,side_a_end_conversation_tool:Z.value||null};h.value==="dual_ai"&&(ye.side_b_label=P.value||null,ye.side_b_agent_prompt=V.value,ye.side_b_stop_on_response=q.value,ye.side_b_stop_tool=O.value||null,ye.side_b_stop_tool_response_property=B.value||null,ye.side_b_max_turns=le.value,ye.side_b_end_conversation_tool=ue.value||null),d.value&&e.editAgent?.id&&(ye.id=e.editAgent.id),c("save",ye),qe(),c("update:modelValue",!1)},Kt=()=>{qe(),c("update:modelValue",!1)};oe(I,async Y=>{if(Ue.value||(F.value="",D.value=""),!Y){Me.value=null;return}Qe.value=!0;try{const se=await fetch(J(`/api/prompts/${Y}`));se.ok&&(Me.value=await se.json())}catch(se){console.error("Error fetching Side A prompt:",se)}finally{Qe.value=!1}}),oe(V,async Y=>{if(Ue.value||(O.value="",B.value=""),!Y){Ae.value=null;return}Ye.value=!0;try{const se=await fetch(J(`/api/prompts/${Y}`));se.ok&&(Ae.value=await se.json())}catch(se){console.error("Error fetching Side B prompt:",se)}finally{Ye.value=!1}}),oe(j,Y=>{Y||(F.value="",D.value="")}),oe(M,Y=>{Y||(O.value="",B.value="")}),oe(()=>e.modelValue,async Y=>{Y&&(await Promise.all([ke(),Fe()]),d.value?(qe(),await pt()):qe())});const mt={props:e,emit:c,isEditMode:d,isLoading:r,originalName:n,name:p,nameError:v,nameInputRef:g,title:f,agentType:h,exposeAsTool:w,toolDescription:x,toolDescriptionError:k,maxSessionTurns:C,maxSessionTurnsError:y,sideALabel:_,sideAAgentPrompt:I,sideAAgentPromptError:U,sideAStopOnResponse:L,sideAStopOnToolCall:j,sideAStopTool:F,sideAStopToolError:K,sideAStopToolResponseProperty:D,sideAStopToolResponsePropertyError:E,sideAManualStopCondition:H,sideAMaxTurns:R,sideAMaxTurnsError:N,sideAEndConversationTool:Z,sideAEndConversationToolError:G,sideBLabel:P,sideBAgentPrompt:V,sideBAgentPromptError:T,sideBStopOnResponse:q,sideBStopOnToolCall:M,sideBStopTool:O,sideBStopToolError:A,sideBStopToolResponseProperty:B,sideBStopToolResponsePropertyError:te,sideBMaxTurns:le,sideBMaxTurnsError:re,sideBEndConversationTool:ue,sideBEndConversationToolError:me,promptsData:we,fetchPrompts:ke,toolsData:be,fetchTools:Fe,sideAPromptData:Me,sideAPromptLoading:Qe,sideBPromptData:Ae,sideBPromptLoading:Ye,isLoadingAgentData:Ue,promptOptions:qt,getToolByName:$e,sideAToolOptions:Nt,sideBToolOptions:Bt,sideAResponsePropertyOptions:Rt,sideBResponsePropertyOptions:Ft,agentTypeOptions:zt,agentName:Ht,handleNameFocus:Wt,validateAgentName:ut,resetForm:qe,loadAgentData:pt,handleSubmit:Jt,handleCancel:Kt,Modal:Ve,TextInput:je,TextareaInput:Et,SelectInput:xe,CheckboxInput:Xe};return Object.defineProperty(mt,"__isScriptSetup",{enumerable:!1,value:!0}),mt}}),Ws={key:0,class:"min-h-[400px] flex items-center justify-center"},Js={key:1,class:"space-y-6 pr-2 pb-4"},Ks={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Zs={key:1,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Gs={key:0},Xs={key:1},Qs={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Ys={key:2},$s={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},el={class:"grid grid-cols-2 gap-6"},tl={"data-testid":"side-a-container",class:"space-y-4 p-4 bg-gray-50 dark:bg-gray-900 rounded-lg"},ol={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},rl={class:"space-y-3"},al={class:"flex items-start"},sl={key:0,class:"ml-8 mt-2 space-y-2"},ll={key:0,class:"text-xs text-gray-500 dark:text-gray-400 -mt-1"},nl={key:1},il={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},dl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},cl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},ul={"data-testid":"side-b-container",class:"space-y-4 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg"},pl={class:"font-semibold text-base mb-4 text-gray-800 dark:text-gray-200"},ml={key:0,class:"flex flex-col items-center justify-center py-8"},gl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},fl={class:"space-y-3"},hl={class:"flex items-start"},vl={key:0,class:"ml-8 mt-2 space-y-2"},bl={key:0,class:"text-xs text-gray-500 dark:text-gray-400 -mt-1"},yl={key:1},xl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},kl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},_l={class:"flex justify-between"},wl=["disabled"];function Cl(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[23]||(t[23]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:ae(()=>[o("div",_l,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:e.isLoading},b(e.isEditMode?"Update Agent":"Create Agent"),9,wl)])]),default:ae(()=>[e.isLoading?(s(),l("div",Ws,[...t[24]||(t[24]=[o("span",{class:"text-gray-500"},"Loading agent data...",-1)])])):(s(),l("div",Js,[i(" Agent Name "),o("div",null,[S(e.TextInput,{ref:"nameInputRef",modelValue:e.agentName,"onUpdate:modelValue":t[0]||(t[0]=r=>e.agentName=r),label:"Agent Name",placeholder:"research_agent",error:e.nameError,required:"",disabled:e.isEditMode,onFocus:e.handleNameFocus,onClick:e.handleNameFocus},null,8,["modelValue","error","disabled"]),!e.nameError&&!e.isEditMode?(s(),l("p",Ks," Names are automatically formatted to snake_case with the _agent suffix ")):i("v-if",!0),e.isEditMode?(s(),l("p",Zs," Agent names cannot be changed after creation (used as foreign key for threads) ")):i("v-if",!0)]),i(" Agent Title "),o("div",null,[S(e.TextInput,{modelValue:e.title,"onUpdate:modelValue":t[1]||(t[1]=r=>e.title=r),label:"Display Title (Optional)",placeholder:"Research Assistant"},null,8,["modelValue"]),t[25]||(t[25]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Human-readable title shown in the UI. If not set, the name will be used. ",-1))]),i(" Agent Type "),o("div",null,[S(e.SelectInput,{modelValue:e.agentType,"onUpdate:modelValue":t[2]||(t[2]=r=>e.agentType=r),label:"Agent Type",options:e.agentTypeOptions},null,8,["modelValue"]),t[26]||(t[26]=o("p",{class:"mt-1 text-sm text-gray-500 dark:text-gray-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),i(" Expose as Tool (only for dual_ai agents) "),e.agentType==="dual_ai"?(s(),l("div",Gs,[S(e.CheckboxInput,{modelValue:e.exposeAsTool,"onUpdate:modelValue":t[3]||(t[3]=r=>e.exposeAsTool=r),label:"Expose as Tool"},null,8,["modelValue"]),t[27]||(t[27]=o("p",{class:"mt-1 text-sm text-gray-500 dark:text-gray-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):i("v-if",!0),i(" Tool Description (only show if expose_as_tool is checked and agent is dual_ai) "),e.exposeAsTool&&e.agentType==="dual_ai"?(s(),l("div",Xs,[S(e.TextareaInput,{modelValue:e.toolDescription,"onUpdate:modelValue":t[4]||(t[4]=r=>e.toolDescription=r),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:e.toolDescriptionError,rows:3},null,8,["modelValue","error"]),e.toolDescriptionError?i("v-if",!0):(s(),l("p",Qs," This description helps other agents understand when to use this agent "))])):i("v-if",!0),i(" Max Session Turns (only show for dual_ai) "),e.agentType==="dual_ai"?(s(),l("div",Ys,[S(e.TextInput,{"model-value":e.maxSessionTurns?.toString()||"","onUpdate:modelValue":t[5]||(t[5]=r=>e.maxSessionTurns=r?parseInt(r):null),label:"Max Session Turns",type:"number",error:e.maxSessionTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.maxSessionTurnsError?i("v-if",!0):(s(),l("p",$s," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):i("v-if",!0),i(" Two Column Layout for both sides "),o("div",el,[i(" Side A (AI) "),o("div",tl,[t[34]||(t[34]=o("h4",{class:"font-semibold text-base mb-4 text-gray-800 dark:text-gray-200"}," Side A (AI) ",-1)),i(" Label (Optional) "),o("div",null,[S(e.TextInput,{modelValue:e.sideALabel,"onUpdate:modelValue":t[6]||(t[6]=r=>e.sideALabel=r),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),t[28]||(t[28]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),i(" Agent Prompt "),o("div",null,[S(e.SelectInput,{modelValue:e.sideAAgentPrompt,"onUpdate:modelValue":t[7]||(t[7]=r=>e.sideAAgentPrompt=r),label:"Agent Prompt",options:e.promptOptions,error:e.sideAAgentPromptError,required:""},null,8,["modelValue","options","error"]),e.sideAAgentPromptError?i("v-if",!0):(s(),l("p",ol," The prompt that defines this agent's behavior "))]),i(" Stop Conditions "),o("div",rl,[t[31]||(t[31]=o("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),t[32]||(t[32]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),i(" Stop on Response "),o("div",al,[S(e.CheckboxInput,{modelValue:e.sideAStopOnResponse,"onUpdate:modelValue":t[8]||(t[8]=r=>e.sideAStopOnResponse=r),label:"Stop when agent returns content"},null,8,["modelValue"])]),t[33]||(t[33]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),i(" Stop on Tool Call "),o("div",null,[S(e.CheckboxInput,{modelValue:e.sideAStopOnToolCall,"onUpdate:modelValue":t[9]||(t[9]=r=>e.sideAStopOnToolCall=r),label:"Stop on specific tool call"},null,8,["modelValue"]),e.sideAStopOnToolCall?(s(),l("div",sl,[S(e.SelectInput,{modelValue:e.sideAStopTool,"onUpdate:modelValue":t[10]||(t[10]=r=>e.sideAStopTool=r),label:"Stop Tool",options:e.sideAToolOptions,error:e.sideAStopToolError,placeholder:"Select a tool...",disabled:e.sideAPromptLoading||!e.sideAAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideAStopToolError?i("v-if",!0):(s(),l("p",ll," Agent stops when this tool is called ")),e.sideAStopTool?(s(),l("div",nl,[S(e.SelectInput,{modelValue:e.sideAStopToolResponseProperty,"onUpdate:modelValue":t[11]||(t[11]=r=>e.sideAStopToolResponseProperty=r),label:"Response Property",options:e.sideAResponsePropertyOptions,error:e.sideAStopToolResponsePropertyError,placeholder:"Select property..."},null,8,["modelValue","options","error"]),t[29]||(t[29]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Property from tool arguments to return as final response ",-1))])):i("v-if",!0)])):i("v-if",!0)]),i(" Manual Stop Condition (only for ai_human when both stop conditions are unchecked) "),e.agentType==="ai_human"&&!e.sideAStopOnResponse&&!e.sideAStopOnToolCall?(s(),l("div",il,[S(e.CheckboxInput,{modelValue:e.sideAManualStopCondition,"onUpdate:modelValue":t[12]||(t[12]=r=>e.sideAManualStopCondition=r),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),t[30]||(t[30]=o("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):i("v-if",!0)]),i(" Max Turns "),o("div",null,[S(e.TextInput,{"model-value":e.sideAMaxTurns?.toString()||"","onUpdate:modelValue":t[13]||(t[13]=r=>e.sideAMaxTurns=r?parseInt(r):null),label:"Max Turns",type:"number",error:e.sideAMaxTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.sideAMaxTurnsError?i("v-if",!0):(s(),l("p",dl," Maximum turns this side can take before yielding (safety limit) "))]),i(" End Conversation Tool "),o("div",null,[S(e.SelectInput,{modelValue:e.sideAEndConversationTool,"onUpdate:modelValue":t[14]||(t[14]=r=>e.sideAEndConversationTool=r),label:"End Conversation Tool",options:e.sideAToolOptions,error:e.sideAEndConversationToolError,placeholder:"Select a tool...",disabled:e.sideAPromptLoading||!e.sideAAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideAEndConversationToolError?i("v-if",!0):(s(),l("p",cl," Tool that ends the entire conversation when called "))])]),i(" Side B (AI or Human) "),o("div",ul,[o("h4",pl," Side B ("+b(e.agentType==="ai_human"?"Human":"AI")+") ",1),i(" Label (Optional) - Available for both AI and Human "),o("div",null,[S(e.TextInput,{modelValue:e.sideBLabel,"onUpdate:modelValue":t[15]||(t[15]=r=>e.sideBLabel=r),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),t[35]||(t[35]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e.agentType==="ai_human"?(s(),l("div",ml,[...t[36]||(t[36]=[o("svg",{class:"w-20 h-20 mb-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),o("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),o("p",{class:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(s(),l(W,{key:1},[i(" Agent Prompt "),o("div",null,[S(e.SelectInput,{modelValue:e.sideBAgentPrompt,"onUpdate:modelValue":t[16]||(t[16]=r=>e.sideBAgentPrompt=r),label:"Agent Prompt",options:e.promptOptions,error:e.sideBAgentPromptError,required:""},null,8,["modelValue","options","error"]),e.sideBAgentPromptError?i("v-if",!0):(s(),l("p",gl," The prompt that defines this agent's behavior "))]),i(" Stop Conditions "),o("div",fl,[t[38]||(t[38]=o("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),t[39]||(t[39]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),i(" Stop on Response "),o("div",hl,[S(e.CheckboxInput,{modelValue:e.sideBStopOnResponse,"onUpdate:modelValue":t[17]||(t[17]=r=>e.sideBStopOnResponse=r),label:"Stop when agent returns content"},null,8,["modelValue"])]),t[40]||(t[40]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),i(" Stop on Tool Call "),o("div",null,[S(e.CheckboxInput,{modelValue:e.sideBStopOnToolCall,"onUpdate:modelValue":t[18]||(t[18]=r=>e.sideBStopOnToolCall=r),label:"Stop on specific tool call"},null,8,["modelValue"]),e.sideBStopOnToolCall?(s(),l("div",vl,[S(e.SelectInput,{modelValue:e.sideBStopTool,"onUpdate:modelValue":t[19]||(t[19]=r=>e.sideBStopTool=r),label:"Stop Tool",options:e.sideBToolOptions,error:e.sideBStopToolError,placeholder:"Select a tool...",disabled:e.sideBPromptLoading||!e.sideBAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideBStopToolError?i("v-if",!0):(s(),l("p",bl," Agent stops when this tool is called ")),e.sideBStopTool?(s(),l("div",yl,[S(e.SelectInput,{modelValue:e.sideBStopToolResponseProperty,"onUpdate:modelValue":t[20]||(t[20]=r=>e.sideBStopToolResponseProperty=r),label:"Response Property",options:e.sideBResponsePropertyOptions,error:e.sideBStopToolResponsePropertyError,placeholder:"Select property..."},null,8,["modelValue","options","error"]),t[37]||(t[37]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Property from tool arguments to return as final response ",-1))])):i("v-if",!0)])):i("v-if",!0)])]),i(" Max Turns "),o("div",null,[S(e.TextInput,{"model-value":e.sideBMaxTurns?.toString()||"","onUpdate:modelValue":t[21]||(t[21]=r=>e.sideBMaxTurns=r?parseInt(r):null),label:"Max Turns",type:"number",error:e.sideBMaxTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.sideBMaxTurnsError?i("v-if",!0):(s(),l("p",xl," Maximum turns this side can take before yielding (safety limit) "))]),i(" End Conversation Tool "),o("div",null,[S(e.SelectInput,{modelValue:e.sideBEndConversationTool,"onUpdate:modelValue":t[22]||(t[22]=r=>e.sideBEndConversationTool=r),label:"End Conversation Tool",options:e.sideBToolOptions,error:e.sideBEndConversationToolError,placeholder:"Select a tool...",disabled:e.sideBPromptLoading||!e.sideBAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideBEndConversationToolError?i("v-if",!0):(s(),l("p",kl," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"])}const Sl=Q(Hs,[["render",Cl],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AgentModal.vue"]]),Tl=$({__name:"AgentsView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!1),d=m("add"),r=m(null),n=m(null);oe(()=>e.query.refresh,()=>{e.query.refresh&&(n.value?.refresh(),a.replace({path:"/agents",query:{}}))});const f={router:a,route:e,showModal:c,modalMode:d,editingAgent:r,dataTableRef:n,handleAdd:()=>{d.value="add",r.value=null,c.value=!0},handleEdit:h=>{d.value="edit",r.value=h,c.value=!0},handleSave:async h=>{try{const w=d.value==="edit"&&r.value?.id,{originalName:x,...k}=h,C=J(w?`/api/agents/${r.value.id}`:"/api/agents"),_=await fetch(C,{method:w?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(_.ok)n.value?.refresh(),c.value=!1,r.value=null;else{const I=await _.json();alert(I.error||`Failed to ${w?"update":"create"} agent`)}}catch(w){console.error(`Error ${d.value==="edit"?"updating":"creating"} agent:`,w),alert(`Failed to ${d.value==="edit"?"update":"create"} agent`)}},AgentsDataTable:Sa,AgentModal:Sl};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),Ml={class:"p-8"};function Il(u,t,a,e,c,d){return s(),l("div",Ml,[o("div",{class:"flex justify-between items-center mb-6"},[t[1]||(t[1]=o("h1",{class:"text-3xl font-bold"},"Agents",-1)),o("button",{onClick:e.handleAdd,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),t[2]||(t[2]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"},"Configure and manage your AI agents.",-1)),S(e.AgentsDataTable,{ref:"dataTableRef",onAdd:e.handleAdd,onEdit:e.handleEdit},null,512),S(e.AgentModal,{modelValue:e.showModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showModal=r),mode:e.modalMode,editAgent:e.editingAgent,onSave:e.handleSave},null,8,["modelValue","mode","editAgent"])])}const Vl=Q(Tl,[["render",Il],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/AgentsView.vue"]]);function Al(u){const{limit:t=50,offset:a=0,agentId:e=null,userId:c=null,autoFetch:d=!0}={},r=z(()=>{const C=new URLSearchParams,y=typeof t=="number"?t:t.value,_=typeof a=="number"?a:a.value,I=typeof e=="string"?e:e?.value,U=typeof c=="string"?c:c?.value;return C.append("limit",y.toString()),C.append("offset",_.toString()),I&&C.append("agent_id",I),U&&C.append("user_id",U),J(`/api/threads?${C.toString()}`)}),{data:n,error:p,isFetching:v,isFinished:g,execute:f,abort:h}=ve(r,{immediate:d}).get().json(),w=z(()=>n.value?.threads||[]),x=z(()=>n.value?.total||0),k=z(()=>n.value?.hasMore||!1);return{threads:w,total:x,hasMore:k,error:p,isFetching:v,isFinished:g,refetch:f,abort:h}}function nt(u){const t=z(()=>!!(typeof u=="string"?u:u?.value)),a=z(()=>{const g=typeof u=="string"?u:u?.value;return J(g?`/api/threads/${g}`:"/api/threads/placeholder")}),{data:e,error:c,isFetching:d,isFinished:r,execute:n,abort:p}=ve(a,{immediate:!1}).get().json();return oe(t,g=>{g&&n()},{immediate:!0}),{thread:z(()=>e.value?{id:e.value.thread.id,agent_id:e.value.thread.agent_id,user_id:e.value.thread.user_id,tags:e.value.thread.tags||[],created_at:e.value.thread.created_at,agent:e.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:e.value.stats}:null),error:c,isFetching:d,isFinished:r,refetch:n,abort:p}}function Pl(u){const{autoConnect:t=!0,onEvent:a}=u||{},e=m(null),c=m(!1),d=m(null),r=()=>{e.value&&e.value.close();const p=window.location.protocol==="https:"?"wss:":"ws:",v=window.location.host;let g=`${p}//${v}${J("/api/events")}`;const f=localStorage.getItem("auth_token");f&&(g+=`?token=${encodeURIComponent(f)}`);try{e.value=new WebSocket(g),e.value.onopen=()=>{c.value=!0,d.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},e.value.onmessage=h=>{try{const w=JSON.parse(h.data);console.log("[AgentBuilderEvents] Received event:",w.type),a&&a(w)}catch(w){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",w)}},e.value.onerror=h=>{d.value="WebSocket connection error",c.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",h)},e.value.onclose=()=>{c.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(h){d.value=h.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",h)}},n=()=>{e.value&&(e.value.close(),e.value=null,c.value=!1)};return t&&r(),Te(()=>{n()}),{wsConnected:c,wsError:d,connect:r,disconnect:n}}const El=$({__name:"Loader",props:{size:{type:String,required:!1,default:"md"}},setup(u,{expose:t}){t();const a=u,e=z(()=>{switch(a.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}}),c={props:a,sizeClasses:e};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}}),Ol={class:"inline-flex items-center justify-center"};function jl(u,t,a,e,c,d){return s(),l("div",Ol,[o("div",{class:ee([e.sizeClasses,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)])}const De=Q(El,[["render",jl],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Loader.vue"]]);function Ll(u){const a=Date.now()*1e3-u,e=Math.floor(a/1e6);if(e<60)return e===1?"1 second ago":`${e} seconds ago`;const c=Math.floor(e/60);if(c<60)return c===1?"1 minute ago":`${c} minutes ago`;const d=Math.floor(c/60);if(d<24)return d===1?"1 hour ago":`${d} hours ago`;const r=Math.floor(d/24);if(r<30)return r===1?"1 day ago":`${r} days ago`;const n=Math.floor(r/30);if(n<12)return n===1?"1 month ago":`${n} months ago`;const p=Math.floor(n/12);return p===1?"1 year ago":`${p} years ago`}function Dl(u){const t=m("");let a=null;const e=()=>typeof u=="function"?u():typeof u=="number"?u:u.value,c=()=>{const d=e();t.value=Ll(d);const n=Date.now()*1e3-d,p=Math.floor(n/1e6);a!==null&&(clearInterval(a),a=null),p<60?a=setInterval(c,1e3):p<3600?a=setInterval(c,6e4):p<86400&&(a=setInterval(c,6e5))};return c(),Te(()=>{a!==null&&clearInterval(a)}),t}const Ul=$({__name:"TimeAgo",props:{timestamp:{type:Number,required:!0}},setup(u,{expose:t}){t();const a=u,e=Dl(()=>a.timestamp),c={props:a,timeString:e};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}});function ql(u,t,a,e,c,d){return s(),l("span",null,b(e.timeString),1)}const it=Q(Ul,[["render",ql],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/TimeAgo.vue"]]),Nl=$({__name:"ThreadListPane",props:{selectedThreadId:{type:[String,null],required:!0}},emits:["selectThread","collapse","createThread"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(""),{threads:r,isFetching:n,error:p,refetch:v}=Al(),g=m([]),f=m(new Set),h=z(()=>{const _=r.value.filter(L=>!f.value.has(L.id)),I=new Set(_.map(L=>L.id));return[...g.value.filter(L=>!I.has(L.id)&&!f.value.has(L.id)),..._].sort((L,j)=>j.created_at-L.created_at)}),w=async _=>{if(_.type==="thread_created"){const I={id:_.thread.id,agent_id:_.thread.agent_name,user_id:_.thread.user_id,tags:_.thread.tags||[],created_at:_.thread.created_at,agent:{title:_.thread.agent_name,type:"ai_human"}};g.value.unshift(I)}else _.type==="thread_deleted"&&(f.value.add(_.threadId),g.value=g.value.filter(I=>I.id!==_.threadId))},{wsConnected:x,wsError:k}=Pl({onEvent:w});oe(r,()=>{g.value=[]}),t({refetch:v});const y={props:e,emit:c,searchQuery:d,fetchedThreads:r,isFetching:n,error:p,refetch:v,wsAddedThreads:g,wsRemovedThreadIds:f,threads:h,handleEvent:w,wsConnected:x,wsError:k,handleThreadClick:_=>{c("selectThread",_)},Loader:De,TimeAgo:it,get ListIcon(){return _t},get ChevronLeftIcon(){return Ze}};return Object.defineProperty(y,"__isScriptSetup",{enumerable:!1,value:!0}),y}}),Bl={class:"flex flex-col h-full"},Rl={class:"p-4 border-b border-gray-300 dark:border-gray-700"},Fl={class:"flex items-center justify-between"},zl={class:"flex items-center gap-2"},Hl={class:"flex items-center gap-2"},Wl={class:"text-xs pr-5"},Jl={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},Kl={key:1,class:"text-red-600 dark:text-red-400"},Zl={key:2,class:"text-gray-400 dark:text-gray-600"},Gl={class:"flex-1 overflow-y-auto text-xs"},Xl={key:0,class:"p-2 flex justify-center"},Ql={class:"p-2 text-red-600 dark:text-red-400"},Yl=["id","onClick"],$l={class:"flex items-center gap-2 mb-1"},en={class:"font-medium truncate flex-1 min-w-0"},tn={class:"flex-shrink-0 text-gray-500 dark:text-gray-400"},on={key:0,class:"flex flex-wrap gap-1"};function rn(u,t,a,e,c,d){return s(),l("div",Bl,[i(" Header (matches MessagesPane style) "),o("div",Rl,[o("div",Fl,[o("div",zl,[S(e.ListIcon,{size:20,class:"flex-shrink-0"}),t[2]||(t[2]=o("h2",{class:"text-xl font-bold"},"Threads",-1))]),o("div",Hl,[i(" WebSocket status "),o("div",Wl,[e.wsConnected?(s(),l("span",Jl,[...t[3]||(t[3]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",Kl," ● Error ")):(s(),l("span",Zl," ○ Offline "))]),o("button",{onClick:t[0]||(t[0]=r=>e.emit("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),o("button",{onClick:t[1]||(t[1]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Thread list "),o("div",Gl,[i(" Loading state "),e.isFetching?(s(),l("div",Xl,[S(e.Loader)])):e.error?(s(),l(W,{key:1},[i(" Error state "),o("div",Ql," Error: "+b(e.error),1)],2112)):e.threads.length===0?(s(),l(W,{key:2},[i(" Empty state "),t[4]||(t[4]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-12 text-base"}," No threads found ",-1))],2112)):(s(),l(W,{key:3},[i(" Thread items - two line layout "),o("div",null,[(s(!0),l(W,null,ne(e.threads,r=>(s(),l("button",{key:r.id,id:`thread-${r.id}`,class:ee(["w-full text-left px-2 py-2 border-b border-gray-200 dark:border-gray-800 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors",{"bg-gray-100 dark:bg-gray-900":a.selectedThreadId===r.id}]),onClick:n=>e.handleThreadClick(r.id)},[i(" First line: Title and time "),o("div",$l,[o("span",en,b(r.agent.title),1),o("span",tn,[S(e.TimeAgo,{timestamp:r.created_at*1e6},null,8,["timestamp"])])]),i(" Second line: Tags "),r.tags.length>0?(s(),l("div",on,[(s(!0),l(W,null,ne(r.tags,n=>(s(),l("span",{key:n,class:"inline-block px-1.5 py-0.5 rounded text-[10px] bg-gray-200 dark:bg-gray-800 text-gray-700 dark:text-gray-300"},b(n),1))),128))])):i("v-if",!0)],10,Yl))),128))])],2112))])])}const an=Q(Nl,[["render",rn],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/ThreadListPane.vue"]]),ze=150;function sn(u,t={}){const{enableWebSocket:a=!0,autoConnect:e=!0}=t,c=m([]),d=m(null),r=m(!1),n=m(!1),p=m(null),v=m(!1),g=m(null),f=m(!1),h=m(!1),w=m(0),x=m(0);let k=null,C=null;function y(N){if(!d.value?.agent)return null;const Z=d.value.agent,G=N==="assistant"?"A":"B";return G==="A"&&Z.side_a_label?Z.side_a_label:G==="B"&&Z.side_b_label?Z.side_b_label:null}function _(N,Z){return N==="system"||Z==="system"?!1:N!==Z}const I=z(()=>{const N=[],Z=c.value.filter(V=>(V.depth??0)===0),G=new Map;for(let V=0;V<Z.length;V++){const T=Z[V],q=T.role;if(q==="tool"){const re=T.tool_call_id;if(re&&G.has(re)){const ue=G.get(re),me=N[ue],we=me.items.find(ke=>ke.type==="tool_call"&&ke.tool_call_id===re);if(we){we.response=T.content||"",we.response_log_id=T.log_id;const ke=(T.content||"").toLowerCase(),be=ke.length,Fe=ke.includes("failed")||ke.includes("error"),Me=be<500;Fe&&Me?we.response_status="failed":we.response_status="success"}me.updated_at=T.created_at,G.delete(re)}continue}const M=y(q==="tool"?"assistant":q),O=N[N.length-1],A=O?.role;O&&_(q,A)&&O.type==="work"&&!O.isComplete&&(O.isComplete=!0);let B=null;if(T.tool_calls)if(typeof T.tool_calls=="string")try{B=JSON.parse(T.tool_calls)}catch(re){console.error("Failed to parse tool_calls:",re)}else Array.isArray(T.tool_calls)&&(B=T.tool_calls);const te=B&&B.length>0,le=O?.type==="work"&&O.role===q&&!O.isComplete;if(te){let re,ue;le?(re=O,ue=N.length-1):(re={type:"work",id:T.id,role:q,items:[],created_at:T.created_at,updated_at:T.created_at,isComplete:!1,sideLabel:M,isExpanded:!1,request_sent_at:T.request_sent_at,response_completed_at:T.response_completed_at,status:T.status||"completed"},N.push(re),ue=N.length-1),T.reasoning_content&&re.items.push({id:`${T.id}-reasoning`,type:"reasoning",content:T.reasoning_content,created_at:T.created_at,log_id:T.log_id}),T.content&&re.items.push({id:`${T.id}-content`,type:"content",content:T.content,created_at:T.created_at,log_id:T.log_id}),B.forEach(me=>{re.items.push({id:me.id,type:"tool_call",content:me.function.name,created_at:T.created_at,tool_name:me.function.name,tool_call_id:me.id,tool_arguments:me.function.arguments,log_id:T.log_id,response:null,response_status:"pending",response_log_id:null}),G.set(me.id,ue)}),re.updated_at=T.created_at,T.response_completed_at&&(re.response_completed_at=T.response_completed_at),T.status&&T.status!=="completed"?re.status=T.status:T.status==="completed"&&re.status==="pending"&&(re.status="completed")}else le&&T.status!=="pending"&&(O.isComplete=!0),(T.content||q==="system"||T.status==="pending")&&N.push({type:"text",id:T.id,role:q,content:T.content||"",created_at:T.created_at,log_id:T.log_id,sideLabel:M,isOptimistic:T.isOptimistic,status:T.status})}const P=N[N.length-1];return P?.type==="work"&&!P.isComplete&&(P.isComplete=!0),N});async function U(){if(!u.value){c.value=[],d.value=null,h.value=!1,w.value=0,x.value=0;return}r.value=!0,p.value=null;try{const N=await fetch(J(`/api/threads/${u.value}/messages?limit=${ze}&includeSilent=true`));if(!N.ok)throw new Error(`Failed to fetch messages: ${N.statusText}`);const Z=await N.json();c.value=Z.messages||[],h.value=Z.hasMore||!1,w.value=Z.total||0,x.value=ze,console.log(`Loaded ${c.value.length} messages, total: ${w.value}, hasMore: ${h.value}`);const G=await fetch(J(`/api/threads/${u.value}`));if(G.ok){const P=await G.json();d.value=P}}catch(N){p.value=N instanceof Error?N.message:"Unknown error",console.error("Error fetching messages:",N)}finally{r.value=!1}}async function L(){if(!(!u.value||n.value||!h.value)){n.value=!0;try{const N=await fetch(J(`/api/threads/${u.value}/messages?limit=${ze}&offset=${x.value}`));if(!N.ok)throw new Error(`Failed to fetch more messages: ${N.statusText}`);const Z=await N.json(),G=Z.messages||[];c.value=[...G,...c.value],h.value=Z.hasMore||!1,x.value+=ze,console.log(`Loaded ${G.length} more messages, offset now: ${x.value}, hasMore: ${h.value}`)}catch(N){p.value=N instanceof Error?N.message:"Unknown error",console.error("Error loading more messages:",N)}finally{n.value=!1}}}function j(){if(!(!a||!u.value||k))try{let Z=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${J(`/api/threads/${u.value}/stream?includeSilent=true`)}`;const G=localStorage.getItem("auth_token");G&&(Z+=`&token=${encodeURIComponent(G)}`),k=new WebSocket(Z),k.onopen=()=>{v.value=!0,g.value=null,console.log("WebSocket connected")},k.onmessage=P=>{try{if(P.data==="pong")return;const V=JSON.parse(P.data);if(V.type==="message_data"&&V.message_id){const T=V.message_id,q=V.data,M=c.value.findIndex(O=>O.id===T);if(M>=0)c.value[M]={...c.value[M],...q,id:T};else{const O={id:T,...q},A=c.value.filter(B=>{if(!B.isOptimistic)return!0;if(B.id===T)return!1;const te=B.content===O.content,le=B.role===O.role,re=Math.abs(B.created_at-O.created_at)<5e6;return!(te&&le&&re)});A.push(O),c.value=A.sort((B,te)=>B.created_at-te.created_at)}if(q.status==="pending")f.value=!0;else if(q.status==="completed"||q.status==="failed"){const O=c.value.some(A=>{if((A.depth??0)>0)return!1;if(A.status==="pending"||A.role==="tool"&&A.tool_call_id&&!A.tool_status)return!0;if(A.tool_calls)try{const te=JSON.parse(A.tool_calls);if(Array.isArray(te)&&te.length>0&&!te.every(re=>c.value.some(ue=>(ue.depth??0)===0&&ue.role==="tool"&&ue.tool_call_id===re.id&&ue.tool_status)))return!0}catch{}return!1});f.value=O}}else if(V.type==="message_chunk"){const T=V.message_id,q=V.chunk,M=c.value.findIndex(O=>O.id===T);if(M>=0){const O=c.value[M].content||"",A={...c.value[M],content:O+q};c.value.splice(M,1,A)}else{const O={id:T,role:"assistant",content:q,created_at:Date.now()*1e3,status:"pending"};c.value.push(O),c.value=c.value.sort((A,B)=>A.created_at-B.created_at)}}else V.type==="error"&&(g.value=V.error||"WebSocket error",console.error("WebSocket error:",V.error))}catch(V){console.error("Error parsing WebSocket message:",V)}},k.onerror=P=>{g.value="WebSocket connection error",console.error("WebSocket error:",P)},k.onclose=()=>{v.value=!1,k=null,u.value&&a&&(C=setTimeout(()=>{console.log("Attempting WebSocket reconnect..."),j()},3e3))}}catch(N){g.value=N instanceof Error?N.message:"Unknown error",console.error("Error connecting WebSocket:",N)}}function F(){C&&(clearTimeout(C),C=null),k&&(k.close(),k=null,v.value=!1)}async function K(){await U()}function D(N){c.value.push({...N,isOptimistic:!0})}function E(N){c.value=c.value.filter(Z=>Z.id!==N)}async function H(N){if(!u.value)return;const Z=[...c.value];c.value=c.value.filter(G=>G.id!==N);try{if(!(await fetch(J(`/api/threads/${u.value}/messages/${N}`),{method:"DELETE"})).ok)throw c.value=Z,new Error("Failed to delete message")}catch(G){throw c.value=Z,G}}async function R(){if(u.value){f.value=!1;try{if(!(await fetch(J(`/api/threads/${u.value}/stop`),{method:"POST"})).ok)throw new Error("Failed to stop thread")}catch(N){throw console.error("Error stopping thread:",N),N}}}return oe(u,async(N,Z)=>{N!==Z&&(F(),N?(await U(),e&&a&&j()):(c.value=[],d.value=null))},{immediate:e}),Te(()=>{F()}),{messages:I,threadInfo:d,isFetching:r,isLoadingMore:n,error:p,wsConnected:v,wsError:g,isExecuting:f,hasMore:h,totalMessages:w,refetch:K,loadMoreMessages:L,connectWebSocket:j,disconnectWebSocket:F,addOptimisticMessage:D,removeOptimisticMessage:E,deleteMessageById:H,stopThread:R}}const ln=$({__name:"AgentMessages",props:{messages:{type:Array,required:!0},selectedMessageId:{type:[String,null],required:!1},selectedLogId:{type:[String,null],required:!1}},emits:["messageClick","deleteMessage"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(new Set),n=m(new Set),p=m(new Set);function v(D){r.value.has(D)?r.value.delete(D):r.value.add(D)}function g(D){n.value.has(D)?n.value.delete(D):n.value.add(D)}function f(D){p.value.has(D)?p.value.delete(D):p.value.add(D)}function h(D){if(!D)return{};try{return JSON.parse(D)}catch{return{raw:D}}}function w(D){if(!D)return null;const E=h(D),H=Object.keys(E);if(H.length===0)return null;const R=E[H[0]];return typeof R=="string"?R:JSON.stringify(R)}function x(D){return new Date(D/1e3).toLocaleTimeString()}function k(D){const E=Math.round(D/1e6);if(E<1)return"< 1s";if(E<60)return`${E}s`;const H=Math.floor(E/60),R=E%60;return`${H}m ${R}s`}function C(D){if(D.status==="pending")return"...";if(!D.isComplete)return"Working...";let E;return D.request_sent_at&&D.response_completed_at?E=D.response_completed_at-D.request_sent_at:E=D.updated_at-D.created_at,`Worked for ${k(E)}`}function y(D){const E=D.filter(H=>H.type==="content");if(E.length===0){const H=D.filter(R=>R.type==="reasoning");return H.length>0?H[H.length-1].content:null}return E[E.length-1].content}function _(D){const E=D.split(`
2
- `)[0];return E.length>60?E.substring(0,60):E}function I(D){const E=D.filter(H=>H.type==="tool_call");return E.length===0?null:E[E.length-1].tool_name||null}function U(D){return e.selectedMessageId===D.id?!0:e.selectedLogId?D.items.some(E=>E.log_id===e.selectedLogId):!1}function L(D){return!!(e.selectedLogId&&D.log_id===e.selectedLogId)}function j(){return e.messages.some(D=>D.type==="work"&&!D.isComplete)}function F(D){return!D.isComplete}const K={props:e,emit:c,hoveredMessageId:d,expandedMessages:r,expandedToolCalls:n,expandedReasoning:p,toggleWorkMessage:v,toggleToolCall:g,toggleReasoning:f,parseArguments:h,getArgumentsPreview:w,formatTime:x,formatDuration:k,getWorkStatus:C,getLatestContent:y,getFirstLine:_,getLatestToolName:I,isWorkMessageSelected:U,isWorkItemSelected:L,hasActiveWorkMessage:j,isWorkMessageActive:F,get ChevronDownIcon(){return oo},get ChevronRightIcon(){return to},get AlertTriangleIcon(){return eo},get Trash2Icon(){return wt}};return Object.defineProperty(K,"__isScriptSetup",{enumerable:!1,value:!0}),K}}),nn={class:"space-y-3"},dn=["onMouseenter"],cn=["onClick"],un={key:1,class:"w-full text-center text-xs text-gray-400 dark:text-gray-500 py-1"},pn=["onClick"],mn={key:0,class:"whitespace-pre-wrap text-sm"},gn={key:0,class:"opacity-50"},fn={key:1,class:"opacity-50 italic text-gray-500 dark:text-gray-400"},hn=["onClick"],vn=["onClick"],bn={key:0,class:"space-y-1"},yn={class:"flex items-start gap-2"},xn={class:"flex-1 min-w-0"},kn={key:0,class:"truncate opacity-80"},_n={key:1,class:"italic opacity-60"},wn={class:"flex items-center gap-2 pl-5 opacity-60"},Cn={class:"text-[10px]"},Sn={class:"text-[10px]"},Tn={class:"space-y-2"},Mn={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},In={class:"text-[10px] italic"},Vn={class:"text-[10px] ml-auto"},An={key:0,class:"space-y-1"},Pn=["onClick"],En={class:"font-mono text-[11px] flex-shrink-0"},On={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},jn={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},Ln={key:0,class:"pl-4 space-y-2 text-[10px]"},Dn={key:0},Un={class:"w-full border-collapse"},qn={class:"py-0.5 pr-2 opacity-65 align-top"},Nn={class:"py-0.5 opacity-85 break-all"},Bn={key:1},Rn=["onClick"],Fn={class:"whitespace-pre-wrap break-all"},zn={class:"text-[10px]"},Hn=["onClick"],Wn={key:0,class:"mt-1 pl-4 whitespace-pre-wrap opacity-80"},Jn={class:"text-[10px] opacity-80 pl-4 pb-2"},Kn=["onClick"];function Zn(u,t,a,e,c,d){return s(),l("div",nn,[(s(!0),l(W,null,ne(a.messages,r=>(s(),l("div",{key:r.id,class:ee(["flex items-center gap-2",{"justify-start":r.role==="assistant","justify-end":r.role==="user","justify-center":r.role==="system"}]),onMouseenter:n=>e.hoveredMessageId=r.id,onMouseleave:t[0]||(t[0]=n=>e.hoveredMessageId=null)},[i(" Delete button for user messages (left side) "),r.role==="user"&&e.hoveredMessageId===r.id&&!r.isOptimistic?(s(),l("button",{key:0,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,cn)):i("v-if",!0),i(" Interruption message (iOS style) "),r.type==="text"&&r.role==="system"&&r.content?.includes("Execution stopped")?(s(),l("div",un,b(r.content),1)):r.type==="text"?(s(),l(W,{key:2},[i(" Text Message "),o("div",{class:ee(["max-w-[80%] rounded-2xl px-4 py-2 text-sm cursor-pointer transition-all min-h-[2.5rem]",{"bg-black text-white dark:bg-white dark:text-black":r.role==="assistant"&&!r.silent,"bg-gray-200 text-black dark:bg-gray-800 dark:text-white":r.role==="user"&&!r.silent,"bg-gray-100 text-gray-600 dark:bg-gray-900 dark:text-gray-400 text-xs":r.role==="system"&&!r.silent,"bg-gray-300 text-gray-500 dark:bg-gray-700 dark:text-gray-400 opacity-70 border-2 border-dashed border-gray-400 dark:border-gray-500":r.silent,"ring-2 ring-blue-500":r.id===a.selectedMessageId||a.selectedLogId&&r.log_id===a.selectedLogId,"opacity-60":r.isOptimistic}]),onClick:n=>e.emit("messageClick",r.id,r.log_id||null)},[i(" Message content or typing indicator "),r.content?(s(),l("div",mn,b(r.content),1)):r.status==="pending"?(s(),l(W,{key:1},[i(" Typing indicator for pending messages with no content "),t[1]||(t[1]=o("div",{class:"flex gap-1 items-center min-h-[1.5rem]"},[o("span",{class:"typing-dot",style:{"animation-delay":"0ms"}}),o("span",{class:"typing-dot",style:{"animation-delay":"150ms"}}),o("span",{class:"typing-dot",style:{"animation-delay":"300ms"}})],-1))],2112)):i("v-if",!0),i(" Label and Timestamp (hide when pending) "),r.status!=="pending"?(s(),l("div",{key:2,class:ee(["text-xs mt-1 opacity-60 flex gap-2",{"justify-start":r.role==="assistant","justify-end":r.role!=="assistant"}])},[r.sideLabel?(s(),l("span",gn,b(r.sideLabel),1)):i("v-if",!0),o("span",null,b(e.formatTime(r.created_at)),1),r.silent?(s(),l("span",fn," silent ")):i("v-if",!0)],2)):i("v-if",!0)],10,pn)],2112)):i("v-if",!0),i(" Delete button for assistant messages (right side) "),r.type==="text"&&r.role==="assistant"&&e.hoveredMessageId===r.id&&!r.isOptimistic?(s(),l("button",{key:3,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,hn)):r.type==="work"?(s(),l(W,{key:4},[i(" Work Message "),o("div",{class:ee(["max-w-[80%] min-w-[200px] rounded-lg px-3 py-2 text-xs cursor-pointer transition-all border",{"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700":r.role==="assistant"&&!r.silent,"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:border-blue-800":r.role==="user"&&!r.silent,"bg-gray-200 text-gray-500 border-gray-400 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 opacity-70 border-dashed":r.silent,"ring-2 ring-blue-500":e.isWorkMessageSelected(r)}]),onClick:n=>e.toggleWorkMessage(r.id)},[i(" Collapsed state "),e.expandedMessages.has(r.id)?(s(),l(W,{key:1},[i(" Expanded state "),o("div",Tn,[i(" Status header "),o("div",Mn,[S(e.ChevronDownIcon,{size:14,class:"flex-shrink-0"}),o("span",In,b(e.getWorkStatus(r)),1),o("span",Vn,b(r.items.length)+" operation"+b(r.items.length!==1?"s":""),1)]),(s(!0),l(W,null,ne(r.items,n=>(s(),l("div",{key:n.id,class:"mb-1"},[i(" Tool Call (with merged response) "),n.type==="tool_call"?(s(),l("div",An,[i(" Collapsed: Single row with tool name and status "),o("div",{onClick:he(p=>e.toggleToolCall(n.id),["stop"]),class:ee(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity",{"ring-1 ring-blue-500":e.isWorkItemSelected(n)}])},[e.expandedToolCalls.has(n.id)?(s(),X(e.ChevronDownIcon,{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(s(),X(e.ChevronRightIcon,{key:0,size:12,class:"flex-shrink-0 opacity-50"})),o("span",En,b(n.tool_name),1),e.getArgumentsPreview(n.tool_arguments)?(s(),l("span",On,b(e.getArgumentsPreview(n.tool_arguments)),1)):i("v-if",!0),n.response_status==="success"?(s(),l("span",jn,"✓")):n.response_status==="failed"?(s(),X(e.AlertTriangleIcon,{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):i("v-if",!0)],10,Pn),i(" Expanded: Arguments and Response as tables "),e.expandedToolCalls.has(n.id)?(s(),l("div",Ln,[i(" Arguments table "),n.tool_arguments?(s(),l("div",Dn,[t[2]||(t[2]=o("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),o("table",Un,[o("tbody",null,[(s(!0),l(W,null,ne(e.parseArguments(n.tool_arguments),(p,v)=>(s(),l("tr",{key:v,class:"border-b border-current border-opacity-10"},[o("td",qn,b(v),1),o("td",Nn,b(typeof p=="object"?JSON.stringify(p):p),1)]))),128))])])])):i("v-if",!0),i(" Response "),n.response?(s(),l("div",Bn,[t[3]||(t[3]=o("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),o("div",{class:ee(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-blue-500":a.selectedLogId&&n.response_log_id===a.selectedLogId}]),onClick:he(p=>n.response_log_id&&e.emit("messageClick",r.id,n.response_log_id),["stop"])},[o("div",Fn,b(n.response),1)],10,Rn)])):i("v-if",!0)])):i("v-if",!0)])):n.type==="reasoning"?(s(),l(W,{key:1},[i(" Reasoning (nested expandable) "),o("div",zn,[o("button",{onClick:he(p=>e.toggleReasoning(n.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[e.expandedReasoning.has(n.id)?(s(),X(e.ChevronDownIcon,{key:1,size:12,class:"flex-shrink-0"})):(s(),X(e.ChevronRightIcon,{key:0,size:12,class:"flex-shrink-0"})),t[4]||(t[4]=o("span",{class:"font-semibold"},"Reasoning",-1))],8,Hn),e.expandedReasoning.has(n.id)?(s(),l("div",Wn,b(n.content),1)):i("v-if",!0)])],2112)):n.type==="content"?(s(),l(W,{key:2},[i(" Content "),o("div",Jn,b(n.content),1)],2112)):i("v-if",!0)]))),128))])],2112)):(s(),l("div",bn,[i(" Preview text or status "),o("div",yn,[S(e.ChevronRightIcon,{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),o("div",xn,[e.getLatestContent(r.items)?(s(),l("div",kn,b(e.getFirstLine(e.getLatestContent(r.items)))+"... ",1)):(s(),l("div",_n,b(e.getWorkStatus(r)),1))])]),i(" Status line "),o("div",wn,[o("span",Cn,b(r.items.length)+" operation"+b(r.items.length!==1?"s":""),1),o("span",Sn,"• "+b(e.getWorkStatus(r)),1)])]))],10,vn)],2112)):i("v-if",!0),i(" Delete button for work messages on right side (assistant) "),r.type==="work"&&r.role==="assistant"&&e.hoveredMessageId===r.id?(s(),l("button",{key:5,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,Kn)):i("v-if",!0)],42,dn))),128))])}const Gn=Q(ln,[["render",Zn],["__scopeId","data-v-9082ef4d"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/AgentMessages.vue"]]),Xn=$({__name:"MessagesPane",props:{threadId:{type:[String,null],required:!0},selectedMessageId:{type:[String,null],required:!1},selectedLogId:{type:[String,null],required:!1}},emits:["collapse","messageClick"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,{messages:d,threadInfo:r,isFetching:n,isLoadingMore:p,error:v,wsConnected:g,wsError:f,isExecuting:h,hasMore:w,totalMessages:x,loadMoreMessages:k,connectWebSocket:C,disconnectWebSocket:y,addOptimisticMessage:_,removeOptimisticMessage:I,deleteMessageById:U,stopThread:L}=sn(z(()=>e.threadId),{enableWebSocket:!0}),{thread:j}=nt(z(()=>e.threadId)),F=m(null);typeof window<"u"&&(window.__testLoadMoreMessages=k);const K=m(""),D=m(null),E=m("B"),H=m(!1),R=m(!1),N=async()=>{await pe(),F.value&&(F.value.scrollTop=F.value.scrollHeight)},Z=async A=>{A.target.scrollTop<100&&w.value&&!p.value&&!R.value&&(R.value=!0,await k(),R.value=!1)};oe(()=>d.value.length,async()=>{!p.value&&!R.value&&await N()}),oe(()=>e.threadId,async A=>{A&&await N()}),oe(n,async(A,B)=>{B&&!A&&await N()});const G=z(()=>{const A=r.value?.agent||j.value?.agent;if(!A)return"ai A";const B=A.type;return E.value==="A"&&A.side_a_label?A.side_a_label:E.value==="B"&&A.side_b_label?A.side_b_label:B==="ai_human"?E.value==="A"?"ai":"human":E.value==="A"?"ai A":"ai B"}),P=()=>{E.value=E.value==="A"?"B":"A"},V=async()=>{if(!K.value.trim()||!e.threadId||H.value)return;const A=K.value,B=E.value==="A"?"assistant":"user",te=`optimistic-${Date.now()}`,le={id:te,role:B,content:A,created_at:Date.now()*1e3,isOptimistic:!0};_(le),K.value="",D.value&&(D.value.style.height="auto",D.value.style.height="24px"),H.value=!0;try{if(!(await fetch(J(`/api/threads/${e.threadId}/message`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:A,role:B})})).ok)throw new Error("Failed to send message");await N()}catch(re){console.error("Error sending message:",re),I(te)}finally{H.value=!1,await pe(),D.value&&D.value.focus()}},O={props:e,emit:c,messages:d,threadInfo:r,isFetching:n,isLoadingMore:p,error:v,wsConnected:g,wsError:f,isExecuting:h,hasMore:w,totalMessages:x,loadMoreMessages:k,connectWebSocket:C,disconnectWebSocket:y,addOptimisticMessage:_,removeOptimisticMessage:I,deleteMessageById:U,stopThread:L,thread:j,messagesContainer:F,messageInput:K,messageTextarea:D,currentSide:E,isSending:H,isLoadingOlder:R,scrollToBottom:N,handleScroll:Z,sideLabel:G,toggleSide:P,sendMessage:V,handleKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),V())},handleDeleteMessage:async A=>{if(e.threadId)try{await U(A)}catch(B){console.error("Error deleting message:",B)}},handleStopThread:async()=>{if(e.threadId)try{await L()}catch(A){console.error("Error stopping thread:",A)}},AgentMessages:Gn,Loader:De,get MessageSquareIcon(){return Ct},get ChevronLeftIcon(){return Ze}};return Object.defineProperty(O,"__isScriptSetup",{enumerable:!1,value:!0}),O}}),Qn={class:"flex flex-col h-full"},Yn={class:"p-4 border-b border-gray-300 dark:border-gray-700"},$n={class:"flex items-center justify-between"},ei={class:"flex items-center gap-2"},ti={class:"flex items-center gap-2"},oi={key:0,class:"text-xs"},ri={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},ai={key:1,class:"text-red-600 dark:text-red-400"},si={key:2,class:"text-gray-400 dark:text-gray-600"},li={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-8"},ni={key:1,class:"flex justify-center py-2"},ii={class:"flex justify-center py-8"},di={class:"text-red-600 dark:text-red-400 text-center py-8"},ci={key:0,class:"p-3 bg-white dark:bg-black"},ui={class:"flex items-start gap-2"},pi={class:"flex-1 flex items-start gap-2 p-2 rounded-2xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900"},mi=["disabled"],gi=["disabled"],fi={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},hi={key:1,class:"w-4 h-4"};function vi(u,t,a,e,c,d){return s(),l("div",Qn,[i(" Header "),o("div",Yn,[o("div",$n,[o("div",ei,[S(e.MessageSquareIcon,{size:20,class:"flex-shrink-0"}),t[4]||(t[4]=o("h2",{class:"text-xl font-bold"},"Messages",-1))]),o("div",ti,[i(" WebSocket status "),a.threadId?(s(),l("div",oi,[e.wsConnected?(s(),l("span",ri,[...t[5]||(t[5]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",ai," ● Error ")):(s(),l("span",si," ○ Offline "))])):i("v-if",!0),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Messages content "),o("div",{ref:"messagesContainer",class:"flex-1 overflow-y-auto p-4 space-y-4",onScroll:e.handleScroll},[i(" No thread selected "),a.threadId?i("v-if",!0):(s(),l("div",li," Select a thread to view messages ")),i(" Loading older messages indicator "),e.isLoadingMore?(s(),l("div",ni,[S(e.Loader,{size:"sm"}),t[6]||(t[6]=o("span",{class:"ml-2 text-xs text-gray-500"},"Loading older messages...",-1))])):e.isFetching?(s(),l(W,{key:2},[i(" Loading state "),o("div",ii,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:3},[i(" Error state "),o("div",di," Error loading messages: "+b(e.error),1)],2112)):e.messages.length===0?(s(),l(W,{key:4},[i(" Empty state "),t[7]||(t[7]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-8"}," No messages yet ",-1))],2112)):(s(),l(W,{key:5},[i(" Message bubbles (using AgentMessages component) "),S(e.AgentMessages,{messages:e.messages,selectedMessageId:a.selectedMessageId,selectedLogId:a.selectedLogId,onMessageClick:t[1]||(t[1]=(r,n)=>e.emit("messageClick",r,n)),onDeleteMessage:e.handleDeleteMessage},null,8,["messages","selectedMessageId","selectedLogId"])],2112))],544),i(" Message input section (iOS-style single bubble) "),a.threadId?(s(),l("div",ci,[o("div",ui,[i(" Side toggle tag (outside bubble) "),o("button",{onClick:e.toggleSide,class:ee(["flex-shrink-0 px-2 h-7 rounded-md flex items-center justify-center font-medium text-xs transition-colors mt-2.5",{"bg-black text-white dark:bg-white dark:text-black":e.currentSide==="A","bg-gray-300 text-black dark:bg-gray-600 dark:text-white":e.currentSide==="B"}]),title:"Toggle between sides"},b(e.sideLabel),3),i(" Input bubble "),o("div",pi,[i(" Message input (no border, transparent) "),fe(o("textarea",{ref:"messageTextarea","onUpdate:modelValue":t[2]||(t[2]=r=>e.messageInput=r),onKeydown:e.handleKeyDown,disabled:e.isSending,placeholder:"Type a message...",rows:"1",class:"flex-1 bg-transparent text-black dark:text-white resize-none focus:outline-none disabled:opacity-50 mt-0.5",style:{"max-height":"120px","min-height":"24px"},onInput:t[3]||(t[3]=r=>{const n=r.target;n.style.height="auto",n.style.height=Math.min(n.scrollHeight,120)+"px"})},null,40,mi),[[_e,e.messageInput]]),i(" Send/Stop button (inside bubble) "),e.isExecuting?(s(),l(W,{key:1},[i(" Stop button (shown when thread is executing) "),o("button",{id:"stop-thread-button",onClick:e.handleStopThread,class:"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",title:"Stop execution"},[...t[9]||(t[9]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])])],2112)):(s(),l("button",{key:0,id:"send-message-button",onClick:e.sendMessage,disabled:!e.messageInput.trim()||e.isSending,class:ee(["flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all",{"bg-black text-white dark:bg-white dark:text-black":e.messageInput.trim()&&!e.isSending,"bg-gray-200 text-gray-400 dark:bg-gray-700 dark:text-gray-600":!e.messageInput.trim()||e.isSending}]),title:"Send message (Enter)"},[e.isSending?(s(),l("div",hi,[S(e.Loader)])):(s(),l("svg",fi,[...t[8]||(t[8]=[o("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,gi))])])])):i("v-if",!0)])}const bi=Q(Xn,[["render",vi],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/MessagesPane.vue"]]),yi=$({__name:"MetaPane",props:{threadId:{type:[String,null],required:!0}},emits:["collapse","threadDeleted","editThread"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,{thread:d,isFetching:r,error:n}=nt(z(()=>e.threadId)),p=m(!1),v=m(!1),g=m(!1),f=m(!1),h=m(""),w=m(!1),x=m(!1),k=m(null),{data:C,isFetching:y}=ve(J("/api/agents"),{refetch:!0}).json(),_=z(()=>C.value?.agents?C.value.agents.filter(R=>R.type==="ai_human").map(R=>({value:R.id,label:R.title,description:`Type: ${R.type}`})):[]),I=z(()=>d.value?.agent.type==="ai_human"),H={props:e,emit:c,thread:d,isFetching:r,error:n,showDeleteConfirm:p,isDeleting:v,isEditingAgent:g,isSavingAgent:f,selectedAgentId:h,showCostBreakdown:w,isFetchingCost:x,costData:k,agentsData:C,isFetchingAgents:y,aiHumanAgents:_,isAiHumanAgent:I,formatDate:R=>new Date(R*1e3).toLocaleString(),startEditingAgent:()=>{d.value&&(h.value=d.value.agent.id,g.value=!0)},cancelEditingAgent:()=>{g.value=!1,h.value=""},saveAgent:async()=>{if(!(!e.threadId||!h.value)){f.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:h.value})});if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to update agent")}window.location.reload()}catch(R){console.error("Error updating agent:",R),alert(`Failed to update agent: ${R.message}`)}finally{f.value=!1}}},fetchCostBreakdown:async()=>{if(e.threadId){x.value=!0,w.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}/cost`));if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to fetch cost breakdown")}k.value=await R.json()}catch(R){console.error("Error fetching cost breakdown:",R),alert(`Failed to fetch cost breakdown: ${R.message}`),w.value=!1}finally{x.value=!1}}},formatCurrency:R=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(R),handleDeleteThread:async()=>{if(e.threadId){v.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}`),{method:"DELETE"});if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to delete thread")}c("threadDeleted",e.threadId)}catch(R){console.error("Error deleting thread:",R),alert(`Failed to delete thread: ${R.message}`)}finally{v.value=!1}}},Loader:De,ConfirmDialog:Pt,SelectInput:xe,get InfoIcon(){return St},get ChevronLeftIcon(){return Ze},get Trash2Icon(){return wt},get PencilIcon(){return ao},get DollarSignIcon(){return ro}};return Object.defineProperty(H,"__isScriptSetup",{enumerable:!1,value:!0}),H}}),xi={class:"flex flex-col h-full"},ki={class:"p-4 border-b border-gray-300 dark:border-gray-700"},_i={class:"flex items-center justify-between"},wi={class:"flex items-center gap-2"},Ci={class:"flex-1 overflow-y-auto p-4"},Si={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-8"},Ti={class:"flex justify-center py-8"},Mi={class:"text-red-600 dark:text-red-400 text-center py-8"},Ii={class:"space-y-4"},Vi={class:"text-sm font-mono break-all"},Ai={class:"flex items-center justify-between mb-2"},Pi={key:0},Ei={class:"text-sm"},Oi={class:"text-xs text-gray-500 dark:text-gray-500 mt-1"},ji={key:1,class:"space-y-2"},Li={class:"flex gap-2"},Di=["disabled"],Ui=["disabled"],qi={class:"text-sm"},Ni={key:0},Bi={class:"text-sm font-mono"},Ri={class:"flex items-center justify-between mb-2"},Fi={key:0,class:"flex flex-wrap gap-2"},zi={key:1,class:"text-sm text-gray-500 dark:text-gray-500 italic"},Hi={class:"flex items-center justify-between mb-2"},Wi=["disabled"],Ji={key:0,class:"flex justify-center py-4"},Ki={key:1,class:"space-y-3"},Zi={class:"grid grid-cols-2 gap-2 text-xs"},Gi={class:"p-2 bg-gray-100 dark:bg-gray-900 rounded"},Xi={class:"font-mono font-bold"},Qi={class:"p-2 bg-gray-100 dark:bg-gray-900 rounded"},Yi={class:"font-mono font-bold"},$i={key:0,class:"space-y-2"},ed={class:"overflow-x-auto"},td={class:"w-full text-xs"},od={class:"py-2 pr-2 font-medium"},rd={class:"text-right py-2 px-2 font-mono"},ad={class:"text-right py-2 px-2 font-mono"},sd={class:"text-right py-2 pl-2 font-mono"},ld={key:1,class:"text-xs text-gray-500 dark:text-gray-500 italic py-2"},nd={class:"pt-4 mt-4 border-t border-red-300 dark:border-red-700"},id=["disabled"],dd={key:0},cd={key:1};function ud(u,t,a,e,c,d){return s(),l("div",xi,[i(" Header "),o("div",ki,[o("div",_i,[o("div",wi,[S(e.InfoIcon,{size:20,class:"flex-shrink-0"}),t[6]||(t[6]=o("h2",{class:"text-xl font-bold"},"Metadata",-1))]),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])]),i(" Content "),o("div",Ci,[i(" No thread selected "),a.threadId?e.isFetching?(s(),l(W,{key:1},[i(" Loading state "),o("div",Ti,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:2},[i(" Error state "),o("div",Mi," Error loading metadata: "+b(e.error),1)],2112)):e.thread?(s(),l(W,{key:3},[i(" Metadata display "),o("div",Ii,[i(" Thread ID "),o("div",null,[t[7]||(t[7]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," Thread ID ",-1)),o("div",Vi,b(e.thread.id),1)]),i(" Agent "),o("div",null,[o("div",Ai,[t[9]||(t[9]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Agent ",-1)),e.isAiHumanAgent&&!e.isEditingAgent?(s(),l("button",{key:0,onClick:e.startEditingAgent,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Change agent"},[S(e.PencilIcon,{size:12}),t[8]||(t[8]=o("span",null,"Change",-1))])):i("v-if",!0)]),e.isEditingAgent?(s(),l("div",ji,[S(e.SelectInput,{modelValue:e.selectedAgentId,"onUpdate:modelValue":t[1]||(t[1]=r=>e.selectedAgentId=r),options:e.aiHumanAgents,loading:e.isFetchingAgents,placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),o("div",Li,[o("button",{onClick:e.saveAgent,disabled:e.isSavingAgent||!e.selectedAgentId,class:"flex-1 px-3 py-2 text-sm bg-black dark:bg-white text-white dark:text-black hover:bg-black/80 dark:hover:bg-white/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},b(e.isSavingAgent?"Saving...":"Save"),9,Di),o("button",{onClick:e.cancelEditingAgent,disabled:e.isSavingAgent,class:"flex-1 px-3 py-2 text-sm border border-black dark:border-white hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Ui)])])):(s(),l("div",Pi,[o("div",Ei,b(e.thread.agent.title),1),o("div",Oi," Type: "+b(e.thread.agent.type),1)]))]),i(" Created At "),o("div",null,[t[10]||(t[10]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," Created ",-1)),o("div",qi,b(e.formatDate(e.thread.created_at)),1)]),i(" User ID "),e.thread.user_id?(s(),l("div",Ni,[t[11]||(t[11]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," User ID ",-1)),o("div",Bi,b(e.thread.user_id),1)])):i("v-if",!0),i(" Tags "),o("div",null,[o("div",Ri,[t[13]||(t[13]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Tags ",-1)),o("button",{onClick:t[2]||(t[2]=r=>e.emit("editThread")),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Edit thread"},[S(e.PencilIcon,{size:12}),t[12]||(t[12]=o("span",null,"Edit",-1))])]),e.thread.tags?.length>0?(s(),l("div",Fi,[(s(!0),l(W,null,ne(e.thread.tags,r=>(s(),l("span",{key:r,class:"inline-block px-3 py-1 text-sm rounded bg-black text-white dark:bg-white dark:text-black"},b(r),1))),128))])):(s(),l("div",zi," No tags "))]),i(" Cost Breakdown "),o("div",null,[o("div",Hi,[t[15]||(t[15]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Cost Analysis ",-1)),e.showCostBreakdown?(s(),l("button",{key:1,onClick:t[3]||(t[3]=r=>e.showCostBreakdown=!1),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Hide cost breakdown"},[...t[14]||(t[14]=[o("span",null,"Hide",-1)])])):(s(),l("button",{key:0,onClick:e.fetchCostBreakdown,disabled:e.isFetchingCost,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"View cost breakdown"},[S(e.DollarSignIcon,{size:12}),o("span",null,b(e.isFetchingCost?"Loading...":"View Costs"),1)],8,Wi))]),e.isFetchingCost?(s(),l("div",Ji,[S(e.Loader)])):e.showCostBreakdown&&e.costData?(s(),l("div",Ki,[i(" Summary Stats "),o("div",Zi,[o("div",Gi,[t[16]||(t[16]=o("div",{class:"text-gray-500 dark:text-gray-500 mb-1"},"Total Cost",-1)),o("div",Xi,b(e.formatCurrency(e.costData.totalCost)),1)]),o("div",Qi,[t[17]||(t[17]=o("div",{class:"text-gray-500 dark:text-gray-500 mb-1"},"Avg/Message",-1)),o("div",Yi,b(e.formatCurrency(e.costData.avgCostPerMessage)),1)])]),i(" Model Breakdown Table "),e.costData.modelBreakdown.length>0?(s(),l("div",$i,[t[19]||(t[19]=o("div",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"}," By Model ",-1)),o("div",ed,[o("table",td,[t[18]||(t[18]=o("thead",{class:"border-b border-gray-300 dark:border-gray-700"},[o("tr",null,[o("th",{class:"text-left py-2 pr-2 font-medium text-gray-600 dark:text-gray-400"},"Model"),o("th",{class:"text-right py-2 px-2 font-medium text-gray-600 dark:text-gray-400"},"Requests"),o("th",{class:"text-right py-2 px-2 font-medium text-gray-600 dark:text-gray-400"},"Total"),o("th",{class:"text-right py-2 pl-2 font-medium text-gray-600 dark:text-gray-400"},"Avg/Req")])],-1)),o("tbody",null,[(s(!0),l(W,null,ne(e.costData.modelBreakdown,r=>(s(),l("tr",{key:r.modelName,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("td",od,b(r.modelName),1),o("td",rd,b(r.requestCount),1),o("td",ad,b(e.formatCurrency(r.totalCost)),1),o("td",sd,b(e.formatCurrency(r.avgCostPerRequest)),1)]))),128))])])])])):(s(),l("div",ld," No cost data available for this thread "))])):i("v-if",!0)]),i(" Danger Zone "),o("div",nd,[t[20]||(t[20]=o("div",{class:"text-sm font-medium text-red-600 dark:text-red-400 mb-2"}," Danger Zone ",-1)),o("button",{onClick:t[4]||(t[4]=r=>e.showDeleteConfirm=!0),disabled:e.isDeleting,class:"flex items-center gap-2 px-3 py-2 text-sm bg-white dark:bg-black text-red-600 border-2 border-red-600 hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[S(e.Trash2Icon,{size:16}),e.isDeleting?(s(),l("span",dd,"Deleting...")):(s(),l("span",cd,"Delete Thread"))],8,id),t[21]||(t[21]=o("p",{class:"text-xs text-gray-500 dark:text-gray-500 mt-2"}," This will permanently delete the thread, all messages, and all logs. This action cannot be undone. ",-1))])])],2112)):i("v-if",!0):(s(),l("div",Si," Select a thread to view metadata "))]),i(" Delete Confirmation Dialog "),S(e.ConfirmDialog,{modelValue:e.showDeleteConfirm,"onUpdate:modelValue":t[5]||(t[5]=r=>e.showDeleteConfirm=r),title:"Delete Thread?",message:"Are you sure you want to delete this thread? This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete Thread","cancel-text":"Cancel",onConfirm:e.handleDeleteThread},null,8,["modelValue"])])}const pd=Q(yi,[["render",ud],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/MetaPane.vue"]]);function md(u,t){const{limit:a=100,offset:e=0,order:c="desc",autoFetch:d=!0,enableWebSocket:r=!1}=t||{};z(()=>!!(typeof u=="string"?u:u?.value));const n=z(()=>{const D=typeof u=="string"?u:u?.value;if(!D)return J("/api/threads/placeholder/logs");const E=new URLSearchParams,H=typeof a=="number"?a:a.value,R=typeof e=="number"?e:e.value,N=typeof c=="string"?c:c.value;return E.append("limit",H.toString()),E.append("offset",R.toString()),E.append("order",N),J(`/api/threads/${D}/logs?${E.toString()}`)}),{data:p,error:v,isFetching:g,isFinished:f,execute:h,abort:w}=ve(n,{immediate:!1}).get().json();oe([n,()=>d],([D,E])=>{D&&!D.includes("placeholder")&&E&&h()},{immediate:!0});const x=z(()=>!v.value||v.value.toString().includes("aborted")||v.value.toString().includes("abort")?null:v.value),k=z(()=>p.value?.logs||[]),C=z(()=>p.value?.total||0),y=z(()=>p.value?.hasMore||!1),_=m(null),I=m(!1),U=m(null),L=m([]),j=()=>{const D=typeof u=="string"?u:u?.value;if(!D||!r)return;_.value&&_.value.close(),L.value=[];const E=window.location.protocol==="https:"?"wss:":"ws:",H=window.location.host;let R=`${E}//${H}${J(`/api/threads/${D}/logs`)}`;const N=localStorage.getItem("auth_token");N&&(R+=`?token=${encodeURIComponent(N)}`);try{_.value=new WebSocket(R),_.value.onopen=()=>{I.value=!0,U.value=null,console.log("WebSocket connected for logs")},_.value.onmessage=Z=>{try{const G=JSON.parse(Z.data);if(G.type==="log_data"){const P=L.value.findIndex(T=>T.id===G.log_id),V=k.value.find(T=>T.id===G.log_id);P>=0?(L.value[P]={...L.value[P],...G.data},console.log("[WebSocket] Updated existing realtime log:",G.log_id)):V?(L.value.push({...V,...G.data}),console.log("[WebSocket] Updated HTTP log:",G.log_id)):(L.value.push({id:G.log_id,...G.data}),console.log("[WebSocket] Added new log:",G.log_id))}}catch(G){console.error("Failed to parse WebSocket message:",G)}},_.value.onerror=Z=>{U.value="WebSocket connection error",I.value=!1,console.error("WebSocket error:",Z)},_.value.onclose=()=>{I.value=!1,console.log("WebSocket disconnected")}}catch(Z){U.value=Z.message||"Failed to create WebSocket",console.error("WebSocket creation error:",Z)}},F=()=>{_.value&&(_.value.close(),_.value=null,I.value=!1),L.value=[]};return Te(()=>{F()}),{logs:z(()=>{if(!r)return k.value;const D=new Map;k.value.forEach(R=>D.set(R.id,R)),L.value.forEach(R=>D.set(R.id,R));const E=typeof c=="string"?c:c.value;return Array.from(D.values()).sort((R,N)=>E==="desc"?N.created_at-R.created_at:R.created_at-N.created_at)}),total:C,hasMore:y,error:x,isFetching:g,isFinished:f,refetch:h,abort:w,wsConnected:I,wsError:U,connectWebSocket:j,disconnectWebSocket:F}}function gd(u,t){const a=z(()=>{const n=u.value,p=t.value;return!n||!p?null:J(`/api/threads/${n}/logs/${p}`)}),{data:e,error:c,isFetching:d,execute:r}=ve(a,{immediate:!1}).get().json();return oe([u,t],([n,p])=>{n&&p&&r()},{immediate:!0}),{logDetails:e,error:c,isFetching:d,refetch:r}}const fd=$({__name:"CopyButton",props:{content:{type:String,required:!0},variant:{type:String,required:!1},size:{type:String,required:!1},disabled:{type:Boolean,required:!1}},setup(u,{expose:t}){t();const a=u,e=m(!1),c=m(!1),p={props:a,copying:e,copied:c,copyToClipboard:async()=>{e.value=!0;try{await navigator.clipboard.writeText(a.content),c.value=!0,setTimeout(()=>{c.value=!1},2e3)}catch(v){console.error("Failed to copy:",v),alert(`Failed to copy: ${v instanceof Error?v.message:"Unknown error"}`)}finally{e.value=!1}},sizeClasses:{xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},variantClasses:{solid:"bg-black text-white dark:bg-white dark:text-black",ghost:"bg-white dark:bg-gray-950 border border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-900"},Loader:De};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),hd=["disabled","title"],vd={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},bd={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},yd={key:3};function xd(u,t,a,e,c,d){return s(),l("button",{onClick:e.copyToClipboard,disabled:e.copying||a.disabled,class:ee([e.sizeClasses[a.size||"sm"],e.variantClasses[a.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:a.disabled?"No content to copy":e.copied?"Copied!":"Copy to clipboard"},[e.copying?(s(),X(e.Loader,{key:0,size:"xs"})):a.variant==="ghost"&&!e.copied?(s(),l("svg",vd,[...t[0]||(t[0]=[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):a.variant==="ghost"&&e.copied?(s(),l("svg",bd,[...t[1]||(t[1]=[o("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(s(),l("span",yd,b(e.copied?"Copied!":"Copy"),1))],10,hd)}const kd=Q(fd,[["render",xd],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/CopyButton.vue"]]),_d=$({__name:"LogDetails",props:{log:{type:null,required:!0}},emits:["close"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m("request"),r=m(new Set),n=m(new Set),p=m(!1),v=m(!1),g=m(null),f=j=>{if(!j)return"N/A";try{return JSON.stringify(JSON.parse(j),null,2)}catch{return j}},h=z(()=>{if(!e.log.tools_schema)return[];try{const j=JSON.parse(e.log.tools_schema);return Array.isArray(j)?j:[]}catch{return[]}}),w=z(()=>{if(!e.log.response_body)return[];try{const F=JSON.parse(e.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(F)?F:[]}catch{return[]}}),x=z(()=>{if(!e.log.tool_results)return new Map;try{const j=JSON.parse(e.log.tool_results),F=new Map;return Array.isArray(j)&&j.forEach(K=>{K.tool_call_id&&F.set(K.tool_call_id,{content:K.content,status:K.status,tool_name:K.tool_name,timestamp:K.timestamp})}),F}catch{return new Map}}),k=z(()=>{if(!e.log.response_body)return[];try{const F=JSON.parse(e.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(F)?F:[]}catch{return[]}}),C=j=>{r.value.has(j)?r.value.delete(j):r.value.add(j)},y=j=>{n.value.has(j)?n.value.delete(j):n.value.add(j)},_=z(()=>{if(!e.log.errors)return[];try{const j=JSON.parse(e.log.errors);return Array.isArray(j)?j:[]}catch{return[]}}),I=()=>{pe(()=>{g.value&&(g.value.scrollTop=g.value.scrollHeight)})};oe(()=>e.log.message_history,()=>{I()},{immediate:!0});const L={props:e,emit:c,activeTab:d,expandedTools:r,expandedToolCalls:n,copyingCurl:p,copiedCurl:v,messagesContainer:g,formatJson:f,tools:h,toolCallsDetailed:w,toolResults:x,reasoningDetails:k,toggleTool:C,toggleToolCall:y,errorsArray:_,scrollMessagesToBottom:I,copyCurlCommand:async()=>{p.value=!0;try{if(!e.log.request_body||!e.log.model)throw new Error("Missing request data");const j=await fetch(J(`/api/models/${e.log.model}/curl-data`));if(!j.ok)throw new Error("Failed to fetch model data");const F=await j.json(),K=f(e.log.request_body);let D=`curl -X POST '${F.endpoint}' \\
1
+ import{m as ge,c as l,o as s,a as ot,b as o,d as $,u as Pe,e as Le,f as z,r as m,g as ce,h as Te,i,j as X,F as W,k as ne,n as ee,t as b,w as he,l as S,p as He,R as Yt,q as ie,s as Be,v as oe,x as pe,y as ae,T as We,z as st,A as fe,B as _e,C as $t,D as ve,E as Ze,L as _t,G as wt,H as eo,I as to,J as oo,M as Ct,K as ro,P as ao,N as St,O as Ne,Q as so,S as Tt,U as lo,V as rt,W as Se,X as Ee,Y as no,Z as io,_ as lt,$ as Mt,a0 as It,a1 as co,a2 as uo,a3 as po,a4 as mo}from"./vue.js";import{W as go,a as fo,e as gt}from"./monaco.js";import"./vendor.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))e(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const r of d.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&e(r)}).observe(document,{childList:!0,subtree:!0});function a(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function e(c){if(c.ep)return;c.ep=!0;const d=a(c);fetch(c.href,d)}})();const ho={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function vo(u,t){return s(),l("svg",ho,[...t[0]||(t[0]=[ot('<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></g>',1)])])}const bo=ge({name:"lucide-layout-dashboard",render:vo}),yo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xo(u,t){return s(),l("svg",yo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 8V4H8"}),o("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),o("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const ko=ge({name:"lucide-bot",render:xo}),_o={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wo(u,t){return s(),l("svg",_o,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"},null,-1)])])}const ft=ge({name:"lucide-message-square",render:wo}),Co={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function So(u,t){return s(),l("svg",Co,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),o("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),o("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const To=ge({name:"lucide-cpu",render:So}),Mo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Io(u,t){return s(),l("svg",Mo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),o("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),o("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Vo=ge({name:"lucide-server",render:Io}),Ao={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Po(u,t){return s(),l("svg",Ao,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"},null,-1)])])}const Eo=ge({name:"lucide-wrench",render:Po}),Oo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function jo(u,t){return s(),l("svg",Oo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0a2.34 2.34 0 0 0 3.319 1.915a2.34 2.34 0 0 1 2.33 4.033a2.34 2.34 0 0 0 0 3.831a2.34 2.34 0 0 1-2.33 4.033a2.34 2.34 0 0 0-3.319 1.915a2.34 2.34 0 0 1-4.659 0a2.34 2.34 0 0 0-3.32-1.915a2.34 2.34 0 0 1-2.33-4.033a2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}),o("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Lo=ge({name:"lucide-settings",render:jo}),Do={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Uo(u,t){return s(),l("svg",Do,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5h16M4 12h16M4 19h16"},null,-1)])])}const qo=ge({name:"lucide-menu",render:Uo}),No={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bo(u,t){return s(),l("svg",No,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Ro=ge({name:"lucide-chevron-left",render:Bo}),Fo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function zo(u,t){return s(),l("svg",Fo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})],-1)])])}const Ho=ge({name:"lucide-sun",render:zo}),Wo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Jo(u,t){return s(),l("svg",Wo,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"},null,-1)])])}const Ko=ge({name:"lucide-moon",render:Jo}),Zo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Go(u,t){return s(),l("svg",Zo,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"},null,-1)])])}const Xo=ge({name:"lucide-activity",render:Go}),Qo={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yo(u,t){return s(),l("svg",Qo,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),o("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3m-6 4.2h5.7"})],-1)])])}const $o=ge({name:"lucide-function-square",render:Yo}),er={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function tr(u,t){return s(),l("svg",er,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 22v-5M9 8V2m6 6V2m3 6v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"},null,-1)])])}const or=ge({name:"lucide-plug",render:tr}),rr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ar(u,t){return s(),l("svg",rr,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 17l5-5l-5-5m5 5H9m0 9H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"},null,-1)])])}const sr=ge({name:"lucide-log-out",render:ar}),lr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nr(u,t){return s(),l("svg",lr,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3.128a4 4 0 0 1 0 7.744M22 21v-2a4 4 0 0 0-3-3.87"}),o("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const ir=ge({name:"lucide-users",render:nr}),dr={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cr(u,t){return s(),l("svg",dr,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"m15.5 7.5l2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4m2-2l-9.6 9.6"}),o("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const ur=ge({name:"lucide-key",render:cr}),pr=$({__name:"Sidebar",props:{isCollapsed:{type:Boolean,required:!0},isDark:{type:Boolean,required:!0}},emits:["toggle-sidebar","toggle-theme"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Pe(),r=Le(),n=z(()=>d.name),p=[{id:"dashboard",label:"Dashboard",icon:bo,path:"/"},{id:"threads",label:"Threads",icon:Xo,path:"/threads"},{id:"agents",label:"Agents",icon:ko,path:"/agents"},{id:"prompts",label:"Prompts",icon:ft,path:"/prompts"},{id:"tools",label:"Tools",icon:Eo,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:$o,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:ft,path:"/tools#prompts"},{id:"tools-mcp",label:"MCP",icon:or,path:"/tools#mcp"}]},{id:"models",label:"Models",icon:To,path:"/models"},{id:"providers",label:"Providers",icon:Vo,path:"/providers"}],v=y=>{r.push(y)},g=z(()=>typeof n.value=="string"&&(n.value==="tools"||n.value.startsWith("tools-"))),f=m(!1),h=z(()=>n.value==="users"||n.value==="api-keys"),w=()=>{f.value=!f.value},x=()=>{localStorage.removeItem("auth_token"),r.push("/login")},k=y=>{const _=y.target;f.value&&!_.closest(".settings-menu-container")&&(f.value=!1)};ce(()=>{document.addEventListener("click",k)}),Te(()=>{document.removeEventListener("click",k)});const C={props:e,emit:c,route:d,router:r,activeRoute:n,navItems:p,navigateTo:v,isToolsActive:g,showSettingsMenu:f,isSettingsActive:h,toggleSettingsMenu:w,handleLogout:x,handleClickOutside:k,get IconSettings(){return Lo},get IconMenu(){return qo},get IconChevronLeft(){return Ro},get IconSun(){return Ho},get IconMoon(){return Ko},get IconLogOut(){return sr},get IconUsers(){return ir},get IconKey(){return ur}};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),Q=(u,t)=>{const a=u.__vccOpts||u;for(const[e,c]of t)a[e]=c;return a},mr={class:"p-4 border-b border-gray-300 dark:border-gray-700 flex items-center justify-between"},gr={key:0,class:"text-xl font-bold"},fr={class:"flex-1 flex flex-col justify-between py-4"},hr={class:"flex flex-col gap-1 px-2"},vr={key:0},br=["onClick","title"],yr={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},xr={key:0,class:"ml-4 space-y-0.5"},kr=["onClick"],_r={class:"whitespace-nowrap overflow-hidden text-ellipsis"},wr=["onClick","title"],Cr={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Sr={class:"flex flex-col gap-1 px-2"},Tr=["title"],Mr={key:2,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Ir={class:"relative settings-menu-container"},Vr=["title"],Ar={key:0,class:"flex-1 text-left whitespace-nowrap overflow-hidden text-ellipsis"},Pr={key:0,class:"absolute left-full ml-2 bottom-0 bg-white dark:bg-black border border-black dark:border-white rounded shadow-lg py-2 min-w-[160px] z-50"},Er=["title"],Or={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"};function jr(u,t,a,e,c,d){return s(),l("aside",{class:ee(["flex flex-col border-r border-black dark:border-white transition-all duration-300",a.isCollapsed?"w-16":"w-60"])},[o("div",mr,[a.isCollapsed?i("v-if",!0):(s(),l("h2",gr,"AgentBuilder")),o("button",{onClick:t[0]||(t[0]=r=>u.$emit("toggle-sidebar")),class:"p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors","aria-label":"Toggle sidebar"},[a.isCollapsed?(s(),X(e.IconMenu,{key:1,class:"w-5 h-5"})):(s(),X(e.IconChevronLeft,{key:0,class:"w-5 h-5"}))])]),o("nav",fr,[o("div",hr,[(s(),l(W,null,ne(e.navItems,r=>(s(),l(W,{key:r.id},[r.hasSubnav?(s(),l("div",vr,[i(" Main Tools button "),o("button",{onClick:n=>e.navigateTo(r.path),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",e.isToolsActive?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?r.label:void 0},[(s(),X(He(r.icon),{class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",yr,b(r.label),1))],10,br),i(" Tools subnav "),!a.isCollapsed&&r.subnav?(s(),l("div",xr,[(s(!0),l(W,null,ne(r.subnav,n=>(s(),l("button",{key:n.id,onClick:p=>e.navigateTo(n.path),class:ee(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",e.activeRoute===n.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(s(),X(He(n.icon),{class:"w-4 h-4 flex-shrink-0"})),o("span",_r,b(n.label),1)],10,kr))),128))])):i("v-if",!0)])):(s(),l("button",{key:1,onClick:n=>e.navigateTo(r.path),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",e.activeRoute===r.id?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?r.label:void 0},[(s(),X(He(r.icon),{class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",Cr,b(r.label),1))],10,wr))],64))),64))]),o("div",Sr,[o("button",{onClick:t[1]||(t[1]=r=>u.$emit("toggle-theme")),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all","hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Toggle theme":void 0},[a.isDark?(s(),X(e.IconMoon,{key:1,class:"w-5 h-5 flex-shrink-0"})):(s(),X(e.IconSun,{key:0,class:"w-5 h-5 flex-shrink-0"})),a.isCollapsed?i("v-if",!0):(s(),l("span",Mr,b(a.isDark?"Dark Mode":"Light Mode"),1))],10,Tr),i(" Settings Menu "),o("div",Ir,[o("button",{onClick:he(e.toggleSettingsMenu,["stop"]),class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",e.isSettingsActive?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Settings":void 0},[S(e.IconSettings,{class:"w-5 h-5 flex-shrink-0"}),a.isCollapsed?i("v-if",!0):(s(),l("span",Ar," Settings "))],10,Vr),i(" Settings Popover Menu "),e.showSettingsMenu?(s(),l("div",Pr,[o("button",{onClick:t[2]||(t[2]=r=>{e.navigateTo("/settings/users"),e.showSettingsMenu=!1}),class:ee(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",e.activeRoute==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[S(e.IconUsers,{class:"w-4 h-4 flex-shrink-0"}),t[4]||(t[4]=o("span",{class:"whitespace-nowrap"},"Users",-1))],2),o("button",{onClick:t[3]||(t[3]=r=>{e.navigateTo("/settings/api-keys"),e.showSettingsMenu=!1}),class:ee(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",e.activeRoute==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[S(e.IconKey,{class:"w-4 h-4 flex-shrink-0"}),t[5]||(t[5]=o("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)])):i("v-if",!0)]),o("button",{onClick:e.handleLogout,class:ee(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all","hover:bg-red-500/10 dark:hover:bg-red-500/10 text-red-600 dark:text-red-400",a.isCollapsed&&"justify-center"]),title:a.isCollapsed?"Logout":void 0},[S(e.IconLogOut,{class:"w-5 h-5 flex-shrink-0"}),a.isCollapsed?i("v-if",!0):(s(),l("span",Or," Logout "))],10,Er)])])],2)}const Lr=Q(pr,[["render",jr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Sidebar.vue"]]);function Dr(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function Ge(){return Dr().mountPoint}function J(u){const t=Ge(),a=u.startsWith("/")?u:`/${u}`;return t==="/"?a:`${t}${a}`}const Ur=$({__name:"WarningBanner",setup(u,{expose:t}){t();const a=m([]),e=m(new Set),c=async()=>{if(localStorage.getItem("auth_token"))try{const g=await fetch(J("/api/diagnostics"));if(g.ok){const f=await g.json();a.value=f.warnings||[]}}catch{}},d=v=>{const g=`${v.type}:${v.details?.name||v.message}`;e.value.add(g)},r=v=>{const g=`${v.type}:${v.details?.name||v.message}`;return!e.value.has(g)},n=v=>{if(v.type==="duplicate_tool_name"){const g=v.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${v.details?.name}" (defined as both ${g}). This may cause unexpected behavior.`}return v.message};ce(()=>{c()});const p={warnings:a,dismissed:e,fetchWarnings:c,dismiss:d,isVisible:r,formatWarning:n};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),qr={class:"warning-banner-container"},Nr={key:0,class:"warning-banner flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-900/30 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200 text-sm"},Br={class:"flex items-center gap-2"},Rr=["onClick"];function Fr(u,t,a,e,c,d){return s(),l("div",qr,[(s(!0),l(W,null,ne(e.warnings,r=>(s(),l(W,{key:`${r.type}:${r.details?.name}`},[e.isVisible(r)?(s(),l("div",Nr,[o("div",Br,[t[0]||(t[0]=o("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z","clip-rule":"evenodd"})],-1)),o("span",null,b(e.formatWarning(r)),1)]),o("button",{onClick:n=>e.dismiss(r),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...t[1]||(t[1]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])],8,Rr)])):i("v-if",!0)],64))),128))])}const zr=Q(Ur,[["render",Fr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/WarningBanner.vue"]]),Hr=$({__name:"App",setup(u,{expose:t}){t();const a=Pe(),e=m(!1),c=m(!1),d=z(()=>a.name!=="login"),r=()=>{e.value=!e.value},n=()=>{c.value=!c.value,c.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};ce(()=>{const v=localStorage.getItem("theme");(v==="dark"||!v&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(c.value=!0,document.documentElement.classList.add("dark"))});const p={route:a,isCollapsed:e,isDark:c,showSidebar:d,toggleSidebar:r,toggleTheme:n,get RouterView(){return Yt},Sidebar:Lr,WarningBanner:zr};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),Wr={class:"flex h-screen font-sans bg-white text-black dark:bg-black dark:text-white"},Jr={class:"flex-1 overflow-auto bg-white dark:bg-black flex flex-col"},Kr={class:"flex-1 overflow-auto"};function Zr(u,t,a,e,c,d){return s(),l("div",Wr,[e.showSidebar?(s(),X(e.Sidebar,{key:0,"is-collapsed":e.isCollapsed,"is-dark":e.isDark,onToggleSidebar:e.toggleSidebar,onToggleTheme:e.toggleTheme},null,8,["is-collapsed","is-dark"])):i("v-if",!0),o("main",Jr,[e.showSidebar?(s(),X(e.WarningBanner,{key:0})):i("v-if",!0),o("div",Kr,[S(e.RouterView)])])])}const Gr=Q(Hr,[["render",Zr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/App.vue"]]),Xr={},Qr={class:"p-8"};function Yr(u,t){return s(),l("div",Qr,[...t[0]||(t[0]=[o("h1",{class:"text-3xl font-bold mb-4"},"Dashboard",-1),o("p",{class:"text-gray-600 dark:text-gray-400"},"Welcome to Agent Kit. Monitor and manage your AI agents from here.",-1)])])}const $r=Q(Xr,[["render",Yr],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/DashboardView.vue"]]),ea={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ta(u,t){return s(),l("svg",ea,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])])}const oa=ge({name:"lucide-trash-2",render:ta}),ra={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function aa(u,t){return s(),l("svg",ra,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),o("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})],-1)])])}const sa=ge({name:"lucide-edit",render:aa}),la={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function na(u,t){return s(),l("svg",la,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),o("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Vt=ge({name:"lucide-eye",render:na}),ia=$({__name:"DataTable",props:{columns:{type:Array,required:!0},data:{type:Array,required:!0},actions:{type:Array,required:!1},emptyMessage:{type:String,required:!1,default:"No data available"},loading:{type:Boolean,required:!1,default:!1}},setup(u,{expose:t}){t();const n={props:u,getIcon:p=>{switch(p){case"edit":return sa;case"delete":return oa;case"view":return Vt;default:return null}},getCellValue:(p,v)=>{const g=p[v.key];return v.formatter?v.formatter(g):g??"-"},getCellAlignment:p=>{switch(p){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},handleAction:(p,v)=>{if(p.confirm){const g=p.confirmMessage||`Are you sure you want to ${p.label.toLowerCase()}?`;confirm(g)&&p.handler(v)}else p.handler(v)}};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),da={class:"w-full"},ca={class:"border border-black dark:border-white rounded overflow-hidden"},ua={class:"overflow-x-auto"},pa={class:"w-full"},ma={class:"border-b border-black dark:border-white"},ga={key:0,class:"px-4 py-3 text-right font-medium text-sm"},fa={key:0},ha=["colspan"],va=["colspan"],ba=["innerHTML"],ya={key:0,class:"px-4 py-3 text-right"},xa={class:"inline-flex gap-1"},ka=["onClick","title"];function _a(u,t,a,e,c,d){return s(),l("div",da,[o("div",ca,[o("div",ua,[o("table",pa,[o("thead",ma,[o("tr",null,[(s(!0),l(W,null,ne(a.columns,r=>(s(),l("th",{key:r.key,class:ee(["px-4 py-3 font-medium text-sm",e.getCellAlignment(r.align),r.width||""])},b(r.label),3))),128)),a.actions&&a.actions.length>0?(s(),l("th",ga," Actions ")):i("v-if",!0)])]),o("tbody",null,[i(" Loading state "),a.loading?(s(),l("tr",fa,[o("td",{colspan:a.columns.length+(a.actions?1:0),class:"px-4 py-8 text-center text-gray-500"},[...t[0]||(t[0]=[o("div",{class:"inline-flex items-center gap-2"},[o("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),ie(" Loading... ")],-1)])],8,ha)])):a.data.length===0?(s(),l(W,{key:1},[i(" Empty state "),o("tr",null,[o("td",{colspan:a.columns.length+(a.actions?1:0),class:"px-4 py-8 text-center text-gray-500"},b(a.emptyMessage),9,va)])],2112)):(s(),l(W,{key:2},[i(" Data rows "),(s(!0),l(W,null,ne(a.data,(r,n)=>(s(),l("tr",{key:n,class:"border-t border-gray-200 dark:border-gray-800 hover:bg-black/5 dark:hover:bg-white/5 transition-colors"},[(s(!0),l(W,null,ne(a.columns,p=>(s(),l("td",{key:p.key,class:ee(["px-4 py-3 text-sm",e.getCellAlignment(p.align)])},[Be(u.$slots,`cell-${p.key}`,{value:r[p.key],row:r,column:p},()=>[p.html?(s(),l("span",{key:0,innerHTML:e.getCellValue(r,p)},null,8,ba)):(s(),l(W,{key:1},[ie(b(e.getCellValue(r,p)),1)],64))])],2))),128)),a.actions&&a.actions.length>0?(s(),l("td",ya,[o("div",xa,[(s(!0),l(W,null,ne(a.actions,(p,v)=>(s(),l("button",{key:v,onClick:g=>e.handleAction(p,r),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:p.label},[(s(),X(He(e.getIcon(p.icon)),{class:"w-4 h-4"}))],8,ka))),128))])])):i("v-if",!0)]))),128))],2112))])])])])])}const Oe=Q(ia,[["render",_a],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/DataTable.vue"]]),wa=$({__name:"AgentsDataTable",emits:["add","edit","delete"],setup(u,{expose:t,emit:a}){const e=a,c=m([]),d=m(!1),r=[{key:"title",label:"Title",width:"w-1/5"},{key:"type",label:"Type",width:"w-1/12",formatter:f=>f==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:f=>f||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:f=>f||"Human"},{key:"created_at",label:"Created",width:"w-1/6",formatter:f=>f?new Date(f*1e3).toLocaleDateString():"-"}],n=[{icon:"edit",label:"Edit",handler:f=>e("edit",f)},{icon:"delete",label:"Delete",handler:async f=>{await v(f)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?"}],p=async()=>{d.value=!0;try{const f=await fetch(J("/api/agents"));if(f.ok){const h=await f.json();c.value=h.agents||[]}}catch(f){console.error("Error fetching agents:",f)}finally{d.value=!1}},v=async f=>{try{const h=await fetch(J(`/api/agents/${f.id}`),{method:"DELETE"});if(h.ok)await p();else{const w=await h.json();alert(w.error||"Failed to delete agent")}}catch(h){console.error("Error deleting agent:",h),alert("Failed to delete agent")}};ce(()=>{p()}),t({refresh:p});const g={emit:e,agents:c,loading:d,columns:r,actions:n,fetchAgents:p,deleteAgent:v,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}});function Ca(u,t,a,e,c,d){return s(),l("div",null,[S(e.DataTable,{columns:e.columns,data:e.agents,actions:e.actions,loading:e.loading,"empty-message":"No agents available. Create your first agent to get started."},null,8,["data","loading"])])}const Sa=Q(wa,[["render",Ca],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AgentsDataTable.vue"]]),Ta=$({__name:"DropShadow",props:{offsetX:{type:Number,required:!1,default:8},offsetY:{type:Number,required:!1,default:8},intensity:{type:Number,required:!1,default:.5},pattern:{type:String,required:!1,default:"crosshatch"}},setup(u,{expose:t}){t();const a=u,e=m(),c=m(),d=m(),r=async()=>{if(await pe(),!e.value||!c.value||!d.value)return;const g=e.value.getContext("2d");if(!g)return;const f=d.value.getBoundingClientRect(),h=f.width+a.offsetX+4,w=f.height+a.offsetY+4;e.value.width=h,e.value.height=w,e.value.style.width=`${h}px`,e.value.style.height=`${w}px`,g.clearRect(0,0,e.value.width,e.value.height);const x=document.documentElement.classList.contains("dark");if(g.fillStyle=x?"#6b7280":"black",g.globalAlpha=a.intensity,a.pattern==="crosshatch"){const k=x?4:3;g.lineWidth=1,g.strokeStyle=x?"#6b7280":"black";for(let C=-f.height;C<f.width;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY),g.lineTo(a.offsetX+C+f.height,a.offsetY+f.height),g.stroke();for(let C=0;C<f.width+f.height;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY+f.height),g.lineTo(a.offsetX+C-f.height,a.offsetY),g.stroke()}else if(a.pattern==="dots"){const C=x?3:2,y=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let _=0;_<f.width;_+=C)for(let V=0;V<f.height;V+=C){const U=Math.floor(_/C)%4,L=Math.floor(V/C)%4;y[L][U]/16<a.intensity&&g.fillRect(a.offsetX+_,a.offsetY+V,1,1)}}else if(a.pattern==="diagonal"){const k=x?5:4;g.lineWidth=1,g.strokeStyle=x?"#6b7280":"black";for(let C=-f.height;C<f.width;C+=k)g.beginPath(),g.moveTo(a.offsetX+C,a.offsetY),g.lineTo(a.offsetX+C+f.height,a.offsetY+f.height),g.stroke()}};let n=null,p=null;ce(()=>{n=new ResizeObserver(()=>{r()}),d.value&&n.observe(d.value),r(),p=new MutationObserver(()=>{r()}),p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),Te(()=>{d.value&&n&&n.unobserve(d.value),p&&p.disconnect()}),oe(()=>[a.offsetX,a.offsetY,a.intensity,a.pattern],()=>{r()});const v={props:a,canvas:e,container:c,contentEl:d,drawDitheredShadow:r,get resizeObserver(){return n},set resizeObserver(g){n=g},get mutationObserver(){return p},set mutationObserver(g){p=g}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),Ma={ref:"container",class:"relative"},Ia={ref:"canvas",class:"absolute top-0 left-0 pointer-events-none"},Va={ref:"contentEl",class:"relative"};function Aa(u,t,a,e,c,d){return s(),l("div",Ma,[o("canvas",Ia,null,512),o("div",Va,[Be(u.$slots,"default")],512)],512)}const Re=Q(Ta,[["render",Aa],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/DropShadow.vue"]]),Pa={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ea(u,t){return s(),l("svg",Pa,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const At=ge({name:"lucide-x",render:Ea}),Oa=$({__name:"ConfirmDialog",props:{modelValue:{type:Boolean,required:!0},title:{type:String,required:!1,default:"Confirm Action"},message:{type:String,required:!1,default:"Are you sure you want to continue? You will lose any unsaved changes."},confirmText:{type:String,required:!1,default:"Continue"},cancelText:{type:String,required:!1,default:"Cancel"}},emits:["update:modelValue","confirm","cancel"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=()=>{c("update:modelValue",!1)},r=()=>{c("confirm"),d()},n=()=>{c("cancel"),d()},p=g=>{g.key==="Escape"&&e.modelValue&&n()};oe(()=>e.modelValue,g=>{g?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")});const v={props:e,emit:c,close:d,handleConfirm:r,handleCancel:n,handleKeydown:p,DropShadow:Re,get IconX(){return At}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),ja={key:0,class:"w-full max-w-md"},La={class:"flex items-center justify-between p-4 border-b-2 border-red-600 flex-shrink-0"},Da={class:"text-xl font-bold text-red-600"},Ua={class:"p-6"},qa={class:"text-gray-700 dark:text-gray-300 mb-6"},Na={class:"flex justify-end gap-3"};function Ba(u,t,a,e,c,d){return s(),X(st,{to:"body"},[S(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onClick:e.handleCancel},[S(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ae(()=>[a.modelValue?(s(),l("div",ja,[S(e.DropShadow,{"offset-x":12,"offset-y":12,intensity:.4},{default:ae(()=>[o("div",{class:"bg-white dark:bg-black border-2 border-red-600 flex flex-col",onClick:t[0]||(t[0]=he(()=>{},["stop"]))},[i(" Header "),o("div",La,[o("h2",Da,b(a.title),1),o("button",{onClick:e.handleCancel,class:"p-1 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors","aria-label":"Close dialog"},[S(e.IconX,{class:"w-5 h-5 text-red-600"})])]),i(" Content "),o("div",Ua,[o("p",qa,b(a.message),1),o("div",Na,[o("button",{onClick:e.handleCancel,class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors"},b(a.cancelText),1),o("button",{onClick:e.handleConfirm,class:"px-4 py-2 border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700 transition-colors"},b(a.confirmText),1)])])])]),_:1})])):i("v-if",!0)]),_:1})])):i("v-if",!0)]),_:1})])}const Pt=Q(Oa,[["render",Ba],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ConfirmDialog.vue"]]),Ra=$({__name:"Modal",props:{modelValue:{type:Boolean,required:!0},title:{type:String,required:!1},width:{type:String,required:!1,default:"max-w-lg"},minHeight:{type:String,required:!1,default:"min-h-[24rem]"},hasChanges:{type:Boolean,required:!1,default:void 0}},emits:["update:modelValue","close"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(),r=m(!1),n=m(new Map),p=()=>d.value&&(d.value.querySelector("input")||d.value.querySelector("textarea")||d.value.querySelector("select")||d.value.querySelector("[contenteditable]")||d.value.querySelector(".monaco-editor")),v=()=>{if(!d.value)return;d.value.querySelectorAll(".monaco-editor-container").forEach(j=>{const F=j.__monacoEditor;if(F&&typeof F.getValue=="function"){const K=F.getValue();n.value.set(j,K)}})},g=()=>{if(!d.value)return!1;const L=d.value.querySelectorAll(".monaco-editor-container");for(const j of L){const F=j.__monacoEditor;if(F&&typeof F.getValue=="function"){const K=F.getValue(),D=n.value.get(j);if(D===void 0||(F.getRawOptions?.()||{}).readOnly===!0)continue;if(K!==D)return!0}}return!1},f=()=>{if(e.hasChanges!==void 0)return e.hasChanges;if(!d.value)return!1;if(g())return!0;const L=d.value.querySelectorAll("form");for(const F of L){const D=F.querySelectorAll("input, textarea, select");for(const E of D){const H=E;if(H.type==="checkbox"||H.type==="radio"){const R=H;if(R.checked!==R.defaultChecked)return!0}else if(H.tagName==="SELECT"){const R=H;if(R.value!==R.defaultValue)return!0}else if(H.value!==H.defaultValue)return!0}}const j=d.value.querySelectorAll("input:not(form input), textarea:not(form textarea), select:not(form select)");for(const F of j){const K=F;if(K.type==="checkbox"||K.type==="radio"){const D=K;if(D.checked!==D.defaultChecked)return!0}else if(K.tagName==="SELECT"){const D=K;if(D.value!==D.defaultValue)return!0}else if(K.value!==K.defaultValue)return!0}return!1},h=()=>{p()&&f()?r.value=!0:w()},w=()=>{c("update:modelValue",!1),c("close")},x=()=>{r.value=!1,w()},k=()=>{r.value=!1},C=L=>{L.key==="Escape"&&e.modelValue&&(p()||w())};oe(()=>e.modelValue,async L=>{L?(document.addEventListener("keydown",C),document.body.style.overflow="hidden",await pe(),setTimeout(()=>{v()},100)):(document.removeEventListener("keydown",C),document.body.style.overflow="",n.value.clear())});const y=m(!1),U={props:e,emit:c,modalRef:d,showConfirmDialog:r,monacoInitialValues:n,hasFormFields:p,captureMonacoInitialValues:v,hasMonacoChanges:g,hasUnsavedChanges:f,attemptClose:h,close:w,handleConfirmClose:x,handleCancelClose:k,handleKeydown:C,mouseDownOnBackdrop:y,handleBackdropMouseDown:L=>{y.value=L.target===L.currentTarget},handleBackdropClick:L=>{L.target===L.currentTarget&&y.value&&(p()||w()),y.value=!1},DropShadow:Re,ConfirmDialog:Pt,get IconX(){return At}};return Object.defineProperty(U,"__isScriptSetup",{enumerable:!1,value:!0}),U}}),Fa={class:"flex items-center justify-between p-4 border-b-2 border-black dark:border-white flex-shrink-0"},za={class:"text-xl font-bold"},Ha={class:"overflow-y-auto flex-1"},Wa={class:"p-6"},Ja={key:0,class:"p-6 border-t-2 border-black dark:border-white flex-shrink-0"};function Ka(u,t,a,e,c,d){return s(),X(st,{to:"body"},[S(We,{"enter-active-class":"transition-opacity duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-opacity duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-white/80 dark:bg-black/80 backdrop-blur-sm dark:text-white",onMousedown:e.handleBackdropMouseDown,onClick:e.handleBackdropClick},[S(We,{"enter-active-class":"transition-all duration-200","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition-all duration-200","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:ae(()=>[a.modelValue?(s(),l("div",{key:0,class:ee(["w-full",a.width,"max-h-[85vh] flex flex-col"])},[S(e.DropShadow,{"offset-x":12,"offset-y":12,intensity:.4},{default:ae(()=>[o("div",{ref:"modalRef",class:ee(["bg-white dark:bg-black border-2 border-black dark:border-white flex flex-col max-h-[85vh]",a.minHeight])},[i(" Header (fixed) "),o("div",Fa,[o("h2",za,b(a.title),1),o("button",{onClick:e.attemptClose,class:"p-1 hover:bg-black/5 dark:hover:bg-white/10 rounded transition-colors","aria-label":"Close modal"},[S(e.IconX,{class:"w-5 h-5"})])]),i(" Content (scrollable) "),o("div",Ha,[o("div",Wa,[Be(u.$slots,"default")])]),i(" Footer (fixed, optional) "),u.$slots.footer?(s(),l("div",Ja,[Be(u.$slots,"footer")])):i("v-if",!0)],2)]),_:3})],2)):i("v-if",!0)]),_:3})],32)):i("v-if",!0)]),_:3}),i(" Confirmation dialog for unsaved changes "),S(e.ConfirmDialog,{modelValue:e.showConfirmDialog,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showConfirmDialog=r),title:"Unsaved Changes",message:"You have unsaved changes that will be lost. Are you sure you want to close?","confirm-text":"Close Anyway","cancel-text":"Keep Editing",onConfirm:e.handleConfirmClose,onCancel:e.handleCancelClose},null,8,["modelValue"])])}const Ve=Q(Ra,[["render",Ka],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Modal.vue"]]),Za=$({__name:"TextInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},type:{type:String,required:!1,default:"text"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue","focus","click"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(null),r=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n=f=>{const h=f.target;c("update:modelValue",h.value)},p=f=>{c("focus",f)},v=f=>{c("click",f)};t({inputRef:d});const g={props:e,emit:c,inputRef:d,inputClasses:r,handleInput:n,handleFocus:p,handleClick:v};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),Ga={class:"space-y-1"},Xa={key:0,class:"block text-sm font-medium"},Qa={key:0,class:"text-red-500"},Ya=["type","value","placeholder","disabled"],$a={key:1,class:"text-xs text-red-500 dark:text-red-400"};function es(u,t,a,e,c,d){return s(),l("div",Ga,[a.label?(s(),l("label",Xa,[ie(b(a.label)+" ",1),a.required?(s(),l("span",Qa,"*")):i("v-if",!0)])):i("v-if",!0),o("input",{ref:"inputRef",type:a.type,value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,class:ee(e.inputClasses),onInput:e.handleInput,onFocus:e.handleFocus,onClick:e.handleClick},null,42,Ya),a.error?(s(),l("p",$a,b(a.error),1)):i("v-if",!0)])}const je=Q(Za,[["render",es],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/TextInput.vue"]]),ts=$({__name:"TextareaInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},rows:{type:Number,required:!1,default:4}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-y",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n={props:e,emit:c,textareaClasses:d,handleInput:p=>{const v=p.target;c("update:modelValue",v.value)}};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),os={class:"space-y-1"},rs={key:0,class:"block text-sm font-medium"},as={key:0,class:"text-red-500"},ss=["value","placeholder","disabled","rows"],ls={key:1,class:"text-xs text-red-500 dark:text-red-400"};function ns(u,t,a,e,c,d){return s(),l("div",os,[a.label?(s(),l("label",rs,[ie(b(a.label)+" ",1),a.required?(s(),l("span",as,"*")):i("v-if",!0)])):i("v-if",!0),o("textarea",{value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,class:ee(e.textareaClasses),onInput:e.handleInput},null,42,ss),a.error?(s(),l("p",ls,b(a.error),1)):i("v-if",!0)])}const Et=Q(ts,[["render",ns],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/TextareaInput.vue"]]),is=$({__name:"SelectInput",props:{modelValue:{type:String,required:!1},options:{type:Array,required:!0},placeholder:{type:String,required:!1,default:"Select an option"},searchPlaceholder:{type:String,required:!1,default:"Search..."},label:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(!1),r=m(""),n=m(),p=m(),v=m(),g=m(),f=m(-1),h=z(()=>e.options.find(E=>E.value===e.modelValue)),w=z(()=>["w-full px-3 py-2 text-left rounded focus:outline-none focus:ring-2 bg-white dark:bg-black disabled:opacity-50 disabled:cursor-not-allowed font-mono text-sm overflow-hidden",e.error?"border border-red-500 dark:border-red-400 focus:ring-red-500 dark:focus:ring-red-400":"border border-black dark:border-white focus:ring-black dark:focus:ring-white"]),x=z(()=>{if(!r.value)return e.options;const E=r.value.toLowerCase();return e.options.filter(H=>H.label.toLowerCase().includes(E)||H.value.toLowerCase().includes(E)||H.description&&H.description.toLowerCase().includes(E))});oe(x,()=>{f.value=-1});const k=()=>{e.disabled||(d.value?_():(d.value=!0,r.value="",f.value=-1,pe(()=>{if(g.value&&(g.value.setAttribute("popover","auto"),g.value.addEventListener("toggle",K),"showPopover"in g.value))try{g.value.showPopover()}catch{}V(),setTimeout(()=>n.value?.focus(),0)})))},C=E=>{c("update:modelValue",E.value),_(),r.value="",f.value=-1},y=E=>{E.stopPropagation(),c("update:modelValue","")},_=()=>{if(g.value){if("hidePopover"in g.value)try{g.value.hidePopover()}catch{}g.value.removeEventListener("toggle",K)}d.value=!1,f.value=-1},V=()=>{if(!v.value||!g.value)return;const E=v.value.getBoundingClientRect();g.value.offsetWidth||E.width,g.value.style.position="fixed",g.value.style.top=`${E.bottom+8}px`,g.value.style.left=`${E.left}px`,g.value.style.width=`${E.width}px`,g.value.style.margin="0"},U=E=>{p.value&&!p.value.contains(E.target)&&g.value&&!g.value.contains(E.target)&&_()},L=E=>{E.key==="Escape"&&d.value&&(_(),v.value?.focus())},j=E=>{if(!d.value)return;const H=x.value;if(H.length!==0)switch(E.key){case"ArrowDown":E.preventDefault(),f.value=f.value<H.length-1?f.value+1:0,F();break;case"ArrowUp":E.preventDefault(),f.value=f.value>0?f.value-1:H.length-1,F();break;case"Enter":E.preventDefault(),f.value>=0&&f.value<H.length&&C(H[f.value]);break}},F=()=>{pe(()=>{const E=g.value?.querySelector(".highlighted-option");E&&E.scrollIntoView({block:"nearest",behavior:"smooth"})})},K=E=>{E.target===g.value&&(d.value=E.newState==="open",d.value&&V())};ce(()=>{document.addEventListener("click",U),document.addEventListener("keydown",L);const E=()=>{d.value&&V()};window.addEventListener("resize",E),window.addEventListener("scroll",E,!0)}),Te(()=>{document.removeEventListener("click",U),document.removeEventListener("keydown",L),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)});const D={props:e,emit:c,isOpen:d,searchQuery:r,searchInput:n,dropdownRef:p,buttonRef:v,popoverRef:g,highlightedIndex:f,selectedOption:h,buttonClasses:w,filteredOptions:x,toggleDropdown:k,selectOption:C,clearValue:y,closePopover:_,positionPopover:V,handleClickOutside:U,handleEscape:L,handleKeyDown:j,scrollToHighlighted:F,handlePopoverToggle:K,DropShadow:Re};return Object.defineProperty(D,"__isScriptSetup",{enumerable:!1,value:!0}),D}}),ds={ref:"dropdownRef",class:"relative"},cs={key:0,class:"block text-sm font-medium mb-2"},us={key:0,class:"text-red-500"},ps=["disabled","aria-expanded"],ms={class:"flex items-center justify-between gap-1"},gs={key:0,class:"flex items-center gap-2 text-gray-400 flex-1 min-w-0"},fs={key:1,class:"flex items-center gap-2 flex-1 min-w-0"},hs=["src","alt"],vs={class:"block truncate"},bs={key:2,class:"block truncate text-gray-400 flex-1 min-w-0"},ys={key:1,ref:"popoverRef",class:"dropdown-popover"},xs={class:"bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg overflow-hidden"},ks={class:"p-2 border-b border-gray-200 dark:border-gray-700"},_s=["placeholder"],ws={class:"max-h-60 overflow-y-auto"},Cs={key:0,class:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400"},Ss=["onClick","onMouseenter"],Ts={class:"flex-shrink-0 w-5 h-5 mt-0.5"},Ms=["src","alt"],Is={key:1,class:"w-full h-full bg-gray-200 dark:bg-gray-700 rounded"},Vs={class:"flex-1 min-w-0"},As={class:"text-sm font-medium text-black dark:text-white"},Ps={key:0,class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Es={key:2,class:"mt-1 text-xs text-red-500 dark:text-red-400"};function Os(u,t,a,e,c,d){return s(),l("div",ds,[a.label?(s(),l("label",cs,[ie(b(a.label)+" ",1),a.required?(s(),l("span",us,"*")):i("v-if",!0)])):i("v-if",!0),o("button",{ref:"buttonRef",type:"button",onClick:e.toggleDropdown,disabled:a.disabled,"aria-expanded":e.isOpen,"aria-haspopup":!0,class:ee(e.buttonClasses)},[o("div",ms,[a.loading?(s(),l("span",gs,[...t[1]||(t[1]=[o("svg",{class:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1),ie(" Loading... ",-1)])])):e.selectedOption?(s(),l("span",fs,[e.selectedOption.icon?(s(),l("img",{key:0,src:e.selectedOption.icon,alt:e.selectedOption.label,class:"w-5 h-5 flex-shrink-0"},null,8,hs)):i("v-if",!0),o("span",vs,b(e.selectedOption.label),1)])):(s(),l("span",bs,b(a.placeholder),1)),i(" Clear button (only shown when value is selected) "),e.selectedOption&&!a.disabled?(s(),l("button",{key:3,type:"button",onClick:e.clearValue,class:"flex-shrink-0 p-0.5 hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors","aria-label":"Clear selection"},[...t[2]||(t[2]=[o("svg",{class:"h-4 w-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)])])):i("v-if",!0),i(" Dropdown chevron "),t[3]||(t[3]=o("svg",{class:"h-5 w-5 text-gray-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[o("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])],10,ps),i(" Popover dropdown "),e.isOpen?(s(),l("div",ys,[S(e.DropShadow,{"offset-x":4,"offset-y":4,intensity:.3},{default:ae(()=>[o("div",xs,[o("div",ks,[fe(o("input",{ref:"searchInput","onUpdate:modelValue":t[0]||(t[0]=r=>e.searchQuery=r),type:"text",placeholder:a.searchPlaceholder,onKeydown:e.handleKeyDown,class:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white bg-white dark:bg-black text-black dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500"},null,40,_s),[[_e,e.searchQuery]])]),o("div",ws,[e.filteredOptions.length===0?(s(),l("div",Cs," No options found ")):i("v-if",!0),(s(!0),l(W,null,ne(e.filteredOptions,(r,n)=>(s(),l("button",{key:r.value,type:"button",onClick:p=>e.selectOption(r),onMouseenter:p=>e.highlightedIndex=n,class:ee(["w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-900 focus:bg-gray-100 dark:focus:bg-gray-900 focus:outline-none flex items-start gap-3",{"bg-gray-50 dark:bg-gray-900":r.value===a.modelValue,"bg-gray-100 dark:bg-gray-800 highlighted-option":n===e.highlightedIndex}])},[o("div",Ts,[r.icon?(s(),l("img",{key:0,src:r.icon,alt:r.label,class:"w-full h-full"},null,8,Ms)):(s(),l("div",Is))]),o("div",Vs,[o("div",As,b(r.label),1),r.description?(s(),l("div",Ps,b(r.description),1)):i("v-if",!0)])],42,Ss))),128))])])]),_:1})],512)):i("v-if",!0),a.error?(s(),l("p",Es,b(a.error),1)):i("v-if",!0)],512)}const xe=Q(is,[["render",Os],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/SelectInput.vue"]]),js=$({__name:"CheckboxInput",props:{modelValue:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1},helpText:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},error:{type:String,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=$t(),r=z(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50":"hover:scale-110",e.modelValue?"bg-black dark:bg-white":"bg-white dark:bg-black","before:content-[''] before:absolute before:inset-0 before:m-auto before:w-2.5 before:h-1.5 before:border-white dark:before:border-black before:border-b-2 before:border-l-2 before:rotate-[-45deg]",e.modelValue?"before:block":"before:hidden"]),p={props:e,emit:c,checkboxId:d,decoratorClasses:r,handleChange:v=>{if(!e.disabled){const g=v.target;c("update:modelValue",g.checked)}}};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),Ls={class:"flex items-start"},Ds=["for"],Us=["id","checked","disabled"],qs={class:"flex items-center h-5"},Ns={class:"flex-1"},Bs={key:0,class:"text-red-500"},Rs={key:1,class:"text-xs text-gray-600 dark:text-gray-400 mt-1"},Fs={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function zs(u,t,a,e,c,d){return s(),l("div",Ls,[o("label",{for:e.checkboxId,class:ee(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":a.disabled}])},[o("input",{id:e.checkboxId,type:"checkbox",checked:a.modelValue,disabled:a.disabled,onChange:e.handleChange,class:"absolute left-[-9999px]"},null,40,Us),o("div",qs,[o("span",{class:ee(e.decoratorClasses)},null,2)]),o("div",Ns,[a.label?(s(),l("span",{key:0,class:ee(["block text-sm font-medium",{"opacity-50":a.disabled}])},[ie(b(a.label)+" ",1),a.required?(s(),l("span",Bs,"*")):i("v-if",!0)],2)):i("v-if",!0),a.helpText?(s(),l("p",Rs,b(a.helpText),1)):i("v-if",!0),a.error?(s(),l("p",Fs,b(a.error),1)):i("v-if",!0)])],10,Ds)])}const Xe=Q(js,[["render",zs],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/CheckboxInput.vue"]]),Hs=$({__name:"AgentModal",props:{modelValue:{type:Boolean,required:!0},editAgent:{type:null,required:!1},mode:{type:String,required:!1}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>e.mode==="edit"),r=m(!1),n=m(""),p=m(""),v=m(""),g=m(null),f=m(""),h=m("dual_ai"),w=m(!1),x=m(""),k=m(""),C=m(null),y=m(""),_=m(""),V=m(""),U=m(""),L=m(!0),j=m(!1),F=m(""),K=m(""),D=m(""),E=m(""),H=m(!1),R=m(null),N=m(""),Z=m(""),G=m(""),P=m(""),I=m(""),T=m(""),q=m(!0),M=m(!1),O=m(""),A=m(""),B=m(""),te=m(""),le=m(null),re=m(""),ue=m(""),me=m(""),{data:we,execute:ke}=ve(J("/api/prompts"),{immediate:!1}).json(),{data:be,execute:Fe}=ve(J("/api/tools?schema=true"),{immediate:!1}).json(),Me=m(null),Qe=m(!1),Ae=m(null),Ye=m(!1),Ue=m(!1),qt=z(()=>{if(!we.value)return[{value:"",label:"Select a prompt..."}];const Y=we.value?.prompts||[];return[{value:"",label:"None"},...Y.map(se=>({value:se.id,label:se.name}))]}),$e=Y=>be.value?be.value[Y]:null,Nt=z(()=>!Me.value||!Me.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Me.value.tools.map(Y=>{const se=typeof Y=="string"?Y:Y.name;return{value:se,label:se}})]),Bt=z(()=>!Ae.value||!Ae.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ae.value.tools.map(Y=>{const se=typeof Y=="string"?Y:Y.name;return{value:se,label:se}})]),Rt=z(()=>{if(!F.value)return[];const Y=$e(F.value);return!Y||!Y.schema||!Y.schema.properties?[]:Object.keys(Y.schema.properties).map(se=>({value:se,label:se}))}),Ft=z(()=>{if(!O.value)return[];const Y=$e(O.value);return!Y||!Y.schema||!Y.schema.properties?[]:Object.keys(Y.schema.properties).map(se=>({value:se,label:se}))}),zt=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Ht=z({get(){return p.value},set(Y){const se=g.value?.inputRef,de=se?.selectionStart??Y.length;let Ce=Y.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(Ce.endsWith("_agent")||(Ce=Ce+"_agent"),p.value=Ce,se){se.value=Ce;const ye=Math.min(de,Ce.length-6);se.setSelectionRange(ye,ye)}}}),Wt=async()=>{await pe();const Y=g.value?.inputRef;if(Y&&p.value.endsWith("_agent")){const se=p.value.length-6;Y.setSelectionRange(se,se)}},ut=Y=>!Y||Y==="_agent"?(v.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(Y)?(v.value="",!0):(v.value="Name must start with a letter",!1),qe=()=>{p.value="",n.value="",v.value="",f.value="",h.value="dual_ai",w.value=!1,x.value="",k.value="",C.value=null,y.value="",V.value="",U.value="",L.value=!0,j.value=!1,F.value="",K.value="",D.value="",E.value="",H.value=!1,R.value=null,N.value="",Z.value="",G.value="",Me.value=null,I.value="",T.value="",q.value=!0,M.value=!1,O.value="",A.value="",B.value="",te.value="",le.value=null,re.value="",ue.value="",me.value="",Ae.value=null},pt=async()=>{if(e.editAgent?.id){r.value=!0,Ue.value=!0;try{const Y=await fetch(J(`/api/agents/${e.editAgent.id}`));if(Y.ok){const se=await Y.json(),de=se.agent||se;p.value=de.name||"",n.value=de.name||"",f.value=de.title||"",h.value=de.type||"dual_ai",w.value=de.expose_as_tool||!1,x.value=de.tool_description||"",C.value=de.max_session_turns;const Ce=de.side_a_stop_tool||"",ye=de.side_a_stop_tool_response_property||"",Zt=de.side_b_stop_tool||"",Gt=de.side_b_stop_tool_response_property||"",Xt=de.side_a_end_conversation_tool||"",Qt=de.side_b_end_conversation_tool||"";_.value=de.side_a_label||"",P.value=de.side_b_label||"",V.value=de.side_a_agent_prompt||"",I.value=de.side_b_agent_prompt||"",L.value=!!de.side_a_stop_on_response,j.value=!!de.side_a_stop_tool,H.value=!!de.side_a_manual_stop_condition,R.value=de.side_a_max_turns,q.value=!!de.side_b_stop_on_response,M.value=!!de.side_b_stop_tool,le.value=de.side_b_max_turns,await pe(),F.value=Ce,D.value=ye,O.value=Zt,B.value=Gt,Z.value=Xt,ue.value=Qt}}catch(Y){console.error("Error loading agent data:",Y)}finally{r.value=!1,Ue.value=!1}}},Jt=async()=>{v.value="",y.value="",U.value="",K.value="",E.value="",N.value="",G.value="",T.value="",A.value="",te.value="",re.value="",me.value="";let Y=!1;ut(p.value)||(Y=!0);const se=p.value;h.value==="dual_ai"&&C.value!==null&&C.value!==void 0&&C.value<=0&&(y.value="Max session turns must be a positive number",Y=!0),V.value||(U.value="Please select an agent prompt",Y=!0);const de=L.value||F.value,Ce=h.value==="ai_human"&&H.value;if(!de&&!Ce&&(U.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Y=!0),F.value&&!D.value&&(E.value="Response property required when using stop tool",Y=!0),R.value!==null&&R.value<=0&&(N.value="Max turns must be a positive number",Y=!0),h.value==="dual_ai"&&!Z.value&&!ue.value&&(G.value="At least one side must have an end conversation tool",me.value="At least one side must have an end conversation tool",Y=!0),h.value==="dual_ai"&&(I.value||(T.value="Please select an agent prompt",Y=!0),O.value&&!B.value&&(te.value="Response property required when using stop tool",Y=!0),le.value!==null&&le.value<=0&&(re.value="Max turns must be a positive number",Y=!0)),Y)return;const ye={name:se,title:f.value||null,type:h.value,expose_as_tool:w.value,tool_description:w.value?x.value:null,max_session_turns:h.value==="dual_ai"?C.value:null,side_a_label:_.value||null,side_a_agent_prompt:V.value,side_a_stop_on_response:L.value,side_a_stop_tool:F.value||null,side_a_stop_tool_response_property:D.value||null,side_a_manual_stop_condition:H.value,side_a_max_turns:R.value,side_a_end_conversation_tool:Z.value||null};h.value==="dual_ai"&&(ye.side_b_label=P.value||null,ye.side_b_agent_prompt=I.value,ye.side_b_stop_on_response=q.value,ye.side_b_stop_tool=O.value||null,ye.side_b_stop_tool_response_property=B.value||null,ye.side_b_max_turns=le.value,ye.side_b_end_conversation_tool=ue.value||null),d.value&&e.editAgent?.id&&(ye.id=e.editAgent.id),c("save",ye),qe(),c("update:modelValue",!1)},Kt=()=>{qe(),c("update:modelValue",!1)};oe(V,async Y=>{if(Ue.value||(F.value="",D.value=""),!Y){Me.value=null;return}Qe.value=!0;try{const se=await fetch(J(`/api/prompts/${Y}`));se.ok&&(Me.value=await se.json())}catch(se){console.error("Error fetching Side A prompt:",se)}finally{Qe.value=!1}}),oe(I,async Y=>{if(Ue.value||(O.value="",B.value=""),!Y){Ae.value=null;return}Ye.value=!0;try{const se=await fetch(J(`/api/prompts/${Y}`));se.ok&&(Ae.value=await se.json())}catch(se){console.error("Error fetching Side B prompt:",se)}finally{Ye.value=!1}}),oe(j,Y=>{Y||(F.value="",D.value="")}),oe(M,Y=>{Y||(O.value="",B.value="")}),oe(()=>e.modelValue,async Y=>{Y&&(await Promise.all([ke(),Fe()]),d.value?(qe(),await pt()):qe())});const mt={props:e,emit:c,isEditMode:d,isLoading:r,originalName:n,name:p,nameError:v,nameInputRef:g,title:f,agentType:h,exposeAsTool:w,toolDescription:x,toolDescriptionError:k,maxSessionTurns:C,maxSessionTurnsError:y,sideALabel:_,sideAAgentPrompt:V,sideAAgentPromptError:U,sideAStopOnResponse:L,sideAStopOnToolCall:j,sideAStopTool:F,sideAStopToolError:K,sideAStopToolResponseProperty:D,sideAStopToolResponsePropertyError:E,sideAManualStopCondition:H,sideAMaxTurns:R,sideAMaxTurnsError:N,sideAEndConversationTool:Z,sideAEndConversationToolError:G,sideBLabel:P,sideBAgentPrompt:I,sideBAgentPromptError:T,sideBStopOnResponse:q,sideBStopOnToolCall:M,sideBStopTool:O,sideBStopToolError:A,sideBStopToolResponseProperty:B,sideBStopToolResponsePropertyError:te,sideBMaxTurns:le,sideBMaxTurnsError:re,sideBEndConversationTool:ue,sideBEndConversationToolError:me,promptsData:we,fetchPrompts:ke,toolsData:be,fetchTools:Fe,sideAPromptData:Me,sideAPromptLoading:Qe,sideBPromptData:Ae,sideBPromptLoading:Ye,isLoadingAgentData:Ue,promptOptions:qt,getToolByName:$e,sideAToolOptions:Nt,sideBToolOptions:Bt,sideAResponsePropertyOptions:Rt,sideBResponsePropertyOptions:Ft,agentTypeOptions:zt,agentName:Ht,handleNameFocus:Wt,validateAgentName:ut,resetForm:qe,loadAgentData:pt,handleSubmit:Jt,handleCancel:Kt,Modal:Ve,TextInput:je,TextareaInput:Et,SelectInput:xe,CheckboxInput:Xe};return Object.defineProperty(mt,"__isScriptSetup",{enumerable:!1,value:!0}),mt}}),Ws={key:0,class:"min-h-[400px] flex items-center justify-center"},Js={key:1,class:"space-y-6 pr-2 pb-4"},Ks={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Zs={key:1,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Gs={key:0},Xs={key:1},Qs={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Ys={key:2},$s={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},el={class:"grid grid-cols-2 gap-6"},tl={"data-testid":"side-a-container",class:"space-y-4 p-4 bg-gray-50 dark:bg-gray-900 rounded-lg"},ol={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},rl={class:"space-y-3"},al={class:"flex items-start"},sl={key:0,class:"ml-8 mt-2 space-y-2"},ll={key:0,class:"text-xs text-gray-500 dark:text-gray-400 -mt-1"},nl={key:1},il={key:0,class:"mt-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded"},dl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},cl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},ul={"data-testid":"side-b-container",class:"space-y-4 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg"},pl={class:"font-semibold text-base mb-4 text-gray-800 dark:text-gray-200"},ml={key:0,class:"flex flex-col items-center justify-center py-8"},gl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},fl={class:"space-y-3"},hl={class:"flex items-start"},vl={key:0,class:"ml-8 mt-2 space-y-2"},bl={key:0,class:"text-xs text-gray-500 dark:text-gray-400 -mt-1"},yl={key:1},xl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},kl={key:0,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},_l={class:"flex justify-between"},wl=["disabled"];function Cl(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[23]||(t[23]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Agent":"Create Agent",width:"max-w-6xl"},{footer:ae(()=>[o("div",_l,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:e.isLoading},b(e.isEditMode?"Update Agent":"Create Agent"),9,wl)])]),default:ae(()=>[e.isLoading?(s(),l("div",Ws,[...t[24]||(t[24]=[o("span",{class:"text-gray-500"},"Loading agent data...",-1)])])):(s(),l("div",Js,[i(" Agent Name "),o("div",null,[S(e.TextInput,{ref:"nameInputRef",modelValue:e.agentName,"onUpdate:modelValue":t[0]||(t[0]=r=>e.agentName=r),label:"Agent Name",placeholder:"research_agent",error:e.nameError,required:"",disabled:e.isEditMode,onFocus:e.handleNameFocus,onClick:e.handleNameFocus},null,8,["modelValue","error","disabled"]),!e.nameError&&!e.isEditMode?(s(),l("p",Ks," Names are automatically formatted to snake_case with the _agent suffix ")):i("v-if",!0),e.isEditMode?(s(),l("p",Zs," Agent names cannot be changed after creation (used as foreign key for threads) ")):i("v-if",!0)]),i(" Agent Title "),o("div",null,[S(e.TextInput,{modelValue:e.title,"onUpdate:modelValue":t[1]||(t[1]=r=>e.title=r),label:"Display Title (Optional)",placeholder:"Research Assistant"},null,8,["modelValue"]),t[25]||(t[25]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Human-readable title shown in the UI. If not set, the name will be used. ",-1))]),i(" Agent Type "),o("div",null,[S(e.SelectInput,{modelValue:e.agentType,"onUpdate:modelValue":t[2]||(t[2]=r=>e.agentType=r),label:"Agent Type",options:e.agentTypeOptions},null,8,["modelValue"]),t[26]||(t[26]=o("p",{class:"mt-1 text-sm text-gray-500 dark:text-gray-400"}," Choose between two AI agents conversing, or an AI agent conversing with a human ",-1))]),i(" Expose as Tool (only for dual_ai agents) "),e.agentType==="dual_ai"?(s(),l("div",Gs,[S(e.CheckboxInput,{modelValue:e.exposeAsTool,"onUpdate:modelValue":t[3]||(t[3]=r=>e.exposeAsTool=r),label:"Expose as Tool"},null,8,["modelValue"]),t[27]||(t[27]=o("p",{class:"mt-1 text-sm text-gray-500 dark:text-gray-400"}," Make this subagent available as a tool that can be called by other prompts or agents. When called, it will execute as a subagent. ",-1))])):i("v-if",!0),i(" Tool Description (only show if expose_as_tool is checked and agent is dual_ai) "),e.exposeAsTool&&e.agentType==="dual_ai"?(s(),l("div",Xs,[S(e.TextareaInput,{modelValue:e.toolDescription,"onUpdate:modelValue":t[4]||(t[4]=r=>e.toolDescription=r),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",error:e.toolDescriptionError,rows:3},null,8,["modelValue","error"]),e.toolDescriptionError?i("v-if",!0):(s(),l("p",Qs," This description helps other agents understand when to use this agent "))])):i("v-if",!0),i(" Max Session Turns (only show for dual_ai) "),e.agentType==="dual_ai"?(s(),l("div",Ys,[S(e.TextInput,{"model-value":e.maxSessionTurns?.toString()||"","onUpdate:modelValue":t[5]||(t[5]=r=>e.maxSessionTurns=r?parseInt(r):null),label:"Max Session Turns",type:"number",error:e.maxSessionTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.maxSessionTurnsError?i("v-if",!0):(s(),l("p",$s," Maximum number of back-and-forth exchanges between the two agents before the conversation ends "))])):i("v-if",!0),i(" Two Column Layout for both sides "),o("div",el,[i(" Side A (AI) "),o("div",tl,[t[34]||(t[34]=o("h4",{class:"font-semibold text-base mb-4 text-gray-800 dark:text-gray-200"}," Side A (AI) ",-1)),i(" Label (Optional) "),o("div",null,[S(e.TextInput,{modelValue:e.sideALabel,"onUpdate:modelValue":t[6]||(t[6]=r=>e.sideALabel=r),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),t[28]||(t[28]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),i(" Agent Prompt "),o("div",null,[S(e.SelectInput,{modelValue:e.sideAAgentPrompt,"onUpdate:modelValue":t[7]||(t[7]=r=>e.sideAAgentPrompt=r),label:"Agent Prompt",options:e.promptOptions,error:e.sideAAgentPromptError,required:""},null,8,["modelValue","options","error"]),e.sideAAgentPromptError?i("v-if",!0):(s(),l("p",ol," The prompt that defines this agent's behavior "))]),i(" Stop Conditions "),o("div",rl,[t[31]||(t[31]=o("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),t[32]||(t[32]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),i(" Stop on Response "),o("div",al,[S(e.CheckboxInput,{modelValue:e.sideAStopOnResponse,"onUpdate:modelValue":t[8]||(t[8]=r=>e.sideAStopOnResponse=r),label:"Stop when agent returns content"},null,8,["modelValue"])]),t[33]||(t[33]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),i(" Stop on Tool Call "),o("div",null,[S(e.CheckboxInput,{modelValue:e.sideAStopOnToolCall,"onUpdate:modelValue":t[9]||(t[9]=r=>e.sideAStopOnToolCall=r),label:"Stop on specific tool call"},null,8,["modelValue"]),e.sideAStopOnToolCall?(s(),l("div",sl,[S(e.SelectInput,{modelValue:e.sideAStopTool,"onUpdate:modelValue":t[10]||(t[10]=r=>e.sideAStopTool=r),label:"Stop Tool",options:e.sideAToolOptions,error:e.sideAStopToolError,placeholder:"Select a tool...",disabled:e.sideAPromptLoading||!e.sideAAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideAStopToolError?i("v-if",!0):(s(),l("p",ll," Agent stops when this tool is called ")),e.sideAStopTool?(s(),l("div",nl,[S(e.SelectInput,{modelValue:e.sideAStopToolResponseProperty,"onUpdate:modelValue":t[11]||(t[11]=r=>e.sideAStopToolResponseProperty=r),label:"Response Property",options:e.sideAResponsePropertyOptions,error:e.sideAStopToolResponsePropertyError,placeholder:"Select property..."},null,8,["modelValue","options","error"]),t[29]||(t[29]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Property from tool arguments to return as final response ",-1))])):i("v-if",!0)])):i("v-if",!0)]),i(" Manual Stop Condition (only for ai_human when both stop conditions are unchecked) "),e.agentType==="ai_human"&&!e.sideAStopOnResponse&&!e.sideAStopOnToolCall?(s(),l("div",il,[S(e.CheckboxInput,{modelValue:e.sideAManualStopCondition,"onUpdate:modelValue":t[12]||(t[12]=r=>e.sideAManualStopCondition=r),label:"I have manually implemented a stop condition"},null,8,["modelValue"]),t[30]||(t[30]=o("p",{class:"mt-2 text-xs text-yellow-800 dark:text-yellow-200"}," ⚠️ Warning: Only check this if you have implemented a custom stop condition in your code (e.g., via hooks or custom logic). Without a stop condition, the agent may run indefinitely. ",-1))])):i("v-if",!0)]),i(" Max Turns "),o("div",null,[S(e.TextInput,{"model-value":e.sideAMaxTurns?.toString()||"","onUpdate:modelValue":t[13]||(t[13]=r=>e.sideAMaxTurns=r?parseInt(r):null),label:"Max Turns",type:"number",error:e.sideAMaxTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.sideAMaxTurnsError?i("v-if",!0):(s(),l("p",dl," Maximum turns this side can take before yielding (safety limit) "))]),i(" End Conversation Tool "),o("div",null,[S(e.SelectInput,{modelValue:e.sideAEndConversationTool,"onUpdate:modelValue":t[14]||(t[14]=r=>e.sideAEndConversationTool=r),label:"End Conversation Tool",options:e.sideAToolOptions,error:e.sideAEndConversationToolError,placeholder:"Select a tool...",disabled:e.sideAPromptLoading||!e.sideAAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideAEndConversationToolError?i("v-if",!0):(s(),l("p",cl," Tool that ends the entire conversation when called "))])]),i(" Side B (AI or Human) "),o("div",ul,[o("h4",pl," Side B ("+b(e.agentType==="ai_human"?"Human":"AI")+") ",1),i(" Label (Optional) - Available for both AI and Human "),o("div",null,[S(e.TextInput,{modelValue:e.sideBLabel,"onUpdate:modelValue":t[15]||(t[15]=r=>e.sideBLabel=r),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer, Support"},null,8,["modelValue"]),t[35]||(t[35]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Custom label for this side (shows in message bubbles and toggle) ",-1))]),e.agentType==="ai_human"?(s(),l("div",ml,[...t[36]||(t[36]=[o("svg",{class:"w-20 h-20 mb-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),o("h5",{class:"font-medium text-lg mb-2"},"Human User",-1),o("p",{class:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-xs"}," This side of the conversation will be handled by a human user through the interface ",-1)])])):(s(),l(W,{key:1},[i(" Agent Prompt "),o("div",null,[S(e.SelectInput,{modelValue:e.sideBAgentPrompt,"onUpdate:modelValue":t[16]||(t[16]=r=>e.sideBAgentPrompt=r),label:"Agent Prompt",options:e.promptOptions,error:e.sideBAgentPromptError,required:""},null,8,["modelValue","options","error"]),e.sideBAgentPromptError?i("v-if",!0):(s(),l("p",gl," The prompt that defines this agent's behavior "))]),i(" Stop Conditions "),o("div",fl,[t[38]||(t[38]=o("label",{class:"block text-sm font-medium"}," Stop Conditions ",-1)),t[39]||(t[39]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)),i(" Stop on Response "),o("div",hl,[S(e.CheckboxInput,{modelValue:e.sideBStopOnResponse,"onUpdate:modelValue":t[17]||(t[17]=r=>e.sideBStopOnResponse=r),label:"Stop when agent returns content"},null,8,["modelValue"])]),t[40]||(t[40]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6"}," Agent stops when it returns a response without calling tools ",-1)),i(" Stop on Tool Call "),o("div",null,[S(e.CheckboxInput,{modelValue:e.sideBStopOnToolCall,"onUpdate:modelValue":t[18]||(t[18]=r=>e.sideBStopOnToolCall=r),label:"Stop on specific tool call"},null,8,["modelValue"]),e.sideBStopOnToolCall?(s(),l("div",vl,[S(e.SelectInput,{modelValue:e.sideBStopTool,"onUpdate:modelValue":t[19]||(t[19]=r=>e.sideBStopTool=r),label:"Stop Tool",options:e.sideBToolOptions,error:e.sideBStopToolError,placeholder:"Select a tool...",disabled:e.sideBPromptLoading||!e.sideBAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideBStopToolError?i("v-if",!0):(s(),l("p",bl," Agent stops when this tool is called ")),e.sideBStopTool?(s(),l("div",yl,[S(e.SelectInput,{modelValue:e.sideBStopToolResponseProperty,"onUpdate:modelValue":t[20]||(t[20]=r=>e.sideBStopToolResponseProperty=r),label:"Response Property",options:e.sideBResponsePropertyOptions,error:e.sideBStopToolResponsePropertyError,placeholder:"Select property..."},null,8,["modelValue","options","error"]),t[37]||(t[37]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Property from tool arguments to return as final response ",-1))])):i("v-if",!0)])):i("v-if",!0)])]),i(" Max Turns "),o("div",null,[S(e.TextInput,{"model-value":e.sideBMaxTurns?.toString()||"","onUpdate:modelValue":t[21]||(t[21]=r=>e.sideBMaxTurns=r?parseInt(r):null),label:"Max Turns",type:"number",error:e.sideBMaxTurnsError,placeholder:"Unlimited"},null,8,["model-value","error"]),e.sideBMaxTurnsError?i("v-if",!0):(s(),l("p",xl," Maximum turns this side can take before yielding (safety limit) "))]),i(" End Conversation Tool "),o("div",null,[S(e.SelectInput,{modelValue:e.sideBEndConversationTool,"onUpdate:modelValue":t[22]||(t[22]=r=>e.sideBEndConversationTool=r),label:"End Conversation Tool",options:e.sideBToolOptions,error:e.sideBEndConversationToolError,placeholder:"Select a tool...",disabled:e.sideBPromptLoading||!e.sideBAgentPrompt},null,8,["modelValue","options","error","disabled"]),e.sideBEndConversationToolError?i("v-if",!0):(s(),l("p",kl," Tool that ends the entire conversation when called "))])],64))])])]))]),_:1},8,["model-value","title"])}const Sl=Q(Hs,[["render",Cl],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AgentModal.vue"]]),Tl=$({__name:"AgentsView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!1),d=m("add"),r=m(null),n=m(null);oe(()=>e.query.refresh,()=>{e.query.refresh&&(n.value?.refresh(),a.replace({path:"/agents",query:{}}))});const f={router:a,route:e,showModal:c,modalMode:d,editingAgent:r,dataTableRef:n,handleAdd:()=>{d.value="add",r.value=null,c.value=!0},handleEdit:h=>{d.value="edit",r.value=h,c.value=!0},handleSave:async h=>{try{const w=d.value==="edit"&&r.value?.id,{originalName:x,...k}=h,C=J(w?`/api/agents/${r.value.id}`:"/api/agents"),_=await fetch(C,{method:w?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(_.ok)n.value?.refresh(),c.value=!1,r.value=null;else{const V=await _.json();alert(V.error||`Failed to ${w?"update":"create"} agent`)}}catch(w){console.error(`Error ${d.value==="edit"?"updating":"creating"} agent:`,w),alert(`Failed to ${d.value==="edit"?"update":"create"} agent`)}},AgentsDataTable:Sa,AgentModal:Sl};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),Ml={class:"p-8"};function Il(u,t,a,e,c,d){return s(),l("div",Ml,[o("div",{class:"flex justify-between items-center mb-6"},[t[1]||(t[1]=o("h1",{class:"text-3xl font-bold"},"Agents",-1)),o("button",{onClick:e.handleAdd,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Agent ")]),t[2]||(t[2]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"},"Configure and manage your AI agents.",-1)),S(e.AgentsDataTable,{ref:"dataTableRef",onAdd:e.handleAdd,onEdit:e.handleEdit},null,512),S(e.AgentModal,{modelValue:e.showModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showModal=r),mode:e.modalMode,editAgent:e.editingAgent,onSave:e.handleSave},null,8,["modelValue","mode","editAgent"])])}const Vl=Q(Tl,[["render",Il],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/AgentsView.vue"]]);function Al(u){const{limit:t=50,offset:a=0,agentId:e=null,userId:c=null,autoFetch:d=!0}={},r=z(()=>{const C=new URLSearchParams,y=typeof t=="number"?t:t.value,_=typeof a=="number"?a:a.value,V=typeof e=="string"?e:e?.value,U=typeof c=="string"?c:c?.value;return C.append("limit",y.toString()),C.append("offset",_.toString()),V&&C.append("agent_id",V),U&&C.append("user_id",U),J(`/api/threads?${C.toString()}`)}),{data:n,error:p,isFetching:v,isFinished:g,execute:f,abort:h}=ve(r,{immediate:d}).get().json(),w=z(()=>n.value?.threads||[]),x=z(()=>n.value?.total||0),k=z(()=>n.value?.hasMore||!1);return{threads:w,total:x,hasMore:k,error:p,isFetching:v,isFinished:g,refetch:f,abort:h}}function nt(u){const t=z(()=>!!(typeof u=="string"?u:u?.value)),a=z(()=>{const g=typeof u=="string"?u:u?.value;return J(g?`/api/threads/${g}`:"/api/threads/placeholder")}),{data:e,error:c,isFetching:d,isFinished:r,execute:n,abort:p}=ve(a,{immediate:!1}).get().json();return oe(t,g=>{g&&n()},{immediate:!0}),{thread:z(()=>e.value?{id:e.value.thread.id,agent_id:e.value.thread.agent_id,user_id:e.value.thread.user_id,tags:e.value.thread.tags||[],created_at:e.value.thread.created_at,agent:e.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:e.value.stats}:null),error:c,isFetching:d,isFinished:r,refetch:n,abort:p}}function Pl(u){const{autoConnect:t=!0,onEvent:a}=u||{},e=m(null),c=m(!1),d=m(null),r=()=>{e.value&&e.value.close();const p=window.location.protocol==="https:"?"wss:":"ws:",v=window.location.host;let g=`${p}//${v}${J("/api/events")}`;const f=localStorage.getItem("auth_token");f&&(g+=`?token=${encodeURIComponent(f)}`);try{e.value=new WebSocket(g),e.value.onopen=()=>{c.value=!0,d.value=null,console.log("[AgentBuilderEvents] WebSocket connected")},e.value.onmessage=h=>{try{const w=JSON.parse(h.data);console.log("[AgentBuilderEvents] Received event:",w.type),a&&a(w)}catch(w){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",w)}},e.value.onerror=h=>{d.value="WebSocket connection error",c.value=!1,console.error("[AgentBuilderEvents] WebSocket error:",h)},e.value.onclose=()=>{c.value=!1,console.log("[AgentBuilderEvents] WebSocket disconnected")}}catch(h){d.value=h.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",h)}},n=()=>{e.value&&(e.value.close(),e.value=null,c.value=!1)};return t&&r(),Te(()=>{n()}),{wsConnected:c,wsError:d,connect:r,disconnect:n}}const El=$({__name:"Loader",props:{size:{type:String,required:!1,default:"md"}},setup(u,{expose:t}){t();const a=u,e=z(()=>{switch(a.size){case"xs":return"w-3 h-3 border";case"sm":return"w-3.5 h-3.5 border";case"md":default:return"w-4 h-4 border-2"}}),c={props:a,sizeClasses:e};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}}),Ol={class:"inline-flex items-center justify-center"};function jl(u,t,a,e,c,d){return s(),l("div",Ol,[o("div",{class:ee([e.sizeClasses,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)])}const De=Q(El,[["render",jl],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/Loader.vue"]]);function Ll(u){const a=Date.now()*1e3-u,e=Math.floor(a/1e6);if(e<60)return e===1?"1 second ago":`${e} seconds ago`;const c=Math.floor(e/60);if(c<60)return c===1?"1 minute ago":`${c} minutes ago`;const d=Math.floor(c/60);if(d<24)return d===1?"1 hour ago":`${d} hours ago`;const r=Math.floor(d/24);if(r<30)return r===1?"1 day ago":`${r} days ago`;const n=Math.floor(r/30);if(n<12)return n===1?"1 month ago":`${n} months ago`;const p=Math.floor(n/12);return p===1?"1 year ago":`${p} years ago`}function Dl(u){const t=m("");let a=null;const e=()=>typeof u=="function"?u():typeof u=="number"?u:u.value,c=()=>{const d=e();t.value=Ll(d);const n=Date.now()*1e3-d,p=Math.floor(n/1e6);a!==null&&(clearInterval(a),a=null),p<60?a=setInterval(c,1e3):p<3600?a=setInterval(c,6e4):p<86400&&(a=setInterval(c,6e5))};return c(),Te(()=>{a!==null&&clearInterval(a)}),t}const Ul=$({__name:"TimeAgo",props:{timestamp:{type:Number,required:!0}},setup(u,{expose:t}){t();const a=u,e=Dl(()=>a.timestamp),c={props:a,timeString:e};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}});function ql(u,t,a,e,c,d){return s(),l("span",null,b(e.timeString),1)}const it=Q(Ul,[["render",ql],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/TimeAgo.vue"]]),Nl=$({__name:"ThreadListPane",props:{selectedThreadId:{type:[String,null],required:!0}},emits:["selectThread","collapse","createThread"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(""),{threads:r,isFetching:n,error:p,refetch:v}=Al(),g=m([]),f=m(new Set),h=z(()=>{const _=r.value.filter(L=>!f.value.has(L.id)),V=new Set(_.map(L=>L.id));return[...g.value.filter(L=>!V.has(L.id)&&!f.value.has(L.id)),..._].sort((L,j)=>j.created_at-L.created_at)}),w=async _=>{if(_.type==="thread_created"){const V={id:_.thread.id,agent_id:_.thread.agent_name,user_id:_.thread.user_id,tags:_.thread.tags||[],created_at:_.thread.created_at,agent:{title:_.thread.agent_name,type:"ai_human"}};g.value.unshift(V)}else _.type==="thread_deleted"&&(f.value.add(_.threadId),g.value=g.value.filter(V=>V.id!==_.threadId))},{wsConnected:x,wsError:k}=Pl({onEvent:w});oe(r,()=>{g.value=[]}),t({refetch:v});const y={props:e,emit:c,searchQuery:d,fetchedThreads:r,isFetching:n,error:p,refetch:v,wsAddedThreads:g,wsRemovedThreadIds:f,threads:h,handleEvent:w,wsConnected:x,wsError:k,handleThreadClick:_=>{c("selectThread",_)},Loader:De,TimeAgo:it,get ListIcon(){return _t},get ChevronLeftIcon(){return Ze}};return Object.defineProperty(y,"__isScriptSetup",{enumerable:!1,value:!0}),y}}),Bl={class:"flex flex-col h-full"},Rl={class:"p-4 border-b border-gray-300 dark:border-gray-700"},Fl={class:"flex items-center justify-between"},zl={class:"flex items-center gap-2"},Hl={class:"flex items-center gap-2"},Wl={class:"text-xs pr-5"},Jl={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},Kl={key:1,class:"text-red-600 dark:text-red-400"},Zl={key:2,class:"text-gray-400 dark:text-gray-600"},Gl={class:"flex-1 overflow-y-auto text-xs"},Xl={key:0,class:"p-2 flex justify-center"},Ql={class:"p-2 text-red-600 dark:text-red-400"},Yl=["id","onClick"],$l={class:"flex items-center gap-2 mb-1"},en={class:"font-medium truncate flex-1 min-w-0"},tn={class:"flex-shrink-0 text-gray-500 dark:text-gray-400"},on={key:0,class:"flex flex-wrap gap-1"};function rn(u,t,a,e,c,d){return s(),l("div",Bl,[i(" Header (matches MessagesPane style) "),o("div",Rl,[o("div",Fl,[o("div",zl,[S(e.ListIcon,{size:20,class:"flex-shrink-0"}),t[2]||(t[2]=o("h2",{class:"text-xl font-bold"},"Threads",-1))]),o("div",Hl,[i(" WebSocket status "),o("div",Wl,[e.wsConnected?(s(),l("span",Jl,[...t[3]||(t[3]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",Kl," ● Error ")):(s(),l("span",Zl," ○ Offline "))]),o("button",{onClick:t[0]||(t[0]=r=>e.emit("createThread")),type:"button",class:"px-2 py-1 text-xs bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity whitespace-nowrap"}," + New "),o("button",{onClick:t[1]||(t[1]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Thread list "),o("div",Gl,[i(" Loading state "),e.isFetching?(s(),l("div",Xl,[S(e.Loader)])):e.error?(s(),l(W,{key:1},[i(" Error state "),o("div",Ql," Error: "+b(e.error),1)],2112)):e.threads.length===0?(s(),l(W,{key:2},[i(" Empty state "),t[4]||(t[4]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-12 text-base"}," No threads found ",-1))],2112)):(s(),l(W,{key:3},[i(" Thread items - two line layout "),o("div",null,[(s(!0),l(W,null,ne(e.threads,r=>(s(),l("button",{key:r.id,id:`thread-${r.id}`,class:ee(["w-full text-left px-2 py-2 border-b border-gray-200 dark:border-gray-800 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors",{"bg-gray-100 dark:bg-gray-900":a.selectedThreadId===r.id}]),onClick:n=>e.handleThreadClick(r.id)},[i(" First line: Title and time "),o("div",$l,[o("span",en,b(r.agent.title),1),o("span",tn,[S(e.TimeAgo,{timestamp:r.created_at*1e6},null,8,["timestamp"])])]),i(" Second line: Tags "),r.tags.length>0?(s(),l("div",on,[(s(!0),l(W,null,ne(r.tags,n=>(s(),l("span",{key:n,class:"inline-block px-1.5 py-0.5 rounded text-[10px] bg-gray-200 dark:bg-gray-800 text-gray-700 dark:text-gray-300"},b(n),1))),128))])):i("v-if",!0)],10,Yl))),128))])],2112))])])}const an=Q(Nl,[["render",rn],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/ThreadListPane.vue"]]),ze=150;function sn(u,t={}){const{enableWebSocket:a=!0,autoConnect:e=!0}=t,c=m([]),d=m(null),r=m(!1),n=m(!1),p=m(null),v=m(!1),g=m(null),f=m(!1),h=m(!1),w=m(0),x=m(0);let k=null,C=null;function y(N){if(!d.value?.agent)return null;const Z=d.value.agent,G=N==="assistant"?"A":"B";return G==="A"&&Z.side_a_label?Z.side_a_label:G==="B"&&Z.side_b_label?Z.side_b_label:null}function _(N,Z){return N==="system"||Z==="system"?!1:N!==Z}const V=z(()=>{const N=[],Z=c.value.filter(I=>(I.depth??0)===0),G=new Map;for(let I=0;I<Z.length;I++){const T=Z[I],q=T.role;if(q==="tool"){const re=T.tool_call_id;if(re&&G.has(re)){const ue=G.get(re),me=N[ue],we=me.items.find(ke=>ke.type==="tool_call"&&ke.tool_call_id===re);if(we){we.response=T.content||"",we.response_log_id=T.log_id;const ke=(T.content||"").toLowerCase(),be=ke.length,Fe=ke.includes("failed")||ke.includes("error"),Me=be<500;Fe&&Me?we.response_status="failed":we.response_status="success"}me.updated_at=T.created_at,G.delete(re)}continue}const M=y(q==="tool"?"assistant":q),O=N[N.length-1],A=O?.role;O&&_(q,A)&&O.type==="work"&&!O.isComplete&&(O.isComplete=!0);let B=null;if(T.tool_calls)if(typeof T.tool_calls=="string")try{B=JSON.parse(T.tool_calls)}catch(re){console.error("Failed to parse tool_calls:",re)}else Array.isArray(T.tool_calls)&&(B=T.tool_calls);const te=B&&B.length>0,le=O?.type==="work"&&O.role===q&&!O.isComplete;if(te){let re,ue;le?(re=O,ue=N.length-1):(re={type:"work",id:T.id,role:q,items:[],created_at:T.created_at,updated_at:T.created_at,isComplete:!1,sideLabel:M,isExpanded:!1,request_sent_at:T.request_sent_at,response_completed_at:T.response_completed_at,status:T.status||"completed"},N.push(re),ue=N.length-1),T.reasoning_content&&re.items.push({id:`${T.id}-reasoning`,type:"reasoning",content:T.reasoning_content,created_at:T.created_at,log_id:T.log_id}),T.content&&re.items.push({id:`${T.id}-content`,type:"content",content:T.content,created_at:T.created_at,log_id:T.log_id}),B.forEach(me=>{re.items.push({id:me.id,type:"tool_call",content:me.function.name,created_at:T.created_at,tool_name:me.function.name,tool_call_id:me.id,tool_arguments:me.function.arguments,log_id:T.log_id,response:null,response_status:"pending",response_log_id:null}),G.set(me.id,ue)}),re.updated_at=T.created_at,T.response_completed_at&&(re.response_completed_at=T.response_completed_at),T.status&&T.status!=="completed"?re.status=T.status:T.status==="completed"&&re.status==="pending"&&(re.status="completed")}else le&&T.status!=="pending"&&(O.isComplete=!0),(T.content||q==="system"||T.status==="pending")&&N.push({type:"text",id:T.id,role:q,content:T.content||"",created_at:T.created_at,log_id:T.log_id,sideLabel:M,isOptimistic:T.isOptimistic,status:T.status})}const P=N[N.length-1];return P?.type==="work"&&!P.isComplete&&(P.isComplete=!0),N});async function U(){if(!u.value){c.value=[],d.value=null,h.value=!1,w.value=0,x.value=0;return}r.value=!0,p.value=null;try{const N=await fetch(J(`/api/threads/${u.value}/messages?limit=${ze}&includeSilent=true`));if(!N.ok)throw new Error(`Failed to fetch messages: ${N.statusText}`);const Z=await N.json();c.value=Z.messages||[],h.value=Z.hasMore||!1,w.value=Z.total||0,x.value=ze,console.log(`Loaded ${c.value.length} messages, total: ${w.value}, hasMore: ${h.value}`);const G=await fetch(J(`/api/threads/${u.value}`));if(G.ok){const P=await G.json();d.value=P}}catch(N){p.value=N instanceof Error?N.message:"Unknown error",console.error("Error fetching messages:",N)}finally{r.value=!1}}async function L(){if(!(!u.value||n.value||!h.value)){n.value=!0;try{const N=await fetch(J(`/api/threads/${u.value}/messages?limit=${ze}&offset=${x.value}`));if(!N.ok)throw new Error(`Failed to fetch more messages: ${N.statusText}`);const Z=await N.json(),G=Z.messages||[];c.value=[...G,...c.value],h.value=Z.hasMore||!1,x.value+=ze,console.log(`Loaded ${G.length} more messages, offset now: ${x.value}, hasMore: ${h.value}`)}catch(N){p.value=N instanceof Error?N.message:"Unknown error",console.error("Error loading more messages:",N)}finally{n.value=!1}}}function j(){if(!(!a||!u.value||k))try{let Z=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${J(`/api/threads/${u.value}/stream?includeSilent=true`)}`;const G=localStorage.getItem("auth_token");G&&(Z+=`&token=${encodeURIComponent(G)}`),k=new WebSocket(Z),k.onopen=()=>{v.value=!0,g.value=null,console.log("WebSocket connected")},k.onmessage=P=>{try{if(P.data==="pong")return;const I=JSON.parse(P.data);if(I.type==="message_data"&&I.message_id){const T=I.message_id,q=I.data,M=c.value.findIndex(O=>O.id===T);if(M>=0)c.value[M]={...c.value[M],...q,id:T};else{const O={id:T,...q},A=c.value.filter(B=>{if(!B.isOptimistic)return!0;if(B.id===T)return!1;const te=B.content===O.content,le=B.role===O.role,re=Math.abs(B.created_at-O.created_at)<5e6;return!(te&&le&&re)});A.push(O),c.value=A.sort((B,te)=>B.created_at-te.created_at)}if(q.status==="pending")f.value=!0;else if(q.status==="completed"||q.status==="failed"){const O=c.value.some(A=>{if((A.depth??0)>0)return!1;if(A.status==="pending"||A.role==="tool"&&A.tool_call_id&&!A.tool_status)return!0;if(A.tool_calls)try{const te=JSON.parse(A.tool_calls);if(Array.isArray(te)&&te.length>0&&!te.every(re=>c.value.some(ue=>(ue.depth??0)===0&&ue.role==="tool"&&ue.tool_call_id===re.id&&ue.tool_status)))return!0}catch{}return!1});f.value=O}}else if(I.type==="message_chunk"){const T=I.message_id,q=I.chunk,M=c.value.findIndex(O=>O.id===T);if(M>=0){const O=c.value[M].content||"",A={...c.value[M],content:O+q};c.value.splice(M,1,A)}else{const O={id:T,role:"assistant",content:q,created_at:Date.now()*1e3,status:"pending"};c.value.push(O),c.value=c.value.sort((A,B)=>A.created_at-B.created_at)}}else I.type==="event"?console.log("📡",I.eventType,I.data):I.type==="error"&&(g.value=I.error||"WebSocket error",console.error("WebSocket error:",I.error))}catch(I){console.error("Error parsing WebSocket message:",I)}},k.onerror=P=>{g.value="WebSocket connection error",console.error("WebSocket error:",P)},k.onclose=()=>{v.value=!1,k=null,u.value&&a&&(C=setTimeout(()=>{console.log("Attempting WebSocket reconnect..."),j()},3e3))}}catch(N){g.value=N instanceof Error?N.message:"Unknown error",console.error("Error connecting WebSocket:",N)}}function F(){C&&(clearTimeout(C),C=null),k&&(k.close(),k=null,v.value=!1)}async function K(){await U()}function D(N){c.value.push({...N,isOptimistic:!0})}function E(N){c.value=c.value.filter(Z=>Z.id!==N)}async function H(N){if(!u.value)return;const Z=[...c.value];c.value=c.value.filter(G=>G.id!==N);try{if(!(await fetch(J(`/api/threads/${u.value}/messages/${N}`),{method:"DELETE"})).ok)throw c.value=Z,new Error("Failed to delete message")}catch(G){throw c.value=Z,G}}async function R(){if(u.value){f.value=!1;try{if(!(await fetch(J(`/api/threads/${u.value}/stop`),{method:"POST"})).ok)throw new Error("Failed to stop thread")}catch(N){throw console.error("Error stopping thread:",N),N}}}return oe(u,async(N,Z)=>{N!==Z&&(F(),N?(await U(),e&&a&&j()):(c.value=[],d.value=null))},{immediate:e}),Te(()=>{F()}),{messages:V,threadInfo:d,isFetching:r,isLoadingMore:n,error:p,wsConnected:v,wsError:g,isExecuting:f,hasMore:h,totalMessages:w,refetch:K,loadMoreMessages:L,connectWebSocket:j,disconnectWebSocket:F,addOptimisticMessage:D,removeOptimisticMessage:E,deleteMessageById:H,stopThread:R}}const ln=$({__name:"AgentMessages",props:{messages:{type:Array,required:!0},selectedMessageId:{type:[String,null],required:!1},selectedLogId:{type:[String,null],required:!1}},emits:["messageClick","deleteMessage"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(new Set),n=m(new Set),p=m(new Set);function v(D){r.value.has(D)?r.value.delete(D):r.value.add(D)}function g(D){n.value.has(D)?n.value.delete(D):n.value.add(D)}function f(D){p.value.has(D)?p.value.delete(D):p.value.add(D)}function h(D){if(!D)return{};try{return JSON.parse(D)}catch{return{raw:D}}}function w(D){if(!D)return null;const E=h(D),H=Object.keys(E);if(H.length===0)return null;const R=E[H[0]];return typeof R=="string"?R:JSON.stringify(R)}function x(D){return new Date(D/1e3).toLocaleTimeString()}function k(D){const E=Math.round(D/1e6);if(E<1)return"< 1s";if(E<60)return`${E}s`;const H=Math.floor(E/60),R=E%60;return`${H}m ${R}s`}function C(D){if(D.status==="pending")return"...";if(!D.isComplete)return"Working...";let E;return D.request_sent_at&&D.response_completed_at?E=D.response_completed_at-D.request_sent_at:E=D.updated_at-D.created_at,`Worked for ${k(E)}`}function y(D){const E=D.filter(H=>H.type==="content");if(E.length===0){const H=D.filter(R=>R.type==="reasoning");return H.length>0?H[H.length-1].content:null}return E[E.length-1].content}function _(D){const E=D.split(`
2
+ `)[0];return E.length>60?E.substring(0,60):E}function V(D){const E=D.filter(H=>H.type==="tool_call");return E.length===0?null:E[E.length-1].tool_name||null}function U(D){return e.selectedMessageId===D.id?!0:e.selectedLogId?D.items.some(E=>E.log_id===e.selectedLogId):!1}function L(D){return!!(e.selectedLogId&&D.log_id===e.selectedLogId)}function j(){return e.messages.some(D=>D.type==="work"&&!D.isComplete)}function F(D){return!D.isComplete}const K={props:e,emit:c,hoveredMessageId:d,expandedMessages:r,expandedToolCalls:n,expandedReasoning:p,toggleWorkMessage:v,toggleToolCall:g,toggleReasoning:f,parseArguments:h,getArgumentsPreview:w,formatTime:x,formatDuration:k,getWorkStatus:C,getLatestContent:y,getFirstLine:_,getLatestToolName:V,isWorkMessageSelected:U,isWorkItemSelected:L,hasActiveWorkMessage:j,isWorkMessageActive:F,get ChevronDownIcon(){return oo},get ChevronRightIcon(){return to},get AlertTriangleIcon(){return eo},get Trash2Icon(){return wt}};return Object.defineProperty(K,"__isScriptSetup",{enumerable:!1,value:!0}),K}}),nn={class:"space-y-3"},dn=["onMouseenter"],cn=["onClick"],un={key:1,class:"w-full text-center text-xs text-gray-400 dark:text-gray-500 py-1"},pn=["onClick"],mn={key:0,class:"whitespace-pre-wrap text-sm"},gn={key:0,class:"opacity-50"},fn={key:1,class:"opacity-50 italic text-gray-500 dark:text-gray-400"},hn=["onClick"],vn=["onClick"],bn={key:0,class:"space-y-1"},yn={class:"flex items-start gap-2"},xn={class:"flex-1 min-w-0"},kn={key:0,class:"truncate opacity-80"},_n={key:1,class:"italic opacity-60"},wn={class:"flex items-center gap-2 pl-5 opacity-60"},Cn={class:"text-[10px]"},Sn={class:"text-[10px]"},Tn={class:"space-y-2"},Mn={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},In={class:"text-[10px] italic"},Vn={class:"text-[10px] ml-auto"},An={key:0,class:"space-y-1"},Pn=["onClick"],En={class:"font-mono text-[11px] flex-shrink-0"},On={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},jn={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},Ln={key:0,class:"pl-4 space-y-2 text-[10px]"},Dn={key:0},Un={class:"w-full border-collapse"},qn={class:"py-0.5 pr-2 opacity-65 align-top"},Nn={class:"py-0.5 opacity-85 break-all"},Bn={key:1},Rn=["onClick"],Fn={class:"whitespace-pre-wrap break-all"},zn={class:"text-[10px]"},Hn=["onClick"],Wn={key:0,class:"mt-1 pl-4 whitespace-pre-wrap opacity-80"},Jn={class:"text-[10px] opacity-80 pl-4 pb-2"},Kn=["onClick"];function Zn(u,t,a,e,c,d){return s(),l("div",nn,[(s(!0),l(W,null,ne(a.messages,r=>(s(),l("div",{key:r.id,class:ee(["flex items-center gap-2",{"justify-start":r.role==="assistant","justify-end":r.role==="user","justify-center":r.role==="system"}]),onMouseenter:n=>e.hoveredMessageId=r.id,onMouseleave:t[0]||(t[0]=n=>e.hoveredMessageId=null)},[i(" Delete button for user messages (left side) "),r.role==="user"&&e.hoveredMessageId===r.id&&!r.isOptimistic?(s(),l("button",{key:0,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,cn)):i("v-if",!0),i(" Interruption message (iOS style) "),r.type==="text"&&r.role==="system"&&r.content?.includes("Execution stopped")?(s(),l("div",un,b(r.content),1)):r.type==="text"?(s(),l(W,{key:2},[i(" Text Message "),o("div",{class:ee(["max-w-[80%] rounded-2xl px-4 py-2 text-sm cursor-pointer transition-all min-h-[2.5rem]",{"bg-black text-white dark:bg-white dark:text-black":r.role==="assistant"&&!r.silent,"bg-gray-200 text-black dark:bg-gray-800 dark:text-white":r.role==="user"&&!r.silent,"bg-gray-100 text-gray-600 dark:bg-gray-900 dark:text-gray-400 text-xs":r.role==="system"&&!r.silent,"bg-gray-300 text-gray-500 dark:bg-gray-700 dark:text-gray-400 opacity-70 border-2 border-dashed border-gray-400 dark:border-gray-500":r.silent,"ring-2 ring-blue-500":r.id===a.selectedMessageId||a.selectedLogId&&r.log_id===a.selectedLogId,"opacity-60":r.isOptimistic}]),onClick:n=>e.emit("messageClick",r.id,r.log_id||null)},[i(" Message content or typing indicator "),r.content?(s(),l("div",mn,b(r.content),1)):r.status==="pending"?(s(),l(W,{key:1},[i(" Typing indicator for pending messages with no content "),t[1]||(t[1]=o("div",{class:"flex gap-1 items-center min-h-[1.5rem]"},[o("span",{class:"typing-dot",style:{"animation-delay":"0ms"}}),o("span",{class:"typing-dot",style:{"animation-delay":"150ms"}}),o("span",{class:"typing-dot",style:{"animation-delay":"300ms"}})],-1))],2112)):i("v-if",!0),i(" Label and Timestamp (hide when pending) "),r.status!=="pending"?(s(),l("div",{key:2,class:ee(["text-xs mt-1 opacity-60 flex gap-2",{"justify-start":r.role==="assistant","justify-end":r.role!=="assistant"}])},[r.sideLabel?(s(),l("span",gn,b(r.sideLabel),1)):i("v-if",!0),o("span",null,b(e.formatTime(r.created_at)),1),r.silent?(s(),l("span",fn," silent ")):i("v-if",!0)],2)):i("v-if",!0)],10,pn)],2112)):i("v-if",!0),i(" Delete button for assistant messages (right side) "),r.type==="text"&&r.role==="assistant"&&e.hoveredMessageId===r.id&&!r.isOptimistic?(s(),l("button",{key:3,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,hn)):r.type==="work"?(s(),l(W,{key:4},[i(" Work Message "),o("div",{class:ee(["max-w-[80%] min-w-[200px] rounded-lg px-3 py-2 text-xs cursor-pointer transition-all border",{"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700":r.role==="assistant"&&!r.silent,"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:border-blue-800":r.role==="user"&&!r.silent,"bg-gray-200 text-gray-500 border-gray-400 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 opacity-70 border-dashed":r.silent,"ring-2 ring-blue-500":e.isWorkMessageSelected(r)}]),onClick:n=>e.toggleWorkMessage(r.id)},[i(" Collapsed state "),e.expandedMessages.has(r.id)?(s(),l(W,{key:1},[i(" Expanded state "),o("div",Tn,[i(" Status header "),o("div",Mn,[S(e.ChevronDownIcon,{size:14,class:"flex-shrink-0"}),o("span",In,b(e.getWorkStatus(r)),1),o("span",Vn,b(r.items.length)+" operation"+b(r.items.length!==1?"s":""),1)]),(s(!0),l(W,null,ne(r.items,n=>(s(),l("div",{key:n.id,class:"mb-1"},[i(" Tool Call (with merged response) "),n.type==="tool_call"?(s(),l("div",An,[i(" Collapsed: Single row with tool name and status "),o("div",{onClick:he(p=>e.toggleToolCall(n.id),["stop"]),class:ee(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity",{"ring-1 ring-blue-500":e.isWorkItemSelected(n)}])},[e.expandedToolCalls.has(n.id)?(s(),X(e.ChevronDownIcon,{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(s(),X(e.ChevronRightIcon,{key:0,size:12,class:"flex-shrink-0 opacity-50"})),o("span",En,b(n.tool_name),1),e.getArgumentsPreview(n.tool_arguments)?(s(),l("span",On,b(e.getArgumentsPreview(n.tool_arguments)),1)):i("v-if",!0),n.response_status==="success"?(s(),l("span",jn,"✓")):n.response_status==="failed"?(s(),X(e.AlertTriangleIcon,{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):i("v-if",!0)],10,Pn),i(" Expanded: Arguments and Response as tables "),e.expandedToolCalls.has(n.id)?(s(),l("div",Ln,[i(" Arguments table "),n.tool_arguments?(s(),l("div",Dn,[t[2]||(t[2]=o("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),o("table",Un,[o("tbody",null,[(s(!0),l(W,null,ne(e.parseArguments(n.tool_arguments),(p,v)=>(s(),l("tr",{key:v,class:"border-b border-current border-opacity-10"},[o("td",qn,b(v),1),o("td",Nn,b(typeof p=="object"?JSON.stringify(p):p),1)]))),128))])])])):i("v-if",!0),i(" Response "),n.response?(s(),l("div",Bn,[t[3]||(t[3]=o("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),o("div",{class:ee(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-blue-500":a.selectedLogId&&n.response_log_id===a.selectedLogId}]),onClick:he(p=>n.response_log_id&&e.emit("messageClick",r.id,n.response_log_id),["stop"])},[o("div",Fn,b(n.response),1)],10,Rn)])):i("v-if",!0)])):i("v-if",!0)])):n.type==="reasoning"?(s(),l(W,{key:1},[i(" Reasoning (nested expandable) "),o("div",zn,[o("button",{onClick:he(p=>e.toggleReasoning(n.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[e.expandedReasoning.has(n.id)?(s(),X(e.ChevronDownIcon,{key:1,size:12,class:"flex-shrink-0"})):(s(),X(e.ChevronRightIcon,{key:0,size:12,class:"flex-shrink-0"})),t[4]||(t[4]=o("span",{class:"font-semibold"},"Reasoning",-1))],8,Hn),e.expandedReasoning.has(n.id)?(s(),l("div",Wn,b(n.content),1)):i("v-if",!0)])],2112)):n.type==="content"?(s(),l(W,{key:2},[i(" Content "),o("div",Jn,b(n.content),1)],2112)):i("v-if",!0)]))),128))])],2112)):(s(),l("div",bn,[i(" Preview text or status "),o("div",yn,[S(e.ChevronRightIcon,{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),o("div",xn,[e.getLatestContent(r.items)?(s(),l("div",kn,b(e.getFirstLine(e.getLatestContent(r.items)))+"... ",1)):(s(),l("div",_n,b(e.getWorkStatus(r)),1))])]),i(" Status line "),o("div",wn,[o("span",Cn,b(r.items.length)+" operation"+b(r.items.length!==1?"s":""),1),o("span",Sn,"• "+b(e.getWorkStatus(r)),1)])]))],10,vn)],2112)):i("v-if",!0),i(" Delete button for work messages on right side (assistant) "),r.type==="work"&&r.role==="assistant"&&e.hoveredMessageId===r.id?(s(),l("button",{key:5,onClick:he(n=>e.emit("deleteMessage",r.id),["stop"]),class:"flex-shrink-0 w-6 h-6 rounded-full bg-red-500 text-white hover:bg-red-600 flex items-center justify-center transition-all",title:"Delete message"},[S(e.Trash2Icon,{size:14})],8,Kn)):i("v-if",!0)],42,dn))),128))])}const Gn=Q(ln,[["render",Zn],["__scopeId","data-v-9082ef4d"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/AgentMessages.vue"]]),Xn=$({__name:"MessagesPane",props:{threadId:{type:[String,null],required:!0},selectedMessageId:{type:[String,null],required:!1},selectedLogId:{type:[String,null],required:!1}},emits:["collapse","messageClick"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,{messages:d,threadInfo:r,isFetching:n,isLoadingMore:p,error:v,wsConnected:g,wsError:f,isExecuting:h,hasMore:w,totalMessages:x,loadMoreMessages:k,connectWebSocket:C,disconnectWebSocket:y,addOptimisticMessage:_,removeOptimisticMessage:V,deleteMessageById:U,stopThread:L}=sn(z(()=>e.threadId),{enableWebSocket:!0}),{thread:j}=nt(z(()=>e.threadId)),F=m(null);typeof window<"u"&&(window.__testLoadMoreMessages=k);const K=m(""),D=m(null),E=m("B"),H=m(!1),R=m(!1),N=async()=>{await pe(),F.value&&(F.value.scrollTop=F.value.scrollHeight)},Z=async A=>{A.target.scrollTop<100&&w.value&&!p.value&&!R.value&&(R.value=!0,await k(),R.value=!1)};oe(()=>d.value.length,async()=>{!p.value&&!R.value&&await N()}),oe(()=>e.threadId,async A=>{A&&await N()}),oe(n,async(A,B)=>{B&&!A&&await N()});const G=z(()=>{const A=r.value?.agent||j.value?.agent;if(!A)return"ai A";const B=A.type;return E.value==="A"&&A.side_a_label?A.side_a_label:E.value==="B"&&A.side_b_label?A.side_b_label:B==="ai_human"?E.value==="A"?"ai":"human":E.value==="A"?"ai A":"ai B"}),P=()=>{E.value=E.value==="A"?"B":"A"},I=async()=>{if(!K.value.trim()||!e.threadId||H.value)return;const A=K.value,B=E.value==="A"?"assistant":"user",te=`optimistic-${Date.now()}`,le={id:te,role:B,content:A,created_at:Date.now()*1e3,isOptimistic:!0};_(le),K.value="",D.value&&(D.value.style.height="auto",D.value.style.height="24px"),H.value=!0;try{if(!(await fetch(J(`/api/threads/${e.threadId}/message`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:A,role:B})})).ok)throw new Error("Failed to send message");await N()}catch(re){console.error("Error sending message:",re),V(te)}finally{H.value=!1,await pe(),D.value&&D.value.focus()}},O={props:e,emit:c,messages:d,threadInfo:r,isFetching:n,isLoadingMore:p,error:v,wsConnected:g,wsError:f,isExecuting:h,hasMore:w,totalMessages:x,loadMoreMessages:k,connectWebSocket:C,disconnectWebSocket:y,addOptimisticMessage:_,removeOptimisticMessage:V,deleteMessageById:U,stopThread:L,thread:j,messagesContainer:F,messageInput:K,messageTextarea:D,currentSide:E,isSending:H,isLoadingOlder:R,scrollToBottom:N,handleScroll:Z,sideLabel:G,toggleSide:P,sendMessage:I,handleKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),I())},handleDeleteMessage:async A=>{if(e.threadId)try{await U(A)}catch(B){console.error("Error deleting message:",B)}},handleStopThread:async()=>{if(e.threadId)try{await L()}catch(A){console.error("Error stopping thread:",A)}},AgentMessages:Gn,Loader:De,get MessageSquareIcon(){return Ct},get ChevronLeftIcon(){return Ze}};return Object.defineProperty(O,"__isScriptSetup",{enumerable:!1,value:!0}),O}}),Qn={class:"flex flex-col h-full"},Yn={class:"p-4 border-b border-gray-300 dark:border-gray-700"},$n={class:"flex items-center justify-between"},ei={class:"flex items-center gap-2"},ti={class:"flex items-center gap-2"},oi={key:0,class:"text-xs"},ri={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},ai={key:1,class:"text-red-600 dark:text-red-400"},si={key:2,class:"text-gray-400 dark:text-gray-600"},li={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-8"},ni={key:1,class:"flex justify-center py-2"},ii={class:"flex justify-center py-8"},di={class:"text-red-600 dark:text-red-400 text-center py-8"},ci={key:0,class:"p-3 bg-white dark:bg-black"},ui={class:"flex items-start gap-2"},pi={class:"flex-1 flex items-start gap-2 p-2 rounded-2xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900"},mi=["disabled"],gi=["disabled"],fi={key:0,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},hi={key:1,class:"w-4 h-4"};function vi(u,t,a,e,c,d){return s(),l("div",Qn,[i(" Header "),o("div",Yn,[o("div",$n,[o("div",ei,[S(e.MessageSquareIcon,{size:20,class:"flex-shrink-0"}),t[4]||(t[4]=o("h2",{class:"text-xl font-bold"},"Messages",-1))]),o("div",ti,[i(" WebSocket status "),a.threadId?(s(),l("div",oi,[e.wsConnected?(s(),l("span",ri,[...t[5]||(t[5]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",ai," ● Error ")):(s(),l("span",si," ○ Offline "))])):i("v-if",!0),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Messages content "),o("div",{ref:"messagesContainer",class:"flex-1 overflow-y-auto p-4 space-y-4",onScroll:e.handleScroll},[i(" No thread selected "),a.threadId?i("v-if",!0):(s(),l("div",li," Select a thread to view messages ")),i(" Loading older messages indicator "),e.isLoadingMore?(s(),l("div",ni,[S(e.Loader,{size:"sm"}),t[6]||(t[6]=o("span",{class:"ml-2 text-xs text-gray-500"},"Loading older messages...",-1))])):e.isFetching?(s(),l(W,{key:2},[i(" Loading state "),o("div",ii,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:3},[i(" Error state "),o("div",di," Error loading messages: "+b(e.error),1)],2112)):e.messages.length===0?(s(),l(W,{key:4},[i(" Empty state "),t[7]||(t[7]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-8"}," No messages yet ",-1))],2112)):(s(),l(W,{key:5},[i(" Message bubbles (using AgentMessages component) "),S(e.AgentMessages,{messages:e.messages,selectedMessageId:a.selectedMessageId,selectedLogId:a.selectedLogId,onMessageClick:t[1]||(t[1]=(r,n)=>e.emit("messageClick",r,n)),onDeleteMessage:e.handleDeleteMessage},null,8,["messages","selectedMessageId","selectedLogId"])],2112))],544),i(" Message input section (iOS-style single bubble) "),a.threadId?(s(),l("div",ci,[o("div",ui,[i(" Side toggle tag (outside bubble) "),o("button",{onClick:e.toggleSide,class:ee(["flex-shrink-0 px-2 h-7 rounded-md flex items-center justify-center font-medium text-xs transition-colors mt-2.5",{"bg-black text-white dark:bg-white dark:text-black":e.currentSide==="A","bg-gray-300 text-black dark:bg-gray-600 dark:text-white":e.currentSide==="B"}]),title:"Toggle between sides"},b(e.sideLabel),3),i(" Input bubble "),o("div",pi,[i(" Message input (no border, transparent) "),fe(o("textarea",{ref:"messageTextarea","onUpdate:modelValue":t[2]||(t[2]=r=>e.messageInput=r),onKeydown:e.handleKeyDown,disabled:e.isSending,placeholder:"Type a message...",rows:"1",class:"flex-1 bg-transparent text-black dark:text-white resize-none focus:outline-none disabled:opacity-50 mt-0.5",style:{"max-height":"120px","min-height":"24px"},onInput:t[3]||(t[3]=r=>{const n=r.target;n.style.height="auto",n.style.height=Math.min(n.scrollHeight,120)+"px"})},null,40,mi),[[_e,e.messageInput]]),i(" Send/Stop button (inside bubble) "),e.isExecuting?(s(),l(W,{key:1},[i(" Stop button (shown when thread is executing) "),o("button",{id:"stop-thread-button",onClick:e.handleStopThread,class:"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all bg-red-600 text-white dark:bg-red-500 hover:bg-red-700 dark:hover:bg-red-600",title:"Stop execution"},[...t[9]||(t[9]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",class:"w-4 h-4"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"})],-1)])])],2112)):(s(),l("button",{key:0,id:"send-message-button",onClick:e.sendMessage,disabled:!e.messageInput.trim()||e.isSending,class:ee(["flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center transition-all",{"bg-black text-white dark:bg-white dark:text-black":e.messageInput.trim()&&!e.isSending,"bg-gray-200 text-gray-400 dark:bg-gray-700 dark:text-gray-600":!e.messageInput.trim()||e.isSending}]),title:"Send message (Enter)"},[e.isSending?(s(),l("div",hi,[S(e.Loader)])):(s(),l("svg",fi,[...t[8]||(t[8]=[o("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,gi))])])])):i("v-if",!0)])}const bi=Q(Xn,[["render",vi],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/MessagesPane.vue"]]),yi=$({__name:"MetaPane",props:{threadId:{type:[String,null],required:!0}},emits:["collapse","threadDeleted","editThread"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,{thread:d,isFetching:r,error:n}=nt(z(()=>e.threadId)),p=m(!1),v=m(!1),g=m(!1),f=m(!1),h=m(""),w=m(!1),x=m(!1),k=m(null),{data:C,isFetching:y}=ve(J("/api/agents"),{refetch:!0}).json(),_=z(()=>C.value?.agents?C.value.agents.filter(R=>R.type==="ai_human").map(R=>({value:R.id,label:R.title,description:`Type: ${R.type}`})):[]),V=z(()=>d.value?.agent.type==="ai_human"),H={props:e,emit:c,thread:d,isFetching:r,error:n,showDeleteConfirm:p,isDeleting:v,isEditingAgent:g,isSavingAgent:f,selectedAgentId:h,showCostBreakdown:w,isFetchingCost:x,costData:k,agentsData:C,isFetchingAgents:y,aiHumanAgents:_,isAiHumanAgent:V,formatDate:R=>new Date(R*1e3).toLocaleString(),startEditingAgent:()=>{d.value&&(h.value=d.value.agent.id,g.value=!0)},cancelEditingAgent:()=>{g.value=!1,h.value=""},saveAgent:async()=>{if(!(!e.threadId||!h.value)){f.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:h.value})});if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to update agent")}window.location.reload()}catch(R){console.error("Error updating agent:",R),alert(`Failed to update agent: ${R.message}`)}finally{f.value=!1}}},fetchCostBreakdown:async()=>{if(e.threadId){x.value=!0,w.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}/cost`));if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to fetch cost breakdown")}k.value=await R.json()}catch(R){console.error("Error fetching cost breakdown:",R),alert(`Failed to fetch cost breakdown: ${R.message}`),w.value=!1}finally{x.value=!1}}},formatCurrency:R=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(R),handleDeleteThread:async()=>{if(e.threadId){v.value=!0;try{const R=await fetch(J(`/api/threads/${e.threadId}`),{method:"DELETE"});if(!R.ok){const N=await R.json();throw new Error(N.error||"Failed to delete thread")}c("threadDeleted",e.threadId)}catch(R){console.error("Error deleting thread:",R),alert(`Failed to delete thread: ${R.message}`)}finally{v.value=!1}}},Loader:De,ConfirmDialog:Pt,SelectInput:xe,get InfoIcon(){return St},get ChevronLeftIcon(){return Ze},get Trash2Icon(){return wt},get PencilIcon(){return ao},get DollarSignIcon(){return ro}};return Object.defineProperty(H,"__isScriptSetup",{enumerable:!1,value:!0}),H}}),xi={class:"flex flex-col h-full"},ki={class:"p-4 border-b border-gray-300 dark:border-gray-700"},_i={class:"flex items-center justify-between"},wi={class:"flex items-center gap-2"},Ci={class:"flex-1 overflow-y-auto p-4"},Si={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-8"},Ti={class:"flex justify-center py-8"},Mi={class:"text-red-600 dark:text-red-400 text-center py-8"},Ii={class:"space-y-4"},Vi={class:"text-sm font-mono break-all"},Ai={class:"flex items-center justify-between mb-2"},Pi={key:0},Ei={class:"text-sm"},Oi={class:"text-xs text-gray-500 dark:text-gray-500 mt-1"},ji={key:1,class:"space-y-2"},Li={class:"flex gap-2"},Di=["disabled"],Ui=["disabled"],qi={class:"text-sm"},Ni={key:0},Bi={class:"text-sm font-mono"},Ri={class:"flex items-center justify-between mb-2"},Fi={key:0,class:"flex flex-wrap gap-2"},zi={key:1,class:"text-sm text-gray-500 dark:text-gray-500 italic"},Hi={class:"flex items-center justify-between mb-2"},Wi=["disabled"],Ji={key:0,class:"flex justify-center py-4"},Ki={key:1,class:"space-y-3"},Zi={class:"grid grid-cols-2 gap-2 text-xs"},Gi={class:"p-2 bg-gray-100 dark:bg-gray-900 rounded"},Xi={class:"font-mono font-bold"},Qi={class:"p-2 bg-gray-100 dark:bg-gray-900 rounded"},Yi={class:"font-mono font-bold"},$i={key:0,class:"space-y-2"},ed={class:"overflow-x-auto"},td={class:"w-full text-xs"},od={class:"py-2 pr-2 font-medium"},rd={class:"text-right py-2 px-2 font-mono"},ad={class:"text-right py-2 px-2 font-mono"},sd={class:"text-right py-2 pl-2 font-mono"},ld={key:1,class:"text-xs text-gray-500 dark:text-gray-500 italic py-2"},nd={class:"pt-4 mt-4 border-t border-red-300 dark:border-red-700"},id=["disabled"],dd={key:0},cd={key:1};function ud(u,t,a,e,c,d){return s(),l("div",xi,[i(" Header "),o("div",ki,[o("div",_i,[o("div",wi,[S(e.InfoIcon,{size:20,class:"flex-shrink-0"}),t[6]||(t[6]=o("h2",{class:"text-xl font-bold"},"Metadata",-1))]),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])]),i(" Content "),o("div",Ci,[i(" No thread selected "),a.threadId?e.isFetching?(s(),l(W,{key:1},[i(" Loading state "),o("div",Ti,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:2},[i(" Error state "),o("div",Mi," Error loading metadata: "+b(e.error),1)],2112)):e.thread?(s(),l(W,{key:3},[i(" Metadata display "),o("div",Ii,[i(" Thread ID "),o("div",null,[t[7]||(t[7]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," Thread ID ",-1)),o("div",Vi,b(e.thread.id),1)]),i(" Agent "),o("div",null,[o("div",Ai,[t[9]||(t[9]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Agent ",-1)),e.isAiHumanAgent&&!e.isEditingAgent?(s(),l("button",{key:0,onClick:e.startEditingAgent,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Change agent"},[S(e.PencilIcon,{size:12}),t[8]||(t[8]=o("span",null,"Change",-1))])):i("v-if",!0)]),e.isEditingAgent?(s(),l("div",ji,[S(e.SelectInput,{modelValue:e.selectedAgentId,"onUpdate:modelValue":t[1]||(t[1]=r=>e.selectedAgentId=r),options:e.aiHumanAgents,loading:e.isFetchingAgents,placeholder:"Select an agent"},null,8,["modelValue","options","loading"]),o("div",Li,[o("button",{onClick:e.saveAgent,disabled:e.isSavingAgent||!e.selectedAgentId,class:"flex-1 px-3 py-2 text-sm bg-black dark:bg-white text-white dark:text-black hover:bg-black/80 dark:hover:bg-white/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},b(e.isSavingAgent?"Saving...":"Save"),9,Di),o("button",{onClick:e.cancelEditingAgent,disabled:e.isSavingAgent,class:"flex-1 px-3 py-2 text-sm border border-black dark:border-white hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"}," Cancel ",8,Ui)])])):(s(),l("div",Pi,[o("div",Ei,b(e.thread.agent.title),1),o("div",Oi," Type: "+b(e.thread.agent.type),1)]))]),i(" Created At "),o("div",null,[t[10]||(t[10]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," Created ",-1)),o("div",qi,b(e.formatDate(e.thread.created_at)),1)]),i(" User ID "),e.thread.user_id?(s(),l("div",Ni,[t[11]||(t[11]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400 mb-1"}," User ID ",-1)),o("div",Bi,b(e.thread.user_id),1)])):i("v-if",!0),i(" Tags "),o("div",null,[o("div",Ri,[t[13]||(t[13]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Tags ",-1)),o("button",{onClick:t[2]||(t[2]=r=>e.emit("editThread")),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Edit thread"},[S(e.PencilIcon,{size:12}),t[12]||(t[12]=o("span",null,"Edit",-1))])]),e.thread.tags?.length>0?(s(),l("div",Fi,[(s(!0),l(W,null,ne(e.thread.tags,r=>(s(),l("span",{key:r,class:"inline-block px-3 py-1 text-sm rounded bg-black text-white dark:bg-white dark:text-black"},b(r),1))),128))])):(s(),l("div",zi," No tags "))]),i(" Cost Breakdown "),o("div",null,[o("div",Hi,[t[15]||(t[15]=o("div",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"}," Cost Analysis ",-1)),e.showCostBreakdown?(s(),l("button",{key:1,onClick:t[3]||(t[3]=r=>e.showCostBreakdown=!1),type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors",title:"Hide cost breakdown"},[...t[14]||(t[14]=[o("span",null,"Hide",-1)])])):(s(),l("button",{key:0,onClick:e.fetchCostBreakdown,disabled:e.isFetchingCost,type:"button",class:"flex items-center gap-1 px-2 py-1 text-xs border border-black dark:border-white rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"View cost breakdown"},[S(e.DollarSignIcon,{size:12}),o("span",null,b(e.isFetchingCost?"Loading...":"View Costs"),1)],8,Wi))]),e.isFetchingCost?(s(),l("div",Ji,[S(e.Loader)])):e.showCostBreakdown&&e.costData?(s(),l("div",Ki,[i(" Summary Stats "),o("div",Zi,[o("div",Gi,[t[16]||(t[16]=o("div",{class:"text-gray-500 dark:text-gray-500 mb-1"},"Total Cost",-1)),o("div",Xi,b(e.formatCurrency(e.costData.totalCost)),1)]),o("div",Qi,[t[17]||(t[17]=o("div",{class:"text-gray-500 dark:text-gray-500 mb-1"},"Avg/Message",-1)),o("div",Yi,b(e.formatCurrency(e.costData.avgCostPerMessage)),1)])]),i(" Model Breakdown Table "),e.costData.modelBreakdown.length>0?(s(),l("div",$i,[t[19]||(t[19]=o("div",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"}," By Model ",-1)),o("div",ed,[o("table",td,[t[18]||(t[18]=o("thead",{class:"border-b border-gray-300 dark:border-gray-700"},[o("tr",null,[o("th",{class:"text-left py-2 pr-2 font-medium text-gray-600 dark:text-gray-400"},"Model"),o("th",{class:"text-right py-2 px-2 font-medium text-gray-600 dark:text-gray-400"},"Requests"),o("th",{class:"text-right py-2 px-2 font-medium text-gray-600 dark:text-gray-400"},"Total"),o("th",{class:"text-right py-2 pl-2 font-medium text-gray-600 dark:text-gray-400"},"Avg/Req")])],-1)),o("tbody",null,[(s(!0),l(W,null,ne(e.costData.modelBreakdown,r=>(s(),l("tr",{key:r.modelName,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("td",od,b(r.modelName),1),o("td",rd,b(r.requestCount),1),o("td",ad,b(e.formatCurrency(r.totalCost)),1),o("td",sd,b(e.formatCurrency(r.avgCostPerRequest)),1)]))),128))])])])])):(s(),l("div",ld," No cost data available for this thread "))])):i("v-if",!0)]),i(" Danger Zone "),o("div",nd,[t[20]||(t[20]=o("div",{class:"text-sm font-medium text-red-600 dark:text-red-400 mb-2"}," Danger Zone ",-1)),o("button",{onClick:t[4]||(t[4]=r=>e.showDeleteConfirm=!0),disabled:e.isDeleting,class:"flex items-center gap-2 px-3 py-2 text-sm bg-white dark:bg-black text-red-600 border-2 border-red-600 hover:bg-red-50 dark:hover:bg-red-950/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[S(e.Trash2Icon,{size:16}),e.isDeleting?(s(),l("span",dd,"Deleting...")):(s(),l("span",cd,"Delete Thread"))],8,id),t[21]||(t[21]=o("p",{class:"text-xs text-gray-500 dark:text-gray-500 mt-2"}," This will permanently delete the thread, all messages, and all logs. This action cannot be undone. ",-1))])])],2112)):i("v-if",!0):(s(),l("div",Si," Select a thread to view metadata "))]),i(" Delete Confirmation Dialog "),S(e.ConfirmDialog,{modelValue:e.showDeleteConfirm,"onUpdate:modelValue":t[5]||(t[5]=r=>e.showDeleteConfirm=r),title:"Delete Thread?",message:"Are you sure you want to delete this thread? This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete Thread","cancel-text":"Cancel",onConfirm:e.handleDeleteThread},null,8,["modelValue"])])}const pd=Q(yi,[["render",ud],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/MetaPane.vue"]]);function md(u,t){const{limit:a=100,offset:e=0,order:c="desc",autoFetch:d=!0,enableWebSocket:r=!1}=t||{};z(()=>!!(typeof u=="string"?u:u?.value));const n=z(()=>{const D=typeof u=="string"?u:u?.value;if(!D)return J("/api/threads/placeholder/logs");const E=new URLSearchParams,H=typeof a=="number"?a:a.value,R=typeof e=="number"?e:e.value,N=typeof c=="string"?c:c.value;return E.append("limit",H.toString()),E.append("offset",R.toString()),E.append("order",N),J(`/api/threads/${D}/logs?${E.toString()}`)}),{data:p,error:v,isFetching:g,isFinished:f,execute:h,abort:w}=ve(n,{immediate:!1}).get().json();oe([n,()=>d],([D,E])=>{D&&!D.includes("placeholder")&&E&&h()},{immediate:!0});const x=z(()=>!v.value||v.value.toString().includes("aborted")||v.value.toString().includes("abort")?null:v.value),k=z(()=>p.value?.logs||[]),C=z(()=>p.value?.total||0),y=z(()=>p.value?.hasMore||!1),_=m(null),V=m(!1),U=m(null),L=m([]),j=()=>{const D=typeof u=="string"?u:u?.value;if(!D||!r)return;_.value&&_.value.close(),L.value=[];const E=window.location.protocol==="https:"?"wss:":"ws:",H=window.location.host;let R=`${E}//${H}${J(`/api/threads/${D}/logs`)}`;const N=localStorage.getItem("auth_token");N&&(R+=`?token=${encodeURIComponent(N)}`);try{_.value=new WebSocket(R),_.value.onopen=()=>{V.value=!0,U.value=null,console.log("WebSocket connected for logs")},_.value.onmessage=Z=>{try{const G=JSON.parse(Z.data);if(G.type==="log_data"){const P=L.value.findIndex(T=>T.id===G.log_id),I=k.value.find(T=>T.id===G.log_id);P>=0?(L.value[P]={...L.value[P],...G.data},console.log("[WebSocket] Updated existing realtime log:",G.log_id)):I?(L.value.push({...I,...G.data}),console.log("[WebSocket] Updated HTTP log:",G.log_id)):(L.value.push({id:G.log_id,...G.data}),console.log("[WebSocket] Added new log:",G.log_id))}}catch(G){console.error("Failed to parse WebSocket message:",G)}},_.value.onerror=Z=>{U.value="WebSocket connection error",V.value=!1,console.error("WebSocket error:",Z)},_.value.onclose=()=>{V.value=!1,console.log("WebSocket disconnected")}}catch(Z){U.value=Z.message||"Failed to create WebSocket",console.error("WebSocket creation error:",Z)}},F=()=>{_.value&&(_.value.close(),_.value=null,V.value=!1),L.value=[]};return Te(()=>{F()}),{logs:z(()=>{if(!r)return k.value;const D=new Map;k.value.forEach(R=>D.set(R.id,R)),L.value.forEach(R=>D.set(R.id,R));const E=typeof c=="string"?c:c.value;return Array.from(D.values()).sort((R,N)=>E==="desc"?N.created_at-R.created_at:R.created_at-N.created_at)}),total:C,hasMore:y,error:x,isFetching:g,isFinished:f,refetch:h,abort:w,wsConnected:V,wsError:U,connectWebSocket:j,disconnectWebSocket:F}}function gd(u,t){const a=z(()=>{const n=u.value,p=t.value;return!n||!p?null:J(`/api/threads/${n}/logs/${p}`)}),{data:e,error:c,isFetching:d,execute:r}=ve(a,{immediate:!1}).get().json();return oe([u,t],([n,p])=>{n&&p&&r()},{immediate:!0}),{logDetails:e,error:c,isFetching:d,refetch:r}}const fd=$({__name:"CopyButton",props:{content:{type:String,required:!0},variant:{type:String,required:!1},size:{type:String,required:!1},disabled:{type:Boolean,required:!1}},setup(u,{expose:t}){t();const a=u,e=m(!1),c=m(!1),p={props:a,copying:e,copied:c,copyToClipboard:async()=>{e.value=!0;try{await navigator.clipboard.writeText(a.content),c.value=!0,setTimeout(()=>{c.value=!1},2e3)}catch(v){console.error("Failed to copy:",v),alert(`Failed to copy: ${v instanceof Error?v.message:"Unknown error"}`)}finally{e.value=!1}},sizeClasses:{xs:"p-1 text-xs",sm:"px-2 py-1 text-xs"},variantClasses:{solid:"bg-black text-white dark:bg-white dark:text-black",ghost:"bg-white dark:bg-gray-950 border border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-900"},Loader:De};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),hd=["disabled","title"],vd={key:1,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},bd={key:2,xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},yd={key:3};function xd(u,t,a,e,c,d){return s(),l("button",{onClick:e.copyToClipboard,disabled:e.copying||a.disabled,class:ee([e.sizeClasses[a.size||"sm"],e.variantClasses[a.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:a.disabled?"No content to copy":e.copied?"Copied!":"Copy to clipboard"},[e.copying?(s(),X(e.Loader,{key:0,size:"xs"})):a.variant==="ghost"&&!e.copied?(s(),l("svg",vd,[...t[0]||(t[0]=[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):a.variant==="ghost"&&e.copied?(s(),l("svg",bd,[...t[1]||(t[1]=[o("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(s(),l("span",yd,b(e.copied?"Copied!":"Copy"),1))],10,hd)}const kd=Q(fd,[["render",xd],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/CopyButton.vue"]]),_d=$({__name:"LogDetails",props:{log:{type:null,required:!0}},emits:["close"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m("request"),r=m(new Set),n=m(new Set),p=m(!1),v=m(!1),g=m(null),f=j=>{if(!j)return"N/A";try{return JSON.stringify(JSON.parse(j),null,2)}catch{return j}},h=z(()=>{if(!e.log.tools_schema)return[];try{const j=JSON.parse(e.log.tools_schema);return Array.isArray(j)?j:[]}catch{return[]}}),w=z(()=>{if(!e.log.response_body)return[];try{const F=JSON.parse(e.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(F)?F:[]}catch{return[]}}),x=z(()=>{if(!e.log.tool_results)return new Map;try{const j=JSON.parse(e.log.tool_results),F=new Map;return Array.isArray(j)&&j.forEach(K=>{K.tool_call_id&&F.set(K.tool_call_id,{content:K.content,status:K.status,tool_name:K.tool_name,timestamp:K.timestamp})}),F}catch{return new Map}}),k=z(()=>{if(!e.log.response_body)return[];try{const F=JSON.parse(e.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(F)?F:[]}catch{return[]}}),C=j=>{r.value.has(j)?r.value.delete(j):r.value.add(j)},y=j=>{n.value.has(j)?n.value.delete(j):n.value.add(j)},_=z(()=>{if(!e.log.errors)return[];try{const j=JSON.parse(e.log.errors);return Array.isArray(j)?j:[]}catch{return[]}}),V=()=>{pe(()=>{g.value&&(g.value.scrollTop=g.value.scrollHeight)})};oe(()=>e.log.message_history,()=>{V()},{immediate:!0});const L={props:e,emit:c,activeTab:d,expandedTools:r,expandedToolCalls:n,copyingCurl:p,copiedCurl:v,messagesContainer:g,formatJson:f,tools:h,toolCallsDetailed:w,toolResults:x,reasoningDetails:k,toggleTool:C,toggleToolCall:y,errorsArray:_,scrollMessagesToBottom:V,copyCurlCommand:async()=>{p.value=!0;try{if(!e.log.request_body||!e.log.model)throw new Error("Missing request data");const j=await fetch(J(`/api/models/${e.log.model}/curl-data`));if(!j.ok)throw new Error("Failed to fetch model data");const F=await j.json(),K=f(e.log.request_body);let D=`curl -X POST '${F.endpoint}' \\
3
3
  `;D+=` -H 'Content-Type: application/json' \\
4
4
  `,F.sdk?.toLowerCase()==="openrouter"?(D+=` -H 'Authorization: Bearer ${F.api_key}' \\
5
5
  `,D+=` -H 'HTTP-Referer: https://agentkit.local' \\
6
6
  `,D+=` -H 'X-Title: AgentKit' \\
7
7
  `):F.sdk?.toLowerCase()==="openai"&&(D+=` -H 'Authorization: Bearer ${F.api_key}' \\
8
- `),D+=` -d '${K.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(D),v.value=!0,setTimeout(()=>{v.value=!1},2e3)}catch(j){console.error("Failed to copy cURL command:",j),alert(`Failed to copy cURL: ${j instanceof Error?j.message:"Unknown error"}`)}finally{p.value=!1}},Loader:De,TimeAgo:it,CopyButton:kd};return Object.defineProperty(L,"__isScriptSetup",{enumerable:!1,value:!0}),L}}),wd={class:"p-4 h-full overflow-y-auto"},Cd={class:"flex items-center justify-between mb-3"},Sd={class:"text-lg font-bold"},Td={class:"flex items-center gap-2"},Md=["disabled","title"],Id={key:1},Vd={class:"@container border-b border-gray-300 dark:border-gray-700 pb-3 mb-3"},Ad={class:"hidden @[600px]:block"},Pd={class:"w-full text-xs"},Ed={class:"py-1 font-mono"},Od={class:"py-1 font-mono"},jd={key:1},Ld={class:"py-1 font-mono"},Dd={key:1},Ud={class:"py-1 font-mono"},qd={key:1},Nd={class:"py-1 font-mono"},Bd={key:1},Rd={class:"py-1 font-mono text-xs"},Fd={class:"@[600px]:hidden space-y-2"},zd={class:"w-full text-xs"},Hd={class:"py-1 font-mono"},Wd={class:"py-1 font-mono"},Jd={key:1},Kd={class:"w-full text-xs"},Zd={class:"py-1 font-mono"},Gd={key:1},Xd={class:"py-1 font-mono"},Qd={key:1},Yd={class:"py-1 font-mono"},$d={key:1},ec={class:"py-1 font-mono text-xs"},tc={class:"border-b border-gray-300 dark:border-gray-700 mb-3"},oc={class:"flex gap-4"},rc={key:0,class:"text-red-600 dark:text-red-400"},ac={class:"space-y-3"},sc={key:0,class:"mb-4"},lc={class:"text-xs font-semibold mb-1"},nc={class:"relative"},ic={class:"absolute top-[5px] right-[5px]"},dc={key:1,class:"mb-4"},cc={class:"relative"},uc={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-32"},pc={class:"absolute top-[5px] right-[5px]"},mc={key:2,class:"mb-4"},gc={class:"text-xs font-semibold mb-1"},fc={class:"border border-gray-300 dark:border-gray-700 rounded overflow-hidden"},hc=["onClick"],vc={class:"font-mono"},bc={class:"text-gray-500"},yc={class:"px-2 py-2 bg-gray-50 dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800"},xc={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mb-2"},kc={class:"text-xs overflow-x-auto"},_c={key:3,class:"mb-4"},wc={class:"relative"},Cc={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-64"},Sc={class:"absolute top-[5px] right-[5px]"},Tc={key:0,class:"mb-4"},Mc={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Ic={class:"space-y-2"},Vc={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},Ac={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},Pc={class:"mb-4"},Ec={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Oc={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},jc={key:2,class:"mb-4"},Lc={class:"w-full text-xs border border-gray-300 dark:border-gray-700 rounded"},Dc={class:"border-b border-gray-200 dark:border-gray-800"},Uc={class:"py-1 px-2 font-mono"},qc={key:1},Nc={class:"border-b border-gray-200 dark:border-gray-800"},Bc={class:"py-1 px-2 font-mono"},Rc={key:1},Fc={key:0,class:"border-b border-gray-200 dark:border-gray-800"},zc={class:"py-1 px-2 font-mono"},Hc={key:1},Wc={class:"border-b border-gray-200 dark:border-gray-800"},Jc={class:"py-1 px-2 font-mono"},Kc={key:1},Zc={key:1,class:"border-b border-gray-200 dark:border-gray-800"},Gc={class:"py-1 px-2 font-mono text-blue-600 dark:text-blue-400"},Xc={class:"border-b border-gray-200 dark:border-gray-800"},Qc={class:"py-1 px-2 font-mono font-semibold"},Yc={key:1},$c={class:"py-1 px-2 font-mono font-semibold"},eu={key:1},tu={key:3,class:"mb-4"},ou={class:"text-xs font-semibold mb-1"},ru={class:"border border-gray-300 dark:border-gray-700 rounded overflow-hidden"},au=["onClick"],su={class:"font-mono"},lu={class:"text-gray-500"},nu={class:"px-2 py-2 bg-gray-50 dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800"},iu={class:"text-xs mb-2"},du={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-gray-200 dark:border-gray-800"},cu={class:"text-xs mb-2"},uu={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-gray-200 dark:border-gray-800"},pu={class:"text-xs mb-2"},mu={class:"text-xs overflow-x-auto bg-white dark:bg-black p-2 rounded border border-gray-200 dark:border-gray-800"},gu={key:0,class:"text-xs"},fu={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},hu={key:1,class:"text-xs"},vu={key:4,class:"mb-4"},bu={class:"border border-blue-300 dark:border-blue-700 rounded overflow-hidden bg-blue-50 dark:bg-blue-950/20"},yu={class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-blue-900 dark:text-blue-100"},xu={key:5,class:"mb-4"},ku={class:"text-xs font-semibold mb-1"},_u={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},wu={class:"divide-y divide-purple-200 dark:divide-purple-800"},Cu={class:"flex items-center gap-2 mb-1"},Su={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},Tu={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},Mu={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},Iu={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},Vu={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Au={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Pu={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Eu={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},Ou={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},ju={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Lu={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},Du={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},Uu={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},qu={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},Nu={key:6,class:"mb-4"},Bu={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-96"};function Ru(u,t,a,e,c,d){return s(),l("div",wd,[i(" Header "),o("div",Cd,[o("h3",Sd,b(a.log.prompt_name||a.log.model_name||a.log.model),1),o("div",Td,[o("button",{onClick:e.copyCurlCommand,disabled:e.copyingCurl||!a.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:a.log.request_body?"Copy cURL command":"No request data available"},[e.copyingCurl?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Id,b(e.copiedCurl?"Copied!":"Copy cURL"),1))],8,Md),o("button",{onClick:t[0]||(t[0]=r=>e.emit("close")),class:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":"Close details"}," ✕ ")])]),i(" Summary Table "),o("div",Vd,[i(" Single table for wider containers "),o("div",Ad,[o("table",Pd,[t[3]||(t[3]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Status"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Provider"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Prompt"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Latency"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Tokens"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Cost"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Created")])],-1)),o("tbody",null,[o("tr",null,[o("td",{class:ee(["py-1 font-mono",a.log.error?"text-red-600 dark:text-red-400":a.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},b(a.log.error?"ERROR":a.log.is_complete?"SUCCESS":"LOADING"),3),o("td",Ed,b(a.log.provider),1),o("td",Od,[!a.log.is_complete&&!a.log.prompt_name?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",jd,b(a.log.prompt_name||"—"),1))]),o("td",Ld,[!a.log.is_complete&&!a.log.latency_ms?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Dd,b(a.log.latency_ms?`${a.log.latency_ms}ms`:"—"),1))]),o("td",Ud,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",qd,b(a.log.total_tokens?`${a.log.input_tokens}/${a.log.output_tokens} (${a.log.total_tokens})`:"—"),1))]),o("td",Nd,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Bd,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))]),o("td",Rd,[S(e.TimeAgo,{timestamp:a.log.created_at},null,8,["timestamp"])])])])])]),i(" Two stacked tables for narrow containers "),o("div",Fd,[i(" First table: Status, Provider, Prompt "),o("table",zd,[t[4]||(t[4]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Status"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Provider"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Prompt")])],-1)),o("tbody",null,[o("tr",null,[o("td",{class:ee(["py-1 font-mono",a.log.error?"text-red-600 dark:text-red-400":a.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},b(a.log.error?"ERROR":a.log.is_complete?"SUCCESS":"LOADING"),3),o("td",Hd,b(a.log.provider),1),o("td",Wd,[!a.log.is_complete&&!a.log.prompt_name?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Jd,b(a.log.prompt_name||"—"),1))])])])]),i(" Second table: Latency, Tokens, Cost, Created "),o("table",Kd,[t[5]||(t[5]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Latency"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Tokens"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Cost"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Created")])],-1)),o("tbody",null,[o("tr",null,[o("td",Zd,[!a.log.is_complete&&!a.log.latency_ms?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Gd,b(a.log.latency_ms?`${a.log.latency_ms}ms`:"—"),1))]),o("td",Xd,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Qd,b(a.log.total_tokens?`${a.log.input_tokens}/${a.log.output_tokens} (${a.log.total_tokens})`:"—"),1))]),o("td",Yd,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",$d,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))]),o("td",ec,[S(e.TimeAgo,{timestamp:a.log.created_at},null,8,["timestamp"])])])])])])]),i(" Tabs "),o("div",tc,[o("div",oc,[o("button",{onClick:t[1]||(t[1]=r=>e.activeTab="request"),class:ee(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",e.activeTab==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white"])}," Request ",2),o("button",{onClick:t[2]||(t[2]=r=>e.activeTab="response"),class:ee(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",e.activeTab==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white"])},[t[6]||(t[6]=ie(" Response ",-1)),a.log.error||e.errorsArray.length>0?(s(),l("span",rc,"⚠")):i("v-if",!0)],2)])]),i(" Tab Content "),o("div",ac,[i(" Request Tab "),fe(o("div",null,[i(" Messages (actual messages sent to LLM) - Moved to top, taller, auto-scroll to bottom "),a.log.message_history?(s(),l("div",sc,[o("div",lc,"Messages ("+b(a.log.message_history_length||0)+" messages)",1),o("div",nc,[o("pre",{ref:"messagesContainer",class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-[600px] overflow-y-auto"},b(e.formatJson(a.log.message_history)),513),o("div",ic,[S(e.CopyButton,{content:e.formatJson(a.log.message_history),variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0),i(" System Prompt "),a.log.system_prompt?(s(),l("div",dc,[t[7]||(t[7]=o("div",{class:"text-xs font-semibold mb-1"},"System Prompt",-1)),o("div",cc,[o("pre",uc,b(a.log.system_prompt),1),o("div",pc,[S(e.CopyButton,{content:a.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0),i(" Tools "),e.tools.length>0?(s(),l("div",mc,[o("div",gc,"Available Tools ("+b(e.tools.length)+")",1),o("div",fc,[(s(!0),l(W,null,ne(e.tools,(r,n)=>(s(),l("div",{key:n,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("button",{onClick:p=>e.toggleTool(n),class:"w-full px-2 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors flex items-center justify-between text-xs"},[o("span",vc,b(r.function?.name||r.name||"Unknown"),1),o("span",bc,b(e.expandedTools.has(n)?"▼":"▶"),1)],8,hc),fe(o("div",yc,[r.function?.description||r.description?(s(),l("div",xc,b(r.function?.description||r.description),1)):i("v-if",!0),o("pre",kc,b(JSON.stringify(r,null,2)),1)],512),[[Ne,e.expandedTools.has(n)]])]))),128))])])):i("v-if",!0),i(" Request Body "),a.log.request_body?(s(),l("div",_c,[t[8]||(t[8]=o("div",{class:"text-xs font-semibold mb-1"},"Full Request Body",-1)),o("div",wc,[o("pre",Cc,b(e.formatJson(a.log.request_body)),1),o("div",Sc,[S(e.CopyButton,{content:e.formatJson(a.log.request_body),variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0)],512),[[Ne,e.activeTab==="request"]]),i(" Response Tab "),fe(o("div",null,[i(" Errors (Multiple errors from errors array) "),e.errorsArray.length>0?(s(),l("div",Tc,[o("div",Mc,b(e.errorsArray.length>1?`Errors (${e.errorsArray.length})`:"Error"),1),o("div",Ic,[(s(!0),l(W,null,ne(e.errorsArray,(r,n)=>(s(),l("div",{key:n,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[o("div",Vc,b(r.type||"error"),1),o("pre",Ac,b(r.message),1)]))),128))])])):a.log.error?(s(),l(W,{key:1},[i(" Fallback: Single error (for backwards compatibility) "),o("div",Pc,[o("div",Ec," Error "+b(a.log.error_type?`(${a.log.error_type})`:""),1),o("pre",Oc,b(a.log.error),1)])],2112)):i("v-if",!0),i(" Response Stats "),a.log.is_complete||!a.log.error?(s(),l("div",jc,[t[16]||(t[16]=o("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),o("table",Lc,[o("tbody",null,[o("tr",Dc,[t[9]||(t[9]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Finish Reason",-1)),o("td",Uc,[!a.log.is_complete&&!a.log.finish_reason?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",qc,b(a.log.finish_reason||"—"),1))])]),o("tr",Nc,[t[10]||(t[10]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Input Tokens",-1)),o("td",Bc,[!a.log.is_complete&&!a.log.input_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Rc,b(a.log.input_tokens||"—"),1))])]),a.log.cached_tokens||!a.log.is_complete?(s(),l("tr",Fc,[t[11]||(t[11]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Cached Tokens",-1)),o("td",zc,[!a.log.is_complete&&!a.log.cached_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Hc,b(a.log.cached_tokens||0),1))])])):i("v-if",!0),o("tr",Wc,[t[12]||(t[12]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Output Tokens",-1)),o("td",Jc,[!a.log.is_complete&&!a.log.output_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Kc,b(a.log.output_tokens||"—"),1))])]),a.log.reasoning_tokens&&a.log.reasoning_tokens>0?(s(),l("tr",Zc,[t[13]||(t[13]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Reasoning Tokens",-1)),o("td",Gc,b(a.log.reasoning_tokens),1)])):i("v-if",!0),o("tr",Xc,[t[14]||(t[14]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Total Tokens",-1)),o("td",Qc,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Yc,b(a.log.total_tokens||"—"),1))])]),o("tr",null,[t[15]||(t[15]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Total Cost",-1)),o("td",$c,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",eu,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):i("v-if",!0),i(" Tools Called "),e.toolCallsDetailed.length>0?(s(),l("div",tu,[o("div",ou,"Tools Called ("+b(e.toolCallsDetailed.length)+")",1),o("div",ru,[(s(!0),l(W,null,ne(e.toolCallsDetailed,(r,n)=>(s(),l("div",{key:n,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("button",{onClick:p=>e.toggleToolCall(n),class:"w-full px-2 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors flex items-center justify-between text-xs"},[o("span",su,b(r.function?.name||"Unknown"),1),o("span",lu,b(e.expandedToolCalls.has(n)?"▼":"▶"),1)],8,au),fe(o("div",nu,[o("div",iu,[t[17]||(t[17]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Tool Call ID",-1)),o("div",du,b(r.id),1)]),o("div",cu,[t[18]||(t[18]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Function Name",-1)),o("div",uu,b(r.function?.name),1)]),o("div",pu,[t[19]||(t[19]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Arguments",-1)),o("pre",mu,b(e.formatJson(r.function?.arguments||"{}")),1)]),i(" Tool Result "),e.toolResults.has(r.id)?(s(),l("div",gu,[t[20]||(t[20]=o("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"},"Result",-1)),o("pre",fu,b(e.toolResults.get(r.id)?.content||"No content"),1)])):(s(),l("div",hu,[...t[21]||(t[21]=[o("div",{class:"font-semibold text-gray-500 dark:text-gray-500 mb-1"},"Result",-1),o("div",{class:"text-xs text-gray-500 dark:text-gray-500 italic"},"No result available",-1)])]))],512),[[Ne,e.expandedToolCalls.has(n)]])]))),128))])])):i("v-if",!0),i(" Reasoning Content (from models like o1) "),a.log.reasoning_content?(s(),l("div",vu,[t[23]||(t[23]=o("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),o("div",bu,[t[22]||(t[22]=o("div",{class:"px-2 py-1.5 bg-blue-100 dark:bg-blue-900/30 text-xs text-blue-800 dark:text-blue-200 border-b border-blue-300 dark:border-blue-700"}," Internal reasoning output (not displayed to users) ",-1)),o("pre",yu,b(a.log.reasoning_content),1)])])):i("v-if",!0),i(" Reasoning Details (OpenRouter structured reasoning blocks) "),e.reasoningDetails.length>0?(s(),l("div",xu,[o("div",ku,"Reasoning Details ("+b(e.reasoningDetails.length)+" blocks)",1),o("div",_u,[t[28]||(t[28]=o("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),o("div",wu,[(s(!0),l(W,null,ne(e.reasoningDetails,(r,n)=>(s(),l("div",{key:n,class:"p-2"},[o("div",Cu,[o("span",Su,b(r.type||"unknown"),1),r.id?(s(),l("span",Tu," ID: "+b(r.id),1)):i("v-if",!0),r.format?(s(),l("span",Mu," Format: "+b(r.format),1)):i("v-if",!0),r.index!==void 0?(s(),l("span",Iu," Index: "+b(r.index),1)):i("v-if",!0)]),i(" Summary type "),r.type==="reasoning.summary"&&r.summary?(s(),l("div",Vu,[t[24]||(t[24]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Summary:",-1)),o("div",Au,b(r.summary),1)])):i("v-if",!0),i(" Encrypted type "),r.type==="reasoning.encrypted"&&r.data?(s(),l("div",Pu,[t[25]||(t[25]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Encrypted Data:",-1)),o("div",Eu,b(r.data),1)])):i("v-if",!0),i(" Text type "),r.type==="reasoning.text"&&r.text?(s(),l("div",Ou,[t[27]||(t[27]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Reasoning Text:",-1)),o("div",ju,b(r.text),1),r.signature?(s(),l("div",Lu,[t[26]||(t[26]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Signature:",-1)),o("div",Du,b(r.signature),1)])):i("v-if",!0)])):i("v-if",!0),i(" Unknown type - show raw JSON "),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(r.type)?i("v-if",!0):(s(),l("div",Uu,[o("pre",qu,b(JSON.stringify(r,null,2)),1)]))]))),128))])])])):i("v-if",!0),i(" Response Body "),a.log.response_body?(s(),l("div",Nu,[t[29]||(t[29]=o("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),o("pre",Bu,b(e.formatJson(a.log.response_body)),1)])):i("v-if",!0)],512),[[Ne,e.activeTab==="response"]])])])}const Fu=Q(_d,[["render",Ru],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/LogDetails.vue"]]),et=20,ht=20,zu=$({__name:"LogsPane",props:{threadId:{type:[String,null],required:!0},selectedLogId:{type:[String,null],required:!1}},emits:["collapse","logClick"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(0),r=m(et),{logs:n,total:p,hasMore:v,isFetching:g,error:f,wsConnected:h,wsError:w,connectWebSocket:x,disconnectWebSocket:k,refetch:C}=md(z(()=>e.threadId),{limit:z(()=>r.value),offset:z(()=>d.value),enableWebSocket:!0,order:"desc"}),y=m([]),_=m(!0),I=m(null),U=m(null),L=m(!1),j=m(!1),F=m(new Map),K=async()=>{await pe(),U.value&&(U.value.scrollTop=U.value.scrollHeight)};oe(n,async M=>{if(d.value===0)y.value=[...M].reverse(),_.value&&y.value.length>0&&(await K(),_.value=!1);else{const O=[...M].reverse(),A=new Map;y.value.forEach(B=>A.set(B.id,B)),O.forEach(B=>A.set(B.id,B)),y.value=Array.from(A.values()).sort((B,te)=>B.created_at-te.created_at)}},{deep:!0});const{logDetails:D,isFetching:E}=gd(z(()=>e.threadId),z(()=>I.value)),H=z(()=>{if(!I.value)return null;const O=y.value.find(A=>A.id===I.value);return O?D.value?{...D.value,...O}:O:null}),R=M=>{c("logClick",M.id),I.value=M.id},N=(M,O)=>{O?F.value.set(M,O):F.value.delete(M)};oe(I,async M=>{if(M){await pe();const O=F.value.get(M);O&&U.value&&O.scrollIntoView({behavior:"smooth",block:"nearest"})}});const Z=async()=>{if(j.value||!v.value||g.value)return;j.value=!0;const M=U.value?.scrollHeight||0;if(d.value+=r.value,r.value=ht,await C(),await pe(),U.value){const O=U.value.scrollHeight;U.value.scrollTop+=O-M}j.value=!1};oe(()=>e.threadId,async M=>{M?(k(),x()):k(),d.value=0,r.value=et,y.value=[],I.value=null,L.value=!1,_.value=!0},{immediate:!0}),oe(y,async()=>{L.value||await K()},{deep:!0});const G=()=>{if(!U.value)return;const{scrollTop:M,scrollHeight:O,clientHeight:A}=U.value,B=O-M-A<50;L.value=!B},P=M=>{if(!M.tools_called)return"—";try{const O=JSON.parse(M.tools_called);return Array.isArray(O)?O.join(", "):M.tools_called}catch{return M.tools_called}},V=M=>M==null?"—":`$${M.toFixed(6)}`,T=z(()=>{const M=new Map,O=new Map;y.value.forEach(te=>{M.set(te.id,te);const le=te.parent_log_id;le&&(O.has(le)||O.set(le,[]),O.get(le).push(te))});const A=[],B=(te,le)=>{A.push({...te,depth:le}),(O.get(te.id)||[]).forEach(ue=>{B(ue,le+1)})};return y.value.forEach(te=>{te.parent_log_id||B(te,0)}),A}),q={props:e,emit:c,INITIAL_LOAD_LIMIT:et,LOAD_MORE_LIMIT:ht,offset:d,limit:r,fetchedLogs:n,total:p,hasMore:v,isFetching:g,error:f,wsConnected:h,wsError:w,connectWebSocket:x,disconnectWebSocket:k,refetch:C,allLoadedLogs:y,isFirstLoad:_,selectedLogIdForDetails:I,logsScrollContainer:U,userHasScrolledUp:L,isLoadingMore:j,logRowRefs:F,scrollToBottom:K,logDetails:D,isFetchingDetails:E,selectedLog:H,selectLog:R,setLogRowRef:N,loadMoreLogs:Z,handleScroll:G,getToolsCalled:P,formatCost:V,logsWithDepth:T,LogDetailsComponent:Fu,Loader:De,TimeAgo:it,get ScrollTextIcon(){return Tt},get ChevronLeftIcon(){return Ze},get RotateCwIcon(){return so}};return Object.defineProperty(q,"__isScriptSetup",{enumerable:!1,value:!0}),q}}),Hu={class:"flex flex-col h-full"},Wu={class:"p-4 border-b border-gray-300 dark:border-gray-700"},Ju={class:"flex items-center justify-between"},Ku={class:"flex items-center gap-2"},Zu={class:"flex items-center gap-2"},Gu={key:0,class:"text-xs"},Xu={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},Qu={key:1,class:"text-red-600 dark:text-red-400"},Yu={key:2,class:"text-gray-400 dark:text-gray-600"},$u={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-12"},e0={class:"flex justify-center py-12"},t0={class:"text-red-600 dark:text-red-400 text-center py-12"},o0={key:0,class:"border-b border-gray-300 dark:border-gray-700 bg-white dark:bg-black sticky top-0 z-10"},r0=["disabled"],a0={key:1},s0={key:2},l0={class:"w-full text-sm"},n0=["onClick"],i0={class:"px-3 py-2 text-xs"},d0={class:"flex items-center gap-1"},c0={key:0,class:"text-gray-400 dark:text-gray-600 mr-1"},u0={key:3},p0={class:"px-3 py-2"},m0={class:"flex items-center gap-2"},g0={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},f0={class:"font-mono text-xs"},h0={class:"px-3 py-2 font-mono text-xs"},v0={key:1},b0={class:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400"},y0={key:1},x0={class:"px-3 py-2 text-right text-xs text-gray-500 dark:text-gray-500"},k0={key:0,class:"relative flex-shrink-0 border-t-2 border-gray-300 dark:border-gray-700 overflow-y-auto",style:{height:"min(60%, calc(100vh - 400px))","min-height":"min(40%, 400px)"}},_0={key:0,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"};function w0(u,t,a,e,c,d){return s(),l("div",Hu,[i(" Header "),o("div",Wu,[o("div",Ju,[o("div",Ku,[S(e.ScrollTextIcon,{size:20,class:"flex-shrink-0"}),t[2]||(t[2]=o("h2",{class:"text-xl font-bold"},"Logs",-1))]),o("div",Zu,[i(" WebSocket status "),a.threadId?(s(),l("div",Gu,[e.wsConnected?(s(),l("span",Xu,[...t[3]||(t[3]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",Qu," ● Error ")):(s(),l("span",Yu," ○ Offline "))])):i("v-if",!0),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Top half: Scrollable logs list "),o("div",{ref:"logsScrollContainer",class:"flex-1 overflow-y-auto overflow-x-auto",onScroll:e.handleScroll},[i(" No thread selected "),a.threadId?e.isFetching&&e.offset===0?(s(),l(W,{key:1},[i(" Loading state (initial load only) "),o("div",e0,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:2},[i(" Error state "),o("div",t0," Error loading logs: "+b(e.error),1)],2112)):e.allLoadedLogs.length===0?(s(),l(W,{key:3},[i(" Empty state "),t[4]||(t[4]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-12"}," No logs yet ",-1))],2112)):(s(),l(W,{key:4},[i(" Logs table "),o("div",null,[i(" Load previous logs button "),e.hasMore?(s(),l("div",o0,[o("button",{onClick:e.loadMoreLogs,disabled:e.isLoadingMore,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[e.isLoadingMore?(s(),X(e.Loader,{key:0,size:"xs"})):i("v-if",!0),e.isLoadingMore?(s(),l("span",a0,"Loading older logs...")):(s(),l("span",s0,"Load previous logs"))],8,r0)])):i("v-if",!0),o("table",l0,[o("thead",{class:ee(["border-b border-gray-300 dark:border-gray-700 sticky bg-white dark:bg-black",{"top-0":!e.hasMore,"top-[34px]":e.hasMore}])},[...t[5]||(t[5]=[o("tr",null,[o("th",{class:"text-left px-3 py-2 font-semibold"},"Prompt"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Model"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Cost"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Tools Called"),o("th",{class:"text-right px-3 py-2 font-semibold"},"Called At")],-1)])],2),o("tbody",null,[(s(!0),l(W,null,ne(e.logsWithDepth,r=>(s(),l("tr",{key:r.id,ref_for:!0,ref:n=>e.setLogRowRef(r.id,n),class:ee(["border-b border-gray-200 dark:border-gray-800 cursor-pointer transition-colors",{"bg-red-50 dark:bg-red-950/20":r.error,"bg-blue-50 dark:bg-blue-950/20":e.selectedLogIdForDetails===r.id,"ring-2 ring-blue-500":r.id===e.props.selectedLogId}]),onClick:n=>e.selectLog(r)},[o("td",i0,[o("div",d0,[r.depth>0?(s(),l("span",c0,"└─")):i("v-if",!0),r.retry_of_log_id?(s(),X(e.RotateCwIcon,{key:1,size:14,class:"text-gray-500 dark:text-gray-400 flex-shrink-0"})):i("v-if",!0),!r.is_complete&&!r.prompt_name?(s(),X(e.Loader,{key:2,size:"xs"})):(s(),l("span",u0,b(r.prompt_name||"—"),1))])]),o("td",p0,[o("div",m0,[r.error?(s(),l("span",g0," ✕ ")):i("v-if",!0),o("span",f0,b(r.model_name||r.model),1)])]),o("td",h0,[!r.is_complete&&!r.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",v0,b(e.formatCost(r.cost_total)),1))]),o("td",b0,[!r.is_complete&&e.getToolsCalled(r)==="—"?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",y0,b(e.getToolsCalled(r)),1))]),o("td",x0,[S(e.TimeAgo,{timestamp:r.created_at},null,8,["timestamp"])])],10,n0))),128))])])])],2112)):(s(),l("div",$u," Select a thread to view logs "))],544),i(" Bottom half: Log details "),e.selectedLog?(s(),l("div",k0,[S(e.LogDetailsComponent,{log:e.selectedLog,onClose:t[1]||(t[1]=r=>e.selectedLogIdForDetails=null)},null,8,["log"]),i(" Loading overlay for log details "),e.isFetchingDetails?(s(),l("div",_0,[S(e.Loader)])):i("v-if",!0)])):i("v-if",!0)])}const C0=Q(zu,[["render",w0],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/LogsPane.vue"]]),S0=$({__name:"CreateThreadModal",props:{modelValue:{type:Boolean,required:!0},editThread:{type:null,required:!1}},emits:["update:modelValue","thread-created","thread-updated"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>!!e.editThread),r=m(""),n=m(""),p=m({}),v=m([]),g=m(""),f=m(!1),h=m(""),w=m(null),{data:x,isFetching:k,execute:C}=ve(J("/api/agents"),{immediate:!1}).json(),y=z(()=>x.value?(x.value?.agents||[]).map(q=>({value:q.id,label:q.title})):[]),_=z(()=>!r.value||!x.value?null:(x.value?.agents||[]).find(q=>q.id===r.value)),I=z(()=>_.value&&_.value.type==="ai_human"?"AI":"Side A"),U=z(()=>_.value&&_.value.type==="ai_human"?"Human":"Side B"),{data:L,isFetching:j,execute:F}=ve(z(()=>_.value?.side_a_system_prompt?J(`/api/prompts/${_.value.side_a_system_prompt}`):""),{immediate:!1}).json(),K=z(()=>{if(!L.value)return null;const T=L.value?.required_schema;if(!T)return null;try{return typeof T=="string"?JSON.parse(T):T}catch{return null}}),D=z(()=>{const T=K.value;return!T||!T.properties?[]:Object.entries(T.properties).map(([q,M])=>({name:q,type:M.type||"string",description:M.description||"",required:T.required?.includes(q)||!1,enum:M.enum}))});oe(r,async T=>{T&&_.value?.side_a_system_prompt?(await F(),p.value={}):p.value={}});const E=()=>{const T=w.value;T&&(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)},H=T=>{g.value.trim()&&(v.value.push({id:crypto.randomUUID(),role:T,content:g.value.trim()}),g.value="",setTimeout(()=>E(),0))},R=T=>{v.value=v.value.filter(q=>q.id!==T)},N=()=>{r.value="",n.value="",p.value={},v.value=[],g.value="",h.value=""},Z=()=>{e.editThread&&(r.value=e.editThread.agent_id,n.value=e.editThread.tags?.join(", ")||"")},G=async()=>{if(!r.value){h.value="Please select an agent";return}if(!d.value&&D.value.length>0){for(const T of D.value)if(T.required&&!p.value[T.name]){h.value=`Please provide ${T.name}`;return}}f.value=!0,h.value="";try{const T=n.value.split(",").map(q=>q.trim()).filter(q=>q.length>0);if(d.value){const q=await fetch(J(`/api/threads/${e.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:T})});if(!q.ok){const M=await q.json();throw new Error(M.error||"Failed to update thread")}c("thread-updated"),N(),c("update:modelValue",!1)}else{const q={agent_id:r.value,tags:T.length>0?T:void 0};v.value.length>0&&(q.initial_messages=v.value.map(B=>({role:B.role,content:B.content}))),Object.keys(p.value).length>0&&(q.data=p.value);const M=await fetch(J("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q)});if(!M.ok){const B=await M.json();throw new Error(B.error||"Failed to create thread")}const A=(await M.json()).threadId;if(!A)throw new Error("Thread created but ID not found in response");c("thread-created",A),N(),c("update:modelValue",!1)}}catch(T){console.error(`Error ${d.value?"updating":"creating"} thread:`,T),h.value=T.message||`Failed to ${d.value?"update":"create"} thread`}finally{f.value=!1}},P=()=>{N(),c("update:modelValue",!1)};oe(()=>e.modelValue,async T=>{T&&(await C(),N(),d.value&&Z())});const V={props:e,emit:c,isEditMode:d,selectedAgentId:r,tags:n,requiredData:p,messages:v,newMessageContent:g,isSubmitting:f,errorMessage:h,textareaRef:w,agentsData:x,isFetchingAgents:k,fetchAgents:C,agentOptions:y,selectedAgent:_,sideALabel:I,sideBLabel:U,promptData:L,isFetchingPrompt:j,fetchPrompt:F,requiredSchema:K,schemaFields:D,adjustHeight:E,addMessage:H,removeMessage:R,resetForm:N,populateEditForm:Z,handleSubmit:G,handleCancel:P,Modal:Ve,SelectInput:xe,TextInput:je,TextareaInput:Et};return Object.defineProperty(V,"__isScriptSetup",{enumerable:!1,value:!0}),V}}),T0={class:"space-y-4"},M0={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},I0={class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},V0={key:0},A0={key:1},P0={key:1,class:"space-y-4 p-4 bg-gray-50 dark:bg-gray-900 rounded-lg"},E0={class:"flex items-center gap-2"},O0=["onUpdate:modelValue","id"],j0=["for"],L0={key:0,class:"text-red-500"},D0={key:5,class:"text-xs text-gray-500 dark:text-gray-400 mt-1"},U0={key:2,class:"p-4 bg-gray-50 dark:bg-gray-900 rounded-lg text-center text-sm text-gray-500"},q0={key:3},N0={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},B0={class:"text-xs font-medium mb-1 opacity-70"},R0={class:"text-sm whitespace-pre-wrap"},F0=["onClick"],z0={class:"space-y-2"},H0={class:"flex items-stretch border border-black dark:border-white rounded overflow-hidden bg-white dark:bg-black"},W0=["disabled","title"],J0={class:"flex-1 relative"},K0=["disabled","title"],Z0={class:"text-xs text-gray-500 dark:text-gray-400"},G0={class:"flex justify-between"},X0=["disabled"],Q0=["disabled"];function Y0(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[7]||(t[7]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:ae(()=>[o("div",G0,[o("button",{onClick:e.handleCancel,type:"button",disabled:e.isSubmitting,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,X0),o("button",{onClick:e.handleSubmit,type:"button",disabled:e.isSubmitting||e.isFetchingAgents,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[e.isEditMode?(s(),l(W,{key:0},[ie(b(e.isSubmitting?"Updating...":"Update Thread"),1)],64)):(s(),l(W,{key:1},[ie(b(e.isSubmitting?"Creating...":"Create Thread"),1)],64))],8,Q0)])]),default:ae(()=>[o("div",T0,[i(" Error Message "),e.errorMessage?(s(),l("div",M0,b(e.errorMessage),1)):i("v-if",!0),i(" Agent Selection (disabled in edit mode) "),o("div",null,[S(e.SelectInput,{modelValue:e.selectedAgentId,"onUpdate:modelValue":t[0]||(t[0]=r=>e.selectedAgentId=r),label:"Agent",options:e.agentOptions,disabled:e.isFetchingAgents||e.isEditMode,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),o("p",I0,[e.isEditMode?(s(),l("span",V0,"Agent cannot be changed after thread creation")):(s(),l("span",A0,"Choose which agent will handle this conversation"))])]),i(" Dynamic schema fields (only in create mode) "),!e.isEditMode&&e.schemaFields.length>0&&!e.isFetchingPrompt?(s(),l("div",P0,[t[8]||(t[8]=o("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Required Information ",-1)),(s(!0),l(W,null,ne(e.schemaFields,r=>(s(),l("div",{key:r.name,class:"space-y-2"},[i(" Enum field (dropdown) "),r.enum?(s(),X(e.SelectInput,{key:0,modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,options:[{value:"",label:"Select..."},...r.enum.map(n=>({value:n,label:n}))],required:r.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):r.type==="string"?(s(),l(W,{key:1},[i(" Text field "),S(e.TextInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,placeholder:r.description,required:r.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)):r.type==="number"||r.type==="integer"?(s(),l(W,{key:2},[i(" Number field "),S(e.TextInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,modelModifiers:{number:!0},label:r.name,placeholder:r.description,type:"number",required:r.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)):r.type==="boolean"?(s(),l(W,{key:3},[i(" Boolean field "),o("div",E0,[fe(o("input",{"onUpdate:modelValue":n=>e.requiredData[r.name]=n,type:"checkbox",id:`field-${r.name}`,class:"w-4 h-4"},null,8,O0),[[lo,e.requiredData[r.name]]]),o("label",{for:`field-${r.name}`,class:"text-sm"},[ie(b(r.name)+" ",1),r.required?(s(),l("span",L0,"*")):i("v-if",!0)],8,j0)])],2112)):(s(),l(W,{key:4},[i(" Fallback: textarea for complex types "),S(e.TextareaInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,placeholder:r.description||`Enter ${r.name} (JSON format)`,required:r.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)),r.description?(s(),l("p",D0,b(r.description),1)):i("v-if",!0)]))),128))])):i("v-if",!0),i(" Loading prompt schema (only in create mode) "),!e.isEditMode&&e.isFetchingPrompt?(s(),l("div",U0," Loading agent requirements... ")):i("v-if",!0),i(" Conversation Builder (only in create mode) "),e.isEditMode?i("v-if",!0):(s(),l("div",q0,[t[12]||(t[12]=o("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),i(" Messages List (iOS style) "),e.messages.length>0?(s(),l("div",N0,[(s(!0),l(W,null,ne(e.messages,r=>(s(),l("div",{key:r.id,class:ee(["flex items-start gap-2",{"justify-start":r.role==="assistant","justify-end":r.role==="user"}])},[o("div",{class:ee(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":r.role==="assistant","bg-gray-200 text-black dark:bg-gray-800 dark:text-white":r.role==="user"}])},[o("div",B0,b(r.role==="assistant"?e.sideALabel:e.sideBLabel),1),o("div",R0,b(r.content),1)],2),o("button",{onClick:n=>e.removeMessage(r.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,F0)],2))),128))])):(s(),l(W,{key:1},[i(" Empty state "),t[9]||(t[9]=o("div",{class:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm"}," No messages yet. Add messages to start the conversation. ",-1))],2112)),i(" Add Message Form "),o("div",z0,[i(" Unified Input Container "),o("div",H0,[i(" Agent/Side A Button (LEFT) "),o("button",{onClick:t[1]||(t[1]=r=>e.addMessage("assistant")),type:"button",disabled:!e.newMessageContent.trim(),title:`Add as ${e.sideALabel}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-white flex-shrink-0"},[t[10]||(t[10]=o("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),o("span",null,b(e.sideALabel),1)],8,W0),i(" Multiline Input (no border, no padding adjustments needed) "),o("div",J0,[fe(o("textarea",{"onUpdate:modelValue":t[2]||(t[2]=r=>e.newMessageContent=r),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref:"textareaRef",onInput:e.adjustHeight,onKeydown:[t[3]||(t[3]=rt(he(r=>e.addMessage("user"),["meta"]),["enter"])),t[4]||(t[4]=rt(he(r=>e.addMessage("user"),["ctrl"]),["enter"]))]},null,544),[[_e,e.newMessageContent]])]),i(" Human/Side B Button (RIGHT) "),o("button",{onClick:t[5]||(t[5]=r=>e.addMessage("user")),type:"button",disabled:!e.newMessageContent.trim(),title:`Add as ${e.sideBLabel}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-white flex-shrink-0"},[t[11]||(t[11]=o("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),o("span",null,b(e.sideBLabel),1)],8,K0)]),o("p",Z0," Type a message and click "+b(e.sideALabel)+" (left) or "+b(e.sideBLabel)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+b(e.sideBLabel)+". ",1)])])),i(" Tags "),o("div",null,[S(e.TextInput,{modelValue:e.tags,"onUpdate:modelValue":t[6]||(t[6]=r=>e.tags=r),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),t[13]||(t[13]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"])}const $0=Q(S0,[["render",Y0],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/CreateThreadModal.vue"]]),ep=$({__name:"ThreadsView",setup(u,{expose:t}){t();const a=Pe(),e=Le(),c=m(typeof a.params.id=="string"?a.params.id:null),d=m({threadList:!1,messages:!1,meta:!0,logs:!1}),r=m(!1),n=m(null),p=m(null),{thread:v}=nt(z(()=>c.value)),g=m(null),f=m(null);oe(()=>a.params.id,j=>{c.value=typeof j=="string"?j:null,g.value=null,f.value=null});const L={route:a,router:e,selectedThreadId:c,collapsedPanes:d,showThreadModal:r,editingThread:n,threadListPaneRef:p,thread:v,selectedMessageId:g,selectedLogId:f,handleThreadSelect:j=>{e.push(`/threads/${j}`)},handleThreadDeleted:j=>{window.location.href="/threads"},handleEditThread:()=>{v.value&&(n.value=v.value,r.value=!0)},handleCreateThread:()=>{n.value=null,r.value=!0},handleThreadCreated:j=>{p.value?.refetch(),e.push(`/threads/${j}`)},handleThreadUpdated:()=>{window.location.reload()},togglePane:j=>{d.value[j]=!d.value[j]},handleMessageClick:(j,F)=>{g.value=j,f.value=F},handleLogClick:j=>{f.value=j,g.value=null},ThreadListPane:an,MessagesPane:bi,MetaPane:pd,LogsPane:C0,CreateThreadModal:$0,get ListIcon(){return _t},get MessageSquareIcon(){return Ct},get InfoIcon(){return St},get ScrollTextIcon(){return Tt}};return Object.defineProperty(L,"__isScriptSetup",{enumerable:!1,value:!0}),L}}),tp={class:"flex h-screen bg-white dark:bg-black overflow-hidden"},op={key:0,class:"flex flex-col items-center p-4"},rp={key:0,class:"flex flex-col items-center p-4"},ap={key:0,class:"flex flex-col items-center p-4"},sp={key:0,class:"flex flex-col items-center p-4"};function lp(u,t,a,e,c,d){return s(),l("div",tp,[i(" Pane 1: Thread List "),o("div",{class:ee([e.collapsedPanes.threadList?"w-[60px]":"w-[320px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.threadList?(s(),l("div",op,[o("button",{onClick:t[0]||(t[0]=r=>e.togglePane("threadList")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Threads pane"},[S(e.ListIcon,{size:20})])])):(s(),X(e.ThreadListPane,{key:1,ref:"threadListPaneRef","selected-thread-id":e.selectedThreadId,onSelectThread:e.handleThreadSelect,onCollapse:t[1]||(t[1]=r=>e.togglePane("threadList")),onCreateThread:e.handleCreateThread},null,8,["selected-thread-id"]))],2),i(" Pane 2: Messages "),o("div",{class:ee([e.collapsedPanes.messages?"w-[60px]":"w-[350px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.messages?(s(),l("div",rp,[o("button",{onClick:t[2]||(t[2]=r=>e.togglePane("messages")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Messages pane"},[S(e.MessageSquareIcon,{size:20})])])):(s(),X(e.MessagesPane,{key:1,"thread-id":e.selectedThreadId,"selected-message-id":e.selectedMessageId,"selected-log-id":e.selectedLogId,onCollapse:t[3]||(t[3]=r=>e.togglePane("messages")),onMessageClick:e.handleMessageClick},null,8,["thread-id","selected-message-id","selected-log-id"]))],2),i(" Pane 3: Meta Info "),o("div",{class:ee([e.collapsedPanes.meta?"w-[60px]":"w-[350px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.meta?(s(),l("div",ap,[o("button",{onClick:t[4]||(t[4]=r=>e.togglePane("meta")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Metadata pane"},[S(e.InfoIcon,{size:20})])])):(s(),X(e.MetaPane,{key:1,"thread-id":e.selectedThreadId,onCollapse:t[5]||(t[5]=r=>e.togglePane("meta")),onThreadDeleted:e.handleThreadDeleted,onEditThread:e.handleEditThread},null,8,["thread-id"]))],2),i(" Pane 4: Logs (flexible width) "),o("div",{class:ee([e.collapsedPanes.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200"])},[e.collapsedPanes.logs?(s(),l("div",sp,[o("button",{onClick:t[6]||(t[6]=r=>e.togglePane("logs")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Logs pane"},[S(e.ScrollTextIcon,{size:20})])])):(s(),X(e.LogsPane,{key:1,"thread-id":e.selectedThreadId,"selected-log-id":e.selectedLogId,onCollapse:t[7]||(t[7]=r=>e.togglePane("logs")),onLogClick:e.handleLogClick},null,8,["thread-id","selected-log-id"]))],2),i(" Thread Modal (Create/Edit) "),S(e.CreateThreadModal,{modelValue:e.showThreadModal,"onUpdate:modelValue":t[8]||(t[8]=r=>e.showThreadModal=r),"edit-thread":e.editingThread,onThreadCreated:e.handleThreadCreated,onThreadUpdated:e.handleThreadUpdated},null,8,["modelValue","edit-thread"])])}const vt=Q(ep,[["render",lp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ThreadsView.vue"]]),np=$({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(u,{expose:t,emit:a}){const e=a,c=m([]),d=m(!1),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(f,h)=>f||h.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:f=>f?new Date(f*1e3).toLocaleDateString():"-"}],n=[{icon:"edit",label:"Edit",handler:f=>e("edit",f)},{icon:"delete",label:"Delete",handler:async f=>{await v(f)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],p=async()=>{d.value=!0;try{const f=await fetch(J("/api/prompts"));if(f.ok){const h=await f.json();c.value=h.prompts||[]}}catch(f){console.error("Error fetching prompts:",f)}finally{d.value=!1}},v=async f=>{try{const h=await fetch(J(`/api/prompts/${f.id}`),{method:"DELETE"});if(h.ok)await p();else{const w=await h.json();alert(w.error||"Failed to delete prompt")}}catch(h){console.error("Error deleting prompt:",h),alert("Failed to delete prompt")}};ce(()=>{p()}),t({refresh:p});const g={emit:e,prompts:c,loading:d,columns:r,actions:n,fetchPrompts:p,deletePrompt:v,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}});function ip(u,t,a,e,c,d){return s(),l("div",null,[S(e.DataTable,{columns:e.columns,data:e.prompts,actions:e.actions,loading:e.loading,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])])}const dp=Q(np,[["render",ip],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/PromptsDataTable.vue"]]),cp=$({__name:"PromptBasicInfo",props:{name:{type:String,required:!0},toolDescription:{type:String,required:!0}},emits:["update:name","update:toolDescription"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(""),r=v=>{let g=v.replace(/[^a-zA-Z0-9\s_]/g,"");return g=g.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),g?/^[a-z][a-z0-9_]*$/.test(g)?d.value="":d.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":d.value="Name is required",g},n=v=>{const g=r(v);c("update:name",g)};oe(()=>e.name,v=>{v&&r(v)},{immediate:!0});const p={props:e,emit:c,nameError:d,validateAndFormatName:r,handleNameInput:n,TextInput:je};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),up={class:"space-y-4"},pp={key:0,class:"mt-1 text-sm text-red-500"},mp={key:1,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},gp={class:"px-1 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},fp=["value"];function hp(u,t,a,e,c,d){return s(),l("div",up,[o("div",null,[S(e.TextInput,{"model-value":a.name,"onUpdate:modelValue":e.handleNameInput,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),e.nameError?(s(),l("p",pp,b(e.nameError),1)):a.name?(s(),l("p",mp,[t[1]||(t[1]=ie(" Will be saved as: ",-1)),o("code",gp,b(a.name),1)])):i("v-if",!0)]),o("div",null,[t[2]||(t[2]=o("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),o("textarea",{value:a.toolDescription,onInput:t[0]||(t[0]=r=>e.emit("update:toolDescription",r.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,fp)])])}const vp=Q(cp,[["render",hp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptBasicInfo.vue"]]),bp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",Je="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",yp="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",bt="/agents/assets/img/meta.svg",xp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",kp="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",_p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",wp="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",Cp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",Sp="/agents/assets/img/moonshotai.svg",Tp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",Mp="/agents/assets/img/zai.svg",Ip="/agents/assets/img/zai.svg",Vp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",at="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function Ap(u){const t=Ge();return t==="/"?u.replace("/agentbuilder/","/"):u.replace("/agentbuilder/",`${t}/`)}const Pp={anthropic:bp,openai:Je,"openai-sdk":Je,google:yp,meta:bt,"meta-llama":bt,nvidia:xp,alibaba:kp,deepseek:_p,qwen:wp,minimax:Cp,moonshotai:Sp,"x-ai":Tp,"z-ai":Mp,zai:Ip,exaone:Vp,openrouter:at},Ep=new Proxy(Pp,{get(u,t){const a=u[t];return a?Ap(a):void 0}});function Op(u){if(u&&u.includes("/"))return u.split("/")[0].toLowerCase()}function Ke(u){return Ep[u.toLowerCase()]}function dt(u,t){const a=Op(u);if(a){const e=Ke(a);if(e)return e}if(t)return Ke(t)}const jp=$({__name:"PromptModelSelect",props:{modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(!1),n=z(()=>d.value.map(g=>({value:g.id,label:g.name,description:g.model||g.provider,icon:dt(g.model||g.name,g.provider_id||g.provider)}))),p=async()=>{r.value=!0;try{const g=await fetch(J("/api/models"));if(g.ok){const f=await g.json();d.value=f.models||[]}}catch(g){console.error("Error fetching models:",g)}finally{r.value=!1}};ce(()=>{p()});const v={props:e,emit:c,models:d,loadingModels:r,modelOptions:n,fetchModels:p,SelectInput:xe};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),Lp={class:"space-y-4"};function Dp(u,t,a,e,c,d){return s(),l("div",Lp,[S(e.SelectInput,{"model-value":a.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.emit("update:modelValue",r)),options:e.modelOptions,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:e.loadingModels},null,8,["model-value","options","loading"])])}const Up=Q(jp,[["render",Dp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptModelSelect.vue"]]),qp=$({__name:"PropertyEditor",props:Se({propertyId:{type:String,required:!0},isNested:{type:Boolean,required:!1,default:!1},parentId:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},enableDrag:{type:Boolean,required:!1,default:!0}},{modelValue:{type:Object,required:!0},modelModifiers:{}}),emits:Se(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Ee(u,"modelValue"),r=m(!1),n=m(),p={string:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"/></svg>',number:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"/></svg>',boolean:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>',object:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/></svg>',array:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>',enum:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/></svg>',anyOf:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>'},v=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' 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'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],g=z(()=>["object","array","enum","anyOf"].includes(d.value.type));oe(()=>d.value.type,async(I,U)=>{if(["object","array","enum","anyOf"].includes(I)&&(r.value=!0,I==="anyOf"&&!d.value.anyOf&&(d.value.anyOf=[]),I==="object"&&!d.value.properties&&(d.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),I==="array"&&!d.value.items&&(d.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),I==="enum"&&!d.value.enum&&(d.value.enum=["value1"])),U!==void 0){await pe();const L=e.isNested?`[data-nested-property-id="${e.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${e.propertyId}"] input[placeholder="Description"]`,j=document.querySelector(L);j&&j.focus()}});const f=I=>{I.shiftKey&&d.value.type==="object"&&d.value.properties?k():c("add-top-level")},h=()=>{d.value.items||(d.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},w=()=>{d.value.enum||(d.value.enum=[]),d.value.enum.push(`value${d.value.enum.length+1}`)},x=I=>{d.value.enum&&d.value.enum.splice(I,1)},k=async()=>{const I={id:crypto.randomUUID(),name:d.value.type==="anyOf"?"":`property${(d.value.properties?.length||d.value.anyOf?.length||0)+1}`,type:"string",description:""};d.value.type==="anyOf"?(d.value.anyOf||(d.value.anyOf=[]),d.value.anyOf.push(I)):(d.value.properties||(d.value.properties=[]),d.value.properties.push(I)),await pe();const U=document.querySelector(`[data-nested-property-id="${I.id}"] input[placeholder="Property name"]`);U&&(U.focus(),U.select())},_={props:e,emit:c,modelValue:d,expanded:r,propertyListRef:n,typeIcons:p,typeOptions:v,isExpandable:g,handleEnterKey:f,initArrayItems:h,addEnumValue:w,removeEnumValue:x,addNestedProperty:k,removeNestedProperty:I=>{d.value.type==="anyOf"&&d.value.anyOf?d.value.anyOf=d.value.anyOf.filter(U=>U.id!==I):d.value.properties&&(d.value.properties=d.value.properties.filter(U=>U.id!==I))},handleNestedDescriptionKeydown:I=>{},SelectInput:xe,TextInput:je};return Object.defineProperty(_,"__isScriptSetup",{enumerable:!1,value:!0}),_}}),Np=["data-property-id","data-nested-property-id"],Bp={class:"p-3 space-y-3"},Rp={class:"flex items-start gap-2"},Fp={key:0,class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400 mt-2"},zp={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Hp={class:"flex items-center gap-2 mt-2"},Wp=["disabled"],Jp={key:0,class:"ml-6"},Kp={key:0,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg space-y-2"},Zp={class:"flex items-center justify-between mb-2"},Gp=["disabled"],Xp={key:0,class:"space-y-1"},Qp=["onClick","disabled"],Yp={key:1,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg"},$p={class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"},em={class:"space-y-2"},tm={class:"flex items-center justify-between"},om=["disabled"],rm={class:"space-y-2"},am={key:2,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg"},sm={key:0,class:"mb-2"},lm=["disabled"],nm={key:1,class:"space-y-2"};function im(u,t,a,e,c,d){const r=no("PropertyEditor",!0);return s(),l("div",{"data-property-id":a.isNested?void 0:a.propertyId,"data-nested-property-id":a.isNested?a.propertyId:void 0,class:ee(["border rounded-lg",a.isNested?"border-gray-100 dark:border-gray-900":"border-gray-200 dark:border-gray-800"])},[o("div",Bp,[o("div",Rp,[i(" Drag handle "),a.enableDrag?(s(),l("div",Fp,[...t[10]||(t[10]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):i("v-if",!0),i(" Property fields "),o("div",zp,[S(e.TextInput,{modelValue:e.modelValue.name,"onUpdate:modelValue":t[0]||(t[0]=n=>e.modelValue.name=n),placeholder:"Property name",disabled:a.disabled},null,8,["modelValue","disabled"]),S(e.SelectInput,{modelValue:e.modelValue.type,"onUpdate:modelValue":t[1]||(t[1]=n=>e.modelValue.type=n),options:e.typeOptions,disabled:a.disabled},null,8,["modelValue","disabled"]),S(e.TextInput,{modelValue:e.modelValue.description,"onUpdate:modelValue":t[2]||(t[2]=n=>e.modelValue.description=n),placeholder:"Description",disabled:a.disabled,onKeydown:t[3]||(t[3]=rt(he(n=>e.handleEnterKey(n),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),i(" Controls "),o("div",Hp,[e.isExpandable?(s(),l("button",{key:0,onClick:t[4]||(t[4]=n=>e.expanded=!e.expanded),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors"},[(s(),l("svg",{class:ee(["w-4 h-4 transition-transform",e.expanded?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...t[11]||(t[11]=[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):i("v-if",!0),o("button",{onClick:t[5]||(t[5]=n=>u.$emit("remove")),type:"button",disabled:a.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...t[12]||(t[12]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Wp)])]),i(" Expandable content "),e.expanded&&e.isExpandable?(s(),l("div",Jp,[i(" Enum values "),e.modelValue.type==="enum"?(s(),l("div",Kp,[o("div",Zp,[t[13]||(t[13]=o("h4",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"},"Enum Values",-1)),o("button",{onClick:e.addEnumValue,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Add Value ",8,Gp)]),e.modelValue.enum?(s(),l("div",Xp,[(s(!0),l(W,null,ne(e.modelValue.enum,(n,p)=>(s(),l("div",{key:p,class:"flex items-center gap-2"},[S(e.TextInput,{modelValue:e.modelValue.enum[p],"onUpdate:modelValue":v=>e.modelValue.enum[p]=v,placeholder:"Enum value",disabled:a.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),o("button",{onClick:v=>e.removeEnumValue(p),type:"button",disabled:a.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...t[14]||(t[14]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Qp)]))),128))])):i("v-if",!0)])):i("v-if",!0),i(" Object properties / anyOf types "),e.modelValue.type==="object"||e.modelValue.type==="anyOf"?(s(),l("div",Yp,[o("h4",$p,b(e.modelValue.type==="anyOf"?"Type Options":"Nested Properties"),1),o("div",em,[i(" Add nested properties buttons "),o("div",tm,[o("button",{onClick:e.addNestedProperty,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Add "+b(e.modelValue.type==="anyOf"?"Type Option":"Property"),9,om)]),i(" Render nested properties "),o("div",rm,[(s(!0),l(W,null,ne(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties,(n,p)=>(s(),X(r,{key:n.id,modelValue:(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties)[p],"onUpdate:modelValue":v=>(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties)[p]=v,"property-id":n.id,"is-nested":!0,"parent-id":a.propertyId,disabled:a.disabled,"enable-drag":!1,onRemove:v=>e.removeNestedProperty(n.id),onAddTopLevel:t[6]||(t[6]=v=>e.emit("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):i("v-if",!0),i(" Array items "),e.modelValue.type==="array"?(s(),l("div",am,[t[15]||(t[15]=o("h4",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"},"Array Item Type",-1)),e.modelValue.items?i("v-if",!0):(s(),l("div",sm,[o("button",{onClick:e.initArrayItems,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,lm)])),e.modelValue.items?(s(),l("div",nm,[S(r,{modelValue:e.modelValue.items,"onUpdate:modelValue":t[7]||(t[7]=n=>e.modelValue.items=n),"property-id":e.modelValue.items.id,"is-nested":!0,"parent-id":a.propertyId,disabled:a.disabled,"enable-drag":!1,onRemove:t[8]||(t[8]=n=>e.modelValue.items=null),onAddTopLevel:t[9]||(t[9]=n=>e.emit("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):i("v-if",!0)])):i("v-if",!0)])):i("v-if",!0)])],10,Np)}const dm=Q(qp,[["render",im],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PropertyEditor.vue"]]),cm=$({__name:"PropertyList",props:Se({disabled:{type:Boolean,required:!1,default:!1},parentId:{type:String,required:!1},isNested:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:Se(["add-property","description-keydown"],["update:modelValue"]),setup(u,{expose:t,emit:a}){const e=u,c=a,d=Ee(u,"modelValue"),r=m();let n=!1;ce(async()=>{}),Te(()=>{});const p=async()=>{if(n)return;n=!0;const h={id:crypto.randomUUID(),name:`property${d.value.length+1}`,type:"string",description:"",required:!1};d.value=[...d.value,h],await pe();const w=e.parentId?`[data-nested-property-id="${h.id}"]`:`[data-property-id="${h.id}"]`,x=document.querySelector(`${w} input[placeholder="Property name"]`);x&&(x.focus(),x.select()),c("add-property"),n=!1},v=h=>{d.value=d.value.filter(w=>w.id!==h)},g=h=>{};t({addProperty:p});const f={props:e,emit:c,modelValue:d,dragAreaRef:r,get isAddingProperty(){return n},set isAddingProperty(h){n=h},addProperty:p,removeProperty:v,handleDescriptionKeydown:g,PropertyEditor:dm};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),um={class:"space-y-2"},pm={ref:"dragAreaRef",class:"space-y-2"},mm=["disabled"];function gm(u,t,a,e,c,d){return s(),l("div",um,[o("div",pm,[(s(!0),l(W,null,ne(e.modelValue,r=>(s(),X(e.PropertyEditor,{key:r.id,modelValue:e.modelValue[e.modelValue.indexOf(r)],"onUpdate:modelValue":n=>e.modelValue[e.modelValue.indexOf(r)]=n,"property-id":r.id,"is-nested":a.isNested,"parent-id":a.parentId,disabled:a.disabled,"enable-drag":!a.isNested,onRemove:n=>e.removeProperty(r.id),onAddTopLevel:t[0]||(t[0]=n=>u.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),i(" Add Property button at the bottom for both nested and non-nested "),o("div",{class:ee(a.isNested?"mt-2":"mt-3 pt-3 border-t border-gray-200 dark:border-gray-800")},[o("button",{onClick:e.addProperty,type:"button",disabled:a.disabled,class:ee(a.isNested?"px-2 py-1 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 rounded transition-colors disabled:opacity-50 border border-dashed border-gray-300 dark:border-gray-700")},[...t[1]||(t[1]=[o("span",{class:"flex items-center justify-center gap-2"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ie(" Add Property ")],-1)])],10,mm)],2)])}const fm=Q(cm,[["render",gm],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PropertyList.vue"]]),hm=$({__name:"JSONSchemaInput",props:Se({label:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1}},{modelValue:{type:null,required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(),r=m(!1),n=()=>{if(e.value?.properties){const y=[];e.value.required;for(const[_,I]of Object.entries(e.value.properties)){const U=I,L={id:crypto.randomUUID(),name:_,type:U.type||"string",description:U.description||""};U.enum&&(L.enum=U.enum),U.anyOf&&(L.type="anyOf",L.anyOf=p(U.anyOf)),U.type==="array"&&U.items&&(L.items=v(U.items)),U.type==="object"&&U.properties&&(L.properties=g(U.properties,U.required||[])),y.push(L)}c.value=y}},p=y=>y.map(_=>typeof _=="object"&&_.type?{id:crypto.randomUUID(),name:"",type:_.type,description:_.description||"",properties:_.properties?g(_.properties,_.required||[]):void 0,items:_.items?v(_.items):void 0,enum:_.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),v=y=>{const _={id:crypto.randomUUID(),name:"",type:y.type||"string",description:y.description||""};return y.enum&&(_.enum=y.enum),y.anyOf&&(_.type="anyOf",_.anyOf=p(y.anyOf)),y.type==="array"&&y.items&&(_.items=v(y.items)),y.type==="object"&&y.properties&&(_.properties=g(y.properties,y.required||[])),_},g=(y,_)=>{const I=[];for(const[U,L]of Object.entries(y)){const j=L,F={id:crypto.randomUUID(),name:U,type:j.type||"string",description:j.description||""};j.enum&&(F.enum=j.enum),j.anyOf&&(F.type="anyOf",F.anyOf=p(j.anyOf)),j.type==="array"&&j.items&&(F.items=v(j.items)),j.type==="object"&&j.properties&&(F.properties=g(j.properties,j.required||[])),I.push(F)}return I};n();const f=()=>{const y={type:"object",properties:{},required:[],additionalProperties:!1},{properties:_,required:I}=w(c.value);y.properties=_,y.required=Object.keys(_),e.value=y},h=y=>{const _={type:y.type==="anyOf"?void 0:y.type,description:y.description};if(y.type==="enum"&&y.enum&&(_.enum=y.enum,_.type="string"),y.type==="anyOf"&&y.anyOf&&(delete _.type,_.anyOf=y.anyOf.map(h)),y.type==="object"&&y.properties){const{properties:I,required:U}=w(y.properties);_.properties=I,_.required=Object.keys(I),_.additionalProperties=!1}return y.type==="array"&&y.items&&(_.items=h(y.items)),_},w=y=>{const _={},I=[];for(const U of y){const L={type:U.type==="anyOf"?void 0:U.type,description:U.description};if(I.push(U.name),U.type==="enum"&&U.enum&&(L.enum=U.enum,L.type="string"),U.type==="anyOf"&&U.anyOf&&U.anyOf.length>0&&(delete L.type,L.anyOf=U.anyOf.map(h)),U.type==="array"&&U.items&&(L.items=h(U.items)),U.type==="object"&&U.properties){const{properties:j,required:F}=w(U.properties);L.properties=j,L.required=Object.keys(j),L.additionalProperties=!1}_[U.name]=L}return{properties:_,required:I}};oe(c,()=>{f()},{deep:!0}),f();const x=z(()=>JSON.stringify(e.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),C={props:a,modelValue:e,properties:c,propertyListRef:d,showSchema:r,initializeProperties:n,convertAnyOfToProperties:p,convertSchemaToProperty:v,convertSchemaToProperties:g,updateSchema:f,convertPropertyToSchema:h,convertPropertiesToSchema:w,highlightedSchema:x,addProperty:async()=>{if(c.value.length===0){const y={id:crypto.randomUUID(),name:"property1",type:"string",description:""};c.value.push(y),await pe();const _=document.querySelector(`[data-property-id="${y.id}"] input[placeholder="Property name"]`);_&&(_.focus(),_.select())}else d.value&&d.value.addProperty()},PropertyList:fm};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),vm={class:"space-y-4"},bm={key:0,class:"flex items-center justify-between"},ym={class:"text-sm font-medium"},xm={key:0,class:"text-red-500"},km={class:"space-y-2 border border-gray-200 dark:border-gray-800 rounded-lg p-4"},_m={key:0,class:"flex items-center justify-between mb-2"},wm={key:1,class:"text-center py-12"},Cm=["disabled"],Sm={class:"mt-4 text-center"},Tm={key:3,class:"mt-4"},Mm={class:"bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-lg p-4 overflow-x-auto"},Im={class:"text-xs leading-relaxed"},Vm=["innerHTML"];function Am(u,t,a,e,c,d){return s(),l("div",vm,[a.label?(s(),l("div",bm,[o("label",ym,[ie(b(a.label)+" ",1),a.required?(s(),l("span",xm,"*")):i("v-if",!0)])])):i("v-if",!0),o("div",km,[e.properties.length>0?(s(),l("div",_m,[...t[2]||(t[2]=[o("h3",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Properties",-1)])])):i("v-if",!0),e.properties.length===0?(s(),l("div",wm,[t[4]||(t[4]=o("div",{class:"mb-4"},[o("svg",{class:"w-12 h-12 mx-auto text-gray-400 dark:text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),t[5]||(t[5]=o("p",{class:"text-gray-500 dark:text-gray-400 text-sm mb-4"},"No properties defined",-1)),o("button",{onClick:e.addProperty,type:"button",disabled:a.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-gray-800 dark:hover:bg-gray-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...t[3]||(t[3]=[o("span",{class:"flex items-center gap-2"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ie(" Add Property ")],-1)])],8,Cm)])):i("v-if",!0),e.properties.length>0?(s(),X(e.PropertyList,{key:2,ref:"propertyListRef",modelValue:e.properties,"onUpdate:modelValue":t[0]||(t[0]=r=>e.properties=r),disabled:a.disabled,onAddProperty:e.addProperty},null,8,["modelValue","disabled"])):i("v-if",!0),i(" Show JSON Schema link "),o("div",Sm,[o("button",{onClick:t[1]||(t[1]=r=>e.showSchema=!e.showSchema),type:"button",class:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:underline transition-colors"},b(e.showSchema?"Hide":"Show")+" JSON Schema ",1)]),i(" JSON Schema Display "),e.showSchema?(s(),l("div",Tm,[o("div",Mm,[o("pre",Im,[o("code",{class:"font-mono",innerHTML:e.highlightedSchema},null,8,Vm)])])])):i("v-if",!0)])])}const Ot=Q(hm,[["render",Am],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/JSONSchemaInput.vue"]]),Pm=$({__name:"PromptInput",props:{modelValue:{type:Array,required:!1},search:{type:Function,required:!1},placeholder:{type:String,required:!1,default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,required:!1,default:!1},maxLength:{type:Number,required:!1},allowedTypes:{type:Array,required:!1,default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(),r=m(),n=io({segments:e.modelValue&&e.modelValue.length?e.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),v=P=>P.type==="string"?"":`@${P.type==="variable"?P.label||P.value:P.label||P.id}`,g=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!d.value)return null;const V=P.getRangeAt(0);let T=0;const q=Array.from(d.value.childNodes);for(let M=0;M<q.length;M++){const O=q[M];if(O===V.startContainer||O.contains?.(V.startContainer)){if(O.nodeType===Node.TEXT_NODE)return{segmentIndex:T,offset:V.startOffset};if(O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag"))return{segmentIndex:T,offset:0}}(O.nodeType===Node.TEXT_NODE||O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag"))&&T++}return{segmentIndex:0,offset:0}},f=P=>{if(!d.value)return;const V=window.getSelection();if(!V)return;const T=Array.from(d.value.childNodes);let q=0,M=null,O=0;for(const A of T){if(q===P.segmentIndex){if(A.nodeType===Node.TEXT_NODE)M=A,O=Math.min(P.offset,A.textContent?.length||0);else if(A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag")){const B=A.nextSibling;if(B&&B.nodeType===Node.TEXT_NODE)M=B,O=0;else{const te=document.createTextNode("");A.parentNode?.insertBefore(te,A.nextSibling),M=te,O=0}}break}(A.nodeType===Node.TEXT_NODE||A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag"))&&q++}if(!M&&T.length){const A=T[T.length-1];if(A.nodeType===Node.TEXT_NODE)M=A,O=A.textContent?.length||0;else if(A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag")){const B=document.createTextNode("");A.parentNode?.insertBefore(B,A.nextSibling),M=B,O=0}}if(M){const A=document.createRange();A.setStart(M,O),A.collapse(!0),V.removeAllRanges(),V.addRange(A)}},h=()=>{if(!d.value)return;const P=n.segments.map(V=>{if(V.type==="string")return(V.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const T=V._uid||(V._uid=p()),q=v(V),M=V.type==="variable"?{type:"variable",value:V.value,label:V.label,schema:V.schema,meta:V.meta}:{type:"prompt",id:V.id,label:V.label,schema:V.schema,meta:V.meta},O=encodeURIComponent(JSON.stringify(M)),A=V.type==="prompt"&&V.meta&&!V.meta.isValid,B=A?'<span class="prompt-tag-warning" title="'+(V.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${A?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${T}" data-segment="${O}">${q}${B}</span>`}}).join("");d.value.innerHTML=P||"<br>"},w=()=>{const P=[];for(const V of n.segments)V.type==="string"&&P.length>0&&P[P.length-1].type==="string"?P[P.length-1].value+=V.value:P.push(V);n.segments=P.length?P:[{type:"string",value:""}]},x=P=>{const V=P.dataset.segmentUid;let T=n.segments.find(q=>q._uid===V);if(!T){const q=P.dataset.segment;if(q)try{const M=JSON.parse(decodeURIComponent(q));M&&(M.type==="variable"||M.type==="prompt")&&(T=M.type==="variable"?{type:"variable",value:M.value,label:M.label,schema:M.schema,meta:M.meta,_uid:V}:{type:"prompt",id:M.id,label:M.label,schema:M.schema,meta:M.meta,_uid:V})}catch{}}return T||null},k=P=>{const V=P.target;if(V.classList?.contains("prompt-tag")){const T=x(V);T&&c("segment-click",T,P)}},C=P=>{if(n.isComposing)return;const V=P.target,T=[];let q="";const M=()=>{q.length>0&&(T.push({type:"string",value:q}),q="")},O=le=>{if(le.nodeType===Node.TEXT_NODE){const re=(le.textContent||"").replace(/\u00A0/g," ");q+=re;return}if(le.nodeType===Node.ELEMENT_NODE){const re=le;if(re.classList?.contains("prompt-tag")){M();const me=x(re);me&&T.push(me);return}if(re.tagName==="BR"){q+=`
8
+ `),D+=` -d '${K.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(D),v.value=!0,setTimeout(()=>{v.value=!1},2e3)}catch(j){console.error("Failed to copy cURL command:",j),alert(`Failed to copy cURL: ${j instanceof Error?j.message:"Unknown error"}`)}finally{p.value=!1}},Loader:De,TimeAgo:it,CopyButton:kd};return Object.defineProperty(L,"__isScriptSetup",{enumerable:!1,value:!0}),L}}),wd={class:"p-4 h-full overflow-y-auto"},Cd={class:"flex items-center justify-between mb-3"},Sd={class:"text-lg font-bold"},Td={class:"flex items-center gap-2"},Md=["disabled","title"],Id={key:1},Vd={class:"@container border-b border-gray-300 dark:border-gray-700 pb-3 mb-3"},Ad={class:"hidden @[600px]:block"},Pd={class:"w-full text-xs"},Ed={class:"py-1 font-mono"},Od={class:"py-1 font-mono"},jd={key:1},Ld={class:"py-1 font-mono"},Dd={key:1},Ud={class:"py-1 font-mono"},qd={key:1},Nd={class:"py-1 font-mono"},Bd={key:1},Rd={class:"py-1 font-mono text-xs"},Fd={class:"@[600px]:hidden space-y-2"},zd={class:"w-full text-xs"},Hd={class:"py-1 font-mono"},Wd={class:"py-1 font-mono"},Jd={key:1},Kd={class:"w-full text-xs"},Zd={class:"py-1 font-mono"},Gd={key:1},Xd={class:"py-1 font-mono"},Qd={key:1},Yd={class:"py-1 font-mono"},$d={key:1},ec={class:"py-1 font-mono text-xs"},tc={class:"border-b border-gray-300 dark:border-gray-700 mb-3"},oc={class:"flex gap-4"},rc={key:0,class:"text-red-600 dark:text-red-400"},ac={class:"space-y-3"},sc={key:0,class:"mb-4"},lc={class:"text-xs font-semibold mb-1"},nc={class:"relative"},ic={class:"absolute top-[5px] right-[5px]"},dc={key:1,class:"mb-4"},cc={class:"relative"},uc={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-32"},pc={class:"absolute top-[5px] right-[5px]"},mc={key:2,class:"mb-4"},gc={class:"text-xs font-semibold mb-1"},fc={class:"border border-gray-300 dark:border-gray-700 rounded overflow-hidden"},hc=["onClick"],vc={class:"font-mono"},bc={class:"text-gray-500"},yc={class:"px-2 py-2 bg-gray-50 dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800"},xc={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mb-2"},kc={class:"text-xs overflow-x-auto"},_c={key:3,class:"mb-4"},wc={class:"relative"},Cc={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-64"},Sc={class:"absolute top-[5px] right-[5px]"},Tc={key:0,class:"mb-4"},Mc={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Ic={class:"space-y-2"},Vc={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},Ac={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},Pc={class:"mb-4"},Ec={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Oc={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},jc={key:2,class:"mb-4"},Lc={class:"w-full text-xs border border-gray-300 dark:border-gray-700 rounded"},Dc={class:"border-b border-gray-200 dark:border-gray-800"},Uc={class:"py-1 px-2 font-mono"},qc={key:1},Nc={class:"border-b border-gray-200 dark:border-gray-800"},Bc={class:"py-1 px-2 font-mono"},Rc={key:1},Fc={key:0,class:"border-b border-gray-200 dark:border-gray-800"},zc={class:"py-1 px-2 font-mono"},Hc={key:1},Wc={class:"border-b border-gray-200 dark:border-gray-800"},Jc={class:"py-1 px-2 font-mono"},Kc={key:1},Zc={key:1,class:"border-b border-gray-200 dark:border-gray-800"},Gc={class:"py-1 px-2 font-mono text-blue-600 dark:text-blue-400"},Xc={class:"border-b border-gray-200 dark:border-gray-800"},Qc={class:"py-1 px-2 font-mono font-semibold"},Yc={key:1},$c={class:"py-1 px-2 font-mono font-semibold"},eu={key:1},tu={key:3,class:"mb-4"},ou={class:"text-xs font-semibold mb-1"},ru={class:"border border-gray-300 dark:border-gray-700 rounded overflow-hidden"},au=["onClick"],su={class:"font-mono"},lu={class:"text-gray-500"},nu={class:"px-2 py-2 bg-gray-50 dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800"},iu={class:"text-xs mb-2"},du={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-gray-200 dark:border-gray-800"},cu={class:"text-xs mb-2"},uu={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-gray-200 dark:border-gray-800"},pu={class:"text-xs mb-2"},mu={class:"text-xs overflow-x-auto bg-white dark:bg-black p-2 rounded border border-gray-200 dark:border-gray-800"},gu={key:0,class:"text-xs"},fu={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},hu={key:1,class:"text-xs"},vu={key:4,class:"mb-4"},bu={class:"border border-blue-300 dark:border-blue-700 rounded overflow-hidden bg-blue-50 dark:bg-blue-950/20"},yu={class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-blue-900 dark:text-blue-100"},xu={key:5,class:"mb-4"},ku={class:"text-xs font-semibold mb-1"},_u={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},wu={class:"divide-y divide-purple-200 dark:divide-purple-800"},Cu={class:"flex items-center gap-2 mb-1"},Su={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},Tu={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},Mu={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},Iu={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},Vu={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Au={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Pu={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Eu={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},Ou={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},ju={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Lu={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},Du={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},Uu={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},qu={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},Nu={key:6,class:"mb-4"},Bu={class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-96"};function Ru(u,t,a,e,c,d){return s(),l("div",wd,[i(" Header "),o("div",Cd,[o("h3",Sd,b(a.log.prompt_name||a.log.model_name||a.log.model),1),o("div",Td,[o("button",{onClick:e.copyCurlCommand,disabled:e.copyingCurl||!a.log.request_body,class:"px-3 py-1 text-xs font-medium bg-black text-white dark:bg-white dark:text-black rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity",title:a.log.request_body?"Copy cURL command":"No request data available"},[e.copyingCurl?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Id,b(e.copiedCurl?"Copied!":"Copy cURL"),1))],8,Md),o("button",{onClick:t[0]||(t[0]=r=>e.emit("close")),class:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-label":"Close details"}," ✕ ")])]),i(" Summary Table "),o("div",Vd,[i(" Single table for wider containers "),o("div",Ad,[o("table",Pd,[t[3]||(t[3]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Status"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Provider"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Prompt"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Latency"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Tokens"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Cost"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Created")])],-1)),o("tbody",null,[o("tr",null,[o("td",{class:ee(["py-1 font-mono",a.log.error?"text-red-600 dark:text-red-400":a.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},b(a.log.error?"ERROR":a.log.is_complete?"SUCCESS":"LOADING"),3),o("td",Ed,b(a.log.provider),1),o("td",Od,[!a.log.is_complete&&!a.log.prompt_name?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",jd,b(a.log.prompt_name||"—"),1))]),o("td",Ld,[!a.log.is_complete&&!a.log.latency_ms?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Dd,b(a.log.latency_ms?`${a.log.latency_ms}ms`:"—"),1))]),o("td",Ud,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",qd,b(a.log.total_tokens?`${a.log.input_tokens}/${a.log.output_tokens} (${a.log.total_tokens})`:"—"),1))]),o("td",Nd,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Bd,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))]),o("td",Rd,[S(e.TimeAgo,{timestamp:a.log.created_at},null,8,["timestamp"])])])])])]),i(" Two stacked tables for narrow containers "),o("div",Fd,[i(" First table: Status, Provider, Prompt "),o("table",zd,[t[4]||(t[4]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Status"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Provider"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Prompt")])],-1)),o("tbody",null,[o("tr",null,[o("td",{class:ee(["py-1 font-mono",a.log.error?"text-red-600 dark:text-red-400":a.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},b(a.log.error?"ERROR":a.log.is_complete?"SUCCESS":"LOADING"),3),o("td",Hd,b(a.log.provider),1),o("td",Wd,[!a.log.is_complete&&!a.log.prompt_name?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Jd,b(a.log.prompt_name||"—"),1))])])])]),i(" Second table: Latency, Tokens, Cost, Created "),o("table",Kd,[t[5]||(t[5]=o("thead",null,[o("tr",{class:"border-b border-gray-200 dark:border-gray-800"},[o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Latency"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Tokens"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Cost"),o("th",{class:"text-left py-1 pr-4 text-gray-600 dark:text-gray-400 font-medium"},"Created")])],-1)),o("tbody",null,[o("tr",null,[o("td",Zd,[!a.log.is_complete&&!a.log.latency_ms?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Gd,b(a.log.latency_ms?`${a.log.latency_ms}ms`:"—"),1))]),o("td",Xd,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Qd,b(a.log.total_tokens?`${a.log.input_tokens}/${a.log.output_tokens} (${a.log.total_tokens})`:"—"),1))]),o("td",Yd,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",$d,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))]),o("td",ec,[S(e.TimeAgo,{timestamp:a.log.created_at},null,8,["timestamp"])])])])])])]),i(" Tabs "),o("div",tc,[o("div",oc,[o("button",{onClick:t[1]||(t[1]=r=>e.activeTab="request"),class:ee(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",e.activeTab==="request"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white"])}," Request ",2),o("button",{onClick:t[2]||(t[2]=r=>e.activeTab="response"),class:ee(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",e.activeTab==="response"?"border-black dark:border-white text-black dark:text-white":"border-transparent text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white"])},[t[6]||(t[6]=ie(" Response ",-1)),a.log.error||e.errorsArray.length>0?(s(),l("span",rc,"⚠")):i("v-if",!0)],2)])]),i(" Tab Content "),o("div",ac,[i(" Request Tab "),fe(o("div",null,[i(" Messages (actual messages sent to LLM) - Moved to top, taller, auto-scroll to bottom "),a.log.message_history?(s(),l("div",sc,[o("div",lc,"Messages ("+b(a.log.message_history_length||0)+" messages)",1),o("div",nc,[o("pre",{ref:"messagesContainer",class:"text-xs bg-gray-50 dark:bg-gray-950 p-2 rounded overflow-x-auto border border-gray-300 dark:border-gray-700 max-h-[600px] overflow-y-auto"},b(e.formatJson(a.log.message_history)),513),o("div",ic,[S(e.CopyButton,{content:e.formatJson(a.log.message_history),variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0),i(" System Prompt "),a.log.system_prompt?(s(),l("div",dc,[t[7]||(t[7]=o("div",{class:"text-xs font-semibold mb-1"},"System Prompt",-1)),o("div",cc,[o("pre",uc,b(a.log.system_prompt),1),o("div",pc,[S(e.CopyButton,{content:a.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0),i(" Tools "),e.tools.length>0?(s(),l("div",mc,[o("div",gc,"Available Tools ("+b(e.tools.length)+")",1),o("div",fc,[(s(!0),l(W,null,ne(e.tools,(r,n)=>(s(),l("div",{key:n,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("button",{onClick:p=>e.toggleTool(n),class:"w-full px-2 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors flex items-center justify-between text-xs"},[o("span",vc,b(r.function?.name||r.name||"Unknown"),1),o("span",bc,b(e.expandedTools.has(n)?"▼":"▶"),1)],8,hc),fe(o("div",yc,[r.function?.description||r.description?(s(),l("div",xc,b(r.function?.description||r.description),1)):i("v-if",!0),o("pre",kc,b(JSON.stringify(r,null,2)),1)],512),[[Ne,e.expandedTools.has(n)]])]))),128))])])):i("v-if",!0),i(" Request Body "),a.log.request_body?(s(),l("div",_c,[t[8]||(t[8]=o("div",{class:"text-xs font-semibold mb-1"},"Full Request Body",-1)),o("div",wc,[o("pre",Cc,b(e.formatJson(a.log.request_body)),1),o("div",Sc,[S(e.CopyButton,{content:e.formatJson(a.log.request_body),variant:"ghost",size:"xs"},null,8,["content"])])])])):i("v-if",!0)],512),[[Ne,e.activeTab==="request"]]),i(" Response Tab "),fe(o("div",null,[i(" Errors (Multiple errors from errors array) "),e.errorsArray.length>0?(s(),l("div",Tc,[o("div",Mc,b(e.errorsArray.length>1?`Errors (${e.errorsArray.length})`:"Error"),1),o("div",Ic,[(s(!0),l(W,null,ne(e.errorsArray,(r,n)=>(s(),l("div",{key:n,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[o("div",Vc,b(r.type||"error"),1),o("pre",Ac,b(r.message),1)]))),128))])])):a.log.error?(s(),l(W,{key:1},[i(" Fallback: Single error (for backwards compatibility) "),o("div",Pc,[o("div",Ec," Error "+b(a.log.error_type?`(${a.log.error_type})`:""),1),o("pre",Oc,b(a.log.error),1)])],2112)):i("v-if",!0),i(" Response Stats "),a.log.is_complete||!a.log.error?(s(),l("div",jc,[t[16]||(t[16]=o("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),o("table",Lc,[o("tbody",null,[o("tr",Dc,[t[9]||(t[9]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Finish Reason",-1)),o("td",Uc,[!a.log.is_complete&&!a.log.finish_reason?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",qc,b(a.log.finish_reason||"—"),1))])]),o("tr",Nc,[t[10]||(t[10]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Input Tokens",-1)),o("td",Bc,[!a.log.is_complete&&!a.log.input_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Rc,b(a.log.input_tokens||"—"),1))])]),a.log.cached_tokens||!a.log.is_complete?(s(),l("tr",Fc,[t[11]||(t[11]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Cached Tokens",-1)),o("td",zc,[!a.log.is_complete&&!a.log.cached_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Hc,b(a.log.cached_tokens||0),1))])])):i("v-if",!0),o("tr",Wc,[t[12]||(t[12]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Output Tokens",-1)),o("td",Jc,[!a.log.is_complete&&!a.log.output_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Kc,b(a.log.output_tokens||"—"),1))])]),a.log.reasoning_tokens&&a.log.reasoning_tokens>0?(s(),l("tr",Zc,[t[13]||(t[13]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Reasoning Tokens",-1)),o("td",Gc,b(a.log.reasoning_tokens),1)])):i("v-if",!0),o("tr",Xc,[t[14]||(t[14]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Total Tokens",-1)),o("td",Qc,[!a.log.is_complete&&!a.log.total_tokens?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",Yc,b(a.log.total_tokens||"—"),1))])]),o("tr",null,[t[15]||(t[15]=o("td",{class:"py-1 px-2 text-gray-600 dark:text-gray-400 font-medium bg-gray-50 dark:bg-gray-950"},"Total Cost",-1)),o("td",$c,[!a.log.is_complete&&!a.log.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",eu,b(a.log.cost_total?`$${a.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):i("v-if",!0),i(" Tools Called "),e.toolCallsDetailed.length>0?(s(),l("div",tu,[o("div",ou,"Tools Called ("+b(e.toolCallsDetailed.length)+")",1),o("div",ru,[(s(!0),l(W,null,ne(e.toolCallsDetailed,(r,n)=>(s(),l("div",{key:n,class:"border-b border-gray-200 dark:border-gray-800 last:border-b-0"},[o("button",{onClick:p=>e.toggleToolCall(n),class:"w-full px-2 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors flex items-center justify-between text-xs"},[o("span",su,b(r.function?.name||"Unknown"),1),o("span",lu,b(e.expandedToolCalls.has(n)?"▼":"▶"),1)],8,au),fe(o("div",nu,[o("div",iu,[t[17]||(t[17]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Tool Call ID",-1)),o("div",du,b(r.id),1)]),o("div",cu,[t[18]||(t[18]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Function Name",-1)),o("div",uu,b(r.function?.name),1)]),o("div",pu,[t[19]||(t[19]=o("div",{class:"font-semibold text-gray-600 dark:text-gray-400 mb-1"},"Arguments",-1)),o("pre",mu,b(e.formatJson(r.function?.arguments||"{}")),1)]),i(" Tool Result "),e.toolResults.has(r.id)?(s(),l("div",gu,[t[20]||(t[20]=o("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"},"Result",-1)),o("pre",fu,b(e.toolResults.get(r.id)?.content||"No content"),1)])):(s(),l("div",hu,[...t[21]||(t[21]=[o("div",{class:"font-semibold text-gray-500 dark:text-gray-500 mb-1"},"Result",-1),o("div",{class:"text-xs text-gray-500 dark:text-gray-500 italic"},"No result available",-1)])]))],512),[[Ne,e.expandedToolCalls.has(n)]])]))),128))])])):i("v-if",!0),i(" Reasoning Content (from models like o1) "),a.log.reasoning_content?(s(),l("div",vu,[t[23]||(t[23]=o("div",{class:"text-xs font-semibold mb-1"},"Reasoning Content",-1)),o("div",bu,[t[22]||(t[22]=o("div",{class:"px-2 py-1.5 bg-blue-100 dark:bg-blue-900/30 text-xs text-blue-800 dark:text-blue-200 border-b border-blue-300 dark:border-blue-700"}," Internal reasoning output (not displayed to users) ",-1)),o("pre",yu,b(a.log.reasoning_content),1)])])):i("v-if",!0),i(" Reasoning Details (OpenRouter structured reasoning blocks) "),e.reasoningDetails.length>0?(s(),l("div",xu,[o("div",ku,"Reasoning Details ("+b(e.reasoningDetails.length)+" blocks)",1),o("div",_u,[t[28]||(t[28]=o("div",{class:"px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 border-b border-purple-300 dark:border-purple-700"}," Structured reasoning blocks from OpenRouter (preserved for multi-turn continuity) ",-1)),o("div",wu,[(s(!0),l(W,null,ne(e.reasoningDetails,(r,n)=>(s(),l("div",{key:n,class:"p-2"},[o("div",Cu,[o("span",Su,b(r.type||"unknown"),1),r.id?(s(),l("span",Tu," ID: "+b(r.id),1)):i("v-if",!0),r.format?(s(),l("span",Mu," Format: "+b(r.format),1)):i("v-if",!0),r.index!==void 0?(s(),l("span",Iu," Index: "+b(r.index),1)):i("v-if",!0)]),i(" Summary type "),r.type==="reasoning.summary"&&r.summary?(s(),l("div",Vu,[t[24]||(t[24]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Summary:",-1)),o("div",Au,b(r.summary),1)])):i("v-if",!0),i(" Encrypted type "),r.type==="reasoning.encrypted"&&r.data?(s(),l("div",Pu,[t[25]||(t[25]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Encrypted Data:",-1)),o("div",Eu,b(r.data),1)])):i("v-if",!0),i(" Text type "),r.type==="reasoning.text"&&r.text?(s(),l("div",Ou,[t[27]||(t[27]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Reasoning Text:",-1)),o("div",ju,b(r.text),1),r.signature?(s(),l("div",Lu,[t[26]||(t[26]=o("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"},"Signature:",-1)),o("div",Du,b(r.signature),1)])):i("v-if",!0)])):i("v-if",!0),i(" Unknown type - show raw JSON "),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(r.type)?i("v-if",!0):(s(),l("div",Uu,[o("pre",qu,b(JSON.stringify(r,null,2)),1)]))]))),128))])])])):i("v-if",!0),i(" Response Body "),a.log.response_body?(s(),l("div",Nu,[t[29]||(t[29]=o("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),o("pre",Bu,b(e.formatJson(a.log.response_body)),1)])):i("v-if",!0)],512),[[Ne,e.activeTab==="response"]])])])}const Fu=Q(_d,[["render",Ru],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/LogDetails.vue"]]),et=20,ht=20,zu=$({__name:"LogsPane",props:{threadId:{type:[String,null],required:!0},selectedLogId:{type:[String,null],required:!1}},emits:["collapse","logClick"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(0),r=m(et),{logs:n,total:p,hasMore:v,isFetching:g,error:f,wsConnected:h,wsError:w,connectWebSocket:x,disconnectWebSocket:k,refetch:C}=md(z(()=>e.threadId),{limit:z(()=>r.value),offset:z(()=>d.value),enableWebSocket:!0,order:"desc"}),y=m([]),_=m(!0),V=m(null),U=m(null),L=m(!1),j=m(!1),F=m(new Map),K=async()=>{await pe(),U.value&&(U.value.scrollTop=U.value.scrollHeight)};oe(n,async M=>{if(d.value===0)y.value=[...M].reverse(),_.value&&y.value.length>0&&(await K(),_.value=!1);else{const O=[...M].reverse(),A=new Map;y.value.forEach(B=>A.set(B.id,B)),O.forEach(B=>A.set(B.id,B)),y.value=Array.from(A.values()).sort((B,te)=>B.created_at-te.created_at)}},{deep:!0});const{logDetails:D,isFetching:E}=gd(z(()=>e.threadId),z(()=>V.value)),H=z(()=>{if(!V.value)return null;const O=y.value.find(A=>A.id===V.value);return O?D.value?{...D.value,...O}:O:null}),R=M=>{c("logClick",M.id),V.value=M.id},N=(M,O)=>{O?F.value.set(M,O):F.value.delete(M)};oe(V,async M=>{if(M){await pe();const O=F.value.get(M);O&&U.value&&O.scrollIntoView({behavior:"smooth",block:"nearest"})}});const Z=async()=>{if(j.value||!v.value||g.value)return;j.value=!0;const M=U.value?.scrollHeight||0;if(d.value+=r.value,r.value=ht,await C(),await pe(),U.value){const O=U.value.scrollHeight;U.value.scrollTop+=O-M}j.value=!1};oe(()=>e.threadId,async M=>{M?(k(),x()):k(),d.value=0,r.value=et,y.value=[],V.value=null,L.value=!1,_.value=!0},{immediate:!0}),oe(y,async()=>{L.value||await K()},{deep:!0});const G=()=>{if(!U.value)return;const{scrollTop:M,scrollHeight:O,clientHeight:A}=U.value,B=O-M-A<50;L.value=!B},P=M=>{if(!M.tools_called)return"—";try{const O=JSON.parse(M.tools_called);return Array.isArray(O)?O.join(", "):M.tools_called}catch{return M.tools_called}},I=M=>M==null?"—":`$${M.toFixed(6)}`,T=z(()=>{const M=new Map,O=new Map;y.value.forEach(te=>{M.set(te.id,te);const le=te.parent_log_id;le&&(O.has(le)||O.set(le,[]),O.get(le).push(te))});const A=[],B=(te,le)=>{A.push({...te,depth:le}),(O.get(te.id)||[]).forEach(ue=>{B(ue,le+1)})};return y.value.forEach(te=>{te.parent_log_id||B(te,0)}),A}),q={props:e,emit:c,INITIAL_LOAD_LIMIT:et,LOAD_MORE_LIMIT:ht,offset:d,limit:r,fetchedLogs:n,total:p,hasMore:v,isFetching:g,error:f,wsConnected:h,wsError:w,connectWebSocket:x,disconnectWebSocket:k,refetch:C,allLoadedLogs:y,isFirstLoad:_,selectedLogIdForDetails:V,logsScrollContainer:U,userHasScrolledUp:L,isLoadingMore:j,logRowRefs:F,scrollToBottom:K,logDetails:D,isFetchingDetails:E,selectedLog:H,selectLog:R,setLogRowRef:N,loadMoreLogs:Z,handleScroll:G,getToolsCalled:P,formatCost:I,logsWithDepth:T,LogDetailsComponent:Fu,Loader:De,TimeAgo:it,get ScrollTextIcon(){return Tt},get ChevronLeftIcon(){return Ze},get RotateCwIcon(){return so}};return Object.defineProperty(q,"__isScriptSetup",{enumerable:!1,value:!0}),q}}),Hu={class:"flex flex-col h-full"},Wu={class:"p-4 border-b border-gray-300 dark:border-gray-700"},Ju={class:"flex items-center justify-between"},Ku={class:"flex items-center gap-2"},Zu={class:"flex items-center gap-2"},Gu={key:0,class:"text-xs"},Xu={key:0,class:"text-green-600 dark:text-green-400 flex items-center gap-1"},Qu={key:1,class:"text-red-600 dark:text-red-400"},Yu={key:2,class:"text-gray-400 dark:text-gray-600"},$u={key:0,class:"text-gray-500 dark:text-gray-400 text-center py-12"},e0={class:"flex justify-center py-12"},t0={class:"text-red-600 dark:text-red-400 text-center py-12"},o0={key:0,class:"border-b border-gray-300 dark:border-gray-700 bg-white dark:bg-black sticky top-0 z-10"},r0=["disabled"],a0={key:1},s0={key:2},l0={class:"w-full text-sm"},n0=["onClick"],i0={class:"px-3 py-2 text-xs"},d0={class:"flex items-center gap-1"},c0={key:0,class:"text-gray-400 dark:text-gray-600 mr-1"},u0={key:3},p0={class:"px-3 py-2"},m0={class:"flex items-center gap-2"},g0={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},f0={class:"font-mono text-xs"},h0={class:"px-3 py-2 font-mono text-xs"},v0={key:1},b0={class:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400"},y0={key:1},x0={class:"px-3 py-2 text-right text-xs text-gray-500 dark:text-gray-500"},k0={key:0,class:"relative flex-shrink-0 border-t-2 border-gray-300 dark:border-gray-700 overflow-y-auto",style:{height:"min(60%, calc(100vh - 400px))","min-height":"min(40%, 400px)"}},_0={key:0,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"};function w0(u,t,a,e,c,d){return s(),l("div",Hu,[i(" Header "),o("div",Wu,[o("div",Ju,[o("div",Ku,[S(e.ScrollTextIcon,{size:20,class:"flex-shrink-0"}),t[2]||(t[2]=o("h2",{class:"text-xl font-bold"},"Logs",-1))]),o("div",Zu,[i(" WebSocket status "),a.threadId?(s(),l("div",Gu,[e.wsConnected?(s(),l("span",Xu,[...t[3]||(t[3]=[o("span",{class:"inline-block w-2 h-2 rounded-full bg-green-600 dark:bg-green-400"},null,-1),ie(" Live ",-1)])])):e.wsError?(s(),l("span",Qu," ● Error ")):(s(),l("span",Yu," ○ Offline "))])):i("v-if",!0),o("button",{onClick:t[0]||(t[0]=r=>e.emit("collapse")),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Collapse pane"},[S(e.ChevronLeftIcon,{size:20})])])])]),i(" Top half: Scrollable logs list "),o("div",{ref:"logsScrollContainer",class:"flex-1 overflow-y-auto overflow-x-auto",onScroll:e.handleScroll},[i(" No thread selected "),a.threadId?e.isFetching&&e.offset===0?(s(),l(W,{key:1},[i(" Loading state (initial load only) "),o("div",e0,[S(e.Loader)])],2112)):e.error?(s(),l(W,{key:2},[i(" Error state "),o("div",t0," Error loading logs: "+b(e.error),1)],2112)):e.allLoadedLogs.length===0?(s(),l(W,{key:3},[i(" Empty state "),t[4]||(t[4]=o("div",{class:"text-gray-500 dark:text-gray-400 text-center py-12"}," No logs yet ",-1))],2112)):(s(),l(W,{key:4},[i(" Logs table "),o("div",null,[i(" Load previous logs button "),e.hasMore?(s(),l("div",o0,[o("button",{onClick:e.loadMoreLogs,disabled:e.isLoadingMore,type:"button",class:"w-full px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"},[e.isLoadingMore?(s(),X(e.Loader,{key:0,size:"xs"})):i("v-if",!0),e.isLoadingMore?(s(),l("span",a0,"Loading older logs...")):(s(),l("span",s0,"Load previous logs"))],8,r0)])):i("v-if",!0),o("table",l0,[o("thead",{class:ee(["border-b border-gray-300 dark:border-gray-700 sticky bg-white dark:bg-black",{"top-0":!e.hasMore,"top-[34px]":e.hasMore}])},[...t[5]||(t[5]=[o("tr",null,[o("th",{class:"text-left px-3 py-2 font-semibold"},"Prompt"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Model"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Cost"),o("th",{class:"text-left px-3 py-2 font-semibold"},"Tools Called"),o("th",{class:"text-right px-3 py-2 font-semibold"},"Called At")],-1)])],2),o("tbody",null,[(s(!0),l(W,null,ne(e.logsWithDepth,r=>(s(),l("tr",{key:r.id,ref_for:!0,ref:n=>e.setLogRowRef(r.id,n),class:ee(["border-b border-gray-200 dark:border-gray-800 cursor-pointer transition-colors",{"bg-red-50 dark:bg-red-950/20":r.error,"bg-blue-50 dark:bg-blue-950/20":e.selectedLogIdForDetails===r.id,"ring-2 ring-blue-500":r.id===e.props.selectedLogId}]),onClick:n=>e.selectLog(r)},[o("td",i0,[o("div",d0,[r.depth>0?(s(),l("span",c0,"└─")):i("v-if",!0),r.retry_of_log_id?(s(),X(e.RotateCwIcon,{key:1,size:14,class:"text-gray-500 dark:text-gray-400 flex-shrink-0"})):i("v-if",!0),!r.is_complete&&!r.prompt_name?(s(),X(e.Loader,{key:2,size:"xs"})):(s(),l("span",u0,b(r.prompt_name||"—"),1))])]),o("td",p0,[o("div",m0,[r.error?(s(),l("span",g0," ✕ ")):i("v-if",!0),o("span",f0,b(r.model_name||r.model),1)])]),o("td",h0,[!r.is_complete&&!r.cost_total?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",v0,b(e.formatCost(r.cost_total)),1))]),o("td",b0,[!r.is_complete&&e.getToolsCalled(r)==="—"?(s(),X(e.Loader,{key:0,size:"xs"})):(s(),l("span",y0,b(e.getToolsCalled(r)),1))]),o("td",x0,[S(e.TimeAgo,{timestamp:r.created_at},null,8,["timestamp"])])],10,n0))),128))])])])],2112)):(s(),l("div",$u," Select a thread to view logs "))],544),i(" Bottom half: Log details "),e.selectedLog?(s(),l("div",k0,[S(e.LogDetailsComponent,{log:e.selectedLog,onClose:t[1]||(t[1]=r=>e.selectedLogIdForDetails=null)},null,8,["log"]),i(" Loading overlay for log details "),e.isFetchingDetails?(s(),l("div",_0,[S(e.Loader)])):i("v-if",!0)])):i("v-if",!0)])}const C0=Q(zu,[["render",w0],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/LogsPane.vue"]]),S0=$({__name:"CreateThreadModal",props:{modelValue:{type:Boolean,required:!0},editThread:{type:null,required:!1}},emits:["update:modelValue","thread-created","thread-updated"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>!!e.editThread),r=m(""),n=m(""),p=m({}),v=m([]),g=m(""),f=m(!1),h=m(""),w=m(null),{data:x,isFetching:k,execute:C}=ve(J("/api/agents"),{immediate:!1}).json(),y=z(()=>x.value?(x.value?.agents||[]).map(q=>({value:q.id,label:q.title})):[]),_=z(()=>!r.value||!x.value?null:(x.value?.agents||[]).find(q=>q.id===r.value)),V=z(()=>_.value&&_.value.type==="ai_human"?"AI":"Side A"),U=z(()=>_.value&&_.value.type==="ai_human"?"Human":"Side B"),{data:L,isFetching:j,execute:F}=ve(z(()=>_.value?.side_a_system_prompt?J(`/api/prompts/${_.value.side_a_system_prompt}`):""),{immediate:!1}).json(),K=z(()=>{if(!L.value)return null;const T=L.value?.required_schema;if(!T)return null;try{return typeof T=="string"?JSON.parse(T):T}catch{return null}}),D=z(()=>{const T=K.value;return!T||!T.properties?[]:Object.entries(T.properties).map(([q,M])=>({name:q,type:M.type||"string",description:M.description||"",required:T.required?.includes(q)||!1,enum:M.enum}))});oe(r,async T=>{T&&_.value?.side_a_system_prompt?(await F(),p.value={}):p.value={}});const E=()=>{const T=w.value;T&&(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)},H=T=>{g.value.trim()&&(v.value.push({id:crypto.randomUUID(),role:T,content:g.value.trim()}),g.value="",setTimeout(()=>E(),0))},R=T=>{v.value=v.value.filter(q=>q.id!==T)},N=()=>{r.value="",n.value="",p.value={},v.value=[],g.value="",h.value=""},Z=()=>{e.editThread&&(r.value=e.editThread.agent_id,n.value=e.editThread.tags?.join(", ")||"")},G=async()=>{if(!r.value){h.value="Please select an agent";return}if(!d.value&&D.value.length>0){for(const T of D.value)if(T.required&&!p.value[T.name]){h.value=`Please provide ${T.name}`;return}}f.value=!0,h.value="";try{const T=n.value.split(",").map(q=>q.trim()).filter(q=>q.length>0);if(d.value){const q=await fetch(J(`/api/threads/${e.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:T})});if(!q.ok){const M=await q.json();throw new Error(M.error||"Failed to update thread")}c("thread-updated"),N(),c("update:modelValue",!1)}else{const q={agent_id:r.value,tags:T.length>0?T:void 0};v.value.length>0&&(q.initial_messages=v.value.map(B=>({role:B.role,content:B.content}))),Object.keys(p.value).length>0&&(q.data=p.value);const M=await fetch(J("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q)});if(!M.ok){const B=await M.json();throw new Error(B.error||"Failed to create thread")}const A=(await M.json()).threadId;if(!A)throw new Error("Thread created but ID not found in response");c("thread-created",A),N(),c("update:modelValue",!1)}}catch(T){console.error(`Error ${d.value?"updating":"creating"} thread:`,T),h.value=T.message||`Failed to ${d.value?"update":"create"} thread`}finally{f.value=!1}},P=()=>{N(),c("update:modelValue",!1)};oe(()=>e.modelValue,async T=>{T&&(await C(),N(),d.value&&Z())});const I={props:e,emit:c,isEditMode:d,selectedAgentId:r,tags:n,requiredData:p,messages:v,newMessageContent:g,isSubmitting:f,errorMessage:h,textareaRef:w,agentsData:x,isFetchingAgents:k,fetchAgents:C,agentOptions:y,selectedAgent:_,sideALabel:V,sideBLabel:U,promptData:L,isFetchingPrompt:j,fetchPrompt:F,requiredSchema:K,schemaFields:D,adjustHeight:E,addMessage:H,removeMessage:R,resetForm:N,populateEditForm:Z,handleSubmit:G,handleCancel:P,Modal:Ve,SelectInput:xe,TextInput:je,TextareaInput:Et};return Object.defineProperty(I,"__isScriptSetup",{enumerable:!1,value:!0}),I}}),T0={class:"space-y-4"},M0={key:0,class:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-sm text-red-800 dark:text-red-200"},I0={class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},V0={key:0},A0={key:1},P0={key:1,class:"space-y-4 p-4 bg-gray-50 dark:bg-gray-900 rounded-lg"},E0={class:"flex items-center gap-2"},O0=["onUpdate:modelValue","id"],j0=["for"],L0={key:0,class:"text-red-500"},D0={key:5,class:"text-xs text-gray-500 dark:text-gray-400 mt-1"},U0={key:2,class:"p-4 bg-gray-50 dark:bg-gray-900 rounded-lg text-center text-sm text-gray-500"},q0={key:3},N0={key:0,class:"space-y-3 mb-4 max-h-64 overflow-y-auto p-2"},B0={class:"text-xs font-medium mb-1 opacity-70"},R0={class:"text-sm whitespace-pre-wrap"},F0=["onClick"],z0={class:"space-y-2"},H0={class:"flex items-stretch border border-black dark:border-white rounded overflow-hidden bg-white dark:bg-black"},W0=["disabled","title"],J0={class:"flex-1 relative"},K0=["disabled","title"],Z0={class:"text-xs text-gray-500 dark:text-gray-400"},G0={class:"flex justify-between"},X0=["disabled"],Q0=["disabled"];function Y0(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[7]||(t[7]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Thread":"Create New Thread",width:"max-w-3xl"},{footer:ae(()=>[o("div",G0,[o("button",{onClick:e.handleCancel,type:"button",disabled:e.isSubmitting,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors disabled:opacity-50"}," Cancel ",8,X0),o("button",{onClick:e.handleSubmit,type:"button",disabled:e.isSubmitting||e.isFetchingAgents,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50"},[e.isEditMode?(s(),l(W,{key:0},[ie(b(e.isSubmitting?"Updating...":"Update Thread"),1)],64)):(s(),l(W,{key:1},[ie(b(e.isSubmitting?"Creating...":"Create Thread"),1)],64))],8,Q0)])]),default:ae(()=>[o("div",T0,[i(" Error Message "),e.errorMessage?(s(),l("div",M0,b(e.errorMessage),1)):i("v-if",!0),i(" Agent Selection (disabled in edit mode) "),o("div",null,[S(e.SelectInput,{modelValue:e.selectedAgentId,"onUpdate:modelValue":t[0]||(t[0]=r=>e.selectedAgentId=r),label:"Agent",options:e.agentOptions,disabled:e.isFetchingAgents||e.isEditMode,placeholder:"Select an agent...",required:""},null,8,["modelValue","options","disabled"]),o("p",I0,[e.isEditMode?(s(),l("span",V0,"Agent cannot be changed after thread creation")):(s(),l("span",A0,"Choose which agent will handle this conversation"))])]),i(" Dynamic schema fields (only in create mode) "),!e.isEditMode&&e.schemaFields.length>0&&!e.isFetchingPrompt?(s(),l("div",P0,[t[8]||(t[8]=o("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Required Information ",-1)),(s(!0),l(W,null,ne(e.schemaFields,r=>(s(),l("div",{key:r.name,class:"space-y-2"},[i(" Enum field (dropdown) "),r.enum?(s(),X(e.SelectInput,{key:0,modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,options:[{value:"",label:"Select..."},...r.enum.map(n=>({value:n,label:n}))],required:r.required},null,8,["modelValue","onUpdate:modelValue","label","options","required"])):r.type==="string"?(s(),l(W,{key:1},[i(" Text field "),S(e.TextInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,placeholder:r.description,required:r.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)):r.type==="number"||r.type==="integer"?(s(),l(W,{key:2},[i(" Number field "),S(e.TextInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,modelModifiers:{number:!0},label:r.name,placeholder:r.description,type:"number",required:r.required},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)):r.type==="boolean"?(s(),l(W,{key:3},[i(" Boolean field "),o("div",E0,[fe(o("input",{"onUpdate:modelValue":n=>e.requiredData[r.name]=n,type:"checkbox",id:`field-${r.name}`,class:"w-4 h-4"},null,8,O0),[[lo,e.requiredData[r.name]]]),o("label",{for:`field-${r.name}`,class:"text-sm"},[ie(b(r.name)+" ",1),r.required?(s(),l("span",L0,"*")):i("v-if",!0)],8,j0)])],2112)):(s(),l(W,{key:4},[i(" Fallback: textarea for complex types "),S(e.TextareaInput,{modelValue:e.requiredData[r.name],"onUpdate:modelValue":n=>e.requiredData[r.name]=n,label:r.name,placeholder:r.description||`Enter ${r.name} (JSON format)`,required:r.required,rows:3},null,8,["modelValue","onUpdate:modelValue","label","placeholder","required"])],2112)),r.description?(s(),l("p",D0,b(r.description),1)):i("v-if",!0)]))),128))])):i("v-if",!0),i(" Loading prompt schema (only in create mode) "),!e.isEditMode&&e.isFetchingPrompt?(s(),l("div",U0," Loading agent requirements... ")):i("v-if",!0),i(" Conversation Builder (only in create mode) "),e.isEditMode?i("v-if",!0):(s(),l("div",q0,[t[12]||(t[12]=o("h4",{class:"text-sm font-medium mb-3"},"Initial Conversation",-1)),i(" Messages List (iOS style) "),e.messages.length>0?(s(),l("div",N0,[(s(!0),l(W,null,ne(e.messages,r=>(s(),l("div",{key:r.id,class:ee(["flex items-start gap-2",{"justify-start":r.role==="assistant","justify-end":r.role==="user"}])},[o("div",{class:ee(["max-w-[80%] rounded-2xl px-4 py-2 break-words",{"bg-black text-white dark:bg-white dark:text-black":r.role==="assistant","bg-gray-200 text-black dark:bg-gray-800 dark:text-white":r.role==="user"}])},[o("div",B0,b(r.role==="assistant"?e.sideALabel:e.sideBLabel),1),o("div",R0,b(r.content),1)],2),o("button",{onClick:n=>e.removeMessage(r.id),type:"button",class:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 text-xs mt-2"}," ✕ ",8,F0)],2))),128))])):(s(),l(W,{key:1},[i(" Empty state "),t[9]||(t[9]=o("div",{class:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm"}," No messages yet. Add messages to start the conversation. ",-1))],2112)),i(" Add Message Form "),o("div",z0,[i(" Unified Input Container "),o("div",H0,[i(" Agent/Side A Button (LEFT) "),o("button",{onClick:t[1]||(t[1]=r=>e.addMessage("assistant")),type:"button",disabled:!e.newMessageContent.trim(),title:`Add as ${e.sideALabel}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-r border-black dark:border-white flex-shrink-0"},[t[10]||(t[10]=o("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),o("span",null,b(e.sideALabel),1)],8,W0),i(" Multiline Input (no border, no padding adjustments needed) "),o("div",J0,[fe(o("textarea",{"onUpdate:modelValue":t[2]||(t[2]=r=>e.newMessageContent=r),placeholder:"Type a message...",class:"w-full px-3 py-2 bg-transparent border-0 font-mono text-sm focus:outline-none resize-none overflow-hidden",rows:"1",ref:"textareaRef",onInput:e.adjustHeight,onKeydown:[t[3]||(t[3]=rt(he(r=>e.addMessage("user"),["meta"]),["enter"])),t[4]||(t[4]=rt(he(r=>e.addMessage("user"),["ctrl"]),["enter"]))]},null,544),[[_e,e.newMessageContent]])]),i(" Human/Side B Button (RIGHT) "),o("button",{onClick:t[5]||(t[5]=r=>e.addMessage("user")),type:"button",disabled:!e.newMessageContent.trim(),title:`Add as ${e.sideBLabel}`,class:"px-3 py-2 bg-black text-white dark:bg-white dark:text-black text-sm hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap inline-flex items-center gap-1 border-l border-black dark:border-white flex-shrink-0"},[t[11]||(t[11]=o("svg",{class:"w-[1em] h-[1em]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 10l7-7m0 0l7 7m-7-7v18"})],-1)),o("span",null,b(e.sideBLabel),1)],8,K0)]),o("p",Z0," Type a message and click "+b(e.sideALabel)+" (left) or "+b(e.sideBLabel)+" (right) to add. Or press Cmd+Enter (Mac) / Ctrl+Enter (Windows) to add as "+b(e.sideBLabel)+". ",1)])])),i(" Tags "),o("div",null,[S(e.TextInput,{modelValue:e.tags,"onUpdate:modelValue":t[6]||(t[6]=r=>e.tags=r),label:"Tags",placeholder:"research, urgent, production"},null,8,["modelValue"]),t[13]||(t[13]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Comma-separated tags to help organize and search threads ",-1))])])]),_:1},8,["model-value","title"])}const $0=Q(S0,[["render",Y0],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/threads/CreateThreadModal.vue"]]),ep=$({__name:"ThreadsView",setup(u,{expose:t}){t();const a=Pe(),e=Le(),c=m(typeof a.params.id=="string"?a.params.id:null),d=m({threadList:!1,messages:!1,meta:!0,logs:!1}),r=m(!1),n=m(null),p=m(null),{thread:v}=nt(z(()=>c.value)),g=m(null),f=m(null);oe(()=>a.params.id,j=>{c.value=typeof j=="string"?j:null,g.value=null,f.value=null});const L={route:a,router:e,selectedThreadId:c,collapsedPanes:d,showThreadModal:r,editingThread:n,threadListPaneRef:p,thread:v,selectedMessageId:g,selectedLogId:f,handleThreadSelect:j=>{e.push(`/threads/${j}`)},handleThreadDeleted:j=>{window.location.href="/threads"},handleEditThread:()=>{v.value&&(n.value=v.value,r.value=!0)},handleCreateThread:()=>{n.value=null,r.value=!0},handleThreadCreated:j=>{p.value?.refetch(),e.push(`/threads/${j}`)},handleThreadUpdated:()=>{window.location.reload()},togglePane:j=>{d.value[j]=!d.value[j]},handleMessageClick:(j,F)=>{g.value=j,f.value=F},handleLogClick:j=>{f.value=j,g.value=null},ThreadListPane:an,MessagesPane:bi,MetaPane:pd,LogsPane:C0,CreateThreadModal:$0,get ListIcon(){return _t},get MessageSquareIcon(){return Ct},get InfoIcon(){return St},get ScrollTextIcon(){return Tt}};return Object.defineProperty(L,"__isScriptSetup",{enumerable:!1,value:!0}),L}}),tp={class:"flex h-screen bg-white dark:bg-black overflow-hidden"},op={key:0,class:"flex flex-col items-center p-4"},rp={key:0,class:"flex flex-col items-center p-4"},ap={key:0,class:"flex flex-col items-center p-4"},sp={key:0,class:"flex flex-col items-center p-4"};function lp(u,t,a,e,c,d){return s(),l("div",tp,[i(" Pane 1: Thread List "),o("div",{class:ee([e.collapsedPanes.threadList?"w-[60px]":"w-[320px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.threadList?(s(),l("div",op,[o("button",{onClick:t[0]||(t[0]=r=>e.togglePane("threadList")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Threads pane"},[S(e.ListIcon,{size:20})])])):(s(),X(e.ThreadListPane,{key:1,ref:"threadListPaneRef","selected-thread-id":e.selectedThreadId,onSelectThread:e.handleThreadSelect,onCollapse:t[1]||(t[1]=r=>e.togglePane("threadList")),onCreateThread:e.handleCreateThread},null,8,["selected-thread-id"]))],2),i(" Pane 2: Messages "),o("div",{class:ee([e.collapsedPanes.messages?"w-[60px]":"w-[350px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.messages?(s(),l("div",rp,[o("button",{onClick:t[2]||(t[2]=r=>e.togglePane("messages")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Messages pane"},[S(e.MessageSquareIcon,{size:20})])])):(s(),X(e.MessagesPane,{key:1,"thread-id":e.selectedThreadId,"selected-message-id":e.selectedMessageId,"selected-log-id":e.selectedLogId,onCollapse:t[3]||(t[3]=r=>e.togglePane("messages")),onMessageClick:e.handleMessageClick},null,8,["thread-id","selected-message-id","selected-log-id"]))],2),i(" Pane 3: Meta Info "),o("div",{class:ee([e.collapsedPanes.meta?"w-[60px]":"w-[350px]","border-r border-gray-300 dark:border-gray-700 flex-shrink-0 overflow-hidden transition-all duration-200"])},[e.collapsedPanes.meta?(s(),l("div",ap,[o("button",{onClick:t[4]||(t[4]=r=>e.togglePane("meta")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Metadata pane"},[S(e.InfoIcon,{size:20})])])):(s(),X(e.MetaPane,{key:1,"thread-id":e.selectedThreadId,onCollapse:t[5]||(t[5]=r=>e.togglePane("meta")),onThreadDeleted:e.handleThreadDeleted,onEditThread:e.handleEditThread},null,8,["thread-id"]))],2),i(" Pane 4: Logs (flexible width) "),o("div",{class:ee([e.collapsedPanes.logs?"w-[60px]":"flex-1","overflow-hidden transition-all duration-200"])},[e.collapsedPanes.logs?(s(),l("div",sp,[o("button",{onClick:t[6]||(t[6]=r=>e.togglePane("logs")),class:"p-2 hover:bg-gray-100 dark:hover:bg-gray-900 rounded transition-colors",title:"Expand Logs pane"},[S(e.ScrollTextIcon,{size:20})])])):(s(),X(e.LogsPane,{key:1,"thread-id":e.selectedThreadId,"selected-log-id":e.selectedLogId,onCollapse:t[7]||(t[7]=r=>e.togglePane("logs")),onLogClick:e.handleLogClick},null,8,["thread-id","selected-log-id"]))],2),i(" Thread Modal (Create/Edit) "),S(e.CreateThreadModal,{modelValue:e.showThreadModal,"onUpdate:modelValue":t[8]||(t[8]=r=>e.showThreadModal=r),"edit-thread":e.editingThread,onThreadCreated:e.handleThreadCreated,onThreadUpdated:e.handleThreadUpdated},null,8,["modelValue","edit-thread"])])}const vt=Q(ep,[["render",lp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ThreadsView.vue"]]),np=$({__name:"PromptsDataTable",emits:["add","edit","delete"],setup(u,{expose:t,emit:a}){const e=a,c=m([]),d=m(!1),r=[{key:"name",label:"Name",width:"w-1/4"},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",formatter:(f,h)=>f||h.model_id||"-"},{key:"created_at",label:"Created",width:"w-1/6",formatter:f=>f?new Date(f*1e3).toLocaleDateString():"-"}],n=[{icon:"edit",label:"Edit",handler:f=>e("edit",f)},{icon:"delete",label:"Delete",handler:async f=>{await v(f)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?"}],p=async()=>{d.value=!0;try{const f=await fetch(J("/api/prompts"));if(f.ok){const h=await f.json();c.value=h.prompts||[]}}catch(f){console.error("Error fetching prompts:",f)}finally{d.value=!1}},v=async f=>{try{const h=await fetch(J(`/api/prompts/${f.id}`),{method:"DELETE"});if(h.ok)await p();else{const w=await h.json();alert(w.error||"Failed to delete prompt")}}catch(h){console.error("Error deleting prompt:",h),alert("Failed to delete prompt")}};ce(()=>{p()}),t({refresh:p});const g={emit:e,prompts:c,loading:d,columns:r,actions:n,fetchPrompts:p,deletePrompt:v,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}});function ip(u,t,a,e,c,d){return s(),l("div",null,[S(e.DataTable,{columns:e.columns,data:e.prompts,actions:e.actions,loading:e.loading,"empty-message":"No prompts available. Create your first prompt to get started."},null,8,["data","loading"])])}const dp=Q(np,[["render",ip],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/PromptsDataTable.vue"]]),cp=$({__name:"PromptBasicInfo",props:{name:{type:String,required:!0},toolDescription:{type:String,required:!0}},emits:["update:name","update:toolDescription"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(""),r=v=>{let g=v.replace(/[^a-zA-Z0-9\s_]/g,"");return g=g.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),g?/^[a-z][a-z0-9_]*$/.test(g)?d.value="":d.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":d.value="Name is required",g},n=v=>{const g=r(v);c("update:name",g)};oe(()=>e.name,v=>{v&&r(v)},{immediate:!0});const p={props:e,emit:c,nameError:d,validateAndFormatName:r,handleNameInput:n,TextInput:je};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),up={class:"space-y-4"},pp={key:0,class:"mt-1 text-sm text-red-500"},mp={key:1,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},gp={class:"px-1 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},fp=["value"];function hp(u,t,a,e,c,d){return s(),l("div",up,[o("div",null,[S(e.TextInput,{"model-value":a.name,"onUpdate:modelValue":e.handleNameInput,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)"},null,8,["model-value"]),e.nameError?(s(),l("p",pp,b(e.nameError),1)):a.name?(s(),l("p",mp,[t[1]||(t[1]=ie(" Will be saved as: ",-1)),o("code",gp,b(a.name),1)])):i("v-if",!0)]),o("div",null,[t[2]||(t[2]=o("label",{class:"block text-sm font-medium mb-2"},"Tool Description",-1)),o("textarea",{value:a.toolDescription,onInput:t[0]||(t[0]=r=>e.emit("update:toolDescription",r.target.value)),placeholder:"Describe what this prompt does (shown when used as a tool)",class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent resize-none",rows:"3"},null,40,fp)])])}const vp=Q(cp,[["render",hp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptBasicInfo.vue"]]),bp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='%23F0EFEA'/%3e%3cpath%20d='M32.84%2010H26.72L37.88%2038H44L32.84%2010Z'%20fill='black'/%3e%3cpath%20d='M15.16%2010L4%2038H10.24L12.5224%2032.12H24.1976L26.48%2038H32.72L21.56%2010H15.16ZM14.5408%2026.92L18.36%2017.08L22.1793%2026.92H14.5408Z'%20fill='black'/%3e%3c/svg%3e",Je="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20rx='24'%20fill='white'/%3e%3cpath%20d='M19.3418%2018.5599V14.7599C19.3418%2014.4399%2019.4608%2014.1998%2019.7382%2014.04L27.3102%209.63997C28.3409%209.03999%2029.5699%208.76014%2030.8383%208.76014C35.5954%208.76014%2038.6085%2012.4802%2038.6085%2016.4401C38.6085%2016.72%2038.6085%2017.04%2038.5687%2017.3601L30.7194%2012.72C30.2437%2012.4401%2029.7678%2012.4401%2029.2922%2012.72L19.3418%2018.5599ZM37.0226%2033.36V24.2799C37.0226%2023.7197%2036.7846%2023.3197%2036.309%2023.0398L26.3586%2017.1998L29.6093%2015.3197C29.8868%2015.1599%2030.1247%2015.1599%2030.4022%2015.3197L37.9741%2019.7197C40.1547%2020.9999%2041.6213%2023.7197%2041.6213%2026.3596C41.6213%2029.3995%2039.8375%2032.1999%2037.0226%2033.36ZM17.0029%2025.3601L13.7522%2023.4402C13.4748%2023.2804%2013.3557%2023.0402%2013.3557%2022.7202V13.9203C13.3557%209.64039%2016.6065%206.40016%2021.0069%206.40016C22.6722%206.40016%2024.2179%206.96029%2025.5265%207.96025L17.7168%2012.5204C17.2412%2012.8003%2017.0033%2013.2002%2017.0033%2013.7605L17.0029%2025.3601ZM24%2029.44L19.3418%2026.8001V21.2003L24%2018.5604L28.6578%2021.2003V26.8001L24%2029.44ZM26.993%2041.6002C25.3278%2041.6002%2023.7821%2041.04%2022.4735%2040.0402L30.2831%2035.4799C30.7588%2035.2001%2030.9967%2034.8001%2030.9967%2034.2399V22.6399L34.2873%2024.5598C34.5646%2024.7196%2034.6837%2024.9597%2034.6837%2025.2798V34.0797C34.6837%2038.3596%2031.3931%2041.6002%2026.993%2041.6002ZM17.5975%2032.6802L10.0255%2028.2803C7.84493%2027.0001%206.37833%2024.2803%206.37833%2021.6404C6.37833%2018.5604%208.20193%2015.8004%2011.0164%2014.6403V23.7602C11.0164%2024.3204%2011.2544%2024.7204%2011.73%2025.0003L21.641%2030.8001L18.3902%2032.6802C18.1129%2032.84%2017.8749%2032.84%2017.5975%2032.6802ZM17.1617%2039.2402C12.682%2039.2402%209.39151%2035.8402%209.39151%2031.6401C9.39151%2031.3201%209.43125%2031.0001%209.47066%2030.68L17.2803%2035.2402C17.7559%2035.5201%2018.2319%2035.5201%2018.7074%2035.2402L28.6578%2029.4404V33.2404C28.6578%2033.5605%2028.5388%2033.8005%2028.2614%2033.9604L20.6894%2038.3604C19.6586%2038.9603%2018.4301%2039.2402%2017.1617%2039.2402ZM26.993%2044C31.7899%2044%2035.7936%2040.5601%2036.7057%2036C41.1457%2034.8399%2044%2030.6399%2044%2026.36C44%2023.5598%2042.8108%2020.8401%2040.6701%2018.88C40.8683%2018.0399%2040.9872%2017.1998%2040.9872%2016.3602C40.9872%2010.6403%2036.3885%206.35998%2031.0763%206.35998C30.0062%206.35998%2028.9754%206.51979%2027.9446%206.88001C26.1604%205.11992%2023.7025%204%2021.0069%204C16.2101%204%2012.2064%207.4398%2011.2943%2012C6.8543%2013.1601%204%2017.3601%204%2021.6399C4%2024.4401%205.18916%2027.1599%207.32995%2029.1199C7.13174%2029.96%207.01277%2030.8001%207.01277%2031.6398C7.01277%2037.3597%2011.6114%2041.6399%2016.9236%2041.6399C17.9938%2041.6399%2019.0246%2041.4801%2020.0554%2041.1199C21.8392%2042.88%2024.2971%2044%2026.993%2044Z'%20fill='black'/%3e%3c/svg%3e",yp="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%3e%3cpath%20fill='%234285F4'%20d='M14.9%208.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24%203.24%200%2001-1.407%202.127v1.75h2.269c1.332-1.22%202.097-3.02%202.097-5.15z'/%3e%3cpath%20fill='%2334A853'%20d='M8.14%2015c1.898%200%203.499-.62%204.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836%200-3.393-1.232-3.952-2.888H1.85v1.803A7.044%207.044%200%20008.14%2015z'/%3e%3cpath%20fill='%23FBBC04'%20d='M4.187%209.342a4.17%204.17%200%20010-2.68V4.859H1.849a6.97%206.97%200%20000%206.286l2.338-1.803z'/%3e%3cpath%20fill='%23EA4335'%20d='M8.14%203.77a3.837%203.837%200%20012.7%201.05l2.01-1.999a6.786%206.786%200%2000-4.71-1.82%207.042%207.042%200%2000-6.29%203.858L4.186%206.66c.556-1.658%202.116-2.89%203.952-2.89z'/%3e%3c/svg%3e",bt="/agents/assets/img/meta.svg",xp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.8962%2017.7465V14.9519C18.1789%2014.9346%2018.4615%2014.9174%2018.7442%2014.9174C26.5881%2014.6758%2031.7291%2021.5072%2031.7291%2021.5072C31.7291%2021.5072%2026.1818%2029.0287%2020.2282%2029.0287C19.4332%2029.0287%2018.6559%2028.9079%2017.9139%2028.6664V20.1789C20.9702%2020.5412%2021.5885%2021.8523%2023.4082%2024.8367L27.4891%2021.49C27.4891%2021.49%2024.5035%2017.6775%2019.4862%2017.6775C18.9562%2017.6603%2018.4262%2017.6948%2017.8962%2017.7465ZM17.8962%208.5V12.6747L18.7442%2012.623C29.6445%2012.2607%2036.7641%2021.352%2036.7641%2021.352C36.7641%2021.352%2028.6021%2031.047%2020.1045%2031.047C19.3625%2031.047%2018.6382%2030.978%2017.9139%2030.8573V33.4449C18.5145%2033.5139%2019.1329%2033.5657%2019.7335%2033.5657C27.6481%2033.5657%2033.3721%2029.6152%2038.9194%2024.9574C39.8381%2025.682%2043.601%2027.4243%2044.3784%2028.1834C39.1137%2032.4961%2026.8355%2035.9636%2019.8749%2035.9636C19.2035%2035.9636%2018.5675%2035.9291%2017.9315%2035.86V39.5H48V8.5L17.8962%208.5ZM17.8962%2028.6664V30.8745C10.5823%2029.5979%208.55061%2022.1628%208.55061%2022.1628C8.55061%2022.1628%2012.0662%2018.3676%2017.8962%2017.7465V20.1617H17.8785C14.8222%2019.7994%2012.4196%2022.594%2012.4196%2022.594C12.4196%2022.594%2013.7799%2027.3036%2017.8962%2028.6664ZM4.9113%2021.8523C4.9113%2021.8523%209.2396%2015.6074%2017.9139%2014.9519V12.6747C8.30327%2013.4338%200%2021.3692%200%2021.3692C0%2021.3692%204.6993%2034.6525%2017.8962%2035.86V33.4449C8.21494%2032.2718%204.9113%2021.8523%204.9113%2021.8523Z'%20fill='%2376B900'/%3e%3c/svg%3e",kp="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",_p="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M47.4964%209.43757C46.988%209.19072%2046.769%209.66115%2046.4717%209.90013C46.37%209.97722%2046.284%2010.0774%2046.1979%2010.1699C45.4548%2010.9562%2044.5866%2011.4729%2043.4523%2011.4112C41.794%2011.3186%2040.3781%2011.8353%2039.1265%2013.092C38.8605%2011.5423%2037.9767%2010.617%2036.6312%2010.0234C35.9273%209.71497%2035.2154%209.40651%2034.7226%208.7357C34.3784%208.25783%2034.2845%207.7258%2034.1124%207.20147C34.0029%206.8854%2033.8934%206.56146%2033.5257%206.50747C33.1268%206.44587%2032.9703%206.77725%2032.8138%207.05499C32.1881%208.18844%2031.9456%209.43749%2031.969%2010.7019C32.0237%2013.5471%2033.2363%2015.8137%2035.6455%2017.4252C35.9193%2017.6103%2035.9896%2017.7952%2035.9036%2018.0652C35.7393%2018.6204%2035.5437%2019.16%2035.3717%2019.7151C35.2622%2020.0699%2035.0978%2020.147%2034.7146%2019.9926C33.3926%2019.4453%2032.2505%2018.6357%2031.2414%2017.6566C29.5284%2016.0143%2027.9795%2014.2024%2026.0475%2012.7837C25.5938%2012.4521%2025.1401%2012.1438%2024.6707%2011.8507C22.6994%209.95412%2024.9289%208.39653%2025.4451%208.21163C25.9848%208.01885%2025.6329%207.35566%2023.8884%207.36353C22.144%207.37114%2020.5483%207.94946%2018.5146%208.72047C18.2173%208.83615%2017.9043%208.92086%2017.5836%208.99025C15.7376%208.64338%2013.8211%208.56612%2011.8186%208.78986C8.04819%209.20613%205.03671%2010.9718%202.823%2013.9865C0.16347%2017.6103%20-0.462297%2021.7274%200.304303%2026.0221C1.11002%2030.5478%203.44099%2034.295%207.02367%2037.225C10.7393%2040.2626%2015.0181%2041.7507%2019.8992%2041.4655C22.8639%2041.2959%2026.1649%2040.9027%2029.8884%2037.7801C30.827%2038.2427%2031.8126%2038.4276%2033.4475%2038.5664C34.7069%2038.6821%2035.9194%2038.5048%2036.858%2038.3121C38.3286%2038.0037%2038.227%2036.6544%2037.6951%2036.4077C33.385%2034.4185%2034.3314%2035.228%2033.471%2034.5726C35.6613%2032.0052%2038.9624%2029.3374%2040.253%2020.6942C40.3546%2020.0081%2040.2686%2019.5763%2040.253%2019.0211C40.2451%2018.682%2040.3234%2018.551%2040.7145%2018.5123C41.794%2018.3889%2042.8422%2018.096%2043.8043%2017.5717C46.5969%2016.0606%2047.7233%2013.5779%2047.9892%2010.6017C48.0284%2010.1468%2047.9814%209.67638%2047.4964%209.43757ZM23.1611%2036.2225C18.984%2032.969%2016.9581%2031.8971%2016.1211%2031.9434C15.3388%2031.9897%2015.4797%2032.8764%2015.6517%2033.4547C15.8316%2034.0252%2016.0663%2034.4185%2016.3948%2034.9196C16.6216%2035.2511%2016.7782%2035.7445%2016.168%2036.1147C14.8226%2036.9397%2012.4836%2035.8371%2012.3741%2035.7832C9.65202%2034.1948%207.37571%2032.0975%205.77205%2029.2295C4.22322%2026.4691%203.32373%2023.5086%203.17504%2020.3474C3.13592%2019.5841%203.36276%2019.3141%204.12936%2019.1755C5.13843%2018.9904%206.17884%2018.9517%207.1879%2019.0982C11.4512%2019.7151%2015.0807%2021.6041%2018.1235%2024.5956C19.86%2026.2995%2021.1742%2028.3352%2022.5275%2030.3243C23.9668%2032.4368%2025.5156%2034.4493%2027.4868%2036.0992C28.183%2036.6775%2028.7384%2037.1169%2029.2703%2037.4408C27.6668%2037.6181%2024.9915%2037.6568%2023.1611%2036.2225ZM25.1636%2023.4623C25.1636%2023.123%2025.4374%2022.8532%2025.7817%2022.8532C25.8599%2022.8532%2025.9303%2022.8685%2025.9929%2022.8916C26.079%2022.9225%2026.1572%2022.9688%2026.2198%2023.038C26.3293%2023.1461%2026.3919%2023.3002%2026.3919%2023.4622C26.3919%2023.8014%2026.1181%2024.0712%2025.774%2024.0712C25.4299%2024.0712%2025.1636%2023.8015%2025.1636%2023.4623ZM31.3824%2026.6235C30.9835%2026.7854%2030.5846%2026.9241%2030.2013%2026.9395C29.6068%2026.9703%2028.9575%2026.7313%2028.6056%2026.4383C28.058%2025.9834%2027.6669%2025.7291%2027.5026%2024.9349C27.4322%2024.5956%2027.4713%2024.0713%2027.534%2023.7707C27.6747%2023.123%2027.5183%2022.7067%2027.0568%2022.3288C26.6813%2022.0204%2026.2041%2021.9357%2025.68%2021.9357C25.4844%2021.9357%2025.3046%2021.8508%2025.1716%2021.7814C24.9525%2021.6735%2024.7727%2021.4036%2024.9447%2021.0721C24.9995%2020.9643%2025.2655%2020.702%2025.3281%2020.6558C26.04%2020.2548%2026.8613%2020.3859%2027.6201%2020.6866C28.3242%2020.9719%2028.8561%2021.4962%2029.6226%2022.2363C30.4048%2023.1306%2030.5456%2023.3776%2030.9915%2024.0482C31.3436%2024.5725%2031.6643%2025.1122%2031.8833%2025.7291C32.0162%2026.1146%2031.844%2026.4307%2031.3824%2026.6235Z'%20fill='%234D6BFE'/%3e%3c/svg%3e",wp="data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201513%20975'%20width='1513'%20height='975'%3e%3ctitle%3eae99cd49-2667-464e-b9db-b39cee0126e1-svg%3c/title%3e%3cstyle%3e%20.s0%20{%20fill:%20%23ff5a00%20}%20%3c/style%3e%3cg%20id='%23ff5a00ff'%3e%3cpath%20id='Layer'%20class='s0'%20d='m989.5%200h67.8c95.3%205.4%20196.5%2023.1%20272.4%2085.5%2060.6%2049.1%2086.3%20133%2071.4%20208.6-11.4%2056.4-37.4%20108.4-65.4%20158.1-56.8%2098.4-126.6%20188.2-193%20280.1-11.9%2015.2-21.2%2033.8-20%2053.6%201.1%2015.7%2013.1%2028.4%2027.2%2034%2027.3%2011.1%2057.5%208.9%2086.2%207.3%2090.7-9.5%20178.1-37%20264.6-64.6%206.6-4.1%208.8%202.6%2011.3%207.4-91.9%2061.3-190.8%20112.4-294.8%20150-57.5%2019.3-118.3%2037.6-179.6%2030.4-32.2-3.2-64.5-22.4-74.6-54.5-12.5-41.8-7.9-88.1%2010.2-127.6%2027.5-61.7%2070.2-114.7%20110.7-168.2%2067.1-88%20136.4-175.5%20189.1-273.3%2017.4-34.7%2036-76.8%2018.7-115.1-16.3-35.3-51.7-56.1-85.6-71.8-60.2-26.9-124.4-43.1-187.7-61.1q-14.3%209.4-28.5%2019c22%2016.8%2044%2033.6%2065.8%2050.7-83.3%2015-166.3%2031.8-248.3%2052.7-124.9%2031-246.8%2072.5-367.6%20116.5%2011.8%2023.5%2023.5%2047.1%2034.7%2070.9-27.3%2030.2-54.4%2060.7-81.7%2090.9%2065.6%2019.6%20136.3%2022.3%20203.2%207.5%2057.2-12.8%20111-40.2%20154.7-79.3-11.9-14.8-26.9-26.7-43.1-36.5%2053.1%201.1%20101.4%2047.4%20101.5%20101.1q-15.6%200.1-31%200.2c-2.2-11.7-5.3-23-9.4-34.1-60.3%2054.5-138.2%2088.6-218.9%2097.4-71.1%208.2-143.8-1.6-210.7-26.6%204.5%2041.4%209%2082.6%2013.2%20124-38%2014.8-73.3%2036.2-104.9%2062-25.1%2021.9-50%2047.1-59.6%2079.9-9.2%2028.9%205.8%2061.7%2031.1%2077.2%2030.7%2019%2066.5%2027.8%20101.9%2032.9%2046.7%206.1%2093.9%205.6%20140.8%202.3%2092.1-6.8%20183.1-24.1%20272.7-45.8%208.9-3.6%2013.1%2011.1%204%2013.4-71.5%2036.8-146.3%2067.8-224.3%2087.8-73.3%2018.9-148.8%2028.6-224.4%2031.2-77.1-2.4-159-17.3-220.1-67.8-45.4-36.8-69.3-95.2-69.5-153.1v-3.1c1.5-61.2%2022.2-120.4%2052-173.4%2039.2-74.8%2087.5-145%20144.6-207.3%2098.7-108.7%20222.5-192.8%20355.6-253.7%20137.9-62.5%20285.5-107.4%20437.3-115.7z'/%3e%3c/g%3e%3c/svg%3e",Cp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNGRjZCNkIiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0id2hpdGUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZm9udC13ZWlnaHQ9ImJvbGQiPk1NPC90ZXh0Pgo8L3N2Zz4=",Sp="/agents/assets/img/moonshotai.svg",Tp="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3crect%20width='48'%20height='48'%20fill='black'/%3e%3cpath%20d='M10.008%2019.311L24.0672%2040H30.3165L16.2557%2019.311H10.008ZM16.2509%2030.8017L10%2040H16.2541L19.3771%2035.4017L16.2509%2030.8017ZM31.7459%208L20.941%2023.8993L24.0672%2028.5009L38%208H31.7459ZM32.8777%2017.8382V40H38V10.3008L32.8777%2017.8382Z'%20fill='white'/%3e%3c/svg%3e",Mp="/agents/assets/img/zai.svg",Ip="/agents/assets/img/zai.svg",Vp="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIj4KICA8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIGZpbGw9IiNBOEU2QTMiLz4KICA8dGV4dCB4PSI1MCUiIHk9IjUwJSIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJDM0U1MCIgZm9udC1mYW1pbHk9IkFyaWFsLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBmb250LXdlaWdodD0iYm9sZCI+RVhBPC90ZXh0Pgo8L3N2Zz4=",at="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenRouter%3c/title%3e%3cpath%20d='M16.804%201.957l7.22%204.105v.087L16.73%2010.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147%201.352L8.345%2011.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314%201.17.796%202.701%201.866%201.11.775%202.083%201.177%203.147%201.352l.3.045c.694.091%201.375.094%202.825.033l.022-2.159%207.22%204.105v.087L16.589%2022l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997%2021.997%200%2000-.755-.498l-.467-.28a55.927%2055.927%200%2000-.76-.43C2.908%2014.73.563%2014.116%200%2014.116V9.888l.14.004c.564-.007%202.91-.622%203.809-1.124l1.016-.58.438-.274c.428-.28%201.072-.726%202.686-1.853%201.621-1.133%203.186-1.78%204.881-2.059%201.152-.19%201.974-.213%203.814-.138l.02-1.907z'%3e%3c/path%3e%3c/svg%3e";function Ap(u){const t=Ge();return t==="/"?u.replace("/agents/","/"):u.replace("/agents/",`${t}/`)}const Pp={anthropic:bp,openai:Je,"openai-sdk":Je,google:yp,meta:bt,"meta-llama":bt,nvidia:xp,alibaba:kp,deepseek:_p,qwen:wp,minimax:Cp,moonshotai:Sp,"x-ai":Tp,"z-ai":Mp,zai:Ip,exaone:Vp,openrouter:at},Ep=new Proxy(Pp,{get(u,t){const a=u[t];return a?Ap(a):void 0}});function Op(u){if(u&&u.includes("/"))return u.split("/")[0].toLowerCase()}function Ke(u){return Ep[u.toLowerCase()]}function dt(u,t){const a=Op(u);if(a){const e=Ke(a);if(e)return e}if(t)return Ke(t)}const jp=$({__name:"PromptModelSelect",props:{modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(!1),n=z(()=>d.value.map(g=>({value:g.id,label:g.name,description:g.model||g.provider,icon:dt(g.model||g.name,g.provider_id||g.provider)}))),p=async()=>{r.value=!0;try{const g=await fetch(J("/api/models"));if(g.ok){const f=await g.json();d.value=f.models||[]}}catch(g){console.error("Error fetching models:",g)}finally{r.value=!1}};ce(()=>{p()});const v={props:e,emit:c,models:d,loadingModels:r,modelOptions:n,fetchModels:p,SelectInput:xe};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),Lp={class:"space-y-4"};function Dp(u,t,a,e,c,d){return s(),l("div",Lp,[S(e.SelectInput,{"model-value":a.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.emit("update:modelValue",r)),options:e.modelOptions,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:e.loadingModels},null,8,["model-value","options","loading"])])}const Up=Q(jp,[["render",Dp],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptModelSelect.vue"]]),qp=$({__name:"PropertyEditor",props:Se({propertyId:{type:String,required:!0},isNested:{type:Boolean,required:!1,default:!1},parentId:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},enableDrag:{type:Boolean,required:!1,default:!0}},{modelValue:{type:Object,required:!0},modelModifiers:{}}),emits:Se(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Ee(u,"modelValue"),r=m(!1),n=m(),p={string:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"/></svg>',number:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"/></svg>',boolean:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>',object:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/></svg>',array:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>',enum:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/></svg>',anyOf:'<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>'},v=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' 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'/%3E%3C/svg%3E"},{value:"number",label:"Number",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 20l4-16m2 16l4-16M6 9h14M4 15h14'/%3E%3C/svg%3E"},{value:"boolean",label:"Boolean",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E"},{value:"object",label:"Object",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'/%3E%3C/svg%3E"},{value:"array",label:"Array",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 6h16M4 10h16M4 14h16M4 18h16'/%3E%3C/svg%3E"},{value:"enum",label:"Enum",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4'/%3E%3C/svg%3E"},{value:"anyOf",label:"Any Of (Multiple Types)",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='w-4 h-4' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E"}],g=z(()=>["object","array","enum","anyOf"].includes(d.value.type));oe(()=>d.value.type,async(V,U)=>{if(["object","array","enum","anyOf"].includes(V)&&(r.value=!0,V==="anyOf"&&!d.value.anyOf&&(d.value.anyOf=[]),V==="object"&&!d.value.properties&&(d.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),V==="array"&&!d.value.items&&(d.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),V==="enum"&&!d.value.enum&&(d.value.enum=["value1"])),U!==void 0){await pe();const L=e.isNested?`[data-nested-property-id="${e.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${e.propertyId}"] input[placeholder="Description"]`,j=document.querySelector(L);j&&j.focus()}});const f=V=>{V.shiftKey&&d.value.type==="object"&&d.value.properties?k():c("add-top-level")},h=()=>{d.value.items||(d.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},w=()=>{d.value.enum||(d.value.enum=[]),d.value.enum.push(`value${d.value.enum.length+1}`)},x=V=>{d.value.enum&&d.value.enum.splice(V,1)},k=async()=>{const V={id:crypto.randomUUID(),name:d.value.type==="anyOf"?"":`property${(d.value.properties?.length||d.value.anyOf?.length||0)+1}`,type:"string",description:""};d.value.type==="anyOf"?(d.value.anyOf||(d.value.anyOf=[]),d.value.anyOf.push(V)):(d.value.properties||(d.value.properties=[]),d.value.properties.push(V)),await pe();const U=document.querySelector(`[data-nested-property-id="${V.id}"] input[placeholder="Property name"]`);U&&(U.focus(),U.select())},_={props:e,emit:c,modelValue:d,expanded:r,propertyListRef:n,typeIcons:p,typeOptions:v,isExpandable:g,handleEnterKey:f,initArrayItems:h,addEnumValue:w,removeEnumValue:x,addNestedProperty:k,removeNestedProperty:V=>{d.value.type==="anyOf"&&d.value.anyOf?d.value.anyOf=d.value.anyOf.filter(U=>U.id!==V):d.value.properties&&(d.value.properties=d.value.properties.filter(U=>U.id!==V))},handleNestedDescriptionKeydown:V=>{},SelectInput:xe,TextInput:je};return Object.defineProperty(_,"__isScriptSetup",{enumerable:!1,value:!0}),_}}),Np=["data-property-id","data-nested-property-id"],Bp={class:"p-3 space-y-3"},Rp={class:"flex items-start gap-2"},Fp={key:0,class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400 mt-2"},zp={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Hp={class:"flex items-center gap-2 mt-2"},Wp=["disabled"],Jp={key:0,class:"ml-6"},Kp={key:0,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg space-y-2"},Zp={class:"flex items-center justify-between mb-2"},Gp=["disabled"],Xp={key:0,class:"space-y-1"},Qp=["onClick","disabled"],Yp={key:1,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg"},$p={class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"},em={class:"space-y-2"},tm={class:"flex items-center justify-between"},om=["disabled"],rm={class:"space-y-2"},am={key:2,class:"p-3 bg-gray-50 dark:bg-gray-900 rounded-lg"},sm={key:0,class:"mb-2"},lm=["disabled"],nm={key:1,class:"space-y-2"};function im(u,t,a,e,c,d){const r=no("PropertyEditor",!0);return s(),l("div",{"data-property-id":a.isNested?void 0:a.propertyId,"data-nested-property-id":a.isNested?a.propertyId:void 0,class:ee(["border rounded-lg",a.isNested?"border-gray-100 dark:border-gray-900":"border-gray-200 dark:border-gray-800"])},[o("div",Bp,[o("div",Rp,[i(" Drag handle "),a.enableDrag?(s(),l("div",Fp,[...t[10]||(t[10]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):i("v-if",!0),i(" Property fields "),o("div",zp,[S(e.TextInput,{modelValue:e.modelValue.name,"onUpdate:modelValue":t[0]||(t[0]=n=>e.modelValue.name=n),placeholder:"Property name",disabled:a.disabled},null,8,["modelValue","disabled"]),S(e.SelectInput,{modelValue:e.modelValue.type,"onUpdate:modelValue":t[1]||(t[1]=n=>e.modelValue.type=n),options:e.typeOptions,disabled:a.disabled},null,8,["modelValue","disabled"]),S(e.TextInput,{modelValue:e.modelValue.description,"onUpdate:modelValue":t[2]||(t[2]=n=>e.modelValue.description=n),placeholder:"Description",disabled:a.disabled,onKeydown:t[3]||(t[3]=rt(he(n=>e.handleEnterKey(n),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),i(" Controls "),o("div",Hp,[e.isExpandable?(s(),l("button",{key:0,onClick:t[4]||(t[4]=n=>e.expanded=!e.expanded),type:"button",class:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors"},[(s(),l("svg",{class:ee(["w-4 h-4 transition-transform",e.expanded?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...t[11]||(t[11]=[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):i("v-if",!0),o("button",{onClick:t[5]||(t[5]=n=>u.$emit("remove")),type:"button",disabled:a.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...t[12]||(t[12]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Wp)])]),i(" Expandable content "),e.expanded&&e.isExpandable?(s(),l("div",Jp,[i(" Enum values "),e.modelValue.type==="enum"?(s(),l("div",Kp,[o("div",Zp,[t[13]||(t[13]=o("h4",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"},"Enum Values",-1)),o("button",{onClick:e.addEnumValue,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Add Value ",8,Gp)]),e.modelValue.enum?(s(),l("div",Xp,[(s(!0),l(W,null,ne(e.modelValue.enum,(n,p)=>(s(),l("div",{key:p,class:"flex items-center gap-2"},[S(e.TextInput,{modelValue:e.modelValue.enum[p],"onUpdate:modelValue":v=>e.modelValue.enum[p]=v,placeholder:"Enum value",disabled:a.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),o("button",{onClick:v=>e.removeEnumValue(p),type:"button",disabled:a.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...t[14]||(t[14]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Qp)]))),128))])):i("v-if",!0)])):i("v-if",!0),i(" Object properties / anyOf types "),e.modelValue.type==="object"||e.modelValue.type==="anyOf"?(s(),l("div",Yp,[o("h4",$p,b(e.modelValue.type==="anyOf"?"Type Options":"Nested Properties"),1),o("div",em,[i(" Add nested properties buttons "),o("div",tm,[o("button",{onClick:e.addNestedProperty,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Add "+b(e.modelValue.type==="anyOf"?"Type Option":"Property"),9,om)]),i(" Render nested properties "),o("div",rm,[(s(!0),l(W,null,ne(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties,(n,p)=>(s(),X(r,{key:n.id,modelValue:(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties)[p],"onUpdate:modelValue":v=>(e.modelValue.type==="anyOf"?e.modelValue.anyOf:e.modelValue.properties)[p]=v,"property-id":n.id,"is-nested":!0,"parent-id":a.propertyId,disabled:a.disabled,"enable-drag":!1,onRemove:v=>e.removeNestedProperty(n.id),onAddTopLevel:t[6]||(t[6]=v=>e.emit("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):i("v-if",!0),i(" Array items "),e.modelValue.type==="array"?(s(),l("div",am,[t[15]||(t[15]=o("h4",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"},"Array Item Type",-1)),e.modelValue.items?i("v-if",!0):(s(),l("div",sm,[o("button",{onClick:e.initArrayItems,type:"button",disabled:a.disabled,class:"px-2 py-0.5 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,lm)])),e.modelValue.items?(s(),l("div",nm,[S(r,{modelValue:e.modelValue.items,"onUpdate:modelValue":t[7]||(t[7]=n=>e.modelValue.items=n),"property-id":e.modelValue.items.id,"is-nested":!0,"parent-id":a.propertyId,disabled:a.disabled,"enable-drag":!1,onRemove:t[8]||(t[8]=n=>e.modelValue.items=null),onAddTopLevel:t[9]||(t[9]=n=>e.emit("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"])])):i("v-if",!0)])):i("v-if",!0)])):i("v-if",!0)])],10,Np)}const dm=Q(qp,[["render",im],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PropertyEditor.vue"]]),cm=$({__name:"PropertyList",props:Se({disabled:{type:Boolean,required:!1,default:!1},parentId:{type:String,required:!1},isNested:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:Se(["add-property","description-keydown"],["update:modelValue"]),setup(u,{expose:t,emit:a}){const e=u,c=a,d=Ee(u,"modelValue"),r=m();let n=!1;ce(async()=>{}),Te(()=>{});const p=async()=>{if(n)return;n=!0;const h={id:crypto.randomUUID(),name:`property${d.value.length+1}`,type:"string",description:"",required:!1};d.value=[...d.value,h],await pe();const w=e.parentId?`[data-nested-property-id="${h.id}"]`:`[data-property-id="${h.id}"]`,x=document.querySelector(`${w} input[placeholder="Property name"]`);x&&(x.focus(),x.select()),c("add-property"),n=!1},v=h=>{d.value=d.value.filter(w=>w.id!==h)},g=h=>{};t({addProperty:p});const f={props:e,emit:c,modelValue:d,dragAreaRef:r,get isAddingProperty(){return n},set isAddingProperty(h){n=h},addProperty:p,removeProperty:v,handleDescriptionKeydown:g,PropertyEditor:dm};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),um={class:"space-y-2"},pm={ref:"dragAreaRef",class:"space-y-2"},mm=["disabled"];function gm(u,t,a,e,c,d){return s(),l("div",um,[o("div",pm,[(s(!0),l(W,null,ne(e.modelValue,r=>(s(),X(e.PropertyEditor,{key:r.id,modelValue:e.modelValue[e.modelValue.indexOf(r)],"onUpdate:modelValue":n=>e.modelValue[e.modelValue.indexOf(r)]=n,"property-id":r.id,"is-nested":a.isNested,"parent-id":a.parentId,disabled:a.disabled,"enable-drag":!a.isNested,onRemove:n=>e.removeProperty(r.id),onAddTopLevel:t[0]||(t[0]=n=>u.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),i(" Add Property button at the bottom for both nested and non-nested "),o("div",{class:ee(a.isNested?"mt-2":"mt-3 pt-3 border-t border-gray-200 dark:border-gray-800")},[o("button",{onClick:e.addProperty,type:"button",disabled:a.disabled,class:ee(a.isNested?"px-2 py-1 text-xs bg-gray-800 dark:bg-gray-200 text-white dark:text-black rounded hover:bg-gray-700 dark:hover:bg-gray-300 transition-colors disabled:opacity-50":"w-full px-3 py-2 text-sm bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 rounded transition-colors disabled:opacity-50 border border-dashed border-gray-300 dark:border-gray-700")},[...t[1]||(t[1]=[o("span",{class:"flex items-center justify-center gap-2"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ie(" Add Property ")],-1)])],10,mm)],2)])}const fm=Q(cm,[["render",gm],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PropertyList.vue"]]),hm=$({__name:"JSONSchemaInput",props:Se({label:{type:String,required:!1},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1}},{modelValue:{type:null,required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(),r=m(!1),n=()=>{if(e.value?.properties){const y=[];e.value.required;for(const[_,V]of Object.entries(e.value.properties)){const U=V,L={id:crypto.randomUUID(),name:_,type:U.type||"string",description:U.description||""};U.enum&&(L.enum=U.enum),U.anyOf&&(L.type="anyOf",L.anyOf=p(U.anyOf)),U.type==="array"&&U.items&&(L.items=v(U.items)),U.type==="object"&&U.properties&&(L.properties=g(U.properties,U.required||[])),y.push(L)}c.value=y}},p=y=>y.map(_=>typeof _=="object"&&_.type?{id:crypto.randomUUID(),name:"",type:_.type,description:_.description||"",properties:_.properties?g(_.properties,_.required||[]):void 0,items:_.items?v(_.items):void 0,enum:_.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),v=y=>{const _={id:crypto.randomUUID(),name:"",type:y.type||"string",description:y.description||""};return y.enum&&(_.enum=y.enum),y.anyOf&&(_.type="anyOf",_.anyOf=p(y.anyOf)),y.type==="array"&&y.items&&(_.items=v(y.items)),y.type==="object"&&y.properties&&(_.properties=g(y.properties,y.required||[])),_},g=(y,_)=>{const V=[];for(const[U,L]of Object.entries(y)){const j=L,F={id:crypto.randomUUID(),name:U,type:j.type||"string",description:j.description||""};j.enum&&(F.enum=j.enum),j.anyOf&&(F.type="anyOf",F.anyOf=p(j.anyOf)),j.type==="array"&&j.items&&(F.items=v(j.items)),j.type==="object"&&j.properties&&(F.properties=g(j.properties,j.required||[])),V.push(F)}return V};n();const f=()=>{const y={type:"object",properties:{},required:[],additionalProperties:!1},{properties:_,required:V}=w(c.value);y.properties=_,y.required=Object.keys(_),e.value=y},h=y=>{const _={type:y.type==="anyOf"?void 0:y.type,description:y.description};if(y.type==="enum"&&y.enum&&(_.enum=y.enum,_.type="string"),y.type==="anyOf"&&y.anyOf&&(delete _.type,_.anyOf=y.anyOf.map(h)),y.type==="object"&&y.properties){const{properties:V,required:U}=w(y.properties);_.properties=V,_.required=Object.keys(V),_.additionalProperties=!1}return y.type==="array"&&y.items&&(_.items=h(y.items)),_},w=y=>{const _={},V=[];for(const U of y){const L={type:U.type==="anyOf"?void 0:U.type,description:U.description};if(V.push(U.name),U.type==="enum"&&U.enum&&(L.enum=U.enum,L.type="string"),U.type==="anyOf"&&U.anyOf&&U.anyOf.length>0&&(delete L.type,L.anyOf=U.anyOf.map(h)),U.type==="array"&&U.items&&(L.items=h(U.items)),U.type==="object"&&U.properties){const{properties:j,required:F}=w(U.properties);L.properties=j,L.required=Object.keys(j),L.additionalProperties=!1}_[U.name]=L}return{properties:_,required:V}};oe(c,()=>{f()},{deep:!0}),f();const x=z(()=>JSON.stringify(e.value,null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"]+)":/g,'<span class="text-blue-600 dark:text-blue-400">"$1"</span>:').replace(/:"([^"]*)"/g,':<span class="text-green-600 dark:text-green-400">"$1"</span>').replace(/:(\d+)/g,':<span class="text-yellow-600 dark:text-yellow-400">$1</span>').replace(/:(true|false)/g,':<span class="text-purple-600 dark:text-purple-400">$1</span>').replace(/:(null)/g,':<span class="text-red-600 dark:text-red-400">$1</span>')),C={props:a,modelValue:e,properties:c,propertyListRef:d,showSchema:r,initializeProperties:n,convertAnyOfToProperties:p,convertSchemaToProperty:v,convertSchemaToProperties:g,updateSchema:f,convertPropertyToSchema:h,convertPropertiesToSchema:w,highlightedSchema:x,addProperty:async()=>{if(c.value.length===0){const y={id:crypto.randomUUID(),name:"property1",type:"string",description:""};c.value.push(y),await pe();const _=document.querySelector(`[data-property-id="${y.id}"] input[placeholder="Property name"]`);_&&(_.focus(),_.select())}else d.value&&d.value.addProperty()},PropertyList:fm};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),vm={class:"space-y-4"},bm={key:0,class:"flex items-center justify-between"},ym={class:"text-sm font-medium"},xm={key:0,class:"text-red-500"},km={class:"space-y-2 border border-gray-200 dark:border-gray-800 rounded-lg p-4"},_m={key:0,class:"flex items-center justify-between mb-2"},wm={key:1,class:"text-center py-12"},Cm=["disabled"],Sm={class:"mt-4 text-center"},Tm={key:3,class:"mt-4"},Mm={class:"bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-lg p-4 overflow-x-auto"},Im={class:"text-xs leading-relaxed"},Vm=["innerHTML"];function Am(u,t,a,e,c,d){return s(),l("div",vm,[a.label?(s(),l("div",bm,[o("label",ym,[ie(b(a.label)+" ",1),a.required?(s(),l("span",xm,"*")):i("v-if",!0)])])):i("v-if",!0),o("div",km,[e.properties.length>0?(s(),l("div",_m,[...t[2]||(t[2]=[o("h3",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Properties",-1)])])):i("v-if",!0),e.properties.length===0?(s(),l("div",wm,[t[4]||(t[4]=o("div",{class:"mb-4"},[o("svg",{class:"w-12 h-12 mx-auto text-gray-400 dark:text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})])],-1)),t[5]||(t[5]=o("p",{class:"text-gray-500 dark:text-gray-400 text-sm mb-4"},"No properties defined",-1)),o("button",{onClick:e.addProperty,type:"button",disabled:a.disabled,class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black rounded hover:bg-gray-800 dark:hover:bg-gray-200 transition-colors disabled:opacity-50 font-medium text-sm"},[...t[3]||(t[3]=[o("span",{class:"flex items-center gap-2"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ie(" Add Property ")],-1)])],8,Cm)])):i("v-if",!0),e.properties.length>0?(s(),X(e.PropertyList,{key:2,ref:"propertyListRef",modelValue:e.properties,"onUpdate:modelValue":t[0]||(t[0]=r=>e.properties=r),disabled:a.disabled,onAddProperty:e.addProperty},null,8,["modelValue","disabled"])):i("v-if",!0),i(" Show JSON Schema link "),o("div",Sm,[o("button",{onClick:t[1]||(t[1]=r=>e.showSchema=!e.showSchema),type:"button",class:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:underline transition-colors"},b(e.showSchema?"Hide":"Show")+" JSON Schema ",1)]),i(" JSON Schema Display "),e.showSchema?(s(),l("div",Tm,[o("div",Mm,[o("pre",Im,[o("code",{class:"font-mono",innerHTML:e.highlightedSchema},null,8,Vm)])])])):i("v-if",!0)])])}const Ot=Q(hm,[["render",Am],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/JSONSchemaInput.vue"]]),Pm=$({__name:"PromptInput",props:{modelValue:{type:Array,required:!1},search:{type:Function,required:!1},placeholder:{type:String,required:!1,default:"Type @ to insert variables or prompts..."},disabled:{type:Boolean,required:!1,default:!1},maxLength:{type:Number,required:!1},allowedTypes:{type:Array,required:!1,default:()=>["variable","prompt"]}},emits:["update:modelValue","segment-click"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(),r=m(),n=io({segments:e.modelValue&&e.modelValue.length?e.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),v=P=>P.type==="string"?"":`@${P.type==="variable"?P.label||P.value:P.label||P.id}`,g=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!d.value)return null;const I=P.getRangeAt(0);let T=0;const q=Array.from(d.value.childNodes);for(let M=0;M<q.length;M++){const O=q[M];if(O===I.startContainer||O.contains?.(I.startContainer)){if(O.nodeType===Node.TEXT_NODE)return{segmentIndex:T,offset:I.startOffset};if(O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag"))return{segmentIndex:T,offset:0}}(O.nodeType===Node.TEXT_NODE||O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag"))&&T++}return{segmentIndex:0,offset:0}},f=P=>{if(!d.value)return;const I=window.getSelection();if(!I)return;const T=Array.from(d.value.childNodes);let q=0,M=null,O=0;for(const A of T){if(q===P.segmentIndex){if(A.nodeType===Node.TEXT_NODE)M=A,O=Math.min(P.offset,A.textContent?.length||0);else if(A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag")){const B=A.nextSibling;if(B&&B.nodeType===Node.TEXT_NODE)M=B,O=0;else{const te=document.createTextNode("");A.parentNode?.insertBefore(te,A.nextSibling),M=te,O=0}}break}(A.nodeType===Node.TEXT_NODE||A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag"))&&q++}if(!M&&T.length){const A=T[T.length-1];if(A.nodeType===Node.TEXT_NODE)M=A,O=A.textContent?.length||0;else if(A.nodeType===Node.ELEMENT_NODE&&A.classList?.contains("prompt-tag")){const B=document.createTextNode("");A.parentNode?.insertBefore(B,A.nextSibling),M=B,O=0}}if(M){const A=document.createRange();A.setStart(M,O),A.collapse(!0),I.removeAllRanges(),I.addRange(A)}},h=()=>{if(!d.value)return;const P=n.segments.map(I=>{if(I.type==="string")return(I.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"";{const T=I._uid||(I._uid=p()),q=v(I),M=I.type==="variable"?{type:"variable",value:I.value,label:I.label,schema:I.schema,meta:I.meta}:{type:"prompt",id:I.id,label:I.label,schema:I.schema,meta:I.meta},O=encodeURIComponent(JSON.stringify(M)),A=I.type==="prompt"&&I.meta&&!I.meta.isValid,B=A?'<span class="prompt-tag-warning" title="'+(I.meta.validationMessage||"").replace(/"/g,"&quot;")+'">⚠️</span>':"";return`<span class="prompt-tag prompt-tag-clickable${A?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${T}" data-segment="${O}">${q}${B}</span>`}}).join("");d.value.innerHTML=P||"<br>"},w=()=>{const P=[];for(const I of n.segments)I.type==="string"&&P.length>0&&P[P.length-1].type==="string"?P[P.length-1].value+=I.value:P.push(I);n.segments=P.length?P:[{type:"string",value:""}]},x=P=>{const I=P.dataset.segmentUid;let T=n.segments.find(q=>q._uid===I);if(!T){const q=P.dataset.segment;if(q)try{const M=JSON.parse(decodeURIComponent(q));M&&(M.type==="variable"||M.type==="prompt")&&(T=M.type==="variable"?{type:"variable",value:M.value,label:M.label,schema:M.schema,meta:M.meta,_uid:I}:{type:"prompt",id:M.id,label:M.label,schema:M.schema,meta:M.meta,_uid:I})}catch{}}return T||null},k=P=>{const I=P.target;if(I.classList?.contains("prompt-tag")){const T=x(I);T&&c("segment-click",T,P)}},C=P=>{if(n.isComposing)return;const I=P.target,T=[];let q="";const M=()=>{q.length>0&&(T.push({type:"string",value:q}),q="")},O=le=>{if(le.nodeType===Node.TEXT_NODE){const re=(le.textContent||"").replace(/\u00A0/g," ");q+=re;return}if(le.nodeType===Node.ELEMENT_NODE){const re=le;if(re.classList?.contains("prompt-tag")){M();const me=x(re);me&&T.push(me);return}if(re.tagName==="BR"){q+=`
9
9
  `;return}const ue=Array.from(re.childNodes);for(const me of ue)O(me);(re.tagName==="DIV"||re.tagName==="P"||re.tagName==="LI")&&re.nextSibling&&(q+=`
10
- `);return}},A=Array.from(V.childNodes);for(const le of A)O(le);M();const te=T.some(le=>le.type!=="string")?T:[{type:"string",value:(V.innerText||"").replace(/\r\n/g,`
11
- `)}];n.segments=te.length?te:[{type:"string",value:""}],w(),y(),R()},y=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!d.value)return;const V=P.getRangeAt(0);if(V.startContainer.nodeType!==Node.TEXT_NODE){n.dialogOpen&&I();return}const q=V.startContainer.textContent||"",M=V.startOffset;if(M>0&&q[M-1]==="@")n.atTriggerIndex=M-1,n.searchQuery="",_(),j("");else if(n.dialogOpen&&n.atTriggerIndex>=0)if(V.startContainer.nodeType===Node.TEXT_NODE){const O=V.startContainer.textContent||"",A=V.startOffset;if(A<=n.atTriggerIndex){I();return}const B=O.substring(0,A);if(B.length>n.atTriggerIndex&&B[n.atTriggerIndex]==="@"){const te=B.substring(n.atTriggerIndex+1);te.includes(" ")||te.includes(`
12
- `)||te.length>n.searchQuery.length+5?I():(n.searchQuery=te,j(te))}else I()}else I()},_=async()=>{n.dialogOpen=!0,n.selectedIndex=0,await pe(),U()},I=()=>{n.dialogOpen=!1,n.searchResults=[],n.searchQuery="",n.atTriggerIndex=-1,n.isSearching=!1},U=()=>{if(!r.value||!d.value)return;const P=window.getSelection();if(!P||!P.rangeCount)return;const T=P.getRangeAt(0).getBoundingClientRect(),q=d.value.getBoundingClientRect();n.dialogPosition={x:T.left-q.left,y:T.bottom-q.top+4}};let L=null;const j=async P=>{if(!e.search){n.searchResults=[];return}L&&clearTimeout(L),n.isSearching=!0,L=setTimeout(async()=>{try{const V=await e.search(P);n.searchResults=(V||[]).filter(T=>e.allowedTypes?.includes(T.type))}catch(V){console.error("Search error:",V),n.searchResults=[]}finally{n.isSearching=!1}},200)},F=P=>P.type==="variable"?{type:"variable",value:P.value??P.id??"",label:P.label,schema:P.schema,_uid:p(),meta:P.meta}:{type:"prompt",id:P.id??P.value??"",label:P.label,schema:P.schema,_uid:p(),meta:P.meta},K=P=>{if(n.atTriggerIndex<0||!d.value)return;const V=window.getSelection();if(!V||!V.rangeCount)return;const T=V.getRangeAt(0);if(T.startContainer.nodeType!==Node.TEXT_NODE)return;const q=T.startContainer,M=q.data.slice(0,n.atTriggerIndex),O=q.data.slice(T.startOffset),A=document.createElement("span"),B=F(P),te=B.type==="prompt"&&B.meta&&!B.meta.isValid;A.className=`prompt-tag${te?" prompt-tag-invalid":""}`,A.setAttribute("contenteditable","false");const le=B._uid||(B._uid=p());A.dataset.segmentUid=le;const re=B.type==="variable"?{type:"variable",value:B.value,label:B.label,schema:B.schema}:{type:"prompt",id:B.id,label:B.label,schema:B.schema};if(A.dataset.segment=encodeURIComponent(JSON.stringify(re)),A.textContent=v(B),te){const be=document.createElement("span");be.className="prompt-tag-warning",be.textContent="⚠️",be.setAttribute("title",B.meta.validationMessage||"Validation error"),A.appendChild(be)}const ue=q.parentNode,me=document.createTextNode(O),we=document.createTextNode(M);ue.insertBefore(we,q),ue.insertBefore(A,q),ue.insertBefore(me,q),ue.removeChild(q),I(),C({target:d.value});const ke=window.getSelection();if(ke){const be=document.createRange();be.setStart(me,0),be.collapse(!0),ke.removeAllRanges(),ke.addRange(be)}d.value.focus()},D=P=>{if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&setTimeout(()=>y(),0),n.dialogOpen)P.key==="ArrowDown"?(P.preventDefault(),n.selectedIndex=Math.min(n.selectedIndex+1,n.searchResults.length-1)):P.key==="ArrowUp"?(P.preventDefault(),n.selectedIndex=Math.max(n.selectedIndex-1,0)):P.key==="Enter"?(P.preventDefault(),n.searchResults[n.selectedIndex]&&K(n.searchResults[n.selectedIndex])):(P.key==="Escape"||P.key==="Esc")&&(P.preventDefault(),I());else if(P.key==="Backspace"||P.key==="Delete"){const V=g();if(P.key==="Backspace"){const T=window.getSelection();if(T&&T.rangeCount){const q=T.getRangeAt(0);if(q.collapsed&&q.startContainer.nodeType===Node.TEXT_NODE&&q.startOffset===0){let M=q.startContainer;for(;M&&M!==d.value;){const O=M.previousSibling;if(O&&O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag")){P.preventDefault(),O.parentNode?.removeChild(O),C({target:d.value});return}M=M.parentNode}}}}if(!V)return;if(P.key==="Backspace"&&V.offset===0&&V.segmentIndex>0)n.segments[V.segmentIndex-1].type!=="string"&&(P.preventDefault(),n.segments.splice(V.segmentIndex-1,1),w(),R(),h());else if(P.key==="Delete"&&V.segmentIndex<n.segments.length-1){const T=n.segments[V.segmentIndex];T.type==="string"&&(T.value?.length??0)===V.offset&&n.segments[V.segmentIndex+1].type!=="string"&&(P.preventDefault(),n.segments.splice(V.segmentIndex+1,1),w(),R(),h())}}},E=P=>{P.preventDefault();const V=P.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,V)},H=P=>{if(!n.dialogOpen)return;const V=r.value;V&&(V.contains(P.target)||I())},R=()=>{n.ignoreNextWatch=!0;const P=n.segments.map(V=>{const{_uid:T,...q}=V||{};return q});c("update:modelValue",P)},N=()=>{const P=window.getSelection();if(!P||!d.value)return;const V=P.anchorNode;V&&d.value.contains(V)&&y()},Z=P=>{(P.key==="Escape"||P.key==="Esc")&&n.dialogOpen&&(P.preventDefault(),I())};ce(()=>{e.modelValue&&e.modelValue.length&&(n.segments=JSON.parse(JSON.stringify(e.modelValue))),h(),document.addEventListener("mousedown",H),document.addEventListener("selectionchange",N),document.addEventListener("keydown",Z,!0)}),Te(()=>{document.removeEventListener("mousedown",H),document.removeEventListener("selectionchange",N),document.removeEventListener("keydown",Z,!0)}),oe(()=>e.modelValue,P=>{if(n.ignoreNextWatch){n.ignoreNextWatch=!1;return}P&&(n.segments=JSON.parse(JSON.stringify(P)),h())},{deep:!0});const G={props:e,emit:c,editorRef:d,dialogRef:r,state:n,createUid:p,segmentDisplay:v,getLogicalCursorPosition:g,setLogicalCursorPosition:f,renderContent:h,mergeAdjacentTextSegments:w,readTagSegment:x,handleSegmentClick:k,handleInput:C,checkForAtTrigger:y,openDialog:_,closeDialog:I,positionDialog:U,get searchTimeout(){return L},set searchTimeout(P){L=P},performSearch:j,toSegmentFromResult:F,selectResult:K,handleKeyDown:D,handlePaste:E,onDocumentMouseDown:H,emitUpdate:R,onSelectionChange:N,onDocKeyDown:Z,DropShadow:Re};return Object.defineProperty(G,"__isScriptSetup",{enumerable:!1,value:!0}),G}}),Em={class:"prompt-input-container relative"},Om=["contenteditable","data-placeholder"],jm={class:"bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},Lm={key:0,class:"p-3 text-sm text-gray-500"},Dm={key:1,class:"p-3 text-sm text-gray-500"},Um={key:2,class:"max-h-[220px] overflow-y-auto"},qm=["onClick"],Nm={class:"font-medium flex items-center gap-2"},Bm=["title"],Rm={key:0,class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Fm={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},zm={class:"text-xs mt-1"};function Hm(u,t,a,e,c,d){return s(),l("div",Em,[o("div",{ref:"editorRef","data-testid":"prompt-editor",contenteditable:!a.disabled,onInput:e.handleInput,onKeydown:e.handleKeyDown,onPaste:e.handlePaste,onClick:e.handleSegmentClick,onKeyup:t[0]||(t[0]=r=>{r.key==="Escape"?(r.preventDefault(),e.closeDialog()):(r.key==="ArrowLeft"||r.key==="ArrowRight")&&e.checkForAtTrigger()}),onCompositionstart:t[1]||(t[1]=r=>e.state.isComposing=!0),onCompositionend:t[2]||(t[2]=r=>e.state.isComposing=!1),class:ee(["prompt-input-editor","min-h-[100px] p-3 border-2 rounded-lg","border-black dark:border-white","bg-white dark:bg-black","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",a.disabled?"opacity-50 cursor-not-allowed":""]),"data-placeholder":a.placeholder},[i(" Slot for custom segment rendering - hidden but provides slot content "),fe(o("div",null,[Be(u.$slots,"segment",{segment:null},void 0,!0)],512),[[Ne,!1]])],42,Om),i(" Mention Dialog "),e.state.dialogOpen?(s(),l("div",{key:0,ref:"dialogRef","data-testid":"mention-dialog",class:"absolute z-50",style:lt({left:`${e.state.dialogPosition.x}px`,top:`${e.state.dialogPosition.y}px`})},[S(e.DropShadow,{"offset-x":2,"offset-y":2,intensity:.3},{default:ae(()=>[o("div",jm,[e.state.isSearching?(s(),l("div",Lm,"Searching...")):e.state.searchResults.length===0?(s(),l("div",Dm,"No results found")):(s(),l("div",Um,[(s(!0),l(W,null,ne(e.state.searchResults,(r,n)=>(s(),l("button",{key:r.id||r.value||n,type:"button",onClick:p=>e.selectResult(r),class:ee(["w-full px-3 py-2 text-left text-sm","hover:bg-gray-100 dark:hover:bg-gray-900","focus:bg-gray-100 dark:focus:bg-gray-900 focus:outline-none",e.state.selectedIndex===n?"bg-gray-100 dark:bg-gray-900":""])},[o("div",Nm,[ie(b(r.label||r.id||r.value)+" ",1),r.type==="prompt"&&r.meta&&!r.meta.isValid?(s(),l("span",{key:0,title:r.meta.validationMessage,class:"text-red-500"},"⚠️",8,Bm)):i("v-if",!0)]),r.description?(s(),l("div",Rm,b(r.description),1)):i("v-if",!0),r.type==="prompt"&&r.meta&&!r.meta.isValid?(s(),l("div",Fm,b(r.meta.validationMessage),1)):i("v-if",!0),o("div",zm,[o("span",{class:ee(["inline-block px-1.5 py-0.5 rounded",r.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},b(r.type),3)])],10,qm))),128))]))])]),_:1})],4)):i("v-if",!0)])}const jt=Q(Pm,[["render",Hm],["__scopeId","data-v-5b9dcb11"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PromptInput.vue"]]);function yt(u,t){if(!t||!t.properties||Object.keys(t.properties).length===0)return!0;if(!u||!u.properties)return Object.keys(t.properties);const a=[],e=u.properties||{},c=t.properties||{};return(t.required||[]).forEach(r=>{r in e||a.push(r)}),Object.keys(c).forEach(r=>{!(r in e)&&!a.includes(r)&&a.push(r)}),a.length>0?a:!0}function xt(u){return u.length===0?"":u.length===1?`Missing required field: ${u[0]}`:`Missing required fields: ${u.join(", ")}`}const Wm=$({__name:"PromptTemplate",props:{promptText:{type:String,required:!0},beforeTool:{type:String,required:!0},afterTool:{type:String,required:!0},requiredSchema:{type:String,required:!0},currentPromptName:{type:String,required:!1}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(!1),n=x=>x.type==="text"?{type:"string",value:x.content||""}:x.type==="include"?{type:"prompt",id:x.prompt||"",label:x.prompt||""}:x.type==="string"?{type:"string",value:x.value||""}:x.type==="prompt"?{type:"prompt",id:x.id||"",label:x.label||x.id||""}:x.type==="variable"?{type:"variable",value:x.value||"",label:x.label||x.value||""}:{type:"string",value:""},p=z(()=>{if(!e.promptText)return[{type:"string",value:""}];let x=[];try{const C=JSON.parse(e.promptText);Array.isArray(C)?x=C.map(n):x=[{type:"string",value:e.promptText}]}catch{x=[{type:"string",value:e.promptText}]}const k=e.requiredSchema?JSON.parse(e.requiredSchema):{};return x.map(C=>{if(C.type==="prompt"&&C.schema){const y=yt(k,C.schema),_=y===!0,I=_?[]:y;return{...C,meta:{isValid:_,missingFields:I,validationMessage:_?"":xt(I)}}}return C})}),v=z(()=>{try{const x=JSON.parse(e.requiredSchema);if(x.properties&&typeof x.properties=="object")return Object.keys(x.properties)}catch{return[]}return[]}),g=async x=>{r.value=!0;try{const k=new URLSearchParams;x&&k.set("search",x);const C=await fetch(J(`/api/prompts${k.toString()?"?"+k.toString():""}`));if(C.ok){const y=await C.json();d.value=y.prompts||[]}}catch(k){console.error("Error fetching prompts:",k)}finally{r.value=!1}},f=async x=>{const k=[];return v.value.forEach(C=>{(!x||C.toLowerCase().includes(x.toLowerCase()))&&k.push({type:"variable",value:C,label:C,description:"Schema property"})}),x!==void 0&&await g(x),d.value.forEach(C=>{if(!(e.currentPromptName&&C.name===e.currentPromptName)&&(!x||C.name.toLowerCase().includes(x.toLowerCase()))){const y=e.requiredSchema?JSON.parse(e.requiredSchema):{},_=yt(y,C.required_schema),I=_===!0,U=I?[]:_;k.push({type:"prompt",id:C.name,label:C.name,description:C.tool_description||"Available prompt",schema:C.required_schema,meta:{isValid:I,missingFields:U,validationMessage:I?"":xt(U)}})}}),k},h=x=>{const k=x.map(C=>{const{type:y,value:_,label:I,id:U,schema:L}=C;return y==="string"?{type:y,value:_||""}:y==="variable"?{type:y,value:_||"",label:I}:y==="prompt"?{type:y,id:U||"",label:I,schema:L}:C});c("update:promptText",JSON.stringify(k))};ce(()=>{g()});const w={props:e,emit:c,availablePrompts:d,loadingPrompts:r,normalizeSegment:n,promptSegments:p,schemaProperties:v,fetchPrompts:g,searchReferences:f,handleSegmentsUpdate:h,PromptInput:jt};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),Jm={class:"space-y-4"};function Km(u,t,a,e,c,d){return s(),l("div",Jm,[o("div",null,[t[0]||(t[0]=o("label",{class:"block text-sm font-medium mb-2"},"Prompt Template",-1)),t[1]||(t[1]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-2"}," Type @ to insert schema properties or other prompts ",-1)),S(e.PromptInput,{"model-value":e.promptSegments,"onUpdate:modelValue":e.handleSegmentsUpdate,search:e.searchReferences,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])])])}const Zm=Q(Wm,[["render",Km],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptTemplate.vue"]]),Gm=$({__name:"PromptToolOptions",props:{toolName:{type:String,required:!0},toolConfig:{type:Object,required:!0},disabled:{type:Boolean,required:!1}},emits:["update:option"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(!0),n=z(()=>d.value?.properties?Object.entries(d.value.properties).map(([f,h])=>({value:f,label:f,description:h.description||h.type||""})):[]),p=async()=>{try{const f=await fetch(J(`/api/prompts/${encodeURIComponent(e.toolName)}`));if(f.ok){const h=await f.json();h?.prompt?.required_schema&&(d.value=h.prompt.required_schema)}}catch(f){console.error("Error fetching prompt schema:",f)}finally{r.value=!1}};ce(()=>{p()});const g={props:e,emit:c,schema:d,loading:r,propertyOptions:n,fetchSchema:p,updateOption:(f,h)=>{c("update:option",f,h)},SelectInput:xe,CheckboxInput:Xe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),Xm={class:"space-y-3"},Qm={class:"space-y-2 pl-4 border-l-2 border-blue-200 dark:border-blue-700"},Ym={class:"space-y-1"},$m={class:"space-y-2 pl-4 border-l-2 border-gray-200 dark:border-gray-700"};function e2(u,t,a,e,c,d){return s(),l("div",Xm,[i(" Initialization Options "),o("div",Qm,[t[6]||(t[6]=o("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"}," Initialization Options: ",-1)),o("div",Ym,[t[4]||(t[4]=o("label",{class:"block text-xs font-medium text-gray-700 dark:text-gray-300"}," User message property ",-1)),S(e.SelectInput,{"model-value":a.toolConfig.init_user_message_property||"","onUpdate:modelValue":t[0]||(t[0]=r=>e.updateOption("init_user_message_property",r||null)),placeholder:"Don't inject a user message",options:e.propertyOptions,disabled:a.disabled||e.loading||e.propertyOptions.length===0,loading:e.loading},null,8,["model-value","options","disabled","loading"]),t[5]||(t[5]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected. ",-1))])]),i(" Response Options "),o("div",$m,[t[7]||(t[7]=o("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"}," Sub-Prompt Response Options: ",-1)),S(e.CheckboxInput,{"model-value":a.toolConfig.include_text_response,"onUpdate:modelValue":t[1]||(t[1]=r=>e.updateOption("include_text_response",r)),label:"Include text response","help-text":"Include the final text content from the sub-prompt",disabled:a.disabled},null,8,["model-value","disabled"]),S(e.CheckboxInput,{"model-value":a.toolConfig.include_tool_calls,"onUpdate:modelValue":t[2]||(t[2]=r=>e.updateOption("include_tool_calls",r)),label:"Include tool calls and responses","help-text":"Include tool calls executed by the sub-prompt and their responses",disabled:a.disabled},null,8,["model-value","disabled"]),S(e.CheckboxInput,{"model-value":a.toolConfig.include_errors,"onUpdate:modelValue":t[3]||(t[3]=r=>e.updateOption("include_errors",r)),label:"Include errors","help-text":"Include error information if the sub-prompt fails",disabled:a.disabled},null,8,["model-value","disabled"])])])}const t2=Q(Gm,[["render",e2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PromptToolOptions.vue"]]);async function Ie(u,t={}){const a=localStorage.getItem("auth_token"),e={"Content-Type":"application/json",...t.headers};a&&(e.Authorization=`Bearer ${a}`);const c=u.startsWith("/")?u:`/${u}`,d=await fetch(J(`/api${c}`),{...t,headers:e});if(d.status===401)throw localStorage.removeItem("auth_token"),window.location.href=J("/login"),new Error("Unauthorized");return d}const o2=$({__name:"ToolSelectorWithOptions",props:Se({label:{type:String,required:!1,default:"Available Tools"},placeholder:{type:String,required:!1,default:"Select a tool"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=m();Mt(async()=>{r.value,await pe(),r.value&&e.value.length>0&&await It({parent:r,values:e,dragHandle:".drag-handle"})});const n=z(()=>{const x=new Set(e.value.map(k=>k.name));return c.value.filter(k=>!x.has(k.name)).map(k=>{let C=k.name;return k.type==="prompt"?C=`${k.name} (prompt)`:k.type==="mcp"&&(C=`${k.name} (mcp)`),{value:k.name,label:C,description:k.description}})}),p=async()=>{d.value=!0;try{const x=await Ie("/tools");if(x.ok){const k=await x.json();c.value=Object.entries(k).map(([C,y])=>({name:C,description:y.description||"",type:y.type,model:y.model}))}}catch(x){console.error("Error fetching tools:",x)}finally{d.value=!1}},v=x=>{x&&(e.value.find(k=>k.name===x)||(e.value=[...e.value,{name:x,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}]))},g=x=>{e.value=e.value.filter(k=>k.name!==x)},f=x=>c.value.find(k=>k.name===x),h=(x,k,C)=>{e.value=e.value.map(y=>y.name===x?{...y,[k]:C}:y)};ce(()=>{p()});const w={props:a,modelValue:e,tools:c,loadingTools:d,dragAreaRef:r,toolOptions:n,fetchTools:p,handleSelect:v,removeTool:g,getToolInfo:f,updateToolOption:h,SelectInput:xe,PromptToolOptions:t2};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),r2={class:"space-y-4"},a2={class:"block text-sm font-medium mb-2"},s2={key:0,class:"text-red-500"},l2={key:0,class:"space-y-3 mb-4",ref:"dragAreaRef"},n2={class:"flex items-start justify-between"},i2={class:"flex items-center gap-2 flex-1"},d2={class:"flex-1"},c2={class:"font-medium text-sm"},u2={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mt-1"},p2=["onClick","disabled","aria-label"],m2={key:1,class:"text-xs text-red-500 dark:text-red-400 mt-1"},g2={key:0,class:"text-center py-8 text-sm text-gray-500 dark:text-gray-400 border border-dashed border-gray-300 dark:border-gray-600 rounded-lg"};function f2(u,t,a,e,c,d){return s(),l("div",r2,[o("div",null,[o("label",a2,[ie(b(a.label)+" ",1),a.required?(s(),l("span",s2,"*")):i("v-if",!0)]),i(" Selected tools list (above dropdown) "),e.modelValue.length>0?(s(),l("div",l2,[(s(!0),l(W,null,ne(e.modelValue,r=>(s(),l("div",{key:r.name,class:"border border-gray-300 dark:border-gray-600 rounded-lg p-4"},[o("div",n2,[o("div",i2,[i(" Drag handle "),t[0]||(t[0]=o("div",{class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),o("div",d2,[o("h4",c2,b(r.name),1),e.getToolInfo(r.name)?.description?(s(),l("p",u2,b(e.getToolInfo(r.name)?.description),1)):i("v-if",!0)])]),o("button",{onClick:n=>e.removeTool(r.name),type:"button",disabled:a.disabled,class:"p-1 hover:bg-gray-200 dark:hover:bg-gray-800 rounded transition-colors text-gray-500 hover:text-red-500","aria-label":`Remove ${r.name}`},[...t[1]||(t[1]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,p2)]),i(" Prompt tool options (fetches schema on mount) "),e.getToolInfo(r.name)?.type==="prompt"?(s(),X(e.PromptToolOptions,{key:0,"tool-name":r.name,"tool-config":r,disabled:a.disabled,"onUpdate:option":(n,p)=>e.updateToolOption(r.name,n,p)},null,8,["tool-name","tool-config","disabled","onUpdate:option"])):i("v-if",!0)]))),128))],512)):i("v-if",!0),i(" Tool selector dropdown "),S(e.SelectInput,{"model-value":"","onUpdate:modelValue":e.handleSelect,placeholder:e.modelValue.length>0?"Add another tool...":a.placeholder,"search-placeholder":"Search tools...",options:e.toolOptions,disabled:a.disabled||e.loadingTools||e.toolOptions.length===0,loading:e.loadingTools},null,8,["placeholder","options","disabled","loading"]),a.error?(s(),l("p",m2,b(a.error),1)):i("v-if",!0)]),i(" Empty state (only when no tools are available at all) "),e.modelValue.length===0&&!e.loadingTools&&e.toolOptions.length===0?(s(),l("div",g2," No tools available. Create tools in your agentbuilder/tools directory. ")):i("v-if",!0)])}const h2=Q(o2,[["render",f2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/ToolSelectorWithOptions.vue"]]),v2=$({__name:"MultipleSelectionsInput",props:Se({label:{type:String,required:!1},placeholder:{type:String,required:!1,default:"Select an option"},searchPlaceholder:{type:String,required:!1,default:"Search..."},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},options:{type:Array,required:!0},addLabel:{type:String,required:!1,default:"Add another"},loading:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:Se(["removeItem"],["update:modelValue"]),setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Ee(u,"modelValue"),r=m();Mt(async()=>{r.value,await pe(),await It({parent:r,values:d,dragHandle:".drag-handle"})});const n=z(()=>Array.isArray(d.value)?d.value.length>0&&typeof d.value[0]=="object"?d.value:d.value.map(h=>{const w=e.options.find(x=>x.value===h);return{id:h,label:w?.label||h,description:w?.description,icon:w?.icon}}):[]),p=z(()=>{const h=n.value.map(w=>w.id);return e.options.filter(w=>!h.includes(w.value))}),f={props:e,emit:c,modelValue:d,dragAreaRef:r,selectedItems:n,availableOptions:p,handleSelect:h=>{if(!h)return;const w=e.options.find(x=>x.value===h);if(w)if(d.value.length===0||typeof d.value[0]=="string")d.value=[...d.value,h];else{const x={id:h,label:w.label,description:w.description,icon:w.icon};d.value=[...d.value,x]}},removeItem:h=>{typeof d.value[0]=="string"?d.value=d.value.filter(w=>w!==h):d.value=d.value.filter(w=>w.id!==h),c("removeItem",h)},SelectInput:xe};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),b2={class:"space-y-2"},y2={key:0,class:"space-y-2"},x2={key:0,class:"block text-sm font-medium"},k2={key:0,class:"text-red-500"},_2={class:"space-y-1",ref:"dragAreaRef"},w2=["src","alt"],C2={class:"flex-1 text-sm"},S2={key:0,class:"text-xs text-gray-500 dark:text-gray-400 ml-1"},T2=["onClick","aria-label"],M2={key:1,class:"text-xs text-red-500 dark:text-red-400"};function I2(u,t,a,e,c,d){return s(),l("div",b2,[e.selectedItems.length>0?(s(),l("div",y2,[a.label?(s(),l("label",x2,[ie(b(a.label)+" ",1),a.required?(s(),l("span",k2,"*")):i("v-if",!0)])):i("v-if",!0),o("div",_2,[(s(!0),l(W,null,ne(e.selectedItems,r=>(s(),l("div",{key:r.id,class:ee(["flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-900 rounded border","border-gray-200 dark:border-gray-800",a.disabled?"opacity-50":""])},[i(" Drag handle "),t[1]||(t[1]=o("div",{class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),i(" Icon "),r.icon?(s(),l("img",{key:0,src:r.icon,alt:r.label,class:"w-4 h-4 flex-shrink-0"},null,8,w2)):i("v-if",!0),i(" Label and description "),o("span",C2,[ie(b(r.label)+" ",1),r.description?(s(),l("span",S2," ("+b(r.description)+") ",1)):i("v-if",!0)]),i(" Remove button "),a.disabled?i("v-if",!0):(s(),l("button",{key:1,onClick:n=>e.removeItem(r.id),type:"button",class:"p-1 hover:bg-gray-200 dark:hover:bg-gray-800 rounded transition-colors","aria-label":`Remove ${r.label}`},[...t[0]||(t[0]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,T2))],2))),128))],512)])):i("v-if",!0),i(" Select input for adding new items "),S(e.SelectInput,{"model-value":"","onUpdate:modelValue":e.handleSelect,label:e.selectedItems.length>0?a.addLabel:a.label,options:e.availableOptions,placeholder:a.placeholder,"search-placeholder":a.searchPlaceholder,disabled:a.disabled||e.availableOptions.length===0,loading:a.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),a.error?(s(),l("p",M2,b(a.error),1)):i("v-if",!0)])}const ct=Q(v2,[["render",I2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/MultipleSelectionsInput.vue"]]),V2=$({__name:"AgentSelectorInput",props:Se({label:{type:String,required:!1,default:"Handoff Agents"},placeholder:{type:String,required:!1,default:"Select an agent"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},allowMultiple:{type:Boolean,required:!1,default:!0},agentType:{type:String,required:!1,default:"ai_human"}},{modelValue:{type:[String,Array],required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=z(()=>c.value.map(g=>({value:g.id,label:g.title,description:g.tool_description||`Handoff to ${g.title} agent`}))),n=async()=>{d.value=!0;try{const g=J(`/api/agents${a.agentType?`?type=${a.agentType}`:""}`),f=await fetch(g);if(f.ok){const h=await f.json();c.value=h.agents||[]}}catch(g){console.error("Error fetching agents:",g)}finally{d.value=!1}},p=g=>{};ce(()=>{n()}),oe(()=>a.allowMultiple,()=>{a.allowMultiple&&typeof e.value=="string"?e.value=e.value?[e.value]:[]:!a.allowMultiple&&Array.isArray(e.value)&&(e.value=e.value[0]||"")},{immediate:!0});const v={props:a,modelValue:e,agents:c,loadingAgents:d,agentOptions:r,fetchAgents:n,handleRemoveItem:p,SelectInput:xe,MultipleSelectionsInput:ct};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),A2={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function P2(u,t,a,e,c,d){return s(),l(W,null,[a.allowMultiple?(s(),X(e.MultipleSelectionsInput,{key:0,modelValue:e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search agents...",error:a.error,required:a.required,disabled:a.disabled,options:e.agentOptions,loading:e.loadingAgents,"add-label":"Add another agent",onRemoveItem:e.handleRemoveItem},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(s(),X(e.SelectInput,{key:1,modelValue:e.modelValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search agents...",options:e.agentOptions,disabled:a.disabled,loading:e.loadingAgents},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!a.allowMultiple&&a.error?(s(),l("p",A2,b(a.error),1)):i("v-if",!0)],64)}const E2=Q(V2,[["render",P2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/AgentSelectorInput.vue"]]),O2=$({__name:"PromptModal",props:{modelValue:{type:Boolean,required:!0},editPrompt:{type:null,required:!1},mode:{type:String,required:!1}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>e.mode==="edit"),r=m(!1),n=z(()=>_.value.length===1),p=m(""),v=m(""),g=m(""),f=m(""),h=m({type:"object",properties:{},required:[],additionalProperties:!1}),w=m(""),x=m(!1),k=m(!1),C=m(""),y=m(""),_=m([]),I=m([]),U=m(!1),L=m("auto"),j=m(null),F=m(null),K=m(!1),D=m(!1),E=z({get:()=>j.value||"",set:V=>j.value=V||null}),H=z({get:()=>L.value,set:V=>L.value=V}),R=()=>{v.value="",p.value="",g.value="",f.value="",h.value={type:"object",properties:{},required:[],additionalProperties:!1},w.value="",x.value=!1,k.value=!1,C.value="",y.value="",_.value=[],I.value=[],U.value=!1,L.value="auto",j.value=null,F.value=null,K.value=!1,D.value=!1},N=async()=>{if(e.editPrompt?.id){r.value=!0;try{const V=await Ie(`/prompts/${e.editPrompt.id}`);if(V.ok){const T=await V.json(),q=T.prompt||T;v.value=q.name||"",p.value=q.name||"",g.value=q.tool_description||"",f.value=q.model_id||"";let M=q.required_schema;if(typeof M=="string")try{M=JSON.parse(M)}catch{M=null}h.value=M||{type:"object",properties:{},required:[],additionalProperties:!1},w.value=q.prompt||"",x.value=q.include_chat||!1,k.value=q.include_past_tools||!1,C.value=q.before_tool||"",y.value=q.after_tool||"";const O=q.tools||[];_.value=O.map(B=>typeof B=="string"?{name:B,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:B),I.value=q.prompts||q.handoff_agents||[],U.value=q.parallel_tool_calls||!1,L.value=q.tool_choice||"auto";const A=q.reasoning||{};j.value=A.effort||q.reasoning_effort||null,F.value=A.maxTokens||q.reasoning_max_tokens||null,K.value=A.exclude||q.reasoning_exclude||!1,D.value=q.include_reasoning||!1}}catch(V){console.error("Error loading prompt data:",V)}finally{r.value=!1}}},Z=async()=>{const V=/^[a-z][a-z0-9_]*$/;if(!v.value||!V.test(v.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!g.value){alert("Please enter a description");return}if(!f.value){alert("Please select a model");return}if(!w.value){alert("Please enter the prompt template");return}const T={name:v.value,tool_description:g.value,prompt:w.value,required_schema:h.value,model_id:f.value,include_chat:x.value,include_past_tools:k.value,before_tool:C.value||null,after_tool:y.value||null,parallel_tool_calls:U.value,tool_choice:L.value,tools:_.value,handoff_agents:I.value,reasoning_effort:j.value,reasoning_max_tokens:F.value,reasoning_exclude:K.value,include_reasoning:D.value};d.value&&e.editPrompt?.id&&(T.id=e.editPrompt.id,p.value&&p.value!==v.value&&(T.originalName=p.value)),c("save",T),R(),c("update:modelValue",!1)},G=()=>{R(),c("update:modelValue",!1)};oe(()=>_.value.length,V=>{L.value==="function"&&V!==1&&(L.value="auto")}),oe(()=>e.modelValue,async V=>{V&&(d.value?(R(),await pe(),await N()):R())}),oe(()=>e.editPrompt,async V=>{V&&d.value&&e.modelValue&&(await pe(),await N())},{immediate:!0});const P={props:e,emit:c,isEditMode:d,isLoading:r,isFunctionChoiceAvailable:n,originalName:p,name:v,toolDescription:g,selectedModel:f,requiredSchema:h,promptText:w,includeChat:x,includePastTools:k,beforeTool:C,afterTool:y,selectedTools:_,handoffAgents:I,parallelToolCalls:U,toolChoice:L,reasoningEffort:j,reasoningMaxTokens:F,reasoningExclude:K,includeReasoning:D,reasoningEffortValue:E,toolChoiceValue:H,resetForm:R,loadPromptData:N,handleSubmit:Z,handleCancel:G,Modal:Ve,PromptBasicInfo:vp,PromptModelSelect:Up,JSONSchemaInput:Ot,PromptTemplate:Zm,CheckboxInput:Xe,ToolSelectorWithOptions:h2,AgentSelectorInput:E2,SelectInput:xe};return Object.defineProperty(P,"__isScriptSetup",{enumerable:!1,value:!0}),P}}),j2={key:0,class:"min-h-[400px] flex items-center justify-center"},L2={class:"space-y-6 pr-2 pb-4"},D2={class:"space-y-4"},U2={class:"space-y-4"},q2={class:"flex justify-between"},N2={class:"flex gap-2"},B2=["disabled"];function R2(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[17]||(t[17]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Prompt":"Add Prompt",width:"max-w-4xl"},{footer:ae(()=>[o("div",q2,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("div",N2,[o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:e.isLoading},b(e.isEditMode?"Update Prompt":"Create Prompt"),9,B2)])])]),default:ae(()=>[e.isLoading?(s(),l("div",j2,[...t[18]||(t[18]=[o("span",{class:"text-gray-500"},"Loading prompt data...",-1)])])):(s(),l(W,{key:1},[i(" Single long form for both edit and add modes "),o("div",L2,[o("div",null,[S(e.PromptBasicInfo,{name:e.name,"onUpdate:name":t[0]||(t[0]=r=>e.name=r),"tool-description":e.toolDescription,"onUpdate:toolDescription":t[1]||(t[1]=r=>e.toolDescription=r)},null,8,["name","tool-description"])]),o("div",null,[S(e.PromptModelSelect,{modelValue:e.selectedModel,"onUpdate:modelValue":t[2]||(t[2]=r=>e.selectedModel=r)},null,8,["modelValue"])]),o("div",null,[S(e.JSONSchemaInput,{modelValue:e.requiredSchema,"onUpdate:modelValue":t[3]||(t[3]=r=>e.requiredSchema=r),label:"Required Schema (Optional)"},null,8,["modelValue"])]),o("div",null,[S(e.PromptTemplate,{"prompt-text":e.promptText,"onUpdate:promptText":t[4]||(t[4]=r=>e.promptText=r),"before-tool":e.beforeTool,"onUpdate:beforeTool":t[5]||(t[5]=r=>e.beforeTool=r),"after-tool":e.afterTool,"onUpdate:afterTool":t[6]||(t[6]=r=>e.afterTool=r),"required-schema":JSON.stringify(e.requiredSchema,null,2),"current-prompt-name":e.isEditMode?e.name:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),o("div",null,[S(e.ToolSelectorWithOptions,{modelValue:e.selectedTools,"onUpdate:modelValue":t[7]||(t[7]=r=>e.selectedTools=r)},null,8,["modelValue"])]),o("div",D2,[t[20]||(t[20]=o("h3",{class:"text-sm font-medium text-gray-900 dark:text-gray-100"}," Tool Configuration ",-1)),i(" Parallel Tool Calls "),o("div",null,[S(e.CheckboxInput,{modelValue:e.parallelToolCalls,"onUpdate:modelValue":t[8]||(t[8]=r=>e.parallelToolCalls=r),label:"Allow parallel tool calls","help-text":"Allow the model to call multiple tools simultaneously in a single turn"},null,8,["modelValue"])]),i(" Tool Choice "),o("div",null,[S(e.SelectInput,{modelValue:e.toolChoiceValue,"onUpdate:modelValue":t[9]||(t[9]=r=>e.toolChoiceValue=r),label:"Tool Choice",options:[{value:"auto",label:"Auto",description:"Model decides"},{value:"none",label:"None",description:"No tools allowed"},{value:"required",label:"Required",description:"Must call a tool"},{value:"function",label:"Function",description:e.isFunctionChoiceAvailable?"Call specific tool":"Requires exactly 1 tool"}].filter(r=>r.value!=="function"||e.isFunctionChoiceAvailable),placeholder:"Select tool choice"},null,8,["modelValue","options"]),t[19]||(t[19]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Controls whether and how the model can call tools ",-1))])]),o("div",null,[S(e.AgentSelectorInput,{modelValue:e.handoffAgents,"onUpdate:modelValue":t[10]||(t[10]=r=>e.handoffAgents=r),"allow-multiple":!0,label:"Handoff Agents (Optional)",placeholder:"Select AI + Human agents to hand off to","agent-type":"ai_human"},null,8,["modelValue"]),t[21]||(t[21]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," AI + Human agents that this prompt can hand off conversations to. These will be exposed as tools. ",-1))]),i(" Reasoning Tokens Configuration "),o("div",U2,[t[25]||(t[25]=o("h3",{class:"text-sm font-medium text-gray-900 dark:text-gray-100"}," Context & Reasoning Configuration ",-1)),i(" Include Chat History "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includeChat,"onUpdate:modelValue":t[11]||(t[11]=r=>e.includeChat=r),label:"Include chat history","help-text":"Expose chat history to the LLM when this prompt is used as a full prompt (not a partial in another prompt)"},null,8,["modelValue"])]),i(" Include Past Tool Calls "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includePastTools,"onUpdate:modelValue":t[12]||(t[12]=r=>e.includePastTools=r),label:"Include past tool calls","help-text":"Include prior tool call history in this prompt. Uncheck to remove past tool calls"},null,8,["modelValue"])]),i(" Include Reasoning in Message History "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includeReasoning,"onUpdate:modelValue":t[13]||(t[13]=r=>e.includeReasoning=r),label:"Include reasoning in message history","help-text":"When loading message history, include reasoning_details from previous responses. Required for multi-turn reasoning continuity."},null,8,["modelValue"])]),t[26]||(t[26]=o("hr",{class:"border-gray-300 dark:border-gray-600"},null,-1)),t[27]||(t[27]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),i(" Reasoning Effort "),o("div",null,[S(e.SelectInput,{modelValue:e.reasoningEffortValue,"onUpdate:modelValue":t[14]||(t[14]=r=>e.reasoningEffortValue=r),label:"Reasoning Effort",options:[{value:"",label:"None",description:"Disabled"},{value:"low",label:"Low",description:"~20% of max_tokens"},{value:"medium",label:"Medium",description:"~50% of max_tokens"},{value:"high",label:"High",description:"~80% of max_tokens"}],placeholder:"Select reasoning effort"},null,8,["modelValue"]),t[22]||(t[22]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Controls reasoning capacity allocation. Supported by OpenAI o-series and Grok models. ",-1))]),i(" Max Reasoning Tokens "),o("div",null,[t[23]||(t[23]=o("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Max Reasoning Tokens ",-1)),fe(o("input",{"onUpdate:modelValue":t[15]||(t[15]=r=>e.reasoningMaxTokens=r),type:"number",min:"1024",max:"32000",step:"1024",placeholder:"Leave empty to disable or use effort level",class:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent"},null,512),[[_e,e.reasoningMaxTokens,void 0,{number:!0}]]),t[24]||(t[24]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Directly specify reasoning token limit (1024-32000). Supported by Anthropic, Gemini Thinking, and some Qwen models. ",-1))]),i(" Exclude Reasoning from Response "),o("div",null,[S(e.CheckboxInput,{modelValue:e.reasoningExclude,"onUpdate:modelValue":t[16]||(t[16]=r=>e.reasoningExclude=r),label:"Exclude reasoning from response","help-text":"Use reasoning internally but don't return it in the response (saves tokens and cost)"},null,8,["modelValue"])])])])],2112))]),_:1},8,["model-value","title"])}const Lt=Q(O2,[["render",R2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/PromptModal.vue"]]),F2=$({__name:"PromptsView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!1),d=m(null);oe(()=>e.query.refresh,()=>{e.query.refresh&&(d.value?.refresh(),a.replace({path:"/prompts",query:{}}))});const v={router:a,route:e,showModal:c,dataTableRef:d,handleAdd:()=>{c.value=!0},handleEdit:g=>{a.push(`/prompts/${g.id}`)},handleSave:async g=>{try{const f=await fetch(J("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(f.ok)c.value=!1,await new Promise(h=>setTimeout(h,100)),await d.value?.refresh();else{const h=await f.json();alert(h.error||"Failed to create prompt")}}catch(f){console.error("Error creating prompt:",f),alert("Failed to create prompt")}},PromptsDataTable:dp,PromptModal:Lt};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),z2={class:"p-8"};function H2(u,t,a,e,c,d){return s(),l("div",z2,[o("div",{class:"flex justify-between items-center mb-6"},[t[1]||(t[1]=o("h1",{class:"text-3xl font-bold"},"Prompts",-1)),o("button",{onClick:e.handleAdd,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Prompt ")]),t[2]||(t[2]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"},"Define and manage prompt templates for your agents.",-1)),S(e.PromptsDataTable,{ref:"dataTableRef",onAdd:e.handleAdd,onEdit:e.handleEdit},null,512),S(e.PromptModal,{modelValue:e.showModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showModal=r),mode:"add",onSave:e.handleSave},null,8,["modelValue"])])}const W2=Q(F2,[["render",H2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/PromptsView.vue"]]),J2=$({__name:"PromptEditView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!0),d=m(null),r=m(!0),n=async()=>{const f=e.params.id;if(!f){a.push("/prompts");return}r.value=!0;try{const h=await fetch(J(`/api/prompts/${f}`));if(h.ok){const w=await h.json();d.value=w.prompt||w}else alert("Prompt not found"),a.push("/prompts")}catch(h){console.error("Error loading prompt:",h),alert("Failed to load prompt"),a.push("/prompts")}finally{r.value=!1}},p=async f=>{try{const{originalName:h,...w}=f,x=h||w.id,k=await fetch(J(`/api/prompts/${x}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(k.ok)a.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const C=await k.json();alert(C.error||"Failed to update prompt")}}catch(h){console.error("Error updating prompt:",h),alert("Failed to update prompt")}},v=f=>{f||a.push("/prompts")};ce(()=>{n()}),oe(c,f=>{f||a.push("/prompts")});const g={router:a,route:e,showModal:c,editingPrompt:d,isLoading:r,loadPrompt:n,handleSave:p,handleClose:v,PromptModal:Lt};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),K2={class:"p-8"},Z2={key:0,class:"flex items-center justify-center min-h-[400px]"},G2={key:2,class:"flex items-center justify-center min-h-[400px]"};function X2(u,t,a,e,c,d){return s(),l("div",K2,[e.isLoading?(s(),l("div",Z2,[...t[1]||(t[1]=[o("span",{class:"text-gray-500"},"Loading prompt...",-1)])])):e.editingPrompt?(s(),X(e.PromptModal,{key:1,modelValue:e.showModal,"onUpdate:modelValue":[t[0]||(t[0]=r=>e.showModal=r),e.handleClose],mode:"edit","edit-prompt":e.editingPrompt,onSave:e.handleSave},null,8,["modelValue","edit-prompt"])):(s(),l("div",G2,[...t[2]||(t[2]=[o("span",{class:"text-gray-500"},"Prompt not found",-1)])]))])}const Q2=Q(J2,[["render",X2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/PromptEditView.vue"]]),Y2=$({__name:"ExposedSelectList",props:{providers:{type:Array,required:!0,default:()=>[]},modelValue:{type:Array,required:!0,default:()=>[]},label:{type:String,required:!1},loading:{type:Boolean,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();function e(w){if(w===0)return"$0.00";const x=Math.abs(w);let k;return x<1e-4?k=x.toExponential(3):x<.001||x<.01||x<.1?k=x.toFixed(4):x<1?k=x.toFixed(3):x<10||x<100?k=x.toFixed(2):x<1e3?k=x.toFixed(1):k=x.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),k.includes(".")&&(k=k.replace(/\.?0+$/,""),!k.includes(".")&&x<100&&(k=x.toFixed(2))),w<0?`-$${k}`:`$${k}`}const c=u,d=a,r=w=>c.modelValue.includes(w),n=w=>{const x=[...c.modelValue],k=x.indexOf(w);k>-1?x.splice(k,1):x.push(w),d("update:modelValue",x)},p=()=>{d("update:modelValue",c.providers.map(w=>w.id))},v=()=>{d("update:modelValue",[])},g=z(()=>c.providers.length>0&&c.modelValue.length===c.providers.length),f=z(()=>c.modelValue.length>0&&c.modelValue.length<c.providers.length),h={dollars:e,props:c,emit:d,isSelected:r,toggleProvider:n,selectAll:p,deselectAll:v,allSelected:g,someSelected:f};return Object.defineProperty(h,"__isScriptSetup",{enumerable:!1,value:!0}),h}}),$2={class:"border-2 border-black dark:border-white rounded-lg overflow-hidden"},eg={key:0,class:"px-4 py-2 border-b-2 border-black dark:border-white bg-gray-50 dark:bg-gray-900"},tg={class:"flex items-center justify-between"},og={class:"text-sm font-medium"},rg={class:"flex items-center gap-2"},ag={key:1,class:"px-4 py-8 flex items-center justify-center"},sg={key:2,class:"px-4 py-8 text-center text-gray-500"},lg={key:3,class:"divide-y divide-gray-200 dark:divide-gray-700"},ng=["onClick"],ig={class:"flex items-start gap-3"},dg={class:"flex-shrink-0 mt-0.5"},cg=["checked","onClick"],ug={class:"flex-1 min-w-0"},pg={class:"flex items-center gap-2"},mg={class:"text-sm font-medium"},gg={key:0,class:"text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},fg={class:"mt-1 text-xs text-gray-600 dark:text-gray-400 space-y-0.5"},hg={key:0},vg={key:0},bg={key:1},yg={key:2};function xg(u,t,a,e,c,d){return s(),l("div",$2,[a.label?(s(),l("div",eg,[o("div",tg,[o("span",og,b(a.label),1),o("div",rg,[o("button",{type:"button",onClick:t[0]||(t[0]=r=>e.allSelected?e.deselectAll():e.selectAll()),class:"text-xs px-2 py-1 border border-gray-400 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-800"},b(e.allSelected?"Deselect All":"Select All"),1)])])])):i("v-if",!0),a.loading?(s(),l("div",ag,[...t[1]||(t[1]=[o("div",{class:"flex items-center gap-2 text-gray-500"},[o("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),o("span",null,"Loading providers...")],-1)])])):a.providers.length===0?(s(),l("div",sg," No providers available ")):(s(),l("div",lg,[(s(!0),l(W,null,ne(a.providers,r=>(s(),l("div",{key:r.id,class:"px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-900 cursor-pointer",onClick:n=>e.toggleProvider(r.id)},[o("div",ig,[o("div",dg,[o("input",{type:"checkbox",checked:e.isSelected(r.id),onClick:he(n=>e.toggleProvider(r.id),["stop"]),class:"w-4 h-4 border-2 border-black dark:border-white rounded focus:ring-2 focus:ring-black dark:focus:ring-white"},null,8,cg)]),o("div",ug,[o("div",pg,[o("span",mg,b(r.name),1),r.quantization?(s(),l("span",gg,b(r.quantization),1)):i("v-if",!0)]),o("div",fg,[o("div",null,b(e.dollars(r.pricing.prompt*1e6))+"/M input • "+b(e.dollars(r.pricing.completion*1e6))+"/M output ",1),r.maxPromptTokens||r.maxCompletionTokens?(s(),l("div",hg,[r.maxPromptTokens?(s(),l("span",vg," Max prompt: "+b(r.maxPromptTokens.toLocaleString())+" tokens ",1)):i("v-if",!0),r.maxPromptTokens&&r.maxCompletionTokens?(s(),l("span",bg," • ")):i("v-if",!0),r.maxCompletionTokens?(s(),l("span",yg," Max completion: "+b(r.maxCompletionTokens.toLocaleString())+" tokens ",1)):i("v-if",!0)])):i("v-if",!0)])])])],8,ng))),128))]))])}const kg=Q(Y2,[["render",xg],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ExposedSelectList.vue"]]),_g=$({__name:"ModelSelectorInput",props:Se({label:{type:String,required:!1},placeholder:{type:String,required:!1,default:"Select a model"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},allowMultiple:{type:Boolean,required:!1,default:!1}},{modelValue:{type:[String,Array],required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=z(()=>c.value.map(g=>({value:g.id,label:g.name,description:g.provider_id||g.provider,icon:dt(g.model||g.name,g.provider_id||g.provider)}))),n=async()=>{d.value=!0;try{const g=await fetch(J("/api/models"));if(g.ok){const f=await g.json();c.value=f.models||[]}}catch(g){console.error("Error fetching models:",g)}finally{d.value=!1}},p=g=>{};ce(()=>{n()}),oe(()=>a.allowMultiple,()=>{a.allowMultiple&&typeof e.value=="string"?e.value=e.value?[e.value]:[]:!a.allowMultiple&&Array.isArray(e.value)&&(e.value=e.value[0]||"")});const v={props:a,modelValue:e,models:c,loadingModels:d,modelOptions:r,fetchModels:n,handleRemoveItem:p,SelectInput:xe,MultipleSelectionsInput:ct};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),wg={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function Cg(u,t,a,e,c,d){return s(),l(W,null,[a.allowMultiple?(s(),X(e.MultipleSelectionsInput,{key:0,modelValue:e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search models...",error:a.error,required:a.required,disabled:a.disabled,options:e.modelOptions,loading:e.loadingModels,"add-label":"Add another model",onRemoveItem:e.handleRemoveItem},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(s(),X(e.SelectInput,{key:1,modelValue:e.modelValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search models...",options:e.modelOptions,disabled:a.disabled,loading:e.loadingModels},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!a.allowMultiple&&a.error?(s(),l("p",wg,b(a.error),1)):i("v-if",!0)],64)}const Sg=Q(_g,[["render",Cg],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/ModelSelectorInput.vue"]]),Tg=$({__name:"ModelModal",props:{modelValue:{type:Boolean,required:!0},editModel:{type:null,required:!1},mode:{type:String,required:!1,default:"add"}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(""),n=m(""),p=m([]),v=m(!1),g=m(!1),f=m([]),h=m([]),w=m(!1),x=m([]),k=z(()=>e.mode==="edit"),C=m(""),y=m(""),_=m(""),I=M=>{let O=M.replace(/[^a-zA-Z0-9\s_-]/g,"");return O=O.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),O?/^[a-z][a-z0-9_]*$/.test(O)?_.value="":_.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":_.value="Name is required",O},U=M=>{const O=M.target.value;y.value=I(O)},L=m(!1),j=m(null),F=z(()=>d.value.filter(M=>M.hasApiKey).map(M=>({value:M.name,label:M.name,description:M.sdk==="openai-sdk"?"OpenAI SDK":M.sdk==="openrouter"?"OpenRouter":M.sdk,icon:Ke(M.sdk)}))),K=z(()=>p.value.map(M=>({...M,icon:M.iconId?Ke(M.iconId):void 0}))),D=z(()=>!k.value||!j.value||L.value?!1:y.value!==j.value.name||r.value!==j.value.provider||n.value!==j.value.model||JSON.stringify(h.value.sort())!==JSON.stringify(j.value.endpoints.sort())||JSON.stringify(x.value)!==JSON.stringify(j.value.fallbacks)),E=z(()=>d.value.find(O=>O.name===r.value)?.sdk==="openrouter"),H=async()=>{v.value=!0;try{const M=await fetch(J("/api/providers"));if(M.ok){const O=await M.json();d.value=O.providers||[]}}catch(M){console.error("Error fetching providers:",M)}finally{v.value=!1}},R=async()=>{if(!r.value){p.value=[];return}g.value=!0;try{const M=await fetch(J("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.value})});if(M.ok){const O=await M.json();p.value=O.models||[]}else{const O=await M.json();console.error("Error fetching models:",O),p.value=[],alert(O.error||"Failed to fetch available models")}}catch(M){console.error("Error fetching models:",M),p.value=[]}finally{g.value=!1}},N=()=>{y.value="",C.value="",r.value="",n.value="",p.value=[],x.value=[],f.value=[],h.value=[],j.value=null,L.value=!1},Z=async()=>{if(e.editModel){L.value=!0;try{await H(),y.value=e.editModel.name||"",C.value=e.editModel.name||"",r.value=e.editModel.provider_id||e.editModel.provider,await R(),n.value=e.editModel.model,await P(),e.editModel.included_providers&&e.editModel.included_providers.length>0&&(h.value=e.editModel.included_providers),await G(),j.value={name:y.value,provider:r.value,model:n.value,endpoints:[...h.value],fallbacks:[...x.value]}}finally{L.value=!1}}};oe(()=>e.modelValue,async M=>{M?k.value&&e.editModel?await Z():(await H(),N()):N()});const G=async()=>{if(e.editModel?.id){if(e.editModel.fallbacks&&Array.isArray(e.editModel.fallbacks)){x.value=e.editModel.fallbacks.map(M=>typeof M=="string"?M:M.id);return}try{const M=await fetch(J(`/api/models/${e.editModel.id}/fallbacks`));if(M.ok){const O=await M.json();x.value=O.fallbacks.map(A=>A.fallback_model_id)}}catch(M){console.error("Error loading fallbacks:",M)}}};oe(r,async(M,O)=>{L.value||k.value&&!O&&M===(e.editModel?.provider_id||e.editModel?.provider)||(n.value="",f.value=[],h.value=[],r.value&&await R())});const P=async()=>{if(!n.value||!r.value){f.value=[];return}const M=d.value.find(A=>A.name===r.value);if(!M||M.sdk!=="openrouter"){f.value=[];return}const O=K.value.find(A=>A.value===n.value);if(!O?.slug){console.error("Model slug not found"),f.value=[];return}w.value=!0;try{const A=await fetch(J("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.value,modelSlug:O.slug})});if(A.ok){const B=await A.json();f.value=B.endpoints||[],k.value||(h.value=f.value.map(te=>te.id))}else{const B=await A.json();console.error("Error fetching endpoints:",B),f.value=[]}}catch(A){console.error("Error fetching endpoints:",A),f.value=[]}finally{w.value=!1}};oe(n,async(M,O)=>{L.value||k.value&&!O&&M===e.editModel?.model||(n.value?(await P(),O&&M!==O&&(h.value=f.value.map(A=>A.id))):(f.value=[],h.value=[]))});const q={props:e,emit:c,providers:d,selectedProvider:r,selectedModel:n,availableModels:p,loadingProviders:v,loadingModels:g,endpoints:f,selectedEndpoints:h,loadingEndpoints:w,fallbackModels:x,isEditMode:k,originalName:C,modelName:y,nameError:_,validateAndFormatName:I,handleNameInput:U,isLoading:L,initialState:j,providerOptions:F,modelOptions:K,hasChanges:D,isOpenRouter:E,fetchProviders:H,fetchAvailableModels:R,resetForm:N,loadEditData:Z,loadModelFallbacks:G,fetchEndpoints:P,handleSubmit:()=>{if(!r.value||!n.value){alert("Please select a provider and model");return}if(!y.value){alert("Please enter a name for the model");return}if(_.value){alert(_.value);return}const M=E.value?h.value:[],O={name:y.value,model:n.value,provider:r.value,included_providers:M,fallbacks:x.value};k.value&&e.editModel?.id&&(O.id=e.editModel.id,C.value&&C.value!==y.value&&(O.originalName=C.value)),c("save",O)},handleCancel:()=>{N(),c("update:modelValue",!1)},Modal:Ve,SelectInput:xe,ExposedSelectList:kg,ModelSelectorInput:Sg};return Object.defineProperty(q,"__isScriptSetup",{enumerable:!1,value:!0}),q}}),Mg={class:"space-y-4"},Ig={key:0},Vg={key:1},Ag=["value"],Pg={key:0,class:"mt-1 text-xs text-red-500"},Eg={key:1,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Og={class:"px-1 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},jg={key:2,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Lg={key:2},Dg={key:3},Ug={class:"flex justify-end gap-2"},qg=["disabled"];function Ng(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[4]||(t[4]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":e.hasChanges},{footer:ae(()=>[o("div",Ug,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:!e.selectedProvider||!e.selectedModel},b(e.isEditMode?"Update Model":"Add Model"),9,qg)])]),default:ae(()=>[o("div",Mg,[S(e.SelectInput,{modelValue:e.selectedProvider,"onUpdate:modelValue":t[0]||(t[0]=r=>e.selectedProvider=r),options:e.providerOptions,label:"Provider",placeholder:"Select a provider",disabled:e.loadingProviders||e.isEditMode&&!!e.props.editModel},null,8,["modelValue","options","disabled"]),e.selectedProvider?(s(),l("div",Ig,[S(e.SelectInput,{modelValue:e.selectedModel,"onUpdate:modelValue":t[1]||(t[1]=r=>e.selectedModel=r),options:e.modelOptions,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:e.loadingModels},null,8,["modelValue","options","loading"])])):i("v-if",!0),i(" Name field (shown after model selection) "),e.selectedModel?(s(),l("div",Vg,[t[6]||(t[6]=o("label",{class:"block text-sm font-medium mb-2"},"Name",-1)),o("input",{value:e.modelName,onInput:e.handleNameInput,type:"text",class:ee(["w-full px-3 py-2 text-sm border rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent",e.nameError?"border-red-500":"border-gray-300 dark:border-gray-600"]),placeholder:"e.g., coding_model, planning_model, fast_response"},null,42,Ag),e.nameError?(s(),l("p",Pg,b(e.nameError),1)):e.modelName?(s(),l("p",Eg,[t[5]||(t[5]=ie(" Will be saved as: ",-1)),o("code",Og,b(e.modelName),1)])):(s(),l("p",jg," A descriptive name for this model (e.g., coding_model, planning_model). This becomes the filename and reference ID. "))])):i("v-if",!0),e.selectedModel&&e.isOpenRouter?(s(),l("div",Lg,[t[7]||(t[7]=o("label",{class:"block text-sm font-medium mb-2"}," Available Providers ",-1)),S(e.ExposedSelectList,{modelValue:e.selectedEndpoints,"onUpdate:modelValue":t[2]||(t[2]=r=>e.selectedEndpoints=r),providers:e.endpoints,loading:e.loadingEndpoints},null,8,["modelValue","providers","loading"]),t[8]||(t[8]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Select which providers can be used for this model ",-1))])):i("v-if",!0),i(" Fallback Models Section "),e.selectedModel?(s(),l("div",Dg,[S(e.ModelSelectorInput,{modelValue:e.fallbackModels,"onUpdate:modelValue":t[3]||(t[3]=r=>e.fallbackModels=r),label:"Fallback Models",placeholder:"Add fallback model...","allow-multiple":!0},null,8,["modelValue"]),t[9]||(t[9]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Fallback models will be used in order if the primary model fails ",-1))])):i("v-if",!0)])]),_:1},8,["model-value","title","has-changes"])}const Bg=Q(Tg,[["render",Ng],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ModelModal.vue"]]),Rg=$({__name:"ModelsView",setup(u,{expose:t}){t();const a=m(!1),e=m([]),c=m(!1),d=m(null),r=m("add"),n=[{key:"name",label:"Name",width:"w-1/4"},{key:"model",label:"Model",width:"w-1/4"},{key:"provider",label:"Provider",width:"w-1/4"},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],p=[{icon:"edit",label:"Edit",handler:w=>{d.value=w,r.value="edit",a.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",handler:async w=>{await f(w.id)}}],v=async()=>{c.value=!0;try{const w=await fetch(J("/api/models"));if(!w.ok)throw new Error("Failed to fetch models");const x=await w.json();e.value=x.models||[]}catch(w){console.error("Error fetching models:",w),e.value=[]}finally{c.value=!1}},g=async w=>{try{if(d.value){const{originalName:x,...k}=w,C=x||d.value.id,y=await fetch(J(`/api/models/${C}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(!y.ok){const _=await y.json();alert(_.error||"Failed to update model");return}}else{const x=await fetch(J("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!x.ok){const k=await x.json();alert(k.error||"Failed to add model");return}}await v(),a.value=!1,d.value=null,r.value="add"}catch(x){console.error("Error saving model:",x),alert("Failed to save model")}},f=async w=>{try{const x=await fetch(J(`/api/models/${w}`),{method:"DELETE"});if(!x.ok){const k=await x.json();alert(k.error||"Failed to delete model");return}await v()}catch(x){console.error("Error deleting model:",x),alert("Failed to delete model")}};ce(()=>{v()});const h={showModal:a,models:e,loading:c,editingModel:d,modalMode:r,columns:n,actions:p,fetchModels:v,handleAddModel:g,deleteModel:f,ModelModal:Bg,DataTable:Oe,get getModelIcon(){return dt}};return Object.defineProperty(h,"__isScriptSetup",{enumerable:!1,value:!0}),h}}),Fg={class:"p-8"},zg={class:"flex justify-between items-center mb-6"},Hg={class:"flex items-center gap-2"},Wg=["src","alt"],Jg={class:"text-sm text-gray-600 dark:text-gray-400 font-mono"},Kg={key:0,class:"space-y-0.5"},Zg=["title"],Gg={class:"shrink-0 font-mono pr-2"},Xg=["src","alt"],Qg={class:"truncate"},Yg={key:1,class:"text-gray-400 dark:text-gray-600 text-sm"};function $g(u,t,a,e,c,d){return s(),l("div",Fg,[o("div",zg,[t[3]||(t[3]=o("h1",{class:"text-3xl font-bold"},"Models",-1)),o("button",{onClick:t[0]||(t[0]=()=>{e.modalMode="add",e.editingModel=null,e.showModal=!0}),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Model ")]),t[4]||(t[4]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-8"}," Configure AI models from your connected providers. Models define which AI capabilities are available to your agents. ",-1)),S(e.DataTable,{columns:e.columns,data:e.models,actions:e.actions,loading:e.loading,"empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":ae(({value:r,row:n})=>[o("div",Hg,[e.getModelIcon(n.model,n.provider)?(s(),l("img",{key:0,src:e.getModelIcon(n.model,n.provider),class:"w-5 h-5 shrink-0",alt:n.provider},null,8,Wg)):i("v-if",!0),o("span",null,b(r),1)])]),"cell-model":ae(({value:r})=>[o("span",Jg,b(r||"—"),1)]),"cell-fallbacks":ae(({value:r})=>[r&&r.length>0?(s(),l("div",Kg,[(s(!0),l(W,null,ne(r,(n,p)=>(s(),l("div",{key:n.id,class:"text-sm text-gray-600 dark:text-gray-400 flex items-center",title:n.name},[o("span",Gg,b(p===r.length-1?"└─":"├─"),1),e.getModelIcon(n.model,n.provider)?(s(),l("img",{key:0,src:e.getModelIcon(n.model,n.provider),class:"w-4 h-4 shrink-0 mr-1.5",alt:n.provider},null,8,Xg)):i("v-if",!0),o("span",Qg,b(n.name),1)],8,Zg))),128))])):(s(),l("span",Yg," None "))]),_:1},8,["data","loading"]),i(" Model Modal "),S(e.ModelModal,{modelValue:e.showModal,"onUpdate:modelValue":[t[1]||(t[1]=r=>e.showModal=r),t[2]||(t[2]=r=>{e.showModal=r,r||(e.editingModel=null,e.modalMode="add")})],"edit-model":e.editingModel,mode:e.modalMode,onSave:e.handleAddModel},null,8,["modelValue","edit-model","mode"])])}const e1=Q(Rg,[["render",$g],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ModelsView.vue"]]),t1=$({__name:"AddProviderModal",props:{modelValue:{type:Boolean,required:!0}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=a,c=m({name:"",type:"",apiKey:"",baseUrl:""}),d=[{value:"openai",label:"OpenAI",icon:Je,sdk:"openai-sdk"},{value:"openrouter",label:"OpenRouter",icon:at,sdk:"openrouter"}],r=y=>y==="openai-sdk"||y==="openai"?Je:y==="openrouter"?at:null,n=m(!1),p=z(()=>d.find(y=>y.value===c.value.type)),v=()=>{setTimeout(()=>{n.value=!1},200)},g=m({});oe(()=>c.value.type,y=>{if(y&&!c.value.name){const _=d.find(I=>I.value===y);_&&(c.value.name=_.label)}});const f=z(()=>c.value.type==="custom"||c.value.type==="openai"),h=()=>{g.value={};let y=!0;return c.value.name||(g.value.name="Provider name is required",y=!1),c.value.type||(g.value.type="Provider type is required",y=!1),c.value.apiKey||(g.value.apiKey="API key is required",y=!1),f.value&&c.value.type==="custom"&&!c.value.baseUrl&&(g.value.baseUrl="Base URL is required for custom providers",y=!1),y},w=()=>{h()&&(e("save",{...c.value}),k(),e("update:modelValue",!1))},x=()=>{k(),e("update:modelValue",!1)},k=()=>{c.value={name:"",type:"",apiKey:""},g.value={}},C={emit:e,formData:c,providerTypes:d,getProviderIcon:r,isDropdownOpen:n,selectedProvider:p,handleDropdownBlur:v,errors:g,showBaseUrl:f,validateForm:h,handleSave:w,handleCancel:x,resetForm:k,Modal:Ve,TextInput:je};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),o1={class:"space-y-4"},r1={class:"space-y-1"},a1={class:"relative"},s1={key:0,class:"flex items-center gap-2"},l1=["src","alt"],n1={key:1,class:"text-gray-500"},i1={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-black dark:border-white rounded shadow-lg"},d1=["onClick"],c1=["src","alt"],u1={key:0,class:"text-xs text-red-500 dark:text-red-400"};function p1(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[4]||(t[4]=r=>u.$emit("update:modelValue",r)),title:"Add Provider",width:"max-w-md"},{footer:ae(()=>[o("div",{class:"flex gap-2 justify-end"},[o("button",{onClick:e.handleCancel,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSave,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")])]),default:ae(()=>[o("div",o1,[o("div",r1,[t[6]||(t[6]=o("label",{class:"block text-sm font-medium"},[ie(" Provider Type "),o("span",{class:"text-red-500"},"*")],-1)),o("div",a1,[o("button",{type:"button",onClick:t[0]||(t[0]=r=>e.isDropdownOpen=!e.isDropdownOpen),onBlur:e.handleDropdownBlur,class:ee(["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm text-left focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white transition-colors",[e.errors.type?"border-red-500 dark:border-red-400":"border-black dark:border-white"]])},[e.selectedProvider?(s(),l("div",s1,[o("img",{src:e.selectedProvider.icon,alt:e.selectedProvider.label,class:"w-5 h-5"},null,8,l1),o("span",null,b(e.selectedProvider.label),1)])):(s(),l("span",n1,"Select a provider")),t[5]||(t[5]=o("div",{class:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})])],-1))],34),e.isDropdownOpen?(s(),l("div",i1,[(s(),l(W,null,ne(e.providerTypes,r=>o("button",{key:r.value,type:"button",onClick:n=>{e.formData.type=r.value,e.isDropdownOpen=!1},class:"w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-center gap-2"},[o("img",{src:r.icon,alt:r.label,class:"w-5 h-5"},null,8,c1),o("span",null,b(r.label),1)],8,d1)),64))])):i("v-if",!0)]),e.errors.type?(s(),l("p",u1,b(e.errors.type),1)):i("v-if",!0)]),S(e.TextInput,{modelValue:e.formData.name,"onUpdate:modelValue":t[1]||(t[1]=r=>e.formData.name=r),label:"Provider Name",placeholder:"e.g., My OpenAI Provider",error:e.errors.name,required:""},null,8,["modelValue","error"]),S(e.TextInput,{modelValue:e.formData.apiKey,"onUpdate:modelValue":t[2]||(t[2]=r=>e.formData.apiKey=r),label:"API Key",type:"password",placeholder:"sk-...",error:e.errors.apiKey,required:""},null,8,["modelValue","error"]),e.showBaseUrl?(s(),X(e.TextInput,{key:0,modelValue:e.formData.baseUrl,"onUpdate:modelValue":t[3]||(t[3]=r=>e.formData.baseUrl=r),label:"Base URL",placeholder:"https://api.example.com",error:e.errors.baseUrl,required:e.formData.type==="custom"},null,8,["modelValue","error","required"])):i("v-if",!0)])]),_:1},8,["model-value"])}const m1=Q(t1,[["render",p1],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AddProviderModal.vue"]]),g1=$({__name:"ProvidersView",setup(u,{expose:t}){t();const a=m(!1),e=m([]),c=m(!1),d=[{key:"name",label:"Name",width:"w-1/3"},{key:"sdk",label:"SDK Type",width:"w-1/3",formatter:f=>({"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"})[f]||f},{key:"hasApiKey",label:"API Key",width:"w-1/3",formatter:f=>f?"✓ Configured":"✗ Not configured"}],r=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",handler:async f=>{await v(f.name)}}],n=async()=>{c.value=!0;try{const f=await fetch(J("/api/providers"));if(!f.ok)throw new Error("Failed to fetch providers");const h=await f.json();e.value=h.providers||[]}catch(f){console.error("Error fetching providers:",f),e.value=[]}finally{c.value=!1}},p=async f=>{try{const h=await fetch(J("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){const w=await h.json();alert(w.error||"Failed to add provider");return}await n(),a.value=!1}catch(h){console.error("Error adding provider:",h),alert("Failed to add provider")}},v=async f=>{try{const h=await fetch(J(`/api/providers/${encodeURIComponent(f)}`),{method:"DELETE"});if(!h.ok){const w=await h.json();w.modelCount?alert(`${w.error}
10
+ `);return}},A=Array.from(I.childNodes);for(const le of A)O(le);M();const te=T.some(le=>le.type!=="string")?T:[{type:"string",value:(I.innerText||"").replace(/\r\n/g,`
11
+ `)}];n.segments=te.length?te:[{type:"string",value:""}],w(),y(),R()},y=()=>{const P=window.getSelection();if(!P||!P.rangeCount||!d.value)return;const I=P.getRangeAt(0);if(I.startContainer.nodeType!==Node.TEXT_NODE){n.dialogOpen&&V();return}const q=I.startContainer.textContent||"",M=I.startOffset;if(M>0&&q[M-1]==="@")n.atTriggerIndex=M-1,n.searchQuery="",_(),j("");else if(n.dialogOpen&&n.atTriggerIndex>=0)if(I.startContainer.nodeType===Node.TEXT_NODE){const O=I.startContainer.textContent||"",A=I.startOffset;if(A<=n.atTriggerIndex){V();return}const B=O.substring(0,A);if(B.length>n.atTriggerIndex&&B[n.atTriggerIndex]==="@"){const te=B.substring(n.atTriggerIndex+1);te.includes(" ")||te.includes(`
12
+ `)||te.length>n.searchQuery.length+5?V():(n.searchQuery=te,j(te))}else V()}else V()},_=async()=>{n.dialogOpen=!0,n.selectedIndex=0,await pe(),U()},V=()=>{n.dialogOpen=!1,n.searchResults=[],n.searchQuery="",n.atTriggerIndex=-1,n.isSearching=!1},U=()=>{if(!r.value||!d.value)return;const P=window.getSelection();if(!P||!P.rangeCount)return;const T=P.getRangeAt(0).getBoundingClientRect(),q=d.value.getBoundingClientRect();n.dialogPosition={x:T.left-q.left,y:T.bottom-q.top+4}};let L=null;const j=async P=>{if(!e.search){n.searchResults=[];return}L&&clearTimeout(L),n.isSearching=!0,L=setTimeout(async()=>{try{const I=await e.search(P);n.searchResults=(I||[]).filter(T=>e.allowedTypes?.includes(T.type))}catch(I){console.error("Search error:",I),n.searchResults=[]}finally{n.isSearching=!1}},200)},F=P=>P.type==="variable"?{type:"variable",value:P.value??P.id??"",label:P.label,schema:P.schema,_uid:p(),meta:P.meta}:{type:"prompt",id:P.id??P.value??"",label:P.label,schema:P.schema,_uid:p(),meta:P.meta},K=P=>{if(n.atTriggerIndex<0||!d.value)return;const I=window.getSelection();if(!I||!I.rangeCount)return;const T=I.getRangeAt(0);if(T.startContainer.nodeType!==Node.TEXT_NODE)return;const q=T.startContainer,M=q.data.slice(0,n.atTriggerIndex),O=q.data.slice(T.startOffset),A=document.createElement("span"),B=F(P),te=B.type==="prompt"&&B.meta&&!B.meta.isValid;A.className=`prompt-tag${te?" prompt-tag-invalid":""}`,A.setAttribute("contenteditable","false");const le=B._uid||(B._uid=p());A.dataset.segmentUid=le;const re=B.type==="variable"?{type:"variable",value:B.value,label:B.label,schema:B.schema}:{type:"prompt",id:B.id,label:B.label,schema:B.schema};if(A.dataset.segment=encodeURIComponent(JSON.stringify(re)),A.textContent=v(B),te){const be=document.createElement("span");be.className="prompt-tag-warning",be.textContent="⚠️",be.setAttribute("title",B.meta.validationMessage||"Validation error"),A.appendChild(be)}const ue=q.parentNode,me=document.createTextNode(O),we=document.createTextNode(M);ue.insertBefore(we,q),ue.insertBefore(A,q),ue.insertBefore(me,q),ue.removeChild(q),V(),C({target:d.value});const ke=window.getSelection();if(ke){const be=document.createRange();be.setStart(me,0),be.collapse(!0),ke.removeAllRanges(),ke.addRange(be)}d.value.focus()},D=P=>{if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&setTimeout(()=>y(),0),n.dialogOpen)P.key==="ArrowDown"?(P.preventDefault(),n.selectedIndex=Math.min(n.selectedIndex+1,n.searchResults.length-1)):P.key==="ArrowUp"?(P.preventDefault(),n.selectedIndex=Math.max(n.selectedIndex-1,0)):P.key==="Enter"?(P.preventDefault(),n.searchResults[n.selectedIndex]&&K(n.searchResults[n.selectedIndex])):(P.key==="Escape"||P.key==="Esc")&&(P.preventDefault(),V());else if(P.key==="Backspace"||P.key==="Delete"){const I=g();if(P.key==="Backspace"){const T=window.getSelection();if(T&&T.rangeCount){const q=T.getRangeAt(0);if(q.collapsed&&q.startContainer.nodeType===Node.TEXT_NODE&&q.startOffset===0){let M=q.startContainer;for(;M&&M!==d.value;){const O=M.previousSibling;if(O&&O.nodeType===Node.ELEMENT_NODE&&O.classList?.contains("prompt-tag")){P.preventDefault(),O.parentNode?.removeChild(O),C({target:d.value});return}M=M.parentNode}}}}if(!I)return;if(P.key==="Backspace"&&I.offset===0&&I.segmentIndex>0)n.segments[I.segmentIndex-1].type!=="string"&&(P.preventDefault(),n.segments.splice(I.segmentIndex-1,1),w(),R(),h());else if(P.key==="Delete"&&I.segmentIndex<n.segments.length-1){const T=n.segments[I.segmentIndex];T.type==="string"&&(T.value?.length??0)===I.offset&&n.segments[I.segmentIndex+1].type!=="string"&&(P.preventDefault(),n.segments.splice(I.segmentIndex+1,1),w(),R(),h())}}},E=P=>{P.preventDefault();const I=P.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,I)},H=P=>{if(!n.dialogOpen)return;const I=r.value;I&&(I.contains(P.target)||V())},R=()=>{n.ignoreNextWatch=!0;const P=n.segments.map(I=>{const{_uid:T,...q}=I||{};return q});c("update:modelValue",P)},N=()=>{const P=window.getSelection();if(!P||!d.value)return;const I=P.anchorNode;I&&d.value.contains(I)&&y()},Z=P=>{(P.key==="Escape"||P.key==="Esc")&&n.dialogOpen&&(P.preventDefault(),V())};ce(()=>{e.modelValue&&e.modelValue.length&&(n.segments=JSON.parse(JSON.stringify(e.modelValue))),h(),document.addEventListener("mousedown",H),document.addEventListener("selectionchange",N),document.addEventListener("keydown",Z,!0)}),Te(()=>{document.removeEventListener("mousedown",H),document.removeEventListener("selectionchange",N),document.removeEventListener("keydown",Z,!0)}),oe(()=>e.modelValue,P=>{if(n.ignoreNextWatch){n.ignoreNextWatch=!1;return}P&&(n.segments=JSON.parse(JSON.stringify(P)),h())},{deep:!0});const G={props:e,emit:c,editorRef:d,dialogRef:r,state:n,createUid:p,segmentDisplay:v,getLogicalCursorPosition:g,setLogicalCursorPosition:f,renderContent:h,mergeAdjacentTextSegments:w,readTagSegment:x,handleSegmentClick:k,handleInput:C,checkForAtTrigger:y,openDialog:_,closeDialog:V,positionDialog:U,get searchTimeout(){return L},set searchTimeout(P){L=P},performSearch:j,toSegmentFromResult:F,selectResult:K,handleKeyDown:D,handlePaste:E,onDocumentMouseDown:H,emitUpdate:R,onSelectionChange:N,onDocKeyDown:Z,DropShadow:Re};return Object.defineProperty(G,"__isScriptSetup",{enumerable:!1,value:!0}),G}}),Em={class:"prompt-input-container relative"},Om=["contenteditable","data-placeholder"],jm={class:"bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg overflow-hidden min-w-[240px] max-w-[320px]"},Lm={key:0,class:"p-3 text-sm text-gray-500"},Dm={key:1,class:"p-3 text-sm text-gray-500"},Um={key:2,class:"max-h-[220px] overflow-y-auto"},qm=["onClick"],Nm={class:"font-medium flex items-center gap-2"},Bm=["title"],Rm={key:0,class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Fm={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},zm={class:"text-xs mt-1"};function Hm(u,t,a,e,c,d){return s(),l("div",Em,[o("div",{ref:"editorRef","data-testid":"prompt-editor",contenteditable:!a.disabled,onInput:e.handleInput,onKeydown:e.handleKeyDown,onPaste:e.handlePaste,onClick:e.handleSegmentClick,onKeyup:t[0]||(t[0]=r=>{r.key==="Escape"?(r.preventDefault(),e.closeDialog()):(r.key==="ArrowLeft"||r.key==="ArrowRight")&&e.checkForAtTrigger()}),onCompositionstart:t[1]||(t[1]=r=>e.state.isComposing=!0),onCompositionend:t[2]||(t[2]=r=>e.state.isComposing=!1),class:ee(["prompt-input-editor","min-h-[100px] p-3 border-2 rounded-lg","border-black dark:border-white","bg-white dark:bg-black","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white",a.disabled?"opacity-50 cursor-not-allowed":""]),"data-placeholder":a.placeholder},[i(" Slot for custom segment rendering - hidden but provides slot content "),fe(o("div",null,[Be(u.$slots,"segment",{segment:null},void 0,!0)],512),[[Ne,!1]])],42,Om),i(" Mention Dialog "),e.state.dialogOpen?(s(),l("div",{key:0,ref:"dialogRef","data-testid":"mention-dialog",class:"absolute z-50",style:lt({left:`${e.state.dialogPosition.x}px`,top:`${e.state.dialogPosition.y}px`})},[S(e.DropShadow,{"offset-x":2,"offset-y":2,intensity:.3},{default:ae(()=>[o("div",jm,[e.state.isSearching?(s(),l("div",Lm,"Searching...")):e.state.searchResults.length===0?(s(),l("div",Dm,"No results found")):(s(),l("div",Um,[(s(!0),l(W,null,ne(e.state.searchResults,(r,n)=>(s(),l("button",{key:r.id||r.value||n,type:"button",onClick:p=>e.selectResult(r),class:ee(["w-full px-3 py-2 text-left text-sm","hover:bg-gray-100 dark:hover:bg-gray-900","focus:bg-gray-100 dark:focus:bg-gray-900 focus:outline-none",e.state.selectedIndex===n?"bg-gray-100 dark:bg-gray-900":""])},[o("div",Nm,[ie(b(r.label||r.id||r.value)+" ",1),r.type==="prompt"&&r.meta&&!r.meta.isValid?(s(),l("span",{key:0,title:r.meta.validationMessage,class:"text-red-500"},"⚠️",8,Bm)):i("v-if",!0)]),r.description?(s(),l("div",Rm,b(r.description),1)):i("v-if",!0),r.type==="prompt"&&r.meta&&!r.meta.isValid?(s(),l("div",Fm,b(r.meta.validationMessage),1)):i("v-if",!0),o("div",zm,[o("span",{class:ee(["inline-block px-1.5 py-0.5 rounded",r.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},b(r.type),3)])],10,qm))),128))]))])]),_:1})],4)):i("v-if",!0)])}const jt=Q(Pm,[["render",Hm],["__scopeId","data-v-5b9dcb11"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PromptInput.vue"]]);function yt(u,t){if(!t||!t.properties||Object.keys(t.properties).length===0)return!0;if(!u||!u.properties)return Object.keys(t.properties);const a=[],e=u.properties||{},c=t.properties||{};return(t.required||[]).forEach(r=>{r in e||a.push(r)}),Object.keys(c).forEach(r=>{!(r in e)&&!a.includes(r)&&a.push(r)}),a.length>0?a:!0}function xt(u){return u.length===0?"":u.length===1?`Missing required field: ${u[0]}`:`Missing required fields: ${u.join(", ")}`}const Wm=$({__name:"PromptTemplate",props:{promptText:{type:String,required:!0},beforeTool:{type:String,required:!0},afterTool:{type:String,required:!0},requiredSchema:{type:String,required:!0},currentPromptName:{type:String,required:!1}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(!1),n=x=>x.type==="text"?{type:"string",value:x.content||""}:x.type==="include"?{type:"prompt",id:x.prompt||"",label:x.prompt||""}:x.type==="string"?{type:"string",value:x.value||""}:x.type==="prompt"?{type:"prompt",id:x.id||"",label:x.label||x.id||""}:x.type==="variable"?{type:"variable",value:x.value||"",label:x.label||x.value||""}:{type:"string",value:""},p=z(()=>{if(!e.promptText)return[{type:"string",value:""}];let x=[];try{const C=JSON.parse(e.promptText);Array.isArray(C)?x=C.map(n):x=[{type:"string",value:e.promptText}]}catch{x=[{type:"string",value:e.promptText}]}const k=e.requiredSchema?JSON.parse(e.requiredSchema):{};return x.map(C=>{if(C.type==="prompt"&&C.schema){const y=yt(k,C.schema),_=y===!0,V=_?[]:y;return{...C,meta:{isValid:_,missingFields:V,validationMessage:_?"":xt(V)}}}return C})}),v=z(()=>{try{const x=JSON.parse(e.requiredSchema);if(x.properties&&typeof x.properties=="object")return Object.keys(x.properties)}catch{return[]}return[]}),g=async x=>{r.value=!0;try{const k=new URLSearchParams;x&&k.set("search",x);const C=await fetch(J(`/api/prompts${k.toString()?"?"+k.toString():""}`));if(C.ok){const y=await C.json();d.value=y.prompts||[]}}catch(k){console.error("Error fetching prompts:",k)}finally{r.value=!1}},f=async x=>{const k=[];return v.value.forEach(C=>{(!x||C.toLowerCase().includes(x.toLowerCase()))&&k.push({type:"variable",value:C,label:C,description:"Schema property"})}),x!==void 0&&await g(x),d.value.forEach(C=>{if(!(e.currentPromptName&&C.name===e.currentPromptName)&&(!x||C.name.toLowerCase().includes(x.toLowerCase()))){const y=e.requiredSchema?JSON.parse(e.requiredSchema):{},_=yt(y,C.required_schema),V=_===!0,U=V?[]:_;k.push({type:"prompt",id:C.name,label:C.name,description:C.tool_description||"Available prompt",schema:C.required_schema,meta:{isValid:V,missingFields:U,validationMessage:V?"":xt(U)}})}}),k},h=x=>{const k=x.map(C=>{const{type:y,value:_,label:V,id:U,schema:L}=C;return y==="string"?{type:y,value:_||""}:y==="variable"?{type:y,value:_||"",label:V}:y==="prompt"?{type:y,id:U||"",label:V,schema:L}:C});c("update:promptText",JSON.stringify(k))};ce(()=>{g()});const w={props:e,emit:c,availablePrompts:d,loadingPrompts:r,normalizeSegment:n,promptSegments:p,schemaProperties:v,fetchPrompts:g,searchReferences:f,handleSegmentsUpdate:h,PromptInput:jt};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),Jm={class:"space-y-4"};function Km(u,t,a,e,c,d){return s(),l("div",Jm,[o("div",null,[t[0]||(t[0]=o("label",{class:"block text-sm font-medium mb-2"},"Prompt Template",-1)),t[1]||(t[1]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-2"}," Type @ to insert schema properties or other prompts ",-1)),S(e.PromptInput,{"model-value":e.promptSegments,"onUpdate:modelValue":e.handleSegmentsUpdate,search:e.searchReferences,placeholder:"Enter your prompt template... Type @ to insert variables or prompts"},null,8,["model-value"])])])}const Zm=Q(Wm,[["render",Km],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/prompt-form/PromptTemplate.vue"]]),Gm=$({__name:"PromptToolOptions",props:{toolName:{type:String,required:!0},toolConfig:{type:Object,required:!0},disabled:{type:Boolean,required:!1}},emits:["update:option"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(!0),n=z(()=>d.value?.properties?Object.entries(d.value.properties).map(([f,h])=>({value:f,label:f,description:h.description||h.type||""})):[]),p=async()=>{try{const f=await fetch(J(`/api/prompts/${encodeURIComponent(e.toolName)}`));if(f.ok){const h=await f.json();h?.prompt?.required_schema&&(d.value=h.prompt.required_schema)}}catch(f){console.error("Error fetching prompt schema:",f)}finally{r.value=!1}};ce(()=>{p()});const g={props:e,emit:c,schema:d,loading:r,propertyOptions:n,fetchSchema:p,updateOption:(f,h)=>{c("update:option",f,h)},SelectInput:xe,CheckboxInput:Xe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),Xm={class:"space-y-3"},Qm={class:"space-y-2 pl-4 border-l-2 border-blue-200 dark:border-blue-700"},Ym={class:"space-y-1"},$m={class:"space-y-2 pl-4 border-l-2 border-gray-200 dark:border-gray-700"};function e2(u,t,a,e,c,d){return s(),l("div",Xm,[i(" Initialization Options "),o("div",Qm,[t[6]||(t[6]=o("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"}," Initialization Options: ",-1)),o("div",Ym,[t[4]||(t[4]=o("label",{class:"block text-xs font-medium text-gray-700 dark:text-gray-300"}," User message property ",-1)),S(e.SelectInput,{"model-value":a.toolConfig.init_user_message_property||"","onUpdate:modelValue":t[0]||(t[0]=r=>e.updateOption("init_user_message_property",r||null)),placeholder:"Don't inject a user message",options:e.propertyOptions,disabled:a.disabled||e.loading||e.propertyOptions.length===0,loading:e.loading},null,8,["model-value","options","disabled","loading"]),t[5]||(t[5]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected. ",-1))])]),i(" Response Options "),o("div",$m,[t[7]||(t[7]=o("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-2"}," Sub-Prompt Response Options: ",-1)),S(e.CheckboxInput,{"model-value":a.toolConfig.include_text_response,"onUpdate:modelValue":t[1]||(t[1]=r=>e.updateOption("include_text_response",r)),label:"Include text response","help-text":"Include the final text content from the sub-prompt",disabled:a.disabled},null,8,["model-value","disabled"]),S(e.CheckboxInput,{"model-value":a.toolConfig.include_tool_calls,"onUpdate:modelValue":t[2]||(t[2]=r=>e.updateOption("include_tool_calls",r)),label:"Include tool calls and responses","help-text":"Include tool calls executed by the sub-prompt and their responses",disabled:a.disabled},null,8,["model-value","disabled"]),S(e.CheckboxInput,{"model-value":a.toolConfig.include_errors,"onUpdate:modelValue":t[3]||(t[3]=r=>e.updateOption("include_errors",r)),label:"Include errors","help-text":"Include error information if the sub-prompt fails",disabled:a.disabled},null,8,["model-value","disabled"])])])}const t2=Q(Gm,[["render",e2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/PromptToolOptions.vue"]]);async function Ie(u,t={}){const a=localStorage.getItem("auth_token"),e={"Content-Type":"application/json",...t.headers};a&&(e.Authorization=`Bearer ${a}`);const c=u.startsWith("/")?u:`/${u}`,d=await fetch(J(`/api${c}`),{...t,headers:e});if(d.status===401)throw localStorage.removeItem("auth_token"),window.location.href=J("/login"),new Error("Unauthorized");return d}const o2=$({__name:"ToolSelectorWithOptions",props:Se({label:{type:String,required:!1,default:"Available Tools"},placeholder:{type:String,required:!1,default:"Select a tool"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=m();Mt(async()=>{r.value,await pe(),r.value&&e.value.length>0&&await It({parent:r,values:e,dragHandle:".drag-handle"})});const n=z(()=>{const x=new Set(e.value.map(k=>k.name));return c.value.filter(k=>!x.has(k.name)).map(k=>{let C=k.name;return k.type==="prompt"?C=`${k.name} (prompt)`:k.type==="mcp"&&(C=`${k.name} (mcp)`),{value:k.name,label:C,description:k.description}})}),p=async()=>{d.value=!0;try{const x=await Ie("/tools");if(x.ok){const k=await x.json();c.value=Object.entries(k).map(([C,y])=>({name:C,description:y.description||"",type:y.type,model:y.model}))}}catch(x){console.error("Error fetching tools:",x)}finally{d.value=!1}},v=x=>{x&&(e.value.find(k=>k.name===x)||(e.value=[...e.value,{name:x,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}]))},g=x=>{e.value=e.value.filter(k=>k.name!==x)},f=x=>c.value.find(k=>k.name===x),h=(x,k,C)=>{e.value=e.value.map(y=>y.name===x?{...y,[k]:C}:y)};ce(()=>{p()});const w={props:a,modelValue:e,tools:c,loadingTools:d,dragAreaRef:r,toolOptions:n,fetchTools:p,handleSelect:v,removeTool:g,getToolInfo:f,updateToolOption:h,SelectInput:xe,PromptToolOptions:t2};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),r2={class:"space-y-4"},a2={class:"block text-sm font-medium mb-2"},s2={key:0,class:"text-red-500"},l2={key:0,class:"space-y-3 mb-4",ref:"dragAreaRef"},n2={class:"flex items-start justify-between"},i2={class:"flex items-center gap-2 flex-1"},d2={class:"flex-1"},c2={class:"font-medium text-sm"},u2={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mt-1"},p2=["onClick","disabled","aria-label"],m2={key:1,class:"text-xs text-red-500 dark:text-red-400 mt-1"},g2={key:0,class:"text-center py-8 text-sm text-gray-500 dark:text-gray-400 border border-dashed border-gray-300 dark:border-gray-600 rounded-lg"};function f2(u,t,a,e,c,d){return s(),l("div",r2,[o("div",null,[o("label",a2,[ie(b(a.label)+" ",1),a.required?(s(),l("span",s2,"*")):i("v-if",!0)]),i(" Selected tools list (above dropdown) "),e.modelValue.length>0?(s(),l("div",l2,[(s(!0),l(W,null,ne(e.modelValue,r=>(s(),l("div",{key:r.name,class:"border border-gray-300 dark:border-gray-600 rounded-lg p-4"},[o("div",n2,[o("div",i2,[i(" Drag handle "),t[0]||(t[0]=o("div",{class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),o("div",d2,[o("h4",c2,b(r.name),1),e.getToolInfo(r.name)?.description?(s(),l("p",u2,b(e.getToolInfo(r.name)?.description),1)):i("v-if",!0)])]),o("button",{onClick:n=>e.removeTool(r.name),type:"button",disabled:a.disabled,class:"p-1 hover:bg-gray-200 dark:hover:bg-gray-800 rounded transition-colors text-gray-500 hover:text-red-500","aria-label":`Remove ${r.name}`},[...t[1]||(t[1]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,p2)]),i(" Prompt tool options (fetches schema on mount) "),e.getToolInfo(r.name)?.type==="prompt"?(s(),X(e.PromptToolOptions,{key:0,"tool-name":r.name,"tool-config":r,disabled:a.disabled,"onUpdate:option":(n,p)=>e.updateToolOption(r.name,n,p)},null,8,["tool-name","tool-config","disabled","onUpdate:option"])):i("v-if",!0)]))),128))],512)):i("v-if",!0),i(" Tool selector dropdown "),S(e.SelectInput,{"model-value":"","onUpdate:modelValue":e.handleSelect,placeholder:e.modelValue.length>0?"Add another tool...":a.placeholder,"search-placeholder":"Search tools...",options:e.toolOptions,disabled:a.disabled||e.loadingTools||e.toolOptions.length===0,loading:e.loadingTools},null,8,["placeholder","options","disabled","loading"]),a.error?(s(),l("p",m2,b(a.error),1)):i("v-if",!0)]),i(" Empty state (only when no tools are available at all) "),e.modelValue.length===0&&!e.loadingTools&&e.toolOptions.length===0?(s(),l("div",g2," No tools available. Create tools in your agentbuilder/tools directory. ")):i("v-if",!0)])}const h2=Q(o2,[["render",f2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/ToolSelectorWithOptions.vue"]]),v2=$({__name:"MultipleSelectionsInput",props:Se({label:{type:String,required:!1},placeholder:{type:String,required:!1,default:"Select an option"},searchPlaceholder:{type:String,required:!1,default:"Search..."},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},options:{type:Array,required:!0},addLabel:{type:String,required:!1,default:"Add another"},loading:{type:Boolean,required:!1,default:!1}},{modelValue:{type:Array,required:!0,default:()=>[]},modelModifiers:{}}),emits:Se(["removeItem"],["update:modelValue"]),setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=Ee(u,"modelValue"),r=m();Mt(async()=>{r.value,await pe(),await It({parent:r,values:d,dragHandle:".drag-handle"})});const n=z(()=>Array.isArray(d.value)?d.value.length>0&&typeof d.value[0]=="object"?d.value:d.value.map(h=>{const w=e.options.find(x=>x.value===h);return{id:h,label:w?.label||h,description:w?.description,icon:w?.icon}}):[]),p=z(()=>{const h=n.value.map(w=>w.id);return e.options.filter(w=>!h.includes(w.value))}),f={props:e,emit:c,modelValue:d,dragAreaRef:r,selectedItems:n,availableOptions:p,handleSelect:h=>{if(!h)return;const w=e.options.find(x=>x.value===h);if(w)if(d.value.length===0||typeof d.value[0]=="string")d.value=[...d.value,h];else{const x={id:h,label:w.label,description:w.description,icon:w.icon};d.value=[...d.value,x]}},removeItem:h=>{typeof d.value[0]=="string"?d.value=d.value.filter(w=>w!==h):d.value=d.value.filter(w=>w.id!==h),c("removeItem",h)},SelectInput:xe};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),b2={class:"space-y-2"},y2={key:0,class:"space-y-2"},x2={key:0,class:"block text-sm font-medium"},k2={key:0,class:"text-red-500"},_2={class:"space-y-1",ref:"dragAreaRef"},w2=["src","alt"],C2={class:"flex-1 text-sm"},S2={key:0,class:"text-xs text-gray-500 dark:text-gray-400 ml-1"},T2=["onClick","aria-label"],M2={key:1,class:"text-xs text-red-500 dark:text-red-400"};function I2(u,t,a,e,c,d){return s(),l("div",b2,[e.selectedItems.length>0?(s(),l("div",y2,[a.label?(s(),l("label",x2,[ie(b(a.label)+" ",1),a.required?(s(),l("span",k2,"*")):i("v-if",!0)])):i("v-if",!0),o("div",_2,[(s(!0),l(W,null,ne(e.selectedItems,r=>(s(),l("div",{key:r.id,class:ee(["flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-900 rounded border","border-gray-200 dark:border-gray-800",a.disabled?"opacity-50":""])},[i(" Drag handle "),t[1]||(t[1]=o("div",{class:"drag-handle cursor-move text-gray-400 hover:text-gray-600 dark:text-gray-600 dark:hover:text-gray-400"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),i(" Icon "),r.icon?(s(),l("img",{key:0,src:r.icon,alt:r.label,class:"w-4 h-4 flex-shrink-0"},null,8,w2)):i("v-if",!0),i(" Label and description "),o("span",C2,[ie(b(r.label)+" ",1),r.description?(s(),l("span",S2," ("+b(r.description)+") ",1)):i("v-if",!0)]),i(" Remove button "),a.disabled?i("v-if",!0):(s(),l("button",{key:1,onClick:n=>e.removeItem(r.id),type:"button",class:"p-1 hover:bg-gray-200 dark:hover:bg-gray-800 rounded transition-colors","aria-label":`Remove ${r.label}`},[...t[0]||(t[0]=[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,T2))],2))),128))],512)])):i("v-if",!0),i(" Select input for adding new items "),S(e.SelectInput,{"model-value":"","onUpdate:modelValue":e.handleSelect,label:e.selectedItems.length>0?a.addLabel:a.label,options:e.availableOptions,placeholder:a.placeholder,"search-placeholder":a.searchPlaceholder,disabled:a.disabled||e.availableOptions.length===0,loading:a.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),a.error?(s(),l("p",M2,b(a.error),1)):i("v-if",!0)])}const ct=Q(v2,[["render",I2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/MultipleSelectionsInput.vue"]]),V2=$({__name:"AgentSelectorInput",props:Se({label:{type:String,required:!1,default:"Handoff Agents"},placeholder:{type:String,required:!1,default:"Select an agent"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},allowMultiple:{type:Boolean,required:!1,default:!0},agentType:{type:String,required:!1,default:"ai_human"}},{modelValue:{type:[String,Array],required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=z(()=>c.value.map(g=>({value:g.id,label:g.title,description:g.tool_description||`Handoff to ${g.title} agent`}))),n=async()=>{d.value=!0;try{const g=J(`/api/agents${a.agentType?`?type=${a.agentType}`:""}`),f=await fetch(g);if(f.ok){const h=await f.json();c.value=h.agents||[]}}catch(g){console.error("Error fetching agents:",g)}finally{d.value=!1}},p=g=>{};ce(()=>{n()}),oe(()=>a.allowMultiple,()=>{a.allowMultiple&&typeof e.value=="string"?e.value=e.value?[e.value]:[]:!a.allowMultiple&&Array.isArray(e.value)&&(e.value=e.value[0]||"")},{immediate:!0});const v={props:a,modelValue:e,agents:c,loadingAgents:d,agentOptions:r,fetchAgents:n,handleRemoveItem:p,SelectInput:xe,MultipleSelectionsInput:ct};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),A2={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function P2(u,t,a,e,c,d){return s(),l(W,null,[a.allowMultiple?(s(),X(e.MultipleSelectionsInput,{key:0,modelValue:e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search agents...",error:a.error,required:a.required,disabled:a.disabled,options:e.agentOptions,loading:e.loadingAgents,"add-label":"Add another agent",onRemoveItem:e.handleRemoveItem},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(s(),X(e.SelectInput,{key:1,modelValue:e.modelValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search agents...",options:e.agentOptions,disabled:a.disabled,loading:e.loadingAgents},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!a.allowMultiple&&a.error?(s(),l("p",A2,b(a.error),1)):i("v-if",!0)],64)}const E2=Q(V2,[["render",P2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/AgentSelectorInput.vue"]]),O2=$({__name:"PromptModal",props:{modelValue:{type:Boolean,required:!0},editPrompt:{type:null,required:!1},mode:{type:String,required:!1}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=z(()=>e.mode==="edit"),r=m(!1),n=z(()=>_.value.length===1),p=m(""),v=m(""),g=m(""),f=m(""),h=m({type:"object",properties:{},required:[],additionalProperties:!1}),w=m(""),x=m(!1),k=m(!1),C=m(""),y=m(""),_=m([]),V=m([]),U=m(!1),L=m("auto"),j=m(null),F=m(null),K=m(!1),D=m(!1),E=z({get:()=>j.value||"",set:I=>j.value=I||null}),H=z({get:()=>L.value,set:I=>L.value=I}),R=()=>{v.value="",p.value="",g.value="",f.value="",h.value={type:"object",properties:{},required:[],additionalProperties:!1},w.value="",x.value=!1,k.value=!1,C.value="",y.value="",_.value=[],V.value=[],U.value=!1,L.value="auto",j.value=null,F.value=null,K.value=!1,D.value=!1},N=async()=>{if(e.editPrompt?.id){r.value=!0;try{const I=await Ie(`/prompts/${e.editPrompt.id}`);if(I.ok){const T=await I.json(),q=T.prompt||T;v.value=q.name||"",p.value=q.name||"",g.value=q.tool_description||"",f.value=q.model_id||"";let M=q.required_schema;if(typeof M=="string")try{M=JSON.parse(M)}catch{M=null}h.value=M||{type:"object",properties:{},required:[],additionalProperties:!1},w.value=q.prompt||"",x.value=q.include_chat||!1,k.value=q.include_past_tools||!1,C.value=q.before_tool||"",y.value=q.after_tool||"";const O=q.tools||[];_.value=O.map(B=>typeof B=="string"?{name:B,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null}:B),V.value=q.prompts||q.handoff_agents||[],U.value=q.parallel_tool_calls||!1,L.value=q.tool_choice||"auto";const A=q.reasoning||{};j.value=A.effort||q.reasoning_effort||null,F.value=A.maxTokens||q.reasoning_max_tokens||null,K.value=A.exclude||q.reasoning_exclude||!1,D.value=q.include_reasoning||!1}}catch(I){console.error("Error loading prompt data:",I)}finally{r.value=!1}}},Z=async()=>{const I=/^[a-z][a-z0-9_]*$/;if(!v.value||!I.test(v.value)){alert("Please enter a valid name (lowercase letters, numbers, and underscores only, must start with a letter)");return}if(!g.value){alert("Please enter a description");return}if(!f.value){alert("Please select a model");return}if(!w.value){alert("Please enter the prompt template");return}const T={name:v.value,tool_description:g.value,prompt:w.value,required_schema:h.value,model_id:f.value,include_chat:x.value,include_past_tools:k.value,before_tool:C.value||null,after_tool:y.value||null,parallel_tool_calls:U.value,tool_choice:L.value,tools:_.value,handoff_agents:V.value,reasoning_effort:j.value,reasoning_max_tokens:F.value,reasoning_exclude:K.value,include_reasoning:D.value};d.value&&e.editPrompt?.id&&(T.id=e.editPrompt.id,p.value&&p.value!==v.value&&(T.originalName=p.value)),c("save",T),R(),c("update:modelValue",!1)},G=()=>{R(),c("update:modelValue",!1)};oe(()=>_.value.length,I=>{L.value==="function"&&I!==1&&(L.value="auto")}),oe(()=>e.modelValue,async I=>{I&&(d.value?(R(),await pe(),await N()):R())}),oe(()=>e.editPrompt,async I=>{I&&d.value&&e.modelValue&&(await pe(),await N())},{immediate:!0});const P={props:e,emit:c,isEditMode:d,isLoading:r,isFunctionChoiceAvailable:n,originalName:p,name:v,toolDescription:g,selectedModel:f,requiredSchema:h,promptText:w,includeChat:x,includePastTools:k,beforeTool:C,afterTool:y,selectedTools:_,handoffAgents:V,parallelToolCalls:U,toolChoice:L,reasoningEffort:j,reasoningMaxTokens:F,reasoningExclude:K,includeReasoning:D,reasoningEffortValue:E,toolChoiceValue:H,resetForm:R,loadPromptData:N,handleSubmit:Z,handleCancel:G,Modal:Ve,PromptBasicInfo:vp,PromptModelSelect:Up,JSONSchemaInput:Ot,PromptTemplate:Zm,CheckboxInput:Xe,ToolSelectorWithOptions:h2,AgentSelectorInput:E2,SelectInput:xe};return Object.defineProperty(P,"__isScriptSetup",{enumerable:!1,value:!0}),P}}),j2={key:0,class:"min-h-[400px] flex items-center justify-center"},L2={class:"space-y-6 pr-2 pb-4"},D2={class:"space-y-4"},U2={class:"space-y-4"},q2={class:"flex justify-between"},N2={class:"flex gap-2"},B2=["disabled"];function R2(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[17]||(t[17]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Prompt":"Add Prompt",width:"max-w-4xl"},{footer:ae(()=>[o("div",q2,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("div",N2,[o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:e.isLoading},b(e.isEditMode?"Update Prompt":"Create Prompt"),9,B2)])])]),default:ae(()=>[e.isLoading?(s(),l("div",j2,[...t[18]||(t[18]=[o("span",{class:"text-gray-500"},"Loading prompt data...",-1)])])):(s(),l(W,{key:1},[i(" Single long form for both edit and add modes "),o("div",L2,[o("div",null,[S(e.PromptBasicInfo,{name:e.name,"onUpdate:name":t[0]||(t[0]=r=>e.name=r),"tool-description":e.toolDescription,"onUpdate:toolDescription":t[1]||(t[1]=r=>e.toolDescription=r)},null,8,["name","tool-description"])]),o("div",null,[S(e.PromptModelSelect,{modelValue:e.selectedModel,"onUpdate:modelValue":t[2]||(t[2]=r=>e.selectedModel=r)},null,8,["modelValue"])]),o("div",null,[S(e.JSONSchemaInput,{modelValue:e.requiredSchema,"onUpdate:modelValue":t[3]||(t[3]=r=>e.requiredSchema=r),label:"Required Schema (Optional)"},null,8,["modelValue"])]),o("div",null,[S(e.PromptTemplate,{"prompt-text":e.promptText,"onUpdate:promptText":t[4]||(t[4]=r=>e.promptText=r),"before-tool":e.beforeTool,"onUpdate:beforeTool":t[5]||(t[5]=r=>e.beforeTool=r),"after-tool":e.afterTool,"onUpdate:afterTool":t[6]||(t[6]=r=>e.afterTool=r),"required-schema":JSON.stringify(e.requiredSchema,null,2),"current-prompt-name":e.isEditMode?e.name:void 0},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name"])]),o("div",null,[S(e.ToolSelectorWithOptions,{modelValue:e.selectedTools,"onUpdate:modelValue":t[7]||(t[7]=r=>e.selectedTools=r)},null,8,["modelValue"])]),o("div",D2,[t[20]||(t[20]=o("h3",{class:"text-sm font-medium text-gray-900 dark:text-gray-100"}," Tool Configuration ",-1)),i(" Parallel Tool Calls "),o("div",null,[S(e.CheckboxInput,{modelValue:e.parallelToolCalls,"onUpdate:modelValue":t[8]||(t[8]=r=>e.parallelToolCalls=r),label:"Allow parallel tool calls","help-text":"Allow the model to call multiple tools simultaneously in a single turn"},null,8,["modelValue"])]),i(" Tool Choice "),o("div",null,[S(e.SelectInput,{modelValue:e.toolChoiceValue,"onUpdate:modelValue":t[9]||(t[9]=r=>e.toolChoiceValue=r),label:"Tool Choice",options:[{value:"auto",label:"Auto",description:"Model decides"},{value:"none",label:"None",description:"No tools allowed"},{value:"required",label:"Required",description:"Must call a tool"},{value:"function",label:"Function",description:e.isFunctionChoiceAvailable?"Call specific tool":"Requires exactly 1 tool"}].filter(r=>r.value!=="function"||e.isFunctionChoiceAvailable),placeholder:"Select tool choice"},null,8,["modelValue","options"]),t[19]||(t[19]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Controls whether and how the model can call tools ",-1))])]),o("div",null,[S(e.AgentSelectorInput,{modelValue:e.handoffAgents,"onUpdate:modelValue":t[10]||(t[10]=r=>e.handoffAgents=r),"allow-multiple":!0,label:"Handoff Agents (Optional)",placeholder:"Select AI + Human agents to hand off to","agent-type":"ai_human"},null,8,["modelValue"]),t[21]||(t[21]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," AI + Human agents that this prompt can hand off conversations to. These will be exposed as tools. ",-1))]),i(" Reasoning Tokens Configuration "),o("div",U2,[t[25]||(t[25]=o("h3",{class:"text-sm font-medium text-gray-900 dark:text-gray-100"}," Context & Reasoning Configuration ",-1)),i(" Include Chat History "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includeChat,"onUpdate:modelValue":t[11]||(t[11]=r=>e.includeChat=r),label:"Include chat history","help-text":"Expose chat history to the LLM when this prompt is used as a full prompt (not a partial in another prompt)"},null,8,["modelValue"])]),i(" Include Past Tool Calls "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includePastTools,"onUpdate:modelValue":t[12]||(t[12]=r=>e.includePastTools=r),label:"Include past tool calls","help-text":"Include prior tool call history in this prompt. Uncheck to remove past tool calls"},null,8,["modelValue"])]),i(" Include Reasoning in Message History "),o("div",null,[S(e.CheckboxInput,{modelValue:e.includeReasoning,"onUpdate:modelValue":t[13]||(t[13]=r=>e.includeReasoning=r),label:"Include reasoning in message history","help-text":"When loading message history, include reasoning_details from previous responses. Required for multi-turn reasoning continuity."},null,8,["modelValue"])]),t[26]||(t[26]=o("hr",{class:"border-gray-300 dark:border-gray-600"},null,-1)),t[27]||(t[27]=o("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),i(" Reasoning Effort "),o("div",null,[S(e.SelectInput,{modelValue:e.reasoningEffortValue,"onUpdate:modelValue":t[14]||(t[14]=r=>e.reasoningEffortValue=r),label:"Reasoning Effort",options:[{value:"",label:"None",description:"Disabled"},{value:"low",label:"Low",description:"~20% of max_tokens"},{value:"medium",label:"Medium",description:"~50% of max_tokens"},{value:"high",label:"High",description:"~80% of max_tokens"}],placeholder:"Select reasoning effort"},null,8,["modelValue"]),t[22]||(t[22]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Controls reasoning capacity allocation. Supported by OpenAI o-series and Grok models. ",-1))]),i(" Max Reasoning Tokens "),o("div",null,[t[23]||(t[23]=o("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Max Reasoning Tokens ",-1)),fe(o("input",{"onUpdate:modelValue":t[15]||(t[15]=r=>e.reasoningMaxTokens=r),type:"number",min:"1024",max:"32000",step:"1024",placeholder:"Leave empty to disable or use effort level",class:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent"},null,512),[[_e,e.reasoningMaxTokens,void 0,{number:!0}]]),t[24]||(t[24]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Directly specify reasoning token limit (1024-32000). Supported by Anthropic, Gemini Thinking, and some Qwen models. ",-1))]),i(" Exclude Reasoning from Response "),o("div",null,[S(e.CheckboxInput,{modelValue:e.reasoningExclude,"onUpdate:modelValue":t[16]||(t[16]=r=>e.reasoningExclude=r),label:"Exclude reasoning from response","help-text":"Use reasoning internally but don't return it in the response (saves tokens and cost)"},null,8,["modelValue"])])])])],2112))]),_:1},8,["model-value","title"])}const Lt=Q(O2,[["render",R2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/PromptModal.vue"]]),F2=$({__name:"PromptsView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!1),d=m(null);oe(()=>e.query.refresh,()=>{e.query.refresh&&(d.value?.refresh(),a.replace({path:"/prompts",query:{}}))});const v={router:a,route:e,showModal:c,dataTableRef:d,handleAdd:()=>{c.value=!0},handleEdit:g=>{a.push(`/prompts/${g.id}`)},handleSave:async g=>{try{const f=await fetch(J("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(f.ok)c.value=!1,await new Promise(h=>setTimeout(h,100)),await d.value?.refresh();else{const h=await f.json();alert(h.error||"Failed to create prompt")}}catch(f){console.error("Error creating prompt:",f),alert("Failed to create prompt")}},PromptsDataTable:dp,PromptModal:Lt};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),z2={class:"p-8"};function H2(u,t,a,e,c,d){return s(),l("div",z2,[o("div",{class:"flex justify-between items-center mb-6"},[t[1]||(t[1]=o("h1",{class:"text-3xl font-bold"},"Prompts",-1)),o("button",{onClick:e.handleAdd,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Create Prompt ")]),t[2]||(t[2]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"},"Define and manage prompt templates for your agents.",-1)),S(e.PromptsDataTable,{ref:"dataTableRef",onAdd:e.handleAdd,onEdit:e.handleEdit},null,512),S(e.PromptModal,{modelValue:e.showModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showModal=r),mode:"add",onSave:e.handleSave},null,8,["modelValue"])])}const W2=Q(F2,[["render",H2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/PromptsView.vue"]]),J2=$({__name:"PromptEditView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(!0),d=m(null),r=m(!0),n=async()=>{const f=e.params.id;if(!f){a.push("/prompts");return}r.value=!0;try{const h=await fetch(J(`/api/prompts/${f}`));if(h.ok){const w=await h.json();d.value=w.prompt||w}else alert("Prompt not found"),a.push("/prompts")}catch(h){console.error("Error loading prompt:",h),alert("Failed to load prompt"),a.push("/prompts")}finally{r.value=!1}},p=async f=>{try{const{originalName:h,...w}=f,x=h||w.id,k=await fetch(J(`/api/prompts/${x}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(k.ok)a.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const C=await k.json();alert(C.error||"Failed to update prompt")}}catch(h){console.error("Error updating prompt:",h),alert("Failed to update prompt")}},v=f=>{f||a.push("/prompts")};ce(()=>{n()}),oe(c,f=>{f||a.push("/prompts")});const g={router:a,route:e,showModal:c,editingPrompt:d,isLoading:r,loadPrompt:n,handleSave:p,handleClose:v,PromptModal:Lt};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),K2={class:"p-8"},Z2={key:0,class:"flex items-center justify-center min-h-[400px]"},G2={key:2,class:"flex items-center justify-center min-h-[400px]"};function X2(u,t,a,e,c,d){return s(),l("div",K2,[e.isLoading?(s(),l("div",Z2,[...t[1]||(t[1]=[o("span",{class:"text-gray-500"},"Loading prompt...",-1)])])):e.editingPrompt?(s(),X(e.PromptModal,{key:1,modelValue:e.showModal,"onUpdate:modelValue":[t[0]||(t[0]=r=>e.showModal=r),e.handleClose],mode:"edit","edit-prompt":e.editingPrompt,onSave:e.handleSave},null,8,["modelValue","edit-prompt"])):(s(),l("div",G2,[...t[2]||(t[2]=[o("span",{class:"text-gray-500"},"Prompt not found",-1)])]))])}const Q2=Q(J2,[["render",X2],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/PromptEditView.vue"]]),Y2=$({__name:"ExposedSelectList",props:{providers:{type:Array,required:!0,default:()=>[]},modelValue:{type:Array,required:!0,default:()=>[]},label:{type:String,required:!1},loading:{type:Boolean,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();function e(w){if(w===0)return"$0.00";const x=Math.abs(w);let k;return x<1e-4?k=x.toExponential(3):x<.001||x<.01||x<.1?k=x.toFixed(4):x<1?k=x.toFixed(3):x<10||x<100?k=x.toFixed(2):x<1e3?k=x.toFixed(1):k=x.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),k.includes(".")&&(k=k.replace(/\.?0+$/,""),!k.includes(".")&&x<100&&(k=x.toFixed(2))),w<0?`-$${k}`:`$${k}`}const c=u,d=a,r=w=>c.modelValue.includes(w),n=w=>{const x=[...c.modelValue],k=x.indexOf(w);k>-1?x.splice(k,1):x.push(w),d("update:modelValue",x)},p=()=>{d("update:modelValue",c.providers.map(w=>w.id))},v=()=>{d("update:modelValue",[])},g=z(()=>c.providers.length>0&&c.modelValue.length===c.providers.length),f=z(()=>c.modelValue.length>0&&c.modelValue.length<c.providers.length),h={dollars:e,props:c,emit:d,isSelected:r,toggleProvider:n,selectAll:p,deselectAll:v,allSelected:g,someSelected:f};return Object.defineProperty(h,"__isScriptSetup",{enumerable:!1,value:!0}),h}}),$2={class:"border-2 border-black dark:border-white rounded-lg overflow-hidden"},eg={key:0,class:"px-4 py-2 border-b-2 border-black dark:border-white bg-gray-50 dark:bg-gray-900"},tg={class:"flex items-center justify-between"},og={class:"text-sm font-medium"},rg={class:"flex items-center gap-2"},ag={key:1,class:"px-4 py-8 flex items-center justify-center"},sg={key:2,class:"px-4 py-8 text-center text-gray-500"},lg={key:3,class:"divide-y divide-gray-200 dark:divide-gray-700"},ng=["onClick"],ig={class:"flex items-start gap-3"},dg={class:"flex-shrink-0 mt-0.5"},cg=["checked","onClick"],ug={class:"flex-1 min-w-0"},pg={class:"flex items-center gap-2"},mg={class:"text-sm font-medium"},gg={key:0,class:"text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},fg={class:"mt-1 text-xs text-gray-600 dark:text-gray-400 space-y-0.5"},hg={key:0},vg={key:0},bg={key:1},yg={key:2};function xg(u,t,a,e,c,d){return s(),l("div",$2,[a.label?(s(),l("div",eg,[o("div",tg,[o("span",og,b(a.label),1),o("div",rg,[o("button",{type:"button",onClick:t[0]||(t[0]=r=>e.allSelected?e.deselectAll():e.selectAll()),class:"text-xs px-2 py-1 border border-gray-400 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-800"},b(e.allSelected?"Deselect All":"Select All"),1)])])])):i("v-if",!0),a.loading?(s(),l("div",ag,[...t[1]||(t[1]=[o("div",{class:"flex items-center gap-2 text-gray-500"},[o("svg",{class:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[o("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),o("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),o("span",null,"Loading providers...")],-1)])])):a.providers.length===0?(s(),l("div",sg," No providers available ")):(s(),l("div",lg,[(s(!0),l(W,null,ne(a.providers,r=>(s(),l("div",{key:r.id,class:"px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-900 cursor-pointer",onClick:n=>e.toggleProvider(r.id)},[o("div",ig,[o("div",dg,[o("input",{type:"checkbox",checked:e.isSelected(r.id),onClick:he(n=>e.toggleProvider(r.id),["stop"]),class:"w-4 h-4 border-2 border-black dark:border-white rounded focus:ring-2 focus:ring-black dark:focus:ring-white"},null,8,cg)]),o("div",ug,[o("div",pg,[o("span",mg,b(r.name),1),r.quantization?(s(),l("span",gg,b(r.quantization),1)):i("v-if",!0)]),o("div",fg,[o("div",null,b(e.dollars(r.pricing.prompt*1e6))+"/M input • "+b(e.dollars(r.pricing.completion*1e6))+"/M output ",1),r.maxPromptTokens||r.maxCompletionTokens?(s(),l("div",hg,[r.maxPromptTokens?(s(),l("span",vg," Max prompt: "+b(r.maxPromptTokens.toLocaleString())+" tokens ",1)):i("v-if",!0),r.maxPromptTokens&&r.maxCompletionTokens?(s(),l("span",bg," • ")):i("v-if",!0),r.maxCompletionTokens?(s(),l("span",yg," Max completion: "+b(r.maxCompletionTokens.toLocaleString())+" tokens ",1)):i("v-if",!0)])):i("v-if",!0)])])])],8,ng))),128))]))])}const kg=Q(Y2,[["render",xg],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ExposedSelectList.vue"]]),_g=$({__name:"ModelSelectorInput",props:Se({label:{type:String,required:!1},placeholder:{type:String,required:!1,default:"Select a model"},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},allowMultiple:{type:Boolean,required:!1,default:!1}},{modelValue:{type:[String,Array],required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(u,{expose:t}){t();const a=u,e=Ee(u,"modelValue"),c=m([]),d=m(!1),r=z(()=>c.value.map(g=>({value:g.id,label:g.name,description:g.provider_id||g.provider,icon:dt(g.model||g.name,g.provider_id||g.provider)}))),n=async()=>{d.value=!0;try{const g=await fetch(J("/api/models"));if(g.ok){const f=await g.json();c.value=f.models||[]}}catch(g){console.error("Error fetching models:",g)}finally{d.value=!1}},p=g=>{};ce(()=>{n()}),oe(()=>a.allowMultiple,()=>{a.allowMultiple&&typeof e.value=="string"?e.value=e.value?[e.value]:[]:!a.allowMultiple&&Array.isArray(e.value)&&(e.value=e.value[0]||"")});const v={props:a,modelValue:e,models:c,loadingModels:d,modelOptions:r,fetchModels:n,handleRemoveItem:p,SelectInput:xe,MultipleSelectionsInput:ct};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),wg={key:2,class:"text-xs text-red-500 dark:text-red-400 mt-1"};function Cg(u,t,a,e,c,d){return s(),l(W,null,[a.allowMultiple?(s(),X(e.MultipleSelectionsInput,{key:0,modelValue:e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search models...",error:a.error,required:a.required,disabled:a.disabled,options:e.modelOptions,loading:e.loadingModels,"add-label":"Add another model",onRemoveItem:e.handleRemoveItem},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(s(),X(e.SelectInput,{key:1,modelValue:e.modelValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.modelValue=r),label:a.label,placeholder:a.placeholder,"search-placeholder":"Search models...",options:e.modelOptions,disabled:a.disabled,loading:e.loadingModels},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!a.allowMultiple&&a.error?(s(),l("p",wg,b(a.error),1)):i("v-if",!0)],64)}const Sg=Q(_g,[["render",Cg],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/ModelSelectorInput.vue"]]),Tg=$({__name:"ModelModal",props:{modelValue:{type:Boolean,required:!0},editModel:{type:null,required:!1},mode:{type:String,required:!1,default:"add"}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m([]),r=m(""),n=m(""),p=m([]),v=m(!1),g=m(!1),f=m([]),h=m([]),w=m(!1),x=m([]),k=z(()=>e.mode==="edit"),C=m(""),y=m(""),_=m(""),V=M=>{let O=M.replace(/[^a-zA-Z0-9\s_-]/g,"");return O=O.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),O?/^[a-z][a-z0-9_]*$/.test(O)?_.value="":_.value="Name must start with a letter and contain only lowercase letters, numbers, and underscores":_.value="Name is required",O},U=M=>{const O=M.target.value;y.value=V(O)},L=m(!1),j=m(null),F=z(()=>d.value.filter(M=>M.hasApiKey).map(M=>({value:M.name,label:M.name,description:M.sdk==="openai-sdk"?"OpenAI SDK":M.sdk==="openrouter"?"OpenRouter":M.sdk,icon:Ke(M.sdk)}))),K=z(()=>p.value.map(M=>({...M,icon:M.iconId?Ke(M.iconId):void 0}))),D=z(()=>!k.value||!j.value||L.value?!1:y.value!==j.value.name||r.value!==j.value.provider||n.value!==j.value.model||JSON.stringify(h.value.sort())!==JSON.stringify(j.value.endpoints.sort())||JSON.stringify(x.value)!==JSON.stringify(j.value.fallbacks)),E=z(()=>d.value.find(O=>O.name===r.value)?.sdk==="openrouter"),H=async()=>{v.value=!0;try{const M=await fetch(J("/api/providers"));if(M.ok){const O=await M.json();d.value=O.providers||[]}}catch(M){console.error("Error fetching providers:",M)}finally{v.value=!1}},R=async()=>{if(!r.value){p.value=[];return}g.value=!0;try{const M=await fetch(J("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.value})});if(M.ok){const O=await M.json();p.value=O.models||[]}else{const O=await M.json();console.error("Error fetching models:",O),p.value=[],alert(O.error||"Failed to fetch available models")}}catch(M){console.error("Error fetching models:",M),p.value=[]}finally{g.value=!1}},N=()=>{y.value="",C.value="",r.value="",n.value="",p.value=[],x.value=[],f.value=[],h.value=[],j.value=null,L.value=!1},Z=async()=>{if(e.editModel){L.value=!0;try{await H(),y.value=e.editModel.name||"",C.value=e.editModel.name||"",r.value=e.editModel.provider_id||e.editModel.provider,await R(),n.value=e.editModel.model,await P(),e.editModel.included_providers&&e.editModel.included_providers.length>0&&(h.value=e.editModel.included_providers),await G(),j.value={name:y.value,provider:r.value,model:n.value,endpoints:[...h.value],fallbacks:[...x.value]}}finally{L.value=!1}}};oe(()=>e.modelValue,async M=>{M?k.value&&e.editModel?await Z():(await H(),N()):N()});const G=async()=>{if(e.editModel?.id){if(e.editModel.fallbacks&&Array.isArray(e.editModel.fallbacks)){x.value=e.editModel.fallbacks.map(M=>typeof M=="string"?M:M.id);return}try{const M=await fetch(J(`/api/models/${e.editModel.id}/fallbacks`));if(M.ok){const O=await M.json();x.value=O.fallbacks.map(A=>A.fallback_model_id)}}catch(M){console.error("Error loading fallbacks:",M)}}};oe(r,async(M,O)=>{L.value||k.value&&!O&&M===(e.editModel?.provider_id||e.editModel?.provider)||(n.value="",f.value=[],h.value=[],r.value&&await R())});const P=async()=>{if(!n.value||!r.value){f.value=[];return}const M=d.value.find(A=>A.name===r.value);if(!M||M.sdk!=="openrouter"){f.value=[];return}const O=K.value.find(A=>A.value===n.value);if(!O?.slug){console.error("Model slug not found"),f.value=[];return}w.value=!0;try{const A=await fetch(J("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.value,modelSlug:O.slug})});if(A.ok){const B=await A.json();f.value=B.endpoints||[],k.value||(h.value=f.value.map(te=>te.id))}else{const B=await A.json();console.error("Error fetching endpoints:",B),f.value=[]}}catch(A){console.error("Error fetching endpoints:",A),f.value=[]}finally{w.value=!1}};oe(n,async(M,O)=>{L.value||k.value&&!O&&M===e.editModel?.model||(n.value?(await P(),O&&M!==O&&(h.value=f.value.map(A=>A.id))):(f.value=[],h.value=[]))});const q={props:e,emit:c,providers:d,selectedProvider:r,selectedModel:n,availableModels:p,loadingProviders:v,loadingModels:g,endpoints:f,selectedEndpoints:h,loadingEndpoints:w,fallbackModels:x,isEditMode:k,originalName:C,modelName:y,nameError:_,validateAndFormatName:V,handleNameInput:U,isLoading:L,initialState:j,providerOptions:F,modelOptions:K,hasChanges:D,isOpenRouter:E,fetchProviders:H,fetchAvailableModels:R,resetForm:N,loadEditData:Z,loadModelFallbacks:G,fetchEndpoints:P,handleSubmit:()=>{if(!r.value||!n.value){alert("Please select a provider and model");return}if(!y.value){alert("Please enter a name for the model");return}if(_.value){alert(_.value);return}const M=E.value?h.value:[],O={name:y.value,model:n.value,provider:r.value,included_providers:M,fallbacks:x.value};k.value&&e.editModel?.id&&(O.id=e.editModel.id,C.value&&C.value!==y.value&&(O.originalName=C.value)),c("save",O)},handleCancel:()=>{N(),c("update:modelValue",!1)},Modal:Ve,SelectInput:xe,ExposedSelectList:kg,ModelSelectorInput:Sg};return Object.defineProperty(q,"__isScriptSetup",{enumerable:!1,value:!0}),q}}),Mg={class:"space-y-4"},Ig={key:0},Vg={key:1},Ag=["value"],Pg={key:0,class:"mt-1 text-xs text-red-500"},Eg={key:1,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Og={class:"px-1 py-0.5 bg-gray-100 dark:bg-gray-800 rounded"},jg={key:2,class:"mt-1 text-xs text-gray-500 dark:text-gray-400"},Lg={key:2},Dg={key:3},Ug={class:"flex justify-end gap-2"},qg=["disabled"];function Ng(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[4]||(t[4]=r=>u.$emit("update:modelValue",r)),title:e.isEditMode?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":e.hasChanges},{footer:ae(()=>[o("div",Ug,[o("button",{onClick:e.handleCancel,type:"button",class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSubmit,type:"button",class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity",disabled:!e.selectedProvider||!e.selectedModel},b(e.isEditMode?"Update Model":"Add Model"),9,qg)])]),default:ae(()=>[o("div",Mg,[S(e.SelectInput,{modelValue:e.selectedProvider,"onUpdate:modelValue":t[0]||(t[0]=r=>e.selectedProvider=r),options:e.providerOptions,label:"Provider",placeholder:"Select a provider",disabled:e.loadingProviders||e.isEditMode&&!!e.props.editModel},null,8,["modelValue","options","disabled"]),e.selectedProvider?(s(),l("div",Ig,[S(e.SelectInput,{modelValue:e.selectedModel,"onUpdate:modelValue":t[1]||(t[1]=r=>e.selectedModel=r),options:e.modelOptions,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:e.loadingModels},null,8,["modelValue","options","loading"])])):i("v-if",!0),i(" Name field (shown after model selection) "),e.selectedModel?(s(),l("div",Vg,[t[6]||(t[6]=o("label",{class:"block text-sm font-medium mb-2"},"Name",-1)),o("input",{value:e.modelName,onInput:e.handleNameInput,type:"text",class:ee(["w-full px-3 py-2 text-sm border rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent",e.nameError?"border-red-500":"border-gray-300 dark:border-gray-600"]),placeholder:"e.g., coding_model, planning_model, fast_response"},null,42,Ag),e.nameError?(s(),l("p",Pg,b(e.nameError),1)):e.modelName?(s(),l("p",Eg,[t[5]||(t[5]=ie(" Will be saved as: ",-1)),o("code",Og,b(e.modelName),1)])):(s(),l("p",jg," A descriptive name for this model (e.g., coding_model, planning_model). This becomes the filename and reference ID. "))])):i("v-if",!0),e.selectedModel&&e.isOpenRouter?(s(),l("div",Lg,[t[7]||(t[7]=o("label",{class:"block text-sm font-medium mb-2"}," Available Providers ",-1)),S(e.ExposedSelectList,{modelValue:e.selectedEndpoints,"onUpdate:modelValue":t[2]||(t[2]=r=>e.selectedEndpoints=r),providers:e.endpoints,loading:e.loadingEndpoints},null,8,["modelValue","providers","loading"]),t[8]||(t[8]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Select which providers can be used for this model ",-1))])):i("v-if",!0),i(" Fallback Models Section "),e.selectedModel?(s(),l("div",Dg,[S(e.ModelSelectorInput,{modelValue:e.fallbackModels,"onUpdate:modelValue":t[3]||(t[3]=r=>e.fallbackModels=r),label:"Fallback Models",placeholder:"Add fallback model...","allow-multiple":!0},null,8,["modelValue"]),t[9]||(t[9]=o("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," Fallback models will be used in order if the primary model fails ",-1))])):i("v-if",!0)])]),_:1},8,["model-value","title","has-changes"])}const Bg=Q(Tg,[["render",Ng],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/ModelModal.vue"]]),Rg=$({__name:"ModelsView",setup(u,{expose:t}){t();const a=m(!1),e=m([]),c=m(!1),d=m(null),r=m("add"),n=[{key:"name",label:"Name",width:"w-1/4"},{key:"model",label:"Model",width:"w-1/4"},{key:"provider",label:"Provider",width:"w-1/4"},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],p=[{icon:"edit",label:"Edit",handler:w=>{d.value=w,r.value="edit",a.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",handler:async w=>{await f(w.id)}}],v=async()=>{c.value=!0;try{const w=await fetch(J("/api/models"));if(!w.ok)throw new Error("Failed to fetch models");const x=await w.json();e.value=x.models||[]}catch(w){console.error("Error fetching models:",w),e.value=[]}finally{c.value=!1}},g=async w=>{try{if(d.value){const{originalName:x,...k}=w,C=x||d.value.id,y=await fetch(J(`/api/models/${C}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(!y.ok){const _=await y.json();alert(_.error||"Failed to update model");return}}else{const x=await fetch(J("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!x.ok){const k=await x.json();alert(k.error||"Failed to add model");return}}await v(),a.value=!1,d.value=null,r.value="add"}catch(x){console.error("Error saving model:",x),alert("Failed to save model")}},f=async w=>{try{const x=await fetch(J(`/api/models/${w}`),{method:"DELETE"});if(!x.ok){const k=await x.json();alert(k.error||"Failed to delete model");return}await v()}catch(x){console.error("Error deleting model:",x),alert("Failed to delete model")}};ce(()=>{v()});const h={showModal:a,models:e,loading:c,editingModel:d,modalMode:r,columns:n,actions:p,fetchModels:v,handleAddModel:g,deleteModel:f,ModelModal:Bg,DataTable:Oe,get getModelIcon(){return dt}};return Object.defineProperty(h,"__isScriptSetup",{enumerable:!1,value:!0}),h}}),Fg={class:"p-8"},zg={class:"flex justify-between items-center mb-6"},Hg={class:"flex items-center gap-2"},Wg=["src","alt"],Jg={class:"text-sm text-gray-600 dark:text-gray-400 font-mono"},Kg={key:0,class:"space-y-0.5"},Zg=["title"],Gg={class:"shrink-0 font-mono pr-2"},Xg=["src","alt"],Qg={class:"truncate"},Yg={key:1,class:"text-gray-400 dark:text-gray-600 text-sm"};function $g(u,t,a,e,c,d){return s(),l("div",Fg,[o("div",zg,[t[3]||(t[3]=o("h1",{class:"text-3xl font-bold"},"Models",-1)),o("button",{onClick:t[0]||(t[0]=()=>{e.modalMode="add",e.editingModel=null,e.showModal=!0}),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Model ")]),t[4]||(t[4]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-8"}," Configure AI models from your connected providers. Models define which AI capabilities are available to your agents. ",-1)),S(e.DataTable,{columns:e.columns,data:e.models,actions:e.actions,loading:e.loading,"empty-message":"No models configured yet. Add your first model to get started."},{"cell-name":ae(({value:r,row:n})=>[o("div",Hg,[e.getModelIcon(n.model,n.provider)?(s(),l("img",{key:0,src:e.getModelIcon(n.model,n.provider),class:"w-5 h-5 shrink-0",alt:n.provider},null,8,Wg)):i("v-if",!0),o("span",null,b(r),1)])]),"cell-model":ae(({value:r})=>[o("span",Jg,b(r||"—"),1)]),"cell-fallbacks":ae(({value:r})=>[r&&r.length>0?(s(),l("div",Kg,[(s(!0),l(W,null,ne(r,(n,p)=>(s(),l("div",{key:n.id,class:"text-sm text-gray-600 dark:text-gray-400 flex items-center",title:n.name},[o("span",Gg,b(p===r.length-1?"└─":"├─"),1),e.getModelIcon(n.model,n.provider)?(s(),l("img",{key:0,src:e.getModelIcon(n.model,n.provider),class:"w-4 h-4 shrink-0 mr-1.5",alt:n.provider},null,8,Xg)):i("v-if",!0),o("span",Qg,b(n.name),1)],8,Zg))),128))])):(s(),l("span",Yg," None "))]),_:1},8,["data","loading"]),i(" Model Modal "),S(e.ModelModal,{modelValue:e.showModal,"onUpdate:modelValue":[t[1]||(t[1]=r=>e.showModal=r),t[2]||(t[2]=r=>{e.showModal=r,r||(e.editingModel=null,e.modalMode="add")})],"edit-model":e.editingModel,mode:e.modalMode,onSave:e.handleAddModel},null,8,["modelValue","edit-model","mode"])])}const e1=Q(Rg,[["render",$g],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ModelsView.vue"]]),t1=$({__name:"AddProviderModal",props:{modelValue:{type:Boolean,required:!0}},emits:["update:modelValue","save"],setup(u,{expose:t,emit:a}){t();const e=a,c=m({name:"",type:"",apiKey:"",baseUrl:""}),d=[{value:"openai",label:"OpenAI",icon:Je,sdk:"openai-sdk"},{value:"openrouter",label:"OpenRouter",icon:at,sdk:"openrouter"}],r=y=>y==="openai-sdk"||y==="openai"?Je:y==="openrouter"?at:null,n=m(!1),p=z(()=>d.find(y=>y.value===c.value.type)),v=()=>{setTimeout(()=>{n.value=!1},200)},g=m({});oe(()=>c.value.type,y=>{if(y&&!c.value.name){const _=d.find(V=>V.value===y);_&&(c.value.name=_.label)}});const f=z(()=>c.value.type==="custom"||c.value.type==="openai"),h=()=>{g.value={};let y=!0;return c.value.name||(g.value.name="Provider name is required",y=!1),c.value.type||(g.value.type="Provider type is required",y=!1),c.value.apiKey||(g.value.apiKey="API key is required",y=!1),f.value&&c.value.type==="custom"&&!c.value.baseUrl&&(g.value.baseUrl="Base URL is required for custom providers",y=!1),y},w=()=>{h()&&(e("save",{...c.value}),k(),e("update:modelValue",!1))},x=()=>{k(),e("update:modelValue",!1)},k=()=>{c.value={name:"",type:"",apiKey:""},g.value={}},C={emit:e,formData:c,providerTypes:d,getProviderIcon:r,isDropdownOpen:n,selectedProvider:p,handleDropdownBlur:v,errors:g,showBaseUrl:f,validateForm:h,handleSave:w,handleCancel:x,resetForm:k,Modal:Ve,TextInput:je};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),o1={class:"space-y-4"},r1={class:"space-y-1"},a1={class:"relative"},s1={key:0,class:"flex items-center gap-2"},l1=["src","alt"],n1={key:1,class:"text-gray-500"},i1={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-black dark:border-white rounded shadow-lg"},d1=["onClick"],c1=["src","alt"],u1={key:0,class:"text-xs text-red-500 dark:text-red-400"};function p1(u,t,a,e,c,d){return s(),X(e.Modal,{"model-value":a.modelValue,"onUpdate:modelValue":t[4]||(t[4]=r=>u.$emit("update:modelValue",r)),title:"Add Provider",width:"max-w-md"},{footer:ae(()=>[o("div",{class:"flex gap-2 justify-end"},[o("button",{onClick:e.handleCancel,class:"px-3 py-1.5 text-sm border border-black dark:border-white rounded font-medium hover:bg-black/5 dark:hover:bg-white/10 transition-colors"}," Cancel "),o("button",{onClick:e.handleSave,class:"px-3 py-1.5 text-sm bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")])]),default:ae(()=>[o("div",o1,[o("div",r1,[t[6]||(t[6]=o("label",{class:"block text-sm font-medium"},[ie(" Provider Type "),o("span",{class:"text-red-500"},"*")],-1)),o("div",a1,[o("button",{type:"button",onClick:t[0]||(t[0]=r=>e.isDropdownOpen=!e.isDropdownOpen),onBlur:e.handleDropdownBlur,class:ee(["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm text-left focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white transition-colors",[e.errors.type?"border-red-500 dark:border-red-400":"border-black dark:border-white"]])},[e.selectedProvider?(s(),l("div",s1,[o("img",{src:e.selectedProvider.icon,alt:e.selectedProvider.label,class:"w-5 h-5"},null,8,l1),o("span",null,b(e.selectedProvider.label),1)])):(s(),l("span",n1,"Select a provider")),t[5]||(t[5]=o("div",{class:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none"},[o("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})])],-1))],34),e.isDropdownOpen?(s(),l("div",i1,[(s(),l(W,null,ne(e.providerTypes,r=>o("button",{key:r.value,type:"button",onClick:n=>{e.formData.type=r.value,e.isDropdownOpen=!1},class:"w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-center gap-2"},[o("img",{src:r.icon,alt:r.label,class:"w-5 h-5"},null,8,c1),o("span",null,b(r.label),1)],8,d1)),64))])):i("v-if",!0)]),e.errors.type?(s(),l("p",u1,b(e.errors.type),1)):i("v-if",!0)]),S(e.TextInput,{modelValue:e.formData.name,"onUpdate:modelValue":t[1]||(t[1]=r=>e.formData.name=r),label:"Provider Name",placeholder:"e.g., My OpenAI Provider",error:e.errors.name,required:""},null,8,["modelValue","error"]),S(e.TextInput,{modelValue:e.formData.apiKey,"onUpdate:modelValue":t[2]||(t[2]=r=>e.formData.apiKey=r),label:"API Key",type:"password",placeholder:"sk-...",error:e.errors.apiKey,required:""},null,8,["modelValue","error"]),e.showBaseUrl?(s(),X(e.TextInput,{key:0,modelValue:e.formData.baseUrl,"onUpdate:modelValue":t[3]||(t[3]=r=>e.formData.baseUrl=r),label:"Base URL",placeholder:"https://api.example.com",error:e.errors.baseUrl,required:e.formData.type==="custom"},null,8,["modelValue","error","required"])):i("v-if",!0)])]),_:1},8,["model-value"])}const m1=Q(t1,[["render",p1],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/AddProviderModal.vue"]]),g1=$({__name:"ProvidersView",setup(u,{expose:t}){t();const a=m(!1),e=m([]),c=m(!1),d=[{key:"name",label:"Name",width:"w-1/3"},{key:"sdk",label:"SDK Type",width:"w-1/3",formatter:f=>({"openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"})[f]||f},{key:"hasApiKey",label:"API Key",width:"w-1/3",formatter:f=>f?"✓ Configured":"✗ Not configured"}],r=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",handler:async f=>{await v(f.name)}}],n=async()=>{c.value=!0;try{const f=await fetch(J("/api/providers"));if(!f.ok)throw new Error("Failed to fetch providers");const h=await f.json();e.value=h.providers||[]}catch(f){console.error("Error fetching providers:",f),e.value=[]}finally{c.value=!1}},p=async f=>{try{const h=await fetch(J("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){const w=await h.json();alert(w.error||"Failed to add provider");return}await n(),a.value=!1}catch(h){console.error("Error adding provider:",h),alert("Failed to add provider")}},v=async f=>{try{const h=await fetch(J(`/api/providers/${encodeURIComponent(f)}`),{method:"DELETE"});if(!h.ok){const w=await h.json();w.modelCount?alert(`${w.error}
13
13
 
14
- This provider has ${w.modelCount} associated model(s).`):alert(w.error||"Failed to delete provider");return}await n()}catch(h){console.error("Error deleting provider:",h),alert("Failed to delete provider")}};ce(()=>{n()});const g={showAddModal:a,providers:e,loading:c,columns:d,actions:r,fetchProviders:n,handleAddProvider:p,deleteProvider:v,AddProviderModal:m1,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),f1={class:"p-8"},h1={class:"flex justify-between items-center mb-6"};function v1(u,t,a,e,c,d){return s(),l("div",f1,[o("div",h1,[t[2]||(t[2]=o("h1",{class:"text-3xl font-bold"},"Providers",-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")]),t[3]||(t[3]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-8"}," Manage API providers and authentication keys. All API keys are encrypted at rest. ",-1)),S(e.DataTable,{columns:e.columns,data:e.providers,actions:e.actions,loading:e.loading,"empty-message":"No providers configured yet. Add your first provider to get started."},null,8,["data","loading"]),i(" Add Provider Modal "),S(e.AddProviderModal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[1]||(t[1]=r=>e.showAddModal=r),onSave:e.handleAddProvider},null,8,["modelValue"])])}const b1=Q(g1,[["render",v1],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ProvidersView.vue"]]),y1=$({__name:"JsonViewer",props:{value:{type:null,required:!0}},setup(u,{expose:t}){t();const a=u;function e(n){return n.replace(/"([^"\\]|\\.)*"/g,p=>`<span class="json-string">${c(p)}</span>`).replace(/\b(-?\d+\.?\d*)\b/g,'<span class="json-number">$1</span>').replace(/\b(true|false|null)\b/g,'<span class="json-boolean">$1</span>')}function c(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const d=z(()=>{try{const n=JSON.stringify(a.value,null,2);return e(n)}catch{return c(String(a.value))}}),r={props:a,highlightJson:e,escapeHtml:c,formattedJson:d};return Object.defineProperty(r,"__isScriptSetup",{enumerable:!1,value:!0}),r}}),x1={class:"json-viewer overflow-auto"},k1=["innerHTML"];function _1(u,t,a,e,c,d){return s(),l("div",x1,[o("pre",{class:"p-4 text-sm font-mono leading-relaxed",innerHTML:e.formattedJson},null,8,k1)])}const w1=Q(y1,[["render",_1],["__scopeId","data-v-01a533a8"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/JsonViewer.vue"]]),C1={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function S1(u,t){return s(),l("svg",C1,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}const T1=ge({name:"lucide-info",render:S1}),M1={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function I1(u,t){return s(),l("svg",M1,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const V1=ge({name:"lucide-triangle-alert",render:I1}),A1=$({__name:"ToolsView",setup(u,{expose:t}){t();const a=m(null),e=m(!1),{data:c}=ve(J("/api/config")).json(),{data:d,error:r,isFetching:n,execute:p}=ve(J("/api/tools?type=tools"),{immediate:!1}).json(),{data:v,error:g,isFetching:f,execute:h}=ve(J("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:w,error:x,isFetching:k,execute:C}=ve(J("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:y,error:_,isFetching:I,execute:U}=ve(()=>a.value?J(`/api/tools/${a.value.name}`):null,{immediate:!1}).json(),L=m([]),j=m([]),F=m([]),K=async A=>{a.value=A,await U(),y.value?a.value={...A,schema:y.value.schema||null}:_.value&&console.error("Error fetching tool schema:",_.value),e.value=!0},D=async A=>{if(a.value=A,e.value=!0,!A.schema&&A.type==="prompt"){const B=await fetch(J("/api/tools?type=prompts&schema=true"));if(B.ok){const te=await B.json();te[A.name]&&(a.value={...A,schema:te[A.name].schema||null})}}},E=[{key:"name",label:"Prompt Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6"}],H=[{key:"name",label:"Tool Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],R=A=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(A)||/^[a-z]$/.test(A),N=A=>A.hasError&&A.error?A.error:A.description||"No description available",Z=()=>{d.value&&(L.value=Object.entries(d.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:null,hasError:B.hasError||!1,error:B.error,type:B.type||"tool"})))},G=()=>{v.value&&(j.value=Object.entries(v.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:B.schema||null,hasError:!1,type:"prompt",model:B.model})))},P=()=>{w.value&&(F.value=Object.entries(w.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:B.schema||null,hasError:!1,type:"agent",model:B.model})))},V=async()=>{await p(),Z()},T=async()=>{await h(),G()},q=async()=>{await C(),P()},M=()=>{e.value=!1,a.value=null};ce(()=>{V(),T(),q()});const O={selectedTool:a,showSchemaModal:e,configData:c,toolsData:d,error:r,isFetching:n,execute:p,promptsData:v,promptsError:g,isFetchingPrompts:f,executePrompts:h,agentsData:w,agentsError:x,isFetchingAgents:k,executeAgents:C,toolSchemaData:y,toolSchemaError:_,isFetchingSchema:I,executeToolSchema:U,tools:L,prompts:j,agents:F,openSchema:K,openPromptSchema:D,promptColumns:E,columns:H,isSnakeCase:R,getDescription:N,processToolsData:Z,processPromptsData:G,processAgentsData:P,fetchTools:V,fetchPrompts:T,fetchAgents:q,closeModal:M,DataTable:Oe,Modal:Ve,JsonViewer:w1,get IconInfo(){return T1},get IconEye(){return Vt},get IconTriangleAlert(){return V1}};return Object.defineProperty(O,"__isScriptSetup",{enumerable:!1,value:!0}),O}}),P1={class:"p-8"},E1={class:"mb-6 p-4 border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},O1={class:"flex items-start gap-3"},j1={class:"text-sm"},L1={class:"font-medium mb-1"},D1={class:"px-1.5 py-0.5 bg-black/10 dark:bg-white/10 rounded font-mono text-xs"},U1=["onClick"],q1={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},N1={key:2,class:"relative group"},B1={key:3,class:"relative group"},R1={class:"flex justify-end"},F1=["onClick"],z1={key:1,class:"text-gray-400 text-sm"},H1={class:"mt-12"},W1=["onClick"],J1={class:"text-gray-600 dark:text-gray-400"},K1={class:"text-sm text-gray-500 dark:text-gray-400"},Z1={class:"mt-12"},G1=["onClick"],X1={class:"text-gray-600 dark:text-gray-400"},Q1={class:"text-sm text-gray-500 dark:text-gray-400"},Y1={class:"flex items-center gap-2"},$1={key:0,class:"space-y-4"},ef={class:"text-lg font-medium mb-2"},tf={class:"text-sm text-gray-600 dark:text-gray-400 mb-4"},of={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"};function rf(u,t,a,e,c,d){return s(),l("div",P1,[t[11]||(t[11]=o("div",{class:"flex justify-between items-center mb-6"},[o("h1",{class:"text-3xl font-bold"},"Tools")],-1)),t[12]||(t[12]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are four types of tools: functions, prompts, agents, and MCP tools. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. MCP tools are tools that are exposed via third party MCP servers. ",-1)),i(" Info banner "),o("div",E1,[o("div",O1,[S(e.IconInfo,{class:"w-5 h-5 mt-0.5 text-black/60 dark:text-white/60 flex-shrink-0"}),o("div",j1,[o("p",L1,[t[1]||(t[1]=ie(" To create or modify tools, edit the ",-1)),o("code",D1,b(e.configData?.toolsDir||"agentbuilder/tools")+"/",1),t[2]||(t[2]=ie(" directory of your codebase. ",-1))]),t[3]||(t[3]=o("p",{class:"text-black/70 dark:text-white/70"}," Changes will be automatically detected. ",-1))])])]),S(e.DataTable,{columns:e.columns,data:e.tools,loading:e.isFetching,"empty-message":`No tools found. Add tool files to the ${e.configData?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":ae(({row:r})=>[o("div",{class:ee(["flex items-center gap-2",{"text-red-600 dark:text-red-400":r.hasError}])},[r.hasError?(s(),l("span",q1,b(r.name),1)):(s(),l("button",{key:0,onClick:n=>e.openSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,U1)),r.hasError?(s(),l("div",N1,[S(e.IconTriangleAlert,{class:"w-4 h-4 text-red-500"}),t[4]||(t[4]=o("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ie(" This tool has validation errors "),o("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))])):e.isSnakeCase(r.name)?i("v-if",!0):(s(),l("div",B1,[S(e.IconTriangleAlert,{class:"w-4 h-4 text-amber-500"}),t[5]||(t[5]=o("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ie(" Tool name should be in snake_case format (e.g., 'log_name', 'send_email') "),o("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))]))],2)]),"cell-description":ae(({row:r})=>[o("span",{class:ee({"text-red-600 dark:text-red-400":r.hasError,"text-gray-600 dark:text-gray-400":!r.hasError})},b(e.getDescription(r)),3)]),"cell-actions":ae(({row:r})=>[o("div",R1,[r.hasError?(s(),l("span",z1,"—")):(s(),l("button",{key:0,onClick:n=>e.openSchema(r),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[S(e.IconEye,{class:"w-4 h-4"})],8,F1))])]),_:1},8,["data","loading","empty-message"]),i(" Prompts Section "),o("div",H1,[t[6]||(t[6]=o("h2",{class:"text-2xl font-bold mb-4"},"Prompts",-1)),t[7]||(t[7]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains. ",-1)),S(e.DataTable,{columns:e.promptColumns,data:e.prompts,loading:e.isFetchingPrompts,"empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":ae(({row:r})=>[o("button",{onClick:n=>e.openPromptSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,W1)]),"cell-description":ae(({row:r})=>[o("span",J1,b(r.description),1)]),"cell-model":ae(({row:r})=>[o("span",K1,b(r.model||"-"),1)]),_:1},8,["data","loading"])]),i(" Agents Section "),o("div",Z1,[t[8]||(t[8]=o("h2",{class:"text-2xl font-bold mb-4"},"Agents",-1)),t[9]||(t[9]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema. ",-1)),S(e.DataTable,{columns:e.promptColumns,data:e.agents,loading:e.isFetchingAgents,"empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":ae(({row:r})=>[o("button",{onClick:n=>e.openPromptSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,G1)]),"cell-description":ae(({row:r})=>[o("span",X1,b(r.description),1)]),"cell-model":ae(({row:r})=>[o("span",Q1,b(r.model||"-"),1)]),_:1},8,["data","loading"])]),i(" Schema Modal "),S(e.Modal,{modelValue:e.showSchemaModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showSchemaModal=r),onClose:e.closeModal,width:"max-w-4xl"},{header:ae(()=>[o("div",Y1,[S(e.IconEye,{class:"w-5 h-5"}),o("span",null,b(e.selectedTool?.name)+" Schema",1)])]),footer:ae(()=>[o("button",{onClick:e.closeModal,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Close ")]),default:ae(()=>[e.selectedTool?(s(),l("div",$1,[o("div",null,[o("h3",ef,b(e.selectedTool.type==="prompt"?"Required Schema":"JSON Schema"),1),o("p",tf,b(e.selectedTool.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),e.selectedTool.schema===null?(s(),l("div",of,[...t[10]||(t[10]=[o("p",{class:"text-gray-500 dark:text-gray-400"}," No parameters required ",-1)])])):(s(),X(e.JsonViewer,{key:1,value:e.selectedTool.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):i("v-if",!0)]),_:1},8,["modelValue"])])}const af=Q(A1,[["render",rf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ToolsView.vue"]]),sf=$({__name:"UsersView",setup(u,{expose:t}){t();const a=m(!1),e=m(!1),c=m([]),d=m(!1),r=m(null),n=m({username:"",password:"",role:"admin"}),p=m({username:"",password:"",role:"admin"}),v=[{value:"admin",label:"Admin"}],g=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:y=>new Date(y*1e3).toLocaleString()}],f=[{icon:"edit",label:"Edit",handler:async y=>{r.value=y,p.value={username:y.username,password:"",role:y.role},e.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async y=>{await k(y.id)}}],h=async()=>{d.value=!0;try{const y=await Ie("/users");if(!y.ok)throw new Error("Failed to fetch users");const _=await y.json();c.value=_.users||[]}catch(y){console.error("Error fetching users:",y),c.value=[]}finally{d.value=!1}},w=async()=>{if(!n.value.username||!n.value.password){alert("Username and password are required");return}try{const y=await Ie("/users",{method:"POST",body:JSON.stringify(n.value)});if(!y.ok){const _=await y.json();alert(_.error||"Failed to add user");return}await h(),a.value=!1,n.value={username:"",password:"",role:"admin"}}catch(y){console.error("Error adding user:",y),alert("Failed to add user")}},x=async()=>{if(!p.value.username){alert("Username is required");return}try{const y={username:p.value.username,role:p.value.role};p.value.password&&(y.password=p.value.password);const _=await Ie(`/users/${r.value.id}`,{method:"PUT",body:JSON.stringify(y)});if(!_.ok){const I=await _.json();alert(I.error||"Failed to update user");return}await h(),e.value=!1,r.value=null}catch(y){console.error("Error updating user:",y),alert("Failed to update user")}},k=async y=>{try{const _=await Ie(`/users/${y}`,{method:"DELETE"});if(!_.ok){const I=await _.json();alert(I.error||"Failed to delete user");return}await h()}catch(_){console.error("Error deleting user:",_),alert("Failed to delete user")}};ce(()=>{h()});const C={showAddModal:a,showEditModal:e,users:c,loading:d,editingUser:r,newUser:n,editUser:p,roleOptions:v,columns:g,actions:f,fetchUsers:h,handleAddUser:w,handleEditUser:x,deleteUser:k,DataTable:Oe,Modal:Ve,SelectInput:xe};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),lf={class:"p-8"},nf={class:"flex justify-between items-center mb-6"},df={class:"flex justify-end gap-2 mt-4"},cf={class:"flex justify-end gap-2 mt-4"};function uf(u,t,a,e,c,d){return s(),l("div",lf,[o("div",nf,[t[13]||(t[13]=o("div",null,[o("h1",{class:"text-3xl font-bold"},"Users"),o("p",{class:"text-gray-600 dark:text-gray-400 mt-2"},"Manage user accounts and permissions")],-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ")]),S(e.DataTable,{columns:e.columns,data:e.users,actions:e.actions,loading:e.loading,"empty-message":"No users found"},null,8,["data","loading"]),i(" Add User Modal "),S(e.Modal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[5]||(t[5]=r=>e.showAddModal=r),title:"Add User",onClose:t[6]||(t[6]=r=>e.showAddModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleAddUser,["prevent"]),class:"space-y-4"},[o("div",null,[t[14]||(t[14]=o("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),fe(o("input",{"onUpdate:modelValue":t[1]||(t[1]=r=>e.newUser.username=r),type:"text",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newUser.username]])]),o("div",null,[t[15]||(t[15]=o("label",{class:"block text-sm font-medium mb-1"},"Password",-1)),fe(o("input",{"onUpdate:modelValue":t[2]||(t[2]=r=>e.newUser.password=r),type:"password",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newUser.password]])]),o("div",null,[S(e.SelectInput,{modelValue:e.newUser.role,"onUpdate:modelValue":t[3]||(t[3]=r=>e.newUser.role=r),options:e.roleOptions,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),o("div",df,[o("button",{type:"button",onClick:t[4]||(t[4]=r=>e.showAddModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[16]||(t[16]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ",-1))])],32)]),_:1},8,["modelValue"]),i(" Edit User Modal "),S(e.Modal,{modelValue:e.showEditModal,"onUpdate:modelValue":t[11]||(t[11]=r=>e.showEditModal=r),title:"Edit User",onClose:t[12]||(t[12]=r=>e.showEditModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleEditUser,["prevent"]),class:"space-y-4"},[o("div",null,[t[17]||(t[17]=o("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),fe(o("input",{"onUpdate:modelValue":t[7]||(t[7]=r=>e.editUser.username=r),type:"text",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.editUser.username]])]),o("div",null,[t[18]||(t[18]=o("label",{class:"block text-sm font-medium mb-1"},"Password (leave blank to keep current)",-1)),fe(o("input",{"onUpdate:modelValue":t[8]||(t[8]=r=>e.editUser.password=r),type:"password",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.editUser.password]])]),o("div",null,[S(e.SelectInput,{modelValue:e.editUser.role,"onUpdate:modelValue":t[9]||(t[9]=r=>e.editUser.role=r),options:e.roleOptions,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),o("div",cf,[o("button",{type:"button",onClick:t[10]||(t[10]=r=>e.showEditModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[19]||(t[19]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Update User ",-1))])],32)]),_:1},8,["modelValue"])])}const pf=Q(sf,[["render",uf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/UsersView.vue"]]),mf=$({__name:"ApiKeysView",setup(u,{expose:t}){t();const a=m(!1),e=m(!1),c=m([]),d=m(!1),r=m(""),n=m({name:""}),p=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:k=>`<code class="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-sm">${k}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:k=>new Date(k*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:k=>k?new Date(k*1e3).toLocaleDateString():"Never"}],v=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async k=>{await h(k.id)}}],g=async()=>{d.value=!0;try{const k=await Ie("/api-keys");if(!k.ok)throw new Error("Failed to fetch API keys");const C=await k.json();c.value=(C.keys||[]).map(y=>({...y,keyPreview:`${y.key_prefix}...${y.last_five}`,createdAt:y.created_at,lastUsedAt:y.last_used_at}))}catch(k){console.error("Error fetching API keys:",k),c.value=[]}finally{d.value=!1}},f=async()=>{if(!n.value.name){alert("Name is required");return}try{const k=await Ie("/api-keys",{method:"POST",body:JSON.stringify(n.value)}),C=await k.json();if(!k.ok){alert(C.error||"Failed to create API key");return}r.value=C.key,a.value=!1,e.value=!0,await g(),n.value={name:""}}catch(k){console.error("Error creating API key:",k),alert("Failed to create API key")}},h=async k=>{try{const C=await Ie(`/api-keys/${k}`,{method:"DELETE"});if(!C.ok){const y=await C.json();alert(y.error||"Failed to delete API key");return}await g()}catch(C){console.error("Error deleting API key:",C),alert("Failed to delete API key")}},w=async k=>{try{await navigator.clipboard.writeText(k),alert("API key copied to clipboard!")}catch(C){console.error("Failed to copy:",C)}};ce(()=>{g()});const x={showAddModal:a,showKeyModal:e,apiKeys:c,loading:d,newApiKey:r,newKeyData:n,columns:p,actions:v,fetchApiKeys:g,handleAddApiKey:f,deleteApiKey:h,copyToClipboard:w,DataTable:Oe,Modal:Ve};return Object.defineProperty(x,"__isScriptSetup",{enumerable:!1,value:!0}),x}}),gf={class:"p-8"},ff={class:"flex justify-between items-center mb-6"},hf={class:"flex justify-end gap-2 mt-4"},vf={class:"space-y-4"},bf={class:"flex gap-2"},yf=["value"],xf={class:"bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-800 text-blue-800 dark:text-blue-400 px-4 py-3 rounded"},kf={class:"block mt-2 bg-white dark:bg-gray-800 px-3 py-2 rounded text-xs"},_f={class:"flex justify-end mt-4"};function wf(u,t,a,e,c,d){return s(),l("div",gf,[o("div",ff,[t[9]||(t[9]=o("div",null,[o("h1",{class:"text-3xl font-bold"},"API Keys"),o("p",{class:"text-gray-600 dark:text-gray-400 mt-2"},"Manage API keys for programmatic access")],-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create API Key ")]),S(e.DataTable,{columns:e.columns,data:e.apiKeys,actions:e.actions,loading:e.loading,"empty-message":"No API keys found"},null,8,["data","loading"]),i(" Add API Key Modal "),S(e.Modal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[3]||(t[3]=r=>e.showAddModal=r),title:"Create API Key",onClose:t[4]||(t[4]=r=>e.showAddModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleAddApiKey,["prevent"]),class:"space-y-4"},[o("div",null,[t[10]||(t[10]=o("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),fe(o("input",{"onUpdate:modelValue":t[1]||(t[1]=r=>e.newKeyData.name=r),type:"text",required:"",placeholder:"e.g., Production API Key",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newKeyData.name]]),t[11]||(t[11]=o("p",{class:"text-sm text-gray-500 dark:text-gray-400 mt-1"}," A descriptive name to help you identify this key ",-1))]),o("div",hf,[o("button",{type:"button",onClick:t[2]||(t[2]=r=>e.showAddModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[12]||(t[12]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create Key ",-1))])],32)]),_:1},8,["modelValue"]),i(" Show New API Key Modal "),S(e.Modal,{modelValue:e.showKeyModal,"onUpdate:modelValue":t[7]||(t[7]=r=>e.showKeyModal=r),title:"API Key Created",onClose:t[8]||(t[8]=r=>e.showKeyModal=!1)},{default:ae(()=>[o("div",vf,[t[15]||(t[15]=o("div",{class:"bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-800 text-yellow-800 dark:text-yellow-400 px-4 py-3 rounded"},[o("p",{class:"font-semibold"},"Important: Save this key now!"),o("p",{class:"text-sm mt-1"},"You won't be able to see it again. If you lose this key, you'll need to create a new one.")],-1)),o("div",null,[t[13]||(t[13]=o("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),o("div",bf,[o("input",{value:e.newApiKey,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700 font-mono text-sm"},null,8,yf),o("button",{onClick:t[5]||(t[5]=r=>e.copyToClipboard(e.newApiKey)),class:"px-4 py-2 bg-gray-200 dark:bg-gray-700 rounded hover:bg-gray-300 dark:hover:bg-gray-600"}," Copy ")])]),o("div",xf,[t[14]||(t[14]=o("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),o("code",kf," Authorization: Bearer "+b(e.newApiKey),1)]),o("div",_f,[o("button",{onClick:t[6]||(t[6]=r=>e.showKeyModal=!1),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Done ")])])]),_:1},8,["modelValue"])])}const Cf=Q(mf,[["render",wf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ApiKeysView.vue"]]),Sf=$({__name:"LoginView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(""),d=m(""),r=m(""),n=m(!1),p=m(!1),v=m(!1);ce(async()=>{const x=e.query.token,k=e.query.error;if(x){localStorage.setItem("auth_token",x),a.push("/");return}k&&(k==="oauth_failed"?r.value="OAuth authentication failed. Please try again.":k==="oauth_not_configured"&&(r.value="OAuth provider is not configured."));try{const C=await fetch(J("/api/auth/config"));if(C.ok){const y=await C.json();p.value=y.github||!1,v.value=y.google||!1}}catch(C){console.error("Failed to fetch auth config:",C)}});async function g(){r.value="",n.value=!0;try{const x=await fetch(J("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:c.value,password:d.value})}),k=await x.json();x.ok?(localStorage.setItem("auth_token",k.token),a.push("/")):r.value=k.error||"Login failed"}catch{r.value="Network error. Please try again."}finally{n.value=!1}}function f(){window.location.href=J("/api/auth/oauth/github")}function h(){window.location.href=J("/api/auth/oauth/google")}const w={router:a,route:e,username:c,password:d,error:r,loading:n,showGithubLogin:p,showGoogleLogin:v,handleLogin:g,handleGithubLogin:f,handleGoogleLogin:h,TextInput:je,DropShadow:Re};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),Tf={class:"min-h-screen flex items-center justify-center bg-white dark:bg-black px-4"},Mf={class:"max-w-md w-full space-y-8"},If={class:"bg-white dark:bg-black border border-black dark:border-white py-8 px-6"},Vf={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3"},Af=["disabled"],Pf={key:0,class:"mt-6"};function Ef(u,t,a,e,c,d){return s(),l("div",Tf,[o("div",Mf,[t[5]||(t[5]=o("div",null,[o("h2",{class:"mt-6 text-center text-3xl font-bold text-black dark:text-white"}," Sign in to AgentBuilder ")],-1)),S(e.DropShadow,{offsetX:8,offsetY:8,intensity:.5,pattern:"crosshatch"},{default:ae(()=>[o("div",If,[o("form",{class:"space-y-6",onSubmit:he(e.handleLogin,["prevent"])},[e.error?(s(),l("div",Vf,b(e.error),1)):i("v-if",!0),S(e.TextInput,{modelValue:e.username,"onUpdate:modelValue":t[0]||(t[0]=r=>e.username=r),label:"Username",type:"text",required:!0,disabled:e.loading,placeholder:"Enter your username"},null,8,["modelValue","disabled"]),S(e.TextInput,{modelValue:e.password,"onUpdate:modelValue":t[1]||(t[1]=r=>e.password=r),label:"Password",type:"password",required:!0,disabled:e.loading,placeholder:"Enter your password"},null,8,["modelValue","disabled"]),o("div",null,[o("button",{type:"submit",disabled:e.loading,class:"w-full px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed"},b(e.loading?"Signing in...":"Sign in"),9,Af)])],32),e.showGithubLogin||e.showGoogleLogin?(s(),l("div",Pf,[t[4]||(t[4]=o("div",{class:"relative"},[o("div",{class:"absolute inset-0 flex items-center"},[o("div",{class:"w-full border-t border-black dark:border-white"})]),o("div",{class:"relative flex justify-center text-sm"},[o("span",{class:"px-2 bg-white dark:bg-black text-black dark:text-white"},"Or continue with")])],-1)),o("div",{class:ee(["mt-6 grid gap-3",e.showGithubLogin&&e.showGoogleLogin?"grid-cols-2":"grid-cols-1"])},[e.showGithubLogin?(s(),l("button",{key:0,onClick:e.handleGithubLogin,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"},[...t[2]||(t[2]=[o("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[o("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),o("span",{class:"ml-2"},"GitHub",-1)])])):i("v-if",!0),e.showGoogleLogin?(s(),l("button",{key:1,onClick:e.handleGoogleLogin,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"},[...t[3]||(t[3]=[o("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[o("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),o("span",{class:"ml-2"},"Google",-1)])])):i("v-if",!0)],2)])):i("v-if",!0)])]),_:1})])])}const Of=Q(Sf,[["render",Ef],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/LoginView.vue"]]),jf=$({__name:"MultilineInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue","focus","blur"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(null),r=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-none overflow-hidden",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n=()=>{const h=d.value;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight+2}px`)},p=h=>{const w=h.target;c("update:modelValue",w.value),n()},v=h=>{c("focus",h)},g=h=>{c("blur",h)};ce(()=>{n()}),oe(()=>e.modelValue,async()=>{await pe(),n()}),t({textareaRef:d,adjustHeight:n});const f={props:e,emit:c,textareaRef:d,inputClasses:r,adjustHeight:n,handleInput:p,handleFocus:v,handleBlur:g};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),Lf={class:"space-y-1"},Df={key:0,class:"block text-sm font-medium"},Uf={key:0,class:"text-red-500"},qf=["value","placeholder","disabled"],Nf={key:1,class:"text-xs text-red-500 dark:text-red-400"};function Bf(u,t,a,e,c,d){return s(),l("div",Lf,[a.label?(s(),l("label",Df,[ie(b(a.label)+" ",1),a.required?(s(),l("span",Uf,"*")):i("v-if",!0)])):i("v-if",!0),o("textarea",{ref:"textareaRef",value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,class:ee(e.inputClasses),rows:"1",onInput:e.handleInput,onFocus:e.handleFocus,onBlur:e.handleBlur},null,42,qf),a.error?(s(),l("p",Nf,b(a.error),1)):i("v-if",!0)])}const Rf=Q(jf,[["render",Bf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/MultilineInput.vue"]]),Ff=$({__name:"TestView",setup(u,{expose:t}){t();const a=m(""),e=m(""),c=m(""),d=m(`Line 1
14
+ This provider has ${w.modelCount} associated model(s).`):alert(w.error||"Failed to delete provider");return}await n()}catch(h){console.error("Error deleting provider:",h),alert("Failed to delete provider")}};ce(()=>{n()});const g={showAddModal:a,providers:e,loading:c,columns:d,actions:r,fetchProviders:n,handleAddProvider:p,deleteProvider:v,AddProviderModal:m1,DataTable:Oe};return Object.defineProperty(g,"__isScriptSetup",{enumerable:!1,value:!0}),g}}),f1={class:"p-8"},h1={class:"flex justify-between items-center mb-6"};function v1(u,t,a,e,c,d){return s(),l("div",f1,[o("div",h1,[t[2]||(t[2]=o("h1",{class:"text-3xl font-bold"},"Providers",-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Add Provider ")]),t[3]||(t[3]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-8"}," Manage API providers and authentication keys. All API keys are encrypted at rest. ",-1)),S(e.DataTable,{columns:e.columns,data:e.providers,actions:e.actions,loading:e.loading,"empty-message":"No providers configured yet. Add your first provider to get started."},null,8,["data","loading"]),i(" Add Provider Modal "),S(e.AddProviderModal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[1]||(t[1]=r=>e.showAddModal=r),onSave:e.handleAddProvider},null,8,["modelValue"])])}const b1=Q(g1,[["render",v1],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ProvidersView.vue"]]),y1=$({__name:"JsonViewer",props:{value:{type:null,required:!0}},setup(u,{expose:t}){t();const a=u;function e(n){return n.replace(/"([^"\\]|\\.)*"/g,p=>`<span class="json-string">${c(p)}</span>`).replace(/\b(-?\d+\.?\d*)\b/g,'<span class="json-number">$1</span>').replace(/\b(true|false|null)\b/g,'<span class="json-boolean">$1</span>')}function c(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const d=z(()=>{try{const n=JSON.stringify(a.value,null,2);return e(n)}catch{return c(String(a.value))}}),r={props:a,highlightJson:e,escapeHtml:c,formattedJson:d};return Object.defineProperty(r,"__isScriptSetup",{enumerable:!1,value:!0}),r}}),x1={class:"json-viewer overflow-auto"},k1=["innerHTML"];function _1(u,t,a,e,c,d){return s(),l("div",x1,[o("pre",{class:"p-4 text-sm font-mono leading-relaxed",innerHTML:e.formattedJson},null,8,k1)])}const w1=Q(y1,[["render",_1],["__scopeId","data-v-01a533a8"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/JsonViewer.vue"]]),C1={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function S1(u,t){return s(),l("svg",C1,[...t[0]||(t[0]=[o("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}const T1=ge({name:"lucide-info",render:S1}),M1={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function I1(u,t){return s(),l("svg",M1,[...t[0]||(t[0]=[o("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const V1=ge({name:"lucide-triangle-alert",render:I1}),A1=$({__name:"ToolsView",setup(u,{expose:t}){t();const a=m(null),e=m(!1),{data:c}=ve(J("/api/config")).json(),{data:d,error:r,isFetching:n,execute:p}=ve(J("/api/tools?type=tools"),{immediate:!1}).json(),{data:v,error:g,isFetching:f,execute:h}=ve(J("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:w,error:x,isFetching:k,execute:C}=ve(J("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:y,error:_,isFetching:V,execute:U}=ve(()=>a.value?J(`/api/tools/${a.value.name}`):null,{immediate:!1}).json(),L=m([]),j=m([]),F=m([]),K=async A=>{a.value=A,await U(),y.value?a.value={...A,schema:y.value.schema||null}:_.value&&console.error("Error fetching tool schema:",_.value),e.value=!0},D=async A=>{if(a.value=A,e.value=!0,!A.schema&&A.type==="prompt"){const B=await fetch(J("/api/tools?type=prompts&schema=true"));if(B.ok){const te=await B.json();te[A.name]&&(a.value={...A,schema:te[A.name].schema||null})}}},E=[{key:"name",label:"Prompt Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6"}],H=[{key:"name",label:"Tool Name",width:"w-1/3"},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],R=A=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(A)||/^[a-z]$/.test(A),N=A=>A.hasError&&A.error?A.error:A.description||"No description available",Z=()=>{d.value&&(L.value=Object.entries(d.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:null,hasError:B.hasError||!1,error:B.error,type:B.type||"tool"})))},G=()=>{v.value&&(j.value=Object.entries(v.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:B.schema||null,hasError:!1,type:"prompt",model:B.model})))},P=()=>{w.value&&(F.value=Object.entries(w.value).map(([A,B])=>({name:A,description:B.description||"No description available",schema:B.schema||null,hasError:!1,type:"agent",model:B.model})))},I=async()=>{await p(),Z()},T=async()=>{await h(),G()},q=async()=>{await C(),P()},M=()=>{e.value=!1,a.value=null};ce(()=>{I(),T(),q()});const O={selectedTool:a,showSchemaModal:e,configData:c,toolsData:d,error:r,isFetching:n,execute:p,promptsData:v,promptsError:g,isFetchingPrompts:f,executePrompts:h,agentsData:w,agentsError:x,isFetchingAgents:k,executeAgents:C,toolSchemaData:y,toolSchemaError:_,isFetchingSchema:V,executeToolSchema:U,tools:L,prompts:j,agents:F,openSchema:K,openPromptSchema:D,promptColumns:E,columns:H,isSnakeCase:R,getDescription:N,processToolsData:Z,processPromptsData:G,processAgentsData:P,fetchTools:I,fetchPrompts:T,fetchAgents:q,closeModal:M,DataTable:Oe,Modal:Ve,JsonViewer:w1,get IconInfo(){return T1},get IconEye(){return Vt},get IconTriangleAlert(){return V1}};return Object.defineProperty(O,"__isScriptSetup",{enumerable:!1,value:!0}),O}}),P1={class:"p-8"},E1={class:"mb-6 p-4 border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},O1={class:"flex items-start gap-3"},j1={class:"text-sm"},L1={class:"font-medium mb-1"},D1={class:"px-1.5 py-0.5 bg-black/10 dark:bg-white/10 rounded font-mono text-xs"},U1=["onClick"],q1={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},N1={key:2,class:"relative group"},B1={key:3,class:"relative group"},R1={class:"flex justify-end"},F1=["onClick"],z1={key:1,class:"text-gray-400 text-sm"},H1={class:"mt-12"},W1=["onClick"],J1={class:"text-gray-600 dark:text-gray-400"},K1={class:"text-sm text-gray-500 dark:text-gray-400"},Z1={class:"mt-12"},G1=["onClick"],X1={class:"text-gray-600 dark:text-gray-400"},Q1={class:"text-sm text-gray-500 dark:text-gray-400"},Y1={class:"flex items-center gap-2"},$1={key:0,class:"space-y-4"},ef={class:"text-lg font-medium mb-2"},tf={class:"text-sm text-gray-600 dark:text-gray-400 mb-4"},of={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"};function rf(u,t,a,e,c,d){return s(),l("div",P1,[t[11]||(t[11]=o("div",{class:"flex justify-between items-center mb-6"},[o("h1",{class:"text-3xl font-bold"},"Tools")],-1)),t[12]||(t[12]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are four types of tools: functions, prompts, agents, and MCP tools. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. MCP tools are tools that are exposed via third party MCP servers. ",-1)),i(" Info banner "),o("div",E1,[o("div",O1,[S(e.IconInfo,{class:"w-5 h-5 mt-0.5 text-black/60 dark:text-white/60 flex-shrink-0"}),o("div",j1,[o("p",L1,[t[1]||(t[1]=ie(" To create or modify tools, edit the ",-1)),o("code",D1,b(e.configData?.toolsDir||"agentbuilder/tools")+"/",1),t[2]||(t[2]=ie(" directory of your codebase. ",-1))]),t[3]||(t[3]=o("p",{class:"text-black/70 dark:text-white/70"}," Changes will be automatically detected. ",-1))])])]),S(e.DataTable,{columns:e.columns,data:e.tools,loading:e.isFetching,"empty-message":`No tools found. Add tool files to the ${e.configData?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":ae(({row:r})=>[o("div",{class:ee(["flex items-center gap-2",{"text-red-600 dark:text-red-400":r.hasError}])},[r.hasError?(s(),l("span",q1,b(r.name),1)):(s(),l("button",{key:0,onClick:n=>e.openSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,U1)),r.hasError?(s(),l("div",N1,[S(e.IconTriangleAlert,{class:"w-4 h-4 text-red-500"}),t[4]||(t[4]=o("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ie(" This tool has validation errors "),o("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))])):e.isSnakeCase(r.name)?i("v-if",!0):(s(),l("div",B1,[S(e.IconTriangleAlert,{class:"w-4 h-4 text-amber-500"}),t[5]||(t[5]=o("div",{class:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-black dark:bg-white text-white dark:text-black text-xs rounded whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},[ie(" Tool name should be in snake_case format (e.g., 'log_name', 'send_email') "),o("div",{class:"absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-black dark:border-t-white"})],-1))]))],2)]),"cell-description":ae(({row:r})=>[o("span",{class:ee({"text-red-600 dark:text-red-400":r.hasError,"text-gray-600 dark:text-gray-400":!r.hasError})},b(e.getDescription(r)),3)]),"cell-actions":ae(({row:r})=>[o("div",R1,[r.hasError?(s(),l("span",z1,"—")):(s(),l("button",{key:0,onClick:n=>e.openSchema(r),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[S(e.IconEye,{class:"w-4 h-4"})],8,F1))])]),_:1},8,["data","loading","empty-message"]),i(" Prompts Section "),o("div",H1,[t[6]||(t[6]=o("h2",{class:"text-2xl font-bold mb-4"},"Prompts",-1)),t[7]||(t[7]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains. ",-1)),S(e.DataTable,{columns:e.promptColumns,data:e.prompts,loading:e.isFetchingPrompts,"empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":ae(({row:r})=>[o("button",{onClick:n=>e.openPromptSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,W1)]),"cell-description":ae(({row:r})=>[o("span",J1,b(r.description),1)]),"cell-model":ae(({row:r})=>[o("span",K1,b(r.model||"-"),1)]),_:1},8,["data","loading"])]),i(" Agents Section "),o("div",Z1,[t[8]||(t[8]=o("h2",{class:"text-2xl font-bold mb-4"},"Agents",-1)),t[9]||(t[9]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-6"}," Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema. ",-1)),S(e.DataTable,{columns:e.promptColumns,data:e.agents,loading:e.isFetchingAgents,"empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":ae(({row:r})=>[o("button",{onClick:n=>e.openPromptSchema(r),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},b(r.name),9,G1)]),"cell-description":ae(({row:r})=>[o("span",X1,b(r.description),1)]),"cell-model":ae(({row:r})=>[o("span",Q1,b(r.model||"-"),1)]),_:1},8,["data","loading"])]),i(" Schema Modal "),S(e.Modal,{modelValue:e.showSchemaModal,"onUpdate:modelValue":t[0]||(t[0]=r=>e.showSchemaModal=r),onClose:e.closeModal,width:"max-w-4xl"},{header:ae(()=>[o("div",Y1,[S(e.IconEye,{class:"w-5 h-5"}),o("span",null,b(e.selectedTool?.name)+" Schema",1)])]),footer:ae(()=>[o("button",{onClick:e.closeModal,class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"}," Close ")]),default:ae(()=>[e.selectedTool?(s(),l("div",$1,[o("div",null,[o("h3",ef,b(e.selectedTool.type==="prompt"?"Required Schema":"JSON Schema"),1),o("p",tf,b(e.selectedTool.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),e.selectedTool.schema===null?(s(),l("div",of,[...t[10]||(t[10]=[o("p",{class:"text-gray-500 dark:text-gray-400"}," No parameters required ",-1)])])):(s(),X(e.JsonViewer,{key:1,value:e.selectedTool.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):i("v-if",!0)]),_:1},8,["modelValue"])])}const af=Q(A1,[["render",rf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ToolsView.vue"]]),sf=$({__name:"UsersView",setup(u,{expose:t}){t();const a=m(!1),e=m(!1),c=m([]),d=m(!1),r=m(null),n=m({username:"",password:"",role:"admin"}),p=m({username:"",password:"",role:"admin"}),v=[{value:"admin",label:"Admin"}],g=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:y=>new Date(y*1e3).toLocaleString()}],f=[{icon:"edit",label:"Edit",handler:async y=>{r.value=y,p.value={username:y.username,password:"",role:y.role},e.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async y=>{await k(y.id)}}],h=async()=>{d.value=!0;try{const y=await Ie("/users");if(!y.ok)throw new Error("Failed to fetch users");const _=await y.json();c.value=_.users||[]}catch(y){console.error("Error fetching users:",y),c.value=[]}finally{d.value=!1}},w=async()=>{if(!n.value.username||!n.value.password){alert("Username and password are required");return}try{const y=await Ie("/users",{method:"POST",body:JSON.stringify(n.value)});if(!y.ok){const _=await y.json();alert(_.error||"Failed to add user");return}await h(),a.value=!1,n.value={username:"",password:"",role:"admin"}}catch(y){console.error("Error adding user:",y),alert("Failed to add user")}},x=async()=>{if(!p.value.username){alert("Username is required");return}try{const y={username:p.value.username,role:p.value.role};p.value.password&&(y.password=p.value.password);const _=await Ie(`/users/${r.value.id}`,{method:"PUT",body:JSON.stringify(y)});if(!_.ok){const V=await _.json();alert(V.error||"Failed to update user");return}await h(),e.value=!1,r.value=null}catch(y){console.error("Error updating user:",y),alert("Failed to update user")}},k=async y=>{try{const _=await Ie(`/users/${y}`,{method:"DELETE"});if(!_.ok){const V=await _.json();alert(V.error||"Failed to delete user");return}await h()}catch(_){console.error("Error deleting user:",_),alert("Failed to delete user")}};ce(()=>{h()});const C={showAddModal:a,showEditModal:e,users:c,loading:d,editingUser:r,newUser:n,editUser:p,roleOptions:v,columns:g,actions:f,fetchUsers:h,handleAddUser:w,handleEditUser:x,deleteUser:k,DataTable:Oe,Modal:Ve,SelectInput:xe};return Object.defineProperty(C,"__isScriptSetup",{enumerable:!1,value:!0}),C}}),lf={class:"p-8"},nf={class:"flex justify-between items-center mb-6"},df={class:"flex justify-end gap-2 mt-4"},cf={class:"flex justify-end gap-2 mt-4"};function uf(u,t,a,e,c,d){return s(),l("div",lf,[o("div",nf,[t[13]||(t[13]=o("div",null,[o("h1",{class:"text-3xl font-bold"},"Users"),o("p",{class:"text-gray-600 dark:text-gray-400 mt-2"},"Manage user accounts and permissions")],-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ")]),S(e.DataTable,{columns:e.columns,data:e.users,actions:e.actions,loading:e.loading,"empty-message":"No users found"},null,8,["data","loading"]),i(" Add User Modal "),S(e.Modal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[5]||(t[5]=r=>e.showAddModal=r),title:"Add User",onClose:t[6]||(t[6]=r=>e.showAddModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleAddUser,["prevent"]),class:"space-y-4"},[o("div",null,[t[14]||(t[14]=o("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),fe(o("input",{"onUpdate:modelValue":t[1]||(t[1]=r=>e.newUser.username=r),type:"text",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newUser.username]])]),o("div",null,[t[15]||(t[15]=o("label",{class:"block text-sm font-medium mb-1"},"Password",-1)),fe(o("input",{"onUpdate:modelValue":t[2]||(t[2]=r=>e.newUser.password=r),type:"password",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newUser.password]])]),o("div",null,[S(e.SelectInput,{modelValue:e.newUser.role,"onUpdate:modelValue":t[3]||(t[3]=r=>e.newUser.role=r),options:e.roleOptions,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),o("div",df,[o("button",{type:"button",onClick:t[4]||(t[4]=r=>e.showAddModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[16]||(t[16]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Add User ",-1))])],32)]),_:1},8,["modelValue"]),i(" Edit User Modal "),S(e.Modal,{modelValue:e.showEditModal,"onUpdate:modelValue":t[11]||(t[11]=r=>e.showEditModal=r),title:"Edit User",onClose:t[12]||(t[12]=r=>e.showEditModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleEditUser,["prevent"]),class:"space-y-4"},[o("div",null,[t[17]||(t[17]=o("label",{class:"block text-sm font-medium mb-1"},"Username",-1)),fe(o("input",{"onUpdate:modelValue":t[7]||(t[7]=r=>e.editUser.username=r),type:"text",required:"",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.editUser.username]])]),o("div",null,[t[18]||(t[18]=o("label",{class:"block text-sm font-medium mb-1"},"Password (leave blank to keep current)",-1)),fe(o("input",{"onUpdate:modelValue":t[8]||(t[8]=r=>e.editUser.password=r),type:"password",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.editUser.password]])]),o("div",null,[S(e.SelectInput,{modelValue:e.editUser.role,"onUpdate:modelValue":t[9]||(t[9]=r=>e.editUser.role=r),options:e.roleOptions,label:"Role",placeholder:"Select role"},null,8,["modelValue"])]),o("div",cf,[o("button",{type:"button",onClick:t[10]||(t[10]=r=>e.showEditModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[19]||(t[19]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Update User ",-1))])],32)]),_:1},8,["modelValue"])])}const pf=Q(sf,[["render",uf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/UsersView.vue"]]),mf=$({__name:"ApiKeysView",setup(u,{expose:t}){t();const a=m(!1),e=m(!1),c=m([]),d=m(!1),r=m(""),n=m({name:""}),p=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:k=>`<code class="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-sm">${k}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:k=>new Date(k*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:k=>k?new Date(k*1e3).toLocaleDateString():"Never"}],v=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async k=>{await h(k.id)}}],g=async()=>{d.value=!0;try{const k=await Ie("/api-keys");if(!k.ok)throw new Error("Failed to fetch API keys");const C=await k.json();c.value=(C.keys||[]).map(y=>({...y,keyPreview:`${y.key_prefix}...${y.last_five}`,createdAt:y.created_at,lastUsedAt:y.last_used_at}))}catch(k){console.error("Error fetching API keys:",k),c.value=[]}finally{d.value=!1}},f=async()=>{if(!n.value.name){alert("Name is required");return}try{const k=await Ie("/api-keys",{method:"POST",body:JSON.stringify(n.value)}),C=await k.json();if(!k.ok){alert(C.error||"Failed to create API key");return}r.value=C.key,a.value=!1,e.value=!0,await g(),n.value={name:""}}catch(k){console.error("Error creating API key:",k),alert("Failed to create API key")}},h=async k=>{try{const C=await Ie(`/api-keys/${k}`,{method:"DELETE"});if(!C.ok){const y=await C.json();alert(y.error||"Failed to delete API key");return}await g()}catch(C){console.error("Error deleting API key:",C),alert("Failed to delete API key")}},w=async k=>{try{await navigator.clipboard.writeText(k),alert("API key copied to clipboard!")}catch(C){console.error("Failed to copy:",C)}};ce(()=>{g()});const x={showAddModal:a,showKeyModal:e,apiKeys:c,loading:d,newApiKey:r,newKeyData:n,columns:p,actions:v,fetchApiKeys:g,handleAddApiKey:f,deleteApiKey:h,copyToClipboard:w,DataTable:Oe,Modal:Ve};return Object.defineProperty(x,"__isScriptSetup",{enumerable:!1,value:!0}),x}}),gf={class:"p-8"},ff={class:"flex justify-between items-center mb-6"},hf={class:"flex justify-end gap-2 mt-4"},vf={class:"space-y-4"},bf={class:"flex gap-2"},yf=["value"],xf={class:"bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-800 text-blue-800 dark:text-blue-400 px-4 py-3 rounded"},kf={class:"block mt-2 bg-white dark:bg-gray-800 px-3 py-2 rounded text-xs"},_f={class:"flex justify-end mt-4"};function wf(u,t,a,e,c,d){return s(),l("div",gf,[o("div",ff,[t[9]||(t[9]=o("div",null,[o("h1",{class:"text-3xl font-bold"},"API Keys"),o("p",{class:"text-gray-600 dark:text-gray-400 mt-2"},"Manage API keys for programmatic access")],-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showAddModal=!0),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create API Key ")]),S(e.DataTable,{columns:e.columns,data:e.apiKeys,actions:e.actions,loading:e.loading,"empty-message":"No API keys found"},null,8,["data","loading"]),i(" Add API Key Modal "),S(e.Modal,{modelValue:e.showAddModal,"onUpdate:modelValue":t[3]||(t[3]=r=>e.showAddModal=r),title:"Create API Key",onClose:t[4]||(t[4]=r=>e.showAddModal=!1)},{default:ae(()=>[o("form",{onSubmit:he(e.handleAddApiKey,["prevent"]),class:"space-y-4"},[o("div",null,[t[10]||(t[10]=o("label",{class:"block text-sm font-medium mb-1"},"Name",-1)),fe(o("input",{"onUpdate:modelValue":t[1]||(t[1]=r=>e.newKeyData.name=r),type:"text",required:"",placeholder:"e.g., Production API Key",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700"},null,512),[[_e,e.newKeyData.name]]),t[11]||(t[11]=o("p",{class:"text-sm text-gray-500 dark:text-gray-400 mt-1"}," A descriptive name to help you identify this key ",-1))]),o("div",hf,[o("button",{type:"button",onClick:t[2]||(t[2]=r=>e.showAddModal=!1),class:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700"}," Cancel "),t[12]||(t[12]=o("button",{type:"submit",class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Create Key ",-1))])],32)]),_:1},8,["modelValue"]),i(" Show New API Key Modal "),S(e.Modal,{modelValue:e.showKeyModal,"onUpdate:modelValue":t[7]||(t[7]=r=>e.showKeyModal=r),title:"API Key Created",onClose:t[8]||(t[8]=r=>e.showKeyModal=!1)},{default:ae(()=>[o("div",vf,[t[15]||(t[15]=o("div",{class:"bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-800 text-yellow-800 dark:text-yellow-400 px-4 py-3 rounded"},[o("p",{class:"font-semibold"},"Important: Save this key now!"),o("p",{class:"text-sm mt-1"},"You won't be able to see it again. If you lose this key, you'll need to create a new one.")],-1)),o("div",null,[t[13]||(t[13]=o("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),o("div",bf,[o("input",{value:e.newApiKey,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-700 font-mono text-sm"},null,8,yf),o("button",{onClick:t[5]||(t[5]=r=>e.copyToClipboard(e.newApiKey)),class:"px-4 py-2 bg-gray-200 dark:bg-gray-700 rounded hover:bg-gray-300 dark:hover:bg-gray-600"}," Copy ")])]),o("div",xf,[t[14]||(t[14]=o("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),o("code",kf," Authorization: Bearer "+b(e.newApiKey),1)]),o("div",_f,[o("button",{onClick:t[6]||(t[6]=r=>e.showKeyModal=!1),class:"px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded hover:bg-black/80 dark:hover:bg-white/80 font-medium"}," Done ")])])]),_:1},8,["modelValue"])])}const Cf=Q(mf,[["render",wf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/ApiKeysView.vue"]]),Sf=$({__name:"LoginView",setup(u,{expose:t}){t();const a=Le(),e=Pe(),c=m(""),d=m(""),r=m(""),n=m(!1),p=m(!1),v=m(!1);ce(async()=>{const x=e.query.token,k=e.query.error;if(x){localStorage.setItem("auth_token",x),a.push("/");return}k&&(k==="oauth_failed"?r.value="OAuth authentication failed. Please try again.":k==="oauth_not_configured"&&(r.value="OAuth provider is not configured."));try{const C=await fetch(J("/api/auth/config"));if(C.ok){const y=await C.json();p.value=y.github||!1,v.value=y.google||!1}}catch(C){console.error("Failed to fetch auth config:",C)}});async function g(){r.value="",n.value=!0;try{const x=await fetch(J("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:c.value,password:d.value})}),k=await x.json();x.ok?(localStorage.setItem("auth_token",k.token),a.push("/")):r.value=k.error||"Login failed"}catch{r.value="Network error. Please try again."}finally{n.value=!1}}function f(){window.location.href=J("/api/auth/oauth/github")}function h(){window.location.href=J("/api/auth/oauth/google")}const w={router:a,route:e,username:c,password:d,error:r,loading:n,showGithubLogin:p,showGoogleLogin:v,handleLogin:g,handleGithubLogin:f,handleGoogleLogin:h,TextInput:je,DropShadow:Re};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}}),Tf={class:"min-h-screen flex items-center justify-center bg-white dark:bg-black px-4"},Mf={class:"max-w-md w-full space-y-8"},If={class:"bg-white dark:bg-black border border-black dark:border-white py-8 px-6"},Vf={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3"},Af=["disabled"],Pf={key:0,class:"mt-6"};function Ef(u,t,a,e,c,d){return s(),l("div",Tf,[o("div",Mf,[t[5]||(t[5]=o("div",null,[o("h2",{class:"mt-6 text-center text-3xl font-bold text-black dark:text-white"}," Sign in to AgentBuilder ")],-1)),S(e.DropShadow,{offsetX:8,offsetY:8,intensity:.5,pattern:"crosshatch"},{default:ae(()=>[o("div",If,[o("form",{class:"space-y-6",onSubmit:he(e.handleLogin,["prevent"])},[e.error?(s(),l("div",Vf,b(e.error),1)):i("v-if",!0),S(e.TextInput,{modelValue:e.username,"onUpdate:modelValue":t[0]||(t[0]=r=>e.username=r),label:"Username",type:"text",required:!0,disabled:e.loading,placeholder:"Enter your username"},null,8,["modelValue","disabled"]),S(e.TextInput,{modelValue:e.password,"onUpdate:modelValue":t[1]||(t[1]=r=>e.password=r),label:"Password",type:"password",required:!0,disabled:e.loading,placeholder:"Enter your password"},null,8,["modelValue","disabled"]),o("div",null,[o("button",{type:"submit",disabled:e.loading,class:"w-full px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed"},b(e.loading?"Signing in...":"Sign in"),9,Af)])],32),e.showGithubLogin||e.showGoogleLogin?(s(),l("div",Pf,[t[4]||(t[4]=o("div",{class:"relative"},[o("div",{class:"absolute inset-0 flex items-center"},[o("div",{class:"w-full border-t border-black dark:border-white"})]),o("div",{class:"relative flex justify-center text-sm"},[o("span",{class:"px-2 bg-white dark:bg-black text-black dark:text-white"},"Or continue with")])],-1)),o("div",{class:ee(["mt-6 grid gap-3",e.showGithubLogin&&e.showGoogleLogin?"grid-cols-2":"grid-cols-1"])},[e.showGithubLogin?(s(),l("button",{key:0,onClick:e.handleGithubLogin,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"},[...t[2]||(t[2]=[o("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[o("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),o("span",{class:"ml-2"},"GitHub",-1)])])):i("v-if",!0),e.showGoogleLogin?(s(),l("button",{key:1,onClick:e.handleGoogleLogin,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2 bg-black text-white dark:bg-white dark:text-black rounded font-medium hover:opacity-90 transition-opacity"},[...t[3]||(t[3]=[o("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[o("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),o("span",{class:"ml-2"},"Google",-1)])])):i("v-if",!0)],2)])):i("v-if",!0)])]),_:1})])])}const Of=Q(Sf,[["render",Ef],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/LoginView.vue"]]),jf=$({__name:"MultilineInput",props:{modelValue:{type:String,required:!1},label:{type:String,required:!1},placeholder:{type:String,required:!1},error:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},emits:["update:modelValue","focus","blur"],setup(u,{expose:t,emit:a}){const e=u,c=a,d=m(null),r=z(()=>["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-black dark:focus:ring-white","transition-colors resize-none overflow-hidden",e.error?"border-red-500 dark:border-red-400":"border-black dark:border-white",e.disabled?"opacity-50 cursor-not-allowed":""]),n=()=>{const h=d.value;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight+2}px`)},p=h=>{const w=h.target;c("update:modelValue",w.value),n()},v=h=>{c("focus",h)},g=h=>{c("blur",h)};ce(()=>{n()}),oe(()=>e.modelValue,async()=>{await pe(),n()}),t({textareaRef:d,adjustHeight:n});const f={props:e,emit:c,textareaRef:d,inputClasses:r,adjustHeight:n,handleInput:p,handleFocus:v,handleBlur:g};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),Lf={class:"space-y-1"},Df={key:0,class:"block text-sm font-medium"},Uf={key:0,class:"text-red-500"},qf=["value","placeholder","disabled"],Nf={key:1,class:"text-xs text-red-500 dark:text-red-400"};function Bf(u,t,a,e,c,d){return s(),l("div",Lf,[a.label?(s(),l("label",Df,[ie(b(a.label)+" ",1),a.required?(s(),l("span",Uf,"*")):i("v-if",!0)])):i("v-if",!0),o("textarea",{ref:"textareaRef",value:a.modelValue,placeholder:a.placeholder,disabled:a.disabled,class:ee(e.inputClasses),rows:"1",onInput:e.handleInput,onFocus:e.handleFocus,onBlur:e.handleBlur},null,42,qf),a.error?(s(),l("p",Nf,b(a.error),1)):i("v-if",!0)])}const Rf=Q(jf,[["render",Bf],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/inputs/MultilineInput.vue"]]),Ff=$({__name:"TestView",setup(u,{expose:t}){t();const a=m(""),e=m(""),c=m(""),d=m(`Line 1
15
15
  Line 2
16
- Line 3`),r=m(""),n=m(""),p=m("option2"),v=m(""),g=m(""),f=m(""),h=m([]),w=m(["test1","test2"]),x=m(!1),k=m(!0),C=m(!1),y=m(!1),_=m({type:"object",properties:{},required:[]}),I=m(0);ce(()=>{window.resetJSONSchema=()=>{_.value={type:"object",properties:{},required:[]},I.value++}});const F={textValue:a,emailValue:e,multilineValue:c,multilineWithNewlines:d,multilineError:r,selectValue:n,disabledSelectValue:p,overflowSelectValue:v,dropdownValue:g,overflowDropdownValue:f,multipleSelectValue:h,multipleSelectDisabled:w,checkboxValue:x,checkboxWithHelp:k,checkboxDisabled:C,checkboxError:y,jsonSchemaValue:_,jsonSchemaKey:I,selectOptions:[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],dropdownOptions:[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],multipleTestOptions:[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}],TextInput:je,MultilineInput:Rf,SelectInput:xe,MultipleSelectionsInput:ct,CheckboxInput:Xe,JSONSchemaInput:Ot};return Object.defineProperty(F,"__isScriptSetup",{enumerable:!1,value:!0}),F}}),zf={class:"p-8 space-y-6"},Hf={"data-testid":"basic-input"},Wf={"data-testid":"output"},Jf={"data-testid":"error-input"},Kf={class:"mt-12"},Zf={"data-testid":"basic-multiline",class:"mb-6"},Gf={"data-testid":"multiline-output"},Xf={"data-testid":"multiline-with-newlines",class:"mb-6"},Qf={"data-testid":"multiline-newlines-output"},Yf={"data-testid":"error-multiline",class:"mb-6"},$f={"data-testid":"basic-select"},eh={"data-testid":"select-output"},th={"data-testid":"error-select"},oh={"data-testid":"disabled-select"},rh={"data-testid":"overflow-container",class:"mt-8"},ah={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},sh={class:"mt-12"},lh={"data-testid":"basic-dropdown",class:"mb-6"},nh={"data-testid":"dropdown-output"},ih={"data-testid":"dropdown-overflow-container"},dh={class:"border-2 border-blue-500 p-4 h-32 overflow-hidden relative"},ch={class:"mt-12"},uh={"data-testid":"multiple-select-test",class:"mb-6"},ph={"data-testid":"multiple-output"},mh={"data-testid":"multiple-select-disabled",class:"mb-6"},gh={class:"mt-12"},fh={"data-testid":"basic-checkbox",class:"mb-6"},hh={"data-testid":"checkbox-output",class:"mt-2 text-sm"},vh={"data-testid":"checkbox-with-help",class:"mb-6"},bh={"data-testid":"checkbox-help-output",class:"mt-2 text-sm"},yh={"data-testid":"disabled-checkbox",class:"mb-6"},xh={"data-testid":"error-checkbox",class:"mb-6"},kh={class:"mt-12"},_h={"data-testid":"json-schema-input",class:"mb-6"},wh={class:"mt-4 p-4 bg-gray-100 dark:bg-gray-900 rounded"},Ch={"data-testid":"json-schema-output",class:"text-xs overflow-x-auto"};function Sh(u,t,a,e,c,d){return s(),l("div",zf,[t[30]||(t[30]=o("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),i(" Basic TextInput "),o("div",Hf,[S(e.TextInput,{modelValue:e.textValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.textValue=r),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),o("p",Wf,b(e.textValue),1)]),i(" TextInput with Error "),o("div",Jf,[S(e.TextInput,{modelValue:e.emailValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.emailValue=r),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),i(" MultilineInput Tests "),o("div",Kf,[t[18]||(t[18]=o("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),i(" Basic MultilineInput "),o("div",Zf,[S(e.MultilineInput,{modelValue:e.multilineValue,"onUpdate:modelValue":t[2]||(t[2]=r=>e.multilineValue=r),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),o("p",Gf,b(e.multilineValue),1)]),i(" MultilineInput with pre-filled newlines "),o("div",Xf,[S(e.MultilineInput,{modelValue:e.multilineWithNewlines,"onUpdate:modelValue":t[3]||(t[3]=r=>e.multilineWithNewlines=r),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),o("pre",Qf,b(e.multilineWithNewlines),1)]),i(" MultilineInput with Error "),o("div",Yf,[S(e.MultilineInput,{modelValue:e.multilineError,"onUpdate:modelValue":t[4]||(t[4]=r=>e.multilineError=r),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),i(" Basic SelectInput "),o("div",$f,[S(e.SelectInput,{modelValue:e.selectValue,"onUpdate:modelValue":t[5]||(t[5]=r=>e.selectValue=r),options:e.selectOptions,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),o("p",eh,b(e.selectValue),1)]),i(" SelectInput with Error "),o("div",th,[i(" Note: SelectInput doesn't support error prop yet "),S(e.SelectInput,{modelValue:e.selectValue,"onUpdate:modelValue":t[6]||(t[6]=r=>e.selectValue=r),options:e.selectOptions,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),i(" Disabled SelectInput "),o("div",oh,[S(e.SelectInput,{modelValue:e.disabledSelectValue,"onUpdate:modelValue":t[7]||(t[7]=r=>e.disabledSelectValue=r),options:e.selectOptions,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),i(" SelectInput in overflow:hidden container "),o("div",rh,[t[20]||(t[20]=o("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),o("div",ah,[t[19]||(t[19]=o("p",{class:"text-sm text-gray-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),S(e.SelectInput,{modelValue:e.overflowSelectValue,"onUpdate:modelValue":t[8]||(t[8]=r=>e.overflowSelectValue=r),options:e.selectOptions,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),t[21]||(t[21]=o("p",{class:"mt-2 text-sm text-gray-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),i(" DropdownList Tests "),o("div",sh,[t[25]||(t[25]=o("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),i(" Basic DropdownList "),o("div",lh,[S(e.SelectInput,{modelValue:e.dropdownValue,"onUpdate:modelValue":t[9]||(t[9]=r=>e.dropdownValue=r),options:e.dropdownOptions,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),o("p",nh,b(e.dropdownValue),1)]),i(" DropdownList in overflow:hidden container "),o("div",ih,[t[23]||(t[23]=o("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),o("div",dh,[t[22]||(t[22]=o("p",{class:"text-sm text-gray-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),S(e.SelectInput,{modelValue:e.overflowDropdownValue,"onUpdate:modelValue":t[10]||(t[10]=r=>e.overflowDropdownValue=r),options:e.dropdownOptions,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),t[24]||(t[24]=o("p",{class:"mt-2 text-sm text-gray-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),i(" MultipleSelectionsInput Tests "),o("div",ch,[t[26]||(t[26]=o("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),i(" Basic MultipleSelectionsInput "),o("div",uh,[S(e.MultipleSelectionsInput,{modelValue:e.multipleSelectValue,"onUpdate:modelValue":t[11]||(t[11]=r=>e.multipleSelectValue=r),options:e.multipleTestOptions,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),o("p",ph,b(e.multipleSelectValue),1)]),i(" Disabled MultipleSelectionsInput "),o("div",mh,[S(e.MultipleSelectionsInput,{modelValue:e.multipleSelectDisabled,"onUpdate:modelValue":t[12]||(t[12]=r=>e.multipleSelectDisabled=r),options:e.multipleTestOptions,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),i(" CheckboxInput Tests "),o("div",gh,[t[27]||(t[27]=o("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),i(" Basic CheckboxInput "),o("div",fh,[S(e.CheckboxInput,{modelValue:e.checkboxValue,"onUpdate:modelValue":t[13]||(t[13]=r=>e.checkboxValue=r),label:"Basic Checkbox"},null,8,["modelValue"]),o("p",hh," Value: "+b(e.checkboxValue),1)]),i(" CheckboxInput with Help Text "),o("div",vh,[S(e.CheckboxInput,{modelValue:e.checkboxWithHelp,"onUpdate:modelValue":t[14]||(t[14]=r=>e.checkboxWithHelp=r),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),o("p",bh," Value: "+b(e.checkboxWithHelp),1)]),i(" Disabled CheckboxInput "),o("div",yh,[S(e.CheckboxInput,{modelValue:e.checkboxDisabled,"onUpdate:modelValue":t[15]||(t[15]=r=>e.checkboxDisabled=r),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),i(" CheckboxInput with Error "),o("div",xh,[S(e.CheckboxInput,{modelValue:e.checkboxError,"onUpdate:modelValue":t[16]||(t[16]=r=>e.checkboxError=r),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),i(" JSONSchemaInput Tests "),o("div",kh,[t[29]||(t[29]=o("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),i(" Basic JSONSchemaInput "),o("div",_h,[(s(),X(e.JSONSchemaInput,{key:e.jsonSchemaKey,modelValue:e.jsonSchemaValue,"onUpdate:modelValue":t[17]||(t[17]=r=>e.jsonSchemaValue=r),label:"JSON Schema Builder"},null,8,["modelValue"])),o("div",wh,[t[28]||(t[28]=o("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),o("pre",Ch,b(JSON.stringify(e.jsonSchemaValue,null,2)),1)])])])])}const Th=Q(Ff,[["render",Sh],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestView.vue"]]),Mh=$({__name:"ReferenceInput",props:{modelValue:{type:String,required:!0},search:{type:Function,required:!1},placeholder:{type:String,required:!1},rows:{type:Number,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(null),n=m(!1),p=m(""),v=m([]),g=m(0),f=m(-1),h=m(-1),w=m(0),x=m({top:0,left:0}),k=async E=>{const H=E.target,R=H.value,N=H.selectionStart;c("update:modelValue",R),R[N-1]==="@"&&!n.value?C(N):n.value&&await _(R,N)},C=async E=>{f.value=E-1,h.value=E,p.value="",w.value=0,n.value=!0,g.value=0,await y(),await I("")},y=async()=>{if(!d.value)return;await pe();const E=d.value.getBoundingClientRect(),H=window.getComputedStyle(d.value),R=parseInt(H.lineHeight||"20"),N=parseInt(H.paddingTop||"8"),G=e.modelValue.substring(0,h.value).split(`
17
- `),P=G.length,V=G[G.length-1],q=Math.min(V.length*8,200);x.value={top:E.top+N+P*R+4,left:E.left+N+q}},_=async(E,H)=>{if(H<=f.value){L();return}const R=f.value+1,N=E.substring(R,H);if(v.value.length===0?w.value++:w.value=0,v.value.length===0&&w.value>=5){L();return}p.value=N,await I(N)},I=async E=>{if(!e.search){v.value=[];return}const H=await e.search(E);v.value=Array.isArray(H)?H:[],g.value>=v.value.length&&(g.value=0)},U=E=>{if(!d.value)return;const H=e.modelValue,R=H.substring(0,f.value),N=H.substring(h.value+p.value.length),Z=`@${E.value}`,G=R+Z+N;c("update:modelValue",G),pe(()=>{if(!d.value)return;const P=R.length+Z.length;d.value.focus(),d.value.setSelectionRange(P,P)}),L()},L=()=>{n.value=!1,p.value="",v.value=[],g.value=0,f.value=-1,h.value=-1,w.value=0},j=E=>{if(n.value)switch(E.key){case"Escape":E.preventDefault(),L();break;case"ArrowDown":E.preventDefault(),g.value=Math.min(g.value+1,v.value.length-1);break;case"ArrowUp":E.preventDefault(),g.value=Math.max(g.value-1,0);break;case"Enter":v.value.length>0&&(E.preventDefault(),U(v.value[g.value]));break;case"Tab":v.value.length>0&&(E.preventDefault(),U(v.value[g.value]));break}},F=()=>{if(!n.value||!d.value)return;d.value.selectionStart<=f.value&&L()},K=E=>{if(!r.value||!n.value)return;const H=E.target;!r.value.contains(H)&&H!==d.value&&L()};oe(n,E=>{E?document.addEventListener("click",K):document.removeEventListener("click",K)});const D={props:e,emit:c,textarea:d,searchDialog:r,isSearchMode:n,searchQuery:p,searchResults:v,selectedIndex:g,atSymbolPosition:f,searchStartCursorPosition:h,charactersTypedSinceSearch:w,dialogPosition:x,handleInput:k,startSearchMode:C,positionDialog:y,handleSearchModeInput:_,performSearch:I,insertResult:U,exitSearchMode:L,handleKeyDown:j,handleSelectionChange:F,handleClickOutside:K};return Object.defineProperty(D,"__isScriptSetup",{enumerable:!1,value:!0}),D}}),Ih={class:"relative"},Vh=["value","placeholder","rows"],Ah={class:"bg-white dark:bg-black rounded-lg"},Ph={class:"px-3 py-2 border-b border-black dark:border-white"},Eh={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Oh={key:0,class:"max-h-[200px] overflow-y-auto"},jh=["onClick"],Lh={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Dh={class:"flex-1"},Uh={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"};function qh(u,t,a,e,c,d){return s(),l("div",Ih,[o("textarea",{ref:"textarea",value:a.modelValue,onInput:e.handleInput,onKeydown:e.handleKeyDown,onSelect:e.handleSelectionChange,placeholder:a.placeholder||"Type @ to insert references...",rows:a.rows||10,class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,Vh),i(" Search Dialog with 1-bit dither shadow "),(s(),X(st,{to:"body"},[e.isSearchMode?(s(),l("div",{key:0,ref:"searchDialog",class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg",style:lt({top:`${e.dialogPosition.top}px`,left:`${e.dialogPosition.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
16
+ Line 3`),r=m(""),n=m(""),p=m("option2"),v=m(""),g=m(""),f=m(""),h=m([]),w=m(["test1","test2"]),x=m(!1),k=m(!0),C=m(!1),y=m(!1),_=m({type:"object",properties:{},required:[]}),V=m(0);ce(()=>{window.resetJSONSchema=()=>{_.value={type:"object",properties:{},required:[]},V.value++}});const F={textValue:a,emailValue:e,multilineValue:c,multilineWithNewlines:d,multilineError:r,selectValue:n,disabledSelectValue:p,overflowSelectValue:v,dropdownValue:g,overflowDropdownValue:f,multipleSelectValue:h,multipleSelectDisabled:w,checkboxValue:x,checkboxWithHelp:k,checkboxDisabled:C,checkboxError:y,jsonSchemaValue:_,jsonSchemaKey:V,selectOptions:[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],dropdownOptions:[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],multipleTestOptions:[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}],TextInput:je,MultilineInput:Rf,SelectInput:xe,MultipleSelectionsInput:ct,CheckboxInput:Xe,JSONSchemaInput:Ot};return Object.defineProperty(F,"__isScriptSetup",{enumerable:!1,value:!0}),F}}),zf={class:"p-8 space-y-6"},Hf={"data-testid":"basic-input"},Wf={"data-testid":"output"},Jf={"data-testid":"error-input"},Kf={class:"mt-12"},Zf={"data-testid":"basic-multiline",class:"mb-6"},Gf={"data-testid":"multiline-output"},Xf={"data-testid":"multiline-with-newlines",class:"mb-6"},Qf={"data-testid":"multiline-newlines-output"},Yf={"data-testid":"error-multiline",class:"mb-6"},$f={"data-testid":"basic-select"},eh={"data-testid":"select-output"},th={"data-testid":"error-select"},oh={"data-testid":"disabled-select"},rh={"data-testid":"overflow-container",class:"mt-8"},ah={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},sh={class:"mt-12"},lh={"data-testid":"basic-dropdown",class:"mb-6"},nh={"data-testid":"dropdown-output"},ih={"data-testid":"dropdown-overflow-container"},dh={class:"border-2 border-blue-500 p-4 h-32 overflow-hidden relative"},ch={class:"mt-12"},uh={"data-testid":"multiple-select-test",class:"mb-6"},ph={"data-testid":"multiple-output"},mh={"data-testid":"multiple-select-disabled",class:"mb-6"},gh={class:"mt-12"},fh={"data-testid":"basic-checkbox",class:"mb-6"},hh={"data-testid":"checkbox-output",class:"mt-2 text-sm"},vh={"data-testid":"checkbox-with-help",class:"mb-6"},bh={"data-testid":"checkbox-help-output",class:"mt-2 text-sm"},yh={"data-testid":"disabled-checkbox",class:"mb-6"},xh={"data-testid":"error-checkbox",class:"mb-6"},kh={class:"mt-12"},_h={"data-testid":"json-schema-input",class:"mb-6"},wh={class:"mt-4 p-4 bg-gray-100 dark:bg-gray-900 rounded"},Ch={"data-testid":"json-schema-output",class:"text-xs overflow-x-auto"};function Sh(u,t,a,e,c,d){return s(),l("div",zf,[t[30]||(t[30]=o("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),i(" Basic TextInput "),o("div",Hf,[S(e.TextInput,{modelValue:e.textValue,"onUpdate:modelValue":t[0]||(t[0]=r=>e.textValue=r),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),o("p",Wf,b(e.textValue),1)]),i(" TextInput with Error "),o("div",Jf,[S(e.TextInput,{modelValue:e.emailValue,"onUpdate:modelValue":t[1]||(t[1]=r=>e.emailValue=r),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),i(" MultilineInput Tests "),o("div",Kf,[t[18]||(t[18]=o("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),i(" Basic MultilineInput "),o("div",Zf,[S(e.MultilineInput,{modelValue:e.multilineValue,"onUpdate:modelValue":t[2]||(t[2]=r=>e.multilineValue=r),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),o("p",Gf,b(e.multilineValue),1)]),i(" MultilineInput with pre-filled newlines "),o("div",Xf,[S(e.MultilineInput,{modelValue:e.multilineWithNewlines,"onUpdate:modelValue":t[3]||(t[3]=r=>e.multilineWithNewlines=r),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),o("pre",Qf,b(e.multilineWithNewlines),1)]),i(" MultilineInput with Error "),o("div",Yf,[S(e.MultilineInput,{modelValue:e.multilineError,"onUpdate:modelValue":t[4]||(t[4]=r=>e.multilineError=r),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),i(" Basic SelectInput "),o("div",$f,[S(e.SelectInput,{modelValue:e.selectValue,"onUpdate:modelValue":t[5]||(t[5]=r=>e.selectValue=r),options:e.selectOptions,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),o("p",eh,b(e.selectValue),1)]),i(" SelectInput with Error "),o("div",th,[i(" Note: SelectInput doesn't support error prop yet "),S(e.SelectInput,{modelValue:e.selectValue,"onUpdate:modelValue":t[6]||(t[6]=r=>e.selectValue=r),options:e.selectOptions,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),i(" Disabled SelectInput "),o("div",oh,[S(e.SelectInput,{modelValue:e.disabledSelectValue,"onUpdate:modelValue":t[7]||(t[7]=r=>e.disabledSelectValue=r),options:e.selectOptions,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),i(" SelectInput in overflow:hidden container "),o("div",rh,[t[20]||(t[20]=o("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),o("div",ah,[t[19]||(t[19]=o("p",{class:"text-sm text-gray-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),S(e.SelectInput,{modelValue:e.overflowSelectValue,"onUpdate:modelValue":t[8]||(t[8]=r=>e.overflowSelectValue=r),options:e.selectOptions,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),t[21]||(t[21]=o("p",{class:"mt-2 text-sm text-gray-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),i(" DropdownList Tests "),o("div",sh,[t[25]||(t[25]=o("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),i(" Basic DropdownList "),o("div",lh,[S(e.SelectInput,{modelValue:e.dropdownValue,"onUpdate:modelValue":t[9]||(t[9]=r=>e.dropdownValue=r),options:e.dropdownOptions,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),o("p",nh,b(e.dropdownValue),1)]),i(" DropdownList in overflow:hidden container "),o("div",ih,[t[23]||(t[23]=o("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),o("div",dh,[t[22]||(t[22]=o("p",{class:"text-sm text-gray-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),S(e.SelectInput,{modelValue:e.overflowDropdownValue,"onUpdate:modelValue":t[10]||(t[10]=r=>e.overflowDropdownValue=r),options:e.dropdownOptions,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),t[24]||(t[24]=o("p",{class:"mt-2 text-sm text-gray-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),i(" MultipleSelectionsInput Tests "),o("div",ch,[t[26]||(t[26]=o("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),i(" Basic MultipleSelectionsInput "),o("div",uh,[S(e.MultipleSelectionsInput,{modelValue:e.multipleSelectValue,"onUpdate:modelValue":t[11]||(t[11]=r=>e.multipleSelectValue=r),options:e.multipleTestOptions,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),o("p",ph,b(e.multipleSelectValue),1)]),i(" Disabled MultipleSelectionsInput "),o("div",mh,[S(e.MultipleSelectionsInput,{modelValue:e.multipleSelectDisabled,"onUpdate:modelValue":t[12]||(t[12]=r=>e.multipleSelectDisabled=r),options:e.multipleTestOptions,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),i(" CheckboxInput Tests "),o("div",gh,[t[27]||(t[27]=o("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),i(" Basic CheckboxInput "),o("div",fh,[S(e.CheckboxInput,{modelValue:e.checkboxValue,"onUpdate:modelValue":t[13]||(t[13]=r=>e.checkboxValue=r),label:"Basic Checkbox"},null,8,["modelValue"]),o("p",hh," Value: "+b(e.checkboxValue),1)]),i(" CheckboxInput with Help Text "),o("div",vh,[S(e.CheckboxInput,{modelValue:e.checkboxWithHelp,"onUpdate:modelValue":t[14]||(t[14]=r=>e.checkboxWithHelp=r),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),o("p",bh," Value: "+b(e.checkboxWithHelp),1)]),i(" Disabled CheckboxInput "),o("div",yh,[S(e.CheckboxInput,{modelValue:e.checkboxDisabled,"onUpdate:modelValue":t[15]||(t[15]=r=>e.checkboxDisabled=r),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),i(" CheckboxInput with Error "),o("div",xh,[S(e.CheckboxInput,{modelValue:e.checkboxError,"onUpdate:modelValue":t[16]||(t[16]=r=>e.checkboxError=r),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),i(" JSONSchemaInput Tests "),o("div",kh,[t[29]||(t[29]=o("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),i(" Basic JSONSchemaInput "),o("div",_h,[(s(),X(e.JSONSchemaInput,{key:e.jsonSchemaKey,modelValue:e.jsonSchemaValue,"onUpdate:modelValue":t[17]||(t[17]=r=>e.jsonSchemaValue=r),label:"JSON Schema Builder"},null,8,["modelValue"])),o("div",wh,[t[28]||(t[28]=o("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),o("pre",Ch,b(JSON.stringify(e.jsonSchemaValue,null,2)),1)])])])])}const Th=Q(Ff,[["render",Sh],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestView.vue"]]),Mh=$({__name:"ReferenceInput",props:{modelValue:{type:String,required:!0},search:{type:Function,required:!1},placeholder:{type:String,required:!1},rows:{type:Number,required:!1}},emits:["update:modelValue"],setup(u,{expose:t,emit:a}){t();const e=u,c=a,d=m(null),r=m(null),n=m(!1),p=m(""),v=m([]),g=m(0),f=m(-1),h=m(-1),w=m(0),x=m({top:0,left:0}),k=async E=>{const H=E.target,R=H.value,N=H.selectionStart;c("update:modelValue",R),R[N-1]==="@"&&!n.value?C(N):n.value&&await _(R,N)},C=async E=>{f.value=E-1,h.value=E,p.value="",w.value=0,n.value=!0,g.value=0,await y(),await V("")},y=async()=>{if(!d.value)return;await pe();const E=d.value.getBoundingClientRect(),H=window.getComputedStyle(d.value),R=parseInt(H.lineHeight||"20"),N=parseInt(H.paddingTop||"8"),G=e.modelValue.substring(0,h.value).split(`
17
+ `),P=G.length,I=G[G.length-1],q=Math.min(I.length*8,200);x.value={top:E.top+N+P*R+4,left:E.left+N+q}},_=async(E,H)=>{if(H<=f.value){L();return}const R=f.value+1,N=E.substring(R,H);if(v.value.length===0?w.value++:w.value=0,v.value.length===0&&w.value>=5){L();return}p.value=N,await V(N)},V=async E=>{if(!e.search){v.value=[];return}const H=await e.search(E);v.value=Array.isArray(H)?H:[],g.value>=v.value.length&&(g.value=0)},U=E=>{if(!d.value)return;const H=e.modelValue,R=H.substring(0,f.value),N=H.substring(h.value+p.value.length),Z=`@${E.value}`,G=R+Z+N;c("update:modelValue",G),pe(()=>{if(!d.value)return;const P=R.length+Z.length;d.value.focus(),d.value.setSelectionRange(P,P)}),L()},L=()=>{n.value=!1,p.value="",v.value=[],g.value=0,f.value=-1,h.value=-1,w.value=0},j=E=>{if(n.value)switch(E.key){case"Escape":E.preventDefault(),L();break;case"ArrowDown":E.preventDefault(),g.value=Math.min(g.value+1,v.value.length-1);break;case"ArrowUp":E.preventDefault(),g.value=Math.max(g.value-1,0);break;case"Enter":v.value.length>0&&(E.preventDefault(),U(v.value[g.value]));break;case"Tab":v.value.length>0&&(E.preventDefault(),U(v.value[g.value]));break}},F=()=>{if(!n.value||!d.value)return;d.value.selectionStart<=f.value&&L()},K=E=>{if(!r.value||!n.value)return;const H=E.target;!r.value.contains(H)&&H!==d.value&&L()};oe(n,E=>{E?document.addEventListener("click",K):document.removeEventListener("click",K)});const D={props:e,emit:c,textarea:d,searchDialog:r,isSearchMode:n,searchQuery:p,searchResults:v,selectedIndex:g,atSymbolPosition:f,searchStartCursorPosition:h,charactersTypedSinceSearch:w,dialogPosition:x,handleInput:k,startSearchMode:C,positionDialog:y,handleSearchModeInput:_,performSearch:V,insertResult:U,exitSearchMode:L,handleKeyDown:j,handleSelectionChange:F,handleClickOutside:K};return Object.defineProperty(D,"__isScriptSetup",{enumerable:!1,value:!0}),D}}),Ih={class:"relative"},Vh=["value","placeholder","rows"],Ah={class:"bg-white dark:bg-black rounded-lg"},Ph={class:"px-3 py-2 border-b border-black dark:border-white"},Eh={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Oh={key:0,class:"max-h-[200px] overflow-y-auto"},jh=["onClick"],Lh={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5"},Dh={class:"flex-1"},Uh={key:0,class:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"};function qh(u,t,a,e,c,d){return s(),l("div",Ih,[o("textarea",{ref:"textarea",value:a.modelValue,onInput:e.handleInput,onKeydown:e.handleKeyDown,onSelect:e.handleSelectionChange,placeholder:a.placeholder||"Type @ to insert references...",rows:a.rows||10,class:"w-full px-3 py-2 border border-black dark:border-white rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,Vh),i(" Search Dialog with 1-bit dither shadow "),(s(),X(st,{to:"body"},[e.isSearchMode?(s(),l("div",{key:0,ref:"searchDialog",class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-white rounded-lg",style:lt({top:`${e.dialogPosition.top}px`,left:`${e.dialogPosition.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
18
18
  repeating-linear-gradient(
19
19
  45deg,
20
20
  transparent,
@@ -36,4 +36,4 @@ In a real app, this could:
36
36
  - Expand inline to show the full prompt
37
37
  - Navigate to the prompt editor`):p.type==="variable"&&alert(`Variable clicked: ${p.label||p.value}
38
38
 
39
- Description: ${p.meta?.description||"No description"}`)},PromptInput:jt};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),ov={class:"min-h-screen bg-white dark:bg-black p-8"},rv={class:"max-w-4xl mx-auto"},av={class:"space-y-8"},sv={class:"space-y-4"},lv={"data-testid":"prompt-input-test"},nv={class:"space-y-4"},iv={class:"p-4 bg-gray-100 dark:bg-gray-900 rounded-lg"},dv={"data-testid":"prompt-output",class:"text-sm text-black dark:text-white"};function cv(u,t,a,e,c,d){return s(),l("div",ov,[o("div",rv,[t[6]||(t[6]=o("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),o("div",av,[i(" Basic Example "),o("div",sv,[t[0]||(t[0]=o("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),t[1]||(t[1]=o("p",{class:"text-gray-600 dark:text-gray-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),o("div",lv,[S(e.PromptInput,{"model-value":e.promptValue,search:e.searchPrompts,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":e.handleUpdate,onSegmentClick:e.handleSegmentClick},null,8,["model-value"])])]),i(" Output Display "),o("div",nv,[t[3]||(t[3]=o("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),o("div",iv,[t[2]||(t[2]=o("h3",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Segments (value): ",-1)),o("pre",dv,b(JSON.stringify(e.promptValue,null,2)),1)])]),i(" Instructions "),t[4]||(t[4]=ot('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-gray-600 dark:text-gray-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li>The dialog will auto-close after typing 5+ characters without selection</li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div>',1)),i(" Test Scenarios "),t[5]||(t[5]=ot('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Variables</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Prompts</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Mixed Content</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Edge Cases</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',1))])])])}const uv=Q(tv,[["render",cv],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestPromptInput.vue"]]),pv=$({__name:"JsonEditor",props:{modelValue:{type:String,required:!0},placeholder:{type:String,required:!1},error:{type:String,required:!1},rows:{type:Number,required:!1},readonly:{type:Boolean,required:!1}},emits:["update:modelValue","blur"],setup(u,{expose:t,emit:a}){t(),self.MonacoEnvironment={getWorker(k,C){return C==="json"?new go:new fo}};const e=u,c=a,d=m(null);let r=null,n=!1;const p=m(!1),v={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:e.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},g=()=>{if(!(!r||e.readonly))try{const k=r.getValue(),C=JSON.parse(k),y=JSON.stringify(C,null,2);y!==k&&(n=!0,r.setValue(y),n=!1)}catch{}},f=()=>{p.value=document.documentElement.classList.contains("dark"),r&&gt.setTheme(p.value?"vs-dark":"vs")},h=()=>{d.value&&(r=gt.create(d.value,{value:e.modelValue||"{}",language:"json",theme:p.value?"vs-dark":"vs",...v})(d.value).__monacoEditor=r,r.onDidChangeModelContent(()=>{if(!n){const k=r.getValue();c("update:modelValue",k)}}),r.onDidBlurEditorText(()=>{c("blur"),g()}))};ce(async()=>{f(),await pe(),h();const k=new MutationObserver(f);k.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),Te(()=>{k.disconnect(),r&&r.dispose()})}),oe(()=>e.modelValue,k=>{r&&r.getValue()!==k&&(n=!0,r.setValue(k||""),n=!1)}),oe(()=>e.readonly,k=>{r&&r.updateOptions({readOnly:k})});const w=e.rows?`${e.rows*1.5}rem`:"18rem",x={props:e,emit:c,containerRef:d,get monacoEditor(){return r},set monacoEditor(k){r=k},get isUpdatingFromProp(){return n},set isUpdatingFromProp(k){n=k},isDark:p,editorOptions:v,formatJson:g,updateTheme:f,initEditor:h,editorHeight:w};return Object.defineProperty(x,"__isScriptSetup",{enumerable:!1,value:!0}),x}}),mv={class:"relative"},gv={key:0,class:"mt-1 text-sm text-red-500"};function fv(u,t,a,e,c,d){return s(),l("div",mv,[o("div",{class:ee(["border rounded overflow-hidden bg-white dark:bg-black",[a.error?"border-red-500":"border-black dark:border-white"]])},[o("div",{ref:"containerRef",class:"monaco-editor-container",style:lt({height:e.editorHeight})},null,4)],2),a.error?(s(),l("div",gv,b(a.error),1)):i("v-if",!0)])}const hv=Q(pv,[["render",fv],["__scopeId","data-v-903708b4"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/JsonEditor.vue"]]),vv=$({__name:"TestJsonEditorModal",setup(u,{expose:t}){t();const a=m(!1),e=m(JSON.stringify({name:"Test",value:123},null,2)),c=m(!1),d=m(JSON.stringify({editable:!0,count:0},null,2)),r={showModal:a,jsonValue:e,showEditableModal:c,editableJsonValue:d,Modal:Ve,JsonEditor:hv};return Object.defineProperty(r,"__isScriptSetup",{enumerable:!1,value:!0}),r}}),bv={class:"p-8"},yv={class:"space-y-4"},xv={class:"space-y-4"},kv={class:"space-y-4"};function _v(u,t,a,e,c,d){return s(),l("div",bv,[t[13]||(t[13]=o("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),o("div",yv,[o("div",null,[t[7]||(t[7]=o("h2",{class:"text-xl font-semibold mb-2"},"Read-only JsonEditor in Modal",-1)),t[8]||(t[8]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showModal=!0),"data-testid":"open-readonly-modal",class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),o("div",null,[t[9]||(t[9]=o("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),t[10]||(t[10]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),o("button",{onClick:t[1]||(t[1]=r=>e.showEditableModal=!0),"data-testid":"open-editable-modal",class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),i(" Read-only Modal "),S(e.Modal,{modelValue:e.showModal,"onUpdate:modelValue":t[3]||(t[3]=r=>e.showModal=r),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:ae(()=>[o("button",{onClick:t[2]||(t[2]=r=>e.showModal=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:ae(()=>[o("div",xv,[t[11]||(t[11]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),S(e.JsonEditor,{"model-value":e.jsonValue,readonly:!0,"data-testid":"readonly-json-editor"},null,8,["model-value"])])]),_:1},8,["modelValue"]),i(" Editable Modal "),S(e.Modal,{modelValue:e.showEditableModal,"onUpdate:modelValue":t[6]||(t[6]=r=>e.showEditableModal=r),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:ae(()=>[o("button",{onClick:t[5]||(t[5]=r=>e.showEditableModal=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:ae(()=>[o("div",kv,[t[12]||(t[12]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),S(e.JsonEditor,{modelValue:e.editableJsonValue,"onUpdate:modelValue":t[4]||(t[4]=r=>e.editableJsonValue=r),"data-testid":"editable-json-editor"},null,8,["modelValue"])])]),_:1},8,["modelValue"])])}const wv=Q(vv,[["render",_v],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestJsonEditorModal.vue"]]),kt="10000000-0000-0000-0000-000000000101",tt="10000000-0000-0000-0000-000000000102",Cv=$({__name:"TestPromptInterpolation",setup(u,{expose:t}){t();const a=m([]),e=m(null),c=m(null),d=m(""),r=m("Alice Johnson"),n=m("alice@example.com"),p=m("28"),{data:v,error:g}=ve(J(`/api/prompts/${kt}`)).json(),{data:f,error:h}=ve(J(`/api/prompts/${tt}`)).json();oe(v,C=>{if(C){e.value=C;try{a.value=JSON.parse(C.prompt)}catch(y){console.error("Failed to parse prompt A:",y)}}},{immediate:!0}),oe(f,C=>{C&&(c.value=C)},{immediate:!0});function w(C,y){return C.map(_=>{if(_.type==="string")return _.value||"";if(_.type==="variable"){const I=y[_.value];return I===void 0?`{{${_.value}}}`:typeof I=="string"?I:JSON.stringify(I)}else if(_.type==="prompt"){if(_.id===tt&&c.value)try{const I=JSON.parse(c.value.prompt);return w(I,y)}catch{return`[Error loading prompt: ${_.label}]`}return""}return""}).join("")}function x(){const C={name:r.value,email:n.value,age:p.value};d.value=w(a.value,C)}const k={PROMPT_A_ID:kt,PROMPT_B_ID:tt,promptTemplate:a,promptAData:e,promptBData:c,renderedOutput:d,inputName:r,inputEmail:n,inputAge:p,promptA:v,errorA:g,promptB:f,errorB:h,interpolatePrompt:w,renderPrompt:x};return Object.defineProperty(k,"__isScriptSetup",{enumerable:!1,value:!0}),k}}),Sv={class:"p-8 max-w-2xl mx-auto"},Tv={class:"mb-6"},Mv={"data-testid":"prompt-template",class:"p-4 bg-gray-100 dark:bg-gray-800 rounded font-mono text-sm"},Iv={key:0},Vv={class:"whitespace-pre-wrap"},Av={key:1,class:"text-gray-500"},Pv={class:"mb-6"},Ev={class:"space-y-2"},Ov={class:"mt-6"},jv={"data-testid":"rendered-output",class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},Lv={key:0,class:"font-mono"},Dv={key:1,class:"text-gray-500"};function Uv(u,t,a,e,c,d){return s(),l("div",Sv,[t[11]||(t[11]=o("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),o("div",Tv,[t[4]||(t[4]=o("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),o("div",Mv,[e.promptAData?(s(),l("div",Iv,[t[3]||(t[3]=o("div",{class:"font-bold mb-2"},"Prompt A:",-1)),o("pre",Vv,b(JSON.stringify(e.promptTemplate,null,2)),1)])):(s(),l("div",Av,"Loading..."))])]),o("div",Pv,[t[8]||(t[8]=o("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),o("div",Ev,[o("div",null,[t[5]||(t[5]=o("label",{class:"block text-sm mb-1"},"Name:",-1)),fe(o("input",{"data-testid":"input-name","onUpdate:modelValue":t[0]||(t[0]=r=>e.inputName=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputName]])]),o("div",null,[t[6]||(t[6]=o("label",{class:"block text-sm mb-1"},"Email:",-1)),fe(o("input",{"data-testid":"input-email","onUpdate:modelValue":t[1]||(t[1]=r=>e.inputEmail=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputEmail]])]),o("div",null,[t[7]||(t[7]=o("label",{class:"block text-sm mb-1"},"Age:",-1)),fe(o("input",{"data-testid":"input-age","onUpdate:modelValue":t[2]||(t[2]=r=>e.inputAge=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputAge]])])])]),o("button",{"data-testid":"render-button",onClick:e.renderPrompt,class:"px-4 py-2 bg-black text-white rounded hover:bg-gray-800"}," Render Prompt "),o("div",Ov,[t[9]||(t[9]=o("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),o("div",jv,[e.renderedOutput?(s(),l("div",Lv,b(e.renderedOutput),1)):(s(),l("div",Dv,'Click "Render Prompt" to see output'))]),t[10]||(t[10]=o("div",{class:"mt-4 p-4 bg-blue-50 dark:bg-blue-900 rounded text-sm"},[o("div",{class:"font-semibold mb-1"},"Expected Output (when feature is implemented):"),o("div",{class:"font-mono"},"User Profile: Alice Johnson <alice@example.com> (Age: 28)")],-1))])])}const qv=Q(Cv,[["render",Uv],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestPromptInterpolation.vue"]]),Dt=uo({history:po(Ge()),routes:[{path:"/login",name:"login",component:Of,meta:{public:!0}},{path:"/",name:"dashboard",component:$r},{path:"/agents",name:"agents",component:Vl},{path:"/threads",name:"threads",component:vt},{path:"/threads/:id",name:"thread-detail",component:vt},{path:"/prompts",name:"prompts",component:W2},{path:"/prompts/:id",name:"prompt-edit",component:Q2},{path:"/models",name:"models",component:e1},{path:"/providers",name:"providers",component:b1},{path:"/tools",name:"tools",component:af},{path:"/settings/users",name:"users",component:pf},{path:"/settings/api-keys",name:"api-keys",component:Cf},{path:"/test",name:"test",component:Th},{path:"/test-reference-input",name:"test-reference-input",component:Zh},{path:"/debug",name:"debug",component:ev},{path:"/test-prompt-input",name:"test-prompt-input",component:uv},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:wv},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:qv}]});Dt.beforeEach(async(u,t,a)=>{const e=u.meta.public===!0,c=localStorage.getItem("auth_token");!e&&!c?a({name:"login"}):e&&c&&u.name==="login"?a({name:"dashboard"}):a()});const Nv=window.fetch;window.fetch=async function(u,t){const a=typeof u=="string"?u:u instanceof URL?u.toString():u.url,e=Ge(),c=e==="/"?"/api/":`${e}/api/`,d=a.includes(c)||e==="/"&&a.startsWith("/api/");if(d){const p=localStorage.getItem("auth_token");p&&t?t.headers={...t.headers,Authorization:`Bearer ${p}`}:p&&(t={...t,headers:{Authorization:`Bearer ${p}`}})}const r=await Nv(u,t),n=a.includes("/api/auth/");return r.status===401&&d&&!n&&(localStorage.removeItem("auth_token"),window.location.href=J("/login")),r};const Ut=mo(Gr);Ut.use(Dt);Ut.mount("#app");
39
+ Description: ${p.meta?.description||"No description"}`)},PromptInput:jt};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}}),ov={class:"min-h-screen bg-white dark:bg-black p-8"},rv={class:"max-w-4xl mx-auto"},av={class:"space-y-8"},sv={class:"space-y-4"},lv={"data-testid":"prompt-input-test"},nv={class:"space-y-4"},iv={class:"p-4 bg-gray-100 dark:bg-gray-900 rounded-lg"},dv={"data-testid":"prompt-output",class:"text-sm text-black dark:text-white"};function cv(u,t,a,e,c,d){return s(),l("div",ov,[o("div",rv,[t[6]||(t[6]=o("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),o("div",av,[i(" Basic Example "),o("div",sv,[t[0]||(t[0]=o("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),t[1]||(t[1]=o("p",{class:"text-gray-600 dark:text-gray-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),o("div",lv,[S(e.PromptInput,{"model-value":e.promptValue,search:e.searchPrompts,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":e.handleUpdate,onSegmentClick:e.handleSegmentClick},null,8,["model-value"])])]),i(" Output Display "),o("div",nv,[t[3]||(t[3]=o("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),o("div",iv,[t[2]||(t[2]=o("h3",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Segments (value): ",-1)),o("pre",dv,b(JSON.stringify(e.promptValue,null,2)),1)])]),i(" Instructions "),t[4]||(t[4]=ot('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-gray-600 dark:text-gray-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li>The dialog will auto-close after typing 5+ characters without selection</li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div>',1)),i(" Test Scenarios "),t[5]||(t[5]=ot('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Variables</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Prompts</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Mixed Content</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-gray-300 dark:border-gray-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2">Edge Cases</h3><p class="text-sm text-gray-600 dark:text-gray-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',1))])])])}const uv=Q(tv,[["render",cv],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestPromptInput.vue"]]),pv=$({__name:"JsonEditor",props:{modelValue:{type:String,required:!0},placeholder:{type:String,required:!1},error:{type:String,required:!1},rows:{type:Number,required:!1},readonly:{type:Boolean,required:!1}},emits:["update:modelValue","blur"],setup(u,{expose:t,emit:a}){t(),self.MonacoEnvironment={getWorker(k,C){return C==="json"?new go:new fo}};const e=u,c=a,d=m(null);let r=null,n=!1;const p=m(!1),v={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:e.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},g=()=>{if(!(!r||e.readonly))try{const k=r.getValue(),C=JSON.parse(k),y=JSON.stringify(C,null,2);y!==k&&(n=!0,r.setValue(y),n=!1)}catch{}},f=()=>{p.value=document.documentElement.classList.contains("dark"),r&&gt.setTheme(p.value?"vs-dark":"vs")},h=()=>{d.value&&(r=gt.create(d.value,{value:e.modelValue||"{}",language:"json",theme:p.value?"vs-dark":"vs",...v})(d.value).__monacoEditor=r,r.onDidChangeModelContent(()=>{if(!n){const k=r.getValue();c("update:modelValue",k)}}),r.onDidBlurEditorText(()=>{c("blur"),g()}))};ce(async()=>{f(),await pe(),h();const k=new MutationObserver(f);k.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),Te(()=>{k.disconnect(),r&&r.dispose()})}),oe(()=>e.modelValue,k=>{r&&r.getValue()!==k&&(n=!0,r.setValue(k||""),n=!1)}),oe(()=>e.readonly,k=>{r&&r.updateOptions({readOnly:k})});const w=e.rows?`${e.rows*1.5}rem`:"18rem",x={props:e,emit:c,containerRef:d,get monacoEditor(){return r},set monacoEditor(k){r=k},get isUpdatingFromProp(){return n},set isUpdatingFromProp(k){n=k},isDark:p,editorOptions:v,formatJson:g,updateTheme:f,initEditor:h,editorHeight:w};return Object.defineProperty(x,"__isScriptSetup",{enumerable:!1,value:!0}),x}}),mv={class:"relative"},gv={key:0,class:"mt-1 text-sm text-red-500"};function fv(u,t,a,e,c,d){return s(),l("div",mv,[o("div",{class:ee(["border rounded overflow-hidden bg-white dark:bg-black",[a.error?"border-red-500":"border-black dark:border-white"]])},[o("div",{ref:"containerRef",class:"monaco-editor-container",style:lt({height:e.editorHeight})},null,4)],2),a.error?(s(),l("div",gv,b(a.error),1)):i("v-if",!0)])}const hv=Q(pv,[["render",fv],["__scopeId","data-v-903708b4"],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/components/JsonEditor.vue"]]),vv=$({__name:"TestJsonEditorModal",setup(u,{expose:t}){t();const a=m(!1),e=m(JSON.stringify({name:"Test",value:123},null,2)),c=m(!1),d=m(JSON.stringify({editable:!0,count:0},null,2)),r={showModal:a,jsonValue:e,showEditableModal:c,editableJsonValue:d,Modal:Ve,JsonEditor:hv};return Object.defineProperty(r,"__isScriptSetup",{enumerable:!1,value:!0}),r}}),bv={class:"p-8"},yv={class:"space-y-4"},xv={class:"space-y-4"},kv={class:"space-y-4"};function _v(u,t,a,e,c,d){return s(),l("div",bv,[t[13]||(t[13]=o("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),o("div",yv,[o("div",null,[t[7]||(t[7]=o("h2",{class:"text-xl font-semibold mb-2"},"Read-only JsonEditor in Modal",-1)),t[8]||(t[8]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),o("button",{onClick:t[0]||(t[0]=r=>e.showModal=!0),"data-testid":"open-readonly-modal",class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),o("div",null,[t[9]||(t[9]=o("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),t[10]||(t[10]=o("p",{class:"text-gray-600 dark:text-gray-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),o("button",{onClick:t[1]||(t[1]=r=>e.showEditableModal=!0),"data-testid":"open-editable-modal",class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),i(" Read-only Modal "),S(e.Modal,{modelValue:e.showModal,"onUpdate:modelValue":t[3]||(t[3]=r=>e.showModal=r),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:ae(()=>[o("button",{onClick:t[2]||(t[2]=r=>e.showModal=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:ae(()=>[o("div",xv,[t[11]||(t[11]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),S(e.JsonEditor,{"model-value":e.jsonValue,readonly:!0,"data-testid":"readonly-json-editor"},null,8,["model-value"])])]),_:1},8,["modelValue"]),i(" Editable Modal "),S(e.Modal,{modelValue:e.showEditableModal,"onUpdate:modelValue":t[6]||(t[6]=r=>e.showEditableModal=r),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:ae(()=>[o("button",{onClick:t[5]||(t[5]=r=>e.showEditableModal=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:ae(()=>[o("div",kv,[t[12]||(t[12]=o("p",{class:"text-sm text-gray-600 dark:text-gray-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),S(e.JsonEditor,{modelValue:e.editableJsonValue,"onUpdate:modelValue":t[4]||(t[4]=r=>e.editableJsonValue=r),"data-testid":"editable-json-editor"},null,8,["modelValue"])])]),_:1},8,["modelValue"])])}const wv=Q(vv,[["render",_v],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestJsonEditorModal.vue"]]),kt="10000000-0000-0000-0000-000000000101",tt="10000000-0000-0000-0000-000000000102",Cv=$({__name:"TestPromptInterpolation",setup(u,{expose:t}){t();const a=m([]),e=m(null),c=m(null),d=m(""),r=m("Alice Johnson"),n=m("alice@example.com"),p=m("28"),{data:v,error:g}=ve(J(`/api/prompts/${kt}`)).json(),{data:f,error:h}=ve(J(`/api/prompts/${tt}`)).json();oe(v,C=>{if(C){e.value=C;try{a.value=JSON.parse(C.prompt)}catch(y){console.error("Failed to parse prompt A:",y)}}},{immediate:!0}),oe(f,C=>{C&&(c.value=C)},{immediate:!0});function w(C,y){return C.map(_=>{if(_.type==="string")return _.value||"";if(_.type==="variable"){const V=y[_.value];return V===void 0?`{{${_.value}}}`:typeof V=="string"?V:JSON.stringify(V)}else if(_.type==="prompt"){if(_.id===tt&&c.value)try{const V=JSON.parse(c.value.prompt);return w(V,y)}catch{return`[Error loading prompt: ${_.label}]`}return""}return""}).join("")}function x(){const C={name:r.value,email:n.value,age:p.value};d.value=w(a.value,C)}const k={PROMPT_A_ID:kt,PROMPT_B_ID:tt,promptTemplate:a,promptAData:e,promptBData:c,renderedOutput:d,inputName:r,inputEmail:n,inputAge:p,promptA:v,errorA:g,promptB:f,errorB:h,interpolatePrompt:w,renderPrompt:x};return Object.defineProperty(k,"__isScriptSetup",{enumerable:!1,value:!0}),k}}),Sv={class:"p-8 max-w-2xl mx-auto"},Tv={class:"mb-6"},Mv={"data-testid":"prompt-template",class:"p-4 bg-gray-100 dark:bg-gray-800 rounded font-mono text-sm"},Iv={key:0},Vv={class:"whitespace-pre-wrap"},Av={key:1,class:"text-gray-500"},Pv={class:"mb-6"},Ev={class:"space-y-2"},Ov={class:"mt-6"},jv={"data-testid":"rendered-output",class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},Lv={key:0,class:"font-mono"},Dv={key:1,class:"text-gray-500"};function Uv(u,t,a,e,c,d){return s(),l("div",Sv,[t[11]||(t[11]=o("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),o("div",Tv,[t[4]||(t[4]=o("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),o("div",Mv,[e.promptAData?(s(),l("div",Iv,[t[3]||(t[3]=o("div",{class:"font-bold mb-2"},"Prompt A:",-1)),o("pre",Vv,b(JSON.stringify(e.promptTemplate,null,2)),1)])):(s(),l("div",Av,"Loading..."))])]),o("div",Pv,[t[8]||(t[8]=o("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),o("div",Ev,[o("div",null,[t[5]||(t[5]=o("label",{class:"block text-sm mb-1"},"Name:",-1)),fe(o("input",{"data-testid":"input-name","onUpdate:modelValue":t[0]||(t[0]=r=>e.inputName=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputName]])]),o("div",null,[t[6]||(t[6]=o("label",{class:"block text-sm mb-1"},"Email:",-1)),fe(o("input",{"data-testid":"input-email","onUpdate:modelValue":t[1]||(t[1]=r=>e.inputEmail=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputEmail]])]),o("div",null,[t[7]||(t[7]=o("label",{class:"block text-sm mb-1"},"Age:",-1)),fe(o("input",{"data-testid":"input-age","onUpdate:modelValue":t[2]||(t[2]=r=>e.inputAge=r),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[_e,e.inputAge]])])])]),o("button",{"data-testid":"render-button",onClick:e.renderPrompt,class:"px-4 py-2 bg-black text-white rounded hover:bg-gray-800"}," Render Prompt "),o("div",Ov,[t[9]||(t[9]=o("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),o("div",jv,[e.renderedOutput?(s(),l("div",Lv,b(e.renderedOutput),1)):(s(),l("div",Dv,'Click "Render Prompt" to see output'))]),t[10]||(t[10]=o("div",{class:"mt-4 p-4 bg-blue-50 dark:bg-blue-900 rounded text-sm"},[o("div",{class:"font-semibold mb-1"},"Expected Output (when feature is implemented):"),o("div",{class:"font-mono"},"User Profile: Alice Johnson <alice@example.com> (Age: 28)")],-1))])])}const qv=Q(Cv,[["render",Uv],["__file","/Users/justinschroeder/Projects/agentbuilder/packages/builder/ui/src/views/TestPromptInterpolation.vue"]]),Dt=uo({history:po(Ge()),routes:[{path:"/login",name:"login",component:Of,meta:{public:!0}},{path:"/",name:"dashboard",component:$r},{path:"/agents",name:"agents",component:Vl},{path:"/threads",name:"threads",component:vt},{path:"/threads/:id",name:"thread-detail",component:vt},{path:"/prompts",name:"prompts",component:W2},{path:"/prompts/:id",name:"prompt-edit",component:Q2},{path:"/models",name:"models",component:e1},{path:"/providers",name:"providers",component:b1},{path:"/tools",name:"tools",component:af},{path:"/settings/users",name:"users",component:pf},{path:"/settings/api-keys",name:"api-keys",component:Cf},{path:"/test",name:"test",component:Th},{path:"/test-reference-input",name:"test-reference-input",component:Zh},{path:"/debug",name:"debug",component:ev},{path:"/test-prompt-input",name:"test-prompt-input",component:uv},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:wv},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:qv}]});Dt.beforeEach(async(u,t,a)=>{const e=u.meta.public===!0,c=localStorage.getItem("auth_token");!e&&!c?a({name:"login"}):e&&c&&u.name==="login"?a({name:"dashboard"}):a()});const Nv=window.fetch;window.fetch=async function(u,t){const a=typeof u=="string"?u:u instanceof URL?u.toString():u.url,e=Ge(),c=e==="/"?"/api/":`${e}/api/`,d=a.includes(c)||e==="/"&&a.startsWith("/api/");if(d){const p=localStorage.getItem("auth_token");p&&t?t.headers={...t.headers,Authorization:`Bearer ${p}`}:p&&(t={...t,headers:{Authorization:`Bearer ${p}`}})}const r=await Nv(u,t),n=a.includes("/api/auth/");return r.status===401&&d&&!n&&(localStorage.removeItem("auth_token"),window.location.href=J("/login")),r};const Ut=mo(Gr);Ut.use(Dt);Ut.mount("#app");