@newsails/veil-studio 1.0.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.
- package/README.md +181 -0
- package/bin/veil-studio.js +142 -0
- package/nuxt-app/.output/public/200.html +13 -0
- package/nuxt-app/.output/public/404.html +13 -0
- package/nuxt-app/.output/public/_nuxt/builds/latest.json +1 -0
- package/nuxt-app/.output/public/_nuxt/builds/meta/6b28df26-54af-4fad-a1f0-38808960d9fe.json +1 -0
- package/nuxt-app/.output/public/_nuxt/entry.BrrOeBSX.js +120 -0
- package/nuxt-app/.output/public/_nuxt/entry.CYnp7zY5.css +1 -0
- package/nuxt-app/.output/public/_nuxt/error-404.BbdzCaXe.js +1 -0
- package/nuxt-app/.output/public/_nuxt/error-404.JekaaCis.css +1 -0
- package/nuxt-app/.output/public/_nuxt/error-500.CNP9nqm1.css +1 -0
- package/nuxt-app/.output/public/_nuxt/error-500.DbOlBIIY.js +1 -0
- package/nuxt-app/.output/public/_nuxt/index.BEoXSIOu.css +1 -0
- package/nuxt-app/.output/public/_nuxt/index.CNms2yAq.js +1 -0
- package/nuxt-app/.output/public/_nuxt/materialdesignicons-webfont.B7mPwVP_.ttf +0 -0
- package/nuxt-app/.output/public/_nuxt/materialdesignicons-webfont.CSr8KVlo.eot +0 -0
- package/nuxt-app/.output/public/_nuxt/materialdesignicons-webfont.Dp5v-WZN.woff2 +0 -0
- package/nuxt-app/.output/public/_nuxt/materialdesignicons-webfont.PXm3-2wK.woff +0 -0
- package/nuxt-app/.output/public/_nuxt/vue.-sixQ7xP.BlWffD__.js +1 -0
- package/nuxt-app/.output/public/index.html +13 -0
- package/package.json +37 -0
- package/server/index.js +184 -0
- package/server/routes/files.js +80 -0
- package/server/socket.js +507 -0
- package/server/utils/board-state.js +357 -0
- package/server/utils/config.js +51 -0
- package/server/utils/db.js +484 -0
- package/server/utils/element-instances.js +104 -0
- package/server/utils/element-registry.js +127 -0
- package/server/utils/elements/agent-instance.js +62 -0
- package/server/utils/elements/agent.js +93 -0
- package/server/utils/elements/annotation.js +30 -0
- package/server/utils/elements/approval-gate.js +49 -0
- package/server/utils/elements/assumption.js +32 -0
- package/server/utils/elements/blocker.js +36 -0
- package/server/utils/elements/chat-room.js +47 -0
- package/server/utils/elements/chat-view.js +33 -0
- package/server/utils/elements/code-block.js +39 -0
- package/server/utils/elements/collapsible-group.js +37 -0
- package/server/utils/elements/comparison-table.js +38 -0
- package/server/utils/elements/constraint.js +32 -0
- package/server/utils/elements/decision.js +39 -0
- package/server/utils/elements/diff-patch.js +38 -0
- package/server/utils/elements/divider.js +30 -0
- package/server/utils/elements/document-draft.js +35 -0
- package/server/utils/elements/fact-claim.js +36 -0
- package/server/utils/elements/feedback-request.js +43 -0
- package/server/utils/elements/file-reference.js +31 -0
- package/server/utils/elements/filter.js +48 -0
- package/server/utils/elements/generator.js +51 -0
- package/server/utils/elements/goal.js +36 -0
- package/server/utils/elements/html.js +35 -0
- package/server/utils/elements/idea.js +32 -0
- package/server/utils/elements/image-local.js +21 -0
- package/server/utils/elements/image.js +34 -0
- package/server/utils/elements/json-object.js +47 -0
- package/server/utils/elements/label-tag.js +30 -0
- package/server/utils/elements/markdown.js +37 -0
- package/server/utils/elements/merger.js +36 -0
- package/server/utils/elements/message.js +40 -0
- package/server/utils/elements/milestone.js +44 -0
- package/server/utils/elements/notification.js +34 -0
- package/server/utils/elements/outline.js +35 -0
- package/server/utils/elements/primitive.js +36 -0
- package/server/utils/elements/pro-con-list.js +39 -0
- package/server/utils/elements/processor.js +54 -0
- package/server/utils/elements/project.js +40 -0
- package/server/utils/elements/question.js +42 -0
- package/server/utils/elements/queue.js +85 -0
- package/server/utils/elements/research-note.js +41 -0
- package/server/utils/elements/section.js +35 -0
- package/server/utils/elements/source-collection.js +45 -0
- package/server/utils/elements/splitter.js +42 -0
- package/server/utils/elements/status-update.js +38 -0
- package/server/utils/elements/task.js +72 -0
- package/server/utils/elements/template.js +46 -0
- package/server/utils/elements/test-case.js +42 -0
- package/server/utils/elements/text.js +29 -0
- package/server/utils/elements/todo-list.js +57 -0
- package/server/utils/elements/url-card.js +37 -0
- package/server/utils/elements/web-search-query.js +46 -0
- package/server/utils/elements/web-snapshot.js +37 -0
- package/server/utils/file-utils.js +88 -0
- package/server/utils/session-watcher.js +108 -0
- package/server/utils/socket-io.js +14 -0
- package/server/utils/veil-client.js +185 -0
- package/server/utils/veil-ws.js +207 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as w,d as z,o as A,a as B,r as E,b as L,c as T,h as _,e as j,j as U,p as I,f as V,g as D,i as y,k as P,l as C,m as N,n as F,w as H,q as O,s as $,_ as M,t as G,v as Q,x as m,y as k,z as W,A as X,B as J}from"./entry.BrrOeBSX.js";import{u as K}from"./vue.-sixQ7xP.BlWffD__.js";async function R(t,a=w()){const{path:i,matched:e}=a.resolve(t);if(!e.length||(a._routePreloaded||(a._routePreloaded=new Set),a._routePreloaded.has(i)))return;const r=a._preloadPromises=a._preloadPromises||[];if(r.length>4)return Promise.all(r).then(()=>R(t,a));a._routePreloaded.add(i);const s=e.map(c=>{var n;return(n=c.components)==null?void 0:n.default}).filter(c=>typeof c=="function");for(const c of s){const n=Promise.resolve(c()).catch(()=>{}).finally(()=>r.splice(r.indexOf(n)));r.push(n)}await Promise.all(r)}const Y=(...t)=>t.find(a=>a!==void 0),Z="noopener noreferrer";function ee(t){const a=t.componentName||"NuxtLink",i=(e,r)=>{if(!e||t.trailingSlash!=="append"&&t.trailingSlash!=="remove")return e;if(typeof e=="string")return S(e,t.trailingSlash);const s="path"in e?e.path:r(e).path;return{...e,name:void 0,path:S(s,t.trailingSlash)}};return z({name:a,props:{to:{type:[String,Object],default:void 0,required:!1},href:{type:[String,Object],default:void 0,required:!1},target:{type:String,default:void 0,required:!1},rel:{type:String,default:void 0,required:!1},noRel:{type:Boolean,default:void 0,required:!1},prefetch:{type:Boolean,default:void 0,required:!1},noPrefetch:{type:Boolean,default:void 0,required:!1},activeClass:{type:String,default:void 0,required:!1},exactActiveClass:{type:String,default:void 0,required:!1},prefetchedClass:{type:String,default:void 0,required:!1},replace:{type:Boolean,default:void 0,required:!1},ariaCurrentValue:{type:String,default:void 0,required:!1},external:{type:Boolean,default:void 0,required:!1},custom:{type:Boolean,default:void 0,required:!1}},setup(e,{slots:r}){const s=w(),c=D(),n=y(()=>{const o=e.to||e.href||"";return i(o,s.resolve)}),f=y(()=>typeof n.value=="string"&&P(n.value,{acceptRelative:!0})),h=y(()=>e.external||e.target&&e.target!=="_self"?!0:typeof n.value=="object"?!1:n.value===""||f.value),x=C(!1),p=C(null),q=o=>{var d;p.value=e.custom?(d=o==null?void 0:o.$el)==null?void 0:d.nextElementSibling:o==null?void 0:o.$el};if(e.prefetch!==!1&&e.noPrefetch!==!0&&e.target!=="_blank"&&!ne()){const d=N();let v,l=null;A(()=>{const b=ae();B(()=>{v=E(()=>{var g;(g=p==null?void 0:p.value)!=null&&g.tagName&&(l=b.observe(p.value,async()=>{l==null||l(),l=null;const u=typeof n.value=="string"?n.value:s.resolve(n.value).fullPath;await Promise.all([d.hooks.callHook("link:prefetch",u).catch(()=>{}),!h.value&&R(n.value,s).catch(()=>{})]),x.value=!0}))})})}),L(()=>{v&&T(v),l==null||l(),l=null})}return()=>{var b,g;if(!h.value){const u={ref:q,to:n.value,activeClass:e.activeClass||t.activeClass,exactActiveClass:e.exactActiveClass||t.exactActiveClass,replace:e.replace,ariaCurrentValue:e.ariaCurrentValue,custom:e.custom};return e.custom||(x.value&&(u.class=e.prefetchedClass||t.prefetchedClass),u.rel=e.rel),_(j("RouterLink"),u,r.default)}const o=typeof n.value=="object"?((b=s.resolve(n.value))==null?void 0:b.href)??null:n.value&&!e.external&&!f.value?i(U(c.app.baseURL,n.value),s.resolve):n.value||null,d=e.target||null,v=e.noRel?null:Y(e.rel,t.externalRelAttribute,o?Z:"")||null,l=()=>F(o,{replace:e.replace});return e.custom?r.default?r.default({href:o,navigate:l,get route(){if(!o)return;const u=I(o);return{path:u.pathname,fullPath:u.pathname,get query(){return V(u.search)},hash:u.hash,params:{},name:void 0,matched:[],redirectedFrom:void 0,meta:{},href:o}},rel:v,target:d,isExternal:h.value,isActive:!1,isExactActive:!1}):null:_("a",{ref:p,href:o,rel:v,target:d},(g=r.default)==null?void 0:g.call(r))}}})}const te=ee($);function S(t,a){const i=a==="append"?H:O;return P(t)&&!t.startsWith("http")?t:i(t,!0)}function ae(){const t=N();if(t._observer)return t._observer;let a=null;const i=new Map,e=(s,c)=>(a||(a=new IntersectionObserver(n=>{for(const f of n){const h=i.get(f.target);(f.isIntersecting||f.intersectionRatio>0)&&h&&h()}})),i.set(s,c),a.observe(s),()=>{i.delete(s),a.unobserve(s),i.size===0&&(a.disconnect(),a=null)});return t._observer={observe:e}}function ne(){const t=navigator.connection;return!!(t&&(t.saveData||/2g/.test(t.effectiveType)))}const re={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},oe={class:"max-w-520px text-center z-20"},se=["textContent"],ie=["textContent"],le={class:"w-full flex items-center justify-center"},ue={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const a=t;return K({title:`${a.statusCode} - ${a.statusMessage} | ${a.appName}`,script:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,p{margin:0}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(i,e)=>{const r=te;return G(),Q("div",re,[e[0]||(e[0]=m("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),m("div",oe,[m("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:k(t.statusCode)},null,8,se),m("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:k(t.description)},null,8,ie),m("div",le,[W(r,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:X(()=>[J(k(t.backHome),1)]),_:1})])])])}}},fe=M(ue,[["__scopeId","data-v-73a07988"]]);export{fe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-73a07988]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-73a07988]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-73a07988]{background-color:#ffffff4d}.gradient-border[data-v-73a07988]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-73a07988]{background-color:#1414144d}.gradient-border[data-v-73a07988]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-73a07988]:before{background-size:400% auto;border-radius:.5rem;bottom:0;content:"";left:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:.5;padding:2px;position:absolute;right:0;top:0;transition:background-position .3s ease-in-out,opacity .2s ease-in-out;width:100%}.gradient-border[data-v-73a07988]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-73a07988]{position:fixed}.left-0[data-v-73a07988]{left:0}.right-0[data-v-73a07988]{right:0}.z-10[data-v-73a07988]{z-index:10}.z-20[data-v-73a07988]{z-index:20}.grid[data-v-73a07988]{display:grid}.mb-16[data-v-73a07988]{margin-bottom:4rem}.mb-8[data-v-73a07988]{margin-bottom:2rem}.max-w-520px[data-v-73a07988]{max-width:520px}.min-h-screen[data-v-73a07988]{min-height:100vh}.w-full[data-v-73a07988]{width:100%}.flex[data-v-73a07988]{display:flex}.cursor-pointer[data-v-73a07988]{cursor:pointer}.place-content-center[data-v-73a07988]{place-content:center}.items-center[data-v-73a07988]{align-items:center}.justify-center[data-v-73a07988]{justify-content:center}.overflow-hidden[data-v-73a07988]{overflow:hidden}.bg-white[data-v-73a07988]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-73a07988]{padding-left:1rem;padding-right:1rem}.px-8[data-v-73a07988]{padding-left:2rem;padding-right:2rem}.py-2[data-v-73a07988]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-73a07988]{text-align:center}.text-8xl[data-v-73a07988]{font-size:6rem;line-height:1}.text-xl[data-v-73a07988]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-73a07988]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-73a07988]{font-weight:300}.font-medium[data-v-73a07988]{font-weight:500}.leading-tight[data-v-73a07988]{line-height:1.25}.font-sans[data-v-73a07988]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-73a07988]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-73a07988]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-73a07988]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-73a07988]{padding-left:0;padding-right:0}.sm\:px-6[data-v-73a07988]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-73a07988]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-73a07988]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-73a07988]{font-size:1.25rem;line-height:1.75rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.spotlight[data-v-6fdef64d]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-6fdef64d]{position:fixed}.-bottom-1\/2[data-v-6fdef64d]{bottom:-50%}.left-0[data-v-6fdef64d]{left:0}.right-0[data-v-6fdef64d]{right:0}.grid[data-v-6fdef64d]{display:grid}.mb-16[data-v-6fdef64d]{margin-bottom:4rem}.mb-8[data-v-6fdef64d]{margin-bottom:2rem}.h-1\/2[data-v-6fdef64d]{height:50%}.max-w-520px[data-v-6fdef64d]{max-width:520px}.min-h-screen[data-v-6fdef64d]{min-height:100vh}.place-content-center[data-v-6fdef64d]{place-content:center}.overflow-hidden[data-v-6fdef64d]{overflow:hidden}.bg-white[data-v-6fdef64d]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-6fdef64d]{padding-left:2rem;padding-right:2rem}.text-center[data-v-6fdef64d]{text-align:center}.text-8xl[data-v-6fdef64d]{font-size:6rem;line-height:1}.text-xl[data-v-6fdef64d]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-6fdef64d]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-6fdef64d]{font-weight:300}.font-medium[data-v-6fdef64d]{font-weight:500}.leading-tight[data-v-6fdef64d]{line-height:1.25}.font-sans[data-v-6fdef64d]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-6fdef64d]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-6fdef64d]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-6fdef64d]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-6fdef64d]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-6fdef64d]{font-size:2.25rem;line-height:2.5rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as a}from"./vue.-sixQ7xP.BlWffD__.js";import{_ as s,t as i,v as u,x as t,y as o}from"./entry.BrrOeBSX.js";const l={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},d={class:"max-w-520px text-center"},c=["textContent"],p=["textContent"],g={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(e){const n=e;return a({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[],style:[{children:'*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(b,r)=>(i(),u("div",l,[r[0]||(r[0]=t("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),t("div",d,[t("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:o(e.statusCode)},null,8,c),t("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:o(e.description)},null,8,p)])]))}},m=s(g,[["__scopeId","data-v-6fdef64d"]]);export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.palette-item[data-v-d0de459d]{align-items:center;border-radius:.5rem;cursor:pointer;display:flex;gap:.5rem;padding:.25rem .5rem;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);-webkit-user-select:none;-moz-user-select:none;user-select:none}.palette-item[data-v-d0de459d]:hover{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.tag-chip[data-v-d0de459d]{border-radius:9999px;border-width:1px;cursor:pointer;font-size:9px;padding:.125rem .5rem;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);-webkit-user-select:none;-moz-user-select:none;user-select:none}.tag-chip-active[data-v-d0de459d]{background-color:#3b82f61a;border-color:rgb(59 130 246/var(--tw-border-opacity,1));color:rgb(59 130 246/var(--tw-text-opacity,1))}.tag-chip-active[data-v-d0de459d],.tag-chip-inactive[data-v-d0de459d]{--tw-border-opacity:1;--tw-text-opacity:1}.tag-chip-inactive[data-v-d0de459d]{background-color:transparent;border-color:rgb(51 65 85/var(--tw-border-opacity,1));color:rgb(100 116 139/var(--tw-text-opacity,1))}.tag-chip-inactive[data-v-d0de459d]:hover{--tw-border-opacity:1;border-color:rgb(100 116 139/var(--tw-border-opacity,1));--tw-text-opacity:1;color:rgb(203 213 225/var(--tw-text-opacity,1))}@keyframes flow-972a93f9{0%{stroke-dashoffset:24}to{stroke-dashoffset:0}}.link-flow[data-v-972a93f9]{animation:flow-972a93f9 1.2s linear infinite;stroke-dasharray:8 4}.z-normal[data-v-4234675e]{z-index:3}.z-selected[data-v-4234675e]{z-index:100}.z-dragging[data-v-4234675e]{z-index:200}.fading[data-v-4234675e]{opacity:.5;transition:opacity 2s,height 2s}.canvas-element[data-v-4234675e]{transition:box-shadow .1s}.toolbar-btn[data-v-7f7a6b6b]{border-radius:.25rem;font-size:.75rem;line-height:1rem;padding:.125rem .5rem;--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1));transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.toolbar-btn[data-v-7f7a6b6b]:hover{background-color:#33415599;--tw-text-opacity:1;color:rgb(241 245 249/var(--tw-text-opacity,1))}.ctx-item[data-v-db0833bf]{font-size:.875rem;line-height:1.25rem;padding:.375rem .75rem;text-align:left;width:100%;--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1));transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ctx-item[data-v-db0833bf]:hover{--tw-bg-opacity:1;background-color:rgb(51 65 85/var(--tw-bg-opacity,1))}.field-label[data-v-93baa80e]{font-size:10px;font-weight:500;letter-spacing:.025em;margin-bottom:0;text-transform:uppercase;--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.field-input[data-v-93baa80e]{border-radius:.5rem;border-width:1px;width:100%;--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1));font-size:.75rem;line-height:1rem;padding:.375rem .5rem;--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.field-input[data-v-93baa80e]::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(71 85 105/var(--tw-placeholder-opacity,1))}.field-input[data-v-93baa80e]::placeholder{--tw-placeholder-opacity:1;color:rgb(71 85 105/var(--tw-placeholder-opacity,1))}.field-input[data-v-93baa80e]{outline:2px solid transparent;outline-offset:2px;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.field-input[data-v-93baa80e]:focus{--tw-border-opacity:1;border-color:rgb(168 85 247/var(--tw-border-opacity,1))}.toggle-btn[data-v-93baa80e]{align-items:center;display:inline-flex;flex-shrink:0;height:1.25rem;position:relative;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);width:2.25rem}.toggle-btn[data-v-93baa80e],.toggle-knob[data-v-93baa80e]{border-radius:9999px}.toggle-knob[data-v-93baa80e]{display:inline-block;height:.875rem;width:.875rem;--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1));transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.hint[data-v-93baa80e]{font-size:10px;--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.studio-root[data-v-043c6a99]{outline:none}.w-90[data-v-043c6a99]{width:360px}.w-agent-editor[data-v-043c6a99]{width:420px}.panel-left-enter-active[data-v-043c6a99],.panel-left-leave-active[data-v-043c6a99],.panel-right-enter-active[data-v-043c6a99],.panel-right-leave-active[data-v-043c6a99]{overflow:hidden;transition:width .2s ease,opacity .2s ease}.panel-left-enter-from[data-v-043c6a99],.panel-left-leave-to[data-v-043c6a99],.panel-right-enter-from[data-v-043c6a99],.panel-right-leave-to[data-v-043c6a99]{opacity:0;width:0!important}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as de,l as A,t as l,v as s,x as e,J,K as Xe,L as me,y as P,M as L,N as O,O as oe,P as M,T as Ze,Q as Ge,i as N,R as we,S as Ce,o as Ie,U as ie,B as Ee,V as Re,z as be,W as Oe,F as Me,X as y,Y as W,Z as ne,$ as ot,a0 as ze,a1 as Te,a2 as nt,a3 as qe,a4 as ge,a5 as Ke,a6 as _e,_ as Pe,a7 as lt,a8 as st,a9 as Qe,aa as at,A as Ne,ab as rt,ac as it,ad as dt,ae as ut,af as Fe}from"./entry.BrrOeBSX.js";const ct={class:"relative"},pt={key:0,class:"fixed top-12 right-4 z-[9999] w-[640px] max-h-[70vh] flex flex-col rounded-xl border border-slate-700 bg-slate-950 shadow-2xl overflow-hidden"},xt={class:"flex items-center gap-2 px-3 py-2 border-b border-slate-800 flex-shrink-0"},vt={class:"text-[10px] text-slate-600"},mt={class:"flex gap-1 px-3 py-1.5 border-b border-slate-800 flex-shrink-0 flex-wrap"},ft=["onClick"],bt={class:"flex-1 overflow-y-auto font-mono text-[10px] px-1 py-1"},gt={class:"text-slate-600 flex-shrink-0 w-24"},yt={class:"text-slate-400 flex-shrink-0 max-w-[180px] truncate"},ht={class:"text-slate-600 flex-1 truncate"},kt={key:0,class:"text-center text-slate-700 py-8"},wt=de({__name:"DebugPanel",setup(g){const o=Ge(),{entries:d}=o,S=A(!1),m=A(!1),p=["emit","recv","info","error"],v=A(new Set(p));function x($){v.value.has($)?v.value.delete($):v.value.add($)}const h=N(()=>d.value.filter($=>v.value.has($.direction)));function a($){return{emit:"text-blue-400",recv:"text-green-400",info:"text-slate-400",error:"text-red-400"}[$]??"text-slate-400"}function i($){return{emit:"bg-blue-500/20 border-blue-500/40 text-blue-300",recv:"bg-green-500/20 border-green-500/40 text-green-300",info:"bg-slate-700/40 border-slate-600 text-slate-300",error:"bg-red-500/20 border-red-500/40 text-red-300"}[$]??""}function f(){o.copyAll(),m.value=!0,setTimeout(()=>{m.value=!1},2e3)}return($,j)=>(l(),s("div",ct,[e("button",{class:J(["flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-mono border transition-colors",S.value?"bg-amber-600/20 border-amber-500/40 text-amber-300":"bg-slate-800 border-slate-700 text-slate-500 hover:text-slate-300 hover:border-slate-600"]),title:"Debug log",onClick:j[0]||(j[0]=n=>S.value=!S.value)},[...j[4]||(j[4]=[Xe('<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2l1.88 1.88"></path><path d="M14.12 3.88L16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 116 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 014-4h4a4 4 0 014 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"></path></svg>',1)])],2),(l(),me(Ze,{to:"body"},[S.value?(l(),s("div",pt,[e("div",xt,[j[5]||(j[5]=e("span",{class:"text-xs font-semibold text-slate-300 flex-1"},"Debug Log",-1)),e("span",vt,P(L(d).length)+" entries",1),e("button",{class:"text-[10px] text-slate-500 hover:text-slate-300 px-2 py-0.5 rounded border border-slate-700 hover:border-slate-600",onClick:j[1]||(j[1]=n=>m.value?null:f())},P(m.value?"✓ Copied":"Copy All"),1),e("button",{class:"text-[10px] text-slate-500 hover:text-red-400 px-2 py-0.5 rounded border border-slate-700 hover:border-slate-600",onClick:j[2]||(j[2]=n=>L(o).clear())},"Clear"),e("button",{class:"text-slate-500 hover:text-slate-200 p-1 rounded hover:bg-slate-800",onClick:j[3]||(j[3]=n=>S.value=!1)},"✕")]),e("div",mt,[(l(),s(O,null,oe(p,n=>e("button",{key:n,class:J(["text-[9px] px-1.5 py-0.5 rounded-full border font-mono transition-colors",v.value.has(n)?i(n)+" border-opacity-60":"bg-transparent border-slate-700 text-slate-600"]),onClick:c=>x(n)},P(n),11,ft)),64))]),e("div",bt,[(l(!0),s(O,null,oe(h.value,(n,c)=>(l(),s("div",{key:c,class:"flex items-start gap-1.5 px-2 py-0.5 rounded hover:bg-slate-900"},[e("span",gt,P(n.ts),1),e("span",{class:J(["flex-shrink-0 w-10 font-bold uppercase text-[9px]",a(n.direction)])},P(n.direction),3),e("span",yt,P(n.event),1),e("span",ht,P(n.detail),1)]))),128)),h.value.length?M("",!0):(l(),s("div",kt,"No entries"))])])):M("",!0)]))]))}}),_t={key:0,class:"text-xs text-slate-500 font-mono truncate max-w-48 hidden sm:block"},Ct={class:"flex items-center gap-1.5"},$t=["title"],St={class:"text-xs text-slate-500 hidden sm:block"},Mt={key:1,class:"flex items-center gap-1 text-xs text-slate-500"},Pt={class:"flex items-center gap-1.5 ml-1"},Et=["title"],zt={style:{"-webkit-app-region":"no-drag"}},It={key:2,class:"flex items-center gap-0.5 ml-1",style:{"-webkit-app-region":"no-drag"}},Tt=de({__name:"StudioHeader",setup(g){const o=we(),d=Ce(),S=N(()=>{const a=d.meta.projectDir??"";return a?a.split("/").filter(Boolean).pop()??a:""}),m=N(()=>d.elements.filter(a=>a.type==="agent").length),p=A(!1);Ie(()=>{p.value=typeof window<"u"&&!!window.electronWin});function v(){var a;(a=window.electronWin)==null||a.minimize()}function x(){var a;(a=window.electronWin)==null||a.maximize()}function h(){var a;(a=window.electronWin)==null||a.close()}return(a,i)=>{const f=wt;return l(),s("header",{class:"flex items-center gap-2 px-3 h-10 border-b border-slate-800 bg-slate-950 flex-shrink-0 z-50 select-none",style:ie(p.value?{"-webkit-app-region":"drag"}:{})},[e("button",{class:"text-slate-400 hover:text-slate-200 transition-colors p-1 rounded hover:bg-slate-800",style:{"-webkit-app-region":"no-drag"},title:"Toggle panel",onClick:i[0]||(i[0]=$=>L(o).leftPanelOpen=!L(o).leftPanelOpen)},"☰"),i[4]||(i[4]=e("span",{class:"text-sm font-bold text-slate-100 tracking-tight"},[Ee("Veil "),e("span",{class:"text-wire-blue"},"Studio")],-1)),S.value?(l(),s("span",_t,P(S.value),1)):M("",!0),i[5]||(i[5]=e("div",{class:"flex-1"},null,-1)),e("div",Ct,[e("span",{class:J(["w-2 h-2 rounded-full flex-shrink-0 transition-colors",L(o).veilConnected?"bg-green-400":"bg-slate-600"]),title:L(o).veilConnected?"VeilCLI connected":"VeilCLI disconnected"},null,10,$t),e("span",St,P(L(o).veilConnected?"CLI":"No CLI"),1)]),m.value>0?(l(),s("div",Mt,[e("span",null,P(m.value)+" agent"+P(m.value!==1?"s":""),1)])):M("",!0),e("div",Pt,[e("span",{class:J(["w-2 h-2 rounded-full flex-shrink-0",L(Re)?"bg-wire-blue animate-pulse":"bg-slate-700"]),title:L(Re)?"Connected to Studio":"Disconnected"},null,10,Et)]),e("div",zt,[be(f)]),p.value?(l(),s("div",It,[e("button",{class:"w-7 h-7 flex items-center justify-center rounded text-slate-500 hover:text-slate-200 hover:bg-slate-700 transition-colors text-sm",title:"Minimize",onClick:i[1]||(i[1]=$=>v())},"–"),e("button",{class:"w-7 h-7 flex items-center justify-center rounded text-slate-500 hover:text-slate-200 hover:bg-slate-700 transition-colors text-xs",title:"Maximize / Restore",onClick:i[2]||(i[2]=$=>x())},"□"),e("button",{class:"w-7 h-7 flex items-center justify-center rounded text-slate-500 hover:text-red-400 hover:bg-red-500/20 transition-colors text-xs",title:"Close",onClick:i[3]||(i[3]=$=>h())},"✕")])):M("",!0)],4)}}});function ee(g,o={}){const d=Ge();return new Promise((S,m)=>{const p=Oe();if(!p){const v="No socket — call useSocket() first";return d.error(g,v),m(new Error(v))}if(!p.connected){const v=`socket not connected (state=${p.disconnected?"disconnected":"connecting"})`;return d.error(g,v),m(new Error(v))}d.emit(g,JSON.stringify(o).slice(0,120)),p.emit(g,o,v=>{v!=null&&v.error?(d.error(g+":ack",v.error),m(new Error(v.error))):(d.recv(g+":ack",JSON.stringify(v).slice(0,120)),S(v))})})}function He(){return{getAgents:()=>ee("veil:get-agents"),createAgent:z=>ee("veil:create-agent",{data:z}),getAgent:z=>ee("veil:get-agent",{name:z}),updateAgent:(z,q)=>ee("veil:update-agent",{name:z,data:q}),deleteAgent:z=>ee("veil:delete-agent",{name:z}),reloadAgent:z=>ee("veil:reload-agent",{name:z}),getAgentSkills:z=>ee("veil:get-agent-skills",{name:z}),getSessions:z=>ee("veil:get-sessions",{agentName:z}),createSession:z=>ee("veil:create-session",{agentName:z}),getSession:z=>ee("veil:get-session",{id:z}),deleteSession:z=>ee("veil:delete-session",{id:z}),getSessionMessages:z=>ee("veil:get-session-messages",{id:z}),resetSession:z=>ee("veil:reset-session",{id:z}),createTask:(z,q)=>ee("veil:create-task",{agentName:z,prompt:q}),getTasks:z=>ee("veil:get-tasks",{agentName:z}),getTask:z=>ee("veil:get-task",{id:z}),cancelTask:z=>ee("veil:cancel-task",{id:z}),respondTask:(z,q)=>ee("veil:respond-task",{id:z,message:q}),getDaemons:()=>ee("veil:get-daemons"),daemonStart:z=>ee("veil:daemon-start",{agentName:z}),daemonStop:z=>ee("veil:daemon-stop",{agentName:z}),daemonTrigger:z=>ee("veil:daemon-trigger",{agentName:z}),getMemory:(z,q="agent")=>ee("veil:get-memory",{agentName:z,level:q}),getMemoryFile:(z,q,se="agent")=>ee("veil:get-memory-file",{agentName:q,file:z,level:se}),updateMemoryFile:(z,q,se,ye="agent")=>ee("veil:update-memory-file",{agentName:se,file:z,content:q,level:ye}),deleteMemoryFile:(z,q,se="agent")=>ee("veil:delete-memory-file",{agentName:q,file:z,level:se}),getModels:()=>ee("veil:get-models"),getAgentMd:z=>ee("veil:get-agent-md",{name:z}),getSettings:()=>ee("veil:get-settings"),updateSettings:z=>ee("veil:update-settings",{settings:z})}}const Dt={class:"model-picker-input"},At={class:"relative"},Lt=["disabled"],Vt={key:0,class:"flex-1 text-slate-200 font-mono truncate"},jt={key:1,class:"flex-1 text-slate-600"},Nt={key:0,class:"mt-1.5 bg-slate-800/60 border border-slate-700/60 rounded-lg p-2.5 flex flex-col gap-1"},Rt={class:"text-xs font-medium text-slate-200"},Ft={class:"text-[10px] text-slate-500 font-mono"},Bt={class:"flex flex-wrap gap-x-3 gap-y-0.5 mt-0.5 text-[10px] text-slate-400"},Ut={key:0},Yt={key:1},Ot={key:2},Xt={key:3},Kt={key:0,class:"flex gap-1 flex-wrap mt-0.5"},Ht={class:"bg-slate-900 border border-slate-700 rounded-xl shadow-2xl flex flex-col",style:{width:"580px","max-width":"92vw","max-height":"78vh"}},Wt={class:"flex items-center gap-2 px-4 py-3 border-b border-slate-700 flex-shrink-0"},Jt={class:"px-4 py-2.5 border-b border-slate-700/60 flex-shrink-0"},Zt={class:"flex-1 overflow-y-auto"},Gt={key:0,class:"py-10 text-center text-slate-500 text-sm"},qt={key:1,class:"py-10 text-center text-slate-500 text-sm"},Qt=["onClick"],eo={class:"flex-1 min-w-0"},to={class:"text-sm text-slate-200 font-medium truncate"},oo={class:"text-[11px] text-slate-500 font-mono truncate mt-0.5"},no={class:"flex flex-wrap gap-x-3 mt-0.5 text-[10px] text-slate-500"},lo={key:0},so={key:1},ao={key:2},ro={key:0,class:"text-purple-400 text-base flex-shrink-0 mt-0.5"},et=de({__name:"ModelPickerInput",props:{modelValue:{},placeholder:{},disabled:{type:Boolean}},emits:["update:modelValue"],setup(g,{emit:o}){const d=g,S=o,m=He(),p=A(!1),v=A(""),x=A([]),h=A(!1),a=A(null),i=N(()=>d.modelValue&&x.value.find(n=>n.id===d.modelValue)||null),f=N(()=>{const n=v.value.trim().toLowerCase();return n?x.value.filter(c=>(c.id||"").toLowerCase().includes(n)||(c.name||"").toLowerCase().includes(n)):x.value});async function $(){if(!x.value.length){h.value=!0;try{const c=(await m.getModels()).models;x.value=Array.isArray(c)?c:(c==null?void 0:c.models)??[]}catch(n){console.error("[ModelPickerInput] loadModels error:",n)}finally{h.value=!1}}}Ie(()=>{d.modelValue&&$()}),Me(p,async n=>{var c;n?(await $(),await ot(),(c=a.value)==null||c.focus()):v.value=""});function j(n){S("update:modelValue",n.id),p.value=!1}return(n,c)=>{var E,X,F;return l(),s(O,null,[e("div",Dt,[e("div",At,[e("button",{type:"button",class:"w-full flex items-center gap-1.5 bg-slate-800 border border-slate-700 rounded-lg px-2 py-1.5 text-xs text-left outline-none focus:border-purple-500 hover:border-slate-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:g.disabled,onClick:c[0]||(c[0]=V=>!g.disabled&&(p.value=!0)),onPointerdown:c[1]||(c[1]=y(()=>{},["stop"]))},[g.modelValue?(l(),s("span",Vt,P(g.modelValue),1)):(l(),s("span",jt,P(g.placeholder),1)),c[6]||(c[6]=e("span",{class:"text-slate-500 flex-shrink-0 text-[10px]"},"▾",-1))],40,Lt)]),i.value?(l(),s("div",Nt,[e("div",Rt,P(i.value.name||i.value.id),1),e("div",Ft,P(i.value.id),1),e("div",Bt,[i.value.context_length?(l(),s("span",Ut,"ctx "+P((i.value.context_length/1e3).toFixed(0))+"k tokens",1)):M("",!0),i.value.max_completion_tokens?(l(),s("span",Yt,"out max "+P((i.value.max_completion_tokens/1e3).toFixed(0))+"k",1)):M("",!0),(E=i.value.pricing)!=null&&E.prompt?(l(),s("span",Ot,"in $"+P((i.value.pricing.prompt*1e6).toFixed(2))+"/M",1)):M("",!0),(X=i.value.pricing)!=null&&X.completion?(l(),s("span",Xt,"out $"+P((i.value.pricing.completion*1e6).toFixed(2))+"/M",1)):M("",!0)]),(F=i.value.input_modalities)!=null&&F.length?(l(),s("div",Kt,[(l(!0),s(O,null,oe(i.value.input_modalities,V=>(l(),s("span",{key:V,class:"text-[9px] px-1.5 py-0.5 rounded bg-slate-700/60 text-slate-400 border border-slate-600/40"},P(V),1))),128))])):M("",!0)])):M("",!0)]),(l(),me(Ze,{to:"body"},[p.value?(l(),s("div",{key:0,class:"fixed inset-0 z-[300] flex items-center justify-center bg-black/60",onClick:c[5]||(c[5]=y(V=>p.value=!1,["self"]))},[e("div",Ht,[e("div",Wt,[c[7]||(c[7]=e("span",{class:"font-semibold text-slate-200 flex-1 text-sm"},"Select Model",-1)),e("button",{class:"text-slate-500 hover:text-slate-200 transition-colors text-sm",onClick:c[2]||(c[2]=V=>p.value=!1)},"✕")]),e("div",Jt,[W(e("input",{ref_key:"searchInput",ref:a,"onUpdate:modelValue":c[3]||(c[3]=V=>v.value=V),type:"text",placeholder:"Search by name or ID…",class:"w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-1.5 text-sm text-slate-200 outline-none focus:border-purple-500 placeholder-slate-600",onPointerdown:c[4]||(c[4]=y(()=>{},["stop"]))},null,544),[[ne,v.value]])]),e("div",Zt,[h.value?(l(),s("div",Gt,"Loading models…")):f.value.length===0?(l(),s("div",qt,"No models found")):M("",!0),(l(!0),s(O,null,oe(f.value,V=>{var ae,le;return l(),s("div",{key:V.id,class:J(["flex items-start gap-3 px-4 py-2.5 cursor-pointer hover:bg-slate-800/70 border-b border-slate-800/50 transition-colors",V.id===g.modelValue?"bg-purple-900/20":""]),onClick:U=>j(V)},[e("div",eo,[e("div",to,P(V.name||V.id),1),e("div",oo,P(V.id),1),e("div",no,[V.context_length?(l(),s("span",lo,"ctx "+P((V.context_length/1e3).toFixed(0))+"k",1)):M("",!0),(ae=V.pricing)!=null&&ae.prompt?(l(),s("span",so,"in $"+P((V.pricing.prompt*1e6).toFixed(2))+"/M",1)):M("",!0),(le=V.pricing)!=null&&le.completion?(l(),s("span",ao,"out $"+P((V.pricing.completion*1e6).toFixed(2))+"/M",1)):M("",!0),(l(!0),s(O,null,oe(V.input_modalities||[],U=>(l(),s("span",{key:U,class:"px-1 py-0.5 bg-slate-700/50 rounded text-slate-400"},P(U),1))),128))])]),V.id===g.modelValue?(l(),s("span",ro,"✓")):M("",!0)],10,Qt)}),128))])])])):M("",!0)]))],64)}}}),io={class:"sidebar-palette flex flex-col h-full overflow-hidden"},uo={class:"px-2 pt-2 pb-1 flex-shrink-0 border-b border-slate-800"},co={class:"flex items-center mb-1.5"},po={key:0,class:"mb-2 p-2 bg-slate-800/60 border border-slate-700/60 rounded-lg flex flex-col gap-1.5"},xo=["onKeydown"],vo={class:"flex gap-1"},mo=["disabled"],fo={key:0,class:"text-[10px] text-red-400 break-all"},bo={class:"max-h-36 overflow-y-auto"},go=["onDragstart"],yo={class:"w-4 h-4 rounded-full bg-purple-600/30 border border-purple-500/40 flex-shrink-0 flex items-center justify-center text-[9px] text-purple-300 font-bold"},ho={class:"text-xs text-slate-300 truncate flex-1"},ko={class:"hidden group-hover/agent:flex items-center gap-0.5 flex-shrink-0"},wo=["onClick"],_o=["disabled","onClick"],Co={key:0,class:"text-[10px] text-red-400 px-1 py-0.5 break-all"},$o={key:1,class:"text-xs text-slate-600 px-1 py-1"},So={class:"px-2 py-1.5 flex-shrink-0"},Mo={class:"px-2 pb-1.5 flex-shrink-0"},Po={class:"flex items-center gap-1 overflow-x-auto",style:{"scrollbar-width":"none"}},Eo=["onClick"],zo={class:"flex-1 overflow-y-auto px-2 pb-2"},Io={class:"mb-3"},To={class:"flex items-center gap-1.5"},Do=["title"],Ao={width:"28",height:"28",viewBox:"0 0 28 28",fill:"none"},Lo={class:"text-[9px] text-slate-400"},Vo={class:"flex justify-center gap-1 mt-1"},jo=["onClick"],No={class:"text-[9px] text-slate-600 font-semibold uppercase tracking-wide mb-1.5"},Ro={key:0,class:"text-slate-700 font-normal normal-case ml-1"},Fo=["onDragstart","onClick"],Bo={class:"text-xs text-slate-300 truncate flex-1"},Uo={key:1,class:"text-[9px] text-amber-400 flex-shrink-0"},Yo={key:0,class:"text-xs text-slate-600 py-2 text-center"},Oo=["onClick"],Xo={class:"text-xs text-slate-300 truncate flex-1"},Ko=["onClick"],Ho={class:"flex-shrink-0 border-t border-slate-800 px-2 py-1.5"},Wo=["disabled"],Jo=de({__name:"SidebarPalette",setup(g){const o=Ce(),d=ge(),S=Ke(),m=He(),{camera:p,goToPosition:v}=_e(),x=A(""),h=A(!1),a=A(""),i=A(null),f=A([]),$=A(!1),j=A(""),n=A(""),c=A("project"),E=A(""),X=A(!1);let F=A(new Set);const V={cli:"#8b5cf6",data:"#3b82f6",content:"#6366f1",research:"#f59e0b",dev:"#22c55e",thinking:"#ec4899",media:"#06b6d4",file:"#14b8a6",tool:"#64748b",memory:"#a78bfa",task:"#fb923c",todo:"#34d399"};function ae(k){const w=V[k]??"#64748b";return{backgroundColor:w+"22",color:w,border:`1px solid ${w}44`}}const le=N(()=>{const k=S.getAllTypeDefinitions().filter(Z=>!Z.hiddenFromPalette),w=new Set;for(const Z of k)for(const r of Z.tags??[])w.add(r);return Array.from(w).sort()});function U(k){const w=new Set(F.value);w.has(k)?w.delete(k):w.add(k),F.value=w}const ce=N(()=>{let k=S.getAllTypeDefinitions().filter(w=>!w.hiddenFromPalette);if(x.value){const w=x.value.toLowerCase();k=k.filter(Z=>Z.name.toLowerCase().includes(w)||Z.type.toLowerCase().includes(w))}return F.value.size>0&&(k=k.filter(w=>(w.tags??[]).some(Z=>F.value.has(Z)))),k}),b=[{id:"rectangle",label:"Rectangle",svg:{template:'<rect x="2" y="4" width="24" height="18" rx="2" fill="none" stroke="currentColor" stroke-width="1.5"/>'}},{id:"circle",label:"Circle",svg:{template:'<circle cx="14" cy="14" r="11" fill="none" stroke="currentColor" stroke-width="1.5"/>'}},{id:"ellipse",label:"Ellipse",svg:{template:'<ellipse cx="14" cy="14" rx="12" ry="8" fill="none" stroke="currentColor" stroke-width="1.5"/>'}},{id:"diamond",label:"Diamond",svg:{template:'<polygon points="14,2 26,14 14,26 2,14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>'}},{id:"triangle",label:"Triangle",svg:{template:'<polygon points="14,2 26,24 2,24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>'}},{id:"hexagon",label:"Hexagon",svg:{template:'<polygon points="14,2 24,8 24,20 14,26 4,20 4,8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>'}},{id:"pentagon",label:"Pentagon",svg:{template:'<polygon points="14,2 26,11 21,25 7,25 2,11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>'}},{id:"star",label:"Star",svg:{template:'<polygon points="14,2 17,10 26,10 19,16 22,25 14,19 6,25 9,16 2,10 11,10" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>'}},{id:"text-label",label:"Text Label",svg:{template:'<text x="14" y="19" text-anchor="middle" font-size="14" font-weight="bold" fill="currentColor">T</text>'}}],I=A(0);function Y(){I.value=(I.value-1+b.length)%b.length}function K(){I.value=(I.value+1)%b.length}function te(){const k=ge(),{camera:w}=_e(),Z=(window.innerWidth/2-w.x)/w.zoom,r=(window.innerHeight/2-w.y)/w.zoom;k.addShape({subtype:b[I.value].id,x:Z-80,y:r-60,width:160,height:120})}function Q(k){var w;(w=k.dataTransfer)==null||w.setData("application/x-veil-shape",JSON.stringify({subtype:b[I.value].id}))}async function z(){if(!(!j.value.trim()||X.value)){X.value=!0,E.value="";try{await m.createAgent({name:j.value.trim(),level:c.value,config:{model:n.value.trim()||"anthropic/claude-sonnet-4-5",temperature:.7}}),$.value=!1,j.value="",n.value="",c.value="project",await T()}catch(k){E.value=(k==null?void 0:k.message)??String(k)}finally{X.value=!1}}}function q(k){const w=window.innerWidth/2/p.zoom-p.x/p.zoom,Z=window.innerHeight/2/p.zoom-p.y/p.zoom;d.addElement(k.type,w,Z)}function se(k){const w=window.innerWidth/2/p.zoom-p.x/p.zoom,Z=window.innerHeight/2/p.zoom-p.y/p.zoom;d.addElement("agent",w,Z,{name:k.name,model:k.model??"",description:k.description??"",modes:k.modes??[],source:k.source??"project"})}async function ye(k){if(!i.value){i.value=k.name;try{const w=Oe();if(!w)throw new Error("No socket");const Z=window.innerWidth/2/p.zoom-p.x/p.zoom,r=window.innerHeight/2/p.zoom-p.y/p.zoom;await new Promise((C,H)=>{w.emit("board:add-agent-instance",{agentName:k.name,x:Z,y:r},xe=>{xe!=null&&xe.error?H(new Error(xe.error)):C()})})}catch(w){console.error("[SidebarPalette] createAgentInstance error:",w.message)}finally{i.value=null}}}function ke(k,w){var Z;(Z=k.dataTransfer)==null||Z.setData("application/x-veil-element",JSON.stringify({type:w.type}))}function pe(k,w){var Z;(Z=k.dataTransfer)==null||Z.setData("application/x-veil-element",JSON.stringify({type:"agent",data:{name:w.name,model:w.model??"",description:w.description??"",modes:w.modes??[],source:w.source??"project"}}))}function R(k){v(k.cameraX,k.cameraY,k.zoom)}async function _(){const k=Oe();k&&(h.value=!0,k.emit("element:reload-custom",{},()=>{h.value=!1}))}async function T(){a.value="";try{const k=await m.getAgents();f.value=Array.isArray(k)?k:k.agents??[]}catch(k){a.value=(k==null?void 0:k.message)??String(k)}}return Me(Re,k=>{k&&!f.value.length&&T()},{immediate:!1}),Ie(async()=>{Re.value&&await T()}),(k,w)=>{const Z=et;return l(),s("div",io,[e("div",uo,[e("div",co,[w[8]||(w[8]=e("span",{class:"text-[10px] text-slate-500 font-semibold uppercase tracking-wide flex-1"},"Agents",-1)),e("button",{class:"text-[10px] text-slate-600 hover:text-purple-400 px-1.5 py-0.5 rounded hover:bg-slate-700 mr-0.5",title:"Create new agent",onClick:w[0]||(w[0]=r=>$.value=!$.value)},"+"),e("button",{class:"text-[10px] text-slate-600 hover:text-slate-400 px-1.5 py-0.5 rounded hover:bg-slate-700",title:"Reload agents",onClick:T},"↻")]),$.value?(l(),s("div",po,[W(e("input",{"onUpdate:modelValue":w[1]||(w[1]=r=>j.value=r),type:"text",placeholder:"Agent name…",class:"w-full bg-slate-900 border border-slate-700 rounded px-2 py-1 text-xs text-slate-200 outline-none focus:border-purple-500 placeholder-slate-600",onKeydown:[ze(y(z,["stop"]),["enter"]),w[2]||(w[2]=ze(y(r=>$.value=!1,["stop"]),["escape"]))]},null,40,xo),[[ne,j.value]]),be(Z,{modelValue:n.value,"onUpdate:modelValue":w[3]||(w[3]=r=>n.value=r),placeholder:"Select model…"},null,8,["modelValue"]),e("div",vo,[W(e("select",{"onUpdate:modelValue":w[4]||(w[4]=r=>c.value=r),class:"flex-1 bg-slate-900 border border-slate-700 rounded px-1 py-1 text-xs text-slate-300 outline-none focus:border-purple-500"},[...w[9]||(w[9]=[e("option",{value:"project"},"project",-1),e("option",{value:"global"},"global",-1)])],512),[[Te,c.value]]),e("button",{class:"px-2 py-1 text-xs bg-purple-600/40 hover:bg-purple-600/60 border border-purple-600/40 text-purple-300 rounded transition-colors",disabled:!j.value.trim()||X.value,onClick:z},P(X.value?"…":"Create"),9,mo),e("button",{class:"px-2 py-1 text-xs bg-slate-700 hover:bg-slate-600 text-slate-400 rounded transition-colors",onClick:w[5]||(w[5]=r=>$.value=!1)},"✕")]),E.value?(l(),s("div",fo,P(E.value),1)):M("",!0)])):M("",!0),e("div",bo,[(l(!0),s(O,null,oe(f.value,r=>{var C;return l(),s("div",{key:r.name,class:"palette-item group/agent",draggable:"true",onDragstart:H=>pe(H,r)},[e("span",yo,P((C=r.name[0])==null?void 0:C.toUpperCase()),1),e("span",ho,P(r.name),1),e("div",ko,[e("button",{class:"text-[9px] px-1.5 py-0.5 rounded bg-purple-600/30 hover:bg-purple-600/50 text-purple-300 border border-purple-600/30",title:"Add Agent element",onClick:y(H=>se(r),["stop"])},"Agent",8,wo),e("button",{class:"text-[9px] px-1.5 py-0.5 rounded bg-green-600/30 hover:bg-green-600/50 text-green-300 border border-green-600/30",title:"Create Instance (with session)",disabled:i.value===r.name,onClick:y(H=>ye(r),["stop"])},P(i.value===r.name?"…":"Instance"),9,_o)])],40,go)}),128)),a.value?(l(),s("div",Co,P(a.value),1)):f.value.length?M("",!0):(l(),s("div",$o,"No agents loaded"))])]),e("div",So,[W(e("input",{"onUpdate:modelValue":w[6]||(w[6]=r=>x.value=r),type:"text",placeholder:"Search elements…",class:"w-full bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-xs text-slate-300 outline-none focus:border-wire-blue placeholder-slate-600"},null,512),[[ne,x.value]])]),e("div",Mo,[e("div",Po,[(l(!0),s(O,null,oe(le.value,r=>(l(),s("button",{key:r,class:J(["tag-chip flex-shrink-0",L(F).has(r)?"tag-chip-active":"tag-chip-inactive"]),onClick:C=>U(r)},P(r),11,Eo))),128)),L(F).size>0?(l(),s("button",{key:0,class:"flex-shrink-0 text-[9px] px-1.5 py-0.5 rounded-full border border-slate-600 text-slate-500 hover:border-slate-400 hover:text-slate-300 transition-colors ml-0.5",onClick:w[7]||(w[7]=r=>{L(F).clear(),nt(F)?F.value=new Set:F=new Set})},"✕ clear")):M("",!0)])]),e("div",zo,[e("div",Io,[w[10]||(w[10]=e("div",{class:"text-[9px] text-slate-600 font-semibold uppercase tracking-wide mb-1.5"},"Shapes",-1)),e("div",To,[e("button",{class:"w-5 h-5 flex items-center justify-center rounded text-slate-500 hover:text-slate-200 hover:bg-slate-700 transition-colors flex-shrink-0 text-xs",onClick:Y},"‹"),e("div",{class:"flex-1 flex flex-col items-center gap-0.5 py-1.5 rounded-lg border border-slate-700 bg-slate-800/60 hover:border-slate-500 hover:bg-slate-700/60 transition-colors cursor-pointer select-none",draggable:"true",title:b[I.value].label+" – click to add, drag to place",onClick:te,onDragstart:Q},[(l(),s("svg",Ao,[(l(),me(qe(b[I.value].svg)))])),e("span",Lo,P(b[I.value].label),1)],40,Do),e("button",{class:"w-5 h-5 flex items-center justify-center rounded text-slate-500 hover:text-slate-200 hover:bg-slate-700 transition-colors flex-shrink-0 text-xs",onClick:K},"›")]),e("div",Vo,[(l(),s(O,null,oe(b,(r,C)=>e("button",{key:r.id,class:J(["w-1.5 h-1.5 rounded-full transition-colors",C===I.value?"bg-slate-400":"bg-slate-700 hover:bg-slate-600"]),onClick:H=>I.value=C},null,10,jo)),64))])]),e("div",No,[w[11]||(w[11]=Ee(" Elements ",-1)),L(F).size>0||x.value?(l(),s("span",Ro,P(ce.value.length)+" shown",1)):M("",!0)]),(l(!0),s(O,null,oe(ce.value,r=>{var C;return l(),s("div",{key:r.type,class:"palette-item",draggable:"true",onDragstart:H=>ke(H,r),onClick:H=>q(r)},[w[12]||(w[12]=e("span",{class:"text-slate-500 text-xs flex-shrink-0"},[e("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[e("rect",{x:"1",y:"1",width:"10",height:"10",rx:"2"})])],-1)),e("span",Bo,P(r.name),1),(C=r.tags)!=null&&C[0]?(l(),s("span",{key:0,class:"text-[8px] px-1 py-0.5 rounded flex-shrink-0 font-medium",style:ie(ae(r.tags[0]))},P(r.tags[0]),5)):M("",!0),r.isBuiltIn?M("",!0):(l(),s("span",Uo,"custom"))],40,Fo)}),128)),ce.value.length===0?(l(),s("div",Yo,"No elements found")):M("",!0),L(o).views.length?(l(),s(O,{key:1},[w[14]||(w[14]=e("div",{class:"text-[9px] text-slate-600 font-semibold uppercase tracking-wide mb-1.5 mt-3"},"Saved Views",-1)),(l(!0),s(O,null,oe(L(o).views,r=>(l(),s("div",{key:r.id,class:"palette-item",onClick:C=>R(r)},[w[13]||(w[13]=e("span",{class:"text-xs text-slate-500"},"🔖",-1)),e("span",Xo,P(r.name),1),e("button",{class:"text-[10px] text-slate-500 hover:text-red-400",onClick:y(C=>L(d).deleteView(r.id),["stop"])},"✕",8,Ko)],8,Oo))),128))],64)):M("",!0)]),e("div",Ho,[e("button",{class:"w-full text-xs bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-slate-300 rounded-lg px-2 py-1 transition-colors",disabled:h.value,onClick:_},P(h.value?"…":"↻ Reload Custom Elements"),9,Wo)])])}}}),Zo=Pe(Jo,[["__scopeId","data-v-d0de459d"]]),Go={class:"text-[10px] w-3 text-center text-slate-500 flex-shrink-0"},qo={class:"text-sm flex-shrink-0"},Qo={class:"text-xs text-slate-300 truncate flex-1"},en={key:0},tt=de({__name:"FileTreeNode",props:{node:{},depth:{}},setup(g){const o=g,d=A(o.depth<2),S=ge(),m=N(()=>{if(o.node.type==="directory")return d.value?"📂":"📁";const h=o.node.name.split(".").pop()??"";return{ts:"📘",js:"📒",vue:"💚",json:"📋",md:"📝",py:"🐍",txt:"📄"}[h]??"📄"});function p(){o.node.type==="directory"&&(d.value=!d.value)}function v(){S.addElement("file-reference",100,100,{filePath:o.node.path,title:o.node.name})}function x(h){}return(h,a)=>{const i=tt;return l(),s("div",null,[e("div",{class:"flex items-center gap-1 px-1 py-0.5 rounded cursor-pointer hover:bg-slate-800 group select-none",style:ie({paddingLeft:g.depth*12+4+"px"}),onClick:p,onContextmenu:y(x,["prevent"])},[e("span",Go,P(g.node.type==="directory"?d.value?"▼":"▶":""),1),e("span",qo,P(m.value),1),e("span",Qo,P(g.node.name),1),g.node.type==="file"?(l(),s("button",{key:0,class:"hidden group-hover:flex text-[10px] text-slate-500 hover:text-wire-blue",title:"Add to Board",onClick:y(v,["stop"])},"+")):M("",!0)],36),d.value&&g.node.children?(l(),s("div",en,[(l(!0),s(O,null,oe(g.node.children,f=>(l(),me(i,{key:f.path,node:f,depth:g.depth+1},null,8,["node","depth"]))),128))])):M("",!0)])}}}),We=A([]),Be=A(!1),Ue=A(null);function tn(){const{authHeaders:g,markUnauthorized:o}=lt();function d(a){if(a.status===401)throw o(),new Error("Unauthorized");if(!a.ok)throw new Error(`HTTP ${a.status}`);return a}async function S(){Be.value=!0,Ue.value=null;try{const a=await fetch("/api/files/tree",{headers:g()});d(a),We.value=await a.json()}catch(a){Ue.value=a.message}finally{Be.value=!1}}async function m(a){const i=await fetch(`/api/files/content?path=${encodeURIComponent(a)}`,{headers:g()});return d(i),(await i.json()).content}async function p(a,i){const f=await fetch("/api/files/content",{method:"PUT",headers:g({"Content-Type":"application/json"}),body:JSON.stringify({path:a,content:i})});d(f)}async function v(a){const i=await fetch("/api/files/mkdir",{method:"POST",headers:g({"Content-Type":"application/json"}),body:JSON.stringify({path:a})});d(i)}async function x(a,i){const f=await fetch("/api/files/rename",{method:"POST",headers:g({"Content-Type":"application/json"}),body:JSON.stringify({from:a,to:i})});d(f)}async function h(a){const i=await fetch("/api/files/delete",{method:"POST",headers:g({"Content-Type":"application/json"}),body:JSON.stringify({path:a})});d(i)}return{tree:We,loading:Be,error:Ue,fetchTree:S,readFile:m,writeFile:p,mkdir:v,renameFile:x,deleteFile:h}}const on={class:"sidebar-files flex flex-col h-full overflow-hidden"},nn={class:"flex items-center gap-1 px-2 py-1.5 border-b border-slate-700 flex-shrink-0"},ln={class:"text-[10px] text-slate-500 flex-1 truncate font-mono"},sn={class:"flex-1 overflow-y-auto"},an={key:0,class:"flex items-center justify-center h-16 text-slate-600 text-xs"},rn={key:1,class:"p-2 text-xs text-red-400"},dn=de({__name:"SidebarFiles",setup(g){const{tree:o,loading:d,error:S,fetchTree:m}=tn(),p=Ce(),v=N(()=>p.meta.projectDir??"");function x(){m()}return Ie(()=>{m()}),(h,a)=>{const i=tt;return l(),s("div",on,[e("div",nn,[e("span",ln,P(v.value),1),e("button",{class:"text-slate-400 hover:text-slate-200 text-xs p-1 rounded hover:bg-slate-700",title:"Refresh",onClick:x},"↻")]),e("div",sn,[L(d)?(l(),s("div",an,"Loading…")):L(S)?(l(),s("div",rn,P(L(S)),1)):M("",!0),(l(!0),s(O,null,oe(L(o),f=>(l(),me(i,{key:f.path,node:f,depth:0},null,8,["node"]))),128))])])}}}),un={class:"sidebar-left flex flex-col h-full overflow-hidden bg-slate-900"},cn={class:"flex items-center border-b border-slate-700 flex-shrink-0"},pn=["onClick"],xn={class:"flex-1 overflow-hidden"},vn=de({__name:"SidebarLeft",setup(g){const o=we(),d=[{id:"palette",label:"Elements"},{id:"files",label:"Files"}];return(S,m)=>{const p=Zo,v=dn;return l(),s("div",un,[e("div",cn,[(l(),s(O,null,oe(d,x=>e("button",{key:x.id,class:J(["flex-1 py-2 text-xs font-medium transition-colors",L(o).leftPanelTab===x.id?"text-slate-100 border-b-2 border-wire-blue":"text-slate-500 hover:text-slate-300"]),onClick:h=>L(o).leftPanelTab=x.id},P(x.label),11,pn)),64)),e("button",{class:"px-2 py-2 text-slate-500 hover:text-slate-300 transition-colors text-xs",title:"Close sidebar",onClick:m[0]||(m[0]=x=>L(o).leftPanelOpen=!1)},"✕")]),e("div",xn,[L(o).leftPanelTab==="palette"?(l(),me(p,{key:0})):L(o).leftPanelTab==="files"?(l(),me(v,{key:1})):M("",!0)])])}}}),mn=["data-shape-preview","data-shape-id"],fn=["title","onClick"],bn=["value"],gn=["title","onClick"],yn=["value"],hn=["title","onClick"],kn=["title","onClick"],wn={class:"absolute inset-0 w-full h-full overflow-visible",viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{"pointer-events":"none"}},_n=["fill","stroke","stroke-width"],Cn=["fill","stroke","stroke-width"],$n=["fill","stroke","stroke-width"],Sn=["fill","stroke","stroke-width"],Mn=["fill","stroke","stroke-width"],Pn=["fill","stroke","stroke-width"],En=["fill","stroke","stroke-width"],zn=["fill","stroke","stroke-width"],In={key:8,x:"1",y:"1",width:"98",height:"98",fill:"transparent",stroke:"#4b5563","stroke-width":"1","stroke-dasharray":"4 3"},Tn=["onPointerdown"],Dn=de({__name:"CanvasShape",props:{shape:{}},setup(g){const o=g,d=ge(),{camera:S}=_e(),m=A(!1),p=A(o.shape.fillColor||"transparent"),v=A(o.shape.strokeColor||"#6b7280"),x=A(o.shape.strokeWidth??1.5),h=A(o.shape.title||""),a=A(o.shape.text||""),i=A(o.shape.textAlign||"center");Me(()=>o.shape,R=>{m.value||(p.value=R.fillColor||"transparent",v.value=R.strokeColor||"#6b7280",x.value=R.strokeWidth??1.5,h.value=R.title||"",a.value=R.text||"",i.value=R.textAlign||"center")},{deep:!0});const f=["transparent","#1e3a5f","#1e3a2f","#3b1f1f","#2a1a3e","#1a2540"],$=["#6b7280","#60a5fa","#34d399","#f87171","#a78bfa","#f59e0b"],j=[{val:1,label:"—"},{val:2.5,label:"━"},{val:5,label:"█"}],n=[{val:"left",icon:"⬅",label:"Align left"},{val:"center",icon:"≡",label:"Align center"},{val:"right",icon:"➡",label:"Align right"}],c=N(()=>({left:o.shape.x+"px",top:o.shape.y+"px",width:o.shape.width+"px",height:o.shape.height+"px",zIndex:m.value?10:0,pointerEvents:"auto",userSelect:"none"})),E=N(()=>x.value/Math.min(o.shape.width,o.shape.height)*100),X=[{id:"tl",cursor:"cursor-nwse-resize",style:"top:-6px;left:-6px"},{id:"t",cursor:"cursor-ns-resize",style:"top:-6px;left:calc(50% - 6px)"},{id:"tr",cursor:"cursor-nesw-resize",style:"top:-6px;right:-6px"},{id:"r",cursor:"cursor-ew-resize",style:"top:calc(50% - 6px);right:-6px"},{id:"br",cursor:"cursor-nwse-resize",style:"bottom:-6px;right:-6px"},{id:"b",cursor:"cursor-ns-resize",style:"bottom:-6px;left:calc(50% - 6px)"},{id:"bl",cursor:"cursor-nesw-resize",style:"bottom:-6px;left:-6px"},{id:"l",cursor:"cursor-ew-resize",style:"top:calc(50% - 6px);left:-6px"}];let F=null;function V(){F&&clearTimeout(F),F=setTimeout(ae,400)}function ae(){F&&(clearTimeout(F),F=null),d.updateShape(o.shape.id,{fillColor:p.value,strokeColor:v.value,strokeWidth:x.value,title:h.value,text:a.value,textAlign:i.value})}function le(R){p.value=R.target.value,V()}function U(R){v.value=R.target.value,V()}function ce(){d.deleteShape(o.shape.id)}let b={px:0,py:0,sx:0,sy:0},I=!1;function Y(R){I=!0,b={px:R.clientX,py:R.clientY,sx:o.shape.x,sy:o.shape.y},window.addEventListener("pointermove",ke,{passive:!1}),window.addEventListener("pointerup",pe)}function K(R){}let te="",Q={px:0,py:0,x:0,y:0,w:0,h:0},z=!1;function q(R,_){z=!0,te=_,Q={px:R.clientX,py:R.clientY,x:o.shape.x,y:o.shape.y,w:o.shape.width,h:o.shape.height},R.preventDefault(),window.addEventListener("pointermove",se,{passive:!1}),window.addEventListener("pointerup",ye)}function se(R){if(!z)return;const _=S.zoom,T=(R.clientX-Q.px)/_,k=(R.clientY-Q.py)/_;let{x:w,y:Z,w:r,h:C}=Q;const H=20;switch(te){case"br":r=Math.max(H,r+T),C=Math.max(H,C+k);break;case"tr":r=Math.max(H,r+T),Z=Q.y+k,C=Math.max(H,C-k);break;case"bl":w=Q.x+T,r=Math.max(H,r-T),C=Math.max(H,C+k);break;case"tl":w=Q.x+T,r=Math.max(H,r-T),Z=Q.y+k,C=Math.max(H,C-k);break;case"r":r=Math.max(H,r+T);break;case"l":w=Q.x+T,r=Math.max(H,r-T);break;case"b":C=Math.max(H,C+k);break;case"t":Z=Q.y+k,C=Math.max(H,C-k);break}d.updateShape(o.shape.id,{x:w,y:Z,width:r,height:C})}function ye(){z=!1,window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",ye)}function ke(R){if(!I)return;const _=S.zoom,T=(R.clientX-b.px)/_,k=(R.clientY-b.py)/_;d.updateShape(o.shape.id,{x:b.sx+T,y:b.sy+k})}function pe(){I=!1,window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",pe)}return(R,_)=>(l(),s("div",{class:"absolute group","data-shape-preview":!m.value||void 0,"data-shape-id":g.shape.id,style:ie(c.value),onPointerdown:K},[m.value?(l(),s("div",{key:0,class:"absolute left-0 flex items-center gap-0.5 bg-slate-800 border border-slate-600 rounded-lg px-1.5 py-1 shadow-xl z-50 flex-wrap",style:{bottom:"calc(100% + 6px)","min-width":"260px","pointer-events":"auto"},onPointerdown:_[1]||(_[1]=y(()=>{},["stop"]))},[_[7]||(_[7]=e("span",{class:"text-[9px] text-slate-500 mr-0.5"},"Fill",-1)),(l(),s(O,null,oe(f,T=>e("button",{key:T,class:J(["w-4 h-4 rounded border transition-all",p.value===T?"border-white scale-110":"border-slate-600 hover:border-slate-400"]),style:ie({background:T==="transparent"?"transparent":T,backgroundImage:T==="transparent"?"repeating-linear-gradient(45deg,#555 0,#555 2px,transparent 0,transparent 8px)":"none"}),title:T,onClick:y(k=>{p.value=T,V()},["stop"])},null,14,fn)),64)),e("input",{type:"color",class:"w-5 h-5 rounded cursor-pointer border-0 bg-transparent",value:p.value==="transparent"?"#000000":p.value,onInput:le,title:"Custom fill"},null,40,bn),_[8]||(_[8]=e("div",{class:"w-px h-4 bg-slate-700 mx-0.5"},null,-1)),_[9]||(_[9]=e("span",{class:"text-[9px] text-slate-500 mr-0.5"},"Border",-1)),(l(),s(O,null,oe($,T=>e("button",{key:T,class:J(["w-4 h-4 rounded border transition-all",v.value===T?"border-white scale-110":"border-slate-600 hover:border-slate-400"]),style:ie({background:T}),title:T,onClick:y(k=>{v.value=T,V()},["stop"])},null,14,gn)),64)),e("input",{type:"color",class:"w-5 h-5 rounded cursor-pointer border-0 bg-transparent",value:v.value,onInput:U,title:"Custom border"},null,40,yn),_[10]||(_[10]=e("div",{class:"w-px h-4 bg-slate-700 mx-0.5"},null,-1)),_[11]||(_[11]=e("span",{class:"text-[9px] text-slate-500 mr-0.5"},"Width",-1)),(l(),s(O,null,oe(j,T=>e("button",{key:T.val,class:J(["px-1.5 py-0.5 text-[9px] rounded transition-colors",x.value===T.val?"bg-slate-600 text-white":"text-slate-400 hover:bg-slate-700"]),title:T.label,onClick:y(k=>{x.value=T.val,V()},["stop"])},P(T.label),11,hn)),64)),_[12]||(_[12]=e("div",{class:"w-px h-4 bg-slate-700 mx-0.5"},null,-1)),(l(),s(O,null,oe(n,T=>e("button",{key:T.val,class:J(["px-1 py-0.5 text-[10px] rounded transition-colors",i.value===T.val?"bg-slate-600 text-white":"text-slate-500 hover:bg-slate-700"]),title:T.label,onClick:y(k=>{i.value=T.val,V()},["stop"])},P(T.icon),11,kn)),64)),_[13]||(_[13]=e("div",{class:"w-px h-4 bg-slate-700 mx-0.5"},null,-1)),e("button",{class:"px-1.5 py-0.5 text-[10px] rounded bg-red-900/60 text-red-400 hover:bg-red-800/80 transition-colors",title:"Delete shape",onClick:y(ce,["stop"])},"✕"),e("button",{class:"px-1.5 py-0.5 text-[10px] rounded bg-slate-700 text-slate-200 hover:bg-slate-600 transition-colors ml-0.5",title:"Done editing",onClick:_[0]||(_[0]=y(T=>m.value=!1,["stop"]))},"Done")],32)):M("",!0),m.value?(l(),s("div",{key:1,class:"absolute left-0 right-0 flex gap-1",style:{bottom:"calc(100% + 38px)","pointer-events":"auto"},onPointerdown:_[4]||(_[4]=y(()=>{},["stop"]))},[W(e("input",{"onUpdate:modelValue":_[2]||(_[2]=T=>h.value=T),placeholder:"Title…",class:"flex-1 text-[10px] text-slate-200 bg-slate-800/90 border border-slate-600 rounded px-1.5 py-0.5 outline-none",onInput:V},null,544),[[ne,h.value]]),W(e("input",{"onUpdate:modelValue":_[3]||(_[3]=T=>a.value=T),placeholder:"Text…",class:"flex-1 text-[10px] text-slate-200 bg-slate-800/90 border border-slate-600 rounded px-1.5 py-0.5 outline-none",onInput:V},null,544),[[ne,a.value]])],32)):M("",!0),(l(),s("svg",wn,[g.shape.subtype==="rectangle"?(l(),s("rect",{key:0,x:"1",y:"1",width:"98",height:"98",rx:"3",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,_n)):g.shape.subtype==="circle"?(l(),s("circle",{key:1,cx:"50",cy:"50",r:"48",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,Cn)):g.shape.subtype==="ellipse"?(l(),s("ellipse",{key:2,cx:"50",cy:"50",rx:"48",ry:"36",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,$n)):g.shape.subtype==="diamond"?(l(),s("polygon",{key:3,points:"50,1 99,50 50,99 1,50",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,Sn)):g.shape.subtype==="triangle"?(l(),s("polygon",{key:4,points:"50,1 99,98 1,98",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,Mn)):g.shape.subtype==="hexagon"?(l(),s("polygon",{key:5,points:"50,1 93,25 93,75 50,99 7,75 7,25",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,Pn)):g.shape.subtype==="pentagon"?(l(),s("polygon",{key:6,points:"50,1 99,37 80,98 20,98 1,37",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,En)):g.shape.subtype==="star"?(l(),s("polygon",{key:7,points:"50,2 61,36 98,36 68,57 79,91 50,70 21,91 32,57 2,36 39,36",fill:p.value,stroke:v.value,"stroke-width":E.value},null,8,zn)):g.shape.subtype==="text-label"?(l(),s("rect",In)):M("",!0)])),h.value||a.value?(l(),s("div",{key:2,class:"absolute inset-0 flex flex-col items-center justify-center overflow-hidden px-2 pointer-events-none select-none",style:ie({textAlign:i.value})},[h.value?(l(),s("span",{key:0,class:"text-[11px] font-semibold text-slate-100 leading-tight truncate w-full",style:ie({textAlign:i.value})},P(h.value),5)):M("",!0),a.value?(l(),s("span",{key:1,class:"text-[10px] text-slate-300 leading-tight truncate w-full",style:ie({textAlign:i.value})},P(a.value),5)):M("",!0)],4)):M("",!0),m.value?M("",!0):(l(),s("button",{key:3,class:"absolute top-1 right-1 w-5 h-5 rounded bg-slate-900/80 border border-slate-600 text-slate-400 hover:text-slate-100 hover:bg-slate-700 transition-all opacity-0 group-hover:opacity-100 flex items-center justify-center z-10",style:{"pointer-events":"auto","font-size":"10px"},title:"Edit shape",onClick:_[5]||(_[5]=y(T=>m.value=!0,["stop"])),onPointerdown:_[6]||(_[6]=y(()=>{},["stop"]))},"✎",32)),m.value?(l(),s(O,{key:4},oe(X,T=>e("div",{key:T.id,class:J(["absolute w-3 h-3 bg-white border border-slate-500 rounded-sm z-10",T.cursor]),style:ie(T.style),onPointerdown:y(k=>q(k,T.id),["stop"])},null,46,Tn)),64)):M("",!0),m.value?(l(),s("div",{key:5,class:"absolute inset-0",style:{cursor:"move","pointer-events":"auto"},onPointerdown:y(Y,["stop","prevent"])},null,32)):M("",!0)],44,mn))}}),An={class:"truncate"},Ln=de({__name:"CanvasZone",props:{zone:{}},setup(g){const o=g,d=ge(),{camera:S}=_e();let m={px:0,py:0,zx:0,zy:0,zw:0,zh:0,mode:"move"},p=!1;function v($,j){m={px:$.clientX,py:$.clientY,zx:o.zone.x,zy:o.zone.y,zw:o.zone.width,zh:o.zone.height,mode:j},p=!0,$.currentTarget.setPointerCapture($.pointerId),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i,{once:!0})}function x($){v($,"move")}function h($){v($,"resize")}function a($){if(!p)return;const j=($.clientX-m.px)/S.zoom,n=($.clientY-m.py)/S.zoom;m.mode==="move"?d.updateZone(o.zone.id,{x:m.zx+j,y:m.zy+n}):d.updateZone(o.zone.id,{width:Math.max(80,m.zw+j),height:Math.max(60,m.zh+n)})}function i(){p=!1,window.removeEventListener("pointermove",a)}function f(){d.deleteZone(o.zone.id)}return($,j)=>(l(),s("div",{class:"canvas-zone absolute rounded-lg",style:ie({left:g.zone.x+"px",top:g.zone.y+"px",width:g.zone.width+"px",height:g.zone.height+"px",border:`2px solid ${g.zone.color}`,backgroundColor:g.zone.color+"1A",zIndex:1})},[e("div",{class:"zone-label absolute top-0 left-0 right-0 flex items-center gap-1 px-2 py-0.5 rounded-t-lg cursor-grab text-xs font-medium select-none",style:ie({backgroundColor:g.zone.color+"33",color:g.zone.color}),onPointerdown:y(x,["stop"])},[e("span",An,P(g.zone.name||"Zone"),1),e("button",{class:"ml-auto opacity-60 hover:opacity-100 text-current",onClick:y(f,["stop"])},"✕")],36),e("div",{class:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",style:{"border-bottom":"2px solid","border-right":"2px solid","border-color":"inherit","border-radius":"0 0 6px 0"},onPointerdown:y(h,["stop"])},null,32)],4))}}),Vn=["d"],jn=["d","stroke","stroke-dasharray"],Nn=["cx","cy"],Rn=["x","y"],Fn=de({__name:"CanvasLink",props:{link:{}},setup(g){const o=g,d=Ce(),S=ge(),m=A(!1),p=N(()=>d.getElementById(o.link.fromElementId)),v=N(()=>d.getElementById(o.link.toElementId)),x=N(()=>{if(!p.value)return null;const n=d.elementPorts.get(o.link.fromElementId)??[],c=n.findIndex(X=>X.key===o.link.fromPortKey),E=n[c];return E?S.portPosition(p.value,E,c,n.length):{x:p.value.x+p.value.width,y:p.value.y+p.value.height/2}}),h=N(()=>{if(!v.value)return null;const n=d.elementPorts.get(o.link.toElementId)??[],c=n.findIndex(X=>X.key===o.link.toPortKey),E=n[c];return E?S.portPosition(v.value,E,c,n.length):{x:v.value.x,y:v.value.y+v.value.height/2}}),a=N(()=>{const n=x.value,c=h.value;if(!n||!c)return"";const E=Math.max(80,Math.abs(c.x-n.x)*.5);return`M ${n.x} ${n.y} C ${n.x+E} ${n.y}, ${c.x-E} ${c.y}, ${c.x} ${c.y}`}),i=N(()=>{const n=x.value,c=h.value;return!n||!c?null:{x:(n.x+c.x)/2,y:(n.y+c.y)/2}}),f=N(()=>({dasharray:o.link.type==="zone-input"?"8 4":"none"}));function $(){m.value=!m.value}function j(){S.deleteLink(o.link.id)}return(n,c)=>(l(),s("g",{class:"canvas-link",style:{"pointer-events":"stroke"},onClick:y($,["stop"])},[e("path",{d:a.value,fill:"none",stroke:"transparent","stroke-width":"12",style:{"pointer-events":"stroke",cursor:"pointer"}},null,8,Vn),e("path",{d:a.value,fill:"none",stroke:m.value?"#60a5fa":"#475569","stroke-width":"2","stroke-linecap":"round","stroke-dasharray":f.value.dasharray,class:J({"link-flow":o.link.type==="zone-input"})},null,10,jn),m.value&&i.value?(l(),s("g",{key:0,onClick:y(j,["stop"]),style:{cursor:"pointer"}},[e("circle",{cx:i.value.x,cy:i.value.y,r:"8",fill:"#1e293b",stroke:"#ef4444","stroke-width":"1.5"},null,8,Nn),e("text",{x:i.value.x,y:i.value.y+4,"text-anchor":"middle","font-size":"10",fill:"#ef4444"},"×",8,Rn)])):M("",!0)]))}}),Bn=Pe(Fn,[["__scopeId","data-v-972a93f9"]]),Un={class:"absolute pointer-events-none",style:{left:"0",top:"0",width:"0",height:"0",overflow:"visible"},"aria-hidden":"true"},Yn=["d"],On=de({__name:"CanvasLinks",setup(g){const o=Ce(),d=we(),S=ge(),m=N(()=>{const v=d.linkingState;if(!v)return null;const x=o.getElementById(v.fromElementId);if(!x)return null;const h=o.elementPorts.get(v.fromElementId)??[],a=h.findIndex(f=>f.key===v.fromPortKey),i=h[a];return i?S.portPosition(x,i,a,h.length):null}),p=N(()=>{const v=d.linkingState;if(!v||!m.value)return"";const{x,y:h}=m.value,{currentX:a,currentY:i}=v,f=Math.abs(a-x)*.5;return`M ${x} ${h} C ${x+f} ${h}, ${a-f} ${i}, ${a} ${i}`});return(v,x)=>{const h=Bn;return l(),s("svg",Un,[(l(!0),s(O,null,oe(L(o).links,a=>(l(),me(h,{key:a.id,link:a},null,8,["link"]))),128)),L(d).linkingState&&m.value?(l(),s("path",{key:0,d:p.value,fill:"none",stroke:"#3b82f6","stroke-width":"2","stroke-dasharray":"6 4",opacity:"0.7"},null,8,Yn)):M("",!0)])}}}),Xn=["title"],Ye=12,Kn=de({__name:"CanvasPortDot",props:{element:{},port:{},portIndex:{},totalPorts:{}},setup(g){const o=g,d=we(),S=ge(),m=N(()=>{const h=(o.portIndex+1)/(o.totalPorts+1),a=o.element.height*h-Ye/2;return o.port.direction==="input"?{left:`-${Ye/2}px`,top:`${a}px`}:{left:`${o.element.width-Ye/2}px`,top:`${a}px`}}),p=N(()=>({text:"hover:border-sky-400 hover:bg-sky-400",json:"hover:border-amber-400 hover:bg-amber-400",agent:"hover:border-purple-400 hover:bg-purple-400",task:"hover:border-green-400 hover:bg-green-400",file:"hover:border-orange-400 hover:bg-orange-400"})[o.port.dataType]??"hover:border-wire-blue hover:bg-wire-blue");function v(){if(!d.tapConnectPort)d.tapConnectPort={elementId:o.element.id,portKey:o.port.key};else{const h=d.tapConnectPort;if(h.elementId!==o.element.id||h.portKey!==o.port.key){const a=h.portKey.includes("out")||o.port.direction==="input"?h:{elementId:o.element.id,portKey:o.port.key},i=a===h?{elementId:o.element.id,portKey:o.port.key}:h;S.createLink(a.elementId,a.portKey,i.elementId,i.portKey)}d.tapConnectPort=null}}function x(h){var $;const{screenToBoard:a}=_e(),i=($=h.currentTarget.closest(".canvas-root"))==null?void 0:$.getBoundingClientRect(),f=a(h.clientX-((i==null?void 0:i.left)??0),h.clientY-((i==null?void 0:i.top)??0));d.linkingState={fromElementId:o.element.id,fromPortKey:o.port.key,currentX:f.x,currentY:f.y},h.stopPropagation()}return(h,a)=>(l(),s("div",{class:J(["canvas-port-dot absolute w-3 h-3 rounded-full border-2 border-slate-500 bg-slate-900 cursor-crosshair hover:border-wire-blue hover:bg-wire-blue transition-colors z-20",p.value]),style:ie(m.value),title:g.port.label,onPointerdown:y(x,["stop"]),onClick:y(v,["stop"])},null,46,Xn))}}),Hn=["data-element-id"],Wn={key:0,class:"absolute left-0 right-0 z-30 opacity-0 group-hover:opacity-100 transition-opacity duration-150",style:{top:"-35px","pointer-events":"none"}},Jn={class:"flex items-center gap-1 px-2 py-1.5 bg-slate-900/95 backdrop-blur-sm rounded-lg border border-slate-700/60 select-none",style:{"pointer-events":"auto"}},Zn=["onKeydown"],Gn={class:"absolute inset-0 flex flex-col items-center justify-center gap-1.5 pointer-events-none px-10"},qn={class:"text-sm font-medium text-slate-200 text-center w-full truncate text-center"},Qn=30,el=de({__name:"CanvasElement",props:{element:{}},setup(g){const o=g,d=we(),S=Ce(),m=ge(),p=Qe(),v=Ke(),{camera:x}=_e(),h=A(!1),a=A(!1),i=N(()=>d.selectedElementIds.includes(o.element.id)),f=A(!1),$=A(""),j=N(()=>({left:o.element.x+"px",top:o.element.y+"px",width:o.element.width+"px",height:o.element.height+"px"})),n={cli:"#8b5cf6",data:"#3b82f6",research:"#f59e0b",docs:"#f97316",dev:"#22c55e",thinking:"#ec4899",pm:"#14b8a6",comm:"#06b6d4",flow:"#6366f1",org:"#64748b"},c=N(()=>v.getAllTypeDefinitions().find(r=>r.type===o.element.type)),E=N(()=>{var r;for(const C of((r=c.value)==null?void 0:r.tags)??[])if(n[C])return n[C];return"#64748b"}),X=N(()=>({backgroundColor:E.value+"33",color:E.value})),F=N(()=>({running:"bg-green-400 animate-pulse",completed:"bg-green-400",error:"bg-red-400",fading:"bg-slate-500"})[o.element.state??""]??""),V=N(()=>S.elementViewData.get(o.element.id)??{}),ae=N(()=>{const r=V.value,C=o.element.data;return(r==null?void 0:r.name)??(r==null?void 0:r.title)??(C==null?void 0:C.name)??(C==null?void 0:C.title)??(C==null?void 0:C.agentName)??o.element.type}),le=N(()=>S.elementPorts.get(o.element.id)??[]);let U={px:0,py:0,ex:0,ey:0},ce=0;function b(r){a.value=!0,d.draggingElementId=o.element.id,U={px:r.clientX,py:r.clientY,ex:o.element.x,ey:o.element.y},r.currentTarget.setPointerCapture(r.pointerId)}function I(r){r.target.closest("button")||b(r)}function Y(r){r.target.closest("button")||b(r)}function K(r){if(!a.value)return;const C=Date.now();if(C-ce<Qn)return;ce=C;const H=(r.clientX-U.px)/x.zoom,xe=(r.clientY-U.py)/x.zoom;m.moveElement(o.element.id,U.ex+H,U.ey+xe)}function te(){a.value=!1,d.draggingElementId=null}let Q={px:0,py:0,ew:0,eh:0},z=!1;function q(r){z=!0,Q={px:r.clientX,py:r.clientY,ew:o.element.width,eh:o.element.height},r.currentTarget.setPointerCapture(r.pointerId)}function se(r){if(!z)return;const C=(r.clientX-Q.px)/x.zoom,H=(r.clientY-Q.py)/x.zoom,xe=Math.max(120,Q.ew+C),D=Math.max(60,Q.eh+H);m.resizeElement(o.element.id,Math.round(xe),Math.round(D))}function ye(){z=!1}function ke(r){var C,H,xe;r.name==="openChat"||r.name==="openSession"?(p.openChatSidebar(o.element.id,r.agentName??((C=o.element.data)==null?void 0:C.agentName)??((H=o.element.data)==null?void 0:H.name)??"",r.sessionId??((xe=o.element.data)==null?void 0:xe.sessionId)??o.element.id),r.name==="openSession"&&m.invokeElementAction(o.element.id,"openSession",{}).catch(()=>{})):r.name==="addChatView"?m.addElement("chat-view",o.element.x+o.element.width+20,o.element.y,{agentName:r.agentName,sessionId:r.sessionId}):r.name==="invokeAction"?m.invokeElementAction(o.element.id,r.action,r.params??{}).then(r.resolve??(()=>{})).catch(r.reject??(()=>{})):r.name==="updateData"?m.updateElement(o.element.id,{data:{...o.element.data,...r.data}}):r.name==="startDrag"?b(r.event):r.name==="stopDrag"?te():r.name==="dragMove"&&K(r.event)}const pe={mounted:r=>r.focus()};function R(){$.value=ae.value,f.value=!0}function _(){f.value=!1;const r=$.value.trim();!r||r===ae.value||m.updateElement(o.element.id,{data:{...o.element.data,name:r}})}function T(r){d.selectElement(o.element.id,r.shiftKey||r.ctrlKey)}function k(r){d.contextMenu={x:r.clientX,y:r.clientY,targetElementId:o.element.id}}function w(r){r.button===0&&(r.ctrlKey||r.metaKey||d.selectedElementIds.includes(o.element.id)||d.selectElement(o.element.id,r.shiftKey))}function Z(r){const C=o.element.expanded!==!1,H=d.selectedElementIds.includes(o.element.id);C&&H||(r.preventDefault(),d.selectElement(o.element.id,r.shiftKey||r.ctrlKey),k(r))}return st(()=>{a.value&&te()}),(r,C)=>{var xe,D;const H=Kn;return l(),s("div",{class:J(["canvas-element absolute group",[a.value?"z-dragging":i.value?"z-selected":"z-normal",g.element.state==="fading"?"fading":"",i.value?"ring-2 ring-wire-blue ring-offset-1 ring-offset-slate-950":""]]),style:ie(j.value),"data-element-id":g.element.id,onPointerdownCapture:w,onClick:y(T,["stop"]),onContextmenu:y(Z,["stop"]),onPointerenter:C[11]||(C[11]=t=>h.value=!0),onPointerleave:C[12]||(C[12]=t=>h.value=!1)},[g.element.expanded!==!1?(l(),s("div",Wn,[e("div",Jn,[e("div",{class:"flex-1 flex items-center gap-1.5 cursor-grab active:cursor-grabbing overflow-hidden",onPointerdown:I,onPointermove:K,onPointerup:te},[e("span",{class:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full flex-shrink-0",style:ie(X.value)},P(((xe=c.value)==null?void 0:xe.name)??g.element.type),5),f.value?W((l(),s("input",{key:0,"onUpdate:modelValue":C[0]||(C[0]=t=>$.value=t),class:"flex-1 text-xs font-medium text-slate-200 bg-slate-800 border border-slate-600 rounded px-1 outline-none",style:{"pointer-events":"auto"},onPointerdown:C[1]||(C[1]=y(()=>{},["stop"])),onKeydown:[ze(y(_,["stop"]),["enter"]),C[2]||(C[2]=ze(y(t=>f.value=!1,["stop"]),["escape"]))],onBlur:_},null,40,Zn)),[[ne,$.value],[pe]]):(l(),s("span",{key:1,class:"flex-1 text-xs font-medium text-slate-200 truncate",onDblclick:y(R,["stop"])},P(ae.value),33)),F.value?(l(),s("span",{key:2,class:J(["w-2 h-2 rounded-full flex-shrink-0",F.value])},null,2)):M("",!0)],32),e("button",{class:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200 text-[10px]",onPointerdown:C[3]||(C[3]=y(()=>{},["stop"])),onClick:C[4]||(C[4]=y(t=>L(m).collapseElement(g.element.id),["stop"])),title:"Collapse"},"▲",32),e("button",{class:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200 text-xs",onPointerdown:C[5]||(C[5]=y(()=>{},["stop"])),onClick:C[6]||(C[6]=y(t=>k(t),["stop"]))},"⋮",32)])])):M("",!0),g.element.expanded===!1?(l(),s("div",{key:1,class:"w-full h-full relative rounded-lg border border-slate-700/80 bg-slate-900 select-none",onPointerdown:y(Y,["stop"]),onPointermove:y(K,["stop"]),onPointerup:y(te,["stop"])},[e("div",Gn,[e("span",{class:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:ie(X.value)},P(((D=c.value)==null?void 0:D.name)??g.element.type),5),e("span",qn,P(ae.value),1)]),e("button",{class:"absolute top-2 right-8 w-5 h-5 flex items-center justify-center rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200 text-[10px]",onPointerdown:C[7]||(C[7]=y(()=>{},["stop"])),onClick:C[8]||(C[8]=y(t=>L(m).expandElement(g.element.id),["stop"])),title:"Expand"},"▼",32),e("button",{class:"absolute top-2 right-2 w-5 h-5 flex items-center justify-center rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200 text-xs",onPointerdown:C[9]||(C[9]=y(()=>{},["stop"])),onClick:C[10]||(C[10]=y(t=>k(t),["stop"]))},"⋮",32)],32)):(l(),me(qe(L(v).getComponent(g.element.type)),{key:2,element:g.element,viewData:L(S).elementViewData.get(g.element.id)??{},style:ie(i.value?{userSelect:"text"}:{}),onAction:ke},null,40,["element","viewData","style"])),h.value||L(d).linkingState||L(d).tapConnectPort?(l(!0),s(O,{key:3},oe(le.value,(t,G)=>(l(),me(H,{key:t.key,element:g.element,port:t,portIndex:G,totalPorts:le.value.length},null,8,["element","port","portIndex","totalPorts"]))),128)):M("",!0),e("div",{class:"resize-handle absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-20 flex items-end justify-end pr-0.5 pb-0.5",onPointerdown:y(q,["stop"]),onPointermove:y(se,["stop"]),onPointerup:y(ye,["stop"])},[...C[13]||(C[13]=[e("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none"},[e("path",{d:"M1 7L7 1M4 7L7 4M7 7L7 7",stroke:"#475569","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],32)],46,Hn)}}}),tl=Pe(el,[["__scopeId","data-v-4234675e"]]),ol={width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{"flex-shrink":"0",color:"#60a5fa"}},nl={class:"text-xs font-medium text-slate-200"},Le=8,ll=30,sl=de({__name:"CanvasMultiSelectBox",setup(g){const o=we(),d=Ce(),S=ge(),{camera:m}=_e(),p=N(()=>d.elements.filter(n=>o.selectedElementIds.includes(n.id))),v=N(()=>p.value.length),x=N(()=>{const n=p.value;if(n.length<=1)return null;const c=Math.min(...n.map(V=>V.x))-Le,E=Math.min(...n.map(V=>V.y))-Le,X=Math.max(...n.map(V=>V.x+V.width))+Le,F=Math.max(...n.map(V=>V.y+V.height))+Le;return{x:c,y:E,w:X-c,h:F-E}}),h=N(()=>x.value?{left:x.value.x+"px",top:x.value.y+"px",width:x.value.w+"px",height:x.value.h+"px"}:{});let a=null,i=0;function f(n){a={px:n.clientX,py:n.clientY,positions:p.value.map(c=>({id:c.id,x:c.x,y:c.y}))},n.currentTarget.setPointerCapture(n.pointerId),n.preventDefault()}function $(n){if(!a)return;const c=Date.now();if(c-i<ll)return;i=c;const E=(n.clientX-a.px)/m.zoom,X=(n.clientY-a.py)/m.zoom;for(const F of a.positions)S.moveElement(F.id,F.x+E,F.y+X)}function j(){a=null}return(n,c)=>x.value?(l(),s("div",{key:0,class:"absolute pointer-events-none",style:ie(h.value)},[c[1]||(c[1]=e("div",{class:"absolute inset-0 border-2 border-dashed border-blue-500/60 rounded-sm",style:{"background-color":"#3b82f626"}},null,-1)),e("div",{class:"absolute left-1/2 -translate-x-1/2 pointer-events-auto flex items-center gap-1.5 px-2.5 py-1 bg-slate-800 border border-blue-500/60 rounded-full shadow-lg cursor-grab active:cursor-grabbing select-none whitespace-nowrap",style:{top:"-30px"},onPointerdown:y(f,["stop"]),onPointermove:y($,["stop"]),onPointerup:y(j,["stop"])},[(l(),s("svg",ol,[...c[0]||(c[0]=[e("path",{d:"M6 1v10M1 6h10",stroke:"currentColor","stroke-width":"1.4","stroke-linecap":"round"},null,-1),e("path",{d:"M4 3L6 1l2 2M4 9l2 2 2-2M3 4L1 6l2 2M9 4l2 2-2 2",stroke:"currentColor","stroke-width":"1.4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])),e("span",nl,P(v.value)+" selected",1)],32)],4)):M("",!0)}}),al=de({__name:"CanvasTransform",setup(g){const{transformStyle:o}=_e();return(d,S)=>(l(),s("div",{class:"canvas-transform absolute top-0 left-0",style:ie([{"transform-origin":"0 0","will-change":"transform"},L(o)])},[at(d.$slots,"default")],4))}}),rl=de({__name:"CanvasToolbar",setup(g){const{camera:o,zoomAt:d,fitToContent:S}=_e(),m=Ce(),p=we(),v=ge(),x=N(()=>Math.round(o.zoom*100)),h=A(!1);function a(){d(-1,window.innerWidth/2,window.innerHeight/2)}function i(){d(1,window.innerWidth/2,window.innerHeight/2)}function f(){o.zoom=1,o.x=0,o.y=0}function $(){S(m.elements)}async function j(){if(!h.value){h.value=!0;try{await v.restoreLastDeleted()}finally{h.value=!1}}}return(n,c)=>(l(),s("div",{class:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 flex items-center gap-0.5 bg-slate-900/95 backdrop-blur border-t border-l border-r border-slate-700/60 px-2 py-1",style:{width:"fit-content","border-top-left-radius":"7px","border-top-right-radius":"7px"},onPointerdown:c[1]||(c[1]=y(()=>{},["stop"]))},[e("button",{class:"toolbar-btn",title:"Zoom out",onClick:i},"−"),e("button",{class:"toolbar-btn w-14 text-center font-mono",onClick:f},P(x.value)+"%",1),e("button",{class:"toolbar-btn",title:"Zoom in",onClick:a},"+"),c[5]||(c[5]=e("div",{class:"w-px h-4 bg-slate-700 mx-1"},null,-1)),e("button",{class:"toolbar-btn",title:"Fit to content",onClick:$},[...c[2]||(c[2]=[Xe('<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-7f7a6b6b><path d="M8 3H5a2 2 0 0 0-2 2v3" data-v-7f7a6b6b></path><path d="M21 8V5a2 2 0 0 0-2-2h-3" data-v-7f7a6b6b></path><path d="M3 16v3a2 2 0 0 0 2 2h3" data-v-7f7a6b6b></path><path d="M16 21h3a2 2 0 0 0 2-2v-3" data-v-7f7a6b6b></path></svg>',1)])]),c[6]||(c[6]=e("div",{class:"w-px h-4 bg-slate-700 mx-1"},null,-1)),e("button",{class:J(["toolbar-btn",{"opacity-40 cursor-default":h.value}]),title:"Undo last delete",onClick:j},[...c[3]||(c[3]=[e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M3 7v6h6"}),e("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.36 2.64L3 13"})],-1)])],2),c[7]||(c[7]=e("div",{class:"w-px h-4 bg-slate-700 mx-1"},null,-1)),e("button",{class:J(["toolbar-btn",{"text-wire-blue":L(p).minimapVisible}]),title:"Toggle minimap",onClick:c[0]||(c[0]=E=>L(p).setMinimapVisible(!L(p).minimapVisible))},[...c[4]||(c[4]=[e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e("rect",{x:"12",y:"12",width:"8",height:"8",rx:"1",fill:"currentColor",opacity:"0.4"})],-1)])],2)],32))}}),il=Pe(rl,[["__scopeId","data-v-7f7a6b6b"]]),dl=["viewBox"],ul=["x","y","width","height","fill"],cl=["x","y","width","height"],Ve=40,pl=de({__name:"CanvasMinimap",setup(g){const o=Ce(),d=we(),{camera:S,goToPosition:m}=_e(),p=N(()=>{const a=o.elements;if(!a.length)return{minX:0,minY:0,maxX:800,maxY:600};let i=1/0,f=1/0,$=-1/0,j=-1/0;for(const n of a)i=Math.min(i,n.x-Ve),f=Math.min(f,n.y-Ve),$=Math.max($,n.x+n.width+Ve),j=Math.max(j,n.y+n.height+Ve);return{minX:i,minY:f,maxX:$,maxY:j}}),v=N(()=>{const{minX:a,minY:i,maxX:f,maxY:$}=p.value;return`${a} ${i} ${f-a} ${$-i}`}),x=N(()=>{const{minX:a,minY:i,maxX:f,maxY:$}=p.value,j=f-a,n=$-i;if(j<=0||n<=0)return null;const c=window.innerWidth/S.zoom,E=window.innerHeight/S.zoom,X=-S.x/S.zoom,F=-S.y/S.zoom;return{x:X,y:F,w:c,h:E}});function h(a){const i=a.currentTarget.getBoundingClientRect(),f=(a.clientX-i.left)/i.width,$=(a.clientY-i.top)/i.height,{minX:j,minY:n,maxX:c,maxY:E}=p.value,X=j+(c-j)*f,F=n+(E-n)*$,V=o.elements.find(U=>X>=U.x&&X<=U.x+U.width&&F>=U.y&&F<=U.y+U.height),ae=V?V.x+V.width/2:X,le=V?V.y+V.height/2:F;m(window.innerWidth/2-ae*S.zoom,window.innerHeight/2-le*S.zoom)}return(a,i)=>(l(),s("div",{class:"absolute bottom-2 right-2 z-40 bg-slate-900/90 border border-slate-700 rounded-lg overflow-hidden shadow-xl cursor-pointer",style:{width:"200px",height:"150px"},onClick:h,title:"Click to navigate · Click element to center on it"},[(l(),s("svg",{width:"200",height:"150",viewBox:v.value},[(l(!0),s(O,null,oe(L(o).elements,f=>(l(),s("rect",{key:f.id,x:f.x,y:f.y,width:f.width,height:f.height,rx:"2",fill:L(d).selectedElementIds.includes(f.id)?"#3b82f6":"#475569",opacity:"0.85"},null,8,ul))),128)),x.value?(l(),s("rect",{key:0,x:x.value.x,y:x.value.y,width:x.value.w,height:x.value.h,fill:"none",stroke:"#3b82f6","stroke-width":"3",opacity:"0.7"},null,8,cl)):M("",!0)],8,dl))]))}}),xl=de({__name:"ElementContextMenu",props:{elementId:{}},emits:["close"],setup(g,{emit:o}){const d=g,S=o,m=we(),p=ge(),v=N(()=>{const i=m.contextMenu;return i?{position:"fixed",left:i.x+"px",top:i.y-40+"px"}:{}});function x(){p.duplicateElement(d.elementId),S("close")}function h(){p.archiveElement(d.elementId),S("close")}function a(){p.deleteElement(d.elementId),S("close")}return(i,f)=>(l(),s("div",{class:"absolute z-50 bg-slate-800 border border-slate-700 rounded-xl shadow-2xl py-1 min-w-44",style:ie(v.value),onClick:f[0]||(f[0]=y(()=>{},["stop"]))},[e("button",{class:"ctx-item",onClick:x},"Duplicate"),e("button",{class:"ctx-item",onClick:h},"Archive"),f[1]||(f[1]=e("div",{class:"my-1 border-t border-slate-700"},null,-1)),e("button",{class:"ctx-item text-red-400 hover:text-red-300",onClick:a},"Delete")],4))}}),vl=Pe(xl,[["__scopeId","data-v-db0833bf"]]),ml={class:"absolute inset-0 w-full h-full pointer-events-none","aria-hidden":"true"},fl=["x","y","width","height"],bl=["fill"],gl=["onClick"],Je="dot-grid",je=32,yl=de({__name:"Canvas",setup(g){const o=A(null),d=we(),S=Ce(),{camera:m,zoomAt:p,screenToBoard:v}=_e(),x=ge(),h=Ke(),a=A(null);Me(()=>d.contextMenu,async b=>{if(b&&!b.targetElementId){a.value=null;try{const I=await navigator.clipboard.readText();I!=null&&I.trim()&&(a.value=I)}catch{}}else a.value=null});const i=A(!1),f=A(!1),$=N(()=>i.value||f.value);let j={x:0,y:0,cx:0,cy:0};const n=A(null);let c=null;function E(b){const I=b.target.closest("[data-element-id]");if(I){const Y=I.getAttribute("data-element-id");if(Y&&d.selectedElementIds.includes(Y))return}if(b.preventDefault(),b.ctrlKey||b.metaKey){const Y=o.value.getBoundingClientRect();p(b.deltaY,b.clientX-Y.left,b.clientY-Y.top)}else b.shiftKey?m.x-=b.deltaY:m.y-=b.deltaY}function X(b){if(d.contextMenu){d.closeContextMenu();return}if(b.button!==0&&b.button!==1)return;const I=b.target.closest(".canvas-element")!==null||b.target.closest(".canvas-zone")!==null;if(b.button===1||b.ctrlKey||b.metaKey||d.spaceHeld){i.value=!0,f.value=!1,j={x:b.clientX,y:b.clientY,cx:m.x,cy:m.y},b.currentTarget.setPointerCapture(b.pointerId),b.preventDefault();return}I||b.target.closest("[data-shape-preview]")||(b.currentTarget.setPointerCapture(b.pointerId),b.preventDefault(),c={x:b.clientX,y:b.clientY},n.value=null)}function F(b){if(i.value){const I=b.clientX-j.x,Y=b.clientY-j.y;!f.value&&(Math.abs(I)>3||Math.abs(Y)>3)&&(f.value=!0),f.value&&(m.x=j.cx+I,m.y=j.cy+Y);return}if(c){const I=o.value.getBoundingClientRect(),Y=Math.min(c.x,b.clientX)-I.left,K=Math.min(c.y,b.clientY)-I.top,te=Math.max(c.x,b.clientX)-I.left,Q=Math.max(c.y,b.clientY)-I.top;(Math.abs(b.clientX-c.x)>3||Math.abs(b.clientY-c.y)>3)&&(n.value={x:Y,y:K,w:te-Y,h:Q-K});return}if(d.linkingState){const I=o.value.getBoundingClientRect(),Y=v(b.clientX-I.left,b.clientY-I.top);d.linkingState.currentX=Y.x,d.linkingState.currentY=Y.y}}function V(b){if(i.value){b.currentTarget.releasePointerCapture(b.pointerId),f.value||(d.deselectAll(),d.linkingState=null,d.tapConnectPort=null),i.value=!1,f.value=!1;return}if(c){if(b.currentTarget.releasePointerCapture(b.pointerId),n.value){const I=v(n.value.x,n.value.y),Y=v(n.value.x+n.value.w,n.value.y+n.value.h),K=S.elements.filter(te=>te.x<Y.x&&te.x+te.width>I.x&&te.y<Y.y&&te.y+te.height>I.y).map(te=>te.id);d.selectedElementIds=K}else d.deselectAll(),d.linkingState=null,d.tapConnectPort=null;n.value=null,c=null}}function ae(b){b.target.closest(".canvas-element")===null&&(d.contextMenu={x:b.clientX,y:b.clientY,targetElementId:null})}function le(b){if(!d.contextMenu)return;const I=o.value.getBoundingClientRect(),Y=v(d.contextMenu.x-I.left,d.contextMenu.y-I.top);x.addElement(b,Y.x,Y.y),d.closeContextMenu()}function U(){if(!a.value||!d.contextMenu)return;const b=o.value.getBoundingClientRect(),I=v(d.contextMenu.x-b.left,d.contextMenu.y-b.top);x.addElement("markdown",I.x,I.y,{content:a.value}),d.closeContextMenu()}function ce(b){var z,q;const I=o.value.getBoundingClientRect(),Y=v(b.clientX-I.left,b.clientY-I.top),K=(z=b.dataTransfer)==null?void 0:z.getData("application/x-veil-shape");if(K){try{const{subtype:se}=JSON.parse(K);x.addShape({subtype:se,x:Y.x-80,y:Y.y-60,width:160,height:120})}catch{}return}const te=(q=b.dataTransfer)==null?void 0:q.getData("application/x-veil-element");if(!te)return;let Q;try{Q=JSON.parse(te)}catch{return}x.addElement(Q.type,Y.x,Y.y,Q.data)}return(b,I)=>{var pe;const Y=Dn,K=Ln,te=On,Q=tl,z=sl,q=al,se=il,ye=pl,ke=vl;return l(),s("div",{ref_key:"canvasRef",ref:o,class:J(["canvas-root w-full h-full relative overflow-hidden bg-slate-950 select-none",{"cursor-grab":$.value&&!f.value,"cursor-grabbing":f.value,"cursor-crosshair":!!L(c)}]),onWheel:E,onPointerdown:X,onPointermove:F,onPointerup:V,onContextmenu:y(ae,["prevent"]),onDragover:I[3]||(I[3]=y(()=>{},["prevent"])),onDrop:y(ce,["prevent"])},[(l(),s("svg",ml,[e("defs",null,[e("pattern",{id:Je,x:L(m).x%(je*L(m).zoom),y:L(m).y%(je*L(m).zoom),width:je*L(m).zoom,height:je*L(m).zoom,patternUnits:"userSpaceOnUse"},[...I[4]||(I[4]=[e("circle",{cx:"1",cy:"1",r:"1",fill:"#334155"},null,-1)])],8,fl)]),e("rect",{width:"100%",height:"100%",fill:`url(#${Je})`},null,8,bl)])),be(q,null,{default:Ne(()=>[(l(!0),s(O,null,oe(L(S).shapes,R=>(l(),me(Y,{key:R.id,shape:R},null,8,["shape"]))),128)),(l(!0),s(O,null,oe(L(S).zones,R=>(l(),me(K,{key:R.id,zone:R},null,8,["zone"]))),128)),be(te),(l(!0),s(O,null,oe(L(S).elements,R=>(l(),me(Q,{key:R.id,element:R},null,8,["element"]))),128)),be(z)]),_:1}),be(se),L(d).minimapVisible?(l(),me(ye,{key:0})):M("",!0),n.value?(l(),s("div",{key:1,class:"absolute pointer-events-none z-30 border border-blue-500 bg-blue-500/10",style:ie({left:n.value.x+"px",top:n.value.y+"px",width:n.value.w+"px",height:n.value.h+"px"})},null,4)):M("",!0),(pe=L(d).contextMenu)!=null&&pe.targetElementId?(l(),me(ke,{key:2,elementId:L(d).contextMenu.targetElementId,onClose:I[0]||(I[0]=R=>L(d).closeContextMenu()),onPointerdown:I[1]||(I[1]=y(()=>{},["stop"]))},null,8,["elementId"])):M("",!0),L(d).contextMenu&&!L(d).contextMenu.targetElementId?(l(),s("div",{key:3,class:"z-50 bg-slate-800 border border-slate-700 rounded-lg shadow-xl py-1 w-[200px]",onPointerdown:I[2]||(I[2]=y(()=>{},["stop"])),style:ie({position:"fixed",left:L(d).contextMenu.x+"px",top:L(d).contextMenu.y+"px"})},[a.value?(l(),s(O,{key:0},[e("button",{class:"w-full text-left px-3 py-1.5 text-sm hover:bg-slate-700 text-blue-300",onClick:U},"Paste as Text"),I[5]||(I[5]=e("div",{class:"my-1 border-t border-slate-700"},null,-1))],64)):M("",!0),I[6]||(I[6]=e("div",{class:"px-3 py-1 text-xs text-slate-500 font-medium uppercase tracking-wide"},"Add Element",-1)),(l(!0),s(O,null,oe(L(h).typeDefinitions.value.filter(R=>!R.hiddenFromPalette).slice(0,8),R=>(l(),s("button",{key:R.type,class:"w-full text-left px-3 py-1.5 text-sm hover:bg-slate-700 text-slate-200",onClick:_=>le(R.type)},P(R.name),9,gl))),128))],36)):M("",!0)],34)}}}),hl={class:"agent-editor-sidebar flex flex-col h-full overflow-hidden bg-slate-900"},kl={class:"flex items-center gap-2 px-4 py-3 border-b border-slate-700/60 flex-shrink-0"},wl={class:"w-6 h-6 rounded-full bg-purple-600/40 border border-purple-500/50 flex items-center justify-center text-xs text-purple-300 font-bold flex-shrink-0"},_l={class:"flex-1 text-sm font-semibold text-slate-200 truncate"},Cl={key:0,class:"text-[10px] text-slate-400 bg-slate-700/60 px-1.5 py-0.5 rounded border border-slate-600/40"},$l={key:1,class:"text-[10px] text-amber-400 bg-amber-400/10 px-1.5 py-0.5 rounded border border-amber-400/20"},Sl={class:"flex border-b border-slate-700/60 flex-shrink-0"},Ml=["onClick"],Pl={key:0,class:"flex-1 flex items-center justify-center"},El={key:1,class:"flex-1 flex items-center justify-center px-4"},zl={class:"text-red-400 text-xs text-center"},Il={key:2,class:"flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-4"},Tl={class:"flex items-center gap-2"},Dl={class:"text-xs font-semibold text-slate-100"},Al={class:"flex flex-col gap-1"},Ll=["readonly"],Vl={class:"flex flex-col gap-1"},jl={class:"flex flex-col gap-1"},Nl=["disabled"],Rl={class:"flex flex-col gap-1"},Fl=["disabled"],Bl={class:"flex flex-col gap-1"},Ul=["disabled"],Yl={class:"flex items-center justify-between"},Ol=["disabled"],Xl={class:"flex gap-1 flex-wrap"},Kl=["onClick"],Hl={class:"flex items-center justify-between"},Wl=["disabled"],Jl={class:"flex flex-col gap-1"},Zl=["readonly"],Gl={class:"flex flex-col gap-1"},ql=["readonly"],Ql={class:"flex flex-col gap-1"},es=["readonly"],ts={class:"flex flex-col gap-1"},os=["readonly"],ns={class:"flex flex-col gap-1"},ls=["readonly"],ss={class:"flex flex-col gap-1"},as=["readonly"],rs={class:"flex flex-col gap-1"},is=["readonly"],ds={class:"border border-slate-700/50 rounded-lg p-3 flex flex-col gap-2"},us={class:"flex flex-col gap-1"},cs=["readonly"],ps={class:"flex flex-col gap-1"},xs=["readonly"],vs={class:"grid grid-cols-2 gap-2"},ms={class:"flex flex-col gap-1"},fs={class:"flex flex-col gap-1"},bs={class:"flex flex-col gap-1"},gs={class:"grid grid-cols-2 gap-2"},ys={class:"flex flex-col gap-1"},hs={class:"flex flex-col gap-1"},ks={class:"flex flex-col gap-1"},ws={class:"flex flex-col gap-1"},_s={class:"flex flex-col gap-1"},Cs={class:"flex flex-col gap-1"},$s={class:"flex items-center justify-between"},Ss=["disabled"],Ms={key:0,class:"flex flex-col gap-1"},Ps=["disabled"],Es={class:"flex flex-col gap-2"},zs={class:"flex items-center justify-between"},Is={class:"flex items-center gap-2"},Ts={key:0,class:"flex flex-col gap-1.5 p-2.5 bg-slate-800/60 border border-slate-700/40 rounded-lg"},Ds={class:"flex gap-1.5 items-center"},As=["disabled"],Ls={key:0,class:"text-[10px] text-red-400 leading-relaxed"},Vs={class:"flex flex-col gap-1"},js={class:"flex items-center gap-1.5"},Ns={key:0,class:"text-[9px] text-slate-600"},Rs={key:0,class:"text-[11px] text-slate-600 italic pl-1"},Fs=["onClick"],Bs={class:"text-slate-500 text-[9px]"},Us={class:"text-xs text-slate-300 flex-1 truncate font-mono"},Ys={key:0,class:"text-[9px] text-amber-400 bg-amber-400/10 px-1 py-0.5 rounded border border-amber-400/20 flex-shrink-0"},Os={class:"text-[10px] text-slate-600 flex-shrink-0"},Xs=["value","readonly","onInput"],Ks={class:"flex flex-col gap-1"},Hs={class:"flex items-center gap-1.5"},Ws={key:0,class:"text-[9px] text-slate-600"},Js={key:0,class:"text-[11px] text-slate-600 italic pl-1"},Zs=["onClick"],Gs={class:"text-slate-500 text-[9px]"},qs={class:"text-xs text-slate-300 flex-1 truncate font-mono"},Qs={key:0,class:"text-[9px] text-amber-400 bg-amber-400/10 px-1 py-0.5 rounded border border-amber-400/20 flex-shrink-0"},ea={class:"text-[10px] text-slate-600 flex-shrink-0"},ta=["value","onInput"],oa={class:"flex items-center justify-between"},na={class:"text-[10px] text-slate-600"},la=["readonly"],sa={key:3,class:"flex-shrink-0 border-t border-slate-700/60 px-4 py-3 flex flex-col gap-2"},aa={key:0,class:"bg-red-950/60 border border-red-700/50 rounded-lg px-3 py-2 text-[11px] text-red-300 leading-relaxed break-words whitespace-pre-line"},ra={key:1,class:"text-[11px] text-green-400"},ia={class:"flex items-center justify-end gap-2"},da=["disabled","title"],ua=de({__name:"AgentEditorSidebar",setup(g){const o=we(),d=He(),S=N(()=>o.agentEditorName||""),m=[{id:"basics",label:"Basics"},{id:"modes",label:"Modes"},{id:"memory",label:"Memory"},{id:"prompt",label:"Prompt"}],p=["chat","task","subagent","daemon"],v=A("basics"),x=A("chat"),h=A(!1),a=A(""),i=A(!1),f=A(""),$=A(!1);function j(){return{enabled:!1,tools:"",disallowedTools:"",skills:"",autoLoadSkills:"",mcpServers:"",allowedAgents:"",disallowedAgents:"",permissionsAllow:"",permissionsDeny:"",maxIterations:void 0,maxDurationSeconds:void 0,onExhausted:"fail",cron:"",conflictPolicy:"skip",heartbeatFile:"",alertRouting:""}}const n=rt({name:"",level:"project",source:"project",description:"",model:"",temperature:void 0,maxTokens:void 0,reasoning:"",skillDiscovery:!1,memoryEnabled:!1,memoryMaxLines:500,agentMd:"",modes:{chat:j(),task:j(),subagent:j(),daemon:j()}}),c=A(""),E=N(()=>n.source==="bundled"||n.level==="bundled"),X=A([]),F=A([]),V=A(!1),ae=A(!1),le=A(new Set),U=A({}),ce=A({});function b(D,t){return`${D}::${t}`}const I=N(()=>Object.keys(U.value).some(D=>U.value[D]!==ce.value[D])),Y=N(()=>JSON.stringify(n)!==c.value||I.value);function K(D){return typeof D=="string"?D:D.name||D.file||String(D)}function te(D){return typeof D=="object"&&D.size!=null?D.size<1024?`${D.size}B`:`${(D.size/1024).toFixed(1)}KB`:""}function Q(D,t){const G=b(D,t);return G in U.value&&U.value[G]!==ce.value[G]}function z(D,t,G){U.value[b(D,t)]=G}const q=A(!1),se=A(""),ye=A("agent"),ke=A(!1),pe=A("");async function R(){const D=se.value.trim();if(D){ke.value=!0,pe.value="";try{const t=ye.value,G=t==="agent"?S.value:void 0;await d.updateMemoryFile(D,"",G,t),await r();const B=b(t,D),u=new Set(le.value);u.add(B),le.value=u,ce.value[B]="",U.value[B]="",se.value="",q.value=!1}catch(t){pe.value=(t==null?void 0:t.message)||String(t)}finally{ke.value=!1}}}const _=N(()=>n.modes[x.value]);function T(D){return D?Array.isArray(D)?D.filter(Boolean).join(", "):D:""}function k(D){if(D!=null&&D.trim())return D.split(/[,\n]+/).map(t=>t.trim()).filter(Boolean)}async function w(){var D,t,G,B,u,ve;if(!S.value){h.value=!1;return}h.value=!0,a.value="";try{const[he,De]=await Promise.all([d.getAgent(S.value),d.getAgentMd(S.value).catch(()=>({content:""}))]),$e=he,fe=((D=$e==null?void 0:$e.agent)==null?void 0:D.agent)??($e==null?void 0:$e.agent)??$e;n.name=fe.name||S.value,n.level=fe.level||"project",n.source=fe.source||"project",n.description=fe.description||"",n.model=fe.model||"",n.temperature=fe.temperature,n.maxTokens=fe.maxTokens,n.reasoning=fe.reasoning||"",n.skillDiscovery=fe.skillDiscovery??!1,n.memoryEnabled=((t=fe.memory)==null?void 0:t.enabled)??!1,n.memoryMaxLines=((G=fe.memory)==null?void 0:G.maxLines)??500,n.agentMd=De.content||"";const Ae=fe.modes||{};for(const Se of p){const re=Ae[Se]||{},ue=n.modes[Se];ue.enabled=re.enabled??!1,ue.tools=T(re.tools),ue.disallowedTools=T(re.disallowedTools),ue.skills=T(re.skills),ue.autoLoadSkills=T(re.autoLoadSkills),ue.mcpServers=T(re.mcpServers),ue.allowedAgents=T(re.allowedAgents),ue.disallowedAgents=T(re.disallowedAgents),ue.permissionsAllow=T((B=re.permissions)==null?void 0:B.allow),ue.permissionsDeny=T((u=re.permissions)==null?void 0:u.deny),Se!=="chat"&&(ue.maxIterations=re.maxIterations,ue.maxDurationSeconds=re.maxDurationSeconds,ue.onExhausted=re.onExhausted||"fail"),Se==="daemon"&&(ue.cron=re.cron||"",ue.conflictPolicy=re.conflictPolicy||"skip",ue.heartbeatFile=re.heartbeatFile||"",ue.alertRouting=typeof re.alertRouting=="string"?re.alertRouting:((ve=re.alertRouting)==null?void 0:ve[0])||"")}c.value=JSON.stringify(n)}catch(he){a.value=(he==null?void 0:he.message)||String(he)}finally{h.value=!1}}function Z(){const D={};for(const G of p){const B=n.modes[G],u={enabled:B.enabled},ve=k(B.tools),he=k(B.disallowedTools),De=k(B.skills),$e=k(B.autoLoadSkills),fe=k(B.mcpServers),Ae=k(B.allowedAgents),Se=k(B.disallowedAgents),re=k(B.permissionsAllow),ue=k(B.permissionsDeny);ve&&(u.tools=ve),he&&(u.disallowedTools=he),De&&(u.skills=De),$e&&(u.autoLoadSkills=$e),fe&&(u.mcpServers=fe),Ae&&(u.allowedAgents=Ae),Se&&(u.disallowedAgents=Se),(re||ue)&&(u.permissions={...re?{allow:re}:{},...ue?{deny:ue}:{}}),G!=="chat"&&(B.maxIterations!=null&&(u.maxIterations=B.maxIterations),B.maxDurationSeconds!=null&&(u.maxDurationSeconds=B.maxDurationSeconds)),G==="task"&&(u.onExhausted=B.onExhausted),G==="daemon"&&(B.cron&&(u.cron=B.cron),u.conflictPolicy=B.conflictPolicy,B.heartbeatFile&&(u.heartbeatFile=B.heartbeatFile),B.alertRouting&&(u.alertRouting=B.alertRouting)),D[G]=u}const t={model:n.model,modes:D};return n.description&&(t.description=n.description),n.temperature!=null&&(t.temperature=n.temperature),n.maxTokens!=null&&(t.maxTokens=n.maxTokens),n.reasoning&&(t.reasoning=n.reasoning),t.skillDiscovery=n.skillDiscovery,t.memory={enabled:n.memoryEnabled,...n.memoryEnabled&&n.memoryMaxLines?{maxLines:n.memoryMaxLines}:{}},t}async function r(){if(S.value){V.value=!0,ae.value=!0;try{const[D,t]=await Promise.all([d.getMemory(S.value,"agent").catch(()=>({files:[]})),d.getMemory(void 0,"global").catch(()=>({files:[]}))]);X.value=Array.isArray(D.files)?D.files:[],F.value=Array.isArray(t.files)?t.files:[]}finally{V.value=!1,ae.value=!1}}}async function C(D,t){const G=b(D,t),B=new Set(le.value);if(B.has(G)){B.delete(G),le.value=B;return}if(B.add(G),le.value=B,!(G in U.value))try{const u=D==="agent"?S.value:void 0,he=(await d.getMemoryFile(t,u,D)).content||"";ce.value[G]=he,U.value[G]=he}catch{ce.value[G]="",U.value[G]=""}}async function H(){i.value=!0,f.value="",$.value=!1;try{const D=Z();await d.updateAgent(n.name,{config:D,...n.agentMd!==void 0?{agentMd:n.agentMd}:{}});for(const[t,G]of Object.entries(U.value))if(G!==ce.value[t]){const[B,...u]=t.split("::"),ve=u.join("::"),he=B==="agent"?n.name:void 0;await d.updateMemoryFile(ve,G,he,B),ce.value[t]=G}await d.reloadAgent(n.name),c.value=JSON.stringify(n),$.value=!0,setTimeout(()=>{$.value=!1},3e3)}catch(D){f.value=(D==null?void 0:D.message)||String(D)}finally{i.value=!1}}function xe(){Y.value&&!confirm("You have unsaved changes. Discard them?")||o.closeAgentEditor()}return Me(()=>o.agentEditorName,D=>{D&&(v.value="basics",X.value=[],F.value=[],le.value=new Set,Object.keys(U.value).forEach(t=>delete U.value[t]),ce.value={},q.value=!1,se.value="",pe.value="",w())}),Me(v,D=>{D==="memory"&&!X.value.length&&!F.value.length&&!V.value&&!ae.value&&r()}),Ie(()=>{w()}),(D,t)=>{var B;const G=et;return l(),s("div",hl,[e("div",kl,[e("span",wl,P((B=(S.value||"?")[0])==null?void 0:B.toUpperCase()),1),e("span",_l,P(S.value),1),E.value?(l(),s("span",Cl,"read-only")):Y.value?(l(),s("span",$l,"unsaved")):M("",!0),e("button",{class:"text-slate-500 hover:text-slate-200 transition-colors text-sm ml-1",onClick:xe},"✕")]),e("div",Sl,[(l(),s(O,null,oe(m,u=>e("button",{key:u.id,class:J(["flex-1 py-2 text-[11px] font-medium transition-colors",v.value===u.id?"text-purple-400 border-b-2 border-purple-500":"text-slate-500 hover:text-slate-300"]),onClick:ve=>v.value=u.id},P(u.label),11,Ml)),64))]),h.value?(l(),s("div",Pl,[...t[64]||(t[64]=[e("span",{class:"text-slate-500 text-sm"},"Loading…",-1)])])):a.value?(l(),s("div",El,[e("div",zl,P(a.value),1)])):(l(),s("div",Il,[v.value==="basics"?(l(),s(O,{key:0},[e("div",Tl,[e("span",Dl,P(n.name),1),e("span",{class:J(["text-[9px] px-1.5 py-0.5 rounded-full border",n.level==="global"?"bg-amber-600/25 text-amber-400 border-amber-600/30":"bg-slate-700 text-slate-400 border-slate-600"])},P(n.level||"project"),3)]),e("div",Al,[t[65]||(t[65]=e("label",{class:"field-label"},"Description",-1)),W(e("textarea",{"onUpdate:modelValue":t[0]||(t[0]=u=>n.description=u),rows:"2",class:J(["field-input resize-none",E.value?"opacity-60 cursor-default":""]),placeholder:"Agent description…",readonly:E.value,onPointerdown:t[1]||(t[1]=y(()=>{},["stop"]))},null,42,Ll),[[ne,n.description]])]),e("div",Vl,[t[66]||(t[66]=e("label",{class:"field-label"},"Model",-1)),be(G,{modelValue:n.model,"onUpdate:modelValue":t[2]||(t[2]=u=>n.model=u),placeholder:"Click to select model…",disabled:E.value},null,8,["modelValue","disabled"])]),e("div",jl,[t[67]||(t[67]=e("label",{class:"field-label"},[Ee("Temperature "),e("span",{class:"font-normal normal-case text-slate-600"},"(0–2)")],-1)),W(e("input",{"onUpdate:modelValue":t[3]||(t[3]=u=>n.temperature=u),type:"number",min:"0",max:"2",step:"0.1",class:"field-input",disabled:E.value,onPointerdown:t[4]||(t[4]=y(()=>{},["stop"]))},null,40,Nl),[[ne,n.temperature,void 0,{number:!0}]])]),e("div",Rl,[t[68]||(t[68]=e("label",{class:"field-label"},"Max Tokens",-1)),W(e("input",{"onUpdate:modelValue":t[5]||(t[5]=u=>n.maxTokens=u),type:"number",min:"1",class:"field-input",placeholder:"Model default",disabled:E.value,onPointerdown:t[6]||(t[6]=y(()=>{},["stop"]))},null,40,Fl),[[ne,n.maxTokens,void 0,{number:!0}]])]),e("div",Bl,[t[70]||(t[70]=e("label",{class:"field-label"},"Reasoning",-1)),W(e("select",{"onUpdate:modelValue":t[7]||(t[7]=u=>n.reasoning=u),class:"field-input",disabled:E.value,onPointerdown:t[8]||(t[8]=y(()=>{},["stop"]))},[...t[69]||(t[69]=[Xe('<option value="" data-v-93baa80e>none</option><option value="minimal" data-v-93baa80e>minimal</option><option value="low" data-v-93baa80e>low</option><option value="medium" data-v-93baa80e>medium</option><option value="high" data-v-93baa80e>high</option>',5)])],40,Ul),[[Te,n.reasoning]])]),e("div",Yl,[t[71]||(t[71]=e("label",{class:"field-label mb-0"},"Skill Discovery",-1)),e("button",{class:J(["toggle-btn",n.skillDiscovery?"bg-purple-600":"bg-slate-600"]),disabled:E.value,onClick:t[9]||(t[9]=u=>!E.value&&(n.skillDiscovery=!n.skillDiscovery)),onPointerdown:t[10]||(t[10]=y(()=>{},["stop"]))},[e("span",{class:J(["toggle-knob",n.skillDiscovery?"translate-x-4":"translate-x-0.5"])},null,2)],42,Ol)])],64)):M("",!0),v.value==="modes"?(l(),s(O,{key:1},[e("div",Xl,[(l(),s(O,null,oe(p,u=>e("button",{key:u,class:J(["px-2.5 py-1 text-[11px] rounded-lg border transition-colors flex items-center gap-1",x.value===u?"bg-purple-600/30 border-purple-500/60 text-purple-300":"bg-slate-800 border-slate-700 text-slate-400 hover:text-slate-200"]),onClick:ve=>x.value=u},[e("span",{class:J(["text-[8px]",n.modes[u].enabled?"text-purple-400":"text-slate-600"])},P(n.modes[u].enabled?"●":"○"),3),Ee(" "+P(u),1)],10,Kl)),64))]),e("div",Hl,[t[72]||(t[72]=e("label",{class:"field-label mb-0"},"Enabled",-1)),e("button",{class:J(["toggle-btn",_.value.enabled?"bg-purple-600":"bg-slate-600"]),disabled:E.value,onClick:t[11]||(t[11]=u=>!E.value&&(_.value.enabled=!_.value.enabled)),onPointerdown:t[12]||(t[12]=y(()=>{},["stop"]))},[e("span",{class:J(["toggle-knob",_.value.enabled?"translate-x-4":"translate-x-0.5"])},null,2)],42,Wl)]),e("div",Jl,[t[73]||(t[73]=e("label",{class:"field-label"},"Tools (allowed — LLM sees these)",-1)),W(e("textarea",{"onUpdate:modelValue":t[13]||(t[13]=u=>_.value.tools=u),rows:"2",class:"field-input font-mono resize-none",placeholder:"bash, read_file, write_file…",readonly:E.value,onPointerdown:t[14]||(t[14]=y(()=>{},["stop"]))},null,40,Zl),[[ne,_.value.tools]]),t[74]||(t[74]=e("span",{class:"hint"},"Comma or newline-separated",-1))]),e("div",Gl,[t[75]||(t[75]=e("label",{class:"field-label"},"Disallowed Tools (hidden from LLM)",-1)),W(e("textarea",{"onUpdate:modelValue":t[15]||(t[15]=u=>_.value.disallowedTools=u),rows:"2",class:"field-input font-mono resize-none",placeholder:"write_file…",readonly:E.value,onPointerdown:t[16]||(t[16]=y(()=>{},["stop"]))},null,40,ql),[[ne,_.value.disallowedTools]])]),e("div",Ql,[t[76]||(t[76]=e("label",{class:"field-label"},"Skills",-1)),W(e("input",{"onUpdate:modelValue":t[17]||(t[17]=u=>_.value.skills=u),type:"text",class:"field-input font-mono",placeholder:"my-skill, web-search…",readonly:E.value,onPointerdown:t[18]||(t[18]=y(()=>{},["stop"]))},null,40,es),[[ne,_.value.skills]])]),e("div",ts,[t[77]||(t[77]=e("label",{class:"field-label"},"Auto-load Skills",-1)),W(e("input",{"onUpdate:modelValue":t[19]||(t[19]=u=>_.value.autoLoadSkills=u),type:"text",class:"field-input font-mono",placeholder:"boot-skill…",readonly:E.value,onPointerdown:t[20]||(t[20]=y(()=>{},["stop"]))},null,40,os),[[ne,_.value.autoLoadSkills]])]),e("div",ns,[t[78]||(t[78]=e("label",{class:"field-label"},"MCP Servers",-1)),W(e("input",{"onUpdate:modelValue":t[21]||(t[21]=u=>_.value.mcpServers=u),type:"text",class:"field-input font-mono",placeholder:"my-mcp…",readonly:E.value,onPointerdown:t[22]||(t[22]=y(()=>{},["stop"]))},null,40,ls),[[ne,_.value.mcpServers]])]),e("div",ss,[t[79]||(t[79]=e("label",{class:"field-label"},"Allowed Agents (sub-agents)",-1)),W(e("input",{"onUpdate:modelValue":t[23]||(t[23]=u=>_.value.allowedAgents=u),type:"text",class:"field-input font-mono",placeholder:"coder, writer…",readonly:E.value,onPointerdown:t[24]||(t[24]=y(()=>{},["stop"]))},null,40,as),[[ne,_.value.allowedAgents]])]),e("div",rs,[t[80]||(t[80]=e("label",{class:"field-label"},"Disallowed Agents",-1)),W(e("input",{"onUpdate:modelValue":t[25]||(t[25]=u=>_.value.disallowedAgents=u),type:"text",class:"field-input font-mono",placeholder:"untrusted-agent…",readonly:E.value,onPointerdown:t[26]||(t[26]=y(()=>{},["stop"]))},null,40,is),[[ne,_.value.disallowedAgents]])]),e("div",ds,[t[83]||(t[83]=e("span",{class:"field-label mb-0"},"Runtime Permissions",-1)),e("div",us,[t[81]||(t[81]=e("label",{class:"text-[9px] text-slate-600 uppercase tracking-wide"},"Allow (execute)",-1)),W(e("textarea",{"onUpdate:modelValue":t[27]||(t[27]=u=>_.value.permissionsAllow=u),rows:"2",class:"field-input font-mono resize-none",placeholder:"read_file, list_dir, bash…",readonly:E.value,onPointerdown:t[28]||(t[28]=y(()=>{},["stop"]))},null,40,cs),[[ne,_.value.permissionsAllow]])]),e("div",ps,[t[82]||(t[82]=e("label",{class:"text-[9px] text-slate-600 uppercase tracking-wide"},"Deny (blocked)",-1)),W(e("textarea",{"onUpdate:modelValue":t[29]||(t[29]=u=>_.value.permissionsDeny=u),rows:"2",class:"field-input font-mono resize-none",placeholder:"bash(rm *), bash(sudo *)…",readonly:E.value,onPointerdown:t[30]||(t[30]=y(()=>{},["stop"]))},null,40,xs),[[ne,_.value.permissionsDeny]])])]),x.value==="task"||x.value==="subagent"?(l(),s(O,{key:0},[e("div",vs,[e("div",ms,[t[84]||(t[84]=e("label",{class:"field-label"},"Max Iterations",-1)),W(e("input",{"onUpdate:modelValue":t[31]||(t[31]=u=>_.value.maxIterations=u),type:"number",min:"1",class:"field-input",onPointerdown:t[32]||(t[32]=y(()=>{},["stop"]))},null,544),[[ne,_.value.maxIterations,void 0,{number:!0}]])]),e("div",fs,[t[85]||(t[85]=e("label",{class:"field-label"},"Max Duration (s)",-1)),W(e("input",{"onUpdate:modelValue":t[33]||(t[33]=u=>_.value.maxDurationSeconds=u),type:"number",min:"1",class:"field-input",onPointerdown:t[34]||(t[34]=y(()=>{},["stop"]))},null,544),[[ne,_.value.maxDurationSeconds,void 0,{number:!0}]])])]),e("div",bs,[t[87]||(t[87]=e("label",{class:"field-label"},"On Exhausted",-1)),W(e("select",{"onUpdate:modelValue":t[35]||(t[35]=u=>_.value.onExhausted=u),class:"field-input",onPointerdown:t[36]||(t[36]=y(()=>{},["stop"]))},[...t[86]||(t[86]=[e("option",{value:"fail"},"fail",-1),e("option",{value:"wait"},"wait (pauses, awaits respond)",-1)])],544),[[Te,_.value.onExhausted]])])],64)):M("",!0),x.value==="daemon"?(l(),s(O,{key:1},[e("div",gs,[e("div",ys,[t[88]||(t[88]=e("label",{class:"field-label"},"Max Iterations",-1)),W(e("input",{"onUpdate:modelValue":t[37]||(t[37]=u=>_.value.maxIterations=u),type:"number",min:"1",class:"field-input",onPointerdown:t[38]||(t[38]=y(()=>{},["stop"]))},null,544),[[ne,_.value.maxIterations,void 0,{number:!0}]])]),e("div",hs,[t[89]||(t[89]=e("label",{class:"field-label"},"Max Duration (s)",-1)),W(e("input",{"onUpdate:modelValue":t[39]||(t[39]=u=>_.value.maxDurationSeconds=u),type:"number",min:"1",class:"field-input",onPointerdown:t[40]||(t[40]=y(()=>{},["stop"]))},null,544),[[ne,_.value.maxDurationSeconds,void 0,{number:!0}]])])]),e("div",ks,[t[90]||(t[90]=e("label",{class:"field-label"},"Cron Expression",-1)),W(e("input",{"onUpdate:modelValue":t[41]||(t[41]=u=>_.value.cron=u),type:"text",class:"field-input font-mono",placeholder:"*/15 * * * *",onPointerdown:t[42]||(t[42]=y(()=>{},["stop"]))},null,544),[[ne,_.value.cron]])]),e("div",ws,[t[92]||(t[92]=e("label",{class:"field-label"},"Conflict Policy",-1)),W(e("select",{"onUpdate:modelValue":t[43]||(t[43]=u=>_.value.conflictPolicy=u),class:"field-input",onPointerdown:t[44]||(t[44]=y(()=>{},["stop"]))},[...t[91]||(t[91]=[e("option",{value:"skip"},"skip",-1),e("option",{value:"queue"},"queue",-1),e("option",{value:"restart"},"restart",-1)])],544),[[Te,_.value.conflictPolicy]])]),e("div",_s,[t[93]||(t[93]=e("label",{class:"field-label"},"Heartbeat File",-1)),W(e("input",{"onUpdate:modelValue":t[45]||(t[45]=u=>_.value.heartbeatFile=u),type:"text",class:"field-input font-mono",onPointerdown:t[46]||(t[46]=y(()=>{},["stop"]))},null,544),[[ne,_.value.heartbeatFile]])]),e("div",Cs,[t[94]||(t[94]=e("label",{class:"field-label"},"Alert Routing (agent name)",-1)),W(e("input",{"onUpdate:modelValue":t[47]||(t[47]=u=>_.value.alertRouting=u),type:"text",class:"field-input",onPointerdown:t[48]||(t[48]=y(()=>{},["stop"]))},null,544),[[ne,_.value.alertRouting]])])],64)):M("",!0)],64)):M("",!0),v.value==="memory"?(l(),s(O,{key:2},[e("div",$s,[t[95]||(t[95]=e("label",{class:"field-label mb-0"},"Memory Enabled",-1)),e("button",{class:J(["toggle-btn",n.memoryEnabled?"bg-purple-600":"bg-slate-600"]),disabled:E.value,onClick:t[49]||(t[49]=u=>!E.value&&(n.memoryEnabled=!n.memoryEnabled)),onPointerdown:t[50]||(t[50]=y(()=>{},["stop"]))},[e("span",{class:J(["toggle-knob",n.memoryEnabled?"translate-x-4":"translate-x-0.5"])},null,2)],42,Ss)]),n.memoryEnabled?(l(),s("div",Ms,[t[96]||(t[96]=e("label",{class:"field-label"},"Max Lines",-1)),W(e("input",{"onUpdate:modelValue":t[51]||(t[51]=u=>n.memoryMaxLines=u),type:"number",min:"1",class:"field-input",disabled:E.value,onPointerdown:t[52]||(t[52]=y(()=>{},["stop"]))},null,40,Ps),[[ne,n.memoryMaxLines,void 0,{number:!0}]])])):M("",!0),e("div",Es,[e("div",zs,[t[97]||(t[97]=e("label",{class:"field-label mb-0"},"Memory Files",-1)),e("div",Is,[!V.value&&!ae.value?(l(),s("button",{key:0,class:"text-[10px] text-slate-500 hover:text-slate-300 transition-colors",onClick:r},"↺ Refresh")):M("",!0),E.value?M("",!0):(l(),s("button",{key:1,class:"text-[10px] text-purple-400 hover:text-purple-300 transition-colors",onClick:t[53]||(t[53]=u=>{q.value=!q.value,pe.value=""})},"+ New file"))])]),q.value&&!E.value?(l(),s("div",Ts,[e("div",Ds,[W(e("select",{"onUpdate:modelValue":t[54]||(t[54]=u=>ye.value=u),class:"field-input w-[72px] flex-shrink-0 text-[11px]",style:{width:"72px"},onPointerdown:t[55]||(t[55]=y(()=>{},["stop"]))},[...t[98]||(t[98]=[e("option",{value:"agent"},"Agent",-1),e("option",{value:"global"},"Global",-1)])],544),[[Te,ye.value]]),W(e("input",{"onUpdate:modelValue":t[56]||(t[56]=u=>se.value=u),type:"text",class:"field-input flex-1",placeholder:"MEMORY.md",onKeydown:[ze(R,["enter"]),t[57]||(t[57]=ze(u=>{q.value=!1,se.value="",pe.value=""},["escape"]))],onPointerdown:t[58]||(t[58]=y(()=>{},["stop"]))},null,544),[[ne,se.value]]),e("button",{class:"px-2 py-1.5 text-[11px] bg-purple-600 hover:bg-purple-500 text-white rounded-lg transition-colors disabled:opacity-50 flex-shrink-0",disabled:!se.value.trim()||ke.value,onClick:R},P(ke.value?"…":"Create"),9,As),e("button",{class:"px-2 py-1.5 text-[11px] bg-slate-700 hover:bg-slate-600 text-slate-300 rounded-lg transition-colors flex-shrink-0",onClick:t[59]||(t[59]=u=>{q.value=!1,se.value="",pe.value=""})},"✕")]),pe.value?(l(),s("span",Ls,P(pe.value),1)):M("",!0)])):M("",!0),e("div",Vs,[e("div",js,[t[99]||(t[99]=e("span",{class:"text-[9px] font-semibold text-slate-500 uppercase tracking-widest"},"Agent",-1)),V.value?(l(),s("span",Ns,"loading…")):M("",!0)]),!V.value&&X.value.length===0?(l(),s("div",Rs,"No agent memory files.")):M("",!0),(l(!0),s(O,null,oe(X.value,u=>(l(),s("div",{key:K(u),class:"border border-slate-700/60 rounded-lg overflow-hidden"},[e("div",{class:"flex items-center gap-2 px-3 py-2 bg-slate-800/60 cursor-pointer hover:bg-slate-800 transition-colors select-none",onClick:ve=>C("agent",K(u))},[e("span",Bs,P(le.value.has(b("agent",K(u)))?"▼":"▶"),1),e("span",Us,P(K(u)),1),Q("agent",K(u))?(l(),s("span",Ys,"unsaved")):M("",!0),e("span",Os,P(te(u)),1)],8,Fs),le.value.has(b("agent",K(u)))?(l(),s("textarea",{key:0,value:U.value[b("agent",K(u))]??"",readonly:E.value,rows:"8",class:J(["field-input font-mono resize-y text-[11px] leading-relaxed rounded-none border-0 border-t border-slate-700/60 w-full",E.value?"opacity-60 cursor-default":""]),onInput:ve=>z("agent",K(u),ve.target.value),onPointerdown:t[60]||(t[60]=y(()=>{},["stop"]))},null,42,Xs)):M("",!0)]))),128))]),e("div",Ks,[e("div",Hs,[t[100]||(t[100]=e("span",{class:"text-[9px] font-semibold text-slate-500 uppercase tracking-widest"},"Global",-1)),ae.value?(l(),s("span",Ws,"loading…")):M("",!0)]),!ae.value&&F.value.length===0?(l(),s("div",Js,"No global memory files.")):M("",!0),(l(!0),s(O,null,oe(F.value,u=>(l(),s("div",{key:K(u),class:"border border-slate-700/60 rounded-lg overflow-hidden"},[e("div",{class:"flex items-center gap-2 px-3 py-2 bg-slate-800/60 cursor-pointer hover:bg-slate-800 transition-colors select-none",onClick:ve=>C("global",K(u))},[e("span",Gs,P(le.value.has(b("global",K(u)))?"▼":"▶"),1),e("span",qs,P(K(u)),1),Q("global",K(u))?(l(),s("span",Qs,"unsaved")):M("",!0),e("span",ea,P(te(u)),1)],8,Zs),le.value.has(b("global",K(u)))?(l(),s("textarea",{key:0,value:U.value[b("global",K(u))]??"",rows:"8",class:"field-input font-mono resize-y text-[11px] leading-relaxed rounded-none border-0 border-t border-slate-700/60 w-full",onInput:ve=>z("global",K(u),ve.target.value),onPointerdown:t[61]||(t[61]=y(()=>{},["stop"]))},null,40,ta)):M("",!0)]))),128))])]),t[101]||(t[101]=e("div",{class:"p-2.5 bg-slate-800/40 border border-slate-700/40 rounded-lg text-[11px] text-slate-500 leading-relaxed"}," Memory files are injected into the system prompt at the start of each session. Enable memory above to activate injection. ",-1))],64)):M("",!0),v.value==="prompt"?(l(),s(O,{key:3},[e("div",oa,[t[102]||(t[102]=e("label",{class:"field-label mb-0"},"AGENT.md",-1)),e("span",na,P(n.agentMd.length)+" chars",1)]),W(e("textarea",{"onUpdate:modelValue":t[62]||(t[62]=u=>n.agentMd=u),rows:"22",class:J(["field-input font-mono resize-y text-[11px] leading-relaxed",E.value?"opacity-60 cursor-default":""]),placeholder:"You are…",readonly:E.value,onPointerdown:t[63]||(t[63]=y(()=>{},["stop"]))},null,42,la),[[ne,n.agentMd]]),t[103]||(t[103]=e("div",{class:"text-[10px] text-slate-600 leading-relaxed"},[Ee(" Variables: "),e("code",{class:"text-slate-400"},"$AGENT_FOLDER"),Ee(", "),e("code",{class:"text-slate-400"},"$PROJECT_ROOT")],-1))],64)):M("",!0)])),!h.value&&!a.value?(l(),s("div",sa,[f.value?(l(),s("div",aa,P(f.value),1)):$.value?(l(),s("div",ra,"Saved & reloaded ✓")):M("",!0),e("div",ia,[e("button",{class:"px-3 py-1.5 text-xs bg-slate-700 hover:bg-slate-600 text-slate-300 rounded-lg transition-colors",onClick:xe},"Cancel"),e("button",{class:"px-3 py-1.5 text-xs bg-purple-600 hover:bg-purple-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",disabled:i.value||E.value,title:E.value?"Bundled agents are read-only":"",onClick:H},P(i.value?"Saving…":"Save"),9,da)])])):M("",!0)])}}}),ca=Pe(ua,[["__scopeId","data-v-93baa80e"]]),pa={class:"chat-sidebar flex flex-col h-full overflow-hidden bg-slate-900"},xa={class:"flex items-center px-3 py-2 border-b border-slate-700 flex-shrink-0"},va={key:1,class:"flex-1 flex items-center justify-center text-slate-600 text-sm"},ma=de({__name:"ChatSidebar",setup(g){const o=we(),d=Ce(),S=ge(),m=Qe(),p=N(()=>o.chatSidebarElementId?d.getElementById(o.chatSidebarElementId):null),v=N(()=>{var a,i,f,$;return((i=(a=p.value)==null?void 0:a.data)==null?void 0:i.agentName)??(($=(f=p.value)==null?void 0:f.data)==null?void 0:$.name)??""}),x=N(()=>{var a,i;return((i=(a=p.value)==null?void 0:a.data)==null?void 0:i.sessionId)??o.chatSidebarElementId??""});function h(){if(!x.value)return;const a=p.value,i=a?a.x+(a.width??200)+20:200,f=a?a.y:200;S.addElement("chat-view",i,f,{agentName:v.value,sessionId:x.value})}return Me(x,async a=>{a&&v.value&&await m.loadMessages(a,v.value)},{immediate:!0}),(a,i)=>{const f=it;return l(),s("div",pa,[e("div",xa,[i[1]||(i[1]=e("span",{class:"text-sm font-semibold text-slate-200 flex-1"},"Chat",-1)),x.value?(l(),s("button",{key:0,class:"text-slate-400 hover:text-slate-200 p-1 rounded hover:bg-slate-700 transition-colors text-xs mr-1",title:"Create Chat View element on canvas",onClick:h},"⊞")):M("",!0),e("button",{class:"text-slate-400 hover:text-slate-200 p-1 rounded hover:bg-slate-700 transition-colors",onClick:i[0]||(i[0]=$=>L(o).closeChatSidebar())},"✕")]),x.value?(l(),me(f,{key:x.value,sessionId:x.value,agentName:v.value,elementId:L(o).chatSidebarElementId??void 0},null,8,["sessionId","agentName","elementId"])):(l(),s("div",va," No session selected "))])}}}),fa={class:"flex flex-1 overflow-hidden"},ba={class:"w-60 flex-shrink-0 border-r border-slate-800 flex flex-col overflow-hidden"},ga={class:"flex-1 relative overflow-hidden"},ya={key:0,class:"w-agent-editor flex-shrink-0 border-l border-slate-800 flex flex-col overflow-hidden"},ha={key:0,class:"w-90 flex-shrink-0 border-l border-slate-800 flex flex-col overflow-hidden"},ka=de({__name:"index",setup(g){dt();const o=we(),{restoreCamera:d,startCameraWatch:S}=_e();o.loadPersistedState(),document.documentElement.classList.add("dark");const m=ge();function p(x){var i,f;const h=(i=x.target)==null?void 0:i.tagName;if(!(h==="INPUT"||h==="TEXTAREA"||(f=x.target)!=null&&f.isContentEditable)){if(x.code==="Space"&&(o.spaceHeld=!0,x.preventDefault()),x.key==="Escape"){if(o.agentEditorOpen){o.closeAgentEditor();return}o.deselectAll(),o.closeContextMenu(),o.linkingState=null,o.tapConnectPort=null}if((x.key==="Delete"||x.key==="Backspace")&&o.selectedElementIds.length>0){for(const $ of o.selectedElementIds)m.deleteElement($);o.deselectAll()}if(x.ctrlKey&&x.key==="d"){x.preventDefault();for(const $ of o.selectedElementIds)m.duplicateElement($)}}}function v(x){x.code==="Space"&&(o.spaceHeld=!1)}return Ie(()=>{var x;(x=document.querySelector(".studio-root"))==null||x.focus(),d(),S(),navigator.permissions&&navigator.permissions.query({name:"clipboard-read"}).catch(()=>{})}),(x,h)=>{const a=Tt,i=vn,f=yl,$=ca,j=ma;return l(),s("div",{class:"studio-root flex flex-col h-screen bg-slate-950 text-slate-100 overflow-hidden",onKeydown:p,onKeyup:v,tabindex:"-1"},[be(a),e("div",fa,[be(Fe,{name:"panel-left"},{default:Ne(()=>[W(e("div",ba,[be(i)],512),[[ut,L(o).leftPanelOpen]])]),_:1}),e("div",ga,[be(f)]),be(Fe,{name:"panel-right"},{default:Ne(()=>[L(o).agentEditorOpen?(l(),s("div",ya,[be($)])):M("",!0)]),_:1}),be(Fe,{name:"panel-right"},{default:Ne(()=>[L(o).chatSidebarOpen?(l(),s("div",ha,[be(j)])):M("",!0)]),_:1})])],32)}}}),_a=Pe(ka,[["__scopeId","data-v-043c6a99"]]);export{_a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as o,D as f,E as d,F as v,b as l,G as i,H as h,l as u,I as m}from"./entry.BrrOeBSX.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{n.value=s.value?{}:d(a)});const r=t.push(n.value,e);return v(n,c=>{r.patch(c)}),m()&&(l(()=>{r.dispose()}),i(()=>{s.value=!0}),h(()=>{s.value=!1})),r}export{U as u};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8">
|
|
2
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
+
<title>Veil Studio</title>
|
|
4
|
+
<link rel="stylesheet" href="/_nuxt/entry.CYnp7zY5.css">
|
|
5
|
+
<link rel="modulepreload" as="script" crossorigin href="/_nuxt/entry.BrrOeBSX.js">
|
|
6
|
+
<link rel="prefetch" as="style" crossorigin href="/_nuxt/error-404.JekaaCis.css">
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/_nuxt/error-404.BbdzCaXe.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/_nuxt/vue.-sixQ7xP.BlWffD__.js">
|
|
9
|
+
<link rel="prefetch" as="style" crossorigin href="/_nuxt/error-500.CNP9nqm1.css">
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/_nuxt/error-500.DbOlBIIY.js">
|
|
11
|
+
<script type="module" src="/_nuxt/entry.BrrOeBSX.js" crossorigin></script>
|
|
12
|
+
<script id="unhead:payload" type="application/json">{"title":"Veil Studio"}</script></head><body><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4,"once":5},{},false,{},{},["Set"]]</script>
|
|
13
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@newsails/veil-studio",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Visual IDE for Veil CLI agents — drag-and-drop canvas, real-time chat, and agent editor",
|
|
5
|
+
"bin": {
|
|
6
|
+
"veil-studio": "bin/veil-studio.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "node bin/veil-studio.js",
|
|
10
|
+
"dev": "node bin/veil-studio.js",
|
|
11
|
+
"build": "node scripts/build-ui.js",
|
|
12
|
+
"prepack": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/",
|
|
16
|
+
"server/",
|
|
17
|
+
"nuxt-app/.output/public/"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"veil",
|
|
24
|
+
"ai",
|
|
25
|
+
"agents",
|
|
26
|
+
"studio",
|
|
27
|
+
"canvas",
|
|
28
|
+
"llm"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"better-sqlite3": "^9.4.3",
|
|
32
|
+
"express": "^4.18.2",
|
|
33
|
+
"http-proxy-middleware": "^2.0.6",
|
|
34
|
+
"socket.io": "^4.7.5",
|
|
35
|
+
"ws": "^8.16.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/server/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const express = require('express')
|
|
4
|
+
const { createServer } = require('http')
|
|
5
|
+
const { Server } = require('socket.io')
|
|
6
|
+
const { createProxyMiddleware } = require('http-proxy-middleware')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const fs = require('fs')
|
|
9
|
+
const { execSync, spawn } = require('child_process')
|
|
10
|
+
|
|
11
|
+
const { STUDIO_PORT, STUDIO_SECRET } = require('./utils/config.js')
|
|
12
|
+
const { initDB } = require('./utils/db.js')
|
|
13
|
+
const { loadFromDB } = require('./utils/board-state.js')
|
|
14
|
+
const { setIO } = require('./utils/socket-io.js')
|
|
15
|
+
const { registerSocketHandlers } = require('./socket.js')
|
|
16
|
+
const { connectVeilWS } = require('./utils/veil-ws.js')
|
|
17
|
+
const { loadCustomElements } = require('./utils/element-registry.js')
|
|
18
|
+
const { initAllInstances } = require('./utils/element-instances.js')
|
|
19
|
+
|
|
20
|
+
// 1. Initialize DB + state (sync, fast)
|
|
21
|
+
initDB()
|
|
22
|
+
loadFromDB()
|
|
23
|
+
loadCustomElements()
|
|
24
|
+
initAllInstances()
|
|
25
|
+
|
|
26
|
+
// 2. Create Express app + http.Server
|
|
27
|
+
const app = express()
|
|
28
|
+
const httpServer = createServer(app)
|
|
29
|
+
|
|
30
|
+
// 3. Attach Socket.IO
|
|
31
|
+
const io = new Server(httpServer, {
|
|
32
|
+
cors: { origin: '*' },
|
|
33
|
+
})
|
|
34
|
+
setIO(io)
|
|
35
|
+
|
|
36
|
+
// Socket.IO auth middleware
|
|
37
|
+
if (STUDIO_SECRET) {
|
|
38
|
+
io.use((socket, next) => {
|
|
39
|
+
const token = socket.handshake.auth?.token || socket.handshake.headers?.['x-studio-secret']
|
|
40
|
+
if (token === STUDIO_SECRET) return next()
|
|
41
|
+
next(new Error('Unauthorized'))
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
registerSocketHandlers(io)
|
|
46
|
+
connectVeilWS()
|
|
47
|
+
|
|
48
|
+
// 4. Mount API routes (files only)
|
|
49
|
+
app.use(express.json())
|
|
50
|
+
|
|
51
|
+
// Express auth middleware for all /api routes
|
|
52
|
+
if (STUDIO_SECRET) {
|
|
53
|
+
app.use('/api', (req, res, next) => {
|
|
54
|
+
const token = req.headers['x-studio-secret']
|
|
55
|
+
|| (req.headers['authorization'] || '').replace(/^Bearer\s+/i, '')
|
|
56
|
+
if (token === STUDIO_SECRET) return next()
|
|
57
|
+
res.status(401).json({ error: 'Unauthorized' })
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
app.get('/api/ping', (_req, res) => res.json({ ok: true }))
|
|
62
|
+
app.use('/api/files', require('./routes/files.js'))
|
|
63
|
+
|
|
64
|
+
// 5. Serve UI
|
|
65
|
+
const staticPath = path.resolve(__dirname, '../nuxt-app/.output/public')
|
|
66
|
+
const forceDevMode = process.env.STUDIO_DEV === '1'
|
|
67
|
+
|
|
68
|
+
if (!forceDevMode && !fs.existsSync(staticPath)) {
|
|
69
|
+
console.error('\n ERROR: UI is not compiled.')
|
|
70
|
+
console.error(' Run `npm run build` to build the UI, or start with --dev flag to use nuxt dev.\n')
|
|
71
|
+
process.exit(1)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!forceDevMode && fs.existsSync(staticPath)) {
|
|
75
|
+
app.use(express.static(staticPath))
|
|
76
|
+
app.get('*', (_req, res) => res.sendFile(path.join(staticPath, 'index.html')))
|
|
77
|
+
} else {
|
|
78
|
+
// Dev mode: find a free port and spawn nuxt dev
|
|
79
|
+
const nuxtPort = findFreePort(13100)
|
|
80
|
+
spawnNuxtDev(nuxtPort)
|
|
81
|
+
const proxy = createProxyMiddleware({
|
|
82
|
+
target: `http://localhost:${nuxtPort}`,
|
|
83
|
+
changeOrigin: true,
|
|
84
|
+
ws: false,
|
|
85
|
+
pathFilter: (path) => !path.startsWith('/socket.io') && !path.startsWith('/api'),
|
|
86
|
+
logLevel: 'silent',
|
|
87
|
+
on: {
|
|
88
|
+
error: (_err, _req, res) => {
|
|
89
|
+
if (res && res.writeHead) {
|
|
90
|
+
res.writeHead(502)
|
|
91
|
+
res.end('Nuxt dev server not ready yet. Please refresh.')
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
app.use('/', proxy)
|
|
97
|
+
// Only proxy non-Socket.IO WebSocket upgrades (Vite HMR etc.)
|
|
98
|
+
httpServer.on('upgrade', (req, socket, head) => {
|
|
99
|
+
if (req.url && req.url.startsWith('/socket.io')) return
|
|
100
|
+
proxy.upgrade(req, socket, head)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 6. Listen
|
|
105
|
+
httpServer.listen(STUDIO_PORT, () => {
|
|
106
|
+
console.log(`\n Veil Studio ready: http://localhost:${STUDIO_PORT}\n`)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
function findFreePort(startPort) {
|
|
112
|
+
let port = startPort
|
|
113
|
+
while (port < startPort + 100) {
|
|
114
|
+
try {
|
|
115
|
+
execSync(`lsof -ti:${port}`, { stdio: 'ignore' })
|
|
116
|
+
port++
|
|
117
|
+
} catch (_) {
|
|
118
|
+
return port
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return startPort
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function findNode20Plus() {
|
|
125
|
+
const home = process.env.HOME || require('os').homedir()
|
|
126
|
+
const candidates = []
|
|
127
|
+
|
|
128
|
+
// N_PREFIX env var (user-configured)
|
|
129
|
+
if (process.env.N_PREFIX) candidates.push(path.join(process.env.N_PREFIX, 'bin', 'node'))
|
|
130
|
+
|
|
131
|
+
// ~/.n/bin/node (common: N_PREFIX=$HOME/.n)
|
|
132
|
+
candidates.push(path.join(home, '.n', 'bin', 'node'))
|
|
133
|
+
|
|
134
|
+
// /usr/local/bin/node (default n prefix)
|
|
135
|
+
candidates.push('/usr/local/bin/node')
|
|
136
|
+
|
|
137
|
+
for (const candidate of candidates) {
|
|
138
|
+
if (!fs.existsSync(candidate)) continue
|
|
139
|
+
if (candidate === process.execPath) continue // already running this one
|
|
140
|
+
try {
|
|
141
|
+
const ver = execSync(`"${candidate}" -e "process.stdout.write(process.versions.node)"`,
|
|
142
|
+
{ encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'] }).trim()
|
|
143
|
+
const major = parseInt(ver.split('.')[0], 10)
|
|
144
|
+
if (major >= 20) return { nodePath: candidate, version: ver }
|
|
145
|
+
} catch { /* skip */ }
|
|
146
|
+
}
|
|
147
|
+
return null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function spawnNuxtDev(port) {
|
|
151
|
+
const nuxtAppDir = path.resolve(__dirname, '../nuxt-app')
|
|
152
|
+
|
|
153
|
+
// Prefer Node 20+ for nuxt dev (newer nuxt/nitropack require it)
|
|
154
|
+
const node20 = findNode20Plus()
|
|
155
|
+
const devNode = node20 ? node20.nodePath : process.execPath
|
|
156
|
+
const devNodeDir = path.dirname(devNode)
|
|
157
|
+
const env = { ...process.env, PATH: `${devNodeDir}:${process.env.PATH}` }
|
|
158
|
+
|
|
159
|
+
if (node20) {
|
|
160
|
+
console.log(` Using Node ${node20.version} for nuxt dev (${devNode})`)
|
|
161
|
+
} else {
|
|
162
|
+
console.log(` Using Node ${process.versions.node} for nuxt dev (no Node 20+ found via n)`)
|
|
163
|
+
}
|
|
164
|
+
console.log(` Spawning nuxt dev on port ${port}...`)
|
|
165
|
+
|
|
166
|
+
const npx = path.join(devNodeDir, 'npx')
|
|
167
|
+
const child = spawn(npx, ['nuxt', 'dev', '--port', String(port)], {
|
|
168
|
+
cwd: nuxtAppDir,
|
|
169
|
+
env,
|
|
170
|
+
stdio: 'inherit',
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
child.on('error', (err) => {
|
|
174
|
+
console.error('[nuxt-dev] Failed to start:', err.message)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
child.on('exit', (code) => {
|
|
178
|
+
if (code !== 0) console.error(`[nuxt-dev] Exited with code ${code}`)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
process.on('exit', () => child.kill())
|
|
182
|
+
process.on('SIGINT', () => { child.kill(); process.exit(0) })
|
|
183
|
+
process.on('SIGTERM', () => { child.kill(); process.exit(0) })
|
|
184
|
+
}
|