brainctl 0.1.13 → 0.1.15
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
|
@@ -55,7 +55,13 @@ Reload the MCP in Claude Code: `/mcp` → `brainctl` → **Reconnect**.
|
|
|
55
55
|
<details open>
|
|
56
56
|
<summary><b>🟢 Codex</b> — <code>~/.codex/config.toml</code></summary>
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Easiest: use the `codex` CLI.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
codex mcp add brainctl -- npx -y brainctl mcp
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or edit `~/.codex/config.toml` directly:
|
|
59
65
|
|
|
60
66
|
```toml
|
|
61
67
|
[mcp_servers.brainctl]
|
|
@@ -70,7 +76,13 @@ Restart your Codex session to pick it up.
|
|
|
70
76
|
<details open>
|
|
71
77
|
<summary><b>🔵 Gemini CLI</b> — <code>~/.gemini/settings.json</code></summary>
|
|
72
78
|
|
|
73
|
-
|
|
79
|
+
Easiest: use the `gemini` CLI.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
gemini mcp add -s user brainctl npx -y brainctl mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Or edit `~/.gemini/settings.json` directly (merge into the top-level `mcpServers` object):
|
|
74
86
|
|
|
75
87
|
```json
|
|
76
88
|
{
|
|
@@ -60,6 +60,6 @@ You can add a description to the \`${ws}\` by passing a \`${js}\` component as a
|
|
|
60
60
|
|
|
61
61
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ws}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
62
62
|
|
|
63
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return _.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},Rs=_s,zs=xs,Bs=Cs,Vs=Os,Hs=Ps,Us=Is,Ws=As,Gs=Ms;function Ks({open:e,onOpenChange:t,title:n,description:r,children:i,confirmLabel:a=`Confirm`,cancelLabel:o=`Cancel`,variant:s=`default`,onConfirm:c}){return(0,F.jsx)(Rs,{open:e,onOpenChange:t,children:(0,F.jsxs)(zs,{children:[(0,F.jsx)(Bs,{className:`fixed inset-0 z-50 bg-black/40 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),(0,F.jsxs)(Vs,{className:`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-zinc-200/80 bg-white p-6 shadow-xl`,children:[(0,F.jsx)(Ws,{className:`text-lg font-semibold tracking-tight text-zinc-900`,children:n}),r&&(0,F.jsx)(Gs,{className:`mt-2 text-sm leading-relaxed text-zinc-500`,children:r}),i&&(0,F.jsx)(`div`,{className:`mt-3`,children:i}),(0,F.jsxs)(`div`,{className:`mt-6 flex items-center justify-end gap-3`,children:[(0,F.jsx)(Us,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex min-h-[36px] items-center justify-center rounded-lg border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 shadow-sm transition-all hover:bg-zinc-50 hover:text-zinc-900`,children:o})}),(0,F.jsx)(Hs,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:[`inline-flex min-h-[36px] items-center justify-center rounded-lg px-4 text-sm font-medium shadow-sm transition-all`,s===`danger`?`bg-red-600 text-white hover:bg-red-700`:`bg-zinc-900 text-white hover:bg-zinc-800`].join(` `),onClick:c,children:a})})]})]})]})})}async function qs(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error??`HTTP ${n.status}`)}return n.json()}function Js(e){let t=e.split(`:`);if(t.length<3)return null;let n=t[1];return n!==`mcp`&&n!==`skill`&&n!==`plugin`?null:{agent:t[0],category:n,key:t.slice(2).join(`:`)}}function Ys(e){let t=e.match(/^(\w+):(mcps|skills|plugins|column)(?::anchor)?$/);return t?{agent:t[1],category:t[2]===`mcps`?`mcp`:t[2]===`skills`?`skill`:t[2]===`plugins`?`plugin`:`column`}:null}var Xs={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Zs=e=>{let t=Ht(e);if(t.length===0)return t;let{active:n,droppableContainers:r}=e,i=Js(n.id);if(!i)return t;let a=t[0].id,o=Ys(a);if(o&&o.agent!==i.agent){let e=i.category===`mcp`?`mcps`:i.category===`skill`?`skills`:`plugins`,t=`${o.agent}:${e}:anchor`,n=r.find(e=>e.id===t);if(n)return[{id:t,data:n.data,value:100}]}return t};function Qs({id:e,children:t}){let{setNodeRef:n}=Rr({id:e});return(0,F.jsx)(`div`,{ref:n,className:t?`w-full`:`h-0 w-full`,children:t})}var $s=({activatorEvent:e,draggingNodeRect:t,transform:n})=>{if(e&&t){let r=e,i=r.clientX-t.left,a=r.clientY-t.top;return{...n,x:n.x+i-20,y:n.y+a-20}}return n},ec=0;function tc(){return`change-${++ec}`}function nc(e,t){let n=e.map(e=>({...e,mcpServers:{...e.mcpServers},remoteMcpServers:{...e.remoteMcpServers},skills:[...e.skills]}));for(let e of t){let t=n.find(t=>t.agent===e.agent);t&&(e.category===`mcp`?e.type===`add`&&e.entry?(t.mcpServers[e.key]=e.entry,delete t.remoteMcpServers[e.key]):e.type===`add`&&e.remoteEntry?(t.remoteMcpServers[e.key]=e.remoteEntry,delete t.mcpServers[e.key]):e.type===`remove`&&(delete t.mcpServers[e.key],delete t.remoteMcpServers[e.key]):e.category===`skill`?e.type===`add`&&e.skillEntry?t.skills.some(t=>t.name===e.key)||(t.skills=[...t.skills,e.skillEntry]):e.type===`remove`&&(t.skills=t.skills.filter(t=>t.name!==e.key)):e.category===`plugin`&&(e.type===`add`&&e.pluginEntry?t.skills.some(t=>t.name===e.key&&t.kind===`plugin`)||(t.skills=[...t.skills,e.pluginEntry]):e.type===`remove`&&(t.skills=t.skills.filter(t=>!(t.name===e.key&&t.kind===`plugin`)))))}return n}function rc(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;for(let s of e){if(s.category===`plugin`){let e=s.type===`add`?a:o;e.has(s.agent)||e.set(s.agent,new Set),e.get(s.agent).add(s.key);continue}let e=s.category===`skill`,c=s.type===`add`?e?r:t:e?i:n;c.has(s.agent)||c.set(s.agent,new Set),c.get(s.agent).add(s.key)}return{added:t,removed:n,skillAdded:r,skillRemoved:i,pluginAdded:a,pluginRemoved:o}}function ic({id:e,label:t,sublabel:n,icon:r,status:i,onRemove:a,editable:o}){let{attributes:s,listeners:c,setNodeRef:l,isDragging:u}=Pr({id:e,disabled:!o}),d=i===`added`?` border-emerald-200 bg-emerald-50/50 shadow-[0_0_12px_rgba(16,185,129,0.15)] ring-1 ring-emerald-400/20`:i===`removed`?` border-red-200 bg-red-50 opacity-50 line-through`:` border-zinc-200 bg-white hover:border-zinc-300`,f=o?` cursor-grab active:cursor-grabbing hover:shadow-sm`:``,p=o?{...c,...s}:{};return(0,F.jsx)(`div`,{ref:l,className:`flex items-start gap-3 rounded-xl border p-3 transition-all duration-200 group ${u?`opacity-50`:``}${d}${f}`,...p,children:(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3`,children:[r?(0,F.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-zinc-50 text-zinc-600 transition-colors group-hover:text-zinc-900`,children:r}):null,(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:t}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:n})]}),i&&(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md px-2 py-0.5 text-xs font-medium leading-none ${i===`added`?`bg-zinc-100 text-zinc-700`:`bg-red-100 text-red-700`}`,children:i===`added`?`Added`:`Removed`}),a&&!i&&(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-red-50 hover:text-red-600`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:a,title:`Remove ${t}`,children:(0,F.jsx)(ze,{size:16})})]})})}function ac({label:e,sublabel:t}){return(0,F.jsx)(`div`,{className:`flex items-start gap-3 rounded-xl border border-zinc-200 bg-white p-3 shadow-lg rotate-2`,children:(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3 text-zinc-900`,children:[(0,F.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-zinc-50 text-zinc-600`,children:(0,F.jsx)(we,{size:16})}),(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:e}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:t})]})]})})}function oc({id:e,label:t,sublabel:n,details:r,status:i,onRemove:a,editable:o}){let{attributes:s,listeners:c,setNodeRef:l,isDragging:u}=Pr({id:e,disabled:!o}),[d,f]=(0,_.useState)(!1),p=i===`added`?` border-emerald-200 bg-emerald-50/50 shadow-[0_0_12px_rgba(16,185,129,0.15)] ring-1 ring-emerald-400/20`:i===`removed`?` border-red-200 bg-red-50 opacity-50 line-through`:` border-zinc-200 bg-white hover:border-zinc-300`,m=o?` cursor-grab active:cursor-grabbing hover:shadow-sm`:``,h=(r?.length??0)>0,g=o?{...c,...s}:{};return(0,F.jsxs)(`div`,{ref:l,className:`flex flex-col items-start gap-2 rounded-xl border p-3 transition-all duration-200 group ${u?`opacity-50`:``}${p}${m}`,...g,children:[(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3`,children:[(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:t}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:n})]}),i?(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md px-2 py-0.5 text-xs font-medium leading-none ${i===`added`?`bg-zinc-100 text-zinc-700`:`bg-red-100 text-red-700`}`,children:i===`added`?`Added`:`Removed`}):(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md border border-zinc-200 bg-zinc-50 px-2 py-0.5 text-xs font-medium leading-none text-zinc-600`,children:`Plugin`}),h?(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-zinc-50 hover:text-zinc-900`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:()=>f(e=>!e),title:d?`Collapse ${t}`:`Expand ${t}`,"aria-expanded":d,children:d?(0,F.jsx)(Oe,{size:16}):(0,F.jsx)(ke,{size:16})}):null,a&&!i?(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-red-50 hover:text-red-600`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:a,title:`Remove ${t}`,children:(0,F.jsx)(ze,{size:16})}):null]}),h&&d?(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-2 w-full border-t border-zinc-100 mt-1`,children:r.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border bg-white px-2 py-0.5 text-[11px] font-medium shadow-sm ${e.kind===`mcp`?`border-indigo-200 text-indigo-700`:e.kind===`agent`?`border-amber-200 text-amber-700`:e.kind===`command`?`border-sky-200 text-sky-700`:`border-violet-200 text-violet-700`}`,children:[e.kind===`mcp`&&(0,F.jsx)(Le,{size:10,className:`opacity-70`}),e.kind===`agent`&&(0,F.jsx)(Te,{size:10,className:`opacity-70`}),e.kind===`command`&&(0,F.jsx)(Re,{size:10,className:`opacity-70`}),e.kind===`skill`&&(0,F.jsx)(je,{size:10,className:`opacity-70`}),(0,F.jsx)(`span`,{className:`opacity-80 text-[10px] uppercase tracking-wider`,children:e.kind}),(0,F.jsx)(`span`,{className:`text-zinc-800`,children:e.name})]},`${e.kind}:${e.name}`))}):null]})}function sc({id:e,label:t,icon:n,count:r,children:i}){let{isOver:a,setNodeRef:o}=Rr({id:e}),[s,c]=(0,_.useState)(!0),{active:l,over:u}=Fr();return(0,F.jsxs)(`div`,{ref:o,className:`flex flex-col gap-3 rounded-2xl p-4 transition-all duration-300 ${(()=>{if(!l||!u)return!1;let t=Js(l.id),n=Ys(u.id),r=Ys(e);return!t||!n||!r?!1:t.category===r.category&&n.agent===r.agent})()||a&&!l?`bg-zinc-100 border-2 border-zinc-300 border-dashed shadow-inner`:`bg-zinc-50/50 border border-zinc-200 border-dashed`} ${s?`min-h-[120px]`:`min-h-0 pb-4`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-4 cursor-pointer select-none transition-colors hover:opacity-80 ${s?`border-b border-zinc-200/60 pb-2`:``}`,onClick:()=>c(!s),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-white text-zinc-600`,children:n}),(0,F.jsx)(`p`,{className:`text-xs font-semibold text-zinc-600 m-0`,children:t})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`inline-flex min-w-[28px] items-center justify-center rounded-full border border-zinc-200 bg-white px-2 py-0.5 text-xs font-medium text-zinc-600 shadow-sm`,children:r}),(0,F.jsx)(`span`,{className:`text-zinc-400`,children:s?(0,F.jsx)(Oe,{size:14}):(0,F.jsx)(ke,{size:14})})]})]}),s&&(0,F.jsx)(`div`,{className:`grid gap-2 relative`,children:i})]})}function cc({config:e,pendingAdded:t,pendingRemoved:n,pendingSkillAdded:r,pendingSkillRemoved:i,pendingPluginAdded:a,pendingPluginRemoved:o,onStagedRemove:s,editable:c}){let{setNodeRef:l}=Rr({id:`${e.agent}:column`}),{active:u,over:d}=Fr(),f=(()=>{if(!u||!d)return!1;let t=Js(u.id),n=Ys(d.id);return!t||!n?!1:n.agent===e.agent&&t.agent!==e.agent})(),p=[...Object.entries(e.mcpServers).map(([e,t])=>({key:e,type:`local`,sublabel:t.args&&t.args.length>0?`${t.command} ${t.args.join(` `)}`:t.command})),...Object.entries(e.remoteMcpServers).map(([e,t])=>({key:e,type:`remote`,sublabel:`${t.transport.toUpperCase()} ${t.url}`}))],{skills:m,plugins:h}=$r(e.skills);return(0,F.jsxs)(`div`,{ref:l,className:`flex flex-col gap-4 profile-column-${e.agent} transition-all duration-300 rounded-2xl ${f?`bg-zinc-50 ring-4 ring-zinc-200/50 shadow-inner p-4 -m-4`:``}`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-zinc-100 pb-4`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`grid size-12 place-items-center rounded-xl border border-zinc-200 bg-white text-zinc-900 shadow-sm`,children:(0,F.jsx)(We,{agent:e.agent,className:`size-6 overflow-hidden`})}),(0,F.jsxs)(`div`,{className:`space-y-0.5 overflow-hidden`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold text-zinc-900 m-0`,children:Xs[e.agent]??e.agent}),(0,F.jsx)(`p`,{className:`font-mono text-[10px] text-zinc-400 m-0 break-all`,children:e.configPath})]})]}),(0,F.jsx)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium shadow-sm ${e.exists?`border-zinc-200 bg-zinc-50 text-zinc-700`:`border-zinc-200 bg-zinc-50 text-zinc-400`}`,children:e.exists?`Active`:`Offline`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(Le,{size:14}),` `,p.length,` MCPs`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(je,{size:14}),` `,m.length,` Skills`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(Ee,{size:14}),` `,h.length,` Plugins`]})]}),(0,F.jsxs)(sc,{id:`${e.agent}:skills`,label:`Skills`,icon:(0,F.jsx)(je,{size:16}),count:m.length,children:[m.map((t,n)=>{let a=r.has(t.name)?`added`:i.has(t.name)?`removed`:void 0,o=(0,F.jsx)(ic,{id:`${e.agent}:skill:${t.name}`,label:t.name,sublabel:t.source??`local`,icon:(0,F.jsx)(je,{size:16}),status:a,onRemove:c?()=>s(e.agent,`skill`,t.name):void 0,editable:c},t.name);return n===m.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:skills:anchor`,children:o},t.name):o}),m.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:skills:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No skills installed.`})})]}),(0,F.jsxs)(sc,{id:`${e.agent}:mcps`,label:`MCP Servers`,icon:(0,F.jsx)(Le,{size:16}),count:p.length,children:[p.map(({key:r,sublabel:i,type:a},o)=>{let l=t.has(r)?`added`:n.has(r)?`removed`:void 0,u=(0,F.jsx)(ic,{id:`${e.agent}:mcp:${r}`,label:r,sublabel:a===`remote`?`[remote] ${i}`:i,icon:(0,F.jsx)(Le,{size:16}),status:l,onRemove:c?()=>s(e.agent,`mcp`,r):void 0,editable:c},r);return o===p.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:mcps:anchor`,children:u},r):u}),p.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:mcps:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No MCPs configured.`})})]}),(0,F.jsxs)(sc,{id:`${e.agent}:plugins`,label:`Plugins`,icon:(0,F.jsx)(Ee,{size:16}),count:h.length,children:[h.map((t,n)=>{let r=a.has(t.name)?`added`:o.has(t.name)?`removed`:void 0,i=(0,F.jsx)(oc,{id:`${e.agent}:plugin:${t.name}`,label:t.name,sublabel:ei(t),details:[...(t.pluginSkills??[]).map(e=>({name:e,kind:`skill`})),...(t.pluginMcps??[]).map(e=>({name:e,kind:`mcp`})),...(t.pluginAgents??[]).map(e=>({name:e,kind:`agent`})),...(t.pluginCommands??[]).map(e=>({name:e,kind:`command`}))],status:r,onRemove:c&&(t.managed||(e.agent===`codex`||e.agent===`claude`)&&typeof t.installPath==`string`&&typeof t.source==`string`)?()=>s(e.agent,`plugin`,t.name):void 0,editable:c},t.name);return n===h.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:plugins:anchor`,children:i},t.name):i}),h.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:plugins:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No plugins discovered.`})})]})]})}function lc({changes:e,onUndoChange:t,onDiscardAll:n,onSave:r,saving:i}){return e.length===0?null:(0,F.jsxs)(`div`,{className:`sticky top-6 z-20 grid gap-4 rounded-2xl border border-zinc-200 bg-white p-5 shadow-lg mb-8`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-4 sm:flex-row sm:items-center`,children:[(0,F.jsxs)(`p`,{className:`text-sm font-semibold text-zinc-900 m-0`,children:[e.length,` pending change`,e.length>1?`s`:``]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsxs)(`button`,{className:`inline-flex h-9 items-center gap-2 rounded-xl border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 transition-colors hover:bg-zinc-50 disabled:opacity-50`,onClick:n,disabled:i,children:[(0,F.jsx)(Be,{size:16}),` Discard all`]}),(0,F.jsxs)(`button`,{className:`inline-flex h-9 items-center gap-2 rounded-xl bg-zinc-900 px-5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 shadow-sm`,onClick:r,disabled:i,children:[i?(0,F.jsx)(Me,{size:16,className:`animate-spin`}):(0,F.jsx)(Ie,{size:16}),` `,`Save & apply`]})]})]}),(0,F.jsx)(`div`,{className:`grid gap-2`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border p-3 text-sm font-medium ${e.type===`add`?`border-zinc-200 bg-zinc-50 text-zinc-900`:`border-red-200 bg-red-50 text-red-900`}`,children:[(0,F.jsx)(`span`,{className:`grid size-8 place-items-center shrink-0 rounded-lg ${e.type===`add`?`bg-white border border-zinc-200 text-zinc-600`:`bg-white border border-red-200 text-red-600`}`,children:e.type===`add`?(0,F.jsx)(Pe,{size:16}):(0,F.jsx)(Ve,{size:16})}),(0,F.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[(0,F.jsxs)(`strong`,{className:`text-zinc-900`,children:[`[`,e.category,`] `,e.key]}),e.type===`add`?(0,F.jsxs)(F.Fragment,{children:[` `,`→ `,Xs[e.agent],e.sourceAgent?` (from ${Xs[e.sourceAgent]})`:``]}):(0,F.jsxs)(F.Fragment,{children:[` removed from `,Xs[e.agent]]})]}),(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-white hover:border-zinc-200 hover:text-zinc-900 hover:shadow-sm`,onClick:()=>t(e.id),title:`Undo this change`,disabled:i,children:(0,F.jsx)(Be,{size:14})})]},e.id))})]})}function uc(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(`idle`),g=jt(At(Nn,{activationConstraint:{distance:8}})),v=(0,_.useCallback)((e,t)=>{e===`success`?re.success(t):re.error(t)},[]),y=(0,_.useCallback)(async()=>{try{t(await qs(`/api/agents/live`))}catch(e){v(`error`,`Failed to load agent configs: ${e.message}`)}},[v]),b=(0,_.useCallback)(async()=>{if(m===`loading`)return;h(`loading`),r([]);let e=Date.now();try{await y();let t=Date.now()-e;t<400&&await new Promise(e=>setTimeout(e,400-t)),h(`success`),re.success(`Agent configs refreshed`),setTimeout(()=>{h(e=>e===`success`?`idle`:e)},1200)}catch{h(`idle`)}},[y,m]);(0,_.useEffect)(()=>{(async()=>{await y(),s(!1)})()},[]);let x=nc(e,n),{added:S,removed:C,skillAdded:w,skillRemoved:T,pluginAdded:E,pluginRemoved:ee}=rc(n),D=(0,_.useCallback)((e,t,i)=>{n.some(n=>n.agent===e&&n.category===t&&n.key===i)||r(n=>[...n,{id:tc(),type:`remove`,category:t,agent:e,key:i}])},[n]),O=(0,_.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e))},[]),te=(0,_.useCallback)(()=>{r([])},[]),k=(0,_.useCallback)(()=>{n.length!==0&&p(!0)},[n]),ne=(0,_.useCallback)(async()=>{p(!1);let e=n.length;l(!0);try{let t=await ti(n,async e=>{if(e.category===`mcp`)if(e.type===`add`&&(e.entry||e.remoteEntry))await qs(`/api/agents/${e.agent}/mcps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e.key,entry:e.entry,remoteEntry:e.remoteEntry})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/mcps/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`MCP "${e.key}" is missing the staged metadata needed to apply this change.`);else if(e.category===`skill`)if(e.type===`add`&&e.sourceAgent)await qs(`/api/agents/${e.agent}/skills`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.key,sourceAgent:e.sourceAgent,source:e.skillEntry?.source})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/skills/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`Skill "${e.key}" is missing the staged metadata needed to apply this change.`);else if(e.category===`plugin`)if(e.type===`add`&&e.sourceAgent)await qs(`/api/agents/${e.agent}/plugins`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.key,sourceAgent:e.sourceAgent})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/plugins/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`Plugin "${e.key}" is missing the staged metadata needed to apply this change.`)});r(t.failed.map(e=>e.change)),await y(),t.failed.length>0?v(`error`,`Applied ${t.applied.length}/${e}. ${t.failed[0]?.error} ${t.failed.length} change${t.failed.length>1?`s remain`:` remains`} staged.`):(d(!1),v(`success`,`Applied ${t.applied.length} change${t.applied.length>1?`s`:``}`))}finally{l(!1)}},[n,y,v]),ie=n.map(e=>{let t=e.category===`skill`?`[Skill] `:`[MCP] `;return e.category===`plugin`?e.type===`add`?`+ [Plugin] ${e.key} → ${Xs[e.agent]}`:`- [Plugin] ${e.key} from ${Xs[e.agent]}`:e.type===`add`?`+ ${t}${e.key} → ${Xs[e.agent]}`:`- ${t}${e.key} from ${Xs[e.agent]}`}),ae=(0,_.useCallback)(e=>{u&&a(e.active.id)},[u]),A=(0,_.useCallback)(e=>{if(a(null),!u)return;let{active:t,over:i}=e;if(!i)return;let o=Js(t.id),s=Ys(i.id);if(!o||!s||o.agent===s.agent)return;let c=x.find(e=>e.agent===o.agent);if(c){if(o.category===`mcp`){let e=c.mcpServers[o.key],t=c.remoteMcpServers[o.key];if(!e&&!t||n.some(e=>e.type===`add`&&e.category===`mcp`&&e.agent===s.agent&&e.key===o.key))return;let i={id:tc(),type:`add`,category:`mcp`,agent:s.agent,key:o.key,entry:e,remoteEntry:t,sourceAgent:o.agent},a=Qr(x,i);if(a){v(`error`,a);return}(async()=>{try{let n=(await qs(`/api/agents/${s.agent}/mcps/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:o.key,entry:e,remoteEntry:t})})).checks.find(e=>e.status===`error`);if(n){v(`error`,n.message);return}r(e=>[...e,i])}catch(e){v(`error`,`Failed to validate MCP "${o.key}" before staging: ${e.message}`)}})()}else if(o.category===`skill`){let e=c.skills.find(e=>e.name===o.key);if(!e||n.some(e=>e.type===`add`&&e.category===`skill`&&e.agent===s.agent&&e.key===o.key))return;let t={id:tc(),type:`add`,category:`skill`,agent:s.agent,key:o.key,skillEntry:e,sourceAgent:o.agent},i=Qr(x,t);if(i){v(`error`,i);return}(async()=>{try{let n=(await qs(`/api/agents/${s.agent}/skills/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:o.key,sourceAgent:o.agent,source:e.source})})).checks.find(e=>e.status===`error`);if(n){v(`error`,n.message);return}r(e=>[...e,t])}catch(e){v(`error`,`Failed to validate skill "${o.key}" before staging: ${e.message}`)}})()}else if(o.category===`plugin`){let e=c.skills.find(e=>e.name===o.key&&e.kind===`plugin`);if(!e||n.some(e=>e.type===`add`&&e.category===`plugin`&&e.agent===s.agent&&e.key===o.key))return;let t={id:tc(),type:`add`,category:`plugin`,agent:s.agent,key:o.key,pluginEntry:e,sourceAgent:o.agent},i=Qr(x,t);if(i){v(`error`,i);return}(async()=>{try{let e=(await qs(`/api/agents/${s.agent}/plugins/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:o.key,sourceAgent:o.agent})})).checks.find(e=>e.status===`error`);if(e){v(`error`,e.message);return}r(e=>[...e,t])}catch(e){v(`error`,`Failed to validate plugin "${o.key}" before staging: ${e.message}`)}})()}}},[u,x,n,v]);(0,_.useEffect)(()=>{u||a(null)},[u]);let j=(()=>{if(!i)return null;let e=Js(i);if(!e)return null;let t=x.find(t=>t.agent===e.agent);if(!t)return null;if(e.category===`mcp`){let n=t.mcpServers[e.key];if(n){let t=n.args&&n.args.length>0?`${n.command} ${n.args.join(` `)}`:n.command;return{label:e.key,sublabel:t}}let r=t.remoteMcpServers[e.key];return r?{label:e.key,sublabel:`[remote] ${r.transport.toUpperCase()} ${r.url}`}:null}else if(e.category===`skill`){let n=t.skills.find(t=>t.name===e.key);return n?{label:n.name,sublabel:n.source??`local`}:null}let n=t.skills.find(t=>t.kind===`plugin`&&t.name===e.key);return n?{label:n.name,sublabel:ei(n)}:null})();if(o)return(0,F.jsx)(`div`,{className:`grid gap-4 w-full`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-3 py-8 text-zinc-500 font-medium`,children:[(0,F.jsx)(Me,{size:20,className:`animate-spin text-zinc-400`}),` Loading agent configs...`]})});let M=x.filter(e=>e.exists).length,oe=x.reduce((e,t)=>e+Object.keys(t.mcpServers).length+Object.keys(t.remoteMcpServers).length+$r(t.skills).skills.length+$r(t.skills).plugins.length,0);return(0,F.jsxs)(`div`,{className:`grid gap-4 w-full`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-stretch gap-4 pb-4 border-b border-zinc-200/60 lg:flex-row lg:items-end lg:justify-between`,children:[(0,F.jsxs)(`div`,{className:`grid gap-1`,children:[(0,F.jsx)(`h3`,{className:`text-xl font-semibold tracking-tight text-zinc-900 m-0`,children:`Local agents`}),(0,F.jsx)(`span`,{className:`text-[13px] font-medium text-zinc-500`,children:`Drag skills, MCPs, and plugins across columns.`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(we,{size:12,className:`text-zinc-400`}),` `,M,` agents`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(Ee,{size:12,className:`text-zinc-400`}),` `,oe,` items`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(Ie,{size:12,className:`text-zinc-400`}),` `,n.length,` staged`]}),(0,F.jsxs)(`button`,{className:`inline-flex h-8 items-center gap-2 rounded-lg px-3 text-[13px] font-medium transition-all disabled:opacity-50 ${u?`bg-zinc-900 text-white shadow-sm`:`border border-zinc-200 bg-white text-zinc-700 shadow-sm hover:bg-zinc-50`}`,type:`button`,onClick:()=>d(e=>!e),disabled:c,children:[u?(0,F.jsx)(De,{size:14}):(0,F.jsx)(Ne,{size:14}),u?`Done editing`:`Edit items`]}),(0,F.jsx)(`button`,{className:[`inline-flex h-8 items-center gap-2 rounded-lg border px-3 text-[13px] font-medium shadow-sm transition-all duration-200 disabled:opacity-50`,m===`success`?`border-emerald-300 bg-emerald-50 text-emerald-700`:m===`loading`?`border-zinc-300 bg-zinc-100 text-zinc-700`:`border-zinc-200 bg-white text-zinc-700 hover:bg-zinc-50`].join(` `),onClick:()=>void b(),disabled:c||m===`loading`,children:m===`loading`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Me,{size:12,className:`animate-spin`}),` Refreshing`]}):m===`success`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(De,{size:12,className:`animate-[ping_400ms_ease-out_1]`}),` Up to date`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Fe,{size:12}),` Refresh`]})})]})]}),(0,F.jsx)(lc,{changes:n,onUndoChange:O,onDiscardAll:te,onSave:k,saving:c}),(0,F.jsxs)(Ar,{sensors:g,collisionDetection:Zs,onDragStart:ae,onDragEnd:A,children:[(0,F.jsx)(`div`,{className:`grid grid-cols-1 items-start lg:grid-cols-3 w-full`,children:x.map((e,t)=>(0,F.jsx)(`div`,{className:`py-10 lg:py-0 lg:px-10 ${t===0?``:`border-t border-zinc-200 lg:border-t-0 lg:border-l`} ${t===0?`lg:pl-0 lg:pr-10 pt-0`:``} ${t===x.length-1?`lg:pr-0 lg:pl-10 pb-0`:``}`,children:(0,F.jsx)(cc,{config:e,pendingAdded:S.get(e.agent)??new Set,pendingRemoved:C.get(e.agent)??new Set,pendingSkillAdded:w.get(e.agent)??new Set,pendingSkillRemoved:T.get(e.agent)??new Set,pendingPluginAdded:E.get(e.agent)??new Set,pendingPluginRemoved:ee.get(e.agent)??new Set,onStagedRemove:D,editable:u})},e.agent))}),(0,F.jsx)(Xr,{modifiers:[$s],children:j?(0,F.jsx)(ac,{label:j.label,sublabel:j.sublabel}):null})]}),(0,F.jsx)(Ks,{open:f,onOpenChange:p,title:`Apply ${n.length} change${n.length>1?`s`:``}?`,description:`The following changes will be written to agent config files:`,confirmLabel:`Apply changes`,cancelLabel:`Cancel`,variant:`default`,onConfirm:()=>void ne(),children:(0,F.jsx)(`div`,{className:`mt-4 rounded-xl border border-zinc-200 bg-zinc-50 p-4 max-h-64 overflow-y-auto`,children:(0,F.jsx)(`ul`,{className:`space-y-2 font-mono text-xs font-medium text-zinc-700`,children:ie.map((e,t)=>(0,F.jsx)(`li`,{className:e.startsWith(`+`)?`text-zinc-900`:`text-zinc-500 line-through`,children:e},t))})})})]})}async function dc(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error??`HTTP ${n.status}`)}return n.json()}function fc({icon:e,label:t,active:n,onClick:r,disabled:i,tooltip:a}){return(0,F.jsxs)(`div`,{className:`relative group`,children:[(0,F.jsxs)(`button`,{className:[`inline-flex h-9 items-center gap-2 rounded-xl px-4 text-sm font-medium transition-all duration-200`,i?`cursor-not-allowed border border-zinc-200 bg-white/60 text-zinc-400`:n?`bg-zinc-900 text-white shadow-sm`:`border border-zinc-200 bg-white text-zinc-700 shadow-sm hover:bg-zinc-50 hover:text-zinc-900`].join(` `),type:`button`,onClick:i?void 0:r,disabled:i,"aria-disabled":i,children:[e,(0,F.jsx)(`span`,{children:t})]}),i&&a?(0,F.jsx)(`span`,{className:`pointer-events-none absolute left-1/2 top-full z-20 mt-2 -translate-x-1/2 whitespace-nowrap rounded-md bg-zinc-900 px-2.5 py-1.5 text-[11px] font-medium text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100`,children:a}):null]})}function pc({tone:e,children:t}){return(0,F.jsxs)(`div`,{className:[`flex items-start gap-3 rounded-xl border px-4 py-3 text-sm transition-all`,e===`success`?`border-zinc-200 bg-zinc-50 text-zinc-800`:`border-red-200 bg-red-50 text-red-800`].join(` `),children:[(0,F.jsx)(`div`,{className:`mt-1`,children:e===`success`?(0,F.jsx)(`div`,{className:`size-2 rounded-full bg-zinc-500`}):(0,F.jsx)(`div`,{className:`size-2 rounded-full bg-red-500`})}),(0,F.jsx)(`div`,{className:`leading-relaxed`,children:t})]})}function mc({title:e,description:t,onClose:n,children:r}){return(0,F.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm lg:p-8 mb-8`,children:[(0,F.jsxs)(`div`,{className:`mb-8 flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-zinc-900`,children:e}),(0,F.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-zinc-500`,children:t})]}),(0,F.jsx)(`button`,{className:`inline-flex size-8 items-center justify-center rounded-full text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700`,type:`button`,onClick:n,children:(0,F.jsx)(Ve,{size:18})})]}),r]})}function hc(){let e=[`claude`,`codex`,`gemini`],[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(`profile`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`claude`),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),[te,k]=(0,_.useState)([]),[ne,re]=(0,_.useState)(``),[ie,ae]=(0,_.useState)(``),[A,j]=(0,_.useState)(!1),[M,oe]=(0,_.useState)(!1),[se,ce]=(0,_.useState)(null),[N,P]=(0,_.useState)(null);(0,_.useEffect)(()=>{le()},[]),(0,_.useEffect)(()=>{t===`pack`&&fe()},[t,l,d,p]);async function le(){c(!0);try{let e=await dc(`/api/profiles`);i(e.profiles),o(e.activeProfile),f(t=>t||e.activeProfile||e.profiles[0]||``)}catch{}finally{c(!1)}}async function ue(){if(l===`profile`&&!d){C(`Choose a profile to export.`);return}y(!0),C(null),x(null);try{x(`Packed to ${(await dc(`/api/profiles/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({source:l===`profile`?{source:`profile`,name:d}:{source:`agent`,agent:p},name:l===`profile`?d:void 0,agent:l===`agent`?p:void 0,outputPath:h.trim()||void 0})})).archivePath}`)}catch(e){C(e.message)}finally{y(!1)}}async function de(){if(!ne.trim()){P(`Enter a profile archive path.`);return}let e;if(ie.trim())try{let t=JSON.parse(ie);e=Object.fromEntries(Object.entries(t).map(([e,t])=>{if(typeof t!=`string`||t.trim().length===0)throw Error(`Credential "${e}" must be a non-empty string.`);return[e,t]}))}catch(e){P(e instanceof Error?e.message:`Credential map must be valid JSON with string values.`);return}oe(!0),P(null),ce(null);try{let t=await dc(`/api/profiles/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({archivePath:ne.trim(),force:A,credentials:e})}),n=t.installedMcps.length>0?` Installed bundled MCPs: ${t.installedMcps.join(`, `)}.`:``;ce(`Installed profile "${t.profileName}".${n}`),await le()}catch(e){P(e.message)}finally{oe(!1)}}async function fe(){T(!0),ee(null);try{if(l===`profile`){if(!d){O(null);return}O(await dc(`/api/profiles/${encodeURIComponent(d)}`));return}k(await dc(`/api/agents/live`))}catch(e){ee(e.message),l===`profile`&&O(null)}finally{T(!1)}}let pe=l===`profile`?`Pack profile`:`Pack agent config`,me=l===`profile`?`Export a saved Brainctl profile into a portable tarball.`:`Export a live agent config into a portable tarball.`,he=te.find(e=>e.agent===p)??null,ge=(he?.skills??[]).filter(e=>e.kind!==`plugin`),_e=(he?.skills??[]).filter(e=>e.kind===`plugin`),ve=l===`profile`?Object.entries(D?.mcps??{}):[...Object.entries(he?.mcpServers??{}).map(([e,t])=>[e,{label:t.command,kind:`local`}]),...Object.entries(he?.remoteMcpServers??{}).map(([e,t])=>[e,{label:`${t.transport} ${t.url}`,kind:`remote`}])],ye=l===`profile`?Object.entries(D?.skills??{}).map(([e,t])=>({key:e,label:t.description??`Skill`})):ge.map(e=>({key:e.name,label:e.source??`Skill`}));return l===`agent`&&_e.map(e=>({key:e.name,label:e.source?`Plugin · ${e.source}`:`Plugin`})),(0,F.jsx)(`main`,{className:`min-h-screen bg-[#fcfcfc] p-4 lg:p-6 text-zinc-900`,children:(0,F.jsxs)(`div`,{className:`mx-auto grid w-full gap-4`,children:[(0,F.jsxs)(`header`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-7 place-items-center rounded-lg bg-zinc-900 text-white shadow-sm`,children:(0,F.jsx)(`img`,{src:`/favicon-light.svg`,alt:`Brainctl Logo`,className:`size-3.5`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold tracking-tight leading-none`,children:`Brainctl`}),(0,F.jsx)(`p`,{className:`text-[9px] font-medium text-zinc-500 leading-tight`,children:`Transfer Board`})]})]}),(0,F.jsx)(`div`,{className:`hidden lg:flex items-center gap-1.5`,children:[`claude`,`codex`,`gemini`].map(e=>(0,F.jsxs)(`span`,{className:`inline-flex h-8 items-center gap-1.5 rounded-xl flex-none border border-zinc-200 bg-white px-3 text-[10px] font-medium text-zinc-600 shadow-sm`,children:[(0,F.jsx)(`span`,{className:`grid size-3.5 place-items-center overflow-hidden text-zinc-900`,children:(0,F.jsx)(We,{agent:e,className:`size-full object-contain`})}),e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(fc,{icon:(0,F.jsx)(Ee,{size:12}),label:`Pack`,active:t===`pack`,onClick:()=>{n(e=>e===`pack`?null:`pack`),C(null),x(null)},disabled:!0,tooltip:`Coming soon — still grinding on portable packs`}),(0,F.jsx)(fc,{icon:(0,F.jsx)(Ae,{size:16}),label:`Install`,active:t===`install`,onClick:()=>{n(e=>e===`install`?null:`install`),P(null),ce(null)},disabled:!0,tooltip:`Coming soon — portable install flow under construction`})]})]}),(0,F.jsxs)(`div`,{className:`w-full`,children:[t===`pack`?(0,F.jsxs)(mc,{title:pe,description:me,onClose:()=>n(null),children:[(0,F.jsxs)(`div`,{className:`grid gap-10 lg:grid-cols-[1fr_1.2fr]`,children:[(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Pack source`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:l,onChange:e=>u(e.target.value),disabled:v,children:[(0,F.jsx)(`option`,{value:`profile`,children:`Saved profile`}),(0,F.jsx)(`option`,{value:`agent`,children:`Live agent config`})]}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}),l===`profile`?(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Profile to export`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:d,onChange:e=>f(e.target.value),disabled:s||r.length===0||v,children:[r.length===0?(0,F.jsx)(`option`,{value:``,children:`No profiles found`}):null,r.map(e=>(0,F.jsxs)(`option`,{value:e,children:[e,e===a?` (active)`:``]},e))]}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}):(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Agent to pack`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:p,onChange:e=>m(e.target.value),disabled:v,children:e.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}),(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-sm font-medium text-zinc-700`,children:[`Output path `,(0,F.jsx)(`span`,{className:`text-zinc-400`,children:`(optional)`})]}),(0,F.jsx)(`input`,{className:`h-10 w-full rounded-xl border border-zinc-200 bg-white px-3 text-sm outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400 disabled:opacity-50`,placeholder:`./my-profile.tar.gz`,value:h,onChange:e=>g(e.target.value),disabled:v})]}),(0,F.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,F.jsxs)(`button`,{className:`inline-flex h-10 items-center justify-center gap-2 rounded-xl bg-zinc-900 px-6 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50`,type:`button`,onClick:()=>void ue(),disabled:v||l===`profile`&&r.length===0,children:[v?(0,F.jsx)(Me,{size:16,className:`animate-spin`}):(0,F.jsx)(Ee,{size:16}),`Pack tarball`]}),(0,F.jsx)(`button`,{className:`inline-flex h-10 items-center justify-center rounded-xl border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 transition-colors hover:bg-zinc-50 disabled:opacity-50`,type:`button`,onClick:()=>void le(),disabled:v,children:`Refresh`})]})]}),(0,F.jsxs)(`div`,{className:`rounded-2xl border border-zinc-200 bg-zinc-50/50 p-6`,children:[(0,F.jsx)(`p`,{className:`mb-4 text-xs font-medium text-zinc-500`,children:`Preview`}),(0,F.jsxs)(`div`,{className:`grid gap-4`,children:[w?(0,F.jsx)(`span`,{className:`text-sm text-zinc-500`,children:`Loading...`}):null,E?(0,F.jsx)(`span`,{className:`text-sm text-red-600`,children:E}):null,!w&&!E?(0,F.jsxs)(`div`,{className:`grid gap-4 text-sm text-zinc-900`,children:[(0,F.jsx)(`div`,{className:`grid gap-1 rounded-xl border border-zinc-200 bg-white p-4`,children:l===`profile`&&D?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:D.name}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(D.skills).length,` skills`]}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(D.mcps).length,` MCPs`]})]}):l===`agent`&&he?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:he.agent}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(he.mcpServers).length+Object.keys(he.remoteMcpServers).length,` MCPs`]}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[ge.length,` skills`]})]}):(0,F.jsx)(`span`,{className:`text-zinc-500`,children:`No preview available`})}),ve.length>0&&(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-zinc-200 bg-white p-4`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium text-zinc-500`,children:`MCPs`}),ve.map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 py-1`,children:[(0,F.jsx)(`span`,{className:`font-medium text-zinc-900`,children:e}),`label`in t?(0,F.jsx)(`span`,{className:`text-xs text-zinc-500 truncate`,children:t.label}):null]},e))]}),ye.length>0&&(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-zinc-200 bg-white p-4`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium text-zinc-500`,children:`Skills`}),ye.map(e=>(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 py-1`,children:[(0,F.jsx)(`span`,{className:`font-medium text-zinc-900`,children:e.key}),(0,F.jsx)(`span`,{className:`text-xs text-zinc-500 truncate`,children:e.label})]},e.key))]})]}):null]})]})]}),(b||S)&&(0,F.jsxs)(`div`,{className:`mt-8 grid gap-3`,children:[b?(0,F.jsx)(pc,{tone:`success`,children:b}):null,S?(0,F.jsx)(pc,{tone:`error`,children:S}):null]})]}):null,t===`install`?(0,F.jsxs)(mc,{title:`Install profile`,description:`Import a packed archive and unpack bundled MCPs into the local store.`,onClose:()=>n(null),children:[(0,F.jsxs)(`div`,{className:`grid gap-10 lg:grid-cols-[1fr_1.2fr]`,children:[(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Archive path`}),(0,F.jsx)(`input`,{className:`h-10 w-full rounded-xl border border-zinc-200 bg-white px-3 text-sm outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400 disabled:opacity-50`,placeholder:`/path/to/profile.tar.gz`,value:ne,onChange:e=>re(e.target.value),disabled:M})]}),(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Credentials JSON`}),(0,F.jsx)(`textarea`,{className:`min-h-[120px] w-full rounded-xl border border-zinc-200 bg-white p-3 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50 font-mono text-zinc-700`,placeholder:`{
|
|
63
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return _.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},Rs=_s,zs=xs,Bs=Cs,Vs=Os,Hs=Ps,Us=Is,Ws=As,Gs=Ms;function Ks({open:e,onOpenChange:t,title:n,description:r,children:i,confirmLabel:a=`Confirm`,cancelLabel:o=`Cancel`,variant:s=`default`,onConfirm:c}){return(0,F.jsx)(Rs,{open:e,onOpenChange:t,children:(0,F.jsxs)(zs,{children:[(0,F.jsx)(Bs,{className:`fixed inset-0 z-50 bg-black/40 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),(0,F.jsxs)(Vs,{className:`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-zinc-200/80 bg-white p-6 shadow-xl`,children:[(0,F.jsx)(Ws,{className:`text-lg font-semibold tracking-tight text-zinc-900`,children:n}),r&&(0,F.jsx)(Gs,{className:`mt-2 text-sm leading-relaxed text-zinc-500`,children:r}),i&&(0,F.jsx)(`div`,{className:`mt-3`,children:i}),(0,F.jsxs)(`div`,{className:`mt-6 flex items-center justify-end gap-3`,children:[(0,F.jsx)(Us,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex min-h-[36px] items-center justify-center rounded-lg border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 shadow-sm transition-all hover:bg-zinc-50 hover:text-zinc-900`,children:o})}),(0,F.jsx)(Hs,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:[`inline-flex min-h-[36px] items-center justify-center rounded-lg px-4 text-sm font-medium shadow-sm transition-all`,s===`danger`?`bg-red-600 text-white hover:bg-red-700`:`bg-zinc-900 text-white hover:bg-zinc-800`].join(` `),onClick:c,children:a})})]})]})]})})}async function qs(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error??`HTTP ${n.status}`)}return n.json()}function Js(e){let t=e.split(`:`);if(t.length<3)return null;let n=t[1];return n!==`mcp`&&n!==`skill`&&n!==`plugin`?null:{agent:t[0],category:n,key:t.slice(2).join(`:`)}}function Ys(e){let t=e.match(/^(\w+):(mcps|skills|plugins|column)(?::anchor)?$/);return t?{agent:t[1],category:t[2]===`mcps`?`mcp`:t[2]===`skills`?`skill`:t[2]===`plugins`?`plugin`:`column`}:null}var Xs={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Zs=e=>{let t=Ht(e);if(t.length===0)return t;let{active:n,droppableContainers:r}=e,i=Js(n.id);if(!i)return t;let a=t[0].id,o=Ys(a);if(o&&o.agent!==i.agent){let e=i.category===`mcp`?`mcps`:i.category===`skill`?`skills`:`plugins`,t=`${o.agent}:${e}:anchor`,n=r.find(e=>e.id===t);if(n)return[{id:t,data:n.data,value:100}]}return t};function Qs({id:e,children:t}){let{setNodeRef:n}=Rr({id:e});return(0,F.jsx)(`div`,{ref:n,className:t?`w-full`:`h-0 w-full`,children:t})}var $s=({activatorEvent:e,draggingNodeRect:t,transform:n})=>{if(e&&t){let r=e,i=r.clientX-t.left,a=r.clientY-t.top;return{...n,x:n.x+i-20,y:n.y+a-20}}return n},ec=0;function tc(){return`change-${++ec}`}function nc(e,t){let n=e.map(e=>({...e,mcpServers:{...e.mcpServers},remoteMcpServers:{...e.remoteMcpServers},skills:[...e.skills]}));for(let e of t){let t=n.find(t=>t.agent===e.agent);t&&(e.category===`mcp`?e.type===`add`&&e.entry?(t.mcpServers[e.key]=e.entry,delete t.remoteMcpServers[e.key]):e.type===`add`&&e.remoteEntry?(t.remoteMcpServers[e.key]=e.remoteEntry,delete t.mcpServers[e.key]):e.type===`remove`&&(delete t.mcpServers[e.key],delete t.remoteMcpServers[e.key]):e.category===`skill`?e.type===`add`&&e.skillEntry?t.skills.some(t=>t.name===e.key)||(t.skills=[...t.skills,e.skillEntry]):e.type===`remove`&&(t.skills=t.skills.filter(t=>t.name!==e.key)):e.category===`plugin`&&(e.type===`add`&&e.pluginEntry?t.skills.some(t=>t.name===e.key&&t.kind===`plugin`)||(t.skills=[...t.skills,e.pluginEntry]):e.type===`remove`&&(t.skills=t.skills.filter(t=>!(t.name===e.key&&t.kind===`plugin`)))))}return n}function rc(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;for(let s of e){if(s.category===`plugin`){let e=s.type===`add`?a:o;e.has(s.agent)||e.set(s.agent,new Set),e.get(s.agent).add(s.key);continue}let e=s.category===`skill`,c=s.type===`add`?e?r:t:e?i:n;c.has(s.agent)||c.set(s.agent,new Set),c.get(s.agent).add(s.key)}return{added:t,removed:n,skillAdded:r,skillRemoved:i,pluginAdded:a,pluginRemoved:o}}function ic({id:e,label:t,sublabel:n,icon:r,status:i,onRemove:a,editable:o}){let{attributes:s,listeners:c,setNodeRef:l,isDragging:u}=Pr({id:e,disabled:!o}),d=i===`added`?` border-emerald-200 bg-emerald-50/50 shadow-[0_0_12px_rgba(16,185,129,0.15)] ring-1 ring-emerald-400/20`:i===`removed`?` border-red-200 bg-red-50 opacity-50 line-through`:` border-zinc-200 bg-white hover:border-zinc-300`,f=o?` cursor-grab active:cursor-grabbing hover:shadow-sm`:``,p=o?{...c,...s}:{};return(0,F.jsx)(`div`,{ref:l,className:`flex items-start gap-3 rounded-xl border p-3 transition-all duration-200 group ${u?`opacity-50`:``}${d}${f}`,...p,children:(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3`,children:[r?(0,F.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-zinc-50 text-zinc-600 transition-colors group-hover:text-zinc-900`,children:r}):null,(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:t}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:n})]}),i&&(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md px-2 py-0.5 text-xs font-medium leading-none ${i===`added`?`bg-zinc-100 text-zinc-700`:`bg-red-100 text-red-700`}`,children:i===`added`?`Added`:`Removed`}),a&&!i&&(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-red-50 hover:text-red-600`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:a,title:`Remove ${t}`,children:(0,F.jsx)(ze,{size:16})})]})})}function ac({label:e,sublabel:t}){return(0,F.jsx)(`div`,{className:`flex items-start gap-3 rounded-xl border border-zinc-200 bg-white p-3 shadow-lg rotate-2`,children:(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3 text-zinc-900`,children:[(0,F.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-zinc-50 text-zinc-600`,children:(0,F.jsx)(we,{size:16})}),(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:e}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:t})]})]})})}function oc({id:e,label:t,sublabel:n,details:r,status:i,onRemove:a,editable:o}){let{attributes:s,listeners:c,setNodeRef:l,isDragging:u}=Pr({id:e,disabled:!o}),[d,f]=(0,_.useState)(!1),p=i===`added`?` border-emerald-200 bg-emerald-50/50 shadow-[0_0_12px_rgba(16,185,129,0.15)] ring-1 ring-emerald-400/20`:i===`removed`?` border-red-200 bg-red-50 opacity-50 line-through`:` border-zinc-200 bg-white hover:border-zinc-300`,m=o?` cursor-grab active:cursor-grabbing hover:shadow-sm`:``,h=(r?.length??0)>0,g=o?{...c,...s}:{};return(0,F.jsxs)(`div`,{ref:l,className:`flex flex-col items-start gap-2 rounded-xl border p-3 transition-all duration-200 group ${u?`opacity-50`:``}${p}${m}`,...g,children:[(0,F.jsxs)(`div`,{className:`flex w-full items-start gap-3`,children:[(0,F.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,F.jsx)(`strong`,{className:`truncate text-sm font-semibold text-zinc-900`,children:t}),(0,F.jsx)(`span`,{className:`truncate text-xs text-zinc-500`,children:n})]}),i?(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md px-2 py-0.5 text-xs font-medium leading-none ${i===`added`?`bg-zinc-100 text-zinc-700`:`bg-red-100 text-red-700`}`,children:i===`added`?`Added`:`Removed`}):(0,F.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-md border border-zinc-200 bg-zinc-50 px-2 py-0.5 text-xs font-medium leading-none text-zinc-600`,children:`Plugin`}),h?(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-zinc-50 hover:text-zinc-900`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:()=>f(e=>!e),title:d?`Collapse ${t}`:`Expand ${t}`,"aria-expanded":d,children:d?(0,F.jsx)(Oe,{size:16}):(0,F.jsx)(ke,{size:16})}):null,a&&!i?(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-red-50 hover:text-red-600`,type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:a,title:`Remove ${t}`,children:(0,F.jsx)(ze,{size:16})}):null]}),h&&d?(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-2 w-full border-t border-zinc-100 mt-1`,children:r.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border bg-white px-2 py-0.5 text-[11px] font-medium shadow-sm ${e.kind===`mcp`?`border-indigo-200 text-indigo-700`:e.kind===`agent`?`border-amber-200 text-amber-700`:e.kind===`command`?`border-sky-200 text-sky-700`:`border-violet-200 text-violet-700`}`,children:[e.kind===`mcp`&&(0,F.jsx)(Le,{size:10,className:`opacity-70`}),e.kind===`agent`&&(0,F.jsx)(Te,{size:10,className:`opacity-70`}),e.kind===`command`&&(0,F.jsx)(Re,{size:10,className:`opacity-70`}),e.kind===`skill`&&(0,F.jsx)(je,{size:10,className:`opacity-70`}),(0,F.jsx)(`span`,{className:`opacity-80 text-[10px] uppercase tracking-wider`,children:e.kind}),(0,F.jsx)(`span`,{className:`text-zinc-800`,children:e.name})]},`${e.kind}:${e.name}`))}):null]})}function sc({id:e,label:t,icon:n,count:r,children:i}){let{isOver:a,setNodeRef:o}=Rr({id:e}),[s,c]=(0,_.useState)(!0),{active:l,over:u}=Fr();return(0,F.jsxs)(`div`,{ref:o,className:`flex flex-col gap-3 rounded-2xl p-4 transition-all duration-300 ${(()=>{if(!l||!u)return!1;let t=Js(l.id),n=Ys(u.id),r=Ys(e);return!t||!n||!r?!1:t.category===r.category&&n.agent===r.agent})()||a&&!l?`bg-zinc-100 border-2 border-zinc-300 border-dashed shadow-inner`:`bg-zinc-50/50 border border-zinc-200 border-dashed`} ${s?`min-h-[120px]`:`min-h-0 pb-4`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-4 cursor-pointer select-none transition-colors hover:opacity-80 ${s?`border-b border-zinc-200/60 pb-2`:``}`,onClick:()=>c(!s),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg border border-zinc-200 bg-white text-zinc-600`,children:n}),(0,F.jsx)(`p`,{className:`text-xs font-semibold text-zinc-600 m-0`,children:t})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`inline-flex min-w-[28px] items-center justify-center rounded-full border border-zinc-200 bg-white px-2 py-0.5 text-xs font-medium text-zinc-600 shadow-sm`,children:r}),(0,F.jsx)(`span`,{className:`text-zinc-400`,children:s?(0,F.jsx)(Oe,{size:14}):(0,F.jsx)(ke,{size:14})})]})]}),s&&(0,F.jsx)(`div`,{className:`grid gap-2 relative`,children:i})]})}function cc({config:e,pendingAdded:t,pendingRemoved:n,pendingSkillAdded:r,pendingSkillRemoved:i,pendingPluginAdded:a,pendingPluginRemoved:o,onStagedRemove:s,editable:c}){let{setNodeRef:l}=Rr({id:`${e.agent}:column`}),{active:u,over:d}=Fr(),f=(()=>{if(!u||!d)return!1;let t=Js(u.id),n=Ys(d.id);return!t||!n?!1:n.agent===e.agent&&t.agent!==e.agent})(),p=[...Object.entries(e.mcpServers).map(([e,t])=>({key:e,type:`local`,sublabel:t.args&&t.args.length>0?`${t.command} ${t.args.join(` `)}`:t.command})),...Object.entries(e.remoteMcpServers).map(([e,t])=>({key:e,type:`remote`,sublabel:`${t.transport.toUpperCase()} ${t.url}`}))],{skills:m,plugins:h}=$r(e.skills);return(0,F.jsxs)(`div`,{ref:l,className:`flex flex-col gap-4 profile-column-${e.agent} transition-all duration-300 rounded-2xl ${f?`bg-zinc-50 ring-4 ring-zinc-200/50 shadow-inner p-4 -m-4`:``}`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-zinc-100 pb-4`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`grid size-12 place-items-center rounded-xl border border-zinc-200 bg-white text-zinc-900 shadow-sm`,children:(0,F.jsx)(We,{agent:e.agent,className:`size-6 overflow-hidden`})}),(0,F.jsxs)(`div`,{className:`space-y-0.5 overflow-hidden`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold text-zinc-900 m-0`,children:Xs[e.agent]??e.agent}),(0,F.jsx)(`p`,{className:`font-mono text-[10px] text-zinc-400 m-0 break-all`,children:e.configPath})]})]}),(0,F.jsx)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium shadow-sm ${e.exists?`border-zinc-200 bg-zinc-50 text-zinc-700`:`border-zinc-200 bg-zinc-50 text-zinc-400`}`,children:e.exists?`Active`:`Offline`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(Le,{size:14}),` `,p.length,` MCPs`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(je,{size:14}),` `,m.length,` Skills`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs font-medium text-zinc-600`,children:[(0,F.jsx)(Ee,{size:14}),` `,h.length,` Plugins`]})]}),(0,F.jsxs)(sc,{id:`${e.agent}:skills`,label:`Skills`,icon:(0,F.jsx)(je,{size:16}),count:m.length,children:[m.map((t,n)=>{let a=r.has(t.name)?`added`:i.has(t.name)?`removed`:void 0,o=(0,F.jsx)(ic,{id:`${e.agent}:skill:${t.name}`,label:t.name,sublabel:t.source??`local`,icon:(0,F.jsx)(je,{size:16}),status:a,onRemove:c?()=>s(e.agent,`skill`,t.name):void 0,editable:c},t.name);return n===m.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:skills:anchor`,children:o},t.name):o}),m.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:skills:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No skills installed.`})})]}),(0,F.jsxs)(sc,{id:`${e.agent}:mcps`,label:`MCP Servers`,icon:(0,F.jsx)(Le,{size:16}),count:p.length,children:[p.map(({key:r,sublabel:i,type:a},o)=>{let l=t.has(r)?`added`:n.has(r)?`removed`:void 0,u=(0,F.jsx)(ic,{id:`${e.agent}:mcp:${r}`,label:r,sublabel:a===`remote`?`[remote] ${i}`:i,icon:(0,F.jsx)(Le,{size:16}),status:l,onRemove:c?()=>s(e.agent,`mcp`,r):void 0,editable:c},r);return o===p.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:mcps:anchor`,children:u},r):u}),p.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:mcps:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No MCPs configured.`})})]}),(0,F.jsxs)(sc,{id:`${e.agent}:plugins`,label:`Plugins`,icon:(0,F.jsx)(Ee,{size:16}),count:h.length,children:[h.map((t,n)=>{let r=a.has(t.name)?`added`:o.has(t.name)?`removed`:void 0,i=(0,F.jsx)(oc,{id:`${e.agent}:plugin:${t.name}`,label:t.name,sublabel:ei(t),details:[...(t.pluginSkills??[]).map(e=>({name:e,kind:`skill`})),...(t.pluginMcps??[]).map(e=>({name:e,kind:`mcp`})),...(t.pluginAgents??[]).map(e=>({name:e,kind:`agent`})),...(t.pluginCommands??[]).map(e=>({name:e,kind:`command`}))],status:r,onRemove:c&&(t.managed||(e.agent===`codex`||e.agent===`claude`)&&typeof t.installPath==`string`&&typeof t.source==`string`)?()=>s(e.agent,`plugin`,t.name):void 0,editable:c},t.name);return n===h.length-1?(0,F.jsx)(Qs,{id:`${e.agent}:plugins:anchor`,children:i},t.name):i}),h.length===0&&(0,F.jsx)(Qs,{id:`${e.agent}:plugins:anchor`,children:(0,F.jsx)(`p`,{className:`text-sm font-medium text-zinc-400 m-3`,children:`No plugins discovered.`})})]})]})}function lc({changes:e,onUndoChange:t,onDiscardAll:n,onSave:r,saving:i}){return e.length===0?null:(0,F.jsxs)(`div`,{className:`sticky top-6 z-20 grid gap-4 rounded-2xl border border-zinc-200 bg-white p-5 shadow-lg mb-8`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-4 sm:flex-row sm:items-center`,children:[(0,F.jsxs)(`p`,{className:`text-sm font-semibold text-zinc-900 m-0`,children:[e.length,` pending change`,e.length>1?`s`:``]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsxs)(`button`,{className:`inline-flex h-9 items-center gap-2 rounded-xl border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 transition-colors hover:bg-zinc-50 disabled:opacity-50`,onClick:n,disabled:i,children:[(0,F.jsx)(Be,{size:16}),` Discard all`]}),(0,F.jsxs)(`button`,{className:`inline-flex h-9 items-center gap-2 rounded-xl bg-zinc-900 px-5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 shadow-sm`,onClick:r,disabled:i,children:[i?(0,F.jsx)(Me,{size:16,className:`animate-spin`}):(0,F.jsx)(Ie,{size:16}),` `,`Save & apply`]})]})]}),(0,F.jsx)(`div`,{className:`grid gap-2`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border p-3 text-sm font-medium ${e.type===`add`?`border-zinc-200 bg-zinc-50 text-zinc-900`:`border-red-200 bg-red-50 text-red-900`}`,children:[(0,F.jsx)(`span`,{className:`grid size-8 place-items-center shrink-0 rounded-lg ${e.type===`add`?`bg-white border border-zinc-200 text-zinc-600`:`bg-white border border-red-200 text-red-600`}`,children:e.type===`add`?(0,F.jsx)(Pe,{size:16}):(0,F.jsx)(Ve,{size:16})}),(0,F.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[(0,F.jsxs)(`strong`,{className:`text-zinc-900`,children:[`[`,e.category,`] `,e.key]}),e.type===`add`?(0,F.jsxs)(F.Fragment,{children:[` `,`→ `,Xs[e.agent],e.sourceAgent?` (from ${Xs[e.sourceAgent]})`:``]}):(0,F.jsxs)(F.Fragment,{children:[` removed from `,Xs[e.agent]]})]}),(0,F.jsx)(`button`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border border-transparent text-zinc-400 transition-colors hover:bg-white hover:border-zinc-200 hover:text-zinc-900 hover:shadow-sm`,onClick:()=>t(e.id),title:`Undo this change`,disabled:i,children:(0,F.jsx)(Be,{size:14})})]},e.id))})]})}function uc(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(`idle`),g=jt(At(Nn,{activationConstraint:{distance:8}})),v=(0,_.useCallback)((e,t)=>{e===`success`?re.success(t):re.error(t)},[]),y=(0,_.useCallback)(async()=>{try{t(await qs(`/api/agents/live`))}catch(e){v(`error`,`Failed to load agent configs: ${e.message}`)}},[v]),b=(0,_.useCallback)(async()=>{if(m===`loading`)return;h(`loading`),r([]);let e=Date.now();try{await y();let t=Date.now()-e;t<400&&await new Promise(e=>setTimeout(e,400-t)),h(`success`),re.success(`Agent configs refreshed`),setTimeout(()=>{h(e=>e===`success`?`idle`:e)},1200)}catch{h(`idle`)}},[y,m]);(0,_.useEffect)(()=>{(async()=>{await y(),s(!1)})()},[]);let x=nc(e,n),{added:S,removed:C,skillAdded:w,skillRemoved:T,pluginAdded:E,pluginRemoved:ee}=rc(n),D=(0,_.useCallback)((e,t,i)=>{n.some(n=>n.agent===e&&n.category===t&&n.key===i)||r(n=>[...n,{id:tc(),type:`remove`,category:t,agent:e,key:i}])},[n]),O=(0,_.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e))},[]),te=(0,_.useCallback)(()=>{r([])},[]),k=(0,_.useCallback)(()=>{n.length!==0&&p(!0)},[n]),ne=(0,_.useCallback)(async()=>{p(!1);let e=n.length;l(!0);try{let t=await ti(n,async e=>{if(e.category===`mcp`)if(e.type===`add`&&(e.entry||e.remoteEntry))await qs(`/api/agents/${e.agent}/mcps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e.key,entry:e.entry,remoteEntry:e.remoteEntry})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/mcps/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`MCP "${e.key}" is missing the staged metadata needed to apply this change.`);else if(e.category===`skill`)if(e.type===`add`&&e.sourceAgent)await qs(`/api/agents/${e.agent}/skills`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.key,sourceAgent:e.sourceAgent,source:e.skillEntry?.source})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/skills/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`Skill "${e.key}" is missing the staged metadata needed to apply this change.`);else if(e.category===`plugin`)if(e.type===`add`&&e.sourceAgent)await qs(`/api/agents/${e.agent}/plugins`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.key,sourceAgent:e.sourceAgent})});else if(e.type===`remove`)await qs(`/api/agents/${e.agent}/plugins/${encodeURIComponent(e.key)}`,{method:`DELETE`});else throw Error(`Plugin "${e.key}" is missing the staged metadata needed to apply this change.`)});if(r(t.failed.map(e=>e.change)),await y(),t.failed.length>0)v(`error`,`Applied ${t.applied.length}/${e}. ${t.failed[0]?.error} ${t.failed.length} change${t.failed.length>1?`s remain`:` remains`} staged.`);else{d(!1);let e=Array.from(new Set(t.applied.map(e=>e.agent))).map(e=>Xs[e]??e);re.success(`Applied ${t.applied.length} change${t.applied.length>1?`s`:``}`,{description:e.length>0?`Restart ${e.join(` & `)} to pick up the changes.`:void 0,duration:8e3})}}finally{l(!1)}},[n,y,v]),ie=n.map(e=>{let t=e.category===`skill`?`[Skill] `:`[MCP] `;return e.category===`plugin`?e.type===`add`?`+ [Plugin] ${e.key} → ${Xs[e.agent]}`:`- [Plugin] ${e.key} from ${Xs[e.agent]}`:e.type===`add`?`+ ${t}${e.key} → ${Xs[e.agent]}`:`- ${t}${e.key} from ${Xs[e.agent]}`}),ae=(0,_.useCallback)(e=>{u&&a(e.active.id)},[u]),A=(0,_.useCallback)(e=>{if(a(null),!u)return;let{active:t,over:i}=e;if(!i)return;let o=Js(t.id),s=Ys(i.id);if(!o||!s||o.agent===s.agent)return;let c=x.find(e=>e.agent===o.agent);if(c){if(o.category===`mcp`){let e=c.mcpServers[o.key],t=c.remoteMcpServers[o.key];if(!e&&!t||n.some(e=>e.type===`add`&&e.category===`mcp`&&e.agent===s.agent&&e.key===o.key))return;let i={id:tc(),type:`add`,category:`mcp`,agent:s.agent,key:o.key,entry:e,remoteEntry:t,sourceAgent:o.agent},a=Qr(x,i);if(a){v(`error`,a);return}(async()=>{try{let n=(await qs(`/api/agents/${s.agent}/mcps/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:o.key,entry:e,remoteEntry:t})})).checks.find(e=>e.status===`error`);if(n){v(`error`,n.message);return}r(e=>[...e,i])}catch(e){v(`error`,`Failed to validate MCP "${o.key}" before staging: ${e.message}`)}})()}else if(o.category===`skill`){let e=c.skills.find(e=>e.name===o.key);if(!e||n.some(e=>e.type===`add`&&e.category===`skill`&&e.agent===s.agent&&e.key===o.key))return;let t={id:tc(),type:`add`,category:`skill`,agent:s.agent,key:o.key,skillEntry:e,sourceAgent:o.agent},i=Qr(x,t);if(i){v(`error`,i);return}(async()=>{try{let n=(await qs(`/api/agents/${s.agent}/skills/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:o.key,sourceAgent:o.agent,source:e.source})})).checks.find(e=>e.status===`error`);if(n){v(`error`,n.message);return}r(e=>[...e,t])}catch(e){v(`error`,`Failed to validate skill "${o.key}" before staging: ${e.message}`)}})()}else if(o.category===`plugin`){let e=c.skills.find(e=>e.name===o.key&&e.kind===`plugin`);if(!e||n.some(e=>e.type===`add`&&e.category===`plugin`&&e.agent===s.agent&&e.key===o.key))return;let t={id:tc(),type:`add`,category:`plugin`,agent:s.agent,key:o.key,pluginEntry:e,sourceAgent:o.agent},i=Qr(x,t);if(i){v(`error`,i);return}(async()=>{try{let e=(await qs(`/api/agents/${s.agent}/plugins/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:o.key,sourceAgent:o.agent})})).checks.find(e=>e.status===`error`);if(e){v(`error`,e.message);return}r(e=>[...e,t])}catch(e){v(`error`,`Failed to validate plugin "${o.key}" before staging: ${e.message}`)}})()}}},[u,x,n,v]);(0,_.useEffect)(()=>{u||a(null)},[u]);let j=(()=>{if(!i)return null;let e=Js(i);if(!e)return null;let t=x.find(t=>t.agent===e.agent);if(!t)return null;if(e.category===`mcp`){let n=t.mcpServers[e.key];if(n){let t=n.args&&n.args.length>0?`${n.command} ${n.args.join(` `)}`:n.command;return{label:e.key,sublabel:t}}let r=t.remoteMcpServers[e.key];return r?{label:e.key,sublabel:`[remote] ${r.transport.toUpperCase()} ${r.url}`}:null}else if(e.category===`skill`){let n=t.skills.find(t=>t.name===e.key);return n?{label:n.name,sublabel:n.source??`local`}:null}let n=t.skills.find(t=>t.kind===`plugin`&&t.name===e.key);return n?{label:n.name,sublabel:ei(n)}:null})();if(o)return(0,F.jsx)(`div`,{className:`grid gap-4 w-full`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-3 py-8 text-zinc-500 font-medium`,children:[(0,F.jsx)(Me,{size:20,className:`animate-spin text-zinc-400`}),` Loading agent configs...`]})});let M=x.filter(e=>e.exists).length,oe=x.reduce((e,t)=>e+Object.keys(t.mcpServers).length+Object.keys(t.remoteMcpServers).length+$r(t.skills).skills.length+$r(t.skills).plugins.length,0);return(0,F.jsxs)(`div`,{className:`grid gap-4 w-full`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-stretch gap-4 pb-4 border-b border-zinc-200/60 lg:flex-row lg:items-end lg:justify-between`,children:[(0,F.jsxs)(`div`,{className:`grid gap-1`,children:[(0,F.jsx)(`h3`,{className:`text-xl font-semibold tracking-tight text-zinc-900 m-0`,children:`Local agents`}),(0,F.jsx)(`span`,{className:`text-[13px] font-medium text-zinc-500`,children:`Drag skills, MCPs, and plugins across columns.`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(we,{size:12,className:`text-zinc-400`}),` `,M,` agents`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(Ee,{size:12,className:`text-zinc-400`}),` `,oe,` items`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1 text-[11px] font-medium text-zinc-700 shadow-sm`,children:[(0,F.jsx)(Ie,{size:12,className:`text-zinc-400`}),` `,n.length,` staged`]}),(0,F.jsxs)(`button`,{className:`inline-flex h-8 items-center gap-2 rounded-lg px-3 text-[13px] font-medium transition-all disabled:opacity-50 ${u?`bg-zinc-900 text-white shadow-sm`:`border border-zinc-200 bg-white text-zinc-700 shadow-sm hover:bg-zinc-50`}`,type:`button`,onClick:()=>d(e=>!e),disabled:c,children:[u?(0,F.jsx)(De,{size:14}):(0,F.jsx)(Ne,{size:14}),u?`Done editing`:`Edit items`]}),(0,F.jsx)(`button`,{className:[`inline-flex h-8 items-center gap-2 rounded-lg border px-3 text-[13px] font-medium shadow-sm transition-all duration-200 disabled:opacity-50`,m===`success`?`border-emerald-300 bg-emerald-50 text-emerald-700`:m===`loading`?`border-zinc-300 bg-zinc-100 text-zinc-700`:`border-zinc-200 bg-white text-zinc-700 hover:bg-zinc-50`].join(` `),onClick:()=>void b(),disabled:c||m===`loading`,children:m===`loading`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Me,{size:12,className:`animate-spin`}),` Refreshing`]}):m===`success`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(De,{size:12,className:`animate-[ping_400ms_ease-out_1]`}),` Up to date`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Fe,{size:12}),` Refresh`]})})]})]}),(0,F.jsx)(lc,{changes:n,onUndoChange:O,onDiscardAll:te,onSave:k,saving:c}),(0,F.jsxs)(Ar,{sensors:g,collisionDetection:Zs,onDragStart:ae,onDragEnd:A,children:[(0,F.jsx)(`div`,{className:`grid grid-cols-1 items-start lg:grid-cols-3 w-full`,children:x.map((e,t)=>(0,F.jsx)(`div`,{className:`py-10 lg:py-0 lg:px-10 ${t===0?``:`border-t border-zinc-200 lg:border-t-0 lg:border-l`} ${t===0?`lg:pl-0 lg:pr-10 pt-0`:``} ${t===x.length-1?`lg:pr-0 lg:pl-10 pb-0`:``}`,children:(0,F.jsx)(cc,{config:e,pendingAdded:S.get(e.agent)??new Set,pendingRemoved:C.get(e.agent)??new Set,pendingSkillAdded:w.get(e.agent)??new Set,pendingSkillRemoved:T.get(e.agent)??new Set,pendingPluginAdded:E.get(e.agent)??new Set,pendingPluginRemoved:ee.get(e.agent)??new Set,onStagedRemove:D,editable:u})},e.agent))}),(0,F.jsx)(Xr,{modifiers:[$s],children:j?(0,F.jsx)(ac,{label:j.label,sublabel:j.sublabel}):null})]}),(0,F.jsx)(Ks,{open:f,onOpenChange:p,title:`Apply ${n.length} change${n.length>1?`s`:``}?`,description:`The following changes will be written to agent config files:`,confirmLabel:`Apply changes`,cancelLabel:`Cancel`,variant:`default`,onConfirm:()=>void ne(),children:(0,F.jsx)(`div`,{className:`mt-4 rounded-xl border border-zinc-200 bg-zinc-50 p-4 max-h-64 overflow-y-auto`,children:(0,F.jsx)(`ul`,{className:`space-y-2 font-mono text-xs font-medium text-zinc-700`,children:ie.map((e,t)=>(0,F.jsx)(`li`,{className:e.startsWith(`+`)?`text-zinc-900`:`text-zinc-500 line-through`,children:e},t))})})})]})}async function dc(e,t){let n=await fetch(e,t);if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error??`HTTP ${n.status}`)}return n.json()}function fc({icon:e,label:t,active:n,onClick:r,disabled:i,tooltip:a}){return(0,F.jsxs)(`div`,{className:`relative group`,children:[(0,F.jsxs)(`button`,{className:[`inline-flex h-9 items-center gap-2 rounded-xl px-4 text-sm font-medium transition-all duration-200`,i?`cursor-not-allowed border border-zinc-200 bg-white/60 text-zinc-400`:n?`bg-zinc-900 text-white shadow-sm`:`border border-zinc-200 bg-white text-zinc-700 shadow-sm hover:bg-zinc-50 hover:text-zinc-900`].join(` `),type:`button`,onClick:i?void 0:r,disabled:i,"aria-disabled":i,children:[e,(0,F.jsx)(`span`,{children:t})]}),i&&a?(0,F.jsx)(`span`,{className:`pointer-events-none absolute left-1/2 top-full z-20 mt-2 -translate-x-1/2 whitespace-nowrap rounded-md bg-zinc-900 px-2.5 py-1.5 text-[11px] font-medium text-white opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100`,children:a}):null]})}function pc({tone:e,children:t}){return(0,F.jsxs)(`div`,{className:[`flex items-start gap-3 rounded-xl border px-4 py-3 text-sm transition-all`,e===`success`?`border-zinc-200 bg-zinc-50 text-zinc-800`:`border-red-200 bg-red-50 text-red-800`].join(` `),children:[(0,F.jsx)(`div`,{className:`mt-1`,children:e===`success`?(0,F.jsx)(`div`,{className:`size-2 rounded-full bg-zinc-500`}):(0,F.jsx)(`div`,{className:`size-2 rounded-full bg-red-500`})}),(0,F.jsx)(`div`,{className:`leading-relaxed`,children:t})]})}function mc({title:e,description:t,onClose:n,children:r}){return(0,F.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm lg:p-8 mb-8`,children:[(0,F.jsxs)(`div`,{className:`mb-8 flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-zinc-900`,children:e}),(0,F.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-zinc-500`,children:t})]}),(0,F.jsx)(`button`,{className:`inline-flex size-8 items-center justify-center rounded-full text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700`,type:`button`,onClick:n,children:(0,F.jsx)(Ve,{size:18})})]}),r]})}function hc(){let e=[`claude`,`codex`,`gemini`],[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(`profile`),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`claude`),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),[te,k]=(0,_.useState)([]),[ne,re]=(0,_.useState)(``),[ie,ae]=(0,_.useState)(``),[A,j]=(0,_.useState)(!1),[M,oe]=(0,_.useState)(!1),[se,ce]=(0,_.useState)(null),[N,P]=(0,_.useState)(null);(0,_.useEffect)(()=>{le()},[]),(0,_.useEffect)(()=>{t===`pack`&&fe()},[t,l,d,p]);async function le(){c(!0);try{let e=await dc(`/api/profiles`);i(e.profiles),o(e.activeProfile),f(t=>t||e.activeProfile||e.profiles[0]||``)}catch{}finally{c(!1)}}async function ue(){if(l===`profile`&&!d){C(`Choose a profile to export.`);return}y(!0),C(null),x(null);try{x(`Packed to ${(await dc(`/api/profiles/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({source:l===`profile`?{source:`profile`,name:d}:{source:`agent`,agent:p},name:l===`profile`?d:void 0,agent:l===`agent`?p:void 0,outputPath:h.trim()||void 0})})).archivePath}`)}catch(e){C(e.message)}finally{y(!1)}}async function de(){if(!ne.trim()){P(`Enter a profile archive path.`);return}let e;if(ie.trim())try{let t=JSON.parse(ie);e=Object.fromEntries(Object.entries(t).map(([e,t])=>{if(typeof t!=`string`||t.trim().length===0)throw Error(`Credential "${e}" must be a non-empty string.`);return[e,t]}))}catch(e){P(e instanceof Error?e.message:`Credential map must be valid JSON with string values.`);return}oe(!0),P(null),ce(null);try{let t=await dc(`/api/profiles/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({archivePath:ne.trim(),force:A,credentials:e})}),n=t.installedMcps.length>0?` Installed bundled MCPs: ${t.installedMcps.join(`, `)}.`:``;ce(`Installed profile "${t.profileName}".${n}`),await le()}catch(e){P(e.message)}finally{oe(!1)}}async function fe(){T(!0),ee(null);try{if(l===`profile`){if(!d){O(null);return}O(await dc(`/api/profiles/${encodeURIComponent(d)}`));return}k(await dc(`/api/agents/live`))}catch(e){ee(e.message),l===`profile`&&O(null)}finally{T(!1)}}let pe=l===`profile`?`Pack profile`:`Pack agent config`,me=l===`profile`?`Export a saved Brainctl profile into a portable tarball.`:`Export a live agent config into a portable tarball.`,he=te.find(e=>e.agent===p)??null,ge=(he?.skills??[]).filter(e=>e.kind!==`plugin`),_e=(he?.skills??[]).filter(e=>e.kind===`plugin`),ve=l===`profile`?Object.entries(D?.mcps??{}):[...Object.entries(he?.mcpServers??{}).map(([e,t])=>[e,{label:t.command,kind:`local`}]),...Object.entries(he?.remoteMcpServers??{}).map(([e,t])=>[e,{label:`${t.transport} ${t.url}`,kind:`remote`}])],ye=l===`profile`?Object.entries(D?.skills??{}).map(([e,t])=>({key:e,label:t.description??`Skill`})):ge.map(e=>({key:e.name,label:e.source??`Skill`}));return l===`agent`&&_e.map(e=>({key:e.name,label:e.source?`Plugin · ${e.source}`:`Plugin`})),(0,F.jsx)(`main`,{className:`min-h-screen bg-[#fcfcfc] p-4 lg:p-6 text-zinc-900`,children:(0,F.jsxs)(`div`,{className:`mx-auto grid w-full gap-4`,children:[(0,F.jsxs)(`header`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-7 place-items-center rounded-lg bg-zinc-900 text-white shadow-sm`,children:(0,F.jsx)(`img`,{src:`/favicon-light.svg`,alt:`Brainctl Logo`,className:`size-3.5`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold tracking-tight leading-none`,children:`Brainctl`}),(0,F.jsx)(`p`,{className:`text-[9px] font-medium text-zinc-500 leading-tight`,children:`Transfer Board`})]})]}),(0,F.jsx)(`div`,{className:`hidden lg:flex items-center gap-1.5`,children:[`claude`,`codex`,`gemini`].map(e=>(0,F.jsxs)(`span`,{className:`inline-flex h-8 items-center gap-1.5 rounded-xl flex-none border border-zinc-200 bg-white px-3 text-[10px] font-medium text-zinc-600 shadow-sm`,children:[(0,F.jsx)(`span`,{className:`grid size-3.5 place-items-center overflow-hidden text-zinc-900`,children:(0,F.jsx)(We,{agent:e,className:`size-full object-contain`})}),e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(fc,{icon:(0,F.jsx)(Ee,{size:12}),label:`Pack`,active:t===`pack`,onClick:()=>{n(e=>e===`pack`?null:`pack`),C(null),x(null)},disabled:!0,tooltip:`Coming soon — still grinding on portable packs`}),(0,F.jsx)(fc,{icon:(0,F.jsx)(Ae,{size:16}),label:`Install`,active:t===`install`,onClick:()=>{n(e=>e===`install`?null:`install`),P(null),ce(null)},disabled:!0,tooltip:`Coming soon — portable install flow under construction`})]})]}),(0,F.jsxs)(`div`,{className:`w-full`,children:[t===`pack`?(0,F.jsxs)(mc,{title:pe,description:me,onClose:()=>n(null),children:[(0,F.jsxs)(`div`,{className:`grid gap-10 lg:grid-cols-[1fr_1.2fr]`,children:[(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Pack source`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:l,onChange:e=>u(e.target.value),disabled:v,children:[(0,F.jsx)(`option`,{value:`profile`,children:`Saved profile`}),(0,F.jsx)(`option`,{value:`agent`,children:`Live agent config`})]}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}),l===`profile`?(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Profile to export`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsxs)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:d,onChange:e=>f(e.target.value),disabled:s||r.length===0||v,children:[r.length===0?(0,F.jsx)(`option`,{value:``,children:`No profiles found`}):null,r.map(e=>(0,F.jsxs)(`option`,{value:e,children:[e,e===a?` (active)`:``]},e))]}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}):(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Agent to pack`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`select`,{className:`h-10 w-full appearance-none rounded-xl border border-zinc-200 bg-white px-3 pr-10 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50`,value:p,onChange:e=>m(e.target.value),disabled:v,children:e.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-zinc-400`,children:(0,F.jsx)(Oe,{size:16})})]})]}),(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-sm font-medium text-zinc-700`,children:[`Output path `,(0,F.jsx)(`span`,{className:`text-zinc-400`,children:`(optional)`})]}),(0,F.jsx)(`input`,{className:`h-10 w-full rounded-xl border border-zinc-200 bg-white px-3 text-sm outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400 disabled:opacity-50`,placeholder:`./my-profile.tar.gz`,value:h,onChange:e=>g(e.target.value),disabled:v})]}),(0,F.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,F.jsxs)(`button`,{className:`inline-flex h-10 items-center justify-center gap-2 rounded-xl bg-zinc-900 px-6 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50`,type:`button`,onClick:()=>void ue(),disabled:v||l===`profile`&&r.length===0,children:[v?(0,F.jsx)(Me,{size:16,className:`animate-spin`}):(0,F.jsx)(Ee,{size:16}),`Pack tarball`]}),(0,F.jsx)(`button`,{className:`inline-flex h-10 items-center justify-center rounded-xl border border-zinc-200 bg-white px-4 text-sm font-medium text-zinc-700 transition-colors hover:bg-zinc-50 disabled:opacity-50`,type:`button`,onClick:()=>void le(),disabled:v,children:`Refresh`})]})]}),(0,F.jsxs)(`div`,{className:`rounded-2xl border border-zinc-200 bg-zinc-50/50 p-6`,children:[(0,F.jsx)(`p`,{className:`mb-4 text-xs font-medium text-zinc-500`,children:`Preview`}),(0,F.jsxs)(`div`,{className:`grid gap-4`,children:[w?(0,F.jsx)(`span`,{className:`text-sm text-zinc-500`,children:`Loading...`}):null,E?(0,F.jsx)(`span`,{className:`text-sm text-red-600`,children:E}):null,!w&&!E?(0,F.jsxs)(`div`,{className:`grid gap-4 text-sm text-zinc-900`,children:[(0,F.jsx)(`div`,{className:`grid gap-1 rounded-xl border border-zinc-200 bg-white p-4`,children:l===`profile`&&D?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:D.name}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(D.skills).length,` skills`]}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(D.mcps).length,` MCPs`]})]}):l===`agent`&&he?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-semibold`,children:he.agent}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[Object.keys(he.mcpServers).length+Object.keys(he.remoteMcpServers).length,` MCPs`]}),(0,F.jsxs)(`span`,{className:`text-zinc-600`,children:[ge.length,` skills`]})]}):(0,F.jsx)(`span`,{className:`text-zinc-500`,children:`No preview available`})}),ve.length>0&&(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-zinc-200 bg-white p-4`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium text-zinc-500`,children:`MCPs`}),ve.map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 py-1`,children:[(0,F.jsx)(`span`,{className:`font-medium text-zinc-900`,children:e}),`label`in t?(0,F.jsx)(`span`,{className:`text-xs text-zinc-500 truncate`,children:t.label}):null]},e))]}),ye.length>0&&(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-zinc-200 bg-white p-4`,children:[(0,F.jsx)(`span`,{className:`text-xs font-medium text-zinc-500`,children:`Skills`}),ye.map(e=>(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 py-1`,children:[(0,F.jsx)(`span`,{className:`font-medium text-zinc-900`,children:e.key}),(0,F.jsx)(`span`,{className:`text-xs text-zinc-500 truncate`,children:e.label})]},e.key))]})]}):null]})]})]}),(b||S)&&(0,F.jsxs)(`div`,{className:`mt-8 grid gap-3`,children:[b?(0,F.jsx)(pc,{tone:`success`,children:b}):null,S?(0,F.jsx)(pc,{tone:`error`,children:S}):null]})]}):null,t===`install`?(0,F.jsxs)(mc,{title:`Install profile`,description:`Import a packed archive and unpack bundled MCPs into the local store.`,onClose:()=>n(null),children:[(0,F.jsxs)(`div`,{className:`grid gap-10 lg:grid-cols-[1fr_1.2fr]`,children:[(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Archive path`}),(0,F.jsx)(`input`,{className:`h-10 w-full rounded-xl border border-zinc-200 bg-white px-3 text-sm outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400 disabled:opacity-50`,placeholder:`/path/to/profile.tar.gz`,value:ne,onChange:e=>re(e.target.value),disabled:M})]}),(0,F.jsxs)(`label`,{className:`grid gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Credentials JSON`}),(0,F.jsx)(`textarea`,{className:`min-h-[120px] w-full rounded-xl border border-zinc-200 bg-white p-3 text-sm outline-none transition-colors focus:border-zinc-400 disabled:opacity-50 font-mono text-zinc-700`,placeholder:`{
|
|
64
64
|
"token": "..."
|
|
65
65
|
}`,value:ie,onChange:e=>ae(e.target.value),disabled:M})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`input`,{className:`size-4 rounded border-zinc-300 text-zinc-900 focus:ring-zinc-900`,type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),disabled:M}),(0,F.jsx)(`span`,{className:`text-sm font-medium text-zinc-700`,children:`Force overwrite existing profile`})]}),(0,F.jsx)(`div`,{className:`pt-2`,children:(0,F.jsxs)(`button`,{className:`inline-flex h-10 items-center justify-center gap-2 rounded-xl bg-zinc-900 px-6 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 w-full md:w-auto`,type:`button`,onClick:()=>void de(),disabled:M,children:[M?(0,F.jsx)(Me,{size:16,className:`animate-spin`}):(0,F.jsx)(Ae,{size:16}),`Import Archive`]})})]}),(0,F.jsxs)(`div`,{className:`rounded-2xl border border-zinc-200 bg-zinc-50/50 p-6`,children:[(0,F.jsx)(`p`,{className:`mb-4 text-xs font-medium text-zinc-500`,children:`Execution Path`}),(0,F.jsxs)(`ul`,{className:`grid gap-3 text-sm text-zinc-600`,children:[(0,F.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-zinc-400`}),`Unpacks archive to local store`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-zinc-400`}),`Installs bundled dependencies`]}),(0,F.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-zinc-400`}),`Prepares board for live sync`]})]})]})]}),(se||N)&&(0,F.jsxs)(`div`,{className:`mt-8 grid gap-3`,children:[se?(0,F.jsx)(pc,{tone:`success`,children:se}):null,N?(0,F.jsx)(pc,{tone:`error`,children:N}):null]})]}):null,t===null?(0,F.jsx)(`section`,{className:`w-full pt-4`,children:(0,F.jsx)(uc,{})}):null]})]})})}g.createRoot(document.getElementById(`root`)).render((0,F.jsxs)(_.StrictMode,{children:[(0,F.jsx)(hc,{}),(0,F.jsx)(pe,{position:`top-right`,richColors:!0,closeButton:!0})]}));
|
package/dist/web/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
11
11
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
12
12
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400..700&display=swap" rel="stylesheet" />
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-CC4fdvpS.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-Ow6x3bQk.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|