@jx0/agency 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +272 -0
- package/bin/agency.js +2 -0
- package/dashboard/out/404.html +1 -0
- package/dashboard/out/_next/static/chunks/255-67e8754147461423.js +1 -0
- package/dashboard/out/_next/static/chunks/4bd1b696-c023c6e3521b1417.js +1 -0
- package/dashboard/out/_next/static/chunks/app/_not-found/page-ad40673d821037f6.js +1 -0
- package/dashboard/out/_next/static/chunks/app/layout-056f12675e691d12.js +1 -0
- package/dashboard/out/_next/static/chunks/app/page-80f01fdbb09b43c8.js +1 -0
- package/dashboard/out/_next/static/chunks/framework-de98b93a850cfc71.js +1 -0
- package/dashboard/out/_next/static/chunks/main-1a0dcce460eb61ce.js +1 -0
- package/dashboard/out/_next/static/chunks/main-app-1d848b791b823fa6.js +1 -0
- package/dashboard/out/_next/static/chunks/pages/_app-7d307437aca18ad4.js +1 -0
- package/dashboard/out/_next/static/chunks/pages/_error-cb2a52f75f2162e2.js +1 -0
- package/dashboard/out/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/dashboard/out/_next/static/chunks/webpack-4e6bf084ac60582b.js +1 -0
- package/dashboard/out/_next/static/css/27d1ea794f04e96a.css +1 -0
- package/dashboard/out/_next/static/pU1nwWH_dNUOCI8y4nl3C/_buildManifest.js +1 -0
- package/dashboard/out/_next/static/pU1nwWH_dNUOCI8y4nl3C/_ssgManifest.js +1 -0
- package/dashboard/out/index.html +1 -0
- package/dashboard/out/index.txt +19 -0
- package/docs/images/agency_cli_ps.png +0 -0
- package/docs/images/agency_ui_ai_prodivder_settings.png +0 -0
- package/docs/images/agency_ui_aws_settings.png +0 -0
- package/docs/images/agency_ui_identity_settings.png +0 -0
- package/docs/images/agency_ui_mission_control.png +0 -0
- package/docs/images/agent_ui_agent_config.png +0 -0
- package/package.json +31 -0
- package/src/api/db/client.ts +16 -0
- package/src/api/db/migrate.ts +37 -0
- package/src/api/db/migrations/001_initial.ts +193 -0
- package/src/api/db/migrations/002_configs.ts +76 -0
- package/src/api/db/migrations/003_settings_columns.ts +13 -0
- package/src/api/db/seed.ts +142 -0
- package/src/api/db/types.ts +126 -0
- package/src/api/index.ts +73 -0
- package/src/api/lib/activity.ts +13 -0
- package/src/api/lib/fleet-sync.ts +156 -0
- package/src/api/lib/mentions.ts +59 -0
- package/src/api/lib/processes.ts +45 -0
- package/src/api/lib/resolve-agent.ts +5 -0
- package/src/api/lib/tunnels.ts +99 -0
- package/src/api/routes/activities.ts +27 -0
- package/src/api/routes/agents.ts +311 -0
- package/src/api/routes/documents.ts +41 -0
- package/src/api/routes/knowledge.ts +60 -0
- package/src/api/routes/messages.ts +54 -0
- package/src/api/routes/notifications.ts +40 -0
- package/src/api/routes/oauth.ts +171 -0
- package/src/api/routes/role-configs.ts +71 -0
- package/src/api/routes/settings.ts +94 -0
- package/src/api/routes/skills.ts +76 -0
- package/src/api/routes/tasks.ts +154 -0
- package/src/cli/commands/config.ts +42 -0
- package/src/cli/commands/daemon.ts +173 -0
- package/src/cli/commands/doc.ts +47 -0
- package/src/cli/commands/init.ts +105 -0
- package/src/cli/commands/learn.ts +51 -0
- package/src/cli/commands/logs.ts +31 -0
- package/src/cli/commands/msg.ts +18 -0
- package/src/cli/commands/ps.ts +19 -0
- package/src/cli/commands/recall.ts +18 -0
- package/src/cli/commands/skills.ts +66 -0
- package/src/cli/commands/ssh.ts +68 -0
- package/src/cli/commands/start.ts +14 -0
- package/src/cli/commands/status.ts +33 -0
- package/src/cli/commands/stop.ts +11 -0
- package/src/cli/commands/tasks.ts +150 -0
- package/src/cli/index.ts +70 -0
- package/src/cli/lib/api.ts +16 -0
- package/src/cli/lib/config.ts +5 -0
- package/src/cli/lib/find-root.ts +32 -0
- package/src/cli/lib/prompt.ts +20 -0
- package/src/daemon.ts +83 -0
- package/src/templates/implementer/agents-config.md +44 -0
- package/src/templates/implementer/agents.md +32 -0
- package/src/templates/implementer/heartbeat.md +47 -0
- package/src/templates/implementer/tools.md +33 -0
- package/src/templates/orchestrator/agents-config.md +44 -0
- package/src/templates/orchestrator/agents.md +27 -0
- package/src/templates/orchestrator/heartbeat.md +40 -0
- package/src/templates/orchestrator/tools.md +40 -0
- package/src/templates/shared/environment.md +20 -0
- package/src/templates/shared/memory.md +20 -0
- package/src/templates/shared/soul.md +26 -0
- package/src/templates/shared/user.md +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{5313:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>M});var a,r=s(5155),l=s(2115);let n=null!=(a=s(5704).env.NEXT_PUBLIC_API_URL)?a:"";async function o(e){let t=await fetch("".concat(n).concat(e),{cache:"no-store"});if(!t.ok)throw Error("API error: ".concat(t.status));return t.json()}async function c(e,t,s){let a=await fetch("".concat(n).concat(e),{method:t,headers:s?{"Content-Type":"application/json"}:void 0,body:s?JSON.stringify(s):void 0});if(!a.ok){var r;throw Error(null!=(r=(await a.json().catch(()=>({error:"HTTP ".concat(a.status)}))).error)?r:"API error: ".concat(a.status))}return a.json()}let i=[{key:"mission",label:"Mission Control"},{key:"config",label:"Agent Config"},{key:"settings",label:"Settings"},{key:"skills",label:"Skills"},{key:"roles",label:"Roles"}];function d(e){let{activeView:t,onViewChange:s}=e,[a,n]=(0,l.useState)(0),[d,x]=(0,l.useState)(0),[u,m]=(0,l.useState)(""),[p,y]=(0,l.useState)(!0),[h,v]=(0,l.useState)([]),[b,f]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=async()=>{try{let e=await o("/agents"),t=await o("/tasks");n(e.filter(e=>"active"===e.status).length),x(t.filter(e=>"done"!==e.status).length),y(!0)}catch(e){y(!1)}},t=()=>{o("/notifications/pending/human").then(v).catch(()=>{})};e(),t();let s=setInterval(()=>{e(),t()},5e3);return()=>clearInterval(s)},[]);let g=async e=>{await c("/notifications/deliver/".concat(e),"POST"),v(t=>t.filter(t=>t.id!==e))};return(0,l.useEffect)(()=>{let e=()=>{m(new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[]),(0,r.jsxs)("header",{style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},className:"h-14 flex items-center justify-between px-5 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white text-xs font-bold",style:{background:"var(--accent-green)"},children:"A"}),(0,r.jsx)("span",{className:"font-semibold text-sm",children:"Agency"})]}),(0,r.jsx)("nav",{className:"flex gap-1",children:i.map(e=>(0,r.jsx)("button",{onClick:()=>s(e.key),className:"px-3 py-1.5 rounded-md text-sm font-medium transition-colors",style:{background:t===e.key?"var(--bg-tertiary)":"transparent",color:t===e.key?"var(--text-primary)":"var(--text-secondary)"},children:e.label},e.key))})]}),(0,r.jsxs)("div",{className:"flex items-center gap-5 text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",style:{color:"var(--text-secondary)"},children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"font-semibold",style:{color:"var(--text-primary)"},children:a})," ","agents active"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"font-semibold",style:{color:"var(--text-primary)"},children:d})," ","in queue"]})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{onClick:()=>f(!b),className:"relative px-2 py-1 rounded text-sm",style:{color:"var(--text-secondary)"},children:[h.length>0&&(0,r.jsx)("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full text-[10px] font-bold flex items-center justify-center text-white",style:{background:"var(--accent-red, #ef4444)"},children:h.length}),"Bell"]}),b&&h.length>0&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-80 rounded-lg shadow-lg overflow-hidden z-50",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-3 py-2 text-xs font-bold",style:{color:"var(--text-muted)",borderBottom:"1px solid var(--border)"},children:"NOTIFICATIONS"}),(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto",children:h.map(e=>(0,r.jsxs)("div",{className:"px-3 py-2 flex justify-between items-start gap-2 text-sm",style:{borderBottom:"1px solid var(--border)"},children:[(0,r.jsx)("span",{style:{color:"var(--text-primary)"},children:e.content}),(0,r.jsx)("button",{onClick:()=>g(e.id),className:"shrink-0 text-xs px-1 rounded",style:{color:"var(--text-muted)"},children:"x"})]},e.id))})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",style:{color:"var(--text-muted)"},children:[(0,r.jsx)("span",{className:"font-mono text-xs",children:u}),(0,r.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(p?"bg-green-500":"bg-red-500")})]})]})]})}let x={orchestrator:{label:"LEAD",color:"#5c7c5a",bg:"#e8f0e7"},implementer:{label:"INT",color:"#5c6b8c",bg:"#e7ecf0"},specialist:{label:"SPC",color:"#8c6b5c",bg:"#f0ece7"}};function u(e){let{agents:t}=e;return(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsx)("div",{className:"px-4 py-3 text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"AGENTS"}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:t.map(e=>{var t,s;let a=null!=(s=x[t=e.role])?s:{label:t.slice(0,3).toUpperCase(),color:"#6b6b6b",bg:"#f0f0f0"};return(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-2 py-2 rounded-md hover:bg-black/[0.03] cursor-default",children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",style:{background:a.color},children:e.name.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 ".concat("active"===e.status?"bg-green-500":"blocked"===e.status?"bg-red-500":"bg-gray-400")}),(0,r.jsx)("span",{className:"text-sm font-semibold truncate",children:e.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,r.jsx)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded",style:{color:a.color,background:a.bg},children:a.label}),(0,r.jsx)("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:e.role})]})]})]},e.id)})})]})}let m={1:"var(--accent-red)",2:"var(--accent-yellow)",3:"var(--border)"};function p(e){var t,s,a,l;let{task:n,onClick:o}=e,c=null==(t=n.assignees)?void 0:t[0],i=null!=(a=n.updated_at)?a:n.created_at;return(0,r.jsxs)("button",{onClick:o,className:"w-full text-left rounded-lg p-3 transition-all hover:shadow-md",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-light)",borderLeft:"3px solid ".concat(null!=(l=m[n.priority])?l:"var(--border)")},children:[(0,r.jsx)("div",{className:"font-semibold text-sm mb-1 leading-snug",children:n.title}),n.description&&(0,r.jsx)("div",{className:"text-xs mb-2 leading-relaxed line-clamp-2",style:{color:"var(--text-secondary)"},children:n.description}),(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-bold",style:{background:"var(--accent-blue)"},children:c.name.charAt(0).toUpperCase()}),(0,r.jsx)("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:c.name})]}),i&&(0,r.jsxs)("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c?" \xb7 ":"",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return"".concat(s,"m ago");let a=Math.floor(s/60);if(a<24)return"about ".concat(a," hour").concat(a>1?"s":""," ago");let r=Math.floor(a/24);return"".concat(r,"d ago")}(i)]})]})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:n.task_type}),null==(s=n.tags)?void 0:s.map(e=>(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e},e))]})]})}let y=["inbox","assigned","in_progress","review","done"];function h(e){var t;let{taskId:s,onClose:a}=e,[n,i]=(0,l.useState)(null),[d,x]=(0,l.useState)([]),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(!1),[v,b]=(0,l.useState)(""),f=(0,l.useCallback)(()=>{o("/tasks/".concat(s)).then(i).catch(console.error)},[s]);(0,l.useEffect)(()=>{f(),o("/agents").then(x).catch(console.error);let e=setInterval(f,5e3);return()=>clearInterval(e)},[f]);let g=async e=>{await c("/tasks/".concat(s),"PATCH",{status:e,agent_name:"human"}),f()},j=async()=>{v&&(await c("/tasks/".concat(s,"/assign"),"POST",{agent_name:v}),b(""),f())},k=async()=>{if(u.trim()){h(!0);try{await c("/tasks/".concat(s,"/messages"),"POST",{from_agent:"human",content:u.trim()}),m(""),f()}catch(e){console.error(e.message)}finally{h(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/20 z-40",onClick:a}),(0,r.jsxs)("div",{className:"fixed inset-y-0 right-0 w-[600px] overflow-y-auto z-50 shadow-xl flex flex-col",style:{background:"var(--bg-secondary)",borderLeft:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto",children:[(0,r.jsx)("button",{onClick:a,className:"mb-4 text-sm font-medium px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--text-secondary)"},children:"Close"}),n&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h2",{className:"text-xl font-bold",children:n.title}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 items-center",children:y.map(e=>(0,r.jsx)("button",{onClick:()=>g(e),className:"px-2 py-1 rounded text-xs font-medium transition-colors",style:{background:n.status===e?"var(--accent-green)":"var(--bg-tertiary)",color:n.status===e?"white":"var(--text-secondary)"},children:e.replace("_"," ")},e))}),(0,r.jsxs)("div",{className:"text-sm",style:{color:"var(--text-secondary)"},children:["Priority: P",n.priority," \xb7 Assignees:"," ",(null==(t=n.assignees)?void 0:t.map(e=>e.name).join(", "))||"none"]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsxs)("select",{value:v,onChange:e=>b(e.target.value),className:"px-2 py-1 rounded text-sm",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("option",{value:"",children:"Assign agent..."}),d.filter(e=>"human"!==e.name).map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}),v&&(0,r.jsx)("button",{onClick:j,className:"px-3 py-1 rounded text-xs font-medium text-white",style:{background:"var(--accent-blue)"},children:"Assign"})]}),n.description&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"DESCRIPTION"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.description})]}),n.design&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"DESIGN"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.design})]}),n.acceptance&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"ACCEPTANCE"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.acceptance})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"MESSAGES"}),(0,r.jsx)("div",{className:"space-y-2 mb-3",children:n.messages&&n.messages.length>0?n.messages.map((e,t)=>{var s;return(0,r.jsxs)("div",{className:"pl-3",style:{borderLeft:"2px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[(0,r.jsx)("span",{className:"font-bold",style:{color:"var(--text-secondary)"},children:null!=(s=e.from_name)?s:"?"})," ","\xb7 ",new Date(e.created_at).toLocaleString()]}),(0,r.jsx)("div",{className:"text-sm mt-0.5",children:e.content})]},t)}):(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No messages yet"})})]})]})]}),n&&(0,r.jsx)("div",{className:"p-4 border-t",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),k())},placeholder:"Write a message...",className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:k,disabled:p||!u.trim(),className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:p||!u.trim()?.5:1},children:p?"...":"Send"})]})})]})]})}function v(e){let{open:t,onClose:s,onCreated:a}=e,[n,i]=(0,l.useState)(""),[d,x]=(0,l.useState)(""),[u,m]=(0,l.useState)(2),[p,y]=(0,l.useState)("task"),[h,v]=(0,l.useState)(""),[b,f]=(0,l.useState)([]),[g,j]=(0,l.useState)(null),[k,N]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{t&&o("/agents").then(f).catch(console.error)},[t]),!t)return null;let w=async e=>{e.preventDefault(),j(null),N(!0);try{await c("/tasks","POST",{title:n,description:d,from:"human",priority:u,task_type:p,...h?{assign:h}:{}}),i(""),x(""),m(2),y("task"),v(""),a(),s()}catch(e){j(e.message)}finally{N(!1)}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:s,children:(0,r.jsxs)("form",{onClick:e=>e.stopPropagation(),onSubmit:w,className:"rounded-lg shadow-xl w-[480px] max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-5 py-4 border-b",style:{borderColor:"var(--border)"},children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Create Task"})}),(0,r.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[g&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"#fef2f2",color:"#dc2626"},children:g}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Title"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>i(e.target.value),placeholder:"Task title",required:!0,className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Description"}),(0,r.jsx)("textarea",{value:d,onChange:e=>x(e.target.value),placeholder:"Describe the task...",required:!0,rows:4,className:"w-full px-3 py-2 rounded-md text-sm resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Priority"}),(0,r.jsx)("div",{className:"flex gap-3",children:[1,2,3].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"priority",value:e,checked:u===e,onChange:()=>m(e)}),"P",e]},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Type"}),(0,r.jsx)("div",{className:"flex gap-3",children:["task","bug","feature"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"task_type",value:e,checked:p===e,onChange:()=>y(e)}),e.charAt(0).toUpperCase()+e.slice(1)]},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Assign to (optional)"}),(0,r.jsxs)("select",{value:h,onChange:e=>v(e.target.value),className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("option",{value:"",children:"Unassigned"}),b.filter(e=>"human"!==e.name).map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," (",e.role,")"]},e.id))]})]})]}),(0,r.jsxs)("div",{className:"px-5 py-3 flex justify-end gap-2 border-t",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)"},children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:k,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:k?.6:1},children:k?"Creating...":"Create Task"})]})]})})}let b=["inbox","assigned","in_progress","review","done"],f={inbox:"INBOX",assigned:"ASSIGNED",in_progress:"IN PROGRESS",review:"REVIEW",done:"DONE"};function g(){let[e,t]=(0,l.useState)([]),[s,a]=(0,l.useState)(null),[n,c]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=()=>o("/tasks").then(t).catch(console.error);e();let s=setInterval(e,5e3);return()=>clearInterval(s)},[]),(0,r.jsxs)("div",{className:"flex-1 overflow-x-auto p-4",children:[(0,r.jsx)("div",{className:"flex gap-4 min-w-0",children:b.map(t=>{let s=e.filter(e=>e.status===t);return(0,r.jsxs)("div",{className:"flex-1 min-w-[200px]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3 px-1",children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:f[t]}),"inbox"===t&&(0,r.jsx)("button",{onClick:()=>c(!0),className:"w-5 h-5 flex items-center justify-center rounded text-xs font-bold leading-none",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},title:"Create task",children:"+"}),(0,r.jsx)("span",{className:"text-[11px] font-medium px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:s.length})]}),(0,r.jsx)("div",{className:"space-y-2",children:s.map(e=>(0,r.jsx)(p,{task:e,onClick:()=>a(e.id)},e.id))})]},t)})}),s&&(0,r.jsx)(h,{taskId:s,onClose:()=>a(null)}),(0,r.jsx)(v,{open:n,onClose:()=>c(!1),onCreated:()=>o("/tasks").then(t).catch(console.error)})]})}let j=["All","Tasks","Comments","Status"],k={Tasks:["task_created","assigned","document_created"],Comments:["message"],Status:["status_changed"]};function N(){let[e,t]=(0,l.useState)([]),[s,a]=(0,l.useState)("All"),[n,c]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=()=>o("/activities?limit=50").then(t).catch(console.error);e();let s=setInterval(e,5e3);return()=>clearInterval(s)},[]);let i=[...new Set(e.map(e=>e.agent_name).filter(Boolean))],d=e.filter(e=>{if(n&&e.agent_name!==n)return!1;if("All"!==s){let t=k[s];if(t&&e.type&&!t.includes(e.type))return!1}return!0});return(0,r.jsxs)("div",{className:"w-[300px] shrink-0 overflow-y-auto border-l flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3",children:[(0,r.jsx)("div",{className:"text-xs font-bold tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"LIVE FEED"}),(0,r.jsx)("div",{className:"flex gap-1 mb-3",children:j.map(e=>(0,r.jsx)("button",{onClick:()=>a(e),className:"px-2 py-1 rounded text-xs font-medium transition-colors",style:{background:s===e?"var(--bg-tertiary)":"transparent",color:s===e?"var(--text-primary)":"var(--text-muted)"},children:e},e))}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mb-3",children:[(0,r.jsx)("button",{onClick:()=>c(null),className:"px-2 py-0.5 rounded-full text-[11px] font-medium transition-colors",style:{background:null===n?"var(--accent-green)":"var(--bg-tertiary)",color:null===n?"white":"var(--text-secondary)"},children:"All Agents"}),i.map(e=>(0,r.jsx)("button",{onClick:()=>c(e),className:"px-2 py-0.5 rounded-full text-[11px] font-medium transition-colors",style:{background:n===e?"var(--accent-green)":"var(--bg-tertiary)",color:n===e?"white":"var(--text-secondary)"},children:e},e))]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-3",children:[d.map(e=>{var t,s;return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-[10px] font-bold shrink-0 mt-0.5",style:{background:"var(--accent-olive)"},children:(null!=(t=e.agent_name)?t:"S").charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsx)("span",{className:"font-semibold",children:null!=(s=e.agent_name)?s:"system"})," ",(0,r.jsx)("span",{style:{color:"var(--text-secondary)"},children:e.summary})]}),(0,r.jsx)("div",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let s=Math.floor(t/60);if(s<60)return"".concat(s,"m ago");let a=Math.floor(s/60);if(a<24)return"".concat(a,"h ago");let r=Math.floor(a/24);return"".concat(r,"d ago")}(e.created_at)})]})]},e.id)}),0===d.length&&(0,r.jsx)("div",{className:"text-sm text-center py-8",style:{color:"var(--text-muted)"},children:"No activity yet"})]})]})}function w(e){let{content:t,filename:s}=e,a=t.split("\n");return(0,r.jsx)("div",{className:"flex-1 overflow-auto font-mono text-sm",style:{background:"var(--bg-primary)"},children:(0,r.jsx)("div",{className:"p-4",children:a.map((e,t)=>(0,r.jsxs)("div",{className:"flex leading-6 hover:bg-black/[0.02]",children:[(0,r.jsx)("span",{className:"w-12 text-right pr-4 select-none shrink-0",style:{color:"var(--text-muted)",fontSize:"0.8rem"},children:t+1}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all",children:function(e){if(e.startsWith("# "))return(0,r.jsx)("span",{style:{color:"var(--accent-green)",fontWeight:700,fontSize:"1.1em"},children:e});if(e.startsWith("## "))return(0,r.jsx)("span",{style:{color:"var(--accent-blue)",fontWeight:700},children:e});if(e.startsWith("### "))return(0,r.jsx)("span",{style:{color:"var(--accent-olive)",fontWeight:600},children:e});if(e.startsWith("- ")||e.startsWith("* "))return(0,r.jsx)("span",{style:{color:"var(--text-primary)"},children:e});if(e.startsWith("```"))return(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:e});let t=e.split(/(\*\*[^*]+\*\*)/g);return t.length>1?(0,r.jsx)(r.Fragment,{children:t.map((e,t)=>e.startsWith("**")&&e.endsWith("**")?(0,r.jsx)("strong",{children:e.slice(2,-2)},t):(0,r.jsx)("span",{children:e},t))}):(0,r.jsx)("span",{children:e})}(e)})]},t))})})}function S(e){let{open:t,onClose:s,onCreated:a}=e,[n,i]=(0,l.useState)(""),[d,x]=(0,l.useState)(""),[u,m]=(0,l.useState)([]),[p,y]=(0,l.useState)("docker"),[h,v]=(0,l.useState)(!1),[b,f]=(0,l.useState)(""),[g,j]=(0,l.useState)(""),[k,N]=(0,l.useState)(null),[w,S]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{t&&o("/agents/roles").then(e=>{m(e),e.length>0&&!d&&x(e[0])})},[t]),!t)return null;let C=async e=>{e.preventDefault(),N(null),S(!0);try{await c("/agents","POST",{name:n,role:d,location:p,...b?{slack_bot_token:b}:{},...g?{slack_app_token:g}:{}}),i(""),f(""),j(""),v(!1),a(),s()}catch(e){N(e.message)}finally{S(!1)}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:s,children:(0,r.jsxs)("form",{onClick:e=>e.stopPropagation(),onSubmit:C,className:"rounded-lg shadow-xl w-[420px] max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-5 py-4 border-b",style:{borderColor:"var(--border)"},children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Create Agent"})}),(0,r.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[k&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"#fef2f2",color:"#dc2626"},children:k}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Name"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>i(e.target.value),placeholder:"my-agent",required:!0,pattern:"^[a-z][a-z0-9-]{1,30}$",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Lowercase letters, numbers, hyphens. 2-31 chars."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Role"}),(0,r.jsx)("select",{value:d,onChange:e=>x(e.target.value),required:!0,className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:u.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Location"}),(0,r.jsx)("div",{className:"flex gap-3",children:["docker","ec2","local"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"location",value:e,checked:p===e,onChange:()=>y(e)}),e.charAt(0).toUpperCase()+e.slice(1)]},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>v(!h),className:"text-sm font-medium flex items-center gap-1",style:{color:"var(--text-secondary)"},children:[(0,r.jsx)("span",{style:{display:"inline-block",transform:h?"rotate(90deg)":"none",transition:"transform 0.15s"},children:"▶"}),"Slack Configuration"]}),h&&(0,r.jsxs)("div",{className:"mt-2 space-y-3 pl-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium mb-1",children:"Bot Token"}),(0,r.jsx)("input",{type:"password",value:b,onChange:e=>f(e.target.value),placeholder:"xoxb-...",className:"w-full px-3 py-1.5 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium mb-1",children:"App Token"}),(0,r.jsx)("input",{type:"password",value:g,onChange:e=>j(e.target.value),placeholder:"xapp-...",className:"w-full px-3 py-1.5 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]})]})]})]}),(0,r.jsxs)("div",{className:"px-5 py-3 flex justify-end gap-2 border-t",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)"},children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:w,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:w?.6:1},children:w?"Creating...":"Create"})]})]})})}function C(e){var t,s;let{agent:a,onRefresh:n}=e,[o,i]=(0,l.useState)(!1),[d,x]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(null),[b,f]=(0,l.useState)(null!=(t=a.slack_bot_token)?t:""),[g,j]=(0,l.useState)(null!=(s=a.slack_app_token)?s:""),[k,N]=(0,l.useState)(!1),w=async()=>{i(!0),v(null);try{var e;let t=await c("/agents/".concat(a.name,"/deploy"),"POST");v(null!=(e=t.instructions)?e:"Deployed (".concat(t.method,")")),n()}catch(e){v(e.message)}finally{i(!1)}},S=async()=>{x(!0),v(null);try{await c("/agents/".concat(a.name,"/stop"),"POST"),v("Stopped"),n()}catch(e){v(e.message)}finally{x(!1)}},C=async()=>{m(!0);try{await c("/agents/".concat(a.name),"DELETE"),n()}catch(e){v(e.message),m(!1)}},_=async()=>{N(!0);try{await c("/agents/".concat(a.name),"PATCH",{slack_bot_token:b||null,slack_app_token:g||null}),v("Slack tokens saved"),n()}catch(e){v(e.message)}finally{N(!1)}},E="active"===a.status?"#22c55e":"blocked"===a.status?"#ef4444":"#9ca3af";return(0,r.jsxs)("div",{className:"p-5 space-y-4 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"w-2.5 h-2.5 rounded-full",style:{background:E}}),(0,r.jsx)("span",{className:"font-semibold",children:a.name}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a.role}),a.location&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a.location})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:w,disabled:o,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#22c55e",opacity:o?.6:1},children:o?"Deploying...":"Deploy"}),(0,r.jsx)("button",{onClick:S,disabled:d,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#f59e0b",opacity:d?.6:1},children:d?"Stopping...":"Stop"}),p?(0,r.jsx)("button",{onClick:C,disabled:u,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#dc2626",opacity:u?.6:1},children:u?"Deleting...":"Confirm Delete"}):(0,r.jsx)("button",{onClick:()=>y(!0),className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#ef4444"},children:"Delete"})]})]}),h&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:h}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Slack Tokens"}),(0,r.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,r.jsx)("input",{type:"password",value:b,onChange:e=>f(e.target.value),placeholder:"Bot Token",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"password",value:g,onChange:e=>j(e.target.value),placeholder:"App Token",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:_,disabled:k,className:"px-3 py-1.5 rounded text-xs font-medium",style:{background:"var(--bg-tertiary)"},children:k?"Saving...":"Save"})]})]})]})}let _=[{label:"Soul",file:"SOUL.md"},{label:"User",file:"USER.md"},{label:"Agents",file:"AGENTS.md"},{label:"Memory",file:"MEMORY.md"},{label:"Tools",file:"TOOLS.md"}];function E(e){let{agents:t}=e,[s,a]=(0,l.useState)(t),[n,c]=(0,l.useState)(null),[i,d]=(0,l.useState)(_[0].file),[x,u]=(0,l.useState)(""),[m,p]=(0,l.useState)(!1),[y,h]=(0,l.useState)(null),[v,b]=(0,l.useState)(!1),f=s.find(e=>e.name===n),g=(0,l.useCallback)(async()=>{try{let e=await o("/agents");a(e)}catch(e){}},[]);return(0,l.useEffect)(()=>{!n&&s.length>0&&c(s[0].name)},[s,n]),(0,l.useEffect)(()=>{n&&(p(!0),h(null),o("/agents/".concat(n,"/files/").concat(i)).then(e=>{u(e.content),p(!1)}).catch(e=>{h("File not found"),u(""),p(!1)}))},[n,i]),(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[240px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"AGENTS"}),(0,r.jsx)("button",{onClick:()=>b(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},title:"Create agent",children:"+"})]}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:s.map(e=>(0,r.jsxs)("button",{onClick:()=>{c(e.name),d(_[0].file)},className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-left transition-colors",style:{background:n===e.name?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",style:{background:"var(--accent-green)"},children:e.name.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 ".concat("active"===e.status?"bg-green-500":"blocked"===e.status?"bg-red-500":"bg-gray-400")}),(0,r.jsx)("span",{className:"text-sm font-semibold truncate",children:e.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,r.jsx)("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:e.role}),e.location&&(0,r.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.location})]})]})]},e.id))})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C,{agent:f,onRefresh:()=>{g(),s.find(e=>e.name===n)||c(null)}}),(0,r.jsx)("div",{className:"flex gap-0 border-b px-4",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:_.map(e=>(0,r.jsxs)("button",{onClick:()=>d(e.file),className:"px-3 py-2 text-sm font-medium transition-colors relative",style:{color:i===e.file?"var(--text-primary)":"var(--text-muted)"},children:[e.label,i===e.file&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5",style:{background:"var(--accent-green)"}})]},e.file))}),m?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Loading..."}):y?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:y}):(0,r.jsx)(w,{content:x,filename:i})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select an agent"})}),(0,r.jsx)(S,{open:v,onClose:()=>b(!1),onCreated:()=>{g()}})]})}let T="********",A=[{id:"identity",label:"Identity"},{id:"ai",label:"AI Provider"},{id:"aws",label:"AWS"},{id:"ssh",label:"SSH"}],I=new Set(["ai.oauth_access_token","ai.oauth_refresh_token","ai.oauth_expires_at","ai.oauth_subscription_type","ai.auth_method"]);function P(){var e;let[t,s]=(0,l.useState)([]),[a,n]=(0,l.useState)("identity"),[i,d]=(0,l.useState)({}),[x,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(new Set),[y,h]=(0,l.useState)("api_key"),v=(0,l.useCallback)(()=>{o("/settings").then(e=>{s(e);let t=e.find(e=>"ai.auth_method"===e.key);(null==t?void 0:t.value)&&t.value!==T&&h(t.value)}).catch(console.error)},[]);(0,l.useEffect)(()=>{v()},[v]);let b=t.filter(e=>e.category===a),f=async e=>{let t=i[e];if(void 0!==t){u(e);try{await c("/settings/".concat(e),"PUT",{value:t}),v(),d(t=>{let s={...t};return delete s[e],s})}catch(e){console.error(e.message)}finally{u(null)}}},g=async e=>{h(e),await c("/settings/ai.auth_method","PUT",{value:e}),v()},[j,k]=(0,l.useState)(null),[N,w]=(0,l.useState)(!1),S=async()=>{w(!0),k(null);try{(await c("/oauth/claude/import","POST")).ok&&(h("oauth"),v())}catch(e){k(e.message)}finally{w(!1)}},C=async()=>{k(null);try{let e=await o("/oauth/claude/authorize");if(e.error)return void k(e.error);if(e.url){window.open(e.url,"claude-oauth","width=600,height=700");let t=setInterval(()=>{o("/settings?category=ai").then(e=>{let s=e.find(e=>"ai.oauth_access_token"===e.key);s&&s.value===T&&(clearInterval(t),v())})},2e3);setTimeout(()=>clearInterval(t),12e4)}}catch(e){k(e.message)}},_=async()=>{for(let e of["ai.oauth_access_token","ai.oauth_refresh_token","ai.oauth_expires_at","ai.oauth_subscription_type"])await c("/settings/".concat(e),"PUT",{value:""});await c("/settings/ai.auth_method","PUT",{value:"api_key"}),h("api_key"),v()},E=e=>{var t;let s=void 0!==i[e.key],a=null!=(t=i[e.key])?t:e.value,l=s&&i[e.key]!==e.value;if("readonly"===e.input_type)return(0,r.jsx)("span",{className:"text-sm px-3 py-2 block",style:{color:"var(--text-secondary)"},children:e.value||"—"});if("textarea"===e.input_type)return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:a,onChange:t=>d(s=>({...s,[e.key]:t.target.value})),placeholder:e.sensitive?"Paste your private key":"",rows:8,className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",resize:"vertical"}}),l&&(0,r.jsx)(D,{keyName:e.key,saving:x,onSave:f})]});if("password"===e.input_type){let t=m.has(e.key);return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 relative",children:[(0,r.jsx)("input",{type:t?"text":"password",value:a,onChange:t=>d(s=>({...s,[e.key]:t.target.value})),onFocus:()=>{s||e.value!==T||d(t=>({...t,[e.key]:""}))},placeholder:e.value===T?"••••••••":"",className:"w-full px-3 py-2 rounded-md text-sm pr-10",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.key,void p(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs px-1",style:{color:"var(--text-muted)"},children:t?"Hide":"Show"})]}),l&&(0,r.jsx)(D,{keyName:e.key,saving:x,onSave:f})]})}return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:a,onChange:t=>d(s=>({...s,[e.key]:t.target.value})),className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),l&&(0,r.jsx)(D,{keyName:e.key,saving:x,onSave:f})]})};return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsx)("div",{className:"px-4 py-3 text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"CATEGORIES"}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:A.map(e=>(0,r.jsx)("button",{onClick:()=>n(e.id),className:"w-full text-left px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{background:a===e.id?"var(--bg-tertiary)":"transparent",color:a===e.id?"var(--text-primary)":"var(--text-secondary)"},children:e.label},e.id))})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold mb-4",children:[null==(e=A.find(e=>e.id===a))?void 0:e.label," Settings"]}),(()=>{if("ai"===a)return(()=>{let e=b.find(e=>"ai.anthropic_api_key"===e.key),s=t.find(e=>"ai.oauth_access_token"===e.key),a=t.find(e=>"ai.oauth_expires_at"===e.key),l=t.find(e=>"ai.oauth_subscription_type"===e.key),n=(null==s?void 0:s.value)===T,o=null!=a&&!!a.value&&new Date(a.value)<new Date;return(0,r.jsxs)("div",{className:"space-y-6 max-w-xl",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Authentication Method"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>g("api_key"),className:"px-4 py-2 rounded-md text-sm font-medium transition-colors",style:{background:"api_key"===y?"var(--accent-blue)":"var(--bg-secondary)",color:"api_key"===y?"white":"var(--text-secondary)",border:"1px solid var(--border)"},children:"API Key"}),(0,r.jsx)("button",{onClick:()=>g("oauth"),className:"px-4 py-2 rounded-md text-sm font-medium transition-colors",style:{background:"oauth"===y?"var(--accent-blue)":"var(--bg-secondary)",color:"oauth"===y?"white":"var(--text-secondary)",border:"1px solid var(--border)"},children:"Claude Max OAuth"})]})]}),"api_key"===y&&e&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:e.key}),e.description&&(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.description}),E(e)]}),"oauth"===y&&(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Claude OAuth Status"}),j&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded-md",style:{background:"rgba(255,0,0,0.1)",color:"var(--accent-red, #ef4444)"},children:j}),!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Not connected"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:S,disabled:N,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-blue)",opacity:N?.6:1},children:N?"Importing...":"Import from Claude Code"}),(0,r.jsx)("button",{onClick:C,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Connect with OAuth"})]})]}),n&&!o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--accent-green)"},children:"Connected"}),(null==l?void 0:l.value)&&(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Subscription: ",l.value]}),(null==a?void 0:a.value)&&(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Expires: ",new Date(a.value).toLocaleString()]}),(0,r.jsx)("button",{onClick:_,className:"px-3 py-1.5 rounded-md text-xs font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Disconnect"})]}),n&&o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--accent-yellow, orange)"},children:"Token expired"}),(0,r.jsx)("button",{onClick:C,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-blue)"},children:"Reconnect"})]})]})]})})();let e=b.filter(e=>!I.has(e.key));return(0,r.jsxs)("div",{className:"space-y-4 max-w-xl",children:[e.map(e=>(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:e.key}),e.description&&(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.description}),E(e)]},e.key)),0===e.length&&(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:"No settings in this category."})]})})()]})]})}function D(e){let{keyName:t,saving:s,onSave:a}=e;return(0,r.jsx)("button",{onClick:()=>a(t),disabled:s===t,className:"px-3 py-2 rounded-md text-xs font-medium text-white shrink-0",style:{background:"var(--accent-green)",opacity:s===t?.6:1},children:s===t?"Saving...":"Save"})}function O(){let[e,t]=(0,l.useState)([]),[s,a]=(0,l.useState)(null),[n,i]=(0,l.useState)(""),[d,x]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),[p,y]=(0,l.useState)(""),[h,v]=(0,l.useState)("");(0,l.useEffect)(()=>{b()},[]);let b=()=>{let e=h?"?search=".concat(encodeURIComponent(h)):"";o("/skills".concat(e)).then(t).catch(console.error)};(0,l.useEffect)(()=>{b()},[h]);let f=e.find(e=>e.id===s);(0,l.useEffect)(()=>{f&&i(f.body)},[s]);let g=async()=>{if(s){x(!0);try{await c("/skills/".concat(s),"PUT",{body:n}),t(e=>e.map(e=>e.id===s?{...e,body:n}:e))}catch(e){console.error(e.message)}finally{x(!1)}}},j=async()=>{if(p.trim())try{let e=await c("/skills","POST",{name:p,body:"# ".concat(p,"\n")});t(t=>[...t,e]),a(e.id),y(""),m(!1)}catch(e){console.error(e.message)}},k=async e=>{try{await c("/skills/".concat(e),"DELETE"),t(t=>t.filter(t=>t.id!==e)),s===e&&(a(null),i(""))}catch(e){console.error(e.message)}},N=f&&n!==f.body;return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[260px] shrink-0 overflow-y-auto border-r flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"SKILLS"}),(0,r.jsx)("button",{onClick:()=>m(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"})]}),(0,r.jsx)("div",{className:"px-3 pb-2",children:(0,r.jsx)("input",{type:"text",value:h,onChange:e=>v(e.target.value),placeholder:"Search skills...",className:"w-full px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})}),u&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:p,onChange:e=>y(e.target.value),placeholder:"Skill name",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&j(),autoFocus:!0}),(0,r.jsx)("button",{onClick:j,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-0.5 px-2",children:e.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between group",children:[(0,r.jsxs)("button",{onClick:()=>a(e.id),className:"flex-1 text-left px-2 py-2 rounded-md text-sm transition-colors",style:{background:s===e.id?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"font-medium truncate",children:e.name}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[e.category,e.tags.length?" \xb7 ".concat(e.tags.join(", ")):""]})]}),(0,r.jsx)("button",{onClick:()=>k(e.id),className:"opacity-0 group-hover:opacity-100 px-1 text-xs",style:{color:"var(--accent-red)"},title:"Delete",children:"\xd7"})]},e.id))})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-semibold",children:f.name}),(0,r.jsx)("span",{className:"text-xs ml-2",style:{color:"var(--text-muted)"},children:f.category})]}),(0,r.jsx)("button",{onClick:g,disabled:!N||d,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!N||d?.4:1},children:d?"Saving...":"Save"})]}),(0,r.jsx)("textarea",{value:n,onChange:e=>i(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a skill to edit"})})]})}let U=[{key:"heartbeat",label:"Heartbeat"},{key:"agents-config",label:"Config"},{key:"tools",label:"Tools"},{key:"agents",label:"Agents"},{key:"environment",label:"Environment"},{key:"soul",label:"Soul"},{key:"identity",label:"Identity"}];function L(){let[e,t]=(0,l.useState)([]),[s,a]=(0,l.useState)([]),[n,i]=(0,l.useState)(null),[d,x]=(0,l.useState)("heartbeat"),[u,m]=(0,l.useState)(""),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(!1),[b,f]=(0,l.useState)("");(0,l.useEffect)(()=>{g()},[]);let g=async()=>{let e=await o("/role-configs");t(e);let s=[...new Set(e.map(e=>e.role))];a(s),!n&&s.length>0&&i(s[0])};(0,l.useEffect)(()=>{if(n&&d){var t;let s=e.find(e=>e.role===n&&e.config_type===d);m(null!=(t=null==s?void 0:s.content)?t:"")}},[n,d,e]);let j=e.find(e=>e.role===n&&e.config_type===d),k=j?u!==j.content:u.length>0,N=async()=>{if(n){y(!0);try{let e=await c("/role-configs/".concat(n,"/").concat(d),"PUT",{content:u});t(t=>{let s=t.findIndex(e=>e.role===n&&e.config_type===d);if(s>=0){let a=[...t];return a[s]=e,a}return[...t,e]})}catch(e){console.error(e.message)}finally{y(!1)}}},w=async()=>{b.trim()&&(await c("/role-configs/".concat(b,"/heartbeat"),"PUT",{content:"# ".concat(b," Heartbeat\n\nAdd your heartbeat checklist here.")}),f(""),v(!1),await g(),i(b))};return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"ROLES"}),(0,r.jsx)("button",{onClick:()=>v(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"})]}),h&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:b,onChange:e=>f(e.target.value),placeholder:"Role name",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&w(),autoFocus:!0}),(0,r.jsx)("button",{onClick:w,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:s.map(e=>(0,r.jsx)("button",{onClick:()=>i(e),className:"w-full text-left px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{background:n===e?"var(--bg-tertiary)":"transparent",color:n===e?"var(--text-primary)":"var(--text-secondary)"},children:e},e))})]}),n?(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex gap-0 border-b px-4",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:U.map(e=>(0,r.jsxs)("button",{onClick:()=>x(e.key),className:"px-3 py-2 text-sm font-medium transition-colors relative",style:{color:d===e.key?"var(--text-primary)":"var(--text-muted)"},children:[e.label,d===e.key&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5",style:{background:"var(--accent-green)"}})]},e.key))}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:[n," / ",d]}),(0,r.jsx)("button",{onClick:N,disabled:!k||p,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!k||p?.4:1},children:p?"Saving...":"Save"})]}),(0,r.jsx)("textarea",{value:u,onChange:e=>m(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a role"})]})}function M(){let[e,t]=(0,l.useState)("mission"),[s,a]=(0,l.useState)([]);return(0,l.useEffect)(()=>{let e=()=>o("/agents").then(a).catch(console.error);e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,r.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,r.jsx)(d,{activeView:e,onViewChange:t}),"mission"===e?(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsx)(u,{agents:s}),(0,r.jsx)(g,{}),(0,r.jsx)(N,{})]}):"config"===e?(0,r.jsx)(E,{agents:s}):"settings"===e?(0,r.jsx)(P,{}):"skills"===e?(0,r.jsx)(O,{}):"roles"===e?(0,r.jsx)(L,{}):null]})}},5892:(e,t,s)=>{Promise.resolve().then(s.bind(s,5313))}},e=>{e.O(0,[441,255,358],()=>e(e.s=5892)),_N_E=e.O()}]);
|