@swarmroom/server 0.1.0 → 0.2.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.
Files changed (30) hide show
  1. package/dist/app.js +13 -4
  2. package/dist/public/assets/_agentId-B5f3yJc6.js +36 -0
  3. package/dist/public/assets/activity-B3TqhZ-f.js +6 -0
  4. package/dist/public/assets/arrow-left-u9wxRsmJ.js +6 -0
  5. package/dist/public/assets/avatar-B_Cqbi60.js +1 -0
  6. package/dist/public/assets/card-B896vjxa.js +1 -0
  7. package/dist/public/assets/chevron-down-CwGQLAwz.js +6 -0
  8. package/dist/public/assets/error-boundary-GFV_5F1L.js +11 -0
  9. package/dist/public/assets/external-link-skx4o5wJ.js +6 -0
  10. package/dist/public/assets/index-CZLH7_Xl.js +36 -0
  11. package/dist/public/assets/index-D0-THR73.js +16 -0
  12. package/dist/public/assets/index-D8d9U5S5.js +26 -0
  13. package/dist/public/assets/index-DC3HeWGk.js +6 -0
  14. package/dist/public/assets/index-DcbqFmA_.css +1 -0
  15. package/dist/public/assets/index-DqvmWes8.js +213 -0
  16. package/dist/public/assets/index-Drki27xM.js +26 -0
  17. package/dist/public/assets/index-MKgtdaN5.js +6 -0
  18. package/dist/public/assets/input-BROwVVEx.js +1 -0
  19. package/dist/public/assets/loader-circle-atY3HcdA.js +6 -0
  20. package/dist/public/assets/plus-Bq20n-_S.js +6 -0
  21. package/dist/public/assets/radio-D8C4proJ.js +6 -0
  22. package/dist/public/assets/scroll-area-C4F6zoWB.js +1 -0
  23. package/dist/public/assets/send-Dl7T7Bm1.js +6 -0
  24. package/dist/public/assets/useMutation-BhJRnGsH.js +1 -0
  25. package/dist/public/assets/user-minus-SI0czWZH.js +11 -0
  26. package/dist/public/assets/utils-AH9TuImk.js +6 -0
  27. package/dist/public/assets/wifi-BMnLTkMX.js +26 -0
  28. package/dist/public/index.html +14 -0
  29. package/dist/public/vite.svg +4 -0
  30. package/package.json +3 -2
package/dist/app.js CHANGED
@@ -13,8 +13,11 @@ import { projectsRoute } from './routes/projects.js';
13
13
  import { wellKnown } from './routes/well-known.js';
14
14
  import { mcpRoute } from './mcp/transport.js';
15
15
  const __dirname = resolve(fileURLToPath(import.meta.url), '..');
16
- const webDistPath = resolve(__dirname, '../../web/dist');
17
- const webDistExists = existsSync(webDistPath);
16
+ // Try bundled location first (npm install), then monorepo location (dev)
17
+ const bundledWebPath = resolve(__dirname, 'public');
18
+ const monorepoWebPath = resolve(__dirname, '../../web/dist');
19
+ const webDistPath = existsSync(bundledWebPath) ? bundledWebPath : monorepoWebPath;
20
+ const webDistExists = existsSync(webDistPath) && !process.env.SWARMROOM_NO_WEB;
18
21
  const app = new Hono();
19
22
  app.use('*', corsMiddleware);
20
23
  app.onError(errorHandler);
@@ -26,8 +29,14 @@ app.route('/api/teams', teamsRoute);
26
29
  app.route('/api/projects', projectsRoute);
27
30
  app.route('/mcp', mcpRoute);
28
31
  if (webDistExists) {
29
- app.use('*', serveStatic({ root: webDistPath }));
30
- app.get('*', serveStatic({ root: webDistPath, path: '/index.html' }));
32
+ app.use('*', serveStatic({
33
+ root: '',
34
+ rewriteRequestPath: (path) => `${webDistPath}${path}`,
35
+ }));
36
+ app.get('*', serveStatic({
37
+ root: '',
38
+ rewriteRequestPath: () => `${webDistPath}/index.html`,
39
+ }));
31
40
  }
32
41
  else {
33
42
  app.get('/', (c) => {
@@ -0,0 +1,36 @@
1
+ import{c as N,r as p,j as e,I as fe,K as ge,a2 as je,a3 as ve,a4 as Ne,a5 as ye,O as P,P as be,a6 as Y,N as we,x as F,a7 as Ce,a0 as ee,b as h,M as se,p as z,L as ke,D as q,d as D,e as M,f as I,g as _,o as O,u as T,A as g,n as S,t as f,U,a8 as ae,B as Te,a9 as Ae}from"./index-DqvmWes8.js";import{u as A}from"./useMutation-BhJRnGsH.js";import{B as v,S as c,E as ze}from"./error-boundary-GFV_5F1L.js";import{g as Fe,a as Se,s as J,T as Ee,t as $e,f as te}from"./utils-AH9TuImk.js";import{E as Pe}from"./external-link-skx4o5wJ.js";import{C as Le,W as Re,F as W,G as qe,a as De}from"./wifi-BMnLTkMX.js";import{A as Me}from"./arrow-left-u9wxRsmJ.js";import{C as b,b as w,c as C,a as k}from"./card-B896vjxa.js";import{C as Ie}from"./chevron-down-CwGQLAwz.js";import{P as re}from"./plus-Bq20n-_S.js";import{L as ne}from"./loader-circle-atY3HcdA.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const _e=N("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/**
7
+ * @license lucide-react v0.400.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Oe=N("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
12
+ * @license lucide-react v0.400.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ke=N("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
17
+ * @license lucide-react v0.400.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const X=N("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
22
+ * @license lucide-react v0.400.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Qe=N("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
27
+ * @license lucide-react v0.400.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const He=N("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
32
+ * @license lucide-react v0.400.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ve=N("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var Be=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],E=Be.reduce((s,r)=>{const l=fe(`Primitive.${r}`),n=p.forwardRef((a,o)=>{const{asChild:i,...d}=a,x=i?l:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(x,{...d,ref:o})});return n.displayName=`Primitive.${r}`,{...s,[r]:n}},{}),$="Tabs",[Ge]=we($,[Y]),ie=Y(),[Ue,K]=Ge($),oe=p.forwardRef((s,r)=>{const{__scopeTabs:l,value:n,onValueChange:a,defaultValue:o,orientation:i="horizontal",dir:d,activationMode:x="automatic",...t}=s,m=ge(d),[u,j]=je({prop:n,onChange:a,defaultProp:o??"",caller:$});return e.jsx(Ue,{scope:l,baseId:ve(),value:u,onValueChange:j,orientation:i,dir:m,activationMode:x,children:e.jsx(E.div,{dir:m,"data-orientation":i,...t,ref:r})})});oe.displayName=$;var le="TabsList",de=p.forwardRef((s,r)=>{const{__scopeTabs:l,loop:n=!0,...a}=s,o=K(le,l),i=ie(l);return e.jsx(Ne,{asChild:!0,...i,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(E.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:r})})});de.displayName=le;var ce="TabsTrigger",me=p.forwardRef((s,r)=>{const{__scopeTabs:l,value:n,disabled:a=!1,...o}=s,i=K(ce,l),d=ie(l),x=pe(i.baseId,n),t=he(i.baseId,n),m=n===i.value;return e.jsx(ye,{asChild:!0,...d,focusable:!a,active:m,children:e.jsx(E.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":t,"data-state":m?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:x,...o,ref:r,onMouseDown:P(s.onMouseDown,u=>{!a&&u.button===0&&u.ctrlKey===!1?i.onValueChange(n):u.preventDefault()}),onKeyDown:P(s.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&i.onValueChange(n)}),onFocus:P(s.onFocus,()=>{const u=i.activationMode!=="manual";!m&&!a&&u&&i.onValueChange(n)})})})});me.displayName=ce;var xe="TabsContent",ue=p.forwardRef((s,r)=>{const{__scopeTabs:l,value:n,forceMount:a,children:o,...i}=s,d=K(xe,l),x=pe(d.baseId,n),t=he(d.baseId,n),m=n===d.value,u=p.useRef(m);return p.useEffect(()=>{const j=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(j)},[]),e.jsx(be,{present:a||m,children:({present:j})=>e.jsx(E.div,{"data-state":m?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":x,hidden:!j,id:t,tabIndex:0,...i,ref:r,style:{...s.style,animationDuration:u.current?"0s":void 0},children:j&&o})})});ue.displayName=xe;function pe(s,r){return`${s}-trigger-${r}`}function he(s,r){return`${s}-content-${r}`}var Je=oe,We=de,Xe=me,Ze=ue;function Ye({className:s,orientation:r="horizontal",...l}){return e.jsx(Je,{"data-slot":"tabs","data-orientation":r,orientation:r,className:F("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",s),...l})}const es=Ce("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function ss({className:s,variant:r="default",...l}){return e.jsx(We,{"data-slot":"tabs-list","data-variant":r,className:F(es({variant:r}),s),...l})}function L({className:s,...r}){return e.jsx(Xe,{"data-slot":"tabs-trigger",className:F("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",s),...r})}function R({className:s,...r}){return e.jsx(Ze,{"data-slot":"tabs-content",className:F("flex-1 outline-none",s),...r})}function as({agent:s,onDelete:r,isDeleting:l}){var t,m,u,j,Q,H,V,B,G;const[n,a]=p.useState(!1),o=ee(),i=Fe(s.displayName),d=Se(s.displayName),x=J[s.status]??J.offline;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-border/60 bg-card",children:[e.jsx("div",{className:"h-24 w-full",style:{background:`linear-gradient(135deg, ${d}44 0%, ${d}18 40%, transparent 70%)`}}),e.jsxs("div",{className:"relative px-6 pb-6",children:[e.jsxs("div",{className:"-mt-10 flex items-end gap-5",children:[e.jsx("div",{className:"flex size-20 shrink-0 items-center justify-center rounded-2xl text-2xl font-bold text-white shadow-lg ring-4 ring-card",style:{backgroundColor:d},children:i}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-start justify-between gap-4 pt-1",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"truncate text-xl font-bold tracking-tight text-foreground",children:s.displayName}),e.jsxs(v,{variant:x.variant,className:"gap-1.5 text-xs",children:[e.jsx("span",{className:`inline-block size-1.5 rounded-full ${x.dot} ${s.status==="online"?"animate-pulse":""}`}),x.label]})]}),e.jsx("p",{className:"mt-0.5 truncate font-mono text-sm text-muted-foreground",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{size:"sm",onClick:()=>o({to:"/messages",search:{to:s.id}}),children:[e.jsx(se,{className:"size-4"}),"Send Message"]}),e.jsxs(h,{variant:"destructive",size:"sm",onClick:()=>a(!0),children:[e.jsx(Ee,{className:"size-4"}),"Remove"]})]})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-muted-foreground",children:[s.url&&e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 transition-colors hover:text-foreground",children:[e.jsx(Pe,{className:"size-3.5"}),$e(s.url,40)]}),((t=s.agentCard)==null?void 0:t.version)&&e.jsxs(e.Fragment,{children:[e.jsx(z,{orientation:"vertical",className:"!h-4"}),e.jsxs("span",{className:"font-mono text-xs",children:["v",s.agentCard.version]})]}),s.lastHeartbeat&&e.jsxs(e.Fragment,{children:[e.jsx(z,{orientation:"vertical",className:"!h-4"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Le,{className:"size-3.5"}),te(s.lastHeartbeat)]})]}),s.status==="online"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{orientation:"vertical",className:"!h-4"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-emerald-600 dark:text-emerald-400",children:[e.jsx(Re,{className:"size-3.5"}),"Connected"]})]})]}),((((u=(m=s.agentCard)==null?void 0:m.teams)==null?void 0:u.length)??0)>0||(((Q=(j=s.agentCard)==null?void 0:j.projectGroups)==null?void 0:Q.length)??0)>0)&&e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[(V=(H=s.agentCard)==null?void 0:H.teams)==null?void 0:V.map(y=>e.jsx(v,{variant:"secondary",className:"text-xs",children:y},y)),(G=(B=s.agentCard)==null?void 0:B.projectGroups)==null?void 0:G.map(y=>e.jsx(v,{variant:"outline",className:"text-xs",children:y},y))]})]}),e.jsxs(ke,{to:"/agents",className:"absolute top-4 left-4 inline-flex items-center gap-1.5 rounded-lg bg-card/80 px-2.5 py-1.5 text-xs font-medium text-muted-foreground backdrop-blur-sm transition-colors hover:text-foreground",children:[e.jsx(Me,{className:"size-3.5"}),"Agents"]})]}),e.jsx(q,{open:n,onOpenChange:a,children:e.jsxs(D,{children:[e.jsxs(M,{children:[e.jsx(I,{children:"Remove agent"}),e.jsxs(_,{children:["This will set"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.displayName})," ","to offline. The agent can re-register at any time."]})]}),e.jsxs(O,{children:[e.jsx(h,{variant:"outline",onClick:()=>a(!1),disabled:l,children:"Cancel"}),e.jsx(h,{variant:"destructive",disabled:l,onClick:()=>{r(),a(!1)},children:l?"Removing…":"Remove Agent"})]})]})})]})}function ts({agentId:s}){const[r,l]=p.useState(!1),n=T({queryKey:["agent-card",s],queryFn:async()=>{const o=await fetch(`${g}/agents/${s}/card`);if(!o.ok)throw new Error("Failed to fetch agent card");return(await o.json()).data},staleTime:3e4,retry:1});if(n.isLoading)return e.jsx(rs,{});if(n.isError||!n.data)return e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/60 py-16",children:[e.jsx(W,{className:"size-10 text-muted-foreground/40"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"No Agent Card available"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground/60",children:"This agent hasn't published an A2A Agent Card yet."})]});const a=n.data;return e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsxs(b,{className:"gap-0 py-0",children:[e.jsx(w,{className:"border-b px-5 py-4",children:e.jsxs(C,{className:"flex items-center gap-2 text-sm",children:[e.jsx(Qe,{className:"size-4 text-amber-500"}),"Description"]})}),e.jsxs(k,{className:"px-5 py-4",children:[e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:a.description||"No description provided."}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[a.version&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 font-mono",children:["v",a.version]}),a.url&&e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 transition-colors hover:text-foreground",children:[e.jsx(qe,{className:"size-3"}),a.url]})]})]})]}),e.jsxs(b,{className:"gap-0 py-0",children:[e.jsx(w,{className:"border-b px-5 py-4",children:e.jsxs(C,{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ve,{className:"size-4 text-blue-500"}),"Skills",a.skills.length>0&&e.jsx(v,{variant:"secondary",className:"ml-auto text-[10px]",children:a.skills.length})]})}),e.jsx(k,{className:"px-5 py-4",children:a.skills.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No skills declared."}):e.jsx("div",{className:"space-y-3",children:a.skills.map(o=>e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:o.name})]}),e.jsx("p",{className:"ml-5.5 mt-0.5 text-xs leading-relaxed text-muted-foreground",children:o.description}),o.tags.length>0&&e.jsx("div",{className:"ml-5.5 mt-1.5 flex flex-wrap gap-1",children:o.tags.map(i=>e.jsxs(v,{variant:"outline",className:"text-[10px] font-normal",children:[e.jsx(He,{className:"mr-0.5 size-2.5"}),i]},i))})]},o.id))})})]}),e.jsxs(b,{className:"gap-0 py-0 lg:col-span-2",children:[e.jsx(w,{className:"px-5 py-4",children:e.jsxs("button",{type:"button",onClick:()=>l(o=>!o),className:"flex w-full items-center gap-2 text-left",children:[e.jsxs(C,{className:"flex items-center gap-2 text-sm",children:[e.jsx(W,{className:"size-4 text-muted-foreground"}),"Raw Agent Card"]}),r?e.jsx(Ie,{className:"ml-auto size-4 text-muted-foreground"}):e.jsx(Ke,{className:"ml-auto size-4 text-muted-foreground"})]})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsx(k,{className:"px-5 py-4",children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-lg bg-muted/60 p-4 font-mono text-xs leading-relaxed text-foreground/80",children:JSON.stringify(a,null,2)})})]})]})]})}function rs(){return e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx(c,{className:"h-48 rounded-xl"}),e.jsx(c,{className:"h-48 rounded-xl"}),e.jsx(c,{className:"h-20 rounded-xl lg:col-span-2"})]})}const Z={notification:{label:"Notification",variant:"secondary"},query:{label:"Query",variant:"default"},response:{label:"Response",variant:"outline"},broadcast:{label:"Broadcast",variant:"secondary"}};function ns({agentId:s}){const r=T({queryKey:["agent-messages",s],queryFn:async()=>{const n=await fetch(`${g}/messages?agentId=${s}&limit=20`);if(!n.ok)throw new Error("Failed to fetch messages");return(await n.json()).data},staleTime:3e4,refetchInterval:15e3,retry:1});if(r.isLoading)return e.jsx(is,{});const l=r.data??[];return l.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/60 py-16",children:[e.jsx(se,{className:"size-10 text-muted-foreground/40"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"No activity yet"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground/60",children:"Messages sent to or from this agent will appear here."})]}):e.jsx("div",{className:"space-y-1",children:l.map(n=>{const a=n.from===s,o=Z[n.type]??Z.notification;return e.jsxs("div",{className:"group flex items-start gap-3 rounded-lg px-3 py-3 transition-colors hover:bg-muted/40",children:[e.jsx("div",{className:"mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:a?e.jsx(Oe,{className:"size-4 text-blue-500"}):e.jsx(_e,{className:"size-4 text-emerald-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:[a?"Sent to":"Received from"," ",e.jsx("span",{className:"font-semibold text-foreground",children:a?n.to:n.from})]}),e.jsx(v,{variant:o.variant,className:"text-[9px] leading-tight",children:o.label}),e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:te(n.createdAt)})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-foreground/80",children:n.content})]})]},n.id)})})}function is(){return e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>e.jsxs("div",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsx(c,{className:"size-8 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(c,{className:"h-3 w-48"}),e.jsx(c,{className:"h-4 w-full"})]})]},r))})}function os({agent:s}){S();const r=T({queryKey:["teams"],queryFn:async()=>{const t=await fetch(`${g}/teams`);if(!t.ok)throw new Error("Failed to fetch teams");return(await t.json()).data},staleTime:6e4,retry:1}),l=T({queryKey:["projects"],queryFn:async()=>{const t=await fetch(`${g}/projects`);if(!t.ok)throw new Error("Failed to fetch projects");return(await t.json()).data},staleTime:6e4,retry:1}),n=r.data??[],a=l.data??[],o=n.filter(t=>t.agentIds.includes(s.id)),i=a.filter(t=>t.agentIds.includes(s.id)),d=n.filter(t=>!t.agentIds.includes(s.id)),x=a.filter(t=>!t.agentIds.includes(s.id));return e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx(ls,{agent:s,agentTeams:o,availableTeams:d,isLoading:r.isLoading}),e.jsx(ds,{agent:s,agentProjects:i,availableProjects:x,isLoading:l.isLoading})]})}function ls({agent:s,agentTeams:r,availableTeams:l,isLoading:n}){const a=S(),[o,i]=p.useState(!1),d=A({mutationFn:async t=>{if(!(await fetch(`${g}/teams/${t}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:s.id})})).ok)throw new Error("Failed to add agent to team")},onSuccess:()=>{a.invalidateQueries({queryKey:["teams"]}),a.invalidateQueries({queryKey:["agents"]}),f.success("Added to team"),i(!1)},onError:()=>f.error("Failed to add to team")}),x=A({mutationFn:async t=>{if(!(await fetch(`${g}/teams/${t}/agents/${s.id}`,{method:"DELETE"})).ok)throw new Error("Failed to remove agent from team")},onSuccess:()=>{a.invalidateQueries({queryKey:["teams"]}),a.invalidateQueries({queryKey:["agents"]}),f.success("Removed from team")},onError:()=>f.error("Failed to remove from team")});return e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"gap-0 py-0",children:[e.jsx(w,{className:"border-b px-5 py-4",children:e.jsxs(C,{className:"flex items-center gap-2 text-sm",children:[e.jsx(U,{className:"size-4 text-violet-500"}),"Teams",e.jsx(v,{variant:"secondary",className:"ml-auto text-[10px]",children:r.length})]})}),e.jsxs(k,{className:"px-5 py-4",children:[n?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"h-8 w-full"}),e.jsx(c,{className:"h-8 w-2/3"})]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not assigned to any teams."}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t.name}),e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>x.mutate(t.id),disabled:x.isPending,children:e.jsx(ae,{className:"size-3.5"})})]},t.id))}),e.jsxs(h,{variant:"outline",size:"sm",className:"mt-4 w-full",onClick:()=>i(!0),disabled:l.length===0,children:[e.jsx(re,{className:"size-4"}),"Add to Team"]})]})]}),e.jsx(q,{open:o,onOpenChange:i,children:e.jsxs(D,{children:[e.jsxs(M,{children:[e.jsx(I,{children:"Add to team"}),e.jsxs(_,{children:["Select a team to add"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.displayName})," ","to."]})]}),e.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:l.map(t=>e.jsxs("button",{type:"button",onClick:()=>d.mutate(t.id),disabled:d.isPending,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[e.jsx(U,{className:"size-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),t.description&&e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description})]}),d.isPending&&e.jsx(ne,{className:"size-4 animate-spin text-muted-foreground"})]},t.id))}),e.jsx(O,{children:e.jsx(h,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})})]})})]})}function ds({agent:s,agentProjects:r,availableProjects:l,isLoading:n}){const a=S(),[o,i]=p.useState(!1),d=A({mutationFn:async t=>{if(!(await fetch(`${g}/projects/${t}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:s.id})})).ok)throw new Error("Failed to add agent to project")},onSuccess:()=>{a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["agents"]}),f.success("Added to project"),i(!1)},onError:()=>f.error("Failed to add to project")}),x=A({mutationFn:async t=>{if(!(await fetch(`${g}/projects/${t}/agents/${s.id}`,{method:"DELETE"})).ok)throw new Error("Failed to remove agent from project")},onSuccess:()=>{a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["agents"]}),f.success("Removed from project")},onError:()=>f.error("Failed to remove from project")});return e.jsxs(e.Fragment,{children:[e.jsxs(b,{className:"gap-0 py-0",children:[e.jsx(w,{className:"border-b px-5 py-4",children:e.jsxs(C,{className:"flex items-center gap-2 text-sm",children:[e.jsx(X,{className:"size-4 text-teal-500"}),"Projects",e.jsx(v,{variant:"secondary",className:"ml-auto text-[10px]",children:r.length})]})}),e.jsxs(k,{className:"px-5 py-4",children:[n?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"h-8 w-full"}),e.jsx(c,{className:"h-8 w-2/3"})]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not assigned to any projects."}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t.name}),e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>x.mutate(t.id),disabled:x.isPending,children:e.jsx(ae,{className:"size-3.5"})})]},t.id))}),e.jsxs(h,{variant:"outline",size:"sm",className:"mt-4 w-full",onClick:()=>i(!0),disabled:l.length===0,children:[e.jsx(re,{className:"size-4"}),"Add to Project"]})]})]}),e.jsx(q,{open:o,onOpenChange:i,children:e.jsxs(D,{children:[e.jsxs(M,{children:[e.jsx(I,{children:"Add to project"}),e.jsxs(_,{children:["Select a project to add"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.displayName})," ","to."]})]}),e.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:l.map(t=>e.jsxs("button",{type:"button",onClick:()=>d.mutate(t.id),disabled:d.isPending,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[e.jsx(X,{className:"size-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),t.description&&e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description})]}),d.isPending&&e.jsx(ne,{className:"size-4 animate-spin text-muted-foreground"})]},t.id))}),e.jsx(O,{children:e.jsx(h,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})})]})})]})}function cs({agentId:s}){const r=S(),l=ee(),n=T({queryKey:["agent",s],queryFn:async()=>{const i=await fetch(`${g}/agents/${s}`);if(!i.ok)throw new Error("Failed to fetch agent");return(await i.json()).data},staleTime:3e4,refetchInterval:1e4,retry:1}),a=A({mutationFn:async()=>{if(!(await fetch(`${g}/agents/${s}`,{method:"DELETE"})).ok)throw new Error("Failed to remove agent")},onSuccess:()=>{r.invalidateQueries({queryKey:["agents"]}),f.success("Agent removed"),l({to:"/agents"})},onError:()=>{f.error("Failed to remove agent")}});if(n.isLoading)return e.jsx(ms,{});if(n.isError||!n.data)return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-4 sm:p-8",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:e.jsx(Te,{className:"size-8 text-muted-foreground"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Agent not found"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"This agent may have been removed or the ID is invalid."})]})]});const o=n.data;return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsx(as,{agent:o,onDelete:()=>a.mutate(),isDeleting:a.isPending}),e.jsxs(Ye,{defaultValue:"overview",children:[e.jsxs(ss,{variant:"line",children:[e.jsx(L,{value:"overview",children:"Agent Card"}),e.jsx(L,{value:"activity",children:"Activity"}),e.jsx(L,{value:"management",children:"Management"})]}),e.jsx(R,{value:"overview",className:"mt-4",children:e.jsx(ts,{agentId:s})}),e.jsx(R,{value:"activity",className:"mt-4",children:e.jsx(ns,{agentId:s})}),e.jsx(R,{value:"management",className:"mt-4",children:e.jsx(os,{agent:o})})]})]})}function ms(){return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/60",children:[e.jsx(c,{className:"h-24 w-full rounded-none"}),e.jsxs("div",{className:"px-6 pb-6",children:[e.jsxs("div",{className:"-mt-10 flex items-end gap-5",children:[e.jsx(c,{className:"size-20 rounded-2xl"}),e.jsxs("div",{className:"flex-1 space-y-2 pt-1",children:[e.jsx(c,{className:"h-6 w-48"}),e.jsx(c,{className:"h-4 w-32"})]})]}),e.jsxs("div",{className:"mt-5 flex gap-4",children:[e.jsx(c,{className:"h-4 w-40"}),e.jsx(c,{className:"h-4 w-20"}),e.jsx(c,{className:"h-4 w-24"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(c,{className:"h-9 w-24"}),e.jsx(c,{className:"h-9 w-24"}),e.jsx(c,{className:"h-9 w-28"})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx(c,{className:"h-48 rounded-xl"}),e.jsx(c,{className:"h-48 rounded-xl"})]})]})}function ws(){const{agentId:s}=Ae.useParams();return e.jsx(ze,{featureName:"Agent Detail",children:e.jsx(cs,{agentId:s})})}export{ws as component};
@@ -0,0 +1,6 @@
1
+ import{c as t}from"./index-DqvmWes8.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const c=t("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);export{c as A};
@@ -0,0 +1,6 @@
1
+ import{c as e}from"./index-DqvmWes8.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const t=e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);export{t as A};
@@ -0,0 +1 @@
1
+ import{r as u,j as d,I as w,a1 as E,N,Q as j,R as f,x as v}from"./index-DqvmWes8.js";var y=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],g=y.reduce((t,a)=>{const s=w(`Primitive.${a}`),r=u.forwardRef((n,e)=>{const{asChild:l,...o}=n,i=l?s:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(i,{...o,ref:e})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{}),C=E();function R(){return C.useSyncExternalStore(k,()=>!0,()=>!1)}function k(){return()=>{}}var m="Avatar",[I]=N(m),[_,A]=I(m),S=u.forwardRef((t,a)=>{const{__scopeAvatar:s,...r}=t,[n,e]=u.useState("idle");return d.jsx(_,{scope:s,imageLoadingStatus:n,onImageLoadingStatusChange:e,children:d.jsx(g.span,{...r,ref:a})})});S.displayName=m;var h="AvatarImage",P=u.forwardRef((t,a)=>{const{__scopeAvatar:s,src:r,onLoadingStatusChange:n=()=>{},...e}=t,l=A(h,s),o=F(r,e),i=j(c=>{n(c),l.onImageLoadingStatusChange(c)});return f(()=>{o!=="idle"&&i(o)},[o,i]),o==="loaded"?d.jsx(g.img,{...e,ref:a,src:r}):null});P.displayName=h;var L="AvatarFallback",z=u.forwardRef((t,a)=>{const{__scopeAvatar:s,delayMs:r,...n}=t,e=A(L,s),[l,o]=u.useState(r===void 0);return u.useEffect(()=>{if(r!==void 0){const i=window.setTimeout(()=>o(!0),r);return()=>window.clearTimeout(i)}},[r]),l&&e.imageLoadingStatus!=="loaded"?d.jsx(g.span,{...n,ref:a}):null});z.displayName=L;function x(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function F(t,{referrerPolicy:a,crossOrigin:s}){const r=R(),n=u.useRef(null),e=r?(n.current||(n.current=new window.Image),n.current):null,[l,o]=u.useState(()=>x(e,t));return f(()=>{o(x(e,t))},[e,t]),f(()=>{const i=b=>()=>{o(b)};if(!e)return;const c=i("loaded"),p=i("error");return e.addEventListener("load",c),e.addEventListener("error",p),a&&(e.referrerPolicy=a),typeof s=="string"&&(e.crossOrigin=s),()=>{e.removeEventListener("load",c),e.removeEventListener("error",p)}},[e,s,a]),l}var M=S,$=z;function T({className:t,size:a="default",...s}){return d.jsx(M,{"data-slot":"avatar","data-size":a,className:v("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",t),...s})}function H({className:t,...a}){return d.jsx($,{"data-slot":"avatar-fallback",className:v("bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs",t),...a})}function q({className:t,...a}){return d.jsx("div",{"data-slot":"avatar-group",className:v("*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2",t),...a})}function B({className:t,...a}){return d.jsx("div",{"data-slot":"avatar-group-count",className:v("bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",t),...a})}export{q as A,T as a,H as b,B as c};
@@ -0,0 +1 @@
1
+ import{j as r,x as d}from"./index-DqvmWes8.js";function e({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function o({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function n({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{e as C,i as a,o as b,n as c,c as d};
@@ -0,0 +1,6 @@
1
+ import{c as o}from"./index-DqvmWes8.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const n=o("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);export{n as C};
@@ -0,0 +1,11 @@
1
+ var c=Object.defineProperty;var l=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>l(t,typeof e!="symbol"?e+"":e,r);import{c as i,j as s,x as o,ah as u,a7 as h,r as f,b as p}from"./index-DqvmWes8.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const m=i("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
7
+ * @license lucide-react v0.400.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const g=i("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function k({className:t,...e}){return s.jsx("div",{"data-slot":"skeleton",className:o("bg-accent animate-pulse rounded-md",t),...e})}const x=h("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function j({className:t,variant:e="default",asChild:r=!1,...a}){const d=r?u:"span";return s.jsx(d,{"data-slot":"badge","data-variant":e,className:o(x({variant:e}),t),...a})}class w extends f.Component{constructor(r){super(r);n(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,a){console.error(`[ErrorBoundary${this.props.featureName?`:${this.props.featureName}`:""}]`,r,a)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:s.jsx(v,{featureName:this.props.featureName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}}function v({featureName:t,error:e,onRetry:r}){return s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-8",children:[s.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-destructive/10",children:s.jsx(g,{className:"size-8 text-destructive-foreground"})}),s.jsxs("div",{className:"text-center",children:[s.jsx("h2",{className:"text-lg font-semibold",children:t?`Something went wrong in ${t}`:"Something went wrong"}),s.jsx("p",{className:"mt-1.5 max-w-sm text-sm text-muted-foreground",children:"An unexpected error occurred. Try refreshing or click retry below."}),(e==null?void 0:e.message)&&s.jsx("p",{className:"mt-2 max-w-md rounded-lg bg-muted px-3 py-2 font-mono text-xs text-muted-foreground",children:e.message})]}),r&&s.jsxs(p,{variant:"outline",size:"sm",onClick:r,children:[s.jsx(m,{className:"size-4"}),"Retry"]})]})}export{j as B,w as E,m as R,k as S};
@@ -0,0 +1,6 @@
1
+ import{c as a}from"./index-DqvmWes8.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=a("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);export{e as E};
@@ -0,0 +1,36 @@
1
+ import{c as T,r as o,j as e,S as Z,x as i,M as se,y as ae,B as E,b as _,T as ne,z as re,E as oe,m as ie,D as le,d as ce,e as de,f as ue,g as me,n as xe,G as ge,u as B,t as fe,A as q}from"./index-DqvmWes8.js";import{u as he}from"./useMutation-BhJRnGsH.js";import{a as O,b as V}from"./avatar-B_Cqbi60.js";import{S as H,B as Q,E as pe}from"./error-boundary-GFV_5F1L.js";import{S as G}from"./scroll-area-C4F6zoWB.js";import{R as be}from"./radio-D8C4proJ.js";import{C as ye}from"./chevron-down-CwGQLAwz.js";import{S as je}from"./send-Dl7T7Bm1.js";import{A as ve}from"./arrow-left-u9wxRsmJ.js";import{P as Ne}from"./plus-Bq20n-_S.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const we=T("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
7
+ * @license lucide-react v0.400.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ke=T("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
12
+ * @license lucide-react v0.400.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ee=T("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
17
+ * @license lucide-react v0.400.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Me=T("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/**
22
+ * @license lucide-react v0.400.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Y=T("MessageSquareDashed",[["path",{d:"M3 6V5c0-1.1.9-2 2-2h2",key:"9usibi"}],["path",{d:"M11 3h3",key:"1c3ji7"}],["path",{d:"M18 3h1c1.1 0 2 .9 2 2",key:"19esxn"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M21 15c0 1.1-.9 2-2 2h-1",key:"1fo1j8"}],["path",{d:"M14 17h-3",key:"1w4p2m"}],["path",{d:"m7 17-4 4v-5",key:"ph9x1h"}],["path",{d:"M3 12v-2",key:"856n1q"}]]);/**
27
+ * @license lucide-react v0.400.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Ce=T("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
32
+ * @license lucide-react v0.400.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const F=T("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),ze={online:"bg-emerald-500",idle:"bg-amber-400",busy:"bg-rose-500",offline:"bg-zinc-400"},J=["bg-sky-600","bg-violet-600","bg-rose-600","bg-amber-600","bg-emerald-600","bg-cyan-600","bg-fuchsia-600","bg-lime-600"];function Ae(s){let t=0;for(let a=0;a<s.length;a++)t=s.charCodeAt(a)+((t<<5)-t);return J[Math.abs(t)%J.length]}function De(s){return s.split(/[\s-]+/).slice(0,2).map(t=>t[0]).join("").toUpperCase()}function K(s){const t=Date.now()-new Date(s).getTime(),a=Math.floor(t/6e4);if(a<1)return"now";if(a<60)return`${a}m`;const l=Math.floor(a/60);if(l<24)return`${l}h`;const r=Math.floor(l/24);return r<7?`${r}d`:`${Math.floor(r/7)}w`}function Se({agents:s,messages:t,selectedAgentId:a,onSelect:l,isLoading:r,dashboardId:x}){const[d,p]=o.useState(""),g=o.useMemo(()=>{const n=s.map(c=>{const b=t.filter(y=>y.from===c.id&&y.to===x||y.from===x&&y.to===c.id),D=b.sort((y,z)=>new Date(z.createdAt).getTime()-new Date(y.createdAt).getTime())[0],S=b.filter(y=>!y.read&&y.from===c.id).length;return{agent:c,lastMessage:D,unreadCount:S}});return n.sort((c,b)=>{const D=c.lastMessage?new Date(c.lastMessage.createdAt).getTime():0;return(b.lastMessage?new Date(b.lastMessage.createdAt).getTime():0)-D}),n},[s,t,x]),j=o.useMemo(()=>t.filter(n=>n.type==="broadcast"),[t]).sort((n,c)=>new Date(c.createdAt).getTime()-new Date(n.createdAt).getTime())[0],w=o.useMemo(()=>t.filter(n=>n.to===x&&n.senderType==="agent"&&n.type!=="broadcast"),[t,x]),u=o.useMemo(()=>w.filter(n=>!n.read).length,[w]),N=w.sort((n,c)=>new Date(c.createdAt).getTime()-new Date(n.createdAt).getTime())[0],v=d?g.filter(n=>n.agent.displayName.toLowerCase().includes(d.toLowerCase())):g;return r?e.jsx("div",{className:"flex flex-col gap-2 p-3",children:Array.from({length:6}).map((n,c)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[e.jsx(H,{className:"size-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(H,{className:"h-3.5 w-24"}),e.jsx(H,{className:"h-3 w-36"})]})]},c))}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b p-3",children:e.jsxs("div",{className:i("flex items-center gap-2 rounded-xl border bg-muted/40 px-3 py-2","transition-colors focus-within:border-ring focus-within:bg-background"),children:[e.jsx(Z,{className:"size-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search conversations...",value:d,onChange:n=>p(n.target.value),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"})]})}),e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"flex flex-col gap-0.5 p-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>l(null),className:i("flex items-center gap-3 rounded-xl p-3 text-left transition-colors","hover:bg-accent/60",a===null&&"bg-accent"),children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-gradient-to-br from-rose-500 to-amber-500 text-white",children:e.jsx(be,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold",children:"Broadcast"}),j&&e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:K(j.createdAt)})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:j?j.content:"Send to all online agents"})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("__inbox__"),className:i("flex items-center gap-3 rounded-xl p-3 text-left transition-colors","hover:bg-accent/60",a==="__inbox__"&&"bg-accent"),children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-gradient-to-br from-indigo-500 to-sky-500 text-white",children:e.jsx(ee,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:i("truncate text-sm",u>0?"font-bold":"font-semibold"),children:"Dashboard Inbox"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[N&&e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:K(N.createdAt)}),u>0&&e.jsx(Q,{className:"size-5 justify-center bg-indigo-600 p-0 text-[10px] hover:bg-indigo-600",children:u>9?"9+":u})]})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:N?N.content:"Messages from agents to you"})]})]}),v.length===0&&!d&&e.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[e.jsx(se,{className:"size-8 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No conversations yet"})]}),v.length===0&&d&&e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:["No results for “",d,"”"]}),v.map(({agent:n,lastMessage:c,unreadCount:b})=>e.jsxs("button",{type:"button",onClick:()=>l(n.id),className:i("flex items-center gap-3 rounded-xl p-3 text-left transition-colors","hover:bg-accent/60",a===n.id&&"bg-accent"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{children:e.jsx(V,{className:i("text-xs font-bold text-white",Ae(n.id)),children:De(n.displayName)})}),e.jsx("span",{className:i("absolute -bottom-0.5 -right-0.5 size-3 rounded-full ring-2 ring-background",ze[n.status])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:i("truncate text-sm",b>0?"font-bold":"font-medium"),children:n.displayName}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:K(c.createdAt)}),b>0&&e.jsx(Q,{className:"size-5 justify-center p-0 text-[10px]",children:b>9?"9+":b})]})]}),e.jsx("p",{className:i("truncate text-xs",b>0?"font-medium text-foreground":"text-muted-foreground"),children:c?c.content:"No messages yet"})]})]},n.id))]})})]})}const Te={notification:{label:"Notice",variant:"secondary",icon:ae},query:{label:"Query",variant:"default",icon:ke},response:{label:"Reply",variant:"outline",icon:Ce},broadcast:{label:"Broadcast",variant:"destructive",icon:Me}};function _e(s){return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qe({message:s,isSent:t,senderName:a}){const l=Te[s.type],r=s.senderType==="person",x=l.icon;return e.jsxs("div",{className:i("group flex w-full gap-2.5",t?"justify-end":"justify-start"),children:[!t&&e.jsx("div",{className:i("mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg",r?"bg-indigo-500/15 text-indigo-500 dark:bg-indigo-400/15 dark:text-indigo-400":"bg-zinc-500/15 text-zinc-500 dark:bg-zinc-400/15 dark:text-zinc-400"),children:r?e.jsx(F,{className:"size-3.5"}):e.jsx(E,{className:"size-3.5"})}),e.jsxs("div",{className:i("relative max-w-[75%] rounded-2xl px-4 py-2.5 text-sm leading-relaxed","transition-all duration-200 hover:shadow-md",t?r?"rounded-br-md bg-indigo-600 text-white shadow-sm shadow-indigo-600/20 dark:bg-indigo-500":"rounded-br-md bg-primary text-primary-foreground shadow-sm":r?"rounded-bl-md border border-indigo-200/60 bg-indigo-50/80 text-foreground shadow-sm dark:border-indigo-500/20 dark:bg-indigo-950/40":"rounded-bl-md bg-muted text-foreground shadow-sm"),children:[e.jsxs("div",{className:i("mb-1 flex items-center gap-1.5",t?"justify-end":"justify-start"),children:[a&&e.jsx("span",{className:i("text-[11px] font-medium tracking-wide uppercase",t?r?"text-white/70":"text-primary-foreground/70":r?"text-indigo-600 dark:text-indigo-400":"text-muted-foreground"),children:a}),e.jsx("span",{className:i("inline-flex items-center text-[9px]",t?r?"text-white/50":"text-primary-foreground/50":r?"text-indigo-500/60 dark:text-indigo-400/60":"text-muted-foreground/50"),children:r?e.jsx(F,{className:"size-2.5"}):e.jsx(E,{className:"size-2.5"})}),e.jsxs(Q,{variant:l.variant,className:i("h-4 gap-0.5 px-1.5 text-[9px] font-semibold uppercase tracking-widest",t&&r&&"border-white/20 bg-white/20 text-white",t&&!r&&l.variant==="default"&&"bg-primary-foreground/20 text-primary-foreground border-primary-foreground/10",t&&!r&&l.variant==="secondary"&&"bg-primary-foreground/15 text-primary-foreground/80 border-primary-foreground/10",t&&!r&&l.variant==="outline"&&"border-primary-foreground/30 text-primary-foreground/70 bg-transparent",t&&!r&&l.variant==="destructive"&&"bg-primary-foreground/20 text-primary-foreground border-primary-foreground/10",!t&&r&&"border-indigo-300/50 bg-indigo-100/80 text-indigo-600 dark:border-indigo-500/30 dark:bg-indigo-900/40 dark:text-indigo-400"),children:[e.jsx(x,{className:"size-2.5"}),l.label]})]}),e.jsx("p",{className:"whitespace-pre-wrap break-words",children:s.content}),e.jsxs("div",{className:i("mt-1 flex items-center gap-1",t?"justify-end":"justify-start"),children:[e.jsx("span",{className:i("text-[10px] tabular-nums",t?r?"text-white/50":"text-primary-foreground/50":r?"text-indigo-500/50 dark:text-indigo-400/50":"text-muted-foreground/70"),children:_e(s.createdAt)}),t&&e.jsx("span",{className:i("text-[10px]",s.read?r?"text-white/70":"text-primary-foreground/70":r?"text-white/40":"text-primary-foreground/40"),children:s.read?"Read":"Sent"})]})]}),t&&e.jsx("div",{className:i("mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg",r?"bg-indigo-500/15 text-indigo-500 dark:bg-indigo-400/15 dark:text-indigo-400":"bg-primary/15 text-primary"),children:r?e.jsx(F,{className:"size-3.5"}):e.jsx(E,{className:"size-3.5"})})]})}const L=[{value:"notification",label:"Notice"},{value:"query",label:"Query"}];function Ie({onSend:s,disabled:t,selectedType:a,onTypeChange:l,senderType:r,onSenderTypeChange:x}){var v;const d=o.useRef(null),p=r==="person",g=o.useCallback(()=>{const n=d.current;n&&(n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,160)}px`)},[]),f=o.useCallback(()=>{const n=d.current;if(!n)return;const c=n.value.trim();c&&(s(c,a),n.value="",n.style.height="auto")},[s,a]),j=o.useCallback(n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),f())},[f]),w=o.useCallback(()=>{const n=L.findIndex(b=>b.value===a),c=L[(n+1)%L.length];l(c.value)},[a,l]),u=o.useCallback(()=>{x(p?"agent":"person")},[p,x]),N=((v=L.find(n=>n.value===a))==null?void 0:v.label)??"Notice";return e.jsx("div",{className:"border-t bg-background/80 p-3 backdrop-blur-sm",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs(_,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1 text-xs font-medium",onClick:w,children:[N,e.jsx(ye,{className:"size-3 opacity-50"})]}),e.jsxs(ne,{children:[e.jsx(re,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:u,className:i("relative flex size-9 shrink-0 items-center justify-center rounded-xl border transition-all duration-200",p?"border-indigo-400/50 bg-indigo-500/15 text-indigo-600 dark:border-indigo-500/40 dark:text-indigo-400":"border-border bg-muted/40 text-muted-foreground hover:bg-muted"),children:[p?e.jsx(F,{className:"size-4"}):e.jsx(E,{className:"size-4"}),e.jsx("span",{className:i("absolute -right-0.5 -top-0.5 size-2 rounded-full ring-2 ring-background transition-colors",p?"bg-indigo-500":"bg-zinc-400")})]})}),e.jsxs(oe,{side:"top",className:"text-xs",children:[p?"Sending as Person":"Sending as Agent",e.jsx("span",{className:"ml-1 text-muted-foreground",children:"(click to toggle)"})]})]}),e.jsx("div",{className:i("flex min-h-[36px] flex-1 items-end rounded-xl border px-3 py-2","transition-colors focus-within:border-ring focus-within:bg-background",p?"bg-indigo-50/50 dark:bg-indigo-950/20":"bg-muted/40"),children:e.jsx("textarea",{ref:d,rows:1,placeholder:p?"Send as person...":"Type a message...",disabled:t,className:i("w-full resize-none bg-transparent text-sm leading-relaxed outline-none","placeholder:text-muted-foreground/60","disabled:cursor-not-allowed disabled:opacity-50"),onInput:g,onKeyDown:j})}),e.jsx(_,{type:"button",size:"icon",disabled:t,onClick:f,className:i("size-9 shrink-0 rounded-xl",p&&"bg-indigo-600 hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-600"),children:e.jsx(je,{className:"size-4"})})]})})}const W=["bg-sky-600","bg-violet-600","bg-rose-600","bg-amber-600","bg-emerald-600","bg-cyan-600","bg-fuchsia-600","bg-lime-600"];function Re(s){let t=0;for(let a=0;a<s.length;a++)t=s.charCodeAt(a)+((t<<5)-t);return W[Math.abs(t)%W.length]}function $e(s){return s.split(/[\s-]+/).slice(0,2).map(t=>t[0]).join("").toUpperCase()}const Be={online:"bg-emerald-500",idle:"bg-amber-400",busy:"bg-rose-500",offline:"bg-zinc-400"};function Le({agent:s,agents:t,messages:a,dashboardId:l,onSend:r,isBroadcast:x,isInbox:d,onBack:p,showBackButton:g,senderType:f,onSenderTypeChange:j}){const w=o.useRef(null),u=o.useRef(null),[N,v]=o.useState(!1),[n,c]=o.useState(!0),[b,D]=o.useState("notification"),S=o.useRef(a.length),y=o.useCallback(()=>{var h;(h=w.current)==null||h.scrollIntoView({behavior:"smooth"}),v(!1)},[]);o.useEffect(()=>{a.length>S.current&&(n?setTimeout(()=>y(),50):v(!0)),S.current=a.length},[a.length,n,y]),o.useEffect(()=>{setTimeout(()=>y(),100)},[s==null?void 0:s.id,x,y]);const z=o.useCallback(()=>{var $;const h=($=u.current)==null?void 0:$.querySelector("[data-slot='scroll-area-viewport']");if(!h)return;const{scrollTop:k,scrollHeight:m,clientHeight:M}=h,A=m-k-M<60;c(A),A&&v(!1)},[]);if(o.useEffect(()=>{var k;const h=(k=u.current)==null?void 0:k.querySelector("[data-slot='scroll-area-viewport']");if(h)return h.addEventListener("scroll",z),()=>h.removeEventListener("scroll",z)},[z]),!s&&!x&&!d)return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-8",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/10 blur-2xl"}),e.jsx("div",{className:"relative flex size-20 items-center justify-center rounded-2xl bg-muted",children:e.jsx(Y,{className:"size-8 text-muted-foreground"})})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Select a conversation"}),e.jsx("p",{className:"mt-1 max-w-xs text-sm text-muted-foreground",children:"Pick an agent from the list or start a new conversation to begin messaging."})]})]});const P=d?"Dashboard Inbox":x?"Broadcast":(s==null?void 0:s.displayName)??"Unknown",U=d?"Messages from agents to you":x?"Message all online agents":(s==null?void 0:s.status)??"",I=[...a].sort((h,k)=>new Date(h.createdAt).getTime()-new Date(k.createdAt).getTime());let R="";return e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[g&&e.jsx(_,{variant:"ghost",size:"icon-sm",onClick:p,className:"shrink-0",children:e.jsx(ve,{className:"size-4"})}),d?e.jsx("div",{className:"flex size-9 items-center justify-center rounded-full bg-gradient-to-br from-indigo-500 to-sky-500 text-white",children:e.jsx(ee,{className:"size-4"})}):x?e.jsx("div",{className:"flex size-9 items-center justify-center rounded-full bg-gradient-to-br from-rose-500 to-amber-500 text-white",children:e.jsx(Y,{className:"size-4"})}):s&&e.jsxs("div",{className:"relative",children:[e.jsx(O,{children:e.jsx(V,{className:i("text-xs font-bold text-white",Re(s.id)),children:$e(s.displayName)})}),e.jsx("span",{className:i("absolute -bottom-0.5 -right-0.5 size-2.5 rounded-full ring-2 ring-background",Be[s.status])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-sm font-semibold",children:P}),e.jsx("p",{className:"truncate text-xs capitalize text-muted-foreground",children:U})]})]}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(G,{ref:u,className:"absolute inset-0",children:e.jsxs("div",{className:"flex flex-col gap-3 px-4 py-4",children:[I.length===0&&e.jsx("div",{className:"py-20 text-center text-sm text-muted-foreground",children:"No messages yet. Say hello!"}),I.map(h=>{const k=new Date(h.createdAt).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}),m=k!==R;R=k;const M=h.from===l,A=t==null?void 0:t.find(te=>te.id===h.from),$=M?"You":(A==null?void 0:A.displayName)??(s==null?void 0:s.displayName)??h.from.slice(0,8);return e.jsxs(ie.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.2},children:[m&&e.jsxs("div",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-widest text-muted-foreground",children:k}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx(qe,{message:h,isSent:M,senderName:$})]},h.id)}),e.jsx("div",{ref:w})]})}),N&&e.jsxs(_,{variant:"secondary",size:"sm",className:"absolute bottom-4 left-1/2 z-10 -translate-x-1/2 gap-1.5 rounded-full shadow-lg",onClick:y,children:[e.jsx(we,{className:"size-3"}),"New messages"]})]}),!d&&e.jsx(Ie,{onSend:r,selectedType:b,onTypeChange:D,senderType:f,onSenderTypeChange:j})]})}const Ee={online:"Online",idle:"Idle",busy:"Busy",offline:"Offline"},Fe={online:"bg-emerald-500",idle:"bg-amber-400",busy:"bg-rose-500",offline:"bg-zinc-400"},X=["bg-sky-600","bg-violet-600","bg-rose-600","bg-amber-600","bg-emerald-600","bg-cyan-600","bg-fuchsia-600","bg-lime-600"];function Pe(s){let t=0;for(let a=0;a<s.length;a++)t=s.charCodeAt(a)+((t<<5)-t);return X[Math.abs(t)%X.length]}function Ue(s){return s.split(/[\s-]+/).slice(0,2).map(t=>t[0]).join("").toUpperCase()}function He({open:s,onOpenChange:t,agents:a,onSelect:l}){const[r,x]=o.useState(""),d=o.useMemo(()=>{if(!r)return a;const g=r.toLowerCase();return a.filter(f=>f.displayName.toLowerCase().includes(g)||f.name.toLowerCase().includes(g))},[a,r]),p=o.useMemo(()=>{const g=d.filter(u=>u.status==="online"),f=d.filter(u=>u.status==="idle"),j=d.filter(u=>u.status==="busy"),w=d.filter(u=>u.status==="offline");return[{label:"Online",agents:g},{label:"Idle",agents:f},{label:"Busy",agents:j},{label:"Offline",agents:w}].filter(u=>u.agents.length>0)},[d]);return e.jsx(le,{open:s,onOpenChange:t,children:e.jsxs(ce,{className:"max-h-[80vh] p-0 sm:max-w-md",children:[e.jsxs(de,{className:"px-6 pt-6 pb-0",children:[e.jsx(ue,{children:"New Conversation"}),e.jsx(me,{children:"Select an agent to start a conversation"})]}),e.jsx("div",{className:"px-6",children:e.jsxs("div",{className:i("flex items-center gap-2 rounded-xl border bg-muted/40 px-3 py-2","transition-colors focus-within:border-ring focus-within:bg-background"),children:[e.jsx(Z,{className:"size-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search agents...",value:r,onChange:g=>x(g.target.value),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/60",autoFocus:!0})]})}),e.jsx(G,{className:"max-h-[50vh] px-3 pb-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[p.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground",children:[g.label," (",g.agents.length,")"]}),g.agents.map(f=>e.jsxs("button",{type:"button",onClick:()=>{l(f.id),t(!1),x("")},className:i("flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left","transition-colors hover:bg-accent/60"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{children:e.jsx(V,{className:i("text-xs font-bold text-white",Pe(f.id)),children:Ue(f.displayName)})}),e.jsx("span",{className:i("absolute -bottom-0.5 -right-0.5 size-2.5 rounded-full ring-2 ring-background",Fe[f.status])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:f.displayName}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ee[f.status]})]})]},f.id))]},g.label)),d.length===0&&e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No agents found"})]})})]})})}const C="dashboard";async function Ke(){const s=await fetch(`${q}/agents`);if(!s.ok)throw new Error("Failed to fetch agents");return(await s.json()).data}async function Qe(s){const t=await fetch(`${q}/messages?agentId=${encodeURIComponent(s)}&limit=200`);if(!t.ok)throw new Error("Failed to fetch messages");return(await t.json()).data}async function Oe(s,t){const a=await fetch(`${q}/messages/conversation/${encodeURIComponent(s)}/${encodeURIComponent(t)}`);if(!a.ok)throw new Error("Failed to fetch conversation");return(await a.json()).data}async function Ve(s){const t=await fetch(`${q}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const l=await t.json().catch(()=>null);throw new Error((l==null?void 0:l.message)??`Failed to send message (${t.status})`)}return(await t.json()).data}async function Ge(s){await fetch(`${q}/messages/${s}/read`,{method:"PATCH"})}function Ye(){const s=xe(),t=ge(),[a,l]=o.useState(null),[r,x]=o.useState(!1),[d,p]=o.useState("list"),[g,f]=o.useState("person"),{data:j=[],isLoading:w}=B({queryKey:["agents"],queryFn:Ke,refetchInterval:15e3}),{data:u=[]}=B({queryKey:["messages","dashboard"],queryFn:()=>Qe(C),refetchInterval:5e3}),N=a===null&&d==="chat",v=a==="__inbox__",n=!!a&&a!=="__inbox__",{data:c=[]}=B({queryKey:["conversation",C,a],queryFn:()=>a?Oe(C,a):Promise.resolve([]),enabled:n,refetchInterval:3e3}),b=o.useMemo(()=>j.find(m=>m.id===a)??null,[j,a]),D=o.useMemo(()=>u.filter(m=>m.type==="broadcast"),[u]),S=o.useMemo(()=>u.filter(m=>m.to===C&&m.senderType==="agent"&&m.type!=="broadcast"),[u]),y=v?S:N||!a&&d!=="chat"?D:c;B({queryKey:["markRead",a],queryFn:async()=>{if(!a||a==="__inbox__")return null;const m=c.filter(M=>!M.read&&M.from===a);return await Promise.all(m.map(M=>Ge(M.id))),m.length>0&&(s.invalidateQueries({queryKey:["conversation",C,a]}),s.invalidateQueries({queryKey:["messages","dashboard"]})),null},enabled:n&&c.length>0,refetchInterval:!1});const z=he({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["conversation",C,a]}),s.invalidateQueries({queryKey:["messages","dashboard"]})},onError:m=>{fe.error("Failed to send message",{description:m instanceof Error?m.message:"Unknown error"})}}),P=o.useCallback((m,M)=>{if(v)return;const A=N||!a?"broadcast":a;z.mutate({from:C,to:A,content:m,type:N||!a?"broadcast":M,senderType:g})},[a,N,v,z,g]),U=o.useCallback(m=>{l(m),t&&p("chat")},[t]),I=o.useCallback(()=>{p("list")},[]),R=o.useCallback(m=>{l(m),t&&p("chat")},[t]),h=!t||d==="list",k=!t||d==="chat";return e.jsxs("div",{className:"flex h-[calc(100vh-3.5rem)] overflow-hidden",children:[h&&e.jsxs("div",{className:i("flex flex-col border-r",t?"w-full":"w-80 shrink-0 xl:w-96"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsx("h1",{className:"text-lg font-bold tracking-tight",children:"Messages"}),e.jsx(_,{size:"icon-sm",variant:"outline",onClick:()=>x(!0),children:e.jsx(Ne,{className:"size-4"})})]}),e.jsx(Se,{agents:j,messages:u,selectedAgentId:a,onSelect:U,isLoading:w,dashboardId:C})]}),k&&e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(Le,{agent:b,agents:j,messages:y,dashboardId:C,onSend:P,isBroadcast:!v&&(N||!a&&!t),isInbox:v,onBack:I,showBackButton:t,senderType:g,onSenderTypeChange:f})}),e.jsx(He,{open:r,onOpenChange:x,agents:j,onSelect:R})]})}function ot(){return e.jsx(pe,{featureName:"Messages",children:e.jsx(Ye,{})})}export{ot as component};
@@ -0,0 +1,16 @@
1
+ import{c as k,r as p,j as e,m as C,B as U,M as w,U as F,F as R,L as B,D as A,a as M,b as T,d as z,e as D,f as S,g as L,u as N,H as E,h as O,i as H,k as P,l as Q}from"./index-DqvmWes8.js";import{C as h,a as f,b as j,c as v}from"./card-B896vjxa.js";import{S as d,B as K,E as V}from"./error-boundary-GFV_5F1L.js";import{S as _}from"./scroll-area-C4F6zoWB.js";import{A as G}from"./activity-B3TqhZ-f.js";import{S as J}from"./send-Dl7T7Bm1.js";import{P as q}from"./plus-Bq20n-_S.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const W=k("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
7
+ * @license lucide-react v0.400.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const X=k("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
12
+ * @license lucide-react v0.400.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Y=k("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function Z(t,s=250){const[i,a]=p.useState(0),r=p.useRef(0),n=p.useRef(t);return p.useEffect(()=>{if(n.current===t&&i===t)return;const o=n.current!==t?0:i;if(n.current=t,t===0){a(0);return}const g=performance.now();function l(x){const c=x-g,u=Math.min(c/s,1),b=1-Math.pow(1-u,3),m=Math.round(o+(t-o)*b);a(m),u<1&&(r.current=requestAnimationFrame(l))}return r.current=requestAnimationFrame(l),()=>{r.current&&cancelAnimationFrame(r.current)}},[t,s]),i}const ee=[{key:"agents",label:"Total Agents",icon:U,color:"text-brand-500",bgColor:"bg-brand-500/10",trendUp:!0},{key:"messages",label:"Active Messages",icon:w,color:"text-emerald-500",bgColor:"bg-emerald-500/10",trendUp:!0},{key:"teams",label:"Teams",icon:F,color:"text-amber-500",bgColor:"bg-amber-500/10",trendUp:!1},{key:"projects",label:"Projects",icon:R,color:"text-rose-500",bgColor:"bg-rose-500/10",trendUp:!0}];function se(t,s){switch(t){case"agents":return s.agentCount;case"messages":return s.messageCount;case"teams":return s.teamCount;case"projects":return s.projectCount}}function te(t,s){switch(t){case"agents":return`${s.onlineCount} online`;case"messages":return"recent activity";case"teams":return"configured";case"projects":return"active"}}function ne({value:t}){const s=Z(t);return e.jsx(e.Fragment,{children:s})}const ae={hidden:{},visible:{transition:{staggerChildren:.05}}},re={hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:{duration:.25}}};function ie(t){return t.isLoading?e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((s,i)=>e.jsx(h,{className:"relative overflow-hidden",children:e.jsxs(f,{className:"flex items-center gap-4",children:[e.jsx(d,{className:"size-12 rounded-xl"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(d,{className:"h-3 w-20"}),e.jsx(d,{className:"h-7 w-14"}),e.jsx(d,{className:"h-3 w-16"})]})]})},i))}):e.jsx(C.div,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",variants:ae,initial:"hidden",animate:"visible",children:ee.map(s=>{const i=se(s.key,t),a=te(s.key,t),r=s.trendUp?Y:X;return e.jsx(C.div,{variants:re,children:e.jsxs(h,{className:"group relative overflow-hidden transition-all duration-200 hover:shadow-md hover:-translate-y-0.5",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-transparent via-transparent to-brand-500/[0.03] dark:to-brand-400/[0.05]"}),e.jsxs(f,{className:"relative flex items-center gap-4",children:[e.jsx("div",{className:`flex size-12 shrink-0 items-center justify-center rounded-xl ${s.bgColor} transition-transform group-hover:scale-105`,children:e.jsx(s.icon,{className:`size-5 ${s.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium tracking-wide text-muted-foreground uppercase",children:s.label}),e.jsx("p",{className:"mt-0.5 text-2xl font-bold tracking-tight text-foreground tabular-nums",children:e.jsx(ne,{value:i})}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(r,{className:"size-3"}),e.jsx("span",{children:a})]})]})]})]})},s.key)})})}const oe={online:{dot:"bg-emerald-500",pulse:!0,label:"Online"},busy:{dot:"bg-amber-500",pulse:!1,label:"Busy"},idle:{dot:"bg-sky-400",pulse:!1,label:"Idle"},offline:{dot:"bg-zinc-400 dark:bg-zinc-600",pulse:!1,label:"Offline"}};function $({agent:t}){const s=oe[t.status];return e.jsxs(B,{to:"/agents/$agentId",params:{agentId:t.id},className:"group flex items-center gap-2.5 rounded-lg border bg-card px-3 py-2.5 transition-all hover:shadow-sm hover:border-brand-300 dark:hover:border-brand-600",children:[e.jsxs("span",{className:"relative flex size-2.5 shrink-0",children:[e.jsx("span",{className:`absolute inset-0 rounded-full ${s.dot} ${s.pulse?"animate-pulse-dot":""}`}),e.jsx("span",{className:`relative inline-flex size-2.5 rounded-full ${s.dot}`})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"truncate text-sm font-medium text-foreground group-hover:text-brand-600 dark:group-hover:text-brand-400 transition-colors",children:t.displayName})}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:s.label})]})}function le(){return e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(d,{className:"h-5 w-28"})}),e.jsx(f,{children:e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:Array.from({length:6}).map((t,s)=>e.jsx(d,{className:"h-11 rounded-lg"},s))})})]})}function ce({agents:t,teams:s,isLoading:i}){var g;if(i)return e.jsx(le,{});if(t.length===0)return e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(v,{className:"text-base",children:"Agents"})}),e.jsx(f,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents registered yet. Start an agent to see it here."})})]});const a=new Map(s.map(l=>[l.id,l])),r=new Map,n=[];for(const l of t){const x=((g=l.agentCard)==null?void 0:g.teams)??[];if(x.length>0){const c=x[0],u=r.get(c)??[];u.push(l),r.set(c,u)}else n.push(l)}const o=(l,x)=>{const c={online:0,busy:1,idle:2,offline:3};return c[l.status]-c[x.status]};return e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(v,{className:"text-base",children:"Agents"})}),e.jsxs(f,{className:"space-y-5",children:[Array.from(r.entries()).map(([l,x])=>{const c=a.get(l);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:(c==null?void 0:c.name)??l}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:x.sort(o).map(u=>e.jsx($,{agent:u},u.id))})]},l)}),n.length>0&&e.jsxs("div",{children:[r.size>0&&e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Unassigned"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:n.sort(o).map(l=>e.jsx($,{agent:l},l.id))})]})]})]})}function de(t){const s=Date.now(),i=new Date(t).getTime(),a=Math.floor((s-i)/1e3);if(a<60)return"just now";const r=Math.floor(a/60);if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const ue={notification:"secondary",query:"default",response:"outline",broadcast:"secondary"};function me({messages:t,agents:s,isLoading:i}){const a=new Map(s.map(n=>[n.id,n])),r=n=>{var o;return((o=a.get(n))==null?void 0:o.displayName)??n.slice(0,8)};return i?e.jsxs(h,{className:"flex flex-col",children:[e.jsx(j,{children:e.jsx(d,{className:"h-5 w-36"})}),e.jsx(f,{className:"flex-1",children:e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((n,o)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(d,{className:"size-8 rounded-full shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx(d,{className:"h-3 w-32"}),e.jsx(d,{className:"h-3 w-full"})]})]},o))})})]}):e.jsxs(h,{className:"flex flex-col",children:[e.jsx(j,{children:e.jsxs(v,{className:"flex items-center gap-2 text-base",children:[e.jsx(w,{className:"size-4 text-muted-foreground"}),"Recent Messages"]})}),e.jsx(f,{className:"flex-1 p-0",children:e.jsx(_,{className:"h-[340px] px-6 pb-4",children:t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No messages yet"}):e.jsx("div",{className:"space-y-1",children:t.map(n=>e.jsxs("div",{className:"group flex items-start gap-3 rounded-lg p-2.5 transition-colors hover:bg-muted/50",children:[e.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-brand-500/10 text-brand-600 dark:text-brand-400",children:e.jsx(w,{className:"size-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-semibold text-foreground truncate",children:r(n.from)}),e.jsx(W,{className:"size-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-muted-foreground truncate",children:r(n.to)}),e.jsx(K,{variant:ue[n.type]??"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:n.type})]}),e.jsx("p",{className:"mt-0.5 truncate text-sm text-muted-foreground",children:n.content})]}),e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground pt-0.5",children:de(n.createdAt)})]},n.id))})})})]})}function xe(t){const s=new Date,i=[];for(let a=23;a>=0;a--){const n=new Date(s.getTime()-a*60*60*1e3).toLocaleTimeString([],{hour:"2-digit",hour12:!1}).replace(/^24$/,"00");i.push({label:n,count:0})}for(const a of t){const r=new Date(a.createdAt),n=Math.floor((s.getTime()-r.getTime())/(3600*1e3));if(n>=0&&n<24){const o=23-n;i[o].count++}}return i}function ge({messages:t,isLoading:s}){const i=p.useMemo(()=>xe(t),[t]),a=Math.max(...i.map(n=>n.count),1),r=i.reduce((n,o)=>n+o.count,0);return s?e.jsxs(h,{children:[e.jsx(j,{children:e.jsx(d,{className:"h-5 w-40"})}),e.jsx(f,{children:e.jsx(d,{className:"h-[180px] rounded-lg"})})]}):e.jsxs(h,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(v,{className:"flex items-center gap-2 text-base",children:[e.jsx(G,{className:"size-4 text-muted-foreground"}),"Activity"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[r," messages · last 24h"]})]})}),e.jsx(f,{children:e.jsx("div",{className:"flex items-end gap-[3px] h-[180px]",children:i.map((n,o)=>{const g=a>0?n.count/a*100:0,l=o%4===0;return e.jsxs("div",{className:"group relative flex flex-1 flex-col items-center justify-end h-full",children:[e.jsx("div",{className:"relative w-full rounded-t transition-all duration-300 bg-brand-500/70 hover:bg-brand-500 dark:bg-brand-400/60 dark:hover:bg-brand-400",style:{height:`${Math.max(g,2)}%`,minHeight:"2px"},children:e.jsx("div",{className:"absolute -top-7 left-1/2 -translate-x-1/2 rounded bg-foreground px-1.5 py-0.5 text-[10px] font-medium text-background opacity-0 transition-opacity group-hover:opacity-100 whitespace-nowrap pointer-events-none",children:n.count})}),l&&e.jsx("span",{className:"mt-1.5 text-[9px] text-muted-foreground leading-none",children:n.label})]},o)})})})]})}function he(){const[t,s]=p.useState(!1),[i,a]=p.useState(!1);return e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(A,{open:t,onOpenChange:s,children:[e.jsx(M,{asChild:!0,children:e.jsxs(T,{className:"gap-2",size:"sm",children:[e.jsx(J,{className:"size-3.5"}),"Send Message"]})}),e.jsxs(z,{children:[e.jsxs(D,{children:[e.jsx(S,{children:"Send Message"}),e.jsx(L,{children:"Send a message to an agent or broadcast to all agents."})]}),e.jsxs("div",{className:"flex items-center justify-center rounded-lg border border-dashed py-12 text-sm text-muted-foreground",children:[e.jsx(q,{className:"mr-2 size-4"}),"Message composer coming soon"]})]})]}),e.jsxs(A,{open:i,onOpenChange:a,children:[e.jsx(M,{asChild:!0,children:e.jsxs(T,{variant:"outline",className:"gap-2",size:"sm",children:[e.jsx(F,{className:"size-3.5"}),"Create Team"]})}),e.jsxs(z,{children:[e.jsxs(D,{children:[e.jsx(S,{children:"Create Team"}),e.jsx(L,{children:"Group agents into a team for coordinated work."})]}),e.jsxs("div",{className:"flex items-center justify-center rounded-lg border border-dashed py-12 text-sm text-muted-foreground",children:[e.jsx(q,{className:"mr-2 size-4"}),"Team builder coming soon"]})]})]})]})}const y=1e4;function fe(){const t=N({queryKey:["agents"],queryFn:O,refetchInterval:y}),s=N({queryKey:["teams"],queryFn:H,refetchInterval:y}),i=N({queryKey:["projects"],queryFn:P,refetchInterval:y}),a=t.data??[],r=N({queryKey:["dashboard-messages",a.map(c=>c.id)],queryFn:async()=>{if(a.length===0)return[];const c=await Promise.allSettled(a.map(m=>Q(m.id,5))),u=[];for(const m of c)m.status==="fulfilled"&&u.push(...m.value);const b=Array.from(new Map(u.map(m=>[m.id,m])).values());return b.sort((m,I)=>new Date(I.createdAt).getTime()-new Date(m.createdAt).getTime()),b.slice(0,10)},enabled:a.length>0,refetchInterval:y}),n=t.isLoading||s.isLoading||i.isLoading,o=r.data??[],g=s.data??[],l=i.data??[],x=a.filter(c=>c.status==="online").length;return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-xl bg-brand-500/10",children:e.jsx(E,{className:"size-5 text-brand-500"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight text-foreground",children:"Dashboard"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Agent orchestration overview"})]})]}),e.jsx(he,{})]}),e.jsx(ie,{agentCount:a.length,messageCount:o.length,teamCount:g.length,projectCount:l.length,onlineCount:x,isLoading:n}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(ce,{agents:a,teams:g,isLoading:t.isLoading}),e.jsx(me,{messages:o,agents:a,isLoading:r.isLoading&&a.length>0})]}),e.jsx(ge,{messages:o,isLoading:r.isLoading&&a.length>0})]})}function ke(){return e.jsx(V,{featureName:"Dashboard",children:e.jsx(fe,{})})}export{ke as component};
@@ -0,0 +1,26 @@
1
+ import{c as D,j as e,S as ne,V as E,W as $,b as f,X as F,Y as q,Z as H,_,$ as O,x as T,r as m,a0 as re,M as ie,D as ce,d as de,e as oe,f as xe,g as me,o as he,L as Y,n as ue,u as K,t as Q,A as B,m as P,B as ge}from"./index-DqvmWes8.js";import{u as je}from"./useMutation-BhJRnGsH.js";import{B as S,S as C,E as fe}from"./error-boundary-GFV_5F1L.js";import{I as pe}from"./input-BROwVVEx.js";import{a as Z,b as X}from"./avatar-B_Cqbi60.js";import{T as be,s as R,g as J,a as ee,t as ye,f as se}from"./utils-AH9TuImk.js";import{C as Ne,a as ve}from"./card-B896vjxa.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const we=D("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
7
+ * @license lucide-react v0.400.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ke=D("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
12
+ * @license lucide-react v0.400.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ce=D("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
17
+ * @license lucide-react v0.400.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Se=D("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
22
+ * @license lucide-react v0.400.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Te=D("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]),G=[{value:"all",label:"All statuses"},{value:"online",label:"Online"},{value:"offline",label:"Offline"},{value:"busy",label:"Busy"},{value:"idle",label:"Idle"}],ze=[{value:"name",label:"Name"},{value:"status",label:"Status"},{value:"lastSeen",label:"Last seen"}];function Ae({search:s,onSearchChange:t,statusFilter:d,onStatusFilterChange:l,teamFilter:r,onTeamFilterChange:i,viewMode:h,onViewModeChange:x,sortField:o,sortDirection:u,onSortChange:v,teams:p,totalCount:b,filteredCount:z}){var L,A;const I=((L=G.find(n=>n.value===d))==null?void 0:L.label)??"All",w=((A=p.find(n=>n.id===r))==null?void 0:A.name)??"All teams";return e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[e.jsxs("div",{className:"relative max-w-xs flex-1",children:[e.jsx(ne,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2"}),e.jsx(pe,{placeholder:"Search agents...",value:s,onChange:n=>t(n.target.value),className:"pl-8"})]}),e.jsxs(E,{children:[e.jsx($,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"shrink-0",children:[e.jsx("span",{className:`mr-1.5 inline-block size-2 rounded-full ${d==="online"?"bg-emerald-500":d==="offline"?"bg-zinc-400":d==="busy"?"bg-amber-500":d==="idle"?"bg-sky-400":"bg-zinc-300 dark:bg-zinc-600"}`}),I]})}),e.jsxs(F,{align:"start",children:[e.jsx(q,{children:"Filter by status"}),e.jsx(H,{}),G.map(n=>e.jsx(_,{checked:d===n.value,onCheckedChange:()=>l(n.value),children:n.label},n.value))]})]}),p.length>0&&e.jsxs(E,{children:[e.jsx($,{asChild:!0,children:e.jsx(f,{variant:"outline",size:"sm",className:"shrink-0",children:w})}),e.jsxs(F,{align:"start",children:[e.jsx(q,{children:"Filter by team"}),e.jsx(H,{}),e.jsx(_,{checked:r===null,onCheckedChange:()=>i(null),children:"All teams"}),p.map(n=>e.jsxs(_,{checked:r===n.id,onCheckedChange:()=>i(n.id),children:[e.jsx("span",{className:"mr-1.5 inline-block size-2.5 rounded",style:{backgroundColor:n.color}}),n.name]},n.id))]})]}),e.jsxs(E,{children:[e.jsx($,{asChild:!0,children:e.jsxs(f,{variant:"ghost",size:"sm",className:"shrink-0 gap-1",children:[e.jsx(we,{className:"size-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Sort"})]})}),e.jsxs(F,{align:"start",children:[e.jsx(q,{children:"Sort by"}),e.jsx(H,{}),ze.map(n=>e.jsxs(O,{onClick:()=>v(n.value),children:[n.label,o===n.value&&e.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:u==="asc"?"↑":"↓"})]},n.value))]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:z===b?`${b} agent${b!==1?"s":""}`:`${z} of ${b}`}),e.jsxs("div",{className:"bg-muted flex rounded-md p-0.5",children:[e.jsx(f,{variant:h==="table"?"secondary":"ghost",size:"icon-xs",onClick:()=>x("table"),"aria-label":"Table view",children:e.jsx(Te,{className:"size-3.5"})}),e.jsx(f,{variant:h==="grid"?"secondary":"ghost",size:"icon-xs",onClick:()=>x("grid"),"aria-label":"Grid view",children:e.jsx(Se,{className:"size-3.5"})})]})]})]})}function De({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:T("w-full caption-bottom text-sm",s),...t})})}function Ie({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:T("[&_tr]:border-b",s),...t})}function Le({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:T("[&_tr:last-child]:border-0",s),...t})}function W({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:T("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...t})}function y({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:T("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function N({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:T("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function ae({agent:s,onDelete:t,isDeleting:d}){const[l,r]=m.useState(!1),i=re();return e.jsxs(e.Fragment,{children:[e.jsxs(E,{children:[e.jsx($,{asChild:!0,children:e.jsx(f,{variant:"ghost",size:"icon-xs","aria-label":"Agent actions",children:e.jsx(ke,{className:"size-4"})})}),e.jsxs(F,{align:"end",children:[e.jsxs(O,{onClick:()=>i({to:"/agents/$agentId",params:{agentId:s.id}}),children:[e.jsx(Ce,{className:"mr-2 size-4"}),"View Details"]}),e.jsxs(O,{onClick:()=>i({to:"/messages",search:{to:s.id}}),children:[e.jsx(ie,{className:"mr-2 size-4"}),"Send Message"]}),e.jsx(H,{}),e.jsxs(O,{variant:"destructive",onClick:()=>r(!0),children:[e.jsx(be,{className:"mr-2 size-4"}),"Remove"]})]})]}),e.jsx(ce,{open:l,onOpenChange:r,children:e.jsxs(de,{children:[e.jsxs(oe,{children:[e.jsx(xe,{children:"Remove agent"}),e.jsxs(me,{children:["This will set"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.displayName})," ","to offline. The agent can re-register at any time."]})]}),e.jsxs(he,{children:[e.jsx(f,{variant:"outline",onClick:()=>r(!1),disabled:d,children:"Cancel"}),e.jsx(f,{variant:"destructive",disabled:d,onClick:()=>{t(s.id),r(!1)},children:d?"Removing...":"Remove"})]})]})})]})}function Me({agents:s,onDelete:t,deletingId:d}){return e.jsx("div",{className:"overflow-x-auto rounded-lg border",children:e.jsxs(De,{children:[e.jsx(Ie,{children:e.jsxs(W,{children:[e.jsx(y,{className:"w-10"}),e.jsx(y,{children:"Agent"}),e.jsx(y,{className:"hidden md:table-cell",children:"URL"}),e.jsx(y,{className:"hidden lg:table-cell",children:"Teams"}),e.jsx(y,{children:"Status"}),e.jsx(y,{className:"hidden sm:table-cell",children:"Last Seen"}),e.jsx(y,{className:"w-10"})]})}),e.jsx(Le,{children:s.map(l=>{var x,o,u;const r=R[l.status]??R.offline,i=J(l.displayName),h=ee(l.displayName);return e.jsxs(W,{children:[e.jsx(N,{children:e.jsx("span",{className:`inline-block size-2 rounded-full ${r.dot}`,title:r.label})}),e.jsx(N,{children:e.jsxs(Y,{to:"/agents/$agentId",params:{agentId:l.id},className:"flex items-center gap-2.5",children:[e.jsx(Z,{size:"sm",children:e.jsx(X,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:h},children:i})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium leading-tight",children:l.displayName}),e.jsx("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:l.name})]})]})}),e.jsx(N,{className:"hidden md:table-cell",children:e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:ye(l.url)})}),e.jsx(N,{className:"hidden lg:table-cell",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o=(x=l.agentCard)==null?void 0:x.teams)==null?void 0:o.map(v=>e.jsx(S,{variant:"outline",className:"text-[10px] leading-tight",children:v},v)),(!((u=l.agentCard)!=null&&u.teams)||l.agentCard.teams.length===0)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})]})}),e.jsx(N,{children:e.jsx(S,{variant:r.variant,className:"text-[10px]",children:r.label})}),e.jsx(N,{className:"hidden sm:table-cell",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:l.lastHeartbeat?se(l.lastHeartbeat):"Never"})}),e.jsx(N,{children:e.jsx(ae,{agent:l,onDelete:t,isDeleting:d===l.id})})]},l.id)})})]})})}function Ee({agent:s,onDelete:t,isDeleting:d}){var h,x;const l=J(s.displayName),r=ee(s.displayName),i=R[s.status]??R.offline;return e.jsxs(Ne,{className:"group relative gap-0 overflow-hidden py-0 transition-all duration-200 hover:shadow-md hover:-translate-y-0.5",children:[e.jsx("div",{className:"h-1.5 w-full",style:{background:`linear-gradient(90deg, ${r}88, ${r}22)`}}),e.jsxs(ve,{className:"flex flex-col gap-4 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs(Y,{to:"/agents/$agentId",params:{agentId:s.id},className:"flex items-center gap-3",children:[e.jsx(Z,{size:"lg",children:e.jsx(X,{className:"text-sm font-semibold text-white",style:{backgroundColor:r},children:l})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate font-semibold leading-tight text-foreground",children:s.displayName}),e.jsxs("span",{className:"relative flex size-2 shrink-0",children:[s.status==="online"&&e.jsx("span",{className:`absolute inset-0 rounded-full ${i.dot} animate-pulse-dot`}),e.jsx("span",{className:`relative inline-flex size-2 rounded-full ${i.dot}`,title:i.label})]})]}),e.jsx("p",{className:"mt-0.5 truncate font-mono text-xs text-muted-foreground",children:s.name})]})]}),e.jsx(ae,{agent:s,onDelete:t,isDeleting:d})]}),((h=s.agentCard)==null?void 0:h.skills)&&s.agentCard.skills.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.agentCard.skills.slice(0,4).map(o=>e.jsx(S,{variant:"secondary",className:"text-[10px] leading-tight",children:o.name},o.id)),s.agentCard.skills.length>4&&e.jsxs(S,{variant:"outline",className:"text-[10px] leading-tight",children:["+",s.agentCard.skills.length-4]})]}),((x=s.agentCard)==null?void 0:x.teams)&&s.agentCard.teams.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.agentCard.teams.map(o=>e.jsx(S,{variant:"outline",className:"text-[10px] leading-tight",children:o},o))}),e.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border/50 pt-3",children:[e.jsx(S,{variant:i.variant,className:"text-[10px]",children:i.label}),s.lastHeartbeat&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:se(s.lastHeartbeat)})]})]})]})}const te="swarmroom:agents:viewMode";function $e(){try{const s=localStorage.getItem(te);if(s==="grid"||s==="table")return s}catch{}return"grid"}function Fe(){var U;const s=ue(),[t,d]=m.useState(""),[l,r]=m.useState("all"),[i,h]=m.useState(null),[x,o]=m.useState($e),[u,v]=m.useState("name"),[p,b]=m.useState("asc"),[z,I]=m.useState(null),w=K({queryKey:["agents"],queryFn:async()=>{const a=await fetch(`${B}/agents`);if(!a.ok)throw new Error("Failed to fetch agents");return(await a.json()).data},staleTime:3e4,refetchInterval:1e4,retry:1}),L=K({queryKey:["teams"],queryFn:async()=>{const a=await fetch(`${B}/teams`);if(!a.ok)throw new Error("Failed to fetch teams");return(await a.json()).data},staleTime:6e4,retry:1}),A=je({mutationFn:async a=>{if(I(a),!(await fetch(`${B}/agents/${a}`,{method:"DELETE"})).ok)throw new Error("Failed to remove agent")},onSuccess:()=>{s.invalidateQueries({queryKey:["agents"]}),Q.success("Agent removed")},onError:()=>{Q.error("Failed to remove agent")},onSettled:()=>{I(null)}}),n=m.useCallback(a=>{o(a);try{localStorage.setItem(te,a)}catch{}},[]),le=m.useCallback(a=>{a===u?b(c=>c==="asc"?"desc":"asc"):(v(a),b("asc"))},[u]),M=m.useMemo(()=>{let a=w.data??[];if(t){const c=t.toLowerCase();a=a.filter(g=>g.displayName.toLowerCase().includes(c)||g.name.toLowerCase().includes(c))}return l!=="all"&&(a=a.filter(c=>c.status===l)),i&&(a=a.filter(c=>{var g,j;return(j=(g=c.agentCard)==null?void 0:g.teams)==null?void 0:j.some(k=>k===i)})),a=[...a].sort((c,g)=>{let j=0;switch(u){case"name":j=c.displayName.localeCompare(g.displayName);break;case"status":{const k={online:0,busy:1,idle:2,offline:3};j=(k[c.status]??9)-(k[g.status]??9);break}case"lastSeen":{const k=c.lastHeartbeat?new Date(c.lastHeartbeat).getTime():0;j=(g.lastHeartbeat?new Date(g.lastHeartbeat).getTime():0)-k;break}}return p==="asc"?j:-j}),a},[w.data,t,l,i,u,p]),V=((U=w.data)==null?void 0:U.length)??0;return w.isLoading?e.jsx(Re,{}):e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Monitor and manage your AI agents across the swarm"})]}),e.jsx(Ae,{search:t,onSearchChange:d,statusFilter:l,onStatusFilterChange:r,teamFilter:i,onTeamFilterChange:h,viewMode:x,onViewModeChange:n,sortField:u,sortDirection:p,onSortChange:le,teams:L.data??[],totalCount:V,filteredCount:M.length}),V===0?e.jsx(He,{}):M.length===0?e.jsx(Oe,{onClear:()=>{d(""),r("all"),h(null)}}):x==="table"?e.jsx(Me,{agents:M,onDelete:a=>A.mutate(a),deletingId:z}):e.jsx(P.div,{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.05}}},children:M.map(a=>e.jsx(P.div,{variants:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:{duration:.25}}},children:e.jsx(Ee,{agent:a,onDelete:c=>A.mutate(c),isDeleting:z===a.id})},a.id))})]})}function He(){return e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/60 py-20",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:e.jsx(ge,{className:"size-8 text-muted-foreground"})}),e.jsx("h2",{className:"mt-5 text-lg font-semibold",children:"No agents registered"}),e.jsx("p",{className:"mt-1.5 max-w-sm text-center text-sm text-muted-foreground",children:"Agents self-register when they connect to the swarm. Start an agent with the SDK or CLI to see it appear here."}),e.jsx("div",{className:"mt-6 rounded-lg bg-muted/60 px-4 py-3",children:e.jsx("code",{className:"font-mono text-xs text-muted-foreground",children:"npx @swarmroom/cli agent start"})})]})}function Oe({onClear:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents match your filters."}),e.jsx("button",{onClick:s,className:"mt-2 text-sm font-medium text-primary hover:underline",children:"Clear filters"})]})}function Re(){return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{children:[e.jsx(C,{className:"h-8 w-32"}),e.jsx(C,{className:"mt-2 h-4 w-64"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{className:"h-9 w-48"}),e.jsx(C,{className:"h-8 w-24"}),e.jsx(C,{className:"h-8 w-24"})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",children:Array.from({length:6}).map((s,t)=>e.jsx(C,{className:"h-48 rounded-xl"},t))})]})}function Ge(){return e.jsx(fe,{featureName:"Agents",children:e.jsx(Fe,{})})}export{Ge as component};
@@ -0,0 +1,6 @@
1
+ import{c as R,u as C,j as e,U as B,A as y,n as k,r as p,t as j,D as S,d as P,e as F,f as E,g as A,S as G,b as h,p as _,o as D,m as O,F as J}from"./index-DqvmWes8.js";import{B as Q,S as b,E as W}from"./error-boundary-GFV_5F1L.js";import{C as H,a as V}from"./card-B896vjxa.js";import{A as X,a as q,b as $,c as Y}from"./avatar-B_Cqbi60.js";import{t as M,g as T,a as I,s as w,T as Z}from"./utils-AH9TuImk.js";import{E as U}from"./external-link-skx4o5wJ.js";import{u as v}from"./useMutation-BhJRnGsH.js";import{I as N}from"./input-BROwVVEx.js";import{S as ee}from"./scroll-area-C4F6zoWB.js";import{A as se}from"./arrow-left-u9wxRsmJ.js";import{P as te,U as re}from"./user-minus-SI0czWZH.js";import{P as L}from"./plus-Bq20n-_S.js";/**
2
+ * @license lucide-react v0.400.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const K=R("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);function ae(s){const l=["#0ea5e9","#6366f1","#8b5cf6","#ec4899","#f97316","#10b981","#14b8a6","#f43f5e","#84cc16","#eab308","#06b6d4","#3b82f6"];let o=0;for(let c=0;c<s.length;c++)o=s.charCodeAt(c)+((o<<5)-o);return l[Math.abs(o)%l.length]}function ne({project:s,onClick:l}){const o=ae(s.name),d=(C({queryKey:["agents"],queryFn:async()=>{const a=await fetch(`${y}/agents`);if(!a.ok)throw new Error("Failed to fetch agents");return(await a.json()).data},staleTime:3e4,retry:1}).data??[]).filter(a=>s.agentIds.includes(a.id)),m=d.slice(0,5),x=d.length-5;return e.jsxs(H,{className:"group relative cursor-pointer gap-0 overflow-hidden py-0 transition-all duration-200 hover:shadow-md hover:-translate-y-0.5",onClick:l,children:[e.jsx("div",{className:"h-1.5 w-full",style:{background:`linear-gradient(90deg, ${o}, ${o}44)`}}),e.jsxs(V,{className:"flex flex-col gap-3.5 p-5",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-xs font-bold text-white",style:{backgroundColor:o},children:s.name.charAt(0).toUpperCase()}),e.jsx("h3",{className:"truncate text-sm font-semibold leading-tight text-foreground",children:s.name})]}),s.description&&e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground leading-relaxed",children:s.description})]})}),s.repository&&e.jsxs("a",{href:s.repository,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[e.jsx(K,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:M(s.repository)}),e.jsx(U,{className:"ml-auto size-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-100"})]}),e.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border/50 pt-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:m.length>0?e.jsxs(X,{children:[m.map(a=>e.jsx(q,{size:"sm",children:e.jsx($,{className:"text-[9px] font-semibold text-white",style:{backgroundColor:I(a.displayName)},children:T(a.displayName)})},a.id)),x>0&&e.jsxs(Y,{className:"text-[10px]",children:["+",x]})]}):null}),e.jsxs(Q,{variant:"secondary",className:"text-[10px] gap-1",children:[e.jsx(B,{className:"size-3"}),s.agentIds.length]})]})]})]})}function ie({projectId:s,existingAgentIds:l,open:o,onOpenChange:c}){const d=k(),[m,x]=p.useState(""),a=C({queryKey:["agents"],queryFn:async()=>{const r=await fetch(`${y}/agents`);if(!r.ok)throw new Error("Failed to fetch agents");return(await r.json()).data},staleTime:3e4,retry:1}),i=v({mutationFn:async r=>{if(!(await fetch(`${y}/projects/${s}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:r})})).ok)throw new Error("Failed to add agent")},onSuccess:()=>{d.invalidateQueries({queryKey:["projects"]}),j.success("Agent added to project")},onError:()=>{j.error("Failed to add agent")}}),f=p.useMemo(()=>{const u=(a.data??[]).filter(n=>!l.includes(n.id));if(!m)return u;const t=m.toLowerCase();return u.filter(n=>n.displayName.toLowerCase().includes(t)||n.name.toLowerCase().includes(t))},[a.data,l,m]);return e.jsx(S,{open:o,onOpenChange:c,children:e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsx(E,{children:"Add agent"}),e.jsx(A,{children:"Select an agent to add to this project."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(G,{className:"absolute top-2.5 left-3 size-4 text-muted-foreground"}),e.jsx(N,{value:m,onChange:r=>x(r.target.value),placeholder:"Search agents…",className:"pl-9"})]}),e.jsx(ee,{className:"max-h-64",children:f.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:a.isLoading?"Loading agents…":"No available agents found"}):e.jsx("div",{className:"flex flex-col gap-1",children:f.map(r=>{const u=w[r.status]??w.offline;return e.jsxs("button",{type:"button",onClick:()=>{i.mutate(r.id),c(!1),x("")},disabled:i.isPending,className:"flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-accent disabled:opacity-50",children:[e.jsx(q,{size:"sm",children:e.jsx($,{className:"text-[9px] font-semibold text-white",style:{backgroundColor:I(r.displayName)},children:T(r.displayName)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:r.name})]}),e.jsx("span",{className:`size-2 shrink-0 rounded-full ${u.dot}`,title:u.label})]},r.id)})})})]})})}function oe({project:s,onBack:l}){const o=k(),[c,d]=p.useState(!1),[m,x]=p.useState(!1),[a,i]=p.useState(!1),f=C({queryKey:["agents"],queryFn:async()=>{const n=await fetch(`${y}/agents`);if(!n.ok)throw new Error("Failed to fetch agents");return(await n.json()).data},staleTime:3e4,refetchInterval:1e4,retry:1}),r=v({mutationFn:async n=>{if(!(await fetch(`${y}/projects/${s.id}/agents/${n}`,{method:"DELETE"})).ok)throw new Error("Failed to remove agent")},onSuccess:()=>{o.invalidateQueries({queryKey:["projects"]}),j.success("Agent removed from project")},onError:()=>{j.error("Failed to remove agent")}}),u=v({mutationFn:async()=>{if(!(await fetch(`${y}/projects/${s.id}`,{method:"DELETE"})).ok)throw new Error("Failed to delete project")},onSuccess:()=>{o.invalidateQueries({queryKey:["projects"]}),j.success("Project deleted"),l()},onError:()=>{j.error("Failed to delete project")}}),t=(f.data??[]).filter(n=>s.agentIds.includes(n.id));return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground w-fit",children:[e.jsx(se,{className:"size-4"}),"Back to projects"]}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s.name}),s.description&&e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:s.description}),s.repository&&e.jsxs("a",{href:s.repository,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(K,{className:"size-3.5"}),e.jsx("span",{children:M(s.repository,48)}),e.jsx(U,{className:"size-3"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[e.jsx(te,{className:"size-3.5"}),"Edit"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-destructive hover:bg-destructive/10",onClick:()=>i(!0),children:[e.jsx(Z,{className:"size-3.5"}),"Delete"]})]})]}),e.jsx(_,{}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Members"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.length," agent",t.length!==1?"s":""," ","assigned to this project"]})]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>d(!0),children:[e.jsx(L,{className:"size-3.5"}),"Add Agent"]})]}),t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/60 py-12",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents assigned yet"}),e.jsx(h,{size:"sm",variant:"link",className:"mt-1",onClick:()=>d(!0),children:"Add your first agent"})]}):e.jsx("div",{className:"grid gap-2",children:t.map(n=>{const g=w[n.status]??w.offline;return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 px-4 py-3 transition-colors hover:bg-muted/30",children:[e.jsx(q,{children:e.jsx($,{className:"text-xs font-semibold text-white",style:{backgroundColor:I(n.displayName)},children:T(n.displayName)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:n.displayName}),e.jsx("span",{className:`size-2 shrink-0 rounded-full ${g.dot}`,title:g.label})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.name})]}),e.jsx(Q,{variant:g.variant,className:"text-[10px]",children:g.label}),e.jsx(h,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive",onClick:()=>r.mutate(n.id),disabled:r.isPending,children:e.jsx(re,{className:"size-3.5"})})]},n.id)})})]}),e.jsx(ie,{projectId:s.id,existingAgentIds:s.agentIds,open:c,onOpenChange:d}),e.jsx(le,{project:s,open:m,onOpenChange:x}),e.jsx(S,{open:a,onOpenChange:i,children:e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsx(E,{children:"Delete project"}),e.jsxs(A,{children:["This will permanently delete"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.name}),". This action cannot be undone."]})]}),e.jsxs(D,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:u.isPending,children:"Cancel"}),e.jsx(h,{variant:"destructive",onClick:()=>u.mutate(),disabled:u.isPending,children:u.isPending?"Deleting…":"Delete"})]})]})})]})}function le({project:s,open:l,onOpenChange:o}){const c=k(),[d,m]=p.useState(s.name),[x,a]=p.useState(s.description??""),[i,f]=p.useState(s.repository??""),r=v({mutationFn:async()=>{const t={name:d};if(x.trim()?t.description=x.trim():t.description="",i.trim()?t.repository=i.trim():t.repository="",!(await fetch(`${y}/projects/${s.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)throw new Error("Failed to update project")},onSuccess:()=>{c.invalidateQueries({queryKey:["projects"]}),j.success("Project updated"),o(!1)},onError:()=>{j.error("Failed to update project")}});function u(t){t.preventDefault(),d.trim()&&r.mutate()}return e.jsx(S,{open:l,onOpenChange:o,children:e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsx(E,{children:"Edit project"}),e.jsx(A,{children:"Update your project details."})]}),e.jsxs("form",{onSubmit:u,className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:"edit-name",className:"text-sm font-medium",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(N,{id:"edit-name",value:d,onChange:t=>m(t.target.value),required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"edit-description",className:"text-sm font-medium",children:"Description"}),e.jsx(N,{id:"edit-description",value:x,onChange:t=>a(t.target.value),placeholder:"What this project is about"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"edit-repository",className:"text-sm font-medium",children:"Repository URL"}),e.jsx(N,{id:"edit-repository",value:i,onChange:t=>f(t.target.value),placeholder:"https://github.com/org/repo",type:"url"})]}),e.jsxs(D,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>o(!1),disabled:r.isPending,children:"Cancel"}),e.jsx(h,{type:"submit",disabled:!d.trim()||r.isPending,children:r.isPending?"Saving…":"Save"})]})]})]})})}function ce({open:s,onOpenChange:l}){const o=k(),[c,d]=p.useState(""),[m,x]=p.useState(""),[a,i]=p.useState(""),f=v({mutationFn:async()=>{var g;const t={name:c};m.trim()&&(t.description=m.trim()),a.trim()&&(t.repository=a.trim());const n=await fetch(`${y}/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const z=await n.json().catch(()=>null);throw new Error(((g=z==null?void 0:z.error)==null?void 0:g.message)??"Failed to create project")}},onSuccess:()=>{o.invalidateQueries({queryKey:["projects"]}),j.success("Project created"),r()},onError:t=>{j.error(t.message)}});function r(){d(""),x(""),i(""),l(!1)}function u(t){t.preventDefault(),c.trim()&&f.mutate()}return e.jsx(S,{open:s,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(F,{children:[e.jsx(E,{children:"Create project"}),e.jsx(A,{children:"Group agents around a shared codebase or goal."})]}),e.jsxs("form",{onSubmit:u,className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:"project-name",className:"text-sm font-medium",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(N,{id:"project-name",value:c,onChange:t=>d(t.target.value),placeholder:"e.g. swarm-room",required:!0,autoFocus:!0})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"project-description",className:"text-sm font-medium",children:"Description"}),e.jsx(N,{id:"project-description",value:m,onChange:t=>x(t.target.value),placeholder:"What this project is about"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"project-repository",className:"text-sm font-medium",children:"Repository URL"}),e.jsx(N,{id:"project-repository",value:a,onChange:t=>i(t.target.value),placeholder:"https://github.com/org/repo",type:"url"})]}),e.jsxs(D,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:r,disabled:f.isPending,children:"Cancel"}),e.jsx(h,{type:"submit",disabled:!c.trim()||f.isPending,children:f.isPending?"Creating…":"Create"})]})]})]})})}function de(){var a;const[s,l]=p.useState(null),[o,c]=p.useState(!1),d=C({queryKey:["projects"],queryFn:async()=>{const i=await fetch(`${y}/projects`);if(!i.ok)throw new Error("Failed to fetch projects");return(await i.json()).data},staleTime:3e4,refetchInterval:1e4,retry:1}),m=(a=d.data)==null?void 0:a.find(i=>i.id===s);if(d.isLoading)return e.jsx(xe,{});if(m)return e.jsx(oe,{project:m,onBack:()=>l(null)});const x=d.data??[];return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Projects"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Organize agents into project workspaces with linked repositories"})]}),e.jsxs(h,{onClick:()=>c(!0),size:"sm",children:[e.jsx(L,{className:"size-4"}),"New Project"]})]}),x.length===0?e.jsx(me,{onCreateClick:()=>c(!0)}):e.jsx(O.div,{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.05}}},children:x.map(i=>e.jsx(O.div,{variants:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:{duration:.25}}},children:e.jsx(ne,{project:i,onClick:()=>l(i.id)})},i.id))}),e.jsx(ce,{open:o,onOpenChange:c})]})}function me({onCreateClick:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-border/60 py-20",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:e.jsx(J,{className:"size-8 text-muted-foreground"})}),e.jsx("h2",{className:"mt-5 text-lg font-semibold",children:"No projects yet"}),e.jsx("p",{className:"mt-1.5 max-w-sm text-center text-sm text-muted-foreground",children:"Create a project to group agents around a shared codebase or goal. Link a repository and assign team members."}),e.jsxs(h,{className:"mt-6",size:"sm",onClick:s,children:[e.jsx(L,{className:"size-4"}),"Create your first project"]})]})}function xe(){return e.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{className:"h-8 w-36"}),e.jsx(b,{className:"mt-2 h-4 w-72"})]}),e.jsx(b,{className:"h-8 w-28"})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((s,l)=>e.jsx(b,{className:"h-52 rounded-xl"},l))})]})}function ke(){return e.jsx(W,{featureName:"Projects",children:e.jsx(de,{})})}export{ke as component};