agi-farm 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -649,12 +649,22 @@ The dashboard enables direct control over team operations via authenticated REST
649
649
  - `GET /api/usage` — Usage and cost aggregates for dashboard
650
650
 
651
651
  **CRUD Operations:**
652
- - `POST /api/task` — Create a new task with assignee, priority, dependencies
653
- - `POST /api/agent/:id/message` — Send a message to a specific agent
652
+ - `POST /api/tasks` — Create a new task with assignee, priority, dependencies
653
+ - `POST /api/comms/:id/send` — Send a message to a specific agent inbox
654
654
  - `POST /api/broadcast` — Post a team-wide broadcast message
655
655
  - `POST /api/knowledge` — Add a shared knowledge entry
656
656
  - `DELETE /api/knowledge/:id` — Remove a knowledge entry
657
657
 
658
+ **LobsterBoard Parity Foundations (P0):**
659
+ - `GET /api/auth/status` — PIN/public-mode status + write unlock state
660
+ - `POST /api/auth/verify-pin` — Verify PIN and issue write auth token
661
+ - `POST /api/auth/set-pin` / `POST /api/auth/remove-pin` — Manage dashboard PIN lock
662
+ - `POST /api/auth/public-mode` — Toggle read-only public mode
663
+ - `GET /api/secrets` / `GET /api/secrets/:scope` — List masked secrets metadata
664
+ - `POST /api/secrets/:scope` / `DELETE /api/secrets/:scope/:key` — Store/delete scoped secrets
665
+ - `GET /api/templates` / `GET /api/templates/:id` — List and inspect dashboard templates
666
+ - `POST /api/templates/export` / `POST /api/templates/import` — Export/import template settings
667
+
658
668
  **Auto-Update:**
659
669
  - `GET /api/update-check` — Force a fresh GitHub release check
660
670
  - `POST /api/update-install` — Install latest version via npm
@@ -1 +1 @@
1
- import{r as p,a4 as e,at as j,au as F,av as S,ak as C}from"./vendor-gUVFsxOc.js";import{a as E}from"./index-B3IWXYRY.js";const y={active:{bg:"#EEF2FF",color:"var(--accent)",label:"Active"},available:{bg:"#ECFDF5",color:"var(--mint)",label:"Available"},busy:{bg:"#FFFBEB",color:"var(--amber)",label:"Busy"},error:{bg:"#FEF2F2",color:"var(--red)",label:"Error"},running:{bg:"#EEF2FF",color:"var(--accent)",label:"Running"}};function k({minutes:s}){const a=s??999,r=a<5?"var(--mint)":a<15?"var(--amber)":"var(--red)",d=Math.max(0,Math.min(100,100-a/60*100));return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:"var(--muted)",marginBottom:4},children:[e.jsx("span",{children:"Heartbeat"}),e.jsx("span",{style:{color:r,fontWeight:600},children:a<999?`${a}m ago`:"Offline"})]}),e.jsx("div",{className:"progress-track",children:e.jsx("div",{className:"progress-fill",style:{width:`${d}%`,background:r}})})]})}function b({label:s,value:a,color:r}){return e.jsxs("div",{style:{textAlign:"center",padding:"10px 8px",background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:r||"var(--text)"},children:a}),e.jsx("div",{style:{fontSize:9,color:"var(--muted)",fontWeight:700,textTransform:"uppercase",marginTop:2},children:s})]})}function z({agent:s,tasks:a,toast:r,index:d}){const[c,x]=p.useState(!1),[i,g]=p.useState(""),[u,f]=p.useState(!1),v=a.filter(n=>n.assigned_to===s.id),m=v.find(n=>n.status==="in-progress"),t=v.find(n=>n.status==="needs_human_decision"),l=!!t,o=y[s.status]||y.available,h=async()=>{if(i.trim()){f(!0);try{await E(`/api/comms/${s.id}/send`,{message:i.trim()}),r?.(`Message sent to ${s.name}`,"success"),g(""),x(!1)}catch(n){r?.(n.message,"error")}f(!1)}};return e.jsxs("div",{className:"card fade-in",style:{animationDelay:`${d*.05}s`,display:"flex",flexDirection:"column",gap:16,borderColor:l?"#EDE9FE":s.status==="error"?"#FEE2E2":"var(--border)",borderWidth:l||s.status==="error"?2:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("span",{style:{fontSize:28,flexShrink:0},children:s.emoji||"🤖"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)",marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name||s.id}),e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:6},children:s.role||"Agent"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:o.bg,color:o.color,borderRadius:999,padding:"2px 10px",fontSize:11,fontWeight:600},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o.color,display:"inline-block"}}),o.label]})]})]}),l?e.jsxs("div",{style:{padding:"10px 14px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:10},children:[e.jsx("div",{style:{fontSize:10,color:"var(--purple)",fontWeight:700,textTransform:"uppercase",marginBottom:3},children:"⚡ HITL Required"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",fontWeight:500},children:t?.hitl_reason||t?.title})]}):m?e.jsxs("div",{style:{padding:"10px 14px",background:"#EEF2FF",border:"1px solid #E0E7FF",borderRadius:10},children:[e.jsx("div",{style:{fontSize:10,color:"var(--accent)",fontWeight:700,textTransform:"uppercase",marginBottom:3},children:"▶ Working On"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.title})]}):e.jsx("div",{style:{padding:"10px 14px",background:"#F8FAFC",borderRadius:10,textAlign:"center"},children:e.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"Idle — awaiting task"})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[e.jsx(b,{label:"Done",value:s.tasks_completed??0,color:"var(--mint)"}),e.jsx(b,{label:"Failed",value:s.tasks_failed??0,color:"var(--red)"}),e.jsx(b,{label:"Cred.",value:(s.credibility||1).toFixed(1),color:"var(--accent)"})]}),e.jsx(k,{minutes:s.heartbeat_age_minutes}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-dim)",display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:"var(--muted)"},children:"Model"}),e.jsx("span",{style:{fontWeight:600},children:s.model||"--"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(j,{size:11,color:"var(--muted)"}),e.jsx("span",{style:{color:"var(--muted)"},children:"Inbox"})]}),e.jsx("span",{style:{fontWeight:600,color:s.inbox_count>0?"var(--amber)":"var(--text-dim)"},children:s.inbox_count>0?`${s.inbox_count} messages`:"Empty"})]})]}),e.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12},children:c?e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{flex:1,fontSize:12},placeholder:"Send a message…",value:i,onChange:n=>g(n.target.value),onKeyDown:n=>n.key==="Enter"&&h(),autoFocus:!0}),e.jsxs("button",{onClick:h,disabled:u||!i.trim(),style:{background:"var(--accent)",color:"#fff",border:"none",borderRadius:10,padding:"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:600},children:[e.jsx(F,{size:13})," ",u?"…":"Send"]}),e.jsx("button",{onClick:()=>x(!1),style:{background:"transparent",border:"1px solid var(--border)",borderRadius:10,padding:"8px 10px",cursor:"pointer"},children:e.jsx(S,{size:13,color:"var(--muted)"})})]}):e.jsxs("button",{onClick:()=>x(!0),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:8,background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:"10px",cursor:"pointer",fontSize:12,color:"var(--text-dim)",fontWeight:500,transition:"all 0.15s"},children:[e.jsx(C,{size:13})," Message Agent"]})})]})}function A({data:s,toast:a}){const{agents:r=[],tasks:d=[]}=s||{},[c,x]=p.useState(""),[i,g]=p.useState("all"),u=r.filter(t=>{const l=c.toLowerCase(),o=!c||(t.name||"").toLowerCase().includes(l)||(t.id||"").toLowerCase().includes(l),h=i==="all"||t.status===i;return o&&h}),f=r.filter(t=>t.status!=="available").length,v=r.filter(t=>t.status==="available").length,m=r.filter(t=>t.status==="error").length;return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:28},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Agent Directory"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Monitor and message your autonomous agent fleet"})]}),e.jsxs("div",{style:{display:"flex",gap:10},children:[[{label:`${f} Active`,color:"var(--accent)",bg:"#EEF2FF",status:"active"},{label:`${v} Idle`,color:"var(--mint)",bg:"#ECFDF5",status:"available"},{label:`${m} Error`,color:"var(--red)",bg:"#FEF2F2",status:"error"}].map(t=>e.jsx("button",{onClick:()=>g(i===t.status?"all":t.status),style:{background:i===t.status?t.bg:"#F8FAFC",color:i===t.status?t.color:"var(--muted)",border:`1px solid ${i===t.status?t.color+"44":"var(--border)"}`,borderRadius:999,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:t.label},t.status)),e.jsx("input",{className:"input-base",placeholder:"Search agents…",value:c,onChange:t=>x(t.target.value),style:{marginLeft:"auto",width:220,fontSize:13}})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:20},children:u.length>0?u.map((t,l)=>e.jsx(z,{agent:t,tasks:d,toast:a,index:l},t.id)):e.jsx("div",{style:{gridColumn:"1 / -1",textAlign:"center",padding:64,color:"var(--muted)",fontSize:13},children:"No agents match your filter"})})]})}export{A as default};
1
+ import{r as p,a4 as e,at as j,au as F,av as S,ak as C}from"./vendor-gUVFsxOc.js";import{a as E}from"./index-DUjHkafG.js";const y={active:{bg:"#EEF2FF",color:"var(--accent)",label:"Active"},available:{bg:"#ECFDF5",color:"var(--mint)",label:"Available"},busy:{bg:"#FFFBEB",color:"var(--amber)",label:"Busy"},error:{bg:"#FEF2F2",color:"var(--red)",label:"Error"},running:{bg:"#EEF2FF",color:"var(--accent)",label:"Running"}};function k({minutes:s}){const a=s??999,r=a<5?"var(--mint)":a<15?"var(--amber)":"var(--red)",d=Math.max(0,Math.min(100,100-a/60*100));return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:"var(--muted)",marginBottom:4},children:[e.jsx("span",{children:"Heartbeat"}),e.jsx("span",{style:{color:r,fontWeight:600},children:a<999?`${a}m ago`:"Offline"})]}),e.jsx("div",{className:"progress-track",children:e.jsx("div",{className:"progress-fill",style:{width:`${d}%`,background:r}})})]})}function b({label:s,value:a,color:r}){return e.jsxs("div",{style:{textAlign:"center",padding:"10px 8px",background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:r||"var(--text)"},children:a}),e.jsx("div",{style:{fontSize:9,color:"var(--muted)",fontWeight:700,textTransform:"uppercase",marginTop:2},children:s})]})}function z({agent:s,tasks:a,toast:r,index:d}){const[c,x]=p.useState(!1),[i,g]=p.useState(""),[u,f]=p.useState(!1),v=a.filter(n=>n.assigned_to===s.id),m=v.find(n=>n.status==="in-progress"),t=v.find(n=>n.status==="needs_human_decision"),l=!!t,o=y[s.status]||y.available,h=async()=>{if(i.trim()){f(!0);try{await E(`/api/comms/${s.id}/send`,{message:i.trim()}),r?.(`Message sent to ${s.name}`,"success"),g(""),x(!1)}catch(n){r?.(n.message,"error")}f(!1)}};return e.jsxs("div",{className:"card fade-in",style:{animationDelay:`${d*.05}s`,display:"flex",flexDirection:"column",gap:16,borderColor:l?"#EDE9FE":s.status==="error"?"#FEE2E2":"var(--border)",borderWidth:l||s.status==="error"?2:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("span",{style:{fontSize:28,flexShrink:0},children:s.emoji||"🤖"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)",marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name||s.id}),e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:6},children:s.role||"Agent"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,background:o.bg,color:o.color,borderRadius:999,padding:"2px 10px",fontSize:11,fontWeight:600},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o.color,display:"inline-block"}}),o.label]})]})]}),l?e.jsxs("div",{style:{padding:"10px 14px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:10},children:[e.jsx("div",{style:{fontSize:10,color:"var(--purple)",fontWeight:700,textTransform:"uppercase",marginBottom:3},children:"⚡ HITL Required"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",fontWeight:500},children:t?.hitl_reason||t?.title})]}):m?e.jsxs("div",{style:{padding:"10px 14px",background:"#EEF2FF",border:"1px solid #E0E7FF",borderRadius:10},children:[e.jsx("div",{style:{fontSize:10,color:"var(--accent)",fontWeight:700,textTransform:"uppercase",marginBottom:3},children:"▶ Working On"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.title})]}):e.jsx("div",{style:{padding:"10px 14px",background:"#F8FAFC",borderRadius:10,textAlign:"center"},children:e.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"Idle — awaiting task"})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8},children:[e.jsx(b,{label:"Done",value:s.tasks_completed??0,color:"var(--mint)"}),e.jsx(b,{label:"Failed",value:s.tasks_failed??0,color:"var(--red)"}),e.jsx(b,{label:"Cred.",value:(s.credibility||1).toFixed(1),color:"var(--accent)"})]}),e.jsx(k,{minutes:s.heartbeat_age_minutes}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-dim)",display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:"var(--muted)"},children:"Model"}),e.jsx("span",{style:{fontWeight:600},children:s.model||"--"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(j,{size:11,color:"var(--muted)"}),e.jsx("span",{style:{color:"var(--muted)"},children:"Inbox"})]}),e.jsx("span",{style:{fontWeight:600,color:s.inbox_count>0?"var(--amber)":"var(--text-dim)"},children:s.inbox_count>0?`${s.inbox_count} messages`:"Empty"})]})]}),e.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:12},children:c?e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{flex:1,fontSize:12},placeholder:"Send a message…",value:i,onChange:n=>g(n.target.value),onKeyDown:n=>n.key==="Enter"&&h(),autoFocus:!0}),e.jsxs("button",{onClick:h,disabled:u||!i.trim(),style:{background:"var(--accent)",color:"#fff",border:"none",borderRadius:10,padding:"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:600},children:[e.jsx(F,{size:13})," ",u?"…":"Send"]}),e.jsx("button",{onClick:()=>x(!1),style:{background:"transparent",border:"1px solid var(--border)",borderRadius:10,padding:"8px 10px",cursor:"pointer"},children:e.jsx(S,{size:13,color:"var(--muted)"})})]}):e.jsxs("button",{onClick:()=>x(!0),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:8,background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:"10px",cursor:"pointer",fontSize:12,color:"var(--text-dim)",fontWeight:500,transition:"all 0.15s"},children:[e.jsx(C,{size:13})," Message Agent"]})})]})}function A({data:s,toast:a}){const{agents:r=[],tasks:d=[]}=s||{},[c,x]=p.useState(""),[i,g]=p.useState("all"),u=r.filter(t=>{const l=c.toLowerCase(),o=!c||(t.name||"").toLowerCase().includes(l)||(t.id||"").toLowerCase().includes(l),h=i==="all"||t.status===i;return o&&h}),f=r.filter(t=>t.status!=="available").length,v=r.filter(t=>t.status==="available").length,m=r.filter(t=>t.status==="error").length;return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:28},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Agent Directory"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Monitor and message your autonomous agent fleet"})]}),e.jsxs("div",{style:{display:"flex",gap:10},children:[[{label:`${f} Active`,color:"var(--accent)",bg:"#EEF2FF",status:"active"},{label:`${v} Idle`,color:"var(--mint)",bg:"#ECFDF5",status:"available"},{label:`${m} Error`,color:"var(--red)",bg:"#FEF2F2",status:"error"}].map(t=>e.jsx("button",{onClick:()=>g(i===t.status?"all":t.status),style:{background:i===t.status?t.bg:"#F8FAFC",color:i===t.status?t.color:"var(--muted)",border:`1px solid ${i===t.status?t.color+"44":"var(--border)"}`,borderRadius:999,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:t.label},t.status)),e.jsx("input",{className:"input-base",placeholder:"Search agents…",value:c,onChange:t=>x(t.target.value),style:{marginLeft:"auto",width:220,fontSize:13}})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:20},children:u.length>0?u.map((t,l)=>e.jsx(z,{agent:t,tasks:d,toast:a,index:l},t.id)):e.jsx("div",{style:{gridColumn:"1 / -1",textAlign:"center",padding:64,color:"var(--muted)",fontSize:13},children:"No agents match your filter"})})]})}export{A as default};
@@ -1 +1 @@
1
- import{r as c,a4 as t,ax as j,am as b,aB as F,aD as z}from"./vendor-gUVFsxOc.js";import{a as S}from"./index-B3IWXYRY.js";function C(o){if(!o)return"—";try{const r=Math.round((Date.now()-new Date(o))/6e4);return r<1?"just now":r<60?`${r}m ago`:r<1440?`${Math.round(r/60)}h ago`:`${Math.round(r/1440)}d ago`}catch{return o}}function k({data:o,toast:r}){const{approvals:l=[],agents:h=[]}=o||{},[n,m]=c.useState({}),[g,v]=c.useState({}),[d,x]=c.useState({}),a=l.filter(e=>e.status==="pending"&&!n[e.id]),u=l.filter(e=>n[e.id]),p=l.filter(e=>e.status!=="pending"&&!n[e.id]);async function f(e,s){x(i=>({...i,[e.id]:s}));try{await S(`/api/approvals/${e.id}/${s}`,{note:g[e.id]||""}),m(i=>({...i,[e.id]:s})),r?.(`Approval ${s}d`,s==="approve"?"success":"error")}catch(i){r?.(i.message,"error")}x(i=>({...i,[e.id]:null}))}return t.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{marginBottom:4},children:"Approval Queue"}),t.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[a.length," pending approvals require a decision"]})]}),a.length===0&&t.jsxs("div",{className:"card",style:{textAlign:"center",padding:48},children:[t.jsx("div",{style:{fontSize:32,marginBottom:12},children:"✅"}),t.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text)"},children:"All caught up"}),t.jsx("div",{style:{fontSize:13,color:"var(--muted)",marginTop:4},children:"No pending approvals"})]}),a.map(e=>{const s=h.find(i=>i.id===e.requestedBy||i.id===e.agentId);return t.jsxs("div",{style:{background:"#FDFCFF",border:"2px solid #EDE9FE",borderRadius:16,padding:24},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)",marginBottom:4},children:e.action||"Action requires approval"}),t.jsxs("div",{style:{display:"flex",gap:10,fontSize:12,color:"var(--muted)"},children:[s&&t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx(j,{size:11}),s.emoji," ",s.name]}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx(b,{size:11}),C(e.created_at||e.requestedAt)]})]})]}),t.jsx("span",{style:{background:"#F5F3FF",color:"var(--purple)",borderRadius:999,padding:"4px 12px",fontSize:11,fontWeight:600},children:"Pending"})]}),e.reason&&t.jsxs("div",{style:{padding:"12px 14px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:10,marginBottom:14},children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--purple)",marginBottom:4},children:"Reason"}),t.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:e.reason})]}),e.payload&&Object.keys(e.payload).length>0&&t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--muted)",textTransform:"uppercase",marginBottom:6},children:"Payload"}),t.jsx("pre",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:12,fontSize:11,color:"var(--text-dim)",overflow:"auto",fontFamily:"var(--font-mono)",maxHeight:140},children:JSON.stringify(e.payload,null,2)})]}),t.jsx("input",{className:"input-base",placeholder:"Optional note…",value:g[e.id]||"",onChange:i=>v(y=>({...y,[e.id]:i.target.value})),style:{marginBottom:12,width:"100%",boxSizing:"border-box"}}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsxs("button",{onClick:()=>f(e,"approve"),disabled:!!d[e.id],style:{flex:1,padding:12,background:"#ECFDF5",border:"1px solid #6EE7B7",color:"var(--mint)",borderRadius:10,fontWeight:700,fontSize:13,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[t.jsx(F,{size:15})," ",d[e.id]==="approve"?"Processing…":"Approve"]}),t.jsxs("button",{onClick:()=>f(e,"reject"),disabled:!!d[e.id],style:{flex:1,padding:12,background:"#FEF2F2",border:"1px solid #FCA5A5",color:"var(--red)",borderRadius:10,fontWeight:700,fontSize:13,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[t.jsx(z,{size:15})," ",d[e.id]==="reject"?"Processing…":"Reject"]})]})]},e.id)}),(u.length>0||p.length>0)&&t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:12,fontSize:16,color:"var(--text-dim)"},children:"Resolved"}),[...u,...p].map(e=>t.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,padding:"14px 18px",marginBottom:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",fontWeight:500},children:e.action||e.id}),t.jsx("span",{style:{background:(n[e.id]||e.status)==="approve"||(n[e.id]||e.status)==="approved"?"#ECFDF5":"#FEF2F2",color:(n[e.id]||e.status)==="approve"||(n[e.id]||e.status)==="approved"?"var(--mint)":"var(--red)",borderRadius:999,padding:"3px 10px",fontSize:11,fontWeight:600},children:n[e.id]||e.status})]},e.id))]})]})}export{k as default};
1
+ import{r as c,a4 as t,ax as j,am as b,aB as F,aD as z}from"./vendor-gUVFsxOc.js";import{a as S}from"./index-DUjHkafG.js";function C(o){if(!o)return"—";try{const r=Math.round((Date.now()-new Date(o))/6e4);return r<1?"just now":r<60?`${r}m ago`:r<1440?`${Math.round(r/60)}h ago`:`${Math.round(r/1440)}d ago`}catch{return o}}function k({data:o,toast:r}){const{approvals:l=[],agents:h=[]}=o||{},[n,m]=c.useState({}),[g,v]=c.useState({}),[d,x]=c.useState({}),a=l.filter(e=>e.status==="pending"&&!n[e.id]),u=l.filter(e=>n[e.id]),p=l.filter(e=>e.status!=="pending"&&!n[e.id]);async function f(e,s){x(i=>({...i,[e.id]:s}));try{await S(`/api/approvals/${e.id}/${s}`,{note:g[e.id]||""}),m(i=>({...i,[e.id]:s})),r?.(`Approval ${s}d`,s==="approve"?"success":"error")}catch(i){r?.(i.message,"error")}x(i=>({...i,[e.id]:null}))}return t.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{marginBottom:4},children:"Approval Queue"}),t.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[a.length," pending approvals require a decision"]})]}),a.length===0&&t.jsxs("div",{className:"card",style:{textAlign:"center",padding:48},children:[t.jsx("div",{style:{fontSize:32,marginBottom:12},children:"✅"}),t.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text)"},children:"All caught up"}),t.jsx("div",{style:{fontSize:13,color:"var(--muted)",marginTop:4},children:"No pending approvals"})]}),a.map(e=>{const s=h.find(i=>i.id===e.requestedBy||i.id===e.agentId);return t.jsxs("div",{style:{background:"#FDFCFF",border:"2px solid #EDE9FE",borderRadius:16,padding:24},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text)",marginBottom:4},children:e.action||"Action requires approval"}),t.jsxs("div",{style:{display:"flex",gap:10,fontSize:12,color:"var(--muted)"},children:[s&&t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx(j,{size:11}),s.emoji," ",s.name]}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx(b,{size:11}),C(e.created_at||e.requestedAt)]})]})]}),t.jsx("span",{style:{background:"#F5F3FF",color:"var(--purple)",borderRadius:999,padding:"4px 12px",fontSize:11,fontWeight:600},children:"Pending"})]}),e.reason&&t.jsxs("div",{style:{padding:"12px 14px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:10,marginBottom:14},children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--purple)",marginBottom:4},children:"Reason"}),t.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:e.reason})]}),e.payload&&Object.keys(e.payload).length>0&&t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--muted)",textTransform:"uppercase",marginBottom:6},children:"Payload"}),t.jsx("pre",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:12,fontSize:11,color:"var(--text-dim)",overflow:"auto",fontFamily:"var(--font-mono)",maxHeight:140},children:JSON.stringify(e.payload,null,2)})]}),t.jsx("input",{className:"input-base",placeholder:"Optional note…",value:g[e.id]||"",onChange:i=>v(y=>({...y,[e.id]:i.target.value})),style:{marginBottom:12,width:"100%",boxSizing:"border-box"}}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsxs("button",{onClick:()=>f(e,"approve"),disabled:!!d[e.id],style:{flex:1,padding:12,background:"#ECFDF5",border:"1px solid #6EE7B7",color:"var(--mint)",borderRadius:10,fontWeight:700,fontSize:13,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[t.jsx(F,{size:15})," ",d[e.id]==="approve"?"Processing…":"Approve"]}),t.jsxs("button",{onClick:()=>f(e,"reject"),disabled:!!d[e.id],style:{flex:1,padding:12,background:"#FEF2F2",border:"1px solid #FCA5A5",color:"var(--red)",borderRadius:10,fontWeight:700,fontSize:13,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[t.jsx(z,{size:15})," ",d[e.id]==="reject"?"Processing…":"Reject"]})]})]},e.id)}),(u.length>0||p.length>0)&&t.jsxs("div",{children:[t.jsx("h2",{style:{marginBottom:12,fontSize:16,color:"var(--text-dim)"},children:"Resolved"}),[...u,...p].map(e=>t.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,padding:"14px 18px",marginBottom:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",fontWeight:500},children:e.action||e.id}),t.jsx("span",{style:{background:(n[e.id]||e.status)==="approve"||(n[e.id]||e.status)==="approved"?"#ECFDF5":"#FEF2F2",color:(n[e.id]||e.status)==="approve"||(n[e.id]||e.status)==="approved"?"var(--mint)":"var(--red)",borderRadius:999,padding:"3px 10px",fontSize:11,fontWeight:600},children:n[e.id]||e.status})]},e.id))]})]})}export{k as default};
@@ -1 +1 @@
1
- import{r as p,a4 as r,aF as x,am as f,aA as c,aG as g}from"./vendor-gUVFsxOc.js";import{a as u}from"./index-B3IWXYRY.js";function h(e){if(!e)return"Never";try{const t=Math.round((Date.now()-new Date(e))/6e4);return t<1?"just now":t<60?`${t}m ago`:t<1440?`${Math.round(t/60)}h ago`:`${Math.round(t/1440)}d ago`}catch{return e}}function m({errors:e}){const t=e>=3?"var(--red)":e>0?"var(--amber)":"var(--mint)";return r.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function b(e){return e?typeof e=="string"?e:e.kind==="every"&&Number(e.everyMs)>0?`every ${Math.round(Number(e.everyMs)/6e4)}m`:typeof e.cronExpression=="string"?e.cronExpression:typeof e.expr=="string"?e.tz?`${e.expr} (${e.tz})`:e.expr:e.kind||"No schedule":"No schedule"}function y(e){return e==null||Number.isNaN(Number(e))?null:new Date(Date.now()-Number(e)*1e3).toISOString()}function v(e){return e==null||Number.isNaN(Number(e))?"—":e<0?"overdue":e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function j({cron:e,toast:t}){const[i,s]=p.useState(null),o=e._consecutive_errors||0;async function d(){s("toggle");try{await u(`/api/cron/${e.id}/toggle`),t?.(e.enabled!==!1?"Job paused":"Job resumed","success")}catch(l){t?.(l.message,"error")}s(null)}async function a(){s("run");try{await u(`/api/cron/${e.id}/trigger`),t?.("Job triggered","success")}catch(l){t?.(l.message,"error")}s(null)}const n=e.enabled!==!1;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"14px 18px",borderBottom:"1px solid var(--border)",background:o>=3?"#FFF8F8":"#fff",transition:"background 0.2s"},children:[r.jsx(m,{errors:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[r.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:e.name||e.id}),!n&&r.jsx("span",{style:{fontSize:10,background:"#F1F5F9",color:"var(--muted)",borderRadius:999,padding:"1px 8px",fontWeight:600},children:"Paused"}),o>=3&&r.jsxs("span",{style:{fontSize:10,background:"#FEF2F2",color:"var(--red)",borderRadius:999,padding:"1px 8px",fontWeight:600},children:["⚠ ",o," errors"]})]}),r.jsxs("div",{style:{fontSize:11,color:"var(--muted)",display:"flex",gap:12},children:[r.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx(f,{size:10})," ",b(e.schedule)]}),r.jsxs("span",{children:["Last: ",h(y(e._last_run_sec))]}),r.jsxs("span",{children:["Next: ",v(e._next_run_sec)]})]})]}),r.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[r.jsxs("button",{onClick:a,disabled:!!i,title:"Run now",style:{background:"#EEF2FF",border:"1px solid #E0E7FF",borderRadius:8,padding:"6px 10px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--accent)",fontWeight:600},children:[r.jsx(c,{size:11})," ",i==="run"?"…":"Run"]}),r.jsxs("button",{onClick:d,disabled:!!i,title:n?"Pause":"Resume",style:{background:n?"#FEF2F2":"#ECFDF5",border:`1px solid ${n?"#FEE2E2":"#D1FAE5"}`,borderRadius:8,padding:"6px 10px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:11,color:n?"var(--red)":"var(--mint)",fontWeight:600},children:[n?r.jsx(g,{size:11}):r.jsx(c,{size:11})," ",n?"Pause":"Resume"]})]})]})}function N({data:e,toast:t}){const{crons:i=[]}=e||{},[s,o]=p.useState(""),d=i.filter(n=>!s||(n.name||n.id||"").toLowerCase().includes(s.toLowerCase())),a=i.filter(n=>(n._consecutive_errors||0)>=3);return r.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[r.jsxs("div",{children:[r.jsx("h1",{style:{marginBottom:4},children:"Jobs & Crons"}),r.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[i.length," scheduled jobs"]})]}),r.jsx("input",{className:"input-base",placeholder:"Search jobs…",value:s,onChange:n=>o(n.target.value),style:{width:220}})]}),a.length>0&&r.jsxs("div",{style:{padding:"14px 18px",background:"#FFF1F2",border:"1px solid #FEE2E2",borderRadius:14,display:"flex",alignItems:"center",gap:12},children:[r.jsx(x,{size:18,color:"var(--red)"}),r.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--red)"},children:[a.length," job",a.length>1?"s":""," with repeated errors"]})]}),r.jsxs("div",{style:{background:"#fff",border:"1px solid var(--border)",borderRadius:16,overflow:"hidden",boxShadow:"var(--shadow)"},children:[r.jsxs("div",{style:{background:"#F8FAFC",padding:"10px 18px",borderBottom:"1px solid var(--border)",display:"flex",gap:14,fontSize:10,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:[r.jsx("span",{style:{flex:1},children:"Job Name"}),r.jsx("span",{style:{minWidth:100},children:"Schedule"}),r.jsx("span",{style:{minWidth:120},children:"Actions"})]}),d.length===0?r.jsx("div",{style:{padding:48,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No jobs match your search"}):d.map(n=>r.jsx(j,{cron:n,toast:t},n.id))]})]})}export{N as default};
1
+ import{r as p,a4 as r,aF as x,am as f,aA as c,aG as g}from"./vendor-gUVFsxOc.js";import{a as u}from"./index-DUjHkafG.js";function h(e){if(!e)return"Never";try{const t=Math.round((Date.now()-new Date(e))/6e4);return t<1?"just now":t<60?`${t}m ago`:t<1440?`${Math.round(t/60)}h ago`:`${Math.round(t/1440)}d ago`}catch{return e}}function m({errors:e}){const t=e>=3?"var(--red)":e>0?"var(--amber)":"var(--mint)";return r.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function b(e){return e?typeof e=="string"?e:e.kind==="every"&&Number(e.everyMs)>0?`every ${Math.round(Number(e.everyMs)/6e4)}m`:typeof e.cronExpression=="string"?e.cronExpression:typeof e.expr=="string"?e.tz?`${e.expr} (${e.tz})`:e.expr:e.kind||"No schedule":"No schedule"}function y(e){return e==null||Number.isNaN(Number(e))?null:new Date(Date.now()-Number(e)*1e3).toISOString()}function v(e){return e==null||Number.isNaN(Number(e))?"—":e<0?"overdue":e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function j({cron:e,toast:t}){const[i,s]=p.useState(null),o=e._consecutive_errors||0;async function d(){s("toggle");try{await u(`/api/cron/${e.id}/toggle`),t?.(e.enabled!==!1?"Job paused":"Job resumed","success")}catch(l){t?.(l.message,"error")}s(null)}async function a(){s("run");try{await u(`/api/cron/${e.id}/trigger`),t?.("Job triggered","success")}catch(l){t?.(l.message,"error")}s(null)}const n=e.enabled!==!1;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"14px 18px",borderBottom:"1px solid var(--border)",background:o>=3?"#FFF8F8":"#fff",transition:"background 0.2s"},children:[r.jsx(m,{errors:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[r.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text)"},children:e.name||e.id}),!n&&r.jsx("span",{style:{fontSize:10,background:"#F1F5F9",color:"var(--muted)",borderRadius:999,padding:"1px 8px",fontWeight:600},children:"Paused"}),o>=3&&r.jsxs("span",{style:{fontSize:10,background:"#FEF2F2",color:"var(--red)",borderRadius:999,padding:"1px 8px",fontWeight:600},children:["⚠ ",o," errors"]})]}),r.jsxs("div",{style:{fontSize:11,color:"var(--muted)",display:"flex",gap:12},children:[r.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx(f,{size:10})," ",b(e.schedule)]}),r.jsxs("span",{children:["Last: ",h(y(e._last_run_sec))]}),r.jsxs("span",{children:["Next: ",v(e._next_run_sec)]})]})]}),r.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[r.jsxs("button",{onClick:a,disabled:!!i,title:"Run now",style:{background:"#EEF2FF",border:"1px solid #E0E7FF",borderRadius:8,padding:"6px 10px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--accent)",fontWeight:600},children:[r.jsx(c,{size:11})," ",i==="run"?"…":"Run"]}),r.jsxs("button",{onClick:d,disabled:!!i,title:n?"Pause":"Resume",style:{background:n?"#FEF2F2":"#ECFDF5",border:`1px solid ${n?"#FEE2E2":"#D1FAE5"}`,borderRadius:8,padding:"6px 10px",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:11,color:n?"var(--red)":"var(--mint)",fontWeight:600},children:[n?r.jsx(g,{size:11}):r.jsx(c,{size:11})," ",n?"Pause":"Resume"]})]})]})}function N({data:e,toast:t}){const{crons:i=[]}=e||{},[s,o]=p.useState(""),d=i.filter(n=>!s||(n.name||n.id||"").toLowerCase().includes(s.toLowerCase())),a=i.filter(n=>(n._consecutive_errors||0)>=3);return r.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[r.jsxs("div",{children:[r.jsx("h1",{style:{marginBottom:4},children:"Jobs & Crons"}),r.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[i.length," scheduled jobs"]})]}),r.jsx("input",{className:"input-base",placeholder:"Search jobs…",value:s,onChange:n=>o(n.target.value),style:{width:220}})]}),a.length>0&&r.jsxs("div",{style:{padding:"14px 18px",background:"#FFF1F2",border:"1px solid #FEE2E2",borderRadius:14,display:"flex",alignItems:"center",gap:12},children:[r.jsx(x,{size:18,color:"var(--red)"}),r.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--red)"},children:[a.length," job",a.length>1?"s":""," with repeated errors"]})]}),r.jsxs("div",{style:{background:"#fff",border:"1px solid var(--border)",borderRadius:16,overflow:"hidden",boxShadow:"var(--shadow)"},children:[r.jsxs("div",{style:{background:"#F8FAFC",padding:"10px 18px",borderBottom:"1px solid var(--border)",display:"flex",gap:14,fontSize:10,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:[r.jsx("span",{style:{flex:1},children:"Job Name"}),r.jsx("span",{style:{minWidth:100},children:"Schedule"}),r.jsx("span",{style:{minWidth:120},children:"Actions"})]}),d.length===0?r.jsx("div",{style:{padding:48,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No jobs match your search"}):d.map(n=>r.jsx(j,{cron:n,toast:t},n.id))]})]})}export{N as default};
@@ -1 +1 @@
1
- import{r as x,a4 as e,am as u,aB as f,aD as m}from"./vendor-gUVFsxOc.js";import{a as v}from"./index-B3IWXYRY.js";function y(i){if(!i)return"—";try{const n=Math.round((Date.now()-new Date(i))/6e4);return n<1?"just now":n<60?`${n}m ago`:n<1440?`${Math.round(n/60)}h ago`:`${Math.round(n/1440)}d ago`}catch{return i}}function j({task:i,agents:n,onAction:d,toast:c}){const[s,p]=x.useState(""),[t,r]=x.useState(null),a=n.find(o=>o.id===i.assigned_to),l=(i.sla?.priority||i.priority||"").toUpperCase();async function g(o){r(o);try{await v(`/api/hitl/${i.id}/${o}`,{note:s||void 0}),d(i.id,o)}catch(h){c?.(h.message,"error")}r(null)}return e.jsxs("div",{style:{background:"#FDFCFF",border:"2px solid #EDE9FE",borderRadius:16,padding:24,display:"flex",flexDirection:"column",gap:16,boxShadow:"0 4px 24px rgba(139,92,246,0.08)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[e.jsx("span",{style:{fontSize:28,flexShrink:0},children:"🔔"}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:16,color:"var(--text)"},children:i.title}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:i.id}),l&&e.jsx("span",{style:{background:l==="P1"?"#FEF2F2":"#F1F5F9",color:l==="P1"?"var(--red)":"var(--muted)",borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:700},children:l})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-dim)",display:"flex",alignItems:"center",gap:6},children:[a&&e.jsxs("span",{children:[a.emoji," ",a.name," ·"]}),e.jsx(u,{size:11,style:{flexShrink:0}}),e.jsxs("span",{children:["Waiting ",e.jsx("span",{style:{color:"var(--amber)",fontWeight:600},children:y(i.created_at)})]}),i.sla?.deadline&&e.jsxs("span",{children:["· Due ",new Date(i.sla.deadline).toLocaleString()]})]})]})]}),e.jsxs("div",{style:{padding:"14px 16px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:12},children:[e.jsx("div",{style:{fontSize:10,color:"var(--purple)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:8},children:"⚡ Decision Required"}),e.jsx("div",{style:{fontSize:13,color:"var(--text)",lineHeight:1.7},children:i.hitl_reason||"Human decision required before agent can proceed."})]}),i.description&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Context"}),e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.6,background:"#F8FAFC",padding:14,borderRadius:10,border:"1px solid var(--border)"},children:i.description})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"var(--muted)",fontWeight:500,marginBottom:6},children:"Add a note for the agent (optional)"}),e.jsx("input",{value:s,onChange:o=>p(o.target.value),placeholder:"Provide guidance or context…",className:"input-base",style:{width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("button",{onClick:()=>g("approve"),disabled:!!t,style:{flex:1,padding:"12px",background:t==="approve"?"#D1FAE5":"#ECFDF5",border:"1px solid #6EE7B7",color:"var(--mint)",borderRadius:12,fontFamily:"inherit",fontSize:14,fontWeight:700,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"all 0.15s"},children:[e.jsx(f,{size:16})," ",t==="approve"?"Processing…":"✅ Approve — Continue"]}),e.jsxs("button",{onClick:()=>g("reject"),disabled:!!t,style:{flex:1,padding:"12px",background:t==="reject"?"#FEE2E2":"#FEF2F2",border:"1px solid #FCA5A5",color:"var(--red)",borderRadius:12,fontFamily:"inherit",fontSize:14,fontWeight:700,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"all 0.15s"},children:[e.jsx(m,{size:16})," ",t==="reject"?"Processing…":"❌ Reject — Block"]})]})]})}function S({data:i,toast:n}){const{hitl_tasks:d=[],agents:c=[]}=i||{},[s,p]=x.useState(new Set),t=d.filter(r=>!s.has(r.id));return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"HITL Queue"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Human-in-the-loop decisions requiring your input"})]}),e.jsxs("div",{style:{padding:"16px 20px",borderRadius:14,display:"flex",alignItems:"center",gap:12,background:t.length>0?"#FFF7ED":"#ECFDF5",border:`1px solid ${t.length>0?"#FED7AA":"#A7F3D0"}`},children:[e.jsx("span",{style:{fontSize:22},children:t.length>0?"🔔":"✅"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.length>0?"var(--amber)":"var(--mint)"},children:t.length>0?`${t.length} decision${t.length>1?"s":""} awaiting your input`:"All clear — no pending decisions"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",marginTop:2},children:t.length>0?"Agents are paused at approval gates below":"All agents are running autonomously"})]}),s.size>0&&e.jsxs("div",{style:{marginLeft:"auto",fontSize:12,color:"var(--mint)",fontWeight:600},children:[s.size," resolved this session"]})]}),t.map(r=>e.jsx(j,{task:r,agents:c,toast:n,onAction:a=>p(l=>new Set([...l,a]))},r.id))]})}export{S as default};
1
+ import{r as x,a4 as e,am as u,aB as f,aD as m}from"./vendor-gUVFsxOc.js";import{a as v}from"./index-DUjHkafG.js";function y(i){if(!i)return"—";try{const n=Math.round((Date.now()-new Date(i))/6e4);return n<1?"just now":n<60?`${n}m ago`:n<1440?`${Math.round(n/60)}h ago`:`${Math.round(n/1440)}d ago`}catch{return i}}function j({task:i,agents:n,onAction:d,toast:c}){const[s,p]=x.useState(""),[t,r]=x.useState(null),a=n.find(o=>o.id===i.assigned_to),l=(i.sla?.priority||i.priority||"").toUpperCase();async function g(o){r(o);try{await v(`/api/hitl/${i.id}/${o}`,{note:s||void 0}),d(i.id,o)}catch(h){c?.(h.message,"error")}r(null)}return e.jsxs("div",{style:{background:"#FDFCFF",border:"2px solid #EDE9FE",borderRadius:16,padding:24,display:"flex",flexDirection:"column",gap:16,boxShadow:"0 4px 24px rgba(139,92,246,0.08)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[e.jsx("span",{style:{fontSize:28,flexShrink:0},children:"🔔"}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:16,color:"var(--text)"},children:i.title}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:i.id}),l&&e.jsx("span",{style:{background:l==="P1"?"#FEF2F2":"#F1F5F9",color:l==="P1"?"var(--red)":"var(--muted)",borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:700},children:l})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-dim)",display:"flex",alignItems:"center",gap:6},children:[a&&e.jsxs("span",{children:[a.emoji," ",a.name," ·"]}),e.jsx(u,{size:11,style:{flexShrink:0}}),e.jsxs("span",{children:["Waiting ",e.jsx("span",{style:{color:"var(--amber)",fontWeight:600},children:y(i.created_at)})]}),i.sla?.deadline&&e.jsxs("span",{children:["· Due ",new Date(i.sla.deadline).toLocaleString()]})]})]})]}),e.jsxs("div",{style:{padding:"14px 16px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:12},children:[e.jsx("div",{style:{fontSize:10,color:"var(--purple)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:8},children:"⚡ Decision Required"}),e.jsx("div",{style:{fontSize:13,color:"var(--text)",lineHeight:1.7},children:i.hitl_reason||"Human decision required before agent can proceed."})]}),i.description&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Context"}),e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.6,background:"#F8FAFC",padding:14,borderRadius:10,border:"1px solid var(--border)"},children:i.description})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"var(--muted)",fontWeight:500,marginBottom:6},children:"Add a note for the agent (optional)"}),e.jsx("input",{value:s,onChange:o=>p(o.target.value),placeholder:"Provide guidance or context…",className:"input-base",style:{width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("button",{onClick:()=>g("approve"),disabled:!!t,style:{flex:1,padding:"12px",background:t==="approve"?"#D1FAE5":"#ECFDF5",border:"1px solid #6EE7B7",color:"var(--mint)",borderRadius:12,fontFamily:"inherit",fontSize:14,fontWeight:700,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"all 0.15s"},children:[e.jsx(f,{size:16})," ",t==="approve"?"Processing…":"✅ Approve — Continue"]}),e.jsxs("button",{onClick:()=>g("reject"),disabled:!!t,style:{flex:1,padding:"12px",background:t==="reject"?"#FEE2E2":"#FEF2F2",border:"1px solid #FCA5A5",color:"var(--red)",borderRadius:12,fontFamily:"inherit",fontSize:14,fontWeight:700,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"all 0.15s"},children:[e.jsx(m,{size:16})," ",t==="reject"?"Processing…":"❌ Reject — Block"]})]})]})}function S({data:i,toast:n}){const{hitl_tasks:d=[],agents:c=[]}=i||{},[s,p]=x.useState(new Set),t=d.filter(r=>!s.has(r.id));return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"HITL Queue"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Human-in-the-loop decisions requiring your input"})]}),e.jsxs("div",{style:{padding:"16px 20px",borderRadius:14,display:"flex",alignItems:"center",gap:12,background:t.length>0?"#FFF7ED":"#ECFDF5",border:`1px solid ${t.length>0?"#FED7AA":"#A7F3D0"}`},children:[e.jsx("span",{style:{fontSize:22},children:t.length>0?"🔔":"✅"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.length>0?"var(--amber)":"var(--mint)"},children:t.length>0?`${t.length} decision${t.length>1?"s":""} awaiting your input`:"All clear — no pending decisions"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",marginTop:2},children:t.length>0?"Agents are paused at approval gates below":"All agents are running autonomously"})]}),s.size>0&&e.jsxs("div",{style:{marginLeft:"auto",fontSize:12,color:"var(--mint)",fontWeight:600},children:[s.size," resolved this session"]})]}),t.map(r=>e.jsx(j,{task:r,agents:c,toast:n,onAction:a=>p(l=>new Set([...l,a]))},r.id))]})}export{S as default};
@@ -1 +1 @@
1
- import{r as j,a4 as e,a7 as B,aw as O,aA as H,av as K,aB as G,aq as U,ad as q}from"./vendor-gUVFsxOc.js";import{l as X,s as Y,p as J,e as Q}from"./index-B3IWXYRY.js";import{R as V,L as Z,C as ee,X as te,Y as re,T as ie,a as se,b as W,c as ne}from"./charts-CjCN_e1M.js";const _={active:{bg:"#EEF2FF",color:"var(--accent)",label:"Active"},complete:{bg:"#ECFDF5",color:"var(--mint)",label:"Complete"},paused:{bg:"#FFFBEB",color:"var(--amber)",label:"Paused"},archived:{bg:"#F8FAFC",color:"var(--muted)",label:"Archived"},pending:{bg:"#F8FAFC",color:"var(--muted)",label:"Pending"}},T={green:{bg:"#ECFDF5",color:"var(--mint)",label:"On Track"},amber:{bg:"#FFFBEB",color:"var(--amber)",label:"At Risk"},red:{bg:"#FEF2F2",color:"var(--red)",label:"Critical"}};function z(t){if(!t)return"—";try{const s=Math.round((Date.now()-new Date(t))/6e4);return s<1?"just now":s<60?`${s}m ago`:s<1440?`${Math.round(s/60)}h ago`:`${Math.round(s/1440)}d ago`}catch{return t}}function R(t){if(!t)return null;try{const s=Math.ceil((new Date(t)-Date.now())/864e5);return s<0?{label:`${Math.abs(s)}d overdue`,color:"var(--red)"}:s===0?{label:"Due today",color:"var(--amber)"}:s<=3?{label:`${s}d left`,color:"var(--amber)"}:{label:`${s}d left`,color:"var(--muted)"}}catch{return null}}function E(t){const s=(t._risks||[]).filter(f=>!f.resolved),n=t._progress_pct??0,d=t.target_completion?Math.ceil((new Date(t.target_completion)-Date.now())/864e5):999,l=t._task_counts||{};return s.some(f=>f.severity==="critical")||(l.blocked||0)>2||d<-3?"red":s.length>1||(l.hitl||0)>0||d<0||n<30?"amber":"green"}function I({pct:t,size:s=56,color:n="var(--accent)"}){const d=(s-8)/2,l=2*Math.PI*d,f=l*(t/100);return e.jsxs("div",{style:{position:"relative",width:s,height:s,flexShrink:0},children:[e.jsxs("svg",{width:s,height:s,style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:"#E2E8F0",strokeWidth:5}),e.jsx("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:n,strokeWidth:5,strokeDasharray:`${f} ${l}`,strokeLinecap:"round",style:{transition:"stroke-dasharray .8s cubic-bezier(0.4,0,0.2,1)"}})]}),e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:s*.2,fontWeight:800,color:n},children:[t,"%"]})]})}function N({agentId:t,agents:s,isOwner:n}){const d=s.find(l=>l.id===t);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,padding:"3px 10px",borderRadius:999,background:n?"#EEF2FF":"#F8FAFC",color:n?"var(--accent)":"var(--muted)",border:`1px solid ${n?"#E0E7FF":"var(--border)"}`,fontWeight:600},children:[e.jsx("span",{style:{fontSize:14},children:d?.emoji||"🤖"}),e.jsx("span",{children:d?.name||t}),n&&e.jsx("span",{style:{opacity:.6},children:"· Owner"})]})}function P({health:t}){const s=T[t];return e.jsx("span",{style:{background:s.bg,color:s.color,borderRadius:999,padding:"2px 10px",fontSize:10,fontWeight:700},children:s.label})}function ae({project:t}){const s=t.milestones||[];if(!s.length)return e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13,background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:"No milestones defined"});const n=new Date(t.created_at||Date.now()),d=new Date(t.target_completion||Date.now()+30*864e5),l=Math.max(1,d-n),f=Math.max(0,Math.min(100,(Date.now()-n)/l*100)),c={complete:"var(--mint)","in-progress":"var(--accent)",pending:"#E2E8F0",blocked:"var(--red)"};return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:"var(--muted)",marginBottom:12},children:[e.jsx("span",{children:n.toLocaleDateString()}),e.jsx("span",{style:{color:"var(--amber)",fontWeight:600},children:"Today"}),e.jsx("span",{children:d.toLocaleDateString()})]}),e.jsxs("div",{style:{position:"relative",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:"16px 0",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",left:`${f}%`,top:0,bottom:0,width:2,background:"var(--amber)",opacity:.7}}),s.map(u=>{const m=u.due?new Date(u.due):d,y=Math.max(4,Math.min(100,(m-n)/l*100)),h=u.status==="complete";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10,padding:"0 16px"},children:[e.jsx("div",{style:{fontSize:12,color:h?"var(--muted)":"var(--text)",width:130,flexShrink:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,textDecoration:h?"line-through":"none"},children:u.title}),e.jsx("div",{style:{flex:1,position:"relative",height:10,background:"#E2E8F0",borderRadius:999},children:e.jsx("div",{style:{position:"absolute",left:0,width:`${y}%`,height:"100%",background:c[u.status]||"#E2E8F0",borderRadius:999,transition:"width 1s ease"}})}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",width:60,flexShrink:0,textAlign:"right"},children:u.due?new Date(u.due).toLocaleDateString("en",{month:"short",day:"numeric"}):"—"})]},u.id)})]})]})}function oe({project:t,tasks:s}){const n=s.filter(h=>(t.task_ids||[]).includes(h.id)),d=n.length;if(!d)return e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No tasks to plot"});const l=new Date(t.created_at||Date.now()),f=new Date(t.target_completion||Date.now()+7*864e5),c=Math.max(1,Math.ceil((f-l)/864e5)),u=n.filter(h=>h.completed_at).map(h=>Math.max(0,Math.ceil((new Date(h.completed_at)-l)/864e5))).sort((h,x)=>h-x),m=Math.ceil((Date.now()-l)/864e5),y=Array.from({length:c+1},(h,x)=>({day:x,ideal:Math.round(d-d/c*x),actual:x<=m?d-u.filter(g=>g<=x).length:void 0}));return e.jsx(V,{width:"100%",height:220,children:e.jsxs(Z,{data:y,margin:{top:10,right:20,left:0,bottom:10},children:[e.jsx(ee,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),e.jsx(te,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"var(--muted)"}}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"var(--muted)"},orientation:"right"}),e.jsx(ie,{contentStyle:{background:"#fff",border:"1px solid var(--border)",borderRadius:10,fontSize:12}}),e.jsx(se,{verticalAlign:"top",height:32,iconType:"rect",wrapperStyle:{fontSize:11}}),e.jsx(W,{type:"stepAfter",dataKey:"ideal",stroke:"#CBD5E1",strokeDasharray:"4 4",dot:!1,name:"Ideal"}),e.jsx(W,{type:"stepAfter",dataKey:"actual",stroke:"var(--accent)",strokeWidth:2,dot:{r:3,fill:"var(--accent)"},name:"Actual"}),e.jsx(ne,{x:m,stroke:"var(--amber)",strokeDasharray:"3 3"})]})})}function le({project:t,agents:s,selected:n,onClick:d}){const l=t._task_counts||{},f=t._progress_pct??0,c=(t._risks||[]).filter(x=>!x.resolved),u=E(t),m=_[t.status]||_.pending,y=f===100?"var(--mint)":c.length?"var(--red)":"var(--accent)",h=R(t.target_completion);return e.jsxs("div",{onClick:d,className:"card fade-in",style:{cursor:"pointer",padding:"20px",borderColor:n?"var(--accent)":c.length>0?"#FEE2E2":"var(--border)",borderWidth:n?2:1,background:n?"#FAFAFF":"#fff"},children:[e.jsxs("div",{style:{display:"flex",gap:14,marginBottom:16},children:[e.jsx(I,{pct:f,size:52,color:y}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:15,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(P,{health:u})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("span",{style:{background:m.bg,color:m.color,borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600},children:m.label}),h&&e.jsx("span",{style:{fontSize:11,color:h.color,fontWeight:600},children:h.label})]})]}),e.jsx(U,{size:16,color:"var(--muted)",style:{flexShrink:0,marginTop:4}})]}),t.description&&e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.5,marginBottom:14,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t.description}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginBottom:14},children:[{l:"Tasks",v:`${l.done||0}/${l.total||0}`,c:"var(--accent)"},{l:"HITL",v:l.hitl||0,c:l.hitl?"var(--purple)":"var(--muted)"},{l:"Blocked",v:l.blocked||0,c:l.blocked?"var(--red)":"var(--muted)"},{l:"Spend",v:`$${(t.budget?.spent_usd??0).toFixed(0)}`,c:"var(--text-dim)"}].map(x=>e.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px"},children:[e.jsx("div",{style:{fontSize:9,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:3},children:x.l}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:x.c},children:x.v})]},x.l))}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(N,{agentId:t.owner,agents:s,isOwner:!0}),c.length>0&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--red)",fontWeight:600},children:[e.jsx(q,{size:12})," ",c.length," risk",c.length>1?"s":""]})]})]})}const de=["Overview","Timeline","Tasks","Budget","OKRs","Logs"];function ce({project:t,agents:s,tasks:n,onClose:d,onReplan:l,onExecute:f}){const[c,u]=j.useState("Overview");t._task_counts;const m=t._progress_pct??0,y=(t._risks||[]).filter(i=>!i.resolved),h=E(t),x=m===100?"var(--mint)":y.length?"var(--red)":"var(--accent)",g=_[t.status]||_.pending,S=R(t.target_completion);return e.jsxs("div",{className:"fade-in",style:{background:"#fff",border:"2px solid #E0E7FF",borderRadius:20,marginBottom:32,overflow:"hidden",boxShadow:"0 8px 32px rgba(79,70,229,0.08)"},children:[e.jsxs("div",{style:{padding:"28px 32px",background:"linear-gradient(135deg, #FAFAFF 0%, #fff 100%)",borderBottom:"1px solid var(--border)",display:"flex",gap:24,alignItems:"flex-start"},children:[e.jsx(I,{pct:m,size:80,color:x}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:24,fontWeight:800,color:"var(--text)"},children:t.name}),e.jsx("span",{style:{background:g.bg,color:g.color,borderRadius:999,padding:"4px 12px",fontSize:12,fontWeight:600},children:g.label}),e.jsx(P,{health:h})]}),t.description&&e.jsx("div",{style:{fontSize:14,color:"var(--text-dim)",lineHeight:1.6,marginBottom:12,maxWidth:600},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[e.jsx(N,{agentId:t.owner,agents:s,isOwner:!0}),S&&e.jsx("span",{style:{fontSize:12,color:S.color,fontWeight:600},children:S.label}),(t.tags||[]).map(i=>e.jsx("span",{style:{background:"#EEF2FF",color:"var(--accent)",borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600},children:i},i))]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,width:140,flexShrink:0},children:[e.jsxs("button",{className:"btn-primary",onClick:()=>f?.(t.id),style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(H,{size:13})," Execute"]}),e.jsxs("button",{className:"btn-secondary",onClick:()=>l?.(t.id),style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(B,{size:13})," Replan"]}),e.jsxs("button",{className:"btn-secondary",onClick:d,style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(K,{size:13})," Close"]})]})]}),e.jsx("div",{style:{display:"flex",background:"#F8FAFC",borderBottom:"1px solid var(--border)",padding:"0 24px",gap:4},children:de.map(i=>{const p=c===i;return e.jsx("button",{onClick:()=>u(i),style:{background:"none",border:"none",cursor:"pointer",padding:"14px 16px",fontSize:13,fontWeight:p?700:500,color:p?"var(--accent)":"var(--muted)",borderBottom:`2px solid ${p?"var(--accent)":"transparent"}`,transition:"all 0.15s"},children:i},i)})}),e.jsxs("div",{style:{padding:"28px 32px",minHeight:360},children:[c==="Overview"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:40},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:16,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Timeline"}),e.jsx(ae,{project:t}),e.jsx("h3",{style:{marginTop:32,marginBottom:12,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Risks"}),y.length>0?y.map(i=>e.jsxs("div",{style:{padding:"12px 14px",background:"#FFF1F2",border:"1px solid #FEE2E2",borderRadius:10,marginBottom:8},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:4},children:i.description}),e.jsxs("div",{style:{fontSize:11,color:"var(--red)",fontWeight:600},children:[i.severity," · ",z(i.detected_at)]})]},i.id)):e.jsxs("div",{style:{padding:"16px",background:"#ECFDF5",border:"1px solid #D1FAE5",borderRadius:10,display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--mint)",fontWeight:500},children:[e.jsx(G,{size:15})," No active risks"]})]}),e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:16,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Activity"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(t._activity||[]).slice(0,10).map((i,p)=>e.jsxs("div",{style:{display:"flex",gap:10,fontSize:13,padding:"8px 0",borderBottom:"1px solid var(--border)"},children:[e.jsx("span",{style:{color:"var(--muted)",flexShrink:0},children:z(i.ts)}),e.jsx("span",{style:{color:"var(--text-dim)",flex:1},children:i.text})]},p)),(t._activity||[]).length===0&&e.jsx("span",{style:{color:"var(--muted)",fontSize:13},children:"No activity yet"})]})]})]}),c==="Timeline"&&e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:20,fontSize:15},children:"Burndown Chart"}),e.jsx(oe,{project:t,tasks:n})]}),c==="Tasks"&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:16},children:["in-progress","blocked","needs_human_decision","complete"].map(i=>{const v={"in-progress":{label:"In Progress",color:"var(--accent)",bg:"#EEF2FF"},blocked:{label:"Blocked",color:"var(--red)",bg:"#FEF2F2"},needs_human_decision:{label:"HITL",color:"var(--purple)",bg:"#F5F3FF"},complete:{label:"Complete",color:"var(--mint)",bg:"#ECFDF5"}}[i],b=n.filter(a=>(t.task_ids||[]).includes(a.id)&&a.status===i);return e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:12,fontWeight:700,color:v.color,textTransform:"uppercase",marginBottom:10,padding:"4px 10px",background:v.bg,borderRadius:8,display:"inline-block"},children:[v.label," (",b.length,")"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[b.map(a=>e.jsxs("div",{style:{padding:"10px 12px",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",marginBottom:3},children:a.title}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:a.id?.slice(0,12)})]},a.id)),b.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)",fontStyle:"italic"},children:"None"})]})]},i)})}),c==="Budget"&&e.jsx("div",{children:(()=>{const i=t.budget?.allocated_usd||0,p=t.budget?.spent_usd||0,v=i?Math.round(p/i*100):0,b=v>90?"var(--red)":v>75?"var(--amber)":"var(--mint)",a=v>90?"#FEF2F2":v>75?"#FFFBEB":"#F0FDF4";return e.jsxs("div",{style:{background:a,border:`1px solid ${b}44`,borderRadius:16,padding:28,maxWidth:520},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:12},children:"Budget Expenditure"}),e.jsxs("div",{style:{fontSize:32,fontWeight:800,color:b,marginBottom:16},children:["$",p.toFixed(2)," ",e.jsxs("span",{style:{fontSize:16,color:"var(--muted)",fontWeight:500},children:["/ $",i.toFixed(2)]})]}),e.jsx("div",{className:"progress-track",style:{height:12},children:e.jsx("div",{className:"progress-fill",style:{width:`${Math.min(100,v)}%`,background:b,height:"100%",borderRadius:999}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:8,fontSize:12,color:"var(--muted)"},children:[e.jsxs("span",{children:[v,"% utilized"]}),i>0&&e.jsxs("span",{children:["$",(i-p).toFixed(2)," remaining"]})]})]})})()}),c==="OKRs"&&e.jsxs("div",{children:[(t.okr_links||[]).length===0?e.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--muted)",fontSize:13},children:"No OKR links for this project"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:(t.okr_links||[]).map((i,p)=>e.jsxs("div",{style:{padding:"16px 18px",background:"#FAFAFF",border:"1px solid #E0E7FF",borderRadius:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)",marginBottom:4},children:i.objective||i.title||`OKR #${p+1}`}),i.key_result&&e.jsxs("div",{style:{fontSize:12,color:"var(--accent)",marginBottom:4},children:["KR: ",i.key_result]}),i.contribution&&e.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:["Contribution: ",i.contribution]})]},p))}),(t.decisions||[]).length>0&&e.jsxs("div",{style:{marginTop:28},children:[e.jsx("h3",{style:{marginBottom:12,fontSize:15},children:"Decisions"}),t.decisions.map((i,p)=>e.jsxs("div",{style:{padding:"14px 16px",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,marginBottom:8},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:4},children:i.decision}),i.rationale&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)"},children:i.rationale})]},p))]})]}),c==="Logs"&&e.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,overflow:"hidden"},children:[(t._sessions||[]).map((i,p)=>e.jsxs("div",{style:{display:"flex",gap:20,padding:"10px 16px",borderBottom:"1px solid var(--border)",fontSize:12,fontFamily:"var(--font-mono)",background:p%2===0?"#fff":"#F8FAFC"},children:[e.jsx("span",{style:{color:"var(--accent)",minWidth:80},children:i.proc_id||"--"}),e.jsx("span",{style:{flex:1,color:"var(--text-dim)"},children:i.task_id}),e.jsx("span",{style:{color:i.status==="failed"?"var(--red)":"var(--mint)",fontWeight:600},children:i.status}),e.jsx("span",{style:{color:"var(--muted)"},children:z(i.completed_at)})]},p)),(t._sessions||[]).length===0&&e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No session logs"})]})]})]})}function ue({data:t,lastUpdated:s,toast:n}){const{agents:d=[],tasks:l=[],okrs:f={}}=t||{},[c,u]=j.useState([]),[m,y]=j.useState(null),[h,x]=j.useState(!0),[g,S]=j.useState({status:"all",search:"",health:"all"}),[i,p]=j.useState(!1),[v,b]=j.useState(!1),[a,F]=j.useState({title:"",intent:"",description:"",priority:"P2",tags:"",project_hint:"",deadline:"",budget_usd:""}),C=j.useCallback(async()=>{try{const r=await X();u(r.projects||[])}catch{u([])}finally{x(!1)}},[]);j.useEffect(()=>{C()},[C]);const L=async()=>{if(!(!a.intent.trim()&&!a.title.trim())){p(!0);try{const r=await Y({...a,tags:a.tags.split(",").map(o=>o.trim()).filter(Boolean)});await C(),F({title:"",intent:"",description:"",priority:"P2",tags:"",project_hint:"",deadline:"",budget_usd:""}),b(!1),n?.(`Task routed: ${r.projectId}`,"success")}catch(r){n?.(r.message,"error")}finally{p(!1)}}},M=async r=>{try{await J(r),await C(),n?.("Replan initiated","success")}catch(o){n?.(o.message,"error")}},$=async r=>{try{await Q(r),await C(),n?.("Execution started","success")}catch(o){n?.(o.message,"error")}},w=j.useMemo(()=>c.map(r=>{const o=l.filter(k=>(r.task_ids||[]).includes(k.id)),A=o.filter(k=>k.status==="complete").length;return{...r,_task_counts:{total:o.length,done:A,active:o.filter(k=>k.status==="in-progress").length,blocked:o.filter(k=>k.status==="blocked").length,hitl:o.filter(k=>k.status==="needs_human_decision").length},_progress_pct:o.length>0?Math.round(A/o.length*100):0,_risks:r._risks||[],_activity:r._activity||[]}}),[c,l]),D=j.useMemo(()=>w.filter(r=>!(g.status!=="all"&&r.status!==g.status||g.health!=="all"&&E(r)!==g.health||g.search&&!(r.name||"").toLowerCase().includes(g.search.toLowerCase()))).sort((r,o)=>(o.priority_weight||0)-(r.priority_weight||0)),[w,g]);return h?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:80},children:[e.jsx(B,{size:20,color:"var(--accent)",style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{style:{marginLeft:12,color:"var(--muted)",fontSize:13},children:"Loading projects…"})]}):e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Projects"}),e.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[w.length," projects · ",w.filter(r=>r.status==="active").length," active"]})]}),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("button",{className:"btn-secondary",onClick:C,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px"},children:[e.jsx(B,{size:13})," Refresh"]}),e.jsxs("button",{className:"btn-primary",onClick:()=>b(!v),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(O,{size:14})," New Project"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[[{label:"All Health",value:"all",color:"var(--text-dim)",bg:"#F8FAFC"},...Object.entries(T).map(([r,o])=>({label:o.label,value:r,color:o.color,bg:o.bg}))].map(r=>e.jsx("button",{onClick:()=>S(o=>({...o,health:r.value})),style:{background:g.health===r.value?r.bg:"#F8FAFC",color:g.health===r.value?r.color:"var(--muted)",border:`1px solid ${g.health===r.value?r.color+"44":"var(--border)"}`,borderRadius:999,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:r.label},r.value)),e.jsx("input",{className:"input-base",placeholder:"Search projects…",value:g.search,onChange:r=>S(o=>({...o,search:r.target.value})),style:{marginLeft:"auto",width:220}}),e.jsxs("select",{className:"input-base",value:g.status,onChange:r=>S(o=>({...o,status:r.target.value})),style:{width:140},children:[e.jsx("option",{value:"all",children:"All Status"}),Object.entries(_).map(([r,o])=>e.jsx("option",{value:r,children:o.label},r))]})]}),v&&e.jsxs("div",{className:"card",style:{background:"#FAFAFF",border:"2px solid #E0E7FF"},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--accent)",marginBottom:16},children:"New Project Request"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:12},children:[e.jsx("input",{className:"input-base",placeholder:"Title",value:a.title,onChange:r=>F({...a,title:r.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Primary intent (required)",value:a.intent,onChange:r=>F({...a,intent:r.target.value})}),e.jsxs("select",{className:"input-base",value:a.priority,onChange:r=>F({...a,priority:r.target.value}),children:[e.jsx("option",{value:"P1",children:"P1 — Critical"}),e.jsx("option",{value:"P2",children:"P2 — Normal"}),e.jsx("option",{value:"P3",children:"P3 — Low"})]}),e.jsx("input",{className:"input-base",placeholder:"Project hint (optional)",value:a.project_hint,onChange:r=>F({...a,project_hint:r.target.value})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr 120px",gap:12},children:[e.jsx("input",{className:"input-base",placeholder:"Description / constraints",value:a.description,onChange:r=>F({...a,description:r.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Tags (comma separated)",value:a.tags,onChange:r=>F({...a,tags:r.target.value})}),e.jsx("input",{className:"input-base",type:"date",value:a.deadline,onChange:r=>F({...a,deadline:r.target.value})}),e.jsx("input",{className:"input-base",type:"number",placeholder:"Budget (USD)",value:a.budget_usd,onChange:r=>F({...a,budget_usd:r.target.value})}),e.jsx("button",{className:"btn-primary",onClick:L,disabled:i||!a.intent.trim(),children:i?"…":"Submit"})]})]}),(()=>{const r=w.find(o=>o.id===m);return r?e.jsx(ce,{project:r,agents:d,tasks:l,okrs:f,lastUpdated:s,onReplan:M,onExecute:$,onClose:()=>y(null)}):null})(),D.length===0?e.jsxs("div",{className:"card",style:{textAlign:"center",padding:64},children:[e.jsx("div",{style:{fontSize:32,marginBottom:12},children:"📁"}),e.jsx("div",{style:{fontSize:14,fontWeight:600},children:"No projects found"}),e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:4},children:'Use the "New Project" button to get started'})]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(360px, 1fr))",gap:20,opacity:m?.4:1,transition:"opacity 0.3s"},children:D.map(r=>e.jsx(le,{project:r,agents:d,selected:m===r.id,onClick:()=>y(r.id)},r.id))})]})}export{ue as default};
1
+ import{r as j,a4 as e,a7 as B,aw as O,aA as H,av as K,aB as G,aq as U,ad as q}from"./vendor-gUVFsxOc.js";import{l as X,s as Y,p as J,e as Q}from"./index-DUjHkafG.js";import{R as V,L as Z,C as ee,X as te,Y as re,T as ie,a as se,b as W,c as ne}from"./charts-CjCN_e1M.js";const _={active:{bg:"#EEF2FF",color:"var(--accent)",label:"Active"},complete:{bg:"#ECFDF5",color:"var(--mint)",label:"Complete"},paused:{bg:"#FFFBEB",color:"var(--amber)",label:"Paused"},archived:{bg:"#F8FAFC",color:"var(--muted)",label:"Archived"},pending:{bg:"#F8FAFC",color:"var(--muted)",label:"Pending"}},T={green:{bg:"#ECFDF5",color:"var(--mint)",label:"On Track"},amber:{bg:"#FFFBEB",color:"var(--amber)",label:"At Risk"},red:{bg:"#FEF2F2",color:"var(--red)",label:"Critical"}};function z(t){if(!t)return"—";try{const s=Math.round((Date.now()-new Date(t))/6e4);return s<1?"just now":s<60?`${s}m ago`:s<1440?`${Math.round(s/60)}h ago`:`${Math.round(s/1440)}d ago`}catch{return t}}function R(t){if(!t)return null;try{const s=Math.ceil((new Date(t)-Date.now())/864e5);return s<0?{label:`${Math.abs(s)}d overdue`,color:"var(--red)"}:s===0?{label:"Due today",color:"var(--amber)"}:s<=3?{label:`${s}d left`,color:"var(--amber)"}:{label:`${s}d left`,color:"var(--muted)"}}catch{return null}}function E(t){const s=(t._risks||[]).filter(f=>!f.resolved),n=t._progress_pct??0,d=t.target_completion?Math.ceil((new Date(t.target_completion)-Date.now())/864e5):999,l=t._task_counts||{};return s.some(f=>f.severity==="critical")||(l.blocked||0)>2||d<-3?"red":s.length>1||(l.hitl||0)>0||d<0||n<30?"amber":"green"}function I({pct:t,size:s=56,color:n="var(--accent)"}){const d=(s-8)/2,l=2*Math.PI*d,f=l*(t/100);return e.jsxs("div",{style:{position:"relative",width:s,height:s,flexShrink:0},children:[e.jsxs("svg",{width:s,height:s,style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:"#E2E8F0",strokeWidth:5}),e.jsx("circle",{cx:s/2,cy:s/2,r:d,fill:"none",stroke:n,strokeWidth:5,strokeDasharray:`${f} ${l}`,strokeLinecap:"round",style:{transition:"stroke-dasharray .8s cubic-bezier(0.4,0,0.2,1)"}})]}),e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:s*.2,fontWeight:800,color:n},children:[t,"%"]})]})}function N({agentId:t,agents:s,isOwner:n}){const d=s.find(l=>l.id===t);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,padding:"3px 10px",borderRadius:999,background:n?"#EEF2FF":"#F8FAFC",color:n?"var(--accent)":"var(--muted)",border:`1px solid ${n?"#E0E7FF":"var(--border)"}`,fontWeight:600},children:[e.jsx("span",{style:{fontSize:14},children:d?.emoji||"🤖"}),e.jsx("span",{children:d?.name||t}),n&&e.jsx("span",{style:{opacity:.6},children:"· Owner"})]})}function P({health:t}){const s=T[t];return e.jsx("span",{style:{background:s.bg,color:s.color,borderRadius:999,padding:"2px 10px",fontSize:10,fontWeight:700},children:s.label})}function ae({project:t}){const s=t.milestones||[];if(!s.length)return e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13,background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:"No milestones defined"});const n=new Date(t.created_at||Date.now()),d=new Date(t.target_completion||Date.now()+30*864e5),l=Math.max(1,d-n),f=Math.max(0,Math.min(100,(Date.now()-n)/l*100)),c={complete:"var(--mint)","in-progress":"var(--accent)",pending:"#E2E8F0",blocked:"var(--red)"};return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:"var(--muted)",marginBottom:12},children:[e.jsx("span",{children:n.toLocaleDateString()}),e.jsx("span",{style:{color:"var(--amber)",fontWeight:600},children:"Today"}),e.jsx("span",{children:d.toLocaleDateString()})]}),e.jsxs("div",{style:{position:"relative",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10,padding:"16px 0",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",left:`${f}%`,top:0,bottom:0,width:2,background:"var(--amber)",opacity:.7}}),s.map(u=>{const m=u.due?new Date(u.due):d,y=Math.max(4,Math.min(100,(m-n)/l*100)),h=u.status==="complete";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10,padding:"0 16px"},children:[e.jsx("div",{style:{fontSize:12,color:h?"var(--muted)":"var(--text)",width:130,flexShrink:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,textDecoration:h?"line-through":"none"},children:u.title}),e.jsx("div",{style:{flex:1,position:"relative",height:10,background:"#E2E8F0",borderRadius:999},children:e.jsx("div",{style:{position:"absolute",left:0,width:`${y}%`,height:"100%",background:c[u.status]||"#E2E8F0",borderRadius:999,transition:"width 1s ease"}})}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",width:60,flexShrink:0,textAlign:"right"},children:u.due?new Date(u.due).toLocaleDateString("en",{month:"short",day:"numeric"}):"—"})]},u.id)})]})]})}function oe({project:t,tasks:s}){const n=s.filter(h=>(t.task_ids||[]).includes(h.id)),d=n.length;if(!d)return e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No tasks to plot"});const l=new Date(t.created_at||Date.now()),f=new Date(t.target_completion||Date.now()+7*864e5),c=Math.max(1,Math.ceil((f-l)/864e5)),u=n.filter(h=>h.completed_at).map(h=>Math.max(0,Math.ceil((new Date(h.completed_at)-l)/864e5))).sort((h,x)=>h-x),m=Math.ceil((Date.now()-l)/864e5),y=Array.from({length:c+1},(h,x)=>({day:x,ideal:Math.round(d-d/c*x),actual:x<=m?d-u.filter(g=>g<=x).length:void 0}));return e.jsx(V,{width:"100%",height:220,children:e.jsxs(Z,{data:y,margin:{top:10,right:20,left:0,bottom:10},children:[e.jsx(ee,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),e.jsx(te,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"var(--muted)"}}),e.jsx(re,{axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"var(--muted)"},orientation:"right"}),e.jsx(ie,{contentStyle:{background:"#fff",border:"1px solid var(--border)",borderRadius:10,fontSize:12}}),e.jsx(se,{verticalAlign:"top",height:32,iconType:"rect",wrapperStyle:{fontSize:11}}),e.jsx(W,{type:"stepAfter",dataKey:"ideal",stroke:"#CBD5E1",strokeDasharray:"4 4",dot:!1,name:"Ideal"}),e.jsx(W,{type:"stepAfter",dataKey:"actual",stroke:"var(--accent)",strokeWidth:2,dot:{r:3,fill:"var(--accent)"},name:"Actual"}),e.jsx(ne,{x:m,stroke:"var(--amber)",strokeDasharray:"3 3"})]})})}function le({project:t,agents:s,selected:n,onClick:d}){const l=t._task_counts||{},f=t._progress_pct??0,c=(t._risks||[]).filter(x=>!x.resolved),u=E(t),m=_[t.status]||_.pending,y=f===100?"var(--mint)":c.length?"var(--red)":"var(--accent)",h=R(t.target_completion);return e.jsxs("div",{onClick:d,className:"card fade-in",style:{cursor:"pointer",padding:"20px",borderColor:n?"var(--accent)":c.length>0?"#FEE2E2":"var(--border)",borderWidth:n?2:1,background:n?"#FAFAFF":"#fff"},children:[e.jsxs("div",{style:{display:"flex",gap:14,marginBottom:16},children:[e.jsx(I,{pct:f,size:52,color:y}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:15,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx(P,{health:u})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("span",{style:{background:m.bg,color:m.color,borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600},children:m.label}),h&&e.jsx("span",{style:{fontSize:11,color:h.color,fontWeight:600},children:h.label})]})]}),e.jsx(U,{size:16,color:"var(--muted)",style:{flexShrink:0,marginTop:4}})]}),t.description&&e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.5,marginBottom:14,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t.description}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginBottom:14},children:[{l:"Tasks",v:`${l.done||0}/${l.total||0}`,c:"var(--accent)"},{l:"HITL",v:l.hitl||0,c:l.hitl?"var(--purple)":"var(--muted)"},{l:"Blocked",v:l.blocked||0,c:l.blocked?"var(--red)":"var(--muted)"},{l:"Spend",v:`$${(t.budget?.spent_usd??0).toFixed(0)}`,c:"var(--text-dim)"}].map(x=>e.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:8,padding:"8px 10px"},children:[e.jsx("div",{style:{fontSize:9,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:3},children:x.l}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:x.c},children:x.v})]},x.l))}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(N,{agentId:t.owner,agents:s,isOwner:!0}),c.length>0&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--red)",fontWeight:600},children:[e.jsx(q,{size:12})," ",c.length," risk",c.length>1?"s":""]})]})]})}const de=["Overview","Timeline","Tasks","Budget","OKRs","Logs"];function ce({project:t,agents:s,tasks:n,onClose:d,onReplan:l,onExecute:f}){const[c,u]=j.useState("Overview");t._task_counts;const m=t._progress_pct??0,y=(t._risks||[]).filter(i=>!i.resolved),h=E(t),x=m===100?"var(--mint)":y.length?"var(--red)":"var(--accent)",g=_[t.status]||_.pending,S=R(t.target_completion);return e.jsxs("div",{className:"fade-in",style:{background:"#fff",border:"2px solid #E0E7FF",borderRadius:20,marginBottom:32,overflow:"hidden",boxShadow:"0 8px 32px rgba(79,70,229,0.08)"},children:[e.jsxs("div",{style:{padding:"28px 32px",background:"linear-gradient(135deg, #FAFAFF 0%, #fff 100%)",borderBottom:"1px solid var(--border)",display:"flex",gap:24,alignItems:"flex-start"},children:[e.jsx(I,{pct:m,size:80,color:x}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:24,fontWeight:800,color:"var(--text)"},children:t.name}),e.jsx("span",{style:{background:g.bg,color:g.color,borderRadius:999,padding:"4px 12px",fontSize:12,fontWeight:600},children:g.label}),e.jsx(P,{health:h})]}),t.description&&e.jsx("div",{style:{fontSize:14,color:"var(--text-dim)",lineHeight:1.6,marginBottom:12,maxWidth:600},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[e.jsx(N,{agentId:t.owner,agents:s,isOwner:!0}),S&&e.jsx("span",{style:{fontSize:12,color:S.color,fontWeight:600},children:S.label}),(t.tags||[]).map(i=>e.jsx("span",{style:{background:"#EEF2FF",color:"var(--accent)",borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:600},children:i},i))]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,width:140,flexShrink:0},children:[e.jsxs("button",{className:"btn-primary",onClick:()=>f?.(t.id),style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(H,{size:13})," Execute"]}),e.jsxs("button",{className:"btn-secondary",onClick:()=>l?.(t.id),style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(B,{size:13})," Replan"]}),e.jsxs("button",{className:"btn-secondary",onClick:d,style:{padding:"10px",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(K,{size:13})," Close"]})]})]}),e.jsx("div",{style:{display:"flex",background:"#F8FAFC",borderBottom:"1px solid var(--border)",padding:"0 24px",gap:4},children:de.map(i=>{const p=c===i;return e.jsx("button",{onClick:()=>u(i),style:{background:"none",border:"none",cursor:"pointer",padding:"14px 16px",fontSize:13,fontWeight:p?700:500,color:p?"var(--accent)":"var(--muted)",borderBottom:`2px solid ${p?"var(--accent)":"transparent"}`,transition:"all 0.15s"},children:i},i)})}),e.jsxs("div",{style:{padding:"28px 32px",minHeight:360},children:[c==="Overview"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:40},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:16,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Timeline"}),e.jsx(ae,{project:t}),e.jsx("h3",{style:{marginTop:32,marginBottom:12,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Risks"}),y.length>0?y.map(i=>e.jsxs("div",{style:{padding:"12px 14px",background:"#FFF1F2",border:"1px solid #FEE2E2",borderRadius:10,marginBottom:8},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:4},children:i.description}),e.jsxs("div",{style:{fontSize:11,color:"var(--red)",fontWeight:600},children:[i.severity," · ",z(i.detected_at)]})]},i.id)):e.jsxs("div",{style:{padding:"16px",background:"#ECFDF5",border:"1px solid #D1FAE5",borderRadius:10,display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--mint)",fontWeight:500},children:[e.jsx(G,{size:15})," No active risks"]})]}),e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:16,fontSize:14,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Activity"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(t._activity||[]).slice(0,10).map((i,p)=>e.jsxs("div",{style:{display:"flex",gap:10,fontSize:13,padding:"8px 0",borderBottom:"1px solid var(--border)"},children:[e.jsx("span",{style:{color:"var(--muted)",flexShrink:0},children:z(i.ts)}),e.jsx("span",{style:{color:"var(--text-dim)",flex:1},children:i.text})]},p)),(t._activity||[]).length===0&&e.jsx("span",{style:{color:"var(--muted)",fontSize:13},children:"No activity yet"})]})]})]}),c==="Timeline"&&e.jsxs("div",{children:[e.jsx("h3",{style:{marginBottom:20,fontSize:15},children:"Burndown Chart"}),e.jsx(oe,{project:t,tasks:n})]}),c==="Tasks"&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:16},children:["in-progress","blocked","needs_human_decision","complete"].map(i=>{const v={"in-progress":{label:"In Progress",color:"var(--accent)",bg:"#EEF2FF"},blocked:{label:"Blocked",color:"var(--red)",bg:"#FEF2F2"},needs_human_decision:{label:"HITL",color:"var(--purple)",bg:"#F5F3FF"},complete:{label:"Complete",color:"var(--mint)",bg:"#ECFDF5"}}[i],b=n.filter(a=>(t.task_ids||[]).includes(a.id)&&a.status===i);return e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:12,fontWeight:700,color:v.color,textTransform:"uppercase",marginBottom:10,padding:"4px 10px",background:v.bg,borderRadius:8,display:"inline-block"},children:[v.label," (",b.length,")"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[b.map(a=>e.jsxs("div",{style:{padding:"10px 12px",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:10},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text)",marginBottom:3},children:a.title}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:a.id?.slice(0,12)})]},a.id)),b.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)",fontStyle:"italic"},children:"None"})]})]},i)})}),c==="Budget"&&e.jsx("div",{children:(()=>{const i=t.budget?.allocated_usd||0,p=t.budget?.spent_usd||0,v=i?Math.round(p/i*100):0,b=v>90?"var(--red)":v>75?"var(--amber)":"var(--mint)",a=v>90?"#FEF2F2":v>75?"#FFFBEB":"#F0FDF4";return e.jsxs("div",{style:{background:a,border:`1px solid ${b}44`,borderRadius:16,padding:28,maxWidth:520},children:[e.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:12},children:"Budget Expenditure"}),e.jsxs("div",{style:{fontSize:32,fontWeight:800,color:b,marginBottom:16},children:["$",p.toFixed(2)," ",e.jsxs("span",{style:{fontSize:16,color:"var(--muted)",fontWeight:500},children:["/ $",i.toFixed(2)]})]}),e.jsx("div",{className:"progress-track",style:{height:12},children:e.jsx("div",{className:"progress-fill",style:{width:`${Math.min(100,v)}%`,background:b,height:"100%",borderRadius:999}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:8,fontSize:12,color:"var(--muted)"},children:[e.jsxs("span",{children:[v,"% utilized"]}),i>0&&e.jsxs("span",{children:["$",(i-p).toFixed(2)," remaining"]})]})]})})()}),c==="OKRs"&&e.jsxs("div",{children:[(t.okr_links||[]).length===0?e.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--muted)",fontSize:13},children:"No OKR links for this project"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:(t.okr_links||[]).map((i,p)=>e.jsxs("div",{style:{padding:"16px 18px",background:"#FAFAFF",border:"1px solid #E0E7FF",borderRadius:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)",marginBottom:4},children:i.objective||i.title||`OKR #${p+1}`}),i.key_result&&e.jsxs("div",{style:{fontSize:12,color:"var(--accent)",marginBottom:4},children:["KR: ",i.key_result]}),i.contribution&&e.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:["Contribution: ",i.contribution]})]},p))}),(t.decisions||[]).length>0&&e.jsxs("div",{style:{marginTop:28},children:[e.jsx("h3",{style:{marginBottom:12,fontSize:15},children:"Decisions"}),t.decisions.map((i,p)=>e.jsxs("div",{style:{padding:"14px 16px",background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,marginBottom:8},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",marginBottom:4},children:i.decision}),i.rationale&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)"},children:i.rationale})]},p))]})]}),c==="Logs"&&e.jsxs("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:12,overflow:"hidden"},children:[(t._sessions||[]).map((i,p)=>e.jsxs("div",{style:{display:"flex",gap:20,padding:"10px 16px",borderBottom:"1px solid var(--border)",fontSize:12,fontFamily:"var(--font-mono)",background:p%2===0?"#fff":"#F8FAFC"},children:[e.jsx("span",{style:{color:"var(--accent)",minWidth:80},children:i.proc_id||"--"}),e.jsx("span",{style:{flex:1,color:"var(--text-dim)"},children:i.task_id}),e.jsx("span",{style:{color:i.status==="failed"?"var(--red)":"var(--mint)",fontWeight:600},children:i.status}),e.jsx("span",{style:{color:"var(--muted)"},children:z(i.completed_at)})]},p)),(t._sessions||[]).length===0&&e.jsx("div",{style:{padding:32,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No session logs"})]})]})]})}function ue({data:t,lastUpdated:s,toast:n}){const{agents:d=[],tasks:l=[],okrs:f={}}=t||{},[c,u]=j.useState([]),[m,y]=j.useState(null),[h,x]=j.useState(!0),[g,S]=j.useState({status:"all",search:"",health:"all"}),[i,p]=j.useState(!1),[v,b]=j.useState(!1),[a,F]=j.useState({title:"",intent:"",description:"",priority:"P2",tags:"",project_hint:"",deadline:"",budget_usd:""}),C=j.useCallback(async()=>{try{const r=await X();u(r.projects||[])}catch{u([])}finally{x(!1)}},[]);j.useEffect(()=>{C()},[C]);const L=async()=>{if(!(!a.intent.trim()&&!a.title.trim())){p(!0);try{const r=await Y({...a,tags:a.tags.split(",").map(o=>o.trim()).filter(Boolean)});await C(),F({title:"",intent:"",description:"",priority:"P2",tags:"",project_hint:"",deadline:"",budget_usd:""}),b(!1),n?.(`Task routed: ${r.projectId}`,"success")}catch(r){n?.(r.message,"error")}finally{p(!1)}}},M=async r=>{try{await J(r),await C(),n?.("Replan initiated","success")}catch(o){n?.(o.message,"error")}},$=async r=>{try{await Q(r),await C(),n?.("Execution started","success")}catch(o){n?.(o.message,"error")}},w=j.useMemo(()=>c.map(r=>{const o=l.filter(k=>(r.task_ids||[]).includes(k.id)),A=o.filter(k=>k.status==="complete").length;return{...r,_task_counts:{total:o.length,done:A,active:o.filter(k=>k.status==="in-progress").length,blocked:o.filter(k=>k.status==="blocked").length,hitl:o.filter(k=>k.status==="needs_human_decision").length},_progress_pct:o.length>0?Math.round(A/o.length*100):0,_risks:r._risks||[],_activity:r._activity||[]}}),[c,l]),D=j.useMemo(()=>w.filter(r=>!(g.status!=="all"&&r.status!==g.status||g.health!=="all"&&E(r)!==g.health||g.search&&!(r.name||"").toLowerCase().includes(g.search.toLowerCase()))).sort((r,o)=>(o.priority_weight||0)-(r.priority_weight||0)),[w,g]);return h?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:80},children:[e.jsx(B,{size:20,color:"var(--accent)",style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{style:{marginLeft:12,color:"var(--muted)",fontSize:13},children:"Loading projects…"})]}):e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Projects"}),e.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[w.length," projects · ",w.filter(r=>r.status==="active").length," active"]})]}),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("button",{className:"btn-secondary",onClick:C,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px"},children:[e.jsx(B,{size:13})," Refresh"]}),e.jsxs("button",{className:"btn-primary",onClick:()=>b(!v),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(O,{size:14})," New Project"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[[{label:"All Health",value:"all",color:"var(--text-dim)",bg:"#F8FAFC"},...Object.entries(T).map(([r,o])=>({label:o.label,value:r,color:o.color,bg:o.bg}))].map(r=>e.jsx("button",{onClick:()=>S(o=>({...o,health:r.value})),style:{background:g.health===r.value?r.bg:"#F8FAFC",color:g.health===r.value?r.color:"var(--muted)",border:`1px solid ${g.health===r.value?r.color+"44":"var(--border)"}`,borderRadius:999,padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:r.label},r.value)),e.jsx("input",{className:"input-base",placeholder:"Search projects…",value:g.search,onChange:r=>S(o=>({...o,search:r.target.value})),style:{marginLeft:"auto",width:220}}),e.jsxs("select",{className:"input-base",value:g.status,onChange:r=>S(o=>({...o,status:r.target.value})),style:{width:140},children:[e.jsx("option",{value:"all",children:"All Status"}),Object.entries(_).map(([r,o])=>e.jsx("option",{value:r,children:o.label},r))]})]}),v&&e.jsxs("div",{className:"card",style:{background:"#FAFAFF",border:"2px solid #E0E7FF"},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--accent)",marginBottom:16},children:"New Project Request"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:12},children:[e.jsx("input",{className:"input-base",placeholder:"Title",value:a.title,onChange:r=>F({...a,title:r.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Primary intent (required)",value:a.intent,onChange:r=>F({...a,intent:r.target.value})}),e.jsxs("select",{className:"input-base",value:a.priority,onChange:r=>F({...a,priority:r.target.value}),children:[e.jsx("option",{value:"P1",children:"P1 — Critical"}),e.jsx("option",{value:"P2",children:"P2 — Normal"}),e.jsx("option",{value:"P3",children:"P3 — Low"})]}),e.jsx("input",{className:"input-base",placeholder:"Project hint (optional)",value:a.project_hint,onChange:r=>F({...a,project_hint:r.target.value})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr 120px",gap:12},children:[e.jsx("input",{className:"input-base",placeholder:"Description / constraints",value:a.description,onChange:r=>F({...a,description:r.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Tags (comma separated)",value:a.tags,onChange:r=>F({...a,tags:r.target.value})}),e.jsx("input",{className:"input-base",type:"date",value:a.deadline,onChange:r=>F({...a,deadline:r.target.value})}),e.jsx("input",{className:"input-base",type:"number",placeholder:"Budget (USD)",value:a.budget_usd,onChange:r=>F({...a,budget_usd:r.target.value})}),e.jsx("button",{className:"btn-primary",onClick:L,disabled:i||!a.intent.trim(),children:i?"…":"Submit"})]})]}),(()=>{const r=w.find(o=>o.id===m);return r?e.jsx(ce,{project:r,agents:d,tasks:l,okrs:f,lastUpdated:s,onReplan:M,onExecute:$,onClose:()=>y(null)}):null})(),D.length===0?e.jsxs("div",{className:"card",style:{textAlign:"center",padding:64},children:[e.jsx("div",{style:{fontSize:32,marginBottom:12},children:"📁"}),e.jsx("div",{style:{fontSize:14,fontWeight:600},children:"No projects found"}),e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:4},children:'Use the "New Project" button to get started'})]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(360px, 1fr))",gap:20,opacity:m?.4:1,transition:"opacity 0.3s"},children:D.map(r=>e.jsx(le,{project:r,agents:d,selected:m===r.id,onClick:()=>y(r.id)},r.id))})]})}export{ue as default};
@@ -0,0 +1 @@
1
+ import{r as i,a4 as e,a7 as Z,aQ as ee}from"./vendor-gUVFsxOc.js";import{g as te,b as se,d as ae,a as ie,v as le,f as ne,r as re,h as oe,i as ce,j as de,k as ue,m as me}from"./index-DUjHkafG.js";function ge({data:m,toast:a}){const p=m?.workspace_meta||{},s=m?.settings||{},[o,c]=i.useState({budget_daily:s.budget_daily??"",budget_weekly:s.budget_weekly??"",budget_monthly:s.budget_monthly??"",hitl_enabled:s.hitl_enabled!==!1,auto_resume:s.auto_resume===!0,auth:{public_mode:s.auth?.public_mode===!0,has_pin:s.auth?.has_pin===!0}}),[v,j]=i.useState(!1),[g,f]=i.useState(""),[S,w]=i.useState(""),[k,N]=i.useState(""),[_,C]=i.useState(""),[P,I]=i.useState(""),[b,R]=i.useState({hasPin:!1,publicMode:!1,writeUnlocked:!1}),[A,D]=i.useState([]),[T,U]=i.useState("My Dashboard"),[h,W]=i.useState(""),[B,E]=i.useState("replace"),[F,L]=i.useState([]),[d,K]=i.useState("default"),[u,V]=i.useState(""),[x,M]=i.useState("");i.useEffect(()=>{c({budget_daily:s.budget_daily??"",budget_weekly:s.budget_weekly??"",budget_monthly:s.budget_monthly??"",hitl_enabled:s.hitl_enabled!==!1,auto_resume:s.auto_resume===!0,auth:{public_mode:s.auth?.public_mode===!0,has_pin:s.auth?.has_pin===!0}})},[s.budget_daily,s.budget_weekly,s.budget_monthly,s.hitl_enabled,s.auto_resume,s.auth?.public_mode,s.auth?.has_pin]);const n=async()=>{try{const[t,l,y]=await Promise.all([te(),se(),ae()]);R({hasPin:t?.hasPin===!0,publicMode:t?.publicMode===!0,writeUnlocked:t?.writeUnlocked===!0}),D(l?.templates||[]),L(y?.scopes||[])}catch{}};i.useEffect(()=>{n()},[]);const $=async()=>{j(!0);try{await ie("/api/settings",o),a?.("Settings saved","success")}catch(t){a?.(t.message,"error")}j(!1)},G=async()=>{if(g.trim())try{await le(g.trim()),f(""),await n(),a?.("Write access unlocked","success")}catch(t){a?.(t.message,"error")}},q=async()=>{try{await ne(k.trim(),S.trim()),w(""),N(""),await n(),a?.("PIN updated","success")}catch(t){a?.(t.message,"error")}},H=async()=>{try{await re(_.trim()),C(""),await n(),a?.("PIN removed","success")}catch(t){a?.(t.message,"error")}},Q=async()=>{try{await oe(!b.publicMode,P.trim()),I(""),await n(),a?.("Public mode updated","success")}catch(t){a?.(t.message,"error")}},J=async()=>{try{await ce({name:T.trim(),id:h.trim()||void 0}),await n(),a?.("Template exported","success")}catch(t){a?.(t.message,"error")}},O=async()=>{if(h.trim())try{await de({id:h.trim(),mode:B}),await n(),a?.("Template imported","success")}catch(t){a?.(t.message,"error")}},X=async()=>{if(!(!d.trim()||!u.trim()||!x.trim()))try{await ue(d.trim(),{[u.trim()]:x}),M(""),await n(),a?.("Secret stored","success")}catch(t){a?.(t.message,"error")}},Y=async()=>{if(!(!d.trim()||!u.trim()))try{await me(d.trim(),u.trim()),await n(),a?.("Secret removed","success")}catch(t){a?.(t.message,"error")}};function r({label:t,sub:l,children:y}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 0",borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text)"},children:t}),l&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:2},children:l})]}),e.jsx("div",{style:{flexShrink:0},children:y})]})}function z({value:t,onChange:l}){return e.jsx("button",{onClick:()=>l(!t),style:{width:44,height:24,borderRadius:999,border:"none",cursor:"pointer",background:t?"var(--accent)":"#D1D5DB",position:"relative",transition:"background 0.2s",padding:0},children:e.jsx("span",{style:{position:"absolute",top:3,left:t?22:3,width:18,height:18,borderRadius:"50%",background:"#fff",transition:"left 0.2s",display:"block",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})}return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Settings"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Configure your AGI Farm workspace settings"})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:12},children:"Workspace Info"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,fontSize:13,color:"var(--text-dim)"},children:[{k:"Workspace Path",v:p.path||m?.workspace||"—"},{k:"Team Name",v:p.team_name||"—"},{k:"Version",v:p.version||m?.version||"—"},{k:"Process ID",v:p.pid||"—"}].map(t=>e.jsxs("div",{style:{padding:"12px",background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",marginBottom:4},children:t.k}),e.jsx("div",{style:{fontWeight:600,color:"var(--text)",wordBreak:"break-all"},children:t.v})]},t.k))})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Budget Limits"}),e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:16},children:"Spending limits in USD. Leave blank for no limit."}),e.jsx(r,{label:"Daily Limit",sub:"Maximum spend in 24h",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 1.00",value:o.budget_daily,onChange:t=>c(l=>({...l,budget_daily:t.target.value}))})}),e.jsx(r,{label:"Weekly Limit",sub:"Maximum spend in 7 days",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 5.00",value:o.budget_weekly,onChange:t=>c(l=>({...l,budget_weekly:t.target.value}))})}),e.jsx(r,{label:"Monthly Limit",sub:"Maximum spend in 30 days",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 20.00",value:o.budget_monthly,onChange:t=>c(l=>({...l,budget_monthly:t.target.value}))})})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Behavior"}),e.jsx(r,{label:"HITL Gate",sub:"Pause agents at human approval gates",children:e.jsx(z,{value:o.hitl_enabled,onChange:t=>c(l=>({...l,hitl_enabled:t}))})}),e.jsx(r,{label:"Auto Resume",sub:"Automatically resume tasks after approval",children:e.jsx(z,{value:o.auto_resume,onChange:t=>c(l=>({...l,auto_resume:t}))})})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Access Control"}),e.jsx(r,{label:"Write Access",sub:b.writeUnlocked?"Unlocked for this browser session":"PIN required for edits",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{width:130},placeholder:"PIN",value:g,onChange:t=>f(t.target.value)}),e.jsx("button",{className:"btn-secondary",onClick:G,children:"Unlock"})]})}),e.jsx(r,{label:"Public Mode",sub:"Read-only dashboard mode",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{width:130},placeholder:"PIN (if set)",value:P,onChange:t=>I(t.target.value)}),e.jsx("button",{className:"btn-secondary",onClick:Q,children:b.publicMode?"Disable":"Enable"})]})}),e.jsx(r,{label:"Set/Rotate PIN",sub:"4-8 digits",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{width:130},placeholder:"Current PIN",value:S,onChange:t=>w(t.target.value)}),e.jsx("input",{className:"input-base",style:{width:130},placeholder:"New PIN",value:k,onChange:t=>N(t.target.value)}),e.jsx("button",{className:"btn-secondary",onClick:q,children:"Save PIN"})]})}),e.jsx(r,{label:"Remove PIN",sub:"Disables PIN lock",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{className:"input-base",style:{width:130},placeholder:"Current PIN",value:_,onChange:t=>C(t.target.value)}),e.jsx("button",{className:"btn-secondary",onClick:H,children:"Remove"})]})})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Templates"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:12},children:[e.jsx("input",{className:"input-base",placeholder:"Template name",value:T,onChange:t=>U(t.target.value)}),e.jsx("input",{className:"input-base",placeholder:"Template id (optional)",value:h,onChange:t=>W(t.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx("button",{className:"btn-secondary",onClick:J,children:"Export Current"}),e.jsxs("select",{className:"input-base",value:B,onChange:t=>E(t.target.value),style:{width:130},children:[e.jsx("option",{value:"replace",children:"Replace"}),e.jsx("option",{value:"merge",children:"Merge"})]}),e.jsx("button",{className:"btn-secondary",onClick:O,children:"Import Selected ID"})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:["Available: ",(A||[]).map(t=>t.id).join(", ")||"none"]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Secrets"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:10,marginBottom:12},children:[e.jsx("input",{className:"input-base",placeholder:"Scope",value:d,onChange:t=>K(t.target.value)}),e.jsx("input",{className:"input-base",placeholder:"Key",value:u,onChange:t=>V(t.target.value)}),e.jsx("input",{className:"input-base",placeholder:"Value",value:x,onChange:t=>M(t.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsx("button",{className:"btn-secondary",onClick:X,children:"Store Secret"}),e.jsx("button",{className:"btn-secondary",onClick:Y,children:"Delete Secret Key"})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:["Scopes: ",(F||[]).map(t=>`${t.scope}(${t.count})`).join(", ")||"none"]})]}),e.jsx("button",{onClick:$,disabled:v,className:"btn-primary",style:{alignSelf:"flex-start",display:"flex",alignItems:"center",gap:8,padding:"10px 28px"},children:v?e.jsxs(e.Fragment,{children:[e.jsx(Z,{size:14,className:"spin"})," Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:14})," Save Settings"]})})]})}export{ge as default};
@@ -1 +1 @@
1
- import{r as x,a4 as e,aw as E,ax as N,ay as D,az as P,am as _}from"./vendor-gUVFsxOc.js";import{c as A,u as W}from"./index-B3IWXYRY.js";const I=["all","pending","in-progress","complete","failed","blocked","hitl"],j=25,v={complete:{bg:"#ECFDF5",color:"var(--mint)",label:"Complete"},"in-progress":{bg:"#EEF2FF",color:"var(--accent)",label:"In Progress"},failed:{bg:"#FEF2F2",color:"var(--red)",label:"Failed"},needs_human_decision:{bg:"#F5F3FF",color:"var(--purple)",label:"HITL"},blocked:{bg:"#FEF2F2",color:"var(--red)",label:"Blocked"},pending:{bg:"#F1F5F9",color:"var(--muted)",label:"Pending"}};function L({deadline:s}){const[,c]=x.useState(0);if(x.useEffect(()=>{const n=setInterval(()=>c(o=>o+1),1e4);return()=>clearInterval(n)},[]),!s)return null;try{const n=new Date(s),o=Math.round((n-Date.now())/6e4),i=Math.abs(o),d=o<0,r=d?"var(--red)":o<60?"var(--amber)":"var(--text-dim)",p=i<60?`${d?"-":""}${i}m`:i<1440?`${d?"-":""}${Math.round(i/60)}h`:n.toLocaleDateString();return e.jsxs("span",{title:n.toLocaleString(),style:{display:"inline-flex",alignItems:"center",gap:4,color:r,fontSize:11,fontWeight:600},children:[e.jsx(_,{size:11}),p,d?" !":""]})}catch{return null}}function R({task:s,expanded:c,onToggle:n,toast:o}){const i=(s.status||"").toLowerCase(),d=v[i]||v.pending,r=(s.sla?.priority||s.priority||"P3").toUpperCase(),p=i==="needs_human_decision";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:n,style:{borderBottom:"1px solid var(--border)",background:p||c?"#FAFAFF":"#fff",cursor:"pointer",transition:"background 0.15s"},children:[e.jsx("td",{style:{padding:"12px 16px",fontSize:11,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:s.id?.slice(0,12)||"--"}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p&&e.jsx("span",{style:{fontSize:14},children:"🔔"}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:s.title||"--"})]})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:12,color:"var(--text-dim)"},children:[e.jsx(N,{size:12}),s.assigned_to||"—"]})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx("span",{style:{background:r==="P1"?"#FEF2F2":"#F1F5F9",color:r==="P1"?"var(--red)":"var(--muted)",border:`1px solid ${r==="P1"?"#FEE2E2":"#E2E8F0"}`,borderRadius:999,fontSize:10,fontWeight:700,padding:"2px 8px"},children:r})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx("span",{style:{background:d.bg,color:d.color,borderRadius:999,fontSize:11,fontWeight:600,padding:"3px 10px"},children:d.label})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx(L,{deadline:s.sla?.deadline||s.sla?.target})}),e.jsx("td",{style:{padding:"12px 16px",color:"var(--muted)",textAlign:"right"},children:c?e.jsx(D,{size:14}):e.jsx(P,{size:14})})]}),c&&e.jsx("tr",{style:{background:"#FAFAFF",borderBottom:"2px solid #E0E7FF"},children:e.jsx("td",{colSpan:7,style:{padding:"24px 32px"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:32},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[s.hitl_reason&&e.jsxs("div",{style:{padding:"14px 16px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:12},children:[e.jsx("div",{style:{fontSize:11,color:"var(--purple)",fontWeight:700,marginBottom:6},children:"⚡ Intervention Required"}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:s.hitl_reason})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--muted)",textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Description"}),e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.7,background:"#F8FAFC",padding:"14px",borderRadius:10,border:"1px solid var(--border)"},children:s.description||"No description available."})]}),s.output&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--mint)",textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Output"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",lineHeight:1.7,background:"#F0FDF4",padding:"14px",borderRadius:10,border:"1px solid #D1FAE5",fontFamily:"var(--font-mono)"},children:s.output})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{className:"card",style:{gap:8,display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Details"}),[{k:"Type",v:s.type},{k:"Created",v:s.created_at?new Date(s.created_at).toLocaleString():"—"},{k:"Completed",v:s.completed_at?new Date(s.completed_at).toLocaleString():"—"}].filter(l=>l.v).map(l=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12},children:[e.jsx("span",{style:{color:"var(--muted)"},children:l.k}),e.jsx("span",{style:{color:"var(--text)",fontWeight:500},children:l.v})]},l.k))]}),e.jsxs("div",{className:"card",style:{gap:8,display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:"Update Status"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["pending","in-progress","complete","failed","blocked"].filter(l=>l!==i).map(l=>{const g=v[l]||v.pending;return e.jsx("button",{onClick:async h=>{h.stopPropagation();try{await W(s.id,{status:l}),o?.("Status updated","success")}catch(y){o?.(y.message,"error")}},style:{background:g.bg,color:g.color,border:`1px solid ${g.color}44`,borderRadius:8,padding:"5px 12px",fontSize:11,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:g.label},l)})})]})]})]})})})]})}function M({data:s,toast:c}){const{tasks:n=[],agents:o=[]}=s||{},[i,d]=x.useState("all"),[r,p]=x.useState(0),[l,g]=x.useState(null),[h,y]=x.useState(""),[b,F]=x.useState(!1),[a,u]=x.useState({id:"",title:"",description:"",priority:"P2",assigned_to:"",type:"dev"}),[S,k]=x.useState(!1),z=async()=>{if(!(!a.id||!a.title)){k(!0);try{await A(a),c?.("Task created","success"),F(!1),u({id:"",title:"",description:"",priority:"P2",assigned_to:"",type:"dev"})}catch(t){c?.(t.message,"error")}finally{k(!1)}}},C=n.filter(t=>{if(i!=="all"&&t.status!==(i==="hitl"?"needs_human_decision":i))return!1;if(!h)return!0;const m=h.toLowerCase();return(t.id||"").toLowerCase().includes(m)||(t.title||"").toLowerCase().includes(m)}),f=Math.ceil(C.length/j),w=C.slice(r*j,(r+1)*j);return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Task Queue"}),e.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[n.length," tasks across all agents"]})]}),e.jsxs("button",{className:"btn-primary",onClick:()=>F(!b),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(E,{size:14})," New Task"]})]}),b&&e.jsxs("div",{className:"card",style:{background:"#FAFAFF",borderColor:"#E0E7FF",borderWidth:2},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--accent)",marginBottom:16},children:"Create New Task"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[e.jsx("input",{className:"input-base",placeholder:"Task ID *",value:a.id,onChange:t=>u({...a,id:t.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Title *",value:a.title,onChange:t=>u({...a,title:t.target.value}),style:{gridColumn:"span 2"}}),e.jsx("textarea",{className:"input-base",placeholder:"Description",value:a.description,onChange:t=>u({...a,description:t.target.value}),style:{gridColumn:"span 3",minHeight:80,resize:"vertical"}}),e.jsxs("select",{className:"input-base",value:a.priority,onChange:t=>u({...a,priority:t.target.value}),children:[e.jsx("option",{value:"P1",children:"P1 — Critical"}),e.jsx("option",{value:"P2",children:"P2 — Normal"}),e.jsx("option",{value:"P3",children:"P3 — Low"})]}),e.jsxs("select",{className:"input-base",value:a.assigned_to,onChange:t=>u({...a,assigned_to:t.target.value}),children:[e.jsx("option",{value:"",children:"Assign to agent…"}),o.map(t=>e.jsxs("option",{value:t.id,children:[t.emoji," ",t.name||t.id]},t.id))]}),e.jsx("button",{className:"btn-primary",onClick:z,disabled:S||!a.id||!a.title,children:S?"Creating…":"Create Task"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("div",{style:{display:"flex",gap:4},children:I.map(t=>{const m=t==="all"?n.length:n.filter(T=>T.status===(t==="hitl"?"needs_human_decision":t)).length;return e.jsxs("button",{onClick:()=>{d(t),p(0)},style:{background:i===t?"var(--accent)":"#F8FAFC",color:i===t?"#fff":"var(--text-dim)",border:`1px solid ${i===t?"var(--accent)":"var(--border)"}`,borderRadius:8,padding:"6px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:[t," ",m>0&&e.jsxs("span",{style:{opacity:.75},children:["(",m,")"]})]},t)})}),e.jsx("input",{className:"input-base",placeholder:"Search tasks…",value:h,onChange:t=>{y(t.target.value),p(0)},style:{marginLeft:"auto",width:220}})]}),e.jsx("div",{style:{background:"#fff",border:"1px solid var(--border)",borderRadius:16,overflow:"hidden",boxShadow:"var(--shadow)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC",borderBottom:"1px solid var(--border)"},children:["ID","Title","Assigned To","Priority","Status","Deadline",""].map(t=>e.jsx("th",{style:{padding:"10px 16px",textAlign:"left",fontSize:10,color:"var(--muted)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em"},children:t},t))})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:64,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No tasks match your filter"})}):w.map(t=>e.jsx(R,{task:t,expanded:l===t.id,onToggle:()=>g(l===t.id?null:t.id),toast:c},t.id))})]})}),f>1&&e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"center",alignItems:"center"},children:[e.jsx("button",{className:"btn-secondary",onClick:()=>p(Math.max(0,r-1)),disabled:r===0,style:{padding:"6px 16px"},children:"← Prev"}),e.jsxs("span",{style:{fontSize:13,color:"var(--muted)"},children:["Page ",r+1," of ",f]}),e.jsx("button",{className:"btn-secondary",onClick:()=>p(Math.min(f-1,r+1)),disabled:r===f-1,style:{padding:"6px 16px"},children:"Next →"})]})]})}export{M as default};
1
+ import{r as x,a4 as e,aw as E,ax as N,ay as D,az as P,am as _}from"./vendor-gUVFsxOc.js";import{c as A,u as W}from"./index-DUjHkafG.js";const I=["all","pending","in-progress","complete","failed","blocked","hitl"],j=25,v={complete:{bg:"#ECFDF5",color:"var(--mint)",label:"Complete"},"in-progress":{bg:"#EEF2FF",color:"var(--accent)",label:"In Progress"},failed:{bg:"#FEF2F2",color:"var(--red)",label:"Failed"},needs_human_decision:{bg:"#F5F3FF",color:"var(--purple)",label:"HITL"},blocked:{bg:"#FEF2F2",color:"var(--red)",label:"Blocked"},pending:{bg:"#F1F5F9",color:"var(--muted)",label:"Pending"}};function L({deadline:s}){const[,c]=x.useState(0);if(x.useEffect(()=>{const n=setInterval(()=>c(o=>o+1),1e4);return()=>clearInterval(n)},[]),!s)return null;try{const n=new Date(s),o=Math.round((n-Date.now())/6e4),i=Math.abs(o),d=o<0,r=d?"var(--red)":o<60?"var(--amber)":"var(--text-dim)",p=i<60?`${d?"-":""}${i}m`:i<1440?`${d?"-":""}${Math.round(i/60)}h`:n.toLocaleDateString();return e.jsxs("span",{title:n.toLocaleString(),style:{display:"inline-flex",alignItems:"center",gap:4,color:r,fontSize:11,fontWeight:600},children:[e.jsx(_,{size:11}),p,d?" !":""]})}catch{return null}}function R({task:s,expanded:c,onToggle:n,toast:o}){const i=(s.status||"").toLowerCase(),d=v[i]||v.pending,r=(s.sla?.priority||s.priority||"P3").toUpperCase(),p=i==="needs_human_decision";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:n,style:{borderBottom:"1px solid var(--border)",background:p||c?"#FAFAFF":"#fff",cursor:"pointer",transition:"background 0.15s"},children:[e.jsx("td",{style:{padding:"12px 16px",fontSize:11,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:s.id?.slice(0,12)||"--"}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p&&e.jsx("span",{style:{fontSize:14},children:"🔔"}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:s.title||"--"})]})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:12,color:"var(--text-dim)"},children:[e.jsx(N,{size:12}),s.assigned_to||"—"]})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx("span",{style:{background:r==="P1"?"#FEF2F2":"#F1F5F9",color:r==="P1"?"var(--red)":"var(--muted)",border:`1px solid ${r==="P1"?"#FEE2E2":"#E2E8F0"}`,borderRadius:999,fontSize:10,fontWeight:700,padding:"2px 8px"},children:r})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx("span",{style:{background:d.bg,color:d.color,borderRadius:999,fontSize:11,fontWeight:600,padding:"3px 10px"},children:d.label})}),e.jsx("td",{style:{padding:"12px 16px"},children:e.jsx(L,{deadline:s.sla?.deadline||s.sla?.target})}),e.jsx("td",{style:{padding:"12px 16px",color:"var(--muted)",textAlign:"right"},children:c?e.jsx(D,{size:14}):e.jsx(P,{size:14})})]}),c&&e.jsx("tr",{style:{background:"#FAFAFF",borderBottom:"2px solid #E0E7FF"},children:e.jsx("td",{colSpan:7,style:{padding:"24px 32px"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:32},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[s.hitl_reason&&e.jsxs("div",{style:{padding:"14px 16px",background:"#F5F3FF",border:"1px solid #EDE9FE",borderRadius:12},children:[e.jsx("div",{style:{fontSize:11,color:"var(--purple)",fontWeight:700,marginBottom:6},children:"⚡ Intervention Required"}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:s.hitl_reason})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--muted)",textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Description"}),e.jsx("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.7,background:"#F8FAFC",padding:"14px",borderRadius:10,border:"1px solid var(--border)"},children:s.description||"No description available."})]}),s.output&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--mint)",textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Output"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",lineHeight:1.7,background:"#F0FDF4",padding:"14px",borderRadius:10,border:"1px solid #D1FAE5",fontFamily:"var(--font-mono)"},children:s.output})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{className:"card",style:{gap:8,display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Details"}),[{k:"Type",v:s.type},{k:"Created",v:s.created_at?new Date(s.created_at).toLocaleString():"—"},{k:"Completed",v:s.completed_at?new Date(s.completed_at).toLocaleString():"—"}].filter(l=>l.v).map(l=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12},children:[e.jsx("span",{style:{color:"var(--muted)"},children:l.k}),e.jsx("span",{style:{color:"var(--text)",fontWeight:500},children:l.v})]},l.k))]}),e.jsxs("div",{className:"card",style:{gap:8,display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:"Update Status"}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["pending","in-progress","complete","failed","blocked"].filter(l=>l!==i).map(l=>{const g=v[l]||v.pending;return e.jsx("button",{onClick:async h=>{h.stopPropagation();try{await W(s.id,{status:l}),o?.("Status updated","success")}catch(y){o?.(y.message,"error")}},style:{background:g.bg,color:g.color,border:`1px solid ${g.color}44`,borderRadius:8,padding:"5px 12px",fontSize:11,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},children:g.label},l)})})]})]})]})})})]})}function M({data:s,toast:c}){const{tasks:n=[],agents:o=[]}=s||{},[i,d]=x.useState("all"),[r,p]=x.useState(0),[l,g]=x.useState(null),[h,y]=x.useState(""),[b,F]=x.useState(!1),[a,u]=x.useState({id:"",title:"",description:"",priority:"P2",assigned_to:"",type:"dev"}),[S,k]=x.useState(!1),z=async()=>{if(!(!a.id||!a.title)){k(!0);try{await A(a),c?.("Task created","success"),F(!1),u({id:"",title:"",description:"",priority:"P2",assigned_to:"",type:"dev"})}catch(t){c?.(t.message,"error")}finally{k(!1)}}},C=n.filter(t=>{if(i!=="all"&&t.status!==(i==="hitl"?"needs_human_decision":i))return!1;if(!h)return!0;const m=h.toLowerCase();return(t.id||"").toLowerCase().includes(m)||(t.title||"").toLowerCase().includes(m)}),f=Math.ceil(C.length/j),w=C.slice(r*j,(r+1)*j);return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Task Queue"}),e.jsxs("p",{style:{color:"var(--text-dim)",fontSize:14},children:[n.length," tasks across all agents"]})]}),e.jsxs("button",{className:"btn-primary",onClick:()=>F(!b),style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(E,{size:14})," New Task"]})]}),b&&e.jsxs("div",{className:"card",style:{background:"#FAFAFF",borderColor:"#E0E7FF",borderWidth:2},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--accent)",marginBottom:16},children:"Create New Task"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[e.jsx("input",{className:"input-base",placeholder:"Task ID *",value:a.id,onChange:t=>u({...a,id:t.target.value})}),e.jsx("input",{className:"input-base",placeholder:"Title *",value:a.title,onChange:t=>u({...a,title:t.target.value}),style:{gridColumn:"span 2"}}),e.jsx("textarea",{className:"input-base",placeholder:"Description",value:a.description,onChange:t=>u({...a,description:t.target.value}),style:{gridColumn:"span 3",minHeight:80,resize:"vertical"}}),e.jsxs("select",{className:"input-base",value:a.priority,onChange:t=>u({...a,priority:t.target.value}),children:[e.jsx("option",{value:"P1",children:"P1 — Critical"}),e.jsx("option",{value:"P2",children:"P2 — Normal"}),e.jsx("option",{value:"P3",children:"P3 — Low"})]}),e.jsxs("select",{className:"input-base",value:a.assigned_to,onChange:t=>u({...a,assigned_to:t.target.value}),children:[e.jsx("option",{value:"",children:"Assign to agent…"}),o.map(t=>e.jsxs("option",{value:t.id,children:[t.emoji," ",t.name||t.id]},t.id))]}),e.jsx("button",{className:"btn-primary",onClick:z,disabled:S||!a.id||!a.title,children:S?"Creating…":"Create Task"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("div",{style:{display:"flex",gap:4},children:I.map(t=>{const m=t==="all"?n.length:n.filter(T=>T.status===(t==="hitl"?"needs_human_decision":t)).length;return e.jsxs("button",{onClick:()=>{d(t),p(0)},style:{background:i===t?"var(--accent)":"#F8FAFC",color:i===t?"#fff":"var(--text-dim)",border:`1px solid ${i===t?"var(--accent)":"var(--border)"}`,borderRadius:8,padding:"6px 14px",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:[t," ",m>0&&e.jsxs("span",{style:{opacity:.75},children:["(",m,")"]})]},t)})}),e.jsx("input",{className:"input-base",placeholder:"Search tasks…",value:h,onChange:t=>{y(t.target.value),p(0)},style:{marginLeft:"auto",width:220}})]}),e.jsx("div",{style:{background:"#fff",border:"1px solid var(--border)",borderRadius:16,overflow:"hidden",boxShadow:"var(--shadow)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC",borderBottom:"1px solid var(--border)"},children:["ID","Title","Assigned To","Priority","Status","Deadline",""].map(t=>e.jsx("th",{style:{padding:"10px 16px",textAlign:"left",fontSize:10,color:"var(--muted)",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em"},children:t},t))})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:64,textAlign:"center",color:"var(--muted)",fontSize:13},children:"No tasks match your filter"})}):w.map(t=>e.jsx(R,{task:t,expanded:l===t.id,onToggle:()=>g(l===t.id?null:t.id),toast:c},t.id))})]})}),f>1&&e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"center",alignItems:"center"},children:[e.jsx("button",{className:"btn-secondary",onClick:()=>p(Math.max(0,r-1)),disabled:r===0,style:{padding:"6px 16px"},children:"← Prev"}),e.jsxs("span",{style:{fontSize:13,color:"var(--muted)"},children:["Page ",r+1," of ",f]}),e.jsx("button",{className:"btn-secondary",onClick:()=>p(Math.min(f-1,r+1)),disabled:r===f-1,style:{padding:"6px 16px"},children:"Next →"})]})]})}export{M as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Overview-Cp6HOIJF.js","assets/vendor-gUVFsxOc.js","assets/Agents-s1Pcdrga.js","assets/Tasks-DFJ-nyg0.js","assets/Projects-DGWbAWDb.js","assets/charts-CjCN_e1M.js","assets/Jobs-Ch4D8P85.js","assets/Approvals-e-y0qIwz.js","assets/Usage-Cvfmkgit.js","assets/Crons-BsUNSrso.js","assets/HITL-BX5-FQjS.js","assets/Alerts-T-KcEJKx.js","assets/Velocity-DzCZH_YB.js","assets/Budget-DRJWqsop.js","assets/OKRs-Dt0HzTQQ.js","assets/Knowledge-C92uZhl9.js","assets/Comms-DT2o5TCi.js","assets/Memory-DFU5CtTT.js","assets/Processes-btq7Pyex.js","assets/Failures-CaEvQ0t1.js","assets/Decisions-B3i1Rijg.js","assets/Security-BVLBAnlu.js","assets/Policies-CbemgLkX.js","assets/AuditLog-Cc1GUGYz.js","assets/Settings-DWsfHIfK.js"])))=>i.map(i=>d[i]);
2
+ import{r as d,a4 as t,a5 as $,a6 as U,a7 as M,a8 as B,a9 as F,aa as H,ab as K,ac as q,ad as J,ae as Y,af as G,ag as Q,ah as X,ai as Z,aj as ee,ak as te,al as re,am as ne,an as se,ao as oe,ap as ie,aq as ae,ar as ce}from"./vendor-gUVFsxOc.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();const le="modulepreload",ue=function(e){return"/"+e},C={},f=function(r,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(i){return Promise.all(i.map(c=>Promise.resolve(c).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),m=l?.nonce||l?.getAttribute("nonce");o=u(n.map(i=>{if(i=ue(i),i in C)return;C[i]=!0;const c=i.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${h}`))return;const g=document.createElement("link");if(g.rel=c?"stylesheet":le,c||(g.as="script"),g.crossOrigin="",g.href=i,m&&g.setAttribute("nonce",m),document.head.appendChild(g),c)return new Promise((y,_)=>{g.addEventListener("load",y),g.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${i}`)))})}))}function a(l){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=l,window.dispatchEvent(m),!m.defaultPrevented)throw l}return o.then(l=>{for(const m of l||[])m.status==="rejected"&&a(m.reason);return r().catch(a)})};let w=null;const O="agi_farm_write_auth_token";async function de(){const e=await fetch("/api/session");if(!e.ok)throw new Error("failed_to_fetch_session");const r=await e.json();if(!r?.csrfToken)throw new Error("missing_csrf_token");return r.csrfToken}async function T(){return w||(w=de().catch(e=>{throw w=null,e})),w}function fe(){try{return window.localStorage.getItem(O)||""}catch{return""}}function pe(e){try{if(!e){window.localStorage.removeItem(O);return}window.localStorage.setItem(O,String(e))}catch{}}function A(e={}){const r=fe();return r?{...e,"x-agi-farm-auth":r}:e}async function he(e){const r=await T(),n=await fetch(e,{method:"DELETE",headers:A({"x-agi-farm-csrf":r})});let s={};try{s=await n.json()}catch{s={}}if(!n.ok)throw new Error(s?.error||`request_failed_${n.status}`);return s}async function v(e,r=null){const s={"Content-Type":"application/json","x-agi-farm-csrf":await T()},o={method:"POST",headers:A(s)};r!==null&&(o.body=JSON.stringify(r));const a=await fetch(e,o);let l={};try{l=await a.json()}catch{l={}}if(!a.ok)throw new Error(l?.error||`request_failed_${a.status}`);return l}async function I(e){const r=await T(),n=await fetch(e,{headers:A({"x-agi-farm-csrf":r})});let s={};try{s=await n.json()}catch{s={}}if(!n.ok)throw new Error(s?.error||`request_failed_${n.status}`);return s}async function et(e){return v("/api/intake/task",e)}async function tt(e={}){const r=new URLSearchParams;Object.entries(e||{}).forEach(([s,o])=>{o==null||o===""||o==="all"||r.set(s,String(o))});const n=r.toString()?`?${r.toString()}`:"";return I(`/api/projects${n}`)}async function rt(e){return v("/api/tasks",e)}async function nt(e,r){return me(`/api/tasks/${e}`,r)}async function st(e,r={}){return v(`/api/projects/${e}/plan`,r)}async function ot(e,r={}){return v(`/api/projects/${e}/execute`,r)}async function me(e,r=null){const n=await T(),s={method:"PATCH",headers:A({"Content-Type":"application/json","x-agi-farm-csrf":n})};r!==null&&(s.body=JSON.stringify(r));const o=await fetch(e,s);let a={};try{a=await o.json()}catch{a={}}if(!o.ok)throw new Error(a?.error||`request_failed_${o.status}`);return a}async function it(){return I("/api/auth/status")}async function at(e){const r=await v("/api/auth/verify-pin",{pin:e});return r?.authToken&&pe(r.authToken),r}async function ct(e,r=""){return v("/api/auth/set-pin",{pin:e,currentPin:r||void 0})}async function lt(e){return v("/api/auth/remove-pin",{pin:e})}async function ut(e,r=""){return v("/api/auth/public-mode",{publicMode:e,pin:r||void 0})}async function dt(){return I("/api/templates")}async function ft(e){return v("/api/templates/export",e)}async function pt(e){return v("/api/templates/import",e)}async function ht(){return I("/api/secrets")}async function mt(e,r){return v(`/api/secrets/${e}`,{updates:r})}async function gt(e,r){return he(`/api/secrets/${e}/${r}`)}const ge=1e4,D=3e3,z=6e4;function xe(){const[e,r]=d.useState(window.INITIAL_DATA||null),[n,s]=d.useState(!1),[o,a]=d.useState(window.INITIAL_DATA?new Date:null),[l,m]=d.useState(0),u=d.useRef(null),i=d.useRef(!0),c=d.useRef(null),h=d.useRef(null),g=d.useRef(null),y=d.useRef(D),_=d.useCallback(x=>{!x||x.error||x.type==="keepalive"||(r(S=>({...x})),s(!0),a(new Date),m(S=>S+1))},[]),E=d.useCallback(()=>{c.current&&clearInterval(c.current),c.current=setInterval(async()=>{if(!(!i.current||!g.current))try{const x=await fetch("/api/data",{headers:{"x-agi-farm-csrf":g.current}});x.ok&&_(await x.json())}catch{}},ge)},[_]),b=d.useCallback(async()=>{if(!i.current)return;if(u.current)try{u.current.close()}catch{}if(!g.current)try{g.current=await T()}catch{h.current=setTimeout(b,y.current),y.current=Math.min(y.current*2,z);return}const x=new EventSource(`/api/stream?token=${encodeURIComponent(g.current)}`);u.current=x,x.onopen=()=>{i.current&&(s(!0),y.current=D,h.current&&(clearTimeout(h.current),h.current=null))},x.onmessage=S=>{if(i.current)try{_(JSON.parse(S.data))}catch{}},x.onerror=()=>{if(i.current){s(!1);try{x.close()}catch{}u.current=null,h.current=setTimeout(b,y.current),y.current=Math.min(y.current*2,z)}}},[_]);return d.useEffect(()=>(i.current=!0,b(),E(),()=>{if(i.current=!1,u.current)try{u.current.close()}catch{}c.current&&clearInterval(c.current),h.current&&clearTimeout(h.current)}),[b,E]),{data:e,connected:n,lastUpdated:o,updateCount:l}}function ye(){const[e,r]=d.useState(new Date);return d.useEffect(()=>{const n=setInterval(()=>r(new Date),1e3);return()=>clearInterval(n)},[]),t.jsx("span",{style:{color:"var(--text-dim)",fontSize:"12px",fontFamily:"var(--font-mono)",fontWeight:500},children:e.toLocaleTimeString([],{hour12:!0})})}function k({label:e,value:r,color:n}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"6px 14px",borderRadius:10,background:"#F8FAFC",border:"1px solid var(--border)"},children:[t.jsx("span",{style:{fontSize:10,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t.jsx("span",{style:{fontSize:14,fontWeight:700,color:n||"var(--text)",marginTop:1},children:r})]})}function ve({data:e,connected:r,lastUpdated:n,toast:s}){const o=e?.agents||[],a=e?.task_counts||{},l=e?.budget||{},u=r&&(e||{}).gateway_online!==!1,i=r&&u,c=e?.update_info,[h,g]=d.useState(()=>sessionStorage.getItem("update-dismissed")==="true"),[y,_]=d.useState(!1),E=c?.updateAvailable&&!h,b=async()=>{_(!0);try{const j=await v("/api/update-install");j.success?s?.("Update installed — please restart","success"):s?.(j.error||"Update failed","error")}catch(j){s?.(j.message,"error")}_(!1)},x=o.filter(j=>j.status!=="available").length,S=o.length,L=a.needs_human_decision??0,W=(l.current?.daily_usd??0).toFixed(2);return t.jsxs(t.Fragment,{children:[t.jsxs("header",{style:{height:60,borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",display:"flex",alignItems:"center",padding:"0 32px",gap:20,position:"sticky",top:0,zIndex:200,backdropFilter:"blur(20px)",boxShadow:"var(--shadow-sm)",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i?t.jsx($,{size:14,color:"var(--mint)"}):t.jsx(U,{size:14,color:"var(--red)"}),t.jsx("span",{style:{fontSize:11,fontWeight:600,color:i?"var(--mint)":"var(--red)"},children:i?"Connected":r?"Gateway Down":"Offline"})]}),t.jsx("div",{style:{width:1,height:24,background:"var(--border)"}}),t.jsx(k,{label:"Active Agents",value:`${x} / ${S}`,color:"var(--accent)"}),t.jsx(k,{label:"HITL Queue",value:L,color:L>0?"var(--purple)":"var(--text-dim)"}),t.jsx(k,{label:"Daily Spend",value:`$${W}`,color:"var(--mint)"}),t.jsx("div",{style:{flex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[n&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--muted)",fontSize:11},children:[t.jsx(M,{size:11}),t.jsxs("span",{children:["Updated ",n.toLocaleTimeString([],{hour12:!0})]})]}),t.jsx(ye,{})]})]}),E&&t.jsxs("div",{style:{background:"var(--accent)",color:"#fff",padding:"8px 32px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"12px",fontWeight:600},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(B,{size:14}),t.jsxs("span",{children:["Update available: v",c.currentVersion," → v",c.latestVersion]})]}),t.jsxs("div",{style:{display:"flex",gap:12},children:[t.jsx("button",{onClick:b,disabled:y,style:{background:"rgba(255,255,255,0.2)",color:"#fff",border:"1px solid rgba(255,255,255,0.3)",padding:"4px 14px",borderRadius:8,cursor:"pointer",fontSize:11,fontWeight:700},children:y?"Installing…":"Install Now"}),t.jsx("button",{onClick:()=>{g(!0),sessionStorage.setItem("update-dismissed","true")},style:{background:"none",border:"none",cursor:"pointer",color:"#fff",fontSize:16},children:"✕"})]})]})]})}const _e=[{id:"Overview",icon:F,label:"Overview"},{id:"Agents",icon:H,label:"Agents"},{id:"Tasks",icon:K,label:"Tasks"},{id:"HITL",icon:q,label:"HITL",badge:"hitl"},{id:"Alerts",icon:J,label:"Alerts",badge:"alerts"},{id:"Velocity",icon:Y,label:"Velocity"},{id:"Budget",icon:G,label:"Budget"}],be=[{id:"Projects",icon:Q,label:"Projects"},{id:"OKRs",icon:X,label:"OKRs"},{id:"Approvals",icon:Z,label:"Approvals",badge:"approvals"},{id:"Knowledge",icon:ee,label:"Knowledge"},{id:"Comms",icon:te,label:"Comms"}],Se=[{id:"Security",icon:re,label:"Security"},{id:"Crons",icon:ne,label:"Jobs & Crons",badge:"crons"},{id:"Processes",icon:se,label:"Processes"},{id:"Memory",icon:oe,label:"Memory"},{id:"Settings",icon:ie,label:"Settings"}];function P({title:e,items:r,active:n,onChange:s,badges:o={}}){return t.jsxs("div",{style:{marginBottom:24},children:[t.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"var(--muted)",letterSpacing:"0.08em",textTransform:"uppercase",padding:"0 12px",marginBottom:6},children:e}),r.map(({id:a,icon:l,label:m,badge:u})=>{const i=n===a,c=u&&o[u]||0;return t.jsxs("button",{onClick:()=>s(a),style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderRadius:10,border:"none",cursor:"pointer",background:i?"rgba(79,70,229,0.08)":"transparent",color:i?"var(--accent)":"var(--text-dim)",fontWeight:i?600:400,fontSize:13,fontFamily:"var(--font-main)",transition:"all 0.15s ease",textAlign:"left",marginBottom:2},children:[t.jsx(l,{size:15,strokeWidth:i?2.2:1.8,style:{flexShrink:0}}),t.jsx("span",{style:{flex:1},children:m}),c>0&&t.jsx("span",{style:{background:i?"var(--accent)":"#EEF2FF",color:i?"#fff":"var(--accent)",fontSize:10,fontWeight:700,borderRadius:999,padding:"1px 6px",minWidth:18,textAlign:"center"},children:c}),i&&t.jsx(ae,{size:12,style:{flexShrink:0}})]},a)})]})}function je({active:e,onChange:r,badges:n={}}){const s={hitl:n.HITL,alerts:n.Alerts,crons:n.Crons,approvals:n.Approvals};return t.jsxs("nav",{style:{width:220,background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",padding:"16px 8px",overflowY:"auto",boxShadow:"var(--shadow-sm)",flexShrink:0},children:[t.jsxs("div",{style:{padding:"4px 12px 20px",display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:22},children:"🦅"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:700,fontSize:13,color:"var(--text)",letterSpacing:"-0.01em"},children:"AGI Farm"}),t.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontWeight:400},children:"Ops Dashboard"})]})]}),t.jsx(P,{title:"Agent Intelligence",items:_e,active:e,onChange:r,badges:s}),t.jsx(P,{title:"Project Oversight",items:be,active:e,onChange:r,badges:s}),t.jsx("div",{style:{flex:1}}),t.jsx(P,{title:"System",items:Se,active:e,onChange:r,badges:s})]})}const V=d.createContext(null);let Te=0;function Ee(){return d.useContext(V)}function we({children:e}){const[r,n]=d.useState([]),s=d.useRef({}),o=d.useCallback((u,i="info")=>{const c=++Te;return n(h=>[...h,{id:c,message:u,type:i}]),s.current[c]=setTimeout(()=>{n(h=>h.filter(g=>g.id!==c)),delete s.current[c]},4e3),c},[]),a=d.useCallback(u=>{n(i=>i.filter(c=>c.id!==u)),s.current[u]&&(clearTimeout(s.current[u]),delete s.current[u])},[]),l={success:"var(--green)",error:"var(--red)",info:"var(--cyan)"},m={success:"✅",error:"❌",info:"ℹ️"};return t.jsxs(V.Provider,{value:o,children:[e,t.jsx("div",{style:{position:"fixed",bottom:20,right:20,zIndex:99999,display:"flex",flexDirection:"column-reverse",gap:8,maxWidth:360},children:r.map(u=>t.jsxs("div",{className:"toast-enter",style:{background:"var(--bg2)",border:`1px solid ${l[u.type]||l.info}`,borderRadius:6,padding:"10px 14px",fontSize:12,color:"var(--text)",display:"flex",alignItems:"center",gap:8,boxShadow:`0 4px 20px rgba(0,0,0,.5), 0 0 8px ${l[u.type]}33`},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:m[u.type]}),t.jsx("span",{style:{flex:1,lineHeight:1.4},children:u.message}),t.jsx("button",{onClick:()=>a(u.id),style:{background:"none",border:"none",color:"var(--muted)",cursor:"pointer",fontSize:14,padding:0,lineHeight:1},children:"×"})]},u.id))})]})}const R="agi-farm-lazy-retry";function p(e){return d.lazy(async()=>{try{const r=await e();return sessionStorage.removeItem(R),r}catch(r){throw sessionStorage.getItem(R)==="1"||(sessionStorage.setItem(R,"1"),window.location.reload()),r}})}const N=p(()=>f(()=>import("./Overview-Cp6HOIJF.js"),__vite__mapDeps([0,1]))),Ae=p(()=>f(()=>import("./Agents-s1Pcdrga.js"),__vite__mapDeps([2,1]))),Ie=p(()=>f(()=>import("./Tasks-DFJ-nyg0.js"),__vite__mapDeps([3,1]))),ke=p(()=>f(()=>import("./Projects-DGWbAWDb.js"),__vite__mapDeps([4,1,5]))),Pe=p(()=>f(()=>import("./Jobs-Ch4D8P85.js"),__vite__mapDeps([6,1]))),Re=p(()=>f(()=>import("./Approvals-e-y0qIwz.js"),__vite__mapDeps([7,1]))),Oe=p(()=>f(()=>import("./Usage-Cvfmkgit.js"),__vite__mapDeps([8,1,5]))),Le=p(()=>f(()=>import("./Crons-BsUNSrso.js"),__vite__mapDeps([9,1]))),Ce=p(()=>f(()=>import("./HITL-BX5-FQjS.js"),__vite__mapDeps([10,1]))),De=p(()=>f(()=>import("./Alerts-T-KcEJKx.js"),__vite__mapDeps([11,1]))),ze=p(()=>f(()=>import("./Velocity-DzCZH_YB.js"),__vite__mapDeps([12,1,5]))),Ve=p(()=>f(()=>import("./Budget-DRJWqsop.js"),__vite__mapDeps([13,1,5]))),Ne=p(()=>f(()=>import("./OKRs-Dt0HzTQQ.js"),__vite__mapDeps([14,1]))),We=p(()=>f(()=>import("./Knowledge-C92uZhl9.js"),__vite__mapDeps([15,1]))),$e=p(()=>f(()=>import("./Comms-DT2o5TCi.js"),__vite__mapDeps([16,1]))),Ue=p(()=>f(()=>import("./Memory-DFU5CtTT.js"),__vite__mapDeps([17,1]))),Me=p(()=>f(()=>import("./Processes-btq7Pyex.js"),__vite__mapDeps([18,1]))),Be=p(()=>f(()=>import("./Failures-CaEvQ0t1.js"),__vite__mapDeps([19,1]))),Fe=p(()=>f(()=>import("./Decisions-B3i1Rijg.js"),__vite__mapDeps([20,1]))),He=p(()=>f(()=>import("./Security-BVLBAnlu.js"),__vite__mapDeps([21,1]))),Ke=p(()=>f(()=>import("./Policies-CbemgLkX.js"),__vite__mapDeps([22,1]))),qe=p(()=>f(()=>import("./AuditLog-Cc1GUGYz.js"),__vite__mapDeps([23,1]))),Je=p(()=>f(()=>import("./Settings-DWsfHIfK.js"),__vite__mapDeps([24,1]))),Ye={Overview:N,Agents:Ae,Tasks:Ie,HITL:Ce,Alerts:De,Velocity:ze,Budget:Ve,Projects:ke,OKRs:Ne,Approvals:Re,Knowledge:We,Comms:$e,Security:He,Crons:Le,Processes:Me,Memory:Ue,Failures:Be,Decisions:Fe,Jobs:Pe,Usage:Oe,Policies:Ke,Settings:Je,Audit:qe};function Ge(){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:16,color:"var(--text-dim)"},children:[t.jsx("span",{style:{fontSize:48,filter:"grayscale(0.4)"},children:"🦅"}),t.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text)"},children:"Connecting to Ops Room…"}),t.jsx("div",{style:{fontSize:13,color:"var(--muted)"},children:"Waiting for SSE stream from dashboard server"})]})}function Qe(){return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"200px"},children:t.jsx("div",{style:{fontSize:13,color:"var(--muted)"},children:"Loading…"})})}function Xe(){const[e,r]=d.useState("Overview"),{data:n,connected:s,lastUpdated:o,updateCount:a}=xe(),l=Ee(),m={data:n,lastUpdated:o,toast:l},u=n?{HITL:(n.hitl_tasks||[]).length,Alerts:(n.alerts||[]).length,Crons:(n.crons||[]).filter(c=>(c._consecutive_errors||0)>=3).length,Approvals:(n.approvals||[]).filter(c=>c.status==="pending").length}:{},i=d.useMemo(()=>Ye[e]||N,[e]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden"},children:[t.jsx(ve,{data:n,connected:s,lastUpdated:o,updateCount:a,toast:l}),t.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[t.jsx(je,{active:e,onChange:r,badges:u}),t.jsx("main",{style:{flex:1,overflowY:"auto",padding:"40px 48px",background:"var(--bg)"},children:n?t.jsx("div",{className:"fade-in",children:t.jsx(d.Suspense,{fallback:t.jsx(Qe,{}),children:t.jsx(i,{...m})})}):t.jsx(Ge,{})})]})]})}ce.createRoot(document.getElementById("root")).render(t.jsx(d.StrictMode,{children:t.jsx(we,{children:t.jsx(Xe,{})})}));export{v as a,dt as b,rt as c,ht as d,ot as e,ct as f,it as g,ut as h,ft as i,pt as j,mt as k,tt as l,gt as m,st as p,lt as r,et as s,nt as u,at as v};
@@ -6,7 +6,7 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self'; img-src 'self' data:;" />
8
8
  <title>AGI Farm — Ops Room</title>
9
- <script type="module" crossorigin src="/assets/index-B3IWXYRY.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-DUjHkafG.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/vendor-gUVFsxOc.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-Cti3NWck.css">
12
12
  </head>
@@ -2,7 +2,7 @@
2
2
  "id": "agi-farm",
3
3
  "kind": "team-orchestration",
4
4
  "name": "AGI Farm — Multi-Agent Team Builder",
5
- "version": "1.9.0",
5
+ "version": "1.10.0",
6
6
  "description": "Bootstrap complete multi-agent AI teams with auto-dispatcher, live dashboard, and infrastructure. Includes interactive wizard, SOUL.md generation, comms setup, cron registration, and React + SSE ops room.",
7
7
  "author": "oabdelmaksoud",
8
8
  "homepage": "https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agi-farm",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Multi-agent AI team builder for OpenClaw — bootstrap complete teams with auto-dispatcher, dashboard, and infrastructure",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -111,6 +111,8 @@ setInterval(rotateCsrfToken, CSRF_ROTATE_MS);
111
111
  const CRON_FILE = path.join(os.homedir(), '.openclaw', 'cron', 'jobs.json');
112
112
  const SETTINGS_FILE = path.join(WORKSPACE, 'SETTINGS.json');
113
113
  const CHANNEL_ADAPTER_STATE_FILE = path.join(WORKSPACE, 'CHANNEL_ADAPTER_STATE.json');
114
+ const SECRETS_FILE = path.join(WORKSPACE, 'SECRETS.json');
115
+ const DASHBOARD_TEMPLATES_DIR = path.join(WORKSPACE, 'dashboard-templates');
114
116
 
115
117
  class SlowDataCache {
116
118
  constructor() {
@@ -258,7 +260,12 @@ function ensureOperationalFiles() {
258
260
  budget_monthly: null,
259
261
  hitl_enabled: true,
260
262
  auto_resume: false,
263
+ auth: {
264
+ public_mode: false,
265
+ pin_hash: null,
266
+ },
261
267
  })) created.push('SETTINGS.json');
268
+ if (writeJsonIfMissing(SECRETS_FILE, {})) created.push('SECRETS.json');
262
269
  if (writeJsonIfMissing(CHANNEL_ADAPTER_STATE_FILE, { version: 1, seeded: false, files: {} })) created.push('CHANNEL_ADAPTER_STATE.json');
263
270
 
264
271
  if (created.length > 0) {
@@ -284,6 +291,54 @@ function sanitizeSettingsPatch(body) {
284
291
  return out;
285
292
  }
286
293
 
294
+ function readSettings() {
295
+ const raw = asObject(readJson(SETTINGS_FILE));
296
+ const auth = asObject(raw.auth);
297
+ return {
298
+ budget_daily: raw.budget_daily ?? null,
299
+ budget_weekly: raw.budget_weekly ?? null,
300
+ budget_monthly: raw.budget_monthly ?? null,
301
+ hitl_enabled: raw.hitl_enabled !== false,
302
+ auto_resume: raw.auto_resume === true,
303
+ auth: {
304
+ public_mode: auth.public_mode === true,
305
+ pin_hash: typeof auth.pin_hash === 'string' && auth.pin_hash ? auth.pin_hash : null,
306
+ },
307
+ };
308
+ }
309
+
310
+ function updateSettings(mutator) {
311
+ return withFileLockSync(SETTINGS_FILE, () => {
312
+ const current = readSettings();
313
+ const next = mutator(current);
314
+ safeWriteJson(SETTINGS_FILE, next);
315
+ return next;
316
+ });
317
+ }
318
+
319
+ function publicSettingsView(settings) {
320
+ const s = settings || readSettings();
321
+ return {
322
+ budget_daily: s.budget_daily ?? null,
323
+ budget_weekly: s.budget_weekly ?? null,
324
+ budget_monthly: s.budget_monthly ?? null,
325
+ hitl_enabled: s.hitl_enabled !== false,
326
+ auto_resume: s.auto_resume === true,
327
+ auth: {
328
+ public_mode: s.auth?.public_mode === true,
329
+ has_pin: !!s.auth?.pin_hash,
330
+ },
331
+ };
332
+ }
333
+
334
+ function hashPin(pin) {
335
+ return crypto.createHash('sha256').update(String(pin)).digest('hex');
336
+ }
337
+
338
+ function isValidPinFormat(pin) {
339
+ return typeof pin === 'string' && /^\d{4,8}$/.test(pin);
340
+ }
341
+
287
342
  function getHeartbeatAge(workspace, wsDir = '') {
288
343
  const paths = [];
289
344
  if (wsDir) paths.push(path.join(workspace, 'agents-workspaces', wsDir, 'HEARTBEAT.md'));
@@ -720,6 +775,14 @@ const ALLOWED_ORIGINS = new Set([
720
775
  `http://localhost:${PORT}`,
721
776
  `http://[::1]:${PORT}`,
722
777
  ]);
778
+ const WRITE_AUTH_TTL_MS = 12 * 60 * 60 * 1000;
779
+ const _writeAuthTokens = new Map();
780
+ setInterval(() => {
781
+ const now = Date.now();
782
+ for (const [token, expiresAt] of _writeAuthTokens.entries()) {
783
+ if (expiresAt <= now) _writeAuthTokens.delete(token);
784
+ }
785
+ }, 60_000);
723
786
 
724
787
  function requireCsrf(req, res, next) {
725
788
  const origin = req.header('origin');
@@ -736,6 +799,52 @@ function requireCsrf(req, res, next) {
736
799
  next();
737
800
  }
738
801
 
802
+ function issueWriteAuthToken() {
803
+ const token = crypto.randomBytes(24).toString('hex');
804
+ _writeAuthTokens.set(token, Date.now() + WRITE_AUTH_TTL_MS);
805
+ return token;
806
+ }
807
+
808
+ function isValidWriteAuthToken(token) {
809
+ if (!token) return false;
810
+ const expiresAt = _writeAuthTokens.get(token);
811
+ if (!expiresAt) return false;
812
+ if (Date.now() > expiresAt) {
813
+ _writeAuthTokens.delete(token);
814
+ return false;
815
+ }
816
+ return true;
817
+ }
818
+
819
+ function requireWriteAccess(req, res, next) {
820
+ const method = String(req.method || 'GET').toUpperCase();
821
+ if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS') {
822
+ next();
823
+ return;
824
+ }
825
+ if (req.path.startsWith('/auth/')) {
826
+ next();
827
+ return;
828
+ }
829
+
830
+ const settings = readSettings();
831
+ if (settings.auth.public_mode === true) {
832
+ res.status(403).json({ error: 'public_mode_read_only' });
833
+ return;
834
+ }
835
+ if (!settings.auth.pin_hash) {
836
+ next();
837
+ return;
838
+ }
839
+
840
+ const authToken = req.header('x-agi-farm-auth');
841
+ if (!isValidWriteAuthToken(authToken)) {
842
+ res.status(401).json({ error: 'pin_required' });
843
+ return;
844
+ }
845
+ next();
846
+ }
847
+
739
848
  function runOpenclaw(args, timeoutMs = 15000) {
740
849
  return new Promise((resolve) => {
741
850
  let stdout = '';
@@ -818,7 +927,7 @@ function buildWorkspaceSnapshot(cache, services) {
818
927
  const alerts = asArray(readJson(path.join(WORKSPACE, 'ALERTS.json')));
819
928
  const projectsStore = readProjectsStore();
820
929
  const projectsRaw = asArray(projectsStore.projects);
821
- const settings = asObject(readJson(SETTINGS_FILE));
930
+ const settings = readSettings();
822
931
  const teamInfo = asObject(readJson(path.join(WORKSPACE, 'agi-farm-bundle', 'team.json')));
823
932
  const flags = getFeatureFlags();
824
933
 
@@ -965,7 +1074,7 @@ function buildWorkspaceSnapshot(cache, services) {
965
1074
  projects,
966
1075
  project_defaults: projectsStore.defaults,
967
1076
  project_events: projectEvents,
968
- settings,
1077
+ settings: publicSettingsView(settings),
969
1078
  comms,
970
1079
  jobs,
971
1080
  approvals,
@@ -1056,6 +1165,15 @@ function sanitizeText(text, maxLen = 2000) {
1056
1165
  return text.slice(0, maxLen).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '');
1057
1166
  }
1058
1167
 
1168
+ function readSecrets() {
1169
+ return asObject(readJson(SECRETS_FILE));
1170
+ }
1171
+
1172
+ function sanitizeTemplateId(value) {
1173
+ const id = sanitizeText(String(value || '').toLowerCase(), 64).replace(/[^a-z0-9_-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
1174
+ return id || `template-${Date.now()}`;
1175
+ }
1176
+
1059
1177
  function requireFeature(name) {
1060
1178
  return (req, res, next) => {
1061
1179
  const flags = getFeatureFlags();
@@ -1106,6 +1224,7 @@ async function main() {
1106
1224
  const actionLimiter = createRateLimiter(60000, 30);
1107
1225
  const sessionLimiter = createRateLimiter(60000, 20); // stricter limit for token endpoint
1108
1226
  app.use('/api', apiLimiter);
1227
+ app.use('/api', requireWriteAccess);
1109
1228
 
1110
1229
  const cache = new SlowDataCache();
1111
1230
  const broadcaster = new Broadcaster();
@@ -1178,6 +1297,108 @@ async function main() {
1178
1297
  res.json({ csrfToken: getCsrfToken() });
1179
1298
  });
1180
1299
 
1300
+ app.get('/api/auth/status', requireCsrf, (req, res) => {
1301
+ const settings = readSettings();
1302
+ res.json({
1303
+ hasPin: !!settings.auth.pin_hash,
1304
+ publicMode: settings.auth.public_mode === true,
1305
+ writeUnlocked: isValidWriteAuthToken(req.header('x-agi-farm-auth')),
1306
+ });
1307
+ });
1308
+
1309
+ app.post('/api/auth/verify-pin', actionLimiter, requireCsrf, (req, res) => {
1310
+ const pin = sanitizeText(req.body?.pin, 16);
1311
+ const settings = readSettings();
1312
+ if (!settings.auth.pin_hash) {
1313
+ res.json({ valid: true, authToken: issueWriteAuthToken() });
1314
+ return;
1315
+ }
1316
+ const valid = isValidPinFormat(pin) && constantTimeEquals(hashPin(pin), settings.auth.pin_hash);
1317
+ if (!valid) {
1318
+ res.status(401).json({ valid: false, error: 'invalid_pin' });
1319
+ return;
1320
+ }
1321
+ res.json({ valid: true, authToken: issueWriteAuthToken() });
1322
+ });
1323
+
1324
+ app.post('/api/auth/set-pin', actionLimiter, requireCsrf, (req, res) => {
1325
+ const pin = sanitizeText(req.body?.pin, 16);
1326
+ const currentPin = sanitizeText(req.body?.currentPin, 16);
1327
+ if (!isValidPinFormat(pin)) {
1328
+ res.status(400).json({ error: 'invalid_pin_format' });
1329
+ return;
1330
+ }
1331
+ try {
1332
+ const next = updateSettings((current) => {
1333
+ if (current.auth.pin_hash) {
1334
+ if (!isValidPinFormat(currentPin) || !constantTimeEquals(hashPin(currentPin), current.auth.pin_hash)) {
1335
+ throw new Error('invalid_current_pin');
1336
+ }
1337
+ }
1338
+ return {
1339
+ ...current,
1340
+ auth: {
1341
+ ...current.auth,
1342
+ pin_hash: hashPin(pin),
1343
+ },
1344
+ };
1345
+ });
1346
+ services.audit.log('auth_pin_set', {});
1347
+ broadcaster.broadcast(buildWorkspaceSnapshot(cache, services));
1348
+ res.json({ ok: true, settings: publicSettingsView(next) });
1349
+ } catch (err) {
1350
+ res.status(err.message === 'invalid_current_pin' ? 401 : 500).json({ error: err.message || 'pin_set_failed' });
1351
+ }
1352
+ });
1353
+
1354
+ app.post('/api/auth/remove-pin', actionLimiter, requireCsrf, (req, res) => {
1355
+ const pin = sanitizeText(req.body?.pin, 16);
1356
+ try {
1357
+ const next = updateSettings((current) => {
1358
+ if (!current.auth.pin_hash) return current;
1359
+ if (!isValidPinFormat(pin) || !constantTimeEquals(hashPin(pin), current.auth.pin_hash)) {
1360
+ throw new Error('invalid_pin');
1361
+ }
1362
+ return {
1363
+ ...current,
1364
+ auth: {
1365
+ ...current.auth,
1366
+ pin_hash: null,
1367
+ },
1368
+ };
1369
+ });
1370
+ services.audit.log('auth_pin_removed', {});
1371
+ broadcaster.broadcast(buildWorkspaceSnapshot(cache, services));
1372
+ res.json({ ok: true, settings: publicSettingsView(next) });
1373
+ } catch (err) {
1374
+ res.status(err.message === 'invalid_pin' ? 401 : 500).json({ error: err.message || 'pin_remove_failed' });
1375
+ }
1376
+ });
1377
+
1378
+ app.post('/api/auth/public-mode', actionLimiter, requireCsrf, (req, res) => {
1379
+ const publicMode = req.body?.publicMode === true;
1380
+ const pin = sanitizeText(req.body?.pin, 16);
1381
+ try {
1382
+ const next = updateSettings((current) => {
1383
+ if (current.auth.pin_hash && (!isValidPinFormat(pin) || !constantTimeEquals(hashPin(pin), current.auth.pin_hash))) {
1384
+ throw new Error('invalid_pin');
1385
+ }
1386
+ return {
1387
+ ...current,
1388
+ auth: {
1389
+ ...current.auth,
1390
+ public_mode: publicMode,
1391
+ },
1392
+ };
1393
+ });
1394
+ services.audit.log('auth_public_mode_updated', { publicMode });
1395
+ broadcaster.broadcast(buildWorkspaceSnapshot(cache, services));
1396
+ res.json({ ok: true, settings: publicSettingsView(next) });
1397
+ } catch (err) {
1398
+ res.status(err.message === 'invalid_pin' ? 401 : 500).json({ error: err.message || 'public_mode_update_failed' });
1399
+ }
1400
+ });
1401
+
1181
1402
  const reactDist = path.join(__dirname, '..', 'dashboard-react', 'dist');
1182
1403
  const fallbackDist = path.join(__dirname, '..', 'dashboard-dist');
1183
1404
  const staticOptions = {
@@ -1836,18 +2057,222 @@ async function main() {
1836
2057
 
1837
2058
  app.post('/api/settings', actionLimiter, requireCsrf, createPolicyGate(services, () => 'settings:update'), (req, res) => {
1838
2059
  try {
1839
- const next = sanitizeSettingsPatch(req.body);
1840
- withFileLockSync(SETTINGS_FILE, () => {
1841
- safeWriteJson(SETTINGS_FILE, next);
2060
+ const patch = sanitizeSettingsPatch(req.body);
2061
+ const next = updateSettings((current) => {
2062
+ return {
2063
+ ...current,
2064
+ ...patch,
2065
+ auth: {
2066
+ ...current.auth,
2067
+ },
2068
+ };
1842
2069
  });
1843
2070
  services.audit.log('settings_updated', { keys: Object.keys(next) });
1844
2071
  broadcaster.broadcast(buildWorkspaceSnapshot(cache, services));
1845
- res.json({ ok: true, settings: next });
2072
+ res.json({ ok: true, settings: publicSettingsView(next) });
1846
2073
  } catch (err) {
1847
2074
  res.status(500).json({ error: 'settings_update_failed', message: err.message });
1848
2075
  }
1849
2076
  });
1850
2077
 
2078
+ app.get('/api/secrets', requireCsrf, (req, res) => {
2079
+ const secrets = readSecrets();
2080
+ const scopes = Object.keys(secrets).map((scope) => {
2081
+ const keys = Object.keys(asObject(secrets[scope]));
2082
+ return { scope, keys, count: keys.length };
2083
+ });
2084
+ res.json({ scopes });
2085
+ });
2086
+
2087
+ app.get('/api/secrets/:scope', requireCsrf, (req, res) => {
2088
+ const scope = req.params.scope;
2089
+ if (!ID_PATTERN.test(scope)) {
2090
+ res.status(400).json({ error: 'invalid_scope' });
2091
+ return;
2092
+ }
2093
+ const secrets = readSecrets();
2094
+ const scoped = asObject(secrets[scope]);
2095
+ const masked = {};
2096
+ Object.keys(scoped).forEach((key) => {
2097
+ masked[key] = '__SECRET__';
2098
+ });
2099
+ res.json({ scope, secrets: masked, count: Object.keys(masked).length });
2100
+ });
2101
+
2102
+ app.post('/api/secrets/:scope', actionLimiter, requireCsrf, (req, res) => {
2103
+ const scope = req.params.scope;
2104
+ if (!ID_PATTERN.test(scope)) {
2105
+ res.status(400).json({ error: 'invalid_scope' });
2106
+ return;
2107
+ }
2108
+ const updates = asObject(req.body?.updates);
2109
+ const entries = Object.entries(updates).slice(0, 50);
2110
+ if (entries.length === 0) {
2111
+ res.status(400).json({ error: 'updates_required' });
2112
+ return;
2113
+ }
2114
+ const clean = {};
2115
+ for (const [key, value] of entries) {
2116
+ if (!ID_PATTERN.test(key)) continue;
2117
+ const val = sanitizeText(String(value ?? ''), 5000).trim();
2118
+ if (!val) continue;
2119
+ clean[key] = val;
2120
+ }
2121
+ if (Object.keys(clean).length === 0) {
2122
+ res.status(400).json({ error: 'no_valid_secret_keys' });
2123
+ return;
2124
+ }
2125
+ withFileLockSync(SECRETS_FILE, () => {
2126
+ const existing = readSecrets();
2127
+ existing[scope] = {
2128
+ ...asObject(existing[scope]),
2129
+ ...clean,
2130
+ };
2131
+ safeWriteJson(SECRETS_FILE, existing);
2132
+ });
2133
+ services.audit.log('secrets_updated', { scope, keys: Object.keys(clean) });
2134
+ res.json({ ok: true, scope, keys: Object.keys(clean) });
2135
+ });
2136
+
2137
+ app.delete('/api/secrets/:scope/:key', actionLimiter, requireCsrf, (req, res) => {
2138
+ const scope = req.params.scope;
2139
+ const key = req.params.key;
2140
+ if (!ID_PATTERN.test(scope) || !ID_PATTERN.test(key)) {
2141
+ res.status(400).json({ error: 'invalid_secret_path' });
2142
+ return;
2143
+ }
2144
+ withFileLockSync(SECRETS_FILE, () => {
2145
+ const existing = readSecrets();
2146
+ if (!existing[scope]) return;
2147
+ delete existing[scope][key];
2148
+ if (Object.keys(asObject(existing[scope])).length === 0) {
2149
+ delete existing[scope];
2150
+ }
2151
+ safeWriteJson(SECRETS_FILE, existing);
2152
+ });
2153
+ services.audit.log('secret_deleted', { scope, key });
2154
+ res.json({ ok: true });
2155
+ });
2156
+
2157
+ app.get('/api/templates', requireCsrf, (req, res) => {
2158
+ try {
2159
+ fs.mkdirSync(DASHBOARD_TEMPLATES_DIR, { recursive: true });
2160
+ const dirs = fs.readdirSync(DASHBOARD_TEMPLATES_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
2161
+ const templates = dirs.map((d) => {
2162
+ const id = d.name;
2163
+ const metaPath = path.join(DASHBOARD_TEMPLATES_DIR, id, 'meta.json');
2164
+ const meta = asObject(readJson(metaPath));
2165
+ return {
2166
+ id,
2167
+ name: asString(meta.name || id),
2168
+ description: asString(meta.description || ''),
2169
+ tags: asArray(meta.tags).map((t) => sanitizeText(String(t), 32)).slice(0, 20),
2170
+ createdAt: asString(meta.createdAt || ''),
2171
+ updatedAt: asString(meta.updatedAt || ''),
2172
+ };
2173
+ });
2174
+ templates.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
2175
+ res.json({ templates });
2176
+ } catch (err) {
2177
+ res.status(500).json({ error: 'templates_list_failed', message: err.message });
2178
+ }
2179
+ });
2180
+
2181
+ app.get('/api/templates/:id', requireCsrf, validateId, (req, res) => {
2182
+ const id = req.params.id;
2183
+ try {
2184
+ const base = path.join(DASHBOARD_TEMPLATES_DIR, id);
2185
+ const meta = asObject(readJson(path.join(base, 'meta.json')));
2186
+ const config = asObject(readJson(path.join(base, 'config.json')));
2187
+ if (!Object.keys(meta).length && !Object.keys(config).length) {
2188
+ res.status(404).json({ error: 'template_not_found' });
2189
+ return;
2190
+ }
2191
+ res.json({ id, meta, config });
2192
+ } catch (err) {
2193
+ res.status(500).json({ error: 'template_read_failed', message: err.message });
2194
+ }
2195
+ });
2196
+
2197
+ app.post('/api/templates/export', actionLimiter, requireCsrf, (req, res) => {
2198
+ try {
2199
+ fs.mkdirSync(DASHBOARD_TEMPLATES_DIR, { recursive: true });
2200
+ const title = sanitizeText(req.body?.name || 'Dashboard Template', 120).trim() || 'Dashboard Template';
2201
+ const id = sanitizeTemplateId(req.body?.id || title);
2202
+ const description = sanitizeText(req.body?.description || '', 500);
2203
+ const tags = asArray(req.body?.tags).map((t) => sanitizeText(String(t), 32)).filter(Boolean).slice(0, 20);
2204
+ const base = path.join(DASHBOARD_TEMPLATES_DIR, id);
2205
+ fs.mkdirSync(base, { recursive: true });
2206
+ const settings = publicSettingsView(readSettings());
2207
+ const exportConfig = {
2208
+ settings: {
2209
+ budget_daily: settings.budget_daily,
2210
+ budget_weekly: settings.budget_weekly,
2211
+ budget_monthly: settings.budget_monthly,
2212
+ hitl_enabled: settings.hitl_enabled,
2213
+ auto_resume: settings.auto_resume,
2214
+ auth: {
2215
+ public_mode: settings.auth.public_mode,
2216
+ },
2217
+ },
2218
+ };
2219
+ const now = new Date().toISOString();
2220
+ const meta = {
2221
+ id,
2222
+ name: title,
2223
+ description,
2224
+ tags,
2225
+ createdAt: asString(asObject(readJson(path.join(base, 'meta.json'))).createdAt || now),
2226
+ updatedAt: now,
2227
+ };
2228
+ safeWriteJson(path.join(base, 'meta.json'), meta);
2229
+ safeWriteJson(path.join(base, 'config.json'), exportConfig);
2230
+ services.audit.log('template_exported', { id });
2231
+ res.json({ ok: true, id, meta });
2232
+ } catch (err) {
2233
+ res.status(500).json({ error: 'template_export_failed', message: err.message });
2234
+ }
2235
+ });
2236
+
2237
+ app.post('/api/templates/import', actionLimiter, requireCsrf, (req, res) => {
2238
+ const id = sanitizeText(req.body?.id, 128);
2239
+ const mode = req.body?.mode === 'merge' ? 'merge' : 'replace';
2240
+ if (!ID_PATTERN.test(id)) {
2241
+ res.status(400).json({ error: 'invalid_template_id' });
2242
+ return;
2243
+ }
2244
+ try {
2245
+ const configPath = path.join(DASHBOARD_TEMPLATES_DIR, id, 'config.json');
2246
+ const config = asObject(readJson(configPath));
2247
+ const incoming = asObject(config.settings);
2248
+ if (Object.keys(incoming).length === 0) {
2249
+ res.status(400).json({ error: 'template_missing_settings' });
2250
+ return;
2251
+ }
2252
+ const current = readSettings();
2253
+ const merged = sanitizeSettingsPatch({
2254
+ budget_daily: mode === 'merge' ? (current.budget_daily ?? incoming.budget_daily) : incoming.budget_daily,
2255
+ budget_weekly: mode === 'merge' ? (current.budget_weekly ?? incoming.budget_weekly) : incoming.budget_weekly,
2256
+ budget_monthly: mode === 'merge' ? (current.budget_monthly ?? incoming.budget_monthly) : incoming.budget_monthly,
2257
+ hitl_enabled: incoming.hitl_enabled,
2258
+ auto_resume: incoming.auto_resume,
2259
+ });
2260
+ const next = updateSettings((state) => ({
2261
+ ...state,
2262
+ ...merged,
2263
+ auth: {
2264
+ ...state.auth,
2265
+ public_mode: asObject(incoming.auth).public_mode === true,
2266
+ },
2267
+ }));
2268
+ services.audit.log('template_imported', { id, mode });
2269
+ broadcaster.broadcast(buildWorkspaceSnapshot(cache, services));
2270
+ res.json({ ok: true, id, mode, settings: publicSettingsView(next) });
2271
+ } catch (err) {
2272
+ res.status(500).json({ error: 'template_import_failed', message: err.message });
2273
+ }
2274
+ });
2275
+
1851
2276
  // ── Broadcast Endpoint ─────────────────────────────────────────────────
1852
2277
  app.post('/api/broadcast', actionLimiter, requireCsrf, (req, res) => {
1853
2278
  const message = sanitizeText(req.body?.message, 2000);
@@ -1 +0,0 @@
1
- import{r as d,a4 as e,a7 as p,aQ as b}from"./vendor-gUVFsxOc.js";import{a as y}from"./index-B3IWXYRY.js";function j({data:r,toast:u}){const o=r?.workspace_meta||{},s=r?.settings||{},[i,l]=d.useState({budget_daily:s.budget_daily??"",budget_weekly:s.budget_weekly??"",budget_monthly:s.budget_monthly??"",hitl_enabled:s.hitl_enabled!==!1,auto_resume:s.auto_resume===!0}),[g,c]=d.useState(!1);d.useEffect(()=>{l({budget_daily:s.budget_daily??"",budget_weekly:s.budget_weekly??"",budget_monthly:s.budget_monthly??"",hitl_enabled:s.hitl_enabled!==!1,auto_resume:s.auto_resume===!0})},[s.budget_daily,s.budget_weekly,s.budget_monthly,s.hitl_enabled,s.auto_resume]);const h=async()=>{c(!0);try{await y("/api/settings",i),u?.("Settings saved","success")}catch(t){u?.(t.message,"error")}c(!1)};function n({label:t,sub:a,children:x}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 0",borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text)"},children:t}),a&&e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:2},children:a})]}),e.jsx("div",{style:{flexShrink:0},children:x})]})}function m({value:t,onChange:a}){return e.jsx("button",{onClick:()=>a(!t),style:{width:44,height:24,borderRadius:999,border:"none",cursor:"pointer",background:t?"var(--accent)":"#D1D5DB",position:"relative",transition:"background 0.2s",padding:0},children:e.jsx("span",{style:{position:"absolute",top:3,left:t?22:3,width:18,height:18,borderRadius:"50%",background:"#fff",transition:"left 0.2s",display:"block",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})}return e.jsxs("div",{className:"fade-in",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{marginBottom:4},children:"Settings"}),e.jsx("p",{style:{color:"var(--text-dim)",fontSize:14},children:"Configure your AGI Farm workspace settings"})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:12},children:"Workspace Info"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,fontSize:13,color:"var(--text-dim)"},children:[{k:"Workspace Path",v:o.path||r?.workspace||"—"},{k:"Team Name",v:o.team_name||"—"},{k:"Version",v:o.version||r?.version||"—"},{k:"Process ID",v:o.pid||"—"}].map(t=>e.jsxs("div",{style:{padding:"12px",background:"#F8FAFC",borderRadius:10,border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--muted)",textTransform:"uppercase",marginBottom:4},children:t.k}),e.jsx("div",{style:{fontWeight:600,color:"var(--text)",wordBreak:"break-all"},children:t.v})]},t.k))})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Budget Limits"}),e.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:16},children:"Spending limits in USD. Leave blank for no limit."}),e.jsx(n,{label:"Daily Limit",sub:"Maximum spend in 24h",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 1.00",value:i.budget_daily,onChange:t=>l(a=>({...a,budget_daily:t.target.value}))})}),e.jsx(n,{label:"Weekly Limit",sub:"Maximum spend in 7 days",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 5.00",value:i.budget_weekly,onChange:t=>l(a=>({...a,budget_weekly:t.target.value}))})}),e.jsx(n,{label:"Monthly Limit",sub:"Maximum spend in 30 days",children:e.jsx("input",{className:"input-base",style:{width:120,textAlign:"right"},placeholder:"e.g. 20.00",value:i.budget_monthly,onChange:t=>l(a=>({...a,budget_monthly:t.target.value}))})})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{style:{fontSize:15,marginBottom:4},children:"Behavior"}),e.jsx(n,{label:"HITL Gate",sub:"Pause agents at human approval gates",children:e.jsx(m,{value:i.hitl_enabled,onChange:t=>l(a=>({...a,hitl_enabled:t}))})}),e.jsx(n,{label:"Auto Resume",sub:"Automatically resume tasks after approval",children:e.jsx(m,{value:i.auto_resume,onChange:t=>l(a=>({...a,auto_resume:t}))})})]}),e.jsx("button",{onClick:h,disabled:g,className:"btn-primary",style:{alignSelf:"flex-start",display:"flex",alignItems:"center",gap:8,padding:"10px 28px"},children:g?e.jsxs(e.Fragment,{children:[e.jsx(p,{size:14,className:"spin"})," Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{size:14})," Save Settings"]})})]})}export{j as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Overview-Cp6HOIJF.js","assets/vendor-gUVFsxOc.js","assets/Agents-hD22o0iq.js","assets/Tasks-lXCgffoh.js","assets/Projects-DGmgA8FX.js","assets/charts-CjCN_e1M.js","assets/Jobs-Ch4D8P85.js","assets/Approvals-BHXY6xD5.js","assets/Usage-Cvfmkgit.js","assets/Crons-EoAAeNe7.js","assets/HITL-F6AxJIK6.js","assets/Alerts-T-KcEJKx.js","assets/Velocity-DzCZH_YB.js","assets/Budget-DRJWqsop.js","assets/OKRs-Dt0HzTQQ.js","assets/Knowledge-C92uZhl9.js","assets/Comms-DT2o5TCi.js","assets/Memory-DFU5CtTT.js","assets/Processes-btq7Pyex.js","assets/Failures-CaEvQ0t1.js","assets/Decisions-B3i1Rijg.js","assets/Security-BVLBAnlu.js","assets/Policies-CbemgLkX.js","assets/AuditLog-Cc1GUGYz.js","assets/Settings-D9R5JTPF.js"])))=>i.map(i=>d[i]);
2
- import{r as u,a4 as e,a5 as V,a6 as N,a7 as W,a8 as $,a9 as U,aa as B,ab as F,ac as M,ad as H,ae as K,af as q,ag as J,ah as Y,ai as G,aj as Q,ak as X,al as Z,am as ee,an as te,ao as re,ap as ne,aq as se,ar as oe}from"./vendor-gUVFsxOc.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const ie="modulepreload",ae=function(t){return"/"+t},P={},f=function(r,n,o){let s=Promise.resolve();if(n&&n.length>0){let d=function(i){return Promise.all(i.map(c=>Promise.resolve(c).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),m=l?.nonce||l?.getAttribute("nonce");s=d(n.map(i=>{if(i=ae(i),i in P)return;P[i]=!0;const c=i.endsWith(".css"),g=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${g}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":ie,c||(h.as="script"),h.crossOrigin="",h.href=i,m&&h.setAttribute("nonce",m),document.head.appendChild(h),c)return new Promise((v,_)=>{h.addEventListener("load",v),h.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${i}`)))})}))}function a(l){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=l,window.dispatchEvent(m),!m.defaultPrevented)throw l}return s.then(l=>{for(const m of l||[])m.status==="rejected"&&a(m.reason);return r().catch(a)})};let E=null;async function ce(){const t=await fetch("/api/session");if(!t.ok)throw new Error("failed_to_fetch_session");const r=await t.json();if(!r?.csrfToken)throw new Error("missing_csrf_token");return r.csrfToken}async function w(){return E||(E=ce().catch(t=>{throw E=null,t})),E}async function S(t,r=null){const s={method:"POST",headers:{"Content-Type":"application/json","x-agi-farm-csrf":await w()}};r!==null&&(s.body=JSON.stringify(r));const a=await fetch(t,s);let l={};try{l=await a.json()}catch{l={}}if(!a.ok)throw new Error(l?.error||`request_failed_${a.status}`);return l}async function le(t){const r=await w(),n=await fetch(t,{headers:{"x-agi-farm-csrf":r}});let o={};try{o=await n.json()}catch{o={}}if(!n.ok)throw new Error(o?.error||`request_failed_${n.status}`);return o}async function Ye(t){return S("/api/intake/task",t)}async function Ge(t={}){const r=new URLSearchParams;Object.entries(t||{}).forEach(([o,s])=>{s==null||s===""||s==="all"||r.set(o,String(s))});const n=r.toString()?`?${r.toString()}`:"";return le(`/api/projects${n}`)}async function Qe(t){return S("/api/tasks",t)}async function Xe(t,r){return de(`/api/tasks/${t}`,r)}async function Ze(t,r={}){return S(`/api/projects/${t}/plan`,r)}async function et(t,r={}){return S(`/api/projects/${t}/execute`,r)}async function de(t,r=null){const o={method:"PATCH",headers:{"Content-Type":"application/json","x-agi-farm-csrf":await w()}};r!==null&&(o.body=JSON.stringify(r));const s=await fetch(t,o);let a={};try{a=await s.json()}catch{a={}}if(!s.ok)throw new Error(a?.error||`request_failed_${s.status}`);return a}const ue=1e4,O=3e3,L=6e4;function fe(){const[t,r]=u.useState(window.INITIAL_DATA||null),[n,o]=u.useState(!1),[s,a]=u.useState(window.INITIAL_DATA?new Date:null),[l,m]=u.useState(0),d=u.useRef(null),i=u.useRef(!0),c=u.useRef(null),g=u.useRef(null),h=u.useRef(null),v=u.useRef(O),_=u.useCallback(x=>{!x||x.error||x.type==="keepalive"||(r(b=>({...x})),o(!0),a(new Date),m(b=>b+1))},[]),T=u.useCallback(()=>{c.current&&clearInterval(c.current),c.current=setInterval(async()=>{if(!(!i.current||!h.current))try{const x=await fetch("/api/data",{headers:{"x-agi-farm-csrf":h.current}});x.ok&&_(await x.json())}catch{}},ue)},[_]),y=u.useCallback(async()=>{if(!i.current)return;if(d.current)try{d.current.close()}catch{}if(!h.current)try{h.current=await w()}catch{g.current=setTimeout(y,v.current),v.current=Math.min(v.current*2,L);return}const x=new EventSource(`/api/stream?token=${encodeURIComponent(h.current)}`);d.current=x,x.onopen=()=>{i.current&&(o(!0),v.current=O,g.current&&(clearTimeout(g.current),g.current=null))},x.onmessage=b=>{if(i.current)try{_(JSON.parse(b.data))}catch{}},x.onerror=()=>{if(i.current){o(!1);try{x.close()}catch{}d.current=null,g.current=setTimeout(y,v.current),v.current=Math.min(v.current*2,L)}}},[_]);return u.useEffect(()=>(i.current=!0,y(),T(),()=>{if(i.current=!1,d.current)try{d.current.close()}catch{}c.current&&clearInterval(c.current),g.current&&clearTimeout(g.current)}),[y,T]),{data:t,connected:n,lastUpdated:s,updateCount:l}}function pe(){const[t,r]=u.useState(new Date);return u.useEffect(()=>{const n=setInterval(()=>r(new Date),1e3);return()=>clearInterval(n)},[]),e.jsx("span",{style:{color:"var(--text-dim)",fontSize:"12px",fontFamily:"var(--font-mono)",fontWeight:500},children:t.toLocaleTimeString([],{hour12:!0})})}function I({label:t,value:r,color:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"6px 14px",borderRadius:10,background:"#F8FAFC",border:"1px solid var(--border)"},children:[e.jsx("span",{style:{fontSize:10,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:t}),e.jsx("span",{style:{fontSize:14,fontWeight:700,color:n||"var(--text)",marginTop:1},children:r})]})}function ge({data:t,connected:r,lastUpdated:n,toast:o}){const s=t?.agents||[],a=t?.task_counts||{},l=t?.budget||{},d=r&&(t||{}).gateway_online!==!1,i=r&&d,c=t?.update_info,[g,h]=u.useState(()=>sessionStorage.getItem("update-dismissed")==="true"),[v,_]=u.useState(!1),T=c?.updateAvailable&&!g,y=async()=>{_(!0);try{const j=await S("/api/update-install");j.success?o?.("Update installed — please restart","success"):o?.(j.error||"Update failed","error")}catch(j){o?.(j.message,"error")}_(!1)},x=s.filter(j=>j.status!=="available").length,b=s.length,R=a.needs_human_decision??0,z=(l.current?.daily_usd??0).toFixed(2);return e.jsxs(e.Fragment,{children:[e.jsxs("header",{style:{height:60,borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",display:"flex",alignItems:"center",padding:"0 32px",gap:20,position:"sticky",top:0,zIndex:200,backdropFilter:"blur(20px)",boxShadow:"var(--shadow-sm)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i?e.jsx(V,{size:14,color:"var(--mint)"}):e.jsx(N,{size:14,color:"var(--red)"}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:i?"var(--mint)":"var(--red)"},children:i?"Connected":r?"Gateway Down":"Offline"})]}),e.jsx("div",{style:{width:1,height:24,background:"var(--border)"}}),e.jsx(I,{label:"Active Agents",value:`${x} / ${b}`,color:"var(--accent)"}),e.jsx(I,{label:"HITL Queue",value:R,color:R>0?"var(--purple)":"var(--text-dim)"}),e.jsx(I,{label:"Daily Spend",value:`$${z}`,color:"var(--mint)"}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[n&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--muted)",fontSize:11},children:[e.jsx(W,{size:11}),e.jsxs("span",{children:["Updated ",n.toLocaleTimeString([],{hour12:!0})]})]}),e.jsx(pe,{})]})]}),T&&e.jsxs("div",{style:{background:"var(--accent)",color:"#fff",padding:"8px 32px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"12px",fontWeight:600},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx($,{size:14}),e.jsxs("span",{children:["Update available: v",c.currentVersion," → v",c.latestVersion]})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx("button",{onClick:y,disabled:v,style:{background:"rgba(255,255,255,0.2)",color:"#fff",border:"1px solid rgba(255,255,255,0.3)",padding:"4px 14px",borderRadius:8,cursor:"pointer",fontSize:11,fontWeight:700},children:v?"Installing…":"Install Now"}),e.jsx("button",{onClick:()=>{h(!0),sessionStorage.setItem("update-dismissed","true")},style:{background:"none",border:"none",cursor:"pointer",color:"#fff",fontSize:16},children:"✕"})]})]})]})}const me=[{id:"Overview",icon:U,label:"Overview"},{id:"Agents",icon:B,label:"Agents"},{id:"Tasks",icon:F,label:"Tasks"},{id:"HITL",icon:M,label:"HITL",badge:"hitl"},{id:"Alerts",icon:H,label:"Alerts",badge:"alerts"},{id:"Velocity",icon:K,label:"Velocity"},{id:"Budget",icon:q,label:"Budget"}],he=[{id:"Projects",icon:J,label:"Projects"},{id:"OKRs",icon:Y,label:"OKRs"},{id:"Approvals",icon:G,label:"Approvals",badge:"approvals"},{id:"Knowledge",icon:Q,label:"Knowledge"},{id:"Comms",icon:X,label:"Comms"}],xe=[{id:"Security",icon:Z,label:"Security"},{id:"Crons",icon:ee,label:"Jobs & Crons",badge:"crons"},{id:"Processes",icon:te,label:"Processes"},{id:"Memory",icon:re,label:"Memory"},{id:"Settings",icon:ne,label:"Settings"}];function A({title:t,items:r,active:n,onChange:o,badges:s={}}){return e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"var(--muted)",letterSpacing:"0.08em",textTransform:"uppercase",padding:"0 12px",marginBottom:6},children:t}),r.map(({id:a,icon:l,label:m,badge:d})=>{const i=n===a,c=d&&s[d]||0;return e.jsxs("button",{onClick:()=>o(a),style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderRadius:10,border:"none",cursor:"pointer",background:i?"rgba(79,70,229,0.08)":"transparent",color:i?"var(--accent)":"var(--text-dim)",fontWeight:i?600:400,fontSize:13,fontFamily:"var(--font-main)",transition:"all 0.15s ease",textAlign:"left",marginBottom:2},children:[e.jsx(l,{size:15,strokeWidth:i?2.2:1.8,style:{flexShrink:0}}),e.jsx("span",{style:{flex:1},children:m}),c>0&&e.jsx("span",{style:{background:i?"var(--accent)":"#EEF2FF",color:i?"#fff":"var(--accent)",fontSize:10,fontWeight:700,borderRadius:999,padding:"1px 6px",minWidth:18,textAlign:"center"},children:c}),i&&e.jsx(se,{size:12,style:{flexShrink:0}})]},a)})]})}function ve({active:t,onChange:r,badges:n={}}){const o={hitl:n.HITL,alerts:n.Alerts,crons:n.Crons,approvals:n.Approvals};return e.jsxs("nav",{style:{width:220,background:"var(--bg-panel)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",padding:"16px 8px",overflowY:"auto",boxShadow:"var(--shadow-sm)",flexShrink:0},children:[e.jsxs("div",{style:{padding:"4px 12px 20px",display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:22},children:"🦅"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:13,color:"var(--text)",letterSpacing:"-0.01em"},children:"AGI Farm"}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontWeight:400},children:"Ops Dashboard"})]})]}),e.jsx(A,{title:"Agent Intelligence",items:me,active:t,onChange:r,badges:o}),e.jsx(A,{title:"Project Oversight",items:he,active:t,onChange:r,badges:o}),e.jsx("div",{style:{flex:1}}),e.jsx(A,{title:"System",items:xe,active:t,onChange:r,badges:o})]})}const C=u.createContext(null);let _e=0;function ye(){return u.useContext(C)}function be({children:t}){const[r,n]=u.useState([]),o=u.useRef({}),s=u.useCallback((d,i="info")=>{const c=++_e;return n(g=>[...g,{id:c,message:d,type:i}]),o.current[c]=setTimeout(()=>{n(g=>g.filter(h=>h.id!==c)),delete o.current[c]},4e3),c},[]),a=u.useCallback(d=>{n(i=>i.filter(c=>c.id!==d)),o.current[d]&&(clearTimeout(o.current[d]),delete o.current[d])},[]),l={success:"var(--green)",error:"var(--red)",info:"var(--cyan)"},m={success:"✅",error:"❌",info:"ℹ️"};return e.jsxs(C.Provider,{value:s,children:[t,e.jsx("div",{style:{position:"fixed",bottom:20,right:20,zIndex:99999,display:"flex",flexDirection:"column-reverse",gap:8,maxWidth:360},children:r.map(d=>e.jsxs("div",{className:"toast-enter",style:{background:"var(--bg2)",border:`1px solid ${l[d.type]||l.info}`,borderRadius:6,padding:"10px 14px",fontSize:12,color:"var(--text)",display:"flex",alignItems:"center",gap:8,boxShadow:`0 4px 20px rgba(0,0,0,.5), 0 0 8px ${l[d.type]}33`},children:[e.jsx("span",{style:{fontSize:14,flexShrink:0},children:m[d.type]}),e.jsx("span",{style:{flex:1,lineHeight:1.4},children:d.message}),e.jsx("button",{onClick:()=>a(d.id),style:{background:"none",border:"none",color:"var(--muted)",cursor:"pointer",fontSize:14,padding:0,lineHeight:1},children:"×"})]},d.id))})]})}const k="agi-farm-lazy-retry";function p(t){return u.lazy(async()=>{try{const r=await t();return sessionStorage.removeItem(k),r}catch(r){throw sessionStorage.getItem(k)==="1"||(sessionStorage.setItem(k,"1"),window.location.reload()),r}})}const D=p(()=>f(()=>import("./Overview-Cp6HOIJF.js"),__vite__mapDeps([0,1]))),je=p(()=>f(()=>import("./Agents-hD22o0iq.js"),__vite__mapDeps([2,1]))),Se=p(()=>f(()=>import("./Tasks-lXCgffoh.js"),__vite__mapDeps([3,1]))),Te=p(()=>f(()=>import("./Projects-DGmgA8FX.js"),__vite__mapDeps([4,1,5]))),Ee=p(()=>f(()=>import("./Jobs-Ch4D8P85.js"),__vite__mapDeps([6,1]))),we=p(()=>f(()=>import("./Approvals-BHXY6xD5.js"),__vite__mapDeps([7,1]))),Ie=p(()=>f(()=>import("./Usage-Cvfmkgit.js"),__vite__mapDeps([8,1,5]))),Ae=p(()=>f(()=>import("./Crons-EoAAeNe7.js"),__vite__mapDeps([9,1]))),ke=p(()=>f(()=>import("./HITL-F6AxJIK6.js"),__vite__mapDeps([10,1]))),Re=p(()=>f(()=>import("./Alerts-T-KcEJKx.js"),__vite__mapDeps([11,1]))),Pe=p(()=>f(()=>import("./Velocity-DzCZH_YB.js"),__vite__mapDeps([12,1,5]))),Oe=p(()=>f(()=>import("./Budget-DRJWqsop.js"),__vite__mapDeps([13,1,5]))),Le=p(()=>f(()=>import("./OKRs-Dt0HzTQQ.js"),__vite__mapDeps([14,1]))),Ce=p(()=>f(()=>import("./Knowledge-C92uZhl9.js"),__vite__mapDeps([15,1]))),De=p(()=>f(()=>import("./Comms-DT2o5TCi.js"),__vite__mapDeps([16,1]))),ze=p(()=>f(()=>import("./Memory-DFU5CtTT.js"),__vite__mapDeps([17,1]))),Ve=p(()=>f(()=>import("./Processes-btq7Pyex.js"),__vite__mapDeps([18,1]))),Ne=p(()=>f(()=>import("./Failures-CaEvQ0t1.js"),__vite__mapDeps([19,1]))),We=p(()=>f(()=>import("./Decisions-B3i1Rijg.js"),__vite__mapDeps([20,1]))),$e=p(()=>f(()=>import("./Security-BVLBAnlu.js"),__vite__mapDeps([21,1]))),Ue=p(()=>f(()=>import("./Policies-CbemgLkX.js"),__vite__mapDeps([22,1]))),Be=p(()=>f(()=>import("./AuditLog-Cc1GUGYz.js"),__vite__mapDeps([23,1]))),Fe=p(()=>f(()=>import("./Settings-D9R5JTPF.js"),__vite__mapDeps([24,1]))),Me={Overview:D,Agents:je,Tasks:Se,HITL:ke,Alerts:Re,Velocity:Pe,Budget:Oe,Projects:Te,OKRs:Le,Approvals:we,Knowledge:Ce,Comms:De,Security:$e,Crons:Ae,Processes:Ve,Memory:ze,Failures:Ne,Decisions:We,Jobs:Ee,Usage:Ie,Policies:Ue,Settings:Fe,Audit:Be};function He(){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:16,color:"var(--text-dim)"},children:[e.jsx("span",{style:{fontSize:48,filter:"grayscale(0.4)"},children:"🦅"}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text)"},children:"Connecting to Ops Room…"}),e.jsx("div",{style:{fontSize:13,color:"var(--muted)"},children:"Waiting for SSE stream from dashboard server"})]})}function Ke(){return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"200px"},children:e.jsx("div",{style:{fontSize:13,color:"var(--muted)"},children:"Loading…"})})}function qe(){const[t,r]=u.useState("Overview"),{data:n,connected:o,lastUpdated:s,updateCount:a}=fe(),l=ye(),m={data:n,lastUpdated:s,toast:l},d=n?{HITL:(n.hitl_tasks||[]).length,Alerts:(n.alerts||[]).length,Crons:(n.crons||[]).filter(c=>(c._consecutive_errors||0)>=3).length,Approvals:(n.approvals||[]).filter(c=>c.status==="pending").length}:{},i=u.useMemo(()=>Me[t]||D,[t]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden"},children:[e.jsx(ge,{data:n,connected:o,lastUpdated:s,updateCount:a,toast:l}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsx(ve,{active:t,onChange:r,badges:d}),e.jsx("main",{style:{flex:1,overflowY:"auto",padding:"40px 48px",background:"var(--bg)"},children:n?e.jsx("div",{className:"fade-in",children:e.jsx(u.Suspense,{fallback:e.jsx(Ke,{}),children:e.jsx(i,{...m})})}):e.jsx(He,{})})]})]})}oe.createRoot(document.getElementById("root")).render(e.jsx(u.StrictMode,{children:e.jsx(be,{children:e.jsx(qe,{})})}));export{S as a,Qe as c,et as e,Ge as l,Ze as p,Ye as s,Xe as u};