heyio 1.4.0 → 1.4.2

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 (37) hide show
  1. package/README.md +2 -2
  2. package/dist/api/server.js +37 -9
  3. package/dist/copilot/agents.js +47 -3
  4. package/dist/copilot/squad-tools.js +55 -1
  5. package/dist/store/instances.js +4 -0
  6. package/package.json +1 -1
  7. package/web-dist/assets/{AuditLogView-DqxVzjd_.js → AuditLogView-eyz02XQx.js} +2 -2
  8. package/web-dist/assets/{ChatView-BBopM_A3.js → ChatView-DXpE1NMj.js} +1 -1
  9. package/web-dist/assets/{FeedView-Bo4p1stx.js → FeedView-Clis71Lg.js} +2 -2
  10. package/web-dist/assets/HistoryView-B1EJ2Q9S.js +1 -0
  11. package/web-dist/assets/LoginView-bg8Sl_Gw.js +1 -0
  12. package/web-dist/assets/McpView-CBepc2JJ.js +1 -0
  13. package/web-dist/assets/{SchedulesView-B2o3vMm-.js → SchedulesView-DDFUUMPG.js} +2 -2
  14. package/web-dist/assets/SettingsView-BFfDRToB.js +1 -0
  15. package/web-dist/assets/{SkillsView-D_NHLk7C.js → SkillsView-Dv-337Yq.js} +4 -4
  16. package/web-dist/assets/{SquadDetailView-BKXLWvwn.js → SquadDetailView-p4c6XQ5a.js} +2 -2
  17. package/web-dist/assets/SquadHealthView-IjOdIla7.js +11 -0
  18. package/web-dist/assets/SquadsView-C5wQPkBA.js +6 -0
  19. package/web-dist/assets/{UsageView-Cy5Mbprb.js → UsageView-BcHfPX-N.js} +2 -2
  20. package/web-dist/assets/{WikiView-B5TOMnOg.js → WikiView-CKBw5FOf.js} +2 -2
  21. package/web-dist/assets/api-DPUP4xY9.js +1 -0
  22. package/web-dist/assets/{arrow-left-CGMB1w_A.js → arrow-left-BMJZvMdZ.js} +1 -1
  23. package/web-dist/assets/{git-branch-C_Hu39uh.js → git-branch-BF40208L.js} +1 -1
  24. package/web-dist/assets/{index-CiZnRvN4.js → index-DSAUDIwK.js} +63 -62
  25. package/web-dist/assets/{plus-DIBAaEMT.js → plus-aHVgAXQB.js} +1 -1
  26. package/web-dist/assets/{save-Chqlu7QA.js → save-jn5LGsCv.js} +1 -1
  27. package/web-dist/assets/{search-Cl8HcIsG.js → search-DUqJxRNn.js} +1 -1
  28. package/web-dist/assets/{trash-2-CQSzbVIr.js → trash-2-B9ibnt3n.js} +1 -1
  29. package/web-dist/assets/{triangle-alert-C1OjMvP5.js → triangle-alert-Cindqw1C.js} +1 -1
  30. package/web-dist/assets/{x-DThJHYFm.js → x-BDIsved4.js} +1 -1
  31. package/web-dist/index.html +1 -1
  32. package/web-dist/assets/HistoryView-ChTuQvXr.js +0 -1
  33. package/web-dist/assets/LoginView-AnOP3Mau.js +0 -1
  34. package/web-dist/assets/McpView-DPcihjuB.js +0 -1
  35. package/web-dist/assets/SettingsView-rtMUmH43.js +0 -1
  36. package/web-dist/assets/SquadHealthView-CVJiAgVW.js +0 -11
  37. package/web-dist/assets/SquadsView-fammrB7r.js +0 -6
@@ -1,4 +1,4 @@
1
- import{q as A,t as O,W as V,x as j,u as E,y as G,z as s,o,l as t,s as p,K as c,A as z,v as _,J as i,d as B,r as h,n as v,m as I,F as C,E as D,f as R,D as m,k as H,h as F,p as U,i as P,X,w as W,O as Z,G as K,U as Q,g as Y}from"./index-CiZnRvN4.js";import{g as ee}from"./squad-colors-B8B_Y-lz.js";import{X as te}from"./x-DThJHYFm.js";import{G as se}from"./git-branch-C_Hu39uh.js";import{T as oe}from"./trash-2-CQSzbVIr.js";import{A as re}from"./arrow-left-CGMB1w_A.js";/**
1
+ import{l as A,o as J,Q as V,s as z,p as R,t as H,u as s,k as o,h as t,n as p,D as c,A as B,q as _,z as i,d as F,m as h,j as v,i as I,F as C,w as D,f as E,v as m,g as G,R as U,r as Q,J as X,x as Z,U as W}from"./index-DSAUDIwK.js";import{b as O,e as K,c as P,a as Y}from"./api-DPUP4xY9.js";import{g as ee}from"./squad-colors-B8B_Y-lz.js";import{X as te}from"./x-BDIsved4.js";import{G as se}from"./git-branch-BF40208L.js";import{T as oe}from"./trash-2-B9ibnt3n.js";import{A as re}from"./arrow-left-BMJZvMdZ.js";/**
2
2
  * @license lucide-vue-next v0.474.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -23,4 +23,4 @@ import{q as A,t as O,W as V,x as j,u as E,y as G,z as s,o,l as t,s as p,K as c,A
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const de=A("ToggleRightIcon",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]),ue={class:"flex flex-col h-full border border-border rounded-lg overflow-hidden bg-background"},ce={class:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30"},pe={class:"flex items-center gap-2 min-w-0"},me={class:"flex items-center gap-2"},xe=["disabled"],fe=["aria-label","title"],ge={class:"px-4 py-2 text-xs text-muted-foreground border-b border-border bg-muted/10 truncate"},ye={key:0,class:"text-muted-foreground text-xs"},be={key:1,class:"text-muted-foreground text-xs"},ve={class:"flex items-center justify-between mb-1"},he={class:"text-xs font-medium text-muted-foreground uppercase tracking-wide"},we={class:"text-xs text-muted-foreground"},_e={key:0,class:"text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap break-all"},ke={key:1},Se={key:1,class:"text-sm"},$e={key:2,class:"border border-border border-l-2 border-l-yellow-500 rounded-lg p-3 animate-pulse"},Te={key:0,class:"text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap break-all"},Ce=O({__name:"AgentActivityPreview",props:{taskId:{},taskDescription:{},taskStatus:{}},emits:["close","stopped"],setup(f,{emit:M}){const x=f,S=M,w=m([]),u=m(!1),$=m(!0),g=m(!1),y=m();let d=null;const N=H(()=>w.value.filter(l=>l.summary.trim()!=="")),b=m("");async function k(){try{const l=await F(`/tasks/${x.taskId}/events`);w.value=l}finally{$.value=!1}}function T(){y.value&&(y.value.scrollTop=y.value.scrollHeight)}function q(){x.taskStatus!=="pending"&&x.taskStatus!=="in_progress"||(d=U(),d.addEventListener("agent_event",l=>{const e=JSON.parse(l.data);e.taskId===x.taskId&&(e.type==="message_delta"?(b.value=e.summary??"",E(T)):(k().then(()=>E(T)),b.value=""))}))}async function L(){if(!g.value){g.value=!0;try{await P(`/tasks/${x.taskId}/stop`),S("stopped")}catch(l){console.error("Failed to stop agent:",l)}finally{g.value=!1}}}function a(l){switch(l){case"status":return"Status";case"message":return"Agent message";case"message_delta":return"Streaming…";default:return l}}function r(l){return new Date(l).toLocaleTimeString()}return V(()=>x.taskStatus,l=>{(l==="done"||l==="failed"||l==="stopped")&&(b.value="",k(),d&&(d.close(),d=null))}),j(()=>{k().then(()=>E(T)),q()}),G(()=>{d&&(d.close(),d=null)}),(l,e)=>(s(),o("div",ue,[t("div",ce,[t("div",pe,[p(c(z),{class:"w-4 h-4 text-primary flex-shrink-0"}),e[2]||(e[2]=t("h3",{class:"text-sm font-semibold truncate"},"Activity Preview",-1)),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full flex-shrink-0",{"bg-yellow-500/10 text-yellow-500":f.taskStatus==="pending","bg-blue-500/10 text-blue-500":f.taskStatus==="in_progress","bg-green-500/10 text-green-500":f.taskStatus==="done","bg-red-500/10 text-red-500":f.taskStatus==="failed","bg-orange-500/10 text-orange-500":f.taskStatus==="stopped"}])},i(f.taskStatus),3)]),t("div",me,[f.taskStatus==="pending"||f.taskStatus==="in_progress"?(s(),o("button",{key:0,onClick:L,disabled:g.value,class:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-red-500/50 text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Stop agent",title:"Stop agent"},[p(c(B),{class:"w-3 h-3"}),h(" "+i(g.value?"Stopping…":"Stop"),1)],8,xe)):v("",!0),t("button",{onClick:e[0]||(e[0]=n=>u.value=!u.value),class:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors","aria-label":u.value?"Switch to human-readable view":"Switch to raw JSON view",title:u.value?"Switch to human-readable view":"Switch to raw JSON view"},[u.value?(s(),I(c(de),{key:1,class:"w-4 h-4 text-primary"})):(s(),I(c(ie),{key:0,class:"w-4 h-4"})),t("span",null,i(u.value?"Raw JSON":"Readable"),1)],8,fe),t("button",{onClick:e[1]||(e[1]=n=>S("close")),class:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close preview",title:"Close preview"},[p(c(te),{class:"w-4 h-4"})])])]),t("div",ge,i(f.taskDescription),1),t("div",{ref_key:"feedContainer",ref:y,class:"flex-1 overflow-y-auto p-4 space-y-3 text-sm"},[$.value?(s(),o("div",ye,"Loading events…")):N.value.length===0&&!b.value?(s(),o("div",be," No events yet. The agent will start shortly. ")):v("",!0),(s(!0),o(C,null,D(N.value,n=>(s(),o("div",{key:n.id,class:_(["border border-border rounded-lg p-3",{"border-l-2 border-l-green-500":n.type==="status"&&n.summary.includes("completed"),"border-l-2 border-l-red-500":n.type==="status"&&n.summary.includes("failed"),"border-l-2 border-l-blue-500":n.type==="message","border-l-2 border-l-primary":n.type==="status"&&!n.summary.includes("completed")&&!n.summary.includes("failed")}])},[t("div",ve,[t("span",he,i(a(n.type)),1),t("span",we,i(r(n.created_at)),1)]),u.value?(s(),o("pre",_e,i(JSON.stringify(JSON.parse(n.payload),null,2)),1)):(s(),o("div",ke,[n.type==="message"?(s(),I(R,{key:0,content:n.summary,class:"text-sm"},null,8,["content"])):(s(),o("p",Se,i(n.summary),1))]))],2))),128)),b.value.trim()?(s(),o("div",$e,[e[3]||(e[3]=t("div",{class:"flex items-center justify-between mb-1"},[t("span",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wide"}," Agent is responding… "),t("span",{class:"inline-block w-2 h-2 rounded-full bg-yellow-500 animate-ping"})],-1)),u.value?(s(),o("pre",Te,i(JSON.stringify({type:"message_delta",accumulated:b.value},null,2)),1)):(s(),I(R,{key:1,content:b.value,class:"text-sm"},null,8,["content"]))])):v("",!0)],512)]))}}),Ae={class:"p-6"},Ne={key:0,class:"text-muted-foreground"},Ie={class:"mb-6"},De={class:"text-muted-foreground"},Me={class:"mb-8"},qe={class:"border border-border rounded-lg overflow-hidden"},Le={class:"w-full text-sm"},Ee={class:"px-4 py-2 font-medium"},Re={class:"px-4 py-2 text-muted-foreground"},Je={class:"px-4 py-2"},Oe={class:"px-4 py-2 flex gap-1"},je={key:0,class:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded"},ze={key:1,class:"text-xs bg-blue-500/10 text-blue-500 px-1.5 py-0.5 rounded"},Be={key:2,class:"text-xs bg-purple-500/10 text-purple-500 px-1.5 py-0.5 rounded"},Fe={class:"mb-8"},Pe={class:"flex items-center justify-between mb-3"},Ve={key:0,class:"text-sm text-muted-foreground border border-border rounded-lg p-4 text-center"},Ge={key:1,class:"grid grid-cols-1 md:grid-cols-3 gap-3"},He={class:"flex items-center justify-between gap-2"},Ue={class:"flex items-center gap-1.5 min-w-0"},Xe={class:"text-sm font-medium truncate"},We={class:"flex items-center gap-1 text-xs text-muted-foreground"},Ze=["title"],Ke={class:"pt-1 border-t border-border"},Qe=["disabled","onClick"],Ye={key:0,class:"text-sm text-muted-foreground"},et={key:1,class:"space-y-2"},tt={class:"flex items-center justify-between"},st={class:"text-sm"},ot={class:"flex items-center gap-2"},rt=["onClick","disabled"],at=["onClick","aria-label","title"],lt={key:0,class:"mt-3 h-96"},J=3,mt=O({__name:"SquadDetailView",setup(f){const M=Z(),x=m(null),S=m([]),w=m([]),u=m([]),$=m(!0),g=m(null),y=m(null),d=m(null);function N(a){d.value=a}function b(){d.value=null}function k(a){return a==="pending"||a==="in_progress"}async function T(a){if(!y.value){y.value=a;try{await P(`/tasks/${a}/stop`);const r=w.value.find(l=>l.id===a);r&&(r.status="stopped")}catch(r){console.error("Failed to stop task:",r)}finally{y.value=null}}}j(async()=>{try{const a=await F(`/squads/${M.params.id}`);x.value=a.squad,S.value=a.agents,w.value=a.tasks,u.value=a.instances}finally{$.value=!1}});async function q(a,r){if(confirm(`Destroy instance on branch "${r}"? This will remove the worktree.`)){g.value=a;try{await Y(`/instances/${a}`),u.value=u.value.filter(l=>l.id!==a)}finally{g.value=null}}}function L(a){if(!a)return"never";const r=a.replace(" ","T")+(a.includes("T")||a.endsWith("Z")?"":"Z"),l=Date.now()-new Date(r).getTime(),e=Math.floor(l/6e4);if(e<1)return"just now";if(e<60)return`${e}m ago`;const n=Math.floor(e/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}return(a,r)=>{const l=K("router-link");return s(),o("div",Ae,[p(l,{to:"/squads",class:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground mb-4"},{default:X(()=>[p(c(re),{class:"w-4 h-4"}),r[0]||(r[0]=h(" Back to Squads ",-1))]),_:1}),$.value?(s(),o("div",Ne,"Loading...")):x.value?(s(),o(C,{key:1},[t("div",Ie,[t("span",{class:"inline-flex items-center text-sm px-2.5 py-1 rounded-full font-medium mb-2 w-fit",style:W(c(ee)(x.value.color))},i(x.value.name),5),t("p",De,i(x.value.universe),1)]),t("section",Me,[r[5]||(r[5]=t("h2",{class:"text-lg font-semibold mb-3"},"Agent Roster",-1)),t("div",qe,[t("table",Le,[r[4]||(r[4]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Character"),t("th",{class:"text-left px-4 py-2 font-medium"},"Role"),t("th",{class:"text-left px-4 py-2 font-medium"},"Status"),t("th",{class:"text-left px-4 py-2 font-medium"},"Flags")])],-1)),t("tbody",null,[(s(!0),o(C,null,D(S.value,e=>(s(),o("tr",{key:e.id,class:"border-t border-border"},[t("td",Ee,i(e.character_name),1),t("td",Re,i(e.role_title),1),t("td",Je,[t("span",{class:_(["inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full",{"bg-green-500/10 text-green-500":e.status==="idle","bg-yellow-500/10 text-yellow-500":e.status==="working","bg-blue-500/10 text-blue-500":e.status==="reviewing"}])},i(e.status),3)]),t("td",Oe,[e.is_lead?(s(),o("span",je,[p(c(Q),{class:"w-3 h-3 inline"}),r[1]||(r[1]=h(" Lead ",-1))])):v("",!0),e.is_qa?(s(),o("span",ze,[p(c(ne),{class:"w-3 h-3 inline"}),r[2]||(r[2]=h(" QA ",-1))])):v("",!0),e.is_test?(s(),o("span",Be,[p(c(le),{class:"w-3 h-3 inline"}),r[3]||(r[3]=h(" Test ",-1))])):v("",!0)])]))),128))])])])]),t("section",Fe,[t("div",Pe,[r[6]||(r[6]=t("h2",{class:"text-lg font-semibold"},"Instances",-1)),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full font-medium",u.value.length>=J?"bg-red-500/10 text-red-500":"bg-secondary text-secondary-foreground"])},i(u.value.length)+" / "+i(J)+" active ",3)]),u.value.length===0?(s(),o("div",Ve," No active instances. ")):(s(),o("div",Ge,[(s(!0),o(C,null,D(u.value,e=>(s(),o("div",{key:e.id,class:"border border-border rounded-lg p-3 flex flex-col gap-2"},[t("div",He,[t("div",Ue,[p(c(se),{class:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),t("span",Xe,i(e.branch),1)]),t("span",{class:_(["text-xs px-1.5 py-0.5 rounded-full shrink-0",{"bg-green-500/10 text-green-500":e.status==="active","bg-red-500/10 text-red-500":e.status==="destroyed","bg-yellow-500/10 text-yellow-500":e.status==="stale"}])},i(e.status),3)]),t("div",We,[p(c(z),{class:"w-3 h-3 shrink-0"}),t("span",null,i(L(e.last_activity)),1)]),t("div",{class:"font-mono text-xs text-muted-foreground truncate",title:e.worktree_path},i(e.worktree_path),9,Ze),t("div",Ke,[t("button",{class:"inline-flex items-center gap-1 text-xs text-red-500 hover:text-red-400 disabled:opacity-50 disabled:cursor-not-allowed",disabled:g.value===e.id,onClick:n=>q(e.id,e.branch)},[p(c(oe),{class:"w-3 h-3"}),h(" "+i(g.value===e.id?"Destroying…":"Destroy"),1)],8,Qe)])]))),128))]))]),t("section",null,[r[8]||(r[8]=t("h2",{class:"text-lg font-semibold mb-3"},"Recent Tasks",-1)),w.value.length===0?(s(),o("div",Ye,"No tasks yet.")):(s(),o("div",et,[(s(!0),o(C,null,D(w.value,e=>(s(),o("div",{key:e.id,class:"border border-border rounded-lg p-3"},[t("div",tt,[t("span",st,i(e.description),1),t("div",ot,[k(e.status)?(s(),o("button",{key:0,onClick:n=>T(e.id),disabled:y.value===e.id,class:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded border border-red-500/50 text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Stop agent",title:"Stop agent"},[p(c(B),{class:"w-3 h-3"}),h(" "+i(y.value===e.id?"Stopping…":"Stop"),1)],8,rt)):v("",!0),k(e.status)||d.value===e.id?(s(),o("button",{key:1,onClick:n=>d.value===e.id?b():N(e.id),class:_(["inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors",d.value===e.id?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:text-foreground hover:border-foreground"]),"aria-label":d.value===e.id?"Hide activity preview":"Show activity preview",title:d.value===e.id?"Hide preview":"Preview activity"},[p(c(ae),{class:"w-3 h-3"}),r[7]||(r[7]=h(" Preview ",-1))],10,at)):v("",!0),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full",{"bg-yellow-500/10 text-yellow-500":e.status==="pending","bg-blue-500/10 text-blue-500":e.status==="in_progress","bg-green-500/10 text-green-500":e.status==="done","bg-red-500/10 text-red-500":e.status==="failed","bg-orange-500/10 text-orange-500":e.status==="stopped"}])},i(e.status),3)])]),d.value===e.id?(s(),o("div",lt,[p(Ce,{"task-id":e.id,"task-description":e.description,"task-status":e.status,onClose:b,onStopped:n=>e.status="stopped"},null,8,["task-id","task-description","task-status","onStopped"])])):v("",!0)]))),128))]))])],64)):v("",!0)])}}});export{mt as default};
26
+ */const de=A("ToggleRightIcon",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]),ue={class:"flex flex-col h-full border border-border rounded-lg overflow-hidden bg-background"},ce={class:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30"},pe={class:"flex items-center gap-2 min-w-0"},me={class:"flex items-center gap-2"},xe=["disabled"],fe=["aria-label","title"],ge={class:"px-4 py-2 text-xs text-muted-foreground border-b border-border bg-muted/10 truncate"},be={key:0,class:"text-muted-foreground text-xs"},ye={key:1,class:"text-muted-foreground text-xs"},ve={class:"flex items-center justify-between mb-1"},he={class:"text-xs font-medium text-muted-foreground uppercase tracking-wide"},we={class:"text-xs text-muted-foreground"},_e={key:0,class:"text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap break-all"},ke={key:1},Se={key:1,class:"text-sm"},$e={key:2,class:"border border-border border-l-2 border-l-yellow-500 rounded-lg p-3 animate-pulse"},Te={key:0,class:"text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap break-all"},Ce=J({__name:"AgentActivityPreview",props:{taskId:{},taskDescription:{},taskStatus:{}},emits:["close","stopped"],setup(f,{emit:M}){const x=f,S=M,w=m([]),u=m(!1),$=m(!0),g=m(!1),b=m();let d=null;const N=G(()=>w.value.filter(l=>l.summary.trim()!=="")),y=m("");async function k(){try{const l=await O(`/tasks/${x.taskId}/events`);w.value=l}finally{$.value=!1}}function T(){b.value&&(b.value.scrollTop=b.value.scrollHeight)}function q(){x.taskStatus!=="pending"&&x.taskStatus!=="in_progress"||(d=K(),d.addEventListener("agent_event",l=>{const e=JSON.parse(l.data);e.taskId===x.taskId&&(e.type==="message_delta"?(y.value=e.summary??"",R(T)):(k().then(()=>R(T)),y.value=""))}))}async function L(){if(!g.value){g.value=!0;try{await P(`/tasks/${x.taskId}/stop`),S("stopped")}catch(l){console.error("Failed to stop agent:",l)}finally{g.value=!1}}}function a(l){switch(l){case"status":return"Status";case"message":return"Agent message";case"message_delta":return"Streaming…";default:return l}}function r(l){return new Date(l).toLocaleTimeString()}return V(()=>x.taskStatus,l=>{(l==="done"||l==="failed"||l==="stopped")&&(y.value="",k(),d&&(d.close(),d=null))}),z(()=>{k().then(()=>R(T)),q()}),H(()=>{d&&(d.close(),d=null)}),(l,e)=>(s(),o("div",ue,[t("div",ce,[t("div",pe,[p(c(B),{class:"w-4 h-4 text-primary flex-shrink-0"}),e[2]||(e[2]=t("h3",{class:"text-sm font-semibold truncate"},"Activity Preview",-1)),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full flex-shrink-0",{"bg-yellow-500/10 text-yellow-500":f.taskStatus==="pending","bg-blue-500/10 text-blue-500":f.taskStatus==="in_progress","bg-green-500/10 text-green-500":f.taskStatus==="done","bg-red-500/10 text-red-500":f.taskStatus==="failed","bg-orange-500/10 text-orange-500":f.taskStatus==="stopped"}])},i(f.taskStatus),3)]),t("div",me,[f.taskStatus==="pending"||f.taskStatus==="in_progress"?(s(),o("button",{key:0,onClick:L,disabled:g.value,class:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-red-500/50 text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Stop agent",title:"Stop agent"},[p(c(F),{class:"w-3 h-3"}),h(" "+i(g.value?"Stopping…":"Stop"),1)],8,xe)):v("",!0),t("button",{onClick:e[0]||(e[0]=n=>u.value=!u.value),class:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors","aria-label":u.value?"Switch to human-readable view":"Switch to raw JSON view",title:u.value?"Switch to human-readable view":"Switch to raw JSON view"},[u.value?(s(),I(c(de),{key:1,class:"w-4 h-4 text-primary"})):(s(),I(c(ie),{key:0,class:"w-4 h-4"})),t("span",null,i(u.value?"Raw JSON":"Readable"),1)],8,fe),t("button",{onClick:e[1]||(e[1]=n=>S("close")),class:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close preview",title:"Close preview"},[p(c(te),{class:"w-4 h-4"})])])]),t("div",ge,i(f.taskDescription),1),t("div",{ref_key:"feedContainer",ref:b,class:"flex-1 overflow-y-auto p-4 space-y-3 text-sm"},[$.value?(s(),o("div",be,"Loading events…")):N.value.length===0&&!y.value?(s(),o("div",ye," No events yet. The agent will start shortly. ")):v("",!0),(s(!0),o(C,null,D(N.value,n=>(s(),o("div",{key:n.id,class:_(["border border-border rounded-lg p-3",{"border-l-2 border-l-green-500":n.type==="status"&&n.summary.includes("completed"),"border-l-2 border-l-red-500":n.type==="status"&&n.summary.includes("failed"),"border-l-2 border-l-blue-500":n.type==="message","border-l-2 border-l-primary":n.type==="status"&&!n.summary.includes("completed")&&!n.summary.includes("failed")}])},[t("div",ve,[t("span",he,i(a(n.type)),1),t("span",we,i(r(n.created_at)),1)]),u.value?(s(),o("pre",_e,i(JSON.stringify(JSON.parse(n.payload),null,2)),1)):(s(),o("div",ke,[n.type==="message"?(s(),I(E,{key:0,content:n.summary,class:"text-sm"},null,8,["content"])):(s(),o("p",Se,i(n.summary),1))]))],2))),128)),y.value.trim()?(s(),o("div",$e,[e[3]||(e[3]=t("div",{class:"flex items-center justify-between mb-1"},[t("span",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wide"}," Agent is responding… "),t("span",{class:"inline-block w-2 h-2 rounded-full bg-yellow-500 animate-ping"})],-1)),u.value?(s(),o("pre",Te,i(JSON.stringify({type:"message_delta",accumulated:y.value},null,2)),1)):(s(),I(E,{key:1,content:y.value,class:"text-sm"},null,8,["content"]))])):v("",!0)],512)]))}}),Ae={class:"p-6"},Ne={key:0,class:"text-muted-foreground"},Ie={class:"mb-6"},De={class:"text-muted-foreground"},Me={class:"mb-8"},qe={class:"border border-border rounded-lg overflow-hidden"},Le={class:"w-full text-sm"},Re={class:"px-4 py-2 font-medium"},Ee={class:"px-4 py-2 text-muted-foreground"},je={class:"px-4 py-2"},Je={class:"px-4 py-2 flex gap-1"},ze={key:0,class:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded"},Be={key:1,class:"text-xs bg-blue-500/10 text-blue-500 px-1.5 py-0.5 rounded"},Fe={key:2,class:"text-xs bg-purple-500/10 text-purple-500 px-1.5 py-0.5 rounded"},Oe={class:"mb-8"},Pe={class:"flex items-center justify-between mb-3"},Ve={key:0,class:"text-sm text-muted-foreground border border-border rounded-lg p-4 text-center"},He={key:1,class:"grid grid-cols-1 md:grid-cols-3 gap-3"},Ge={class:"flex items-center justify-between gap-2"},Ue={class:"flex items-center gap-1.5 min-w-0"},Qe={class:"text-sm font-medium truncate"},Xe={class:"flex items-center gap-1 text-xs text-muted-foreground"},Ze=["title"],We={class:"pt-1 border-t border-border"},Ke=["disabled","onClick"],Ye={key:0,class:"text-sm text-muted-foreground"},et={key:1,class:"space-y-2"},tt={class:"flex items-center justify-between"},st={class:"text-sm"},ot={class:"flex items-center gap-2"},rt=["onClick","disabled"],at=["onClick","aria-label","title"],lt={key:0,class:"mt-3 h-96"},j=3,xt=J({__name:"SquadDetailView",setup(f){const M=X(),x=m(null),S=m([]),w=m([]),u=m([]),$=m(!0),g=m(null),b=m(null),d=m(null);function N(a){d.value=a}function y(){d.value=null}function k(a){return a==="pending"||a==="in_progress"}async function T(a){if(!b.value){b.value=a;try{await P(`/tasks/${a}/stop`);const r=w.value.find(l=>l.id===a);r&&(r.status="stopped")}catch(r){console.error("Failed to stop task:",r)}finally{b.value=null}}}z(async()=>{try{const a=await O(`/squads/${M.params.id}`);x.value=a.squad,S.value=a.agents,w.value=a.tasks,u.value=a.instances}finally{$.value=!1}});async function q(a,r){if(confirm(`Destroy instance on branch "${r}"? This will remove the worktree.`)){g.value=a;try{await Y(`/instances/${a}`),u.value=u.value.filter(l=>l.id!==a)}finally{g.value=null}}}function L(a){if(!a)return"never";const r=a.replace(" ","T")+(a.includes("T")||a.endsWith("Z")?"":"Z"),l=Date.now()-new Date(r).getTime(),e=Math.floor(l/6e4);if(e<1)return"just now";if(e<60)return`${e}m ago`;const n=Math.floor(e/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}return(a,r)=>{const l=Z("router-link");return s(),o("div",Ae,[p(l,{to:"/squads",class:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground mb-4"},{default:U(()=>[p(c(re),{class:"w-4 h-4"}),r[0]||(r[0]=h(" Back to Squads ",-1))]),_:1}),$.value?(s(),o("div",Ne,"Loading...")):x.value?(s(),o(C,{key:1},[t("div",Ie,[t("span",{class:"inline-flex items-center text-sm px-2.5 py-1 rounded-full font-medium mb-2 w-fit",style:Q(c(ee)(x.value.color))},i(x.value.name),5),t("p",De,i(x.value.universe),1)]),t("section",Me,[r[5]||(r[5]=t("h2",{class:"text-lg font-semibold mb-3"},"Agent Roster",-1)),t("div",qe,[t("table",Le,[r[4]||(r[4]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Character"),t("th",{class:"text-left px-4 py-2 font-medium"},"Role"),t("th",{class:"text-left px-4 py-2 font-medium"},"Status"),t("th",{class:"text-left px-4 py-2 font-medium"},"Flags")])],-1)),t("tbody",null,[(s(!0),o(C,null,D(S.value,e=>(s(),o("tr",{key:e.id,class:"border-t border-border"},[t("td",Re,i(e.character_name),1),t("td",Ee,i(e.role_title),1),t("td",je,[t("span",{class:_(["inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full",{"bg-green-500/10 text-green-500":e.status==="idle","bg-yellow-500/10 text-yellow-500":e.status==="working","bg-blue-500/10 text-blue-500":e.status==="reviewing"}])},i(e.status),3)]),t("td",Je,[e.is_lead?(s(),o("span",ze,[p(c(W),{class:"w-3 h-3 inline"}),r[1]||(r[1]=h(" Lead ",-1))])):v("",!0),e.is_qa?(s(),o("span",Be,[p(c(ne),{class:"w-3 h-3 inline"}),r[2]||(r[2]=h(" QA ",-1))])):v("",!0),e.is_test?(s(),o("span",Fe,[p(c(le),{class:"w-3 h-3 inline"}),r[3]||(r[3]=h(" Test ",-1))])):v("",!0)])]))),128))])])])]),t("section",Oe,[t("div",Pe,[r[6]||(r[6]=t("h2",{class:"text-lg font-semibold"},"Instances",-1)),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full font-medium",u.value.length>=j?"bg-red-500/10 text-red-500":"bg-secondary text-secondary-foreground"])},i(u.value.length)+" / "+i(j)+" active ",3)]),u.value.length===0?(s(),o("div",Ve," No active instances. ")):(s(),o("div",He,[(s(!0),o(C,null,D(u.value,e=>(s(),o("div",{key:e.id,class:"border border-border rounded-lg p-3 flex flex-col gap-2"},[t("div",Ge,[t("div",Ue,[p(c(se),{class:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),t("span",Qe,i(e.branch),1)]),t("span",{class:_(["text-xs px-1.5 py-0.5 rounded-full shrink-0",{"bg-green-500/10 text-green-500":e.status==="active","bg-red-500/10 text-red-500":e.status==="destroyed","bg-yellow-500/10 text-yellow-500":e.status==="stale"}])},i(e.status),3)]),t("div",Xe,[p(c(B),{class:"w-3 h-3 shrink-0"}),t("span",null,i(L(e.last_activity)),1)]),t("div",{class:"font-mono text-xs text-muted-foreground truncate",title:e.worktree_path},i(e.worktree_path),9,Ze),t("div",We,[t("button",{class:"inline-flex items-center gap-1 text-xs text-red-500 hover:text-red-400 disabled:opacity-50 disabled:cursor-not-allowed",disabled:g.value===e.id,onClick:n=>q(e.id,e.branch)},[p(c(oe),{class:"w-3 h-3"}),h(" "+i(g.value===e.id?"Destroying…":"Destroy"),1)],8,Ke)])]))),128))]))]),t("section",null,[r[8]||(r[8]=t("h2",{class:"text-lg font-semibold mb-3"},"Recent Tasks",-1)),w.value.length===0?(s(),o("div",Ye,"No tasks yet.")):(s(),o("div",et,[(s(!0),o(C,null,D(w.value,e=>(s(),o("div",{key:e.id,class:"border border-border rounded-lg p-3"},[t("div",tt,[t("span",st,i(e.description),1),t("div",ot,[k(e.status)?(s(),o("button",{key:0,onClick:n=>T(e.id),disabled:b.value===e.id,class:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded border border-red-500/50 text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Stop agent",title:"Stop agent"},[p(c(F),{class:"w-3 h-3"}),h(" "+i(b.value===e.id?"Stopping…":"Stop"),1)],8,rt)):v("",!0),k(e.status)||d.value===e.id?(s(),o("button",{key:1,onClick:n=>d.value===e.id?y():N(e.id),class:_(["inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors",d.value===e.id?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:text-foreground hover:border-foreground"]),"aria-label":d.value===e.id?"Hide activity preview":"Show activity preview",title:d.value===e.id?"Hide preview":"Preview activity"},[p(c(ae),{class:"w-3 h-3"}),r[7]||(r[7]=h(" Preview ",-1))],10,at)):v("",!0),t("span",{class:_(["text-xs px-2 py-0.5 rounded-full",{"bg-yellow-500/10 text-yellow-500":e.status==="pending","bg-blue-500/10 text-blue-500":e.status==="in_progress","bg-green-500/10 text-green-500":e.status==="done","bg-red-500/10 text-red-500":e.status==="failed","bg-orange-500/10 text-orange-500":e.status==="stopped"}])},i(e.status),3)])]),d.value===e.id?(s(),o("div",lt,[p(Ce,{"task-id":e.id,"task-description":e.description,"task-status":e.status,onClose:y,onStopped:n=>e.status="stopped"},null,8,["task-id","task-description","task-status","onStopped"])])):v("",!0)]))),128))]))])],64)):v("",!0)])}}});export{xt as default};
@@ -0,0 +1,11 @@
1
+ import{b as B}from"./api-DPUP4xY9.js";import{l as I,o as L,s as M,u as o,k as n,h as t,n as u,D as l,A as T,m as g,e as _,F as f,w as h,v,g as N,q as k,R as P,z as a,i as x,j as p,b,x as V}from"./index-DSAUDIwK.js";import{T as w}from"./triangle-alert-Cindqw1C.js";import{G as $}from"./git-branch-BF40208L.js";/**
2
+ * @license lucide-vue-next v0.474.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 j=I("CircleCheckBigIcon",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
7
+ * @license lucide-vue-next v0.474.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 C=I("LoaderCircleIcon",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),z={class:"p-6"},F={class:"flex items-center gap-2 mb-6"},G={key:0,class:"flex items-center gap-2 text-muted-foreground"},H={key:1,class:"text-center py-12 text-muted-foreground"},R={key:2,class:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4"},D={class:"flex items-start justify-between"},E={class:"text-xs text-muted-foreground mt-0.5"},O={key:1},U={key:2},J={key:3},K={class:"grid grid-cols-3 gap-2 text-center"},Q={class:"rounded-md bg-muted px-2 py-2"},W={class:"text-lg font-bold"},X={class:"rounded-md bg-muted px-2 py-2"},Y={class:"text-lg font-bold"},Z={class:"rounded-md bg-muted px-2 py-2"},q={class:"text-lg font-bold flex items-center justify-center gap-1"},ee={class:"flex flex-wrap gap-1.5 text-xs"},te={key:0,class:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-500"},se={key:1,class:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-yellow-500/10 text-yellow-500"},oe={key:2,class:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-500/10 text-red-500"},ne={class:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-secondary text-secondary-foreground"},re={key:0},le={class:"space-y-1"},ae={class:"font-mono truncate"},ie={key:1},de={class:"space-y-1"},ce={class:"truncate text-muted-foreground"},fe=L({__name:"SquadHealthView",setup(ue){const m=v([]),y=v(!0);M(async()=>{try{const r=await B("/squads/health");m.value=r.health}finally{y.value=!1}});function S(r){if(r===null)return"—";if(r<60)return`${Math.round(r)}m`;const s=Math.floor(r/60),c=Math.round(r%60);return c>0?`${s}h ${c}m`:`${s}h`}function d(r){return r.isStalled?"stalled":r.tasksInProgress>0?"active":"idle"}const A=N(()=>[...m.value].sort((r,s)=>{const c={stalled:0,active:1,idle:2};return c[d(r)]-c[d(s)]}));return(r,s)=>{const c=V("router-link");return o(),n("div",z,[t("div",F,[u(l(T),{class:"w-6 h-6"}),s[0]||(s[0]=t("h1",{class:"text-2xl font-bold"},"Squad Health",-1))]),y.value?(o(),n("div",G,[u(l(C),{class:"w-4 h-4 animate-spin"}),s[1]||(s[1]=g(" Loading... ",-1))])):m.value.length===0?(o(),n("div",H,[u(l(_),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),s[2]||(s[2]=t("p",null,"No squads yet.",-1)),s[3]||(s[3]=t("p",{class:"text-sm mt-1"},"Ask IO to create a squad for your project.",-1))])):(o(),n("div",R,[(o(!0),n(f,null,h(A.value,e=>(o(),n("div",{key:e.id,class:k(["rounded-lg border bg-card p-4 flex flex-col gap-3",{"border-red-500/50":e.isStalled,"border-green-500/30":d(e)==="active","border-border":d(e)==="idle"}])},[t("div",D,[t("div",null,[u(c,{to:`/squads/${e.id}`,class:"font-semibold hover:underline"},{default:P(()=>[g(a(e.name),1)]),_:2},1032,["to"]),t("p",E,a(e.universe),1)]),t("span",{class:k(["text-xs px-2 py-0.5 rounded-full font-medium flex items-center gap-1",{"bg-red-500/10 text-red-500":e.isStalled,"bg-green-500/10 text-green-500":d(e)==="active","bg-secondary text-secondary-foreground":d(e)==="idle"}])},[e.isStalled?(o(),x(l(w),{key:0,class:"w-3 h-3"})):p("",!0),e.isStalled?(o(),n("span",O,"Stalled")):d(e)==="active"?(o(),n("span",U,"Active")):(o(),n("span",J,"Idle"))],2)]),t("div",K,[t("div",Q,[t("div",W,a(e.tasksCompleted),1),s[4]||(s[4]=t("div",{class:"text-xs text-muted-foreground"},"Completed",-1))]),t("div",X,[t("div",Y,a(e.tasksCompletedRecent),1),s[5]||(s[5]=t("div",{class:"text-xs text-muted-foreground"},"Last 7d",-1))]),t("div",Z,[t("div",q,[u(l(b),{class:"w-3 h-3 text-muted-foreground"}),g(" "+a(S(e.avgCycleTimeMinutes)),1)]),s[6]||(s[6]=t("div",{class:"text-xs text-muted-foreground"},"Avg cycle",-1))])]),t("div",ee,[e.tasksInProgress>0?(o(),n("span",te,a(e.tasksInProgress)+" in progress ",1)):p("",!0),e.tasksPending>0?(o(),n("span",se,a(e.tasksPending)+" pending ",1)):p("",!0),e.tasksFailed>0?(o(),n("span",oe,a(e.tasksFailed)+" failed ",1)):p("",!0),t("span",ne,[u(l(_),{class:"w-3 h-3"}),g(" "+a(e.agentCount)+" agents ",1)])]),e.activeInstanceCount>0?(o(),n("div",re,[s[7]||(s[7]=t("p",{class:"text-xs font-medium text-muted-foreground mb-1"},"Active instances",-1)),t("div",le,[(o(!0),n(f,null,h(e.activeInstances,i=>(o(),n("div",{key:i.id,class:"flex items-center gap-1.5 text-xs text-muted-foreground"},[u(l($),{class:"w-3 h-3 shrink-0"}),t("span",ae,a(i.branch),1)]))),128))])])):p("",!0),e.recentTasks.length>0?(o(),n("div",ie,[s[8]||(s[8]=t("p",{class:"text-xs font-medium text-muted-foreground mb-1"},"Recent activity",-1)),t("div",de,[(o(!0),n(f,null,h(e.recentTasks,i=>(o(),n("div",{key:i.id,class:"flex items-center gap-2 text-xs"},[i.status==="done"?(o(),x(l(j),{key:0,class:"w-3 h-3 text-green-500 shrink-0"})):i.status==="in_progress"?(o(),x(l(C),{key:1,class:"w-3 h-3 text-blue-500 shrink-0 animate-spin"})):i.status==="failed"?(o(),x(l(w),{key:2,class:"w-3 h-3 text-red-500 shrink-0"})):(o(),x(l(b),{key:3,class:"w-3 h-3 text-yellow-500 shrink-0"})),t("span",ce,a(i.description),1)]))),128))])])):p("",!0)],2))),128))]))])}}});export{fe as default};
@@ -0,0 +1,6 @@
1
+ import{b as y}from"./api-DPUP4xY9.js";import{g as v}from"./squad-colors-B8B_Y-lz.js";import{l as h,o as k,s as b,u as o,k as r,h as t,n as c,D as l,e as w,F as L,w as C,v as d,i as S,R as B,r as f,x as N,z as n,m as _,j as V}from"./index-DSAUDIwK.js";import{G as j}from"./git-branch-BF40208L.js";/**
2
+ * @license lucide-vue-next v0.474.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 q=h("LayersIcon",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),z={class:"p-6"},A={key:0,class:"text-muted-foreground"},M={key:1,class:"text-center py-12 text-muted-foreground"},F={key:2,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},G={class:"flex items-start justify-between"},I={class:"min-w-0"},D={class:"text-sm text-muted-foreground mt-0.5"},E={class:"text-xs bg-secondary text-secondary-foreground px-2 py-0.5 rounded-full"},O={class:"mt-3 flex items-center gap-4 text-xs text-muted-foreground"},R={key:0,class:"flex items-center gap-1"},T={class:"flex items-center gap-1"},P=k({__name:"SquadsView",setup(U){const i=d([]),u=d([]),m=d({}),p=d(!0);b(async()=>{try{const a=await y("/squads");i.value=a.squads,u.value=a.agents,m.value=a.instanceCounts??{}}finally{p.value=!1}});function g(a){return u.value.filter(s=>s.squad_id===a)}return(a,s)=>{const x=N("router-link");return o(),r("div",z,[s[2]||(s[2]=t("h1",{class:"text-2xl font-bold mb-6"},"Squads",-1)),p.value?(o(),r("div",A,"Loading...")):i.value.length===0?(o(),r("div",M,[c(l(w),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),s[0]||(s[0]=t("p",null,"No squads yet.",-1)),s[1]||(s[1]=t("p",{class:"text-sm mt-1"},"Ask IO to create a squad for your project.",-1))])):(o(),r("div",F,[(o(!0),r(L,null,C(i.value,e=>(o(),S(x,{key:e.id,to:`/squads/${e.id}`,class:"block rounded-lg border border-border bg-card p-4 hover:border-primary/50 transition-colors border-l-4",style:f({borderLeftColor:e.color})},{default:B(()=>[t("div",G,[t("div",I,[t("span",{class:"inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium",style:f(l(v)(e.color))},n(e.name),5),t("p",D,n(e.universe),1)]),t("span",E,n(g(e.id).length)+" agents ",1)]),t("div",O,[e.repo_url?(o(),r("span",R,[c(l(j),{class:"w-3 h-3"}),_(" "+n(e.repo_url),1)])):V("",!0),t("span",T,[c(l(q),{class:"w-3 h-3"}),_(" "+n(m.value[e.id]??0)+"/3 instances ",1)])])]),_:2},1032,["to","style"]))),128))]))])}}});export{P as default};
@@ -1,4 +1,4 @@
1
- import{q,t as Y,x as Q,z as d,o as r,l as t,s as _,K as k,C as R,F as i,E as m,r as w,J as o,e as W,n as u,Y as B,V as O,D as a,h as T,j as z,v as X,w as Z,k as tt}from"./index-CiZnRvN4.js";import{T as et}from"./triangle-alert-C1OjMvP5.js";/**
1
+ import{l as q,o as Q,s as R,u as d,k as r,h as t,n as _,D as k,C as W,F as i,w as m,m as w,z as o,e as X,j as u,T as O,O as B,v as a,q as Y,r as Z,g as tt}from"./index-DSAUDIwK.js";import{b as T,d as z}from"./api-DPUP4xY9.js";import{T as et}from"./triangle-alert-Cindqw1C.js";/**
2
2
  * @license lucide-vue-next v0.474.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{q,t as Y,x as Q,z as d,o as r,l as t,s as _,K as k,C as R,F as i,E as m,r
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const dt=q("TrendingUpIcon",[["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"}]]),rt={class:"p-6"},lt={class:"flex items-center gap-3 mb-6"},nt={key:0,class:"text-muted-foreground"},at={class:"flex gap-1 border-b border-border mb-6"},it=["onClick"],ut={key:0,class:"space-y-6"},xt={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},pt={class:"border border-border rounded-lg p-4"},ct={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},mt={class:"text-2xl font-bold"},gt={class:"text-xs text-muted-foreground mt-1"},ht={class:"border border-border rounded-lg p-4"},vt={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},bt={class:"text-2xl font-bold"},yt={class:"border border-border rounded-lg p-4"},ft={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},_t={class:"text-2xl font-bold"},kt={class:"border border-border rounded-lg p-4"},wt={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},Tt={class:"text-2xl font-bold"},Mt={key:0,class:"flex items-center gap-2 text-sm text-yellow-600 bg-yellow-500/10 border border-yellow-500/20 rounded-lg px-4 py-3"},Ct={key:1},Pt={class:"border border-border rounded-lg overflow-hidden"},St={class:"w-full text-sm"},At={class:"px-4 py-2 font-medium"},Ut={class:"px-4 py-2 text-right text-muted-foreground"},$t={class:"px-4 py-2 text-right text-muted-foreground"},Dt={class:"px-4 py-2 text-right text-muted-foreground"},It={key:2,class:"text-sm text-muted-foreground"},Et={key:1},Vt={key:0,class:"text-sm text-muted-foreground"},Ft={key:1,class:"border border-border rounded-lg overflow-hidden"},Nt={class:"w-full text-sm"},Bt={class:"px-4 py-2 font-medium"},Ot={class:"px-4 py-2 text-right text-muted-foreground"},qt={class:"px-4 py-2 text-right text-muted-foreground"},zt={class:"px-4 py-2 text-right font-medium"},Lt={class:"px-4 py-2 text-right text-muted-foreground"},Ht={class:"px-4 py-2 text-right text-muted-foreground"},Kt={key:2},jt={key:0,class:"text-sm text-muted-foreground"},Gt={key:1,class:"border border-border rounded-lg overflow-hidden"},Jt={class:"w-full text-sm"},Yt={class:"px-4 py-2 font-medium"},Qt={class:"px-4 py-2 text-right text-muted-foreground"},Rt={class:"px-4 py-2 text-right text-muted-foreground"},Wt={class:"px-4 py-2 text-right font-medium"},Xt={class:"px-4 py-2 text-right text-muted-foreground"},Zt={class:"px-4 py-2 text-right text-muted-foreground"},te={key:3},ee={key:0,class:"text-sm text-muted-foreground"},se={class:"mb-6"},oe={class:"flex items-end gap-1 h-32 border border-border rounded-lg p-3 bg-muted/20"},de={class:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 hidden group-hover:block bg-popover border border-border text-xs rounded px-2 py-1 whitespace-nowrap z-10"},re={class:"border border-border rounded-lg overflow-hidden"},le={class:"w-full text-sm"},ne={class:"px-4 py-2 font-mono text-xs"},ae={class:"px-4 py-2 text-right text-muted-foreground"},ie={class:"px-4 py-2 text-right text-muted-foreground"},ue={class:"px-4 py-2 text-right font-medium"},xe={class:"px-4 py-2 text-right text-muted-foreground"},pe={key:4,class:"space-y-6"},ce={class:"flex items-center gap-3 max-w-sm"},me=["disabled"],ge={key:0,class:"border border-border rounded-lg p-4 mb-4 max-w-md space-y-3"},he={class:"font-medium text-sm"},ve={class:"bg-muted px-1 rounded"},be={class:"flex gap-3"},ye={class:"flex-1"},fe={class:"flex-1"},_e={class:"flex gap-2"},ke=["disabled"],we={class:"border border-border rounded-lg overflow-hidden"},Te={class:"w-full text-sm"},Me={class:"px-4 py-2 font-mono text-xs"},Ce={class:"px-4 py-2 text-right text-muted-foreground"},Pe={class:"px-4 py-2 text-right text-muted-foreground"},Se={class:"px-4 py-2 text-right"},Ae=["onClick"],Ee=Y({__name:"UsageView",setup(Ue){const N=a(!0),x=a("overview"),L=[{id:"overview",label:"Overview"},{id:"by-squad",label:"By Squad"},{id:"by-agent",label:"By Agent"},{id:"daily",label:"Daily Trend"},{id:"pricing",label:"Pricing"}],g=a(null),h=a([]),C=a([]),M=a([]),v=a({}),b=a(null),P=a(!1),S=a(!1),A=a(!1),U=a(!1),p=a(""),$=a(0),D=a(0);async function H(){N.value=!0;try{const[l,e,c,I,E,V]=await Promise.all([T("/token-usage/summary"),T("/token-usage/by-squad"),T("/token-usage/by-agent"),T("/token-usage/daily?days=30"),T("/token-usage/pricing"),T("/token-usage/alert-threshold")]);g.value=l,h.value=e.filter(f=>f.record_count>0),C.value=c.filter(f=>f.record_count>0),M.value=I,v.value=E,b.value=V.tokenAlertThreshold}finally{N.value=!1}}async function K(){P.value=!0,S.value=!1;try{await z("/token-usage/alert-threshold",{tokenAlertThreshold:b.value}),S.value=!0,setTimeout(()=>S.value=!1,2e3)}finally{P.value=!1}}function j(l){var e,c;p.value=l,$.value=((e=v.value[l])==null?void 0:e.inputPer1M)??0,D.value=((c=v.value[l])==null?void 0:c.outputPer1M)??0}async function G(){if(p.value){A.value=!0,U.value=!1;try{const l={...v.value,[p.value]:{inputPer1M:$.value,outputPer1M:D.value}};await z("/token-usage/pricing",l),v.value=l,p.value="",U.value=!0,setTimeout(()=>U.value=!1,2e3)}finally{A.value=!1}}}function n(l){return l>=1e6?`${(l/1e6).toFixed(2)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:String(l)}function y(l){return l<1e-4?"$0.00":l<.01?`$${l.toFixed(4)}`:`$${l.toFixed(2)}`}const J=tt(()=>Math.max(1,...M.value.map(l=>l.total_tokens)));return Q(H),(l,e)=>{var c,I,E,V,f;return d(),r("div",rt,[t("div",lt,[_(k(R),{class:"w-6 h-6 text-primary"}),e[4]||(e[4]=t("h1",{class:"text-2xl font-bold"},"Token Usage",-1))]),N.value?(d(),r("div",nt,"Loading...")):(d(),r(i,{key:1},[t("div",at,[(d(),r(i,null,m(L,s=>t("button",{key:s.id,onClick:F=>x.value=s.id,class:X(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",x.value===s.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"])},o(s.label),11,it)),64))]),x.value==="overview"?(d(),r("div",ut,[t("div",xt,[t("div",pt,[t("div",ct,[_(k(dt),{class:"w-3 h-3"}),e[5]||(e[5]=w(" Total Tokens ",-1))]),t("div",mt,o(n(((c=g.value)==null?void 0:c.total_tokens)??0)),1),t("div",gt,o(n(((I=g.value)==null?void 0:I.total_input_tokens)??0))+" in / "+o(n(((E=g.value)==null?void 0:E.total_output_tokens)??0))+" out ",1)]),t("div",ht,[t("div",vt,[_(k(ot),{class:"w-3 h-3"}),e[6]||(e[6]=w(" Est. Cost ",-1))]),t("div",bt,o(y(((V=g.value)==null?void 0:V.total_cost_usd)??0)),1),e[7]||(e[7]=t("div",{class:"text-xs text-muted-foreground mt-1"},"all time",-1))]),t("div",yt,[t("div",ft,[_(k(W),{class:"w-3 h-3"}),e[8]||(e[8]=w(" Active Squads ",-1))]),t("div",_t,o(h.value.length),1),e[9]||(e[9]=t("div",{class:"text-xs text-muted-foreground mt-1"},"with usage",-1))]),t("div",kt,[t("div",wt,[_(k(st),{class:"w-3 h-3"}),e[10]||(e[10]=w(" Active Agents ",-1))]),t("div",Tt,o(C.value.length),1),e[11]||(e[11]=t("div",{class:"text-xs text-muted-foreground mt-1"},"with usage",-1))])]),b.value!==null?(d(),r("div",Mt,[_(k(et),{class:"w-4 h-4 shrink-0"}),w(" Alert threshold active: "+o(n(b.value))+" tokens per task ",1)])):u("",!0),h.value.length>0?(d(),r("div",Ct,[e[13]||(e[13]=t("h2",{class:"text-base font-semibold mb-3"},"Top Squads by Token Usage",-1)),t("div",Pt,[t("table",St,[e[12]||(e[12]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Squad"),t("th",{class:"text-right px-4 py-2 font-medium"},"Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(h.value.slice(0,5),s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",At,o(s.name),1),t("td",Ut,o(n(s.total_tokens)),1),t("td",$t,o(y(s.total_cost_usd)),1),t("td",Dt,o(s.record_count),1)]))),128))])])])])):u("",!0),((f=g.value)==null?void 0:f.total_records)===0?(d(),r("div",It," No token usage recorded yet. Usage will appear here after squads or agents complete tasks. ")):u("",!0)])):u("",!0),x.value==="by-squad"?(d(),r("div",Et,[h.value.length===0?(d(),r("div",Vt,"No usage data yet.")):(d(),r("div",Ft,[t("table",Nt,[e[14]||(e[14]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Squad"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"API Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(h.value,s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",Bt,o(s.name),1),t("td",Ot,o(n(s.total_input_tokens)),1),t("td",qt,o(n(s.total_output_tokens)),1),t("td",zt,o(n(s.total_tokens)),1),t("td",Lt,o(y(s.total_cost_usd)),1),t("td",Ht,o(s.record_count),1)]))),128))])])]))])):u("",!0),x.value==="by-agent"?(d(),r("div",Kt,[C.value.length===0?(d(),r("div",jt,"No usage data yet.")):(d(),r("div",Gt,[t("table",Jt,[e[15]||(e[15]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Agent"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"API Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(C.value,s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",Yt,o(s.name),1),t("td",Qt,o(n(s.total_input_tokens)),1),t("td",Rt,o(n(s.total_output_tokens)),1),t("td",Wt,o(n(s.total_tokens)),1),t("td",Xt,o(y(s.total_cost_usd)),1),t("td",Zt,o(s.record_count),1)]))),128))])])]))])):u("",!0),x.value==="daily"?(d(),r("div",te,[M.value.length===0?(d(),r("div",ee,"No usage data yet.")):(d(),r(i,{key:1},[t("div",se,[e[16]||(e[16]=t("h2",{class:"text-base font-semibold mb-3"},"Last 30 Days — Token Usage",-1)),t("div",oe,[(d(!0),r(i,null,m(M.value,s=>(d(),r("div",{key:s.date,class:"flex-1 bg-primary/60 rounded-t min-w-[4px] relative group",style:Z({height:`${s.total_tokens/J.value*100}%`})},[t("div",de,o(s.date)+": "+o(n(s.total_tokens))+" tokens ("+o(y(s.total_cost_usd))+") ",1)],4))),128))])]),t("div",re,[t("table",le,[e[17]||(e[17]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Date"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost")])],-1)),t("tbody",null,[(d(!0),r(i,null,m([...M.value].reverse(),s=>(d(),r("tr",{key:s.date,class:"border-t border-border"},[t("td",ne,o(s.date),1),t("td",ae,o(n(s.total_input_tokens)),1),t("td",ie,o(n(s.total_output_tokens)),1),t("td",ue,o(n(s.total_tokens)),1),t("td",xe,o(y(s.total_cost_usd)),1)]))),128))])])])],64))])):u("",!0),x.value==="pricing"?(d(),r("div",pe,[t("div",null,[e[18]||(e[18]=t("h2",{class:"text-base font-semibold mb-1"},"Alert Threshold",-1)),e[19]||(e[19]=t("p",{class:"text-sm text-muted-foreground mb-3"}," Post a feed alert when a single task exceeds this many tokens. Leave empty to disable. ",-1)),t("div",ce,[B(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>b.value=s),type:"number",min:"0",placeholder:"e.g. 100000",class:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[O,b.value,void 0,{number:!0}]]),t("button",{onClick:K,disabled:P.value,class:"px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 shrink-0"},o(P.value?"Saving...":S.value?"Saved ✓":"Save"),9,me)])]),t("div",null,[e[24]||(e[24]=t("h2",{class:"text-base font-semibold mb-1"},"Model Pricing",-1)),e[25]||(e[25]=t("p",{class:"text-sm text-muted-foreground mb-3"}," Prices in USD per 1M tokens. Used for cost estimates only. ",-1)),p.value?(d(),r("div",ge,[t("div",he,[e[20]||(e[20]=w("Editing: ",-1)),t("code",ve,o(p.value),1)]),t("div",be,[t("div",ye,[e[21]||(e[21]=t("label",{class:"text-xs text-muted-foreground"},"Input (per 1M tokens)",-1)),B(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>$.value=s),type:"number",min:"0",step:"0.01",class:"w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[O,$.value,void 0,{number:!0}]])]),t("div",fe,[e[22]||(e[22]=t("label",{class:"text-xs text-muted-foreground"},"Output (per 1M tokens)",-1)),B(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>D.value=s),type:"number",min:"0",step:"0.01",class:"w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[O,D.value,void 0,{number:!0}]])])]),t("div",_e,[t("button",{onClick:G,disabled:A.value,class:"px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50"},o(A.value?"Saving...":U.value?"Saved ✓":"Save"),9,ke),t("button",{onClick:e[3]||(e[3]=s=>p.value=""),class:"px-3 py-1.5 rounded-md border border-border text-sm hover:bg-accent"},"Cancel")])])):u("",!0),t("div",we,[t("table",Te,[e[23]||(e[23]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Model"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input / 1M tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output / 1M tokens"),t("th",{class:"text-right px-4 py-2 font-medium"})])],-1)),t("tbody",null,[(d(!0),r(i,null,m(v.value,(s,F)=>(d(),r("tr",{key:F,class:"border-t border-border"},[t("td",Me,o(F),1),t("td",Ce,"$"+o(s.inputPer1M.toFixed(2)),1),t("td",Pe,"$"+o(s.outputPer1M.toFixed(2)),1),t("td",Se,[t("button",{onClick:$e=>j(F),class:"text-xs text-primary hover:underline"},"Edit",8,Ae)])]))),128))])])])])])):u("",!0)],64))])}}});export{Ee as default};
16
+ */const dt=q("TrendingUpIcon",[["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"}]]),rt={class:"p-6"},lt={class:"flex items-center gap-3 mb-6"},nt={key:0,class:"text-muted-foreground"},at={class:"flex gap-1 border-b border-border mb-6"},it=["onClick"],ut={key:0,class:"space-y-6"},pt={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},xt={class:"border border-border rounded-lg p-4"},ct={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},mt={class:"text-2xl font-bold"},gt={class:"text-xs text-muted-foreground mt-1"},ht={class:"border border-border rounded-lg p-4"},vt={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},bt={class:"text-2xl font-bold"},yt={class:"border border-border rounded-lg p-4"},ft={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},_t={class:"text-2xl font-bold"},kt={class:"border border-border rounded-lg p-4"},wt={class:"flex items-center gap-2 text-muted-foreground text-xs mb-1"},Tt={class:"text-2xl font-bold"},Mt={key:0,class:"flex items-center gap-2 text-sm text-yellow-600 bg-yellow-500/10 border border-yellow-500/20 rounded-lg px-4 py-3"},Ct={key:1},Pt={class:"border border-border rounded-lg overflow-hidden"},St={class:"w-full text-sm"},At={class:"px-4 py-2 font-medium"},Ut={class:"px-4 py-2 text-right text-muted-foreground"},$t={class:"px-4 py-2 text-right text-muted-foreground"},Dt={class:"px-4 py-2 text-right text-muted-foreground"},It={key:2,class:"text-sm text-muted-foreground"},Et={key:1},Vt={key:0,class:"text-sm text-muted-foreground"},Ft={key:1,class:"border border-border rounded-lg overflow-hidden"},Nt={class:"w-full text-sm"},Ot={class:"px-4 py-2 font-medium"},Bt={class:"px-4 py-2 text-right text-muted-foreground"},qt={class:"px-4 py-2 text-right text-muted-foreground"},zt={class:"px-4 py-2 text-right font-medium"},Lt={class:"px-4 py-2 text-right text-muted-foreground"},Ht={class:"px-4 py-2 text-right text-muted-foreground"},jt={key:2},Gt={key:0,class:"text-sm text-muted-foreground"},Kt={key:1,class:"border border-border rounded-lg overflow-hidden"},Jt={class:"w-full text-sm"},Qt={class:"px-4 py-2 font-medium"},Rt={class:"px-4 py-2 text-right text-muted-foreground"},Wt={class:"px-4 py-2 text-right text-muted-foreground"},Xt={class:"px-4 py-2 text-right font-medium"},Yt={class:"px-4 py-2 text-right text-muted-foreground"},Zt={class:"px-4 py-2 text-right text-muted-foreground"},te={key:3},ee={key:0,class:"text-sm text-muted-foreground"},se={class:"mb-6"},oe={class:"flex items-end gap-1 h-32 border border-border rounded-lg p-3 bg-muted/20"},de={class:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 hidden group-hover:block bg-popover border border-border text-xs rounded px-2 py-1 whitespace-nowrap z-10"},re={class:"border border-border rounded-lg overflow-hidden"},le={class:"w-full text-sm"},ne={class:"px-4 py-2 font-mono text-xs"},ae={class:"px-4 py-2 text-right text-muted-foreground"},ie={class:"px-4 py-2 text-right text-muted-foreground"},ue={class:"px-4 py-2 text-right font-medium"},pe={class:"px-4 py-2 text-right text-muted-foreground"},xe={key:4,class:"space-y-6"},ce={class:"flex items-center gap-3 max-w-sm"},me=["disabled"],ge={key:0,class:"border border-border rounded-lg p-4 mb-4 max-w-md space-y-3"},he={class:"font-medium text-sm"},ve={class:"bg-muted px-1 rounded"},be={class:"flex gap-3"},ye={class:"flex-1"},fe={class:"flex-1"},_e={class:"flex gap-2"},ke=["disabled"],we={class:"border border-border rounded-lg overflow-hidden"},Te={class:"w-full text-sm"},Me={class:"px-4 py-2 font-mono text-xs"},Ce={class:"px-4 py-2 text-right text-muted-foreground"},Pe={class:"px-4 py-2 text-right text-muted-foreground"},Se={class:"px-4 py-2 text-right"},Ae=["onClick"],Ve=Q({__name:"UsageView",setup(Ue){const N=a(!0),p=a("overview"),L=[{id:"overview",label:"Overview"},{id:"by-squad",label:"By Squad"},{id:"by-agent",label:"By Agent"},{id:"daily",label:"Daily Trend"},{id:"pricing",label:"Pricing"}],g=a(null),h=a([]),C=a([]),M=a([]),v=a({}),b=a(null),P=a(!1),S=a(!1),A=a(!1),U=a(!1),x=a(""),$=a(0),D=a(0);async function H(){N.value=!0;try{const[l,e,c,I,E,V]=await Promise.all([T("/token-usage/summary"),T("/token-usage/by-squad"),T("/token-usage/by-agent"),T("/token-usage/daily?days=30"),T("/token-usage/pricing"),T("/token-usage/alert-threshold")]);g.value=l,h.value=e.filter(f=>f.record_count>0),C.value=c.filter(f=>f.record_count>0),M.value=I,v.value=E,b.value=V.tokenAlertThreshold}finally{N.value=!1}}async function j(){P.value=!0,S.value=!1;try{await z("/token-usage/alert-threshold",{tokenAlertThreshold:b.value}),S.value=!0,setTimeout(()=>S.value=!1,2e3)}finally{P.value=!1}}function G(l){var e,c;x.value=l,$.value=((e=v.value[l])==null?void 0:e.inputPer1M)??0,D.value=((c=v.value[l])==null?void 0:c.outputPer1M)??0}async function K(){if(x.value){A.value=!0,U.value=!1;try{const l={...v.value,[x.value]:{inputPer1M:$.value,outputPer1M:D.value}};await z("/token-usage/pricing",l),v.value=l,x.value="",U.value=!0,setTimeout(()=>U.value=!1,2e3)}finally{A.value=!1}}}function n(l){return l>=1e6?`${(l/1e6).toFixed(2)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:String(l)}function y(l){return l<1e-4?"$0.00":l<.01?`$${l.toFixed(4)}`:`$${l.toFixed(2)}`}const J=tt(()=>Math.max(1,...M.value.map(l=>l.total_tokens)));return R(H),(l,e)=>{var c,I,E,V,f;return d(),r("div",rt,[t("div",lt,[_(k(W),{class:"w-6 h-6 text-primary"}),e[4]||(e[4]=t("h1",{class:"text-2xl font-bold"},"Token Usage",-1))]),N.value?(d(),r("div",nt,"Loading...")):(d(),r(i,{key:1},[t("div",at,[(d(),r(i,null,m(L,s=>t("button",{key:s.id,onClick:F=>p.value=s.id,class:Y(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",p.value===s.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"])},o(s.label),11,it)),64))]),p.value==="overview"?(d(),r("div",ut,[t("div",pt,[t("div",xt,[t("div",ct,[_(k(dt),{class:"w-3 h-3"}),e[5]||(e[5]=w(" Total Tokens ",-1))]),t("div",mt,o(n(((c=g.value)==null?void 0:c.total_tokens)??0)),1),t("div",gt,o(n(((I=g.value)==null?void 0:I.total_input_tokens)??0))+" in / "+o(n(((E=g.value)==null?void 0:E.total_output_tokens)??0))+" out ",1)]),t("div",ht,[t("div",vt,[_(k(ot),{class:"w-3 h-3"}),e[6]||(e[6]=w(" Est. Cost ",-1))]),t("div",bt,o(y(((V=g.value)==null?void 0:V.total_cost_usd)??0)),1),e[7]||(e[7]=t("div",{class:"text-xs text-muted-foreground mt-1"},"all time",-1))]),t("div",yt,[t("div",ft,[_(k(X),{class:"w-3 h-3"}),e[8]||(e[8]=w(" Active Squads ",-1))]),t("div",_t,o(h.value.length),1),e[9]||(e[9]=t("div",{class:"text-xs text-muted-foreground mt-1"},"with usage",-1))]),t("div",kt,[t("div",wt,[_(k(st),{class:"w-3 h-3"}),e[10]||(e[10]=w(" Active Agents ",-1))]),t("div",Tt,o(C.value.length),1),e[11]||(e[11]=t("div",{class:"text-xs text-muted-foreground mt-1"},"with usage",-1))])]),b.value!==null?(d(),r("div",Mt,[_(k(et),{class:"w-4 h-4 shrink-0"}),w(" Alert threshold active: "+o(n(b.value))+" tokens per task ",1)])):u("",!0),h.value.length>0?(d(),r("div",Ct,[e[13]||(e[13]=t("h2",{class:"text-base font-semibold mb-3"},"Top Squads by Token Usage",-1)),t("div",Pt,[t("table",St,[e[12]||(e[12]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Squad"),t("th",{class:"text-right px-4 py-2 font-medium"},"Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(h.value.slice(0,5),s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",At,o(s.name),1),t("td",Ut,o(n(s.total_tokens)),1),t("td",$t,o(y(s.total_cost_usd)),1),t("td",Dt,o(s.record_count),1)]))),128))])])])])):u("",!0),((f=g.value)==null?void 0:f.total_records)===0?(d(),r("div",It," No token usage recorded yet. Usage will appear here after squads or agents complete tasks. ")):u("",!0)])):u("",!0),p.value==="by-squad"?(d(),r("div",Et,[h.value.length===0?(d(),r("div",Vt,"No usage data yet.")):(d(),r("div",Ft,[t("table",Nt,[e[14]||(e[14]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Squad"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"API Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(h.value,s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",Ot,o(s.name),1),t("td",Bt,o(n(s.total_input_tokens)),1),t("td",qt,o(n(s.total_output_tokens)),1),t("td",zt,o(n(s.total_tokens)),1),t("td",Lt,o(y(s.total_cost_usd)),1),t("td",Ht,o(s.record_count),1)]))),128))])])]))])):u("",!0),p.value==="by-agent"?(d(),r("div",jt,[C.value.length===0?(d(),r("div",Gt,"No usage data yet.")):(d(),r("div",Kt,[t("table",Jt,[e[15]||(e[15]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Agent"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost"),t("th",{class:"text-right px-4 py-2 font-medium"},"API Calls")])],-1)),t("tbody",null,[(d(!0),r(i,null,m(C.value,s=>(d(),r("tr",{key:s.id,class:"border-t border-border"},[t("td",Qt,o(s.name),1),t("td",Rt,o(n(s.total_input_tokens)),1),t("td",Wt,o(n(s.total_output_tokens)),1),t("td",Xt,o(n(s.total_tokens)),1),t("td",Yt,o(y(s.total_cost_usd)),1),t("td",Zt,o(s.record_count),1)]))),128))])])]))])):u("",!0),p.value==="daily"?(d(),r("div",te,[M.value.length===0?(d(),r("div",ee,"No usage data yet.")):(d(),r(i,{key:1},[t("div",se,[e[16]||(e[16]=t("h2",{class:"text-base font-semibold mb-3"},"Last 30 Days — Token Usage",-1)),t("div",oe,[(d(!0),r(i,null,m(M.value,s=>(d(),r("div",{key:s.date,class:"flex-1 bg-primary/60 rounded-t min-w-[4px] relative group",style:Z({height:`${s.total_tokens/J.value*100}%`})},[t("div",de,o(s.date)+": "+o(n(s.total_tokens))+" tokens ("+o(y(s.total_cost_usd))+") ",1)],4))),128))])]),t("div",re,[t("table",le,[e[17]||(e[17]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Date"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Total Tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Est. Cost")])],-1)),t("tbody",null,[(d(!0),r(i,null,m([...M.value].reverse(),s=>(d(),r("tr",{key:s.date,class:"border-t border-border"},[t("td",ne,o(s.date),1),t("td",ae,o(n(s.total_input_tokens)),1),t("td",ie,o(n(s.total_output_tokens)),1),t("td",ue,o(n(s.total_tokens)),1),t("td",pe,o(y(s.total_cost_usd)),1)]))),128))])])])],64))])):u("",!0),p.value==="pricing"?(d(),r("div",xe,[t("div",null,[e[18]||(e[18]=t("h2",{class:"text-base font-semibold mb-1"},"Alert Threshold",-1)),e[19]||(e[19]=t("p",{class:"text-sm text-muted-foreground mb-3"}," Post a feed alert when a single task exceeds this many tokens. Leave empty to disable. ",-1)),t("div",ce,[O(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>b.value=s),type:"number",min:"0",placeholder:"e.g. 100000",class:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[B,b.value,void 0,{number:!0}]]),t("button",{onClick:j,disabled:P.value,class:"px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 shrink-0"},o(P.value?"Saving...":S.value?"Saved ✓":"Save"),9,me)])]),t("div",null,[e[24]||(e[24]=t("h2",{class:"text-base font-semibold mb-1"},"Model Pricing",-1)),e[25]||(e[25]=t("p",{class:"text-sm text-muted-foreground mb-3"}," Prices in USD per 1M tokens. Used for cost estimates only. ",-1)),x.value?(d(),r("div",ge,[t("div",he,[e[20]||(e[20]=w("Editing: ",-1)),t("code",ve,o(x.value),1)]),t("div",be,[t("div",ye,[e[21]||(e[21]=t("label",{class:"text-xs text-muted-foreground"},"Input (per 1M tokens)",-1)),O(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>$.value=s),type:"number",min:"0",step:"0.01",class:"w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[B,$.value,void 0,{number:!0}]])]),t("div",fe,[e[22]||(e[22]=t("label",{class:"text-xs text-muted-foreground"},"Output (per 1M tokens)",-1)),O(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>D.value=s),type:"number",min:"0",step:"0.01",class:"w-full mt-1 rounded-md border border-input bg-background px-3 py-2 text-sm"},null,512),[[B,D.value,void 0,{number:!0}]])])]),t("div",_e,[t("button",{onClick:K,disabled:A.value,class:"px-3 py-1.5 rounded-md bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50"},o(A.value?"Saving...":U.value?"Saved ✓":"Save"),9,ke),t("button",{onClick:e[3]||(e[3]=s=>x.value=""),class:"px-3 py-1.5 rounded-md border border-border text-sm hover:bg-accent"},"Cancel")])])):u("",!0),t("div",we,[t("table",Te,[e[23]||(e[23]=t("thead",{class:"bg-muted"},[t("tr",null,[t("th",{class:"text-left px-4 py-2 font-medium"},"Model"),t("th",{class:"text-right px-4 py-2 font-medium"},"Input / 1M tokens"),t("th",{class:"text-right px-4 py-2 font-medium"},"Output / 1M tokens"),t("th",{class:"text-right px-4 py-2 font-medium"})])],-1)),t("tbody",null,[(d(!0),r(i,null,m(v.value,(s,F)=>(d(),r("tr",{key:F,class:"border-t border-border"},[t("td",Me,o(F),1),t("td",Ce,"$"+o(s.inputPer1M.toFixed(2)),1),t("td",Pe,"$"+o(s.outputPer1M.toFixed(2)),1),t("td",Se,[t("button",{onClick:$e=>G(F),class:"text-xs text-primary hover:underline"},"Edit",8,Ae)])]))),128))])])])])])):u("",!0)],64))])}}});export{Ve as default};
@@ -1,4 +1,4 @@
1
- import{q as P,t as se,W as oe,z as o,o as a,F as y,E as U,k as Q,l as t,m as B,K as d,s as v,J as j,w as ce,v as E,$ as ve,n as I,D as c,x as pe,h as M,B as Z,r as S,Y as L,V as N,Z as A,f as R,j as z,g as G}from"./index-CiZnRvN4.js";import{S as fe}from"./search-Cl8HcIsG.js";import{P as J}from"./plus-DIBAaEMT.js";import{P as O,S as X}from"./save-Chqlu7QA.js";import{T as Y}from"./trash-2-CQSzbVIr.js";import{X as ee}from"./x-DThJHYFm.js";/**
1
+ import{l as P,o as oe,Q as se,u as s,k as a,F as y,w as Q,g as A,h as t,i as B,D as d,n as v,z as j,r as ce,q as E,W as ve,j as I,v as c,s as pe,B as K,m as S,T as L,O as N,V as Z,f as O}from"./index-DSAUDIwK.js";import{b as M,d as z,a as R}from"./api-DPUP4xY9.js";import{S as fe}from"./search-DUqJxRNn.js";import{P as G}from"./plus-aHVgAXQB.js";import{P as X,S as J}from"./save-jn5LGsCv.js";import{T as Y}from"./trash-2-B9ibnt3n.js";import{X as ee}from"./x-BDIsved4.js";/**
2
2
  * @license lucide-vue-next v0.474.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -33,4 +33,4 @@ import{q as P,t as se,W as oe,z as o,o as a,F as y,E as U,k as Q,l as t,m as B,K
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const be=P("LinkIcon",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ke={class:"select-none"},we=["onClick"],_e={class:"truncate"},Ce=["onClick"],$e=se({__name:"WikiTree",props:{pages:{},selectedPage:{},searchQuery:{}},emits:["select","addFile"],setup(H,{emit:w}){const x=H,f=w,h=c(new Set);function b(i){const u=[];for(const n of i){const p=n.split("/");let m=u;for(let g=0;g<p.length;g++){const q=p[g],$=p.slice(0,g+1).join("/"),k=g<p.length-1;let F=m.find(D=>D.name===q&&D.isFolder===k);F||(F={name:q,path:$,children:[],isFolder:k},m.push(F)),m=F.children}}const s=n=>{n.sort((p,m)=>p.isFolder!==m.isFolder?p.isFolder?-1:1:p.name.localeCompare(m.name)),n.forEach(p=>s(p.children))};return s(u),u}const _=Q(()=>{let i=x.pages;if(x.searchQuery){const u=x.searchQuery.toLowerCase();i=x.pages.filter(s=>s.toLowerCase().includes(u))}return b(i)});oe(()=>x.selectedPage,i=>{if(!i)return;const u=i.split("/");for(let s=1;s<u.length;s++)h.value.add(u.slice(0,s).join("/"))},{immediate:!0});function T(i){h.value.has(i)?h.value.delete(i):h.value.add(i)}function V(i,u){const s=[];for(const n of i)s.push({node:n,depth:u}),n.isFolder&&h.value.has(n.path)&&s.push(...V(n.children,u+1));return s}const C=Q(()=>V(_.value,0));return(i,u)=>(o(),a("div",ke,[(o(!0),a(y,null,U(C.value,({node:s,depth:n})=>(o(),a("div",{key:s.path,class:"group relative"},[t("button",{onClick:p=>s.isFolder?T(s.path):f("select",s.path),class:E(["w-full text-left flex items-center gap-1 py-1 text-xs rounded hover:bg-accent transition-colors",{"bg-accent font-medium":!s.isFolder&&H.selectedPage===s.path}]),style:ce({paddingLeft:n*12+8+"px"})},[s.isFolder?(o(),a(y,{key:0},[h.value.has(s.path)?(o(),B(d(me),{key:0,class:"w-3 h-3 shrink-0 text-muted-foreground"})):(o(),B(d(xe),{key:1,class:"w-3 h-3 shrink-0 text-muted-foreground"})),v(d(ye),{class:"w-3.5 h-3.5 shrink-0 text-muted-foreground"})],64)):(o(),a(y,{key:1},[u[0]||(u[0]=t("span",{class:"w-3 shrink-0"},null,-1)),v(d(ge),{class:"w-3.5 h-3.5 shrink-0 text-muted-foreground"})],64)),t("span",_e,j(s.name),1)],14,we),s.isFolder?(o(),a("button",{key:0,onClick:ve(p=>f("addFile",s.path),["stop"]),class:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-primary/10 text-muted-foreground hover:text-primary transition-all",title:"Add file here"},[v(d(he),{class:"w-3.5 h-3.5"})],8,Ce)):I("",!0)]))),128))]))}}),Fe={class:"flex flex-col h-full"},Pe={class:"flex border-b border-border shrink-0"},qe={key:0,class:"flex flex-1 overflow-hidden"},Me={class:"w-64 border-r border-border flex flex-col shrink-0"},Te={class:"p-3 border-b border-border space-y-2"},Ve={class:"relative"},Se={key:0,class:"space-y-1.5"},Le={class:"flex gap-1"},Ne=["disabled"],je={class:"flex-1 overflow-y-auto p-2"},De={key:0,class:"text-xs text-muted-foreground p-2"},ze={class:"flex-1 flex flex-col overflow-hidden"},Ee={key:0,class:"flex items-center justify-center h-full text-muted-foreground"},Ie={class:"text-center"},Be={class:"flex items-center justify-between px-4 py-2 border-b border-border"},He={class:"text-sm font-medium font-mono"},Ue={class:"flex gap-1"},We={class:"flex-1 overflow-y-auto p-4"},Ke={key:0,class:"mt-8 pt-4 border-t border-border"},Qe={class:"flex items-center gap-1.5 mb-2 text-xs font-medium text-muted-foreground"},Ze={class:"space-y-1"},Ae=["onClick"],Re={key:1,class:"flex flex-1 overflow-hidden"},Ge={class:"w-64 border-r border-border flex flex-col shrink-0"},Je={class:"p-3 border-b border-border space-y-2"},Oe={key:0,class:"space-y-1.5"},Xe={class:"flex gap-1"},Ye=["disabled"],et={class:"flex-1 overflow-y-auto p-2"},tt={key:0,class:"text-xs text-muted-foreground p-2"},st={key:1,class:"text-xs text-muted-foreground p-2"},ot=["onClick"],lt={class:"flex-1 flex flex-col overflow-hidden"},at={key:0,class:"flex items-center justify-center h-full text-muted-foreground"},nt={class:"text-center"},rt={class:"flex items-center justify-between px-4 py-2 border-b border-border"},it={class:"text-sm font-medium font-mono"},ut={class:"flex gap-1"},dt={class:"flex-1 overflow-y-auto p-4"},ht=se({__name:"WikiView",setup(H){const w=c("pages"),x=c([]),f=c(null),h=c(""),b=c(!1),_=c(""),T=c(""),V=c(!0),C=c(!1),i=c(""),u=c([]),s=c([]),n=c(null),p=c(""),m=c(!1),g=c(""),q=c(!1),$=c(!1),k=c("");pe(async()=>{try{x.value=await M("/wiki/pages")}finally{V.value=!1}}),oe(w,async r=>{if(r==="templates"&&s.value.length===0){q.value=!0;try{s.value=await M("/wiki/templates/squad")}finally{q.value=!1}}});async function F(r){f.value=r,b.value=!1;const e=await M(`/wiki/page/${r}`);h.value=e.content,u.value=await M(`/wiki/backlinks/${r}`)}function D(){_.value=h.value,b.value=!0}async function le(){f.value&&(await z(`/wiki/page/${f.value}`,{content:_.value}),h.value=_.value,b.value=!1,u.value=await M(`/wiki/backlinks/${f.value}`))}async function ae(){f.value&&confirm(`Delete "${f.value}"?`)&&(await G(`/wiki/page/${f.value}`),x.value=x.value.filter(r=>r!==f.value),f.value=null,h.value="",u.value=[])}async function W(){const r=i.value.trim();if(!r)return;const e=r.endsWith(".md")?r:`${r}.md`;await z(`/wiki/page/${e}`,{content:""}),x.value.includes(e)||(x.value.push(e),x.value.sort()),C.value=!1,i.value="",f.value=e,h.value="",_.value="",b.value=!0,u.value=[]}async function ne(r){n.value=r,m.value=!1;const e=await M(`/wiki/template/squad/${r}`);p.value=e.content}function re(){g.value=p.value,m.value=!0}async function ie(){n.value&&(await z(`/wiki/template/squad/${n.value}`,{content:g.value}),p.value=g.value,m.value=!1)}async function ue(){n.value&&confirm(`Delete template "${n.value}"?`)&&(await G(`/wiki/template/squad/${n.value}`),s.value=s.value.filter(r=>r!==n.value),n.value=null,p.value="")}async function K(){const r=k.value.trim();if(!r)return;const e=r.endsWith(".md")?r:`${r}.md`;await z(`/wiki/template/squad/${e}`,{content:""}),s.value.includes(e)||(s.value.push(e),s.value.sort()),$.value=!1,k.value="",n.value=e,p.value="",g.value="",m.value=!0}return(r,e)=>(o(),a("div",Fe,[t("div",Pe,[t("button",{onClick:e[0]||(e[0]=l=>w.value="pages"),class:E(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",w.value==="pages"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"])},[v(d(Z),{class:"inline w-4 h-4 mr-1.5 -mt-0.5"}),e[15]||(e[15]=S(" Pages ",-1))],2),t("button",{onClick:e[1]||(e[1]=l=>w.value="templates"),class:E(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",w.value==="templates"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"])},[v(d(te),{class:"inline w-4 h-4 mr-1.5 -mt-0.5"}),e[16]||(e[16]=S(" Squad Templates ",-1))],2)]),w.value==="pages"?(o(),a("div",qe,[t("div",Me,[t("div",Te,[t("div",Ve,[v(d(fe),{class:"absolute left-2.5 top-2.5 w-3.5 h-3.5 text-muted-foreground"}),L(t("input",{"onUpdate:modelValue":e[2]||(e[2]=l=>T.value=l),placeholder:"Search pages...",class:"w-full rounded-md border border-input bg-background pl-8 pr-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-ring"},null,512),[[N,T.value]])]),t("button",{onClick:e[3]||(e[3]=l=>C.value=!C.value),class:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-md bg-primary text-primary-foreground hover:bg-primary/90"},[v(d(J),{class:"w-3.5 h-3.5"}),e[17]||(e[17]=S(" New Page ",-1))]),C.value?(o(),a("div",Se,[L(t("input",{"onUpdate:modelValue":e[4]||(e[4]=l=>i.value=l),placeholder:"path/to/page.md",class:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-ring",onKeyup:A(W,["enter"])},null,544),[[N,i.value]]),t("div",Le,[t("button",{onClick:W,disabled:!i.value.trim(),class:"flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50"}," Create ",8,Ne),t("button",{onClick:e[5]||(e[5]=l=>{C.value=!1,i.value=""}),class:"px-2 py-1 text-xs rounded border border-border hover:bg-accent"}," Cancel ")])])):I("",!0)]),t("div",je,[V.value?(o(),a("div",De,"Loading...")):(o(),B($e,{key:1,pages:x.value,"selected-page":f.value,"search-query":T.value,onSelect:e[6]||(e[6]=l=>F(l)),onAddFile:e[7]||(e[7]=l=>{C.value=!0,i.value=l+"/"})},null,8,["pages","selected-page","search-query"]))])]),t("div",ze,[f.value?(o(),a(y,{key:1},[t("div",Be,[t("span",He,j(f.value),1),t("div",Ue,[b.value?(o(),a(y,{key:1},[t("button",{onClick:le,class:"p-1.5 rounded hover:bg-accent text-green-500",title:"Save"},[v(d(X),{class:"w-4 h-4"})]),t("button",{onClick:e[8]||(e[8]=l=>b.value=!1),class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Cancel"},[v(d(ee),{class:"w-4 h-4"})])],64)):(o(),a(y,{key:0},[t("button",{onClick:D,class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Edit"},[v(d(O),{class:"w-4 h-4"})]),t("button",{onClick:ae,class:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",title:"Delete"},[v(d(Y),{class:"w-4 h-4"})])],64))])]),t("div",We,[b.value?L((o(),a("textarea",{key:0,"onUpdate:modelValue":e[9]||(e[9]=l=>_.value=l),class:"w-full h-full min-h-[400px] font-mono text-sm bg-background border border-input rounded-md p-3 focus:outline-none focus:ring-1 focus:ring-ring resize-none"},null,512)),[[N,_.value]]):(o(),a(y,{key:1},[v(R,{content:h.value},null,8,["content"]),u.value.length>0?(o(),a("div",Ke,[t("div",Qe,[v(d(be),{class:"w-3.5 h-3.5"}),e[19]||(e[19]=S(" Backlinks ",-1))]),t("ul",Ze,[(o(!0),a(y,null,U(u.value,l=>(o(),a("li",{key:l},[t("button",{onClick:de=>F(l),class:"text-xs text-primary hover:underline font-mono"},j(l),9,Ae)]))),128))])])):I("",!0)],64))])],64)):(o(),a("div",Ee,[t("div",Ie,[v(d(Z),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),e[18]||(e[18]=t("p",null,"Select a page to view",-1))])]))])])):(o(),a("div",Re,[t("div",Ge,[t("div",Je,[e[21]||(e[21]=t("p",{class:"text-xs text-muted-foreground"}," Files copied verbatim into each new squad's wiki directory on creation. ",-1)),t("button",{onClick:e[10]||(e[10]=l=>$.value=!$.value),class:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-md bg-primary text-primary-foreground hover:bg-primary/90"},[v(d(J),{class:"w-3.5 h-3.5"}),e[20]||(e[20]=S(" New Template ",-1))]),$.value?(o(),a("div",Oe,[L(t("input",{"onUpdate:modelValue":e[11]||(e[11]=l=>k.value=l),placeholder:"filename.md",class:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-ring",onKeyup:A(K,["enter"])},null,544),[[N,k.value]]),t("div",Xe,[t("button",{onClick:K,disabled:!k.value.trim(),class:"flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50"}," Create ",8,Ye),t("button",{onClick:e[12]||(e[12]=l=>{$.value=!1,k.value=""}),class:"px-2 py-1 text-xs rounded border border-border hover:bg-accent"}," Cancel ")])])):I("",!0)]),t("div",et,[q.value?(o(),a("div",tt,"Loading...")):s.value.length===0?(o(),a("div",st,"No templates yet.")):(o(!0),a(y,{key:2},U(s.value,l=>(o(),a("button",{key:l,onClick:de=>ne(l),class:E(["w-full text-left px-2 py-1.5 text-xs rounded hover:bg-accent font-mono truncate",n.value===l?"bg-accent text-accent-foreground":"text-foreground"])},j(l),11,ot))),128))])]),t("div",lt,[n.value?(o(),a(y,{key:1},[t("div",rt,[t("span",it,j(n.value),1),t("div",ut,[m.value?(o(),a(y,{key:1},[t("button",{onClick:ie,class:"p-1.5 rounded hover:bg-accent text-green-500",title:"Save"},[v(d(X),{class:"w-4 h-4"})]),t("button",{onClick:e[13]||(e[13]=l=>m.value=!1),class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Cancel"},[v(d(ee),{class:"w-4 h-4"})])],64)):(o(),a(y,{key:0},[t("button",{onClick:re,class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Edit"},[v(d(O),{class:"w-4 h-4"})]),t("button",{onClick:ue,class:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",title:"Delete"},[v(d(Y),{class:"w-4 h-4"})])],64))])]),t("div",dt,[m.value?L((o(),a("textarea",{key:0,"onUpdate:modelValue":e[14]||(e[14]=l=>g.value=l),class:"w-full h-full min-h-[400px] font-mono text-sm bg-background border border-input rounded-md p-3 focus:outline-none focus:ring-1 focus:ring-ring resize-none"},null,512)),[[N,g.value]]):(o(),B(R,{key:1,content:p.value},null,8,["content"]))])],64)):(o(),a("div",at,[t("div",nt,[v(d(te),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),e[22]||(e[22]=t("p",null,"Select a template to edit",-1)),e[23]||(e[23]=t("p",{class:"text-xs mt-1"},"Templates are copied into new squads on creation",-1))])]))])]))]))}});export{ht as default};
36
+ */const be=P("LinkIcon",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ke={class:"select-none"},we=["onClick"],_e={class:"truncate"},Ce=["onClick"],$e=oe({__name:"WikiTree",props:{pages:{},selectedPage:{},searchQuery:{}},emits:["select","addFile"],setup(H,{emit:w}){const x=H,f=w,h=c(new Set);function b(i){const u=[];for(const n of i){const p=n.split("/");let m=u;for(let g=0;g<p.length;g++){const q=p[g],$=p.slice(0,g+1).join("/"),k=g<p.length-1;let F=m.find(D=>D.name===q&&D.isFolder===k);F||(F={name:q,path:$,children:[],isFolder:k},m.push(F)),m=F.children}}const o=n=>{n.sort((p,m)=>p.isFolder!==m.isFolder?p.isFolder?-1:1:p.name.localeCompare(m.name)),n.forEach(p=>o(p.children))};return o(u),u}const _=A(()=>{let i=x.pages;if(x.searchQuery){const u=x.searchQuery.toLowerCase();i=x.pages.filter(o=>o.toLowerCase().includes(u))}return b(i)});se(()=>x.selectedPage,i=>{if(!i)return;const u=i.split("/");for(let o=1;o<u.length;o++)h.value.add(u.slice(0,o).join("/"))},{immediate:!0});function T(i){h.value.has(i)?h.value.delete(i):h.value.add(i)}function V(i,u){const o=[];for(const n of i)o.push({node:n,depth:u}),n.isFolder&&h.value.has(n.path)&&o.push(...V(n.children,u+1));return o}const C=A(()=>V(_.value,0));return(i,u)=>(s(),a("div",ke,[(s(!0),a(y,null,Q(C.value,({node:o,depth:n})=>(s(),a("div",{key:o.path,class:"group relative"},[t("button",{onClick:p=>o.isFolder?T(o.path):f("select",o.path),class:E(["w-full text-left flex items-center gap-1 py-1 text-xs rounded hover:bg-accent transition-colors",{"bg-accent font-medium":!o.isFolder&&H.selectedPage===o.path}]),style:ce({paddingLeft:n*12+8+"px"})},[o.isFolder?(s(),a(y,{key:0},[h.value.has(o.path)?(s(),B(d(me),{key:0,class:"w-3 h-3 shrink-0 text-muted-foreground"})):(s(),B(d(xe),{key:1,class:"w-3 h-3 shrink-0 text-muted-foreground"})),v(d(ye),{class:"w-3.5 h-3.5 shrink-0 text-muted-foreground"})],64)):(s(),a(y,{key:1},[u[0]||(u[0]=t("span",{class:"w-3 shrink-0"},null,-1)),v(d(ge),{class:"w-3.5 h-3.5 shrink-0 text-muted-foreground"})],64)),t("span",_e,j(o.name),1)],14,we),o.isFolder?(s(),a("button",{key:0,onClick:ve(p=>f("addFile",o.path),["stop"]),class:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-primary/10 text-muted-foreground hover:text-primary transition-all",title:"Add file here"},[v(d(he),{class:"w-3.5 h-3.5"})],8,Ce)):I("",!0)]))),128))]))}}),Fe={class:"flex flex-col h-full"},Pe={class:"flex border-b border-border shrink-0"},qe={key:0,class:"flex flex-1 overflow-hidden"},Me={class:"w-64 border-r border-border flex flex-col shrink-0"},Te={class:"p-3 border-b border-border space-y-2"},Ve={class:"relative"},Se={key:0,class:"space-y-1.5"},Le={class:"flex gap-1"},Ne=["disabled"],je={class:"flex-1 overflow-y-auto p-2"},De={key:0,class:"text-xs text-muted-foreground p-2"},ze={class:"flex-1 flex flex-col overflow-hidden"},Ee={key:0,class:"flex items-center justify-center h-full text-muted-foreground"},Ie={class:"text-center"},Be={class:"flex items-center justify-between px-4 py-2 border-b border-border"},He={class:"text-sm font-medium font-mono"},Qe={class:"flex gap-1"},Ue={class:"flex-1 overflow-y-auto p-4"},We={key:0,class:"mt-8 pt-4 border-t border-border"},Ae={class:"flex items-center gap-1.5 mb-2 text-xs font-medium text-muted-foreground"},Ke={class:"space-y-1"},Ze=["onClick"],Oe={key:1,class:"flex flex-1 overflow-hidden"},Re={class:"w-64 border-r border-border flex flex-col shrink-0"},Ge={class:"p-3 border-b border-border space-y-2"},Xe={key:0,class:"space-y-1.5"},Je={class:"flex gap-1"},Ye=["disabled"],et={class:"flex-1 overflow-y-auto p-2"},tt={key:0,class:"text-xs text-muted-foreground p-2"},ot={key:1,class:"text-xs text-muted-foreground p-2"},st=["onClick"],lt={class:"flex-1 flex flex-col overflow-hidden"},at={key:0,class:"flex items-center justify-center h-full text-muted-foreground"},nt={class:"text-center"},rt={class:"flex items-center justify-between px-4 py-2 border-b border-border"},it={class:"text-sm font-medium font-mono"},ut={class:"flex gap-1"},dt={class:"flex-1 overflow-y-auto p-4"},gt=oe({__name:"WikiView",setup(H){const w=c("pages"),x=c([]),f=c(null),h=c(""),b=c(!1),_=c(""),T=c(""),V=c(!0),C=c(!1),i=c(""),u=c([]),o=c([]),n=c(null),p=c(""),m=c(!1),g=c(""),q=c(!1),$=c(!1),k=c("");pe(async()=>{try{x.value=await M("/wiki/pages")}finally{V.value=!1}}),se(w,async r=>{if(r==="templates"&&o.value.length===0){q.value=!0;try{o.value=await M("/wiki/templates/squad")}finally{q.value=!1}}});async function F(r){f.value=r,b.value=!1;const e=await M(`/wiki/page/${r}`);h.value=e.content,u.value=await M(`/wiki/backlinks/${r}`)}function D(){_.value=h.value,b.value=!0}async function le(){f.value&&(await z(`/wiki/page/${f.value}`,{content:_.value}),h.value=_.value,b.value=!1,u.value=await M(`/wiki/backlinks/${f.value}`))}async function ae(){f.value&&confirm(`Delete "${f.value}"?`)&&(await R(`/wiki/page/${f.value}`),x.value=x.value.filter(r=>r!==f.value),f.value=null,h.value="",u.value=[])}async function U(){const r=i.value.trim();if(!r)return;const e=r.endsWith(".md")?r:`${r}.md`;await z(`/wiki/page/${e}`,{content:""}),x.value.includes(e)||(x.value.push(e),x.value.sort()),C.value=!1,i.value="",f.value=e,h.value="",_.value="",b.value=!0,u.value=[]}async function ne(r){n.value=r,m.value=!1;const e=await M(`/wiki/template/squad/${r}`);p.value=e.content}function re(){g.value=p.value,m.value=!0}async function ie(){n.value&&(await z(`/wiki/template/squad/${n.value}`,{content:g.value}),p.value=g.value,m.value=!1)}async function ue(){n.value&&confirm(`Delete template "${n.value}"?`)&&(await R(`/wiki/template/squad/${n.value}`),o.value=o.value.filter(r=>r!==n.value),n.value=null,p.value="")}async function W(){const r=k.value.trim();if(!r)return;const e=r.endsWith(".md")?r:`${r}.md`;await z(`/wiki/template/squad/${e}`,{content:""}),o.value.includes(e)||(o.value.push(e),o.value.sort()),$.value=!1,k.value="",n.value=e,p.value="",g.value="",m.value=!0}return(r,e)=>(s(),a("div",Fe,[t("div",Pe,[t("button",{onClick:e[0]||(e[0]=l=>w.value="pages"),class:E(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",w.value==="pages"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"])},[v(d(K),{class:"inline w-4 h-4 mr-1.5 -mt-0.5"}),e[15]||(e[15]=S(" Pages ",-1))],2),t("button",{onClick:e[1]||(e[1]=l=>w.value="templates"),class:E(["px-4 py-2 text-sm font-medium border-b-2 transition-colors",w.value==="templates"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"])},[v(d(te),{class:"inline w-4 h-4 mr-1.5 -mt-0.5"}),e[16]||(e[16]=S(" Squad Templates ",-1))],2)]),w.value==="pages"?(s(),a("div",qe,[t("div",Me,[t("div",Te,[t("div",Ve,[v(d(fe),{class:"absolute left-2.5 top-2.5 w-3.5 h-3.5 text-muted-foreground"}),L(t("input",{"onUpdate:modelValue":e[2]||(e[2]=l=>T.value=l),placeholder:"Search pages...",class:"w-full rounded-md border border-input bg-background pl-8 pr-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-ring"},null,512),[[N,T.value]])]),t("button",{onClick:e[3]||(e[3]=l=>C.value=!C.value),class:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-md bg-primary text-primary-foreground hover:bg-primary/90"},[v(d(G),{class:"w-3.5 h-3.5"}),e[17]||(e[17]=S(" New Page ",-1))]),C.value?(s(),a("div",Se,[L(t("input",{"onUpdate:modelValue":e[4]||(e[4]=l=>i.value=l),placeholder:"path/to/page.md",class:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-ring",onKeyup:Z(U,["enter"])},null,544),[[N,i.value]]),t("div",Le,[t("button",{onClick:U,disabled:!i.value.trim(),class:"flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50"}," Create ",8,Ne),t("button",{onClick:e[5]||(e[5]=l=>{C.value=!1,i.value=""}),class:"px-2 py-1 text-xs rounded border border-border hover:bg-accent"}," Cancel ")])])):I("",!0)]),t("div",je,[V.value?(s(),a("div",De,"Loading...")):(s(),B($e,{key:1,pages:x.value,"selected-page":f.value,"search-query":T.value,onSelect:e[6]||(e[6]=l=>F(l)),onAddFile:e[7]||(e[7]=l=>{C.value=!0,i.value=l+"/"})},null,8,["pages","selected-page","search-query"]))])]),t("div",ze,[f.value?(s(),a(y,{key:1},[t("div",Be,[t("span",He,j(f.value),1),t("div",Qe,[b.value?(s(),a(y,{key:1},[t("button",{onClick:le,class:"p-1.5 rounded hover:bg-accent text-green-500",title:"Save"},[v(d(J),{class:"w-4 h-4"})]),t("button",{onClick:e[8]||(e[8]=l=>b.value=!1),class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Cancel"},[v(d(ee),{class:"w-4 h-4"})])],64)):(s(),a(y,{key:0},[t("button",{onClick:D,class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Edit"},[v(d(X),{class:"w-4 h-4"})]),t("button",{onClick:ae,class:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",title:"Delete"},[v(d(Y),{class:"w-4 h-4"})])],64))])]),t("div",Ue,[b.value?L((s(),a("textarea",{key:0,"onUpdate:modelValue":e[9]||(e[9]=l=>_.value=l),class:"w-full h-full min-h-[400px] font-mono text-sm bg-background border border-input rounded-md p-3 focus:outline-none focus:ring-1 focus:ring-ring resize-none"},null,512)),[[N,_.value]]):(s(),a(y,{key:1},[v(O,{content:h.value},null,8,["content"]),u.value.length>0?(s(),a("div",We,[t("div",Ae,[v(d(be),{class:"w-3.5 h-3.5"}),e[19]||(e[19]=S(" Backlinks ",-1))]),t("ul",Ke,[(s(!0),a(y,null,Q(u.value,l=>(s(),a("li",{key:l},[t("button",{onClick:de=>F(l),class:"text-xs text-primary hover:underline font-mono"},j(l),9,Ze)]))),128))])])):I("",!0)],64))])],64)):(s(),a("div",Ee,[t("div",Ie,[v(d(K),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),e[18]||(e[18]=t("p",null,"Select a page to view",-1))])]))])])):(s(),a("div",Oe,[t("div",Re,[t("div",Ge,[e[21]||(e[21]=t("p",{class:"text-xs text-muted-foreground"}," Files copied verbatim into each new squad's wiki directory on creation. ",-1)),t("button",{onClick:e[10]||(e[10]=l=>$.value=!$.value),class:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-md bg-primary text-primary-foreground hover:bg-primary/90"},[v(d(G),{class:"w-3.5 h-3.5"}),e[20]||(e[20]=S(" New Template ",-1))]),$.value?(s(),a("div",Xe,[L(t("input",{"onUpdate:modelValue":e[11]||(e[11]=l=>k.value=l),placeholder:"filename.md",class:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-ring",onKeyup:Z(W,["enter"])},null,544),[[N,k.value]]),t("div",Je,[t("button",{onClick:W,disabled:!k.value.trim(),class:"flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50"}," Create ",8,Ye),t("button",{onClick:e[12]||(e[12]=l=>{$.value=!1,k.value=""}),class:"px-2 py-1 text-xs rounded border border-border hover:bg-accent"}," Cancel ")])])):I("",!0)]),t("div",et,[q.value?(s(),a("div",tt,"Loading...")):o.value.length===0?(s(),a("div",ot,"No templates yet.")):(s(!0),a(y,{key:2},Q(o.value,l=>(s(),a("button",{key:l,onClick:de=>ne(l),class:E(["w-full text-left px-2 py-1.5 text-xs rounded hover:bg-accent font-mono truncate",n.value===l?"bg-accent text-accent-foreground":"text-foreground"])},j(l),11,st))),128))])]),t("div",lt,[n.value?(s(),a(y,{key:1},[t("div",rt,[t("span",it,j(n.value),1),t("div",ut,[m.value?(s(),a(y,{key:1},[t("button",{onClick:ie,class:"p-1.5 rounded hover:bg-accent text-green-500",title:"Save"},[v(d(J),{class:"w-4 h-4"})]),t("button",{onClick:e[13]||(e[13]=l=>m.value=!1),class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Cancel"},[v(d(ee),{class:"w-4 h-4"})])],64)):(s(),a(y,{key:0},[t("button",{onClick:re,class:"p-1.5 rounded hover:bg-accent text-muted-foreground",title:"Edit"},[v(d(X),{class:"w-4 h-4"})]),t("button",{onClick:ue,class:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",title:"Delete"},[v(d(Y),{class:"w-4 h-4"})])],64))])]),t("div",dt,[m.value?L((s(),a("textarea",{key:0,"onUpdate:modelValue":e[14]||(e[14]=l=>g.value=l),class:"w-full h-full min-h-[400px] font-mono text-sm bg-background border border-input rounded-md p-3 focus:outline-none focus:ring-1 focus:ring-ring resize-none"},null,512)),[[N,g.value]]):(s(),B(O,{key:1,content:p.value},null,8,["content"]))])],64)):(s(),a("div",at,[t("div",nt,[v(d(te),{class:"w-12 h-12 mx-auto mb-3 opacity-50"}),e[22]||(e[22]=t("p",null,"Select a template to edit",-1)),e[23]||(e[23]=t("p",{class:"text-xs mt-1"},"Templates are copied into new squads on creation",-1))])]))])]))]))}});export{gt as default};
@@ -0,0 +1 @@
1
+ import{E as i,y as c}from"./index-DSAUDIwK.js";const o="/api";function u(t){try{return JSON.parse(atob(t.split(".")[1])).exp*1e3<=Date.now()+6e4}catch{return!0}}async function n(){const t=i(),e={"Content-Type":"application/json"};return t.token&&u(t.token)&&await t.refreshToken(),t.token&&(e.Authorization=`Bearer ${t.token}`),e}async function s(t,e){if(t.status===401){const r=i();try{if(await r.refreshToken(),r.token){const a=await e();if(a.status===401)throw r.logout(),c.push("/login"),new Error("Session expired");return a}}catch{}throw r.logout(),c.push("/login"),new Error("Session expired")}return t}async function w(t){const e=await s(await fetch(`${o}${t}`,{headers:await n()}),async()=>fetch(`${o}${t}`,{headers:await n()}));if(!e.ok)throw new Error(`API error: ${e.status}`);return e.json()}async function f(t,e){const r={method:"POST",headers:await n(),body:e?JSON.stringify(e):void 0},a=await s(await fetch(`${o}${t}`,r),async()=>fetch(`${o}${t}`,{...r,headers:await n()}));if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function $(t,e){const r={method:"PUT",headers:await n(),body:e?JSON.stringify(e):void 0},a=await s(await fetch(`${o}${t}`,r),async()=>fetch(`${o}${t}`,{...r,headers:await n()}));if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function d(t){const e={method:"DELETE",headers:await n()},r=await s(await fetch(`${o}${t}`,e),async()=>fetch(`${o}${t}`,{...e,headers:await n()}));if(!r.ok)throw new Error(`API error: ${r.status}`);return r.json()}function p(){const t=i(),e=`${o}/stream?token=${t.token??""}`;return new EventSource(e)}export{d as a,w as b,f as c,$ as d,p as e};
@@ -1,4 +1,4 @@
1
- import{q as e}from"./index-CiZnRvN4.js";/**
1
+ import{l as e}from"./index-DSAUDIwK.js";/**
2
2
  * @license lucide-vue-next v0.474.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{q as c}from"./index-CiZnRvN4.js";/**
1
+ import{l as c}from"./index-DSAUDIwK.js";/**
2
2
  * @license lucide-vue-next v0.474.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.